@stakekit/widget 0.0.286 → 0.0.288
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle/Result-D66k67e4.js +3 -0
- package/dist/bundle/Schema-CnO1Nnkx.js +2 -0
- package/dist/bundle/{cardano-connector-Cg1NVNSz.js → cardano-connector-BdmhtPwK.js} +1 -1
- package/dist/{website/assets/configured-chains-C5lih9lm.js → bundle/configured-chains-BVaAJPl7.js} +1 -1
- package/dist/bundle/{cosmos-connector-meta-B3hXlZyj.js → cosmos-connector-meta-CsjY5xv_.js} +1 -1
- package/dist/bundle/{current-value-stream-sEIwrVMJ.js → current-value-stream-BphKxe9G.js} +1 -1
- package/dist/bundle/{esm-B8ixy8Ti.js → esm-BioWy-zm.js} +1 -1
- package/dist/bundle/index.bundle.css +1 -1
- package/dist/bundle/index.bundle.js +132 -100
- package/dist/bundle/{ledger-connector-ScKbHFK2.js → ledger-connector-BeFXqMQm.js} +2 -2
- package/dist/bundle/{network-DRjEa3NO.js → network-BR2dx0lQ.js} +1 -1
- package/dist/bundle/{polkadot-ledger-transaction-CSI9csNM.js → polkadot-ledger-transaction-CCpzhicj.js} +1 -1
- package/dist/bundle/{safe-connector-BuI_vM2N.js → safe-connector-BW8tBAGV.js} +1 -1
- package/dist/bundle/{solana-connector-BXIkWGi1.js → solana-connector-CEoNnJWx.js} +1 -1
- package/dist/bundle/{stellar-connector-D5G2p6aO.js → stellar-connector-C3GFN35d.js} +1 -1
- package/dist/bundle/{substrate-connector-AJ6EWjQP.js → substrate-connector-B7COXHL7.js} +1 -1
- package/dist/{website/assets/ton-connector-DWz2WVCw.js → bundle/ton-connector-DnPSYtXm.js} +1 -1
- package/dist/bundle/transaction-3CLRKFvX.js +1 -0
- package/dist/{website/assets/transaction-BJ3RmuAw.js → bundle/transaction-BDuN1rLk.js} +2 -2
- package/dist/bundle/{transaction-NX-vBbnh.js → transaction-DU8AaOQz.js} +1 -1
- package/dist/bundle/{tron-connector-nZfhLwx4.js → tron-connector-iA7bb0__.js} +1 -1
- package/dist/bundle/{utils-CfBIlQsz.js → utils-llPzGe7v.js} +1 -1
- package/dist/bundle/wagmi-connect-result-DOu6hDDM.js +11 -0
- package/dist/bundle/{wallet-errors-Bvwwydi9.js → wallet-errors-MrbcJr3I.js} +1 -1
- package/dist/bundle/{wallet-manager-C-MB05Qs.js → wallet-manager-D2AeCPRs.js} +2 -2
- package/dist/package/{Result-Cem4lYBf.js → Result-BA6lrqKV.js} +117 -49
- package/dist/package/{Schema-DFoi51wt.js → Schema-CUut1r-H.js} +1135 -1310
- package/dist/package/{cardano-connector-B9UToMFP.js → cardano-connector-ApyBIRYL.js} +3 -3
- package/dist/package/{configured-chains-BfQ8ESmR.js → configured-chains-CeRB7Tdy.js} +1 -1
- package/dist/package/{cosmos-connector-meta-UMFrkViG.js → cosmos-connector-meta-NNACISY5.js} +1 -1
- package/dist/package/{current-value-stream-BPaLLDf4.js → current-value-stream-Cs2IFPhP.js} +1 -1
- package/dist/package/{esm-89IrCtWy.js → esm-3BtHXmV9.js} +1 -1
- package/dist/package/index.package.css +21 -0
- package/dist/package/index.package.js +8469 -3828
- package/dist/package/{ledger-connector-B8D8xJOD.js → ledger-connector-ebEnv7IA.js} +9 -9
- package/dist/package/{network-DiYap-9L.js → network-Df21Fcdz.js} +1 -1
- package/dist/package/{polkadot-ledger-transaction-Bi14PyTF.js → polkadot-ledger-transaction-Cq_ImU8s.js} +1 -1
- package/dist/package/{safe-connector-lVCS_bS5.js → safe-connector-CMgopygU.js} +4 -4
- package/dist/package/{solana-connector-P-TqgNNC.js → solana-connector-B2Rf5Tyj.js} +3 -3
- package/dist/package/{stellar-connector-BMB2Cql4.js → stellar-connector-DdzqZgoG.js} +4 -4
- package/dist/package/{substrate-connector-a7SNpKjf.js → substrate-connector-DO7OAvZ9.js} +2 -2
- package/dist/package/{ton-connector-CMzOI2bi.js → ton-connector-CUtYVysK.js} +5 -5
- package/dist/package/{transaction-CmOScFm6.js → transaction-BjGgdyu0.js} +5 -5
- package/dist/package/{transaction-Do9wZHM8.js → transaction-MMiSjtGI.js} +1 -1
- package/dist/package/{transaction-C1e6h8J1.js → transaction-fIZimEky.js} +1 -1
- package/dist/package/{tron-connector-PLpMhB65.js → tron-connector-DT1NdAaP.js} +2 -2
- package/dist/package/{wagmi-connect-result-BJ91_jis.js → wagmi-connect-result-Bh6qH5iI.js} +593 -462
- package/dist/package/{wallet-errors-B4cGcGNy.js → wallet-errors-BMdJQ_kv.js} +1 -1
- package/dist/package/{wallet-manager-BsDss9DQ.js → wallet-manager-BbL7EBi6.js} +5 -5
- package/dist/types/domain/network/network.d.ts +2 -2
- package/dist/types/generated/api/legacy-schema.d.ts +3503 -1952
- package/dist/types/generated/api/yield-schema.d.ts +1492 -1113
- package/dist/types/public-api/types.d.ts +2 -2
- package/dist/website/assets/Result-D66k67e4.js +3 -0
- package/dist/website/assets/Schema-CnO1Nnkx.js +2 -0
- package/dist/website/assets/{cardano-connector-JluaLQJr.js → cardano-connector-DkgQsbib.js} +1 -1
- package/dist/{bundle/configured-chains-C5lih9lm.js → website/assets/configured-chains-BVaAJPl7.js} +1 -1
- package/dist/website/assets/{cosmos-connector-meta-B3hXlZyj.js → cosmos-connector-meta-CsjY5xv_.js} +1 -1
- package/dist/website/assets/{current-value-stream-sEIwrVMJ.js → current-value-stream-BphKxe9G.js} +1 -1
- package/dist/website/assets/{esm-DmRWC3up.js → esm-DJUTv1_r.js} +1 -1
- package/dist/website/assets/{index-CYwddl65.css → index-B_e-5cjt.css} +1 -1
- package/dist/website/assets/index-Ifmhd5nI.js +592 -0
- package/dist/website/assets/{ledger-connector-zHWvy_21.js → ledger-connector-CMFH1Z0M.js} +3 -3
- package/dist/website/assets/{network-DRjEa3NO.js → network-BR2dx0lQ.js} +1 -1
- package/dist/website/assets/{polkadot-ledger-transaction-CSI9csNM.js → polkadot-ledger-transaction-CCpzhicj.js} +1 -1
- package/dist/website/assets/{safe-connector-B_IWbdsx.js → safe-connector-BDc3OqKV.js} +1 -1
- package/dist/website/assets/{solana-connector-DUrUEFXI.js → solana-connector-Ij-Dm1HM.js} +1 -1
- package/dist/website/assets/{stellar-connector-D5G2p6aO.js → stellar-connector-C3GFN35d.js} +1 -1
- package/dist/website/assets/{substrate-connector-DxgYUQY4.js → substrate-connector-B-LTNtpz.js} +1 -1
- package/dist/{bundle/ton-connector-DWz2WVCw.js → website/assets/ton-connector-DnPSYtXm.js} +1 -1
- package/dist/{bundle/transaction-BJ3RmuAw.js → website/assets/transaction-BDuN1rLk.js} +2 -2
- package/dist/website/assets/{transaction-BIBBEBi6.js → transaction-Cth5mVGJ.js} +1 -1
- package/dist/website/assets/transaction-peV0IJTV.js +1 -0
- package/dist/website/assets/{tron-connector-C3nKPxdx.js → tron-connector-D_NeRPfc.js} +1 -1
- package/dist/website/assets/{utils-DVCp0qSW.js → utils-DOZR2zEE.js} +1 -1
- package/dist/website/assets/wagmi-connect-result-DOu6hDDM.js +11 -0
- package/dist/website/assets/{wallet-errors-Bvwwydi9.js → wallet-errors-MrbcJr3I.js} +1 -1
- package/dist/website/assets/{wallet-manager-9-XcN6SR.js → wallet-manager-DGQAWJIz.js} +3 -3
- package/dist/website/index.html +13 -13
- package/package.json +12 -11
- package/dist/bundle/Result-3MQjLy1V.js +0 -3
- package/dist/bundle/Schema-DgreXIef.js +0 -2
- package/dist/bundle/transaction-BnkP6nIP.js +0 -1
- package/dist/bundle/wagmi-connect-result-CqXaJhOa.js +0 -11
- package/dist/website/assets/Result-3MQjLy1V.js +0 -3
- package/dist/website/assets/Schema-DgreXIef.js +0 -2
- package/dist/website/assets/index-DtK-tGS5.js +0 -560
- package/dist/website/assets/transaction-Sqg4_vo7.js +0 -1
- package/dist/website/assets/wagmi-connect-result-CqXaJhOa.js +0 -11
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as e,s as t,t as n}from"./rolldown-runtime-BcKkbAw3.js";import{n as r,t as i}from"./dist-C9i0DjyB.js";import{j as a,n as o,t as s}from"./wagmi-connect-result-
|
|
1
|
+
import{r as e,s as t,t as n}from"./rolldown-runtime-BcKkbAw3.js";import{n as r,t as i}from"./dist-C9i0DjyB.js";import{j as a,n as o,t as s}from"./wagmi-connect-result-DOu6hDDM.js";import{n as c,t as l}from"./dist-D6L6gF64.js";import{a as u,n as d,r as f,t as p}from"./assets-CaBpoNKF.js";import{n as m,r as h,t as g}from"./dist-KkMRwAp9.js";import{t as _}from"./eventemitter3-DqfHna5i.js";import{n as v,t as y}from"./Transport-DCf5RHQn.js";import{o as b}from"./configured-chains-BVaAJPl7.js";import{t as x}from"./tron-connector-meta-8UgQa4LI.js";import{a as S,c as ee,i as te,l as C,n as ne,o as re,s as w,t as ie}from"./sha256-BQ-kmMHy.js";import{t as ae}from"./axios-BywHQoip.js";import{n as T,t as oe}from"./bignumber-BKhmepVw.js";h();var se={},ce={},le=(e,t)=>{ce[e]=t},E=e=>{class t extends Error{cause;constructor(n,r,i){if(super(n||e,i),Object.setPrototypeOf(this,t.prototype),this.name=e,r)for(let e in r)this[e]=r[e];if(i&&ue(i)&&`cause`in i&&!this.cause){let e=i.cause;this.cause=e,`stack`in e&&(this.stack=this.stack+`
|
|
2
2
|
CAUSE: `+e.stack)}}}return se[e]=t,t};function ue(e){return typeof e==`object`}E(`AccountNameRequired`),E(`AccountNotSupported`),E(`AccountAwaitingSendPendingOperations`),E(`AmountRequired`),E(`BluetoothRequired`),E(`BtcUnmatchedApp`),E(`CantOpenDevice`),E(`CashAddrNotSupported`),E(`ClaimRewardsFeesWarning`),E(`CurrencyNotSupported`),E(`DeviceAppVerifyNotSupported`),E(`DeviceGenuineSocketEarlyClose`),E(`DeviceNotGenuine`),E(`DeviceOnDashboardExpected`),E(`DeviceOnDashboardUnexpected`),E(`DeviceInOSUExpected`),E(`DeviceHalted`),E(`DeviceNameInvalid`),E(`DeviceSocketFail`),E(`DeviceSocketNoBulkStatus`),E(`DeviceSocketNoBulkStatus`),E(`UnresponsiveDeviceError`);var de=E(`DisconnectedDevice`),fe=E(`DisconnectedDeviceDuringOperation`);E(`DeviceExtractOnboardingStateError`),E(`DeviceOnboardingStatePollingError`),E(`EnpointConfig`),E(`EthAppPleaseEnableContractData`),E(`SolAppPleaseEnableContractData`),E(`CeloAppPleaseEnableContractData`),E(`FeeEstimationFailed`),E(`FirmwareNotRecognized`),E(`HardResetFail`),E(`InvalidXRPTag`),E(`InvalidAddress`),E(`InvalidTransactionError`),E(`InvalidNonce`),E(`InvalidAddressBecauseDestinationIsAlsoSource`),E(`LatestMCUInstalledError`),E(`LatestFirmwareVersionRequired`),E(`UnsupportedFeatureError`),E(`NanoSNotSupported`),E(`UnknownMCU`),E(`LedgerAPIError`),E(`LedgerAPIErrorWithMessage`),E(`LedgerAPINotAvailable`),E(`ManagerAppAlreadyInstalled`),E(`ManagerAppRelyOnBTC`),E(`ManagerAppDepInstallRequired`),E(`ManagerAppDepUninstallRequired`),E(`ManagerDeviceLocked`),E(`ManagerFirmwareNotEnoughSpace`),E(`ManagerNotEnoughSpace`),E(`ManagerUninstallBTCDep`),E(`NetworkDown`),E(`NetworkError`),E(`NoAddressesFound`),E(`NotEnoughBalance`),E(`NotEnoughBalanceFees`),E(`NotEnoughBalanceSwap`),E(`NotEnoughBalanceToDelegate`),E(`UnstakeNotEnoughStakedBalanceLeft`),E(`RestakeNotEnoughStakedBalanceLeft`),E(`NotEnoughToRestake`),E(`NotEnoughToUnstake`),E(`NotEnoughBalanceInParentAccount`),E(`NotEnoughSpendableBalance`),E(`NotEnoughBalanceBecauseDestinationNotCreated`),E(`NotEnoughToStake`),E(`NoAccessToCamera`),E(`NotEnoughGas`),E(`NotEnoughGasSwap`),E(`TronEmptyAccount`),E(`MaybeKeepTronAccountAlive`),E(`NotSupportedLegacyAddress`),E(`GasLessThanEstimate`),E(`PriorityFeeTooLow`),E(`PriorityFeeTooHigh`),E(`PriorityFeeHigherThanMaxFee`),E(`MaxFeeTooLow`),E(`PasswordsDontMatch`),E(`PasswordIncorrect`),E(`RecommendSubAccountsToEmpty`),E(`RecommendUndelegation`),E(`TimeoutTagged`),E(`UnexpectedBootloader`),E(`MCUNotGenuineToDashboard`),E(`RecipientRequired`),E(`UnavailableTezosOriginatedAccountReceive`),E(`UnavailableTezosOriginatedAccountSend`),E(`UpdateFetchFileFail`),E(`UpdateIncorrectHash`),E(`UpdateIncorrectSig`),E(`UpdateYourApp`),E(`UserRefusedDeviceNameChange`),E(`UserRefusedAddress`),E(`UserRefusedFirmwareUpdate`),E(`UserRefusedAllowManager`),E(`UserRefusedOnDevice`),E(`PinNotSet`),E(`ExpertModeRequired`);var pe=E(`TransportOpenUserCancelled`);E(`TransportInterfaceNotAvailable`),E(`TransportRaceCondition`),E(`TransportWebUSBGestureRequired`),E(`TransactionHasBeenValidatedError`),E(`TransportExchangeTimeoutError`),E(`DeviceShouldStayInApp`),E(`WebsocketConnectionError`),E(`WebsocketConnectionFailed`),E(`WrongDeviceForAccount`),E(`WrongDeviceForAccountPayout`),E(`MissingSwapPayloadParamaters`),E(`WrongDeviceForAccountRefund`),E(`WrongAppForCurrency`),E(`ETHAddressNonEIP`),E(`CantScanQRCode`),E(`FeeNotLoaded`),E(`FeeNotLoadedSwap`),E(`FeeRequired`),E(`FeeTooHigh`),E(`ValAddressRequired`),E(`RedelegateDstValAddressRequired`),E(`PendingOperation`),E(`SyncError`),E(`PairingFailed`),E(`PeerRemovedPairing`),E(`GenuineCheckFailed`),E(`LedgerAPI4xx`),E(`LedgerAPI5xx`),E(`FirmwareOrAppUpdateRequired`),E(`ReplacementTransactionUnderpriced`),E(`OpReturnSizeLimit`),E(`DustLimit`),E(`ConcordiumInsufficientFunds`),E(`ConcordiumMemoTooLong`),E(`ConcordiumPairingExpiredError`),E(`ConcordiumSessionExpiredError`),E(`ConcordiumTrustedMetadataServiceError`),E(`ConcordiumAddressVerificationFailedError`),E(`ConcordiumInvalidMaxFeeError`),E(`LanguageNotFound`),E(`NoDBPathGiven`),E(`DBWrongPassword`),E(`DBNotReset`),E(`SequenceNumberError`),E(`DisabledTransactionBroadcastError`),E(`InvalidParameterError`);var me;(function(e){e.Unknown=`Unknown`,e.LocationServicesDisabled=`LocationServicesDisabled`,e.LocationServicesUnauthorized=`LocationServicesUnauthorized`,e.BluetoothScanStartFailed=`BluetoothScanStartFailed`})(me||={});var he=class extends Error{id;constructor(e,t){let n=`TransportError`;super(e||n),this.name=n,this.message=e,this.stack=Error(e).stack,this.id=t}};le(`TransportError`,e=>new he(e.message,e.id));var ge={ACCESS_CONDITION_NOT_FULFILLED:38916,ALGORITHM_NOT_SUPPORTED:38020,CLA_NOT_SUPPORTED:28160,CLA_NOT_SUPPORTED_BOOTLOADER:28161,CODE_BLOCKED:38976,CODE_NOT_INITIALIZED:38914,COMMAND_INCOMPATIBLE_FILE_STRUCTURE:27009,CONDITIONS_OF_USE_NOT_SATISFIED:27013,CONTRADICTION_INVALIDATION:38928,CONTRADICTION_SECRET_CODE_STATUS:38920,DEVICE_IN_RECOVERY_MODE:26159,CUSTOM_IMAGE_EMPTY:26158,FILE_ALREADY_EXISTS:27273,FILE_NOT_FOUND:37892,GP_AUTH_FAILED:25344,HALTED:28586,INCONSISTENT_FILE:37896,INCORRECT_DATA:27264,INCORRECT_LENGTH:26368,INCORRECT_P1_P2:27392,INS_NOT_SUPPORTED:27904,DEVICE_NOT_ONBOARDED:27911,DEVICE_NOT_ONBOARDED_2:26129,INVALID_KCV:38021,INVALID_OFFSET:37890,LICENSING:28482,LOCKED_DEVICE:21781,MAX_VALUE_REACHED:38992,MEMORY_PROBLEM:37440,MISSING_CRITICAL_PARAMETER:26624,NO_EF_SELECTED:37888,NOT_ENOUGH_MEMORY_SPACE:27268,OK:36864,PIN_REMAINING_ATTEMPTS:25536,REFERENCED_DATA_NOT_FOUND:27272,SECURITY_STATUS_NOT_SATISFIED:27010,TECHNICAL_PROBLEM:28416,UNKNOWN_APDU:27906,USER_REFUSED_ON_DEVICE:21761,NOT_ENOUGH_SPACE:20738,APP_NOT_FOUND_OR_INVALID_CONTEXT:20771,INVALID_APP_NAME_LENGTH:26378,GEN_AES_KEY_FAILED:21529,INTERNAL_CRYPTO_OPERATION_FAILED:21530,INTERNAL_COMPUTE_AES_CMAC_FAILED:21531,ENCRYPT_APP_STORAGE_FAILED:21532,INVALID_BACKUP_STATE:26178,PIN_NOT_SET:21762,INVALID_BACKUP_LENGTH:26419,INVALID_RESTORE_STATE:26179,INVALID_CHUNK_LENGTH:26420,INVALID_BACKUP_HEADER:26698,SW_BAD_STATE:45063};function _e(e){switch(e){case 26368:return`Incorrect length`;case 26624:return`Missing critical parameter`;case 27010:return`Security not satisfied (dongle locked or have invalid access rights)`;case 27013:return`Condition of use not satisfied (denied by the user?)`;case 27264:return`Invalid data received`;case 27392:return`Invalid parameter received`;case 21781:return`Locked device`;case 45063:return`Unexpected state on the device`}if(28416<=e&&e<=28671)return`Internal error, please report`}var ve=class e extends Error{statusCode;statusText;constructor(t,{canBeMappedToChildError:n=!0}={}){let r=Object.keys(ge).find(e=>ge[e]===t)||`UNKNOWN_ERROR`,i=`Ledger device: ${_e(t)||r} (0x${t.toString(16)})`;if(super(i),this.name=`TransportStatusError`,this.statusCode=t,this.statusText=r,Object.setPrototypeOf(this,e.prototype),n&&t===ge.LOCKED_DEVICE)return new ye(i)}},ye=class e extends ve{constructor(t){super(ge.LOCKED_DEVICE,{canBeMappedToChildError:!1}),t&&(this.message=t),this.name=`LockedDeviceError`,Object.setPrototypeOf(this,e.prototype)}};le(`TransportStatusError`,e=>new ve(e.statusCode));var be=class extends ne{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,C(e);let n=re(t);if(this.iHash=e.create(),typeof this.iHash.update!=`function`)throw Error(`Expected instance of class which extends utils.Hash`);this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let r=this.blockLen,i=new Uint8Array(r);i.set(n.length>r?e.create().update(n).digest():n);for(let e=0;e<i.length;e++)i[e]^=54;this.iHash.update(i),this.oHash=e.create();for(let e=0;e<i.length;e++)i[e]^=106;this.oHash.update(i),i.fill(0)}update(e){return ee(this),this.iHash.update(e),this}digestInto(e){ee(this),w(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||=Object.create(Object.getPrototypeOf(this),{});let{oHash:t,iHash:n,finished:r,destroyed:i,blockLen:a,outputLen:o}=this;return e=e,e.finished=r,e.destroyed=i,e.blockLen=a,e.outputLen=o,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},xe=(e,t,n)=>new be(e,t).update(n).digest();xe.create=(e,t)=>new be(e,t);var Se=e({abytes:()=>De,bitGet:()=>O,bitLen:()=>Ue,bitMask:()=>Ge,bitSet:()=>We,bytesToHex:()=>ke,bytesToNumberBE:()=>Fe,bytesToNumberLE:()=>Ie,concatBytes:()=>Ve,createHmacDrbg:()=>Je,ensureBytes:()=>Be,equalBytes:()=>D,hexToBytes:()=>Pe,hexToNumber:()=>je,isBytes:()=>Ee,numberToBytesBE:()=>Le,numberToBytesLE:()=>Re,numberToHexUnpadded:()=>Ae,numberToVarBytesBE:()=>ze,utf8ToBytes:()=>He,validateObject:()=>Ye}),Ce=BigInt(0),we=BigInt(1),Te=BigInt(2);function Ee(e){return e instanceof Uint8Array||typeof e==`object`&&!!e&&e.constructor.name===`Uint8Array`}function De(e){if(!Ee(e))throw Error(`Uint8Array expected`)}var Oe=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,`0`));function ke(e){De(e);let t=``;for(let n=0;n<e.length;n++)t+=Oe[e[n]];return t}function Ae(e){let t=e.toString(16);return t.length&1?`0${t}`:t}function je(e){if(typeof e!=`string`)throw Error(`hex string expected, got `+typeof e);return BigInt(e===``?`0`:`0x${e}`)}var Me={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function Ne(e){if(e>=Me._0&&e<=Me._9)return e-Me._0;if(e>=Me._A&&e<=Me._F)return e-(Me._A-10);if(e>=Me._a&&e<=Me._f)return e-(Me._a-10)}function Pe(e){if(typeof e!=`string`)throw Error(`hex string expected, got `+typeof e);let t=e.length,n=t/2;if(t%2)throw Error(`padded hex string expected, got unpadded hex of length `+t);let r=new Uint8Array(n);for(let t=0,i=0;t<n;t++,i+=2){let n=Ne(e.charCodeAt(i)),a=Ne(e.charCodeAt(i+1));if(n===void 0||a===void 0){let t=e[i]+e[i+1];throw Error(`hex string expected, got non-hex character "`+t+`" at index `+i)}r[t]=n*16+a}return r}function Fe(e){return je(ke(e))}function Ie(e){return De(e),je(ke(Uint8Array.from(e).reverse()))}function Le(e,t){return Pe(e.toString(16).padStart(t*2,`0`))}function Re(e,t){return Le(e,t).reverse()}function ze(e){return Pe(Ae(e))}function Be(e,t,n){let r;if(typeof t==`string`)try{r=Pe(t)}catch(n){throw Error(`${e} must be valid hex string, got "${t}". Cause: ${n}`)}else if(Ee(t))r=Uint8Array.from(t);else throw Error(`${e} must be hex string or Uint8Array`);let i=r.length;if(typeof n==`number`&&i!==n)throw Error(`${e} expected ${n} bytes, got ${i}`);return r}function Ve(...e){let t=0;for(let n=0;n<e.length;n++){let r=e[n];De(r),t+=r.length}let n=new Uint8Array(t);for(let t=0,r=0;t<e.length;t++){let i=e[t];n.set(i,r),r+=i.length}return n}function D(e,t){if(e.length!==t.length)return!1;let n=0;for(let r=0;r<e.length;r++)n|=e[r]^t[r];return n===0}function He(e){if(typeof e!=`string`)throw Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function Ue(e){let t;for(t=0;e>Ce;e>>=we,t+=1);return t}function O(e,t){return e>>BigInt(t)&we}function We(e,t,n){return e|(n?we:Ce)<<BigInt(t)}var Ge=e=>(Te<<BigInt(e-1))-we,Ke=e=>new Uint8Array(e),qe=e=>Uint8Array.from(e);function Je(e,t,n){if(typeof e!=`number`||e<2)throw Error(`hashLen must be a number`);if(typeof t!=`number`||t<2)throw Error(`qByteLen must be a number`);if(typeof n!=`function`)throw Error(`hmacFn must be a function`);let r=Ke(e),i=Ke(e),a=0,o=()=>{r.fill(1),i.fill(0),a=0},s=(...e)=>n(i,r,...e),c=(e=Ke())=>{i=s(qe([0]),e),r=s(),e.length!==0&&(i=s(qe([1]),e),r=s())},l=()=>{if(a++>=1e3)throw Error(`drbg: tried 1000 values`);let e=0,n=[];for(;e<t;){r=s();let t=r.slice();n.push(t),e+=r.length}return Ve(...n)};return(e,t)=>{o(),c(e);let n;for(;!(n=t(l()));)c();return o(),n}}var k={bigint:e=>typeof e==`bigint`,function:e=>typeof e==`function`,boolean:e=>typeof e==`boolean`,string:e=>typeof e==`string`,stringOrUint8Array:e=>typeof e==`string`||Ee(e),isSafeInteger:e=>Number.isSafeInteger(e),array:e=>Array.isArray(e),field:(e,t)=>t.Fp.isValid(e),hash:e=>typeof e==`function`&&Number.isSafeInteger(e.outputLen)};function Ye(e,t,n={}){let r=(t,n,r)=>{let i=k[n];if(typeof i!=`function`)throw Error(`Invalid validator "${n}", expected function`);let a=e[t];if(!(r&&a===void 0)&&!i(a,e))throw Error(`Invalid param ${String(t)}=${a} (${typeof a}), expected ${n}`)};for(let[e,n]of Object.entries(t))r(e,n,!1);for(let[e,t]of Object.entries(n))r(e,t,!0);return e}var Xe=BigInt(0),Ze=BigInt(1),Qe=BigInt(2),$e=BigInt(3),et=BigInt(4),tt=BigInt(5),nt=BigInt(8),rt=BigInt(16);function it(e,t){let n=e%t;return n>=Xe?n:t+n}function at(e,t,n){if(n<=Xe||t<Xe)throw Error(`Expected power/modulo > 0`);if(n===Ze)return Xe;let r=Ze;for(;t>Xe;)t&Ze&&(r=r*e%n),e=e*e%n,t>>=Ze;return r}function ot(e,t,n){let r=e;for(;t-->Xe;)r*=r,r%=n;return r}function st(e,t){if(e===Xe||t<=Xe)throw Error(`invert: expected positive integers, got n=${e} mod=${t}`);let n=it(e,t),r=t,i=Xe,a=Ze,o=Ze,s=Xe;for(;n!==Xe;){let e=r/n,t=r%n,c=i-o*e,l=a-s*e;r=n,n=t,i=o,a=s,o=c,s=l}if(r!==Ze)throw Error(`invert: does not exist`);return it(i,t)}function ct(e){let t=(e-Ze)/Qe,n,r,i;for(n=e-Ze,r=0;n%Qe===Xe;n/=Qe,r++);for(i=Qe;i<e&&at(i,t,e)!==e-Ze;i++);if(r===1){let t=(e+Ze)/et;return function(e,n){let r=e.pow(n,t);if(!e.eql(e.sqr(r),n))throw Error(`Cannot find square root`);return r}}let a=(n+Ze)/Qe;return function(e,o){if(e.pow(o,t)===e.neg(e.ONE))throw Error(`Cannot find square root`);let s=r,c=e.pow(e.mul(e.ONE,i),n),l=e.pow(o,a),u=e.pow(o,n);for(;!e.eql(u,e.ONE);){if(e.eql(u,e.ZERO))return e.ZERO;let t=1;for(let n=e.sqr(u);t<s&&!e.eql(n,e.ONE);t++)n=e.sqr(n);let n=e.pow(c,Ze<<BigInt(s-t-1));c=e.sqr(n),l=e.mul(l,n),u=e.mul(u,c),s=t}return l}}function lt(e){if(e%et===$e){let t=(e+Ze)/et;return function(e,n){let r=e.pow(n,t);if(!e.eql(e.sqr(r),n))throw Error(`Cannot find square root`);return r}}if(e%nt===tt){let t=(e-tt)/nt;return function(e,n){let r=e.mul(n,Qe),i=e.pow(r,t),a=e.mul(n,i),o=e.mul(e.mul(a,Qe),i),s=e.mul(a,e.sub(o,e.ONE));if(!e.eql(e.sqr(s),n))throw Error(`Cannot find square root`);return s}}return e%rt,ct(e)}var ut=[`create`,`isValid`,`is0`,`neg`,`inv`,`sqrt`,`sqr`,`eql`,`add`,`sub`,`mul`,`pow`,`div`,`addN`,`subN`,`mulN`,`sqrN`];function dt(e){return Ye(e,ut.reduce((e,t)=>(e[t]=`function`,e),{ORDER:`bigint`,MASK:`bigint`,BYTES:`isSafeInteger`,BITS:`isSafeInteger`}))}function ft(e,t,n){if(n<Xe)throw Error(`Expected power > 0`);if(n===Xe)return e.ONE;if(n===Ze)return t;let r=e.ONE,i=t;for(;n>Xe;)n&Ze&&(r=e.mul(r,i)),i=e.sqr(i),n>>=Ze;return r}function pt(e,t){let n=Array(t.length),r=t.reduce((t,r,i)=>e.is0(r)?t:(n[i]=t,e.mul(t,r)),e.ONE),i=e.inv(r);return t.reduceRight((t,r,i)=>e.is0(r)?t:(n[i]=e.mul(t,n[i]),e.mul(t,r)),i),n}function mt(e,t){let n=t===void 0?e.toString(2).length:t;return{nBitLength:n,nByteLength:Math.ceil(n/8)}}function ht(e,t,n=!1,r={}){if(e<=Xe)throw Error(`Expected Field ORDER > 0, got ${e}`);let{nBitLength:i,nByteLength:a}=mt(e,t);if(a>2048)throw Error(`Field lengths over 2048 bytes are not supported`);let o=lt(e),s=Object.freeze({ORDER:e,BITS:i,BYTES:a,MASK:Ge(i),ZERO:Xe,ONE:Ze,create:t=>it(t,e),isValid:t=>{if(typeof t!=`bigint`)throw Error(`Invalid field element: expected bigint, got ${typeof t}`);return Xe<=t&&t<e},is0:e=>e===Xe,isOdd:e=>(e&Ze)===Ze,neg:t=>it(-t,e),eql:(e,t)=>e===t,sqr:t=>it(t*t,e),add:(t,n)=>it(t+n,e),sub:(t,n)=>it(t-n,e),mul:(t,n)=>it(t*n,e),pow:(e,t)=>ft(s,e,t),div:(t,n)=>it(t*st(n,e),e),sqrN:e=>e*e,addN:(e,t)=>e+t,subN:(e,t)=>e-t,mulN:(e,t)=>e*t,inv:t=>st(t,e),sqrt:r.sqrt||(e=>o(s,e)),invertBatch:e=>pt(s,e),cmov:(e,t,n)=>n?t:e,toBytes:e=>n?Re(e,a):Le(e,a),fromBytes:e=>{if(e.length!==a)throw Error(`Fp.fromBytes: expected ${a}, got ${e.length}`);return n?Ie(e):Fe(e)}});return Object.freeze(s)}function gt(e){if(typeof e!=`bigint`)throw Error(`field order must be bigint`);let t=e.toString(2).length;return Math.ceil(t/8)}function A(e){let t=gt(e);return t+Math.ceil(t/2)}function j(e,t,n=!1){let r=e.length,i=gt(t),a=A(t);if(r<16||r<a||r>1024)throw Error(`expected ${a}-1024 bytes of input, got ${r}`);let o=it(n?Fe(e):Ie(e),t-Ze)+Ze;return n?Re(o,i):Le(o,i)}var _t=BigInt(0),vt=BigInt(1);function yt(e,t){let n=(e,t)=>{let n=t.negate();return e?n:t},r=e=>({windows:Math.ceil(t/e)+1,windowSize:2**(e-1)});return{constTimeNegate:n,unsafeLadder(t,n){let r=e.ZERO,i=t;for(;n>_t;)n&vt&&(r=r.add(i)),i=i.double(),n>>=vt;return r},precomputeWindow(e,t){let{windows:n,windowSize:i}=r(t),a=[],o=e,s=o;for(let e=0;e<n;e++){s=o,a.push(s);for(let e=1;e<i;e++)s=s.add(o),a.push(s);o=s.double()}return a},wNAF(t,i,a){let{windows:o,windowSize:s}=r(t),c=e.ZERO,l=e.BASE,u=BigInt(2**t-1),d=2**t,f=BigInt(t);for(let e=0;e<o;e++){let t=e*s,r=Number(a&u);a>>=f,r>s&&(r-=d,a+=vt);let o=t,p=t+Math.abs(r)-1,m=e%2!=0,h=r<0;r===0?l=l.add(n(m,i[o])):c=c.add(n(h,i[p]))}return{p:c,f:l}},wNAFCached(e,t,n,r){let i=e._WINDOW_SIZE||1,a=t.get(e);return a||(a=this.precomputeWindow(e,i),i!==1&&t.set(e,r(a))),this.wNAF(i,a,n)}}}function M(e){return dt(e.Fp),Ye(e,{n:`bigint`,h:`bigint`,Gx:`field`,Gy:`field`},{nBitLength:`isSafeInteger`,nByteLength:`isSafeInteger`}),Object.freeze({...mt(e.n,e.nBitLength),...e,p:e.Fp.ORDER})}function N(e){let t=M(e);Ye(t,{a:`field`,b:`field`},{allowedPrivateKeyLengths:`array`,wrapPrivateKey:`boolean`,isTorsionFree:`function`,clearCofactor:`function`,allowInfinityPoint:`boolean`,fromBytes:`function`,toBytes:`function`});let{endo:n,Fp:r,a:i}=t;if(n){if(!r.eql(i,r.ZERO))throw Error(`Endomorphism can only be defined for Koblitz curves that have a=0`);if(typeof n!=`object`||typeof n.beta!=`bigint`||typeof n.splitScalar!=`function`)throw Error(`Expected endomorphism with beta: bigint and splitScalar: function`)}return Object.freeze({...t})}var{bytesToNumberBE:bt,hexToBytes:xt}=Se,St={Err:class extends Error{constructor(e=``){super(e)}},_parseInt(e){let{Err:t}=St;if(e.length<2||e[0]!==2)throw new t(`Invalid signature integer tag`);let n=e[1],r=e.subarray(2,n+2);if(!n||r.length!==n)throw new t(`Invalid signature integer: wrong length`);if(r[0]&128)throw new t(`Invalid signature integer: negative`);if(r[0]===0&&!(r[1]&128))throw new t(`Invalid signature integer: unnecessary leading zero`);return{d:bt(r),l:e.subarray(n+2)}},toSig(e){let{Err:t}=St,n=typeof e==`string`?xt(e):e;De(n);let r=n.length;if(r<2||n[0]!=48)throw new t(`Invalid signature tag`);if(n[1]!==r-2)throw new t(`Invalid signature: incorrect length`);let{d:i,l:a}=St._parseInt(n.subarray(2)),{d:o,l:s}=St._parseInt(a);if(s.length)throw new t(`Invalid signature: left bytes after parsing`);return{r:i,s:o}},hexFromSig(e){let t=e=>Number.parseInt(e[0],16)&8?`00`+e:e,n=e=>{let t=e.toString(16);return t.length&1?`0${t}`:t},r=t(n(e.s)),i=t(n(e.r)),a=r.length/2,o=i.length/2,s=n(a),c=n(o);return`30${n(o+a+4)}02${c}${i}02${s}${r}`}},P=BigInt(0),Ct=BigInt(1),wt=BigInt(3);function Tt(e){let t=N(e),{Fp:n}=t,r=t.toBytes||((e,t,r)=>{let i=t.toAffine();return Ve(Uint8Array.from([4]),n.toBytes(i.x),n.toBytes(i.y))}),i=t.fromBytes||(e=>{let t=e.subarray(1);return{x:n.fromBytes(t.subarray(0,n.BYTES)),y:n.fromBytes(t.subarray(n.BYTES,2*n.BYTES))}});function a(e){let{a:r,b:i}=t,a=n.sqr(e),o=n.mul(a,e);return n.add(n.add(o,n.mul(e,r)),i)}if(!n.eql(n.sqr(t.Gy),a(t.Gx)))throw Error(`bad generator point: equation left != right`);function o(e){return typeof e==`bigint`&&P<e&&e<t.n}function s(e){if(!o(e))throw Error(`Expected valid bigint: 0 < bigint < curve.n`)}function c(e){let{allowedPrivateKeyLengths:n,nByteLength:r,wrapPrivateKey:i,n:a}=t;if(n&&typeof e!=`bigint`){if(Ee(e)&&(e=ke(e)),typeof e!=`string`||!n.includes(e.length))throw Error(`Invalid key`);e=e.padStart(r*2,`0`)}let o;try{o=typeof e==`bigint`?e:Fe(Be(`private key`,e,r))}catch{throw Error(`private key must be ${r} bytes, hex or bigint, not ${typeof e}`)}return i&&(o=it(o,a)),s(o),o}let l=new Map;function u(e){if(!(e instanceof d))throw Error(`ProjectivePoint expected`)}class d{constructor(e,t,r){if(this.px=e,this.py=t,this.pz=r,e==null||!n.isValid(e))throw Error(`x required`);if(t==null||!n.isValid(t))throw Error(`y required`);if(r==null||!n.isValid(r))throw Error(`z required`)}static fromAffine(e){let{x:t,y:r}=e||{};if(!e||!n.isValid(t)||!n.isValid(r))throw Error(`invalid affine point`);if(e instanceof d)throw Error(`projective point not allowed`);let i=e=>n.eql(e,n.ZERO);return i(t)&&i(r)?d.ZERO:new d(t,r,n.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(e){let t=n.invertBatch(e.map(e=>e.pz));return e.map((e,n)=>e.toAffine(t[n])).map(d.fromAffine)}static fromHex(e){let t=d.fromAffine(i(Be(`pointHex`,e)));return t.assertValidity(),t}static fromPrivateKey(e){return d.BASE.multiply(c(e))}_setWindowSize(e){this._WINDOW_SIZE=e,l.delete(this)}assertValidity(){if(this.is0()){if(t.allowInfinityPoint&&!n.is0(this.py))return;throw Error(`bad point: ZERO`)}let{x:e,y:r}=this.toAffine();if(!n.isValid(e)||!n.isValid(r))throw Error(`bad point: x or y not FE`);let i=n.sqr(r),o=a(e);if(!n.eql(i,o))throw Error(`bad point: equation left != right`);if(!this.isTorsionFree())throw Error(`bad point: not in prime-order subgroup`)}hasEvenY(){let{y:e}=this.toAffine();if(n.isOdd)return!n.isOdd(e);throw Error(`Field doesn't support isOdd`)}equals(e){u(e);let{px:t,py:r,pz:i}=this,{px:a,py:o,pz:s}=e,c=n.eql(n.mul(t,s),n.mul(a,i)),l=n.eql(n.mul(r,s),n.mul(o,i));return c&&l}negate(){return new d(this.px,n.neg(this.py),this.pz)}double(){let{a:e,b:r}=t,i=n.mul(r,wt),{px:a,py:o,pz:s}=this,c=n.ZERO,l=n.ZERO,u=n.ZERO,f=n.mul(a,a),p=n.mul(o,o),m=n.mul(s,s),h=n.mul(a,o);return h=n.add(h,h),u=n.mul(a,s),u=n.add(u,u),c=n.mul(e,u),l=n.mul(i,m),l=n.add(c,l),c=n.sub(p,l),l=n.add(p,l),l=n.mul(c,l),c=n.mul(h,c),u=n.mul(i,u),m=n.mul(e,m),h=n.sub(f,m),h=n.mul(e,h),h=n.add(h,u),u=n.add(f,f),f=n.add(u,f),f=n.add(f,m),f=n.mul(f,h),l=n.add(l,f),m=n.mul(o,s),m=n.add(m,m),f=n.mul(m,h),c=n.sub(c,f),u=n.mul(m,p),u=n.add(u,u),u=n.add(u,u),new d(c,l,u)}add(e){u(e);let{px:r,py:i,pz:a}=this,{px:o,py:s,pz:c}=e,l=n.ZERO,f=n.ZERO,p=n.ZERO,m=t.a,h=n.mul(t.b,wt),g=n.mul(r,o),_=n.mul(i,s),v=n.mul(a,c),y=n.add(r,i),b=n.add(o,s);y=n.mul(y,b),b=n.add(g,_),y=n.sub(y,b),b=n.add(r,a);let x=n.add(o,c);return b=n.mul(b,x),x=n.add(g,v),b=n.sub(b,x),x=n.add(i,a),l=n.add(s,c),x=n.mul(x,l),l=n.add(_,v),x=n.sub(x,l),p=n.mul(m,b),l=n.mul(h,v),p=n.add(l,p),l=n.sub(_,p),p=n.add(_,p),f=n.mul(l,p),_=n.add(g,g),_=n.add(_,g),v=n.mul(m,v),b=n.mul(h,b),_=n.add(_,v),v=n.sub(g,v),v=n.mul(m,v),b=n.add(b,v),g=n.mul(_,b),f=n.add(f,g),g=n.mul(x,b),l=n.mul(y,l),l=n.sub(l,g),g=n.mul(y,_),p=n.mul(x,p),p=n.add(p,g),new d(l,f,p)}subtract(e){return this.add(e.negate())}is0(){return this.equals(d.ZERO)}wNAF(e){return p.wNAFCached(this,l,e,e=>{let t=n.invertBatch(e.map(e=>e.pz));return e.map((e,n)=>e.toAffine(t[n])).map(d.fromAffine)})}multiplyUnsafe(e){let r=d.ZERO;if(e===P)return r;if(s(e),e===Ct)return this;let{endo:i}=t;if(!i)return p.unsafeLadder(this,e);let{k1neg:a,k1:o,k2neg:c,k2:l}=i.splitScalar(e),u=r,f=r,m=this;for(;o>P||l>P;)o&Ct&&(u=u.add(m)),l&Ct&&(f=f.add(m)),m=m.double(),o>>=Ct,l>>=Ct;return a&&(u=u.negate()),c&&(f=f.negate()),f=new d(n.mul(f.px,i.beta),f.py,f.pz),u.add(f)}multiply(e){s(e);let r=e,i,a,{endo:o}=t;if(o){let{k1neg:e,k1:t,k2neg:s,k2:c}=o.splitScalar(r),{p:l,f:u}=this.wNAF(t),{p:f,f:m}=this.wNAF(c);l=p.constTimeNegate(e,l),f=p.constTimeNegate(s,f),f=new d(n.mul(f.px,o.beta),f.py,f.pz),i=l.add(f),a=u.add(m)}else{let{p:e,f:t}=this.wNAF(r);i=e,a=t}return d.normalizeZ([i,a])[0]}multiplyAndAddUnsafe(e,t,n){let r=d.BASE,i=(e,t)=>t===P||t===Ct||!e.equals(r)?e.multiplyUnsafe(t):e.multiply(t),a=i(this,t).add(i(e,n));return a.is0()?void 0:a}toAffine(e){let{px:t,py:r,pz:i}=this,a=this.is0();e??=a?n.ONE:n.inv(i);let o=n.mul(t,e),s=n.mul(r,e),c=n.mul(i,e);if(a)return{x:n.ZERO,y:n.ZERO};if(!n.eql(c,n.ONE))throw Error(`invZ was invalid`);return{x:o,y:s}}isTorsionFree(){let{h:e,isTorsionFree:n}=t;if(e===Ct)return!0;if(n)return n(d,this);throw Error(`isTorsionFree() has not been declared for the elliptic curve`)}clearCofactor(){let{h:e,clearCofactor:n}=t;return e===Ct?this:n?n(d,this):this.multiplyUnsafe(t.h)}toRawBytes(e=!0){return this.assertValidity(),r(d,this,e)}toHex(e=!0){return ke(this.toRawBytes(e))}}d.BASE=new d(t.Gx,t.Gy,n.ONE),d.ZERO=new d(n.ZERO,n.ONE,n.ZERO);let f=t.nBitLength,p=yt(d,t.endo?Math.ceil(f/2):f);return{CURVE:t,ProjectivePoint:d,normPrivateKeyToScalar:c,weierstrassEquation:a,isWithinCurveOrder:o}}function Et(e){let t=M(e);return Ye(t,{hash:`hash`,hmac:`function`,randomBytes:`function`},{bits2int:`function`,bits2int_modN:`function`,lowS:`boolean`}),Object.freeze({lowS:!0,...t})}function Dt(e){let t=Et(e),{Fp:n,n:r}=t,i=n.BYTES+1,a=2*n.BYTES+1;function o(e){return P<e&&e<n.ORDER}function s(e){return it(e,r)}function c(e){return st(e,r)}let{ProjectivePoint:l,normPrivateKeyToScalar:u,weierstrassEquation:d,isWithinCurveOrder:f}=Tt({...t,toBytes(e,t,r){let i=t.toAffine(),a=n.toBytes(i.x),o=Ve;return r?o(Uint8Array.from([t.hasEvenY()?2:3]),a):o(Uint8Array.from([4]),a,n.toBytes(i.y))},fromBytes(e){let t=e.length,r=e[0],s=e.subarray(1);if(t===i&&(r===2||r===3)){let e=Fe(s);if(!o(e))throw Error(`Point is not on curve`);let t=d(e),i;try{i=n.sqrt(t)}catch(e){let t=e instanceof Error?`: `+e.message:``;throw Error(`Point is not on curve`+t)}let a=(i&Ct)===Ct;return(r&1)==1!==a&&(i=n.neg(i)),{x:e,y:i}}if(t===a&&r===4)return{x:n.fromBytes(s.subarray(0,n.BYTES)),y:n.fromBytes(s.subarray(n.BYTES,2*n.BYTES))};throw Error(`Point of length ${t} was invalid. Expected ${i} compressed bytes or ${a} uncompressed bytes`)}}),p=e=>ke(Le(e,t.nByteLength));function m(e){return e>r>>Ct}function h(e){return m(e)?s(-e):e}let g=(e,t,n)=>Fe(e.slice(t,n));class _{constructor(e,t,n){this.r=e,this.s=t,this.recovery=n,this.assertValidity()}static fromCompact(e){let n=t.nByteLength;return e=Be(`compactSignature`,e,n*2),new _(g(e,0,n),g(e,n,2*n))}static fromDER(e){let{r:t,s:n}=St.toSig(Be(`DER`,e));return new _(t,n)}assertValidity(){if(!f(this.r))throw Error(`r must be 0 < r < CURVE.n`);if(!f(this.s))throw Error(`s must be 0 < s < CURVE.n`)}addRecoveryBit(e){return new _(this.r,this.s,e)}recoverPublicKey(e){let{r,s:i,recovery:a}=this,o=ee(Be(`msgHash`,e));if(a==null||![0,1,2,3].includes(a))throw Error(`recovery id invalid`);let u=a===2||a===3?r+t.n:r;if(u>=n.ORDER)throw Error(`recovery id 2 or 3 invalid`);let d=a&1?`03`:`02`,f=l.fromHex(d+p(u)),m=c(u),h=s(-o*m),g=s(i*m),_=l.BASE.multiplyAndAddUnsafe(f,h,g);if(!_)throw Error(`point at infinify`);return _.assertValidity(),_}hasHighS(){return m(this.s)}normalizeS(){return this.hasHighS()?new _(this.r,s(-this.s),this.recovery):this}toDERRawBytes(){return Pe(this.toDERHex())}toDERHex(){return St.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Pe(this.toCompactHex())}toCompactHex(){return p(this.r)+p(this.s)}}let v={isValidPrivateKey(e){try{return u(e),!0}catch{return!1}},normPrivateKeyToScalar:u,randomPrivateKey:()=>{let e=A(t.n);return j(t.randomBytes(e),t.n)},precompute(e=8,t=l.BASE){return t._setWindowSize(e),t.multiply(BigInt(3)),t}};function y(e,t=!0){return l.fromPrivateKey(e).toRawBytes(t)}function b(e){let t=Ee(e),n=typeof e==`string`,r=(t||n)&&e.length;return t?r===i||r===a:n?r===2*i||r===2*a:e instanceof l}function x(e,t,n=!0){if(b(e))throw Error(`first arg must be private key`);if(!b(t))throw Error(`second arg must be public key`);return l.fromHex(t).multiply(u(e)).toRawBytes(n)}let S=t.bits2int||function(e){let n=Fe(e),r=e.length*8-t.nBitLength;return r>0?n>>BigInt(r):n},ee=t.bits2int_modN||function(e){return s(S(e))},te=Ge(t.nBitLength);function C(e){if(typeof e!=`bigint`)throw Error(`bigint expected`);if(!(P<=e&&e<te))throw Error(`bigint expected < 2^${t.nBitLength}`);return Le(e,t.nByteLength)}function ne(e,r,i=re){if([`recovered`,`canonical`].some(e=>e in i))throw Error(`sign() legacy options not supported`);let{hash:a,randomBytes:o}=t,{lowS:d,prehash:p,extraEntropy:g}=i;d??=!0,e=Be(`msgHash`,e),p&&(e=Be(`prehashed msgHash`,a(e)));let v=ee(e),y=u(r),b=[C(y),C(v)];if(g!=null&&g!==!1){let e=g===!0?o(n.BYTES):g;b.push(Be(`extraEntropy`,e))}let x=Ve(...b),te=v;function ne(e){let t=S(e);if(!f(t))return;let n=c(t),r=l.BASE.multiply(t).toAffine(),i=s(r.x);if(i===P)return;let a=s(n*s(te+i*y));if(a===P)return;let o=(r.x===i?0:2)|Number(r.y&Ct),u=a;return d&&m(a)&&(u=h(a),o^=1),new _(i,u,o)}return{seed:x,k2sig:ne}}let re={lowS:t.lowS,prehash:!1},w={lowS:t.lowS,prehash:!1};function ie(e,n,r=re){let{seed:i,k2sig:a}=ne(e,n,r),o=t;return Je(o.hash.outputLen,o.nByteLength,o.hmac)(i,a)}l.BASE._setWindowSize(8);function ae(e,n,r,i=w){let a=e;if(n=Be(`msgHash`,n),r=Be(`publicKey`,r),`strict`in i)throw Error(`options.strict was renamed to lowS`);let{lowS:o,prehash:u}=i,d,f;try{if(typeof a==`string`||Ee(a))try{d=_.fromDER(a)}catch(e){if(!(e instanceof St.Err))throw e;d=_.fromCompact(a)}else if(typeof a==`object`&&typeof a.r==`bigint`&&typeof a.s==`bigint`){let{r:e,s:t}=a;d=new _(e,t)}else throw Error(`PARSE`);f=l.fromHex(r)}catch(e){if(e.message===`PARSE`)throw Error(`signature must be Signature instance, Uint8Array or hex string`);return!1}if(o&&d.hasHighS())return!1;u&&(n=t.hash(n));let{r:p,s:m}=d,h=ee(n),g=c(m),v=s(h*g),y=s(p*g),b=l.BASE.multiplyAndAddUnsafe(f,v,y)?.toAffine();return b?s(b.x)===p:!1}return{CURVE:t,getPublicKey:y,getSharedSecret:x,sign:ie,verify:ae,ProjectivePoint:l,Signature:_,utils:v}}function Ot(e){return{hash:e,hmac:(t,...n)=>xe(e,t,te(...n)),randomBytes:S}}function kt(e,t){let n=t=>Dt({...e,...Ot(t)});return Object.freeze({...n(t),create:n})}var At=BigInt(`0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f`),jt=BigInt(`0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141`),Mt=BigInt(1),Nt=BigInt(2),Pt=(e,t)=>(e+t/Nt)/t;function Ft(e){let t=At,n=BigInt(3),r=BigInt(6),i=BigInt(11),a=BigInt(22),o=BigInt(23),s=BigInt(44),c=BigInt(88),l=e*e*e%t,u=l*l*e%t,d=ot(ot(ot(u,n,t)*u%t,n,t)*u%t,Nt,t)*l%t,f=ot(d,i,t)*d%t,p=ot(f,a,t)*f%t,m=ot(p,s,t)*p%t,h=ot(ot(ot(ot(ot(ot(m,c,t)*m%t,s,t)*p%t,n,t)*u%t,o,t)*f%t,r,t)*l%t,Nt,t);if(!It.eql(It.sqr(h),e))throw Error(`Cannot find square root`);return h}var It=ht(At,void 0,void 0,{sqrt:Ft}),Lt=kt({a:BigInt(0),b:BigInt(7),Fp:It,n:jt,Gx:BigInt(`55066263022277343669578718895168534326250603453777594175500187360389116729240`),Gy:BigInt(`32670510020758816978083085130507043184471273380659243275938904335757337482424`),h:BigInt(1),lowS:!0,endo:{beta:BigInt(`0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee`),splitScalar:e=>{let t=jt,n=BigInt(`0x3086d221a7d46bcde86c90e49284eb15`),r=-Mt*BigInt(`0xe4437ed6010e88286f547fa90abfe4c3`),i=BigInt(`0x114ca50f7a8e2f3f657c1108d9d44cfd8`),a=n,o=BigInt(`0x100000000000000000000000000000000`),s=Pt(a*e,t),c=Pt(-r*e,t),l=it(e-s*n-c*i,t),u=it(-s*r-c*a,t),d=l>o,f=u>o;if(d&&(l=t-l),f&&(u=t-u),l>o||u>o)throw Error(`splitScalar: Endomorphism failed, k=`+e);return{k1neg:d,k1:l,k2neg:f,k2:u}}}},ie);Lt.ProjectivePoint;var Rt=n(((e,t)=>{var n=Object.prototype.hasOwnProperty,r=`~`;function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(r=!1));function a(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function o(e,t,n,i,o){if(typeof n!=`function`)throw TypeError(`The listener must be a function`);var s=new a(n,i||e,o),c=r?r+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],s]:e._events[c].push(s):(e._events[c]=s,e._eventsCount++),e}function s(e,t){--e._eventsCount===0?e._events=new i:delete e._events[t]}function c(){this._events=new i,this._eventsCount=0}c.prototype.eventNames=function(){var e=[],t,i;if(this._eventsCount===0)return e;for(i in t=this._events)n.call(t,i)&&e.push(r?i.slice(1):i);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(t)):e},c.prototype.listeners=function(e){var t=r?r+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,a=n.length,o=Array(a);i<a;i++)o[i]=n[i].fn;return o},c.prototype.listenerCount=function(e){var t=r?r+e:e,n=this._events[t];return n?n.fn?1:n.length:0},c.prototype.emit=function(e,t,n,i,a,o){var s=r?r+e:e;if(!this._events[s])return!1;var c=this._events[s],l=arguments.length,u,d;if(c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),l){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,n),!0;case 4:return c.fn.call(c.context,t,n,i),!0;case 5:return c.fn.call(c.context,t,n,i,a),!0;case 6:return c.fn.call(c.context,t,n,i,a,o),!0}for(d=1,u=Array(l-1);d<l;d++)u[d-1]=arguments[d];c.fn.apply(c.context,u)}else{var f=c.length,p;for(d=0;d<f;d++)switch(c[d].once&&this.removeListener(e,c[d].fn,void 0,!0),l){case 1:c[d].fn.call(c[d].context);break;case 2:c[d].fn.call(c[d].context,t);break;case 3:c[d].fn.call(c[d].context,t,n);break;case 4:c[d].fn.call(c[d].context,t,n,i);break;default:if(!u)for(p=1,u=Array(l-1);p<l;p++)u[p-1]=arguments[p];c[d].fn.apply(c[d].context,u)}}return!0},c.prototype.on=function(e,t,n){return o(this,e,t,n,!1)},c.prototype.once=function(e,t,n){return o(this,e,t,n,!0)},c.prototype.removeListener=function(e,t,n,i){var a=r?r+e:e;if(!this._events[a])return this;if(!t)return s(this,a),this;var o=this._events[a];if(o.fn)o.fn===t&&(!i||o.once)&&(!n||o.context===n)&&s(this,a);else{for(var c=0,l=[],u=o.length;c<u;c++)(o[c].fn!==t||i&&!o[c].once||n&&o[c].context!==n)&&l.push(o[c]);l.length?this._events[a]=l.length===1?l[0]:l:s(this,a)}return this},c.prototype.removeAllListeners=function(e){var t;return e?(t=r?r+e:e,this._events[t]&&s(this,t)):(this._events=new i,this._eventsCount=0),this},c.prototype.off=c.prototype.removeListener,c.prototype.addListener=c.prototype.on,c.prefixed=r,c.EventEmitter=c,t!==void 0&&(t.exports=c)})),zt=class extends Error{constructor(e,t){super(e),this.error=t}},Bt=class extends zt{constructor(e,t){super(e||`The wallet is not found.`,t),this.name=`WalletNotFoundError`}},Vt=class extends zt{constructor(){super(...arguments),this.name=`WalletDisconnectedError`,this.message=`The wallet is disconnected. Please connect first.`}},Ht=class extends zt{constructor(){super(...arguments),this.name=`WalletConnectionError`}},Ut=class extends zt{constructor(){super(...arguments),this.name=`WalletDisconnectionError`}},Wt=class extends zt{constructor(){super(...arguments),this.name=`WalletSignMessageError`}},Gt=class extends zt{constructor(){super(...arguments),this.name=`WalletSignTransactionError`}},Kt=class extends zt{constructor(e,t){super(e||`The QR window is closed.`,t),this.name=`WalletWindowClosedError`}},qt=class extends zt{constructor(){super(...arguments),this.name=`WalletSwitchChainError`}},Jt=class extends zt{constructor(){super(...arguments),this.name=`WalletGetNetworkError`}},Yt=class extends zt{constructor(){super(...arguments),this.name=`WalletSignTypedDataError`}};function Xt(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Zt(e){if(!Xt(e))throw new Yt(`typedData must be an object.`);if(!Xt(e.domain))throw new Yt(`typedData.domain must be an object.`);if(!Xt(e.types))throw new Yt(`typedData.types must be an object.`);if(!Xt(e.message))throw new Yt(`typedData.message must be an object.`);let{chainId:t}=e.domain;if(typeof t==`string`){let n=Number(t);if(!Number.isFinite(n))throw new Yt(`Invalid domain.chainId: ${t}.`);return Object.assign(Object.assign({},e),{domain:Object.assign(Object.assign({},e.domain),{chainId:n})})}return e}var Qt;(function(e){e.Loading=`Loading`,e.NotFound=`NotFound`,e.Found=`Found`})(Qt||={});var F;(function(e){e.Loading=`Loading`,e.NotFound=`NotFound`,e.Disconnect=`Disconnected`,e.Connected=`Connected`})(F||={});var $t;(function(e){e.Mainnet=`Mainnet`,e.Shasta=`Shasta`,e.Nile=`Nile`,e.Unknown=`Unknown`})($t||={});var en;(function(e){e.Mainnet=`Mainnet`,e.Shasta=`Shasta`,e.Nile=`Nile`})(en||={});var tn=`TIP6963:announceProvider`,nn=`TIP6963:requestProvider`,rn=t(Rt(),1),an=class extends rn.default{get connected(){return this.state===F.Connected}disconnect(){return Promise.resolve()}multiSign(e,t={}){return Promise.reject(`The current wallet doesn't support multiSign.`)}signTypedData(e){let t;try{t=Zt(e)}catch(e){return Promise.reject(e)}return this._signTypedData(t)}_signTypedData(e){return Promise.reject(`The current wallet doesn't support signTypedData.`)}switchChain(e){return Promise.reject(`The current wallet doesn't support switch chain.`)}};function on(){return typeof window<`u`&&typeof document<`u`&&typeof navigator<`u`}function sn(){return typeof navigator<`u`&&navigator.userAgent.match(/Android|webOS|iPhone|iPad|iPod|BlackBerry|Windows Phone/i)}var cn=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})},ln={onRiskDetected:e=>cn(void 0,void 0,void 0,function*(){}),configUrls:[],enabled:!1,timeout:2e3,retries:0,cacheTTL:6e5};function un(e){return!!e&&typeof e==`object`&&typeof e.title==`string`&&e.title.length>0&&(e.noticeType===1||e.noticeType===2||e.noticeType===3)}function dn(e){let t={title:e.title,noticeType:e.noticeType};return typeof e.ext==`string`&&(t.ext=e.ext),typeof e.ios==`string`&&(t.ios=e.ios),typeof e.and==`string`&&(t.and=e.and),t}function fn(e){let t=e&&typeof e==`object`?e:{},n={};if(t.wallets&&typeof t.wallets==`object`)for(let[e,r]of Object.entries(t.wallets)){if(!Array.isArray(r))continue;let t=[];for(let e of r)un(e)&&t.push(dn(e));t.length>0&&(n[e]=t)}return{v:typeof t.v==`string`?t.v:``,ts:typeof t.ts==`number`?t.ts:0,wallets:n}}var pn={};function mn(e){return cn(this,void 0,void 0,function*(){let{configUrls:t=ln.configUrls,timeout:n=ln.timeout,retries:r=ln.retries,onConfigFallback:i,cacheTTL:a=ln.cacheTTL}=e,o=Date.now();function s(e){return cn(this,void 0,void 0,function*(){let t=pn[e];if(t&&o-t.timestamp<a)return t.data;function i(){return cn(this,void 0,void 0,function*(){return new Promise((t,r)=>{let i=new AbortController,a=setTimeout(()=>i.abort(),n);fetch(e,{signal:i.signal}).then(e=>{clearTimeout(a),e.ok?e.json().then(e=>t(fn(e)),r):r(Error(`Fetch failed with code: `+e.status))}).catch(e=>{clearTimeout(a),r(e)})})})}for(let t=0;t<=r;t++)try{let t=yield i();return pn[e]={data:t,timestamp:Date.now()},t}catch{}return null})}let c=(yield Promise.all(t.map(s))).filter(e=>e!==null);return c.length>0?c.reduce((e,t)=>{t.ts>e.ts&&(e.v=t.v,e.ts=t.ts);for(let[n,r]of Object.entries(t.wallets))e.wallets[n]=[...e.wallets[n]??[],...r];return e},{v:``,ts:0,wallets:{}}):i?fn(yield i()):{v:``,ts:0,wallets:{}}})}var hn=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})},gn=class e extends an{constructor(t){if(super(),this.commonConfig={checkTimeout:2e3,openAppWithDeeplink:!0,openUrlWhenWalletNotFound:!0,securityOptions:ln},this._securityCheckCache=null,this.commonConfig=Object.assign(Object.assign({},this.commonConfig),t),typeof this.commonConfig.checkTimeout!=`number`)throw Error(`[WalletAdapter] config.checkTimeout should be a number`);e._validateSecurityOptions(this.commonConfig.securityOptions)}static _validateSecurityOptions(e){let{enabled:t,configUrls:n}=e;if(t&&(!n||n.length===0))throw Error(`[WalletAdapter] config.securityOptions.configUrls is required when securityOptions.enabled is true`)}updateSecurityOptions(t){let n=Object.assign(Object.assign({},this.commonConfig.securityOptions),t);e._validateSecurityOptions(n),this.commonConfig.securityOptions=n,this._securityCheckCache=null}_beforeConnect(){return hn(this,void 0,void 0,function*(){if(this.connected||this.connecting)return!1;if(yield this._checkWallet(),this.readyState===Qt.NotFound)throw on()&&!this._openAppByDeepLinkIfNeed()&&this.commonConfig.openUrlWhenWalletNotFound!==!1&&window.open(this.url,`_blank`),new Bt;return yield this.checkSecurity(),!0})}checkSecurity(){return hn(this,void 0,void 0,function*(){if(!this.commonConfig.securityOptions.enabled)return;let t=this._securityCheckCache;if(t&&(t.settledAt===null||Date.now()-t.settledAt<e.SECURITY_CHECK_CACHE_TTL))return t.promise;let n=hn(this,void 0,void 0,function*(){let e=(yield mn(this.commonConfig.securityOptions)).wallets[this.name];e&&e.length>0&&(yield(this.commonConfig.securityOptions.onRiskDetected||ln.onRiskDetected)({risks:e}))}),r={promise:n,settledAt:null};return this._securityCheckCache=r,n.finally(()=>{this._securityCheckCache===r&&(r.settledAt=Date.now())}).catch(()=>{}),n})}};gn.SECURITY_CHECK_CACHE_TTL=5e3;var _n=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};function vn(){return on()&&!!(window.tron&&window.tron.isTronLink)}function yn(){return on()&&!!(vn()||window.tronLink||window.tronWeb)}function bn(){return on()&&window.iTron!==void 0}function xn({dappIcon:e,dappName:t}={dappIcon:``,dappName:``}){if(!yn()&&sn()&&!bn()){let n=``,r=``;try{n=document.title;let e=document.querySelector(`link[rel*="icon"]`);e&&(r=new URL(e.getAttribute(`href`)||``,location.href).toString())}catch{}let{origin:i,pathname:a,search:o,hash:s}=window.location,c=i+a+o+(s.includes(`?`)?s:`${s}?_=1`),l={action:`open`,actionId:Date.now()+``,callbackUrl:`http://someurl.com`,dappIcon:e||r,dappName:t||n,url:c,protocol:`TronLink`,version:`1.0`,chainId:`0x2b6653dc`};return window.location.href=`tronlinkoutside://pull.activity?param=${encodeURIComponent(JSON.stringify(l))}`,!0}return!1}function Sn(e){return _n(this,void 0,void 0,function*(){return new Promise((t,n)=>{let r=setInterval(()=>{e.tronWeb&&(clearInterval(r),clearTimeout(i),t())},50),i=setTimeout(()=>{clearInterval(r),n("`window.tron.tronweb` is not ready.")},2e3)})})}var Cn=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})},wn={"0x2b6653dc":$t.Mainnet,"0x94a9059e":$t.Shasta,"0xcd8690dc":$t.Nile};function Tn(e){return Cn(this,void 0,void 0,function*(){let{blockID:t=``}=yield e.trx.getBlockByNumber(0),n=`0x${t.slice(-8)}`;return{networkType:wn[n]||$t.Unknown,chainId:n,fullNode:e.fullNode?.host||``,solidityNode:e.solidityNode?.host||``,eventServer:e.eventServer?.host||``}})}var En=`TronLink`,Dn=class extends gn{constructor(e={}){super(e),this.name=En,this.url=`https://www.tronlink.org/`,this.icon=`data:image/png;base64,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`,this._readyState=on()?Qt.Loading:Qt.NotFound,this._state=on()?F.Loading:F.NotFound,this._supportNewTronProtocol=!1,this._onChainChanged=e=>{this.emit(`chainChanged`,e)},this._onAccountsChanged=()=>{let e=this.address||``,t=this._wallet?.tronWeb&&this._wallet?.tronWeb.defaultAddress?.base58||``;this.setAddress(t||null),this.setState(this.address?F.Connected:F.Disconnect),this.emit(`accountsChanged`,this.address||``,e),!e&&this.address?this.emit(`connect`,this.address):e&&!this.address&&this.emit(`disconnect`)},this._checkPromise=null,this._updateWallet=()=>Cn(this,void 0,void 0,function*(){this._supportNewTronProtocol=!1;let e=this.state,t=this.address;if(sn()){if(this._wallet=window.tronLink?window.tronLink:{ready:!!window.tronWeb?.defaultAddress,tronWeb:window.tronWeb,request:()=>Promise.resolve(!0)},t=this._wallet.tronWeb?.defaultAddress?.base58||null,t){try{yield this.checkSecurity()}catch{this.setAddress(null),this.setState(F.Disconnect);return}e=F.Connected}else e=F.Disconnect}else if(this.isLegacyTronLinkProvider(window.tron)){this._supportNewTronProtocol=!0,this._wallet=window.tron,this._listenTronEvent();try{t=this._wallet?.tronWeb&&this._wallet.tronWeb?.defaultAddress?.base58||null,e=t?F.Connected:F.Disconnect}catch{t=null,e=F.Disconnect,this._readyState=Qt.NotFound,this.emit(`readyStateChanged`,this.readyState);return}}else window.tronLink?(this._wallet=window.tronLink,t=this._wallet.tronWeb?.defaultAddress?.base58||null,e=this._wallet.ready?F.Connected:F.Disconnect):(this._wallet=null,t=null,e=F.NotFound);sn()&&e===F.Disconnect&&this.checkForWalletReadyForApp(),this.setAddress(t),this.setState(e)}),this.checkReadyInterval=null;let{checkTimeout:t=5e3,dappIcon:n=``,dappName:r=``,openUrlWhenWalletNotFound:i=!0,openTronLinkAppOnMobile:a=!0,openAppWithDeeplink:o=!0}=e;if(typeof t!=`number`)throw Error(`[TronLinkAdapter] config.checkTimeout should be a number`);if(this.config=Object.assign(Object.assign({},this.commonConfig),{checkTimeout:t,openTronLinkAppOnMobile:a,openAppWithDeeplink:o,openUrlWhenWalletNotFound:i,dappIcon:n,dappName:r}),this._connecting=!1,this._wallet=null,this._address=null,!on()){this._readyState=Qt.NotFound,this.setState(F.NotFound);return}sn()&&(vn()||sn()&&(window.tronLink||window.tronWeb))?(this._readyState=Qt.Found,this._updateWallet().then(()=>{this.connected&&this.emit(`connect`,this.address||``)})):this._checkWallet().then(()=>{this.connected&&this.emit(`connect`,this.address||``)})}get address(){return this._address}get state(){return this._state}get readyState(){return this._readyState}get connecting(){return this._connecting}network(){return Cn(this,void 0,void 0,function*(){try{if(yield this._checkWallet(),this.state!==F.Connected)throw new Vt;let e=this._wallet?.tronWeb||window.tronWeb;if(!e)throw new Vt;try{return yield Tn(e)}catch(e){throw new Jt(e?.message,e)}}catch(e){throw this.emit(`error`,e),e}})}connect(){return Cn(this,void 0,void 0,function*(){try{if(!(yield this._beforeConnect())||!this._wallet)return;if(this._connecting=!0,this._supportNewTronProtocol){let e=this._wallet;try{let t=(yield e.request({method:`eth_requestAccounts`}))[0];this.setAddress(t),this.setState(F.Connected),this._listenTronEvent(),this._wallet.tronWeb||(yield Sn(this._wallet))}catch(e){let t=e?.message||e||`Connect TronLink wallet failed.`;throw e.code===-32002&&(t=`The same DApp has already initiated a request to connect to TronLink wallet, and the pop-up window has not been closed.`),e.code===4001&&(t=`The user rejected connection.`),new Ht(t,e)}}else if(window.tronLink){let e=this._wallet,t=yield e.request({method:`tron_requestAccounts`});if(!t)throw new Ht(`TronLink wallet is locked or no wallet account is avaliable.`);if(t.code===4e3)throw new Ht(`The same DApp has already initiated a request to connect to TronLink wallet, and the pop-up window has not been closed.`);if(t.code===4001)throw new Ht(`The user rejected connection.`);let n=e.tronWeb.defaultAddress?.base58||``;this.setAddress(n),this.setState(F.Connected)}else if(window.tronWeb){let e=this._wallet.tronWeb.defaultAddress?.base58||``;this.setAddress(e),this.setState(F.Connected)}else throw new Ht(`Cannot connect wallet.`);this.connected&&this.emit(`connect`,this.address||``)}catch(e){let t=e instanceof zt?e:new Ht(e?.message,e);throw this.emit(`error`,t),t}finally{this._connecting=!1}})}disconnect(){return Cn(this,void 0,void 0,function*(){this._supportNewTronProtocol&&this._stopListenTronEvent(),this.state===F.Connected&&(this.setAddress(null),this.setState(F.Disconnect),this.emit(`disconnect`))})}_checkAndSign(e,t){return Cn(this,void 0,void 0,function*(){try{let n=yield this.checkAndGetWallet();try{return yield e(n)}catch(e){throw e instanceof Error||typeof e==`object`&&e.message?new t(e.message,e):typeof e==`string`?new t(e,Error(e)):new t(`Unknown error`,e)}}catch(e){throw this.emit(`error`,e),e}})}signTransaction(e){return Cn(this,void 0,void 0,function*(){return this._checkAndSign(t=>t.tronWeb.trx.sign(e),Gt)})}multiSign(e){return Cn(this,arguments,void 0,function*(e,t={}){return this._checkAndSign(n=>n.tronWeb.trx.multiSign(e,void 0,t.permissionId),Gt)})}signMessage(e){return Cn(this,void 0,void 0,function*(){return this._checkAndSign(t=>Cn(this,void 0,void 0,function*(){return t.tronWeb.trx.signMessageV2(e)}),Wt)})}_signTypedData(e){return Cn(this,void 0,void 0,function*(){return this._checkAndSign(t=>Cn(this,void 0,void 0,function*(){return t.tronWeb.trx._signTypedData(e.domain,e.types,e.message)}),Yt)})}switchChain(e){return Cn(this,void 0,void 0,function*(){try{if(yield this._checkWallet(),this.state===F.NotFound)throw this.config.openUrlWhenWalletNotFound!==!1&&on()&&window.open(this.url,`_blank`),new Bt;if(!this._supportNewTronProtocol)throw new qt(`Current version of TronLink doesn't support switch chain operation.`);let t=this._wallet;try{yield t.request({method:`wallet_switchEthereumChain`,params:[{chainId:e}]})}catch(e){throw new qt(e?.message||e,e instanceof Error?e:Error(e))}}catch(e){throw this.emit(`error`,e),e}})}checkAndGetWallet(){return Cn(this,void 0,void 0,function*(){if(this._openAppByDeepLinkIfNeed())throw new Bt;if(yield this._checkWallet(),this.state!==F.Connected)throw new Vt;let e=this._wallet;if(!e||!e.tronWeb)throw new Vt;return e})}_openAppByDeepLinkIfNeed(){if(this.config.openAppWithDeeplink===!1||this.config.openTronLinkAppOnMobile===!1)return!1;let{dappName:e=``,dappIcon:t=``}=this.config;return xn({dappIcon:t,dappName:e})}_listenTronEvent(){var e,t;this._stopListenTronEvent();let n=this._wallet;(e=n.on)==null||e.call(n,`chainChanged`,this._onChainChanged),(t=n.on)==null||t.call(n,`accountsChanged`,this._onAccountsChanged)}_stopListenTronEvent(){var e,t;let n=this._wallet;(e=n.removeListener)==null||e.call(n,`chainChanged`,this._onChainChanged),(t=n.removeListener)==null||t.call(n,`accountsChanged`,this._onAccountsChanged)}isLegacyTronLinkProvider(e){return!!e?.isTronLink}hasDesktopLegacyTronLinkProvider(){return this.isLegacyTronLinkProvider(window.tron)||!!window.tronLink}_checkWallet(){if(this.readyState===Qt.Found)return Promise.resolve(!0);if(this._checkPromise)return this._checkPromise;if(on()&&!sn())return this._checkPromise=new Promise(e=>{let t=!1,n=null,r=null,i=null,a=()=>{r&&=(clearInterval(r),null),n&&=(clearTimeout(n),null),typeof window<`u`&&i&&window.removeEventListener(tn,i)};n=setTimeout(()=>{if(t)return;if(t=!0,a(),typeof window>`u`){e(!1);return}this._updateWallet();let n=this.state!==F.NotFound;this._readyState=n?Qt.Found:Qt.NotFound,this.emit(`readyStateChanged`,this._readyState),e(n)},this.config.checkTimeout),i=n=>Cn(this,void 0,void 0,function*(){if(t)return;let{info:r,provider:i}=n.detail;if(r.name===`TronLink`){t=!0,this._supportNewTronProtocol=!0,this._wallet=i;try{yield this.checkSecurity()}catch{this.setAddress(null),this.setState(F.Disconnect),this._readyState=Qt.Found,this.emit(`readyStateChanged`,this.readyState),e(!0);return}this._listenTronEvent(),this._readyState=Qt.Found;let n=this._wallet?.tronWeb&&this._wallet.tronWeb.defaultAddress?.base58||null,r=n?F.Connected:F.Disconnect;this.setAddress(n),this.setState(r),this.emit(`readyStateChanged`,this.readyState),a(),e(!0)}}),window.addEventListener(tn,i),window.dispatchEvent(new Event(nn))}),this._checkPromise;let e=Math.floor(this.config.checkTimeout/100),t=0,n;return this._checkPromise=new Promise(r=>{let i=()=>{t++,this._updateWallet();let i=!!(sn()&&(window.tronLink||window.tronWeb));(i||t>e)&&(n&&clearInterval(n),this._readyState=i?Qt.Found:Qt.NotFound,this.emit(`readyStateChanged`,this.readyState),r(i))};n=setInterval(i,100),i()}),this._checkPromise}checkForWalletReadyForApp(){if(this.checkReadyInterval)return;let e=0,t=Math.floor(this.config.checkTimeout/200),n=()=>{(window.tronLink?window.tronLink.tronWeb?.defaultAddress:window.tronWeb?.defaultAddress)?(this.checkReadyInterval&&clearInterval(this.checkReadyInterval),this.checkReadyInterval=null,this._updateWallet(),this.emit(`connect`,this.address||``)):e>t?(this.checkReadyInterval&&clearInterval(this.checkReadyInterval),this.checkReadyInterval=null):e++};this.checkReadyInterval=setInterval(n,200)}setAddress(e){this._address=e}setState(e){e!==this.state&&(this._state=e,this.emit(`stateChanged`,e))}};function On(){return!!window.tronLink&&window.isBitKeep}function kn(){if(sn()&&!On()){let{origin:e,pathname:t,search:n,hash:r}=window.location,i=e+t+n+r;return location.href=`https://bkcode.vip?action=dapp&url=${encodeURIComponent(i)}`,!0}return!1}var An=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})},jn=`Bitget Wallet`,Mn=class extends gn{constructor(e={}){if(super(e),this.name=jn,this.url=`https://web3.bitget.com`,this.icon=`data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTEyIiBoZWlnaHQ9IjUxMiIgdmlld0JveD0iMCAwIDUxMiA1MTIiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxyZWN0IHdpZHRoPSI1MTIiIGhlaWdodD0iNTEyIiBmaWxsPSIjMDAxRjI5Ii8+CjxwYXRoIGQ9Ik0yMTkuOTQ4IDk1LjcwMjJDMjAxLjYyMyA5NS42OTI5IDE4My4zMyA5NS42ODM1IDE2NC45NDEgOTUuNzExNkMxNTMuODIyIDk1LjcxMTYgMTQ5LjY1MSAxMDkuNjcxIDE1Ny45MjEgMTE3LjkzOUwyODMuMDk4IDI0My4xMTdDMjg3LjAwNCAyNDYuNjkgMjg5LjQ0MSAyNTAuNTc0IDI4OS41MyAyNTUuNjkzQzI4OS40NDEgMjYwLjgxMiAyODcuMDA0IDI2NC42OTYgMjgzLjA5OCAyNjguMjY5TDE1Ny45MjEgMzkzLjQ0NkMxNDkuNjUxIDQwMS43MTUgMTUzLjgyMiA0MTUuNjc0IDE2NC45NDEgNDE1LjY3NEMxODMuMzMgNDE1LjcwMiAyMDEuNjIzIDQxNS42OTMgMjE5Ljk0OCA0MTUuNjgzQzIyOS4xMjIgNDE1LjY3OSAyMzguMzA1IDQxNS42NzQgMjQ3LjUxMSA0MTUuNjc0QzI1OS41NTUgNDE1LjY3NCAyNjYuNzIgNDA5LjI0IDI3My4xNTQgNDAyLjgwNUwzODYuMDQ3IDI4OS45MTJDMzk1LjA1NyAyODAuOTAyIDQwMy4xMTkgMjY4LjkzOSA0MDMuMDA5IDI1NS42OTNDNDAzLjExOSAyNDIuNDQ3IDM5NS4wNTcgMjMwLjQ4NCAzODYuMDQ3IDIyMS40NzRMMjczLjE1NCAxMDguNThDMjY2LjcyIDEwMi4xNDYgMjU5LjU1NSA5NS43MTE2IDI0Ny41MTEgOTUuNzExNkMyMzguMzA1IDk1LjcxMTYgMjI5LjEyMiA5NS43MDY5IDIxOS45NDggOTUuNzAyMloiIGZpbGw9IiMwMEYwRkYiLz4KPC9zdmc+Cg==`,this._readyState=Qt.Loading,this._state=F.Loading,this.checkReadyInterval=null,this._checkPromise=null,this._updateWallet=()=>An(this,void 0,void 0,function*(){let e=this.state,t=this.address;if(On()){if(sn()){let e=window.bitkeep?.tronLink;this._wallet={tron:e,tronWeb:e?.tronWeb}}else{let e=window.bitkeep?.tronWeb;this._wallet={tron:window.bitkeep.tronLink,tronWeb:e}}let n=this._wallet.tron?.ready;if(t=n?this._wallet.tronWeb.defaultAddress?.base58||null:``,n){try{yield this.checkSecurity()}catch{this.setAddress(null),this.setState(F.Disconnect);return}e=F.Connected}else e=F.Disconnect,this.checkForWalletReady()}else this._wallet=null,t=null,e=F.NotFound;this.setAddress(t),this.setState(e)}),this.config=Object.assign({},this.commonConfig),this._connecting=!1,this._wallet=null,this._address=null,!on()){this._readyState=Qt.NotFound,this.setState(F.NotFound);return}On()?(this._readyState=Qt.Found,this._updateWallet().then(()=>{this.connected&&this.emit(`connect`,this.address||``)})):this._checkWallet().then(()=>{this.connected&&this.emit(`connect`,this.address||``)})}get address(){return this._address}get state(){return this._state}get readyState(){return this._readyState}get connecting(){return this._connecting}network(){return An(this,void 0,void 0,function*(){try{if(yield this._checkWallet(),this.state!==F.Connected)throw new Vt;let e=this._wallet;if(!e||!e.tronWeb)throw new Vt;try{return yield Tn(e.tronWeb)}catch(e){throw new Jt(e?.message,e)}}catch(e){throw this.emit(`error`,e),e}})}connect(){return An(this,void 0,void 0,function*(){try{if(!(yield this._beforeConnect()))return;let e=this._wallet;if(!e)return;if(!sn()){this._connecting=!0;let t=yield e.tron.request({method:`tron_requestAccounts`});if(t?.code!==200)throw new Ht(t?.code===40001?`The connection request is canceled by user.`:t?.message)}let t=e?.tronWeb.defaultAddress?.base58||window.bitkeep?.tronWeb?.defaultAddress?.base58||``;this.setAddress(t),this.setState(F.Connected),this.emit(`connect`,this.address||``)}catch(e){let t=e instanceof zt?e:new Ht(e?.message,e);throw this.emit(`error`,t),t}finally{this._connecting=!1}})}disconnect(){return An(this,void 0,void 0,function*(){this.state===F.Connected&&(this.setAddress(null),this.setState(F.Disconnect),this.emit(`disconnect`))})}signTransaction(e){return An(this,void 0,void 0,function*(){try{let t=yield this.checkAndGetWallet();try{return yield t.tronWeb.trx.sign(e)}catch(e){throw e instanceof Error?new Gt(e.message,e):new Gt(e,Error(e))}}catch(e){throw this.emit(`error`,e),e}})}multiSign(e){return An(this,arguments,void 0,function*(e,t={}){try{let n=yield this.checkAndGetWallet();try{return yield n.tronWeb.trx.multiSign(e,void 0,t.permissionId)}catch(e){throw e instanceof Error?new Gt(e.message,e):new Gt(e,Error(e))}}catch(e){throw this.emit(`error`,e),e}})}signMessage(e){return An(this,void 0,void 0,function*(){try{let t=yield this.checkAndGetWallet();try{return yield t.tronWeb.trx.signMessageV2(e)}catch(e){throw e instanceof Error?new Wt(e.message,e):new Wt(e,Error(e))}}catch(e){throw this.emit(`error`,e),e}})}checkAndGetWallet(){return An(this,void 0,void 0,function*(){if(this.checkIfOpenApp(),yield this._checkWallet(),!this.connected)throw new Vt;let e=this._wallet;if(!e||!e.tronWeb)throw new Vt;return e})}checkForWalletReady(){if(this.checkReadyInterval)return;let e=0,t=Math.floor(this.config.checkTimeout/200),n=()=>An(this,void 0,void 0,function*(){this._wallet&&this._wallet?.tron.ready?(this.checkReadyInterval&&clearInterval(this.checkReadyInterval),this.checkReadyInterval=null,yield this._updateWallet(),this.emit(`connect`,this.address||``)):e>t?(this.checkReadyInterval&&clearInterval(this.checkReadyInterval),this.checkReadyInterval=null):e++});this.checkReadyInterval=setInterval(n,200)}_checkWallet(){if(this.readyState===Qt.Found)return Promise.resolve(!0);if(this._checkPromise)return this._checkPromise;let e=Math.floor(this.config.checkTimeout/100),t=0,n;return this._checkPromise=new Promise(r=>{let i=()=>An(this,void 0,void 0,function*(){t++;let i=On();(i||t>e)&&(n&&clearInterval(n),this._readyState=i?Qt.Found:Qt.NotFound,yield this._updateWallet(),this.emit(`readyStateChanged`,this.readyState),r(i))});n=setInterval(i,100),i()}),this._checkPromise}checkIfOpenApp(){if(this.config.openAppWithDeeplink!==!1&&kn())throw new Bt}setAddress(e){this._address=e}setState(e){e!==this.state&&(this._state=e,this.emit(`stateChanged`,e))}_openAppByDeepLinkIfNeed(){return this.config.openAppWithDeeplink!==!1&&kn()}};typeof window<`u`&&window.Buffer===void 0&&(window.Buffer=m);var Nn=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=`,Pn=class{encode(e){let t=``,n,r,i,a,o,s,c,l=0;for(;l<e.length;)n=e.charCodeAt(l++),r=e.charCodeAt(l++),i=e.charCodeAt(l++),a=n>>2,o=(n&3)<<4|r>>4,s=(r&15)<<2|i>>6,c=i&63,isNaN(r)?s=c=64:isNaN(i)&&(c=64),t=t+Nn.charAt(a)+Nn.charAt(o)+Nn.charAt(s)+Nn.charAt(c);return t}encodeIgnoreUtf8(e){let t=``,n,r,i,a,o,s,c,l=0;for(;l<e.length;)n=e[l++],r=e[l++],i=e[l++],a=n>>2,o=(n&3)<<4|r>>4,s=(r&15)<<2|i>>6,c=i&63,isNaN(r)?s=c=64:isNaN(i)&&(c=64),t=t+Nn.charAt(a)+Nn.charAt(o)+Nn.charAt(s)+Nn.charAt(c);return t}decode(e){let t=``,n,r,i,a,o,s,c,l=0;for(e=e.replace(/[^A-Za-z0-9\+\/\=]/g,``);l<e.length;)a=Nn.indexOf(e.charAt(l++)),o=Nn.indexOf(e.charAt(l++)),s=Nn.indexOf(e.charAt(l++)),c=Nn.indexOf(e.charAt(l++)),n=a<<2|o>>4,r=(o&15)<<4|s>>2,i=(s&3)<<6|c,t+=String.fromCharCode(n),s!=64&&(t+=String.fromCharCode(r)),c!=64&&(t+=String.fromCharCode(i));return this._utf8_decode(t)}decodeToByteArray(e){let t=``,n,r,i,a,o,s,c,l=0;for(e=e.replace(/[^A-Za-z0-9\+\/\=]/g,``);l<e.length;)a=Nn.indexOf(e.charAt(l++)),o=Nn.indexOf(e.charAt(l++)),s=Nn.indexOf(e.charAt(l++)),c=Nn.indexOf(e.charAt(l++)),n=a<<2|o>>4,r=(o&15)<<4|s>>2,i=(s&3)<<6|c,t+=String.fromCharCode(n),s!=64&&(t+=String.fromCharCode(r)),c!=64&&(t+=String.fromCharCode(i));return this._out2ByteArray(t)}_out2ByteArray(e){let t=Array(e.length),n=0,r=0;for(;n<e.length;)r=e.charCodeAt(n),t[n]=r,n++;return t}_utf8_encode(e){e=e.replace(/\r\n/g,`
|
|
3
3
|
`);let t=``;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);r<128?t+=String.fromCharCode(r):r>127&&r<2048?(t+=String.fromCharCode(r>>6|192),t+=String.fromCharCode(r&63|128)):(t+=String.fromCharCode(r>>12|224),t+=String.fromCharCode(r>>6&63|128),t+=String.fromCharCode(r&63|128))}return t}_utf8_decode(e){let t=``,n=0,r=0,i=0,a=0;for(;n<e.length;)r=e.charCodeAt(n),r<128?(t+=String.fromCharCode(r),n++):r>191&&r<224?(i=e.charCodeAt(n+1),t+=String.fromCharCode((r&31)<<6|i&63),n+=2):(i=e.charCodeAt(n+1),a=e.charCodeAt(n+2),t+=String.fromCharCode((r&15)<<12|(i&63)<<6|a&63),n+=3);return t}},Fn=e({base64DecodeFromString:()=>zn,base64EncodeToString:()=>Bn,byte2hexStr:()=>In,byteArray2hexStr:()=>I,bytesToString:()=>Ln,hextoString:()=>Rn});function In(e){if(e<0||e>255)throw Error(`Input must be a byte`);let t=`0123456789ABCDEF`,n=``;return n+=t.charAt(e>>4),n+=t.charAt(e&15),n}function Ln(e){let t=``;for(let n=0;n<e.length;n++){let r=e[n].toString(2),i=r.match(/^1+?(?=0)/);if(i&&r.length===8){let r=i[0].length,a=e[n].toString(2).slice(7-r);for(let t=1;t<r;t++)a+=e[t+n].toString(2).slice(2);t+=String.fromCharCode(parseInt(a,2)),n+=r-1}else t+=String.fromCharCode(e[n])}return t}function Rn(e){let t=e.replace(/^0x/,``).split(``),n=``;for(let e=0;e<t.length/2;e++){let r=`0x${t[e*2]}${t[e*2+1]}`;n+=String.fromCharCode(parseInt(r))}return n}function I(e){let t=``;for(let n=0;n<e.length;n++)t+=In(e[n]);return t}function zn(e){return new Pn().decodeToByteArray(e)}function Bn(e){return new Pn().encodeIgnoreUtf8(e)}var Vn=e({ADDRESS_PREFIX:()=>`41`,ADDRESS_PREFIX_BYTE:()=>65,ADDRESS_PREFIX_REGEX:()=>Hn,ADDRESS_SIZE:()=>34,TRON_BIP39_PATH_INDEX_0:()=>Wn,TRON_BIP39_PATH_PREFIX:()=>Un}),Hn=/^(41)/,Un=`m/44'/195'`,Wn=`m/44'/195'/0'/0/0`,Gn=e({arrayEquals:()=>qn,base64DecodeFromString:()=>zn,base64EncodeToString:()=>Bn,bin2String:()=>Kn,byte2hexStr:()=>In,byteArray2hexStr:()=>I,bytesToString:()=>Ln,getStringType:()=>er,hexChar2byte:()=>Yn,hexStr2byteArray:()=>Zn,hextoString:()=>Rn,isHexChar:()=>Xn,isNumber:()=>$n,strToDate:()=>Qn,stringToBytes:()=>Jn});function Kn(e){return Ln(e)}function qn(e,t,n=!1){if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(n){if(e[r]!=t[r])return!1}else if(JSON.stringify(e[r])!=JSON.stringify(t[r]))return!1;return!0}function Jn(e){let t=[],n=e.length,r;for(let i=0;i<n;i++)r=e.charCodeAt(i),r>=65536&&r<=1114111?(t.push(r>>18&7|240),t.push(r>>12&63|128),t.push(r>>6&63|128),t.push(r&63|128)):r>=2048&&r<=65535?(t.push(r>>12&15|224),t.push(r>>6&63|128),t.push(r&63|128)):r>=128&&r<=2047?(t.push(r>>6&31|192),t.push(r&63|128)):t.push(r&255);return t}function Yn(e){let t;if(e>=`A`&&e<=`F`?t=e.charCodeAt(0)-65+10:e>=`a`&&e<=`f`?t=e.charCodeAt(0)-97+10:e>=`0`&&e<=`9`&&(t=e.charCodeAt(0)-48),typeof t==`number`)return t;throw Error(`The passed hex char is not a valid hex char`)}function Xn(e){return+(e>=`A`&&e<=`F`||e>=`a`&&e<=`f`||e>=`0`&&e<=`9`)}function Zn(e,t=!1){let n=e.length;t&&n%2&&(e=`0${e}`,n++);let r=[],i=0,a=0,o=0;for(let t=0;t<n;t++){let n=e.charAt(t);if(Xn(n))i<<=4,i+=Yn(n),a++,a%2==0&&(r[o++]=i,i=0);else throw Error(`The passed hex char is not a valid hex string`)}return r}function Qn(e){if(!/^\d{4}-\d{2}-\d{2}( \d{2}-\d{2}-\d{2}|)/.test(e))throw Error(`The passed date string is not valid`);let t=e.split(` `),n=t[0].split(`-`),r=parseInt(n[0],10),i=parseInt(n[1],10)-1,a=parseInt(n[2],10);if(t.length>1){let e=t[1].split(`-`),n=parseInt(e[0],10),o=parseInt(e[1],10),s=parseInt(e[2],10);return new Date(r,i,a,n,o,s)}return new Date(r,i,a)}function $n(e){return+(e>=`0`&&e<=`9`)}function er(e){if(e==null||e.length==0||e==``)return-1;let t=0;if(e.length==40)for(;t<40&&Xn(e.charAt(t));t++);if(t==40)return 1;for(t=0;t<e.length&&$n(e.charAt(t));t++);if(t==e.length)return 2;for(t=0;t<e.length;t++)if(e.charAt(t)>` `)return 3;return-1}var tr=e({decode58:()=>or,encode58:()=>ar}),nr=`123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz`,rr={};for(let e=0;e<58;e++)rr[nr.charAt(e)]=e;var ir=58;function ar(e){if(e.length===0)return``;let t,n,r=[0];for(t=0;t<e.length;t++){for(n=0;n<r.length;n++)r[n]<<=8;r[0]+=e[t];let i=0;for(n=0;n<r.length;++n)r[n]+=i,i=r[n]/ir|0,r[n]%=ir;for(;i;)r.push(i%ir),i=i/ir|0}for(t=0;e[t]===0&&t<e.length-1;t++)r.push(0);return r.reverse().map(e=>nr[e]).join(``)}function or(e){if(e.length===0)return[];let t,n,r=[0];for(t=0;t<e.length;t++){let i=e[t];if(!(i in rr))throw Error(`Non-base58 character`);for(n=0;n<r.length;n++)r[n]*=ir;r[0]+=rr[i];let a=0;for(n=0;n<r.length;++n)r[n]+=a,a=r[n]>>8,r[n]&=255;for(;a;)r.push(a&255),a>>=8}for(t=0;e[t]===`1`&&t<e.length-1;t++)r.push(0);return r.reverse()}var sr=`6.13.5`;function cr(e,t,n){let r=t.split(`|`).map(e=>e.trim());for(let n=0;n<r.length;n++)switch(t){case`any`:return;case`bigint`:case`boolean`:case`number`:case`string`:if(typeof e===t)return}let i=Error(`invalid value for type ${t}`);throw i.code=`INVALID_ARGUMENT`,i.argument=`value.${n}`,i.value=e,i}async function lr(e){let t=Object.keys(e);return(await Promise.all(t.map(t=>Promise.resolve(e[t])))).reduce((e,n,r)=>(e[t[r]]=n,e),{})}function L(e,t,n){for(let r in t){let i=t[r],a=n?n[r]:null;a&&cr(i,a,r),Object.defineProperty(e,r,{enumerable:!0,value:i,writable:!1})}}function ur(e){if(e==null)return`null`;if(Array.isArray(e))return`[ `+e.map(ur).join(`, `)+` ]`;if(e instanceof Uint8Array){let t=`0123456789abcdef`,n=`0x`;for(let r=0;r<e.length;r++)n+=t[e[r]>>4],n+=t[e[r]&15];return n}if(typeof e==`object`&&typeof e.toJSON==`function`)return ur(e.toJSON());switch(typeof e){case`boolean`:case`symbol`:return e.toString();case`bigint`:return BigInt(e).toString();case`number`:return e.toString();case`string`:return JSON.stringify(e);case`object`:{let t=Object.keys(e);return t.sort(),`{ `+t.map(t=>`${ur(t)}: ${ur(e[t])}`).join(`, `)+` }`}}return`[ COULD NOT SERIALIZE ]`}function dr(e,t){return e&&e.code===t}function fr(e,t,n){let r=e;{let r=[];if(n){if(`message`in n||`code`in n||`name`in n)throw Error(`value will overwrite populated values: ${ur(n)}`);for(let e in n){if(e===`shortMessage`)continue;let t=n[e];r.push(e+`=`+ur(t))}}r.push(`code=${t}`),r.push(`version=${sr}`),r.length&&(e+=` (`+r.join(`, `)+`)`)}let i;switch(t){case`INVALID_ARGUMENT`:i=TypeError(e);break;case`NUMERIC_FAULT`:case`BUFFER_OVERRUN`:i=RangeError(e);break;default:i=Error(e)}return L(i,{code:t}),n&&Object.assign(i,n),i.shortMessage??L(i,{shortMessage:r}),i}function R(e,t,n,r){if(!e)throw fr(t,n,r)}function z(e,t,n,r){R(e,t,`INVALID_ARGUMENT`,{argument:n,value:r})}function pr(e,t,n){n??=``,n&&=`: `+n,R(e>=t,`missing argument`+n,`MISSING_ARGUMENT`,{count:e,expectedCount:t}),R(e<=t,`too many arguments`+n,`UNEXPECTED_ARGUMENT`,{count:e,expectedCount:t})}var mr=[`NFD`,`NFC`,`NFKD`,`NFKC`].reduce((e,t)=>{try{if(`test`.normalize(t)!==`test`)throw Error(`bad`);if(t===`NFD`&&`é`.normalize(`NFD`)!==`é`)throw Error(`broken`);e.push(t)}catch{}return e},[]);function hr(e){R(mr.indexOf(e)>=0,`platform missing String.prototype.normalize`,`UNSUPPORTED_OPERATION`,{operation:`String.prototype.normalize`,info:{form:e}})}function gr(e,t,n){if(n??=``,e!==t){let e=n,t=`new`;n&&(e+=`.`,t+=` `+n),R(!1,`private constructor; use ${e}from* methods`,`UNSUPPORTED_OPERATION`,{operation:t})}}function _r(e,t,n){if(e instanceof Uint8Array)return n?new Uint8Array(e):e;if(typeof e==`string`&&e.match(/^0x(?:[0-9a-f][0-9a-f])*$/i)){let t=new Uint8Array((e.length-2)/2),n=2;for(let r=0;r<t.length;r++)t[r]=parseInt(e.substring(n,n+2),16),n+=2;return t}z(!1,`invalid BytesLike value`,t||`value`,e)}function B(e,t){return _r(e,t,!1)}function vr(e,t){return _r(e,t,!0)}function yr(e,t){return!(typeof e!=`string`||!e.match(/^0x[0-9A-Fa-f]*$/)||typeof t==`number`&&e.length!==2+2*t||t===!0&&e.length%2!=0)}function br(e){return yr(e,!0)||e instanceof Uint8Array}var xr=`0123456789abcdef`;function V(e){let t=B(e),n=`0x`;for(let e=0;e<t.length;e++){let r=t[e];n+=xr[(r&240)>>4]+xr[r&15]}return n}function Sr(e){return`0x`+e.map(e=>V(e).substring(2)).join(``)}function Cr(e){return yr(e,!0)?(e.length-2)/2:B(e).length}function wr(e,t,n){let r=B(e);return n!=null&&n>r.length&&R(!1,`cannot slice beyond data bounds`,`BUFFER_OVERRUN`,{buffer:r,length:r.length,offset:n}),V(r.slice(t??0,n??r.length))}function Tr(e,t,n){let r=B(e);R(t>=r.length,`padding exceeds data length`,`BUFFER_OVERRUN`,{buffer:new Uint8Array(r),length:t,offset:t+1});let i=new Uint8Array(t);return i.fill(0),n?i.set(r,t-r.length):i.set(r,0),V(i)}function Er(e,t){return Tr(e,t,!0)}var Dr=BigInt(0),Or=BigInt(1),kr=9007199254740991;function Ar(e,t){let n=Pr(e,`value`),r=BigInt(Lr(t,`width`));if(R(n>>r===Dr,`overflow`,`NUMERIC_FAULT`,{operation:`fromTwos`,fault:`overflow`,value:e}),n>>r-Or){let e=(Or<<r)-Or;return-((~n&e)+Or)}return n}function jr(e,t){let n=Nr(e,`value`),r=BigInt(Lr(t,`width`)),i=Or<<r-Or;if(n<Dr){n=-n,R(n<=i,`too low`,`NUMERIC_FAULT`,{operation:`toTwos`,fault:`overflow`,value:e});let t=(Or<<r)-Or;return(~n&t)+Or}return R(n<i,`too high`,`NUMERIC_FAULT`,{operation:`toTwos`,fault:`overflow`,value:e}),n}function Mr(e,t){return Pr(e,`value`)&(Or<<BigInt(Lr(t,`bits`)))-Or}function Nr(e,t){switch(typeof e){case`bigint`:return e;case`number`:return z(Number.isInteger(e),`underflow`,t||`value`,e),z(e>=-9007199254740991&&e<=kr,`overflow`,t||`value`,e),BigInt(e);case`string`:try{if(e===``)throw Error(`empty string`);return e[0]===`-`&&e[1]!==`-`?-BigInt(e.substring(1)):BigInt(e)}catch(n){z(!1,`invalid BigNumberish string: ${n.message}`,t||`value`,e)}}z(!1,`invalid BigNumberish value`,t||`value`,e)}function Pr(e,t){let n=Nr(e,t);return R(n>=Dr,`unsigned value cannot be negative`,`NUMERIC_FAULT`,{fault:`overflow`,operation:`getUint`,value:e}),n}var Fr=`0123456789abcdef`;function Ir(e){if(e instanceof Uint8Array){let t=`0x0`;for(let n of e)t+=Fr[n>>4],t+=Fr[n&15];return BigInt(t)}return Nr(e)}function Lr(e,t){switch(typeof e){case`bigint`:return z(e>=-9007199254740991&&e<=kr,`overflow`,t||`value`,e),Number(e);case`number`:return z(Number.isInteger(e),`underflow`,t||`value`,e),z(e>=-9007199254740991&&e<=kr,`overflow`,t||`value`,e),e;case`string`:try{if(e===``)throw Error(`empty string`);return Lr(BigInt(e),t)}catch(n){z(!1,`invalid numeric string: ${n.message}`,t||`value`,e)}}z(!1,`invalid numeric value`,t||`value`,e)}function Rr(e){return Lr(Ir(e))}function zr(e,t){let n=Pr(e,`value`).toString(16);if(t==null)n.length%2&&(n=`0`+n);else{let r=Lr(t,`width`);for(R(r*2>=n.length,`value exceeds width (${r} bytes)`,`NUMERIC_FAULT`,{operation:`toBeHex`,fault:`overflow`,value:e});n.length<r*2;)n=`0`+n}return`0x`+n}function Br(e){let t=Pr(e,`value`);if(t===Dr)return new Uint8Array([]);let n=t.toString(16);n.length%2&&(n=`0`+n);let r=new Uint8Array(n.length/2);for(let e=0;e<r.length;e++){let t=e*2;r[e]=parseInt(n.substring(t,t+2),16)}return r}function Vr(e){let t=V(br(e)?e:Br(e)).substring(2);for(;t.startsWith(`0`);)t=t.substring(1);return t===``&&(t=`0`),`0x`+t}var Hr=`123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz`,Ur=null;function Wr(e){if(Ur==null){Ur={};for(let e=0;e<58;e++)Ur[Hr[e]]=BigInt(e)}let t=Ur[e];return z(t!=null,`invalid base58 value`,`letter`,e),t}var Gr=BigInt(0),Kr=BigInt(58);function qr(e){let t=B(e),n=Ir(t),r=``;for(;n;)r=Hr[Number(n%Kr)]+r,n/=Kr;for(let e=0;e<t.length&&!t[e];e++)r=Hr[0]+r;return r}function Jr(e){let t=Gr;for(let n=0;n<e.length;n++)t*=Kr,t+=Wr(e[n]);return t}function Yr(e,t,n,r,i){z(!1,`invalid codepoint at offset ${t}; ${e}`,`bytes`,n)}function Xr(e,t,n,r,i){if(e===`BAD_PREFIX`||e===`UNEXPECTED_CONTINUE`){let e=0;for(let r=t+1;r<n.length&&n[r]>>6==2;r++)e++;return e}return e===`OVERRUN`?n.length-t-1:0}function Zr(e,t,n,r,i){return e===`OVERLONG`?(z(typeof i==`number`,`invalid bad code point for replacement`,`badCodepoint`,i),r.push(i),0):(r.push(65533),Xr(e,t,n,r,i))}var Qr=Object.freeze({error:Yr,ignore:Xr,replace:Zr});function $r(e,t){t??=Qr.error;let n=B(e,`bytes`),r=[],i=0;for(;i<n.length;){let e=n[i++];if(!(e>>7)){r.push(e);continue}let a=null,o=null;if((e&224)==192)a=1,o=127;else if((e&240)==224)a=2,o=2047;else if((e&248)==240)a=3,o=65535;else{(e&192)==128?i+=t(`UNEXPECTED_CONTINUE`,i-1,n,r):i+=t(`BAD_PREFIX`,i-1,n,r);continue}if(i-1+a>=n.length){i+=t(`OVERRUN`,i-1,n,r);continue}let s=e&(1<<8-a-1)-1;for(let e=0;e<a;e++){let e=n[i];if((e&192)!=128){i+=t(`MISSING_CONTINUE`,i,n,r),s=null;break}s=s<<6|e&63,i++}if(s!==null){if(s>1114111){i+=t(`OUT_OF_RANGE`,i-1-a,n,r,s);continue}if(s>=55296&&s<=57343){i+=t(`UTF16_SURROGATE`,i-1-a,n,r,s);continue}if(s<=o){i+=t(`OVERLONG`,i-1-a,n,r,s);continue}r.push(s)}}return r}function ei(e,t){z(typeof e==`string`,`invalid string value`,`str`,e),t!=null&&(hr(t),e=e.normalize(t));let n=[];for(let t=0;t<e.length;t++){let r=e.charCodeAt(t);if(r<128)n.push(r);else if(r<2048)n.push(r>>6|192),n.push(r&63|128);else if((r&64512)==55296){t++;let i=e.charCodeAt(t);z(t<e.length&&(i&64512)==56320,`invalid surrogate pair`,`str`,e);let a=65536+((r&1023)<<10)+(i&1023);n.push(a>>18|240),n.push(a>>12&63|128),n.push(a>>6&63|128),n.push(a&63|128)}else n.push(r>>12|224),n.push(r>>6&63|128),n.push(r&63|128)}return new Uint8Array(n)}function ti(e){return e.map(e=>e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10&1023)+55296,(e&1023)+56320))).join(``)}function ni(e,t){return ti($r(e,t))}function ri(e){let t=e.toString(16);for(;t.length<2;)t=`0`+t;return`0x`+t}function ii(e,t,n){let r=0;for(let i=0;i<n;i++)r=r*256+e[t+i];return r}function ai(e,t,n,r){let i=[];for(;n<t+1+r;){let a=oi(e,n);i.push(a.result),n+=a.consumed,R(n<=t+1+r,`child data too short`,`BUFFER_OVERRUN`,{buffer:e,length:r,offset:t})}return{consumed:1+r,result:i}}function oi(e,t){R(e.length!==0,`data too short`,`BUFFER_OVERRUN`,{buffer:e,length:0,offset:1});let n=t=>{R(t<=e.length,`data short segment too short`,`BUFFER_OVERRUN`,{buffer:e,length:e.length,offset:t})};if(e[t]>=248){let r=e[t]-247;n(t+1+r);let i=ii(e,t+1,r);return n(t+1+r+i),ai(e,t,t+1+r,r+i)}if(e[t]>=192){let r=e[t]-192;return n(t+1+r),ai(e,t,t+1,r)}if(e[t]>=184){let r=e[t]-183;n(t+1+r);let i=ii(e,t+1,r);n(t+1+r+i);let a=V(e.slice(t+1+r,t+1+r+i));return{consumed:1+r+i,result:a}}if(e[t]>=128){let r=e[t]-128;n(t+1+r);let i=V(e.slice(t+1,t+1+r));return{consumed:1+r,result:i}}return{consumed:1,result:ri(e[t])}}function si(e){let t=B(e,`data`),n=oi(t,0);return z(n.consumed===t.length,`unexpected junk after rlp payload`,`data`,e),n.result}function ci(e){let t=[];for(;e;)t.unshift(e&255),e>>=8;return t}function li(e){if(Array.isArray(e)){let t=[];if(e.forEach(function(e){t=t.concat(li(e))}),t.length<=55)return t.unshift(192+t.length),t;let n=ci(t.length);return n.unshift(247+n.length),n.concat(t)}let t=Array.prototype.slice.call(B(e,`object`));if(t.length===1&&t[0]<=127)return t;if(t.length<=55)return t.unshift(128+t.length),t;let n=ci(t.length);return n.unshift(183+n.length),n.concat(t)}var ui=`0123456789abcdef`;function di(e){let t=`0x`;for(let n of li(e))t+=ui[n>>4],t+=ui[n&15];return t}function fi(e){let t=B(e,`randomBytes`);t[6]=t[6]&15|64,t[8]=t[8]&63|128;let n=V(t);return[n.substring(2,10),n.substring(10,14),n.substring(14,18),n.substring(18,22),n.substring(22,34)].join(`-`)}var pi=new Uint8Array(32),mi=[`then`],hi={},gi=new WeakMap;function _i(e){return gi.get(e)}function vi(e,t){gi.set(e,t)}function yi(e,t){let n=Error(`deferred error during ABI decoding triggered accessing ${e}`);throw n.error=t,n}function bi(e,t,n){return e.indexOf(null)>=0?t.map((e,t)=>e instanceof xi?bi(_i(e),e,n):e):e.reduce((e,r,i)=>{let a=t.getValue(r);return r in e||(n&&a instanceof xi&&(a=bi(_i(a),a,n)),e[r]=a),e},{})}var xi=class e extends Array{#e;constructor(...e){let t=e[0],n=e[1],r=(e[2]||[]).slice(),i=!0;t!==hi&&(n=e,r=[],i=!1),super(n.length),n.forEach((e,t)=>{this[t]=e});let a=r.reduce((e,t)=>(typeof t==`string`&&e.set(t,(e.get(t)||0)+1),e),new Map);if(vi(this,Object.freeze(n.map((e,t)=>{let n=r[t];return n!=null&&a.get(n)===1?n:null}))),this.#e=[],this.#e??this.#e,!i)return;Object.freeze(this);let o=new Proxy(this,{get:(e,t,n)=>{if(typeof t==`string`){if(t.match(/^[0-9]+$/)){let n=Lr(t,`%index`);if(n<0||n>=this.length)throw RangeError(`out of result range`);let r=e[n];return r instanceof Error&&yi(`index ${n}`,r),r}if(mi.indexOf(t)>=0)return Reflect.get(e,t,n);let r=e[t];if(r instanceof Function)return function(...t){return r.apply(this===n?e:this,t)};if(!(t in e))return e.getValue.apply(this===n?e:this,[t])}return Reflect.get(e,t,n)}});return vi(o,_i(this)),o}toArray(t){let n=[];return this.forEach((r,i)=>{r instanceof Error&&yi(`index ${i}`,r),t&&r instanceof e&&(r=r.toArray(t)),n.push(r)}),n}toObject(e){let t=_i(this);return t.reduce((n,r,i)=>(R(r!=null,`value at index ${i} unnamed`,`UNSUPPORTED_OPERATION`,{operation:`toObject()`}),bi(t,this,e)),{})}slice(t,n){t??=0,t<0&&(t+=this.length,t<0&&(t=0)),n??=this.length,n<0&&(n+=this.length,n<0&&(n=0)),n>this.length&&(n=this.length);let r=_i(this),i=[],a=[];for(let e=t;e<n;e++)i.push(this[e]),a.push(r[e]);return new e(hi,i,a)}filter(t,n){let r=_i(this),i=[],a=[];for(let e=0;e<this.length;e++){let o=this[e];o instanceof Error&&yi(`index ${e}`,o),t.call(n,o,e,this)&&(i.push(o),a.push(r[e]))}return new e(hi,i,a)}map(e,t){let n=[];for(let r=0;r<this.length;r++){let i=this[r];i instanceof Error&&yi(`index ${r}`,i),n.push(e.call(t,i,r,this))}return n}getValue(e){let t=_i(this).indexOf(e);if(t===-1)return;let n=this[t];return n instanceof Error&&yi(`property ${JSON.stringify(e)}`,n.error),n}static fromItems(t,n){return new e(hi,t,n)}};function Si(e){let t=Br(e);return R(t.length<=32,`value out-of-bounds`,`BUFFER_OVERRUN`,{buffer:t,length:32,offset:t.length}),t.length!==32&&(t=vr(Sr([pi.slice(t.length%32),t]))),t}var Ci=class{name;type;localName;dynamic;constructor(e,t,n,r){L(this,{name:e,type:t,localName:n,dynamic:r},{name:`string`,type:`string`,localName:`string`,dynamic:`boolean`})}_throwError(e,t){z(!1,e,this.localName,t)}},wi=class{#e;#t;constructor(){this.#e=[],this.#t=0}get data(){return Sr(this.#e)}get length(){return this.#t}#n(e){return this.#e.push(e),this.#t+=e.length,e.length}appendWriter(e){return this.#n(vr(e.data))}writeBytes(e){let t=vr(e),n=t.length%32;return n&&(t=vr(Sr([t,pi.slice(n)]))),this.#n(t)}writeValue(e){return this.#n(Si(e))}writeUpdatableValue(){let e=this.#e.length;return this.#e.push(pi),this.#t+=32,t=>{this.#e[e]=Si(t)}}},Ti=class e{allowLoose;#e;#t;#n;#r;#i;constructor(e,t,n){L(this,{allowLoose:!!t}),this.#e=vr(e),this.#n=0,this.#r=null,this.#i=n??1024,this.#t=0}get data(){return V(this.#e)}get dataLength(){return this.#e.length}get consumed(){return this.#t}get bytes(){return new Uint8Array(this.#e)}#a(e){if(this.#r)return this.#r.#a(e);this.#n+=e,R(this.#i<1||this.#n<=this.#i*this.dataLength,`compressed ABI data exceeds inflation ratio of ${this.#i} ( see: https:/\/github.com/ethers-io/ethers.js/issues/4537 )`,`BUFFER_OVERRUN`,{buffer:vr(this.#e),offset:this.#t,length:e,info:{bytesRead:this.#n,dataLength:this.dataLength}})}#o(e,t,n){let r=Math.ceil(t/32)*32;return this.#t+r>this.#e.length&&(this.allowLoose&&n&&this.#t+t<=this.#e.length?r=t:R(!1,`data out-of-bounds`,`BUFFER_OVERRUN`,{buffer:vr(this.#e),length:this.#e.length,offset:this.#t+r})),this.#e.slice(this.#t,this.#t+r)}subReader(t){let n=new e(this.#e.slice(this.#t+t),this.allowLoose,this.#i);return n.#r=this,n}readBytes(e,t){let n=this.#o(0,e,!!t);return this.#a(e),this.#t+=n.length,n.slice(0,e)}readValue(){return Ir(this.readBytes(32))}readIndex(){return Rr(this.readBytes(32))}};function Ei(e){if(!Number.isSafeInteger(e)||e<0)throw Error(`Wrong positive integer: ${e}`)}function Di(e,...t){if(!(e instanceof Uint8Array))throw Error(`Expected Uint8Array`);if(t.length>0&&!t.includes(e.length))throw Error(`Expected Uint8Array of length ${t}, not of length=${e.length}`)}function Oi(e){if(typeof e!=`function`||typeof e.create!=`function`)throw Error(`Hash should be wrapped by utils.wrapConstructor`);Ei(e.outputLen),Ei(e.blockLen)}function ki(e,t=!0){if(e.destroyed)throw Error(`Hash instance has been destroyed`);if(t&&e.finished)throw Error(`Hash#digest() has already been called`)}function Ai(e,t){Di(e);let n=t.outputLen;if(e.length<n)throw Error(`digestInto() expects output buffer of length at least ${n}`)}var ji=typeof globalThis==`object`&&`crypto`in globalThis?globalThis.crypto:void 0,Mi=e=>e instanceof Uint8Array,Ni=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4)),Pi=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),Fi=(e,t)=>e<<32-t|e>>>t;if(new Uint8Array(new Uint32Array([287454020]).buffer)[0]!==68)throw Error(`Non little-endian hardware is not supported`);var Ii=async()=>{};async function Li(e,t,n){let r=Date.now();for(let i=0;i<e;i++){n(i);let e=Date.now()-r;e>=0&&e<t||(await Ii(),r+=e)}}function Ri(e){if(typeof e!=`string`)throw Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function zi(e){if(typeof e==`string`&&(e=Ri(e)),!Mi(e))throw Error(`expected Uint8Array, got ${typeof e}`);return e}function Bi(...e){let t=new Uint8Array(e.reduce((e,t)=>e+t.length,0)),n=0;return e.forEach(e=>{if(!Mi(e))throw Error(`Uint8Array expected`);t.set(e,n),n+=e.length}),t}var Vi=class{clone(){return this._cloneInto()}},Hi={}.toString;function Ui(e,t){if(t!==void 0&&Hi.call(t)!==`[object Object]`)throw Error(`Options should be object or undefined`);return Object.assign(e,t)}function Wi(e){let t=t=>e().update(zi(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function Gi(e=32){if(ji&&typeof ji.getRandomValues==`function`)return ji.getRandomValues(new Uint8Array(e));throw Error(`crypto.getRandomValues must be defined`)}var Ki=class extends Vi{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,Oi(e);let n=zi(t);if(this.iHash=e.create(),typeof this.iHash.update!=`function`)throw Error(`Expected instance of class which extends utils.Hash`);this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let r=this.blockLen,i=new Uint8Array(r);i.set(n.length>r?e.create().update(n).digest():n);for(let e=0;e<i.length;e++)i[e]^=54;this.iHash.update(i),this.oHash=e.create();for(let e=0;e<i.length;e++)i[e]^=106;this.oHash.update(i),i.fill(0)}update(e){return ki(this),this.iHash.update(e),this}digestInto(e){ki(this),Di(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||=Object.create(Object.getPrototypeOf(this),{});let{oHash:t,iHash:n,finished:r,destroyed:i,blockLen:a,outputLen:o}=this;return e=e,e.finished=r,e.destroyed=i,e.blockLen=a,e.outputLen=o,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},qi=(e,t,n)=>new Ki(e,t).update(n).digest();qi.create=(e,t)=>new Ki(e,t);function Ji(e,t,n,r){Oi(e);let{c:i,dkLen:a,asyncTick:o}=Ui({dkLen:32,asyncTick:10},r);if(Ei(i),Ei(a),Ei(o),i<1)throw Error(`PBKDF2: iterations (c) should be >= 1`);let s=zi(t),c=zi(n),l=new Uint8Array(a),u=qi.create(e,s);return{c:i,dkLen:a,asyncTick:o,DK:l,PRF:u,PRFSalt:u._cloneInto().update(c)}}function Yi(e,t,n,r,i){return e.destroy(),t.destroy(),r&&r.destroy(),i.fill(0),n}function Xi(e,t,n,r){let{c:i,dkLen:a,DK:o,PRF:s,PRFSalt:c}=Ji(e,t,n,r),l,u=new Uint8Array(4),d=Pi(u),f=new Uint8Array(s.outputLen);for(let e=1,t=0;t<a;e++,t+=s.outputLen){let n=o.subarray(t,t+s.outputLen);d.setInt32(0,e,!1),(l=c._cloneInto(l)).update(u).digestInto(f),n.set(f.subarray(0,n.length));for(let e=1;e<i;e++){s._cloneInto(l).update(f).digestInto(f);for(let e=0;e<n.length;e++)n[e]^=f[e]}}return Yi(s,c,o,l,f)}function Zi(e,t,n,r){if(typeof e.setBigUint64==`function`)return e.setBigUint64(t,n,r);let i=BigInt(32),a=BigInt(4294967295),o=Number(n>>i&a),s=Number(n&a),c=r?4:0,l=r?0:4;e.setUint32(t+c,o,r),e.setUint32(t+l,s,r)}var Qi=class extends Vi{constructor(e,t,n,r){super(),this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=r,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=Pi(this.buffer)}update(e){ki(this);let{view:t,buffer:n,blockLen:r}=this;e=zi(e);let i=e.length;for(let a=0;a<i;){let o=Math.min(r-this.pos,i-a);if(o===r){let t=Pi(e);for(;r<=i-a;a+=r)this.process(t,a);continue}n.set(e.subarray(a,a+o),this.pos),this.pos+=o,a+=o,this.pos===r&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){ki(this),Ai(e,this),this.finished=!0;let{buffer:t,view:n,blockLen:r,isLE:i}=this,{pos:a}=this;t[a++]=128,this.buffer.subarray(a).fill(0),this.padOffset>r-a&&(this.process(n,0),a=0);for(let e=a;e<r;e++)t[e]=0;Zi(n,r-8,BigInt(this.length*8),i),this.process(n,0);let o=Pi(e),s=this.outputLen;if(s%4)throw Error(`_sha2: outputLen should be aligned to 32bit`);let c=s/4,l=this.get();if(c>l.length)throw Error(`_sha2: outputLen bigger than state`);for(let e=0;e<c;e++)o.setUint32(4*e,l[e],i)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||=new this.constructor,e.set(...this.get());let{blockLen:t,buffer:n,length:r,finished:i,destroyed:a,pos:o}=this;return e.length=r,e.pos=o,e.finished=i,e.destroyed=a,r%t&&e.buffer.set(n),e}},$i=(e,t,n)=>e&t^~e&n,ea=(e,t,n)=>e&t^e&n^t&n,ta=new Uint32Array([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]),na=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),ra=new Uint32Array(64),ia=class extends Qi{constructor(){super(64,32,8,!1),this.A=na[0]|0,this.B=na[1]|0,this.C=na[2]|0,this.D=na[3]|0,this.E=na[4]|0,this.F=na[5]|0,this.G=na[6]|0,this.H=na[7]|0}get(){let{A:e,B:t,C:n,D:r,E:i,F:a,G:o,H:s}=this;return[e,t,n,r,i,a,o,s]}set(e,t,n,r,i,a,o,s){this.A=e|0,this.B=t|0,this.C=n|0,this.D=r|0,this.E=i|0,this.F=a|0,this.G=o|0,this.H=s|0}process(e,t){for(let n=0;n<16;n++,t+=4)ra[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){let t=ra[e-15],n=ra[e-2],r=Fi(t,7)^Fi(t,18)^t>>>3,i=Fi(n,17)^Fi(n,19)^n>>>10;ra[e]=i+ra[e-7]+r+ra[e-16]|0}let{A:n,B:r,C:i,D:a,E:o,F:s,G:c,H:l}=this;for(let e=0;e<64;e++){let t=Fi(o,6)^Fi(o,11)^Fi(o,25),u=l+t+$i(o,s,c)+ta[e]+ra[e]|0,d=(Fi(n,2)^Fi(n,13)^Fi(n,22))+ea(n,r,i)|0;l=c,c=s,s=o,o=a+u|0,a=i,i=r,r=n,n=u+d|0}n=n+this.A|0,r=r+this.B|0,i=i+this.C|0,a=a+this.D|0,o=o+this.E|0,s=s+this.F|0,c=c+this.G|0,l=l+this.H|0,this.set(n,r,i,a,o,s,c,l)}roundClean(){ra.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}},aa=Wi(()=>new ia),oa=BigInt(2**32-1),sa=BigInt(32);function ca(e,t=!1){return t?{h:Number(e&oa),l:Number(e>>sa&oa)}:{h:Number(e>>sa&oa)|0,l:Number(e&oa)|0}}function la(e,t=!1){let n=new Uint32Array(e.length),r=new Uint32Array(e.length);for(let i=0;i<e.length;i++){let{h:a,l:o}=ca(e[i],t);[n[i],r[i]]=[a,o]}return[n,r]}var ua=(e,t)=>BigInt(e>>>0)<<sa|BigInt(t>>>0),da=(e,t,n)=>e>>>n,fa=(e,t,n)=>e<<32-n|t>>>n,pa=(e,t,n)=>e>>>n|t<<32-n,ma=(e,t,n)=>e<<32-n|t>>>n,ha=(e,t,n)=>e<<64-n|t>>>n-32,ga=(e,t,n)=>e>>>n-32|t<<64-n,_a=(e,t)=>t,va=(e,t)=>e,ya=(e,t,n)=>e<<n|t>>>32-n,ba=(e,t,n)=>t<<n|e>>>32-n,xa=(e,t,n)=>t<<n-32|e>>>64-n,Sa=(e,t,n)=>e<<n-32|t>>>64-n;function Ca(e,t,n,r){let i=(t>>>0)+(r>>>0);return{h:e+n+(i/2**32|0)|0,l:i|0}}var H={fromBig:ca,split:la,toBig:ua,shrSH:da,shrSL:fa,rotrSH:pa,rotrSL:ma,rotrBH:ha,rotrBL:ga,rotr32H:_a,rotr32L:va,rotlSH:ya,rotlSL:ba,rotlBH:xa,rotlBL:Sa,add:Ca,add3L:(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),add3H:(e,t,n,r)=>t+n+r+(e/2**32|0)|0,add4L:(e,t,n,r)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0),add4H:(e,t,n,r,i)=>t+n+r+i+(e/2**32|0)|0,add5H:(e,t,n,r,i,a)=>t+n+r+i+a+(e/2**32|0)|0,add5L:(e,t,n,r,i)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0)+(i>>>0)},[wa,Ta]=H.split(`0x428a2f98d728ae22.0x7137449123ef65cd.0xb5c0fbcfec4d3b2f.0xe9b5dba58189dbbc.0x3956c25bf348b538.0x59f111f1b605d019.0x923f82a4af194f9b.0xab1c5ed5da6d8118.0xd807aa98a3030242.0x12835b0145706fbe.0x243185be4ee4b28c.0x550c7dc3d5ffb4e2.0x72be5d74f27b896f.0x80deb1fe3b1696b1.0x9bdc06a725c71235.0xc19bf174cf692694.0xe49b69c19ef14ad2.0xefbe4786384f25e3.0x0fc19dc68b8cd5b5.0x240ca1cc77ac9c65.0x2de92c6f592b0275.0x4a7484aa6ea6e483.0x5cb0a9dcbd41fbd4.0x76f988da831153b5.0x983e5152ee66dfab.0xa831c66d2db43210.0xb00327c898fb213f.0xbf597fc7beef0ee4.0xc6e00bf33da88fc2.0xd5a79147930aa725.0x06ca6351e003826f.0x142929670a0e6e70.0x27b70a8546d22ffc.0x2e1b21385c26c926.0x4d2c6dfc5ac42aed.0x53380d139d95b3df.0x650a73548baf63de.0x766a0abb3c77b2a8.0x81c2c92e47edaee6.0x92722c851482353b.0xa2bfe8a14cf10364.0xa81a664bbc423001.0xc24b8b70d0f89791.0xc76c51a30654be30.0xd192e819d6ef5218.0xd69906245565a910.0xf40e35855771202a.0x106aa07032bbd1b8.0x19a4c116b8d2d0c8.0x1e376c085141ab53.0x2748774cdf8eeb99.0x34b0bcb5e19b48a8.0x391c0cb3c5c95a63.0x4ed8aa4ae3418acb.0x5b9cca4f7763e373.0x682e6ff3d6b2b8a3.0x748f82ee5defb2fc.0x78a5636f43172f60.0x84c87814a1f0ab72.0x8cc702081a6439ec.0x90befffa23631e28.0xa4506cebde82bde9.0xbef9a3f7b2c67915.0xc67178f2e372532b.0xca273eceea26619c.0xd186b8c721c0c207.0xeada7dd6cde0eb1e.0xf57d4f7fee6ed178.0x06f067aa72176fba.0x0a637dc5a2c898a6.0x113f9804bef90dae.0x1b710b35131c471b.0x28db77f523047d84.0x32caab7b40c72493.0x3c9ebe0a15c9bebc.0x431d67c49c100d4c.0x4cc5d4becb3e42b6.0x597f299cfc657e2a.0x5fcb6fab3ad6faec.0x6c44198c4a475817`.split(`.`).map(e=>BigInt(e))),Ea=new Uint32Array(80),Da=new Uint32Array(80),Oa=class extends Qi{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){let{Ah:e,Al:t,Bh:n,Bl:r,Ch:i,Cl:a,Dh:o,Dl:s,Eh:c,El:l,Fh:u,Fl:d,Gh:f,Gl:p,Hh:m,Hl:h}=this;return[e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h]}set(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){this.Ah=e|0,this.Al=t|0,this.Bh=n|0,this.Bl=r|0,this.Ch=i|0,this.Cl=a|0,this.Dh=o|0,this.Dl=s|0,this.Eh=c|0,this.El=l|0,this.Fh=u|0,this.Fl=d|0,this.Gh=f|0,this.Gl=p|0,this.Hh=m|0,this.Hl=h|0}process(e,t){for(let n=0;n<16;n++,t+=4)Ea[n]=e.getUint32(t),Da[n]=e.getUint32(t+=4);for(let e=16;e<80;e++){let t=Ea[e-15]|0,n=Da[e-15]|0,r=H.rotrSH(t,n,1)^H.rotrSH(t,n,8)^H.shrSH(t,n,7),i=H.rotrSL(t,n,1)^H.rotrSL(t,n,8)^H.shrSL(t,n,7),a=Ea[e-2]|0,o=Da[e-2]|0,s=H.rotrSH(a,o,19)^H.rotrBH(a,o,61)^H.shrSH(a,o,6),c=H.rotrSL(a,o,19)^H.rotrBL(a,o,61)^H.shrSL(a,o,6),l=H.add4L(i,c,Da[e-7],Da[e-16]),u=H.add4H(l,r,s,Ea[e-7],Ea[e-16]);Ea[e]=u|0,Da[e]=l|0}let{Ah:n,Al:r,Bh:i,Bl:a,Ch:o,Cl:s,Dh:c,Dl:l,Eh:u,El:d,Fh:f,Fl:p,Gh:m,Gl:h,Hh:g,Hl:_}=this;for(let e=0;e<80;e++){let t=H.rotrSH(u,d,14)^H.rotrSH(u,d,18)^H.rotrBH(u,d,41),v=H.rotrSL(u,d,14)^H.rotrSL(u,d,18)^H.rotrBL(u,d,41),y=u&f^~u&m,b=d&p^~d&h,x=H.add5L(_,v,b,Ta[e],Da[e]),S=H.add5H(x,g,t,y,wa[e],Ea[e]),ee=x|0,te=H.rotrSH(n,r,28)^H.rotrBH(n,r,34)^H.rotrBH(n,r,39),C=H.rotrSL(n,r,28)^H.rotrBL(n,r,34)^H.rotrBL(n,r,39),ne=n&i^n&o^i&o,re=r&a^r&s^a&s;g=m|0,_=h|0,m=f|0,h=p|0,f=u|0,p=d|0,{h:u,l:d}=H.add(c|0,l|0,S|0,ee|0),c=o|0,l=s|0,o=i|0,s=a|0,i=n|0,a=r|0;let w=H.add3L(ee,C,re);n=H.add3H(w,S,te,ne),r=w|0}({h:n,l:r}=H.add(this.Ah|0,this.Al|0,n|0,r|0)),{h:i,l:a}=H.add(this.Bh|0,this.Bl|0,i|0,a|0),{h:o,l:s}=H.add(this.Ch|0,this.Cl|0,o|0,s|0),{h:c,l}=H.add(this.Dh|0,this.Dl|0,c|0,l|0),{h:u,l:d}=H.add(this.Eh|0,this.El|0,u|0,d|0),{h:f,l:p}=H.add(this.Fh|0,this.Fl|0,f|0,p|0),{h:m,l:h}=H.add(this.Gh|0,this.Gl|0,m|0,h|0),{h:g,l:_}=H.add(this.Hh|0,this.Hl|0,g|0,_|0),this.set(n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_)}roundClean(){Ea.fill(0),Da.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}},ka=Wi(()=>new Oa);c();function Aa(){if(typeof self<`u`)return self;if(typeof window<`u`)return window;if(l!==void 0)return l;throw Error(`unable to locate global object`)}var ja=Aa(),Ma=ja.crypto||ja.msCrypto;function Na(e){switch(e){case`sha256`:return aa.create();case`sha512`:return ka.create()}z(!1,`invalid hashing algorithm name`,`algorithm`,e)}function Pa(e,t){let n={sha256:aa,sha512:ka}[e];return z(n!=null,`invalid hmac algorithm`,`algorithm`,e),qi.create(n,t)}function Fa(e,t,n,r,i){let a={sha256:aa,sha512:ka}[i];return z(a!=null,`invalid pbkdf2 algorithm`,`algorithm`,i),Xi(a,e,t,{c:n,dkLen:r})}function Ia(e){R(Ma!=null,`platform does not support secure random numbers`,`UNSUPPORTED_OPERATION`,{operation:`randomBytes`}),z(Number.isInteger(e)&&e>0&&e<=1024,`invalid length`,`length`,e);let t=new Uint8Array(e);return Ma.getRandomValues(t),t}var La=!1,Ra=function(e,t,n){return Pa(e,t).update(n).digest()},za=Ra;function Ba(e,t,n){let r=B(t,`key`),i=B(n,`data`);return V(za(e,r,i))}Ba._=Ra,Ba.lock=function(){La=!0},Ba.register=function(e){if(La)throw Error(`computeHmac is locked`);za=e},Object.freeze(Ba);var[Va,Ha,Ua]=[[],[],[]],Wa=BigInt(0),Ga=BigInt(1),Ka=BigInt(2),qa=BigInt(7),Ja=BigInt(256),Ya=BigInt(113);for(let e=0,t=Ga,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],Va.push(2*(5*r+n)),Ha.push((e+1)*(e+2)/2%64);let i=Wa;for(let e=0;e<7;e++)t=(t<<Ga^(t>>qa)*Ya)%Ja,t&Ka&&(i^=Ga<<(Ga<<BigInt(e))-Ga);Ua.push(i)}var[Xa,Za]=la(Ua,!0),Qa=(e,t,n)=>n>32?xa(e,t,n):ya(e,t,n),$a=(e,t,n)=>n>32?Sa(e,t,n):ba(e,t,n);function eo(e,t=24){let n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let t=0;t<10;t++)n[t]=e[t]^e[t+10]^e[t+20]^e[t+30]^e[t+40];for(let t=0;t<10;t+=2){let r=(t+8)%10,i=(t+2)%10,a=n[i],o=n[i+1],s=Qa(a,o,1)^n[r],c=$a(a,o,1)^n[r+1];for(let n=0;n<50;n+=10)e[t+n]^=s,e[t+n+1]^=c}let t=e[2],i=e[3];for(let n=0;n<24;n++){let r=Ha[n],a=Qa(t,i,r),o=$a(t,i,r),s=Va[n];t=e[s],i=e[s+1],e[s]=a,e[s+1]=o}for(let t=0;t<50;t+=10){for(let r=0;r<10;r++)n[r]=e[t+r];for(let r=0;r<10;r++)e[t+r]^=~n[(r+2)%10]&n[(r+4)%10]}e[0]^=Xa[r],e[1]^=Za[r]}n.fill(0)}var to=class e extends Vi{constructor(e,t,n,r=!1,i=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=n,this.enableXOF=r,this.rounds=i,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,Ei(n),0>=this.blockLen||this.blockLen>=200)throw Error(`Sha3 supports only keccak-f1600 function`);this.state=new Uint8Array(200),this.state32=Ni(this.state)}keccak(){eo(this.state32,this.rounds),this.posOut=0,this.pos=0}update(e){ki(this);let{blockLen:t,state:n}=this;e=zi(e);let r=e.length;for(let i=0;i<r;){let a=Math.min(t-this.pos,r-i);for(let t=0;t<a;t++)n[this.pos++]^=e[i++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;let{state:e,suffix:t,pos:n,blockLen:r}=this;e[n]^=t,t&128&&n===r-1&&this.keccak(),e[r-1]^=128,this.keccak()}writeInto(e){ki(this,!1),Di(e),this.finish();let t=this.state,{blockLen:n}=this;for(let r=0,i=e.length;r<i;){this.posOut>=n&&this.keccak();let a=Math.min(n-this.posOut,i-r);e.set(t.subarray(this.posOut,this.posOut+a),r),this.posOut+=a,r+=a}return e}xofInto(e){if(!this.enableXOF)throw Error(`XOF is not possible for this instance`);return this.writeInto(e)}xof(e){return Ei(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(Ai(e,this),this.finished)throw Error(`digest() was already called`);return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(t){let{blockLen:n,suffix:r,outputLen:i,rounds:a,enableXOF:o}=this;return t||=new e(n,r,i,o,a),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=a,t.suffix=r,t.outputLen=i,t.enableXOF=o,t.destroyed=this.destroyed,t}},no=((e,t,n)=>Wi(()=>new to(t,e,n)))(1,136,32),ro=!1,io=function(e){return no(e)},ao=io;function U(e){let t=B(e,`data`);return V(ao(t))}U._=io,U.lock=function(){ro=!0},U.register=function(e){if(ro)throw TypeError(`keccak256 is locked`);ao=e},Object.freeze(U);var oo=new Uint8Array([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),so=Uint8Array.from({length:16},(e,t)=>t),co=so.map(e=>(9*e+5)%16),lo=[so],uo=[co];for(let e=0;e<4;e++)for(let t of[lo,uo])t.push(t[e].map(e=>oo[e]));var fo=[[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8],[12,13,11,15,6,9,9,7,12,15,11,13,7,8,7,7],[13,15,14,11,7,7,6,8,13,14,13,12,5,5,6,9],[14,11,12,14,8,6,5,5,15,12,15,14,9,9,8,6],[15,12,13,13,9,5,8,6,14,11,12,11,8,6,5,5]].map(e=>new Uint8Array(e)),po=lo.map((e,t)=>e.map(e=>fo[t][e])),mo=uo.map((e,t)=>e.map(e=>fo[t][e])),ho=new Uint32Array([0,1518500249,1859775393,2400959708,2840853838]),go=new Uint32Array([1352829926,1548603684,1836072691,2053994217,0]),_o=(e,t)=>e<<t|e>>>32-t;function vo(e,t,n,r){return e===0?t^n^r:e===1?t&n|~t&r:e===2?(t|~n)^r:e===3?t&r|n&~r:t^(n|~r)}var yo=new Uint32Array(16),bo=class extends Qi{constructor(){super(64,20,8,!0),this.h0=1732584193,this.h1=-271733879,this.h2=-1732584194,this.h3=271733878,this.h4=-1009589776}get(){let{h0:e,h1:t,h2:n,h3:r,h4:i}=this;return[e,t,n,r,i]}set(e,t,n,r,i){this.h0=e|0,this.h1=t|0,this.h2=n|0,this.h3=r|0,this.h4=i|0}process(e,t){for(let n=0;n<16;n++,t+=4)yo[n]=e.getUint32(t,!0);let n=this.h0|0,r=n,i=this.h1|0,a=i,o=this.h2|0,s=o,c=this.h3|0,l=c,u=this.h4|0,d=u;for(let e=0;e<5;e++){let t=4-e,f=ho[e],p=go[e],m=lo[e],h=uo[e],g=po[e],_=mo[e];for(let t=0;t<16;t++){let r=_o(n+vo(e,i,o,c)+yo[m[t]]+f,g[t])+u|0;n=u,u=c,c=_o(o,10)|0,o=i,i=r}for(let e=0;e<16;e++){let n=_o(r+vo(t,a,s,l)+yo[h[e]]+p,_[e])+d|0;r=d,d=l,l=_o(s,10)|0,s=a,a=n}}this.set(this.h1+o+l|0,this.h2+c+d|0,this.h3+u+r|0,this.h4+n+a|0,this.h0+i+s|0)}roundClean(){yo.fill(0)}destroy(){this.destroyed=!0,this.buffer.fill(0),this.set(0,0,0,0,0)}},xo=Wi(()=>new bo),So=!1,Co=function(e){return xo(e)},wo=Co;function To(e){let t=B(e,`data`);return V(wo(t))}To._=Co,To.lock=function(){So=!0},To.register=function(e){if(So)throw TypeError(`ripemd160 is locked`);wo=e},Object.freeze(To);var Eo=!1,Do=function(e,t,n,r,i){return Fa(e,t,n,r,i)},Oo=Do;function ko(e,t,n,r,i){let a=B(e,`password`),o=B(t,`salt`);return V(Oo(a,o,n,r,i))}ko._=Do,ko.lock=function(){Eo=!0},ko.register=function(e){if(Eo)throw Error(`pbkdf2 is locked`);Oo=e},Object.freeze(ko);var Ao=!1,jo=function(e){return new Uint8Array(Ia(e))},Mo=jo;function No(e){return Mo(e)}No._=jo,No.lock=function(){Ao=!0},No.register=function(e){if(Ao)throw Error(`randomBytes is locked`);Mo=e},Object.freeze(No);var Po=(e,t)=>e<<t|e>>>32-t;function Fo(e,t,n,r,i,a){let o=e[t++]^n[r++],s=e[t++]^n[r++],c=e[t++]^n[r++],l=e[t++]^n[r++],u=e[t++]^n[r++],d=e[t++]^n[r++],f=e[t++]^n[r++],p=e[t++]^n[r++],m=e[t++]^n[r++],h=e[t++]^n[r++],g=e[t++]^n[r++],_=e[t++]^n[r++],v=e[t++]^n[r++],y=e[t++]^n[r++],b=e[t++]^n[r++],x=e[t++]^n[r++],S=o,ee=s,te=c,C=l,ne=u,re=d,w=f,ie=p,ae=m,T=h,oe=g,se=_,ce=v,le=y,E=b,ue=x;for(let e=0;e<8;e+=2)ne^=Po(S+ce|0,7),ae^=Po(ne+S|0,9),ce^=Po(ae+ne|0,13),S^=Po(ce+ae|0,18),T^=Po(re+ee|0,7),le^=Po(T+re|0,9),ee^=Po(le+T|0,13),re^=Po(ee+le|0,18),E^=Po(oe+w|0,7),te^=Po(E+oe|0,9),w^=Po(te+E|0,13),oe^=Po(w+te|0,18),C^=Po(ue+se|0,7),ie^=Po(C+ue|0,9),se^=Po(ie+C|0,13),ue^=Po(se+ie|0,18),ee^=Po(S+C|0,7),te^=Po(ee+S|0,9),C^=Po(te+ee|0,13),S^=Po(C+te|0,18),w^=Po(re+ne|0,7),ie^=Po(w+re|0,9),ne^=Po(ie+w|0,13),re^=Po(ne+ie|0,18),se^=Po(oe+T|0,7),ae^=Po(se+oe|0,9),T^=Po(ae+se|0,13),oe^=Po(T+ae|0,18),ce^=Po(ue+E|0,7),le^=Po(ce+ue|0,9),E^=Po(le+ce|0,13),ue^=Po(E+le|0,18);i[a++]=o+S|0,i[a++]=s+ee|0,i[a++]=c+te|0,i[a++]=l+C|0,i[a++]=u+ne|0,i[a++]=d+re|0,i[a++]=f+w|0,i[a++]=p+ie|0,i[a++]=m+ae|0,i[a++]=h+T|0,i[a++]=g+oe|0,i[a++]=_+se|0,i[a++]=v+ce|0,i[a++]=y+le|0,i[a++]=b+E|0,i[a++]=x+ue|0}function Io(e,t,n,r,i){let a=r+0,o=r+16*i;for(let r=0;r<16;r++)n[o+r]=e[t+(2*i-1)*16+r];for(let r=0;r<i;r++,a+=16,t+=16)Fo(n,o,e,t,n,a),r>0&&(o+=16),Fo(n,a,e,t+=16,n,o)}function Lo(e,t,n){let{N:r,r:i,p:a,dkLen:o,asyncTick:s,maxmem:c,onProgress:l}=Ui({dkLen:32,asyncTick:10,maxmem:1024**3+1024},n);if(Ei(r),Ei(i),Ei(a),Ei(o),Ei(s),Ei(c),l!==void 0&&typeof l!=`function`)throw Error(`progressCb should be function`);let u=128*i,d=u/4;if(r<=1||r&r-1||r>=2**(u/8)||r>2**32)throw Error(`Scrypt: N must be larger than 1, a power of 2, less than 2^(128 * r / 8) and less than 2^32`);if(a<0||a>(2**32-1)*32/u)throw Error(`Scrypt: p must be a positive integer less than or equal to ((2^32 - 1) * 32) / (128 * r)`);if(o<0||o>(2**32-1)*32)throw Error(`Scrypt: dkLen should be positive integer less than or equal to (2^32 - 1) * 32`);let f=u*(r+a);if(f>c)throw Error(`Scrypt: parameters too large, ${f} (128 * r * (N + p)) > ${c} (maxmem)`);let p=Xi(aa,e,t,{c:1,dkLen:u*a}),m=Ni(p),h=Ni(new Uint8Array(u*r)),g=Ni(new Uint8Array(u)),_=()=>{};if(l){let e=2*r*a,t=Math.max(Math.floor(e/1e4),1),n=0;_=()=>{n++,l&&(!(n%t)||n===e)&&l(n/e)}}return{N:r,r:i,p:a,dkLen:o,blockSize32:d,V:h,B32:m,B:p,tmp:g,blockMixCb:_,asyncTick:s}}function Ro(e,t,n,r,i){let a=Xi(aa,e,n,{c:1,dkLen:t});return n.fill(0),r.fill(0),i.fill(0),a}function zo(e,t,n){let{N:r,r:i,p:a,dkLen:o,blockSize32:s,V:c,B32:l,B:u,tmp:d,blockMixCb:f}=Lo(e,t,n);for(let e=0;e<a;e++){let t=s*e;for(let e=0;e<s;e++)c[e]=l[t+e];for(let e=0,t=0;e<r-1;e++)Io(c,t,c,t+=s,i),f();Io(c,(r-1)*s,l,t,i),f();for(let e=0;e<r;e++){let e=l[t+s-16]%r;for(let n=0;n<s;n++)d[n]=l[t+n]^c[e*s+n];Io(d,0,l,t,i),f()}}return Ro(e,o,u,c,d)}async function Bo(e,t,n){let{N:r,r:i,p:a,dkLen:o,blockSize32:s,V:c,B32:l,B:u,tmp:d,blockMixCb:f,asyncTick:p}=Lo(e,t,n);for(let e=0;e<a;e++){let t=s*e;for(let e=0;e<s;e++)c[e]=l[t+e];let n=0;await Li(r-1,p,()=>{Io(c,n,c,n+=s,i),f()}),Io(c,(r-1)*s,l,t,i),f(),await Li(r,p,()=>{let e=l[t+s-16]%r;for(let n=0;n<s;n++)d[n]=l[t+n]^c[e*s+n];Io(d,0,l,t,i),f()})}return Ro(e,o,u,c,d)}var Vo=!1,Ho=!1,Uo=async function(e,t,n,r,i,a,o){return await Bo(e,t,{N:n,r,p:i,dkLen:a,onProgress:o})},Wo=function(e,t,n,r,i,a){return zo(e,t,{N:n,r,p:i,dkLen:a})},Go=Uo,Ko=Wo;async function qo(e,t,n,r,i,a,o){let s=B(e,`passwd`),c=B(t,`salt`);return V(await Go(s,c,n,r,i,a,o))}qo._=Uo,qo.lock=function(){Ho=!0},qo.register=function(e){if(Ho)throw Error(`scrypt is locked`);Go=e},Object.freeze(qo);function Jo(e,t,n,r,i,a){let o=B(e,`passwd`),s=B(t,`salt`);return V(Ko(o,s,n,r,i,a))}Jo._=Wo,Jo.lock=function(){Vo=!0},Jo.register=function(e){if(Vo)throw Error(`scryptSync is locked`);Ko=e},Object.freeze(Jo);var Yo=function(e){return Na(`sha256`).update(e).digest()},Xo=function(e){return Na(`sha512`).update(e).digest()},Zo=Yo,Qo=Xo,$o=!1,es=!1;function ts(e){let t=B(e,`data`);return V(Zo(t))}ts._=Yo,ts.lock=function(){$o=!0},ts.register=function(e){if($o)throw Error(`sha256 is locked`);Zo=e},Object.freeze(ts);function ns(e){let t=B(e,`data`);return V(Qo(t))}ns._=Xo,ns.lock=function(){es=!0},ns.register=function(e){if(es)throw Error(`sha512 is locked`);Qo=e},Object.freeze(ts);var rs=e({bitGet:()=>Cs,bitLen:()=>Ss,bitMask:()=>Ts,bitSet:()=>ws,bytesToHex:()=>ls,bytesToNumberBE:()=>ps,bytesToNumberLE:()=>ms,concatBytes:()=>ys,createHmacDrbg:()=>Os,ensureBytes:()=>vs,equalBytes:()=>bs,hexToBytes:()=>fs,hexToNumber:()=>ds,numberToBytesBE:()=>hs,numberToBytesLE:()=>gs,numberToHexUnpadded:()=>us,numberToVarBytesBE:()=>_s,utf8ToBytes:()=>xs,validateObject:()=>As}),is=BigInt(0),as=BigInt(1),os=BigInt(2),ss=e=>e instanceof Uint8Array,cs=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,`0`));function ls(e){if(!ss(e))throw Error(`Uint8Array expected`);let t=``;for(let n=0;n<e.length;n++)t+=cs[e[n]];return t}function us(e){let t=e.toString(16);return t.length&1?`0${t}`:t}function ds(e){if(typeof e!=`string`)throw Error(`hex string expected, got `+typeof e);return BigInt(e===``?`0`:`0x${e}`)}function fs(e){if(typeof e!=`string`)throw Error(`hex string expected, got `+typeof e);let t=e.length;if(t%2)throw Error(`padded hex string expected, got unpadded hex of length `+t);let n=new Uint8Array(t/2);for(let t=0;t<n.length;t++){let r=t*2,i=e.slice(r,r+2),a=Number.parseInt(i,16);if(Number.isNaN(a)||a<0)throw Error(`Invalid byte sequence`);n[t]=a}return n}function ps(e){return ds(ls(e))}function ms(e){if(!ss(e))throw Error(`Uint8Array expected`);return ds(ls(Uint8Array.from(e).reverse()))}function hs(e,t){return fs(e.toString(16).padStart(t*2,`0`))}function gs(e,t){return hs(e,t).reverse()}function _s(e){return fs(us(e))}function vs(e,t,n){let r;if(typeof t==`string`)try{r=fs(t)}catch(n){throw Error(`${e} must be valid hex string, got "${t}". Cause: ${n}`)}else if(ss(t))r=Uint8Array.from(t);else throw Error(`${e} must be hex string or Uint8Array`);let i=r.length;if(typeof n==`number`&&i!==n)throw Error(`${e} expected ${n} bytes, got ${i}`);return r}function ys(...e){let t=new Uint8Array(e.reduce((e,t)=>e+t.length,0)),n=0;return e.forEach(e=>{if(!ss(e))throw Error(`Uint8Array expected`);t.set(e,n),n+=e.length}),t}function bs(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function xs(e){if(typeof e!=`string`)throw Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function Ss(e){let t;for(t=0;e>is;e>>=as,t+=1);return t}function Cs(e,t){return e>>BigInt(t)&as}var ws=(e,t,n)=>e|(n?as:is)<<BigInt(t),Ts=e=>(os<<BigInt(e-1))-as,Es=e=>new Uint8Array(e),Ds=e=>Uint8Array.from(e);function Os(e,t,n){if(typeof e!=`number`||e<2)throw Error(`hashLen must be a number`);if(typeof t!=`number`||t<2)throw Error(`qByteLen must be a number`);if(typeof n!=`function`)throw Error(`hmacFn must be a function`);let r=Es(e),i=Es(e),a=0,o=()=>{r.fill(1),i.fill(0),a=0},s=(...e)=>n(i,r,...e),c=(e=Es())=>{i=s(Ds([0]),e),r=s(),e.length!==0&&(i=s(Ds([1]),e),r=s())},l=()=>{if(a++>=1e3)throw Error(`drbg: tried 1000 values`);let e=0,n=[];for(;e<t;){r=s();let t=r.slice();n.push(t),e+=r.length}return ys(...n)};return(e,t)=>{o(),c(e);let n;for(;!(n=t(l()));)c();return o(),n}}var ks={bigint:e=>typeof e==`bigint`,function:e=>typeof e==`function`,boolean:e=>typeof e==`boolean`,string:e=>typeof e==`string`,stringOrUint8Array:e=>typeof e==`string`||e instanceof Uint8Array,isSafeInteger:e=>Number.isSafeInteger(e),array:e=>Array.isArray(e),field:(e,t)=>t.Fp.isValid(e),hash:e=>typeof e==`function`&&Number.isSafeInteger(e.outputLen)};function As(e,t,n={}){let r=(t,n,r)=>{let i=ks[n];if(typeof i!=`function`)throw Error(`Invalid validator "${n}", expected function`);let a=e[t];if(!(r&&a===void 0)&&!i(a,e))throw Error(`Invalid param ${String(t)}=${a} (${typeof a}), expected ${n}`)};for(let[e,n]of Object.entries(t))r(e,n,!1);for(let[e,t]of Object.entries(n))r(e,t,!0);return e}var js=BigInt(0),Ms=BigInt(1),Ns=BigInt(2),Ps=BigInt(3),Fs=BigInt(4),Is=BigInt(5),Ls=BigInt(8),Rs=BigInt(16);function zs(e,t){let n=e%t;return n>=js?n:t+n}function Bs(e,t,n){if(n<=js||t<js)throw Error(`Expected power/modulo > 0`);if(n===Ms)return js;let r=Ms;for(;t>js;)t&Ms&&(r=r*e%n),e=e*e%n,t>>=Ms;return r}function Vs(e,t,n){let r=e;for(;t-->js;)r*=r,r%=n;return r}function Hs(e,t){if(e===js||t<=js)throw Error(`invert: expected positive integers, got n=${e} mod=${t}`);let n=zs(e,t),r=t,i=js,a=Ms,o=Ms,s=js;for(;n!==js;){let e=r/n,t=r%n,c=i-o*e,l=a-s*e;r=n,n=t,i=o,a=s,o=c,s=l}if(r!==Ms)throw Error(`invert: does not exist`);return zs(i,t)}function Us(e){let t=(e-Ms)/Ns,n,r,i;for(n=e-Ms,r=0;n%Ns===js;n/=Ns,r++);for(i=Ns;i<e&&Bs(i,t,e)!==e-Ms;i++);if(r===1){let t=(e+Ms)/Fs;return function(e,n){let r=e.pow(n,t);if(!e.eql(e.sqr(r),n))throw Error(`Cannot find square root`);return r}}let a=(n+Ms)/Ns;return function(e,o){if(e.pow(o,t)===e.neg(e.ONE))throw Error(`Cannot find square root`);let s=r,c=e.pow(e.mul(e.ONE,i),n),l=e.pow(o,a),u=e.pow(o,n);for(;!e.eql(u,e.ONE);){if(e.eql(u,e.ZERO))return e.ZERO;let t=1;for(let n=e.sqr(u);t<s&&!e.eql(n,e.ONE);t++)n=e.sqr(n);let n=e.pow(c,Ms<<BigInt(s-t-1));c=e.sqr(n),l=e.mul(l,n),u=e.mul(u,c),s=t}return l}}function Ws(e){if(e%Fs===Ps){let t=(e+Ms)/Fs;return function(e,n){let r=e.pow(n,t);if(!e.eql(e.sqr(r),n))throw Error(`Cannot find square root`);return r}}if(e%Ls===Is){let t=(e-Is)/Ls;return function(e,n){let r=e.mul(n,Ns),i=e.pow(r,t),a=e.mul(n,i),o=e.mul(e.mul(a,Ns),i),s=e.mul(a,e.sub(o,e.ONE));if(!e.eql(e.sqr(s),n))throw Error(`Cannot find square root`);return s}}return e%Rs,Us(e)}var Gs=[`create`,`isValid`,`is0`,`neg`,`inv`,`sqrt`,`sqr`,`eql`,`add`,`sub`,`mul`,`pow`,`div`,`addN`,`subN`,`mulN`,`sqrN`];function Ks(e){return As(e,Gs.reduce((e,t)=>(e[t]=`function`,e),{ORDER:`bigint`,MASK:`bigint`,BYTES:`isSafeInteger`,BITS:`isSafeInteger`}))}function qs(e,t,n){if(n<js)throw Error(`Expected power > 0`);if(n===js)return e.ONE;if(n===Ms)return t;let r=e.ONE,i=t;for(;n>js;)n&Ms&&(r=e.mul(r,i)),i=e.sqr(i),n>>=Ms;return r}function Js(e,t){let n=Array(t.length),r=t.reduce((t,r,i)=>e.is0(r)?t:(n[i]=t,e.mul(t,r)),e.ONE),i=e.inv(r);return t.reduceRight((t,r,i)=>e.is0(r)?t:(n[i]=e.mul(t,n[i]),e.mul(t,r)),i),n}function Ys(e,t){let n=t===void 0?e.toString(2).length:t;return{nBitLength:n,nByteLength:Math.ceil(n/8)}}function Xs(e,t,n=!1,r={}){if(e<=js)throw Error(`Expected Field ORDER > 0, got ${e}`);let{nBitLength:i,nByteLength:a}=Ys(e,t);if(a>2048)throw Error(`Field lengths over 2048 bytes are not supported`);let o=Ws(e),s=Object.freeze({ORDER:e,BITS:i,BYTES:a,MASK:Ts(i),ZERO:js,ONE:Ms,create:t=>zs(t,e),isValid:t=>{if(typeof t!=`bigint`)throw Error(`Invalid field element: expected bigint, got ${typeof t}`);return js<=t&&t<e},is0:e=>e===js,isOdd:e=>(e&Ms)===Ms,neg:t=>zs(-t,e),eql:(e,t)=>e===t,sqr:t=>zs(t*t,e),add:(t,n)=>zs(t+n,e),sub:(t,n)=>zs(t-n,e),mul:(t,n)=>zs(t*n,e),pow:(e,t)=>qs(s,e,t),div:(t,n)=>zs(t*Hs(n,e),e),sqrN:e=>e*e,addN:(e,t)=>e+t,subN:(e,t)=>e-t,mulN:(e,t)=>e*t,inv:t=>Hs(t,e),sqrt:r.sqrt||(e=>o(s,e)),invertBatch:e=>Js(s,e),cmov:(e,t,n)=>n?t:e,toBytes:e=>n?gs(e,a):hs(e,a),fromBytes:e=>{if(e.length!==a)throw Error(`Fp.fromBytes: expected ${a}, got ${e.length}`);return n?ms(e):ps(e)}});return Object.freeze(s)}function Zs(e){if(typeof e!=`bigint`)throw Error(`field order must be bigint`);let t=e.toString(2).length;return Math.ceil(t/8)}function Qs(e){let t=Zs(e);return t+Math.ceil(t/2)}function $s(e,t,n=!1){let r=e.length,i=Zs(t),a=Qs(t);if(r<16||r<a||r>1024)throw Error(`expected ${a}-1024 bytes of input, got ${r}`);let o=zs(n?ps(e):ms(e),t-Ms)+Ms;return n?gs(o,i):hs(o,i)}var ec=BigInt(0),tc=BigInt(1);function nc(e,t){let n=(e,t)=>{let n=t.negate();return e?n:t},r=e=>({windows:Math.ceil(t/e)+1,windowSize:2**(e-1)});return{constTimeNegate:n,unsafeLadder(t,n){let r=e.ZERO,i=t;for(;n>ec;)n&tc&&(r=r.add(i)),i=i.double(),n>>=tc;return r},precomputeWindow(e,t){let{windows:n,windowSize:i}=r(t),a=[],o=e,s=o;for(let e=0;e<n;e++){s=o,a.push(s);for(let e=1;e<i;e++)s=s.add(o),a.push(s);o=s.double()}return a},wNAF(t,i,a){let{windows:o,windowSize:s}=r(t),c=e.ZERO,l=e.BASE,u=BigInt(2**t-1),d=2**t,f=BigInt(t);for(let e=0;e<o;e++){let t=e*s,r=Number(a&u);a>>=f,r>s&&(r-=d,a+=tc);let o=t,p=t+Math.abs(r)-1,m=e%2!=0,h=r<0;r===0?l=l.add(n(m,i[o])):c=c.add(n(h,i[p]))}return{p:c,f:l}},wNAFCached(e,t,n,r){let i=e._WINDOW_SIZE||1,a=t.get(e);return a||(a=this.precomputeWindow(e,i),i!==1&&t.set(e,r(a))),this.wNAF(i,a,n)}}}function rc(e){return Ks(e.Fp),As(e,{n:`bigint`,h:`bigint`,Gx:`field`,Gy:`field`},{nBitLength:`isSafeInteger`,nByteLength:`isSafeInteger`}),Object.freeze({...Ys(e.n,e.nBitLength),...e,p:e.Fp.ORDER})}function ic(e){let t=rc(e);As(t,{a:`field`,b:`field`},{allowedPrivateKeyLengths:`array`,wrapPrivateKey:`boolean`,isTorsionFree:`function`,clearCofactor:`function`,allowInfinityPoint:`boolean`,fromBytes:`function`,toBytes:`function`});let{endo:n,Fp:r,a:i}=t;if(n){if(!r.eql(i,r.ZERO))throw Error(`Endomorphism can only be defined for Koblitz curves that have a=0`);if(typeof n!=`object`||typeof n.beta!=`bigint`||typeof n.splitScalar!=`function`)throw Error(`Expected endomorphism with beta: bigint and splitScalar: function`)}return Object.freeze({...t})}var{bytesToNumberBE:ac,hexToBytes:oc}=rs,sc={Err:class extends Error{constructor(e=``){super(e)}},_parseInt(e){let{Err:t}=sc;if(e.length<2||e[0]!==2)throw new t(`Invalid signature integer tag`);let n=e[1],r=e.subarray(2,n+2);if(!n||r.length!==n)throw new t(`Invalid signature integer: wrong length`);if(r[0]&128)throw new t(`Invalid signature integer: negative`);if(r[0]===0&&!(r[1]&128))throw new t(`Invalid signature integer: unnecessary leading zero`);return{d:ac(r),l:e.subarray(n+2)}},toSig(e){let{Err:t}=sc,n=typeof e==`string`?oc(e):e;if(!(n instanceof Uint8Array))throw Error(`ui8a expected`);let r=n.length;if(r<2||n[0]!=48)throw new t(`Invalid signature tag`);if(n[1]!==r-2)throw new t(`Invalid signature: incorrect length`);let{d:i,l:a}=sc._parseInt(n.subarray(2)),{d:o,l:s}=sc._parseInt(a);if(s.length)throw new t(`Invalid signature: left bytes after parsing`);return{r:i,s:o}},hexFromSig(e){let t=e=>Number.parseInt(e[0],16)&8?`00`+e:e,n=e=>{let t=e.toString(16);return t.length&1?`0${t}`:t},r=t(n(e.s)),i=t(n(e.r)),a=r.length/2,o=i.length/2,s=n(a),c=n(o);return`30${n(o+a+4)}02${c}${i}02${s}${r}`}},cc=BigInt(0),lc=BigInt(1),uc=BigInt(3);function dc(e){let t=ic(e),{Fp:n}=t,r=t.toBytes||((e,t,r)=>{let i=t.toAffine();return ys(Uint8Array.from([4]),n.toBytes(i.x),n.toBytes(i.y))}),i=t.fromBytes||(e=>{let t=e.subarray(1);return{x:n.fromBytes(t.subarray(0,n.BYTES)),y:n.fromBytes(t.subarray(n.BYTES,2*n.BYTES))}});function a(e){let{a:r,b:i}=t,a=n.sqr(e),o=n.mul(a,e);return n.add(n.add(o,n.mul(e,r)),i)}if(!n.eql(n.sqr(t.Gy),a(t.Gx)))throw Error(`bad generator point: equation left != right`);function o(e){return typeof e==`bigint`&&cc<e&&e<t.n}function s(e){if(!o(e))throw Error(`Expected valid bigint: 0 < bigint < curve.n`)}function c(e){let{allowedPrivateKeyLengths:n,nByteLength:r,wrapPrivateKey:i,n:a}=t;if(n&&typeof e!=`bigint`){if(e instanceof Uint8Array&&(e=ls(e)),typeof e!=`string`||!n.includes(e.length))throw Error(`Invalid key`);e=e.padStart(r*2,`0`)}let o;try{o=typeof e==`bigint`?e:ps(vs(`private key`,e,r))}catch{throw Error(`private key must be ${r} bytes, hex or bigint, not ${typeof e}`)}return i&&(o=zs(o,a)),s(o),o}let l=new Map;function u(e){if(!(e instanceof d))throw Error(`ProjectivePoint expected`)}class d{constructor(e,t,r){if(this.px=e,this.py=t,this.pz=r,e==null||!n.isValid(e))throw Error(`x required`);if(t==null||!n.isValid(t))throw Error(`y required`);if(r==null||!n.isValid(r))throw Error(`z required`)}static fromAffine(e){let{x:t,y:r}=e||{};if(!e||!n.isValid(t)||!n.isValid(r))throw Error(`invalid affine point`);if(e instanceof d)throw Error(`projective point not allowed`);let i=e=>n.eql(e,n.ZERO);return i(t)&&i(r)?d.ZERO:new d(t,r,n.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(e){let t=n.invertBatch(e.map(e=>e.pz));return e.map((e,n)=>e.toAffine(t[n])).map(d.fromAffine)}static fromHex(e){let t=d.fromAffine(i(vs(`pointHex`,e)));return t.assertValidity(),t}static fromPrivateKey(e){return d.BASE.multiply(c(e))}_setWindowSize(e){this._WINDOW_SIZE=e,l.delete(this)}assertValidity(){if(this.is0()){if(t.allowInfinityPoint&&!n.is0(this.py))return;throw Error(`bad point: ZERO`)}let{x:e,y:r}=this.toAffine();if(!n.isValid(e)||!n.isValid(r))throw Error(`bad point: x or y not FE`);let i=n.sqr(r),o=a(e);if(!n.eql(i,o))throw Error(`bad point: equation left != right`);if(!this.isTorsionFree())throw Error(`bad point: not in prime-order subgroup`)}hasEvenY(){let{y:e}=this.toAffine();if(n.isOdd)return!n.isOdd(e);throw Error(`Field doesn't support isOdd`)}equals(e){u(e);let{px:t,py:r,pz:i}=this,{px:a,py:o,pz:s}=e,c=n.eql(n.mul(t,s),n.mul(a,i)),l=n.eql(n.mul(r,s),n.mul(o,i));return c&&l}negate(){return new d(this.px,n.neg(this.py),this.pz)}double(){let{a:e,b:r}=t,i=n.mul(r,uc),{px:a,py:o,pz:s}=this,c=n.ZERO,l=n.ZERO,u=n.ZERO,f=n.mul(a,a),p=n.mul(o,o),m=n.mul(s,s),h=n.mul(a,o);return h=n.add(h,h),u=n.mul(a,s),u=n.add(u,u),c=n.mul(e,u),l=n.mul(i,m),l=n.add(c,l),c=n.sub(p,l),l=n.add(p,l),l=n.mul(c,l),c=n.mul(h,c),u=n.mul(i,u),m=n.mul(e,m),h=n.sub(f,m),h=n.mul(e,h),h=n.add(h,u),u=n.add(f,f),f=n.add(u,f),f=n.add(f,m),f=n.mul(f,h),l=n.add(l,f),m=n.mul(o,s),m=n.add(m,m),f=n.mul(m,h),c=n.sub(c,f),u=n.mul(m,p),u=n.add(u,u),u=n.add(u,u),new d(c,l,u)}add(e){u(e);let{px:r,py:i,pz:a}=this,{px:o,py:s,pz:c}=e,l=n.ZERO,f=n.ZERO,p=n.ZERO,m=t.a,h=n.mul(t.b,uc),g=n.mul(r,o),_=n.mul(i,s),v=n.mul(a,c),y=n.add(r,i),b=n.add(o,s);y=n.mul(y,b),b=n.add(g,_),y=n.sub(y,b),b=n.add(r,a);let x=n.add(o,c);return b=n.mul(b,x),x=n.add(g,v),b=n.sub(b,x),x=n.add(i,a),l=n.add(s,c),x=n.mul(x,l),l=n.add(_,v),x=n.sub(x,l),p=n.mul(m,b),l=n.mul(h,v),p=n.add(l,p),l=n.sub(_,p),p=n.add(_,p),f=n.mul(l,p),_=n.add(g,g),_=n.add(_,g),v=n.mul(m,v),b=n.mul(h,b),_=n.add(_,v),v=n.sub(g,v),v=n.mul(m,v),b=n.add(b,v),g=n.mul(_,b),f=n.add(f,g),g=n.mul(x,b),l=n.mul(y,l),l=n.sub(l,g),g=n.mul(y,_),p=n.mul(x,p),p=n.add(p,g),new d(l,f,p)}subtract(e){return this.add(e.negate())}is0(){return this.equals(d.ZERO)}wNAF(e){return p.wNAFCached(this,l,e,e=>{let t=n.invertBatch(e.map(e=>e.pz));return e.map((e,n)=>e.toAffine(t[n])).map(d.fromAffine)})}multiplyUnsafe(e){let r=d.ZERO;if(e===cc)return r;if(s(e),e===lc)return this;let{endo:i}=t;if(!i)return p.unsafeLadder(this,e);let{k1neg:a,k1:o,k2neg:c,k2:l}=i.splitScalar(e),u=r,f=r,m=this;for(;o>cc||l>cc;)o&lc&&(u=u.add(m)),l&lc&&(f=f.add(m)),m=m.double(),o>>=lc,l>>=lc;return a&&(u=u.negate()),c&&(f=f.negate()),f=new d(n.mul(f.px,i.beta),f.py,f.pz),u.add(f)}multiply(e){s(e);let r=e,i,a,{endo:o}=t;if(o){let{k1neg:e,k1:t,k2neg:s,k2:c}=o.splitScalar(r),{p:l,f:u}=this.wNAF(t),{p:f,f:m}=this.wNAF(c);l=p.constTimeNegate(e,l),f=p.constTimeNegate(s,f),f=new d(n.mul(f.px,o.beta),f.py,f.pz),i=l.add(f),a=u.add(m)}else{let{p:e,f:t}=this.wNAF(r);i=e,a=t}return d.normalizeZ([i,a])[0]}multiplyAndAddUnsafe(e,t,n){let r=d.BASE,i=(e,t)=>t===cc||t===lc||!e.equals(r)?e.multiplyUnsafe(t):e.multiply(t),a=i(this,t).add(i(e,n));return a.is0()?void 0:a}toAffine(e){let{px:t,py:r,pz:i}=this,a=this.is0();e??=a?n.ONE:n.inv(i);let o=n.mul(t,e),s=n.mul(r,e),c=n.mul(i,e);if(a)return{x:n.ZERO,y:n.ZERO};if(!n.eql(c,n.ONE))throw Error(`invZ was invalid`);return{x:o,y:s}}isTorsionFree(){let{h:e,isTorsionFree:n}=t;if(e===lc)return!0;if(n)return n(d,this);throw Error(`isTorsionFree() has not been declared for the elliptic curve`)}clearCofactor(){let{h:e,clearCofactor:n}=t;return e===lc?this:n?n(d,this):this.multiplyUnsafe(t.h)}toRawBytes(e=!0){return this.assertValidity(),r(d,this,e)}toHex(e=!0){return ls(this.toRawBytes(e))}}d.BASE=new d(t.Gx,t.Gy,n.ONE),d.ZERO=new d(n.ZERO,n.ONE,n.ZERO);let f=t.nBitLength,p=nc(d,t.endo?Math.ceil(f/2):f);return{CURVE:t,ProjectivePoint:d,normPrivateKeyToScalar:c,weierstrassEquation:a,isWithinCurveOrder:o}}function fc(e){let t=rc(e);return As(t,{hash:`hash`,hmac:`function`,randomBytes:`function`},{bits2int:`function`,bits2int_modN:`function`,lowS:`boolean`}),Object.freeze({lowS:!0,...t})}function pc(e){let t=fc(e),{Fp:n,n:r}=t,i=n.BYTES+1,a=2*n.BYTES+1;function o(e){return cc<e&&e<n.ORDER}function s(e){return zs(e,r)}function c(e){return Hs(e,r)}let{ProjectivePoint:l,normPrivateKeyToScalar:u,weierstrassEquation:d,isWithinCurveOrder:f}=dc({...t,toBytes(e,t,r){let i=t.toAffine(),a=n.toBytes(i.x),o=ys;return r?o(Uint8Array.from([t.hasEvenY()?2:3]),a):o(Uint8Array.from([4]),a,n.toBytes(i.y))},fromBytes(e){let t=e.length,r=e[0],s=e.subarray(1);if(t===i&&(r===2||r===3)){let e=ps(s);if(!o(e))throw Error(`Point is not on curve`);let t=d(e),i=n.sqrt(t),a=(i&lc)===lc;return(r&1)==1!==a&&(i=n.neg(i)),{x:e,y:i}}if(t===a&&r===4)return{x:n.fromBytes(s.subarray(0,n.BYTES)),y:n.fromBytes(s.subarray(n.BYTES,2*n.BYTES))};throw Error(`Point of length ${t} was invalid. Expected ${i} compressed bytes or ${a} uncompressed bytes`)}}),p=e=>ls(hs(e,t.nByteLength));function m(e){return e>r>>lc}function h(e){return m(e)?s(-e):e}let g=(e,t,n)=>ps(e.slice(t,n));class _{constructor(e,t,n){this.r=e,this.s=t,this.recovery=n,this.assertValidity()}static fromCompact(e){let n=t.nByteLength;return e=vs(`compactSignature`,e,n*2),new _(g(e,0,n),g(e,n,2*n))}static fromDER(e){let{r:t,s:n}=sc.toSig(vs(`DER`,e));return new _(t,n)}assertValidity(){if(!f(this.r))throw Error(`r must be 0 < r < CURVE.n`);if(!f(this.s))throw Error(`s must be 0 < s < CURVE.n`)}addRecoveryBit(e){return new _(this.r,this.s,e)}recoverPublicKey(e){let{r,s:i,recovery:a}=this,o=ee(vs(`msgHash`,e));if(a==null||![0,1,2,3].includes(a))throw Error(`recovery id invalid`);let u=a===2||a===3?r+t.n:r;if(u>=n.ORDER)throw Error(`recovery id 2 or 3 invalid`);let d=a&1?`03`:`02`,f=l.fromHex(d+p(u)),m=c(u),h=s(-o*m),g=s(i*m),_=l.BASE.multiplyAndAddUnsafe(f,h,g);if(!_)throw Error(`point at infinify`);return _.assertValidity(),_}hasHighS(){return m(this.s)}normalizeS(){return this.hasHighS()?new _(this.r,s(-this.s),this.recovery):this}toDERRawBytes(){return fs(this.toDERHex())}toDERHex(){return sc.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return fs(this.toCompactHex())}toCompactHex(){return p(this.r)+p(this.s)}}let v={isValidPrivateKey(e){try{return u(e),!0}catch{return!1}},normPrivateKeyToScalar:u,randomPrivateKey:()=>{let e=Qs(t.n);return $s(t.randomBytes(e),t.n)},precompute(e=8,t=l.BASE){return t._setWindowSize(e),t.multiply(BigInt(3)),t}};function y(e,t=!0){return l.fromPrivateKey(e).toRawBytes(t)}function b(e){let t=e instanceof Uint8Array,n=typeof e==`string`,r=(t||n)&&e.length;return t?r===i||r===a:n?r===2*i||r===2*a:e instanceof l}function x(e,t,n=!0){if(b(e))throw Error(`first arg must be private key`);if(!b(t))throw Error(`second arg must be public key`);return l.fromHex(t).multiply(u(e)).toRawBytes(n)}let S=t.bits2int||function(e){let n=ps(e),r=e.length*8-t.nBitLength;return r>0?n>>BigInt(r):n},ee=t.bits2int_modN||function(e){return s(S(e))},te=Ts(t.nBitLength);function C(e){if(typeof e!=`bigint`)throw Error(`bigint expected`);if(!(cc<=e&&e<te))throw Error(`bigint expected < 2^${t.nBitLength}`);return hs(e,t.nByteLength)}function ne(e,r,i=re){if([`recovered`,`canonical`].some(e=>e in i))throw Error(`sign() legacy options not supported`);let{hash:a,randomBytes:o}=t,{lowS:d,prehash:p,extraEntropy:g}=i;d??=!0,e=vs(`msgHash`,e),p&&(e=vs(`prehashed msgHash`,a(e)));let v=ee(e),y=u(r),b=[C(y),C(v)];if(g!=null){let e=g===!0?o(n.BYTES):g;b.push(vs(`extraEntropy`,e))}let x=ys(...b),te=v;function ne(e){let t=S(e);if(!f(t))return;let n=c(t),r=l.BASE.multiply(t).toAffine(),i=s(r.x);if(i===cc)return;let a=s(n*s(te+i*y));if(a===cc)return;let o=(r.x===i?0:2)|Number(r.y&lc),u=a;return d&&m(a)&&(u=h(a),o^=1),new _(i,u,o)}return{seed:x,k2sig:ne}}let re={lowS:t.lowS,prehash:!1},w={lowS:t.lowS,prehash:!1};function ie(e,n,r=re){let{seed:i,k2sig:a}=ne(e,n,r),o=t;return Os(o.hash.outputLen,o.nByteLength,o.hmac)(i,a)}l.BASE._setWindowSize(8);function ae(e,n,r,i=w){let a=e;if(n=vs(`msgHash`,n),r=vs(`publicKey`,r),`strict`in i)throw Error(`options.strict was renamed to lowS`);let{lowS:o,prehash:u}=i,d,f;try{if(typeof a==`string`||a instanceof Uint8Array)try{d=_.fromDER(a)}catch(e){if(!(e instanceof sc.Err))throw e;d=_.fromCompact(a)}else if(typeof a==`object`&&typeof a.r==`bigint`&&typeof a.s==`bigint`){let{r:e,s:t}=a;d=new _(e,t)}else throw Error(`PARSE`);f=l.fromHex(r)}catch(e){if(e.message===`PARSE`)throw Error(`signature must be Signature instance, Uint8Array or hex string`);return!1}if(o&&d.hasHighS())return!1;u&&(n=t.hash(n));let{r:p,s:m}=d,h=ee(n),g=c(m),v=s(h*g),y=s(p*g),b=l.BASE.multiplyAndAddUnsafe(f,v,y)?.toAffine();return b?s(b.x)===p:!1}return{CURVE:t,getPublicKey:y,getSharedSecret:x,sign:ie,verify:ae,ProjectivePoint:l,Signature:_,utils:v}}function mc(e){return{hash:e,hmac:(t,...n)=>qi(e,t,Bi(...n)),randomBytes:Gi}}function hc(e,t){let n=t=>pc({...e,...mc(t)});return Object.freeze({...n(t),create:n})}var gc=BigInt(`0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f`),_c=BigInt(`0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141`),vc=BigInt(1),yc=BigInt(2),bc=(e,t)=>(e+t/yc)/t;function xc(e){let t=gc,n=BigInt(3),r=BigInt(6),i=BigInt(11),a=BigInt(22),o=BigInt(23),s=BigInt(44),c=BigInt(88),l=e*e*e%t,u=l*l*e%t,d=Vs(Vs(Vs(u,n,t)*u%t,n,t)*u%t,yc,t)*l%t,f=Vs(d,i,t)*d%t,p=Vs(f,a,t)*f%t,m=Vs(p,s,t)*p%t,h=Vs(Vs(Vs(Vs(Vs(Vs(m,c,t)*m%t,s,t)*p%t,n,t)*u%t,o,t)*f%t,r,t)*l%t,yc,t);if(!Sc.eql(Sc.sqr(h),e))throw Error(`Cannot find square root`);return h}var Sc=Xs(gc,void 0,void 0,{sqrt:xc}),Cc=hc({a:BigInt(0),b:BigInt(7),Fp:Sc,n:_c,Gx:BigInt(`55066263022277343669578718895168534326250603453777594175500187360389116729240`),Gy:BigInt(`32670510020758816978083085130507043184471273380659243275938904335757337482424`),h:BigInt(1),lowS:!0,endo:{beta:BigInt(`0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee`),splitScalar:e=>{let t=_c,n=BigInt(`0x3086d221a7d46bcde86c90e49284eb15`),r=-vc*BigInt(`0xe4437ed6010e88286f547fa90abfe4c3`),i=BigInt(`0x114ca50f7a8e2f3f657c1108d9d44cfd8`),a=n,o=BigInt(`0x100000000000000000000000000000000`),s=bc(a*e,t),c=bc(-r*e,t),l=zs(e-s*n-c*i,t),u=zs(-s*r-c*a,t),d=l>o,f=u>o;if(d&&(l=t-l),f&&(u=t-u),l>o||u>o)throw Error(`splitScalar: Endomorphism failed, k=`+e);return{k1neg:d,k1:l,k2neg:f,k2:u}}}},aa);Cc.ProjectivePoint;var wc=`0x0000000000000000000000000000000000000000`,Tc=`0x0000000000000000000000000000000000000000000000000000000000000000`,Ec=`Ethereum Signed Message:
|
|
4
4
|
`,Dc=BigInt(0),Oc=BigInt(1),kc=BigInt(2),Ac=BigInt(27),jc=BigInt(28),Mc=BigInt(35),Nc={};function Pc(e){return Er(Br(e),32)}var Fc=class e{#e;#t;#n;#r;get r(){return this.#e}set r(e){z(Cr(e)===32,`invalid r`,`value`,e),this.#e=V(e)}get s(){return this.#t}set s(e){z(Cr(e)===32,`invalid s`,`value`,e);let t=V(e);z(parseInt(t.substring(0,3))<8,`non-canonical s`,`value`,t),this.#t=t}get v(){return this.#n}set v(e){let t=Lr(e,`value`);z(t===27||t===28,`invalid v`,`v`,e),this.#n=t}get networkV(){return this.#r}get legacyChainId(){let t=this.networkV;return t==null?null:e.getChainId(t)}get yParity(){return this.v===27?0:1}get yParityAndS(){let e=B(this.s);return this.yParity&&(e[0]|=128),V(e)}get compactSerialized(){return Sr([this.r,this.yParityAndS])}get serialized(){return Sr([this.r,this.s,this.yParity?`0x1c`:`0x1b`])}constructor(e,t,n,r){gr(e,Nc,`Signature`),this.#e=t,this.#t=n,this.#n=r,this.#r=null}[Symbol.for(`nodejs.util.inspect.custom`)](){return`Signature { r: "${this.r}", s: "${this.s}", yParity: ${this.yParity}, networkV: ${this.networkV} }`}clone(){let t=new e(Nc,this.r,this.s,this.v);return this.networkV&&(t.#r=this.networkV),t}toJSON(){let e=this.networkV;return{_type:`signature`,networkV:e==null?null:e.toString(),r:this.r,s:this.s,v:this.v}}static getChainId(e){let t=Nr(e,`v`);return t==Ac||t==jc?Dc:(z(t>=Mc,`invalid EIP-155 v`,`v`,e),(t-Mc)/kc)}static getChainIdV(e,t){return Nr(e)*kc+BigInt(35+t-27)}static getNormalizedV(e){let t=Nr(e);return t===Dc||t===Ac?27:t===Oc||t===jc?28:(z(t>=Mc,`invalid v`,`v`,e),t&Oc?27:28)}static from(t){function n(e,n){z(e,n,`signature`,t)}if(t==null)return new e(Nc,Tc,Tc,27);if(typeof t==`string`){let r=B(t,`signature`);if(r.length===64){let t=V(r.slice(0,32)),n=r.slice(32,64),i=n[0]&128?28:27;return n[0]&=127,new e(Nc,t,V(n),i)}if(r.length===65){let t=V(r.slice(0,32)),i=r.slice(32,64);n(!(i[0]&128),`non-canonical s`);let a=e.getNormalizedV(r[64]);return new e(Nc,t,V(i),a)}n(!1,`invalid raw signature length`)}if(t instanceof e)return t.clone();let r=t.r;n(r!=null,`missing r`);let i=Pc(r),a=(function(e,t){if(e!=null)return Pc(e);if(t!=null){n(yr(t,32),`invalid yParityAndS`);let e=B(t);return e[0]&=127,V(e)}n(!1,`missing s`)})(t.s,t.yParityAndS);n(!(B(a)[0]&128),`non-canonical s`);let{networkV:o,v:s}=(function(t,r,i){if(t!=null){let n=Nr(t);return{networkV:n>=Mc?n:void 0,v:e.getNormalizedV(n)}}if(r!=null)return n(yr(r,32),`invalid yParityAndS`),{v:B(r)[0]&128?28:27};if(i!=null){switch(Lr(i,`sig.yParity`)){case 0:return{v:27};case 1:return{v:28}}n(!1,`invalid yParity`)}n(!1,`missing v`)})(t.v,t.yParityAndS,t.yParity),c=new e(Nc,i,a,s);return o&&(c.#r=o),n(t.yParity==null||Lr(t.yParity,`sig.yParity`)===c.yParity,`yParity mismatch`),n(t.yParityAndS==null||t.yParityAndS===c.yParityAndS,`yParityAndS mismatch`),c}},Ic=class e{#e;constructor(e){z(Cr(e)===32,`invalid private key`,`privateKey`,`[REDACTED]`),this.#e=V(e)}get privateKey(){return this.#e}get publicKey(){return e.computePublicKey(this.#e)}get compressedPublicKey(){return e.computePublicKey(this.#e,!0)}sign(e){z(Cr(e)===32,`invalid digest length`,`digest`,e);let t=Cc.sign(vr(e),vr(this.#e),{lowS:!0});return Fc.from({r:zr(t.r,32),s:zr(t.s,32),v:t.recovery?28:27})}computeSharedSecret(t){let n=e.computePublicKey(t);return V(Cc.getSharedSecret(vr(this.#e),B(n),!1))}static computePublicKey(e,t){let n=B(e,`key`);if(n.length===32)return V(Cc.getPublicKey(n,!!t));if(n.length===64){let e=new Uint8Array(65);e[0]=4,e.set(n,1),n=e}return V(Cc.ProjectivePoint.fromHex(n).toRawBytes(t))}static recoverPublicKey(e,t){z(Cr(e)===32,`invalid digest length`,`digest`,e);let n=Fc.from(t),r=Cc.Signature.fromCompact(vr(Sr([n.r,n.s])));r=r.addRecoveryBit(n.yParity);let i=r.recoverPublicKey(vr(e));return z(i!=null,`invalid signautre for digest`,`signature`,t),`0x`+i.toHex(!1)}static addPoints(t,n,r){let i=Cc.ProjectivePoint.fromHex(e.computePublicKey(t).substring(2)),a=Cc.ProjectivePoint.fromHex(e.computePublicKey(n).substring(2));return`0x`+i.add(a).toHex(!!r)}},Lc=BigInt(0),Rc=BigInt(36);function zc(e){e=e.toLowerCase();let t=e.substring(2).split(``),n=new Uint8Array(40);for(let e=0;e<40;e++)n[e]=t[e].charCodeAt(0);let r=B(U(n));for(let e=0;e<40;e+=2)r[e>>1]>>4>=8&&(t[e]=t[e].toUpperCase()),(r[e>>1]&15)>=8&&(t[e+1]=t[e+1].toUpperCase());return`0x`+t.join(``)}var Bc={};for(let e=0;e<10;e++)Bc[String(e)]=String(e);for(let e=0;e<26;e++)Bc[String.fromCharCode(65+e)]=String(10+e);var Vc=15;function Hc(e){e=e.toUpperCase(),e=e.substring(4)+e.substring(0,2)+`00`;let t=e.split(``).map(e=>Bc[e]).join(``);for(;t.length>=Vc;){let e=t.substring(0,Vc);t=parseInt(e,10)%97+t.substring(e.length)}let n=String(98-parseInt(t,10)%97);for(;n.length<2;)n=`0`+n;return n}var Uc=(function(){let e={};for(let t=0;t<36;t++){let n=`0123456789abcdefghijklmnopqrstuvwxyz`[t];e[n]=BigInt(t)}return e})();function Wc(e){e=e.toLowerCase();let t=Lc;for(let n=0;n<e.length;n++)t=t*Rc+Uc[e[n]];return t}function Gc(e){if(z(typeof e==`string`,`invalid address`,`address`,e),e.match(/^(0x)?[0-9a-fA-F]{40}$/)){e.startsWith(`0x`)||(e=`0x`+e);let t=zc(e);return z(!e.match(/([A-F].*[a-f])|([a-f].*[A-F])/)||t===e,`bad address checksum`,`address`,e),t}if(e.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){z(e.substring(2,4)===Hc(e),`bad icap checksum`,`address`,e);let t=Wc(e.substring(4)).toString(16);for(;t.length<40;)t=`0`+t;return zc(`0x`+t)}z(!1,`invalid address`,`address`,e)}function Kc(e){return e&&typeof e.getAddress==`function`}async function qc(e,t){let n=await t;return(n==null||n===`0x0000000000000000000000000000000000000000`)&&(R(typeof e!=`string`,`unconfigured name`,`UNCONFIGURED_NAME`,{value:e}),z(!1,`invalid AddressLike value; did not resolve to a value address`,`target`,e)),Gc(n)}function Jc(e,t){if(typeof e==`string`)return e.match(/^0x[0-9a-f]{40}$/i)?Gc(e):(R(t!=null,`ENS resolution requires a provider`,`UNSUPPORTED_OPERATION`,{operation:`resolveName`}),qc(e,t.resolveName(e)));if(Kc(e))return qc(e,e.getAddress());if(e&&typeof e.then==`function`)return qc(e,e);z(!1,`unsupported addressable value`,`target`,e)}var Yc={};function W(e,t){let n=!1;return t<0&&(n=!0,t*=-1),new Qc(Yc,`${n?``:`u`}int${t}`,e,{signed:n,width:t})}function Xc(e,t){return new Qc(Yc,`bytes${t||``}`,e,{size:t})}var Zc=Symbol.for(`_ethers_typed`),Qc=class e{type;value;#e;_typedSymbol;constructor(e,t,n,r){r??=null,gr(Yc,e,`Typed`),L(this,{_typedSymbol:Zc,type:t,value:n}),this.#e=r,this.format()}format(){if(this.type===`array`||this.type===`dynamicArray`)throw Error(``);return this.type===`tuple`?`tuple(${this.value.map(e=>e.format()).join(`,`)})`:this.type}defaultValue(){return 0}minValue(){return 0}maxValue(){return 0}isBigInt(){return!!this.type.match(/^u?int[0-9]+$/)}isData(){return this.type.startsWith(`bytes`)}isString(){return this.type===`string`}get tupleName(){if(this.type!==`tuple`)throw TypeError(`not a tuple`);return this.#e}get arrayLength(){if(this.type!==`array`)throw TypeError(`not an array`);return this.#e===!0?-1:this.#e===!1?this.value.length:null}static from(t,n){return new e(Yc,t,n)}static uint8(e){return W(e,8)}static uint16(e){return W(e,16)}static uint24(e){return W(e,24)}static uint32(e){return W(e,32)}static uint40(e){return W(e,40)}static uint48(e){return W(e,48)}static uint56(e){return W(e,56)}static uint64(e){return W(e,64)}static uint72(e){return W(e,72)}static uint80(e){return W(e,80)}static uint88(e){return W(e,88)}static uint96(e){return W(e,96)}static uint104(e){return W(e,104)}static uint112(e){return W(e,112)}static uint120(e){return W(e,120)}static uint128(e){return W(e,128)}static uint136(e){return W(e,136)}static uint144(e){return W(e,144)}static uint152(e){return W(e,152)}static uint160(e){return W(e,160)}static uint168(e){return W(e,168)}static uint176(e){return W(e,176)}static uint184(e){return W(e,184)}static uint192(e){return W(e,192)}static uint200(e){return W(e,200)}static uint208(e){return W(e,208)}static uint216(e){return W(e,216)}static uint224(e){return W(e,224)}static uint232(e){return W(e,232)}static uint240(e){return W(e,240)}static uint248(e){return W(e,248)}static uint256(e){return W(e,256)}static uint(e){return W(e,256)}static int8(e){return W(e,-8)}static int16(e){return W(e,-16)}static int24(e){return W(e,-24)}static int32(e){return W(e,-32)}static int40(e){return W(e,-40)}static int48(e){return W(e,-48)}static int56(e){return W(e,-56)}static int64(e){return W(e,-64)}static int72(e){return W(e,-72)}static int80(e){return W(e,-80)}static int88(e){return W(e,-88)}static int96(e){return W(e,-96)}static int104(e){return W(e,-104)}static int112(e){return W(e,-112)}static int120(e){return W(e,-120)}static int128(e){return W(e,-128)}static int136(e){return W(e,-136)}static int144(e){return W(e,-144)}static int152(e){return W(e,-152)}static int160(e){return W(e,-160)}static int168(e){return W(e,-168)}static int176(e){return W(e,-176)}static int184(e){return W(e,-184)}static int192(e){return W(e,-192)}static int200(e){return W(e,-200)}static int208(e){return W(e,-208)}static int216(e){return W(e,-216)}static int224(e){return W(e,-224)}static int232(e){return W(e,-232)}static int240(e){return W(e,-240)}static int248(e){return W(e,-248)}static int256(e){return W(e,-256)}static int(e){return W(e,-256)}static bytes1(e){return Xc(e,1)}static bytes2(e){return Xc(e,2)}static bytes3(e){return Xc(e,3)}static bytes4(e){return Xc(e,4)}static bytes5(e){return Xc(e,5)}static bytes6(e){return Xc(e,6)}static bytes7(e){return Xc(e,7)}static bytes8(e){return Xc(e,8)}static bytes9(e){return Xc(e,9)}static bytes10(e){return Xc(e,10)}static bytes11(e){return Xc(e,11)}static bytes12(e){return Xc(e,12)}static bytes13(e){return Xc(e,13)}static bytes14(e){return Xc(e,14)}static bytes15(e){return Xc(e,15)}static bytes16(e){return Xc(e,16)}static bytes17(e){return Xc(e,17)}static bytes18(e){return Xc(e,18)}static bytes19(e){return Xc(e,19)}static bytes20(e){return Xc(e,20)}static bytes21(e){return Xc(e,21)}static bytes22(e){return Xc(e,22)}static bytes23(e){return Xc(e,23)}static bytes24(e){return Xc(e,24)}static bytes25(e){return Xc(e,25)}static bytes26(e){return Xc(e,26)}static bytes27(e){return Xc(e,27)}static bytes28(e){return Xc(e,28)}static bytes29(e){return Xc(e,29)}static bytes30(e){return Xc(e,30)}static bytes31(e){return Xc(e,31)}static bytes32(e){return Xc(e,32)}static address(t){return new e(Yc,`address`,t)}static bool(t){return new e(Yc,`bool`,!!t)}static bytes(t){return new e(Yc,`bytes`,t)}static string(t){return new e(Yc,`string`,t)}static array(e,t){throw Error(`not implemented yet`)}static tuple(e,t){throw Error(`not implemented yet`)}static overrides(t){return new e(Yc,`overrides`,Object.assign({},t))}static isTyped(e){return e&&typeof e==`object`&&`_typedSymbol`in e&&e._typedSymbol===Zc}static dereference(t,n){if(e.isTyped(t)){if(t.type!==n)throw Error(`invalid type: expecetd ${n}, got ${t.type}`);return t.value}return t}},$c=class extends Ci{constructor(e){super(`address`,`address`,e,!1)}defaultValue(){return`0x0000000000000000000000000000000000000000`}encode(e,t){let n=Qc.dereference(t,`string`);try{n=Gc(n)}catch(e){return this._throwError(e.message,t)}return e.writeValue(n)}decode(e){return Gc(zr(e.readValue(),20))}},el=class extends Ci{coder;constructor(e){super(e.name,e.type,`_`,e.dynamic),this.coder=e}defaultValue(){return this.coder.defaultValue()}encode(e,t){return this.coder.encode(e,t)}decode(e){return this.coder.decode(e)}};function tl(e,t,n){let r=[];if(Array.isArray(n))r=n;else if(n&&typeof n==`object`){let e={};r=t.map(t=>{let r=t.localName;return R(r,`cannot encode object for signature with missing names`,`INVALID_ARGUMENT`,{argument:`values`,info:{coder:t},value:n}),R(!e[r],`cannot encode object for signature with duplicate names`,`INVALID_ARGUMENT`,{argument:`values`,info:{coder:t},value:n}),e[r]=!0,n[r]})}else z(!1,`invalid tuple value`,`tuple`,n);z(t.length===r.length,`types/value length mismatch`,`tuple`,n);let i=new wi,a=new wi,o=[];t.forEach((e,t)=>{let n=r[t];if(e.dynamic){let t=a.length;e.encode(a,n);let r=i.writeUpdatableValue();o.push(e=>{r(e+t)})}else e.encode(i,n)}),o.forEach(e=>{e(i.length)});let s=e.appendWriter(i);return s+=e.appendWriter(a),s}function nl(e,t){let n=[],r=[],i=e.subReader(0);return t.forEach(t=>{let a=null;if(t.dynamic){let n=e.readIndex(),r=i.subReader(n);try{a=t.decode(r)}catch(e){if(dr(e,`BUFFER_OVERRUN`))throw e;a=e,a.baseType=t.name,a.name=t.localName,a.type=t.type}}else try{a=t.decode(e)}catch(e){if(dr(e,`BUFFER_OVERRUN`))throw e;a=e,a.baseType=t.name,a.name=t.localName,a.type=t.type}if(a==null)throw Error(`investigate`);n.push(a),r.push(t.localName||null)}),xi.fromItems(n,r)}var rl=class extends Ci{coder;length;constructor(e,t,n){let r=e.type+`[`+(t>=0?t:``)+`]`,i=t===-1||e.dynamic;super(`array`,r,n,i),L(this,{coder:e,length:t})}defaultValue(){let e=this.coder.defaultValue(),t=[];for(let n=0;n<this.length;n++)t.push(e);return t}encode(e,t){let n=Qc.dereference(t,`array`);Array.isArray(n)||this._throwError(`expected array value`,n);let r=this.length;r===-1&&(r=n.length,e.writeValue(n.length)),pr(n.length,r,`coder array`+(this.localName?` `+this.localName:``));let i=[];for(let e=0;e<n.length;e++)i.push(this.coder);return tl(e,i,n)}decode(e){let t=this.length;t===-1&&(t=e.readIndex(),R(t*32<=e.dataLength,`insufficient data length`,`BUFFER_OVERRUN`,{buffer:e.bytes,offset:t*32,length:e.dataLength}));let n=[];for(let e=0;e<t;e++)n.push(new el(this.coder));return nl(e,n)}},il=class extends Ci{constructor(e){super(`bool`,`bool`,e,!1)}defaultValue(){return!1}encode(e,t){let n=Qc.dereference(t,`bool`);return e.writeValue(+!!n)}decode(e){return!!e.readValue()}},al=class extends Ci{constructor(e,t){super(e,e,t,!0)}defaultValue(){return`0x`}encode(e,t){t=vr(t);let n=e.writeValue(t.length);return n+=e.writeBytes(t),n}decode(e){return e.readBytes(e.readIndex(),!0)}},ol=class extends al{constructor(e){super(`bytes`,e)}decode(e){return V(super.decode(e))}},sl=class extends Ci{size;constructor(e,t){let n=`bytes`+String(e);super(n,n,t,!1),L(this,{size:e},{size:`number`})}defaultValue(){return`0x0000000000000000000000000000000000000000000000000000000000000000`.substring(0,2+this.size*2)}encode(e,t){let n=vr(Qc.dereference(t,this.type));return n.length!==this.size&&this._throwError(`incorrect data length`,t),e.writeBytes(n)}decode(e){return V(e.readBytes(this.size))}},cl=new Uint8Array([]),ll=class extends Ci{constructor(e){super(`null`,``,e,!1)}defaultValue(){return null}encode(e,t){return t!=null&&this._throwError(`not null`,t),e.writeBytes(cl)}decode(e){return e.readBytes(0),null}},ul=BigInt(0),dl=BigInt(1),fl=BigInt(`0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff`),pl=class extends Ci{size;signed;constructor(e,t,n){let r=(t?`int`:`uint`)+e*8;super(r,r,n,!1),L(this,{size:e,signed:t},{size:`number`,signed:`boolean`})}defaultValue(){return 0}encode(e,t){let n=Nr(Qc.dereference(t,this.type)),r=Mr(fl,256);if(this.signed){let e=Mr(r,this.size*8-1);(n>e||n<-(e+dl))&&this._throwError(`value out-of-bounds`,t),n=jr(n,256)}else(n<ul||n>Mr(r,this.size*8))&&this._throwError(`value out-of-bounds`,t);return e.writeValue(n)}decode(e){let t=Mr(e.readValue(),this.size*8);return this.signed&&(t=Ar(t,this.size*8)),t}},ml=class extends al{constructor(e){super(`string`,e)}defaultValue(){return``}encode(e,t){return super.encode(e,ei(Qc.dereference(t,`string`)))}decode(e){return ni(super.decode(e))}},hl=class extends Ci{coders;constructor(e,t){let n=!1,r=[];e.forEach(e=>{e.dynamic&&(n=!0),r.push(e.type)});let i=`tuple(`+r.join(`,`)+`)`;super(`tuple`,i,t,n),L(this,{coders:Object.freeze(e.slice())})}defaultValue(){let e=[];this.coders.forEach(t=>{e.push(t.defaultValue())});let t=this.coders.reduce((e,t)=>{let n=t.localName;return n&&(e[n]||(e[n]=0),e[n]++),e},{});return this.coders.forEach((n,r)=>{let i=n.localName;!i||t[i]!==1||(i===`length`&&(i=`_length`),e[i]??(e[i]=e[r]))}),Object.freeze(e)}encode(e,t){let n=Qc.dereference(t,`tuple`);return tl(e,this.coders,n)}decode(e){return nl(e,this.coders)}};function gl(e){return U(ei(e))}function _l(e,t){return{address:Gc(e),storageKeys:t.map((e,t)=>(z(yr(e,32),`invalid slot`,`storageKeys[${t}]`,e),e.toLowerCase()))}}function vl(e){if(Array.isArray(e))return e.map((t,n)=>Array.isArray(t)?(z(t.length===2,`invalid slot set`,`value[${n}]`,t),_l(t[0],t[1])):(z(typeof t==`object`&&!!t,`invalid address-slot set`,`value`,e),_l(t.address,t.storageKeys)));z(typeof e==`object`&&!!e,`invalid access list`,`value`,e);let t=Object.keys(e).map(t=>{let n=e[t].reduce((e,t)=>(e[t]=!0,e),{});return _l(t,Object.keys(n).sort())});return t.sort((e,t)=>e.address.localeCompare(t.address)),t}function yl(e){let t;return t=typeof e==`string`?Ic.computePublicKey(e,!1):e.publicKey,Gc(U(`0x`+t.substring(4)).substring(26))}function bl(e,t){return yl(Ic.recoverPublicKey(e,t))}var xl=BigInt(0),Sl=BigInt(2),Cl=BigInt(27),wl=BigInt(28),Tl=BigInt(35),El=BigInt(`0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff`),Dl=131072;function Ol(e,t){let n=e.toString(16);for(;n.length<2;)n=`0`+n;return n+=ts(t).substring(4),`0x`+n}function kl(e){return e===`0x`?null:Gc(e)}function Al(e,t){try{return vl(e)}catch(n){z(!1,n.message,t,e)}}function jl(e,t){return e===`0x`?0:Lr(e,t)}function Ml(e,t){if(e===`0x`)return xl;let n=Nr(e,t);return z(n<=El,`value exceeds uint size`,t,n),n}function Nl(e,t){let n=Nr(e,`value`),r=Br(n);return z(r.length<=32,`value too large`,`tx.${t}`,n),r}function Pl(e){return vl(e).map(e=>[e.address,e.storageKeys])}function Fl(e,t){z(Array.isArray(e),`invalid ${t}`,`value`,e);for(let t=0;t<e.length;t++)z(yr(e[t],32),"invalid ${ param } hash",`value[${t}]`,e[t]);return e}function Il(e){let t=si(e);z(Array.isArray(t)&&(t.length===9||t.length===6),`invalid field count for legacy transaction`,`data`,e);let n={type:0,nonce:jl(t[0],`nonce`),gasPrice:Ml(t[1],`gasPrice`),gasLimit:Ml(t[2],`gasLimit`),to:kl(t[3]),value:Ml(t[4],`value`),data:V(t[5]),chainId:xl};if(t.length===6)return n;let r=Ml(t[6],`v`),i=Ml(t[7],`r`),a=Ml(t[8],`s`);if(i===xl&&a===xl)n.chainId=r;else{let e=(r-Tl)/Sl;e<xl&&(e=xl),n.chainId=e,z(e!==xl||r===Cl||r===wl,`non-canonical legacy v`,`v`,t[6]),n.signature=Fc.from({r:Er(t[7],32),s:Er(t[8],32),v:r})}return n}function Ll(e,t){let n=[Nl(e.nonce,`nonce`),Nl(e.gasPrice||0,`gasPrice`),Nl(e.gasLimit,`gasLimit`),e.to||`0x`,Nl(e.value,`value`),e.data],r=xl;if(e.chainId!=xl)r=Nr(e.chainId,`tx.chainId`),z(!t||t.networkV==null||t.legacyChainId===r,`tx.chainId/sig.v mismatch`,`sig`,t);else if(e.signature){let t=e.signature.legacyChainId;t!=null&&(r=t)}if(!t)return r!==xl&&(n.push(Br(r)),n.push(`0x`),n.push(`0x`)),di(n);let i=BigInt(27+t.yParity);return r===xl?BigInt(t.v)!==i&&z(!1,`tx.chainId/sig.v mismatch`,`sig`,t):i=Fc.getChainIdV(r,t.v),n.push(Br(i)),n.push(Br(t.r)),n.push(Br(t.s)),di(n)}function Rl(e,t){let n;try{if(n=jl(t[0],`yParity`),n!==0&&n!==1)throw Error(`bad yParity`)}catch{z(!1,`invalid yParity`,`yParity`,t[0])}let r=Er(t[1],32),i=Er(t[2],32);e.signature=Fc.from({r,s:i,yParity:n})}function zl(e){let t=si(B(e).slice(1));z(Array.isArray(t)&&(t.length===9||t.length===12),`invalid field count for transaction type: 2`,`data`,V(e));let n={type:2,chainId:Ml(t[0],`chainId`),nonce:jl(t[1],`nonce`),maxPriorityFeePerGas:Ml(t[2],`maxPriorityFeePerGas`),maxFeePerGas:Ml(t[3],`maxFeePerGas`),gasPrice:null,gasLimit:Ml(t[4],`gasLimit`),to:kl(t[5]),value:Ml(t[6],`value`),data:V(t[7]),accessList:Al(t[8],`accessList`)};return t.length===9||Rl(n,t.slice(9)),n}function Bl(e,t){let n=[Nl(e.chainId,`chainId`),Nl(e.nonce,`nonce`),Nl(e.maxPriorityFeePerGas||0,`maxPriorityFeePerGas`),Nl(e.maxFeePerGas||0,`maxFeePerGas`),Nl(e.gasLimit,`gasLimit`),e.to||`0x`,Nl(e.value,`value`),e.data,Pl(e.accessList||[])];return t&&(n.push(Nl(t.yParity,`yParity`)),n.push(Br(t.r)),n.push(Br(t.s))),Sr([`0x02`,di(n)])}function Vl(e){let t=si(B(e).slice(1));z(Array.isArray(t)&&(t.length===8||t.length===11),`invalid field count for transaction type: 1`,`data`,V(e));let n={type:1,chainId:Ml(t[0],`chainId`),nonce:jl(t[1],`nonce`),gasPrice:Ml(t[2],`gasPrice`),gasLimit:Ml(t[3],`gasLimit`),to:kl(t[4]),value:Ml(t[5],`value`),data:V(t[6]),accessList:Al(t[7],`accessList`)};return t.length===8||Rl(n,t.slice(8)),n}function Hl(e,t){let n=[Nl(e.chainId,`chainId`),Nl(e.nonce,`nonce`),Nl(e.gasPrice||0,`gasPrice`),Nl(e.gasLimit,`gasLimit`),e.to||`0x`,Nl(e.value,`value`),e.data,Pl(e.accessList||[])];return t&&(n.push(Nl(t.yParity,`recoveryParam`)),n.push(Br(t.r)),n.push(Br(t.s))),Sr([`0x01`,di(n)])}function Ul(e){let t=si(B(e).slice(1)),n=`3`,r=null;if(t.length===4&&Array.isArray(t[0])){n=`3 (network format)`;let e=t[1],i=t[2],a=t[3];z(Array.isArray(e),`invalid network format: blobs not an array`,`fields[1]`,e),z(Array.isArray(i),`invalid network format: commitments not an array`,`fields[2]`,i),z(Array.isArray(a),`invalid network format: proofs not an array`,`fields[3]`,a),z(e.length===i.length,`invalid network format: blobs/commitments length mismatch`,`fields`,t),z(e.length===a.length,`invalid network format: blobs/proofs length mismatch`,`fields`,t),r=[];for(let n=0;n<t[1].length;n++)r.push({data:e[n],commitment:i[n],proof:a[n]});t=t[0]}z(Array.isArray(t)&&(t.length===11||t.length===14),`invalid field count for transaction type: ${n}`,`data`,V(e));let i={type:3,chainId:Ml(t[0],`chainId`),nonce:jl(t[1],`nonce`),maxPriorityFeePerGas:Ml(t[2],`maxPriorityFeePerGas`),maxFeePerGas:Ml(t[3],`maxFeePerGas`),gasPrice:null,gasLimit:Ml(t[4],`gasLimit`),to:kl(t[5]),value:Ml(t[6],`value`),data:V(t[7]),accessList:Al(t[8],`accessList`),maxFeePerBlobGas:Ml(t[9],`maxFeePerBlobGas`),blobVersionedHashes:t[10]};r&&(i.blobs=r),z(i.to!=null,`invalid address for transaction type: ${n}`,`data`,e),z(Array.isArray(i.blobVersionedHashes),`invalid blobVersionedHashes: must be an array`,`data`,e);for(let t=0;t<i.blobVersionedHashes.length;t++)z(yr(i.blobVersionedHashes[t],32),`invalid blobVersionedHash at index ${t}: must be length 32`,`data`,e);return t.length===11||Rl(i,t.slice(11)),i}function Wl(e,t,n){let r=[Nl(e.chainId,`chainId`),Nl(e.nonce,`nonce`),Nl(e.maxPriorityFeePerGas||0,`maxPriorityFeePerGas`),Nl(e.maxFeePerGas||0,`maxFeePerGas`),Nl(e.gasLimit,`gasLimit`),e.to||`0x0000000000000000000000000000000000000000`,Nl(e.value,`value`),e.data,Pl(e.accessList||[]),Nl(e.maxFeePerBlobGas||0,`maxFeePerBlobGas`),Fl(e.blobVersionedHashes||[],`blobVersionedHashes`)];return t&&(r.push(Nl(t.yParity,`yParity`)),r.push(Br(t.r)),r.push(Br(t.s)),n)?Sr([`0x03`,di([r,n.map(e=>e.data),n.map(e=>e.commitment),n.map(e=>e.proof)])]):Sr([`0x03`,di(r)])}var Gl=class e{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p;#m;#h;get type(){return this.#e}set type(e){switch(e){case null:this.#e=null;break;case 0:case`legacy`:this.#e=0;break;case 1:case`berlin`:case`eip-2930`:this.#e=1;break;case 2:case`london`:case`eip-1559`:this.#e=2;break;case 3:case`cancun`:case`eip-4844`:this.#e=3;break;default:z(!1,`unsupported transaction type`,`type`,e)}}get typeName(){switch(this.type){case 0:return`legacy`;case 1:return`eip-2930`;case 2:return`eip-1559`;case 3:return`eip-4844`}return null}get to(){let e=this.#t;return e==null&&this.type===3?wc:e}set to(e){this.#t=e==null?null:Gc(e)}get nonce(){return this.#r}set nonce(e){this.#r=Lr(e,`value`)}get gasLimit(){return this.#i}set gasLimit(e){this.#i=Nr(e)}get gasPrice(){let e=this.#a;return e==null&&(this.type===0||this.type===1)?xl:e}set gasPrice(e){this.#a=e==null?null:Nr(e,`gasPrice`)}get maxPriorityFeePerGas(){return this.#o??(this.type===2||this.type===3?xl:null)}set maxPriorityFeePerGas(e){this.#o=e==null?null:Nr(e,`maxPriorityFeePerGas`)}get maxFeePerGas(){return this.#s??(this.type===2||this.type===3?xl:null)}set maxFeePerGas(e){this.#s=e==null?null:Nr(e,`maxFeePerGas`)}get data(){return this.#n}set data(e){this.#n=V(e)}get value(){return this.#c}set value(e){this.#c=Nr(e,`value`)}get chainId(){return this.#l}set chainId(e){this.#l=Nr(e)}get signature(){return this.#u||null}set signature(e){this.#u=e==null?null:Fc.from(e)}get accessList(){return(this.#d||null)??(this.type===1||this.type===2||this.type===3?[]:null)}set accessList(e){this.#d=e==null?null:vl(e)}get maxFeePerBlobGas(){let e=this.#f;return e==null&&this.type===3?xl:e}set maxFeePerBlobGas(e){this.#f=e==null?null:Nr(e,`maxFeePerBlobGas`)}get blobVersionedHashes(){let e=this.#p;return e==null&&this.type===3?[]:e}set blobVersionedHashes(e){if(e!=null){z(Array.isArray(e),`blobVersionedHashes must be an Array`,`value`,e),e=e.slice();for(let t=0;t<e.length;t++)z(yr(e[t],32),`invalid blobVersionedHash`,`value[${t}]`,e[t])}this.#p=e}get blobs(){return this.#h==null?null:this.#h.map(e=>Object.assign({},e))}set blobs(e){if(e==null){this.#h=null;return}let t=[],n=[];for(let r=0;r<e.length;r++){let i=e[r];if(br(i)){R(this.#m,`adding a raw blob requires a KZG library`,`UNSUPPORTED_OPERATION`,{operation:`set blobs()`});let e=B(i);if(z(e.length<=Dl,`blob is too large`,`blobs[${r}]`,i),e.length!==Dl){let t=new Uint8Array(Dl);t.set(e),e=t}let a=this.#m.blobToKzgCommitment(e),o=V(this.#m.computeBlobKzgProof(e,a));t.push({data:V(e),commitment:V(a),proof:o}),n.push(Ol(1,a))}else{let e=V(i.commitment);t.push({data:V(i.data),commitment:e,proof:V(i.proof)}),n.push(Ol(1,e))}}this.#h=t,this.#p=n}get kzg(){return this.#m}set kzg(e){this.#m=e}constructor(){this.#e=null,this.#t=null,this.#r=0,this.#i=xl,this.#a=null,this.#o=null,this.#s=null,this.#n=`0x`,this.#c=xl,this.#l=xl,this.#u=null,this.#d=null,this.#f=null,this.#p=null,this.#h=null,this.#m=null}get hash(){return this.signature==null?null:U(this.#g(!0,!1))}get unsignedHash(){return U(this.unsignedSerialized)}get from(){return this.signature==null?null:bl(this.unsignedHash,this.signature)}get fromPublicKey(){return this.signature==null?null:Ic.recoverPublicKey(this.unsignedHash,this.signature)}isSigned(){return this.signature!=null}#g(e,t){R(!e||this.signature!=null,`cannot serialize unsigned transaction; maybe you meant .unsignedSerialized`,`UNSUPPORTED_OPERATION`,{operation:`.serialized`});let n=e?this.signature:null;switch(this.inferType()){case 0:return Ll(this,n);case 1:return Hl(this,n);case 2:return Bl(this,n);case 3:return Wl(this,n,t?this.blobs:null)}R(!1,`unsupported transaction type`,`UNSUPPORTED_OPERATION`,{operation:`.serialized`})}get serialized(){return this.#g(!0,!0)}get unsignedSerialized(){return this.#g(!1,!1)}inferType(){let e=this.inferTypes();return e.indexOf(2)>=0?2:e.pop()}inferTypes(){let e=this.gasPrice!=null,t=this.maxFeePerGas!=null||this.maxPriorityFeePerGas!=null,n=this.accessList!=null,r=this.#f!=null||this.#p;this.maxFeePerGas!=null&&this.maxPriorityFeePerGas!=null&&R(this.maxFeePerGas>=this.maxPriorityFeePerGas,`priorityFee cannot be more than maxFee`,`BAD_DATA`,{value:this}),R(!t||this.type!==0&&this.type!==1,`transaction type cannot have maxFeePerGas or maxPriorityFeePerGas`,`BAD_DATA`,{value:this}),R(this.type!==0||!n,`legacy transaction cannot have accessList`,`BAD_DATA`,{value:this});let i=[];return this.type==null?t?i.push(2):e?(i.push(1),n||i.push(0)):n?(i.push(1),i.push(2)):r&&this.to?i.push(3):(i.push(0),i.push(1),i.push(2),i.push(3)):i.push(this.type),i.sort(),i}isLegacy(){return this.type===0}isBerlin(){return this.type===1}isLondon(){return this.type===2}isCancun(){return this.type===3}clone(){return e.from(this)}toJSON(){let e=e=>e==null?null:e.toString();return{type:this.type,to:this.to,data:this.data,nonce:this.nonce,gasLimit:e(this.gasLimit),gasPrice:e(this.gasPrice),maxPriorityFeePerGas:e(this.maxPriorityFeePerGas),maxFeePerGas:e(this.maxFeePerGas),value:e(this.value),chainId:e(this.chainId),sig:this.signature?this.signature.toJSON():null,accessList:this.accessList}}static from(t){if(t==null)return new e;if(typeof t==`string`){let n=B(t);if(n[0]>=127)return e.from(Il(n));switch(n[0]){case 1:return e.from(Vl(n));case 2:return e.from(zl(n));case 3:return e.from(Ul(n))}R(!1,`unsupported transaction type`,`UNSUPPORTED_OPERATION`,{operation:`from`})}let n=new e;return t.type!=null&&(n.type=t.type),t.to!=null&&(n.to=t.to),t.nonce!=null&&(n.nonce=t.nonce),t.gasLimit!=null&&(n.gasLimit=t.gasLimit),t.gasPrice!=null&&(n.gasPrice=t.gasPrice),t.maxPriorityFeePerGas!=null&&(n.maxPriorityFeePerGas=t.maxPriorityFeePerGas),t.maxFeePerGas!=null&&(n.maxFeePerGas=t.maxFeePerGas),t.maxFeePerBlobGas!=null&&(n.maxFeePerBlobGas=t.maxFeePerBlobGas),t.data!=null&&(n.data=t.data),t.value!=null&&(n.value=t.value),t.chainId!=null&&(n.chainId=t.chainId),t.signature!=null&&(n.signature=Fc.from(t.signature)),t.accessList!=null&&(n.accessList=t.accessList),t.blobVersionedHashes!=null&&(n.blobVersionedHashes=t.blobVersionedHashes),t.kzg!=null&&(n.kzg=t.kzg),t.blobs!=null&&(n.blobs=t.blobs),t.hash!=null&&(z(n.isSigned(),`unsigned transaction cannot define '.hash'`,`tx`,t),z(n.hash===t.hash,`hash mismatch`,`tx`,t)),t.from!=null&&(z(n.isSigned(),`unsigned transaction cannot define '.from'`,`tx`,t),z(n.from.toLowerCase()===(t.from||``).toLowerCase(),`from mismatch`,`tx`,t)),n}};function Kl(e){return typeof e==`string`&&(e=ei(e)),U(Sr([ei(Ec),ei(String(e.length)),e]))}var ql=new Uint8Array(32);ql.fill(0);var Jl=BigInt(-1),Yl=BigInt(0),Xl=BigInt(1),Zl=BigInt(`0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff`);function Ql(e){let t=B(e),n=t.length%32;return n?Sr([t,ql.slice(n)]):V(t)}var $l=zr(Xl,32),eu=zr(Yl,32),tu={name:`string`,version:`string`,chainId:`uint256`,verifyingContract:`address`,salt:`bytes32`},nu=[`name`,`version`,`chainId`,`verifyingContract`,`salt`];function ru(e){return function(t){return z(typeof t==`string`,`invalid domain value for ${JSON.stringify(e)}`,`domain.${e}`,t),t}}var iu={name:ru(`name`),version:ru(`version`),chainId:function(e){let t=Nr(e,`domain.chainId`);return z(t>=0,`invalid chain ID`,`domain.chainId`,e),Number.isSafeInteger(t)?Number(t):Vr(t)},verifyingContract:function(e){try{return Gc(e).toLowerCase()}catch{}z(!1,`invalid domain value "verifyingContract"`,`domain.verifyingContract`,e)},salt:function(e){let t=B(e,`domain.salt`);return z(t.length===32,`invalid domain value "salt"`,`domain.salt`,e),V(t)}};function au(e){{let t=e.match(/^(u?)int(\d+)$/);if(t){let n=t[1]===``,r=parseInt(t[2]);z(r%8==0&&r!==0&&r<=256&&t[2]===String(r),`invalid numeric width`,`type`,e);let i=Mr(Zl,n?r-1:r),a=n?(i+Xl)*Jl:Yl;return function(t){let r=Nr(t,`value`);return z(r>=a&&r<=i,`value out-of-bounds for ${e}`,`value`,r),zr(n?jr(r,256):r,32)}}}{let t=e.match(/^bytes(\d+)$/);if(t){let n=parseInt(t[1]);return z(n!==0&&n<=32&&t[1]===String(n),`invalid bytes width`,`type`,e),function(t){return z(B(t).length===n,`invalid length for ${e}`,`value`,t),Ql(t)}}}switch(e){case`address`:return function(e){return Er(Gc(e),32)};case`bool`:return function(e){return e?$l:eu};case`bytes`:return function(e){return U(e)};case`string`:return function(e){return gl(e)}}return null}function ou(e,t){return`${e}(${t.map(({name:e,type:t})=>t+` `+e).join(`,`)})`}function su(e){let t=e.match(/^([^\x5b]*)((\x5b\d*\x5d)*)(\x5b(\d*)\x5d)$/);return t?{base:t[1],index:t[2]+t[4],array:{base:t[1],prefix:t[1]+t[2],count:t[5]?parseInt(t[5]):-1}}:{base:e}}var cu=class e{primaryType;#e;get types(){return JSON.parse(this.#e)}#t;#n;constructor(e){this.#t=new Map,this.#n=new Map;let t=new Map,n=new Map,r=new Map,i={};Object.keys(e).forEach(a=>{i[a]=e[a].map(({name:t,type:n})=>{let{base:r,index:i}=su(n);return r===`int`&&!e.int&&(r=`int256`),r===`uint`&&!e.uint&&(r=`uint256`),{name:t,type:r+(i||``)}}),t.set(a,new Set),n.set(a,[]),r.set(a,new Set)}),this.#e=JSON.stringify(i);for(let r in i){let a=new Set;for(let o of i[r]){z(!a.has(o.name),`duplicate variable name ${JSON.stringify(o.name)} in ${JSON.stringify(r)}`,`types`,e),a.add(o.name);let i=su(o.type).base;z(i!==r,`circular type reference to ${JSON.stringify(i)}`,`types`,e),!au(i)&&(z(n.has(i),`unknown type ${JSON.stringify(i)}`,`types`,e),n.get(i).push(r),t.get(r).add(i))}}let a=Array.from(n.keys()).filter(e=>n.get(e).length===0);z(a.length!==0,`missing primary type`,`types`,e),z(a.length===1,`ambiguous primary types or unused types: ${a.map(e=>JSON.stringify(e)).join(`, `)}`,`types`,e),L(this,{primaryType:a[0]});function o(i,a){z(!a.has(i),`circular type reference to ${JSON.stringify(i)}`,`types`,e),a.add(i);for(let e of t.get(i))if(n.has(e)){o(e,a);for(let t of a)r.get(t).add(e)}a.delete(i)}o(this.primaryType,new Set);for(let[e,t]of r){let n=Array.from(t);n.sort(),this.#t.set(e,ou(e,i[e])+n.map(e=>ou(e,i[e])).join(``))}}getEncoder(e){let t=this.#n.get(e);return t||(t=this.#r(e),this.#n.set(e,t)),t}#r(e){{let t=au(e);if(t)return t}let t=su(e).array;if(t){let e=t.prefix,n=this.getEncoder(e);return r=>{z(t.count===-1||t.count===r.length,`array length mismatch; expected length ${t.count}`,`value`,r);let i=r.map(n);return this.#t.has(e)&&(i=i.map(U)),U(Sr(i))}}let n=this.types[e];if(n){let t=gl(this.#t.get(e));return e=>{let r=n.map(({name:t,type:n})=>{let r=this.getEncoder(n)(e[t]);return this.#t.has(n)?U(r):r});return r.unshift(t),Sr(r)}}z(!1,`unknown type: ${e}`,`type`,e)}encodeType(e){let t=this.#t.get(e);return z(t,`unknown type: ${JSON.stringify(e)}`,`name`,e),t}encodeData(e,t){return this.getEncoder(e)(t)}hashStruct(e,t){return U(this.encodeData(e,t))}encode(e){return this.encodeData(this.primaryType,e)}hash(e){return this.hashStruct(this.primaryType,e)}_visit(e,t,n){if(au(e))return n(e,t);let r=su(e).array;if(r)return z(r.count===-1||r.count===t.length,`array length mismatch; expected length ${r.count}`,`value`,t),t.map(e=>this._visit(r.prefix,e,n));let i=this.types[e];if(i)return i.reduce((e,{name:r,type:i})=>(e[r]=this._visit(i,t[r],n),e),{});z(!1,`unknown type: ${e}`,`type`,e)}visit(e,t){return this._visit(this.primaryType,e,t)}static from(t){return new e(t)}static getPrimaryType(t){return e.from(t).primaryType}static hashStruct(t,n,r){return e.from(n).hashStruct(t,r)}static hashDomain(t){let n=[];for(let e in t){if(t[e]==null)continue;let r=tu[e];z(r,`invalid typed-data domain key: ${JSON.stringify(e)}`,`domain`,t),n.push({name:e,type:r})}return n.sort((e,t)=>nu.indexOf(e.name)-nu.indexOf(t.name)),e.hashStruct(`EIP712Domain`,{EIP712Domain:n},t)}static encode(t,n,r){return Sr([`0x1901`,e.hashDomain(t),e.from(n).hash(r)])}static hash(t,n,r){return U(e.encode(t,n,r))}static async resolveNames(t,n,r,i){t=Object.assign({},t);for(let e in t)t[e]??delete t[e];let a={};t.verifyingContract&&!yr(t.verifyingContract,20)&&(a[t.verifyingContract]=`0x`);let o=e.from(n);o.visit(r,(e,t)=>(e===`address`&&!yr(t,20)&&(a[t]=`0x`),t));for(let e in a)a[e]=await i(e);return t.verifyingContract&&a[t.verifyingContract]&&(t.verifyingContract=a[t.verifyingContract]),r=o.visit(r,(e,t)=>e===`address`&&a[t]?a[t]:t),{domain:t,value:r}}static getPayload(t,n,r){e.hashDomain(t);let i={},a=[];nu.forEach(e=>{let n=t[e];n!=null&&(i[e]=iu[e](n),a.push({name:e,type:tu[e]}))});let o=e.from(n);n=o.types;let s=Object.assign({},n);return z(s.EIP712Domain==null,`types must not contain EIP712Domain type`,`types.EIP712Domain`,n),s.EIP712Domain=a,o.encode(r),{types:s,domain:i,primaryType:o.primaryType,message:o.visit(r,(e,t)=>{if(e.match(/^bytes(\d*)/))return V(B(t));if(e.match(/^u?int/))return Nr(t).toString();switch(e){case`address`:return t.toLowerCase();case`bool`:return!!t;case`string`:return z(typeof t==`string`,`invalid string`,`value`,t),t}z(!1,`unsupported type`,`type`,e)})}}};function lu(e){let t=new Set;return e.forEach(e=>t.add(e)),Object.freeze(t)}lu(`external public payable override`.split(` `));var uu=`constant external internal payable private public pure view override`;lu(uu.split(` `));var du=`constructor error event fallback function receive struct`;lu(du.split(` `));var fu=`calldata memory storage payable indexed`,pu=lu(fu.split(` `)),mu=lu([du,fu,`tuple returns`,uu].join(` `).split(` `)),hu={"(":`OPEN_PAREN`,")":`CLOSE_PAREN`,"[":`OPEN_BRACKET`,"]":`CLOSE_BRACKET`,",":`COMMA`,"@":`AT`},gu=RegExp(`^(\\s*)`),_u=RegExp(`^([0-9]+)`),vu=RegExp(`^([a-zA-Z$_][a-zA-Z0-9$_]*)`),yu=RegExp(`^([a-zA-Z$_][a-zA-Z0-9$_]*)$`),bu=RegExp(`^(address|bool|bytes([0-9]*)|string|u?int([0-9]*))$`),xu=class e{#e;#t;get offset(){return this.#e}get length(){return this.#t.length-this.#e}constructor(e){this.#e=0,this.#t=e.slice()}clone(){return new e(this.#t)}reset(){this.#e=0}#n(t=0,n=0){return new e(this.#t.slice(t,n).map(e=>Object.freeze(Object.assign({},e,{match:e.match-t,linkBack:e.linkBack-t,linkNext:e.linkNext-t}))))}popKeyword(e){let t=this.peek();if(t.type!==`KEYWORD`||!e.has(t.text))throw Error(`expected keyword ${t.text}`);return this.pop().text}popType(e){if(this.peek().type!==e){let t=this.peek();throw Error(`expected ${e}; got ${t.type} ${JSON.stringify(t.text)}`)}return this.pop().text}popParen(){let e=this.peek();if(e.type!==`OPEN_PAREN`)throw Error(`bad start`);let t=this.#n(this.#e+1,e.match+1);return this.#e=e.match+1,t}popParams(){let e=this.peek();if(e.type!==`OPEN_PAREN`)throw Error(`bad start`);let t=[];for(;this.#e<e.match-1;){let e=this.peek().linkNext;t.push(this.#n(this.#e+1,e)),this.#e=e}return this.#e=e.match+1,t}peek(){if(this.#e>=this.#t.length)throw Error(`out-of-bounds`);return this.#t[this.#e]}peekKeyword(e){let t=this.peekType(`KEYWORD`);return t!=null&&e.has(t)?t:null}peekType(e){if(this.length===0)return null;let t=this.peek();return t.type===e?t.text:null}pop(){let e=this.peek();return this.#e++,e}toString(){let e=[];for(let t=this.#e;t<this.#t.length;t++){let n=this.#t[t];e.push(`${n.type}:${n.text}`)}return`<TokenString ${e.join(` `)}>`}};function Su(e){let t=[],n=t=>{let n=a<e.length?JSON.stringify(e[a]):`$EOI`;throw Error(`invalid token ${n} at ${a}: ${t}`)},r=[],i=[],a=0;for(;a<e.length;){let o=e.substring(a),s=o.match(gu);s&&(a+=s[1].length,o=e.substring(a));let c={depth:r.length,linkBack:-1,linkNext:-1,match:-1,type:``,text:``,offset:a,value:-1};t.push(c);let l=hu[o[0]]||``;if(l){if(c.type=l,c.text=o[0],a++,l===`OPEN_PAREN`)r.push(t.length-1),i.push(t.length-1);else if(l==`CLOSE_PAREN`)r.length===0&&n(`no matching open bracket`),c.match=r.pop(),t[c.match].match=t.length-1,c.depth--,c.linkBack=i.pop(),t[c.linkBack].linkNext=t.length-1;else if(l===`COMMA`)c.linkBack=i.pop(),t[c.linkBack].linkNext=t.length-1,i.push(t.length-1);else if(l===`OPEN_BRACKET`)c.type=`BRACKET`;else if(l===`CLOSE_BRACKET`){let e=t.pop().text;if(t.length>0&&t[t.length-1].type===`NUMBER`){let n=t.pop().text;e=n+e,t[t.length-1].value=Lr(n)}if(t.length===0||t[t.length-1].type!==`BRACKET`)throw Error(`missing opening bracket`);t[t.length-1].text+=e}continue}if(s=o.match(vu),s){if(c.text=s[1],a+=c.text.length,mu.has(c.text)){c.type=`KEYWORD`;continue}if(c.text.match(bu)){c.type=`TYPE`;continue}c.type=`ID`;continue}if(s=o.match(_u),s){c.text=s[1],c.type=`NUMBER`,a+=c.text.length;continue}throw Error(`unexpected token ${JSON.stringify(o[0])} at position ${a}`)}return new xu(t.map(e=>Object.freeze(e)))}function Cu(e,t){let n=new Set;for(;;){let r=e.peekType(`KEYWORD`);if(r==null||t&&!t.has(r))break;if(e.pop(),n.has(r))throw Error(`duplicate keywords: ${JSON.stringify(r)}`);n.add(r)}return Object.freeze(n)}var wu=new RegExp(/^(.*)\[([0-9]*)\]$/);function Tu(e){let t=e.match(bu);if(z(t,`invalid type`,`type`,e),e===`uint`)return`uint256`;if(e===`int`)return`int256`;if(t[2]){let n=parseInt(t[2]);z(n!==0&&n<=32,`invalid bytes length`,`type`,e)}else if(t[3]){let n=parseInt(t[3]);z(n!==0&&n<=256&&n%8==0,`invalid numeric width`,`type`,e)}return e}var Eu={},Du=Symbol.for(`_ethers_internal`),Ou=`_ParamTypeInternal`,ku=class e{name;type;baseType;indexed;components;arrayLength;arrayChildren;constructor(e,t,n,r,i,a,o,s){if(gr(e,Eu,`ParamType`),Object.defineProperty(this,Du,{value:Ou}),a&&=Object.freeze(a.slice()),r===`array`){if(o==null||s==null)throw Error(``)}else if(o!=null||s!=null)throw Error(``);if(r===`tuple`){if(a==null)throw Error(``)}else if(a!=null)throw Error(``);L(this,{name:t,type:n,baseType:r,indexed:i,components:a,arrayLength:o,arrayChildren:s})}format(e){if(e??=`sighash`,e===`json`){let t=this.name||``;if(this.isArray()){let e=JSON.parse(this.arrayChildren.format(`json`));return e.name=t,e.type+=`[${this.arrayLength<0?``:String(this.arrayLength)}]`,JSON.stringify(e)}let n={type:this.baseType===`tuple`?`tuple`:this.type,name:t};return typeof this.indexed==`boolean`&&(n.indexed=this.indexed),this.isTuple()&&(n.components=this.components.map(t=>JSON.parse(t.format(e)))),JSON.stringify(n)}let t=``;return this.isArray()?(t+=this.arrayChildren.format(e),t+=`[${this.arrayLength<0?``:String(this.arrayLength)}]`):this.isTuple()?t+=`(`+this.components.map(t=>t.format(e)).join(e===`full`?`, `:`,`)+`)`:t+=this.type,e!==`sighash`&&(this.indexed===!0&&(t+=` indexed`),e===`full`&&this.name&&(t+=` `+this.name)),t}isArray(){return this.baseType===`array`}isTuple(){return this.baseType===`tuple`}isIndexable(){return this.indexed!=null}walk(e,t){if(this.isArray()){if(!Array.isArray(e))throw Error(`invalid array value`);if(this.arrayLength!==-1&&e.length!==this.arrayLength)throw Error(`array is wrong length`);let n=this;return e.map(e=>n.arrayChildren.walk(e,t))}if(this.isTuple()){if(!Array.isArray(e))throw Error(`invalid tuple value`);if(e.length!==this.components.length)throw Error(`array is wrong length`);let n=this;return e.map((e,r)=>n.components[r].walk(e,t))}return t(this.type,e)}#e(e,t,n,r){if(this.isArray()){if(!Array.isArray(t))throw Error(`invalid array value`);if(this.arrayLength!==-1&&t.length!==this.arrayLength)throw Error(`array is wrong length`);let i=this.arrayChildren,a=t.slice();a.forEach((t,r)=>{i.#e(e,t,n,e=>{a[r]=e})}),r(a);return}if(this.isTuple()){let i=this.components,a;if(Array.isArray(t))a=t.slice();else{if(typeof t!=`object`||!t)throw Error(`invalid tuple value`);a=i.map(e=>{if(!e.name)throw Error(`cannot use object value with unnamed components`);if(!(e.name in t))throw Error(`missing value for component ${e.name}`);return t[e.name]})}if(a.length!==this.components.length)throw Error(`array is wrong length`);a.forEach((t,r)=>{i[r].#e(e,t,n,e=>{a[r]=e})}),r(a);return}let i=n(this.type,t);i.then?e.push((async function(){r(await i)})()):r(i)}async walkAsync(e,t){let n=[],r=[e];return this.#e(n,e,t,e=>{r[0]=e}),n.length&&await Promise.all(n),r[0]}static from(t,n){if(e.isParamType(t))return t;if(typeof t==`string`)try{return e.from(Su(t),n)}catch{z(!1,`invalid param type`,`obj`,t)}else if(t instanceof xu){let r=``,i=``,a=null;Cu(t,lu([`tuple`])).has(`tuple`)||t.peekType(`OPEN_PAREN`)?(i=`tuple`,a=t.popParams().map(t=>e.from(t)),r=`tuple(${a.map(e=>e.format()).join(`,`)})`):(r=Tu(t.popType(`TYPE`)),i=r);let o=null,s=null;for(;t.length&&t.peekType(`BRACKET`);){let n=t.pop();o=new e(Eu,``,r,i,null,a,s,o),s=n.value,r+=n.text,i=`array`,a=null}let c=null;if(Cu(t,pu).has(`indexed`)){if(!n)throw Error(``);c=!0}let l=t.peekType(`ID`)?t.pop().text:``;if(t.length)throw Error(`leftover tokens`);return new e(Eu,l,r,i,c,a,s,o)}let r=t.name;z(!r||typeof r==`string`&&r.match(yu),`invalid name`,`obj.name`,r);let i=t.indexed;i!=null&&(z(n,`parameter cannot be indexed`,`obj.indexed`,t.indexed),i=!!i);let a=t.type,o=a.match(wu);if(o){let n=parseInt(o[2]||`-1`),s=e.from({type:o[1],components:t.components});return new e(Eu,r||``,a,`array`,i,null,n,s)}if(a===`tuple`||a.startsWith(`tuple(`)||a.startsWith(`(`)){let n=t.components==null?null:t.components.map(t=>e.from(t));return new e(Eu,r||``,a,`tuple`,i,n,null,null)}return a=Tu(t.type),new e(Eu,r||``,a,a,i,null,null,null)}static isParamType(e){return e&&e[Du]===Ou}},Au=new Map;Au.set(0,`GENERIC_PANIC`),Au.set(1,`ASSERT_FALSE`),Au.set(17,`OVERFLOW`),Au.set(18,`DIVIDE_BY_ZERO`),Au.set(33,`ENUM_RANGE_ERROR`),Au.set(34,`BAD_STORAGE_DATA`),Au.set(49,`STACK_UNDERFLOW`),Au.set(50,`ARRAY_RANGE_ERROR`),Au.set(65,`OUT_OF_MEMORY`),Au.set(81,`UNINITIALIZED_FUNCTION_CALL`);var ju=new RegExp(/^bytes([0-9]*)$/),Mu=new RegExp(/^(u?int)([0-9]*)$/),Nu=null,Pu=1024;function Fu(e,t,n,r){let i=`missing revert data`,a=null,o=null;if(n){i=`execution reverted`;let e=B(n);if(n=V(n),e.length===0)i+=` (no data present; likely require(false) occurred`,a=`require(false)`;else if(e.length%32!=4)i+=` (could not decode reason; invalid data length)`;else if(V(e.slice(0,4))===`0x08c379a0`)try{a=r.decode([`string`],e.slice(4))[0],o={signature:`Error(string)`,name:`Error`,args:[a]},i+=`: ${JSON.stringify(a)}`}catch{i+=` (could not decode reason; invalid string data)`}else if(V(e.slice(0,4))===`0x4e487b71`)try{let t=Number(r.decode([`uint256`],e.slice(4))[0]);o={signature:`Panic(uint256)`,name:`Panic`,args:[t]},a=`Panic due to ${Au.get(t)||`UNKNOWN`}(${t})`,i+=`: ${a}`}catch{i+=` (could not decode panic code)`}else i+=` (unknown custom error)`}let s={to:t.to?Gc(t.to):null,data:t.data||`0x`};return t.from&&(s.from=Gc(t.from)),fr(i,`CALL_EXCEPTION`,{action:e,data:n,reason:a,transaction:s,invocation:null,revert:o})}var Iu=class e{#e(e){if(e.isArray())return new rl(this.#e(e.arrayChildren),e.arrayLength,e.name);if(e.isTuple())return new hl(e.components.map(e=>this.#e(e)),e.name);switch(e.baseType){case`address`:return new $c(e.name);case`bool`:return new il(e.name);case`string`:return new ml(e.name);case`bytes`:return new ol(e.name);case``:return new ll(e.name)}let t=e.type.match(Mu);if(t){let n=parseInt(t[2]||`256`);return z(n!==0&&n<=256&&n%8==0,`invalid `+t[1]+` bit length`,`param`,e),new pl(n/8,t[1]===`int`,e.name)}if(t=e.type.match(ju),t){let n=parseInt(t[1]);return z(n!==0&&n<=32,`invalid bytes length`,`param`,e),new sl(n,e.name)}z(!1,`invalid type`,`type`,e.type)}getDefaultValue(e){return new hl(e.map(e=>this.#e(ku.from(e))),`_`).defaultValue()}encode(e,t){pr(t.length,e.length,`types/values length mismatch`);let n=new hl(e.map(e=>this.#e(ku.from(e))),`_`),r=new wi;return n.encode(r,t),r.data}decode(e,t,n){return new hl(e.map(e=>this.#e(ku.from(e))),`_`).decode(new Ti(t,n,Pu))}static _setDefaultMaxInflation(e){z(typeof e==`number`&&Number.isInteger(e),`invalid defaultMaxInflation factor`,`value`,e),Pu=e}static defaultAbiCoder(){return Nu??=new e,Nu}static getBuiltinCallException(t,n,r){return Fu(t,n,r,e.defaultAbiCoder())}};function Lu(e){let t={};e.to&&(t.to=e.to),e.from&&(t.from=e.from),e.data&&(t.data=V(e.data));let n=`chainId,gasLimit,gasPrice,maxFeePerBlobGas,maxFeePerGas,maxPriorityFeePerGas,value`.split(/,/);for(let r of n)!(r in e)||e[r]==null||(t[r]=Nr(e[r],`request.${r}`));let r=`type,nonce`.split(/,/);for(let n of r)!(n in e)||e[n]==null||(t[n]=Lr(e[n],`request.${n}`));return e.accessList&&(t.accessList=vl(e.accessList)),`blockTag`in e&&(t.blockTag=e.blockTag),`enableCcipRead`in e&&(t.enableCcipRead=!!e.enableCcipRead),`customData`in e&&(t.customData=e.customData),`blobVersionedHashes`in e&&e.blobVersionedHashes&&(t.blobVersionedHashes=e.blobVersionedHashes.slice()),`kzg`in e&&(t.kzg=e.kzg),`blobs`in e&&e.blobs&&(t.blobs=e.blobs.map(e=>br(e)?V(e):Object.assign({},e))),t}function Ru(e,t){if(e.provider)return e.provider;R(!1,`missing provider`,`UNSUPPORTED_OPERATION`,{operation:t})}async function zu(e,t){let n=Lu(t);if(n.to!=null&&(n.to=Jc(n.to,e)),n.from!=null){let t=n.from;n.from=Promise.all([e.getAddress(),Jc(t,e)]).then(([e,t])=>(z(e.toLowerCase()===t.toLowerCase(),`transaction from mismatch`,`tx.from`,t),e))}else n.from=e.getAddress();return await lr(n)}var Bu=class{provider;constructor(e){L(this,{provider:e||null})}async getNonce(e){return Ru(this,`getTransactionCount`).getTransactionCount(await this.getAddress(),e)}async populateCall(e){return await zu(this,e)}async populateTransaction(e){let t=Ru(this,`populateTransaction`),n=await zu(this,e);n.nonce??=await this.getNonce(`pending`),n.gasLimit??=await this.estimateGas(n);let r=await this.provider.getNetwork();n.chainId==null?n.chainId=r.chainId:z(Nr(n.chainId)===r.chainId,`transaction chainId mismatch`,`tx.chainId`,e.chainId);let i=n.maxFeePerGas!=null||n.maxPriorityFeePerGas!=null;if(n.gasPrice!=null&&(n.type===2||i)?z(!1,`eip-1559 transaction do not support gasPrice`,`tx`,e):(n.type===0||n.type===1)&&i&&z(!1,`pre-eip-1559 transaction do not support maxFeePerGas/maxPriorityFeePerGas`,`tx`,e),(n.type===2||n.type==null)&&n.maxFeePerGas!=null&&n.maxPriorityFeePerGas!=null)n.type=2;else if(n.type===0||n.type===1){let e=await t.getFeeData();R(e.gasPrice!=null,`network does not support gasPrice`,`UNSUPPORTED_OPERATION`,{operation:`getGasPrice`}),n.gasPrice??=e.gasPrice}else{let e=await t.getFeeData();if(n.type==null){if(e.maxFeePerGas!=null&&e.maxPriorityFeePerGas!=null){if(n.type=2,n.gasPrice!=null){let e=n.gasPrice;delete n.gasPrice,n.maxFeePerGas=e,n.maxPriorityFeePerGas=e}else n.maxFeePerGas??=e.maxFeePerGas,n.maxPriorityFeePerGas??=e.maxPriorityFeePerGas}else e.gasPrice==null?R(!1,`failed to get consistent fee data`,`UNSUPPORTED_OPERATION`,{operation:`signer.getFeeData`}):(R(!i,`network does not support EIP-1559`,`UNSUPPORTED_OPERATION`,{operation:`populateTransaction`}),n.gasPrice??=e.gasPrice,n.type=0)}else(n.type===2||n.type===3)&&(n.maxFeePerGas??=e.maxFeePerGas,n.maxPriorityFeePerGas??=e.maxPriorityFeePerGas)}return await lr(n)}async estimateGas(e){return Ru(this,`estimateGas`).estimateGas(await this.populateCall(e))}async call(e){return Ru(this,`call`).call(await this.populateCall(e))}async resolveName(e){return await Ru(this,`resolveName`).resolveName(e)}async sendTransaction(e){let t=Ru(this,`sendTransaction`),n=await this.populateTransaction(e);delete n.from;let r=Gl.from(n);return await t.broadcastTransaction(await this.signTransaction(r))}},Vu=class e extends Bu{address;constructor(e,t){super(t),L(this,{address:e})}async getAddress(){return this.address}connect(t){return new e(this.address,t)}#e(e,t){R(!1,`VoidSigner cannot sign ${e}`,`UNSUPPORTED_OPERATION`,{operation:t})}async signTransaction(e){this.#e(`transactions`,`signTransaction`)}async signMessage(e){this.#e(`messages`,`signMessage`)}async signTypedData(e,t,n){this.#e(`typed-data`,`signTypedData`)}},Hu=class e extends Bu{address;#e;constructor(e,t){super(t),z(e&&typeof e.sign==`function`,`invalid private key`,`privateKey`,`[ REDACTED ]`),this.#e=e;let n=yl(this.signingKey.publicKey);L(this,{address:n})}get signingKey(){return this.#e}get privateKey(){return this.signingKey.privateKey}async getAddress(){return this.address}connect(t){return new e(this.#e,t)}async signTransaction(e){e=Lu(e);let{to:t,from:n}=await lr({to:e.to?Jc(e.to,this.provider):void 0,from:e.from?Jc(e.from,this.provider):void 0});t!=null&&(e.to=t),n!=null&&(e.from=n),e.from!=null&&(z(Gc(e.from)===this.address,`transaction from address mismatch`,`tx.from`,e.from),delete e.from);let r=Gl.from(e);return r.signature=this.signingKey.sign(r.unsignedHash),r.serialized}async signMessage(e){return this.signMessageSync(e)}signMessageSync(e){return this.signingKey.sign(Kl(e)).serialized}async signTypedData(e,t,n){let r=await cu.resolveNames(e,t,n,async e=>{R(this.provider!=null,`cannot resolve ENS names without a provider`,`UNSUPPORTED_OPERATION`,{operation:`resolveName`,info:{name:e}});let t=await this.provider.resolveName(e);return R(t!=null,`unconfigured ENS name`,`UNCONFIGURED_NAME`,{value:e}),t});return this.signingKey.sign(cu.hash(r.domain,t,r.value)).serialized}},Uu=" !#$%&'()*+,-./<=>?@[]^_`{|}~",Wu=/^[a-z]*$/i;function Gu(e,t){let n=97;return e.reduce((e,r)=>(r===t?n++:r.match(Wu)?e.push(String.fromCharCode(n)+r):(n=97,e.push(r)),e),[])}function Ku(e,t){for(let n=28;n>=0;n--)e=e.split(Uu[n]).join(t.substring(2*n,2*n+2));let n=[],r=e.replace(/(:|([0-9])|([A-Z][a-z]*))/g,(e,t,r,i)=>{if(r)for(let e=parseInt(r);e>=0;e--)n.push(`;`);else n.push(t.toLowerCase());return``});if(r)throw Error(`leftovers: ${JSON.stringify(r)}`);return Gu(Gu(n,`;`),`:`)}function qu(e){return z(e[0]===`0`,`unsupported auwl data`,`data`,e),Ku(e.substring(59),e.substring(1,59))}var Ju=class{locale;constructor(e){L(this,{locale:e})}split(e){return e.toLowerCase().split(/\s+/g)}join(e){return e.join(` `)}},Yu=class extends Ju{#e;#t;constructor(e,t,n){super(e),this.#e=t,this.#t=n,this.#n=null}get _data(){return this.#e}_decodeWords(){return qu(this.#e)}#n;#r(){if(this.#n==null){let e=this._decodeWords();if(gl(e.join(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-BcKkbAw3.js";import{t}from"./axios-BywHQoip.js";import{n,r,t as i}from"./wallet-manager-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-BcKkbAw3.js";import{t}from"./axios-BywHQoip.js";import{n,r,t as i}from"./wallet-manager-D2AeCPRs.js";var a=async(e,t,n)=>await s(e,t,!1,n)===!1?Promise.reject(`Invalid endpoint.`):e,o=async(e,t,n)=>{try{let r=await Promise.any(e.map(e=>a(e,t,n)));return n?.debug(`rpcEndpoint won the race:`,r),r}catch(e){return Promise.reject(e)}},s=async(e,n,r,i)=>{if(r)return i?.debug(`Skipping test of accessibility for`,e),!0;i?.debug(`Testing accessibility of`,e);try{let r;if(r=typeof e==`string`?n===`rest`?await t.get(`${e}/cosmos/base/tendermint/v1beta1/node_info`):await t.post(e):n===`rest`?await t.get(`${e.url}/cosmos/base/tendermint/v1beta1/node_info`,{headers:e.headers}):await t.post(e.url,{headers:e.headers}),r.status==200)return i?.debug(`Access successfully.`),!0}catch(e){i?.debug(`${e.name}: ${e.message}`)}return i?.debug(`Access failed.`),!1},c=(e,t,n,r,i)=>r===void 0?n===void 0?t===void 0?e!==void 0&&e:t:n:r,l=Error(`Client Not Exist!`),u=Error(`Request Rejected!`),d=Error(`Expired!`),f=class extends Error{walletName;constructor(e){super(`Wallet ${e} is not provided.`),this.walletName=e}},p=class extends Error{name=`ConnectError`;constructor(e){super(e)}},m;(function(e){e.Init=`Init`,e.Pending=`Pending`,e.Done=`Done`,e.Error=`Error`})(m||={});var h;(function(e){e.WalletList=`WalletList`,e.Connecting=`Connecting`,e.Connected=`Connected`,e.Error=`Error`,e.NotExist=`NotExist`,e.Rejected=`Rejected`,e.QRCode=`QRCode`})(h||={});var g;(function(e){e.Disconnected=`Disconnected`,e.Connecting=`Connecting`,e.Connected=`Connected`,e.NotExist=`NotExist`,e.Rejected=`Rejected`,e.Error=`Error`})(g||={});var _=(e,t)=>{switch(e){case`Pending`:return g.Connecting;case`Done`:return g.Connected;case`Error`:switch(t){case l.message:return g.NotExist;case u.message:return g.Rejected;default:return g.Error}case`Init`:return g.Disconnected;default:return g.Disconnected}},v=[{name:`icns`,contract:`osmo1xk0s8xgktn9x5vwcgtjdxqzadg88fgn33p8u9cnpdxwemvxscvast52cdd`,chainName:`osmosis`,getQueryMsg:e=>({icns_names:{address:e}}),slip173:`osmo`},{name:`stargaze`,contract:`stars1fx74nkqkw2748av8j7ew7r3xt9cgjqduwn8m0ur5lhe49uhlsasszc5fhr`,chainName:`stargaze`,getQueryMsg:e=>({name:{address:e}}),slip173:`stars`}],y=e=>{let t=v.find(t=>t.chainName===e);if(!t)throw Error(`No such name service registered with chain `+e);return t},b=e=>v.find(t=>t.name===e),x=e({ClientNotExistError:()=>l,ConnectError:()=>p,ExpiredError:()=>d,Logger:()=>n,RejectedError:()=>u,Session:()=>i,WalletNotProvidedError:()=>f,convertChain:()=>r,getFastestEndpoint:()=>o,getIsLazy:()=>c,getNameServiceRegistryFromChainName:()=>y,getNameServiceRegistryFromName:()=>b,getWalletStatusFromState:()=>_,isValidEndpoint:()=>s});export{l as a,u as c,m as i,f as l,_ as n,p as o,g as r,d as s,x as t,c as u};
|