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