1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[919],{7274:(t,e,r)=>{r.d(e,{BP:()=>rI,NQ:()=>Y});var n=r(786),i=r.n(n),o=r(5223),s=r(1029),a=r(1628),c=r.n(a),u=r(8522),l=r.n(u),d=r(9610),h=(r(1580),r(1210)),_=r(2507),p=r.n(_),f=r(1029).Buffer;let R=t=>"version"in t;function A(t){return new TextDecoder("utf-8").decode(t)}function y(t){return c().encode(t)}function E(t){return s.Buffer.from(t,"base64")}function O(t){return"accounts"in t}async function m(t){let e=(await o.PublicKey.findProgramAddress([],t))[0];return await o.PublicKey.createWithSeed(e,"anchor:idl",t)}let N=d.struct([d.publicKey("authority"),d.vecU8("data")]);function g(t,e,r,n){return(null==t?void 0:t.length)?t[0].name?r(t):n(t):e()}function T(t){return t instanceof o.PublicKey?t:new o.PublicKey(t)}class I extends TypeError{constructor(t,e){let r,{message:n,...i}=t,{path:o}=t;super(0===o.length?n:"At path: "+o.join(".")+" -- "+n),this.value=void 0,this.key=void 0,this.type=void 0,this.refinement=void 0,this.path=void 0,this.branch=void 0,this.failures=void 0,Object.assign(this,i),this.name=this.constructor.name,this.failures=()=>{var n;return null!=(n=r)?n:r=[t,...e()]}}}function v(t){return"object"==typeof t&&null!=t}function C(t){return"string"==typeof t?JSON.stringify(t):""+t}function*w(t,e,r,n){var i;for(let o of(v(i=t)&&"function"==typeof i[Symbol.iterator]||(t=[t]),t)){let t=function(t,e,r,n){if(!0===t)return;!1===t?t={}:"string"==typeof t&&(t={message:t});let{path:i,branch:o}=e,{type:s}=r,{refinement:a,message:c="Expected a value of type `"+s+"`"+(a?" with refinement `"+a+"`":"")+", but received: `"+C(n)+"`"}=t;return{value:n,type:s,refinement:a,key:i[i.length-1],path:i,branch:o,...t,message:c}}(o,e,r,n);t&&(yield t)}}function*S(t,e,r){void 0===r&&(r={});let{path:n=[],branch:i=[t],coerce:o=!1,mask:s=!1}=r,a={path:n,branch:i};if(o&&(t=e.coercer(t,a),s&&"type"!==e.type&&v(e.schema)&&v(t)&&!Array.isArray(t)))for(let r in t)void 0===e.schema[r]&&delete t[r];let c=!0;for(let r of e.validator(t,a))c=!1,yield[r,void 0];for(let[r,u,l]of e.entries(t,a))for(let e of S(u,l,{path:void 0===r?n:[...n,r],branch:void 0===r?i:[...i,u],coerce:o,mask:s}))e[0]?(c=!1,yield[e[0],void 0]):o&&(u=e[1],void 0===r?t=u:t instanceof Map?t.set(r,u):t instanceof Set?t.add(u):v(t)&&(t[r]=u));if(c)for(let r of e.refiner(t,a))c=!1,yield[r,void 0];c&&(yield[void 0,t])}class b{constructor(t){this.TYPE=void 0,this.type=void 0,this.schema=void 0,this.coercer=void 0,this.validator=void 0,this.refiner=void 0,this.entries=void 0;let{type:e,schema:r,validator:n,refiner:i,coercer:o=t=>t,entries:s=function*(){}}=t;this.type=e,this.schema=r,this.entries=s,this.coercer=o,n?this.validator=(t,e)=>w(n(t,e),e,this,t):this.validator=()=>[],i?this.refiner=(t,e)=>w(i(t,e),e,this,t):this.refiner=()=>[]}assert(t){var e=t,r=this;let n=D(e,r);if(n[0])throw n[0]}create(t){return M(t,this)}is(t){var e,r;return e=t,r=this,!D(e,r)[0]}mask(t){var e=t,r=this;let n=D(e,r,{coerce:!0,mask:!0});if(!n[0])return n[1];throw n[0]}validate(t,e){return void 0===e&&(e={}),D(t,this,e)}}function M(t,e){let r=D(t,e,{coerce:!0});if(!r[0])return r[1];throw r[0]}function D(t,e,r){void 0===r&&(r={});let n=S(t,e,r),i=function(t){let{done:e,value:r}=t.next();return e?void 0:r}(n);return i[0]?[new I(i[0],function*(){for(let t of n)t[0]&&(yield t[0])}),void 0]:[void 0,i[1]]}function x(t,e){return new b({type:t,schema:null,validator:e})}function P(t){return new b({type:"array",schema:t,*entries(e){if(t&&Array.isArray(e))for(let[r,n]of e.entries())yield[r,n,t]},coercer:t=>Array.isArray(t)?t.slice():t,validator:t=>Array.isArray(t)||"Expected an array value, but received: "+C(t)})}function H(t){let e=C(t),r=typeof t;return new b({type:"literal",schema:"string"===r||"number"===r||"boolean"===r?t:null,validator:r=>r===t||"Expected the literal `"+e+"`, but received: "+C(r)})}function L(t){return new b({...t,validator:(e,r)=>null===e||t.validator(e,r),refiner:(e,r)=>null===e||t.refiner(e,r)})}function U(){return x("number",t=>"number"==typeof t&&!isNaN(t)||"Expected a number, but received: "+C(t))}function k(t){return new b({...t,validator:(e,r)=>void 0===e||t.validator(e,r),refiner:(e,r)=>void 0===e||t.refiner(e,r)})}function B(){return x("string",t=>"string"==typeof t||"Expected a string, but received: "+C(t))}function G(t){let e=Object.keys(t);return new b({type:"type",schema:t,*entries(r){if(v(r))for(let n of e)yield[n,r[n],t[n]]},validator:t=>v(t)||"Expected an object, but received: "+C(t)})}function V(t){let e=t.map(t=>t.type).join(" | ");return new b({type:"union",schema:null,coercer:(e,r)=>(t.find(t=>{let[r]=t.validate(e,{coerce:!0});return!r})||K()).coercer(e,r),validator(r,n){let i=[];for(let e of t){let[...t]=S(r,e,n),[o]=t;if(!o[0])return[];for(let[e]of t)e&&i.push(e)}return["Expected the value to satisfy a union of `"+e+"`, but received: "+C(r),...i]}})}function K(){return x("unknown",()=>!0)}async function $(t,e,r){if(e.length<=99)return await j(t,e,r);{let n=Array.apply(0,Array(Math.ceil(e.length/99))).map((t,r)=>e.slice(99*r,(r+1)*99));return(await Promise.all(n.map(e=>j(t,e,r)))).flat()}}async function j(t,e,r){let n=null!=r?r:t.commitment,{value:i,context:o}=await t.getMultipleAccountsInfoAndContext(e,n);return i.map((t,r)=>null===t?null:{publicKey:e[r],account:t,context:o})}async function q(t,e,r,n,i){var s;r&&r.length>0&&e.sign(...r);let a=e._compile(),c=a.serialize(),u=e._serialize(c).toString("base64"),l={encoding:"base64",commitment:null!=n?n:t.commitment};i&&(l.accounts={encoding:"base64",addresses:(Array.isArray(i)?i:a.nonProgramIds()).map(t=>
1t.toBase58())}),r&&r.length>0&&(l.sigVerify=!0);let d=[u,l],h=M(await t._rpcRequest("simulateTransaction",d),X);if("error"in h){let t;if("data"in h.error&&(t=null==(s=h.error.data)?void 0:s.logs)&&Array.isArray(t)){let e="\n ",r=e+t.join(e);console.error(h.error.message,r)}throw new o.SendTransactionError("failed to simulate transaction: "+h.error.message,t)}return h.result}let z=F(K());function F(t){return V([G({jsonrpc:H("2.0"),id:B(),result:t}),G({jsonrpc:H("2.0"),id:B(),error:G({code:K(),message:B(),data:k(x("any",()=>!0))})})])}let X=function(t){var e,r,n;return r=F(e=G({context:G({slot:U()}),value:t})),n=t=>"error"in t?t:{...t,result:M(t.result,e)},new b({...r,coercer:(t,e)=>D(t,z)[0]?r.coercer(t,e):r.coercer(n(t,e),e)})}(G({err:L(V([G({}),B()])),logs:L(P(B())),accounts:k(L(P(L(G({executable:x("boolean",t=>"boolean"==typeof t),owner:B(),lamports:U(),data:P(B()),rentEpoch:k(U())}))))),unitsConsumed:k(U())}));class Y{constructor(t,e,r=Y.defaultOptions()){this.connection=t,this.wallet=e,this.opts=r,this.publicKey=null==e?void 0:e.publicKey}static defaultOptions(){return{preflightCommitment:"processed",commitment:"processed"}}static local(t,e=Y.defaultOptions()){throw Error("Provider local is not available on browser.")}static env(){throw Error("Provider env is not available on browser.")}async sendAndConfirm(t,e,r){var n,i,s,a;if(void 0===r&&(r=this.opts),R(t))e&&t.sign(e);else if(t.feePayer=null!=(n=t.feePayer)?n:this.wallet.publicKey,t.recentBlockhash=(await this.connection.getLatestBlockhash(r.preflightCommitment)).blockhash,e)for(let r of e)t.partialSign(r);let c=(t=await this.wallet.signTransaction(t)).serialize();try{return await Q(this.connection,c,r)}catch(e){if(e instanceof Z){let r=y(R(t)?(null==(i=t.signatures)?void 0:i[0])||new Uint8Array:null!=(s=t.signature)?s:new Uint8Array),n=R(t)?0:void 0,c=await this.connection.getTransaction(r,{commitment:"confirmed",maxSupportedTransactionVersion:n});if(c){let t=null==(a=c.meta)?void 0:a.logMessages;throw t?new o.SendTransactionError(e.message,t):e}}throw e}}async sendAll(t,e){var r,n,i;void 0===e&&(e=this.opts);let s=(await this.connection.getLatestBlockhash(e.preflightCommitment)).blockhash,a=t.map(t=>{var e,r;if(R(t.tx)){let e=t.tx;return t.signers&&e.sign(t.signers),e}{let n=t.tx,i=null!=(e=t.signers)?e:[];return n.feePayer=null!=(r=n.feePayer)?r:this.wallet.publicKey,n.recentBlockhash=s,i.forEach(t=>{n.partialSign(t)}),n}}),c=await this.wallet.signAllTransactions(a),u=[];for(let t=0;t<a.length;t+=1){let s=c[t],a=s.serialize();try{u.push(await Q(this.connection,a,e))}catch(t){if(t instanceof Z){let e=y(R(s)?(null==(r=s.signatures)?void 0:r[0])||new Uint8Array:null!=(n=s.signature)?n:new Uint8Array),a=R(s)?0:void 0,c=await this.connection.getTransaction(e,{commitment:"confirmed",maxSupportedTransactionVersion:a});if(c){let e=null==(i=c.meta)?void 0:i.logMessages;throw e?new o.SendTransactionError(t.message,e):t}}throw t}}return u}async simulate(t,e,r,n){let i,o=(await this.connection.getLatestBlockhash(null!=r?r:this.connection.commitment)).blockhash;if(R(t)?(e&&e.length>0&&(t.sign(e),t=await this.wallet.signTransaction(t)),i=await this.connection.simulateTransaction(t,{commitment:r})):(t.feePayer=t.feePayer||this.wallet.publicKey,t.recentBlockhash=o,e&&e.length>0&&(t=await this.wallet.signTransaction(t)),i=await q(this.connection,t,e,r,n)),i.value.err)throw new W(i.value);return i.value}}class W extends Error{constructor(t,e){super(e),this.simulationResponse=t}}async function Q(t,e,r){let n,i=r?{skipPreflight:r.skipPreflight,preflightCommitment:r.preflightCommitment||r.commitment,maxRetries:r.maxRetries,minContextSlot:r.minContextSlot}:{},o=Date.now();for(;Date.now()-o<6e4;)try{let o=await t.sendRawTransaction(e,i);if(null==r?void 0:r.blockhash)if(0===i.maxRetries){let e=AbortSignal.timeout(15e3);n=(await t.confirmTransaction({abortSignal:e,signature:o,...r.blockhash},r&&r.commitment)).value}else n=(await t.confirmTransaction({signature:o,...r.blockhash},r&&r.commitment)).value;else n=(await t.confirmTransaction(o,r&&r.commitment)).value;if(n.err)throw new Z(`Raw transaction ${o} failed (${JSON.stringify(n)})`);return o}catch(t){if("TimeoutError"===t.name)continue;throw t}throw Error("Transaction failed to confirm in 60s")}
1class Z extends Error{constructor(t){super(t)}}function J(){return null===tt?Y.local():tt}let tt=null;var te="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:void 0!==r.g?r.g:"undefined"!=typeof self?self:{},tr={};Object.defineProperty(tr,"__esModule",{value:!0});var tn=tr.ANCHOR_ERROR__REQUIRE_EQ_VIOLATED=tJ=tr.ANCHOR_ERROR__REQUIRE_VIOLATED=tZ=tr.ANCHOR_ERROR__CONSTRAINT_MINT_TRANSFER_HOOK_EXTENSION_PROGRAM_ID=tQ=tr.ANCHOR_ERROR__CONSTRAINT_MINT_TRANSFER_HOOK_EXTENSION_AUTHORITY=tW=tr.ANCHOR_ERROR__CONSTRAINT_MINT_TRANSFER_HOOK_EXTENSION=tY=tr.ANCHOR_ERROR__CONSTRAINT_MINT_PERMANENT_DELEGATE_EXTENSION_DELEGATE=tX=tr.ANCHOR_ERROR__CONSTRAINT_MINT_PERMANENT_DELEGATE_EXTENSION=tF=tr.ANCHOR_ERROR__CONSTRAINT_MINT_CLOSE_AUTHORITY_EXTENSION_AUTHORITY=tz=tr.ANCHOR_ERROR__CONSTRAINT_MINT_CLOSE_AUTHORITY_EXTENSION=tq=tr.ANCHOR_ERROR__CONSTRAINT_MINT_METADATA_POINTER_EXTENSION_METADATA_ADDRESS=tj=tr.ANCHOR_ERROR__CONSTRAINT_MINT_METADATA_POINTER_EXTENSION_AUTHORITY=t$=tr.ANCHOR_ERROR__CONSTRAINT_MINT_METADATA_POINTER_EXTENSION=tK=tr.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_MEMBER_POINTER_EXTENSION_MEMBER_ADDRESS=tV=tr.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_MEMBER_POINTER_EXTENSION_AUTHORITY=tG=tr.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_MEMBER_POINTER_EXTENSION=tB=tr.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_POINTER_EXTENSION_GROUP_ADDRESS=tk=tr.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_POINTER_EXTENSION_AUTHORITY=tU=tr.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_POINTER_EXTENSION=tL=tr.ANCHOR_ERROR__CONSTRAINT_ASSOCIATED_TOKEN_TOKEN_PROGRAM=tH=tr.ANCHOR_ERROR__CONSTRAINT_MINT_TOKEN_PROGRAM=tP=tr.ANCHOR_ERROR__CONSTRAINT_TOKEN_TOKEN_PROGRAM=tx=tr.ANCHOR_ERROR__CONSTRAINT_ACCOUNT_IS_NONE=tD=tr.ANCHOR_ERROR__CONSTRAINT_SPACE=tM=tr.ANCHOR_ERROR__CONSTRAINT_MINT_DECIMALS=tb=tr.ANCHOR_ERROR__CONSTRAINT_MINT_FREEZE_AUTHORITY=tS=tr.ANCHOR_ERROR__CONSTRAINT_MINT_MINT_AUTHORITY=tw=tr.ANCHOR_ERROR__CONSTRAINT_TOKEN_OWNER=tC=tr.ANCHOR_ERROR__CONSTRAINT_TOKEN_MINT=tv=tr.ANCHOR_ERROR__CONSTRAINT_ZERO=tI=tr.ANCHOR_ERROR__CONSTRAINT_ADDRESS=tT=tr.ANCHOR_ERROR__CONSTRAINT_CLOSE=tg=tr.ANCHOR_ERROR__CONSTRAINT_ASSOCIATED_INIT=tN=tr.ANCHOR_ERROR__CONSTRAINT_ASSOCIATED=tm=tr.ANCHOR_ERROR__CONSTRAINT_STATE=tO=tr.ANCHOR_ERROR__CONSTRAINT_EXECUTABLE=tE=tr.ANCHOR_ERROR__CONSTRAINT_SEEDS=ty=tr.ANCHOR_ERROR__CONSTRAINT_RENT_EXEMPT=tA=tr.ANCHOR_ERROR__CONSTRAINT_OWNER=tR=tr.ANCHOR_ERROR__CONSTRAINT_RAW=tf=tr.ANCHOR_ERROR__CONSTRAINT_SIGNER=tp=tr.ANCHOR_ERROR__CONSTRAINT_HAS_ONE=t_=tr.ANCHOR_ERROR__CONSTRAINT_MUT=th=tr.ANCHOR_ERROR__EVENT_INSTRUCTION_STUB=td=tr.ANCHOR_ERROR__IDL_ACCOUNT_NOT_EMPTY=tl=tr.ANCHOR_ERROR__IDL_INSTRUCTION_INVALID_PROGRAM=tu=tr.ANCHOR_ERROR__IDL_INSTRUCTION_STUB=tc=tr.ANCHOR_ERROR__INSTRUCTION_DID_NOT_SERIALIZE=ta=tr.ANCHOR_ERROR__INSTRUCTION_DID_NOT_DESERIALIZE=ts=tr.ANCHOR_ERROR__INSTRUCTION_FALLBACK_NOT_FOUND=to=tr.ANCHOR_ERROR__INSTRUCTION_MISSING=void 0,ti=tr.ANCHOR_ERROR__DEPRECATED=ef=tr.ANCHOR_ERROR__INVALID_NUMERIC_CONVERSION=ep=tr.ANCHOR_ERROR__TRYING_TO_INIT_PAYER_AS_PROGRAM_ACCOUNT=e_=tr.ANCHOR_ERROR__DECLARED_PROGRAM_ID_MISMATCH=eh=tr.ANCHOR_ERROR__ACCOUNT_DUPLICATE_REALLOCS=ed=tr.ANCHOR_ERROR__ACCOUNT_REALLOC_EXCEEDS_LIMIT=el=tr.ANCHOR_ERROR__ACCOUNT_SYSVAR_MISMATCH=eu=tr.ANCHOR_ERROR__ACCOUNT_NOT_ASSOCIATED_TOKEN_ACCOUNT=ec=tr.ANCHOR_ERROR__ACCOUNT_NOT_PROGRAM_DATA=ea=tr.ANCHOR_ERROR__ACCOUNT_NOT_INITIALIZED=es=tr.ANCHOR_ERROR__ACCOUNT_NOT_SYSTEM_OWNED=eo=tr.ANCHOR_ERROR__ACCOUNT_NOT_SIGNER=ei=tr.ANCHOR_ERROR__INVALID_PROGRAM_EXECUTABLE=en=tr.ANCHOR_ERROR__INVALID_PROGRAM_ID=er=tr.ANCHOR_ERROR__ACCOUNT_OWNED_BY_WRONG_PROGRAM=ee=tr.ANCHOR_ERROR__ACCOUNT_NOT_MUTABLE=et=tr.ANCHOR_ERROR__ACCOUNT_NOT_ENOUGH_KEYS=t7=tr.ANCHOR_ERROR__ACCOUNT_DID_NOT_SERIALIZE=t9=tr.ANCHOR_ERROR__ACCOUNT_DID_NOT_DESERIALIZE=t5=tr.ANCHOR_ERROR__ACCOUNT_DISCRIMINATOR_MISMATCH=t4=tr.ANCHOR_ERROR__ACCOUNT_DISCRIMINATOR_NOT_FOUND=t6=tr.ANCHOR_ERROR__ACCOUNT_DISCRIMINATOR_ALREADY_SET=t8=tr.ANCHOR_ERROR__REQUIRE_GTE_VIOLATED=t3=tr.ANCHOR_ERROR__REQUIRE_GT_VIOLATED=t2=tr.ANCHOR_ERROR__REQUIRE_KEYS_NEQ_VIOLATED=t1=tr.ANCHOR_ERROR__REQUIRE_NEQ_VIOLATED=t0=tr.ANCHOR_ERROR__REQUIRE_KEYS_EQ_VIOLATED=void 0,to=tr.ANCHOR_ERROR__INSTRUCTION_MISSING=100,ts=tr.ANCHOR_ERROR__INSTRUCTION_FALLBACK_NOT_FOUND=101,ta=tr.ANCHOR_ERROR__INSTRUCTION_DID_NOT_DESERIALIZE=102,tc=tr.ANCHOR_ERROR__INSTRUCTION_DID_NOT_SERIALIZE=103,tu=tr.ANCHOR_ERROR__IDL_INSTRUCTION_STUB=1e3,tl=tr.ANCHOR_ERROR__IDL_INSTRUCTION_INVA
1LID_PROGRAM=1001,td=tr.ANCHOR_ERROR__IDL_ACCOUNT_NOT_EMPTY=1002,th=tr.ANCHOR_ERROR__EVENT_INSTRUCTION_STUB=1500,t_=tr.ANCHOR_ERROR__CONSTRAINT_MUT=2e3,tp=tr.ANCHOR_ERROR__CONSTRAINT_HAS_ONE=2001,tf=tr.ANCHOR_ERROR__CONSTRAINT_SIGNER=2002,tR=tr.ANCHOR_ERROR__CONSTRAINT_RAW=2003,tA=tr.ANCHOR_ERROR__CONSTRAINT_OWNER=2004,ty=tr.ANCHOR_ERROR__CONSTRAINT_RENT_EXEMPT=2005,tE=tr.ANCHOR_ERROR__CONSTRAINT_SEEDS=2006,tO=tr.ANCHOR_ERROR__CONSTRAINT_EXECUTABLE=2007,tm=tr.ANCHOR_ERROR__CONSTRAINT_STATE=2008,tN=tr.ANCHOR_ERROR__CONSTRAINT_ASSOCIATED=2009,tg=tr.ANCHOR_ERROR__CONSTRAINT_ASSOCIATED_INIT=2010,tT=tr.ANCHOR_ERROR__CONSTRAINT_CLOSE=2011,tI=tr.ANCHOR_ERROR__CONSTRAINT_ADDRESS=2012,tv=tr.ANCHOR_ERROR__CONSTRAINT_ZERO=2013,tC=tr.ANCHOR_ERROR__CONSTRAINT_TOKEN_MINT=2014,tw=tr.ANCHOR_ERROR__CONSTRAINT_TOKEN_OWNER=2015,tS=tr.ANCHOR_ERROR__CONSTRAINT_MINT_MINT_AUTHORITY=2016,tb=tr.ANCHOR_ERROR__CONSTRAINT_MINT_FREEZE_AUTHORITY=2017,tM=tr.ANCHOR_ERROR__CONSTRAINT_MINT_DECIMALS=2018,tD=tr.ANCHOR_ERROR__CONSTRAINT_SPACE=2019,tx=tr.ANCHOR_ERROR__CONSTRAINT_ACCOUNT_IS_NONE=2020,tP=tr.ANCHOR_ERROR__CONSTRAINT_TOKEN_TOKEN_PROGRAM=2021,tH=tr.ANCHOR_ERROR__CONSTRAINT_MINT_TOKEN_PROGRAM=2022,tL=tr.ANCHOR_ERROR__CONSTRAINT_ASSOCIATED_TOKEN_TOKEN_PROGRAM=2023,tU=tr.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_POINTER_EXTENSION=2024,tk=tr.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_POINTER_EXTENSION_AUTHORITY=2025,tB=tr.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_POINTER_EXTENSION_GROUP_ADDRESS=2026,tG=tr.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_MEMBER_POINTER_EXTENSION=2027,tV=tr.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_MEMBER_POINTER_EXTENSION_AUTHORITY=2028,tK=tr.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_MEMBER_POINTER_EXTENSION_MEMBER_ADDRESS=2029,t$=tr.ANCHOR_ERROR__CONSTRAINT_MINT_METADATA_POINTER_EXTENSION=2030,tj=tr.ANCHOR_ERROR__CONSTRAINT_MINT_METADATA_POINTER_EXTENSION_AUTHORITY=2031,tq=tr.ANCHOR_ERROR__CONSTRAINT_MINT_METADATA_POINTER_EXTENSION_METADATA_ADDRESS=2032,tz=tr.ANCHOR_ERROR__CONSTRAINT_MINT_CLOSE_AUTHORITY_EXTENSION=2033,tF=tr.ANCHOR_ERROR__CONSTRAINT_MINT_CLOSE_AUTHORITY_EXTENSION_AUTHORITY=2034,tX=tr.ANCHOR_ERROR__CONSTRAINT_MINT_PERMANENT_DELEGATE_EXTENSION=2035,tY=tr.ANCHOR_ERROR__CONSTRAINT_MINT_PERMANENT_DELEGATE_EXTENSION_DELEGATE=2036,tW=tr.ANCHOR_ERROR__CONSTRAINT_MINT_TRANSFER_HOOK_EXTENSION=2037,tQ=tr.ANCHOR_ERROR__CONSTRAINT_MINT_TRANSFER_HOOK_EXTENSION_AUTHORITY=2038,tZ=tr.ANCHOR_ERROR__CONSTRAINT_MINT_TRANSFER_HOOK_EXTENSION_PROGRAM_ID=2039,tJ=tr.ANCHOR_ERROR__REQUIRE_VIOLATED=2500;tn=tr.ANCHOR_ERROR__REQUIRE_EQ_VIOLATED=2501;var t0=tr.ANCHOR_ERROR__REQUIRE_KEYS_EQ_VIOLATED=2502,t1=tr.ANCHOR_ERROR__REQUIRE_NEQ_VIOLATED=2503,t2=tr.ANCHOR_ERROR__REQUIRE_KEYS_NEQ_VIOLATED=2504,t3=tr.ANCHOR_ERROR__REQUIRE_GT_VIOLATED=2505,t8=tr.ANCHOR_ERROR__REQUIRE_GTE_VIOLATED=2506,t6=tr.ANCHOR_ERROR__ACCOUNT_DISCRIMINATOR_ALREADY_SET=3e3,t4=tr.ANCHOR_ERROR__ACCOUNT_DISCRIMINATOR_NOT_FOUND=3001,t5=tr.ANCHOR_ERROR__ACCOUNT_DISCRIMINATOR_MISMATCH=3002,t9=tr.ANCHOR_ERROR__ACCOUNT_DID_NOT_DESERIALIZE=3003,t7=tr.ANCHOR_ERROR__ACCOUNT_DID_NOT_SERIALIZE=3004,et=tr.ANCHOR_ERROR__ACCOUNT_NOT_ENOUGH_KEYS=3005,ee=tr.ANCHOR_ERROR__ACCOUNT_NOT_MUTABLE=3006,er=tr.ANCHOR_ERROR__ACCOUNT_OWNED_BY_WRONG_PROGRAM=3007,en=tr.ANCHOR_ERROR__INVALID_PROGRAM_ID=3008,ei=tr.ANCHOR_ERROR__INVALID_PROGRAM_EXECUTABLE=3009,eo=tr.ANCHOR_ERROR__ACCOUNT_NOT_SIGNER=3010,es=tr.ANCHOR_ERROR__ACCOUNT_NOT_SYSTEM_OWNED=3011,ea=tr.ANCHOR_ERROR__ACCOUNT_NOT_INITIALIZED=3012,ec=tr.ANCHOR_ERROR__ACCOUNT_NOT_PROGRAM_DATA=3013,eu=tr.ANCHOR_ERROR__ACCOUNT_NOT_ASSOCIATED_TOKEN_ACCOUNT=3014,el=tr.ANCHOR_ERROR__ACCOUNT_SYSVAR_MISMATCH=3015,ed=tr.ANCHOR_ERROR__ACCOUNT_REALLOC_EXCEEDS_LIMIT=3016,eh=tr.ANCHOR_ERROR__ACCOUNT_DUPLICATE_REALLOCS=3017,e_=tr.ANCHOR_ERROR__DECLARED_PROGRAM_ID_MISMATCH=4100,ep=tr.ANCHOR_ERROR__TRYING_TO_INIT_PAYER_AS_PROGRAM_ACCOUNT=4101,ef=tr.ANCHOR_ERROR__INVALID_NUMERIC_CONVERSION=4102;ti=tr.ANCHOR_ERROR__DEPRECATED=5e3;let eR=new Map;function eA(t){return void 0!==eR.get(t)}class ey extends Error{constructor(t){super(t),this.name="IdlError"}}class eE{constructor(t){this.stack=t}static parse(t){var e;
1let r=/^Program (\w*) invoke/,n=/^Program \w* success/,i=[];for(let s=0;s<t.length;s++){if(n.exec(t[s])){i.pop();continue}let a=null==(e=r.exec(t[s]))?void 0:e[1];a&&i.push(new o.PublicKey(a))}return new eE(i)}}class eO extends Error{constructor(t,e,r,n,i,o){super(r.join("\n").replace("Program log: ","")),this.errorLogs=r,this.logs=n,this.error={errorCode:t,errorMessage:e,comparedValues:o,origin:i},this._programErrorStack=eE.parse(n)}static parse(t){let e;if(!t)return null;let r=t.findIndex(t=>t.startsWith("Program log: AnchorError"));if(-1===r)return null;let n=t[r],i=[n];if(r+1<t.length){if("Program log: Left:"===t[r+1]){let n=/^Program log: (.*)$/,s=n.exec(t[r+2])[1],a=n.exec(t[r+4])[1];e=[new o.PublicKey(s),new o.PublicKey(a)],i.push(...t.slice(r+1,r+5))}else if(t[r+1].startsWith("Program log: Left:")){let n=/^Program log: (Left|Right): (.*)$/,o=n.exec(t[r+1])[2],s=n.exec(t[r+2])[2];i.push(...t.slice(r+1,r+3)),e=[o,s]}}let s=/^Program log: AnchorError occurred\. Error Code: (.*)\. Error Number: (\d*)\. Error Message: (.*)\./.exec(n),a=/^Program log: AnchorError thrown in (.*):(\d*)\. Error Code: (.*)\. Error Number: (\d*)\. Error Message: (.*)\./.exec(n),c=/^Program log: AnchorError caused by account: (.*)\. Error Code: (.*)\. Error Number: (\d*)\. Error Message: (.*)\./.exec(n);if(s){let[r,n,o]=s.slice(1,4);return new eO({code:r,number:parseInt(n)},o,i,t,void 0,e)}if(a){let[r,n,o,s,c]=a.slice(1,6);return new eO({code:o,number:parseInt(s)},c,i,t,{file:r,line:parseInt(n)},e)}if(!c)return null;{let[r,n,o,s]=c.slice(1,5);return new eO({code:n,number:parseInt(o)},s,i,t,r,e)}}get program(){return this._programErrorStack.stack[this._programErrorStack.stack.length-1]}get programErrorStack(){return this._programErrorStack.stack}toString(){return this.message}}class em extends Error{constructor(t,e,r){super(),this.code=t,this.msg=e,this.logs=r,r&&(this._programErrorStack=eE.parse(r))}static parse(t,e){let r,n,i=t.toString();if(i.includes("custom program error:")){let t=i.split("custom program error: ");if(2!==t.length)return null;r=t[1]}else{let t=i.match(/"Custom":([0-9]+)}/g);if(!t||t.length>1)return null;r=t[0].match(/([0-9]+)/g)[0]}try{n=parseInt(r)}catch(t){return null}let o=e.get(n);return void 0!==o||void 0!==(o=eT.get(n))?new em(n,o,t.logs):null}get program(){var t;return null==(t=this._programErrorStack)?void 0:t.stack[this._programErrorStack.stack.length-1]}get programErrorStack(){var t;return null==(t=this._programErrorStack)?void 0:t.stack}toString(){return this.msg}}function eN(t,e){eA("debug-logs")&&console.log("Translating error:",t);let r=eO.parse(t.logs);if(r)return r;let n=em.parse(t,e);return n||(t.logs?(t.programErrorStack=eE.parse(t.logs),new Proxy(t,{get:function(e,r){return"programErrorStack"===r?e.programErrorStack.stack:"program"===r?e.programErrorStack.stack[t.programErrorStack.stack.length-1]:Reflect.get(...arguments)}})):t)}let eg={InstructionMissing:to,InstructionFallbackNotFound:ts,InstructionDidNotDeserialize:ta,InstructionDidNotSerialize:tc,IdlInstructionStub:tu,IdlInstructionInvalidProgram:tl,IdlAccountNotEmpty:td,EventInstructionStub:th,ConstraintMut:t_,ConstraintHasOne:tp,ConstraintSigner:tf,ConstraintRaw:tR,ConstraintOwner:tA,ConstraintRentExempt:ty,ConstraintSeeds:tE,ConstraintExecutable:tO,ConstraintState:tm,ConstraintAssociated:tN,ConstraintAssociatedInit:tg,ConstraintClose:tT,ConstraintAddress:tI,ConstraintZero:tv,ConstraintTokenMint:tC,ConstraintTokenOwner:tw,ConstraintMintMintAuthority:tS,ConstraintMintFreezeAuthority:tb,ConstraintMintDecimals:tM,ConstraintSpace:tD,ConstraintAccountIsNone:tx,ConstraintTokenTokenProgram:tP,ConstraintMintTokenProgram:tH,ConstraintAssociatedTokenTokenProgram:tL,ConstraintMintGroupPointerExtension:tU,ConstraintMintGroupPointerExtensionAuthority:tk,ConstraintMintGroupPointerExtensionGroupAddress:tB,ConstraintMintGroupMemberPointerExtension:tG,ConstraintMintGroupMemberPointerExtensionAuthority:tV,ConstraintMintGroupMemberPointerExtensionMemberAddress:tK,ConstraintMintMetadataPointerExtension:t$,ConstraintMintMetadataPointerExtensionAuthority:tj,ConstraintMintMetadataPointerExtensionMetadataAddress:tq,ConstraintMintCloseAuthorityExtension:tz,ConstraintMintCloseAuthorityExtensionAuthority:tF,ConstraintMintPermanentDelegateExtension:tX,ConstraintMintPermanentDelegateExtensionDelegate:tY,ConstraintMintTransferHookExtension:tW,ConstraintMintTransferHookExtensionAuthority:tQ,ConstraintMintTransferHookExtensionProgramId:tZ,RequireViolated:tJ,RequireEqViolated:tn,RequireKeysEqViolated:t0,RequireNeqViolated:t1,RequireKeysNeqViolated:t2,RequireGtViolated:t3,RequireGteViolated:t8,AccountDiscriminatorAlreadySet:t6,AccountDiscriminatorNotFound:t4,AccountDiscriminatorMismatch:t5,AccountDidNotDeserialize:t9,AccountDidNotSerialize:t7,AccountNotEnoughKeys:et,AccountNotMutable:ee,AccountOwnedByWrongProgram:er,InvalidProgramId:en,InvalidProgramExecutable:ei,AccountNotSigner:eo,AccountNotSystemOwned:es,AccountNotInitialized:ea,AccountNotProgramData:ec,AccountNotAssociatedTokenAccount:eu,AccountSysvarMismatch:el,AccountReallocExceedsLimit:ed,AccountDuplicateReallocs:eh,DeclaredProgramIdMismatch:e_,TryingToInitPayerAsProgramAccount:ep,InvalidNumericConversion:ef,Deprecated:ti}
1,eT=new Map([[eg.InstructionMissing,"Instruction discriminator not provided"],[eg.InstructionFallbackNotFound,"Fallback functions are not supported"],[eg.InstructionDidNotDeserialize,"The program could not deserialize the given instruction"],[eg.InstructionDidNotSerialize,"The program could not serialize the given instruction"],[eg.IdlInstructionStub,"The program was compiled without idl instructions"],[eg.IdlInstructionInvalidProgram,"The transaction was given an invalid program for the IDL instruction"],[eg.IdlAccountNotEmpty,"IDL account must be empty in order to resize, try closing first"],[eg.EventInstructionStub,"The program was compiled without `event-cpi` feature"],[eg.ConstraintMut,"A mut constraint was violated"],[eg.ConstraintHasOne,"A has one constraint was violated"],[eg.ConstraintSigner,"A signer constraint was violated"],[eg.ConstraintRaw,"A raw constraint was violated"],[eg.ConstraintOwner,"An owner constraint was violated"],[eg.ConstraintRentExempt,"A rent exemption constraint was violated"],[eg.ConstraintSeeds,"A seeds constraint was violated"],[eg.ConstraintExecutable,"An executable constraint was violated"],[eg.ConstraintState,"Deprecated Error, feel free to replace with something else"],[eg.ConstraintAssociated,"An associated constraint was violated"],[eg.ConstraintAssociatedInit,"An associated init constraint was violated"],[eg.ConstraintClose,"A close constraint was violated"],[eg.ConstraintAddress,"An address constraint was violated"],[eg.ConstraintZero,"Expected zero account discriminant"],[eg.ConstraintTokenMint,"A token mint constraint was violated"],[eg.ConstraintTokenOwner,"A token owner constraint was violated"],[eg.ConstraintMintMintAuthority,"A mint mint authority constraint was violated"],[eg.ConstraintMintFreezeAuthority,"A mint freeze authority constraint was violated"],[eg.ConstraintMintDecimals,"A mint decimals constraint was violated"],[eg.ConstraintSpace,"A space constraint was violated"],[eg.ConstraintAccountIsNone,"A required account for the constraint is None"],[eg.ConstraintTokenTokenProgram,"A token account token program constraint was violated"],[eg.ConstraintMintTokenProgram,"A mint token program constraint was violated"],[eg.ConstraintAssociatedTokenTokenProgram,"An associated token account token program constraint was violated"],[eg.ConstraintMintGroupPointerExtension,"A group pointer extension constraint was violated"],[eg.ConstraintMintGroupPointerExtensionAuthority,"A group pointer extension authority constraint was violated"],[eg.ConstraintMintGroupPointerExtensionGroupAddress,"A group pointer extension group address constraint was violated"],[eg.ConstraintMintGroupMemberPointerExtension,"A group member pointer extension constraint was violated"],[eg.ConstraintMintGroupMemberPointerExtensionAuthority,"A group member pointer extension authority constraint was violated"],[eg.ConstraintMintGroupMemberPointerExtensionMemberAddress,"A group member pointer extension group address constraint was violated"],[eg.ConstraintMintMetadataPointerExtension,"A metadata pointer extension constraint was violated"],[eg.ConstraintMintMetadataPointerExtensionAuthority,"A metadata pointer extension authority constraint was violated"],[eg.ConstraintMintMetadataPointerExtensionMetadataAddress,"A metadata pointer extension metadata address constraint was violated"],[eg.ConstraintMintCloseAuthorityExtension,"A close authority constraint was violated"],[eg.ConstraintMintCloseAuthorityExtensionAuthority,"A close authority extension authority constraint was violated"],[eg.ConstraintMintPermanentDelegateExtension,"A permanent delegate extension constraint was violated"],[eg.ConstraintMintPermanentDelegateExtensionDelegate,"A permanent delegate extension delegate constraint was violated"],[eg.ConstraintMintTransferHookExtension,"A transfer hook extension constraint was violated"],[eg.ConstraintMintTransferHookExtensionAuthority,"A transfer hook extension authority constraint was violated"],[eg.ConstraintMintTransferHookExtensionProgramId,"A transfer hook extension transfer hook program id constraint was violated"],[eg.RequireViolated,"A require expression was violated"],[eg.RequireEqViolated,"A require_eq expression was violated"],[eg.RequireKeysEqViolated,"A require_keys_eq expression was violated"],[eg.RequireNeqViolated,"A require_neq expression was violated"],[eg.RequireKeysNeqViolated,"A require_keys_neq expression was violated"],[eg.RequireGtViolated,"A require_gt expression was violated"],[eg.RequireGteViolated,"A require_gte expression was violated"],[eg.AccountDiscriminatorAlreadySet,"The account discriminator was already set on this account"],[eg.AccountDiscriminatorNotFound,"No discriminator was found on the account"],[eg.AccountDiscriminatorMismatch,"Account discriminator did not match what was expected"],[eg.AccountDidNotDeserialize,"Failed to deserialize the account"],[eg.AccountDidNotSerialize,"Failed to serialize the account"],[eg.AccountNotEnoughKeys,"Not enough account keys given to the instruction"],[eg.AccountNotMutable,"The given account is not mutable"],[eg.AccountOwnedByWrongProgram,"The given account is owned by a different program than expected"],[eg.InvalidProgramId,"Program ID was not as expected"],[eg.InvalidProgramExecutable,"Program account is not executable"],[eg.AccountNotSigner,"The given account did not sign"],[eg.AccountNotSystemOwned,"The given account is not owned by the system program"],[eg.AccountNotInitialized,"The program expected this account to be already initialized"],[eg.AccountNotProgramData,"The given account is not a program data account"],[eg.AccountNotAssociatedTokenAccount,"The given account is not the associated token account"],[eg.AccountSysvarMismatch,"The given public key does not match the required sysvar"],[eg.AccountReallocExceedsLimit,"The account reallocation exceeds the MAX_PERMITTED_DATA_INCREASE limit"],[eg.AccountDuplicateReallocs,"The account was duplicated for more than one reallocation"],[eg.DeclaredProgramIdMismatch,"The declared program id does not match the actual program id"],[eg.TryingToInitPayerAsProgramAccount,"You cannot/should not initialize the payer account as a program account"],[eg.InvalidNumericConversion,"The program could not perform the numeric conversion, out of range integral type conversion attempted"],[eg.Deprecated,"The API being used is deprecated and should no longer be used"]]);class eI{static fieldLayout(t,e=[],r){let n=t.name;switch(t.type){case"bool":return d.bool(n);case"u8":return d.u8(n);case"i8":return d.i8(n);case"u16":return d.u16(n);case"i16":return d.i16(n);case"u32":return d.u32(n);case"i32":return d.i32(n);case"f32":return d.f32(n);case"u64":return d.u64(n);case"i64":return d.i64(n);case"f64":return d.f64(n);case"u128":return d.u128(n);case"i128":return d.i128(n);case"u256":return d.u256(n);case"i256":return d.i256(n);case"bytes":return d.vecU8(n);case"string":return d.str(n);case"pubkey":return d.publicKey(n);default:if("option"in t.type)return d.option(eI.fieldLayout({type:t.type.option},e,r),n);if("vec"in t.type)return d.vec(eI.fieldLayout({type:t.type.vec},e,r),n);if("array"in t.type){let[i,o]=t.type.array;
1return o=eI.resolveArrayLen(o,r),d.array(eI.fieldLayout({type:i},e,r),o,n)}if("defined"in t.type){if(!e)throw new ey("User defined types not provided");let i=t.type.defined.name,o=e.find(t=>t.name===i);if(!o)throw new ey(`Type not found: ${t.name}`);return eI.typeDefLayout({typeDef:o,types:e,genericArgs:null!=r?r:t.type.defined.generics,name:n})}if("generic"in t.type){let n=null==r?void 0:r.at(0);if((null==n?void 0:n.kind)!=="type")throw new ey(`Invalid generic field: ${t.name}`);return eI.fieldLayout({...t,type:n.type},e)}throw new ey(`Not yet implemented: ${JSON.stringify(t.type)}`)}}static typeDefLayout({typeDef:t,types:e,name:r,genericArgs:n}){switch(t.type.kind){case"struct":{let i=g(t.type.fields,()=>[],r=>r.map(r=>{let i=n?eI.resolveGenericArgs({type:r.type,typeDef:t,genericArgs:n}):n;return eI.fieldLayout(r,e,i)}),r=>r.map((r,i)=>{let o=n?eI.resolveGenericArgs({type:r,typeDef:t,genericArgs:n}):n;return eI.fieldLayout({name:i.toString(),type:r},e,o)}));return d.struct(i,r)}case"enum":{let i=t.type.variants.map(r=>{let i=g(r.fields,()=>[],r=>r.map(r=>{let i=n?eI.resolveGenericArgs({type:r.type,typeDef:t,genericArgs:n}):n;return eI.fieldLayout(r,e,i)}),r=>r.map((r,i)=>{let o=n?eI.resolveGenericArgs({type:r,typeDef:t,genericArgs:n}):n;return eI.fieldLayout({name:i.toString(),type:r},e,o)}));return d.struct(i,r.name)});if(void 0!==r)return d.rustEnum(i).replicate(r);return d.rustEnum(i,r)}case"type":return eI.fieldLayout({type:t.type.alias,name:r},e)}}static typeSize(t,e,r){var n;switch(t){case"bool":case"u8":case"i8":case"bytes":case"string":return 1;case"i16":case"u16":return 2;case"u32":case"i32":case"f32":return 4;case"u64":case"i64":case"f64":return 8;case"u128":case"i128":return 16;case"u256":case"i256":case"pubkey":return 32;default:if("option"in t)return 1+eI.typeSize(t.option,e,r);if("coption"in t)return 4+eI.typeSize(t.coption,e,r);if("vec"in t)return 1;if("array"in t){let[n,i]=t.array;return i=eI.resolveArrayLen(i,r),eI.typeSize(n,e,r)*i}if("defined"in t){let i=null==(n=e.types)?void 0:n.find(e=>e.name===t.defined.name);if(!i)throw new ey(`Type not found: ${JSON.stringify(t)}`);let o=n=>{let o=null!=r?r:t.defined.generics,s=o?eI.resolveGenericArgs({type:n,typeDef:i,genericArgs:o}):o;return eI.typeSize(n,e,s)};switch(i.type.kind){case"struct":return g(i.type.fields,()=>[0],t=>t.map(t=>o(t.type)),t=>t.map(t=>o(t))).reduce((t,e)=>t+e,0);case"enum":return Math.max(...i.type.variants.map(t=>g(t.fields,()=>[0],t=>t.map(t=>o(t.type)),t=>t.map(t=>o(t))).reduce((t,e)=>t+e,0)))+1;case"type":return eI.typeSize(i.type.alias,e,r)}}if("generic"in t){let n=null==r?void 0:r.at(0);if((null==n?void 0:n.kind)!=="type")throw new ey(`Invalid generic: ${t.generic}`);return eI.typeSize(n.type,e,r)}throw Error(`Invalid type ${JSON.stringify(t)}`)}}static resolveArrayLen(t,e){if("number"==typeof t)return t;if(e){let r=e.find(t=>"const"===t.kind);(null==r?void 0:r.kind)==="const"&&(t=+r.value)}if("number"!=typeof t)throw new ey("Generic array length did not resolve");return t}static resolveGenericArgs({type:t,typeDef:e,genericArgs:r,isDefined:n}){if("object"!=typeof t)return null;for(let i in e.generics){let o=e.generics[i];if("generic"in t&&o.name===t.generic)return[r[i]];if("option"in t){let i=eI.resolveGenericArgs({type:t.option,typeDef:e,genericArgs:r,isDefined:n});if(!i||!n)return i;if("type"===i[0].kind)return[{kind:"type",type:{option:i[0].type}}]}if("vec"in t){let i=eI.resolveGenericArgs({type:t.vec,typeDef:e,genericArgs:r,isDefined:n});if(!i||!n)return i;if("type"===i[0].kind)return[{kind:"type",type:{vec:i[0].type}}]}if("array"in t){let[s,a]=t.array,c="object"==typeof a,u=eI.resolveGenericArgs({type:s,typeDef:e,genericArgs:r,isDefined:n})||[];if(c){let t=e.generics.findIndex(t=>t.name===a.generic);-1!==t&&u.push(r[t])}if(u.length>0){if(!n)return u;if("type"===u[0].kind&&"const"===u[1].kind)return[{kind:"type",type:{array:[u[0].type,+u[1].value]}}]}if(c&&o.name===a.generic){let t=r[i];if(!n)return[t];return[{kind:"type",type:{array:[s,+t.value]}}]}break}if("defined"in t){if(!t.defined.generics)return null;return t.defined.generics.flatMap(t=>{switch(t.kind){case"type":return eI.resolveGenericArgs({type:t.type,typeDef:e,genericArgs:r,isDefined:!0});case"const":return[t]}}).filter(t=>null!==t)}}return null}}class ev{constructor(t){this.idl=t;let e=t.instructions.map(e=>{let r=e.name,n=e.args.map(e=>eI.fieldLayout(e,t.types)),i=d.struct(n,r);return[r,{discriminator:e.discriminator,layout:i}]});this.ixLayouts=new Map(e)}encode(t,e){let r=s.Buffer.alloc(1e3),n=this.ixLayouts.get(t);if(!n)throw Error(`Unknown method: ${t}`);let i=n.layout.encode(e,r),o=r.slice(0,i);return s.Buffer.concat([s.Buffer.from(n.discriminator),o])}decode(t,e="hex"){for(let[r,n]of("string"==typeof t&&(t="hex"===e?s.Buffer.from(t,"hex"):c().decode(t)),this.ixLayouts)){let e=t.subarray(0,n.discriminator.length);if(e.equals(s.Buffer.from(n.discriminator)))return{name:r,data:n.layout.decode(t.subarray(e.length))}}return null}format(t,e){return eC.format(t,e,this.idl)}}class eC{static format(t,e,r){let n=r.instructions.find(e=>t.name===e.name);if(!n)return console.error("Invalid instruction given"),null;let i=n.args.map(e=>({name:e.name,type:eC.formatIdlType(e.type),data:eC.formatIdlData(e,t.data[e.name],r.types)})),o=eC.flattenIdlAccounts(n.accounts);return{args:i,accounts:e.map((t,e)=>e<o.length?{name:o[e].name,...t}:{name:void 0,...t})}}static formatIdlType(t){if("string"==typeof t)return t;if("option"in t)return`Option<${this.formatIdlType(t.option)}>`;if("coption"in t)return`COption<${this.formatIdlType(t.coption)}>`;if("vec"in t)return`Vec<${this.formatIdlType(t.vec)}>`;if("array"in t)return`Array<${t.array[0]}; ${t.array[1]}>`;if("defined"in t){let e=t.defined.name;if(t.defined.generics){let r=t.defined.generics.map(t=>{switch(t.kind){case"type":return eC.formatIdlType(t.type);case"const":return t.value}}).join(", ");return`${e}<${r}>`}return e}throw Error(`Unknown IDL type: ${t}`)}static formatIdlData(t,e,r){if("string"==typeof t.type)return e.toString();if("vec"in t.type)return"["+e.map(e=>this.formatIdlData({name:"",type:t.type.vec},e,r)).join(", ")+"]";if("option"in t.type)return null===e?"null":this.formatIdlData({name:"",type:t.type.option},e,r);if("defined"in t.type){if(!r)throw Error("User defined types not provided");let n=t.type.defined.name,i=r.find(t=>t.name===n);if(!i)throw Error(`Type not found: ${n}`);return eC.formatIdlDataDefined(i,e,r)}return"unknown"}static formatIdlDataDefined(t,e,r){switch(t.type.kind){case"struct":return"{ "+g(t.type.fields,()=>"",t=>Object.entries(e).map(([e,n])=>{let i=t.find(t=>t.name===e);if(!i)throw Error(`Field not found: ${e}`);return e+": "+eC.formatIdlData(i,n,r)}).join(", "),t=>Object.entries(e).map(([e,n])=>e+": "+eC.formatIdlData({name:"",type:t[e]},n,r)).join(", "))+" }";case"enum":{let n=Object.keys(e)[0],i=t.type.variants.find(t=>t.name===n);if(!i)throw Error(`Unable to find variant: ${n}`);let o=e[n];
1return g(i.fields,()=>n,t=>{let e=Object.keys(o).map(e=>{let n=o[e],i=t.find(t=>t.name===e);if(!i)throw Error(`Field not found: ${e}`);return e+": "+eC.formatIdlData(i,n,r)}).join(", ");return`${n} { ${e} }`},t=>{let e=Object.entries(o).map(([e,n])=>e+": "+eC.formatIdlData({name:"",type:t[e]},n,r)).join(", ");return`${n} { ${e} }`})}case"type":return eC.formatIdlType(t.type.alias)}}static flattenIdlAccounts(t,e){return t.map(t=>{let r=function(t){let e=t.replace(/([A-Z])/g," $1");return e.charAt(0).toUpperCase()+e.slice(1)}(t.name);if(!t.hasOwnProperty("accounts"))return{...t,name:e?`${e} > ${r}`:r};{let n=e?`${e} > ${r}`:r;return eC.flattenIdlAccounts(t.accounts,n)}}).flat()}}class ew{constructor(t){if(this.idl=t,!t.accounts){this.accountLayouts=new Map;return}let e=t.types;if(!e)throw Error("Accounts require `idl.types`");let r=t.accounts.map(t=>{let r=e.find(e=>e.name===t.name);if(!r)throw Error(`Account not found: ${t.name}`);return[t.name,{discriminator:t.discriminator,layout:eI.typeDefLayout({typeDef:r,types:e})}]});this.accountLayouts=new Map(r)}async encode(t,e){let r=s.Buffer.alloc(1e3),n=this.accountLayouts.get(t);if(!n)throw Error(`Unknown account: ${t}`);let i=n.layout.encode(e,r),o=r.slice(0,i),a=this.accountDiscriminator(t);return s.Buffer.concat([a,o])}decode(t,e){let r=this.accountDiscriminator(t);if(r.compare(e.slice(0,r.length)))throw Error("Invalid account discriminator");return this.decodeUnchecked(t,e)}decodeAny(t){for(let[e,r]of this.accountLayouts)if(t.subarray(0,r.discriminator.length).equals(s.Buffer.from(r.discriminator)))return this.decodeUnchecked(e,t);throw Error("Account not found")}decodeUnchecked(t,e){let r=this.accountDiscriminator(t),n=e.subarray(r.length),i=this.accountLayouts.get(t);if(!i)throw Error(`Unknown account: ${t}`);return i.layout.decode(n)}memcmp(t,e){let r=this.accountDiscriminator(t);return{offset:0,bytes:c().encode(e?s.Buffer.concat([r,e]):r)}}size(t){return this.accountDiscriminator(t).length+eI.typeSize({defined:{name:t}},this.idl)}accountDiscriminator(t){var e;let r=null==(e=this.idl.accounts)?void 0:e.find(e=>e.name===t);if(!r)throw Error(`Account not found: ${t}`);return s.Buffer.from(r.discriminator)}}class eS{constructor(t){if(!t.events){this.layouts=new Map;return}let e=t.types;if(!e)throw Error("Events require `idl.types`");let r=t.events.map(t=>{let r=e.find(e=>e.name===t.name);if(!r)throw Error(`Event not found: ${t.name}`);return[t.name,{discriminator:t.discriminator,layout:eI.typeDefLayout({typeDef:r,types:e})}]});this.layouts=new Map(r)}decode(t){let e;try{e=E(t)}catch(t){return null}for(let[t,r]of this.layouts){let n=e.subarray(0,r.discriminator.length);if(n.equals(s.Buffer.from(r.discriminator)))return{name:t,data:r.layout.decode(e.subarray(n.length))}}return null}}class eb{constructor(t){let e=t.types;if(!e){this.typeLayouts=new Map;return}let r=e.filter(t=>!t.generics).map(t=>[t.name,eI.typeDefLayout({typeDef:t,types:e})]);this.typeLayouts=new Map(r)}encode(t,e){let r=s.Buffer.alloc(1e3),n=this.typeLayouts.get(t);if(!n)throw Error(`Unknown type: ${t}`);let i=n.encode(e,r);return r.slice(0,i)}decode(t,e){let r=this.typeLayouts.get(t);if(!r)throw Error(`Unknown type: ${t}`);return r.decode(e)}}class eM{constructor(t){this.instruction=new ev(t),this.accounts=new ew(t),this.events=new eS(t),this.types=new eb(t)}}class eD{constructor(t,e){if(!Number.isInteger(t))throw TypeError("span must be an integer");this.span=t,this.property=e}makeDestinationObject(){return{}}decode(t,e){throw Error("Layout is abstract")}encode(t,e,r){throw Error("Layout is abstract")}getSpan(t,e){if(0>this.span)throw RangeError("indeterminate span");return this.span}replicate(t){let e=Object.create(this.constructor.prototype);return Object.assign(e,this),e.property=t,e}fromArray(t){}}var ex=eD;class eP extends eD{isCount(){throw Error("ExternalLayout is abstract")}}class eH extends eP{constructor(t,e,r){if(!(t instanceof eD))throw TypeError("layout must be a Layout");if(void 0===e)e=0;else if(!Number.isInteger(e))throw TypeError("offset must be integer or undefined");super(t.span,r||t.property),this.layout=t,this.offset=e}isCount(){return this.layout instanceof eL||this.layout instanceof eU}decode(t,e){return void 0===e&&(e=0),this.layout.decode(t,e+this.offset)}encode(t,e,r){return void 0===r&&(r=0),this.layout.encode(t,e,r+this.offset)}}class eL extends eD{constructor(t,e){if(super(t,e),6<this.span)throw RangeError("span must not exceed 6 bytes")}decode(t,e){return void 0===e&&(e=0),t.readUIntLE(e,this.span)}encode(t,e,r){return void 0===r&&(r=0),e.writeUIntLE(t,r,this.span),this.span}}class eU extends eD{constructor(t,e){if(super(t,e),6<this.span)throw RangeError("span must not exceed 6 bytes")}decode(t,e){return void 0===e&&(e=0),t.readUIntBE(e,this.span)}encode(t,e,r){return void 0===r&&(r=0),e.writeUIntBE(t,r,this.span),this.span}}function ek(t){let e=Math.floor(t/0x100000000);return{hi32:e,lo32:t-0x100000000*e}}function eB(t,e){return 0x100000000*t+e}class eG extends eD{constructor(t){super(8,t)}decode(t,e){void 0===e&&(e=0);let r=t.readUInt32LE(e);return eB(t.readUInt32LE(e+4),r)}encode(t,e,r){void 0===r&&(r=0);let n=ek(t);return e.writeUInt32LE(n.lo32,r),e.writeUInt32LE(n.hi32,r+4),8}}class eV extends eD{constructor(t){super(8,t)}decode(t,e){void 0===e&&(e=0);let r=t.readUInt32LE(e);return eB(t.readInt32LE(e+4),r)}encode(t,e,r){void 0===r&&(r=0);let n=ek(t);return e.writeUInt32LE(n.lo32,r),e.writeInt32LE(n.hi32,r+4),8}}class eK extends eD{constructor(t,e,r){if(!(Array.isArray(t)&&t.reduce((t,e)=>t&&e instanceof eD,!0)))throw TypeError("fields must be array of Layout instances");for(let n of("boolean"==typeof e&&void 0===r&&(r=e,e=void 0),t))if(0>
1n.span&&void 0===n.property)throw Error("fields cannot contain unnamed variable-length layout");let n=-1;try{n=t.reduce((t,e)=>t+e.getSpan(),0)}catch(t){}super(n,e),this.fields=t,this.decodePrefixes=!!r}getSpan(t,e){if(0<=this.span)return this.span;void 0===e&&(e=0);let r=0;try{r=this.fields.reduce((r,n)=>{let i=n.getSpan(t,e);return e+=i,r+i},0)}catch(t){throw RangeError("indeterminate span")}return r}decode(t,e){void 0===e&&(e=0);let r=this.makeDestinationObject();for(let n of this.fields)if(void 0!==n.property&&(r[n.property]=n.decode(t,e)),e+=n.getSpan(t,e),this.decodePrefixes&&t.length===e)break;return r}encode(t,e,r){void 0===r&&(r=0);let n=r,i=0,o=0;for(let n of this.fields){let s=n.span;if(o=0<s?s:0,void 0!==n.property){let i=t[n.property];void 0!==i&&(o=n.encode(i,e,r),0>s&&(s=n.getSpan(e,r)))}i=r,r+=s}return i+o-n}fromArray(t){let e=this.makeDestinationObject();for(let r of this.fields)void 0!==r.property&&0<t.length&&(e[r.property]=t.shift());return e}layoutFor(t){if("string"!=typeof t)throw TypeError("property must be string");for(let e of this.fields)if(e.property===t)return e}offsetOf(t){if("string"!=typeof t)throw TypeError("property must be string");let e=0;for(let r of this.fields){if(r.property===t)return e;0>r.span?e=-1:0<=e&&(e+=r.span)}}}class e${constructor(t){this.property=t}decode(){throw Error("UnionDiscriminator is abstract")}encode(){throw Error("UnionDiscriminator is abstract")}}class ej extends e${constructor(t,e){if(!(t instanceof eP&&t.isCount()))throw TypeError("layout must be an unsigned integer ExternalLayout");super(e||t.property||"variant"),this.layout=t}decode(t,e){return this.layout.decode(t,e)}encode(t,e,r){return this.layout.encode(t,e,r)}}class eq extends eD{constructor(t,e,r){let n=t instanceof eL||t instanceof eU;if(n)t=new ej(new eH(t));else if(t instanceof eP&&t.isCount())t=new ej(t);else if(!(t instanceof e$))throw TypeError("discr must be a UnionDiscriminator or an unsigned integer layout");if(void 0===e&&(e=null),!(null===e||e instanceof eD))throw TypeError("defaultLayout must be null or a Layout");if(null!==e){if(0>e.span)throw Error("defaultLayout must have constant span");void 0===e.property&&(e=e.replicate("content"))}let i=-1;e&&0<=(i=e.span)&&n&&(i+=t.layout.span),super(i,r),this.discriminator=t,this.usesPrefixDiscriminator=n,this.defaultLayout=e,this.registry={};let o=this.defaultGetSourceVariant.bind(this);this.getSourceVariant=function(t){return o(t)},this.configGetSourceVariant=function(t){o=t.bind(this)}}getSpan(t,e){if(0<=this.span)return this.span;void 0===e&&(e=0);let r=this.getVariant(t,e);if(!r)throw Error("unable to determine span for unrecognized variant");return r.getSpan(t,e)}defaultGetSourceVariant(t){if(t.hasOwnProperty(this.discriminator.property)){if(this.defaultLayout&&t.hasOwnProperty(this.defaultLayout.property))return;let e=this.registry[t[this.discriminator.property]];if(e&&(!e.layout||t.hasOwnProperty(e.property)))return e}else for(let e in this.registry){let r=this.registry[e];if(t.hasOwnProperty(r.property))return r}throw Error("unable to infer src variant")}decode(t,e){let r;void 0===e&&(e=0);let n=this.discriminator,i=n.decode(t,e),o=this.registry[i];if(void 0===o){let s=0;o=this.defaultLayout,this.usesPrefixDiscriminator&&(s=n.layout.span),(r=this.makeDestinationObject())[n.property]=i,r[o.property]=this.defaultLayout.decode(t,e+s)}else r=o.decode(t,e);return r}encode(t,e,r){void 0===r&&(r=0);let n=this.getSourceVariant(t);if(void 0===n){let n=this.discriminator,i=this.defaultLayout,o=0;return this.usesPrefixDiscriminator&&(o=n.layout.span),n.encode(t[n.property],e,r),o+i.encode(t[i.property],e,r+o)}return n.encode(t,e,r)}addVariant(t,e,r){let n=new ez(this,t,e,r);return this.registry[t]=n,n}getVariant(t,e){let r=t;return f.isBuffer(t)&&(void 0===e&&(e=0),r=this.discriminator.decode(t,e)),this.registry[r]}}class ez extends eD{constructor(t,e,r,n){if(!(t instanceof eq))throw TypeError("union must be a Union");if(!Number.isInteger(e)||0>e)throw TypeError("variant must be a (non-negative) integer");if("string"==typeof r&&void 0===n&&(n=r,r=null),r){if(!(r instanceof eD))throw TypeError("layout must be a Layout");
1if(null!==t.defaultLayout&&0<=r.span&&r.span>t.defaultLayout.span)throw Error("variant span exceeds span of containing union");if("string"!=typeof n)throw TypeError("variant must have a String property")}let i=t.span;0>t.span&&0<=(i=r?r.span:0)&&t.usesPrefixDiscriminator&&(i+=t.discriminator.layout.span),super(i,n),this.union=t,this.variant=e,this.layout=r||null}getSpan(t,e){if(0<=this.span)return this.span;void 0===e&&(e=0);let r=0;return this.union.usesPrefixDiscriminator&&(r=this.union.discriminator.layout.span),r+this.layout.getSpan(t,e+r)}decode(t,e){let r=this.makeDestinationObject();if(void 0===e&&(e=0),this!==this.union.getVariant(t,e))throw Error("variant mismatch");let n=0;return this.union.usesPrefixDiscriminator&&(n=this.union.discriminator.layout.span),this.layout?r[this.property]=this.layout.decode(t,e+n):this.property?r[this.property]=!0:this.union.usesPrefixDiscriminator&&(r[this.union.discriminator.property]=this.variant),r}encode(t,e,r){void 0===r&&(r=0);let n=0;if(this.union.usesPrefixDiscriminator&&(n=this.union.discriminator.layout.span),this.layout&&!t.hasOwnProperty(this.property))throw TypeError("variant lacks property "+this.property);this.union.discriminator.encode(this.variant,e,r);let i=n;if(this.layout&&(this.layout.encode(t[this.property],e,r+n),i+=this.layout.getSpan(e,r+n),0<=this.union.span&&i>this.union.span))throw Error("encoded variant overruns containing union");return i}fromArray(t){if(this.layout)return this.layout.fromArray(t)}}class eF extends eD{constructor(t,e){if(!(t instanceof eP&&t.isCount()||Number.isInteger(t)&&0<=t))throw TypeError("length must be positive integer or an unsigned integer ExternalLayout");let r=-1;t instanceof eP||(r=t),super(r,e),this.length=t}getSpan(t,e){let r=this.span;return 0>r&&(r=this.length.decode(t,e)),r}decode(t,e){void 0===e&&(e=0);let r=this.span;return 0>r&&(r=this.length.decode(t,e)),t.slice(e,e+r)}encode(t,e,r){let n=this.length;if(this.length instanceof eP&&(n=t.length),!(f.isBuffer(t)&&n===t.length)){var i;throw TypeError((i="Blob.encode",(this.property?i+"["+this.property+"]":i)+" requires (length "+n+") Buffer as src"))}if(r+n>e.length)throw RangeError("encoding overruns Buffer");return e.write(t.toString("hex"),r,n,"hex"),this.length instanceof eP&&this.length.encode(n,e,r),n}}var eX=t=>new eL(4,t),eY=t=>new eV(t),eW=(t,e,r)=>new eK(t,e,r),eQ=(t,e,r)=>new eq(t,e,r),eZ=(t,e)=>new eF(t,e);class eJ extends ex{constructor(t){let e;super(-1,t),this.property=t,this.layout=eW([eX("length"),eX("lengthPadding"),eZ(new eH(eX(),-8,e),"chars")],this.property)}encode(t,e,r=0){if(null==t)return this.layout.span;let n={chars:f.from(t,"utf8")};return this.layout.encode(n,e,r)}decode(t,e=0){return this.layout.decode(t,e).chars.toString()}getSpan(t,e=0){return eX().span+eX().span+new(i())(new Uint8Array(t).slice(e,e+4),10,"le").toNumber()}}function e0(t){return new eJ(t)}function e1(t){return eZ(32,t)}let e2=eQ(eX("instruction"));e2.addVariant(0,eW([eY("lamports"),eY("space"),e1("owner")]),"createAccount"),e2.addVariant(1,eW([e1("owner")]),"assign"),e2.addVariant(2,eW([eY("lamports")]),"transfer"),e2.addVariant(3,eW([e1("base"),e0("seed"),eY("lamports"),eY("space"),e1("owner")]),"createAccountWithSeed"),e2.addVariant(4,eW([e1("authorized")]),"advanceNonceAccount"),e2.addVariant(5,eW([eY("lamports")]),"withdrawNonceAccount"),e2.addVariant(6,eW([e1("authorized")]),"initializeNonceAccount"),e2.addVariant(7,eW([e1("authorized")]),"authorizeNonceAccount"),e2.addVariant(8,eW([eY("space")]),"allocate"),e2.addVariant(9,eW([e1("base"),e0("seed"),eY("space"),e1("owner")]),"allocateWithSeed"),e2.addVariant(10,eW([e1("base"),e0("seed"),e1("owner")]),"assignWithSeed"),e2.addVariant(11,eW([eY("lamports"),e0("seed"),e1("owner")]),"transferWithSeed"),Object.values(e2.registry).map(t=>t.span);class e3 extends ex{constructor(t,e,r,n){super(t.span,n),this.layout=t,this.decoder=e,this.encoder=r}decode(t,e){return this.decoder(this.layout.decode(t,e))}encode(t,e,r){return this.layout.encode(this.encoder(t),e,r)}getSpan(t,e){return this.layout.getSpan(t,e)}}function e8(t){return new e3(eZ(32),t=>new o.PublicKey(t),t=>t.toBuffer(),t)}eW([eX("version"),eX("state"),e8("authorizedPubkey"),e8("nonce"),eW([new eG("lamportsPerSignature")
1],"feeCalculator")]),new o.PublicKey("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"),new o.PublicKey("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL");var e6={exports:{}};!function(t,e){var r="undefined"!=typeof self?self:te,n=function(){function t(){this.fetch=!1,this.DOMException=r.DOMException}return t.prototype=r,new t}();(function(t){var e={searchParams:"URLSearchParams"in n,iterable:"Symbol"in n&&"iterator"in Symbol,blob:"FileReader"in n&&"Blob"in n&&function(){try{return new Blob,!0}catch(t){return!1}}(),formData:"FormData"in n,arrayBuffer:"ArrayBuffer"in n};if(e.arrayBuffer)var r=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],i=ArrayBuffer.isView||function(t){return t&&r.indexOf(Object.prototype.toString.call(t))>-1};function o(t){if("string"!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(t))throw TypeError("Invalid character in header field name");return t.toLowerCase()}function s(t){return"string"!=typeof t&&(t=String(t)),t}function a(t){var r={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return e.iterable&&(r[Symbol.iterator]=function(){return r}),r}function c(t){this.map={},t instanceof c?t.forEach(function(t,e){this.append(e,t)},this):Array.isArray(t)?t.forEach(function(t){this.append(t[0],t[1])},this):t&&Object.getOwnPropertyNames(t).forEach(function(e){this.append(e,t[e])},this)}function u(t){if(t.bodyUsed)return Promise.reject(TypeError("Already read"));t.bodyUsed=!0}function l(t){return new Promise(function(e,r){t.onload=function(){e(t.result)},t.onerror=function(){r(t.error)}})}function d(t){var e=new FileReader,r=l(e);return e.readAsArrayBuffer(t),r}function h(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function _(){return this.bodyUsed=!1,this._initBody=function(t){if(this._bodyInit=t,t)if("string"==typeof t)this._bodyText=t;else if(e.blob&&Blob.prototype.isPrototypeOf(t))this._bodyBlob=t;else if(e.formData&&FormData.prototype.isPrototypeOf(t))this._bodyFormData=t;else if(e.searchParams&&URLSearchParams.prototype.isPrototypeOf(t))this._bodyText=t.toString();else{var r;e.arrayBuffer&&e.blob&&(r=t)&&DataView.prototype.isPrototypeOf(r)?(this._bodyArrayBuffer=h(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):e.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(t)||i(t))?this._bodyArrayBuffer=h(t):this._bodyText=t=Object.prototype.toString.call(t)}else this._bodyText="";!this.headers.get("content-type")&&("string"==typeof t?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):e.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},e.blob&&(this.blob=function(){var t=u(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(!this._bodyFormData)return Promise.resolve(new Blob([this._bodyText]));throw Error("could not read FormData body as blob")},this.arrayBuffer=function(){return this._bodyArrayBuffer?u(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(d)}),this.text=function(){var t,e,r,n=u(this);if(n)return n;if(this._bodyBlob)return t=this._bodyBlob,r=l(e=new FileReader),e.readAsText(t),r;if(this._bodyArrayBuffer)return Promise.resolve(function(t){for(var e=new Uint8Array(t),r=Array(e.length),n=0;n<e.length;n++)r[n]=String.fromCharCode(e[n]);return r.join("")}(this._bodyArrayBuffer));if(!this._bodyFormData)return Promise.resolve(this._bodyText);throw Error("could not read FormData body as text")},e.formData&&(this.formData=function(){return this.text().then(R)}),this.json=function(){return this.text().then(JSON.parse)},this}c.prototype.append=function(t,e){t=o(t),e=s(e);var r=this.map[t];this.map[t]=r?r+", "+e:e},c.prototype.delete=function(t){delete this.map[o(t)]},c.prototype.get=function(t){return t=o(t),this.has(t)?this.map[t]:null},c.prototype.has=function(t){return this.map.hasOwnProperty(o(t))},c.prototype.set=function(t,e){this.map[o(t)]=s(e)},c.prototype.forEach=function(t,e){for(var r in this.map)this.map.hasOwnProperty(r)&&t.call(e,this.map[r],r,this)},c.prototype.keys=function(){var t=[];return this.forEach(function(e,r){t.push(r)}),a(t)},c.prototype.values=function(){var t=[];return this.forEach(function(e){t.push(e)}),a(t)},c.prototype.entries=function(){var t=[];return this.forEach(function(e,r){t.push([r,e])}),a(t)},e.iterable&&(c.prototype[Symbol.iterator]=c.prototype.entries);
1var p=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function f(t,e){var r,n,i=(e=e||{}).body;if(t instanceof f){if(t.bodyUsed)throw TypeError("Already read");this.url=t.url,this.credentials=t.credentials,e.headers||(this.headers=new c(t.headers)),this.method=t.method,this.mode=t.mode,this.signal=t.signal,i||null==t._bodyInit||(i=t._bodyInit,t.bodyUsed=!0)}else this.url=String(t);if(this.credentials=e.credentials||this.credentials||"same-origin",(e.headers||!this.headers)&&(this.headers=new c(e.headers)),this.method=(n=(r=e.method||this.method||"GET").toUpperCase(),p.indexOf(n)>-1?n:r),this.mode=e.mode||this.mode||null,this.signal=e.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&i)throw TypeError("Body not allowed for GET or HEAD requests");this._initBody(i)}function R(t){var e=new FormData;return t.trim().split("&").forEach(function(t){if(t){var r=t.split("="),n=r.shift().replace(/\+/g," "),i=r.join("=").replace(/\+/g," ");e.append(decodeURIComponent(n),decodeURIComponent(i))}}),e}function A(t,e){e||(e={}),this.type="default",this.status=void 0===e.status?200:e.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in e?e.statusText:"OK",this.headers=new c(e.headers),this.url=e.url||"",this._initBody(t)}f.prototype.clone=function(){return new f(this,{body:this._bodyInit})},_.call(f.prototype),_.call(A.prototype),A.prototype.clone=function(){return new A(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new c(this.headers),url:this.url})},A.error=function(){var t=new A(null,{status:0,statusText:""});return t.type="error",t};var y=[301,302,303,307,308];A.redirect=function(t,e){if(-1===y.indexOf(e))throw RangeError("Invalid status code");return new A(null,{status:e,headers:{location:t}})},t.DOMException=n.DOMException;try{new t.DOMException}catch(e){t.DOMException=function(t,e){this.message=t,this.name=e;var r=Error(t);this.stack=r.stack},t.DOMException.prototype=Object.create(Error.prototype),t.DOMException.prototype.constructor=t.DOMException}function E(r,n){return new Promise(function(i,o){var s=new f(r,n);if(s.signal&&s.signal.aborted)return o(new t.DOMException("Aborted","AbortError"));var a=new XMLHttpRequest;function u(){a.abort()}a.onload=function(){var t,e,r={status:a.status,statusText:a.statusText,headers:(t=a.getAllResponseHeaders()||"",e=new c,t.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach(function(t){var r=t.split(":"),n=r.shift().trim();if(n){var i=r.join(":").trim();e.append(n,i)}}),e)};r.url="responseURL"in a?a.responseURL:r.headers.get("X-Request-URL"),i(new A("response"in a?a.response:a.responseText,r))},a.onerror=function(){o(TypeError("Network request failed"))},a.ontimeout=function(){o(TypeError("Network request failed"))},a.onabort=function(){o(new t.DOMException("Aborted","AbortError"))},a.open(s.method,s.url,!0),"include"===s.credentials?a.withCredentials=!0:"omit"===s.credentials&&(a.withCredentials=!1),"responseType"in a&&e.blob&&(a.responseType="blob"),s.headers.forEach(function(t,e){a.setRequestHeader(e,t)}),s.signal&&(s.signal.addEventListener("abort",u),a.onreadystatechange=function(){4===a.readyState&&s.signal.removeEventListener("abort",u)}),a.send(void 0===s._bodyInit?null:s._bodyInit)})}E.polyfill=!0,n.fetch||(n.fetch=E,n.Headers=c,n.Request=f,n.Response=A),t.Headers=c,t.Request=f,t.Response=A,t.fetch=E,Object.defineProperty(t,"__esModule",{value:!0})})({}),n.fetch.ponyfill=!0,delete n.fetch.polyfill,(e=n.fetch).default=n.fetch,e.fetch=n.fetch,e.Headers=n.Headers,e.Request=n.Request,e.Response=n.Response,t.exports=e}(e6,e6.exports);e6.exports;d.rustEnum([d.struct([],"uninitialized"),d.struct([d.option(d.publicKey(),"authorityAddress")],"buffer"),d.struct([d.publicKey("programdataAddress")],"program"),d.struct([d.u64("slot"),d.option(d.publicKey(),"upgradeAuthorityAddress")],"programData")],void 0,d.u32());let e4="Program log: ",e5="Program data: ",e9=e4.length,e7=e5.length;class rt{constructor(t,e,r){this._programId=t,this._provider=e,this._eventParser=new re(t,r),this._eventCallbacks=new Map,this._eventListeners=new Map,this._listenerIdCount=0}
1addEventListener(t,e,r){var n;let i=this._listenerIdCount;return this._listenerIdCount+=1,this._eventListeners.has(t)||this._eventListeners.set(t,[]),this._eventListeners.set(t,(null!=(n=this._eventListeners.get(t))?n:[]).concat(i)),this._eventCallbacks.set(i,[t,e]),void 0!==this._onLogsSubscriptionId||(this._onLogsSubscriptionId=this._provider.connection.onLogs(this._programId,(t,e)=>{if(!t.err)for(let r of this._eventParser.parseLogs(t.logs)){let n=this._eventListeners.get(r.name);n&&n.forEach(n=>{let i=this._eventCallbacks.get(n);if(i){let[,n]=i;n(r.data,e.slot,t.signature)}})}},r)),i}async removeEventListener(t){let e=this._eventCallbacks.get(t);if(!e)throw Error(`Event listener ${t} doesn't exist!`);let[r]=e,n=this._eventListeners.get(r);if(!n)throw Error(`Event listeners don't exist for ${r}!`);if(this._eventCallbacks.delete(t),n=n.filter(e=>e!==t),this._eventListeners.set(r,n),0===n.length&&this._eventListeners.delete(r),0===this._eventCallbacks.size){if(0!==this._eventListeners.size)throw Error(`Expected event listeners size to be 0 but got ${this._eventListeners.size}`);void 0!==this._onLogsSubscriptionId&&(await this._provider.connection.removeOnLogsListener(this._onLogsSubscriptionId),this._onLogsSubscriptionId=void 0)}}}class re{constructor(t,e){this.coder=e,this.programId=t}*parseLogs(t,e=!1){let r=new rn(t),n=new rr,i=r.next();for(;null!==i;){let[t,o,s]=this.handleLog(n,i,e);t&&(yield t),o&&n.push(o),s&&n.pop(),i=r.next()}}handleLog(t,e,r){return t.stack.length>0&&t.program()===this.programId.toString()?this.handleProgramLog(e,r):[null,...this.handleSystemLog(e)]}handleProgramLog(t,e){if(!(t.startsWith(e4)||t.startsWith(e5)))return[null,...this.handleSystemLog(t)];{let r=t.startsWith(e4)?t.slice(e9):t.slice(e7),n=this.coder.events.decode(r);if(e&&null===n)throw Error(`Unable to decode event ${r}`);return[n,null,!1]}}handleSystemLog(t){let e=t.split(":")[0];return null!==e.match(/^Program (.*) success/g)?[null,!0]:e.startsWith(`Program ${this.programId.toString()} invoke`)?[this.programId.toString(),!1]:e.includes("invoke")?["cpi",!1]:[null,!1]}}class rr{constructor(){this.stack=[]}program(){if(!this.stack.length)throw Error("Expected the stack to have elements");return this.stack[this.stack.length-1]}push(t){this.stack.push(t)}pop(){if(!this.stack.length)throw Error("Expected the stack to have elements");this.stack.pop()}}class rn{constructor(t){this.logs=t}next(){if(0===this.logs.length)return null;let t=this.logs[0];return this.logs=this.logs.slice(1),t}}function ri(t,e){var r,n;let i={},o=t.args?t.args.length:0;if(e.length>o){if(e.length!==o+1)throw Error(`provided too many arguments ${e} to instruction ${null==t?void 0:t.name} expecting: ${null!=(n=null==(r=t.args)?void 0:r.map(t=>t.name))?n:[]}`);i=e.pop()}return[e,i]}class ro{static build(t,e,r){if("_inner"===t.name)throw new ey("the _inner name is reserved");let n=(...i)=>{let[s,a]=ri(t,[...i]);!function t(e,r={}){e.forEach(e=>{if(O(e))t(e.accounts,r[e.name]);else if(!r[e.name])throw Error(`Account \`${e.name}\` not provided.`)})}(t.accounts,a.accounts),[...i];let c=n.accounts(a.accounts);return void 0!==a.remainingAccounts&&c.push(...a.remainingAccounts),eA("debug-logs")&&console.log("Outgoing account metas:",c),new o.TransactionInstruction({keys:c,programId:r,data:e(t.name,function(t,...e){if(t.args.length!=e.length)throw Error("Invalid argument length");let r={},n=0;return t.args.forEach(t=>{r[t.name]=e[n],n+=1}),r}(t,...s))})};return n.accounts=e=>ro.accountsArray(e,t.accounts,r,t.name),n}static accountsArray(t,e,r,n){return t?e.map(e=>{let i;if(O(e)){let i=t[e.name];return ro.accountsArray(i,e.accounts,r,n).flat()}try{i=T(t[e.name])}catch(t){throw Error(`Wrong input type for account "${e.name}" in the instruction accounts object${void 0!==n?' for instruction "'+n+'"':""}. Expected PublicKey or string.`)}let o=e.optional&&i.equals(r);return{pubkey:i,isWritable:!!(e.writable&&!o),isSigner:!!(e.signer&&!o)}}).flat():[]}}class rs{static build(t,e){return(...r)=>{var n,i,s;let[,a]=ri(t,[...r]),c=new o.Transaction;if(a.preInstructions&&a.instructions)throw Error("instructions is deprecated, use preInstructions");
1return null==(n=a.preInstructions)||n.forEach(t=>c.add(t)),null==(i=a.instructions)||i.forEach(t=>c.add(t)),c.add(e(...r)),null==(s=a.postInstructions)||s.forEach(t=>c.add(t)),c}}}class ra{static build(t,e,r,n){return async(...i)=>{var o;let s=e(...i),[,a]=ri(t,[...i]);if(void 0===n.sendAndConfirm)throw Error("This function requires 'Provider.sendAndConfirm' to be implemented.");try{return await n.sendAndConfirm(s,null!=(o=a.signers)?o:[],a.options)}catch(t){throw eN(t,r)}}}}class rc{static build(t,e,r,n){var i;return(null!=(i=t.accounts)?i:[]).reduce((i,o)=>(i[o.name]=new ru(t,o,r,n,e),i),{})}}class ru{get size(){return this._size}get programId(){return this._programId}get provider(){return this._provider}get coder(){return this._coder}constructor(t,e,r,n,i){this._idlAccount=e,this._programId=r,this._provider=null!=n?n:J(),this._coder=null!=i?i:new eM(t),this._size=this._coder.accounts.size(e.name)}async fetchNullable(t,e){let{data:r}=await this.fetchNullableAndContext(t,e);return r}async fetchNullableAndContext(t,e){let{value:r,context:n}=await this.getAccountInfoAndContext(t,e);return{data:r&&0!==r.data.length?this._coder.accounts.decode(this._idlAccount.name,r.data):null,context:n}}async fetch(t,e){let{data:r}=await this.fetchNullableAndContext(t,e);if(null===r)throw Error(`Account does not exist or has no data ${t.toString()}`);return r}async fetchAndContext(t,e){let{data:r,context:n}=await this.fetchNullableAndContext(t,e);if(null===r)throw Error(`Account does not exist ${t.toString()}`);return{data:r,context:n}}async fetchMultiple(t,e){return(await this.fetchMultipleAndContext(t,e)).map(t=>t?t.data:null)}async fetchMultipleAndContext(t,e){return(await $(this._provider.connection,t.map(t=>T(t)),e)).map(t=>{if(null==t)return null;let{account:e,context:r}=t;return{data:this._coder.accounts.decode(this._idlAccount.name,e.data),context:r}})}async all(t){let e=this.coder.accounts.memcmp(this._idlAccount.name,t instanceof f?t:void 0),r=[];return(null==e?void 0:e.offset)!=void 0&&(null==e?void 0:e.bytes)!=void 0&&r.push({memcmp:{offset:e.offset,bytes:e.bytes}}),(null==e?void 0:e.dataSize)!=void 0&&r.push({dataSize:e.dataSize}),(await this._provider.connection.getProgramAccounts(this._programId,{commitment:this._provider.connection.commitment,filters:[...r,...Array.isArray(t)?t:[]]})).map(({pubkey:t,account:e})=>({publicKey:t,account:this._coder.accounts.decode(this._idlAccount.name,e.data)}))}subscribe(t,e){let r=rl.get(t.toString());if(r)return r.ee;let n=new(p());t=T(t);let i=this._provider.connection.onAccountChange(t,t=>{let e=this._coder.accounts.decode(this._idlAccount.name,t.data);n.emit("change",e)},e);return rl.set(t.toString(),{ee:n,listener:i}),n}async unsubscribe(t){let e=rl.get(t.toString());if(!e)return void console.warn("Address is not subscribed");rl&&await this._provider.connection.removeAccountChangeListener(e.listener).then(()=>{rl.delete(t.toString())}).catch(console.error)}async createInstruction(t,e){let r=this.size;if(void 0===this._provider.publicKey)throw Error("This function requires the Provider interface implementor to have a 'publicKey' field.");return o.SystemProgram.createAccount({fromPubkey:this._provider.publicKey,newAccountPubkey:t.publicKey,space:null!=e?e:r,lamports:await this._provider.connection.getMinimumBalanceForRentExemption(null!=e?e:r),programId:this._programId})}async getAccountInfo(t,e){return await this._provider.connection.getAccountInfo(T(t),e)}async getAccountInfoAndContext(t,e){return await this._provider.connection.getAccountInfoAndContext(T(t),e)}}let rl=new Map;class rd{static build(t,e,r,n,i,o,s){return async(...a)=>{var c;let u,l=e(...a),[,d]=ri(t,[...a]);if(void 0===n.simulate)throw Error("This function requires 'Provider.simulate' to be implemented.");try{u=await n.simulate(l,d.signers,null==(c=d.options)?void 0:c.commitment)}catch(t){throw eN(t,r)}if(void 0===u)throw Error("Unable to simulate transaction");let h=u.logs;if(!h)throw Error("Simulated logs not found");let _=[];if(s.events)for(let t of new re(o,i).parseLogs(h))_.push(t);return{events:_,raw:h}}}}function rh(t){return new rp(eZ(8),t=>rR.fromBuffer(t),t=>t.toBuffer(),t)}function r_(t){return new rp(eZ(32),t=>new o.PublicKey(t),t=>t.toBuffer(),t)}class rp extends ex{constructor(t,e,r,n){super(t.span,n),this.layout=t,this.decoder=e,this.encoder=r}decode(t,e){return this.decoder(this.layout.decode(t,e))}encode(t,e,r){return this.layout.encode(this.encoder(t),e,r)}getSpan(t,e){return this.layout.getSpan(t,e)}}class rf extends ex{constructor(t,e){super(-1,e),this.layout=t,this.discriminator=eX()}encode(t,e,r=0){return null==t?this.layout.span+this.discriminator.encode(0,e,r):(this.discriminator.encode(1,e,r),this.layout.encode(t,e,r+4)+4)}decode(t,e=0){let r=this.discriminator.decode(t,e);if(0===r)return null;if(1===r)return this.layout.decode(t,e+4);throw Error("Invalid coption "+this.layout.property)}getSpan(t,e=0){return this.layout.getSpan(t,e+4)+4}}class rR extends i(){toBuffer(){let t=super.toArray().reverse(),e=f.from(t);if(8===e.length)return e;if(e.length>=8)throw Error("u64 too large");let r=f.alloc(8);return e.copy(r),r}static fromBuffer(t){if(8!==t.length)throw Error(`Invalid buffer length: ${t.length}`);return new rR([...t].reverse().map(t=>`00${t.toString(16)}`.slice(-2)).join(""),16)}}let rA=eW([r_("mint"),r_("owner"),rh("amount"),new rf(r_(),"delegate"),
1(t=>{let e=eQ(new eL(1,"discriminator"),null,t);return e.addVariant(0,eW([]),"uninitialized"),e.addVariant(1,eW([]),"initialized"),e.addVariant(2,eW([]),"frozen"),e})("state"),new rf(rh(),"isNative"),rh("delegatedAmount"),new rf(r_(),"closeAuthority")]);class ry{constructor(t,e,r,n,i,o,s,a){this._args=t,this._accounts=e,this._provider=r,this._programId=n,this._idlIx=i,this._idlTypes=s,this._customResolver=a,this._accountStore=new rE(r,o,n)}args(t){this._args=t}async resolve(){this.resolveEventCpi(this._idlIx.accounts),this.resolveConst(this._idlIx.accounts);let t=0;for(;await this.resolvePdasAndRelations(this._idlIx.accounts)+await this.resolveCustom()>0;)if(16==++t){let t=e=>O(e)?e.accounts.some(t):!!(e.address||e.pda||e.relations),e=(t,r=[],n=[])=>{for(let i of t)O(i)?n.push(...e(i.accounts,[...r,i.name])):n.push([...r,i.name]);return n},r=e(this._idlIx.accounts.filter(t)).filter(t=>!this.get(t)).map(t=>t.reduce((t,e)=>t+"."+e)).map(t=>`\`${t}\``).join(", ");throw Error(`Reached maximum depth for account resolution. Unresolved accounts: ${r}`)}}resolveOptionals(t){Object.assign(this._accounts,this.resolveOptionalsHelper(t,this._idlIx.accounts))}get(t){let e=t.reduce((t,e)=>t&&t[e],this._accounts);if(e&&e.toBase58)return e}set(t,e){let r=this._accounts;t.forEach((n,i)=>{var o;i===t.length-1&&(r[n]=e),r[n]=null!=(o=r[n])?o:{},r=r[n]})}resolveOptionalsHelper(t,e){let r={};for(let n of e){let e=n.name,i=t[e];void 0!==i&&(rm(i)?O(n)?r[e]=this.resolveOptionalsHelper(i,n.accounts):r[e]=function t(e,r){let n={};for(let i in e){let o=e[i];if(null===o){if(r)throw Error("Failed to resolve optionals due to IDL type mismatch with input accounts!");continue}n[i]=rm(o)?t(o,!0):T(o)}return n}(i,!0):null!==i?r[e]=T(i):n.optional&&(r[e]=this._programId))}return r}async resolveCustom(){if(this._customResolver){let{accounts:t,resolved:e}=await this._customResolver({args:this._args,accounts:this._accounts,provider:this._provider,programId:this._programId,idlIx:this._idlIx});return this._accounts=t,e}return 0}resolveEventCpi(t,e=[]){for(let r in t){let n=t[r];O(n)&&this.resolveEventCpi(n.accounts,[...e,n.name]);let i=+r+1;if(i===t.length)return;let s=t[r].name,a=t[i].name;if("eventAuthority"===s&&"program"===a){let t=[...e,s],r=[...e,a];this.get(t)||this.set(t,o.PublicKey.findProgramAddressSync([f.from("__event_authority")],this._programId)[0]),this.get(r)||this.set(r,this._programId);return}}}resolveConst(t,e=[]){for(let r of t){let t=r.name;if(O(r))this.resolveConst(r.accounts,[...e,t]);else if((r.signer||r.address)&&!this.get([...e,t])){if(r.signer){if(!this._provider.publicKey)throw Error("This function requires the `Provider` interface implementor to have a `publicKey` field.");this.set([...e,t],this._provider.publicKey)}r.address&&this.set([...e,t],T(r.address))}}}async resolvePdasAndRelations(t,e=[]){let r=0;for(let n of t){let t=n.name;if(O(n))r+=await this.resolvePdasAndRelations(n.accounts,[...e,t]);else if((n.pda||n.relations)&&!this.get([...e,t])){r++;try{if(n.pda){let r=await Promise.all(n.pda.seeds.map(t=>this.toBuffer(t,e)));if(r.some(t=>!t))continue;let i=await this.parseProgramId(n,e),[s]=o.PublicKey.findProgramAddressSync(r,i);this.set([...e,t],s)}}catch{}try{if(n.relations){let r=this.get([...e,n.relations[0]]);if(r){let n=await this._accountStore.fetchAccount({publicKey:r});this.set([...e,t],n[t])}}}catch{}}}return r}async parseProgramId(t,e=[]){var r;if(!(null==(r=t.pda)?void 0:r.program))return this._programId;let n=await this.toBuffer(t.pda.program,e);if(!n)throw Error(`Program seed not resolved: ${t.name}`);return new o.PublicKey(n)}async toBuffer(t,e=[]){switch(t.kind){case"const":return this.toBufferConst(t);case"arg":return await this.toBufferArg(t);case"account":return await this.toBufferAccount(t,e);default:throw Error(`Unexpected seed: ${t}`)}}toBufferConst(t){return this.toBufferValue("bytes",t.value)}async toBufferArg(t){let[e,...r]=t.path.split("."),n=this._idlIx.args.findIndex(t=>t.name===e);if(-1===n)throw Error(`Unable to find argument for seed: ${e}`);let i=r.reduce((t,e)=>(null!=t?t:{})[e],this._args[n]);if(void 0===i)return;let o=this.getType(this._idlIx.args[n].type,r);return this.toBufferValue(o,i)}async toBufferAccount(t,e=[]){let[r,...n]=t.path.split("."),i=this.get([...e,r]);if(!i)return;if(!n.length)return this.toBufferValue("pubkey",i);if(!t.account)throw Error(`Seed account is required in order to resolve type: ${t.path}`);let o=await this._accountStore.fetchAccount({publicKey:i,name:t.account}),s=n;for(;s.length>0;)o=o[s[0]],s=s.slice(1);if(void 0===o)return;let a=this.getType({defined:{name:t.account}},n);return this.toBufferValue(a,o)}toBufferValue(t,e){switch(t){case"u8":case"i8":return f.from([e]);case"u16":case"i16":return new(i())(e).toArrayLike(f,"le",2);case"u32":case"i32":return new(i())(e).toArrayLike(f,"le",4);case"u64":case"i64":return new(i())(e).toArrayLike(f,"le",8);case"u128":case"i128":return new(i())(e).toArrayLike(f,"le",16);case"u256":case"i256":return new(i())(e).toArrayLike(f,"le",32);case"string":case"bytes":return f.from(e);case"pubkey":return e.toBuffer();default:if(null==t?void 0:t.array)return f.from(e);throw Error(`Unexpected seed type: ${t}`)}}getType(t,e=[]){var r;let n=null==(r=null==t?void 0:t.defined)?void 0:r.name;if(n){if("tokenAccount"===n)switch(e.at(0)){case"mint":case"owner":return"pubkey";case"amount":case"delagatedAmount":return"u64";default:throw Error(`Unknown token account path: ${e}`)}let t=this._idlTypes.find(t=>t.name===n);if(!t)throw Error(`Type not found: ${n}`);let[r,...i]=e,o=t.type.fields.find(t=>t.name===r);if(!o)throw Error(`Field not found: ${r}`);return this.getType(o.type,i)}return t}}class rE{constructor(t,e,r){this._provider=t,this._cache=new Map,this._idls={},this._idls[r.toBase58()]=e}async fetchAccount({publicKey:t,name:e}){let r=t.toBase58();if(!this._cache.has(r)){let i=await this._provider.connection.getAccountInfo(t);if(null===i)throw Error(`Account not found: ${r}`);if("tokenAccount"===e){var n;let t=(n=i.data,rA.decode(n));this._cache.set(r,t)}else{let t=await this.getAccountsNs(i.owner);if(t){let e=Object.values(t)[0];if(e){let t=e.coder.accounts.decodeAny(i.data);this._cache.set(r,t)}}}}return this._cache.get(r)}async getAccountsNs(t){let e=t.toBase58();if(!this._idls[e]){let r=await rI.fetchIdl(t,this._provider);if(r){let t=new rI(r,this._provider);this._idls[e]=t.account}}return this._idls[e]}}class rO{static build(t,e,r,n,i,o,s,a,c,u,l){return(...d)=>new rN(d,n,i,o,s,a,t,e,r,c,u,l)}}function rm(t){return"object"==typeof t&&null!==t&&!("_bn"in t)}class rN{constructor(t,e,r,n,i,o,s,a,c,u,l,d){this._args=t,this._ixFn=e,this._txFn=r,this._rpcFn=n,this._simulateFn=i,this._viewFn=o,this._accounts={},this._remainingAccounts=[],this._signers=[],this._preInstructions=[],this._postInstructions=[],this._resolveAccounts=!0,this._accountsResolver=new ry(t,this._accounts,s,a,c,u,l,d)}args(t){this._args=t,this._accountsResolver.args(t)}accounts(t){return this.accountsPartial(t)}accountsPartial(t){return this._resolveAccounts=!0,this._accountsResolver.resolveOptionals(t),this}accountsStrict(t){return this._resolveAccounts=!1,this._accountsResolver.resolveOptionals(t),this}signers(t){return this._signers=this._signers.concat(t),this}remainingAccounts(t){return this._remainingAccounts=this._remainingAccounts.concat(t),this}preInstructions(t,e=!1){return e?this._preInstructions=t.concat(this._preInstructions):this._preInstructions=this._preInstructions.concat(t),this}postInstructions(t){return this._postInstructions=this._postInstructions.concat(t),this}async pubkeys(){return this._resolveAccounts&&await this._accountsResolver.resolve(),this._accounts}async instruction(){return this._resolveAccounts&&await this._accountsResolver.resolve(),this._ixFn(...this._args,{accounts:this._accounts,signers:this._signers,remainingAccounts:this._remainingAccounts,preInstructions:this._preInstructions,postInstructions:this._postInstructions})}async transaction(){return this._resolveAccounts&&await this._accountsResolver.resolve(),this._txFn(...this._args,{accounts:this._accounts,signers:this._signers,remainingAccounts:this._remainingAccounts,preInstructions:this._preInstructions,postInstructions:this._postInstructions})}async simulate(t){return this._resolveAccounts&&await this._accountsResolver.resolve(),this._simulateFn(...this._args,{accounts:this._accounts,signers:this._signers,remainingAccounts:this._remainingAccounts,preInstructions:this._preInstructions,postInstructions:this._postInstructions,options:t})}async view(t){if(this._resolveAccounts&&await this._accountsResolver.resolve(),!this._viewFn)throw Error("Method does not support views. The instruction should return a value, and its accounts must be read-only");return this._viewFn(...this._args,{accounts:this._accounts,signers:this._signers,remainingAccounts:this._remainingAccounts,preInstructions:this._preInstructions,postInstructions:this._postInstructions,options:t})}async rpc(t){return this._resolveAccounts&&await this._accountsResolver.resolve(),this._rpcFn(...this._args,{accounts:this._accounts,signers:this._signers,remainingAccounts:this._remainingAccounts,preInstructions:this._preInstructions,postInstructions:this._postInstructions,options:t})}async rpcAndKeys(t){return{signature:await this.rpc(t),pubkeys:await this.pubkeys()}}async prepare(){return{instruction:await this.instruction(),signers:this._signers,pubkeys:await this.pubkeys()}}}class rg{static build(t,e,r,n){let i=e.accounts.find(t=>t.writable),o=!!e.returns;if(!i&&o)return async(...i)=>{let o=await r(...i),s=`Program return: ${t} `,a=o.raw.find(t=>t.startsWith(s));if(!a)throw Error("View expected return log");let c=E(a.slice(s.length)),u=e.returns;if(!u)throw Error("View expected return type");return eI.fieldLayout({type:u},n.types).decode(c)}}}class rT{static build(t,e,r,n,i){let o={},s={},a={},c={},u={},l={},d=function(t){let e=new Map;
1return t.errors&&t.errors.forEach(t=>{var r;let n=null!=(r=t.msg)?r:t.name;e.set(t.code,n)}),e}(t),h=t.accounts?rc.build(t,e,r,n):{};return t.instructions.forEach(_=>{let p=ro.build(_,(t,r)=>e.instruction.encode(t,r),r),f=rs.build(_,p),R=ra.build(_,f,d,n),A=rd.build(_,f,d,n,e,r,t),y=rg.build(r,_,A,t),E=rO.build(n,r,_,p,f,R,A,y,h,t.types||[],null==i?void 0:i(_)),O=_.name;s[O]=p,a[O]=f,o[O]=R,c[O]=A,u[O]=E,y&&(l[O]=y)}),[o,s,a,h,c,u,l]}}class rI{get programId(){return this._programId}get idl(){return this._idl}get rawIdl(){return this._rawIdl}get coder(){return this._coder}get provider(){return this._provider}constructor(t,e=J(),r,n){this._idl=function(t){let e=["name","path","account","relations","generic"],r=t=>t.split(".").map(l()).join("."),n=t=>{for(let i in t){let o=t[i];e.includes(i)?t[i]=Array.isArray(o)?o.map(r):r(o):"object"==typeof o&&n(o)}},i=structuredClone(t);return n(i),i}(t),this._rawIdl=t,this._provider=e,this._programId=T(t.address),this._coder=null!=r?r:new eM(this._idl),this._events=new rt(this._programId,e,this._coder);let[i,o,s,a,c,u,d]=rT.build(this._idl,this._coder,this._programId,e,n);this.rpc=i,this.instruction=o,this.transaction=s,this.account=a,this.simulate=c,this.methods=u,this.views=d}static async at(t,e){let r=T(t),n=await rI.fetchIdl(r,e);if(!n)throw Error(`IDL not found for program: ${t.toString()}`);return new rI(n,e)}static async fetchIdl(t,e){var r;e=null!=e?e:J();let n=T(t),i=await m(n),o=await e.connection.getAccountInfo(i);if(!o)return null;let s=(r=o.data.slice(8),N.decode(r));return JSON.parse(A((0,h.UD)(s.data)))}addEventListener(t,e,r){return this._events.addEventListener(t,e,r)}async removeEventListener(t){return await this._events.removeEventListener(t)}}new o.PublicKey("11111111111111111111111111111111")}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.