@revibase/lite 0.5.0 → 0.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,15 +1,15 @@
1
- import {initialize,prepareTransactionMessage,getSettingsFromIndex,fetchSettingsAccountData,UserRole,UserInfoSchema,convertBase64StringToJWK,createClientAuthorizationStartRequestChallenge,createMessageChallenge,convertPubkeyCompressedToCose,bufferToBase64URLString,createTransactionChallenge,createClientAuthorizationCompleteRequestChallenge,getSignedSecp256r1Key,retrieveTransactionManager,prepareTransactionSync,prepareTransactionBundle,tokenTransferIntent,nativeTransferIntent,getSolanaRpc,fetchUserAccountData,createTransactionManagerSigner,getSolanaRpcEndpoint}from'@revibase/core';import {CompactSign,importJWK,compactVerify}from'jose';import {verifyAuthenticationResponse}from'@simplewebauthn/server';var oo=1,io=2,ao=3,so=4,co=5,uo=6,lo=7,Io=8,_o=9,Ao=10,Eo=-32700,Ro=-32603,To=-32602,go=-32601,fo=-32600,Do=-32019,So=-32018,No=-32017,mo=-32016,po=-32015,Co=-32014,Oo=-32013,ho=-32012,yo=-32011,Mo=-32010,Lo=-32009,bo=-32008,Uo=-32007,Po=-32006,vo=-32005,wo=-32004,Bo=-32003,Fo=-32002,zo=-32001,$e=28e5,je=2800001,ko=2800002,jt=2800003,Yt=2800004,qt=2800005,Xt=2800006,Zt=2800007,Jt=2800008,Qt=2800009,en=2800010,tn=2800011,nn=323e4,Ye=32300001,qe=3230002,rn=3230003,Xe=3230004,xo=361e4,Wo=3610001,Go=3610002,Vo=3610003,Ho=3610004,Ko=3610005,$o=3610006,jo=3610007,Yo=3611e3,qo=3704e3,Xo=3704001,Zo=3704002,Jo=3704003,Qo=3704004,ei=4128e3,ti=4128001,ni=4128002,ri=4615e3,oi=4615001,ii=4615002,ai=4615003,si=4615004,ci=4615005,ui=4615006,di=4615007,li=4615008,Ii=4615009,_i=4615010,Ai=4615011,Ei=4615012,Ri=4615013,Ti=4615014,gi=4615015,fi=4615016,Di=4615017,Si=4615018,Ni=4615019,mi=4615020,pi=4615021,Ci=4615022,Oi=4615023,hi=4615024,yi=4615025,Mi=4615026,Li=4615027,bi=4615028,Ui=4615029,Pi=4615030,vi=4615031,wi=4615032,Bi=4615033,Fi=4615034,zi=4615035,ki=4615036,xi=4615037,Wi=4615038,Gi=4615039,Vi=4615040,Hi=4615041,Ki=4615042,$i=4615043,ji=4615044,Yi=4615045,qi=4615046,Xi=4615047,Zi=4615048,Ji=4615049,Qi=4615050,ea=4615051,ta=4615052,na=4615053,ra=4615054,Ze=5508e3,on=5508001,an=5508002,sn=5508003,cn=5508004,un=5508005,dn=5508006,ln=5508007,In=5508008,_n=5508009,An=5508010,oa=5508011,Je=5663e3,Ce=5663001,Qe=5663002,et=5663003,tt=5663004,En=5663005,Rn=5663006,Tn=5663007,gn=5663008,nt=5663009,ia=5663010,aa=5663011,rt=5663012,sa=5663013,ca=5663014,fn=5663015,ot=5663016,Dn=5663017,Sn=5663018,Nn=5663019,mn=5663020,it=5663021,pn=5663022,ua=705e4,da=7050001,la=7050002,Ia=7050003,_a=7050004,Aa=7050005,Ea=7050006,Ra=7050007,Ta=7050008,ga=7050009,fa=7050010,Da=7050011,Sa=7050012,Na=7050013,ma=7050014,pa=7050015,Ca=7050016,Oa=7050017,ha=7050018,ya=7050019,Ma=7050020,La=7050021,ba=7050022,Ua=7050023,Pa=7050024,va=7050025,wa=7050026,Ba=7050027,Fa=7050028,za=7050029,ka=7050030,xa=7050031,Wa=7050032,Ga=7050033,Va=7050034,Ha=7050035,Ka=7050036,$a=7618e3,ja=7618001,Ya=7618002,qa=7618003,at=8078e3,st=8078001,ct=8078002,Cn=8078003,On=8078004,hn=8078005,yn=8078006,ut=8078007,Mn=8078008,Ln=8078009,bn=8078010,dt=8078011,ce=8078012,Un=8078013,Pn=8078014,vn=8078015,wn=8078016,lt=8078017,It=8078018,Xa=8078019,Bn=8078020,Fn=8078021,zn=8078022,kn=8078023,Za=81e5,Ja=8100001,Qa=8100002,es=8100003,ts=819e4,ns=8190001,rs=8190002,os=8190003,is=8190004,as=99e5,ss=9900001,cs=9900002,us=9900003,ds=9900004,ls=9900005,Is=9900006;function xn(e){return Array.isArray(e)?"%5B"+e.map(xn).join("%2C%20")+"%5D":typeof e=="bigint"?`${e}n`:encodeURIComponent(String(e!=null&&Object.getPrototypeOf(e)===null?{...e}:e))}function _s([e,t]){return `${e}=${xn(t)}`}function As(e){let t=Object.entries(e).map(_s).join("&");return Buffer.from(t,"utf8").toString("base64")}var Es={[nn]:"Account not found at address: $address",[Xe]:"Not all accounts were decoded. Encoded accounts found at addresses: $addresses.",[rn]:"Expected decoded account at address: $address",[qe]:"Failed to decode account data at address: $address",[Ye]:"Accounts not found at addresses: $addresses",[Qt]:"Unable to find a viable program address bump seed.",[ko]:"$putativeAddress is not a base58-encoded address.",[$e]:"Expected base58 encoded address to decode to a byte array of length 32. Actual length: $actualLength.",[jt]:"The `CryptoKey` must be an `Ed25519` public key.",[tn]:"$putativeOffCurveAddress is not a base58-encoded off-curve address.",[Jt]:"Invalid seeds; point must fall off the Ed25519 curve.",[Yt]:"Expected given program derived address to have the following format: [Address, ProgramDerivedAddressBump].",[Xt]:"A maximum of $maxSeeds seeds, including the bump seed, may be supplied when creating an address. Received: $actual.",[Zt]:"The seed at index $index with length $actual exceeds the maximum length of $maxSeedLength bytes.",[qt]:"Expected program derived address bump to be in the range [0, 255], got: $bump.",[en]:"Program address cannot end with PDA marker.",[je]:"Expected base58-encoded address string of length in the range [32, 44]. Actual length: $actualLength.",[so]:"Expected base58-encoded blockash string of length in the range [32, 44]. Actual length: $actualLength.",[oo]:"The network has progressed past the last block for which this transaction could have been committed.",[at]:"Codec [$codecDescription] cannot decode empty byte arrays.",[zn]:"Enum codec cannot use lexical values [$stringValues] as discriminators. Either remove all lexical values or set `useValuesAsDiscriminators` to `false`.",[Bn]:"Sentinel [$hexSentinel] must not be present in encoded bytes [$hexEncodedBytes].",[hn]:"Encoder and decoder must have the same fixed size, got [$encoderFixedSize] and [$decoderFixedSize].",[yn]:"Encoder and decoder must have the same max size, got [$encoderMaxSize] and [$decoderMaxSize].",[On]:"Encoder and decoder must either both be fixed-size or variable-size.",[Mn]:"Enum discriminator out of range. Expected a number in [$formattedValidDiscriminators], got $discriminator.",[ct]:"Expected a fixed-size codec, got a variable-size one.",[Un]:"Codec [$codecDescription] expected a positive byte length, got $bytesLength.",[Cn]:"Expected a variable-size codec, got a fixed-size one.",[Xa]:"Codec [$codecDescription] expected zero-value [$hexZeroValue] to have the same size as the provided fixed-size item [$expectedSize bytes].",[st]:"Codec [$codecDescription] expected $expected bytes, got $bytesLength.",[It]:"Expected byte array constant [$hexConstant] to be present in data [$hexData] at offset [$offset].",[Ln]:"Invalid discriminated union variant. Expected one of [$variants], got $value.",[bn]:"Invalid enum variant. Expected one of [$stringValues] or a number in [$formattedNumericalValues], got $variant.",[vn]:"Invalid literal union variant. Expected one of [$variants], got $value.",[ut]:"Expected [$codecDescription] to have $expected items, got $actual.",[ce]:"Invalid value $value for base $base with alphabet $alphabet.",[wn]:"Literal union discriminator out of range. Expected a number between $minRange and $maxRange, got $discriminator.",[dt]:"Codec [$codecDescription] expected number to be in the range [$min, $max], got $value.",[Pn]:"Codec [$codecDescription] expected offset to be in the range [0, $bytesLength], got $offset.",[Fn]:"Expected sentinel [$hexSentinel] to be present in decoded bytes [$hexDecodedBytes].",[lt]:"Union variant out of range. Expected an index between $minRange and $maxRange, got $variant.",[kn]:"This decoder expected a byte array of exactly $expectedLength bytes, but $numExcessBytes unexpected excess bytes remained after decoding. Are you sure that you have chosen the correct decoder for this data?",[Yo]:"No random values implementation could be found.",[Ii]:"instruction requires an uninitialized account",[Oi]:"instruction tries to borrow reference for an account which is already borrowed",[hi]:"instruction left account with an outstanding borrowed reference",[pi]:"program other than the account's owner changed the size of the account data",[ci]:"account data too small for instruction",[Ci]:"instruction expected an executable account",[qi]:"An account does not have enough lamports to be rent-exempt",[Zi]:"Program arithmetic overflowed",[Yi]:"Failed to serialize or deserialize account data: $encodedData",[ra]:"Builtin programs must consume compute units",[wi]:"Cross-program invocation call depth too deep",[Wi]:"Computational budget exceeded",[Mi]:"custom program error: #$code",[Di]:"instruction contains duplicate accounts",[yi]:"instruction modifications of multiply-passed account differ",[Pi]:"executable accounts must be rent exempt",[bi]:"instruction changed executable accounts data",[Ui]:"instruction changed the balance of an executable account",[Si]:"instruction changed executable bit of an account",[Ti]:"instruction modified data of an account it does not own",[Ri]:"instruction spent from the balance of an account it does not own",[oi]:"generic instruction error",[Qi]:"Provided owner is not allowed",[$i]:"Account is immutable",[ji]:"Incorrect authority provided",[di]:"incorrect program id for instruction",[ui]:"insufficient funds for instruction",[si]:"invalid account data for instruction",[Xi]:"Invalid account owner",[ii]:"invalid program argument",[Li]:"program returned invalid error code",[ai]:"invalid instruction data",[xi]:"Failed to reallocate account data",[ki]:"Provided seeds do not result in a valid address",[ea]:"Accounts data allocations exceeded the maximum allowed per transaction",[ta]:"Max accounts exceeded",[na]:"Max instruction trace length exceeded",[zi]:"Length of the seed is too long for address generation",[Bi]:"An account required by the instruction is missing",[li]:"missing required signature for instruction",[Ei]:"instruction illegally modified the program id of an account",[mi]:"insufficient account keys for instruction",[Gi]:"Cross-program invocation with unauthorized signer or writable account",[Vi]:"Failed to create program execution environment",[Ki]:"Program failed to compile",[Hi]:"Program failed to complete",[fi]:"instruction modified data of a read-only account",[gi]:"instruction changed the balance of a read-only account",[Fi]:"Cross-program invocation reentrancy not allowed for this instruction",[Ni]:"instruction modified rent epoch of an account",[Ai]:"sum of account balances before and after instruction do not match",[_i]:"instruction requires an initialized account",[ri]:"",[vi]:"Unsupported program id",[Ji]:"Unsupported sysvar",[ls]:"Invalid instruction plan kind: $kind.",[Ya]:"The provided instruction plan is empty.",[qa]:"The provided transaction plan failed to execute. See the `transactionPlanResult` attribute and the `cause` error for more details.",[$a]:"The provided message has insufficient capacity to accommodate the next instruction(s) in this plan. Expected at least $numBytesRequired free byte(s), got $numFreeBytes byte(s).",[Is]:"Invalid transaction plan kind: $kind.",[ja]:"No more instructions to pack; the message packer has completed the instruction plan.",[ei]:"The instruction does not have any accounts.",[ti]:"The instruction does not have any data.",[ni]:"Expected instruction to have progress address $expectedProgramAddress, got $actualProgramAddress.",[co]:"Expected base58 encoded blockhash to decode to a byte array of length 32. Actual length: $actualLength.",[io]:"The nonce `$expectedNonceValue` is no longer valid. It has advanced to `$actualNonceValue`",[cs]:"Invariant violation: Found no abortable iterable cache entry for key `$cacheKey`. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[ds]:"Invariant violation: This data publisher does not publish to the channel named `$channelName`. Supported channels include $supportedChannelNames.",[ss]:"Invariant violation: WebSocket message iterator state is corrupt; iterated without first resolving existing message promise. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[as]:"Invariant violation: WebSocket message iterator is missing state storage. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[us]:"Invariant violation: Switch statement non-exhaustive. Received unexpected value `$unexpectedValue`. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[Ro]:"JSON-RPC error: Internal JSON-RPC error ($__serverMessage)",[To]:"JSON-RPC error: Invalid method parameter(s) ($__serverMessage)",[fo]:"JSON-RPC error: The JSON sent is not a valid `Request` object ($__serverMessage)",[go]:"JSON-RPC error: The method does not exist / is not available ($__serverMessage)",[Eo]:"JSON-RPC error: An error occurred on the server while parsing the JSON text ($__serverMessage)",[ho]:"$__serverMessage",[zo]:"$__serverMessage",[wo]:"$__serverMessage",[Co]:"$__serverMessage",[No]:"Epoch rewards period still active at slot $slot",[Mo]:"$__serverMessage",[Lo]:"$__serverMessage",[Do]:"Failed to query long-term storage; please try again",[mo]:"Minimum context slot has not been reached",[vo]:"Node is unhealthy; behind by $numSlotsBehind slots",[bo]:"No snapshot",[Fo]:"Transaction simulation failed",[So]:"Rewards cannot be found because slot $slot is not the epoch boundary. This may be due to gap in the queried node's local ledger or long-term storage",[Uo]:"$__serverMessage",[yo]:"Transaction history is not available from this node",[Po]:"$__serverMessage",[Oo]:"Transaction signature length mismatch",[Bo]:"Transaction signature verification failure",[po]:"$__serverMessage",[qo]:"Key pair bytes must be of length 64, got $byteLength.",[Xo]:"Expected private key bytes with length 32. Actual length: $actualLength.",[Zo]:"Expected base58-encoded signature to decode to a byte array of length 64. Actual length: $actualLength.",[Qo]:"The provided private key does not match the provided public key.",[Jo]:"Expected base58-encoded signature string of length in the range [64, 88]. Actual length: $actualLength.",[uo]:"Lamports value must be in the range [0, 2e64-1]",[lo]:"`$value` cannot be parsed as a `BigInt`",[Ao]:"$message",[Io]:"`$value` cannot be parsed as a `Number`",[ao]:"No nonce account could be found at address `$nonceAccountAddress`",[ts]:"The notification name must end in 'Notifications' and the API must supply a subscription plan creator function for the notification '$notificationName'.",[rs]:"WebSocket was closed before payload could be added to the send buffer",[os]:"WebSocket connection closed",[is]:"WebSocket failed to connect",[ns]:"Failed to obtain a subscription id from the server",[es]:"Could not find an API plan for RPC method: `$method`",[Za]:"The $argumentLabel argument to the `$methodName` RPC method$optionalPathLabel was `$value`. This number is unsafe for use with the Solana JSON-RPC because it exceeds `Number.MAX_SAFE_INTEGER`.",[Qa]:"HTTP error ($statusCode): $message",[Ja]:"HTTP header(s) forbidden: $headers. Learn more at https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_header_name.",[Ze]:"Multiple distinct signers were identified for address `$address`. Please ensure that you are using the same signer instance for each address.",[on]:"The provided value does not implement the `KeyPairSigner` interface",[sn]:"The provided value does not implement the `MessageModifyingSigner` interface",[cn]:"The provided value does not implement the `MessagePartialSigner` interface",[an]:"The provided value does not implement any of the `MessageSigner` interfaces",[dn]:"The provided value does not implement the `TransactionModifyingSigner` interface",[ln]:"The provided value does not implement the `TransactionPartialSigner` interface",[In]:"The provided value does not implement the `TransactionSendingSigner` interface",[un]:"The provided value does not implement any of the `TransactionSigner` interfaces",[_n]:"More than one `TransactionSendingSigner` was identified.",[An]:"No `TransactionSendingSigner` was identified. Please provide a valid `TransactionWithSingleSendingSigner` transaction.",[oa]:"Wallet account signers do not support signing multiple messages/transactions in a single operation",[jo]:"Cannot export a non-extractable key.",[Wo]:"No digest implementation could be found.",[xo]:"Cryptographic operations are only allowed in secure browser contexts. Read more here: https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts.",[Go]:`This runtime does not support the generation of Ed25519 key pairs.
1
+ import {initialize,prepareTransactionMessage,getSettingsFromIndex,UserRole,convertBase64StringToJWK,createClientAuthorizationStartRequestChallenge,createMessageChallenge,convertPubkeyCompressedToCose,bufferToBase64URLString,UserInfoSchema,createTransactionChallenge,createClientAuthorizationCompleteRequestChallenge,fetchSettingsAccountData,getSignedSecp256r1Key,retrieveTransactionManager,prepareTransactionSync,prepareTransactionBundle,tokenTransferIntent,nativeTransferIntent,getSolanaRpc,fetchUserAccountData,createTransactionManagerSigner,getSolanaRpcEndpoint}from'@revibase/core';import {CompactSign,importJWK,compactVerify}from'jose';import {verifyAuthenticationResponse}from'@simplewebauthn/server';var so=1,co=2,uo=3,lo=4,Io=5,_o=6,Ao=7,Eo=8,Ro=9,To=10,go=-32700,fo=-32603,Do=-32602,So=-32601,No=-32600,mo=-32019,po=-32018,Co=-32017,Oo=-32016,ho=-32015,yo=-32014,Mo=-32013,Lo=-32012,bo=-32011,Uo=-32010,Po=-32009,vo=-32008,wo=-32007,Bo=-32006,Fo=-32005,zo=-32004,ko=-32003,xo=-32002,Wo=-32001,Ye=28e5,qe=2800001,Go=2800002,qt=2800003,Xt=2800004,Zt=2800005,Jt=2800006,Qt=2800007,en=2800008,tn=2800009,nn=2800010,rn=2800011,on=323e4,Xe=32300001,Ze=3230002,an=3230003,Je=3230004,Vo=361e4,Ho=3610001,Ko=3610002,$o=3610003,jo=3610004,Yo=3610005,qo=3610006,Xo=3610007,Zo=3611e3,Jo=3704e3,Qo=3704001,ei=3704002,ti=3704003,ni=3704004,ri=4128e3,oi=4128001,ii=4128002,ai=4615e3,si=4615001,ci=4615002,ui=4615003,di=4615004,li=4615005,Ii=4615006,_i=4615007,Ai=4615008,Ei=4615009,Ri=4615010,Ti=4615011,gi=4615012,fi=4615013,Di=4615014,Si=4615015,Ni=4615016,mi=4615017,pi=4615018,Ci=4615019,Oi=4615020,hi=4615021,yi=4615022,Mi=4615023,Li=4615024,bi=4615025,Ui=4615026,Pi=4615027,vi=4615028,wi=4615029,Bi=4615030,Fi=4615031,zi=4615032,ki=4615033,xi=4615034,Wi=4615035,Gi=4615036,Vi=4615037,Hi=4615038,Ki=4615039,$i=4615040,ji=4615041,Yi=4615042,qi=4615043,Xi=4615044,Zi=4615045,Ji=4615046,Qi=4615047,ea=4615048,ta=4615049,na=4615050,ra=4615051,oa=4615052,ia=4615053,aa=4615054,Qe=5508e3,sn=5508001,cn=5508002,un=5508003,dn=5508004,ln=5508005,In=5508006,_n=5508007,An=5508008,En=5508009,Rn=5508010,sa=5508011,et=5663e3,he=5663001,tt=5663002,nt=5663003,rt=5663004,Tn=5663005,gn=5663006,fn=5663007,Dn=5663008,ot=5663009,ca=5663010,ua=5663011,it=5663012,da=5663013,la=5663014,Sn=5663015,at=5663016,Nn=5663017,mn=5663018,pn=5663019,Cn=5663020,st=5663021,On=5663022,Ia=705e4,_a=7050001,Aa=7050002,Ea=7050003,Ra=7050004,Ta=7050005,ga=7050006,fa=7050007,Da=7050008,Sa=7050009,Na=7050010,ma=7050011,pa=7050012,Ca=7050013,Oa=7050014,ha=7050015,ya=7050016,Ma=7050017,La=7050018,ba=7050019,Ua=7050020,Pa=7050021,va=7050022,wa=7050023,Ba=7050024,Fa=7050025,za=7050026,ka=7050027,xa=7050028,Wa=7050029,Ga=7050030,Va=7050031,Ha=7050032,Ka=7050033,$a=7050034,ja=7050035,Ya=7050036,qa=7618e3,Xa=7618001,Za=7618002,Ja=7618003,ct=8078e3,ut=8078001,dt=8078002,hn=8078003,yn=8078004,Mn=8078005,Ln=8078006,lt=8078007,bn=8078008,Un=8078009,Pn=8078010,It=8078011,_e=8078012,vn=8078013,wn=8078014,Bn=8078015,Fn=8078016,_t=8078017,At=8078018,Qa=8078019,zn=8078020,kn=8078021,xn=8078022,Wn=8078023,es=81e5,ts=8100001,ns=8100002,rs=8100003,os=819e4,is=8190001,as=8190002,ss=8190003,cs=8190004,us=99e5,ds=9900001,ls=9900002,Is=9900003,_s=9900004,As=9900005,Es=9900006;function Gn(e){return Array.isArray(e)?"%5B"+e.map(Gn).join("%2C%20")+"%5D":typeof e=="bigint"?`${e}n`:encodeURIComponent(String(e!=null&&Object.getPrototypeOf(e)===null?{...e}:e))}function Rs([e,t]){return `${e}=${Gn(t)}`}function Ts(e){let t=Object.entries(e).map(Rs).join("&");return Buffer.from(t,"utf8").toString("base64")}var gs={[on]:"Account not found at address: $address",[Je]:"Not all accounts were decoded. Encoded accounts found at addresses: $addresses.",[an]:"Expected decoded account at address: $address",[Ze]:"Failed to decode account data at address: $address",[Xe]:"Accounts not found at addresses: $addresses",[tn]:"Unable to find a viable program address bump seed.",[Go]:"$putativeAddress is not a base58-encoded address.",[Ye]:"Expected base58 encoded address to decode to a byte array of length 32. Actual length: $actualLength.",[qt]:"The `CryptoKey` must be an `Ed25519` public key.",[rn]:"$putativeOffCurveAddress is not a base58-encoded off-curve address.",[en]:"Invalid seeds; point must fall off the Ed25519 curve.",[Xt]:"Expected given program derived address to have the following format: [Address, ProgramDerivedAddressBump].",[Jt]:"A maximum of $maxSeeds seeds, including the bump seed, may be supplied when creating an address. Received: $actual.",[Qt]:"The seed at index $index with length $actual exceeds the maximum length of $maxSeedLength bytes.",[Zt]:"Expected program derived address bump to be in the range [0, 255], got: $bump.",[nn]:"Program address cannot end with PDA marker.",[qe]:"Expected base58-encoded address string of length in the range [32, 44]. Actual length: $actualLength.",[lo]:"Expected base58-encoded blockash string of length in the range [32, 44]. Actual length: $actualLength.",[so]:"The network has progressed past the last block for which this transaction could have been committed.",[ct]:"Codec [$codecDescription] cannot decode empty byte arrays.",[xn]:"Enum codec cannot use lexical values [$stringValues] as discriminators. Either remove all lexical values or set `useValuesAsDiscriminators` to `false`.",[zn]:"Sentinel [$hexSentinel] must not be present in encoded bytes [$hexEncodedBytes].",[Mn]:"Encoder and decoder must have the same fixed size, got [$encoderFixedSize] and [$decoderFixedSize].",[Ln]:"Encoder and decoder must have the same max size, got [$encoderMaxSize] and [$decoderMaxSize].",[yn]:"Encoder and decoder must either both be fixed-size or variable-size.",[bn]:"Enum discriminator out of range. Expected a number in [$formattedValidDiscriminators], got $discriminator.",[dt]:"Expected a fixed-size codec, got a variable-size one.",[vn]:"Codec [$codecDescription] expected a positive byte length, got $bytesLength.",[hn]:"Expected a variable-size codec, got a fixed-size one.",[Qa]:"Codec [$codecDescription] expected zero-value [$hexZeroValue] to have the same size as the provided fixed-size item [$expectedSize bytes].",[ut]:"Codec [$codecDescription] expected $expected bytes, got $bytesLength.",[At]:"Expected byte array constant [$hexConstant] to be present in data [$hexData] at offset [$offset].",[Un]:"Invalid discriminated union variant. Expected one of [$variants], got $value.",[Pn]:"Invalid enum variant. Expected one of [$stringValues] or a number in [$formattedNumericalValues], got $variant.",[Bn]:"Invalid literal union variant. Expected one of [$variants], got $value.",[lt]:"Expected [$codecDescription] to have $expected items, got $actual.",[_e]:"Invalid value $value for base $base with alphabet $alphabet.",[Fn]:"Literal union discriminator out of range. Expected a number between $minRange and $maxRange, got $discriminator.",[It]:"Codec [$codecDescription] expected number to be in the range [$min, $max], got $value.",[wn]:"Codec [$codecDescription] expected offset to be in the range [0, $bytesLength], got $offset.",[kn]:"Expected sentinel [$hexSentinel] to be present in decoded bytes [$hexDecodedBytes].",[_t]:"Union variant out of range. Expected an index between $minRange and $maxRange, got $variant.",[Wn]:"This decoder expected a byte array of exactly $expectedLength bytes, but $numExcessBytes unexpected excess bytes remained after decoding. Are you sure that you have chosen the correct decoder for this data?",[Zo]:"No random values implementation could be found.",[Ei]:"instruction requires an uninitialized account",[Mi]:"instruction tries to borrow reference for an account which is already borrowed",[Li]:"instruction left account with an outstanding borrowed reference",[hi]:"program other than the account's owner changed the size of the account data",[li]:"account data too small for instruction",[yi]:"instruction expected an executable account",[Ji]:"An account does not have enough lamports to be rent-exempt",[ea]:"Program arithmetic overflowed",[Zi]:"Failed to serialize or deserialize account data: $encodedData",[aa]:"Builtin programs must consume compute units",[zi]:"Cross-program invocation call depth too deep",[Hi]:"Computational budget exceeded",[Ui]:"custom program error: #$code",[mi]:"instruction contains duplicate accounts",[bi]:"instruction modifications of multiply-passed account differ",[Bi]:"executable accounts must be rent exempt",[vi]:"instruction changed executable accounts data",[wi]:"instruction changed the balance of an executable account",[pi]:"instruction changed executable bit of an account",[Di]:"instruction modified data of an account it does not own",[fi]:"instruction spent from the balance of an account it does not own",[si]:"generic instruction error",[na]:"Provided owner is not allowed",[qi]:"Account is immutable",[Xi]:"Incorrect authority provided",[_i]:"incorrect program id for instruction",[Ii]:"insufficient funds for instruction",[di]:"invalid account data for instruction",[Qi]:"Invalid account owner",[ci]:"invalid program argument",[Pi]:"program returned invalid error code",[ui]:"invalid instruction data",[Vi]:"Failed to reallocate account data",[Gi]:"Provided seeds do not result in a valid address",[ra]:"Accounts data allocations exceeded the maximum allowed per transaction",[oa]:"Max accounts exceeded",[ia]:"Max instruction trace length exceeded",[Wi]:"Length of the seed is too long for address generation",[ki]:"An account required by the instruction is missing",[Ai]:"missing required signature for instruction",[gi]:"instruction illegally modified the program id of an account",[Oi]:"insufficient account keys for instruction",[Ki]:"Cross-program invocation with unauthorized signer or writable account",[$i]:"Failed to create program execution environment",[Yi]:"Program failed to compile",[ji]:"Program failed to complete",[Ni]:"instruction modified data of a read-only account",[Si]:"instruction changed the balance of a read-only account",[xi]:"Cross-program invocation reentrancy not allowed for this instruction",[Ci]:"instruction modified rent epoch of an account",[Ti]:"sum of account balances before and after instruction do not match",[Ri]:"instruction requires an initialized account",[ai]:"",[Fi]:"Unsupported program id",[ta]:"Unsupported sysvar",[As]:"Invalid instruction plan kind: $kind.",[Za]:"The provided instruction plan is empty.",[Ja]:"The provided transaction plan failed to execute. See the `transactionPlanResult` attribute and the `cause` error for more details.",[qa]:"The provided message has insufficient capacity to accommodate the next instruction(s) in this plan. Expected at least $numBytesRequired free byte(s), got $numFreeBytes byte(s).",[Es]:"Invalid transaction plan kind: $kind.",[Xa]:"No more instructions to pack; the message packer has completed the instruction plan.",[ri]:"The instruction does not have any accounts.",[oi]:"The instruction does not have any data.",[ii]:"Expected instruction to have progress address $expectedProgramAddress, got $actualProgramAddress.",[Io]:"Expected base58 encoded blockhash to decode to a byte array of length 32. Actual length: $actualLength.",[co]:"The nonce `$expectedNonceValue` is no longer valid. It has advanced to `$actualNonceValue`",[ls]:"Invariant violation: Found no abortable iterable cache entry for key `$cacheKey`. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[_s]:"Invariant violation: This data publisher does not publish to the channel named `$channelName`. Supported channels include $supportedChannelNames.",[ds]:"Invariant violation: WebSocket message iterator state is corrupt; iterated without first resolving existing message promise. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[us]:"Invariant violation: WebSocket message iterator is missing state storage. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[Is]:"Invariant violation: Switch statement non-exhaustive. Received unexpected value `$unexpectedValue`. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[fo]:"JSON-RPC error: Internal JSON-RPC error ($__serverMessage)",[Do]:"JSON-RPC error: Invalid method parameter(s) ($__serverMessage)",[No]:"JSON-RPC error: The JSON sent is not a valid `Request` object ($__serverMessage)",[So]:"JSON-RPC error: The method does not exist / is not available ($__serverMessage)",[go]:"JSON-RPC error: An error occurred on the server while parsing the JSON text ($__serverMessage)",[Lo]:"$__serverMessage",[Wo]:"$__serverMessage",[zo]:"$__serverMessage",[yo]:"$__serverMessage",[Co]:"Epoch rewards period still active at slot $slot",[Uo]:"$__serverMessage",[Po]:"$__serverMessage",[mo]:"Failed to query long-term storage; please try again",[Oo]:"Minimum context slot has not been reached",[Fo]:"Node is unhealthy; behind by $numSlotsBehind slots",[vo]:"No snapshot",[xo]:"Transaction simulation failed",[po]:"Rewards cannot be found because slot $slot is not the epoch boundary. This may be due to gap in the queried node's local ledger or long-term storage",[wo]:"$__serverMessage",[bo]:"Transaction history is not available from this node",[Bo]:"$__serverMessage",[Mo]:"Transaction signature length mismatch",[ko]:"Transaction signature verification failure",[ho]:"$__serverMessage",[Jo]:"Key pair bytes must be of length 64, got $byteLength.",[Qo]:"Expected private key bytes with length 32. Actual length: $actualLength.",[ei]:"Expected base58-encoded signature to decode to a byte array of length 64. Actual length: $actualLength.",[ni]:"The provided private key does not match the provided public key.",[ti]:"Expected base58-encoded signature string of length in the range [64, 88]. Actual length: $actualLength.",[_o]:"Lamports value must be in the range [0, 2e64-1]",[Ao]:"`$value` cannot be parsed as a `BigInt`",[To]:"$message",[Eo]:"`$value` cannot be parsed as a `Number`",[uo]:"No nonce account could be found at address `$nonceAccountAddress`",[os]:"The notification name must end in 'Notifications' and the API must supply a subscription plan creator function for the notification '$notificationName'.",[as]:"WebSocket was closed before payload could be added to the send buffer",[ss]:"WebSocket connection closed",[cs]:"WebSocket failed to connect",[is]:"Failed to obtain a subscription id from the server",[rs]:"Could not find an API plan for RPC method: `$method`",[es]:"The $argumentLabel argument to the `$methodName` RPC method$optionalPathLabel was `$value`. This number is unsafe for use with the Solana JSON-RPC because it exceeds `Number.MAX_SAFE_INTEGER`.",[ns]:"HTTP error ($statusCode): $message",[ts]:"HTTP header(s) forbidden: $headers. Learn more at https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_header_name.",[Qe]:"Multiple distinct signers were identified for address `$address`. Please ensure that you are using the same signer instance for each address.",[sn]:"The provided value does not implement the `KeyPairSigner` interface",[un]:"The provided value does not implement the `MessageModifyingSigner` interface",[dn]:"The provided value does not implement the `MessagePartialSigner` interface",[cn]:"The provided value does not implement any of the `MessageSigner` interfaces",[In]:"The provided value does not implement the `TransactionModifyingSigner` interface",[_n]:"The provided value does not implement the `TransactionPartialSigner` interface",[An]:"The provided value does not implement the `TransactionSendingSigner` interface",[ln]:"The provided value does not implement any of the `TransactionSigner` interfaces",[En]:"More than one `TransactionSendingSigner` was identified.",[Rn]:"No `TransactionSendingSigner` was identified. Please provide a valid `TransactionWithSingleSendingSigner` transaction.",[sa]:"Wallet account signers do not support signing multiple messages/transactions in a single operation",[Xo]:"Cannot export a non-extractable key.",[Ho]:"No digest implementation could be found.",[Vo]:"Cryptographic operations are only allowed in secure browser contexts. Read more here: https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts.",[Ko]:`This runtime does not support the generation of Ed25519 key pairs.
2
2
 
3
3
  Install @solana/webcrypto-ed25519-polyfill and call its \`install\` function before generating keys in environments that do not support Ed25519.
4
4
 
5
- For a list of runtimes that currently support Ed25519 operations, visit https://github.com/WICG/webcrypto-secure-curves/issues/20.`,[Vo]:"No signature verification implementation could be found.",[Ho]:"No key generation implementation could be found.",[Ko]:"No signing implementation could be found.",[$o]:"No key export implementation could be found.",[_o]:"Timestamp value must be in the range [-(2n ** 63n), (2n ** 63n) - 1]. `$value` given",[Ca]:"Transaction processing left an account with an outstanding borrowed reference",[da]:"Account in use",[la]:"Account loaded twice",[Ia]:"Attempt to debit an account but found no record of a prior credit.",[Ua]:"Transaction loads an address table account that doesn't exist",[Ra]:"This transaction has already been processed",[Ta]:"Blockhash not found",[ga]:"Loader call chain is too deep",[pa]:"Transactions are currently disabled due to cluster maintenance",[ka]:"Transaction contains a duplicate instruction ($index) that is not allowed",[Aa]:"Insufficient funds for fee",[xa]:"Transaction results in an account ($accountIndex) with insufficient funds for rent",[Ea]:"This account may not be used to pay transaction fees",[Da]:"Transaction contains an invalid account reference",[va]:"Transaction loads an address table account with invalid data",[wa]:"Transaction address table lookup uses an invalid index",[Pa]:"Transaction loads an address table account with an invalid owner",[Ga]:"LoadedAccountsDataSizeLimit set for transaction must be greater than 0.",[Na]:"This program may not be used for executing instructions",[Ba]:"Transaction leaves an account with a lower balance than rent-exempt minimum",[ya]:"Transaction loads a writable account that cannot be written",[Wa]:"Transaction exceeded max loaded accounts data size cap",[fa]:"Transaction requires a fee but has no signature present",[_a]:"Attempt to load a program that does not exist",[Ha]:"Execution of the program referenced by account at index $accountIndex is temporarily restricted.",[Va]:"ResanitizationNeeded",[ma]:"Transaction failed to sanitize accounts offsets correctly",[Sa]:"Transaction did not pass signature verification",[ba]:"Transaction locked too many accounts",[Ka]:"Sum of account balances before and after transaction do not match",[ua]:"The transaction failed with the error `$errorName`",[ha]:"Transaction version is unsupported",[La]:"Transaction would exceed account data limit within the block",[za]:"Transaction would exceed total account data limit",[Ma]:"Transaction would exceed max account limit within the block",[Oa]:"Transaction would exceed max Block Cost Limit",[Fa]:"Transaction would exceed max Vote Cost Limit",[fn]:"Attempted to sign a transaction with an address that is not a signer for it",[ia]:"Transaction is missing an address at index: $index.",[ot]:"Transaction has no expected signers therefore it cannot be encoded",[mn]:"Transaction size $transactionSize exceeds limit of $transactionSizeLimit bytes",[Qe]:"Transaction does not have a blockhash lifetime",[et]:"Transaction is not a durable nonce transaction",[En]:"Contents of these address lookup tables unknown: $lookupTableAddresses",[Rn]:"Lookup of address at index $highestRequestedIndex failed for lookup table `$lookupTableAddress`. Highest known index is $highestKnownIndex. The lookup table may have been extended since its contents were retrieved",[gn]:"No fee payer set in CompiledTransaction",[Tn]:"Could not find program address at index $index",[Sn]:"Failed to estimate the compute unit consumption for this transaction message. This is likely because simulating the transaction failed. Inspect the `cause` property of this error to learn more",[Nn]:"Transaction failed when it was simulated in order to estimate the compute unit consumption. The compute unit estimate provided is for a transaction that failed when simulated and may not be representative of the compute units this transaction would consume if successful. Inspect the `cause` property of this error to learn more",[aa]:"Transaction is missing a fee payer.",[rt]:"Could not determine this transaction's signature. Make sure that the transaction has been signed by its fee payer.",[ca]:"Transaction first instruction is not advance nonce account instruction.",[sa]:"Transaction with no instructions cannot be durable nonce transaction.",[Je]:"This transaction includes an address (`$programAddress`) which is both invoked and set as the fee payer. Program addresses may not pay fees",[Ce]:"This transaction includes an address (`$programAddress`) which is both invoked and marked writable. Program addresses may not be writable",[Dn]:"The transaction message expected the transaction to have $numRequiredSignatures signatures, got $signaturesLength.",[nt]:"Transaction is missing signatures for addresses: $addresses.",[tt]:"Transaction version must be in the range [0, 127]. `$actualVersion` given",[it]:"This version of Kit does not support decoding transactions with version $unsupportedVersion. The current max supported version is 0.",[pn]:"The transaction has a durable nonce lifetime (with nonce `$nonce`), but the nonce account address is in a lookup table. The lifetime constraint cannot be constructed without fetching the lookup tables for the transaction."},P="i",U="t";function Rs(e,t={}){let n=Es[e];if(n.length===0)return "";let r;function i(a){if(r[U]===2){let s=n.slice(r[P]+1,a);o.push(s in t?`${t[s]}`:`$${s}`);}else r[U]===1&&o.push(n.slice(r[P],a));}let o=[];return n.split("").forEach((a,s)=>{if(s===0){r={[P]:0,[U]:n[0]==="\\"?0:n[0]==="$"?2:1};return}let c;switch(r[U]){case 0:c={[P]:s,[U]:1};break;case 1:a==="\\"?c={[P]:s,[U]:0}:a==="$"&&(c={[P]:s,[U]:2});break;case 2:a==="\\"?c={[P]:s,[U]:0}:a==="$"?c={[P]:s,[U]:2}:a.match(/\w/)||(c={[P]:s,[U]:1});break}c&&(r!==c&&i(s),r=c);}),i(),o.join("")}function Ts(e,t={}){if(process.env.NODE_ENV!=="production")return Rs(e,t);{let n=`Solana error #${e}; Decode this error by running \`npx @solana/errors decode -- ${e}`;return Object.keys(t).length&&(n+=` '${As(t)}'`),`${n}\``}}var I=class extends Error{cause=this.cause;context;constructor(...[e,t]){let n,r;t&&Object.entries(Object.getOwnPropertyDescriptors(t)).forEach(([o,a])=>{o==="cause"?r={cause:a.value}:(n===void 0&&(n={}),Object.defineProperty(n,o,a));});let i=Ts(e,n);super(i,r),this.context=n===void 0?{}:n,this.context.__code=e,this.name="SolanaError";}};function gs(e,t){if(e.length>=t)return e;let n=new Uint8Array(t).fill(0);return n.set(e),n}var fs=(e,t)=>gs(e.length<=t?e:e.slice(0,t),t);function $(e,t,n){let r=n===0&&e.length===t.length?e:e.slice(n,n+t.length);return r.length!==t.length?false:t.every((i,o)=>i===r[o])}function z(e,t){return "fixedSize"in t?t.fixedSize:t.getSizeFromValue(e)}function R(e){return Object.freeze({...e,encode:t=>{let n=new Uint8Array(z(t,e));return e.write(t,n,0),n}})}function g(e){return Object.freeze({...e,decode:(t,n=0)=>e.read(t,n)[0]})}function C(e){return "fixedSize"in e&&typeof e.fixedSize=="number"}function _t(e){if(!C(e))throw new I(ct)}function Ds(e){return !C(e)}function Wn(e,t,n=0){if(t.length-n<=0)throw new I(at,{codecDescription:e})}function Oe(e,t,n,r=0){let i=n.length-r;if(i<t)throw new I(st,{bytesLength:i,codecDescription:e,expected:t})}function Gn(e,t){let n=(a,s,c)=>{let u=e.encode(a);return c=t.write(u.length,s,c),s.set(u,c),c+u.length};if(C(t)&&C(e))return R({...e,fixedSize:t.fixedSize+e.fixedSize,write:n});let r=C(t)?t.fixedSize:t.maxSize??null,i=C(e)?e.fixedSize:e.maxSize??null,o=r!==null&&i!==null?r+i:null;return R({...e,...o!==null?{maxSize:o}:{},getSizeFromValue:a=>{let s=z(a,e);return z(s,t)+s},write:n})}function k(e,t){return R({fixedSize:t,write:(n,r,i)=>{let o=e.encode(n),a=o.length>t?o.slice(0,t):o;return r.set(a,i),i+t}})}function K(e,t){return g({fixedSize:t,read:(n,r)=>{Oe("fixCodecSize",t,n,r),(r>0||n.length>t)&&(n=n.slice(r,r+t)),C(e)&&(n=fs(n,e.fixedSize));let[i]=e.read(n,0);return [i,r+t]}})}function m(e,t){return R({...Ds(e)?{...e,getSizeFromValue:n=>e.getSizeFromValue(t(n))}:e,write:(n,r,i)=>e.write(t(n),r,i)})}function x(e,t){return g({...e,read:(n,r)=>{let[i,o]=e.read(n,r);return [t(i,n,r),o]}})}function Kn(e,t,n=t){if(!t.match(new RegExp(`^[${e}]*$`)))throw new I(ce,{alphabet:e,base:e.length,value:n})}var Ss=e=>R({getSizeFromValue:t=>{let[n,r]=Vn(t,e[0]);if(!r)return t.length;let i=Hn(r,e);return n.length+Math.ceil(i.toString(16).length/2)},write(t,n,r){if(Kn(e,t),t==="")return r;let[i,o]=Vn(t,e[0]);if(!o)return n.set(new Uint8Array(i.length).fill(0),r),r+i.length;let a=Hn(o,e),s=[];for(;a>0n;)s.unshift(Number(a%256n)),a/=256n;let c=[...Array(i.length).fill(0),...s];return n.set(c,r),r+c.length}}),Ns=e=>g({read(t,n){let r=n===0?t:t.slice(n);if(r.length===0)return ["",0];let i=r.findIndex(c=>c!==0);i=i===-1?r.length:i;let o=e[0].repeat(i);if(i===r.length)return [o,t.length];let a=r.slice(i).reduce((c,u)=>c*256n+BigInt(u),0n),s=ms(a,e);return [o+s,t.length]}});function Vn(e,t){let[n,r]=e.split(new RegExp(`((?!${t}).*)`));return [n,r]}function Hn(e,t){let n=BigInt(t.length),r=0n;for(let i of e)r*=n,r+=BigInt(t.indexOf(i));return r}function ms(e,t){let n=BigInt(t.length),r=[];for(;e>0n;)r.unshift(t[Number(e%n)]),e/=n;return r.join("")}var $n="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",ue=()=>Ss($n),he=()=>Ns($n);var ps="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",M=()=>R({getSizeFromValue:e=>Buffer.from(e,"base64").length,write(e,t,n){Kn(ps,e.replace(/=/g,""));let r=Buffer.from(e,"base64");return t.set(r,n),r.length+n}}),O=()=>g({read:(e,t=0)=>[Buffer.from(e,t).toString("base64"),e.length]});function jn(e,t){try{return "exists"in e&&!e.exists?e:Object.freeze({...e,data:t.decode(e.data)})}catch{throw new I(qe,{address:e.address})}}function Cs(e){return !("exists"in e)||"exists"in e&&e.exists}function Yn(e){let t=e.filter(n=>Cs(n)&&n.data instanceof Uint8Array);if(t.length>0){let n=t.map(r=>r.address);throw new I(Xe,{addresses:n})}}function qn(e,t){if(!t)return Object.freeze({address:e,exists:false});let n=M().encode(t.data[0]);return Object.freeze({...Xn(t),address:e,data:n,exists:true})}function Os(e,t){if(!t)return Object.freeze({address:e,exists:false});let n=t.data.parsed.info;return Object.freeze({...Xn(t),address:e,data:n,exists:true})}function Xn(e){return Object.freeze({executable:e.executable,lamports:e.lamports,programAddress:e.owner,space:e.space})}async function Zn(e,t,n={}){let{abortSignal:r,...i}=n,o=await e.getAccountInfo(t,{...i,encoding:"base64"}).send({abortSignal:r});return qn(t,o.value)}async function Jn(e,t,n={}){let{abortSignal:r,...i}=n;return (await e.getMultipleAccounts(t,{...i,encoding:"jsonParsed"}).send({abortSignal:r})).value.map((a,s)=>a&&typeof a=="object"&&"parsed"in a.data?Os(t[s],a):qn(t[s],a))}function At(e){let t=e.filter(n=>!n.exists);if(t.length>0){let n=t.map(r=>r.address);throw new I(Ye,{addresses:n})}}var Et,Rt;function Tt(){return Et||(Et=ue()),Et}function ys(){return Rt||(Rt=he()),Rt}function Qn(e){if(e.length<32||e.length>44)return false;let t=Tt();try{return t.encode(e).byteLength===32}catch{return false}}function gt(e){if(e.length<32||e.length>44)throw new I(je,{actualLength:e.length});let r=Tt().encode(e).byteLength;if(r!==32)throw new I($e,{actualLength:r})}function f(e){return gt(e),e}function G(){return m(k(Tt(),32),e=>f(e))}function v(){return K(ys(),32)}function ye(){return new Intl.Collator("en",{caseFirst:"lower",ignorePunctuation:false,localeMatcher:"best fit",numeric:false,sensitivity:"variant",usage:"sort"}).compare}function er(e,t,n,r){if(r<t||r>n)throw new I(dt,{codecDescription:e,max:n,min:t,value:r})}function tr(e){return e?.endian!==1}function ft(e){return R({fixedSize:e.size,write(t,n,r){e.range&&er(e.name,e.range[0],e.range[1],t);let i=new ArrayBuffer(e.size);return e.set(new DataView(i),t,tr(e.config)),n.set(new Uint8Array(i),r),r+e.size}})}function Me(e){return g({fixedSize:e.size,read(t,n=0){Wn(e.name,t,n),Oe(e.name,e.size,t,n);let r=new DataView(Ms(t,n,e.size));return [e.get(r,tr(e.config)),n+e.size]}})}function Ms(e,t,n){let r=e.byteOffset+(t??0),i=n??e.byteLength;return e.buffer.slice(r,r+i)}var w=()=>R({getSizeFromValue:e=>e<=127?1:e<=16383?2:3,maxSize:3,write:(e,t,n)=>{er("shortU16",0,65535,e);let r=[0];for(let i=0;;i+=1){let o=Number(e)>>i*7;if(o===0)break;let a=127&o;r[i]=a,i>0&&(r[i-1]|=128);}return t.set(r,n),n+r.length}});var nr=(e={})=>Me({config:e,get:(t,n)=>t.getUint16(0,n),name:"u16",size:2});var de=(e={})=>ft({config:e,name:"u32",range:[0,4294967295],set:(t,n,r)=>t.setUint32(0,Number(n),r),size:4}),le=(e={})=>Me({config:e,get:(t,n)=>t.getUint32(0,n),name:"u32",size:4});var Ie=(e={})=>ft({config:e,name:"u64",range:[0n,BigInt("0xffffffffffffffff")],set:(t,n,r)=>t.setBigUint64(0,BigInt(n),r),size:8}),j=(e={})=>Me({config:e,get:(t,n)=>t.getBigUint64(0,n),name:"u64",size:8});var L=()=>ft({name:"u8",range:[0,255],set:(e,t)=>e.setUint8(0,Number(t)),size:1}),B=()=>Me({get:e=>e.getUint8(0),name:"u8",size:1});function Ls(e,t,n){if(t!==n)throw new I(ut,{actual:n,codecDescription:e,expected:t})}function bs(e){return e.reduce((t,n)=>t===null||n===null?null:Math.max(t,n),0)}function Y(e){return e.reduce((t,n)=>t===null||n===null?null:t+n,0)}function _e(e){return C(e)?e.fixedSize:null}function q(e){return C(e)?e.fixedSize:e.maxSize??null}function F(e,t={}){let n=t.size??de(),r=Le(n,_e(e)),i=Le(n,q(e))??void 0;return R({...r!==null?{fixedSize:r}:{getSizeFromValue:o=>(typeof n=="object"?z(o.length,n):0)+[...o].reduce((s,c)=>s+z(c,e),0),maxSize:i},write:(o,a,s)=>(typeof n=="number"&&Ls("array",n,o.length),typeof n=="object"&&(s=n.write(o.length,a,s)),o.forEach(c=>{s=e.write(c,a,s);}),s)})}function be(e,t={}){let n=t.size??le(),r=_e(e),i=Le(n,r),o=Le(n,q(e))??void 0;return g({...i!==null?{fixedSize:i}:{maxSize:o},read:(a,s)=>{let c=[];if(typeof n=="object"&&a.slice(s).length===0)return [c,s];if(n==="remainder"){for(;s<a.length;){let[l,_]=e.read(a,s);s=_,c.push(l);}return [c,s]}let[u,d]=typeof n=="number"?[n,s]:n.read(a,s);s=d;for(let l=0;l<u;l+=1){let[_,E]=e.read(a,s);s=E,c.push(_);}return [c,s]}})}function Le(e,t){return typeof e!="number"?null:e===0?0:t===null?null:t*e}function rr(e={}){return x(e.size??B(),t=>Number(t)===1)}function Ae(){return R({getSizeFromValue:e=>e.length,write:(e,t,n)=>(t.set(e,n),n+e.length)})}var Us=()=>g({read(e,t){return [e.slice(t).reduce((r,i)=>r+i.toString(16).padStart(2,"0"),""),e.length]}});function St(e){return R({fixedSize:e.length,write:(t,n,r)=>(n.set(e,r),r+e.length)})}function or(e){return g({fixedSize:e.length,read:(t,n)=>{let r=Us();if(!$(t,e,n))throw new I(It,{constant:e,data:t,hexConstant:r.decode(e),hexData:r.decode(t),offset:n});return [void 0,n+e.length]}})}function Ue(e){let t=Y(e.map(_e)),n=Y(e.map(q))??void 0;return g({...t===null?{maxSize:n}:{fixedSize:t},read:(r,i)=>{let o=[];return e.forEach(a=>{let[s,c]=a.read(r,i);o.push(s),i=c;}),[o,i]}})}function Nt(e,t){let n=ar(e),r=(o,a,s)=>{let c=t(o);return Dt(e,c),e[c].write(o,a,s)};if(n!==null)return R({fixedSize:n,write:r});let i=sr(e);return R({...i!==null?{maxSize:i}:{},getSizeFromValue:o=>{let a=t(o);return Dt(e,a),z(o,e[a])},write:r})}function ir(e,t){let n=ar(e),r=(o,a)=>{let s=t(o,a);return Dt(e,s),e[s].read(o,a)};if(n!==null)return g({fixedSize:n,read:r});let i=sr(e);return g({...i!==null?{maxSize:i}:{},read:r})}function Dt(e,t){if(typeof e[t]>"u")throw new I(lt,{maxRange:e.length-1,minRange:0,variant:t})}function ar(e){if(e.length===0)return 0;if(!C(e[0]))return null;let t=e[0].fixedSize;return e.every(r=>C(r)&&r.fixedSize===t)?t:null}function sr(e){return bs(e.map(t=>q(t)))}function Pe(){return g({fixedSize:0,read:(e,t)=>[void 0,t]})}function h(e){let t=e.map(([,i])=>i),n=Y(t.map(_e)),r=Y(t.map(q))??void 0;return R({...n===null?{getSizeFromValue:i=>e.map(([o,a])=>z(i[o],a)).reduce((o,a)=>o+a,0),maxSize:r}:{fixedSize:n},write:(i,o,a)=>(e.forEach(([s,c])=>{a=c.write(i[s],o,a);}),a)})}function Ee(e){let t=e.map(([,i])=>i),n=Y(t.map(_e)),r=Y(t.map(q))??void 0;return g({...n===null?{maxSize:r}:{fixedSize:n},read:(i,o)=>{let a={};return e.forEach(([s,c])=>{let[u,d]=c.read(i,o);o=d,a[s]=u;}),[a,o]}})}var Ps=e=>({__option:"Some",value:e}),vs=()=>({__option:"None"});function cr(e,t={}){let n=t.prefix===null?x(Pe(),()=>false):rr({size:t.prefix??B()}),r=t.noneValue==="zeroes"?(_t(e),K(Pe(),e.fixedSize)):t.noneValue?or(t.noneValue):Pe();return ir([x(Ue([n,r]),()=>vs()),x(Ue([n,e]),([,i])=>Ps(i))],(i,o)=>{if(t.prefix===null&&!t.noneValue)return +(o<i.length);if(t.prefix===null&&t.noneValue!=null){let a=t.noneValue==="zeroes"?new Uint8Array(r.fixedSize).fill(0):t.noneValue;return $(i,a,o)?0:1}return Number(n.read(i,o)[0])})}function ve(e,...t){return t.reduce((n,r)=>r(n),e)}var y=(e=>(e[e.WRITABLE_SIGNER=3]="WRITABLE_SIGNER",e[e.READONLY_SIGNER=2]="READONLY_SIGNER",e[e.WRITABLE=1]="WRITABLE",e[e.READONLY=0]="READONLY",e))(y||{});var ws=1;function V(e){return e>=2}function X(e){return (e&ws)!==0}function mt(e,t){return e|t}function ur(e){return Qn(e)}function dr(){return v()}function Rr(e){return "lifetimeConstraint"in e&&typeof e.lifetimeConstraint.blockhash=="string"&&typeof e.lifetimeConstraint.lastValidBlockHeight=="bigint"&&ur(e.lifetimeConstraint.blockhash)}function yt(e,t){return "lifetimeConstraint"in t&&t.lifetimeConstraint&&"blockhash"in t.lifetimeConstraint&&t.lifetimeConstraint.blockhash===e.blockhash&&t.lifetimeConstraint.lastValidBlockHeight===e.lastValidBlockHeight?t:Object.freeze({...t,lifetimeConstraint:Object.freeze(e)})}function zs(e,t,n=t){if(!t.match(new RegExp(`^[${e}]*$`)))throw new I(ce,{alphabet:e,base:e.length,value:n})}var ks=e=>R({getSizeFromValue:t=>{let[n,r]=lr(t,e[0]);if(!r)return t.length;let i=Ir(r,e);return n.length+Math.ceil(i.toString(16).length/2)},write(t,n,r){if(zs(e,t),t==="")return r;let[i,o]=lr(t,e[0]);if(!o)return n.set(new Uint8Array(i.length).fill(0),r),r+i.length;let a=Ir(o,e),s=[];for(;a>0n;)s.unshift(Number(a%256n)),a/=256n;let c=[...Array(i.length).fill(0),...s];return n.set(c,r),r+c.length}});function lr(e,t){let[n,r]=e.split(new RegExp(`((?!${t}).*)`));return [n,r]}function Ir(e,t){let n=BigInt(t.length),r=0n;for(let i of e)r*=n,r+=BigInt(t.indexOf(i));return r}var xs="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",Ws=()=>ks(xs);var pt;function Gs(){if(!pt){let e=F(L(),{size:w()});pt=h([["lookupTableAddress",G()],["writableIndexes",e],["readonlyIndexes",e]]);}return pt}var Ct;function Ot(){return Ct||(Ct=L()),Ct}function Vs(){return h([["numSignerAccounts",Ot()],["numReadonlySignerAccounts",Ot()],["numReadonlyNonSignerAccounts",Ot()]])}var ht;function Hs(){return ht||(ht=m(h([["programAddressIndex",L()],["accountIndices",F(L(),{size:w()})],["data",Gn(Ae(),w())]]),e=>e.accountIndices!==void 0&&e.data!==void 0?e:{...e,accountIndices:e.accountIndices??[],data:e.data??new Uint8Array(0)})),ht}var Ks=0,$s=128;function js(){return R({getSizeFromValue:e=>e==="legacy"?0:1,maxSize:1,write:(e,t,n)=>{if(e==="legacy")return n;if(e<0||e>127)throw new I(tt,{actualVersion:e});if(e>Ks)throw new I(it,{unsupportedVersion:e});return t.set([e|$s],n),n+1}})}function _r(){return h(Tr())}function Ar(){return m(h([...Tr(),["addressTableLookups",Ys()]]),e=>e.version==="legacy"?e:{...e,addressTableLookups:e.addressTableLookups??[]})}function Tr(){let e=Nt([St(new Uint8Array(32)),k(Ws(),32)],t=>t===void 0?0:1);return [["version",js()],["header",Vs()],["staticAccounts",F(G(),{size:w()})],["lifetimeToken",e],["instructions",F(Hs(),{size:w()})]]}function Ys(){return F(Gs(),{size:w()})}function gr(){return R({getSizeFromValue:e=>e.version==="legacy"?_r().getSizeFromValue(e):Ar().getSizeFromValue(e),write:(e,t,n)=>e.version==="legacy"?_r().write(e,t,n):Ar().write(e,t,n)})}function Er(e,t,n){e[t]=n(e[t]??{role:y.READONLY});}var T=Symbol("AddressMapTypeProperty");function qs(e,t){let n={[e]:{[T]:0,role:y.WRITABLE_SIGNER}},r=new Set;for(let i of t){Er(n,i.programAddress,a=>{if(r.add(i.programAddress),T in a){if(X(a.role))switch(a[T]){case 0:throw new I(Je,{programAddress:i.programAddress});default:throw new I(Ce,{programAddress:i.programAddress})}if(a[T]===2)return a}return {[T]:2,role:y.READONLY}});let o;if(i.accounts)for(let a of i.accounts)Er(n,a.address,s=>{let{address:c,...u}=a;if(T in s)switch(s[T]){case 0:return s;case 1:{let d=mt(s.role,u.role);if("lookupTableAddress"in u){if(s.lookupTableAddress!==u.lookupTableAddress&&(o||=ye())(u.lookupTableAddress,s.lookupTableAddress)<0)return {[T]:1,...u,role:d}}else if(V(u.role))return {[T]:2,role:d};return s.role!==d?{...s,role:d}:s}case 2:{let d=mt(s.role,u.role);if(r.has(a.address)){if(X(u.role))throw new I(Ce,{programAddress:a.address});return s.role!==d?{...s,role:d}:s}else return "lookupTableAddress"in u&&!V(s.role)?{...u,[T]:1,role:d}:s.role!==d?{...s,role:d}:s}}return "lookupTableAddress"in u?{...u,[T]:1}:{...u,[T]:2}});}return n}function Xs(e){let t;return Object.entries(e).sort(([r,i],[o,a])=>{if(i[T]!==a[T]){if(i[T]===0)return -1;if(a[T]===0)return 1;if(i[T]===2)return -1;if(a[T]===2)return 1}let s=V(i.role);if(s!==V(a.role))return s?-1:1;let c=X(i.role);return c!==X(a.role)?c?-1:1:(t||=ye(),i[T]===1&&a[T]===1&&i.lookupTableAddress!==a.lookupTableAddress?t(i.lookupTableAddress,a.lookupTableAddress):t(r,o))}).map(([r,i])=>({address:r,...i}))}function Zs(e){let t={};for(let n of e){if(!("lookupTableAddress"in n))continue;let r=t[n.lookupTableAddress]||={readonlyIndexes:[],writableIndexes:[]};n.role===y.WRITABLE?r.writableIndexes.push(n.addressIndex):r.readonlyIndexes.push(n.addressIndex);}return Object.keys(t).sort(ye()).map(n=>({lookupTableAddress:n,...t[n]}))}function Js(e){let t=0,n=0,r=0;for(let i of e){if("lookupTableAddress"in i)break;let o=X(i.role);V(i.role)?(r++,o||n++):o||t++;}return {numReadonlyNonSignerAccounts:t,numReadonlySignerAccounts:n,numSignerAccounts:r}}function Qs(e){let t={};for(let[n,r]of e.entries())t[r.address]=n;return t}function ec(e,t){let n=Qs(t);return e.map(({accounts:r,data:i,programAddress:o})=>({programAddressIndex:n[o],...r?{accountIndices:r.map(({address:a})=>n[a])}:null,...i?{data:i}:null}))}function tc(e){return "nonce"in e?e.nonce:e.blockhash}function nc(e){let t=e.findIndex(r=>"lookupTableAddress"in r);return (t===-1?e:e.slice(0,t)).map(({address:r})=>r)}function fr(e){let t=qs(e.feePayer.address,e.instructions),n=Xs(t),r=e.lifetimeConstraint;return {...e.version!=="legacy"?{addressTableLookups:Zs(n)}:null,...r?{lifetimeToken:tc(r)}:null,header:Js(n),instructions:ec(e.instructions,n),staticAccounts:nc(n),version:e.version}}function rc(e,t,n){for(let[r,i]of Object.entries(n))for(let o=0;o<i.length;o++)if(e===i[o])return {address:e,addressIndex:o,lookupTableAddress:r,role:t}}function Mt(e,t){let n=new Set(e.instructions.map(a=>a.programAddress)),r=new Set(Object.values(t).flatMap(a=>a).filter(a=>!n.has(a))),i=[],o=false;for(let a of e.instructions){if(!a.accounts){i.push(a);continue}let s=[],c=false;for(let u of a.accounts){if("lookupTableAddress"in u||!r.has(u.address)||V(u.role)){s.push(u);continue}let d=rc(u.address,u.role,t);s.push(Object.freeze(d)),c=true,o=true;}i.push(Object.freeze(c?{...a,accounts:s}:a));}return Object.freeze(o?{...e,instructions:i}:e)}function Lt(e){return Object.freeze({instructions:Object.freeze([]),version:e.version})}var oc="SysvarRecentB1ockHashes11111111111111111111",ic="11111111111111111111111111111111";function ac(e){return e.programAddress===ic&&e.data!=null&&sc(e.data)&&e.accounts?.length===3&&e.accounts[0].address!=null&&e.accounts[0].role===y.WRITABLE&&e.accounts[1].address===oc&&e.accounts[1].role===y.READONLY&&e.accounts[2].address!=null&&V(e.accounts[2].role)}function sc(e){return e.byteLength===4&&e[0]===4&&e[1]===0&&e[2]===0&&e[3]===0}function bt(e){return "lifetimeConstraint"in e&&typeof e.lifetimeConstraint.nonce=="string"&&e.instructions[0]!=null&&ac(e.instructions[0])}function Ut(e,t){return Object.freeze({...t,instructions:Object.freeze([...t.instructions,...e])})}function we(e,t){return Object.freeze({...t,instructions:Object.freeze([...e,...t.instructions])})}function cc(e){let t=Object.values(e);if(t.length===0)throw new I(ot);return t.map(n=>n||new Uint8Array(64).fill(0))}function uc(){return m(F(k(Ae(),64),{size:w()}),cc)}function vt(){return h([["signatures",uc()],["messageBytes",Ae()]])}function Z(e){let t=fr(e),n=gr().encode(t),r=t.staticAccounts.slice(0,t.header.numSignerAccounts),i={};for(let a of r)i[a]=null;let o;return Rr(e)?o={blockhash:e.lifetimeConstraint.blockhash,lastValidBlockHeight:e.lifetimeConstraint.lastValidBlockHeight}:bt(e)&&(o={nonce:e.lifetimeConstraint.nonce,nonceAccountAddress:e.instructions[0].accounts[0].address}),Object.freeze({...o?{lifetimeConstraint:o}:void 0,messageBytes:n,signatures:Object.freeze(i)})}var Pt;function wt(e){Pt||(Pt=he());let t=Object.values(e.signatures)[0];if(!t)throw new I(rt);return Pt.decode(t)}function Dr(e){let t=[];if(Object.entries(e.signatures).forEach(([n,r])=>{r||t.push(n);}),t.length>0)throw new I(nt,{addresses:t})}function J(e){let t=vt().encode(e);return O().decode(t)}function Bt(e){let t={};return e.forEach(n=>{if(!t[n.address])t[n.address]=n;else if(t[n.address]!==n)throw new I(Ze,{address:n.address})}),Object.values(t)}function Be(e){return "modifyAndSignTransactions"in e&&typeof e.modifyAndSignTransactions=="function"}function Re(e){return "signTransactions"in e&&typeof e.signTransactions=="function"}function Sr(e){return "signAndSendTransactions"in e&&typeof e.signAndSendTransactions=="function"}function Ft(e){return Re(e)||Be(e)||Sr(e)}function Ic(e){return Bt((e.accounts??[]).flatMap(t=>"signer"in t?t.signer:[]))}function _c(e){return Bt([...e.feePayer&&Ft(e.feePayer)?[e.feePayer]:[],...e.instructions.flatMap(Ic)])}function zt(e,t){Object.freeze(e);let n={...t,feePayer:e};return Object.freeze(n),n}async function Ac(e,t){let{partialSigners:n,modifyingSigners:r}=Ec(Bt(_c(e).filter(Ft)),{identifySendingSigner:false});return await gc(e,r,n,t)}async function kt(e,t){let n=await Ac(e,t);return Dr(n),n}function Ec(e,t={}){let r=t.identifySendingSigner??true?Rc(e):null,i=e.filter(s=>s!==r&&(Be(s)||Re(s))),o=Tc(i),a=i.filter(Re).filter(s=>!o.includes(s));return Object.freeze({modifyingSigners:o,partialSigners:a,sendingSigner:r})}function Rc(e){let t=e.filter(Sr);if(t.length===0)return null;let n=t.filter(r=>!Be(r)&&!Re(r));return n.length>0?n[0]:t[0]}function Tc(e){let t=e.filter(Be);if(t.length===0)return [];let n=t.filter(r=>!Re(r));return n.length>0?n:[t[0]]}async function gc(e,t=[],n=[],r){let i=Z(e),o=await t.reduce(async(s,c)=>{let[u]=await c.modifyAndSignTransactions([await s],r);return Object.freeze(u)},Promise.resolve(i));let a=await Promise.all(n.map(async s=>{let[c]=await s.signTransactions([o],r);return c}));return Object.freeze({...o,signatures:Object.freeze(a.reduce((s,c)=>({...s,...c}),o.signatures??{}))})}async function Nr(e,t,n){if(e.length===0)return {};let r=await Jn(t,e,n);return Yn(r),At(r),r.reduce((i,o)=>({...i,[o.address]:o.data.addresses}),{})}var Fe="ComputeBudget111111111111111111111111111111";var xt=2;function Wt(){return m(h([["discriminator",L()],["units",de()]]),e=>({...e,discriminator:xt}))}function Q(e,t){let n=Fe,r={...e};return Object.freeze({data:Wt().encode(r),programAddress:n})}var Gt=3;function Vt(){return m(h([["discriminator",L()],["microLamports",Ie()]]),e=>({...e,discriminator:Gt}))}function Te(e,t){let n=Fe,r={...e};return Object.freeze({data:Vt().encode(r),programAddress:n})}var ee="https://auth.revibase.com",ze="revibase.com",ge="https://api.revibase.com",ke="2c1LgZfCun82niPCgfg2cTMZmAiahraTjY4KNb1BSU4Z",mr="https://mainnet.block-engine.jito.wtf/api/v1/bundles",pr="https://bundles.jito.wtf/api/v1/bundles/tip_floor";var b=class e extends Error{code;constructor(t,n){super(t),this.name="RevibaseError",this.code=n,Object.setPrototypeOf(this,e.prototype);}},Cr=class e extends b{constructor(t="Popup blocked. Please enable popups."){super(t,"POPUP_BLOCKED"),this.name="RevibasePopupBlockedError",Object.setPrototypeOf(this,e.prototype);}},fe=class e extends b{constructor(t="Popup was closed by the user"){super(t,"POPUP_CLOSED"),this.name="RevibasePopupClosedError",Object.setPrototypeOf(this,e.prototype);}},De=class e extends b{constructor(t="Authentication timed out"){super(t,"TIMEOUT"),this.name="RevibaseTimeoutError",Object.setPrototypeOf(this,e.prototype);}},xe=class e extends b{constructor(t="An authorization flow is already in progress"){super(t,"FLOW_IN_PROGRESS"),this.name="RevibaseFlowInProgressError",Object.setPrototypeOf(this,e.prototype);}},Se=class e extends b{constructor(t="Aborted"){super(t,"ABORTED"),this.name="RevibaseAbortedError",Object.setPrototypeOf(this,e.prototype);}},We=class e extends b{constructor(t="Popup is not open. Call startRequest first."){super(t,"POPUP_NOT_OPEN"),this.name="RevibasePopupNotOpenError",Object.setPrototypeOf(this,e.prototype);}},te=class e extends b{constructor(t){super(t,"AUTH_FAILED"),this.name="RevibaseAuthError",Object.setPrototypeOf(this,e.prototype);}},Ne=class e extends b{constructor(t){super(t,"API_FAILED"),this.name="RevibaseApiError",Object.setPrototypeOf(this,e.prototype);}},Ge=class e extends b{constructor(t="Provider can only be used in a browser environment"){super(t,"ENVIRONMENT"),this.name="RevibaseEnvironmentError",Object.setPrototypeOf(this,e.prototype);}};var Or=180*1e3,hr=2e3,yr=async e=>{let t=await fetch("/api/sendJitoBundle",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),n=await t.json();if(!t.ok)throw new Ne(n.error??"Send jito bundle failed");return n},Mr=async()=>{let e=await fetch("/api/estimateJitoTips"),t=await e.json();if(!e.ok)throw new Ne(t.error??"Estimate jito tips failed");return t},Lr=async e=>{let t=await fetch("/api/clientAuthorization",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),n=await t.json();if(!t.ok)throw new te(n.error??"Authorization failed");return n};function br(e){if(typeof window>"u")throw new Error("Function can only be called in a browser environment");let t=window.innerWidth||window.screen.availWidth,n=window.innerHeight||window.screen.availHeight,r=t<=768,i,o,a,s;if(r)i=t,o=n,a=0,s=0;else {let u=window.screenLeft??window.screenX??0,d=window.screenTop??window.screenY??0,l=window.innerWidth??document.documentElement.clientWidth??window.screen.width,_=window.innerHeight??document.documentElement.clientHeight??window.screen.height;i=500,o=600,s=Math.round(u+(l-i)/2),a=Math.round(d+(_-o)/2);}let c=["popup=yes",`width=${i}`,`height=${o}`,`top=${a}`,`left=${s}`,"toolbar=no","location=no","status=no","menubar=no","scrollbars=yes","resizable=yes"].join(",");return window.open(e??"","_blank",c)}var Ur=class{pending=new Map;onClientAuthorizationCallback;onSendJitoBundleCallback;onEstimateJitoTipsCallback;providerOrigin;popUp=null;constructor(t){let{rpcEndpoint:n,providerOrigin:r,onClientAuthorizationCallback:i,onSendJitoBundleCallback:o,onEstimateJitoTipsCallback:a}=t;this.onClientAuthorizationCallback=i??Lr,this.onSendJitoBundleCallback=o??yr,this.onEstimateJitoTipsCallback=a??Mr,this.providerOrigin=r??ee,initialize({rpcEndpoint:n});}startRequest(){if(this.popUp=br(`${new URL(this.providerOrigin).origin}?clientOrigin=${window.origin}`),!this.popUp)throw new Error("Popup blocked. Disable your popup blocker.")}async sendPayloadToProviderViaPopup({request:t,signature:n,signal:r}){if(typeof window>"u")throw new Ge;if(this.pending.size>0)throw new xe;return new Promise((i,o)=>{let a=setTimeout(()=>{let s=this.pending.get(t.rid);s&&(s.cancel?s.cancel(new De):(this.pending.delete(t.rid),o(new De)));},t.validTill-Date.now());if(!this.popUp||this.popUp.closed)throw new We;this.pending.set(t.rid,{request:t,signature:n,resolve:i,reject:o,timeoutId:a}),this.attachTransport({popup:this.popUp,origin:new URL(this.providerOrigin).origin,request:t,signature:n,signal:r});})}attachTransport(t){let{popup:n,origin:r,request:i,signature:o,signal:a}=t,s=this.pending.get(i.rid);if(!s)return;let c=null,u=false,d=()=>{_(new Se);},l=()=>{a?.removeEventListener("abort",d),window.removeEventListener("message",D);try{c?.close();}catch{}c=null;try{n&&!n.closed&&n.close();}catch{}this.popUp=null,clearInterval(N);},_=A=>{u||(u=true,clearTimeout(s.timeoutId),this.pending.delete(i.rid),l(),s.reject(A));},E=A=>{u||(u=true,clearTimeout(s.timeoutId),this.pending.delete(i.rid),l(),s.resolve(A));};if(s.cancel=_,a?.aborted){_(new Se);return}a?.addEventListener("abort",d);let N=setInterval(()=>{n?.closed&&_(new fe);},hr),D=A=>{if(A.origin!==r||A.source!==n)return;let S=A.data;!S||S.type!=="popup-connect"||A.ports?.[0]&&(c=A.ports[0],c.start(),c.postMessage({type:"popup-init",payload:{request:i,signature:o}}),c.onmessage=p=>{switch(p.data.type){case "popup-complete":E(p.data.payload);break;case "popup-error":_(new te(p.data.error));break;case "popup-closed":{_(new fe("Lost connection with the popup."));break}}},window.removeEventListener("message",D));};window.addEventListener("message",D);}};function Pr(e){let t=e.domain?`${e.domain} wants you to sign in with your account.`:"Sign in with your account.",n=[];return e.nonce&&n.push(`Nonce: ${e.nonce}`),n.length>0?`${t}
5
+ For a list of runtimes that currently support Ed25519 operations, visit https://github.com/WICG/webcrypto-secure-curves/issues/20.`,[$o]:"No signature verification implementation could be found.",[jo]:"No key generation implementation could be found.",[Yo]:"No signing implementation could be found.",[qo]:"No key export implementation could be found.",[Ro]:"Timestamp value must be in the range [-(2n ** 63n), (2n ** 63n) - 1]. `$value` given",[ya]:"Transaction processing left an account with an outstanding borrowed reference",[_a]:"Account in use",[Aa]:"Account loaded twice",[Ea]:"Attempt to debit an account but found no record of a prior credit.",[wa]:"Transaction loads an address table account that doesn't exist",[fa]:"This transaction has already been processed",[Da]:"Blockhash not found",[Sa]:"Loader call chain is too deep",[ha]:"Transactions are currently disabled due to cluster maintenance",[Ga]:"Transaction contains a duplicate instruction ($index) that is not allowed",[Ta]:"Insufficient funds for fee",[Va]:"Transaction results in an account ($accountIndex) with insufficient funds for rent",[ga]:"This account may not be used to pay transaction fees",[ma]:"Transaction contains an invalid account reference",[Fa]:"Transaction loads an address table account with invalid data",[za]:"Transaction address table lookup uses an invalid index",[Ba]:"Transaction loads an address table account with an invalid owner",[Ka]:"LoadedAccountsDataSizeLimit set for transaction must be greater than 0.",[Ca]:"This program may not be used for executing instructions",[ka]:"Transaction leaves an account with a lower balance than rent-exempt minimum",[ba]:"Transaction loads a writable account that cannot be written",[Ha]:"Transaction exceeded max loaded accounts data size cap",[Na]:"Transaction requires a fee but has no signature present",[Ra]:"Attempt to load a program that does not exist",[ja]:"Execution of the program referenced by account at index $accountIndex is temporarily restricted.",[$a]:"ResanitizationNeeded",[Oa]:"Transaction failed to sanitize accounts offsets correctly",[pa]:"Transaction did not pass signature verification",[va]:"Transaction locked too many accounts",[Ya]:"Sum of account balances before and after transaction do not match",[Ia]:"The transaction failed with the error `$errorName`",[La]:"Transaction version is unsupported",[Pa]:"Transaction would exceed account data limit within the block",[Wa]:"Transaction would exceed total account data limit",[Ua]:"Transaction would exceed max account limit within the block",[Ma]:"Transaction would exceed max Block Cost Limit",[xa]:"Transaction would exceed max Vote Cost Limit",[Sn]:"Attempted to sign a transaction with an address that is not a signer for it",[ca]:"Transaction is missing an address at index: $index.",[at]:"Transaction has no expected signers therefore it cannot be encoded",[Cn]:"Transaction size $transactionSize exceeds limit of $transactionSizeLimit bytes",[tt]:"Transaction does not have a blockhash lifetime",[nt]:"Transaction is not a durable nonce transaction",[Tn]:"Contents of these address lookup tables unknown: $lookupTableAddresses",[gn]:"Lookup of address at index $highestRequestedIndex failed for lookup table `$lookupTableAddress`. Highest known index is $highestKnownIndex. The lookup table may have been extended since its contents were retrieved",[Dn]:"No fee payer set in CompiledTransaction",[fn]:"Could not find program address at index $index",[mn]:"Failed to estimate the compute unit consumption for this transaction message. This is likely because simulating the transaction failed. Inspect the `cause` property of this error to learn more",[pn]:"Transaction failed when it was simulated in order to estimate the compute unit consumption. The compute unit estimate provided is for a transaction that failed when simulated and may not be representative of the compute units this transaction would consume if successful. Inspect the `cause` property of this error to learn more",[ua]:"Transaction is missing a fee payer.",[it]:"Could not determine this transaction's signature. Make sure that the transaction has been signed by its fee payer.",[la]:"Transaction first instruction is not advance nonce account instruction.",[da]:"Transaction with no instructions cannot be durable nonce transaction.",[et]:"This transaction includes an address (`$programAddress`) which is both invoked and set as the fee payer. Program addresses may not pay fees",[he]:"This transaction includes an address (`$programAddress`) which is both invoked and marked writable. Program addresses may not be writable",[Nn]:"The transaction message expected the transaction to have $numRequiredSignatures signatures, got $signaturesLength.",[ot]:"Transaction is missing signatures for addresses: $addresses.",[rt]:"Transaction version must be in the range [0, 127]. `$actualVersion` given",[st]:"This version of Kit does not support decoding transactions with version $unsupportedVersion. The current max supported version is 0.",[On]:"The transaction has a durable nonce lifetime (with nonce `$nonce`), but the nonce account address is in a lookup table. The lifetime constraint cannot be constructed without fetching the lookup tables for the transaction."},k="i",F="t";function fs(e,t={}){let n=gs[e];if(n.length===0)return "";let r;function o(a){if(r[F]===2){let s=n.slice(r[k]+1,a);i.push(s in t?`${t[s]}`:`$${s}`);}else r[F]===1&&i.push(n.slice(r[k],a));}let i=[];return n.split("").forEach((a,s)=>{if(s===0){r={[k]:0,[F]:n[0]==="\\"?0:n[0]==="$"?2:1};return}let c;switch(r[F]){case 0:c={[k]:s,[F]:1};break;case 1:a==="\\"?c={[k]:s,[F]:0}:a==="$"&&(c={[k]:s,[F]:2});break;case 2:a==="\\"?c={[k]:s,[F]:0}:a==="$"?c={[k]:s,[F]:2}:a.match(/\w/)||(c={[k]:s,[F]:1});break}c&&(r!==c&&o(s),r=c);}),o(),i.join("")}function Ds(e,t={}){if(process.env.NODE_ENV!=="production")return fs(e,t);{let n=`Solana error #${e}; Decode this error by running \`npx @solana/errors decode -- ${e}`;return Object.keys(t).length&&(n+=` '${Ts(t)}'`),`${n}\``}}var _=class extends Error{cause=this.cause;context;constructor(...[e,t]){let n,r;t&&Object.entries(Object.getOwnPropertyDescriptors(t)).forEach(([i,a])=>{i==="cause"?r={cause:a.value}:(n===void 0&&(n={}),Object.defineProperty(n,i,a));});let o=Ds(e,n);super(o,r),this.context=n===void 0?{}:n,this.context.__code=e,this.name="SolanaError";}};function Ss(e,t){if(e.length>=t)return e;let n=new Uint8Array(t).fill(0);return n.set(e),n}var Ns=(e,t)=>Ss(e.length<=t?e:e.slice(0,t),t);function ee(e,t,n){let r=n===0&&e.length===t.length?e:e.slice(n,n+t.length);return r.length!==t.length?false:t.every((o,i)=>o===r[i])}function K(e,t){return "fixedSize"in t?t.fixedSize:t.getSizeFromValue(e)}function g(e){return Object.freeze({...e,encode:t=>{let n=new Uint8Array(K(t,e));return e.write(t,n,0),n}})}function N(e){return Object.freeze({...e,decode:(t,n=0)=>e.read(t,n)[0]})}function y(e){return "fixedSize"in e&&typeof e.fixedSize=="number"}function Et(e){if(!y(e))throw new _(dt)}function ms(e){return !y(e)}function Vn(e,t,n=0){if(t.length-n<=0)throw new _(ct,{codecDescription:e})}function ye(e,t,n,r=0){let o=n.length-r;if(o<t)throw new _(ut,{bytesLength:o,codecDescription:e,expected:t})}function Hn(e,t){let n=(a,s,c)=>{let u=e.encode(a);return c=t.write(u.length,s,c),s.set(u,c),c+u.length};if(y(t)&&y(e))return g({...e,fixedSize:t.fixedSize+e.fixedSize,write:n});let r=y(t)?t.fixedSize:t.maxSize??null,o=y(e)?e.fixedSize:e.maxSize??null,i=r!==null&&o!==null?r+o:null;return g({...e,...i!==null?{maxSize:i}:{},getSizeFromValue:a=>{let s=K(a,e);return K(s,t)+s},write:n})}function $(e,t){return g({fixedSize:t,write:(n,r,o)=>{let i=e.encode(n),a=i.length>t?i.slice(0,t):i;return r.set(a,o),o+t}})}function Q(e,t){return N({fixedSize:t,read:(n,r)=>{ye("fixCodecSize",t,n,r),(r>0||n.length>t)&&(n=n.slice(r,r+t)),y(e)&&(n=Ns(n,e.fixedSize));let[o]=e.read(n,0);return [o,r+t]}})}function O(e,t){return g({...ms(e)?{...e,getSizeFromValue:n=>e.getSizeFromValue(t(n))}:e,write:(n,r,o)=>e.write(t(n),r,o)})}function j(e,t){return N({...e,read:(n,r)=>{let[o,i]=e.read(n,r);return [t(o,n,r),i]}})}function jn(e,t,n=t){if(!t.match(new RegExp(`^[${e}]*$`)))throw new _(_e,{alphabet:e,base:e.length,value:n})}var ps=e=>g({getSizeFromValue:t=>{let[n,r]=Kn(t,e[0]);if(!r)return t.length;let o=$n(r,e);return n.length+Math.ceil(o.toString(16).length/2)},write(t,n,r){if(jn(e,t),t==="")return r;let[o,i]=Kn(t,e[0]);if(!i)return n.set(new Uint8Array(o.length).fill(0),r),r+o.length;let a=$n(i,e),s=[];for(;a>0n;)s.unshift(Number(a%256n)),a/=256n;let c=[...Array(o.length).fill(0),...s];return n.set(c,r),r+c.length}}),Cs=e=>N({read(t,n){let r=n===0?t:t.slice(n);if(r.length===0)return ["",0];let o=r.findIndex(c=>c!==0);o=o===-1?r.length:o;let i=e[0].repeat(o);if(o===r.length)return [i,t.length];let a=r.slice(o).reduce((c,u)=>c*256n+BigInt(u),0n),s=Os(a,e);return [i+s,t.length]}});function Kn(e,t){let[n,r]=e.split(new RegExp(`((?!${t}).*)`));return [n,r]}function $n(e,t){let n=BigInt(t.length),r=0n;for(let o of e)r*=n,r+=BigInt(t.indexOf(o));return r}function Os(e,t){let n=BigInt(t.length),r=[];for(;e>0n;)r.unshift(t[Number(e%n)]),e/=n;return r.join("")}var Yn="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",Ae=()=>ps(Yn),Me=()=>Cs(Yn);var hs="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",P=()=>g({getSizeFromValue:e=>Buffer.from(e,"base64").length,write(e,t,n){jn(hs,e.replace(/=/g,""));let r=Buffer.from(e,"base64");return t.set(r,n),r.length+n}}),M=()=>N({read:(e,t=0)=>[Buffer.from(e,t).toString("base64"),e.length]});function qn(e,t){try{return "exists"in e&&!e.exists?e:Object.freeze({...e,data:t.decode(e.data)})}catch{throw new _(Ze,{address:e.address})}}function ys(e){return !("exists"in e)||"exists"in e&&e.exists}function Xn(e){let t=e.filter(n=>ys(n)&&n.data instanceof Uint8Array);if(t.length>0){let n=t.map(r=>r.address);throw new _(Je,{addresses:n})}}function Zn(e,t){if(!t)return Object.freeze({address:e,exists:false});let n=P().encode(t.data[0]);return Object.freeze({...Jn(t),address:e,data:n,exists:true})}function Ms(e,t){if(!t)return Object.freeze({address:e,exists:false});let n=t.data.parsed.info;return Object.freeze({...Jn(t),address:e,data:n,exists:true})}function Jn(e){return Object.freeze({executable:e.executable,lamports:e.lamports,programAddress:e.owner,space:e.space})}async function Qn(e,t,n={}){let{abortSignal:r,...o}=n,i=await e.getAccountInfo(t,{...o,encoding:"base64"}).send({abortSignal:r});return Zn(t,i.value)}async function er(e,t,n={}){let{abortSignal:r,...o}=n;return (await e.getMultipleAccounts(t,{...o,encoding:"jsonParsed"}).send({abortSignal:r})).value.map((a,s)=>a&&typeof a=="object"&&"parsed"in a.data?Ms(t[s],a):Zn(t[s],a))}function Rt(e){let t=e.filter(n=>!n.exists);if(t.length>0){let n=t.map(r=>r.address);throw new _(Xe,{addresses:n})}}var Tt,gt;function ft(){return Tt||(Tt=Ae()),Tt}function bs(){return gt||(gt=Me()),gt}function tr(e){if(e.length<32||e.length>44)return false;let t=ft();try{return t.encode(e).byteLength===32}catch{return false}}function Dt(e){if(e.length<32||e.length>44)throw new _(qe,{actualLength:e.length});let r=ft().encode(e).byteLength;if(r!==32)throw new _(Ye,{actualLength:r})}function m(e){return Dt(e),e}function q(){return O($(ft(),32),e=>m(e))}function x(){return Q(bs(),32)}function Le(){return new Intl.Collator("en",{caseFirst:"lower",ignorePunctuation:false,localeMatcher:"best fit",numeric:false,sensitivity:"variant",usage:"sort"}).compare}function nr(e,t,n,r){if(r<t||r>n)throw new _(It,{codecDescription:e,max:n,min:t,value:r})}function rr(e){return e?.endian!==1}function St(e){return g({fixedSize:e.size,write(t,n,r){e.range&&nr(e.name,e.range[0],e.range[1],t);let o=new ArrayBuffer(e.size);return e.set(new DataView(o),t,rr(e.config)),n.set(new Uint8Array(o),r),r+e.size}})}function be(e){return N({fixedSize:e.size,read(t,n=0){Vn(e.name,t,n),ye(e.name,e.size,t,n);let r=new DataView(Us(t,n,e.size));return [e.get(r,rr(e.config)),n+e.size]}})}function Us(e,t,n){let r=e.byteOffset+(t??0),o=n??e.byteLength;return e.buffer.slice(r,r+o)}var W=()=>g({getSizeFromValue:e=>e<=127?1:e<=16383?2:3,maxSize:3,write:(e,t,n)=>{nr("shortU16",0,65535,e);let r=[0];for(let o=0;;o+=1){let i=Number(e)>>o*7;if(i===0)break;let a=127&i;r[o]=a,o>0&&(r[o-1]|=128);}return t.set(r,n),n+r.length}});var or=(e={})=>be({config:e,get:(t,n)=>t.getUint16(0,n),name:"u16",size:2});var Ee=(e={})=>St({config:e,name:"u32",range:[0,4294967295],set:(t,n,r)=>t.setUint32(0,Number(n),r),size:4}),Re=(e={})=>be({config:e,get:(t,n)=>t.getUint32(0,n),name:"u32",size:4});var Te=(e={})=>St({config:e,name:"u64",range:[0n,BigInt("0xffffffffffffffff")],set:(t,n,r)=>t.setBigUint64(0,BigInt(n),r),size:8}),te=(e={})=>be({config:e,get:(t,n)=>t.getBigUint64(0,n),name:"u64",size:8});var v=()=>St({name:"u8",range:[0,255],set:(e,t)=>e.setUint8(0,Number(t)),size:1}),G=()=>be({get:e=>e.getUint8(0),name:"u8",size:1});function Ps(e,t,n){if(t!==n)throw new _(lt,{actual:n,codecDescription:e,expected:t})}function vs(e){return e.reduce((t,n)=>t===null||n===null?null:Math.max(t,n),0)}function ne(e){return e.reduce((t,n)=>t===null||n===null?null:t+n,0)}function ge(e){return y(e)?e.fixedSize:null}function re(e){return y(e)?e.fixedSize:e.maxSize??null}function V(e,t={}){let n=t.size??Ee(),r=Ue(n,ge(e)),o=Ue(n,re(e))??void 0;return g({...r!==null?{fixedSize:r}:{getSizeFromValue:i=>(typeof n=="object"?K(i.length,n):0)+[...i].reduce((s,c)=>s+K(c,e),0),maxSize:o},write:(i,a,s)=>(typeof n=="number"&&Ps("array",n,i.length),typeof n=="object"&&(s=n.write(i.length,a,s)),i.forEach(c=>{s=e.write(c,a,s);}),s)})}function Pe(e,t={}){let n=t.size??Re(),r=ge(e),o=Ue(n,r),i=Ue(n,re(e))??void 0;return N({...o!==null?{fixedSize:o}:{maxSize:i},read:(a,s)=>{let c=[];if(typeof n=="object"&&a.slice(s).length===0)return [c,s];if(n==="remainder"){for(;s<a.length;){let[l,I]=e.read(a,s);s=I,c.push(l);}return [c,s]}let[u,d]=typeof n=="number"?[n,s]:n.read(a,s);s=d;for(let l=0;l<u;l+=1){let[I,E]=e.read(a,s);s=E,c.push(I);}return [c,s]}})}function Ue(e,t){return typeof e!="number"?null:e===0?0:t===null?null:t*e}function ir(e={}){return j(e.size??G(),t=>Number(t)===1)}function fe(){return g({getSizeFromValue:e=>e.length,write:(e,t,n)=>(t.set(e,n),n+e.length)})}var ws=()=>N({read(e,t){return [e.slice(t).reduce((r,o)=>r+o.toString(16).padStart(2,"0"),""),e.length]}});function mt(e){return g({fixedSize:e.length,write:(t,n,r)=>(n.set(e,r),r+e.length)})}function ar(e){return N({fixedSize:e.length,read:(t,n)=>{let r=ws();if(!ee(t,e,n))throw new _(At,{constant:e,data:t,hexConstant:r.decode(e),hexData:r.decode(t),offset:n});return [void 0,n+e.length]}})}function ve(e){let t=ne(e.map(ge)),n=ne(e.map(re))??void 0;return N({...t===null?{maxSize:n}:{fixedSize:t},read:(r,o)=>{let i=[];return e.forEach(a=>{let[s,c]=a.read(r,o);i.push(s),o=c;}),[i,o]}})}function pt(e,t){let n=cr(e),r=(i,a,s)=>{let c=t(i);return Nt(e,c),e[c].write(i,a,s)};if(n!==null)return g({fixedSize:n,write:r});let o=ur(e);return g({...o!==null?{maxSize:o}:{},getSizeFromValue:i=>{let a=t(i);return Nt(e,a),K(i,e[a])},write:r})}function sr(e,t){let n=cr(e),r=(i,a)=>{let s=t(i,a);return Nt(e,s),e[s].read(i,a)};if(n!==null)return N({fixedSize:n,read:r});let o=ur(e);return N({...o!==null?{maxSize:o}:{},read:r})}function Nt(e,t){if(typeof e[t]>"u")throw new _(_t,{maxRange:e.length-1,minRange:0,variant:t})}function cr(e){if(e.length===0)return 0;if(!y(e[0]))return null;let t=e[0].fixedSize;return e.every(r=>y(r)&&r.fixedSize===t)?t:null}function ur(e){return vs(e.map(t=>re(t)))}function we(){return N({fixedSize:0,read:(e,t)=>[void 0,t]})}function L(e){let t=e.map(([,o])=>o),n=ne(t.map(ge)),r=ne(t.map(re))??void 0;return g({...n===null?{getSizeFromValue:o=>e.map(([i,a])=>K(o[i],a)).reduce((i,a)=>i+a,0),maxSize:r}:{fixedSize:n},write:(o,i,a)=>(e.forEach(([s,c])=>{a=c.write(o[s],i,a);}),a)})}function De(e){let t=e.map(([,o])=>o),n=ne(t.map(ge)),r=ne(t.map(re))??void 0;return N({...n===null?{maxSize:r}:{fixedSize:n},read:(o,i)=>{let a={};return e.forEach(([s,c])=>{let[u,d]=c.read(o,i);i=d,a[s]=u;}),[a,i]}})}var Bs=e=>({__option:"Some",value:e}),Fs=()=>({__option:"None"});function dr(e,t={}){let n=t.prefix===null?j(we(),()=>false):ir({size:t.prefix??G()}),r=t.noneValue==="zeroes"?(Et(e),Q(we(),e.fixedSize)):t.noneValue?ar(t.noneValue):we();return sr([j(ve([n,r]),()=>Fs()),j(ve([n,e]),([,o])=>Bs(o))],(o,i)=>{if(t.prefix===null&&!t.noneValue)return +(i<o.length);if(t.prefix===null&&t.noneValue!=null){let a=t.noneValue==="zeroes"?new Uint8Array(r.fixedSize).fill(0):t.noneValue;return ee(o,a,i)?0:1}return Number(n.read(o,i)[0])})}function Be(e,...t){return t.reduce((n,r)=>r(n),e)}var b=(e=>(e[e.WRITABLE_SIGNER=3]="WRITABLE_SIGNER",e[e.READONLY_SIGNER=2]="READONLY_SIGNER",e[e.WRITABLE=1]="WRITABLE",e[e.READONLY=0]="READONLY",e))(b||{});var zs=1;function X(e){return e>=2}function oe(e){return (e&zs)!==0}function Ct(e,t){return e|t}function lr(e){return tr(e)}function Ir(){return x()}function gr(e){return "lifetimeConstraint"in e&&typeof e.lifetimeConstraint.blockhash=="string"&&typeof e.lifetimeConstraint.lastValidBlockHeight=="bigint"&&lr(e.lifetimeConstraint.blockhash)}function Lt(e,t){return "lifetimeConstraint"in t&&t.lifetimeConstraint&&"blockhash"in t.lifetimeConstraint&&t.lifetimeConstraint.blockhash===e.blockhash&&t.lifetimeConstraint.lastValidBlockHeight===e.lastValidBlockHeight?t:Object.freeze({...t,lifetimeConstraint:Object.freeze(e)})}function Ws(e,t,n=t){if(!t.match(new RegExp(`^[${e}]*$`)))throw new _(_e,{alphabet:e,base:e.length,value:n})}var Gs=e=>g({getSizeFromValue:t=>{let[n,r]=_r(t,e[0]);if(!r)return t.length;let o=Ar(r,e);return n.length+Math.ceil(o.toString(16).length/2)},write(t,n,r){if(Ws(e,t),t==="")return r;let[o,i]=_r(t,e[0]);if(!i)return n.set(new Uint8Array(o.length).fill(0),r),r+o.length;let a=Ar(i,e),s=[];for(;a>0n;)s.unshift(Number(a%256n)),a/=256n;let c=[...Array(o.length).fill(0),...s];return n.set(c,r),r+c.length}});function _r(e,t){let[n,r]=e.split(new RegExp(`((?!${t}).*)`));return [n,r]}function Ar(e,t){let n=BigInt(t.length),r=0n;for(let o of e)r*=n,r+=BigInt(t.indexOf(o));return r}var Vs="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",Hs=()=>Gs(Vs);var Ot;function Ks(){if(!Ot){let e=V(v(),{size:W()});Ot=L([["lookupTableAddress",q()],["writableIndexes",e],["readonlyIndexes",e]]);}return Ot}var ht;function yt(){return ht||(ht=v()),ht}function $s(){return L([["numSignerAccounts",yt()],["numReadonlySignerAccounts",yt()],["numReadonlyNonSignerAccounts",yt()]])}var Mt;function js(){return Mt||(Mt=O(L([["programAddressIndex",v()],["accountIndices",V(v(),{size:W()})],["data",Hn(fe(),W())]]),e=>e.accountIndices!==void 0&&e.data!==void 0?e:{...e,accountIndices:e.accountIndices??[],data:e.data??new Uint8Array(0)})),Mt}var Ys=0,qs=128;function Xs(){return g({getSizeFromValue:e=>e==="legacy"?0:1,maxSize:1,write:(e,t,n)=>{if(e==="legacy")return n;if(e<0||e>127)throw new _(rt,{actualVersion:e});if(e>Ys)throw new _(st,{unsupportedVersion:e});return t.set([e|qs],n),n+1}})}function Er(){return L(fr())}function Rr(){return O(L([...fr(),["addressTableLookups",Zs()]]),e=>e.version==="legacy"?e:{...e,addressTableLookups:e.addressTableLookups??[]})}function fr(){let e=pt([mt(new Uint8Array(32)),$(Hs(),32)],t=>t===void 0?0:1);return [["version",Xs()],["header",$s()],["staticAccounts",V(q(),{size:W()})],["lifetimeToken",e],["instructions",V(js(),{size:W()})]]}function Zs(){return V(Ks(),{size:W()})}function Dr(){return g({getSizeFromValue:e=>e.version==="legacy"?Er().getSizeFromValue(e):Rr().getSizeFromValue(e),write:(e,t,n)=>e.version==="legacy"?Er().write(e,t,n):Rr().write(e,t,n)})}function Tr(e,t,n){e[t]=n(e[t]??{role:b.READONLY});}var f=Symbol("AddressMapTypeProperty");function Js(e,t){let n={[e]:{[f]:0,role:b.WRITABLE_SIGNER}},r=new Set;for(let o of t){Tr(n,o.programAddress,a=>{if(r.add(o.programAddress),f in a){if(oe(a.role))switch(a[f]){case 0:throw new _(et,{programAddress:o.programAddress});default:throw new _(he,{programAddress:o.programAddress})}if(a[f]===2)return a}return {[f]:2,role:b.READONLY}});let i;if(o.accounts)for(let a of o.accounts)Tr(n,a.address,s=>{let{address:c,...u}=a;if(f in s)switch(s[f]){case 0:return s;case 1:{let d=Ct(s.role,u.role);if("lookupTableAddress"in u){if(s.lookupTableAddress!==u.lookupTableAddress&&(i||=Le())(u.lookupTableAddress,s.lookupTableAddress)<0)return {[f]:1,...u,role:d}}else if(X(u.role))return {[f]:2,role:d};return s.role!==d?{...s,role:d}:s}case 2:{let d=Ct(s.role,u.role);if(r.has(a.address)){if(oe(u.role))throw new _(he,{programAddress:a.address});return s.role!==d?{...s,role:d}:s}else return "lookupTableAddress"in u&&!X(s.role)?{...u,[f]:1,role:d}:s.role!==d?{...s,role:d}:s}}return "lookupTableAddress"in u?{...u,[f]:1}:{...u,[f]:2}});}return n}function Qs(e){let t;return Object.entries(e).sort(([r,o],[i,a])=>{if(o[f]!==a[f]){if(o[f]===0)return -1;if(a[f]===0)return 1;if(o[f]===2)return -1;if(a[f]===2)return 1}let s=X(o.role);if(s!==X(a.role))return s?-1:1;let c=oe(o.role);return c!==oe(a.role)?c?-1:1:(t||=Le(),o[f]===1&&a[f]===1&&o.lookupTableAddress!==a.lookupTableAddress?t(o.lookupTableAddress,a.lookupTableAddress):t(r,i))}).map(([r,o])=>({address:r,...o}))}function ec(e){let t={};for(let n of e){if(!("lookupTableAddress"in n))continue;let r=t[n.lookupTableAddress]||={readonlyIndexes:[],writableIndexes:[]};n.role===b.WRITABLE?r.writableIndexes.push(n.addressIndex):r.readonlyIndexes.push(n.addressIndex);}return Object.keys(t).sort(Le()).map(n=>({lookupTableAddress:n,...t[n]}))}function tc(e){let t=0,n=0,r=0;for(let o of e){if("lookupTableAddress"in o)break;let i=oe(o.role);X(o.role)?(r++,i||n++):i||t++;}return {numReadonlyNonSignerAccounts:t,numReadonlySignerAccounts:n,numSignerAccounts:r}}function nc(e){let t={};for(let[n,r]of e.entries())t[r.address]=n;return t}function rc(e,t){let n=nc(t);return e.map(({accounts:r,data:o,programAddress:i})=>({programAddressIndex:n[i],...r?{accountIndices:r.map(({address:a})=>n[a])}:null,...o?{data:o}:null}))}function oc(e){return "nonce"in e?e.nonce:e.blockhash}function ic(e){let t=e.findIndex(r=>"lookupTableAddress"in r);return (t===-1?e:e.slice(0,t)).map(({address:r})=>r)}function Sr(e){let t=Js(e.feePayer.address,e.instructions),n=Qs(t),r=e.lifetimeConstraint;return {...e.version!=="legacy"?{addressTableLookups:ec(n)}:null,...r?{lifetimeToken:oc(r)}:null,header:tc(n),instructions:rc(e.instructions,n),staticAccounts:ic(n),version:e.version}}function ac(e,t,n){for(let[r,o]of Object.entries(n))for(let i=0;i<o.length;i++)if(e===o[i])return {address:e,addressIndex:i,lookupTableAddress:r,role:t}}function bt(e,t){let n=new Set(e.instructions.map(a=>a.programAddress)),r=new Set(Object.values(t).flatMap(a=>a).filter(a=>!n.has(a))),o=[],i=false;for(let a of e.instructions){if(!a.accounts){o.push(a);continue}let s=[],c=false;for(let u of a.accounts){if("lookupTableAddress"in u||!r.has(u.address)||X(u.role)){s.push(u);continue}let d=ac(u.address,u.role,t);s.push(Object.freeze(d)),c=true,i=true;}o.push(Object.freeze(c?{...a,accounts:s}:a));}return Object.freeze(i?{...e,instructions:o}:e)}function Ut(e){return Object.freeze({instructions:Object.freeze([]),version:e.version})}var sc="SysvarRecentB1ockHashes11111111111111111111",cc="11111111111111111111111111111111";function uc(e){return e.programAddress===cc&&e.data!=null&&dc(e.data)&&e.accounts?.length===3&&e.accounts[0].address!=null&&e.accounts[0].role===b.WRITABLE&&e.accounts[1].address===sc&&e.accounts[1].role===b.READONLY&&e.accounts[2].address!=null&&X(e.accounts[2].role)}function dc(e){return e.byteLength===4&&e[0]===4&&e[1]===0&&e[2]===0&&e[3]===0}function Pt(e){return "lifetimeConstraint"in e&&typeof e.lifetimeConstraint.nonce=="string"&&e.instructions[0]!=null&&uc(e.instructions[0])}function vt(e,t){return Object.freeze({...t,instructions:Object.freeze([...t.instructions,...e])})}function Fe(e,t){return Object.freeze({...t,instructions:Object.freeze([...e,...t.instructions])})}function lc(e){let t=Object.values(e);if(t.length===0)throw new _(at);return t.map(n=>n||new Uint8Array(64).fill(0))}function Ic(){return O(V($(fe(),64),{size:W()}),lc)}function Bt(){return L([["signatures",Ic()],["messageBytes",fe()]])}function ie(e){let t=Sr(e),n=Dr().encode(t),r=t.staticAccounts.slice(0,t.header.numSignerAccounts),o={};for(let a of r)o[a]=null;let i;return gr(e)?i={blockhash:e.lifetimeConstraint.blockhash,lastValidBlockHeight:e.lifetimeConstraint.lastValidBlockHeight}:Pt(e)&&(i={nonce:e.lifetimeConstraint.nonce,nonceAccountAddress:e.instructions[0].accounts[0].address}),Object.freeze({...i?{lifetimeConstraint:i}:void 0,messageBytes:n,signatures:Object.freeze(o)})}var wt;function Ft(e){wt||(wt=Me());let t=Object.values(e.signatures)[0];if(!t)throw new _(it);return wt.decode(t)}function Nr(e){let t=[];if(Object.entries(e.signatures).forEach(([n,r])=>{r||t.push(n);}),t.length>0)throw new _(ot,{addresses:t})}function ae(e){let t=Bt().encode(e);return M().decode(t)}function zt(e){let t={};return e.forEach(n=>{if(!t[n.address])t[n.address]=n;else if(t[n.address]!==n)throw new _(Qe,{address:n.address})}),Object.values(t)}function ze(e){return "modifyAndSignTransactions"in e&&typeof e.modifyAndSignTransactions=="function"}function Se(e){return "signTransactions"in e&&typeof e.signTransactions=="function"}function mr(e){return "signAndSendTransactions"in e&&typeof e.signAndSendTransactions=="function"}function kt(e){return Se(e)||ze(e)||mr(e)}function Ec(e){return zt((e.accounts??[]).flatMap(t=>"signer"in t?t.signer:[]))}function Rc(e){return zt([...e.feePayer&&kt(e.feePayer)?[e.feePayer]:[],...e.instructions.flatMap(Ec)])}function xt(e,t){Object.freeze(e);let n={...t,feePayer:e};return Object.freeze(n),n}async function Tc(e,t){let{partialSigners:n,modifyingSigners:r}=gc(zt(Rc(e).filter(kt)),{identifySendingSigner:false});return await Sc(e,r,n,t)}async function Wt(e,t){let n=await Tc(e,t);return Nr(n),n}function gc(e,t={}){let r=t.identifySendingSigner??true?fc(e):null,o=e.filter(s=>s!==r&&(ze(s)||Se(s))),i=Dc(o),a=o.filter(Se).filter(s=>!i.includes(s));return Object.freeze({modifyingSigners:i,partialSigners:a,sendingSigner:r})}function fc(e){let t=e.filter(mr);if(t.length===0)return null;let n=t.filter(r=>!ze(r)&&!Se(r));return n.length>0?n[0]:t[0]}function Dc(e){let t=e.filter(ze);if(t.length===0)return [];let n=t.filter(r=>!Se(r));return n.length>0?n:[t[0]]}async function Sc(e,t=[],n=[],r){let o=ie(e),i=await t.reduce(async(s,c)=>{let[u]=await c.modifyAndSignTransactions([await s],r);return Object.freeze(u)},Promise.resolve(o));let a=await Promise.all(n.map(async s=>{let[c]=await s.signTransactions([i],r);return c}));return Object.freeze({...i,signatures:Object.freeze(a.reduce((s,c)=>({...s,...c}),i.signatures??{}))})}async function pr(e,t,n){if(e.length===0)return {};let r=await er(t,e,n);return Xn(r),Rt(r),r.reduce((o,i)=>({...o,[i.address]:i.data.addresses}),{})}var ke="ComputeBudget111111111111111111111111111111";var Gt=2;function Vt(){return O(L([["discriminator",v()],["units",Ee()]]),e=>({...e,discriminator:Gt}))}function se(e,t){let n=ke,r={...e};return Object.freeze({data:Vt().encode(r),programAddress:n})}var Ht=3;function Kt(){return O(L([["discriminator",v()],["microLamports",Te()]]),e=>({...e,discriminator:Ht}))}function Ne(e,t){let n=ke,r={...e};return Object.freeze({data:Kt().encode(r),programAddress:n})}var ce="https://auth.revibase.com",xe="revibase.com",me="https://api.revibase.com",We="2c1LgZfCun82niPCgfg2cTMZmAiahraTjY4KNb1BSU4Z",Cr="https://mainnet.block-engine.jito.wtf/api/v1/bundles",Or="https://bundles.jito.wtf/api/v1/bundles/tip_floor";var w=class e extends Error{code;constructor(t,n){super(t),this.name="RevibaseError",this.code=n,Object.setPrototypeOf(this,e.prototype);}},hr=class e extends w{constructor(t="Popup blocked. Please enable popups."){super(t,"POPUP_BLOCKED"),this.name="RevibasePopupBlockedError",Object.setPrototypeOf(this,e.prototype);}},Z=class e extends w{constructor(t="Popup was closed by the user"){super(t,"POPUP_CLOSED"),this.name="RevibasePopupClosedError",Object.setPrototypeOf(this,e.prototype);}},pe=class e extends w{constructor(t="Authentication timed out"){super(t,"TIMEOUT"),this.name="RevibaseTimeoutError",Object.setPrototypeOf(this,e.prototype);}},Ge=class e extends w{constructor(t="An authorization flow is already in progress"){super(t,"FLOW_IN_PROGRESS"),this.name="RevibaseFlowInProgressError",Object.setPrototypeOf(this,e.prototype);}},Ve=class e extends w{constructor(t="Aborted"){super(t,"ABORTED"),this.name="RevibaseAbortedError",Object.setPrototypeOf(this,e.prototype);}},yr=class e extends w{constructor(t="Popup is not open. Call startRequest first."){super(t,"POPUP_NOT_OPEN"),this.name="RevibasePopupNotOpenError",Object.setPrototypeOf(this,e.prototype);}},z=class e extends w{constructor(t){super(t,"AUTH_FAILED"),this.name="RevibaseAuthError",Object.setPrototypeOf(this,e.prototype);}},Ce=class e extends w{constructor(t){super(t,"API_FAILED"),this.name="RevibaseApiError",Object.setPrototypeOf(this,e.prototype);}},He=class e extends w{constructor(t="Provider can only be used in a browser environment"){super(t,"ENVIRONMENT"),this.name="RevibaseEnvironmentError",Object.setPrototypeOf(this,e.prototype);}};var Mr=180*1e3,$t=2e3,Lr=2e4,br=async e=>{let t=await fetch("/api/sendJitoBundle",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),n=await t.json();if(!t.ok)throw new Ce(n.error??"Send jito bundle failed");return n},Ur=async()=>{let e=await fetch("/api/estimateJitoTips"),t=await e.json();if(!e.ok)throw new Ce(t.error??"Estimate jito tips failed");return t},Pr=async e=>{let t=await fetch("/api/clientAuthorization",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),n=await t.json();if(!t.ok)throw new z(n.error??"Authorization failed");return n};function vr(e){if(typeof window>"u")throw new Error("Function can only be called in a browser environment");let t=window.innerWidth||window.screen.availWidth,n=window.innerHeight||window.screen.availHeight,r=t<=768,o,i,a,s;if(r)o=t,i=n,a=0,s=0;else {let u=window.screenLeft??window.screenX??0,d=window.screenTop??window.screenY??0,l=window.innerWidth??document.documentElement.clientWidth??window.screen.width,I=window.innerHeight??document.documentElement.clientHeight??window.screen.height;o=500,i=600,s=Math.round(u+(l-o)/2),a=Math.round(d+(I-i)/2);}let c=["popup=yes",`width=${o}`,`height=${i}`,`top=${a}`,`left=${s}`,"toolbar=no","location=no","status=no","menubar=no","scrollbars=yes","resizable=yes"].join(",");return window.open(e,"_blank",c)}var wr=class{onClientAuthorizationCallback;onSendJitoBundleCallback;onEstimateJitoTipsCallback;providerOrigin;popUp=null;constructor(t){let{rpcEndpoint:n,providerOrigin:r,onClientAuthorizationCallback:o,onSendJitoBundleCallback:i,onEstimateJitoTipsCallback:a}=t;initialize({rpcEndpoint:n}),this.onClientAuthorizationCallback=o??Pr,this.onSendJitoBundleCallback=i??br,this.onEstimateJitoTipsCallback=a??Ur,this.providerOrigin=r??ce;}async sendRequestToPopupProvider({onConnectedCallback:t,onSuccessCallback:n,signal:r}){if(typeof window>"u")throw new He;if(this.popUp)throw new Ge;let o=M().decode(crypto.getRandomValues(new Uint8Array(16))),i=window.location.origin,a=`${this.providerOrigin}?clientOrigin=${encodeURIComponent(i)}&rid=${encodeURIComponent(o)}`;if(this.popUp=vr(a),!this.popUp)throw new Error("Popup blocked. Please allow popups for this site.");return await new Promise(s=>setTimeout(s,0)),new Promise((s,c)=>{setTimeout(()=>{this.attachTransport({rid:o,clientOrigin:i,onConnectedCallback:t,onSuccessCallback:n,signal:r,resolve:s,reject:c});},0);})}attachTransport(t){let{rid:n,clientOrigin:r,onConnectedCallback:o,onSuccessCallback:i,signal:a,reject:s,resolve:c}=t,u=()=>{s(new Ve);};a?.addEventListener("abort",u,{once:true});let d=null,l=false,I=null,E=null,T=null,S=()=>{window.removeEventListener("message",h),a?.removeEventListener("abort",u),I&&(clearInterval(I),I=null),E&&(clearTimeout(E),E=null),T&&(clearTimeout(T),T=null);try{d?.close();}catch{}d=null;try{this.popUp&&!this.popUp.closed&&this.popUp.close();}catch{}this.popUp=null;},R=D=>{l||(l=true,S(),s(D));},p=D=>{l||(l=true,S(),i(D).then(C=>{c(C);}).catch(C=>{s(C);}));};E=setTimeout(()=>{R(new pe("Popup connection timed out after 20s"));},Lr);let h=D=>{if(l||d||D.origin!==this.providerOrigin)return;let C=D.data;if(!C||C.type!=="popup-connect"||C.rid!==n)return;E&&(clearTimeout(E),E=null);let B=new MessageChannel;d=B.port1,d.start();let J=Date.now();I=setInterval(()=>{if(l){I&&(clearInterval(I),I=null);return}if(this.popUp?.closed){R(new Z("Popup was closed"));return}if(!d){R(new Z("Message channel lost"));return}if(Date.now()-J>$t*2){R(new Z("Lost connection to popup (heartbeat timeout)"));return}try{d.postMessage({type:"ping"});}catch{R(new Z("Failed to send heartbeat"));}},$t),d.onmessage=U=>{if(l)return;let H=U.data;switch(H.type){case "pong":J=Date.now();break;case "popup-complete":H.payload?p(H.payload):R(new z("Invalid completion payload"));break;case "popup-error":R(new z(H.error||"Unknown popup error"));break;case "popup-closed":R(new Z("User closed popup"));break;default:console.warn("Unknown message type from popup:",H);}},d.onmessageerror=()=>{R(new z("Message deserialization error"));};try{this.popUp?.postMessage({type:"popup-init",rid:n},this.providerOrigin,[B.port2]);}catch(U){R(new z(`Failed to initialize popup: ${U}`));return}o(n,r).then(U=>{if(l||!d||this.popUp?.closed)return;try{d.postMessage({type:"popup-start",payload:U});}catch(ao){R(new z(`Failed to send request to popup: ${ao}`));return}T&&(clearTimeout(T),T=null);let H=Math.max(0,U.request.validTill-Date.now());T=setTimeout(()=>{R(new pe("Request expired"));},H);}).catch(U=>{R(U);});};window.addEventListener("message",h);}};function Br(e){let t=e.domain?`${e.domain} wants you to sign in with your account.`:"Sign in with your account.",n=[];return e.nonce&&n.push(`Nonce: ${e.nonce}`),n.length>0?`${t}
6
6
 
7
7
  ${n.join(`
8
- `)}`:t}async function ne(e,t,n){e.startRequest();let r=t(window.origin),{signature:i,rid:o,validTill:a}=await e.onClientAuthorizationCallback(r);return await e.sendPayloadToProviderViaPopup({request:{...r,rid:o,validTill:a},signal:n,signature:i})}async function jl(e,t){let{signal:n}=t??{},r=await ne(e,i=>({phase:"start",data:{type:"message",payload:Pr({domain:i,nonce:O().decode(crypto.getRandomValues(new Uint8Array(16)))})},clientOrigin:i}),n);return await e.onClientAuthorizationCallback(r)}var re="11111111111111111111111111111111";var vr=0,wr=1,Br=2,Fr=3,zr=4,kr=5,xr=6,Wr=7,Gr=8;process.env.NODE_ENV!=="production"&&({[vr]:"an account with the same address already exists",[kr]:"provided address does not match addressed derived from seed",[Fr]:"cannot allocate account data of this length",[Br]:"cannot assign account to this program id",[zr]:"length of requested seed is too long",[Wr]:"stored nonce is still in recent_blockhashes",[xr]:"advancing stored nonce requires a populated RecentBlockhashes sysvar",[Gr]:"specified nonce does not match stored nonce",[wr]:"account does not have enough SOL to perform the operation"});var Ht="TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";function Vr(){return Ee([["discriminator",le()],["deactivationSlot",j()],["lastExtendedSlot",j()],["lastExtendedSlotStartIndex",B()],["authority",cr(v(),{noneValue:"zeroes"})],["padding",nr()],["addresses",be(v(),{size:"remainder"})]])}function Hr(e){return jn(e,Vr())}async function Kt(e,t,n){let r=await Zn(e,t,n);return Hr(r)}async function Ve({instructions:e,payer:t,addressesByLookupTableAddress:n}){let r=await getSolanaRpc().getLatestBlockhash().send(),i=await ve(Lt({version:0}),o=>Ut(e,o),o=>zt(t,o),o=>yt(r.value,o),o=>n?Mt(o,n):o,async o=>{let[a,s]=await Promise.all([cu(o),uu(getSolanaRpc(),o.instructions.flatMap(u=>u.accounts??[]))]),c=Math.ceil((Number(a)??0)*1.1);return we([...c>2e5?[Q({units:c})]:[],...s>0?[Te({microLamports:s})]:[]],o)},async o=>await kt(await o));return await getSolanaRpc().sendTransaction(J(i),{skipPreflight:true,encoding:"base64"}).send(),wt(i)}async function $r(e,t){let n=await Kr(t,true),r=await su(n.map(J),getSolanaRpcEndpoint()),i=await Kr(t.map((o,a)=>({...o,unitsConsumed:r[a]})));return await e.onSendJitoBundleCallback(i.map(J)),wt(i[i.length-1])}async function su(e,t){let r=await(await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({jsonrpc:"2.0",id:"2",method:"simulateBundle",params:[{encodedTransactions:e},{skipSigVerify:true,replaceRecentBlockhash:true,preExecutionAccountsConfigs:e.map(()=>({encoding:"base64",addresses:[]})),postExecutionAccountsConfigs:e.map(()=>({encoding:"base64",addresses:[]}))}]})})).json();if(!r.result||r.error)throw new Error(`Unable to simulate bundle: ${JSON.stringify(r.error??r.result)}`);if(typeof r.result.value.summary!="string"&&r.result.value.summary.failed){let{TransactionFailure:i}=r.result.value.summary.failed.error,[,o]=i;throw new Error(`Simulation failed: ${o}`)}return r.result.value.transactionResults.map(i=>i.unitsConsumed)}async function Kr(e,t=false){let n=t?{blockhash:dr().decode(crypto.getRandomValues(new Uint8Array(32))),lastValidBlockHeight:BigInt(Number.MAX_SAFE_INTEGER)}:(await getSolanaRpc().getLatestBlockhash().send()).value;return await Promise.all(e.map(async r=>await ve(Lt({version:0}),o=>Ut(r.instructions,o),o=>zt(r.payer,o),o=>yt(n,o),o=>r.addressesByLookupTableAddress?Mt(o,r.addressesByLookupTableAddress):o,async o=>{let a=Math.ceil((r.unitsConsumed??0)*1.1);return a>2e5?we([Q({units:a})],o):o},async o=>t?Z(await o):await kt(await o))))}async function cu(e){let t=we([Q({units:8e5}),Te({microLamports:1e4})],e),n=Z(t),r=await getSolanaRpc().simulateTransaction(J(n),{encoding:"base64"}).send();if(r.value.err){if(r.value.logs){let o=["Transaction simulation failed:","",...r.value.logs].join(`
9
- `);throw new Error(o)}let i=["Transaction simulation failed:","",r.value.err.toString()].join(`
10
- `);throw new Error(i)}return r.value.unitsConsumed}async function uu(e,t){let r=(await e.getRecentPrioritizationFees(t.filter(o=>o.role===y.WRITABLE||o.role===y.WRITABLE_SIGNER).map(o=>o.address)).send()).map(o=>Number(o.prioritizationFee));r.sort((o,a)=>o-a);let i=Math.floor(r.length/2);return r.length%2===0?Math.round((r[i-1]+r[i])/2):r[i]}var Yr=new Map;async function oe(){let e=Yr.get(ge);if(e)return e;let t=await fetch(`${ge}/getRandomPayer`,{signal:AbortSignal.timeout(5e3)});if(!t.ok)throw new Error(`Failed to get random payer: ${t.statusText}`);let{randomPayer:n}=await t.json(),r=Iu(f(n),`${ge}/sign`);return Yr.set(ge,r),r}function Iu(e,t){return {address:e,async signTransactions(r){let i={publicKey:e,transactions:r.map(s=>O().decode(vt().encode(s)))},o=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i),signal:AbortSignal.timeout(1e4)});if(!o.ok)throw new Error(`Failed to sign transactions: ${o.statusText}`);let a=await o.json();if("error"in a)throw new Error(a.error);return a.signatures.map(s=>({[e]:ue().encode(s)}))}}}async function ie(e){let{transactionManagerAddress:t,transactionMessageBytes:n,userAddressTreeIndex:r,authResponses:i,onPendingApprovalsCallback:o,onPendingApprovalsSuccess:a,abortController:s,abortSignal:c,cachedAccounts:u}=e,d=s;if(c&&!d){let E=new AbortController;c.aborted?E.abort():c.addEventListener("abort",()=>E.abort(),{once:true}),d=E;}let l;if(t){let E=(await fetchUserAccountData(t,r,u)).transactionManagerUrl;l=E.__option==="Some"?E.value:null;}return t&&l?createTransactionManagerSigner({address:t,url:l,authResponses:i,transactionMessageBytes:n,onPendingApprovalsCallback:o,onPendingApprovalsSuccess:a,abortController:d}):null}async function ae(e){if(!e)return await Nr([f(ke)],getSolanaRpc());if(ke in e)return e;let t=await Kt(getSolanaRpc(),f(ke));return t.exists?{...e,[t.address]:t.data.addresses}:e}async function qr(e,t){let{authResponse:n,settings:r,additionalSigners:i,options:o,payer:a,settingsAddressTreeIndex:s}=t,{startRequest:c,signer:u}=n;if(c.data.type!=="transaction")throw new Error("Invalid request type.");let{transactionActionType:d,transactionMessageBytes:l}=c.data.payload;if(d!=="execute"&&d!=="create_with_preauthorized_execution")throw new Error("Transaction action type must be 'execute' or 'create_with_preauthorized_execution'");let _=new Map,[E,N,D]=await Promise.all([a??oe(),fetchSettingsAccountData(r,s,_),getSignedSecp256r1Key(n)]),A=retrieveTransactionManager(u,N),[S,p]=await Promise.all([ie({authResponses:[n],transactionManagerAddress:A?.transactionManagerAddress,userAddressTreeIndex:A?.userAddressTreeIndex,transactionMessageBytes:M().encode(l),onPendingApprovalsCallback:o?.pendingApprovalsCallback?.onPendingApprovalsCallback,onPendingApprovalsSuccess:o?.pendingApprovalsCallback?.onPendingApprovalsSuccess,abortSignal:o?.signal,cachedAccounts:_}),e.onEstimateJitoTipsCallback()]),H=await prepareTransactionBundle({compressed:N.isCompressed,settings:r,settingsAddressTreeIndex:s,transactionMessageBytes:M().encode(l),creator:S??D,executor:S?D:void 0,jitoBundlesTipAmount:p,additionalSigners:i,payer:E,cachedAccounts:_}),pe=await Promise.all(H.map(async se=>({...se,addressesByLookupTableAddress:await ae(se.addressesByLookupTableAddress)})));return $r(e,pe)}async function Xr(e){let{authResponse:t,settings:n,payer:r,additionalSigners:i,settingsAddressTreeIndex:o,options:a}=e,{startRequest:s,signer:c}=t;if(s.data.type!=="transaction")throw new Error("Invalid request type.");let{transactionActionType:u,transactionMessageBytes:d}=s.data.payload;if(u!=="sync")throw new Error("Transaction action type must be 'sync'");let l=new Map,[_,E,N]=await Promise.all([r??oe(),fetchSettingsAccountData(n,o,l),getSignedSecp256r1Key(t)]),D=retrieveTransactionManager(c,E),A=await ie({authResponses:[t],transactionManagerAddress:D?.transactionManagerAddress,userAddressTreeIndex:D?.userAddressTreeIndex,transactionMessageBytes:M().encode(d),onPendingApprovalsCallback:a?.pendingApprovalsCallback?.onPendingApprovalsCallback,onPendingApprovalsSuccess:a?.pendingApprovalsCallback?.onPendingApprovalsSuccess,abortSignal:a?.signal,cachedAccounts:l}),S=A?[N,A]:[N],{instructions:p,addressesByLookupTableAddress:H}=await prepareTransactionSync({compressed:E.isCompressed,signers:S,payer:_,transactionMessageBytes:M().encode(d),settings:n,settingsAddressTreeIndex:o,cachedAccounts:l,additionalSigners:i});return Ve({instructions:p,payer:_,addressesByLookupTableAddress:await ae(H)})}async function Zr(e){let{authResponse:t,settings:n,settingsAddressTreeIndex:r,options:i,payer:o,addressesByLookupTableAddress:a}=e,{startRequest:s,signer:c}=t;if(s.data.type!=="transaction")throw new Error("Invalid request type.");let{transactionActionType:u,transactionAddress:d,transactionMessageBytes:l}=s.data.payload;if(u!=="transfer_intent")throw new Error("Transaction action type must be 'transfer_intent'");let _=M().encode(l),E=j().decode(_.slice(0,8)),N=v().decode(_.slice(8,40)),D=v().decode(_.slice(40,72)),A=new Map,[S,p,H]=await Promise.all([o??oe(),fetchSettingsAccountData(n,r,A),getSignedSecp256r1Key(t)]),pe=retrieveTransactionManager(c,p),se=await ie({authResponses:[t],transactionManagerAddress:pe?.transactionManagerAddress,userAddressTreeIndex:pe?.userAddressTreeIndex,transactionMessageBytes:M().encode(l),onPendingApprovalsCallback:i?.pendingApprovalsCallback?.onPendingApprovalsCallback,onPendingApprovalsSuccess:i?.pendingApprovalsCallback?.onPendingApprovalsSuccess,abortSignal:i?.signal,cachedAccounts:A}),$t=se?[H,se]:[H],ro=D!==re?await tokenTransferIntent({payer:S,settings:n,settingsAddressTreeIndex:r,amount:E,signers:$t,destination:N,mint:D,tokenProgram:f(d),compressed:p.isCompressed,cachedAccounts:A}):await nativeTransferIntent({payer:o,settings:n,settingsAddressTreeIndex:r,amount:E,signers:$t,destination:N,compressed:p.isCompressed,cachedAccounts:A});return Ve({instructions:ro,payer:S,addressesByLookupTableAddress:await ae(a)})}async function Jr(e,t=30,n=2e3){for(let r=0;r<t;r++){let o=(await getSolanaRpc().getSignatureStatuses([e]).send()).value[0];if(o?.confirmationStatus==="confirmed"||o?.confirmationStatus==="finalized")return e;await new Promise(a=>setTimeout(a,n));}throw new Error("Transaction confirmation timeout")}async function He(e,t){let{request:n,additionalSigners:r,options:i,payer:o,addressesByLookupTableAddress:a}=t,{confirmTransaction:s=true}=i??{};if(n.data.payload.startRequest.data.type==="message")throw new Error("Invalid request type.");let c=UserInfoSchema.parse(n.data.payload.additionalInfo),u=n.data.type==="transaction"&&n.data.payload.startRequest.data.payload.transactionActionType!=="transfer_intent"?n.data.payload.startRequest.data.payload.transactionAddress:c.settingsIndexWithAddress?.index?await getSettingsFromIndex(c.settingsIndexWithAddress.index):null;if(!u)throw Error("User is not delegated to any wallet");let d;switch(n.data.payload.startRequest.data.payload.transactionActionType){case "transfer_intent":d=await Zr({authResponse:n.data.payload,settings:f(u),options:i,payer:o,addressesByLookupTableAddress:a});break;case "execute":case "create_with_preauthorized_execution":d=await qr(e,{authResponse:n.data.payload,settings:f(u),additionalSigners:r,options:i,payer:o});break;case "sync":d=await Xr({authResponse:n.data.payload,settings:f(u),additionalSigners:r,options:i,payer:o});break;default:throw Error("Invalid Transaction Action Type for send tx payload.")}return s&&await Jr(d),{txSig:d,user:c}}async function EU(e,t,n){let{instructions:r,signer:i,addressesByLookupTableAddress:o,settingsIndexWithAddress:a,additionalSigners:s,payer:c}=t,{signal:u}=n??{},d=prepareTransactionMessage({payer:f(i.walletAddress),instructions:r,addressesByLookupTableAddress:o}),l=a??i.settingsIndexWithAddress,_=await getSettingsFromIndex(l.index),N=(await fetchSettingsAccountData(_,l.settingsAddressTreeIndex)).members.some(S=>S.role===UserRole.TransactionManager),D=await ne(e,S=>({phase:"start",data:{type:"transaction",payload:{transactionMessageBytes:O().decode(d),transactionAddress:_,transactionActionType:N?"execute":"create_with_preauthorized_execution"}},clientOrigin:S,signer:i.publicKey}),u),A=await e.onClientAuthorizationCallback(D);return await He(e,{request:A,options:n,additionalSigners:s,addressesByLookupTableAddress:o,payer:c})}async function SU(e,t,n){if(t.amount<=0)throw new Error("Transfer amount must be greater than 0");if(!t.destination||typeof t.destination!="string")throw new Error("Destination address is required");let{mint:r,tokenProgram:i=Ht,amount:o,destination:a,signer:s,payer:c,addressesByLookupTableAddress:u}=t,{signal:d}=n??{},l=await ne(e,E=>({phase:"start",data:{type:"transaction",payload:{transactionActionType:"transfer_intent",transactionAddress:r?i:re,transactionMessageBytes:O().decode(new Uint8Array([...Ie().encode(o),...G().encode(f(a)),...G().encode(f(r??re))]))}},clientOrigin:E,signer:s?.publicKey}),d),_=await e.onClientAuthorizationCallback(l);return await He(e,{request:_,options:n,addressesByLookupTableAddress:u,payer:c})}async function Qr(e,t,n){if(!t.includes(e.clientOrigin))throw new Error("Invalid client origin");let r=O().decode(crypto.getRandomValues(new Uint8Array(16))),i=Date.now()+Or,o=convertBase64StringToJWK(n);if(!o.alg)throw new Error("Property alg in JWK is missing.");return {signature:await new CompactSign(createClientAuthorizationStartRequestChallenge({...e,rid:r,validTill:i})).setProtectedHeader({alg:o.alg}).sign(o),validTill:i,rid:r}}function Ke(e,t){if(e.length!==t.length)return false;let n=0;for(let r=0;r<e.length;r++)n|=e[r]^t[r];return n===0}async function eo(e,t,n,r=ee,i=ze){let{payload:o}=e.data;if(o.startRequest.data.type!=="message")throw new Error("Invalid request type.");if(Date.now()>o.startRequest.validTill)throw new Error("Request expired.");if(!n.includes(o.startRequest.clientOrigin)||!n.includes(o.client.clientOrigin)||o.startRequest.clientOrigin!==o.client.clientOrigin)throw new Error("Invalid client origin");let a=await importJWK(convertBase64StringToJWK(t)),s=await compactVerify(e.data.payload.client.jws,a);if(!Ke(s.payload,createClientAuthorizationStartRequestChallenge(e.data.payload.startRequest)))throw new Error("Invalid client signature");let c=createMessageChallenge(o.startRequest.data.payload,o.startRequest.clientOrigin,o.device.jwk,o.startRequest.rid),{verified:u}=await verifyAuthenticationResponse({response:o.authResponse,expectedChallenge:bufferToBase64URLString(c),expectedRPID:i,expectedOrigin:r,requireUserVerification:false,credential:{counter:0,id:o.authResponse.id,publicKey:convertPubkeyCompressedToCose(o.signer)}});if(!u)throw new Error("Invalid client siganture");return {user:UserInfoSchema.parse(e.data.payload.additionalInfo)}}async function no(e,t,n,r,i=ee,o=ze){let{payload:a}=e.data;if(a.startRequest.data.type!=="transaction")throw new Error("Invalid request type.");if(Date.now()>Math.min(a.startRequest.validTill,a.estimatedSlotHashExpiry))throw new Error("Request expired.");if(!n.includes(a.startRequest.clientOrigin)||!n.includes(a.client.clientOrigin)||a.startRequest.clientOrigin!==a.client.clientOrigin)throw new Error("Invalid client origin");let s=await importJWK(convertBase64StringToJWK(t)),c=await compactVerify(e.data.payload.client.jws,s);if(!Ke(c.payload,createClientAuthorizationStartRequestChallenge(e.data.payload.startRequest)))throw new Error("Invalid client signature");let{challenge:u}=await createTransactionChallenge(a.startRequest.data.payload,a.startRequest.clientOrigin,a.device.jwk,a.startRequest.rid,a.slotHash,a.slotNumber,a.estimatedSlotHashExpiry),{verified:d}=await verifyAuthenticationResponse({response:a.authResponse,expectedChallenge:bufferToBase64URLString(u),expectedRPID:o,expectedOrigin:i,requireUserVerification:false,credential:{counter:0,id:a.authResponse.id,publicKey:convertPubkeyCompressedToCose(a.signer)}});if(!d)throw new Error("Invalid client siganture");let l=convertBase64StringToJWK(r);if(!l.alg)throw new Error("Property alg in JWK is missing.");let _=await new CompactSign(createClientAuthorizationCompleteRequestChallenge(e)).setProtectedHeader({alg:l.alg}).sign(l);return {...e,data:{...e.data,payload:{...e.data.payload,client:{...e.data.payload.client,jws:_}}}}}async function XU({request:e,publicKey:t,allowedClientOrigins:n,privateKey:r,providerOrigin:i,rpId:o}){if(e.phase==="start")return await Qr(e,n,r);if(e.phase==="complete"){if(e.data.type==="message")return await eo(e,t,n,i,o);if(e.data.type==="transaction")return await no(e,t,n,r,i,o);throw new Error("Invalid request type")}else throw new Error("Invalid request phase")}async function QU(e="landed_tips_75th_percentile",t=pr){let n=await fetch(t);if(!n.ok)throw new Error(`Failed to fetch Jito tips: ${n.status} ${n.statusText}`);let r=await n.json();if(!Array.isArray(r)||!r[0]||typeof r[0][e]!="number")throw new Error("Invalid Jito tips response format");return Math.round(r[0][e]*1e9)}async function nP(e,t,n=mr){let o=JSON.stringify({jsonrpc:"2.0",id:1,method:"sendBundle",params:[e,{encoding:"base64"}]}),a=null;for(let c=0;c<=5&&(a=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json",...t?{"x-jito-auth":t}:{}},body:o}),!(a.status!==429||c===5));c++){let u=Math.min(1e4,250*2**c);await ed(u);}if(!a)throw new Error("Failed to send bundles: no response");let s=await a.json();if(s.error)throw new Error(`Error sending bundles: ${JSON.stringify(s.error,null,2)}`);if(!s.result)throw new Error("No bundle ID returned from Jito");return s.result}var ed=e=>new Promise(t=>setTimeout(t,e));/*! Bundled license information:
8
+ `)}`:t}function cu(e){let t=e?.message||"";return t==="Failed to fetch"||t.includes("Load failed")||t.includes("NetworkError")||t.includes("ERR_NETWORK")}async function A(e,t=3,n=500,r=5e3){let o=null;for(let i=0;i<t;i++)try{return await e()}catch(a){if(o=a instanceof Error?a:new Error(String(a)),!cu(o))throw o;if(i===t-1)break;let s=Math.min(n*Math.pow(2,i),r);await new Promise(c=>setTimeout(c,s));}throw o}async function Jl(e,t){let n=async(o,i)=>{let a={phase:"start",rid:o,data:{type:"message",payload:Br({domain:i,nonce:M().decode(crypto.getRandomValues(new Uint8Array(16)))})},clientOrigin:i},{signature:s,validTill:c}=await A(()=>e.onClientAuthorizationCallback(a));return {request:{...a,rid:o,validTill:c},signature:s}},r=async o=>e.onClientAuthorizationCallback(o);return e.sendRequestToPopupProvider({onConnectedCallback:n,onSuccessCallback:r,signal:t?.signal})}var ue="11111111111111111111111111111111";var Fr=0,zr=1,kr=2,xr=3,Wr=4,Gr=5,Vr=6,Hr=7,Kr=8;process.env.NODE_ENV!=="production"&&({[Fr]:"an account with the same address already exists",[Gr]:"provided address does not match addressed derived from seed",[xr]:"cannot allocate account data of this length",[kr]:"cannot assign account to this program id",[Wr]:"length of requested seed is too long",[Hr]:"stored nonce is still in recent_blockhashes",[Vr]:"advancing stored nonce requires a populated RecentBlockhashes sysvar",[Kr]:"specified nonce does not match stored nonce",[zr]:"account does not have enough SOL to perform the operation"});var jt="TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";function $r(){return De([["discriminator",Re()],["deactivationSlot",te()],["lastExtendedSlot",te()],["lastExtendedSlotStartIndex",G()],["authority",dr(x(),{noneValue:"zeroes"})],["padding",or()],["addresses",Pe(x(),{size:"remainder"})]])}function jr(e){return qn(e,$r())}async function Yt(e,t,n){let r=await Qn(e,t,n);return jr(r)}async function Ke({instructions:e,payer:t,addressesByLookupTableAddress:n}){let r=await A(()=>getSolanaRpc().getLatestBlockhash().send()),o=await Be(Ut({version:0}),i=>vt(e,i),i=>xt(t,i),i=>Lt(r.value,i),i=>n?bt(i,n):i,async i=>{let[a,s]=await Promise.all([Iu(i),_u(getSolanaRpc(),i.instructions.flatMap(u=>u.accounts??[]))]),c=Math.ceil((Number(a)??0)*1.1);return Fe([...c>2e5?[se({units:c})]:[],...s>0?[Ne({microLamports:s})]:[]],i)},async i=>await A(async()=>Wt(await i)));return await A(()=>getSolanaRpc().sendTransaction(ae(o),{skipPreflight:!0,encoding:"base64"}).send()),Ft(o)}async function qr(e,t){let n=await Yr(t,true),r=await lu(n.map(ae),getSolanaRpcEndpoint()),o=await Yr(t.map((i,a)=>({...i,unitsConsumed:r[a]})));return await A(()=>e.onSendJitoBundleCallback(o.map(ae))),Ft(o[o.length-1])}async function lu(e,t){let r=await(await A(()=>fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({jsonrpc:"2.0",id:"2",method:"simulateBundle",params:[{encodedTransactions:e},{skipSigVerify:!0,replaceRecentBlockhash:!0,preExecutionAccountsConfigs:e.map(()=>({encoding:"base64",addresses:[]})),postExecutionAccountsConfigs:e.map(()=>({encoding:"base64",addresses:[]}))}]})}))).json();if(!r.result||r.error)throw new Error(`Unable to simulate bundle: ${JSON.stringify(r.error??r.result)}`);if(typeof r.result.value.summary!="string"&&r.result.value.summary.failed){let{TransactionFailure:o}=r.result.value.summary.failed.error,[,i]=o;throw new Error(`Simulation failed: ${i}`)}return r.result.value.transactionResults.map(o=>o.unitsConsumed)}async function Yr(e,t=false){let n=t?{blockhash:Ir().decode(crypto.getRandomValues(new Uint8Array(32))),lastValidBlockHeight:BigInt(Number.MAX_SAFE_INTEGER)}:(await A(()=>getSolanaRpc().getLatestBlockhash().send())).value;return await Promise.all(e.map(async r=>await Be(Ut({version:0}),i=>vt(r.instructions,i),i=>xt(r.payer,i),i=>Lt(n,i),i=>r.addressesByLookupTableAddress?bt(i,r.addressesByLookupTableAddress):i,i=>{let a=Math.ceil((r.unitsConsumed??0)*1.1);return a>2e5?Fe([se({units:a})],i):i},async i=>t?ie(i):await A(()=>Wt(i)))))}async function Iu(e){let t=Fe([se({units:8e5}),Ne({microLamports:1e4})],e),n=ie(t),r=await A(()=>getSolanaRpc().simulateTransaction(ae(n),{encoding:"base64"}).send());if(r.value.err){if(r.value.logs){let i=["Transaction simulation failed:","",...r.value.logs].join(`
9
+ `);throw new Error(i)}let o=["Transaction simulation failed:","",r.value.err.toString()].join(`
10
+ `);throw new Error(o)}return r.value.unitsConsumed}async function _u(e,t){let r=(await A(()=>e.getRecentPrioritizationFees(t.filter(i=>i.role===b.WRITABLE||i.role===b.WRITABLE_SIGNER).map(i=>i.address)).send())).map(i=>Number(i.prioritizationFee));r.sort((i,a)=>i-a);let o=Math.floor(r.length/2);return r.length%2===0?Math.round((r[o-1]+r[o])/2):r[o]}var Zr=new Map;async function de(){let e=Zr.get(me);if(e)return e;let t=await A(()=>fetch(`${me}/getRandomPayer`));if(!t.ok)throw new Error(`Failed to get random payer: ${t.statusText}`);let{randomPayer:n}=await t.json(),r=Ru(m(n),`${me}/sign`);return Zr.set(me,r),r}function Ru(e,t){return {address:e,async signTransactions(r){let o={publicKey:e,transactions:r.map(s=>M().decode(Bt().encode(s)))},i=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)});if(!i.ok)throw new Error(`Failed to sign transactions: ${i.statusText}`);let a=await i.json();if("error"in a)throw new Error(a.error);return a.signatures.map(s=>({[e]:Ae().encode(s)}))}}}async function le(e){let{transactionManagerAddress:t,transactionMessageBytes:n,userAddressTreeIndex:r,authResponses:o,onPendingApprovalsCallback:i,onPendingApprovalsSuccess:a,abortController:s,abortSignal:c,cachedAccounts:u}=e,d=s;if(c&&!d){let E=new AbortController;c.aborted?E.abort():c.addEventListener("abort",()=>E.abort(),{once:true}),d=E;}let l;if(t){let E=(await A(()=>fetchUserAccountData(t,r,u))).transactionManagerUrl;l=E.__option==="Some"?E.value:null;}return t&&l?createTransactionManagerSigner({address:t,url:l,authResponses:o,transactionMessageBytes:n,onPendingApprovalsCallback:i,onPendingApprovalsSuccess:a,abortController:d}):null}async function Ie(e){if(!e)return await A(()=>pr([m(We)],getSolanaRpc()));if(We in e)return e;let t=await A(()=>Yt(getSolanaRpc(),m(We)));return t.exists?{...e,[t.address]:t.data.addresses}:e}async function Jr(e,t){let{authResponse:n,settings:r,additionalSigners:o,options:i,payer:a,settingsAddressTreeIndex:s}=t,{startRequest:c,signer:u}=n;if(c.data.type!=="transaction")throw new Error("Invalid request type.");let{transactionActionType:d,transactionMessageBytes:l}=c.data.payload;if(d!=="execute"&&d!=="create_with_preauthorized_execution")throw new Error("Transaction action type must be 'execute' or 'create_with_preauthorized_execution'");let I=new Map,[E,T,S]=await Promise.all([a??de(),A(()=>fetchSettingsAccountData(r,s,I)),getSignedSecp256r1Key(n)]),R=retrieveTransactionManager(u,T),[p,h]=await Promise.all([le({authResponses:[n],transactionManagerAddress:R?.transactionManagerAddress,userAddressTreeIndex:R?.userAddressTreeIndex,transactionMessageBytes:P().encode(l),onPendingApprovalsCallback:i?.pendingApprovalsCallback?.onPendingApprovalsCallback,onPendingApprovalsSuccess:i?.pendingApprovalsCallback?.onPendingApprovalsSuccess,abortSignal:i?.signal,cachedAccounts:I}),A(()=>e.onEstimateJitoTipsCallback())]),D=await prepareTransactionBundle({compressed:T.isCompressed,settings:r,settingsAddressTreeIndex:s,transactionMessageBytes:P().encode(l),creator:p??S,executor:p?S:void 0,jitoBundlesTipAmount:h,additionalSigners:o,payer:E,cachedAccounts:I}),C=await Promise.all(D.map(async B=>({...B,addressesByLookupTableAddress:await Ie(B.addressesByLookupTableAddress)})));return qr(e,C)}async function Qr(e){let{authResponse:t,settings:n,payer:r,additionalSigners:o,settingsAddressTreeIndex:i,options:a}=e,{startRequest:s,signer:c}=t;if(s.data.type!=="transaction")throw new Error("Invalid request type.");let{transactionActionType:u,transactionMessageBytes:d}=s.data.payload;if(u!=="sync")throw new Error("Transaction action type must be 'sync'");let l=new Map,[I,E,T]=await Promise.all([r??de(),A(()=>fetchSettingsAccountData(n,i,l)),getSignedSecp256r1Key(t)]),S=retrieveTransactionManager(c,E),R=await le({authResponses:[t],transactionManagerAddress:S?.transactionManagerAddress,userAddressTreeIndex:S?.userAddressTreeIndex,transactionMessageBytes:P().encode(d),onPendingApprovalsCallback:a?.pendingApprovalsCallback?.onPendingApprovalsCallback,onPendingApprovalsSuccess:a?.pendingApprovalsCallback?.onPendingApprovalsSuccess,abortSignal:a?.signal,cachedAccounts:l}),p=R?[T,R]:[T],{instructions:h,addressesByLookupTableAddress:D}=await prepareTransactionSync({compressed:E.isCompressed,signers:p,payer:I,transactionMessageBytes:P().encode(d),settings:n,settingsAddressTreeIndex:i,cachedAccounts:l,additionalSigners:o});return Ke({instructions:h,payer:I,addressesByLookupTableAddress:await Ie(D)})}async function eo(e){let{authResponse:t,settings:n,settingsAddressTreeIndex:r,options:o,payer:i,addressesByLookupTableAddress:a}=e,{startRequest:s,signer:c}=t;if(s.data.type!=="transaction")throw new Error("Invalid request type.");let{transactionActionType:u,transactionAddress:d,transactionMessageBytes:l}=s.data.payload;if(u!=="transfer_intent")throw new Error("Transaction action type must be 'transfer_intent'");let I=P().encode(l),E=te().decode(I.slice(0,8)),T=x().decode(I.slice(8,40)),S=x().decode(I.slice(40,72)),R=new Map,[p,h,D]=await Promise.all([i??de(),A(()=>fetchSettingsAccountData(n,r,R)),getSignedSecp256r1Key(t)]),C=retrieveTransactionManager(c,h),B=await le({authResponses:[t],transactionManagerAddress:C?.transactionManagerAddress,userAddressTreeIndex:C?.userAddressTreeIndex,transactionMessageBytes:P().encode(l),onPendingApprovalsCallback:o?.pendingApprovalsCallback?.onPendingApprovalsCallback,onPendingApprovalsSuccess:o?.pendingApprovalsCallback?.onPendingApprovalsSuccess,abortSignal:o?.signal,cachedAccounts:R}),J=B?[D,B]:[D],U=S!==ue?await tokenTransferIntent({payer:p,settings:n,settingsAddressTreeIndex:r,amount:E,signers:J,destination:T,mint:S,tokenProgram:m(d),compressed:h.isCompressed,cachedAccounts:R}):await nativeTransferIntent({payer:p,settings:n,settingsAddressTreeIndex:r,amount:E,signers:J,destination:T,compressed:h.isCompressed,cachedAccounts:R});return Ke({instructions:U,payer:p,addressesByLookupTableAddress:await Ie(a)})}async function to(e,t=30,n=2e3){for(let r=0;r<t;r++){let i=(await A(()=>getSolanaRpc().getSignatureStatuses([e]).send())).value[0];if(i?.confirmationStatus==="confirmed"||i?.confirmationStatus==="finalized")return e;await new Promise(a=>setTimeout(a,n));}throw new Error("Transaction confirmation timeout")}async function $e(e,t){let{request:n,additionalSigners:r,options:o,payer:i,addressesByLookupTableAddress:a}=t,{confirmTransaction:s=true}=o??{};if(n.data.payload.startRequest.data.type==="message")throw new Error("Invalid request type.");let c=UserInfoSchema.parse(n.data.payload.additionalInfo),u=n.data.type==="transaction"&&n.data.payload.startRequest.data.payload.transactionActionType!=="transfer_intent"?n.data.payload.startRequest.data.payload.transactionAddress:c.settingsIndexWithAddress?.index?await getSettingsFromIndex(c.settingsIndexWithAddress.index):null;if(!u)throw Error("User is not delegated to any wallet");let d;switch(n.data.payload.startRequest.data.payload.transactionActionType){case "transfer_intent":d=await eo({authResponse:n.data.payload,settings:m(u),options:o,payer:i,addressesByLookupTableAddress:a});break;case "execute":case "create_with_preauthorized_execution":d=await Jr(e,{authResponse:n.data.payload,settings:m(u),additionalSigners:r,options:o,payer:i});break;case "sync":d=await Qr({authResponse:n.data.payload,settings:m(u),additionalSigners:r,options:o,payer:i});break;default:throw Error("Invalid Transaction Action Type for send tx payload.")}return s&&await to(d),{txSig:d,user:c}}async function OU(e,t,n){let{instructions:r,signer:o,addressesByLookupTableAddress:i,settingsIndexWithAddress:a,additionalSigners:s,payer:c}=t;if(!o.walletAddress||!o.settingsIndexWithAddress)throw new Error("Signer is missing wallet address");let u=async(l,I)=>{let E=prepareTransactionMessage({payer:m(o.walletAddress),instructions:r,addressesByLookupTableAddress:i}),T=a??o.settingsIndexWithAddress,S=await getSettingsFromIndex(T.index),p=(await A(()=>fetchSettingsAccountData(S,T.settingsAddressTreeIndex))).members.some(J=>J.role===UserRole.TransactionManager),h={transactionMessageBytes:M().decode(E),transactionAddress:S,transactionActionType:p?"execute":"create_with_preauthorized_execution"},D={phase:"start",rid:l,data:{type:"transaction",payload:h},clientOrigin:I,signer:o.publicKey},{signature:C,validTill:B}=await A(()=>e.onClientAuthorizationCallback(D));return {request:{...D,rid:l,validTill:B},signature:C}},d=async l=>{let I=await e.onClientAuthorizationCallback(l);return $e(e,{request:I,options:n,additionalSigners:s,addressesByLookupTableAddress:i,payer:c})};return e.sendRequestToPopupProvider({onConnectedCallback:u,onSuccessCallback:d,signal:n?.signal})}async function UU(e,t,n){if(t.amount<=0)throw new Error("Transfer amount must be greater than 0");if(!t.destination||typeof t.destination!="string")throw new Error("Destination address is required");let{mint:r,tokenProgram:o=jt,amount:i,destination:a,signer:s,payer:c,addressesByLookupTableAddress:u}=t,d=async(I,E)=>{let T={transactionActionType:"transfer_intent",transactionAddress:r?o:ue,transactionMessageBytes:M().decode(new Uint8Array([...Te().encode(i),...q().encode(m(a)),...q().encode(m(r??ue))]))},S={phase:"start",rid:I,data:{type:"transaction",payload:T},clientOrigin:E,signer:s?.publicKey},{signature:R,validTill:p}=await A(()=>e.onClientAuthorizationCallback(S));return {request:{...S,rid:I,validTill:p},signature:R}},l=async I=>{let E=await e.onClientAuthorizationCallback(I);return $e(e,{request:E,options:n,addressesByLookupTableAddress:u,payer:c})};return e.sendRequestToPopupProvider({onConnectedCallback:d,onSuccessCallback:l,signal:n?.signal})}async function no(e,t,n){if(!t.includes(e.clientOrigin))throw new Error("Invalid client origin");let r=Date.now()+Mr,o=convertBase64StringToJWK(n);if(!o.alg)throw new Error("Property alg in JWK is missing.");return {signature:await new CompactSign(createClientAuthorizationStartRequestChallenge({...e,validTill:r})).setProtectedHeader({alg:o.alg}).sign(o),validTill:r}}function je(e,t){if(e.length!==t.length)return false;let n=0;for(let r=0;r<e.length;r++)n|=e[r]^t[r];return n===0}async function ro(e,t,n,r=ce,o=xe){let{payload:i}=e.data;if(i.startRequest.data.type!=="message")throw new Error("Invalid request type.");if(Date.now()>i.startRequest.validTill)throw new Error("Request expired.");if(!n.includes(i.startRequest.clientOrigin)||!n.includes(i.client.clientOrigin)||i.startRequest.clientOrigin!==i.client.clientOrigin)throw new Error("Invalid client origin");let a=await importJWK(convertBase64StringToJWK(t)),s=await compactVerify(e.data.payload.client.jws,a);if(!je(s.payload,createClientAuthorizationStartRequestChallenge(e.data.payload.startRequest)))throw new Error("Invalid client signature");let c=createMessageChallenge(i.startRequest.data.payload,i.startRequest.clientOrigin,i.device.jwk,i.startRequest.rid),{verified:u}=await verifyAuthenticationResponse({response:i.authResponse,expectedChallenge:bufferToBase64URLString(c),expectedRPID:o,expectedOrigin:r,requireUserVerification:false,credential:{counter:0,id:i.authResponse.id,publicKey:convertPubkeyCompressedToCose(i.signer)}});if(!u)throw new Error("Invalid client siganture");return {user:UserInfoSchema.parse(e.data.payload.additionalInfo)}}async function io(e,t,n,r,o=ce,i=xe){let{payload:a}=e.data;if(a.startRequest.data.type!=="transaction")throw new Error("Invalid request type.");if(Date.now()>Math.min(a.startRequest.validTill,a.estimatedSlotHashExpiry))throw new Error("Request expired.");if(!n.includes(a.startRequest.clientOrigin)||!n.includes(a.client.clientOrigin)||a.startRequest.clientOrigin!==a.client.clientOrigin)throw new Error("Invalid client origin");let s=await importJWK(convertBase64StringToJWK(t)),c=await compactVerify(e.data.payload.client.jws,s);if(!je(c.payload,createClientAuthorizationStartRequestChallenge(e.data.payload.startRequest)))throw new Error("Invalid client signature");let{challenge:u}=await createTransactionChallenge(a.startRequest.data.payload,a.startRequest.clientOrigin,a.device.jwk,a.startRequest.rid,a.slotHash,a.slotNumber,a.estimatedSlotHashExpiry),{verified:d}=await verifyAuthenticationResponse({response:a.authResponse,expectedChallenge:bufferToBase64URLString(u),expectedRPID:i,expectedOrigin:o,requireUserVerification:false,credential:{counter:0,id:a.authResponse.id,publicKey:convertPubkeyCompressedToCose(a.signer)}});if(!d)throw new Error("Invalid client siganture");let l=convertBase64StringToJWK(r);if(!l.alg)throw new Error("Property alg in JWK is missing.");let I=await new CompactSign(createClientAuthorizationCompleteRequestChallenge(e)).setProtectedHeader({alg:l.alg}).sign(l);return {...e,data:{...e.data,payload:{...e.data.payload,client:{...e.data.payload.client,jws:I}}}}}async function aP({request:e,publicKey:t,allowedClientOrigins:n,privateKey:r,providerOrigin:o,rpId:i}){if(e.phase==="start")return await no(e,n,r);if(e.phase==="complete"){if(e.data.type==="message")return await ro(e,t,n,o,i);if(e.data.type==="transaction")return await io(e,t,n,r,o,i);throw new Error("Invalid request type")}else throw new Error("Invalid request phase")}async function uP(e="landed_tips_75th_percentile",t=Or){let n=await fetch(t);if(!n.ok)throw new Error(`Failed to fetch Jito tips: ${n.status} ${n.statusText}`);let r=await n.json();if(!Array.isArray(r)||!r[0]||typeof r[0][e]!="number")throw new Error("Invalid Jito tips response format");return Math.round(r[0][e]*1e9)}async function IP(e,t,n=Cr){let i=JSON.stringify({jsonrpc:"2.0",id:1,method:"sendBundle",params:[e,{encoding:"base64"}]}),a=null;for(let c=0;c<=5&&(a=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json",...t?{"x-jito-auth":t}:{}},body:i}),!(a.status!==429||c===5));c++){let u=Math.min(1e4,250*2**c);await od(u);}if(!a)throw new Error("Failed to send bundles: no response");let s=await a.json();if(s.error)throw new Error(`Error sending bundles: ${JSON.stringify(s.error,null,2)}`);if(!s.result)throw new Error("No bundle ID returned from Jito");return s.result}var od=e=>new Promise(t=>setTimeout(t,e));/*! Bundled license information:
11
11
 
12
12
  @noble/curves/utils.js:
13
13
  (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
14
- */export{Se as RevibaseAbortedError,Ne as RevibaseApiError,te as RevibaseAuthError,Ge as RevibaseEnvironmentError,b as RevibaseError,xe as RevibaseFlowInProgressError,Cr as RevibasePopupBlockedError,fe as RevibasePopupClosedError,We as RevibasePopupNotOpenError,Ur as RevibaseProvider,De as RevibaseTimeoutError,EU as executeTransaction,XU as processClientAuthCallback,QU as processEstimateJitoTipsCallback,nP as processSendJitoBundleCallback,jl as signIn,SU as transferTokens};//# sourceMappingURL=index.js.map
14
+ */export{Ve as RevibaseAbortedError,Ce as RevibaseApiError,z as RevibaseAuthError,He as RevibaseEnvironmentError,w as RevibaseError,Ge as RevibaseFlowInProgressError,hr as RevibasePopupBlockedError,Z as RevibasePopupClosedError,yr as RevibasePopupNotOpenError,wr as RevibaseProvider,pe as RevibaseTimeoutError,OU as executeTransaction,aP as processClientAuthCallback,uP as processEstimateJitoTipsCallback,IP as processSendJitoBundleCallback,Jl as signIn,UU as transferTokens};//# sourceMappingURL=index.js.map
15
15
  //# sourceMappingURL=index.js.map