@coinflowlabs/vue 0.2.1 → 0.2.3

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/README.md CHANGED
@@ -47,6 +47,10 @@ Props:
47
47
 
48
48
  # Changelog
49
49
 
50
+ # 0.2.3
51
+
52
+ - Custom fonts for card elements
53
+
50
54
  ## 1.0.0
51
55
 
52
56
  - Initial Version of the SDK
@@ -16777,7 +16777,8 @@ const P0 = /* @__PURE__ */ ns(w0, [["render", b0]]), Fc = (o) => {
16777
16777
  n({
16778
16778
  css: f(),
16779
16779
  debug: e.debug,
16780
- origins: e.origins
16780
+ origins: e.origins,
16781
+ fontFamily: e.font
16781
16782
  });
16782
16783
  }, {}), (u, p) => (mr(), Yn("div", { id: lo(di) }, null, 8, x0));
16783
16784
  }
@@ -16844,7 +16845,8 @@ const P0 = /* @__PURE__ */ ns(w0, [["render", b0]]), Fc = (o) => {
16844
16845
  s({
16845
16846
  css: f(),
16846
16847
  debug: e.debug,
16847
- origins: e.origins
16848
+ origins: e.origins,
16849
+ fontFamily: e.font
16848
16850
  });
16849
16851
  }, {}), (u, p) => (mr(), Yn("div", { id: lo(di) }, null, 8, E0));
16850
16852
  }
@@ -20,9 +20,9 @@ ${JSON.stringify(s.slice(-10),null,2)}. `:"",f="\nCatch the `SendTransactionErro
20
20
  ${n}. `+a+f;break;case"simulate":u=`Simulation failed.
21
21
  Message: ${n}.
22
22
  `+a+f;break;default:u=`Unknown action '${(p=>p)(t)}'`}super(u),this.signature=void 0,this.transactionMessage=void 0,this.transactionLogs=void 0,this.signature=e,this.transactionMessage=n,this.transactionLogs=s||void 0}get transactionError(){return{message:this.transactionMessage,logs:Array.isArray(this.transactionLogs)?this.transactionLogs:void 0}}get logs(){const t=this.transactionLogs;if(!(t!=null&&typeof t=="object"&&"then"in t))return t}async getLogs(t){return Array.isArray(this.transactionLogs)||(this.transactionLogs=new Promise((e,n)=>{t.getTransaction(this.signature).then(s=>{if(s&&s.meta&&s.meta.logMessages){const a=s.meta.logMessages;this.transactionLogs=a,e(a)}else n(new Error("Log messages not found"))}).catch(n)})),await this.transactionLogs}}const Wh={JSON_RPC_SERVER_ERROR_BLOCK_CLEANED_UP:-32001,JSON_RPC_SERVER_ERROR_SEND_TRANSACTION_PREFLIGHT_FAILURE:-32002,JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_VERIFICATION_FAILURE:-32003,JSON_RPC_SERVER_ERROR_BLOCK_NOT_AVAILABLE:-32004,JSON_RPC_SERVER_ERROR_NODE_UNHEALTHY:-32005,JSON_RPC_SERVER_ERROR_TRANSACTION_PRECOMPILE_VERIFICATION_FAILURE:-32006,JSON_RPC_SERVER_ERROR_SLOT_SKIPPED:-32007,JSON_RPC_SERVER_ERROR_NO_SNAPSHOT:-32008,JSON_RPC_SERVER_ERROR_LONG_TERM_STORAGE_SLOT_SKIPPED:-32009,JSON_RPC_SERVER_ERROR_KEY_EXCLUDED_FROM_SECONDARY_INDEX:-32010,JSON_RPC_SERVER_ERROR_TRANSACTION_HISTORY_NOT_AVAILABLE:-32011,JSON_RPC_SCAN_ERROR:-32012,JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_LEN_MISMATCH:-32013,JSON_RPC_SERVER_ERROR_BLOCK_STATUS_NOT_AVAILABLE_YET:-32014,JSON_RPC_SERVER_ERROR_UNSUPPORTED_TRANSACTION_VERSION:-32015,JSON_RPC_SERVER_ERROR_MIN_CONTEXT_SLOT_NOT_REACHED:-32016};class ut extends Error{constructor({code:t,message:e,data:n},s){super(s!=null?`${s}: ${e}`:e),this.code=void 0,this.data=void 0,this.code=t,this.data=n,this.name="SolanaJSONRPCError"}}async function lo(o,t,e,n){const s=n&&{skipPreflight:n.skipPreflight,preflightCommitment:n.preflightCommitment||n.commitment,maxRetries:n.maxRetries,minContextSlot:n.minContextSlot},a=await o.sendTransaction(t,e,s);let f;if(t.recentBlockhash!=null&&t.lastValidBlockHeight!=null)f=(await o.confirmTransaction({abortSignal:n==null?void 0:n.abortSignal,signature:a,blockhash:t.recentBlockhash,lastValidBlockHeight:t.lastValidBlockHeight},n&&n.commitment)).value;else if(t.minNonceContextSlot!=null&&t.nonceInfo!=null){const{nonceInstruction:u}=t.nonceInfo,p=u.keys[0].pubkey;f=(await o.confirmTransaction({abortSignal:n==null?void 0:n.abortSignal,minContextSlot:t.minNonceContextSlot,nonceAccountPubkey:p,nonceValue:t.nonceInfo.nonce,signature:a},n&&n.commitment)).value}else(n==null?void 0:n.abortSignal)!=null&&console.warn("sendAndConfirmTransaction(): A transaction with a deprecated confirmation strategy was supplied along with an `abortSignal`. Only transactions having `lastValidBlockHeight` or a combination of `nonceInfo` and `minNonceContextSlot` are abortable."),f=(await o.confirmTransaction(a,n&&n.commitment)).value;if(f.err)throw a!=null?new An({action:"send",signature:a,transactionMessage:`Status: (${JSON.stringify(f)})`}):new Error(`Transaction ${a} failed (${JSON.stringify(f)})`);return a}function Dr(o){return new Promise(t=>setTimeout(t,o))}function Mt(o,t){const e=o.layout.span>=0?o.layout.span:Da(o,t),n=dt.Buffer.alloc(e),s=Object.assign({instruction:o.index},t);return o.layout.encode(s,n),n}function zt(o,t){let e;try{e=o.layout.decode(t)}catch(n){throw new Error("invalid instruction; "+n)}if(e.instruction!==o.index)throw new Error(`invalid instruction; instruction index mismatch ${e.instruction} != ${o.index}`);return e}const Ka=Be("lamportsPerSignature"),qa=ct([at("version"),at("state"),Bt("authorizedPubkey"),Bt("nonce"),ct([Ka],"feeCalculator")]),po=qa.span;class ni{constructor(t){this.authorizedPubkey=void 0,this.nonce=void 0,this.feeCalculator=void 0,this.authorizedPubkey=t.authorizedPubkey,this.nonce=t.nonce,this.feeCalculator=t.feeCalculator}static fromAccountData(t){const e=qa.decode(kt(t),0);return new ni({authorizedPubkey:new tt(e.authorizedPubkey),nonce:new tt(e.nonce).toString(),feeCalculator:e.feeCalculator})}}const Kh=o=>{const t=o.decode.bind(o),e=o.encode.bind(o);return{decode:t,encode:e}},sn=(o=>t=>{const e=jt(o,t),{encode:n,decode:s}=Kh(e),a=e;return a.decode=(f,u)=>{const p=s(f,u);return bf(dt.Buffer.from(p))},a.encode=(f,u,p)=>{const w=fa(f,o);return n(w,u,p)},a})(8);class qh{constructor(){}static decodeInstructionType(t){this.checkProgramId(t.programId);const n=at("instruction").decode(t.data);let s;for(const[a,f]of Object.entries(Vt))if(f.index==n){s=a;break}if(!s)throw new Error("Instruction type incorrect; not a SystemInstruction");return s}static decodeCreateAccount(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,2);const{lamports:e,space:n,programId:s}=zt(Vt.Create,t.data);return{fromPubkey:t.keys[0].pubkey,newAccountPubkey:t.keys[1].pubkey,lamports:e,space:n,programId:new tt(s)}}static decodeTransfer(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,2);const{lamports:e}=zt(Vt.Transfer,t.data);return{fromPubkey:t.keys[0].pubkey,toPubkey:t.keys[1].pubkey,lamports:e}}static decodeTransferWithSeed(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{lamports:e,seed:n,programId:s}=zt(Vt.TransferWithSeed,t.data);return{fromPubkey:t.keys[0].pubkey,basePubkey:t.keys[1].pubkey,toPubkey:t.keys[2].pubkey,lamports:e,seed:n,programId:new tt(s)}}static decodeAllocate(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,1);const{space:e}=zt(Vt.Allocate,t.data);return{accountPubkey:t.keys[0].pubkey,space:e}}static decodeAllocateWithSeed(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,1);const{base:e,seed:n,space:s,programId:a}=zt(Vt.AllocateWithSeed,t.data);return{accountPubkey:t.keys[0].pubkey,basePubkey:new tt(e),seed:n,space:s,programId:new tt(a)}}static decodeAssign(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,1);const{programId:e}=zt(Vt.Assign,t.data);return{accountPubkey:t.keys[0].pubkey,programId:new tt(e)}}static decodeAssignWithSeed(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,1);const{base:e,seed:n,programId:s}=zt(Vt.AssignWithSeed,t.data);return{accountPubkey:t.keys[0].pubkey,basePubkey:new tt(e),seed:n,programId:new tt(s)}}static decodeCreateWithSeed(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,2);const{base:e,seed:n,lamports:s,space:a,programId:f}=zt(Vt.CreateWithSeed,t.data);return{fromPubkey:t.keys[0].pubkey,newAccountPubkey:t.keys[1].pubkey,basePubkey:new tt(e),seed:n,lamports:s,space:a,programId:new tt(f)}}static decodeNonceInitialize(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{authorized:e}=zt(Vt.InitializeNonceAccount,t.data);return{noncePubkey:t.keys[0].pubkey,authorizedPubkey:new tt(e)}}static decodeNonceAdvance(t){return this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3),zt(Vt.AdvanceNonceAccount,t.data),{noncePubkey:t.keys[0].pubkey,authorizedPubkey:t.keys[2].pubkey}}static decodeNonceWithdraw(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,5);const{lamports:e}=zt(Vt.WithdrawNonceAccount,t.data);return{noncePubkey:t.keys[0].pubkey,toPubkey:t.keys[1].pubkey,authorizedPubkey:t.keys[4].pubkey,lamports:e}}static decodeNonceAuthorize(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,2);const{authorized:e}=zt(Vt.AuthorizeNonceAccount,t.data);return{noncePubkey:t.keys[0].pubkey,authorizedPubkey:t.keys[1].pubkey,newAuthorizedPubkey:new tt(e)}}static checkProgramId(t){if(!t.equals(Ee.programId))throw new Error("invalid instruction; programId is not SystemProgram")}static checkKeyLength(t,e){if(t.length<e)throw new Error(`invalid instruction; found ${t.length} keys, expected at least ${e}`)}}const Vt=Object.freeze({Create:{index:0,layout:ct([at("instruction"),De("lamports"),De("space"),Bt("programId")])},Assign:{index:1,layout:ct([at("instruction"),Bt("programId")])},Transfer:{index:2,layout:ct([at("instruction"),sn("lamports")])},CreateWithSeed:{index:3,layout:ct([at("instruction"),Bt("base"),Nr("seed"),De("lamports"),De("space"),Bt("programId")])},AdvanceNonceAccount:{index:4,layout:ct([at("instruction")])},WithdrawNonceAccount:{index:5,layout:ct([at("instruction"),De("lamports")])},InitializeNonceAccount:{index:6,layout:ct([at("instruction"),Bt("authorized")])},AuthorizeNonceAccount:{index:7,layout:ct([at("instruction"),Bt("authorized")])},Allocate:{index:8,layout:ct([at("instruction"),De("space")])},AllocateWithSeed:{index:9,layout:ct([at("instruction"),Bt("base"),Nr("seed"),De("space"),Bt("programId")])},AssignWithSeed:{index:10,layout:ct([at("instruction"),Bt("base"),Nr("seed"),Bt("programId")])},TransferWithSeed:{index:11,layout:ct([at("instruction"),sn("lamports"),Nr("seed"),Bt("programId")])},UpgradeNonceAccount:{index:12,layout:ct([at("instruction")])}});class Ee{constructor(){}static createAccount(t){const e=Vt.Create,n=Mt(e,{lamports:t.lamports,space:t.space,programId:kt(t.programId.toBuffer())});return new Ht({keys:[{pubkey:t.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:t.newAccountPubkey,isSigner:!0,isWritable:!0}],programId:this.programId,data:n})}static transfer(t){let e,n;if("basePubkey"in t){const s=Vt.TransferWithSeed;e=Mt(s,{lamports:BigInt(t.lamports),seed:t.seed,programId:kt(t.programId.toBuffer())}),n=[{pubkey:t.fromPubkey,isSigner:!1,isWritable:!0},{pubkey:t.basePubkey,isSigner:!0,isWritable:!1},{pubkey:t.toPubkey,isSigner:!1,isWritable:!0}]}else{const s=Vt.Transfer;e=Mt(s,{lamports:BigInt(t.lamports)}),n=[{pubkey:t.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:t.toPubkey,isSigner:!1,isWritable:!0}]}return new Ht({keys:n,programId:this.programId,data:e})}static assign(t){let e,n;if("basePubkey"in t){const s=Vt.AssignWithSeed;e=Mt(s,{base:kt(t.basePubkey.toBuffer()),seed:t.seed,programId:kt(t.programId.toBuffer())}),n=[{pubkey:t.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:t.basePubkey,isSigner:!0,isWritable:!1}]}else{const s=Vt.Assign;e=Mt(s,{programId:kt(t.programId.toBuffer())}),n=[{pubkey:t.accountPubkey,isSigner:!0,isWritable:!0}]}return new Ht({keys:n,programId:this.programId,data:e})}static createAccountWithSeed(t){const e=Vt.CreateWithSeed,n=Mt(e,{base:kt(t.basePubkey.toBuffer()),seed:t.seed,lamports:t.lamports,space:t.space,programId:kt(t.programId.toBuffer())});let s=[{pubkey:t.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:t.newAccountPubkey,isSigner:!1,isWritable:!0}];return t.basePubkey!=t.fromPubkey&&s.push({pubkey:t.basePubkey,isSigner:!0,isWritable:!1}),new Ht({keys:s,programId:this.programId,data:n})}static createNonceAccount(t){const e=new Ot;"basePubkey"in t&&"seed"in t?e.add(Ee.createAccountWithSeed({fromPubkey:t.fromPubkey,newAccountPubkey:t.noncePubkey,basePubkey:t.basePubkey,seed:t.seed,lamports:t.lamports,space:po,programId:this.programId})):e.add(Ee.createAccount({fromPubkey:t.fromPubkey,newAccountPubkey:t.noncePubkey,lamports:t.lamports,space:po,programId:this.programId}));const n={noncePubkey:t.noncePubkey,authorizedPubkey:t.authorizedPubkey};return e.add(this.nonceInitialize(n)),e}static nonceInitialize(t){const e=Vt.InitializeNonceAccount,n=Mt(e,{authorized:kt(t.authorizedPubkey.toBuffer())}),s={keys:[{pubkey:t.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:ei,isSigner:!1,isWritable:!1},{pubkey:on,isSigner:!1,isWritable:!1}],programId:this.programId,data:n};return new Ht(s)}static nonceAdvance(t){const e=Vt.AdvanceNonceAccount,n=Mt(e),s={keys:[{pubkey:t.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:ei,isSigner:!1,isWritable:!1},{pubkey:t.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:n};return new Ht(s)}static nonceWithdraw(t){const e=Vt.WithdrawNonceAccount,n=Mt(e,{lamports:t.lamports});return new Ht({keys:[{pubkey:t.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:t.toPubkey,isSigner:!1,isWritable:!0},{pubkey:ei,isSigner:!1,isWritable:!1},{pubkey:on,isSigner:!1,isWritable:!1},{pubkey:t.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:n})}static nonceAuthorize(t){const e=Vt.AuthorizeNonceAccount,n=Mt(e,{authorized:kt(t.newAuthorizedPubkey.toBuffer())});return new Ht({keys:[{pubkey:t.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:t.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:n})}static allocate(t){let e,n;if("basePubkey"in t){const s=Vt.AllocateWithSeed;e=Mt(s,{base:kt(t.basePubkey.toBuffer()),seed:t.seed,space:t.space,programId:kt(t.programId.toBuffer())}),n=[{pubkey:t.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:t.basePubkey,isSigner:!0,isWritable:!1}]}else{const s=Vt.Allocate;e=Mt(s,{space:t.space}),n=[{pubkey:t.accountPubkey,isSigner:!0,isWritable:!0}]}return new Ht({keys:n,programId:this.programId,data:e})}}Ee.programId=new tt("11111111111111111111111111111111");const Hh=Ar-300;class $r{constructor(){}static getMinNumSignatures(t){return 2*(Math.ceil(t/$r.chunkSize)+1+1)}static async load(t,e,n,s,a){{const I=await t.getMinimumBalanceForRentExemption(a.length),M=await t.getAccountInfo(n.publicKey,"confirmed");let T=null;if(M!==null){if(M.executable)return console.error("Program load failed, account is already executable"),!1;M.data.length!==a.length&&(T=T||new Ot,T.add(Ee.allocate({accountPubkey:n.publicKey,space:a.length}))),M.owner.equals(s)||(T=T||new Ot,T.add(Ee.assign({accountPubkey:n.publicKey,programId:s}))),M.lamports<I&&(T=T||new Ot,T.add(Ee.transfer({fromPubkey:e.publicKey,toPubkey:n.publicKey,lamports:I-M.lamports})))}else T=new Ot().add(Ee.createAccount({fromPubkey:e.publicKey,newAccountPubkey:n.publicKey,lamports:I>0?I:1,space:a.length,programId:s}));T!==null&&await lo(t,T,[e,n],{commitment:"confirmed"})}const f=ct([at("instruction"),at("offset"),at("bytesLength"),at("bytesLengthPadding"),Ae(Ct("byte"),Sr(at(),-8),"bytes")]),u=$r.chunkSize;let p=0,w=a,E=[];for(;w.length>0;){const I=w.slice(0,u),M=dt.Buffer.alloc(u+16);f.encode({instruction:0,offset:p,bytes:I,bytesLength:0,bytesLengthPadding:0},M);const T=new Ot().add({keys:[{pubkey:n.publicKey,isSigner:!0,isWritable:!0}],programId:s,data:M});E.push(lo(t,T,[e,n],{commitment:"confirmed"})),t._rpcEndpoint.includes("solana.com")&&await Dr(1e3/4),p+=u,w=w.slice(u)}await Promise.all(E);{const I=ct([at("instruction")]),M=dt.Buffer.alloc(I.span);I.encode({instruction:1},M);const T=new Ot().add({keys:[{pubkey:n.publicKey,isSigner:!0,isWritable:!0},{pubkey:on,isSigner:!1,isWritable:!1}],programId:s,data:M}),U="processed",_=await t.sendTransaction(T,[e,n],{preflightCommitment:U}),{context:C,value:L}=await t.confirmTransaction({signature:_,lastValidBlockHeight:T.lastValidBlockHeight,blockhash:T.recentBlockhash},U);if(L.err)throw new Error(`Transaction ${_} failed (${JSON.stringify(L)})`);for(;;){try{if(await t.getSlot({commitment:U})>C.slot)break}catch{}await new Promise($=>setTimeout($,Math.round(Wa/2)))}}return!0}}$r.chunkSize=Hh;const Vh=new tt("BPFLoader2111111111111111111111111111111111");class jh{static getMinNumSignatures(t){return $r.getMinNumSignatures(t)}static load(t,e,n,s,a){return $r.load(t,e,n,a,s)}}function Gh(o){return o&&o.__esModule&&Object.prototype.hasOwnProperty.call(o,"default")?o.default:o}var Yh=Object.prototype.toString,Zh=Object.keys||function(o){var t=[];for(var e in o)t.push(e);return t};function vn(o,t){var e,n,s,a,f,u,p;if(o===!0)return"true";if(o===!1)return"false";switch(typeof o){case"object":if(o===null)return null;if(o.toJSON&&typeof o.toJSON=="function")return vn(o.toJSON(),t);if(p=Yh.call(o),p==="[object Array]"){for(s="[",n=o.length-1,e=0;e<n;e++)s+=vn(o[e],!0)+",";return n>-1&&(s+=vn(o[e],!0)),s+"]"}else if(p==="[object Object]"){for(a=Zh(o).sort(),n=a.length,s="",e=0;e<n;)f=a[e],u=vn(o[f],!1),u!==void 0&&(s&&(s+=","),s+=JSON.stringify(f)+":"+u),e++;return"{"+s+"}"}else return JSON.stringify(o);case"function":case"undefined":return t?null:void 0;case"string":return JSON.stringify(o);default:return isFinite(o)?o:null}}var Jh=function(o){var t=vn(o,!1);if(t!==void 0)return""+t},Ha=Gh(Jh);const _n=32;function go(o){let t=0;for(;o>1;)o/=2,t++;return t}function Xh(o){return o===0?1:(o--,o|=o>>1,o|=o>>2,o|=o>>4,o|=o>>8,o|=o>>16,o|=o>>32,o+1)}class Va{constructor(t,e,n,s,a){this.slotsPerEpoch=void 0,this.leaderScheduleSlotOffset=void 0,this.warmup=void 0,this.firstNormalEpoch=void 0,this.firstNormalSlot=void 0,this.slotsPerEpoch=t,this.leaderScheduleSlotOffset=e,this.warmup=n,this.firstNormalEpoch=s,this.firstNormalSlot=a}getEpoch(t){return this.getEpochAndSlotIndex(t)[0]}getEpochAndSlotIndex(t){if(t<this.firstNormalSlot){const e=go(Xh(t+_n+1))-go(_n)-1,n=this.getSlotsInEpoch(e),s=t-(n-_n);return[e,s]}else{const e=t-this.firstNormalSlot,n=Math.floor(e/this.slotsPerEpoch),s=this.firstNormalEpoch+n,a=e%this.slotsPerEpoch;return[s,a]}}getFirstSlotInEpoch(t){return t<=this.firstNormalEpoch?(Math.pow(2,t)-1)*_n:(t-this.firstNormalEpoch)*this.slotsPerEpoch+this.firstNormalSlot}getLastSlotInEpoch(t){return this.getFirstSlotInEpoch(t)+this.getSlotsInEpoch(t)-1}getSlotsInEpoch(t){return t<this.firstNormalEpoch?Math.pow(2,t+go(_n)):this.slotsPerEpoch}}var Qh=globalThis.fetch;class tl extends sh{constructor(t,e,n){const s=a=>{const f=ih(a,{autoconnect:!0,max_reconnects:5,reconnect:!0,reconnect_interval:1e3,...e});return"socket"in f?this.underlyingSocket=f.socket:this.underlyingSocket=f,f};super(s,t,e,n),this.underlyingSocket=void 0}call(...t){var n;const e=(n=this.underlyingSocket)==null?void 0:n.readyState;return e===1?super.call(...t):Promise.reject(new Error("Tried to call a JSON-RPC method `"+t[0]+"` but the socket was not `CONNECTING` or `OPEN` (`readyState` was "+e+")"))}notify(...t){var n;const e=(n=this.underlyingSocket)==null?void 0:n.readyState;return e===1?super.notify(...t):Promise.reject(new Error("Tried to send a JSON-RPC notification `"+t[0]+"` but the socket was not `CONNECTING` or `OPEN` (`readyState` was "+e+")"))}}function el(o,t){let e;try{e=o.layout.decode(t)}catch(n){throw new Error("invalid instruction; "+n)}if(e.typeIndex!==o.index)throw new Error(`invalid account data; account type mismatch ${e.typeIndex} != ${o.index}`);return e}const ja=56;class yo{constructor(t){this.key=void 0,this.state=void 0,this.key=t.key,this.state=t.state}isActive(){const t=BigInt("0xffffffffffffffff");return this.state.deactivationSlot===t}static deserialize(t){const e=el(rl,t),n=t.length-ja;Lt(n>=0,"lookup table is invalid"),Lt(n%32===0,"lookup table is invalid");const s=n/32,{addresses:a}=ct([Ae(Bt(),s,"addresses")]).decode(t.slice(ja));return{deactivationSlot:e.deactivationSlot,lastExtendedSlot:e.lastExtendedSlot,lastExtendedSlotStartIndex:e.lastExtendedStartIndex,authority:e.authority.length!==0?new tt(e.authority[0]):void 0,addresses:a.map(f=>new tt(f))}}}const rl={index:1,layout:ct([at("typeIndex"),sn("deactivationSlot"),Be("lastExtendedSlot"),Ct("lastExtendedStartIndex"),Ct(),Ae(Bt(),Sr(Ct(),-1),"authority")])},nl=/^[^:]+:\/\/([^:[]+|\[[^\]]+\])(:\d+)?(.*)/i;function il(o){const t=o.match(nl);if(t==null)throw TypeError(`Failed to validate endpoint URL \`${o}\``);const[e,n,s,a]=t,f=o.startsWith("https:")?"wss:":"ws:",u=s==null?null:parseInt(s.slice(1),10),p=u==null?"":`:${u+1}`;return`${f}//${n}${p}${a}`}const te=xn(Yi(tt),Q(),o=>new tt(o)),Ga=Zi([Q(),Jt("base64")]),mo=xn(Yi(dt.Buffer),Ga,o=>dt.Buffer.from(o[0],"base64")),Ya=30*1e3;function ol(o){if(/^https?:/.test(o)===!1)throw new TypeError("Endpoint URL must start with `http:` or `https:`.");return o}function Yt(o){let t,e;if(typeof o=="string")t=o;else if(o){const{commitment:n,...s}=o;t=n,e=s}return{commitment:t,config:e}}function Za(o){return Ue([j({jsonrpc:Jt("2.0"),id:Q(),result:o}),j({jsonrpc:Jt("2.0"),id:Q(),error:j({code:bn(),message:Q(),data:gt(_f())})})])}const sl=Za(bn());function Et(o){return xn(Za(o),sl,t=>"error"in t?t:{...t,result:et(t.result,o)})}function Qt(o){return Et(j({context:j({slot:O()}),value:o}))}function ii(o){return j({context:j({slot:O()}),value:o})}function wo(o,t){return o===0?new zr({header:t.header,staticAccountKeys:t.accountKeys.map(e=>new tt(e)),recentBlockhash:t.recentBlockhash,compiledInstructions:t.instructions.map(e=>({programIdIndex:e.programIdIndex,accountKeyIndexes:e.accounts,data:ke.decode(e.data)})),addressTableLookups:t.addressTableLookups}):new Ze(t)}const al=j({foundation:O(),foundationTerm:O(),initial:O(),taper:O(),terminal:O()}),cl=Et(nt(rt(j({epoch:O(),effectiveSlot:O(),amount:O(),postBalance:O(),commission:gt(rt(O()))})))),ul=nt(j({slot:O(),prioritizationFee:O()})),fl=j({total:O(),validator:O(),foundation:O(),epoch:O()}),hl=j({epoch:O(),slotIndex:O(),slotsInEpoch:O(),absoluteSlot:O(),blockHeight:gt(O()),transactionCount:gt(O())}),ll=j({slotsPerEpoch:O(),leaderScheduleSlotOffset:O(),warmup:rr(),firstNormalEpoch:O(),firstNormalSlot:O()}),dl=pa(Q(),nt(O())),Wr=rt(Ue([j({}),Q()])),pl=j({err:Wr}),gl=Jt("receivedSignature"),yl=j({"solana-core":Q(),"feature-set":gt(O())}),Ja=Qt(j({err:rt(Ue([j({}),Q()])),logs:rt(nt(Q())),accounts:gt(rt(nt(rt(j({executable:rr(),owner:Q(),lamports:O(),data:nt(Q()),rentEpoch:gt(O())}))))),unitsConsumed:gt(O()),returnData:gt(rt(j({programId:Q(),data:Zi([Q(),Jt("base64")])})))})),ml=Qt(j({byIdentity:pa(Q(),nt(O())),range:j({firstSlot:O(),lastSlot:O()})}));function wl(o,t,e,n,s,a){const f=e||Qh;let u;a!=null&&console.warn("You have supplied an `httpAgent` when creating a `Connection` in a browser environment.It has been ignored; `httpAgent` is only used in Node environments.");let p;return n&&(p=async(E,I)=>{const M=await new Promise((T,U)=>{try{n(E,I,(_,C)=>T([_,C]))}catch(_){U(_)}});return await f(...M)}),new eh(async(E,I)=>{const M={method:"POST",body:E,agent:u,headers:Object.assign({"Content-Type":"application/json"},t||{},bd)};try{let T=5,U,_=500;for(;p?U=await p(o,M):U=await f(o,M),!(U.status!==429||s===!0||(T-=1,T===0));)console.error(`Server responded with ${U.status} ${U.statusText}. Retrying after ${_}ms delay...`),await Dr(_),_*=2;const C=await U.text();U.ok?I(null,C):I(new Error(`${U.status} ${U.statusText}: ${C}`))}catch(T){T instanceof Error&&I(T)}},{})}function bl(o){return(t,e)=>new Promise((n,s)=>{o.request(t,e,(a,f)=>{if(a){s(a);return}n(f)})})}function xl(o){return t=>new Promise((e,n)=>{t.length===0&&e([]);const s=t.map(a=>o.request(a.methodName,a.args));o.request(s,(a,f)=>{if(a){n(a);return}e(f)})})}const kl=Et(al),El=Et(fl),Il=Et(ul),Sl=Et(hl),Bl=Et(ll),Al=Et(dl),vl=Et(O()),_l=Qt(j({total:O(),circulating:O(),nonCirculating:O(),nonCirculatingAccounts:nt(te)})),bo=j({amount:Q(),uiAmount:rt(O()),decimals:O(),uiAmountString:gt(Q())}),Rl=Qt(nt(j({address:te,amount:Q(),uiAmount:rt(O()),decimals:O(),uiAmountString:gt(Q())}))),Tl=Qt(nt(j({pubkey:te,account:j({executable:rr(),owner:te,lamports:O(),data:mo,rentEpoch:O()})}))),xo=j({program:Q(),parsed:bn(),space:O()}),Ml=Qt(nt(j({pubkey:te,account:j({executable:rr(),owner:te,lamports:O(),data:xo,rentEpoch:O()})}))),Pl=Qt(nt(j({lamports:O(),address:te}))),Rn=j({executable:rr(),owner:te,lamports:O(),data:mo,rentEpoch:O()}),Cl=j({pubkey:te,account:Rn}),Ul=xn(Ue([Yi(dt.Buffer),xo]),Ue([Ga,xo]),o=>Array.isArray(o)?et(o,mo):o),ko=j({executable:rr(),owner:te,lamports:O(),data:Ul,rentEpoch:O()}),Ll=j({pubkey:te,account:ko}),Fl=j({state:Ue([Jt("active"),Jt("inactive"),Jt("activating"),Jt("deactivating")]),active:O(),inactive:O()}),Ol=Et(nt(j({signature:Q(),slot:O(),err:Wr,memo:rt(Q()),blockTime:gt(rt(O()))}))),Nl=Et(nt(j({signature:Q(),slot:O(),err:Wr,memo:rt(Q()),blockTime:gt(rt(O()))}))),zl=j({subscription:O(),result:ii(Rn)}),Dl=j({pubkey:te,account:Rn}),$l=j({subscription:O(),result:ii(Dl)}),Wl=j({parent:O(),slot:O(),root:O()}),Kl=j({subscription:O(),result:Wl}),ql=Ue([j({type:Ue([Jt("firstShredReceived"),Jt("completed"),Jt("optimisticConfirmation"),Jt("root")]),slot:O(),timestamp:O()}),j({type:Jt("createdBank"),parent:O(),slot:O(),timestamp:O()}),j({type:Jt("frozen"),slot:O(),timestamp:O(),stats:j({numTransactionEntries:O(),numSuccessfulTransactions:O(),numFailedTransactions:O(),maxTransactionsPerEntry:O()})}),j({type:Jt("dead"),slot:O(),timestamp:O(),err:Q()})]),Hl=j({subscription:O(),result:ql}),Vl=j({subscription:O(),result:ii(Ue([pl,gl]))}),jl=j({subscription:O(),result:O()}),Gl=j({pubkey:Q(),gossip:rt(Q()),tpu:rt(Q()),rpc:rt(Q()),version:rt(Q())}),Xa=j({votePubkey:Q(),nodePubkey:Q(),activatedStake:O(),epochVoteAccount:rr(),epochCredits:nt(Zi([O(),O(),O()])),commission:O(),lastVote:O(),rootSlot:rt(O())}),Yl=Et(j({current:nt(Xa),delinquent:nt(Xa)})),Zl=Ue([Jt("processed"),Jt("confirmed"),Jt("finalized")]),Jl=j({slot:O(),confirmations:rt(O()),err:Wr,confirmationStatus:gt(Zl)}),Xl=Qt(nt(rt(Jl))),Ql=Et(O()),Qa=j({accountKey:te,writableIndexes:nt(O()),readonlyIndexes:nt(O())}),Eo=j({signatures:nt(Q()),message:j({accountKeys:nt(Q()),header:j({numRequiredSignatures:O(),numReadonlySignedAccounts:O(),numReadonlyUnsignedAccounts:O()}),instructions:nt(j({accounts:nt(O()),data:Q(),programIdIndex:O()})),recentBlockhash:Q(),addressTableLookups:gt(nt(Qa))})}),tc=j({pubkey:te,signer:rr(),writable:rr(),source:gt(Ue([Jt("transaction"),Jt("lookupTable")]))}),ec=j({accountKeys:nt(tc),signatures:nt(Q())}),rc=j({parsed:bn(),program:Q(),programId:te}),nc=j({accounts:nt(te),data:Q(),programId:te}),td=Ue([nc,rc]),ed=Ue([j({parsed:bn(),program:Q(),programId:Q()}),j({accounts:nt(Q()),data:Q(),programId:Q()})]),ic=xn(td,ed,o=>"accounts"in o?et(o,nc):et(o,rc)),oc=j({signatures:nt(Q()),message:j({accountKeys:nt(tc),instructions:nt(ic),recentBlockhash:Q(),addressTableLookups:gt(rt(nt(Qa)))})}),oi=j({accountIndex:O(),mint:Q(),owner:gt(Q()),uiTokenAmount:bo}),sc=j({writable:nt(te),readonly:nt(te)}),si=j({err:Wr,fee:O(),innerInstructions:gt(rt(nt(j({index:O(),instructions:nt(j({accounts:nt(O()),data:Q(),programIdIndex:O()}))})))),preBalances:nt(O()),postBalances:nt(O()),logMessages:gt(rt(nt(Q()))),preTokenBalances:gt(rt(nt(oi))),postTokenBalances:gt(rt(nt(oi))),loadedAddresses:gt(sc),computeUnitsConsumed:gt(O())}),Io=j({err:Wr,fee:O(),innerInstructions:gt(rt(nt(j({index:O(),instructions:nt(ic)})))),preBalances:nt(O()),postBalances:nt(O()),logMessages:gt(rt(nt(Q()))),preTokenBalances:gt(rt(nt(oi))),postTokenBalances:gt(rt(nt(oi))),loadedAddresses:gt(sc),computeUnitsConsumed:gt(O())}),an=Ue([Jt(0),Jt("legacy")]),Kr=j({pubkey:Q(),lamports:O(),postBalance:rt(O()),rewardType:rt(Q()),commission:gt(rt(O()))}),rd=Et(rt(j({blockhash:Q(),previousBlockhash:Q(),parentSlot:O(),transactions:nt(j({transaction:Eo,meta:rt(si),version:gt(an)})),rewards:gt(nt(Kr)),blockTime:rt(O()),blockHeight:rt(O())}))),nd=Et(rt(j({blockhash:Q(),previousBlockhash:Q(),parentSlot:O(),rewards:gt(nt(Kr)),blockTime:rt(O()),blockHeight:rt(O())}))),id=Et(rt(j({blockhash:Q(),previousBlockhash:Q(),parentSlot:O(),transactions:nt(j({transaction:ec,meta:rt(si),version:gt(an)})),rewards:gt(nt(Kr)),blockTime:rt(O()),blockHeight:rt(O())}))),od=Et(rt(j({blockhash:Q(),previousBlockhash:Q(),parentSlot:O(),transactions:nt(j({transaction:oc,meta:rt(Io),version:gt(an)})),rewards:gt(nt(Kr)),blockTime:rt(O()),blockHeight:rt(O())}))),sd=Et(rt(j({blockhash:Q(),previousBlockhash:Q(),parentSlot:O(),transactions:nt(j({transaction:ec,meta:rt(Io),version:gt(an)})),rewards:gt(nt(Kr)),blockTime:rt(O()),blockHeight:rt(O())}))),ad=Et(rt(j({blockhash:Q(),previousBlockhash:Q(),parentSlot:O(),rewards:gt(nt(Kr)),blockTime:rt(O()),blockHeight:rt(O())}))),cd=Et(rt(j({blockhash:Q(),previousBlockhash:Q(),parentSlot:O(),transactions:nt(j({transaction:Eo,meta:rt(si)})),rewards:gt(nt(Kr)),blockTime:rt(O())}))),ac=Et(rt(j({blockhash:Q(),previousBlockhash:Q(),parentSlot:O(),signatures:nt(Q()),blockTime:rt(O())}))),So=Et(rt(j({slot:O(),meta:rt(si),blockTime:gt(rt(O())),transaction:Eo,version:gt(an)}))),ai=Et(rt(j({slot:O(),transaction:oc,meta:rt(Io),blockTime:gt(rt(O())),version:gt(an)}))),ud=Qt(j({blockhash:Q(),feeCalculator:j({lamportsPerSignature:O()})})),fd=Qt(j({blockhash:Q(),lastValidBlockHeight:O()})),hd=Qt(rr()),ld=j({slot:O(),numTransactions:O(),numSlots:O(),samplePeriodSecs:O()}),dd=Et(nt(ld)),pd=Qt(rt(j({feeCalculator:j({lamportsPerSignature:O()})}))),gd=Et(Q()),yd=Et(Q()),md=j({err:Wr,logs:nt(Q()),signature:Q()}),wd=j({result:ii(md),subscription:O()}),bd={"solana-client":"js/0.0.0-development"};class xd{constructor(t,e){this._commitment=void 0,this._confirmTransactionInitialTimeout=void 0,this._rpcEndpoint=void 0,this._rpcWsEndpoint=void 0,this._rpcClient=void 0,this._rpcRequest=void 0,this._rpcBatchRequest=void 0,this._rpcWebSocket=void 0,this._rpcWebSocketConnected=!1,this._rpcWebSocketHeartbeat=null,this._rpcWebSocketIdleTimeout=null,this._rpcWebSocketGeneration=0,this._disableBlockhashCaching=!1,this._pollingBlockhash=!1,this._blockhashInfo={latestBlockhash:null,lastFetch:0,transactionSignatures:[],simulatedSignatures:[]},this._nextClientSubscriptionId=0,this._subscriptionDisposeFunctionsByClientSubscriptionId={},this._subscriptionHashByClientSubscriptionId={},this._subscriptionStateChangeCallbacksByHash={},this._subscriptionCallbacksByServerSubscriptionId={},this._subscriptionsByHash={},this._subscriptionsAutoDisposedByRpc=new Set,this.getBlockHeight=(()=>{const w={};return async E=>{const{commitment:I,config:M}=Yt(E),T=this._buildArgs([],I,void 0,M),U=Ha(T);return w[U]=w[U]??(async()=>{try{const _=await this._rpcRequest("getBlockHeight",T),C=et(_,Et(O()));if("error"in C)throw new ut(C.error,"failed to get block height information");return C.result}finally{delete w[U]}})(),await w[U]}})();let n,s,a,f,u,p;e&&typeof e=="string"?this._commitment=e:e&&(this._commitment=e.commitment,this._confirmTransactionInitialTimeout=e.confirmTransactionInitialTimeout,n=e.wsEndpoint,s=e.httpHeaders,a=e.fetch,f=e.fetchMiddleware,u=e.disableRetryOnRateLimit,p=e.httpAgent),this._rpcEndpoint=ol(t),this._rpcWsEndpoint=n||il(t),this._rpcClient=wl(t,s,a,f,u,p),this._rpcRequest=bl(this._rpcClient),this._rpcBatchRequest=xl(this._rpcClient),this._rpcWebSocket=new tl(this._rpcWsEndpoint,{autoconnect:!1,max_reconnects:1/0}),this._rpcWebSocket.on("open",this._wsOnOpen.bind(this)),this._rpcWebSocket.on("error",this._wsOnError.bind(this)),this._rpcWebSocket.on("close",this._wsOnClose.bind(this)),this._rpcWebSocket.on("accountNotification",this._wsOnAccountNotification.bind(this)),this._rpcWebSocket.on("programNotification",this._wsOnProgramAccountNotification.bind(this)),this._rpcWebSocket.on("slotNotification",this._wsOnSlotNotification.bind(this)),this._rpcWebSocket.on("slotsUpdatesNotification",this._wsOnSlotUpdatesNotification.bind(this)),this._rpcWebSocket.on("signatureNotification",this._wsOnSignatureNotification.bind(this)),this._rpcWebSocket.on("rootNotification",this._wsOnRootNotification.bind(this)),this._rpcWebSocket.on("logsNotification",this._wsOnLogsNotification.bind(this))}get commitment(){return this._commitment}get rpcEndpoint(){return this._rpcEndpoint}async getBalanceAndContext(t,e){const{commitment:n,config:s}=Yt(e),a=this._buildArgs([t.toBase58()],n,void 0,s),f=await this._rpcRequest("getBalance",a),u=et(f,Qt(O()));if("error"in u)throw new ut(u.error,`failed to get balance for ${t.toBase58()}`);return u.result}async getBalance(t,e){return await this.getBalanceAndContext(t,e).then(n=>n.value).catch(n=>{throw new Error("failed to get balance of account "+t.toBase58()+": "+n)})}async getBlockTime(t){const e=await this._rpcRequest("getBlockTime",[t]),n=et(e,Et(rt(O())));if("error"in n)throw new ut(n.error,`failed to get block time for slot ${t}`);return n.result}async getMinimumLedgerSlot(){const t=await this._rpcRequest("minimumLedgerSlot",[]),e=et(t,Et(O()));if("error"in e)throw new ut(e.error,"failed to get minimum ledger slot");return e.result}async getFirstAvailableBlock(){const t=await this._rpcRequest("getFirstAvailableBlock",[]),e=et(t,vl);if("error"in e)throw new ut(e.error,"failed to get first available block");return e.result}async getSupply(t){let e={};typeof t=="string"?e={commitment:t}:t?e={...t,commitment:t&&t.commitment||this.commitment}:e={commitment:this.commitment};const n=await this._rpcRequest("getSupply",[e]),s=et(n,_l);if("error"in s)throw new ut(s.error,"failed to get supply");return s.result}async getTokenSupply(t,e){const n=this._buildArgs([t.toBase58()],e),s=await this._rpcRequest("getTokenSupply",n),a=et(s,Qt(bo));if("error"in a)throw new ut(a.error,"failed to get token supply");return a.result}async getTokenAccountBalance(t,e){const n=this._buildArgs([t.toBase58()],e),s=await this._rpcRequest("getTokenAccountBalance",n),a=et(s,Qt(bo));if("error"in a)throw new ut(a.error,"failed to get token account balance");return a.result}async getTokenAccountsByOwner(t,e,n){const{commitment:s,config:a}=Yt(n);let f=[t.toBase58()];"mint"in e?f.push({mint:e.mint.toBase58()}):f.push({programId:e.programId.toBase58()});const u=this._buildArgs(f,s,"base64",a),p=await this._rpcRequest("getTokenAccountsByOwner",u),w=et(p,Tl);if("error"in w)throw new ut(w.error,`failed to get token accounts owned by account ${t.toBase58()}`);return w.result}async getParsedTokenAccountsByOwner(t,e,n){let s=[t.toBase58()];"mint"in e?s.push({mint:e.mint.toBase58()}):s.push({programId:e.programId.toBase58()});const a=this._buildArgs(s,n,"jsonParsed"),f=await this._rpcRequest("getTokenAccountsByOwner",a),u=et(f,Ml);if("error"in u)throw new ut(u.error,`failed to get token accounts owned by account ${t.toBase58()}`);return u.result}async getLargestAccounts(t){const e={...t,commitment:t&&t.commitment||this.commitment},n=e.filter||e.commitment?[e]:[],s=await this._rpcRequest("getLargestAccounts",n),a=et(s,Pl);if("error"in a)throw new ut(a.error,"failed to get largest accounts");return a.result}async getTokenLargestAccounts(t,e){const n=this._buildArgs([t.toBase58()],e),s=await this._rpcRequest("getTokenLargestAccounts",n),a=et(s,Rl);if("error"in a)throw new ut(a.error,"failed to get token largest accounts");return a.result}async getAccountInfoAndContext(t,e){const{commitment:n,config:s}=Yt(e),a=this._buildArgs([t.toBase58()],n,"base64",s),f=await this._rpcRequest("getAccountInfo",a),u=et(f,Qt(rt(Rn)));if("error"in u)throw new ut(u.error,`failed to get info about account ${t.toBase58()}`);return u.result}async getParsedAccountInfo(t,e){const{commitment:n,config:s}=Yt(e),a=this._buildArgs([t.toBase58()],n,"jsonParsed",s),f=await this._rpcRequest("getAccountInfo",a),u=et(f,Qt(rt(ko)));if("error"in u)throw new ut(u.error,`failed to get info about account ${t.toBase58()}`);return u.result}async getAccountInfo(t,e){try{return(await this.getAccountInfoAndContext(t,e)).value}catch(n){throw new Error("failed to get info about account "+t.toBase58()+": "+n)}}async getMultipleParsedAccounts(t,e){const{commitment:n,config:s}=Yt(e),a=t.map(w=>w.toBase58()),f=this._buildArgs([a],n,"jsonParsed",s),u=await this._rpcRequest("getMultipleAccounts",f),p=et(u,Qt(nt(rt(ko))));if("error"in p)throw new ut(p.error,`failed to get info for accounts ${a}`);return p.result}async getMultipleAccountsInfoAndContext(t,e){const{commitment:n,config:s}=Yt(e),a=t.map(w=>w.toBase58()),f=this._buildArgs([a],n,"base64",s),u=await this._rpcRequest("getMultipleAccounts",f),p=et(u,Qt(nt(rt(Rn))));if("error"in p)throw new ut(p.error,`failed to get info for accounts ${a}`);return p.result}async getMultipleAccountsInfo(t,e){return(await this.getMultipleAccountsInfoAndContext(t,e)).value}async getStakeActivation(t,e,n){const{commitment:s,config:a}=Yt(e),f=this._buildArgs([t.toBase58()],s,void 0,{...a,epoch:n??(a==null?void 0:a.epoch)}),u=await this._rpcRequest("getStakeActivation",f),p=et(u,Et(Fl));if("error"in p)throw new ut(p.error,`failed to get Stake Activation ${t.toBase58()}`);return p.result}async getProgramAccounts(t,e){const{commitment:n,config:s}=Yt(e),{encoding:a,...f}=s||{},u=this._buildArgs([t.toBase58()],n,a||"base64",f),p=await this._rpcRequest("getProgramAccounts",u),w=nt(Cl),E=f.withContext===!0?et(p,Qt(w)):et(p,Et(w));if("error"in E)throw new ut(E.error,`failed to get accounts owned by program ${t.toBase58()}`);return E.result}async getParsedProgramAccounts(t,e){const{commitment:n,config:s}=Yt(e),a=this._buildArgs([t.toBase58()],n,"jsonParsed",s),f=await this._rpcRequest("getProgramAccounts",a),u=et(f,Et(nt(Ll)));if("error"in u)throw new ut(u.error,`failed to get accounts owned by program ${t.toBase58()}`);return u.result}async confirmTransaction(t,e){var a;let n;if(typeof t=="string")n=t;else{const f=t;if((a=f.abortSignal)!=null&&a.aborted)return Promise.reject(f.abortSignal.reason);n=f.signature}let s;try{s=ke.decode(n)}catch{throw new Error("signature must be base58 encoded: "+n)}return Lt(s.length===64,"signature has invalid length"),typeof t=="string"?await this.confirmTransactionUsingLegacyTimeoutStrategy({commitment:e||this.commitment,signature:n}):"lastValidBlockHeight"in t?await this.confirmTransactionUsingBlockHeightExceedanceStrategy({commitment:e||this.commitment,strategy:t}):await this.confirmTransactionUsingDurableNonceStrategy({commitment:e||this.commitment,strategy:t})}getCancellationPromise(t){return new Promise((e,n)=>{t!=null&&(t.aborted?n(t.reason):t.addEventListener("abort",()=>{n(t.reason)}))})}getTransactionConfirmationPromise({commitment:t,signature:e}){let n,s,a=!1;const f=new Promise((p,w)=>{try{n=this.onSignature(e,(I,M)=>{n=void 0;const T={context:M,value:I};p({__type:yr.PROCESSED,response:T})},t);const E=new Promise(I=>{n==null?I():s=this._onSubscriptionStateChange(n,M=>{M==="subscribed"&&I()})});(async()=>{if(await E,a)return;const I=await this.getSignatureStatus(e);if(a||I==null)return;const{context:M,value:T}=I;if(T!=null)if(T!=null&&T.err)w(T.err);else{switch(t){case"confirmed":case"single":case"singleGossip":{if(T.confirmationStatus==="processed")return;break}case"finalized":case"max":case"root":{if(T.confirmationStatus==="processed"||T.confirmationStatus==="confirmed")return;break}case"processed":case"recent":}a=!0,p({__type:yr.PROCESSED,response:{context:M,value:T}})}})()}catch(E){w(E)}});return{abortConfirmation:()=>{s&&(s(),s=void 0),n!=null&&(this.removeSignatureListener(n),n=void 0)},confirmationPromise:f}}async confirmTransactionUsingBlockHeightExceedanceStrategy({commitment:t,strategy:{abortSignal:e,lastValidBlockHeight:n,signature:s}}){let a=!1;const f=new Promise(I=>{const M=async()=>{try{return await this.getBlockHeight(t)}catch{return-1}};(async()=>{let T=await M();if(!a){for(;T<=n;)if(await Dr(1e3),a||(T=await M(),a))return;I({__type:yr.BLOCKHEIGHT_EXCEEDED})}})()}),{abortConfirmation:u,confirmationPromise:p}=this.getTransactionConfirmationPromise({commitment:t,signature:s}),w=this.getCancellationPromise(e);let E;try{const I=await Promise.race([w,p,f]);if(I.__type===yr.PROCESSED)E=I.response;else throw new ao(s)}finally{a=!0,u()}return E}async confirmTransactionUsingDurableNonceStrategy({commitment:t,strategy:{abortSignal:e,minContextSlot:n,nonceAccountPubkey:s,nonceValue:a,signature:f}}){let u=!1;const p=new Promise(T=>{let U=a,_=null;const C=async()=>{try{const{context:L,value:$}=await this.getNonceAndContext(s,{commitment:t,minContextSlot:n});return _=L.slot,$==null?void 0:$.nonce}catch{return U}};(async()=>{if(U=await C(),!u)for(;;){if(a!==U){T({__type:yr.NONCE_INVALID,slotInWhichNonceDidAdvance:_});return}if(await Dr(2e3),u||(U=await C(),u))return}})()}),{abortConfirmation:w,confirmationPromise:E}=this.getTransactionConfirmationPromise({commitment:t,signature:f}),I=this.getCancellationPromise(e);let M;try{const T=await Promise.race([I,E,p]);if(T.__type===yr.PROCESSED)M=T.response;else{let U;for(;;){const _=await this.getSignatureStatus(f);if(_==null)break;if(_.context.slot<(T.slotInWhichNonceDidAdvance??n)){await Dr(400);continue}U=_;break}if(U!=null&&U.value){const _=t||"finalized",{confirmationStatus:C}=U.value;switch(_){case"processed":case"recent":if(C!=="processed"&&C!=="confirmed"&&C!=="finalized")throw new nn(f);break;case"confirmed":case"single":case"singleGossip":if(C!=="confirmed"&&C!=="finalized")throw new nn(f);break;case"finalized":case"max":case"root":if(C!=="finalized")throw new nn(f);break;default:}M={context:U.context,value:{err:U.value.err}}}else throw new nn(f)}}finally{u=!0,w()}return M}async confirmTransactionUsingLegacyTimeoutStrategy({commitment:t,signature:e}){let n;const s=new Promise(p=>{let w=this._confirmTransactionInitialTimeout||6e4;switch(t){case"processed":case"recent":case"single":case"confirmed":case"singleGossip":{w=this._confirmTransactionInitialTimeout||3e4;break}}n=setTimeout(()=>p({__type:yr.TIMED_OUT,timeoutMs:w}),w)}),{abortConfirmation:a,confirmationPromise:f}=this.getTransactionConfirmationPromise({commitment:t,signature:e});let u;try{const p=await Promise.race([f,s]);if(p.__type===yr.PROCESSED)u=p.response;else throw new co(e,p.timeoutMs/1e3)}finally{clearTimeout(n),a()}return u}async getClusterNodes(){const t=await this._rpcRequest("getClusterNodes",[]),e=et(t,Et(nt(Gl)));if("error"in e)throw new ut(e.error,"failed to get cluster nodes");return e.result}async getVoteAccounts(t){const e=this._buildArgs([],t),n=await this._rpcRequest("getVoteAccounts",e),s=et(n,Yl);if("error"in s)throw new ut(s.error,"failed to get vote accounts");return s.result}async getSlot(t){const{commitment:e,config:n}=Yt(t),s=this._buildArgs([],e,void 0,n),a=await this._rpcRequest("getSlot",s),f=et(a,Et(O()));if("error"in f)throw new ut(f.error,"failed to get slot");return f.result}async getSlotLeader(t){const{commitment:e,config:n}=Yt(t),s=this._buildArgs([],e,void 0,n),a=await this._rpcRequest("getSlotLeader",s),f=et(a,Et(Q()));if("error"in f)throw new ut(f.error,"failed to get slot leader");return f.result}async getSlotLeaders(t,e){const n=[t,e],s=await this._rpcRequest("getSlotLeaders",n),a=et(s,Et(nt(te)));if("error"in a)throw new ut(a.error,"failed to get slot leaders");return a.result}async getSignatureStatus(t,e){const{context:n,value:s}=await this.getSignatureStatuses([t],e);Lt(s.length===1);const a=s[0];return{context:n,value:a}}async getSignatureStatuses(t,e){const n=[t];e&&n.push(e);const s=await this._rpcRequest("getSignatureStatuses",n),a=et(s,Xl);if("error"in a)throw new ut(a.error,"failed to get signature status");return a.result}async getTransactionCount(t){const{commitment:e,config:n}=Yt(t),s=this._buildArgs([],e,void 0,n),a=await this._rpcRequest("getTransactionCount",s),f=et(a,Et(O()));if("error"in f)throw new ut(f.error,"failed to get transaction count");return f.result}async getTotalSupply(t){return(await this.getSupply({commitment:t,excludeNonCirculatingAccountsList:!0})).value.total}async getInflationGovernor(t){const e=this._buildArgs([],t),n=await this._rpcRequest("getInflationGovernor",e),s=et(n,kl);if("error"in s)throw new ut(s.error,"failed to get inflation");return s.result}async getInflationReward(t,e,n){const{commitment:s,config:a}=Yt(n),f=this._buildArgs([t.map(w=>w.toBase58())],s,void 0,{...a,epoch:e??(a==null?void 0:a.epoch)}),u=await this._rpcRequest("getInflationReward",f),p=et(u,cl);if("error"in p)throw new ut(p.error,"failed to get inflation reward");return p.result}async getInflationRate(){const t=await this._rpcRequest("getInflationRate",[]),e=et(t,El);if("error"in e)throw new ut(e.error,"failed to get inflation rate");return e.result}async getEpochInfo(t){const{commitment:e,config:n}=Yt(t),s=this._buildArgs([],e,void 0,n),a=await this._rpcRequest("getEpochInfo",s),f=et(a,Sl);if("error"in f)throw new ut(f.error,"failed to get epoch info");return f.result}async getEpochSchedule(){const t=await this._rpcRequest("getEpochSchedule",[]),e=et(t,Bl);if("error"in e)throw new ut(e.error,"failed to get epoch schedule");const n=e.result;return new Va(n.slotsPerEpoch,n.leaderScheduleSlotOffset,n.warmup,n.firstNormalEpoch,n.firstNormalSlot)}async getLeaderSchedule(){const t=await this._rpcRequest("getLeaderSchedule",[]),e=et(t,Al);if("error"in e)throw new ut(e.error,"failed to get leader schedule");return e.result}async getMinimumBalanceForRentExemption(t,e){const n=this._buildArgs([t],e),s=await this._rpcRequest("getMinimumBalanceForRentExemption",n),a=et(s,Ql);return"error"in a?(console.warn("Unable to fetch minimum balance for rent exemption"),0):a.result}async getRecentBlockhashAndContext(t){const e=this._buildArgs([],t),n=await this._rpcRequest("getRecentBlockhash",e),s=et(n,ud);if("error"in s)throw new ut(s.error,"failed to get recent blockhash");return s.result}async getRecentPerformanceSamples(t){const e=await this._rpcRequest("getRecentPerformanceSamples",t?[t]:[]),n=et(e,dd);if("error"in n)throw new ut(n.error,"failed to get recent performance samples");return n.result}async getFeeCalculatorForBlockhash(t,e){const n=this._buildArgs([t],e),s=await this._rpcRequest("getFeeCalculatorForBlockhash",n),a=et(s,pd);if("error"in a)throw new ut(a.error,"failed to get fee calculator");const{context:f,value:u}=a.result;return{context:f,value:u!==null?u.feeCalculator:null}}async getFeeForMessage(t,e){const n=kt(t.serialize()).toString("base64"),s=this._buildArgs([n],e),a=await this._rpcRequest("getFeeForMessage",s),f=et(a,Qt(rt(O())));if("error"in f)throw new ut(f.error,"failed to get fee for message");if(f.result===null)throw new Error("invalid blockhash");return f.result}async getRecentPrioritizationFees(t){var f;const e=(f=t==null?void 0:t.lockedWritableAccounts)==null?void 0:f.map(u=>u.toBase58()),n=e!=null&&e.length?[e]:[],s=await this._rpcRequest("getRecentPrioritizationFees",n),a=et(s,Il);if("error"in a)throw new ut(a.error,"failed to get recent prioritization fees");return a.result}async getRecentBlockhash(t){try{return(await this.getRecentBlockhashAndContext(t)).value}catch(e){throw new Error("failed to get recent blockhash: "+e)}}async getLatestBlockhash(t){try{return(await this.getLatestBlockhashAndContext(t)).value}catch(e){throw new Error("failed to get recent blockhash: "+e)}}async getLatestBlockhashAndContext(t){const{commitment:e,config:n}=Yt(t),s=this._buildArgs([],e,void 0,n),a=await this._rpcRequest("getLatestBlockhash",s),f=et(a,fd);if("error"in f)throw new ut(f.error,"failed to get latest blockhash");return f.result}async isBlockhashValid(t,e){const{commitment:n,config:s}=Yt(e),a=this._buildArgs([t],n,void 0,s),f=await this._rpcRequest("isBlockhashValid",a),u=et(f,hd);if("error"in u)throw new ut(u.error,"failed to determine if the blockhash `"+t+"`is valid");return u.result}async getVersion(){const t=await this._rpcRequest("getVersion",[]),e=et(t,Et(yl));if("error"in e)throw new ut(e.error,"failed to get version");return e.result}async getGenesisHash(){const t=await this._rpcRequest("getGenesisHash",[]),e=et(t,Et(Q()));if("error"in e)throw new ut(e.error,"failed to get genesis hash");return e.result}async getBlock(t,e){const{commitment:n,config:s}=Yt(e),a=this._buildArgsAtLeastConfirmed([t],n,void 0,s),f=await this._rpcRequest("getBlock",a);try{switch(s==null?void 0:s.transactionDetails){case"accounts":{const u=et(f,id);if("error"in u)throw u.error;return u.result}case"none":{const u=et(f,nd);if("error"in u)throw u.error;return u.result}default:{const u=et(f,rd);if("error"in u)throw u.error;const{result:p}=u;return p?{...p,transactions:p.transactions.map(({transaction:w,meta:E,version:I})=>({meta:E,transaction:{...w,message:wo(I,w.message)},version:I}))}:null}}}catch(u){throw new ut(u,"failed to get confirmed block")}}async getParsedBlock(t,e){const{commitment:n,config:s}=Yt(e),a=this._buildArgsAtLeastConfirmed([t],n,"jsonParsed",s),f=await this._rpcRequest("getBlock",a);try{switch(s==null?void 0:s.transactionDetails){case"accounts":{const u=et(f,sd);if("error"in u)throw u.error;return u.result}case"none":{const u=et(f,ad);if("error"in u)throw u.error;return u.result}default:{const u=et(f,od);if("error"in u)throw u.error;return u.result}}}catch(u){throw new ut(u,"failed to get block")}}async getBlockProduction(t){let e,n;if(typeof t=="string")n=t;else if(t){const{commitment:u,...p}=t;n=u,e=p}const s=this._buildArgs([],n,"base64",e),a=await this._rpcRequest("getBlockProduction",s),f=et(a,ml);if("error"in f)throw new ut(f.error,"failed to get block production information");return f.result}async getTransaction(t,e){const{commitment:n,config:s}=Yt(e),a=this._buildArgsAtLeastConfirmed([t],n,void 0,s),f=await this._rpcRequest("getTransaction",a),u=et(f,So);if("error"in u)throw new ut(u.error,"failed to get transaction");const p=u.result;return p&&{...p,transaction:{...p.transaction,message:wo(p.version,p.transaction.message)}}}async getParsedTransaction(t,e){const{commitment:n,config:s}=Yt(e),a=this._buildArgsAtLeastConfirmed([t],n,"jsonParsed",s),f=await this._rpcRequest("getTransaction",a),u=et(f,ai);if("error"in u)throw new ut(u.error,"failed to get transaction");return u.result}async getParsedTransactions(t,e){const{commitment:n,config:s}=Yt(e),a=t.map(p=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([p],n,"jsonParsed",s)}));return(await this._rpcBatchRequest(a)).map(p=>{const w=et(p,ai);if("error"in w)throw new ut(w.error,"failed to get transactions");return w.result})}async getTransactions(t,e){const{commitment:n,config:s}=Yt(e),a=t.map(p=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([p],n,void 0,s)}));return(await this._rpcBatchRequest(a)).map(p=>{const w=et(p,So);if("error"in w)throw new ut(w.error,"failed to get transactions");const E=w.result;return E&&{...E,transaction:{...E.transaction,message:wo(E.version,E.transaction.message)}}})}async getConfirmedBlock(t,e){const n=this._buildArgsAtLeastConfirmed([t],e),s=await this._rpcRequest("getConfirmedBlock",n),a=et(s,cd);if("error"in a)throw new ut(a.error,"failed to get confirmed block");const f=a.result;if(!f)throw new Error("Confirmed block "+t+" not found");const u={...f,transactions:f.transactions.map(({transaction:p,meta:w})=>{const E=new Ze(p.message);return{meta:w,transaction:{...p,message:E}}})};return{...u,transactions:u.transactions.map(({transaction:p,meta:w})=>({meta:w,transaction:Ot.populate(p.message,p.signatures)}))}}async getBlocks(t,e,n){const s=this._buildArgsAtLeastConfirmed(e!==void 0?[t,e]:[t],n),a=await this._rpcRequest("getBlocks",s),f=et(a,Et(nt(O())));if("error"in f)throw new ut(f.error,"failed to get blocks");return f.result}async getBlockSignatures(t,e){const n=this._buildArgsAtLeastConfirmed([t],e,void 0,{transactionDetails:"signatures",rewards:!1}),s=await this._rpcRequest("getBlock",n),a=et(s,ac);if("error"in a)throw new ut(a.error,"failed to get block");const f=a.result;if(!f)throw new Error("Block "+t+" not found");return f}async getConfirmedBlockSignatures(t,e){const n=this._buildArgsAtLeastConfirmed([t],e,void 0,{transactionDetails:"signatures",rewards:!1}),s=await this._rpcRequest("getConfirmedBlock",n),a=et(s,ac);if("error"in a)throw new ut(a.error,"failed to get confirmed block");const f=a.result;if(!f)throw new Error("Confirmed block "+t+" not found");return f}async getConfirmedTransaction(t,e){const n=this._buildArgsAtLeastConfirmed([t],e),s=await this._rpcRequest("getConfirmedTransaction",n),a=et(s,So);if("error"in a)throw new ut(a.error,"failed to get transaction");const f=a.result;if(!f)return f;const u=new Ze(f.transaction.message),p=f.transaction.signatures;return{...f,transaction:Ot.populate(u,p)}}async getParsedConfirmedTransaction(t,e){const n=this._buildArgsAtLeastConfirmed([t],e,"jsonParsed"),s=await this._rpcRequest("getConfirmedTransaction",n),a=et(s,ai);if("error"in a)throw new ut(a.error,"failed to get confirmed transaction");return a.result}async getParsedConfirmedTransactions(t,e){const n=t.map(f=>({methodName:"getConfirmedTransaction",args:this._buildArgsAtLeastConfirmed([f],e,"jsonParsed")}));return(await this._rpcBatchRequest(n)).map(f=>{const u=et(f,ai);if("error"in u)throw new ut(u.error,"failed to get confirmed transactions");return u.result})}async getConfirmedSignaturesForAddress(t,e,n){let s={},a=await this.getFirstAvailableBlock();for(;!("until"in s)&&(e--,!(e<=0||e<a));)try{const p=await this.getConfirmedBlockSignatures(e,"finalized");p.signatures.length>0&&(s.until=p.signatures[p.signatures.length-1].toString())}catch(p){if(p instanceof Error&&p.message.includes("skipped"))continue;throw p}let f=await this.getSlot("finalized");for(;!("before"in s)&&(n++,!(n>f));)try{const p=await this.getConfirmedBlockSignatures(n);p.signatures.length>0&&(s.before=p.signatures[p.signatures.length-1].toString())}catch(p){if(p instanceof Error&&p.message.includes("skipped"))continue;throw p}return(await this.getConfirmedSignaturesForAddress2(t,s)).map(p=>p.signature)}async getConfirmedSignaturesForAddress2(t,e,n){const s=this._buildArgsAtLeastConfirmed([t.toBase58()],n,void 0,e),a=await this._rpcRequest("getConfirmedSignaturesForAddress2",s),f=et(a,Ol);if("error"in f)throw new ut(f.error,"failed to get confirmed signatures for address");return f.result}async getSignaturesForAddress(t,e,n){const s=this._buildArgsAtLeastConfirmed([t.toBase58()],n,void 0,e),a=await this._rpcRequest("getSignaturesForAddress",s),f=et(a,Nl);if("error"in f)throw new ut(f.error,"failed to get signatures for address");return f.result}async getAddressLookupTable(t,e){const{context:n,value:s}=await this.getAccountInfoAndContext(t,e);let a=null;return s!==null&&(a=new yo({key:t,state:yo.deserialize(s.data)})),{context:n,value:a}}async getNonceAndContext(t,e){const{context:n,value:s}=await this.getAccountInfoAndContext(t,e);let a=null;return s!==null&&(a=ni.fromAccountData(s.data)),{context:n,value:a}}async getNonce(t,e){return await this.getNonceAndContext(t,e).then(n=>n.value).catch(n=>{throw new Error("failed to get nonce for account "+t.toBase58()+": "+n)})}async requestAirdrop(t,e){const n=await this._rpcRequest("requestAirdrop",[t.toBase58(),e]),s=et(n,gd);if("error"in s)throw new ut(s.error,`airdrop to ${t.toBase58()} failed`);return s.result}async _blockhashWithExpiryBlockHeight(t){if(!t){for(;this._pollingBlockhash;)await Dr(100);const n=Date.now()-this._blockhashInfo.lastFetch>=Ya;if(this._blockhashInfo.latestBlockhash!==null&&!n)return this._blockhashInfo.latestBlockhash}return await this._pollNewBlockhash()}async _pollNewBlockhash(){this._pollingBlockhash=!0;try{const t=Date.now(),e=this._blockhashInfo.latestBlockhash,n=e?e.blockhash:null;for(let s=0;s<50;s++){const a=await this.getLatestBlockhash("finalized");if(n!==a.blockhash)return this._blockhashInfo={latestBlockhash:a,lastFetch:Date.now(),transactionSignatures:[],simulatedSignatures:[]},a;await Dr(Wa/2)}throw new Error(`Unable to obtain a new blockhash after ${Date.now()-t}ms`)}finally{this._pollingBlockhash=!1}}async getStakeMinimumDelegation(t){const{commitment:e,config:n}=Yt(t),s=this._buildArgs([],e,"base64",n),a=await this._rpcRequest("getStakeMinimumDelegation",s),f=et(a,Qt(O()));if("error"in f)throw new ut(f.error,"failed to get stake minimum delegation");return f.result}async simulateTransaction(t,e,n){if("message"in t){const _=t.serialize(),C=dt.Buffer.from(_).toString("base64");if(Array.isArray(e)||n!==void 0)throw new Error("Invalid arguments");const L=e||{};L.encoding="base64","commitment"in L||(L.commitment=this.commitment);const $=[C,L],N=await this._rpcRequest("simulateTransaction",$),H=et(N,Ja);if("error"in H)throw new Error("failed to simulate transaction: "+H.error.message);return H.result}let s;if(t instanceof Ot){let U=t;s=new Ot,s.feePayer=U.feePayer,s.instructions=t.instructions,s.nonceInfo=U.nonceInfo,s.signatures=U.signatures}else s=Ot.populate(t),s._message=s._json=void 0;if(e!==void 0&&!Array.isArray(e))throw new Error("Invalid arguments");const a=e;if(s.nonceInfo&&a)s.sign(...a);else{let U=this._disableBlockhashCaching;for(;;){const _=await this._blockhashWithExpiryBlockHeight(U);if(s.lastValidBlockHeight=_.lastValidBlockHeight,s.recentBlockhash=_.blockhash,!a)break;if(s.sign(...a),!s.signature)throw new Error("!signature");const C=s.signature.toString("base64");if(!this._blockhashInfo.simulatedSignatures.includes(C)&&!this._blockhashInfo.transactionSignatures.includes(C)){this._blockhashInfo.simulatedSignatures.push(C);break}else U=!0}}const f=s._compile(),u=f.serialize(),w=s._serialize(u).toString("base64"),E={encoding:"base64",commitment:this.commitment};if(n){const U=(Array.isArray(n)?n:f.nonProgramIds()).map(_=>_.toBase58());E.accounts={encoding:"base64",addresses:U}}a&&(E.sigVerify=!0);const I=[w,E],M=await this._rpcRequest("simulateTransaction",I),T=et(M,Ja);if("error"in T){let U;if("data"in T.error&&(U=T.error.data.logs,U&&Array.isArray(U))){const _=`
23
- `,C=_+U.join(_);console.error(T.error.message,C)}throw new An({action:"simulate",signature:"",transactionMessage:T.error.message,logs:U})}return T.result}async sendTransaction(t,e,n){if("version"in t){if(e&&Array.isArray(e))throw new Error("Invalid arguments");const f=t.serialize();return await this.sendRawTransaction(f,e)}if(e===void 0||!Array.isArray(e))throw new Error("Invalid arguments");const s=e;if(t.nonceInfo)t.sign(...s);else{let f=this._disableBlockhashCaching;for(;;){const u=await this._blockhashWithExpiryBlockHeight(f);if(t.lastValidBlockHeight=u.lastValidBlockHeight,t.recentBlockhash=u.blockhash,t.sign(...s),!t.signature)throw new Error("!signature");const p=t.signature.toString("base64");if(this._blockhashInfo.transactionSignatures.includes(p))f=!0;else{this._blockhashInfo.transactionSignatures.push(p);break}}}const a=t.serialize();return await this.sendRawTransaction(a,n)}async sendRawTransaction(t,e){const n=kt(t).toString("base64");return await this.sendEncodedTransaction(n,e)}async sendEncodedTransaction(t,e){const n={encoding:"base64"},s=e&&e.skipPreflight,a=s===!0?"processed":e&&e.preflightCommitment||this.commitment;e&&e.maxRetries!=null&&(n.maxRetries=e.maxRetries),e&&e.minContextSlot!=null&&(n.minContextSlot=e.minContextSlot),s&&(n.skipPreflight=s),a&&(n.preflightCommitment=a);const f=[t,n],u=await this._rpcRequest("sendTransaction",f),p=et(u,yd);if("error"in p){let w;throw"data"in p.error&&(w=p.error.data.logs),new An({action:s?"send":"simulate",signature:"",transactionMessage:p.error.message,logs:w})}return p.result}_wsOnOpen(){this._rpcWebSocketConnected=!0,this._rpcWebSocketHeartbeat=setInterval(()=>{(async()=>{try{await this._rpcWebSocket.notify("ping")}catch{}})()},5e3),this._updateSubscriptions()}_wsOnError(t){this._rpcWebSocketConnected=!1,console.error("ws error:",t.message)}_wsOnClose(t){if(this._rpcWebSocketConnected=!1,this._rpcWebSocketGeneration=(this._rpcWebSocketGeneration+1)%Number.MAX_SAFE_INTEGER,this._rpcWebSocketIdleTimeout&&(clearTimeout(this._rpcWebSocketIdleTimeout),this._rpcWebSocketIdleTimeout=null),this._rpcWebSocketHeartbeat&&(clearInterval(this._rpcWebSocketHeartbeat),this._rpcWebSocketHeartbeat=null),t===1e3){this._updateSubscriptions();return}this._subscriptionCallbacksByServerSubscriptionId={},Object.entries(this._subscriptionsByHash).forEach(([e,n])=>{this._setSubscription(e,{...n,state:"pending"})})}_setSubscription(t,e){var s;const n=(s=this._subscriptionsByHash[t])==null?void 0:s.state;if(this._subscriptionsByHash[t]=e,n!==e.state){const a=this._subscriptionStateChangeCallbacksByHash[t];a&&a.forEach(f=>{try{f(e.state)}catch{}})}}_onSubscriptionStateChange(t,e){var a;const n=this._subscriptionHashByClientSubscriptionId[t];if(n==null)return()=>{};const s=(a=this._subscriptionStateChangeCallbacksByHash)[n]||(a[n]=new Set);return s.add(e),()=>{s.delete(e),s.size===0&&delete this._subscriptionStateChangeCallbacksByHash[n]}}async _updateSubscriptions(){if(Object.keys(this._subscriptionsByHash).length===0){this._rpcWebSocketConnected&&(this._rpcWebSocketConnected=!1,this._rpcWebSocketIdleTimeout=setTimeout(()=>{this._rpcWebSocketIdleTimeout=null;try{this._rpcWebSocket.close()}catch(n){n instanceof Error&&console.log(`Error when closing socket connection: ${n.message}`)}},500));return}if(this._rpcWebSocketIdleTimeout!==null&&(clearTimeout(this._rpcWebSocketIdleTimeout),this._rpcWebSocketIdleTimeout=null,this._rpcWebSocketConnected=!0),!this._rpcWebSocketConnected){this._rpcWebSocket.connect();return}const t=this._rpcWebSocketGeneration,e=()=>t===this._rpcWebSocketGeneration;await Promise.all(Object.keys(this._subscriptionsByHash).map(async n=>{const s=this._subscriptionsByHash[n];if(s!==void 0)switch(s.state){case"pending":case"unsubscribed":if(s.callbacks.size===0){delete this._subscriptionsByHash[n],s.state==="unsubscribed"&&delete this._subscriptionCallbacksByServerSubscriptionId[s.serverSubscriptionId],await this._updateSubscriptions();return}await(async()=>{const{args:a,method:f}=s;try{this._setSubscription(n,{...s,state:"subscribing"});const u=await this._rpcWebSocket.call(f,a);this._setSubscription(n,{...s,serverSubscriptionId:u,state:"subscribed"}),this._subscriptionCallbacksByServerSubscriptionId[u]=s.callbacks,await this._updateSubscriptions()}catch(u){if(u instanceof Error&&console.error(`${f} error for argument`,a,u.message),!e())return;this._setSubscription(n,{...s,state:"pending"}),await this._updateSubscriptions()}})();break;case"subscribed":s.callbacks.size===0&&await(async()=>{const{serverSubscriptionId:a,unsubscribeMethod:f}=s;if(this._subscriptionsAutoDisposedByRpc.has(a))this._subscriptionsAutoDisposedByRpc.delete(a);else{this._setSubscription(n,{...s,state:"unsubscribing"}),this._setSubscription(n,{...s,state:"unsubscribing"});try{await this._rpcWebSocket.call(f,[a])}catch(u){if(u instanceof Error&&console.error(`${f} error:`,u.message),!e())return;this._setSubscription(n,{...s,state:"subscribed"}),await this._updateSubscriptions();return}}this._setSubscription(n,{...s,state:"unsubscribed"}),await this._updateSubscriptions()})();break}}))}_handleServerNotification(t,e){const n=this._subscriptionCallbacksByServerSubscriptionId[t];n!==void 0&&n.forEach(s=>{try{s(...e)}catch(a){console.error(a)}})}_wsOnAccountNotification(t){const{result:e,subscription:n}=et(t,zl);this._handleServerNotification(n,[e.value,e.context])}_makeSubscription(t,e){const n=this._nextClientSubscriptionId++,s=Ha([t.method,e]),a=this._subscriptionsByHash[s];return a===void 0?this._subscriptionsByHash[s]={...t,args:e,callbacks:new Set([t.callback]),state:"pending"}:a.callbacks.add(t.callback),this._subscriptionHashByClientSubscriptionId[n]=s,this._subscriptionDisposeFunctionsByClientSubscriptionId[n]=async()=>{delete this._subscriptionDisposeFunctionsByClientSubscriptionId[n],delete this._subscriptionHashByClientSubscriptionId[n];const f=this._subscriptionsByHash[s];Lt(f!==void 0,`Could not find a \`Subscription\` when tearing down client subscription #${n}`),f.callbacks.delete(t.callback),await this._updateSubscriptions()},this._updateSubscriptions(),n}onAccountChange(t,e,n){const s=this._buildArgs([t.toBase58()],n||this._commitment||"finalized","base64");return this._makeSubscription({callback:e,method:"accountSubscribe",unsubscribeMethod:"accountUnsubscribe"},s)}async removeAccountChangeListener(t){await this._unsubscribeClientSubscription(t,"account change")}_wsOnProgramAccountNotification(t){const{result:e,subscription:n}=et(t,$l);this._handleServerNotification(n,[{accountId:e.value.pubkey,accountInfo:e.value.account},e.context])}onProgramAccountChange(t,e,n,s){const a=this._buildArgs([t.toBase58()],n||this._commitment||"finalized","base64",s?{filters:s}:void 0);return this._makeSubscription({callback:e,method:"programSubscribe",unsubscribeMethod:"programUnsubscribe"},a)}async removeProgramAccountChangeListener(t){await this._unsubscribeClientSubscription(t,"program account change")}onLogs(t,e,n){const s=this._buildArgs([typeof t=="object"?{mentions:[t.toString()]}:t],n||this._commitment||"finalized");return this._makeSubscription({callback:e,method:"logsSubscribe",unsubscribeMethod:"logsUnsubscribe"},s)}async removeOnLogsListener(t){await this._unsubscribeClientSubscription(t,"logs")}_wsOnLogsNotification(t){const{result:e,subscription:n}=et(t,wd);this._handleServerNotification(n,[e.value,e.context])}_wsOnSlotNotification(t){const{result:e,subscription:n}=et(t,Kl);this._handleServerNotification(n,[e])}onSlotChange(t){return this._makeSubscription({callback:t,method:"slotSubscribe",unsubscribeMethod:"slotUnsubscribe"},[])}async removeSlotChangeListener(t){await this._unsubscribeClientSubscription(t,"slot change")}_wsOnSlotUpdatesNotification(t){const{result:e,subscription:n}=et(t,Hl);this._handleServerNotification(n,[e])}onSlotUpdate(t){return this._makeSubscription({callback:t,method:"slotsUpdatesSubscribe",unsubscribeMethod:"slotsUpdatesUnsubscribe"},[])}async removeSlotUpdateListener(t){await this._unsubscribeClientSubscription(t,"slot update")}async _unsubscribeClientSubscription(t,e){const n=this._subscriptionDisposeFunctionsByClientSubscriptionId[t];n?await n():console.warn(`Ignored unsubscribe request because an active subscription with id \`${t}\` for '${e}' events could not be found.`)}_buildArgs(t,e,n,s){const a=e||this._commitment;if(a||n||s){let f={};n&&(f.encoding=n),a&&(f.commitment=a),s&&(f=Object.assign(f,s)),t.push(f)}return t}_buildArgsAtLeastConfirmed(t,e,n,s){const a=e||this._commitment;if(a&&!["confirmed","finalized"].includes(a))throw new Error("Using Connection with default commitment: `"+this._commitment+"`, but method requires at least `confirmed`");return this._buildArgs(t,e,n,s)}_wsOnSignatureNotification(t){const{result:e,subscription:n}=et(t,Vl);e.value!=="receivedSignature"&&this._subscriptionsAutoDisposedByRpc.add(n),this._handleServerNotification(n,e.value==="receivedSignature"?[{type:"received"},e.context]:[{type:"status",result:e.value},e.context])}onSignature(t,e,n){const s=this._buildArgs([t],n||this._commitment||"finalized"),a=this._makeSubscription({callback:(f,u)=>{if(f.type==="status"){e(f.result,u);try{this.removeSignatureListener(a)}catch{}}},method:"signatureSubscribe",unsubscribeMethod:"signatureUnsubscribe"},s);return a}onSignatureWithOptions(t,e,n){const{commitment:s,...a}={...n,commitment:n&&n.commitment||this._commitment||"finalized"},f=this._buildArgs([t],s,void 0,a),u=this._makeSubscription({callback:(p,w)=>{e(p,w);try{this.removeSignatureListener(u)}catch{}},method:"signatureSubscribe",unsubscribeMethod:"signatureUnsubscribe"},f);return u}async removeSignatureListener(t){await this._unsubscribeClientSubscription(t,"signature result")}_wsOnRootNotification(t){const{result:e,subscription:n}=et(t,jl);this._handleServerNotification(n,[e])}onRootChange(t){return this._makeSubscription({callback:t,method:"rootSubscribe",unsubscribeMethod:"rootUnsubscribe"},[])}async removeRootChangeListener(t){await this._unsubscribeClientSubscription(t,"root change")}}class cn{constructor(t){this._keypair=void 0,this._keypair=t??La()}static generate(){return new cn(La())}static fromSecretKey(t,e){if(t.byteLength!==64)throw new Error("bad secret key size");const n=t.slice(32,64);if(!e||!e.skipValidation){const s=t.slice(0,32),a=Xn(s);for(let f=0;f<32;f++)if(n[f]!==a[f])throw new Error("provided secretKey is invalid")}return new cn({publicKey:n,secretKey:t})}static fromSeed(t){const e=Xn(t),n=new Uint8Array(64);return n.set(t),n.set(e,32),new cn({publicKey:e,secretKey:n})}get publicKey(){return new tt(this._keypair.publicKey)}get secretKey(){return new Uint8Array(this._keypair.secretKey)}}const mr=Object.freeze({CreateLookupTable:{index:0,layout:ct([at("instruction"),sn("recentSlot"),Ct("bumpSeed")])},FreezeLookupTable:{index:1,layout:ct([at("instruction")])},ExtendLookupTable:{index:2,layout:ct([at("instruction"),sn(),Ae(Bt(),Sr(at(),-8),"addresses")])},DeactivateLookupTable:{index:3,layout:ct([at("instruction")])},CloseLookupTable:{index:4,layout:ct([at("instruction")])}});class kd{constructor(){}static decodeInstructionType(t){this.checkProgramId(t.programId);const n=at("instruction").decode(t.data);let s;for(const[a,f]of Object.entries(mr))if(f.index==n){s=a;break}if(!s)throw new Error("Invalid Instruction. Should be a LookupTable Instruction");return s}static decodeCreateLookupTable(t){this.checkProgramId(t.programId),this.checkKeysLength(t.keys,4);const{recentSlot:e}=zt(mr.CreateLookupTable,t.data);return{authority:t.keys[1].pubkey,payer:t.keys[2].pubkey,recentSlot:Number(e)}}static decodeExtendLookupTable(t){if(this.checkProgramId(t.programId),t.keys.length<2)throw new Error(`invalid instruction; found ${t.keys.length} keys, expected at least 2`);const{addresses:e}=zt(mr.ExtendLookupTable,t.data);return{lookupTable:t.keys[0].pubkey,authority:t.keys[1].pubkey,payer:t.keys.length>2?t.keys[2].pubkey:void 0,addresses:e.map(n=>new tt(n))}}static decodeCloseLookupTable(t){return this.checkProgramId(t.programId),this.checkKeysLength(t.keys,3),{lookupTable:t.keys[0].pubkey,authority:t.keys[1].pubkey,recipient:t.keys[2].pubkey}}static decodeFreezeLookupTable(t){return this.checkProgramId(t.programId),this.checkKeysLength(t.keys,2),{lookupTable:t.keys[0].pubkey,authority:t.keys[1].pubkey}}static decodeDeactivateLookupTable(t){return this.checkProgramId(t.programId),this.checkKeysLength(t.keys,2),{lookupTable:t.keys[0].pubkey,authority:t.keys[1].pubkey}}static checkProgramId(t){if(!t.equals(Bo.programId))throw new Error("invalid instruction; programId is not AddressLookupTable Program")}static checkKeysLength(t,e){if(t.length<e)throw new Error(`invalid instruction; found ${t.length} keys, expected at least ${e}`)}}class Bo{constructor(){}static createLookupTable(t){const[e,n]=tt.findProgramAddressSync([t.authority.toBuffer(),fa(BigInt(t.recentSlot),8)],this.programId),s=mr.CreateLookupTable,a=Mt(s,{recentSlot:BigInt(t.recentSlot),bumpSeed:n}),f=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:t.authority,isSigner:!0,isWritable:!1},{pubkey:t.payer,isSigner:!0,isWritable:!0},{pubkey:Ee.programId,isSigner:!1,isWritable:!1}];return[new Ht({programId:this.programId,keys:f,data:a}),e]}static freezeLookupTable(t){const e=mr.FreezeLookupTable,n=Mt(e),s=[{pubkey:t.lookupTable,isSigner:!1,isWritable:!0},{pubkey:t.authority,isSigner:!0,isWritable:!1}];return new Ht({programId:this.programId,keys:s,data:n})}static extendLookupTable(t){const e=mr.ExtendLookupTable,n=Mt(e,{addresses:t.addresses.map(a=>a.toBytes())}),s=[{pubkey:t.lookupTable,isSigner:!1,isWritable:!0},{pubkey:t.authority,isSigner:!0,isWritable:!1}];return t.payer&&s.push({pubkey:t.payer,isSigner:!0,isWritable:!0},{pubkey:Ee.programId,isSigner:!1,isWritable:!1}),new Ht({programId:this.programId,keys:s,data:n})}static deactivateLookupTable(t){const e=mr.DeactivateLookupTable,n=Mt(e),s=[{pubkey:t.lookupTable,isSigner:!1,isWritable:!0},{pubkey:t.authority,isSigner:!0,isWritable:!1}];return new Ht({programId:this.programId,keys:s,data:n})}static closeLookupTable(t){const e=mr.CloseLookupTable,n=Mt(e),s=[{pubkey:t.lookupTable,isSigner:!1,isWritable:!0},{pubkey:t.authority,isSigner:!0,isWritable:!1},{pubkey:t.recipient,isSigner:!1,isWritable:!0}];return new Ht({programId:this.programId,keys:s,data:n})}}Bo.programId=new tt("AddressLookupTab1e1111111111111111111111111");class Ed{constructor(){}static decodeInstructionType(t){this.checkProgramId(t.programId);const n=Ct("instruction").decode(t.data);let s;for(const[a,f]of Object.entries(sr))if(f.index==n){s=a;break}if(!s)throw new Error("Instruction type incorrect; not a ComputeBudgetInstruction");return s}static decodeRequestUnits(t){this.checkProgramId(t.programId);const{units:e,additionalFee:n}=zt(sr.RequestUnits,t.data);return{units:e,additionalFee:n}}static decodeRequestHeapFrame(t){this.checkProgramId(t.programId);const{bytes:e}=zt(sr.RequestHeapFrame,t.data);return{bytes:e}}static decodeSetComputeUnitLimit(t){this.checkProgramId(t.programId);const{units:e}=zt(sr.SetComputeUnitLimit,t.data);return{units:e}}static decodeSetComputeUnitPrice(t){this.checkProgramId(t.programId);const{microLamports:e}=zt(sr.SetComputeUnitPrice,t.data);return{microLamports:e}}static checkProgramId(t){if(!t.equals(Ao.programId))throw new Error("invalid instruction; programId is not ComputeBudgetProgram")}}const sr=Object.freeze({RequestUnits:{index:0,layout:ct([Ct("instruction"),at("units"),at("additionalFee")])},RequestHeapFrame:{index:1,layout:ct([Ct("instruction"),at("bytes")])},SetComputeUnitLimit:{index:2,layout:ct([Ct("instruction"),at("units")])},SetComputeUnitPrice:{index:3,layout:ct([Ct("instruction"),sn("microLamports")])}});class Ao{constructor(){}static requestUnits(t){const e=sr.RequestUnits,n=Mt(e,t);return new Ht({keys:[],programId:this.programId,data:n})}static requestHeapFrame(t){const e=sr.RequestHeapFrame,n=Mt(e,t);return new Ht({keys:[],programId:this.programId,data:n})}static setComputeUnitLimit(t){const e=sr.SetComputeUnitLimit,n=Mt(e,t);return new Ht({keys:[],programId:this.programId,data:n})}static setComputeUnitPrice(t){const e=sr.SetComputeUnitPrice,n=Mt(e,{microLamports:BigInt(t.microLamports)});return new Ht({keys:[],programId:this.programId,data:n})}}Ao.programId=new tt("ComputeBudget111111111111111111111111111111");const cc=64,uc=32,fc=64,hc=ct([Ct("numSignatures"),Ct("padding"),qe("signatureOffset"),qe("signatureInstructionIndex"),qe("publicKeyOffset"),qe("publicKeyInstructionIndex"),qe("messageDataOffset"),qe("messageDataSize"),qe("messageInstructionIndex")]);class ci{constructor(){}static createInstructionWithPublicKey(t){const{publicKey:e,message:n,signature:s,instructionIndex:a}=t;Lt(e.length===uc,`Public Key must be ${uc} bytes but received ${e.length} bytes`),Lt(s.length===fc,`Signature must be ${fc} bytes but received ${s.length} bytes`);const f=hc.span,u=f+e.length,p=u+s.length,w=1,E=dt.Buffer.alloc(p+n.length),I=a??65535;return hc.encode({numSignatures:w,padding:0,signatureOffset:u,signatureInstructionIndex:I,publicKeyOffset:f,publicKeyInstructionIndex:I,messageDataOffset:p,messageDataSize:n.length,messageInstructionIndex:I},E),E.fill(e,f),E.fill(s,u),E.fill(n,p),new Ht({keys:[],programId:ci.programId,data:E})}static createInstructionWithPrivateKey(t){const{privateKey:e,message:n,instructionIndex:s}=t;Lt(e.length===cc,`Private key must be ${cc} bytes but received ${e.length} bytes`);try{const a=cn.fromSecretKey(e),f=a.publicKey.toBytes(),u=oo(n,a.secretKey);return this.createInstructionWithPublicKey({publicKey:f,message:n,signature:u,instructionIndex:s})}catch(a){throw new Error(`Error creating instruction; ${a}`)}}}ci.programId=new tt("Ed25519SigVerify111111111111111111111111111");const Id=(o,t)=>{const e=Jn.sign(o,t);return[e.toCompactRawBytes(),e.recovery]};Jn.utils.isValidPrivateKey;const Sd=Jn.getPublicKey,lc=32,vo=20,dc=64,Bd=11,_o=ct([Ct("numSignatures"),qe("signatureOffset"),Ct("signatureInstructionIndex"),qe("ethAddressOffset"),Ct("ethAddressInstructionIndex"),qe("messageDataOffset"),qe("messageDataSize"),Ct("messageInstructionIndex"),jt(20,"ethAddress"),jt(64,"signature"),Ct("recoveryId")]);class un{constructor(){}static publicKeyToEthAddress(t){Lt(t.length===dc,`Public key must be ${dc} bytes but received ${t.length} bytes`);try{return dt.Buffer.from(_a(kt(t))).slice(-vo)}catch(e){throw new Error(`Error constructing Ethereum address: ${e}`)}}static createInstructionWithPublicKey(t){const{publicKey:e,message:n,signature:s,recoveryId:a,instructionIndex:f}=t;return un.createInstructionWithEthAddress({ethAddress:un.publicKeyToEthAddress(e),message:n,signature:s,recoveryId:a,instructionIndex:f})}static createInstructionWithEthAddress(t){const{ethAddress:e,message:n,signature:s,recoveryId:a,instructionIndex:f=0}=t;let u;typeof e=="string"?e.startsWith("0x")?u=dt.Buffer.from(e.substr(2),"hex"):u=dt.Buffer.from(e,"hex"):u=e,Lt(u.length===vo,`Address must be ${vo} bytes but received ${u.length} bytes`);const p=1+Bd,w=p,E=p+u.length,I=E+s.length+1,M=1,T=dt.Buffer.alloc(_o.span+n.length);return _o.encode({numSignatures:M,signatureOffset:E,signatureInstructionIndex:f,ethAddressOffset:w,ethAddressInstructionIndex:f,messageDataOffset:I,messageDataSize:n.length,messageInstructionIndex:f,signature:kt(s),ethAddress:kt(u),recoveryId:a},T),T.fill(kt(n),_o.span),new Ht({keys:[],programId:un.programId,data:T})}static createInstructionWithPrivateKey(t){const{privateKey:e,message:n,instructionIndex:s}=t;Lt(e.length===lc,`Private key must be ${lc} bytes but received ${e.length} bytes`);try{const a=kt(e),f=Sd(a,!1).slice(1),u=dt.Buffer.from(_a(kt(n))),[p,w]=Id(u,a);return this.createInstructionWithPublicKey({publicKey:f,message:n,signature:p,recoveryId:w,instructionIndex:s})}catch(a){throw new Error(`Error creating instruction; ${a}`)}}}un.programId=new tt("KeccakSecp256k11111111111111111111111111111");var pc;const gc=new tt("StakeConfig11111111111111111111111111111111");class yc{constructor(t,e){this.staker=void 0,this.withdrawer=void 0,this.staker=t,this.withdrawer=e}}class Tn{constructor(t,e,n){this.unixTimestamp=void 0,this.epoch=void 0,this.custodian=void 0,this.unixTimestamp=t,this.epoch=e,this.custodian=n}}pc=Tn,Tn.default=new pc(0,0,tt.default);class Ad{constructor(){}static decodeInstructionType(t){this.checkProgramId(t.programId);const n=at("instruction").decode(t.data);let s;for(const[a,f]of Object.entries(Ie))if(f.index==n){s=a;break}if(!s)throw new Error("Instruction type incorrect; not a StakeInstruction");return s}static decodeInitialize(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,2);const{authorized:e,lockup:n}=zt(Ie.Initialize,t.data);return{stakePubkey:t.keys[0].pubkey,authorized:new yc(new tt(e.staker),new tt(e.withdrawer)),lockup:new Tn(n.unixTimestamp,n.epoch,new tt(n.custodian))}}static decodeDelegate(t){return this.checkProgramId(t.programId),this.checkKeyLength(t.keys,6),zt(Ie.Delegate,t.data),{stakePubkey:t.keys[0].pubkey,votePubkey:t.keys[1].pubkey,authorizedPubkey:t.keys[5].pubkey}}static decodeAuthorize(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{newAuthorized:e,stakeAuthorizationType:n}=zt(Ie.Authorize,t.data),s={stakePubkey:t.keys[0].pubkey,authorizedPubkey:t.keys[2].pubkey,newAuthorizedPubkey:new tt(e),stakeAuthorizationType:{index:n}};return t.keys.length>3&&(s.custodianPubkey=t.keys[3].pubkey),s}static decodeAuthorizeWithSeed(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,2);const{newAuthorized:e,stakeAuthorizationType:n,authoritySeed:s,authorityOwner:a}=zt(Ie.AuthorizeWithSeed,t.data),f={stakePubkey:t.keys[0].pubkey,authorityBase:t.keys[1].pubkey,authoritySeed:s,authorityOwner:new tt(a),newAuthorizedPubkey:new tt(e),stakeAuthorizationType:{index:n}};return t.keys.length>3&&(f.custodianPubkey=t.keys[3].pubkey),f}static decodeSplit(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{lamports:e}=zt(Ie.Split,t.data);return{stakePubkey:t.keys[0].pubkey,splitStakePubkey:t.keys[1].pubkey,authorizedPubkey:t.keys[2].pubkey,lamports:e}}static decodeMerge(t){return this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3),zt(Ie.Merge,t.data),{stakePubkey:t.keys[0].pubkey,sourceStakePubKey:t.keys[1].pubkey,authorizedPubkey:t.keys[4].pubkey}}static decodeWithdraw(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,5);const{lamports:e}=zt(Ie.Withdraw,t.data),n={stakePubkey:t.keys[0].pubkey,toPubkey:t.keys[1].pubkey,authorizedPubkey:t.keys[4].pubkey,lamports:e};return t.keys.length>5&&(n.custodianPubkey=t.keys[5].pubkey),n}static decodeDeactivate(t){return this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3),zt(Ie.Deactivate,t.data),{stakePubkey:t.keys[0].pubkey,authorizedPubkey:t.keys[2].pubkey}}static checkProgramId(t){if(!t.equals(ui.programId))throw new Error("invalid instruction; programId is not StakeProgram")}static checkKeyLength(t,e){if(t.length<e)throw new Error(`invalid instruction; found ${t.length} keys, expected at least ${e}`)}}const Ie=Object.freeze({Initialize:{index:0,layout:ct([at("instruction"),Ph(),Ch()])},Authorize:{index:1,layout:ct([at("instruction"),Bt("newAuthorized"),at("stakeAuthorizationType")])},Delegate:{index:2,layout:ct([at("instruction")])},Split:{index:3,layout:ct([at("instruction"),De("lamports")])},Withdraw:{index:4,layout:ct([at("instruction"),De("lamports")])},Deactivate:{index:5,layout:ct([at("instruction")])},Merge:{index:7,layout:ct([at("instruction")])},AuthorizeWithSeed:{index:8,layout:ct([at("instruction"),Bt("newAuthorized"),at("stakeAuthorizationType"),Nr("authoritySeed"),Bt("authorityOwner")])}}),vd=Object.freeze({Staker:{index:0},Withdrawer:{index:1}});class ui{constructor(){}static initialize(t){const{stakePubkey:e,authorized:n,lockup:s}=t,a=s||Tn.default,f=Ie.Initialize,u=Mt(f,{authorized:{staker:kt(n.staker.toBuffer()),withdrawer:kt(n.withdrawer.toBuffer())},lockup:{unixTimestamp:a.unixTimestamp,epoch:a.epoch,custodian:kt(a.custodian.toBuffer())}}),p={keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:on,isSigner:!1,isWritable:!1}],programId:this.programId,data:u};return new Ht(p)}static createAccountWithSeed(t){const e=new Ot;e.add(Ee.createAccountWithSeed({fromPubkey:t.fromPubkey,newAccountPubkey:t.stakePubkey,basePubkey:t.basePubkey,seed:t.seed,lamports:t.lamports,space:this.space,programId:this.programId}));const{stakePubkey:n,authorized:s,lockup:a}=t;return e.add(this.initialize({stakePubkey:n,authorized:s,lockup:a}))}static createAccount(t){const e=new Ot;e.add(Ee.createAccount({fromPubkey:t.fromPubkey,newAccountPubkey:t.stakePubkey,lamports:t.lamports,space:this.space,programId:this.programId}));const{stakePubkey:n,authorized:s,lockup:a}=t;return e.add(this.initialize({stakePubkey:n,authorized:s,lockup:a}))}static delegate(t){const{stakePubkey:e,authorizedPubkey:n,votePubkey:s}=t,a=Ie.Delegate,f=Mt(a);return new Ot().add({keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!1,isWritable:!1},{pubkey:or,isSigner:!1,isWritable:!1},{pubkey:ri,isSigner:!1,isWritable:!1},{pubkey:gc,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:f})}static authorize(t){const{stakePubkey:e,authorizedPubkey:n,newAuthorizedPubkey:s,stakeAuthorizationType:a,custodianPubkey:f}=t,u=Ie.Authorize,p=Mt(u,{newAuthorized:kt(s.toBuffer()),stakeAuthorizationType:a.index}),w=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:or,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1}];return f&&w.push({pubkey:f,isSigner:!0,isWritable:!1}),new Ot().add({keys:w,programId:this.programId,data:p})}static authorizeWithSeed(t){const{stakePubkey:e,authorityBase:n,authoritySeed:s,authorityOwner:a,newAuthorizedPubkey:f,stakeAuthorizationType:u,custodianPubkey:p}=t,w=Ie.AuthorizeWithSeed,E=Mt(w,{newAuthorized:kt(f.toBuffer()),stakeAuthorizationType:u.index,authoritySeed:s,authorityOwner:kt(a.toBuffer())}),I=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1},{pubkey:or,isSigner:!1,isWritable:!1}];return p&&I.push({pubkey:p,isSigner:!0,isWritable:!1}),new Ot().add({keys:I,programId:this.programId,data:E})}static splitInstruction(t){const{stakePubkey:e,authorizedPubkey:n,splitStakePubkey:s,lamports:a}=t,f=Ie.Split,u=Mt(f,{lamports:a});return new Ht({keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:u})}static split(t,e){const n=new Ot;return n.add(Ee.createAccount({fromPubkey:t.authorizedPubkey,newAccountPubkey:t.splitStakePubkey,lamports:e,space:this.space,programId:this.programId})),n.add(this.splitInstruction(t))}static splitWithSeed(t,e){const{stakePubkey:n,authorizedPubkey:s,splitStakePubkey:a,basePubkey:f,seed:u,lamports:p}=t,w=new Ot;return w.add(Ee.allocate({accountPubkey:a,basePubkey:f,seed:u,space:this.space,programId:this.programId})),e&&e>0&&w.add(Ee.transfer({fromPubkey:t.authorizedPubkey,toPubkey:a,lamports:e})),w.add(this.splitInstruction({stakePubkey:n,authorizedPubkey:s,splitStakePubkey:a,lamports:p}))}static merge(t){const{stakePubkey:e,sourceStakePubKey:n,authorizedPubkey:s}=t,a=Ie.Merge,f=Mt(a);return new Ot().add({keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!1,isWritable:!0},{pubkey:or,isSigner:!1,isWritable:!1},{pubkey:ri,isSigner:!1,isWritable:!1},{pubkey:s,isSigner:!0,isWritable:!1}],programId:this.programId,data:f})}static withdraw(t){const{stakePubkey:e,authorizedPubkey:n,toPubkey:s,lamports:a,custodianPubkey:f}=t,u=Ie.Withdraw,p=Mt(u,{lamports:a}),w=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!1,isWritable:!0},{pubkey:or,isSigner:!1,isWritable:!1},{pubkey:ri,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}];return f&&w.push({pubkey:f,isSigner:!0,isWritable:!1}),new Ot().add({keys:w,programId:this.programId,data:p})}static deactivate(t){const{stakePubkey:e,authorizedPubkey:n}=t,s=Ie.Deactivate,a=Mt(s);return new Ot().add({keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:or,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:a})}}ui.programId=new tt("Stake11111111111111111111111111111111111111"),ui.space=200;class mc{constructor(t,e,n,s){this.nodePubkey=void 0,this.authorizedVoter=void 0,this.authorizedWithdrawer=void 0,this.commission=void 0,this.nodePubkey=t,this.authorizedVoter=e,this.authorizedWithdrawer=n,this.commission=s}}class _d{constructor(){}static decodeInstructionType(t){this.checkProgramId(t.programId);const n=at("instruction").decode(t.data);let s;for(const[a,f]of Object.entries(ar))if(f.index==n){s=a;break}if(!s)throw new Error("Instruction type incorrect; not a VoteInstruction");return s}static decodeInitializeAccount(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,4);const{voteInit:e}=zt(ar.InitializeAccount,t.data);return{votePubkey:t.keys[0].pubkey,nodePubkey:t.keys[3].pubkey,voteInit:new mc(new tt(e.nodePubkey),new tt(e.authorizedVoter),new tt(e.authorizedWithdrawer),e.commission)}}static decodeAuthorize(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{newAuthorized:e,voteAuthorizationType:n}=zt(ar.Authorize,t.data);return{votePubkey:t.keys[0].pubkey,authorizedPubkey:t.keys[2].pubkey,newAuthorizedPubkey:new tt(e),voteAuthorizationType:{index:n}}}static decodeAuthorizeWithSeed(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{voteAuthorizeWithSeedArgs:{currentAuthorityDerivedKeyOwnerPubkey:e,currentAuthorityDerivedKeySeed:n,newAuthorized:s,voteAuthorizationType:a}}=zt(ar.AuthorizeWithSeed,t.data);return{currentAuthorityDerivedKeyBasePubkey:t.keys[2].pubkey,currentAuthorityDerivedKeyOwnerPubkey:new tt(e),currentAuthorityDerivedKeySeed:n,newAuthorizedPubkey:new tt(s),voteAuthorizationType:{index:a},votePubkey:t.keys[0].pubkey}}static decodeWithdraw(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{lamports:e}=zt(ar.Withdraw,t.data);return{votePubkey:t.keys[0].pubkey,authorizedWithdrawerPubkey:t.keys[2].pubkey,lamports:e,toPubkey:t.keys[1].pubkey}}static checkProgramId(t){if(!t.equals(fn.programId))throw new Error("invalid instruction; programId is not VoteProgram")}static checkKeyLength(t,e){if(t.length<e)throw new Error(`invalid instruction; found ${t.length} keys, expected at least ${e}`)}}const ar=Object.freeze({InitializeAccount:{index:0,layout:ct([at("instruction"),Uh()])},Authorize:{index:1,layout:ct([at("instruction"),Bt("newAuthorized"),at("voteAuthorizationType")])},Withdraw:{index:3,layout:ct([at("instruction"),De("lamports")])},UpdateValidatorIdentity:{index:4,layout:ct([at("instruction")])},AuthorizeWithSeed:{index:10,layout:ct([at("instruction"),Lh()])}}),Rd=Object.freeze({Voter:{index:0},Withdrawer:{index:1}});class fn{constructor(){}static initializeAccount(t){const{votePubkey:e,nodePubkey:n,voteInit:s}=t,a=ar.InitializeAccount,f=Mt(a,{voteInit:{nodePubkey:kt(s.nodePubkey.toBuffer()),authorizedVoter:kt(s.authorizedVoter.toBuffer()),authorizedWithdrawer:kt(s.authorizedWithdrawer.toBuffer()),commission:s.commission}}),u={keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:on,isSigner:!1,isWritable:!1},{pubkey:or,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:f};return new Ht(u)}static createAccount(t){const e=new Ot;return e.add(Ee.createAccount({fromPubkey:t.fromPubkey,newAccountPubkey:t.votePubkey,lamports:t.lamports,space:this.space,programId:this.programId})),e.add(this.initializeAccount({votePubkey:t.votePubkey,nodePubkey:t.voteInit.nodePubkey,voteInit:t.voteInit}))}static authorize(t){const{votePubkey:e,authorizedPubkey:n,newAuthorizedPubkey:s,voteAuthorizationType:a}=t,f=ar.Authorize,u=Mt(f,{newAuthorized:kt(s.toBuffer()),voteAuthorizationType:a.index}),p=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:or,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}];return new Ot().add({keys:p,programId:this.programId,data:u})}static authorizeWithSeed(t){const{currentAuthorityDerivedKeyBasePubkey:e,currentAuthorityDerivedKeyOwnerPubkey:n,currentAuthorityDerivedKeySeed:s,newAuthorizedPubkey:a,voteAuthorizationType:f,votePubkey:u}=t,p=ar.AuthorizeWithSeed,w=Mt(p,{voteAuthorizeWithSeedArgs:{currentAuthorityDerivedKeyOwnerPubkey:kt(n.toBuffer()),currentAuthorityDerivedKeySeed:s,newAuthorized:kt(a.toBuffer()),voteAuthorizationType:f.index}}),E=[{pubkey:u,isSigner:!1,isWritable:!0},{pubkey:or,isSigner:!1,isWritable:!1},{pubkey:e,isSigner:!0,isWritable:!1}];return new Ot().add({keys:E,programId:this.programId,data:w})}static withdraw(t){const{votePubkey:e,authorizedWithdrawerPubkey:n,lamports:s,toPubkey:a}=t,f=ar.Withdraw,u=Mt(f,{lamports:s}),p=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:a,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1}];return new Ot().add({keys:p,programId:this.programId,data:u})}static safeWithdraw(t,e,n){if(t.lamports>e-n)throw new Error("Withdraw will leave vote account with insufficient funds.");return fn.withdraw(t)}static updateValidatorIdentity(t){const{votePubkey:e,authorizedWithdrawerPubkey:n,nodePubkey:s}=t,a=ar.UpdateValidatorIdentity,f=Mt(a),u=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!0,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}];return new Ot().add({keys:u,programId:this.programId,data:f})}}fn.programId=new tt("Vote111111111111111111111111111111111111111"),fn.space=3762;const wc=new tt("Va1idator1nfo111111111111111111111111111111"),Td=j({name:Q(),website:gt(Q()),details:gt(Q()),keybaseUsername:gt(Q())});class Ro{constructor(t,e){this.key=void 0,this.info=void 0,this.key=t,this.info=e}static fromConfigData(t){let e=[...t];if(Le(e)!==2)return null;const s=[];for(let a=0;a<2;a++){const f=new tt(Fe(e,0,nr)),u=ir(e)===1;s.push({publicKey:f,isSigner:u})}if(s[0].publicKey.equals(wc)&&s[1].isSigner){const a=Nr().decode(dt.Buffer.from(e)),f=JSON.parse(a);return la(f,Td),new Ro(s[1].publicKey,f)}return null}}const Md=new tt("Vote111111111111111111111111111111111111111"),Pd=ct([Bt("nodePubkey"),Bt("authorizedWithdrawer"),Ct("commission"),Be(),Ae(ct([Be("slot"),at("confirmationCount")]),Sr(at(),-8),"votes"),Ct("rootSlotValid"),Be("rootSlot"),Be(),Ae(ct([Be("epoch"),Bt("authorizedVoter")]),Sr(at(),-8),"authorizedVoters"),ct([Ae(ct([Bt("authorizedPubkey"),Be("epochOfLastAuthorizedSwitch"),Be("targetEpoch")]),32,"buf"),Be("idx"),Ct("isEmpty")],"priorVoters"),Be(),Ae(ct([Be("epoch"),Be("credits"),Be("prevCredits")]),Sr(at(),-8),"epochCredits"),ct([Be("slot"),Be("timestamp")],"lastTimestamp")]);class To{constructor(t){this.nodePubkey=void 0,this.authorizedWithdrawer=void 0,this.commission=void 0,this.rootSlot=void 0,this.votes=void 0,this.authorizedVoters=void 0,this.priorVoters=void 0,this.epochCredits=void 0,this.lastTimestamp=void 0,this.nodePubkey=t.nodePubkey,this.authorizedWithdrawer=t.authorizedWithdrawer,this.commission=t.commission,this.rootSlot=t.rootSlot,this.votes=t.votes,this.authorizedVoters=t.authorizedVoters,this.priorVoters=t.priorVoters,this.epochCredits=t.epochCredits,this.lastTimestamp=t.lastTimestamp}static fromAccountData(t){const n=Pd.decode(kt(t),4);let s=n.rootSlot;return n.rootSlotValid||(s=null),new To({nodePubkey:new tt(n.nodePubkey),authorizedWithdrawer:new tt(n.authorizedWithdrawer),commission:n.commission,votes:n.votes,rootSlot:s,authorizedVoters:n.authorizedVoters.map(Cd),priorVoters:Ud(n.priorVoters),epochCredits:n.epochCredits,lastTimestamp:n.lastTimestamp})}}function Cd({authorizedVoter:o,epoch:t}){return{epoch:t,authorizedVoter:new tt(o)}}function bc({authorizedPubkey:o,epochOfLastAuthorizedSwitch:t,targetEpoch:e}){return{authorizedPubkey:new tt(o),epochOfLastAuthorizedSwitch:t,targetEpoch:e}}function Ud({buf:o,idx:t,isEmpty:e}){return e?[]:[...o.slice(t+1).map(bc),...o.slice(0,t).map(bc)]}const xc={http:{devnet:"http://api.devnet.solana.com",testnet:"http://api.testnet.solana.com","mainnet-beta":"http://api.mainnet-beta.solana.com/"},https:{devnet:"https://api.devnet.solana.com",testnet:"https://api.testnet.solana.com","mainnet-beta":"https://api.mainnet-beta.solana.com/"}};function Ld(o,t){const e=t===!1?"http":"https";if(!o)return xc[e].devnet;const n=xc[e][o];if(!n)throw new Error(`Unknown ${e} cluster: ${o}`);return n}async function Fd(o,t,e,n){let s,a;e&&Object.prototype.hasOwnProperty.call(e,"lastValidBlockHeight")||e&&Object.prototype.hasOwnProperty.call(e,"nonceValue")?(s=e,a=n):a=e;const f=a&&{skipPreflight:a.skipPreflight,preflightCommitment:a.preflightCommitment||a.commitment,minContextSlot:a.minContextSlot},u=await o.sendRawTransaction(t,f),p=a&&a.commitment,E=(await(s?o.confirmTransaction(s,p):o.confirmTransaction(u,p))).value;if(E.err)throw u!=null?new An({action:f!=null&&f.skipPreflight?"send":"simulate",signature:u,transactionMessage:`Status: (${JSON.stringify(E)})`}):new Error(`Raw transaction ${u} failed (${JSON.stringify(E)})`);return u}const fi=Object.freeze(Object.defineProperty({__proto__:null,Account:Rh,AddressLookupTableAccount:yo,AddressLookupTableInstruction:kd,AddressLookupTableProgram:Bo,Authorized:yc,BLOCKHASH_CACHE_TIMEOUT_MS:Ya,BPF_LOADER_DEPRECATED_PROGRAM_ID:Th,BPF_LOADER_PROGRAM_ID:Vh,BpfLoader:jh,COMPUTE_BUDGET_INSTRUCTION_LAYOUTS:sr,ComputeBudgetInstruction:Ed,ComputeBudgetProgram:Ao,Connection:xd,Ed25519Program:ci,Enum:vh,EpochSchedule:Va,FeeCalculatorLayout:Ka,Keypair:cn,LAMPORTS_PER_SOL:1e9,LOOKUP_TABLE_INSTRUCTION_LAYOUTS:mr,Loader:$r,Lockup:Tn,MAX_SEED_LENGTH:Na,Message:Ze,MessageAccountKeys:Bn,MessageV0:zr,NONCE_ACCOUNT_LENGTH:po,NonceAccount:ni,PACKET_DATA_SIZE:Ar,PUBLIC_KEY_LENGTH:nr,PublicKey:tt,SIGNATURE_LENGTH_IN_BYTES:Sn,SOLANA_SCHEMA:In,STAKE_CONFIG_ID:gc,STAKE_INSTRUCTION_LAYOUTS:Ie,SYSTEM_INSTRUCTION_LAYOUTS:Vt,SYSVAR_CLOCK_PUBKEY:or,SYSVAR_EPOCH_SCHEDULE_PUBKEY:Oh,SYSVAR_INSTRUCTIONS_PUBKEY:Nh,SYSVAR_RECENT_BLOCKHASHES_PUBKEY:ei,SYSVAR_RENT_PUBKEY:on,SYSVAR_REWARDS_PUBKEY:zh,SYSVAR_SLOT_HASHES_PUBKEY:Dh,SYSVAR_SLOT_HISTORY_PUBKEY:$h,SYSVAR_STAKE_HISTORY_PUBKEY:ri,Secp256k1Program:un,SendTransactionError:An,SolanaJSONRPCError:ut,SolanaJSONRPCErrorCode:Wh,StakeAuthorizationLayout:vd,StakeInstruction:Ad,StakeProgram:ui,Struct:so,SystemInstruction:qh,SystemProgram:Ee,Transaction:Ot,TransactionExpiredBlockheightExceededError:ao,TransactionExpiredNonceInvalidError:nn,TransactionExpiredTimeoutError:co,TransactionInstruction:Ht,TransactionMessage:fo,TransactionStatus:yr,VALIDATOR_INFO_KEY:wc,VERSION_PREFIX_MASK:Qn,VOTE_PROGRAM_ID:Md,ValidatorInfo:Ro,VersionedMessage:uo,VersionedTransaction:ho,VoteAccount:To,VoteAuthorizationLayout:Rd,VoteInit:mc,VoteInstruction:_d,VoteProgram:fn,clusterApiUrl:Ld,sendAndConfirmRawTransaction:Fd,sendAndConfirmTransaction:lo},Symbol.toStringTag,{value:"Module"})),vr=ke;var Mo={exports:{}};Mo.exports,function(o){var t=function(){var e=String.fromCharCode,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",a={};function f(p,w){if(!a[p]){a[p]={};for(var E=0;E<p.length;E++)a[p][p.charAt(E)]=E}return a[p][w]}var u={compressToBase64:function(p){if(p==null)return"";var w=u._compress(p,6,function(E){return n.charAt(E)});switch(w.length%4){default:case 0:return w;case 1:return w+"===";case 2:return w+"==";case 3:return w+"="}},decompressFromBase64:function(p){return p==null?"":p==""?null:u._decompress(p.length,32,function(w){return f(n,p.charAt(w))})},compressToUTF16:function(p){return p==null?"":u._compress(p,15,function(w){return e(w+32)})+" "},decompressFromUTF16:function(p){return p==null?"":p==""?null:u._decompress(p.length,16384,function(w){return p.charCodeAt(w)-32})},compressToUint8Array:function(p){for(var w=u.compress(p),E=new Uint8Array(w.length*2),I=0,M=w.length;I<M;I++){var T=w.charCodeAt(I);E[I*2]=T>>>8,E[I*2+1]=T%256}return E},decompressFromUint8Array:function(p){if(p==null)return u.decompress(p);for(var w=new Array(p.length/2),E=0,I=w.length;E<I;E++)w[E]=p[E*2]*256+p[E*2+1];var M=[];return w.forEach(function(T){M.push(e(T))}),u.decompress(M.join(""))},compressToEncodedURIComponent:function(p){return p==null?"":u._compress(p,6,function(w){return s.charAt(w)})},decompressFromEncodedURIComponent:function(p){return p==null?"":p==""?null:(p=p.replace(/ /g,"+"),u._decompress(p.length,32,function(w){return f(s,p.charAt(w))}))},compress:function(p){return u._compress(p,16,function(w){return e(w)})},_compress:function(p,w,E){if(p==null)return"";var I,M,T={},U={},_="",C="",L="",$=2,N=3,H=2,D=[],F=0,W=0,q;for(q=0;q<p.length;q+=1)if(_=p.charAt(q),Object.prototype.hasOwnProperty.call(T,_)||(T[_]=N++,U[_]=!0),C=L+_,Object.prototype.hasOwnProperty.call(T,C))L=C;else{if(Object.prototype.hasOwnProperty.call(U,L)){if(L.charCodeAt(0)<256){for(I=0;I<H;I++)F=F<<1,W==w-1?(W=0,D.push(E(F)),F=0):W++;for(M=L.charCodeAt(0),I=0;I<8;I++)F=F<<1|M&1,W==w-1?(W=0,D.push(E(F)),F=0):W++,M=M>>1}else{for(M=1,I=0;I<H;I++)F=F<<1|M,W==w-1?(W=0,D.push(E(F)),F=0):W++,M=0;for(M=L.charCodeAt(0),I=0;I<16;I++)F=F<<1|M&1,W==w-1?(W=0,D.push(E(F)),F=0):W++,M=M>>1}$--,$==0&&($=Math.pow(2,H),H++),delete U[L]}else for(M=T[L],I=0;I<H;I++)F=F<<1|M&1,W==w-1?(W=0,D.push(E(F)),F=0):W++,M=M>>1;$--,$==0&&($=Math.pow(2,H),H++),T[C]=N++,L=String(_)}if(L!==""){if(Object.prototype.hasOwnProperty.call(U,L)){if(L.charCodeAt(0)<256){for(I=0;I<H;I++)F=F<<1,W==w-1?(W=0,D.push(E(F)),F=0):W++;for(M=L.charCodeAt(0),I=0;I<8;I++)F=F<<1|M&1,W==w-1?(W=0,D.push(E(F)),F=0):W++,M=M>>1}else{for(M=1,I=0;I<H;I++)F=F<<1|M,W==w-1?(W=0,D.push(E(F)),F=0):W++,M=0;for(M=L.charCodeAt(0),I=0;I<16;I++)F=F<<1|M&1,W==w-1?(W=0,D.push(E(F)),F=0):W++,M=M>>1}$--,$==0&&($=Math.pow(2,H),H++),delete U[L]}else for(M=T[L],I=0;I<H;I++)F=F<<1|M&1,W==w-1?(W=0,D.push(E(F)),F=0):W++,M=M>>1;$--,$==0&&($=Math.pow(2,H),H++)}for(M=2,I=0;I<H;I++)F=F<<1|M&1,W==w-1?(W=0,D.push(E(F)),F=0):W++,M=M>>1;for(;;)if(F=F<<1,W==w-1){D.push(E(F));break}else W++;return D.join("")},decompress:function(p){return p==null?"":p==""?null:u._decompress(p.length,32768,function(w){return p.charCodeAt(w)})},_decompress:function(p,w,E){var I=[],M=4,T=4,U=3,_="",C=[],L,$,N,H,D,F,W,q={val:E(0),position:w,index:1};for(L=0;L<3;L+=1)I[L]=L;for(N=0,D=Math.pow(2,2),F=1;F!=D;)H=q.val&q.position,q.position>>=1,q.position==0&&(q.position=w,q.val=E(q.index++)),N|=(H>0?1:0)*F,F<<=1;switch(N){case 0:for(N=0,D=Math.pow(2,8),F=1;F!=D;)H=q.val&q.position,q.position>>=1,q.position==0&&(q.position=w,q.val=E(q.index++)),N|=(H>0?1:0)*F,F<<=1;W=e(N);break;case 1:for(N=0,D=Math.pow(2,16),F=1;F!=D;)H=q.val&q.position,q.position>>=1,q.position==0&&(q.position=w,q.val=E(q.index++)),N|=(H>0?1:0)*F,F<<=1;W=e(N);break;case 2:return""}for(I[3]=W,$=W,C.push(W);;){if(q.index>p)return"";for(N=0,D=Math.pow(2,U),F=1;F!=D;)H=q.val&q.position,q.position>>=1,q.position==0&&(q.position=w,q.val=E(q.index++)),N|=(H>0?1:0)*F,F<<=1;switch(W=N){case 0:for(N=0,D=Math.pow(2,8),F=1;F!=D;)H=q.val&q.position,q.position>>=1,q.position==0&&(q.position=w,q.val=E(q.index++)),N|=(H>0?1:0)*F,F<<=1;I[T++]=e(N),W=T-1,M--;break;case 1:for(N=0,D=Math.pow(2,16),F=1;F!=D;)H=q.val&q.position,q.position>>=1,q.position==0&&(q.position=w,q.val=E(q.index++)),N|=(H>0?1:0)*F,F<<=1;I[T++]=e(N),W=T-1,M--;break;case 2:return C.join("")}if(M==0&&(M=Math.pow(2,U),U++),I[W])_=I[W];else if(W===T)_=$+$.charAt(0);else return null;C.push(_),I[T++]=$+_.charAt(0),M--,$=_,M==0&&(M=Math.pow(2,U),U++)}}};return u}();o!=null?o.exports=t:typeof angular<"u"&&angular!=null&&angular.module("LZString",[]).factory("LZString",function(){return t})}(Mo);var Od=Mo.exports;const cr=ln(Od);class ur{constructor(t){we(this,"env");we(this,"url");this.env=t??"prod",this.env==="prod"?this.url="https://api.coinflow.cash":this.env==="local"?this.url="http://localhost:5000":this.url=`https://api-${this.env}.coinflow.cash`}async getNSurePartnerId(t){return fetch(this.url+`/merchant/view/${t}`).then(e=>e.json()).then(e=>{var n;return((n=e.nSureSettings)==null?void 0:n.nSurePartnerId)||e.nSurePartnerId}).catch(e=>{console.error(e)})}async getCreditBalance(t,e,n){const s=await fetch(this.url+`/api/customer/balances/${e}`,{method:"GET",headers:{"x-coinflow-auth-wallet":t,"x-coinflow-auth-blockchain":n}}),{credits:a}=await s.json();return a}static getCoinflowBaseUrl(t){return!t||t==="prod"?"https://coinflow.cash":t==="local"?"http://localhost:3000":`https://${t}.coinflow.cash`}static getCoinflowApiUrl(t){return!t||t==="prod"?"https://api.coinflow.cash":t==="local"?"http://localhost:5000":`https://api-${t}.coinflow.cash`}static getCoinflowUrl({walletPubkey:t,route:e,routePrefix:n,env:s,amount:a,transaction:f,blockchain:u,webhookInfo:p,email:w,loaderBackground:E,handleHeightChange:I,bankAccountLinkRedirect:M,additionalWallets:T,nearDeposit:U,chargebackProtectionData:_,merchantCss:C,color:L,rent:$,lockDefaultToken:N,token:H,tokens:D,planCode:F,disableApplePay:W,disableGooglePay:q,customerInfo:At,settlementType:yt,lockAmount:ot,nativeSolToConvert:vt,theme:R,usePermit:l,transactionSigner:y,authOnly:k,deviceId:A,jwtToken:S,origins:B}){var d;const P=n?`/${n}/${u}`:`/${u}`,b=new URL(P+e,ur.getCoinflowBaseUrl(s));if(b.searchParams.append("pubkey",t),f&&b.searchParams.append("transaction",f),a&&b.searchParams.append("amount",a.toString()),p&&b.searchParams.append("webhookInfo",cr.compressToEncodedURIComponent(JSON.stringify(p))),R&&b.searchParams.append("theme",cr.compressToEncodedURIComponent(JSON.stringify(R))),At&&b.searchParams.append("customerInfo",cr.compressToEncodedURIComponent(JSON.stringify(At))),w&&b.searchParams.append("email",w),H&&b.searchParams.append("token",H.toString()),D&&b.searchParams.append("tokens",D.toString()),E&&b.searchParams.append("loaderBackground",E),I&&b.searchParams.append("useHeightChange","true"),M&&b.searchParams.append("bankAccountLinkRedirect",M),T&&b.searchParams.append("additionalWallets",cr.compressToEncodedURIComponent(JSON.stringify(T))),U&&b.searchParams.append("nearDeposit",U),_&&b.searchParams.append("chargebackProtectionData",cr.compressToEncodedURIComponent(JSON.stringify(_))),A)b.searchParams.append("deviceId",A);else if(typeof window<"u"){const v=(d=window==null?void 0:window.nSureSDK)==null?void 0:d.getDeviceId();v&&b.searchParams.append("deviceId",v)}return C&&b.searchParams.append("merchantCss",C),L&&b.searchParams.append("color",L),$&&b.searchParams.append("rent",$.lamports.toString()),vt&&b.searchParams.append("nativeSolToConvert",vt.lamports.toString()),N&&b.searchParams.append("lockDefaultToken","true"),F&&b.searchParams.append("planCode",F),W&&b.searchParams.append("disableApplePay","true"),q&&b.searchParams.append("disableGooglePay","true"),yt&&b.searchParams.append("settlementType",yt),ot&&b.searchParams.append("lockAmount","true"),l===!1&&b.searchParams.append("usePermit","false"),y&&b.searchParams.append("transactionSigner",y),k===!0&&b.searchParams.append("authOnly","true"),S&&b.searchParams.append("jwtToken",S),B&&b.searchParams.append("origins",cr.compressToEncodedURIComponent(JSON.stringify(B))),b.toString()}static getTransaction(t){return this.byBlockchain(t.blockchain,{solana:()=>{if(!("transaction"in t))return;const{transaction:e}=t;if(!fi)throw new Error("@solana/web3.js dependency is required for Solana");if(!vr)throw new Error("bs58 dependency is required for Solana");if(e)return vr.encode(e.serialize({requireAllSignatures:!1,verifySignatures:!1}))},polygon:()=>{if(!("transaction"in t))return;const{transaction:e}=t;return cr.compressToEncodedURIComponent(JSON.stringify(e))},eth:()=>{if(!("transaction"in t))return;const{transaction:e}=t;return cr.compressToEncodedURIComponent(JSON.stringify(e))},base:()=>{if(!("transaction"in t))return;const{transaction:e}=t;return cr.compressToEncodedURIComponent(JSON.stringify(e))},near:()=>{if(!("action"in t))return;const{action:e}=t;return cr.compressToEncodedURIComponent(JSON.stringify(e))}})()}static byBlockchain(t,e){switch(t){case"solana":return e.solana;case"near":return e.near;case"polygon":return e.polygon;case"eth":return e.eth;case"base":return e.base;default:throw new Error("blockchain not supported!")}}}var kc=(o=>(o.SignMessage="signMessage",o.SignTransaction="signTransaction",o.SendTransaction="sendTransaction",o.HeightChange="heightChange",o.Success="success",o))(kc||{});function hi({wallet:o}){return"publicKey"in o?o.publicKey.toString():"address"in o?o.address:"accountId"in o?o.accountId:null}function Ec(o,t){let e;try{if(e=JSON.parse(o),!("method"in e)||!("data"in e))return}catch(a){console.error("handleIFrameMessage JSON parse",a);return}const{data:n,method:s}=e;switch(s){case"signMessage":return t.handleSignMessage?t.handleSignMessage(n):void 0;case"signTransaction":return t.handleSignTransaction?t.handleSignTransaction(n):void 0;case"sendTransaction":return t.handleSendTransaction(n);case"heightChange":return t.handleHeightChange?t.handleHeightChange(n):void 0;case"success":if(!t.onSuccess)return;t.onSuccess(e.info);return}console.warn(`Didn't expect to get here, handleIFrameMessage method:${s} is not one of ${Object.values(kc)}`)}function li(o){return ur.byBlockchain(o.blockchain,{solana:()=>Nd(o),near:()=>zd(o),eth:()=>Po(o),polygon:()=>Po(o),base:()=>Po(o)})()}function Nd({wallet:o,onSuccess:t}){return{handleSendTransaction:async e=>{const n=Ic(e);return await o.sendTransaction(n)},handleSignMessage:async e=>{const n=o.signMessage;if(!n)throw new Error("signMessage is not supported by this wallet");const s=await n(new TextEncoder().encode(e));if(!vr)throw new Error("bs58 dependency is required");return vr.encode(s)},handleSignTransaction:async e=>{const n=o.signTransaction;if(!n)throw new Error("signTransaction is not supported by this wallet");const s=Ic(e),a=await n(s);if(!vr)throw new Error("bs58 dependency is required");return vr.encode(a.serialize({requireAllSignatures:!1,verifySignatures:!1}))},onSuccess:t}}function Ic(o){if(!fi)throw new Error("@solana/web3.js is not defined. Please install @solana/web3.js into your project");if(!vr)throw new Error("bs58 is not defined. Please install bs58 into your project");const t=vr.decode(o),e=fi.VersionedTransaction.deserialize(t);return e.version==="legacy"?fi.Transaction.from(t):e}function zd({wallet:o,onSuccess:t}){const e=o;return{handleSendTransaction:async n=>{const s=JSON.parse(Buffer.from(n,"base64").toString()),a=await e.signAndSendTransaction(s);if(!a)throw new Error("Transaction did not send");const{transaction:f}=a;return f.hash},onSuccess:t}}function Po({wallet:o,onSuccess:t}){const e=o;return{handleSendTransaction:async n=>{const s=JSON.parse(Buffer.from(n,"base64").toString()),{hash:a}=await e.sendTransaction(s);return a},handleSignMessage:async n=>e.signMessage(n),onSuccess:t}}const Mn="tokenExCardNumber",Pn="tokenExCardCvv",Sc={[qr.VISA]:"visa",[qr.MASTERCARD]:"masterCard",[qr.AMEX]:"americanExpress",[qr.DISCOVER]:"discover"};async function di({token:o,origins:t,env:e}){return new Promise((n,s)=>{fetch(new ur(e).url+"/api/checkout/authentication-key",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({origins:[...t??[],window.location.origin],token:o})}).then(async a=>{n(await a.json())}).catch(a=>s(a))})}function Co({env:o,setTokenExScriptLoaded:t}){const e="tokenex-script";if(document.head.querySelector(`#${e}`))return;const n=document.createElement("script");n.src=o==="prod"?"https://htp.tokenex.com/iframe/iframe-v3.min.js":"https://test-htp.tokenex.com/iframe/iframe-v3.min.js",n.id=e,document.head.appendChild(n),document.getElementById(e).addEventListener("load",()=>{console.log("Setting tokenExScriptLoaded to true!"),t(!0)})}function Uo({iframe:o,setCachedToken:t,setLoaded:e}){const n=async()=>(o.tokenize(),await new Promise((s,a)=>{o.on("tokenize",f=>{t(f.token),s(f)}),o.on("validate",f=>{(!f.isValid||f.isCvvValid===!1)&&a(f)})}));return o.on("change",()=>t(void 0)),o.on("cvvChange",()=>t(void 0)),o.on("load",()=>{setTimeout(()=>e(!0),350);const s=document.querySelector("#tx_iframe_tokenExCardNumber");s&&(s.scrolling="no")}),e(!1),o.load(),{...o,tokenize:n}}async function Bc({token:o,cardType:t,css:e,debug:n,fontFamily:s,origins:a,tokenExScriptLoaded:f,env:u,setCachedToken:p,setLoaded:w}){if(!f&&typeof TokenEx>"u"){console.warn("Warning Unable to load TokenEx on first attempt waiting for load event from document.head.script#tokenex-script");return}const E=Sc[t],I=await di({token:o,origins:a,env:u}),{styles:M}=Lo(e),T={...I,placeholder:"CVV",enablePrettyFormat:!0,styles:M,token:o,cvvOnly:!0,cvv:!0,cvvContainerID:Pn,cardType:E,debug:n??!1,font:s},U=TokenEx.Iframe(Pn,T);return Uo({iframe:U,setCachedToken:p,setLoaded:w})}async function Ac({css:o,debug:t,fontFamily:e,origins:n,tokenExScriptLoaded:s,env:a,setCachedToken:f,setLoaded:u}){if(!s&&typeof TokenEx>"u"){console.warn("Warning Unable to load TokenEx on first attempt waiting for load event from document.head.script#tokenex-script");return}const p=await di({origins:n,env:a}),{styles:w}=Lo(o),E=TokenEx.Iframe(Mn,{...p,placeholder:"0000 0000 0000 0000",cvvPlaceholder:"CVV",enablePrettyFormat:!0,cvv:!0,cvvContainerID:Pn,styles:w,font:e,debug:t??!1});return Uo({iframe:E,setCachedToken:f,setLoaded:u})}async function vc({css:o,debug:t,fontFamily:e,origins:n,tokenExScriptLoaded:s,env:a,setCachedToken:f,setLoaded:u}){if(!s&&typeof TokenEx>"u"){console.warn("Warning Unable to load TokenEx on first attempt waiting for load event from document.head.script#tokenex-script");return}const p=await di({origins:n,env:a}),{styles:w}=Lo(o),E=TokenEx.Iframe(Mn,{...p,placeholder:"0000 0000 0000 0000",enablePrettyFormat:!0,cvv:!1,styles:w,font:e,debug:t??!1});return Uo({iframe:E,setCachedToken:f,setLoaded:u})}function Lo(o){var n,s,a;const t=JSON.parse(o);return{styles:{base:hn(t.base),focus:hn(t.focus),error:hn(t.error),cvv:{base:hn((n=t.cvv)==null?void 0:n.base),focus:hn((s=t.cvv)==null?void 0:s.focus),error:hn((a=t.cvv)==null?void 0:a.error)}}}}function hn(o){if(!o)return"";if(typeof o=="string")return o;let t="";for(const[e,n]of Object.entries(o)){let s="";e.split("").forEach(a=>{a.toUpperCase()===a?s+="-"+a.toLowerCase():s+=a}),t+=s+":"+n+";"}return t}const Dd=lt.defineComponent({name:"CoinflowIFrame",props:{args:{type:Object,required:!0}},computed:{url(){return ur.getCoinflowUrl(this.args)}},emits:{onMessage({data:o,origin:t}){return console.log({data:o,origin:t}),!0}},methods:{sendMessage(o){const t=this.$refs.iframeRef;if(!(t!=null&&t.contentWindow))throw new Error("Iframe not defined");t.contentWindow.postMessage(o,"*")},handleIframeMessages({data:o,origin:t}){if(!t.includes(ur.getCoinflowBaseUrl(this.args.env)))return;this.$emit("onMessage",{data:o,origin:t});const e=Ec(o,this.args);e&&e.then(this.sendMessage).catch(n=>{console.error(n),this.sendMessage("ERROR "+n.message)})},async listenForMessage(o){let t;return new Promise((e,n)=>{if(t=({data:s,origin:a})=>{if(a.includes(ur.getCoinflowBaseUrl(this.args.env))){if(s.startsWith("ERROR")){n(new Error(s.replace("ERROR","")));return}o(s)&&e(s)}},!window)throw new Error("Window not defined");window.addEventListener("message",t)}).finally(()=>{window.removeEventListener("message",t)})},async sendAndReceiveMessage(o,t){return this.sendMessage(o),this.listenForMessage(t)}},mounted(){if(!window)throw new Error("Window not defined");return window.addEventListener("message",this.handleIframeMessages),()=>{window.removeEventListener("message",this.handleIframeMessages)}}}),Fo=(o,t)=>{const e=o.__vccOpts||o;for(const[n,s]of t)e[n]=s;return e},$d=["src","scrolling"];function Wd(o,t,e,n,s,a){return lt.openBlock(),lt.createElementBlock("iframe",{style:{height:"100%",width:"100%"},ref:"iframeRef",allow:"payment;camera",title:"withdraw",frameBorder:"0",src:o.url,scrolling:o.args.handleHeightChange?"no":"yes",onLoad:t[0]||(t[0]=()=>{const f=o.$refs.iframeRef;f&&(f.style.opacity="1")})},null,40,$d)}const pi=Fo(Dd,[["render",Wd]]),Kd=lt.defineComponent({name:"CoinflowWithdraw",components:{CoinflowIFrame:pi},props:{args:{type:Object,required:!0}},computed:{iframeProps(){const o=hi(this.args);return{...this.args,walletPubkey:o,route:`/withdraw/${this.args.merchantId}`,transaction:void 0}},messageHandlers(){return{...li(this.args),handleHeightChange:this.args.handleHeightChange}}}});function qd(o,t,e,n,s,a){const f=lt.resolveComponent("coinflow-i-frame");return lt.openBlock(),lt.createBlock(f,{args:{...o.iframeProps,...o.messageHandlers}},null,8,["args"])}const Hd=Fo(Kd,[["render",qd]]),Vd=lt.defineComponent({name:"CoinflowPurchase",components:{CoinflowIFrame:pi},props:{args:{type:Object,required:!0}},computed:{iframeProps(){const o=hi(this.args);return{...this.args,walletPubkey:o,route:`/purchase/${this.args.merchantId}`,transaction:ur.getTransaction(this.args)}},messageHandlers(){return{...li(this.args),handleHeightChange:this.args.handleHeightChange}}}});function jd(o,t,e,n,s,a){const f=lt.resolveComponent("coinflow-i-frame");return lt.openBlock(),lt.createBlock(f,{args:{...o.iframeProps,...o.messageHandlers}},null,8,["args"])}const Gd=Fo(Vd,[["render",jd]]),_c=o=>{const t=lt.ref(!1),e=lt.ref(!1),n=lt.ref(void 0),s=lt.ref(void 0);lt.onMounted(()=>{Co({env:o,setTokenExScriptLoaded:()=>{console.log("tokenExScriptLoaded.value = true"),e.value=!0}})});const a=I=>s.value=I,f=()=>t.value=!0,u=I=>n.value=I,p=async({token:I,cardType:M,css:T,debug:U,fontFamily:_,origins:C})=>{const L=await Bc({token:I,cardType:M,css:T,debug:U,fontFamily:_,origins:C,tokenExScriptLoaded:e.value,env:o,setCachedToken:a,setLoaded:f});return u(L),L},w=async({css:I,fontFamily:M,debug:T,origins:U})=>{const _=await Ac({css:I,debug:T,fontFamily:M,origins:U,tokenExScriptLoaded:e.value,env:o,setCachedToken:a,setLoaded:f});return u(_),_},E=async({css:I,fontFamily:M,debug:T,origins:U})=>{const _=await vc({css:I,debug:T,fontFamily:M,origins:U,tokenExScriptLoaded:e.value,env:o,setCachedToken:a,setLoaded:f});return u(_),_};return lt.watchEffect(I=>{n.value&&(n.value.load(),I(()=>{var M;return(M=n.value)==null?void 0:M.remove()}))}),{tokenExIframe:n,initializeTokenExIframe:w,initializeCvvOnlyTokenExIframe:p,initializeTokenExCardOnlyIframe:E,loaded:t,cachedToken:s,setTokenExScriptTag:Co,tokenExScriptLoaded:e}},Yd=["id"],Zd=lt.defineComponent({__name:"CoinflowCardNumberInput",props:{args:{type:Object,required:!0}},setup(o,{expose:t}){const{args:e}=o,{initializeTokenExIframe:n,tokenExIframe:s}=_c(e.env);async function a(){if(!s.value)throw new Error("Unable to get token");return s.value.tokenize()}t({getToken:a});function f(){return JSON.stringify(e.css)}return lt.watchEffect(()=>{n({css:f(),debug:e.debug,origins:e.origins})},{}),(u,p)=>(lt.openBlock(),lt.createElementBlock("div",{id:lt.unref(Mn)},null,8,Yd))}}),Jd=["id"],Rc=lt.defineComponent({__name:"CoinflowCvvInput",setup(o){return(t,e)=>(lt.openBlock(),lt.createElementBlock("div",{id:lt.unref(Pn)},null,8,Jd))}}),Xd=lt.defineComponent({__name:"CoinflowPurchaseProtection",props:{args:{type:Object,required:!0}},setup(o){const{args:{env:t,merchantId:e}}=o,n=lt.ref(void 0);lt.onMounted(()=>new ur(t).getNSurePartnerId(e).then(f=>n.value=f));function s(){return t==="prod"?"9JBW2RHC7JNJN8ZQ":"SANDBOX_CTCE4XK53ZW0R7V1"}function a(){return t==="prod"?"https://sdk.nsureapi.com/sdk.js":"https://sdk.nsureapi.com/sdk-sandbox.js"}return lt.watchEffect(f=>{if(!n.value)return;const u=document.createElement("script");u.src=a(),document.head.appendChild(u);const p=`window.nSureAsyncInit = function(deviceId) {
23
+ `,C=_+U.join(_);console.error(T.error.message,C)}throw new An({action:"simulate",signature:"",transactionMessage:T.error.message,logs:U})}return T.result}async sendTransaction(t,e,n){if("version"in t){if(e&&Array.isArray(e))throw new Error("Invalid arguments");const f=t.serialize();return await this.sendRawTransaction(f,e)}if(e===void 0||!Array.isArray(e))throw new Error("Invalid arguments");const s=e;if(t.nonceInfo)t.sign(...s);else{let f=this._disableBlockhashCaching;for(;;){const u=await this._blockhashWithExpiryBlockHeight(f);if(t.lastValidBlockHeight=u.lastValidBlockHeight,t.recentBlockhash=u.blockhash,t.sign(...s),!t.signature)throw new Error("!signature");const p=t.signature.toString("base64");if(this._blockhashInfo.transactionSignatures.includes(p))f=!0;else{this._blockhashInfo.transactionSignatures.push(p);break}}}const a=t.serialize();return await this.sendRawTransaction(a,n)}async sendRawTransaction(t,e){const n=kt(t).toString("base64");return await this.sendEncodedTransaction(n,e)}async sendEncodedTransaction(t,e){const n={encoding:"base64"},s=e&&e.skipPreflight,a=s===!0?"processed":e&&e.preflightCommitment||this.commitment;e&&e.maxRetries!=null&&(n.maxRetries=e.maxRetries),e&&e.minContextSlot!=null&&(n.minContextSlot=e.minContextSlot),s&&(n.skipPreflight=s),a&&(n.preflightCommitment=a);const f=[t,n],u=await this._rpcRequest("sendTransaction",f),p=et(u,yd);if("error"in p){let w;throw"data"in p.error&&(w=p.error.data.logs),new An({action:s?"send":"simulate",signature:"",transactionMessage:p.error.message,logs:w})}return p.result}_wsOnOpen(){this._rpcWebSocketConnected=!0,this._rpcWebSocketHeartbeat=setInterval(()=>{(async()=>{try{await this._rpcWebSocket.notify("ping")}catch{}})()},5e3),this._updateSubscriptions()}_wsOnError(t){this._rpcWebSocketConnected=!1,console.error("ws error:",t.message)}_wsOnClose(t){if(this._rpcWebSocketConnected=!1,this._rpcWebSocketGeneration=(this._rpcWebSocketGeneration+1)%Number.MAX_SAFE_INTEGER,this._rpcWebSocketIdleTimeout&&(clearTimeout(this._rpcWebSocketIdleTimeout),this._rpcWebSocketIdleTimeout=null),this._rpcWebSocketHeartbeat&&(clearInterval(this._rpcWebSocketHeartbeat),this._rpcWebSocketHeartbeat=null),t===1e3){this._updateSubscriptions();return}this._subscriptionCallbacksByServerSubscriptionId={},Object.entries(this._subscriptionsByHash).forEach(([e,n])=>{this._setSubscription(e,{...n,state:"pending"})})}_setSubscription(t,e){var s;const n=(s=this._subscriptionsByHash[t])==null?void 0:s.state;if(this._subscriptionsByHash[t]=e,n!==e.state){const a=this._subscriptionStateChangeCallbacksByHash[t];a&&a.forEach(f=>{try{f(e.state)}catch{}})}}_onSubscriptionStateChange(t,e){var a;const n=this._subscriptionHashByClientSubscriptionId[t];if(n==null)return()=>{};const s=(a=this._subscriptionStateChangeCallbacksByHash)[n]||(a[n]=new Set);return s.add(e),()=>{s.delete(e),s.size===0&&delete this._subscriptionStateChangeCallbacksByHash[n]}}async _updateSubscriptions(){if(Object.keys(this._subscriptionsByHash).length===0){this._rpcWebSocketConnected&&(this._rpcWebSocketConnected=!1,this._rpcWebSocketIdleTimeout=setTimeout(()=>{this._rpcWebSocketIdleTimeout=null;try{this._rpcWebSocket.close()}catch(n){n instanceof Error&&console.log(`Error when closing socket connection: ${n.message}`)}},500));return}if(this._rpcWebSocketIdleTimeout!==null&&(clearTimeout(this._rpcWebSocketIdleTimeout),this._rpcWebSocketIdleTimeout=null,this._rpcWebSocketConnected=!0),!this._rpcWebSocketConnected){this._rpcWebSocket.connect();return}const t=this._rpcWebSocketGeneration,e=()=>t===this._rpcWebSocketGeneration;await Promise.all(Object.keys(this._subscriptionsByHash).map(async n=>{const s=this._subscriptionsByHash[n];if(s!==void 0)switch(s.state){case"pending":case"unsubscribed":if(s.callbacks.size===0){delete this._subscriptionsByHash[n],s.state==="unsubscribed"&&delete this._subscriptionCallbacksByServerSubscriptionId[s.serverSubscriptionId],await this._updateSubscriptions();return}await(async()=>{const{args:a,method:f}=s;try{this._setSubscription(n,{...s,state:"subscribing"});const u=await this._rpcWebSocket.call(f,a);this._setSubscription(n,{...s,serverSubscriptionId:u,state:"subscribed"}),this._subscriptionCallbacksByServerSubscriptionId[u]=s.callbacks,await this._updateSubscriptions()}catch(u){if(u instanceof Error&&console.error(`${f} error for argument`,a,u.message),!e())return;this._setSubscription(n,{...s,state:"pending"}),await this._updateSubscriptions()}})();break;case"subscribed":s.callbacks.size===0&&await(async()=>{const{serverSubscriptionId:a,unsubscribeMethod:f}=s;if(this._subscriptionsAutoDisposedByRpc.has(a))this._subscriptionsAutoDisposedByRpc.delete(a);else{this._setSubscription(n,{...s,state:"unsubscribing"}),this._setSubscription(n,{...s,state:"unsubscribing"});try{await this._rpcWebSocket.call(f,[a])}catch(u){if(u instanceof Error&&console.error(`${f} error:`,u.message),!e())return;this._setSubscription(n,{...s,state:"subscribed"}),await this._updateSubscriptions();return}}this._setSubscription(n,{...s,state:"unsubscribed"}),await this._updateSubscriptions()})();break}}))}_handleServerNotification(t,e){const n=this._subscriptionCallbacksByServerSubscriptionId[t];n!==void 0&&n.forEach(s=>{try{s(...e)}catch(a){console.error(a)}})}_wsOnAccountNotification(t){const{result:e,subscription:n}=et(t,zl);this._handleServerNotification(n,[e.value,e.context])}_makeSubscription(t,e){const n=this._nextClientSubscriptionId++,s=Ha([t.method,e]),a=this._subscriptionsByHash[s];return a===void 0?this._subscriptionsByHash[s]={...t,args:e,callbacks:new Set([t.callback]),state:"pending"}:a.callbacks.add(t.callback),this._subscriptionHashByClientSubscriptionId[n]=s,this._subscriptionDisposeFunctionsByClientSubscriptionId[n]=async()=>{delete this._subscriptionDisposeFunctionsByClientSubscriptionId[n],delete this._subscriptionHashByClientSubscriptionId[n];const f=this._subscriptionsByHash[s];Lt(f!==void 0,`Could not find a \`Subscription\` when tearing down client subscription #${n}`),f.callbacks.delete(t.callback),await this._updateSubscriptions()},this._updateSubscriptions(),n}onAccountChange(t,e,n){const s=this._buildArgs([t.toBase58()],n||this._commitment||"finalized","base64");return this._makeSubscription({callback:e,method:"accountSubscribe",unsubscribeMethod:"accountUnsubscribe"},s)}async removeAccountChangeListener(t){await this._unsubscribeClientSubscription(t,"account change")}_wsOnProgramAccountNotification(t){const{result:e,subscription:n}=et(t,$l);this._handleServerNotification(n,[{accountId:e.value.pubkey,accountInfo:e.value.account},e.context])}onProgramAccountChange(t,e,n,s){const a=this._buildArgs([t.toBase58()],n||this._commitment||"finalized","base64",s?{filters:s}:void 0);return this._makeSubscription({callback:e,method:"programSubscribe",unsubscribeMethod:"programUnsubscribe"},a)}async removeProgramAccountChangeListener(t){await this._unsubscribeClientSubscription(t,"program account change")}onLogs(t,e,n){const s=this._buildArgs([typeof t=="object"?{mentions:[t.toString()]}:t],n||this._commitment||"finalized");return this._makeSubscription({callback:e,method:"logsSubscribe",unsubscribeMethod:"logsUnsubscribe"},s)}async removeOnLogsListener(t){await this._unsubscribeClientSubscription(t,"logs")}_wsOnLogsNotification(t){const{result:e,subscription:n}=et(t,wd);this._handleServerNotification(n,[e.value,e.context])}_wsOnSlotNotification(t){const{result:e,subscription:n}=et(t,Kl);this._handleServerNotification(n,[e])}onSlotChange(t){return this._makeSubscription({callback:t,method:"slotSubscribe",unsubscribeMethod:"slotUnsubscribe"},[])}async removeSlotChangeListener(t){await this._unsubscribeClientSubscription(t,"slot change")}_wsOnSlotUpdatesNotification(t){const{result:e,subscription:n}=et(t,Hl);this._handleServerNotification(n,[e])}onSlotUpdate(t){return this._makeSubscription({callback:t,method:"slotsUpdatesSubscribe",unsubscribeMethod:"slotsUpdatesUnsubscribe"},[])}async removeSlotUpdateListener(t){await this._unsubscribeClientSubscription(t,"slot update")}async _unsubscribeClientSubscription(t,e){const n=this._subscriptionDisposeFunctionsByClientSubscriptionId[t];n?await n():console.warn(`Ignored unsubscribe request because an active subscription with id \`${t}\` for '${e}' events could not be found.`)}_buildArgs(t,e,n,s){const a=e||this._commitment;if(a||n||s){let f={};n&&(f.encoding=n),a&&(f.commitment=a),s&&(f=Object.assign(f,s)),t.push(f)}return t}_buildArgsAtLeastConfirmed(t,e,n,s){const a=e||this._commitment;if(a&&!["confirmed","finalized"].includes(a))throw new Error("Using Connection with default commitment: `"+this._commitment+"`, but method requires at least `confirmed`");return this._buildArgs(t,e,n,s)}_wsOnSignatureNotification(t){const{result:e,subscription:n}=et(t,Vl);e.value!=="receivedSignature"&&this._subscriptionsAutoDisposedByRpc.add(n),this._handleServerNotification(n,e.value==="receivedSignature"?[{type:"received"},e.context]:[{type:"status",result:e.value},e.context])}onSignature(t,e,n){const s=this._buildArgs([t],n||this._commitment||"finalized"),a=this._makeSubscription({callback:(f,u)=>{if(f.type==="status"){e(f.result,u);try{this.removeSignatureListener(a)}catch{}}},method:"signatureSubscribe",unsubscribeMethod:"signatureUnsubscribe"},s);return a}onSignatureWithOptions(t,e,n){const{commitment:s,...a}={...n,commitment:n&&n.commitment||this._commitment||"finalized"},f=this._buildArgs([t],s,void 0,a),u=this._makeSubscription({callback:(p,w)=>{e(p,w);try{this.removeSignatureListener(u)}catch{}},method:"signatureSubscribe",unsubscribeMethod:"signatureUnsubscribe"},f);return u}async removeSignatureListener(t){await this._unsubscribeClientSubscription(t,"signature result")}_wsOnRootNotification(t){const{result:e,subscription:n}=et(t,jl);this._handleServerNotification(n,[e])}onRootChange(t){return this._makeSubscription({callback:t,method:"rootSubscribe",unsubscribeMethod:"rootUnsubscribe"},[])}async removeRootChangeListener(t){await this._unsubscribeClientSubscription(t,"root change")}}class cn{constructor(t){this._keypair=void 0,this._keypair=t??La()}static generate(){return new cn(La())}static fromSecretKey(t,e){if(t.byteLength!==64)throw new Error("bad secret key size");const n=t.slice(32,64);if(!e||!e.skipValidation){const s=t.slice(0,32),a=Xn(s);for(let f=0;f<32;f++)if(n[f]!==a[f])throw new Error("provided secretKey is invalid")}return new cn({publicKey:n,secretKey:t})}static fromSeed(t){const e=Xn(t),n=new Uint8Array(64);return n.set(t),n.set(e,32),new cn({publicKey:e,secretKey:n})}get publicKey(){return new tt(this._keypair.publicKey)}get secretKey(){return new Uint8Array(this._keypair.secretKey)}}const mr=Object.freeze({CreateLookupTable:{index:0,layout:ct([at("instruction"),sn("recentSlot"),Ct("bumpSeed")])},FreezeLookupTable:{index:1,layout:ct([at("instruction")])},ExtendLookupTable:{index:2,layout:ct([at("instruction"),sn(),Ae(Bt(),Sr(at(),-8),"addresses")])},DeactivateLookupTable:{index:3,layout:ct([at("instruction")])},CloseLookupTable:{index:4,layout:ct([at("instruction")])}});class kd{constructor(){}static decodeInstructionType(t){this.checkProgramId(t.programId);const n=at("instruction").decode(t.data);let s;for(const[a,f]of Object.entries(mr))if(f.index==n){s=a;break}if(!s)throw new Error("Invalid Instruction. Should be a LookupTable Instruction");return s}static decodeCreateLookupTable(t){this.checkProgramId(t.programId),this.checkKeysLength(t.keys,4);const{recentSlot:e}=zt(mr.CreateLookupTable,t.data);return{authority:t.keys[1].pubkey,payer:t.keys[2].pubkey,recentSlot:Number(e)}}static decodeExtendLookupTable(t){if(this.checkProgramId(t.programId),t.keys.length<2)throw new Error(`invalid instruction; found ${t.keys.length} keys, expected at least 2`);const{addresses:e}=zt(mr.ExtendLookupTable,t.data);return{lookupTable:t.keys[0].pubkey,authority:t.keys[1].pubkey,payer:t.keys.length>2?t.keys[2].pubkey:void 0,addresses:e.map(n=>new tt(n))}}static decodeCloseLookupTable(t){return this.checkProgramId(t.programId),this.checkKeysLength(t.keys,3),{lookupTable:t.keys[0].pubkey,authority:t.keys[1].pubkey,recipient:t.keys[2].pubkey}}static decodeFreezeLookupTable(t){return this.checkProgramId(t.programId),this.checkKeysLength(t.keys,2),{lookupTable:t.keys[0].pubkey,authority:t.keys[1].pubkey}}static decodeDeactivateLookupTable(t){return this.checkProgramId(t.programId),this.checkKeysLength(t.keys,2),{lookupTable:t.keys[0].pubkey,authority:t.keys[1].pubkey}}static checkProgramId(t){if(!t.equals(Bo.programId))throw new Error("invalid instruction; programId is not AddressLookupTable Program")}static checkKeysLength(t,e){if(t.length<e)throw new Error(`invalid instruction; found ${t.length} keys, expected at least ${e}`)}}class Bo{constructor(){}static createLookupTable(t){const[e,n]=tt.findProgramAddressSync([t.authority.toBuffer(),fa(BigInt(t.recentSlot),8)],this.programId),s=mr.CreateLookupTable,a=Mt(s,{recentSlot:BigInt(t.recentSlot),bumpSeed:n}),f=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:t.authority,isSigner:!0,isWritable:!1},{pubkey:t.payer,isSigner:!0,isWritable:!0},{pubkey:Ee.programId,isSigner:!1,isWritable:!1}];return[new Ht({programId:this.programId,keys:f,data:a}),e]}static freezeLookupTable(t){const e=mr.FreezeLookupTable,n=Mt(e),s=[{pubkey:t.lookupTable,isSigner:!1,isWritable:!0},{pubkey:t.authority,isSigner:!0,isWritable:!1}];return new Ht({programId:this.programId,keys:s,data:n})}static extendLookupTable(t){const e=mr.ExtendLookupTable,n=Mt(e,{addresses:t.addresses.map(a=>a.toBytes())}),s=[{pubkey:t.lookupTable,isSigner:!1,isWritable:!0},{pubkey:t.authority,isSigner:!0,isWritable:!1}];return t.payer&&s.push({pubkey:t.payer,isSigner:!0,isWritable:!0},{pubkey:Ee.programId,isSigner:!1,isWritable:!1}),new Ht({programId:this.programId,keys:s,data:n})}static deactivateLookupTable(t){const e=mr.DeactivateLookupTable,n=Mt(e),s=[{pubkey:t.lookupTable,isSigner:!1,isWritable:!0},{pubkey:t.authority,isSigner:!0,isWritable:!1}];return new Ht({programId:this.programId,keys:s,data:n})}static closeLookupTable(t){const e=mr.CloseLookupTable,n=Mt(e),s=[{pubkey:t.lookupTable,isSigner:!1,isWritable:!0},{pubkey:t.authority,isSigner:!0,isWritable:!1},{pubkey:t.recipient,isSigner:!1,isWritable:!0}];return new Ht({programId:this.programId,keys:s,data:n})}}Bo.programId=new tt("AddressLookupTab1e1111111111111111111111111");class Ed{constructor(){}static decodeInstructionType(t){this.checkProgramId(t.programId);const n=Ct("instruction").decode(t.data);let s;for(const[a,f]of Object.entries(sr))if(f.index==n){s=a;break}if(!s)throw new Error("Instruction type incorrect; not a ComputeBudgetInstruction");return s}static decodeRequestUnits(t){this.checkProgramId(t.programId);const{units:e,additionalFee:n}=zt(sr.RequestUnits,t.data);return{units:e,additionalFee:n}}static decodeRequestHeapFrame(t){this.checkProgramId(t.programId);const{bytes:e}=zt(sr.RequestHeapFrame,t.data);return{bytes:e}}static decodeSetComputeUnitLimit(t){this.checkProgramId(t.programId);const{units:e}=zt(sr.SetComputeUnitLimit,t.data);return{units:e}}static decodeSetComputeUnitPrice(t){this.checkProgramId(t.programId);const{microLamports:e}=zt(sr.SetComputeUnitPrice,t.data);return{microLamports:e}}static checkProgramId(t){if(!t.equals(Ao.programId))throw new Error("invalid instruction; programId is not ComputeBudgetProgram")}}const sr=Object.freeze({RequestUnits:{index:0,layout:ct([Ct("instruction"),at("units"),at("additionalFee")])},RequestHeapFrame:{index:1,layout:ct([Ct("instruction"),at("bytes")])},SetComputeUnitLimit:{index:2,layout:ct([Ct("instruction"),at("units")])},SetComputeUnitPrice:{index:3,layout:ct([Ct("instruction"),sn("microLamports")])}});class Ao{constructor(){}static requestUnits(t){const e=sr.RequestUnits,n=Mt(e,t);return new Ht({keys:[],programId:this.programId,data:n})}static requestHeapFrame(t){const e=sr.RequestHeapFrame,n=Mt(e,t);return new Ht({keys:[],programId:this.programId,data:n})}static setComputeUnitLimit(t){const e=sr.SetComputeUnitLimit,n=Mt(e,t);return new Ht({keys:[],programId:this.programId,data:n})}static setComputeUnitPrice(t){const e=sr.SetComputeUnitPrice,n=Mt(e,{microLamports:BigInt(t.microLamports)});return new Ht({keys:[],programId:this.programId,data:n})}}Ao.programId=new tt("ComputeBudget111111111111111111111111111111");const cc=64,uc=32,fc=64,hc=ct([Ct("numSignatures"),Ct("padding"),qe("signatureOffset"),qe("signatureInstructionIndex"),qe("publicKeyOffset"),qe("publicKeyInstructionIndex"),qe("messageDataOffset"),qe("messageDataSize"),qe("messageInstructionIndex")]);class ci{constructor(){}static createInstructionWithPublicKey(t){const{publicKey:e,message:n,signature:s,instructionIndex:a}=t;Lt(e.length===uc,`Public Key must be ${uc} bytes but received ${e.length} bytes`),Lt(s.length===fc,`Signature must be ${fc} bytes but received ${s.length} bytes`);const f=hc.span,u=f+e.length,p=u+s.length,w=1,E=dt.Buffer.alloc(p+n.length),I=a??65535;return hc.encode({numSignatures:w,padding:0,signatureOffset:u,signatureInstructionIndex:I,publicKeyOffset:f,publicKeyInstructionIndex:I,messageDataOffset:p,messageDataSize:n.length,messageInstructionIndex:I},E),E.fill(e,f),E.fill(s,u),E.fill(n,p),new Ht({keys:[],programId:ci.programId,data:E})}static createInstructionWithPrivateKey(t){const{privateKey:e,message:n,instructionIndex:s}=t;Lt(e.length===cc,`Private key must be ${cc} bytes but received ${e.length} bytes`);try{const a=cn.fromSecretKey(e),f=a.publicKey.toBytes(),u=oo(n,a.secretKey);return this.createInstructionWithPublicKey({publicKey:f,message:n,signature:u,instructionIndex:s})}catch(a){throw new Error(`Error creating instruction; ${a}`)}}}ci.programId=new tt("Ed25519SigVerify111111111111111111111111111");const Id=(o,t)=>{const e=Jn.sign(o,t);return[e.toCompactRawBytes(),e.recovery]};Jn.utils.isValidPrivateKey;const Sd=Jn.getPublicKey,lc=32,vo=20,dc=64,Bd=11,_o=ct([Ct("numSignatures"),qe("signatureOffset"),Ct("signatureInstructionIndex"),qe("ethAddressOffset"),Ct("ethAddressInstructionIndex"),qe("messageDataOffset"),qe("messageDataSize"),Ct("messageInstructionIndex"),jt(20,"ethAddress"),jt(64,"signature"),Ct("recoveryId")]);class un{constructor(){}static publicKeyToEthAddress(t){Lt(t.length===dc,`Public key must be ${dc} bytes but received ${t.length} bytes`);try{return dt.Buffer.from(_a(kt(t))).slice(-vo)}catch(e){throw new Error(`Error constructing Ethereum address: ${e}`)}}static createInstructionWithPublicKey(t){const{publicKey:e,message:n,signature:s,recoveryId:a,instructionIndex:f}=t;return un.createInstructionWithEthAddress({ethAddress:un.publicKeyToEthAddress(e),message:n,signature:s,recoveryId:a,instructionIndex:f})}static createInstructionWithEthAddress(t){const{ethAddress:e,message:n,signature:s,recoveryId:a,instructionIndex:f=0}=t;let u;typeof e=="string"?e.startsWith("0x")?u=dt.Buffer.from(e.substr(2),"hex"):u=dt.Buffer.from(e,"hex"):u=e,Lt(u.length===vo,`Address must be ${vo} bytes but received ${u.length} bytes`);const p=1+Bd,w=p,E=p+u.length,I=E+s.length+1,M=1,T=dt.Buffer.alloc(_o.span+n.length);return _o.encode({numSignatures:M,signatureOffset:E,signatureInstructionIndex:f,ethAddressOffset:w,ethAddressInstructionIndex:f,messageDataOffset:I,messageDataSize:n.length,messageInstructionIndex:f,signature:kt(s),ethAddress:kt(u),recoveryId:a},T),T.fill(kt(n),_o.span),new Ht({keys:[],programId:un.programId,data:T})}static createInstructionWithPrivateKey(t){const{privateKey:e,message:n,instructionIndex:s}=t;Lt(e.length===lc,`Private key must be ${lc} bytes but received ${e.length} bytes`);try{const a=kt(e),f=Sd(a,!1).slice(1),u=dt.Buffer.from(_a(kt(n))),[p,w]=Id(u,a);return this.createInstructionWithPublicKey({publicKey:f,message:n,signature:p,recoveryId:w,instructionIndex:s})}catch(a){throw new Error(`Error creating instruction; ${a}`)}}}un.programId=new tt("KeccakSecp256k11111111111111111111111111111");var pc;const gc=new tt("StakeConfig11111111111111111111111111111111");class yc{constructor(t,e){this.staker=void 0,this.withdrawer=void 0,this.staker=t,this.withdrawer=e}}class Tn{constructor(t,e,n){this.unixTimestamp=void 0,this.epoch=void 0,this.custodian=void 0,this.unixTimestamp=t,this.epoch=e,this.custodian=n}}pc=Tn,Tn.default=new pc(0,0,tt.default);class Ad{constructor(){}static decodeInstructionType(t){this.checkProgramId(t.programId);const n=at("instruction").decode(t.data);let s;for(const[a,f]of Object.entries(Ie))if(f.index==n){s=a;break}if(!s)throw new Error("Instruction type incorrect; not a StakeInstruction");return s}static decodeInitialize(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,2);const{authorized:e,lockup:n}=zt(Ie.Initialize,t.data);return{stakePubkey:t.keys[0].pubkey,authorized:new yc(new tt(e.staker),new tt(e.withdrawer)),lockup:new Tn(n.unixTimestamp,n.epoch,new tt(n.custodian))}}static decodeDelegate(t){return this.checkProgramId(t.programId),this.checkKeyLength(t.keys,6),zt(Ie.Delegate,t.data),{stakePubkey:t.keys[0].pubkey,votePubkey:t.keys[1].pubkey,authorizedPubkey:t.keys[5].pubkey}}static decodeAuthorize(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{newAuthorized:e,stakeAuthorizationType:n}=zt(Ie.Authorize,t.data),s={stakePubkey:t.keys[0].pubkey,authorizedPubkey:t.keys[2].pubkey,newAuthorizedPubkey:new tt(e),stakeAuthorizationType:{index:n}};return t.keys.length>3&&(s.custodianPubkey=t.keys[3].pubkey),s}static decodeAuthorizeWithSeed(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,2);const{newAuthorized:e,stakeAuthorizationType:n,authoritySeed:s,authorityOwner:a}=zt(Ie.AuthorizeWithSeed,t.data),f={stakePubkey:t.keys[0].pubkey,authorityBase:t.keys[1].pubkey,authoritySeed:s,authorityOwner:new tt(a),newAuthorizedPubkey:new tt(e),stakeAuthorizationType:{index:n}};return t.keys.length>3&&(f.custodianPubkey=t.keys[3].pubkey),f}static decodeSplit(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{lamports:e}=zt(Ie.Split,t.data);return{stakePubkey:t.keys[0].pubkey,splitStakePubkey:t.keys[1].pubkey,authorizedPubkey:t.keys[2].pubkey,lamports:e}}static decodeMerge(t){return this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3),zt(Ie.Merge,t.data),{stakePubkey:t.keys[0].pubkey,sourceStakePubKey:t.keys[1].pubkey,authorizedPubkey:t.keys[4].pubkey}}static decodeWithdraw(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,5);const{lamports:e}=zt(Ie.Withdraw,t.data),n={stakePubkey:t.keys[0].pubkey,toPubkey:t.keys[1].pubkey,authorizedPubkey:t.keys[4].pubkey,lamports:e};return t.keys.length>5&&(n.custodianPubkey=t.keys[5].pubkey),n}static decodeDeactivate(t){return this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3),zt(Ie.Deactivate,t.data),{stakePubkey:t.keys[0].pubkey,authorizedPubkey:t.keys[2].pubkey}}static checkProgramId(t){if(!t.equals(ui.programId))throw new Error("invalid instruction; programId is not StakeProgram")}static checkKeyLength(t,e){if(t.length<e)throw new Error(`invalid instruction; found ${t.length} keys, expected at least ${e}`)}}const Ie=Object.freeze({Initialize:{index:0,layout:ct([at("instruction"),Ph(),Ch()])},Authorize:{index:1,layout:ct([at("instruction"),Bt("newAuthorized"),at("stakeAuthorizationType")])},Delegate:{index:2,layout:ct([at("instruction")])},Split:{index:3,layout:ct([at("instruction"),De("lamports")])},Withdraw:{index:4,layout:ct([at("instruction"),De("lamports")])},Deactivate:{index:5,layout:ct([at("instruction")])},Merge:{index:7,layout:ct([at("instruction")])},AuthorizeWithSeed:{index:8,layout:ct([at("instruction"),Bt("newAuthorized"),at("stakeAuthorizationType"),Nr("authoritySeed"),Bt("authorityOwner")])}}),vd=Object.freeze({Staker:{index:0},Withdrawer:{index:1}});class ui{constructor(){}static initialize(t){const{stakePubkey:e,authorized:n,lockup:s}=t,a=s||Tn.default,f=Ie.Initialize,u=Mt(f,{authorized:{staker:kt(n.staker.toBuffer()),withdrawer:kt(n.withdrawer.toBuffer())},lockup:{unixTimestamp:a.unixTimestamp,epoch:a.epoch,custodian:kt(a.custodian.toBuffer())}}),p={keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:on,isSigner:!1,isWritable:!1}],programId:this.programId,data:u};return new Ht(p)}static createAccountWithSeed(t){const e=new Ot;e.add(Ee.createAccountWithSeed({fromPubkey:t.fromPubkey,newAccountPubkey:t.stakePubkey,basePubkey:t.basePubkey,seed:t.seed,lamports:t.lamports,space:this.space,programId:this.programId}));const{stakePubkey:n,authorized:s,lockup:a}=t;return e.add(this.initialize({stakePubkey:n,authorized:s,lockup:a}))}static createAccount(t){const e=new Ot;e.add(Ee.createAccount({fromPubkey:t.fromPubkey,newAccountPubkey:t.stakePubkey,lamports:t.lamports,space:this.space,programId:this.programId}));const{stakePubkey:n,authorized:s,lockup:a}=t;return e.add(this.initialize({stakePubkey:n,authorized:s,lockup:a}))}static delegate(t){const{stakePubkey:e,authorizedPubkey:n,votePubkey:s}=t,a=Ie.Delegate,f=Mt(a);return new Ot().add({keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!1,isWritable:!1},{pubkey:or,isSigner:!1,isWritable:!1},{pubkey:ri,isSigner:!1,isWritable:!1},{pubkey:gc,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:f})}static authorize(t){const{stakePubkey:e,authorizedPubkey:n,newAuthorizedPubkey:s,stakeAuthorizationType:a,custodianPubkey:f}=t,u=Ie.Authorize,p=Mt(u,{newAuthorized:kt(s.toBuffer()),stakeAuthorizationType:a.index}),w=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:or,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1}];return f&&w.push({pubkey:f,isSigner:!0,isWritable:!1}),new Ot().add({keys:w,programId:this.programId,data:p})}static authorizeWithSeed(t){const{stakePubkey:e,authorityBase:n,authoritySeed:s,authorityOwner:a,newAuthorizedPubkey:f,stakeAuthorizationType:u,custodianPubkey:p}=t,w=Ie.AuthorizeWithSeed,E=Mt(w,{newAuthorized:kt(f.toBuffer()),stakeAuthorizationType:u.index,authoritySeed:s,authorityOwner:kt(a.toBuffer())}),I=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1},{pubkey:or,isSigner:!1,isWritable:!1}];return p&&I.push({pubkey:p,isSigner:!0,isWritable:!1}),new Ot().add({keys:I,programId:this.programId,data:E})}static splitInstruction(t){const{stakePubkey:e,authorizedPubkey:n,splitStakePubkey:s,lamports:a}=t,f=Ie.Split,u=Mt(f,{lamports:a});return new Ht({keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:u})}static split(t,e){const n=new Ot;return n.add(Ee.createAccount({fromPubkey:t.authorizedPubkey,newAccountPubkey:t.splitStakePubkey,lamports:e,space:this.space,programId:this.programId})),n.add(this.splitInstruction(t))}static splitWithSeed(t,e){const{stakePubkey:n,authorizedPubkey:s,splitStakePubkey:a,basePubkey:f,seed:u,lamports:p}=t,w=new Ot;return w.add(Ee.allocate({accountPubkey:a,basePubkey:f,seed:u,space:this.space,programId:this.programId})),e&&e>0&&w.add(Ee.transfer({fromPubkey:t.authorizedPubkey,toPubkey:a,lamports:e})),w.add(this.splitInstruction({stakePubkey:n,authorizedPubkey:s,splitStakePubkey:a,lamports:p}))}static merge(t){const{stakePubkey:e,sourceStakePubKey:n,authorizedPubkey:s}=t,a=Ie.Merge,f=Mt(a);return new Ot().add({keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!1,isWritable:!0},{pubkey:or,isSigner:!1,isWritable:!1},{pubkey:ri,isSigner:!1,isWritable:!1},{pubkey:s,isSigner:!0,isWritable:!1}],programId:this.programId,data:f})}static withdraw(t){const{stakePubkey:e,authorizedPubkey:n,toPubkey:s,lamports:a,custodianPubkey:f}=t,u=Ie.Withdraw,p=Mt(u,{lamports:a}),w=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!1,isWritable:!0},{pubkey:or,isSigner:!1,isWritable:!1},{pubkey:ri,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}];return f&&w.push({pubkey:f,isSigner:!0,isWritable:!1}),new Ot().add({keys:w,programId:this.programId,data:p})}static deactivate(t){const{stakePubkey:e,authorizedPubkey:n}=t,s=Ie.Deactivate,a=Mt(s);return new Ot().add({keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:or,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:a})}}ui.programId=new tt("Stake11111111111111111111111111111111111111"),ui.space=200;class mc{constructor(t,e,n,s){this.nodePubkey=void 0,this.authorizedVoter=void 0,this.authorizedWithdrawer=void 0,this.commission=void 0,this.nodePubkey=t,this.authorizedVoter=e,this.authorizedWithdrawer=n,this.commission=s}}class _d{constructor(){}static decodeInstructionType(t){this.checkProgramId(t.programId);const n=at("instruction").decode(t.data);let s;for(const[a,f]of Object.entries(ar))if(f.index==n){s=a;break}if(!s)throw new Error("Instruction type incorrect; not a VoteInstruction");return s}static decodeInitializeAccount(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,4);const{voteInit:e}=zt(ar.InitializeAccount,t.data);return{votePubkey:t.keys[0].pubkey,nodePubkey:t.keys[3].pubkey,voteInit:new mc(new tt(e.nodePubkey),new tt(e.authorizedVoter),new tt(e.authorizedWithdrawer),e.commission)}}static decodeAuthorize(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{newAuthorized:e,voteAuthorizationType:n}=zt(ar.Authorize,t.data);return{votePubkey:t.keys[0].pubkey,authorizedPubkey:t.keys[2].pubkey,newAuthorizedPubkey:new tt(e),voteAuthorizationType:{index:n}}}static decodeAuthorizeWithSeed(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{voteAuthorizeWithSeedArgs:{currentAuthorityDerivedKeyOwnerPubkey:e,currentAuthorityDerivedKeySeed:n,newAuthorized:s,voteAuthorizationType:a}}=zt(ar.AuthorizeWithSeed,t.data);return{currentAuthorityDerivedKeyBasePubkey:t.keys[2].pubkey,currentAuthorityDerivedKeyOwnerPubkey:new tt(e),currentAuthorityDerivedKeySeed:n,newAuthorizedPubkey:new tt(s),voteAuthorizationType:{index:a},votePubkey:t.keys[0].pubkey}}static decodeWithdraw(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{lamports:e}=zt(ar.Withdraw,t.data);return{votePubkey:t.keys[0].pubkey,authorizedWithdrawerPubkey:t.keys[2].pubkey,lamports:e,toPubkey:t.keys[1].pubkey}}static checkProgramId(t){if(!t.equals(fn.programId))throw new Error("invalid instruction; programId is not VoteProgram")}static checkKeyLength(t,e){if(t.length<e)throw new Error(`invalid instruction; found ${t.length} keys, expected at least ${e}`)}}const ar=Object.freeze({InitializeAccount:{index:0,layout:ct([at("instruction"),Uh()])},Authorize:{index:1,layout:ct([at("instruction"),Bt("newAuthorized"),at("voteAuthorizationType")])},Withdraw:{index:3,layout:ct([at("instruction"),De("lamports")])},UpdateValidatorIdentity:{index:4,layout:ct([at("instruction")])},AuthorizeWithSeed:{index:10,layout:ct([at("instruction"),Lh()])}}),Rd=Object.freeze({Voter:{index:0},Withdrawer:{index:1}});class fn{constructor(){}static initializeAccount(t){const{votePubkey:e,nodePubkey:n,voteInit:s}=t,a=ar.InitializeAccount,f=Mt(a,{voteInit:{nodePubkey:kt(s.nodePubkey.toBuffer()),authorizedVoter:kt(s.authorizedVoter.toBuffer()),authorizedWithdrawer:kt(s.authorizedWithdrawer.toBuffer()),commission:s.commission}}),u={keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:on,isSigner:!1,isWritable:!1},{pubkey:or,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:f};return new Ht(u)}static createAccount(t){const e=new Ot;return e.add(Ee.createAccount({fromPubkey:t.fromPubkey,newAccountPubkey:t.votePubkey,lamports:t.lamports,space:this.space,programId:this.programId})),e.add(this.initializeAccount({votePubkey:t.votePubkey,nodePubkey:t.voteInit.nodePubkey,voteInit:t.voteInit}))}static authorize(t){const{votePubkey:e,authorizedPubkey:n,newAuthorizedPubkey:s,voteAuthorizationType:a}=t,f=ar.Authorize,u=Mt(f,{newAuthorized:kt(s.toBuffer()),voteAuthorizationType:a.index}),p=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:or,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}];return new Ot().add({keys:p,programId:this.programId,data:u})}static authorizeWithSeed(t){const{currentAuthorityDerivedKeyBasePubkey:e,currentAuthorityDerivedKeyOwnerPubkey:n,currentAuthorityDerivedKeySeed:s,newAuthorizedPubkey:a,voteAuthorizationType:f,votePubkey:u}=t,p=ar.AuthorizeWithSeed,w=Mt(p,{voteAuthorizeWithSeedArgs:{currentAuthorityDerivedKeyOwnerPubkey:kt(n.toBuffer()),currentAuthorityDerivedKeySeed:s,newAuthorized:kt(a.toBuffer()),voteAuthorizationType:f.index}}),E=[{pubkey:u,isSigner:!1,isWritable:!0},{pubkey:or,isSigner:!1,isWritable:!1},{pubkey:e,isSigner:!0,isWritable:!1}];return new Ot().add({keys:E,programId:this.programId,data:w})}static withdraw(t){const{votePubkey:e,authorizedWithdrawerPubkey:n,lamports:s,toPubkey:a}=t,f=ar.Withdraw,u=Mt(f,{lamports:s}),p=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:a,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1}];return new Ot().add({keys:p,programId:this.programId,data:u})}static safeWithdraw(t,e,n){if(t.lamports>e-n)throw new Error("Withdraw will leave vote account with insufficient funds.");return fn.withdraw(t)}static updateValidatorIdentity(t){const{votePubkey:e,authorizedWithdrawerPubkey:n,nodePubkey:s}=t,a=ar.UpdateValidatorIdentity,f=Mt(a),u=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!0,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}];return new Ot().add({keys:u,programId:this.programId,data:f})}}fn.programId=new tt("Vote111111111111111111111111111111111111111"),fn.space=3762;const wc=new tt("Va1idator1nfo111111111111111111111111111111"),Td=j({name:Q(),website:gt(Q()),details:gt(Q()),keybaseUsername:gt(Q())});class Ro{constructor(t,e){this.key=void 0,this.info=void 0,this.key=t,this.info=e}static fromConfigData(t){let e=[...t];if(Le(e)!==2)return null;const s=[];for(let a=0;a<2;a++){const f=new tt(Fe(e,0,nr)),u=ir(e)===1;s.push({publicKey:f,isSigner:u})}if(s[0].publicKey.equals(wc)&&s[1].isSigner){const a=Nr().decode(dt.Buffer.from(e)),f=JSON.parse(a);return la(f,Td),new Ro(s[1].publicKey,f)}return null}}const Md=new tt("Vote111111111111111111111111111111111111111"),Pd=ct([Bt("nodePubkey"),Bt("authorizedWithdrawer"),Ct("commission"),Be(),Ae(ct([Be("slot"),at("confirmationCount")]),Sr(at(),-8),"votes"),Ct("rootSlotValid"),Be("rootSlot"),Be(),Ae(ct([Be("epoch"),Bt("authorizedVoter")]),Sr(at(),-8),"authorizedVoters"),ct([Ae(ct([Bt("authorizedPubkey"),Be("epochOfLastAuthorizedSwitch"),Be("targetEpoch")]),32,"buf"),Be("idx"),Ct("isEmpty")],"priorVoters"),Be(),Ae(ct([Be("epoch"),Be("credits"),Be("prevCredits")]),Sr(at(),-8),"epochCredits"),ct([Be("slot"),Be("timestamp")],"lastTimestamp")]);class To{constructor(t){this.nodePubkey=void 0,this.authorizedWithdrawer=void 0,this.commission=void 0,this.rootSlot=void 0,this.votes=void 0,this.authorizedVoters=void 0,this.priorVoters=void 0,this.epochCredits=void 0,this.lastTimestamp=void 0,this.nodePubkey=t.nodePubkey,this.authorizedWithdrawer=t.authorizedWithdrawer,this.commission=t.commission,this.rootSlot=t.rootSlot,this.votes=t.votes,this.authorizedVoters=t.authorizedVoters,this.priorVoters=t.priorVoters,this.epochCredits=t.epochCredits,this.lastTimestamp=t.lastTimestamp}static fromAccountData(t){const n=Pd.decode(kt(t),4);let s=n.rootSlot;return n.rootSlotValid||(s=null),new To({nodePubkey:new tt(n.nodePubkey),authorizedWithdrawer:new tt(n.authorizedWithdrawer),commission:n.commission,votes:n.votes,rootSlot:s,authorizedVoters:n.authorizedVoters.map(Cd),priorVoters:Ud(n.priorVoters),epochCredits:n.epochCredits,lastTimestamp:n.lastTimestamp})}}function Cd({authorizedVoter:o,epoch:t}){return{epoch:t,authorizedVoter:new tt(o)}}function bc({authorizedPubkey:o,epochOfLastAuthorizedSwitch:t,targetEpoch:e}){return{authorizedPubkey:new tt(o),epochOfLastAuthorizedSwitch:t,targetEpoch:e}}function Ud({buf:o,idx:t,isEmpty:e}){return e?[]:[...o.slice(t+1).map(bc),...o.slice(0,t).map(bc)]}const xc={http:{devnet:"http://api.devnet.solana.com",testnet:"http://api.testnet.solana.com","mainnet-beta":"http://api.mainnet-beta.solana.com/"},https:{devnet:"https://api.devnet.solana.com",testnet:"https://api.testnet.solana.com","mainnet-beta":"https://api.mainnet-beta.solana.com/"}};function Ld(o,t){const e=t===!1?"http":"https";if(!o)return xc[e].devnet;const n=xc[e][o];if(!n)throw new Error(`Unknown ${e} cluster: ${o}`);return n}async function Fd(o,t,e,n){let s,a;e&&Object.prototype.hasOwnProperty.call(e,"lastValidBlockHeight")||e&&Object.prototype.hasOwnProperty.call(e,"nonceValue")?(s=e,a=n):a=e;const f=a&&{skipPreflight:a.skipPreflight,preflightCommitment:a.preflightCommitment||a.commitment,minContextSlot:a.minContextSlot},u=await o.sendRawTransaction(t,f),p=a&&a.commitment,E=(await(s?o.confirmTransaction(s,p):o.confirmTransaction(u,p))).value;if(E.err)throw u!=null?new An({action:f!=null&&f.skipPreflight?"send":"simulate",signature:u,transactionMessage:`Status: (${JSON.stringify(E)})`}):new Error(`Raw transaction ${u} failed (${JSON.stringify(E)})`);return u}const fi=Object.freeze(Object.defineProperty({__proto__:null,Account:Rh,AddressLookupTableAccount:yo,AddressLookupTableInstruction:kd,AddressLookupTableProgram:Bo,Authorized:yc,BLOCKHASH_CACHE_TIMEOUT_MS:Ya,BPF_LOADER_DEPRECATED_PROGRAM_ID:Th,BPF_LOADER_PROGRAM_ID:Vh,BpfLoader:jh,COMPUTE_BUDGET_INSTRUCTION_LAYOUTS:sr,ComputeBudgetInstruction:Ed,ComputeBudgetProgram:Ao,Connection:xd,Ed25519Program:ci,Enum:vh,EpochSchedule:Va,FeeCalculatorLayout:Ka,Keypair:cn,LAMPORTS_PER_SOL:1e9,LOOKUP_TABLE_INSTRUCTION_LAYOUTS:mr,Loader:$r,Lockup:Tn,MAX_SEED_LENGTH:Na,Message:Ze,MessageAccountKeys:Bn,MessageV0:zr,NONCE_ACCOUNT_LENGTH:po,NonceAccount:ni,PACKET_DATA_SIZE:Ar,PUBLIC_KEY_LENGTH:nr,PublicKey:tt,SIGNATURE_LENGTH_IN_BYTES:Sn,SOLANA_SCHEMA:In,STAKE_CONFIG_ID:gc,STAKE_INSTRUCTION_LAYOUTS:Ie,SYSTEM_INSTRUCTION_LAYOUTS:Vt,SYSVAR_CLOCK_PUBKEY:or,SYSVAR_EPOCH_SCHEDULE_PUBKEY:Oh,SYSVAR_INSTRUCTIONS_PUBKEY:Nh,SYSVAR_RECENT_BLOCKHASHES_PUBKEY:ei,SYSVAR_RENT_PUBKEY:on,SYSVAR_REWARDS_PUBKEY:zh,SYSVAR_SLOT_HASHES_PUBKEY:Dh,SYSVAR_SLOT_HISTORY_PUBKEY:$h,SYSVAR_STAKE_HISTORY_PUBKEY:ri,Secp256k1Program:un,SendTransactionError:An,SolanaJSONRPCError:ut,SolanaJSONRPCErrorCode:Wh,StakeAuthorizationLayout:vd,StakeInstruction:Ad,StakeProgram:ui,Struct:so,SystemInstruction:qh,SystemProgram:Ee,Transaction:Ot,TransactionExpiredBlockheightExceededError:ao,TransactionExpiredNonceInvalidError:nn,TransactionExpiredTimeoutError:co,TransactionInstruction:Ht,TransactionMessage:fo,TransactionStatus:yr,VALIDATOR_INFO_KEY:wc,VERSION_PREFIX_MASK:Qn,VOTE_PROGRAM_ID:Md,ValidatorInfo:Ro,VersionedMessage:uo,VersionedTransaction:ho,VoteAccount:To,VoteAuthorizationLayout:Rd,VoteInit:mc,VoteInstruction:_d,VoteProgram:fn,clusterApiUrl:Ld,sendAndConfirmRawTransaction:Fd,sendAndConfirmTransaction:lo},Symbol.toStringTag,{value:"Module"})),vr=ke;var Mo={exports:{}};Mo.exports,function(o){var t=function(){var e=String.fromCharCode,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",a={};function f(p,w){if(!a[p]){a[p]={};for(var E=0;E<p.length;E++)a[p][p.charAt(E)]=E}return a[p][w]}var u={compressToBase64:function(p){if(p==null)return"";var w=u._compress(p,6,function(E){return n.charAt(E)});switch(w.length%4){default:case 0:return w;case 1:return w+"===";case 2:return w+"==";case 3:return w+"="}},decompressFromBase64:function(p){return p==null?"":p==""?null:u._decompress(p.length,32,function(w){return f(n,p.charAt(w))})},compressToUTF16:function(p){return p==null?"":u._compress(p,15,function(w){return e(w+32)})+" "},decompressFromUTF16:function(p){return p==null?"":p==""?null:u._decompress(p.length,16384,function(w){return p.charCodeAt(w)-32})},compressToUint8Array:function(p){for(var w=u.compress(p),E=new Uint8Array(w.length*2),I=0,M=w.length;I<M;I++){var T=w.charCodeAt(I);E[I*2]=T>>>8,E[I*2+1]=T%256}return E},decompressFromUint8Array:function(p){if(p==null)return u.decompress(p);for(var w=new Array(p.length/2),E=0,I=w.length;E<I;E++)w[E]=p[E*2]*256+p[E*2+1];var M=[];return w.forEach(function(T){M.push(e(T))}),u.decompress(M.join(""))},compressToEncodedURIComponent:function(p){return p==null?"":u._compress(p,6,function(w){return s.charAt(w)})},decompressFromEncodedURIComponent:function(p){return p==null?"":p==""?null:(p=p.replace(/ /g,"+"),u._decompress(p.length,32,function(w){return f(s,p.charAt(w))}))},compress:function(p){return u._compress(p,16,function(w){return e(w)})},_compress:function(p,w,E){if(p==null)return"";var I,M,T={},U={},_="",C="",L="",$=2,N=3,H=2,D=[],F=0,W=0,q;for(q=0;q<p.length;q+=1)if(_=p.charAt(q),Object.prototype.hasOwnProperty.call(T,_)||(T[_]=N++,U[_]=!0),C=L+_,Object.prototype.hasOwnProperty.call(T,C))L=C;else{if(Object.prototype.hasOwnProperty.call(U,L)){if(L.charCodeAt(0)<256){for(I=0;I<H;I++)F=F<<1,W==w-1?(W=0,D.push(E(F)),F=0):W++;for(M=L.charCodeAt(0),I=0;I<8;I++)F=F<<1|M&1,W==w-1?(W=0,D.push(E(F)),F=0):W++,M=M>>1}else{for(M=1,I=0;I<H;I++)F=F<<1|M,W==w-1?(W=0,D.push(E(F)),F=0):W++,M=0;for(M=L.charCodeAt(0),I=0;I<16;I++)F=F<<1|M&1,W==w-1?(W=0,D.push(E(F)),F=0):W++,M=M>>1}$--,$==0&&($=Math.pow(2,H),H++),delete U[L]}else for(M=T[L],I=0;I<H;I++)F=F<<1|M&1,W==w-1?(W=0,D.push(E(F)),F=0):W++,M=M>>1;$--,$==0&&($=Math.pow(2,H),H++),T[C]=N++,L=String(_)}if(L!==""){if(Object.prototype.hasOwnProperty.call(U,L)){if(L.charCodeAt(0)<256){for(I=0;I<H;I++)F=F<<1,W==w-1?(W=0,D.push(E(F)),F=0):W++;for(M=L.charCodeAt(0),I=0;I<8;I++)F=F<<1|M&1,W==w-1?(W=0,D.push(E(F)),F=0):W++,M=M>>1}else{for(M=1,I=0;I<H;I++)F=F<<1|M,W==w-1?(W=0,D.push(E(F)),F=0):W++,M=0;for(M=L.charCodeAt(0),I=0;I<16;I++)F=F<<1|M&1,W==w-1?(W=0,D.push(E(F)),F=0):W++,M=M>>1}$--,$==0&&($=Math.pow(2,H),H++),delete U[L]}else for(M=T[L],I=0;I<H;I++)F=F<<1|M&1,W==w-1?(W=0,D.push(E(F)),F=0):W++,M=M>>1;$--,$==0&&($=Math.pow(2,H),H++)}for(M=2,I=0;I<H;I++)F=F<<1|M&1,W==w-1?(W=0,D.push(E(F)),F=0):W++,M=M>>1;for(;;)if(F=F<<1,W==w-1){D.push(E(F));break}else W++;return D.join("")},decompress:function(p){return p==null?"":p==""?null:u._decompress(p.length,32768,function(w){return p.charCodeAt(w)})},_decompress:function(p,w,E){var I=[],M=4,T=4,U=3,_="",C=[],L,$,N,H,D,F,W,q={val:E(0),position:w,index:1};for(L=0;L<3;L+=1)I[L]=L;for(N=0,D=Math.pow(2,2),F=1;F!=D;)H=q.val&q.position,q.position>>=1,q.position==0&&(q.position=w,q.val=E(q.index++)),N|=(H>0?1:0)*F,F<<=1;switch(N){case 0:for(N=0,D=Math.pow(2,8),F=1;F!=D;)H=q.val&q.position,q.position>>=1,q.position==0&&(q.position=w,q.val=E(q.index++)),N|=(H>0?1:0)*F,F<<=1;W=e(N);break;case 1:for(N=0,D=Math.pow(2,16),F=1;F!=D;)H=q.val&q.position,q.position>>=1,q.position==0&&(q.position=w,q.val=E(q.index++)),N|=(H>0?1:0)*F,F<<=1;W=e(N);break;case 2:return""}for(I[3]=W,$=W,C.push(W);;){if(q.index>p)return"";for(N=0,D=Math.pow(2,U),F=1;F!=D;)H=q.val&q.position,q.position>>=1,q.position==0&&(q.position=w,q.val=E(q.index++)),N|=(H>0?1:0)*F,F<<=1;switch(W=N){case 0:for(N=0,D=Math.pow(2,8),F=1;F!=D;)H=q.val&q.position,q.position>>=1,q.position==0&&(q.position=w,q.val=E(q.index++)),N|=(H>0?1:0)*F,F<<=1;I[T++]=e(N),W=T-1,M--;break;case 1:for(N=0,D=Math.pow(2,16),F=1;F!=D;)H=q.val&q.position,q.position>>=1,q.position==0&&(q.position=w,q.val=E(q.index++)),N|=(H>0?1:0)*F,F<<=1;I[T++]=e(N),W=T-1,M--;break;case 2:return C.join("")}if(M==0&&(M=Math.pow(2,U),U++),I[W])_=I[W];else if(W===T)_=$+$.charAt(0);else return null;C.push(_),I[T++]=$+_.charAt(0),M--,$=_,M==0&&(M=Math.pow(2,U),U++)}}};return u}();o!=null?o.exports=t:typeof angular<"u"&&angular!=null&&angular.module("LZString",[]).factory("LZString",function(){return t})}(Mo);var Od=Mo.exports;const cr=ln(Od);class ur{constructor(t){we(this,"env");we(this,"url");this.env=t??"prod",this.env==="prod"?this.url="https://api.coinflow.cash":this.env==="local"?this.url="http://localhost:5000":this.url=`https://api-${this.env}.coinflow.cash`}async getNSurePartnerId(t){return fetch(this.url+`/merchant/view/${t}`).then(e=>e.json()).then(e=>{var n;return((n=e.nSureSettings)==null?void 0:n.nSurePartnerId)||e.nSurePartnerId}).catch(e=>{console.error(e)})}async getCreditBalance(t,e,n){const s=await fetch(this.url+`/api/customer/balances/${e}`,{method:"GET",headers:{"x-coinflow-auth-wallet":t,"x-coinflow-auth-blockchain":n}}),{credits:a}=await s.json();return a}static getCoinflowBaseUrl(t){return!t||t==="prod"?"https://coinflow.cash":t==="local"?"http://localhost:3000":`https://${t}.coinflow.cash`}static getCoinflowApiUrl(t){return!t||t==="prod"?"https://api.coinflow.cash":t==="local"?"http://localhost:5000":`https://api-${t}.coinflow.cash`}static getCoinflowUrl({walletPubkey:t,route:e,routePrefix:n,env:s,amount:a,transaction:f,blockchain:u,webhookInfo:p,email:w,loaderBackground:E,handleHeightChange:I,bankAccountLinkRedirect:M,additionalWallets:T,nearDeposit:U,chargebackProtectionData:_,merchantCss:C,color:L,rent:$,lockDefaultToken:N,token:H,tokens:D,planCode:F,disableApplePay:W,disableGooglePay:q,customerInfo:At,settlementType:yt,lockAmount:ot,nativeSolToConvert:vt,theme:R,usePermit:l,transactionSigner:y,authOnly:k,deviceId:A,jwtToken:S,origins:B}){var d;const P=n?`/${n}/${u}`:`/${u}`,b=new URL(P+e,ur.getCoinflowBaseUrl(s));if(b.searchParams.append("pubkey",t),f&&b.searchParams.append("transaction",f),a&&b.searchParams.append("amount",a.toString()),p&&b.searchParams.append("webhookInfo",cr.compressToEncodedURIComponent(JSON.stringify(p))),R&&b.searchParams.append("theme",cr.compressToEncodedURIComponent(JSON.stringify(R))),At&&b.searchParams.append("customerInfo",cr.compressToEncodedURIComponent(JSON.stringify(At))),w&&b.searchParams.append("email",w),H&&b.searchParams.append("token",H.toString()),D&&b.searchParams.append("tokens",D.toString()),E&&b.searchParams.append("loaderBackground",E),I&&b.searchParams.append("useHeightChange","true"),M&&b.searchParams.append("bankAccountLinkRedirect",M),T&&b.searchParams.append("additionalWallets",cr.compressToEncodedURIComponent(JSON.stringify(T))),U&&b.searchParams.append("nearDeposit",U),_&&b.searchParams.append("chargebackProtectionData",cr.compressToEncodedURIComponent(JSON.stringify(_))),A)b.searchParams.append("deviceId",A);else if(typeof window<"u"){const v=(d=window==null?void 0:window.nSureSDK)==null?void 0:d.getDeviceId();v&&b.searchParams.append("deviceId",v)}return C&&b.searchParams.append("merchantCss",C),L&&b.searchParams.append("color",L),$&&b.searchParams.append("rent",$.lamports.toString()),vt&&b.searchParams.append("nativeSolToConvert",vt.lamports.toString()),N&&b.searchParams.append("lockDefaultToken","true"),F&&b.searchParams.append("planCode",F),W&&b.searchParams.append("disableApplePay","true"),q&&b.searchParams.append("disableGooglePay","true"),yt&&b.searchParams.append("settlementType",yt),ot&&b.searchParams.append("lockAmount","true"),l===!1&&b.searchParams.append("usePermit","false"),y&&b.searchParams.append("transactionSigner",y),k===!0&&b.searchParams.append("authOnly","true"),S&&b.searchParams.append("jwtToken",S),B&&b.searchParams.append("origins",cr.compressToEncodedURIComponent(JSON.stringify(B))),b.toString()}static getTransaction(t){return this.byBlockchain(t.blockchain,{solana:()=>{if(!("transaction"in t))return;const{transaction:e}=t;if(!fi)throw new Error("@solana/web3.js dependency is required for Solana");if(!vr)throw new Error("bs58 dependency is required for Solana");if(e)return vr.encode(e.serialize({requireAllSignatures:!1,verifySignatures:!1}))},polygon:()=>{if(!("transaction"in t))return;const{transaction:e}=t;return cr.compressToEncodedURIComponent(JSON.stringify(e))},eth:()=>{if(!("transaction"in t))return;const{transaction:e}=t;return cr.compressToEncodedURIComponent(JSON.stringify(e))},base:()=>{if(!("transaction"in t))return;const{transaction:e}=t;return cr.compressToEncodedURIComponent(JSON.stringify(e))},near:()=>{if(!("action"in t))return;const{action:e}=t;return cr.compressToEncodedURIComponent(JSON.stringify(e))}})()}static byBlockchain(t,e){switch(t){case"solana":return e.solana;case"near":return e.near;case"polygon":return e.polygon;case"eth":return e.eth;case"base":return e.base;default:throw new Error("blockchain not supported!")}}}var kc=(o=>(o.SignMessage="signMessage",o.SignTransaction="signTransaction",o.SendTransaction="sendTransaction",o.HeightChange="heightChange",o.Success="success",o))(kc||{});function hi({wallet:o}){return"publicKey"in o?o.publicKey.toString():"address"in o?o.address:"accountId"in o?o.accountId:null}function Ec(o,t){let e;try{if(e=JSON.parse(o),!("method"in e)||!("data"in e))return}catch(a){console.error("handleIFrameMessage JSON parse",a);return}const{data:n,method:s}=e;switch(s){case"signMessage":return t.handleSignMessage?t.handleSignMessage(n):void 0;case"signTransaction":return t.handleSignTransaction?t.handleSignTransaction(n):void 0;case"sendTransaction":return t.handleSendTransaction(n);case"heightChange":return t.handleHeightChange?t.handleHeightChange(n):void 0;case"success":if(!t.onSuccess)return;t.onSuccess(e.info);return}console.warn(`Didn't expect to get here, handleIFrameMessage method:${s} is not one of ${Object.values(kc)}`)}function li(o){return ur.byBlockchain(o.blockchain,{solana:()=>Nd(o),near:()=>zd(o),eth:()=>Po(o),polygon:()=>Po(o),base:()=>Po(o)})()}function Nd({wallet:o,onSuccess:t}){return{handleSendTransaction:async e=>{const n=Ic(e);return await o.sendTransaction(n)},handleSignMessage:async e=>{const n=o.signMessage;if(!n)throw new Error("signMessage is not supported by this wallet");const s=await n(new TextEncoder().encode(e));if(!vr)throw new Error("bs58 dependency is required");return vr.encode(s)},handleSignTransaction:async e=>{const n=o.signTransaction;if(!n)throw new Error("signTransaction is not supported by this wallet");const s=Ic(e),a=await n(s);if(!vr)throw new Error("bs58 dependency is required");return vr.encode(a.serialize({requireAllSignatures:!1,verifySignatures:!1}))},onSuccess:t}}function Ic(o){if(!fi)throw new Error("@solana/web3.js is not defined. Please install @solana/web3.js into your project");if(!vr)throw new Error("bs58 is not defined. Please install bs58 into your project");const t=vr.decode(o),e=fi.VersionedTransaction.deserialize(t);return e.version==="legacy"?fi.Transaction.from(t):e}function zd({wallet:o,onSuccess:t}){const e=o;return{handleSendTransaction:async n=>{const s=JSON.parse(Buffer.from(n,"base64").toString()),a=await e.signAndSendTransaction(s);if(!a)throw new Error("Transaction did not send");const{transaction:f}=a;return f.hash},onSuccess:t}}function Po({wallet:o,onSuccess:t}){const e=o;return{handleSendTransaction:async n=>{const s=JSON.parse(Buffer.from(n,"base64").toString()),{hash:a}=await e.sendTransaction(s);return a},handleSignMessage:async n=>e.signMessage(n),onSuccess:t}}const Mn="tokenExCardNumber",Pn="tokenExCardCvv",Sc={[qr.VISA]:"visa",[qr.MASTERCARD]:"masterCard",[qr.AMEX]:"americanExpress",[qr.DISCOVER]:"discover"};async function di({token:o,origins:t,env:e}){return new Promise((n,s)=>{fetch(new ur(e).url+"/api/checkout/authentication-key",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({origins:[...t??[],window.location.origin],token:o})}).then(async a=>{n(await a.json())}).catch(a=>s(a))})}function Co({env:o,setTokenExScriptLoaded:t}){const e="tokenex-script";if(document.head.querySelector(`#${e}`))return;const n=document.createElement("script");n.src=o==="prod"?"https://htp.tokenex.com/iframe/iframe-v3.min.js":"https://test-htp.tokenex.com/iframe/iframe-v3.min.js",n.id=e,document.head.appendChild(n),document.getElementById(e).addEventListener("load",()=>{console.log("Setting tokenExScriptLoaded to true!"),t(!0)})}function Uo({iframe:o,setCachedToken:t,setLoaded:e}){const n=async()=>(o.tokenize(),await new Promise((s,a)=>{o.on("tokenize",f=>{t(f.token),s(f)}),o.on("validate",f=>{(!f.isValid||f.isCvvValid===!1)&&a(f)})}));return o.on("change",()=>t(void 0)),o.on("cvvChange",()=>t(void 0)),o.on("load",()=>{setTimeout(()=>e(!0),350);const s=document.querySelector("#tx_iframe_tokenExCardNumber");s&&(s.scrolling="no")}),e(!1),o.load(),{...o,tokenize:n}}async function Bc({token:o,cardType:t,css:e,debug:n,fontFamily:s,origins:a,tokenExScriptLoaded:f,env:u,setCachedToken:p,setLoaded:w}){if(!f&&typeof TokenEx>"u"){console.warn("Warning Unable to load TokenEx on first attempt waiting for load event from document.head.script#tokenex-script");return}const E=Sc[t],I=await di({token:o,origins:a,env:u}),{styles:M}=Lo(e),T={...I,placeholder:"CVV",enablePrettyFormat:!0,styles:M,token:o,cvvOnly:!0,cvv:!0,cvvContainerID:Pn,cardType:E,debug:n??!1,font:s},U=TokenEx.Iframe(Pn,T);return Uo({iframe:U,setCachedToken:p,setLoaded:w})}async function Ac({css:o,debug:t,fontFamily:e,origins:n,tokenExScriptLoaded:s,env:a,setCachedToken:f,setLoaded:u}){if(!s&&typeof TokenEx>"u"){console.warn("Warning Unable to load TokenEx on first attempt waiting for load event from document.head.script#tokenex-script");return}const p=await di({origins:n,env:a}),{styles:w}=Lo(o),E=TokenEx.Iframe(Mn,{...p,placeholder:"0000 0000 0000 0000",cvvPlaceholder:"CVV",enablePrettyFormat:!0,cvv:!0,cvvContainerID:Pn,styles:w,font:e,debug:t??!1});return Uo({iframe:E,setCachedToken:f,setLoaded:u})}async function vc({css:o,debug:t,fontFamily:e,origins:n,tokenExScriptLoaded:s,env:a,setCachedToken:f,setLoaded:u}){if(!s&&typeof TokenEx>"u"){console.warn("Warning Unable to load TokenEx on first attempt waiting for load event from document.head.script#tokenex-script");return}const p=await di({origins:n,env:a}),{styles:w}=Lo(o),E=TokenEx.Iframe(Mn,{...p,placeholder:"0000 0000 0000 0000",enablePrettyFormat:!0,cvv:!1,styles:w,font:e,debug:t??!1});return Uo({iframe:E,setCachedToken:f,setLoaded:u})}function Lo(o){var n,s,a;const t=JSON.parse(o);return{styles:{base:hn(t.base),focus:hn(t.focus),error:hn(t.error),cvv:{base:hn((n=t.cvv)==null?void 0:n.base),focus:hn((s=t.cvv)==null?void 0:s.focus),error:hn((a=t.cvv)==null?void 0:a.error)}}}}function hn(o){if(!o)return"";if(typeof o=="string")return o;let t="";for(const[e,n]of Object.entries(o)){let s="";e.split("").forEach(a=>{a.toUpperCase()===a?s+="-"+a.toLowerCase():s+=a}),t+=s+":"+n+";"}return t}const Dd=lt.defineComponent({name:"CoinflowIFrame",props:{args:{type:Object,required:!0}},computed:{url(){return ur.getCoinflowUrl(this.args)}},emits:{onMessage({data:o,origin:t}){return console.log({data:o,origin:t}),!0}},methods:{sendMessage(o){const t=this.$refs.iframeRef;if(!(t!=null&&t.contentWindow))throw new Error("Iframe not defined");t.contentWindow.postMessage(o,"*")},handleIframeMessages({data:o,origin:t}){if(!t.includes(ur.getCoinflowBaseUrl(this.args.env)))return;this.$emit("onMessage",{data:o,origin:t});const e=Ec(o,this.args);e&&e.then(this.sendMessage).catch(n=>{console.error(n),this.sendMessage("ERROR "+n.message)})},async listenForMessage(o){let t;return new Promise((e,n)=>{if(t=({data:s,origin:a})=>{if(a.includes(ur.getCoinflowBaseUrl(this.args.env))){if(s.startsWith("ERROR")){n(new Error(s.replace("ERROR","")));return}o(s)&&e(s)}},!window)throw new Error("Window not defined");window.addEventListener("message",t)}).finally(()=>{window.removeEventListener("message",t)})},async sendAndReceiveMessage(o,t){return this.sendMessage(o),this.listenForMessage(t)}},mounted(){if(!window)throw new Error("Window not defined");return window.addEventListener("message",this.handleIframeMessages),()=>{window.removeEventListener("message",this.handleIframeMessages)}}}),Fo=(o,t)=>{const e=o.__vccOpts||o;for(const[n,s]of t)e[n]=s;return e},$d=["src","scrolling"];function Wd(o,t,e,n,s,a){return lt.openBlock(),lt.createElementBlock("iframe",{style:{height:"100%",width:"100%"},ref:"iframeRef",allow:"payment;camera",title:"withdraw",frameBorder:"0",src:o.url,scrolling:o.args.handleHeightChange?"no":"yes",onLoad:t[0]||(t[0]=()=>{const f=o.$refs.iframeRef;f&&(f.style.opacity="1")})},null,40,$d)}const pi=Fo(Dd,[["render",Wd]]),Kd=lt.defineComponent({name:"CoinflowWithdraw",components:{CoinflowIFrame:pi},props:{args:{type:Object,required:!0}},computed:{iframeProps(){const o=hi(this.args);return{...this.args,walletPubkey:o,route:`/withdraw/${this.args.merchantId}`,transaction:void 0}},messageHandlers(){return{...li(this.args),handleHeightChange:this.args.handleHeightChange}}}});function qd(o,t,e,n,s,a){const f=lt.resolveComponent("coinflow-i-frame");return lt.openBlock(),lt.createBlock(f,{args:{...o.iframeProps,...o.messageHandlers}},null,8,["args"])}const Hd=Fo(Kd,[["render",qd]]),Vd=lt.defineComponent({name:"CoinflowPurchase",components:{CoinflowIFrame:pi},props:{args:{type:Object,required:!0}},computed:{iframeProps(){const o=hi(this.args);return{...this.args,walletPubkey:o,route:`/purchase/${this.args.merchantId}`,transaction:ur.getTransaction(this.args)}},messageHandlers(){return{...li(this.args),handleHeightChange:this.args.handleHeightChange}}}});function jd(o,t,e,n,s,a){const f=lt.resolveComponent("coinflow-i-frame");return lt.openBlock(),lt.createBlock(f,{args:{...o.iframeProps,...o.messageHandlers}},null,8,["args"])}const Gd=Fo(Vd,[["render",jd]]),_c=o=>{const t=lt.ref(!1),e=lt.ref(!1),n=lt.ref(void 0),s=lt.ref(void 0);lt.onMounted(()=>{Co({env:o,setTokenExScriptLoaded:()=>{console.log("tokenExScriptLoaded.value = true"),e.value=!0}})});const a=I=>s.value=I,f=()=>t.value=!0,u=I=>n.value=I,p=async({token:I,cardType:M,css:T,debug:U,fontFamily:_,origins:C})=>{const L=await Bc({token:I,cardType:M,css:T,debug:U,fontFamily:_,origins:C,tokenExScriptLoaded:e.value,env:o,setCachedToken:a,setLoaded:f});return u(L),L},w=async({css:I,fontFamily:M,debug:T,origins:U})=>{const _=await Ac({css:I,debug:T,fontFamily:M,origins:U,tokenExScriptLoaded:e.value,env:o,setCachedToken:a,setLoaded:f});return u(_),_},E=async({css:I,fontFamily:M,debug:T,origins:U})=>{const _=await vc({css:I,debug:T,fontFamily:M,origins:U,tokenExScriptLoaded:e.value,env:o,setCachedToken:a,setLoaded:f});return u(_),_};return lt.watchEffect(I=>{n.value&&(n.value.load(),I(()=>{var M;return(M=n.value)==null?void 0:M.remove()}))}),{tokenExIframe:n,initializeTokenExIframe:w,initializeCvvOnlyTokenExIframe:p,initializeTokenExCardOnlyIframe:E,loaded:t,cachedToken:s,setTokenExScriptTag:Co,tokenExScriptLoaded:e}},Yd=["id"],Zd=lt.defineComponent({__name:"CoinflowCardNumberInput",props:{args:{type:Object,required:!0}},setup(o,{expose:t}){const{args:e}=o,{initializeTokenExIframe:n,tokenExIframe:s}=_c(e.env);async function a(){if(!s.value)throw new Error("Unable to get token");return s.value.tokenize()}t({getToken:a});function f(){return JSON.stringify(e.css)}return lt.watchEffect(()=>{n({css:f(),debug:e.debug,origins:e.origins,fontFamily:e.font})},{}),(u,p)=>(lt.openBlock(),lt.createElementBlock("div",{id:lt.unref(Mn)},null,8,Yd))}}),Jd=["id"],Rc=lt.defineComponent({__name:"CoinflowCvvInput",setup(o){return(t,e)=>(lt.openBlock(),lt.createElementBlock("div",{id:lt.unref(Pn)},null,8,Jd))}}),Xd=lt.defineComponent({__name:"CoinflowPurchaseProtection",props:{args:{type:Object,required:!0}},setup(o){const{args:{env:t,merchantId:e}}=o,n=lt.ref(void 0);lt.onMounted(()=>new ur(t).getNSurePartnerId(e).then(f=>n.value=f));function s(){return t==="prod"?"9JBW2RHC7JNJN8ZQ":"SANDBOX_CTCE4XK53ZW0R7V1"}function a(){return t==="prod"?"https://sdk.nsureapi.com/sdk.js":"https://sdk.nsureapi.com/sdk-sandbox.js"}return lt.watchEffect(f=>{if(!n.value)return;const u=document.createElement("script");u.src=a(),document.head.appendChild(u);const p=`window.nSureAsyncInit = function(deviceId) {
24
24
  window.nSureSDK.init({
25
25
  appId: '${s()}',
26
26
  partnerId: '${n.value}',
27
27
  });
28
- };`,w=document.createElement("script");w.innerHTML=p,document.head.appendChild(w),f(()=>{document.head.removeChild(u),document.head.removeChild(w)})}),(f,u)=>null}}),Qd=["id"],t0=lt.defineComponent({__name:"CoinflowCardNumberOnlyInput",props:{args:{type:Object,required:!0}},setup(o,{expose:t}){const{args:e}=o,{tokenExIframe:n,initializeTokenExCardOnlyIframe:s}=_c(e.env);async function a(){if(!n.value)throw new Error("Unable to get token");return n.value.tokenize()}t({getToken:a});function f(){return JSON.stringify(e.css)}return lt.watchEffect(()=>{s({css:f(),debug:e.debug,origins:e.origins})},{}),(u,p)=>(lt.openBlock(),lt.createElementBlock("div",{id:lt.unref(Mn)},null,8,Qd))}}),Tc=lt.defineComponent({__name:"MobileWalletButton",props:{args:{type:Object,required:!0},route:{type:String,required:!0}},setup(o){const{args:t,route:e}=o,{onSuccess:n}=t;function s(){const u=hi(t);return{...t,walletPubkey:u,transaction:void 0,routePrefix:"form",route:`/${e}/${t.merchantId}`}}function a(){return{...li(t),handleHeightChange:t.handleHeightChange}}function f({data:u}){try{const p=JSON.parse(u);if(!("method"in p)||p.method!=="getToken")return}catch{return}n==null||n(u)}return(u,p)=>(lt.openBlock(),lt.createBlock(pi,{onOnMessage:f,args:{...s(),...a()}},null,8,["args"]))}}),e0=lt.defineComponent({__name:"CoinflowApplePayButton",props:{args:{type:Object,required:!0}},setup(o){return(t,e)=>(lt.openBlock(),lt.createBlock(Tc,{route:"apple-pay",args:o.args},null,8,["args"]))}}),r0=lt.defineComponent({__name:"CoinflowGooglePayButton",props:{args:{type:Object,required:!0}},setup(o){return(t,e)=>(lt.openBlock(),lt.createBlock(Tc,{route:"google-pay",args:o.args},null,8,["args"]))}});St.CARD_TYPE_MAPPING=Sc,St.CardType=qr,St.CoinflowApplePayButton=e0,St.CoinflowCardNumberInput=Zd,St.CoinflowCardNumberOnlyInput=t0,St.CoinflowCvvInput=Rc,St.CoinflowCvvOnlyInput=Rc,St.CoinflowGooglePayButton=r0,St.CoinflowIframe=pi,St.CoinflowPurchase=Gd,St.CoinflowPurchaseProtection=Xd,St.CoinflowUtils=ur,St.CoinflowWithdraw=Hd,St.MerchantStyle=rs,St.SettlementType=wr,St.TokenExCardNumberIframeId=Mn,St.TokenExCvvContainerID=Pn,St.doInitializeCvvOnlyTokenExIframe=Bc,St.doInitializeTokenExCardOnlyIframe=vc,St.doInitializeTokenExIframe=Ac,St.getHandlers=li,St.getIframeConfig=di,St.getWalletPubkey=hi,St.handleIFrameMessage=Ec,St.setTokenExScriptTag=Co,Object.defineProperty(St,Symbol.toStringTag,{value:"Module"})});
28
+ };`,w=document.createElement("script");w.innerHTML=p,document.head.appendChild(w),f(()=>{document.head.removeChild(u),document.head.removeChild(w)})}),(f,u)=>null}}),Qd=["id"],t0=lt.defineComponent({__name:"CoinflowCardNumberOnlyInput",props:{args:{type:Object,required:!0}},setup(o,{expose:t}){const{args:e}=o,{tokenExIframe:n,initializeTokenExCardOnlyIframe:s}=_c(e.env);async function a(){if(!n.value)throw new Error("Unable to get token");return n.value.tokenize()}t({getToken:a});function f(){return JSON.stringify(e.css)}return lt.watchEffect(()=>{s({css:f(),debug:e.debug,origins:e.origins,fontFamily:e.font})},{}),(u,p)=>(lt.openBlock(),lt.createElementBlock("div",{id:lt.unref(Mn)},null,8,Qd))}}),Tc=lt.defineComponent({__name:"MobileWalletButton",props:{args:{type:Object,required:!0},route:{type:String,required:!0}},setup(o){const{args:t,route:e}=o,{onSuccess:n}=t;function s(){const u=hi(t);return{...t,walletPubkey:u,transaction:void 0,routePrefix:"form",route:`/${e}/${t.merchantId}`}}function a(){return{...li(t),handleHeightChange:t.handleHeightChange}}function f({data:u}){try{const p=JSON.parse(u);if(!("method"in p)||p.method!=="getToken")return}catch{return}n==null||n(u)}return(u,p)=>(lt.openBlock(),lt.createBlock(pi,{onOnMessage:f,args:{...s(),...a()}},null,8,["args"]))}}),e0=lt.defineComponent({__name:"CoinflowApplePayButton",props:{args:{type:Object,required:!0}},setup(o){return(t,e)=>(lt.openBlock(),lt.createBlock(Tc,{route:"apple-pay",args:o.args},null,8,["args"]))}}),r0=lt.defineComponent({__name:"CoinflowGooglePayButton",props:{args:{type:Object,required:!0}},setup(o){return(t,e)=>(lt.openBlock(),lt.createBlock(Tc,{route:"google-pay",args:o.args},null,8,["args"]))}});St.CARD_TYPE_MAPPING=Sc,St.CardType=qr,St.CoinflowApplePayButton=e0,St.CoinflowCardNumberInput=Zd,St.CoinflowCardNumberOnlyInput=t0,St.CoinflowCvvInput=Rc,St.CoinflowCvvOnlyInput=Rc,St.CoinflowGooglePayButton=r0,St.CoinflowIframe=pi,St.CoinflowPurchase=Gd,St.CoinflowPurchaseProtection=Xd,St.CoinflowUtils=ur,St.CoinflowWithdraw=Hd,St.MerchantStyle=rs,St.SettlementType=wr,St.TokenExCardNumberIframeId=Mn,St.TokenExCvvContainerID=Pn,St.doInitializeCvvOnlyTokenExIframe=Bc,St.doInitializeTokenExCardOnlyIframe=vc,St.doInitializeTokenExIframe=Ac,St.getHandlers=li,St.getIframeConfig=di,St.getWalletPubkey=hi,St.handleIFrameMessage=Ec,St.setTokenExScriptTag=Co,Object.defineProperty(St,Symbol.toStringTag,{value:"Module"})});
@@ -285,6 +285,7 @@ type ReservoirItems = ReservoirItem | ReservoirItem[];
285
285
  export interface ReservoirRedeem extends CommonEvmRedeem {
286
286
  type: 'reservoir';
287
287
  items: ReservoirItems;
288
+ taker?: string;
288
289
  }
289
290
  export type EvmTransactionData = SafeMintRedeem | ReturnedTokenIdRedeem | ReservoirRedeem | KnownTokenIdRedeem | NormalRedeem;
290
291
  export interface CoinflowIFrameProps extends Omit<CoinflowTypes, 'merchantId'>, Pick<CoinflowCommonPurchaseProps, 'chargebackProtectionData' | 'webhookInfo' | 'amount' | 'customerInfo' | 'settlementType' | 'email' | 'planCode' | 'deviceId' | 'jwtToken' | 'origins'>, Pick<CoinflowCommonWithdrawProps, 'bankAccountLinkRedirect' | 'additionalWallets' | 'transactionSigner' | 'lockAmount' | 'lockDefaultToken' | 'origins'>, Pick<CoinflowEvmPurchaseProps, 'authOnly'>, Pick<CoinflowSolanaPurchaseProps, 'rent' | 'nativeSolToConvert' | 'token'> {
@@ -31,6 +31,7 @@ export interface CoinflowCardNumberInputProps {
31
31
  };
32
32
  debug?: boolean;
33
33
  origins?: string[];
34
+ font?: string;
34
35
  }
35
36
  export interface CoinflowCvvOnlyInputProps {
36
37
  token: string;
@@ -41,4 +42,5 @@ export interface CoinflowCvvOnlyInputProps {
41
42
  };
42
43
  debug?: boolean;
43
44
  origins?: string[];
45
+ font?: string;
44
46
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@coinflowlabs/vue",
3
3
  "private": false,
4
- "version": "0.2.1",
4
+ "version": "0.2.3",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist",