PageSourceSearch

https://www.dropsome.xyz/_next/static/chunks/76e93f97-33a4b6a95c8bfe5b.js

js dropsome.xyz collected 2026-10-08 12:43:27 UTC 78,476 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[591],{2852:function(t,e,r){r.d(e,{$r:function(){return rZ},BN:function(){return p.a},P6:function(){return rm},Y7:function(){return tu},fc:function(){return th},rV:function(){return h}});var n,i,o,s,a,c,u,l,d,_,h=r(4177),f=r(1823),p=r.n(f),R=r(8764),O=r(7191),E=r.n(O),A=r(7885),y=r(6934),m=r(7748),N=r(6409),g=r(6729),T=r.n(g),v=r(8764).Buffer;let I=t=>"version"in t;function w(t){return new TextDecoder("utf-8").decode(t)}function C(t){return new TextEncoder().encode(t)}function S(t){return E().encode(t)}function b(t){return R.Buffer.from(t,"base64")}var L=Object.freeze({__proto__:null,hex:Object.freeze({__proto__:null,encode:function(t){return t.reduce((t,e)=>t+e.toString(16).padStart(2,"0"),"0x")},decode:function(t){0===t.indexOf("0x")&&(t=t.substr(2)),t.length%2==1&&(t="0"+t);let e=t.match(/.{2}/g);return null===e?R.Buffer.from([]):R.Buffer.from(e.map(t=>parseInt(t,16)))}}),utf8:Object.freeze({__proto__:null,decode:w,encode:C}),bs58:Object.freeze({__proto__:null,encode:S,decode:function(t){return E().decode(t)}}),base64:Object.freeze({__proto__:null,encode:function(t){return t.toString("base64")},decode:b})});function H(t){return"accounts"in t}let D=new h.PublicKey("ProgM6JCCvbYkfKqJYHePx4xxSUSqJp7rh8Lyv7nk7S");function U(t,e,r,n){return(null==t?void 0:t.length)?t[0].name?r(t):n(t):e()}function P(t){return t instanceof h.PublicKey?t:new h.PublicKey(t)}(n=l||(l={}))[n.None=0]="None",n[n.Gzip=1]="Gzip",n[n.Zlib=2]="Zlib",(i=d||(d={}))[i.None=0]="None",i[i.Utf8=1]="Utf8",i[i.Base58=2]="Base58",i[i.Base64=3]="Base64",(o=_||(_={}))[o.None=0]="None",o[o.Json=1]="Json",o[o.Yaml=2]="Yaml",o[o.Toml=3]="Toml";class k extends TypeError{constructor(t,e){let r;let{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 x(t){return"object"==typeof t&&null!=t}function M(t){return"string"==typeof t?JSON.stringify(t):""+t}function*B(t,e,r,n){var i;for(let o of(x(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: `"+M(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*G(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&&x(e.schema)&&x(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 G(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):x(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 ${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)=>B(n(t,e),e,this,t):this.validator=()=>[],i?this.refiner=(t,e)=>B(i(t,e),e,this,t):this.refiner=()=>[]}assert(t){return function(t,e){let r=V(t,e);if(r[0])throw r[0]}(t,this)}create(t){return K(t,this)}is(t){return!V(t,this)[0]}mask(t){return function(t,e){let r=V(t,e,{coerce:!0,mask:!0});if(!r[0])return r[1];throw r[0]}(t,this)}validate(t,e){return void 0===e&&(e={}),V(t,this,e)}}function K(t,e){let r=V(t,e,{coerce:!0});if(!r[0])return r[1];throw r[0]}function V(t,e,r){void 0===r&&(r={});let n=G(t,e,r),i=function(t){let{done:e,value:r}=t.next();return e?void 0:r}(n);return i[0]?[new k(i[0],function*(){for(let t of n)t[0]&&(yield t[0])}),void 0]:[void 0,i[1]]}function z(t,e){return new $({type:t,schema:null,validator:e})}function j(t){return new $({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: "+M(t)})}function Y(t){let e=M(t),r=typeof t;return new $({type:"literal",schema:"string"===r||"number"===r||"boolean"===r?t:null,validator:r=>r===t||"Expected the literal `"+e+"`, but received: "+M(r)})}function X(t){return new $({...t,validator:(e,r)=>null===e||t.validator(e,r),refiner:(e,r)=>null===e||t.refiner(e,r)})}function F(){return z("number",t=>"number"==typeof t&&!isNaN(t)||"Expected a number, but received: "+M(t))}function W(t){return new $({...t,validator:(e,r)=>void 0===e||t.validator(e,r),refiner:(e,r)=>void 0===e||t.refiner(e,r)})}function q(){return z("string",t=>"string"==typeof t||"Expected a string, but received: "+M(t))}function Z(t){let e=Object.keys(t);return new $({type:"type",schema:t,*entries(r){if(x(r))for(let n of e)yield[n,r[n],t[n]]},validator:t=>x(t)||"Expected an object, but received: "+M(t)})}function Q(t){let e=t.map(t=>t.type).join(" | ");return new $({type:"union",schema:null,coercer:(e,r)=>(t.find(t=>{let[r]=t.validate(e,{coerce:!0});return!r})||J()).coercer(e,r),validator(r,n){let i=[];for(let e of t){let[...t]=G(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: "+M(r),...i]}})}function J(){return z("unknown",()=>!0)}async function tt(t,e,r,n){t=P(t),n||(n=tf());let i=new h.Transaction;if(i.add(new h.TransactionInstruction({programId:t,keys:null!=e?e:[],data:r})),void 0===n.sendAndConfirm)throw Error("This function requires 'Provider.sendAndConfirm' to be implemented.");return await n.sendAndConfirm(i,[])}async function te(t,e,r){return(await tr(t,e,r)).map(t=>t?{publicKey:t.publicKey,account:t.account}:null)}async function tr(t,e,r){if(e.length<=99)return await tn(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=>tn(t,e,r)))).flat()}}async function tn(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 ti(t,e,r,n,i){var o;r&&r.length>0&&e.sign(...r);let s=e._compile(),a=s.serialize(),c=e._serialize(a).toString("base64"),u={encoding:"base64",commitment:null!=n?n:t.commitment};if(i){let t=(Array.isArray(i)?i:s.nonProgramIds()).map(t=>
1t.toBase58());u.accounts={encoding:"base64",addresses:t}}r&&r.length>0&&(u.sigVerify=!0);let l=K(await t._rpcRequest("simulateTransaction",[c,u]),ta);if("error"in l){let t;if("data"in l.error&&(t=null===(o=l.error.data)||void 0===o?void 0:o.logs)&&Array.isArray(t)){let e="\n    ",r=e+t.join(e);console.error(l.error.message,r)}throw new h.SendTransactionError("failed to simulate transaction: "+l.error.message,t)}return l.result}let to=ts(J());function ts(t){return Q([Z({jsonrpc:Y("2.0"),id:q(),result:t}),Z({jsonrpc:Y("2.0"),id:q(),error:Z({code:J(),message:q(),data:W(z("any",()=>!0))})})])}let ta=(s=Z({err:X(Q([Z({}),q()])),logs:X(j(q())),accounts:W(X(j(X(Z({executable:z("boolean",t=>"boolean"==typeof t),owner:q(),lamports:F(),data:j(q()),rentEpoch:W(F())}))))),unitsConsumed:W(F())}),c=ts(a=Z({context:Z({slot:F()}),value:s})),u=t=>"error"in t?t:{...t,result:K(t.result,a)},new $({...c,coercer:(t,e)=>V(t,to)[0]?c.coercer(t,e):c.coercer(u(t,e),e)}));var tc=Object.freeze({__proto__:null,invoke:tt,getMultipleAccounts:te,getMultipleAccountsAndContext:tr,simulateTransaction:ti});class tu{constructor(t,e,r=tu.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=tu.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,o,s;if(void 0===r&&(r=this.opts),I(t))e&&t.sign(e);else if(t.feePayer=null!==(n=t.feePayer)&&void 0!==n?n:this.wallet.publicKey,t.recentBlockhash&&"11111111111111111111111111111111"!==t.recentBlockhash||(t.recentBlockhash=(await this.connection.getLatestBlockhash(r.preflightCommitment)).blockhash),e)for(let r of e)t.partialSign(r);let a=(t=await this.wallet.signTransaction(t)).serialize();try{return await td(this.connection,a,r)}catch(e){if(e instanceof t_){let r=S(I(t)?(null===(i=t.signatures)||void 0===i?void 0:i[0])||new Uint8Array:null!==(o=t.signature)&&void 0!==o?o:new Uint8Array),n=I(t)?0:void 0,a=await this.connection.getTransaction(r,{commitment:"confirmed",maxSupportedTransactionVersion:n});if(a){let t=null===(s=a.meta)||void 0===s?void 0:s.logMessages;throw t?new h.SendTransactionError(e.message,t):e}}throw e}}async sendAll(t,e){var r,n,i;let o;void 0===e&&(e=this.opts);let s=()=>(o||(o=this.connection.getLatestBlockhash(e.preflightCommitment).then(t=>t.blockhash)),o),a=await Promise.all(t.map(async t=>{var e,r;if(I(t.tx)){let e=t.tx;return t.signers&&e.sign(t.signers),e}{let n=t.tx,i=null!==(e=t.signers)&&void 0!==e?e:[];return n.feePayer=null!==(r=n.feePayer)&&void 0!==r?r:this.wallet.publicKey,n.recentBlockhash&&"11111111111111111111111111111111"!==n.recentBlockhash||(n.recentBlockhash=await s()),i.forEac
1h(t=>{n.partialSign(t)}),n}})),c=await this.wallet.signAllTransactions(a),u=[];for(let t=0;t<a.length;t+=1){let o=c[t],s=o.serialize();try{u.push(await td(this.connection,s,e))}catch(t){if(t instanceof t_){let e=S(I(o)?(null===(r=o.signatures)||void 0===r?void 0:r[0])||new Uint8Array:null!==(n=o.signature)&&void 0!==n?n:new Uint8Array),s=I(o)?0:void 0,a=await this.connection.getTransaction(e,{commitment:"confirmed",maxSupportedTransactionVersion:s});if(a){let e=null===(i=a.meta)||void 0===i?void 0:i.logMessages;throw e?new h.SendTransactionError(t.message,e):t}}throw t}}return u}async simulate(t,e,r,n){let i;if(I(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&&"11111111111111111111111111111111"!==t.recentBlockhash||(t.recentBlockhash=(await this.connection.getLatestBlockhash(null!=r?r:this.connection.commitment)).blockhash),e&&e.length>0&&(t=await this.wallet.signTransaction(t)),i=await ti(this.connection,t,e,r,n)),i.value.err)throw new tl(i.value);return i.value}}class tl extends Error{constructor(t,e){super(e),this.simulationResponse=t}}async function td(t,e,r){let n;let 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 t_(`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")}class t_ extends Error{constructor(t){super(t)}}function th(t){tp=t}function tf(){return null===tp?tu.local():tp}let tp=null;var tR={};Object.defineProperty(tR,"__esModule",{value:!0});var tO=tR.ANCHOR_ERROR__REQUIRE_EQ_VIOLATED=en=tR.ANCHOR_ERROR__REQUIRE_VIOLATED=er=tR.ANCHOR_ERROR__CONSTRAINT_MINT_TRANSFER_HOOK_EXTENSION_PROGRAM_ID=ee=tR.ANCHOR_ERROR__CONSTRAINT_MINT_TRANSFER_HOOK_EXTENSION_AUTHORITY=et=tR.ANCHOR_ERROR__CONSTRAINT_MINT_TRANSFER_HOOK_EXTENSION=t7=tR.ANCHOR_ERROR__CONSTRAINT_MINT_PERMANENT_DELEGATE_EXTENSION_DELEGATE=t9=tR.ANCHOR_ERROR__CONSTRAINT_MINT_PERMANENT_DELEGATE_EXTENSION=t5=tR.ANCHOR_ERROR__CONSTRAINT_MINT_CLOSE_AUTHORITY_EXTENSION_AUTHORITY=t4=tR.ANCHOR_ERROR__CONSTRAINT_MINT_CLOSE_AUTHORITY_EXTENSION=t8=tR.ANCHOR_ERROR__CONSTRAINT_MINT_METADATA_POINTER_EXTENSION_METADATA_ADDRESS=t6=tR.ANCHOR_ERROR__CONSTRAINT_MINT_METADATA_POINTER_EXTENSION_AUTHORITY=t3=tR.ANCHOR_ERROR__CONSTRAINT_MINT_METADATA_POINTER_EXTENSION=t2=tR.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_MEMBER_POINTER_EXTENSION_MEMBER_ADDRESS=t1=tR.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_MEMBER_POINTER_EXTENSION_AUTHORITY=t0=tR.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_MEMBER_POINTER_EXTENSION=tJ=tR.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_POINTER_EXTENSION_GROUP_ADDRESS=tQ=tR.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_POINTER_EXTENSION_AUTHORITY=tZ=tR.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_POINTER_EXTENSION=tq=tR.ANCHOR_ERROR__CONSTRAINT_ASSOCIATED_TOKEN_TOKEN_PROGRAM=tW=tR.ANCHOR_ERROR__CONSTRAINT_MINT_TOKEN_PROGRAM=tF=tR.ANCHOR_ERROR__CONSTRAINT_TOKEN_TOKEN_PROGRAM=tX=tR.ANCHOR_ERROR__CONSTRAINT_ACCOUNT_IS_NONE=tY=tR.ANCHOR_ERROR__CONSTRAINT_SPACE=tj=tR.ANCHOR_ERROR__CONSTRAINT_MINT_DECIMALS=tz=tR.ANCHOR_ERROR__CONSTRAINT_MINT_FREEZE_AUTHORITY=tV=tR.ANCHOR_ERROR__CONSTRAINT_MINT_MINT_AUTHORITY=tK=tR.ANCHOR_ERROR__CONSTRAINT_TOKEN_OWNER=t$=tR.ANCHOR_ERROR__CONSTRAINT_TOKEN_MINT=tG=tR.ANCHOR_ERROR__CONSTRAINT_ZERO=tB=tR.ANCHOR_ERROR__CONSTRAINT_ADDRESS=tM=tR.ANCHOR_ERROR__CONSTRAINT_CLOSE=tx=tR.ANCHOR_ERROR__CONSTRAINT_ASSOCIATED_INIT=tk=tR.ANCHOR_ERROR__CONSTRAINT_ASSOCIATED=tP=tR.ANCHOR_ERROR__CONSTRAINT_STATE=tU=tR.ANCHOR_ERROR__CONSTRAINT_EXECUTABLE=tD=tR.ANCHOR_ERROR__CONSTRAINT_SEEDS=tH=tR.ANCHOR_ERROR__CONSTRAINT_RENT_EXEMPT=tL=tR.ANCHOR_ERROR__CONSTRAINT_OWNER=tb=tR.ANCHOR_ERROR__CONSTRAINT_RAW
1=tS=tR.ANCHOR_ERROR__CONSTRAINT_SIGNER=tC=tR.ANCHOR_ERROR__CONSTRAINT_HAS_ONE=tw=tR.ANCHOR_ERROR__CONSTRAINT_MUT=tI=tR.ANCHOR_ERROR__EVENT_INSTRUCTION_STUB=tv=tR.ANCHOR_ERROR__IDL_ACCOUNT_NOT_EMPTY=tT=tR.ANCHOR_ERROR__IDL_INSTRUCTION_INVALID_PROGRAM=tg=tR.ANCHOR_ERROR__IDL_INSTRUCTION_STUB=tN=tR.ANCHOR_ERROR__INSTRUCTION_DID_NOT_SERIALIZE=tm=tR.ANCHOR_ERROR__INSTRUCTION_DID_NOT_DESERIALIZE=ty=tR.ANCHOR_ERROR__INSTRUCTION_FALLBACK_NOT_FOUND=tA=tR.ANCHOR_ERROR__INSTRUCTION_MISSING=void 0,tE=tR.ANCHOR_ERROR__DEPRECATED=eS=tR.ANCHOR_ERROR__INVALID_NUMERIC_CONVERSION=eC=tR.ANCHOR_ERROR__TRYING_TO_INIT_PAYER_AS_PROGRAM_ACCOUNT=ew=tR.ANCHOR_ERROR__DECLARED_PROGRAM_ID_MISMATCH=eI=tR.ANCHOR_ERROR__ACCOUNT_DUPLICATE_REALLOCS=ev=tR.ANCHOR_ERROR__ACCOUNT_REALLOC_EXCEEDS_LIMIT=eT=tR.ANCHOR_ERROR__ACCOUNT_SYSVAR_MISMATCH=eg=tR.ANCHOR_ERROR__ACCOUNT_NOT_ASSOCIATED_TOKEN_ACCOUNT=eN=tR.ANCHOR_ERROR__ACCOUNT_NOT_PROGRAM_DATA=em=tR.ANCHOR_ERROR__ACCOUNT_NOT_INITIALIZED=ey=tR.ANCHOR_ERROR__ACCOUNT_NOT_SYSTEM_OWNED=eA=tR.ANCHOR_ERROR__ACCOUNT_NOT_SIGNER=eE=tR.ANCHOR_ERROR__INVALID_PROGRAM_EXECUTABLE=eO=tR.ANCHOR_ERROR__INVALID_PROGRAM_ID=eR=tR.ANCHOR_ERROR__ACCOUNT_OWNED_BY_WRONG_PROGRAM=ep=tR.ANCHOR_ERROR__ACCOUNT_NOT_MUTABLE=ef=tR.ANCHOR_ERROR__ACCOUNT_NOT_ENOUGH_KEYS=eh=tR.ANCHOR_ERROR__ACCOUNT_DID_NOT_SERIALIZE=e_=tR.ANCHOR_ERROR__ACCOUNT_DID_NOT_DESERIALIZE=ed=tR.ANCHOR_ERROR__ACCOUNT_DISCRIMINATOR_MISMATCH=el=tR.ANCHOR_ERROR__ACCOUNT_DISCRIMINATOR_NOT_FOUND=eu=tR.ANCHOR_ERROR__ACCOUNT_DISCRIMINATOR_ALREADY_SET=ec=tR.ANCHOR_ERROR__REQUIRE_GTE_VIOLATED=ea=tR.ANCHOR_ERROR__REQUIRE_GT_VIOLATED=es=tR.ANCHOR_ERROR__REQUIRE_KEYS_NEQ_VIOLATED=eo=tR.ANCHOR_ERROR__REQUIRE_NEQ_VIOLATED=ei=tR.ANCHOR_ERROR__REQUIRE_KEYS_EQ_VIOLATED=void 0,tA=tR.ANCHOR_ERROR__INSTRUCTION_MISSING=100,ty=tR.ANCHOR_ERROR__INSTRUCTION_FALLBACK_NOT_FOUND=101,tm=tR.ANCHOR_ERROR__INSTRUCTION_DID_NOT_DESERIALIZE=102,tN=tR.ANCHOR_ERROR__INSTRUCTION_DID_NOT_SERIALIZE=103,tg=tR.ANCHOR_ERROR__IDL_INSTRUCTION_STUB=1e3,tT=tR.ANCHOR_ERROR__IDL_INSTRUCTION_INVALID_PROGRAM=1001,tv=tR.ANCHOR_ERROR__IDL_ACCOUNT_NOT_EMPTY=1002,tI=tR.ANCHOR_ERROR__EVENT_INSTRUCTION_STUB=1500,tw=tR.ANCHOR_ERROR__CONSTRAINT_MUT=2e3,tC=tR.ANCHOR_ERROR__CONSTRAINT_HAS_ONE=2001,tS=tR.ANCHOR_ERROR__CONSTRAINT_SIGNER=2002,tb=tR.ANCHOR_ERROR__CONSTRAINT_RAW=2003,tL=tR.ANCHOR_ERROR__CONSTRAINT_OWNER=2004,tH=tR.ANCHOR_ERROR__CONSTRAINT_RENT_EXEMPT=2005,tD=tR.ANCHOR_ERROR__CONSTRAINT_SEEDS=2006,tU=tR.ANCHOR_ERROR__CONSTRAINT_EXECUTABLE=2007,tP=tR.ANCHOR_ERROR__CONSTRAINT_STATE=2008,tk=tR.ANCHOR_ERROR__CONSTRAINT_ASSOCIATED=2009,tx=tR.ANCHOR_ERROR__CONSTRAINT_ASSOCIATED_INIT=2010,tM=tR.ANCHOR_ERROR__CONSTRAINT_CLOSE=2011,tB=tR.ANCHOR_ERROR__CONSTRAINT_ADDRESS=2012,tG=tR.ANCHOR_ERROR__CONSTRAINT_ZERO=2013,t$=tR.ANCHOR_ERROR__CONSTRAINT_TOKEN_MINT=2014,tK=tR.ANCHOR_ERROR__CONSTRAINT_TOKEN_OWNER=2015,tV=tR.ANCHOR_ERROR__CONSTRAINT_MINT_MINT_AUTHORITY=2016,tz=tR.ANCHOR_ERROR__CONSTRAINT_MINT_FREEZE_AUTHORITY=2017,tj=tR.ANCHOR_ERROR__CONSTRAINT_MINT_DECIMALS=2018,tY=tR.ANCHOR_ERROR__CONSTRAINT_SPACE=2019,tX=tR.ANCHOR_ERROR__CONSTRAINT_ACCOUNT_IS_NONE=2020,tF=tR.ANCHOR_ERROR__CONSTRAINT_TOKEN_TOKEN_PROGRAM=2021,tW=tR.ANCHOR_ERROR__CONSTRAINT_MINT_TOKEN_PROGRAM=2022,tq=tR.ANCHOR_ERROR__CONSTRAINT_ASSOCIATED_TOKEN_TOKEN_PROGRAM=2023,tZ=tR.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_POINTER_EXTENSION=2024,tQ=tR.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_POINTER_EXTENSION_AUTHORITY=2025,tJ=tR.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_POINTER_EXTENSION_GROUP_ADDRESS=2026,t0=tR.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_MEMBER_POINTER_EXTENSION=2027,t1=tR.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_MEMBER_POINTER_EXTENSION_AUTHORITY=2028,t2=tR.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_MEMBER_POINTER_EXTENSION_MEMBER_ADDRESS=2029,t3=tR.ANCHOR_ERROR__CONSTRAINT_MINT_METADATA_POINTER_EXTENSION=2030,t6=tR.ANCHOR_ERROR__CONSTRAINT_MINT_METADATA_POINTER_EXTENSION_AUTHORITY=2031,t8=tR.ANCHOR_ERROR__CONSTRAINT_MINT_METADATA_POINTER_EXTENSION_METADATA_ADDRESS=2032,t4=tR.ANCHOR_ERROR__CONSTRAINT_MINT_CLOSE_AUTHORITY_EXTENSION=2033,t5=tR.ANCHOR_ERROR__CONSTRAINT_MINT_CLOSE_AUTHORITY_EXTENSION_AUTHORITY=2034,t9=tR.ANCHOR_ERROR__CONSTRAINT_MINT_PERMANENT_DELEGATE_EXTENSION=2035,t7=tR.ANCHOR_ERROR__CONSTRAINT_MINT_PERMANENT_DELEGATE_EXTENSION_DELEGATE=2036,et=tR.ANCHOR_ERROR__CONSTRAINT_MINT_TRANSFER_HOOK_EXTENSION=2037,ee=tR.ANCHOR_ERROR__CONSTRAINT_MINT_TRANSFER_HOOK_EXTENSION_AUTHORITY=2038,er=tR.ANCHOR_ERROR__CONSTRAINT_MINT_TRANSFER_HOOK_EXTENSION_PROGRAM_ID=2039,en=tR.ANCHOR_ERROR__REQUIRE_VIOLATED=2500;
1tO=tR.ANCHOR_ERROR__REQUIRE_EQ_VIOLATED=2501;var ei=tR.ANCHOR_ERROR__REQUIRE_KEYS_EQ_VIOLATED=2502,eo=tR.ANCHOR_ERROR__REQUIRE_NEQ_VIOLATED=2503,es=tR.ANCHOR_ERROR__REQUIRE_KEYS_NEQ_VIOLATED=2504,ea=tR.ANCHOR_ERROR__REQUIRE_GT_VIOLATED=2505,ec=tR.ANCHOR_ERROR__REQUIRE_GTE_VIOLATED=2506,eu=tR.ANCHOR_ERROR__ACCOUNT_DISCRIMINATOR_ALREADY_SET=3e3,el=tR.ANCHOR_ERROR__ACCOUNT_DISCRIMINATOR_NOT_FOUND=3001,ed=tR.ANCHOR_ERROR__ACCOUNT_DISCRIMINATOR_MISMATCH=3002,e_=tR.ANCHOR_ERROR__ACCOUNT_DID_NOT_DESERIALIZE=3003,eh=tR.ANCHOR_ERROR__ACCOUNT_DID_NOT_SERIALIZE=3004,ef=tR.ANCHOR_ERROR__ACCOUNT_NOT_ENOUGH_KEYS=3005,ep=tR.ANCHOR_ERROR__ACCOUNT_NOT_MUTABLE=3006,eR=tR.ANCHOR_ERROR__ACCOUNT_OWNED_BY_WRONG_PROGRAM=3007,eO=tR.ANCHOR_ERROR__INVALID_PROGRAM_ID=3008,eE=tR.ANCHOR_ERROR__INVALID_PROGRAM_EXECUTABLE=3009,eA=tR.ANCHOR_ERROR__ACCOUNT_NOT_SIGNER=3010,ey=tR.ANCHOR_ERROR__ACCOUNT_NOT_SYSTEM_OWNED=3011,em=tR.ANCHOR_ERROR__ACCOUNT_NOT_INITIALIZED=3012,eN=tR.ANCHOR_ERROR__ACCOUNT_NOT_PROGRAM_DATA=3013,eg=tR.ANCHOR_ERROR__ACCOUNT_NOT_ASSOCIATED_TOKEN_ACCOUNT=3014,eT=tR.ANCHOR_ERROR__ACCOUNT_SYSVAR_MISMATCH=3015,ev=tR.ANCHOR_ERROR__ACCOUNT_REALLOC_EXCEEDS_LIMIT=3016,eI=tR.ANCHOR_ERROR__ACCOUNT_DUPLICATE_REALLOCS=3017,ew=tR.ANCHOR_ERROR__DECLARED_PROGRAM_ID_MISMATCH=4100,eC=tR.ANCHOR_ERROR__TRYING_TO_INIT_PAYER_AS_PROGRAM_ACCOUNT=4101,eS=tR.ANCHOR_ERROR__INVALID_NUMERIC_CONVERSION=4102;tE=tR.ANCHOR_ERROR__DEPRECATED=5e3;let eb=new Set(["debug-logs"]),eL=new Map;function eH(t){return void 0!==eL.get(t)}var eD=Object.freeze({__proto__:null,set:function(t){if(!eb.has(t))throw Error("Invalid feature");eL.set(t,!0)},isSet:eH});class eU extends Error{constructor(t){super(t),this.name="IdlError"}}class eP{constructor(t){this.stack=t}static parse(t){var e;
1let r=/^Program (\w*) invoke/,n=/^Program \w* success/,i=[];for(let o=0;o<t.length;o++){if(n.exec(t[o])){i.pop();continue}let s=null===(e=r.exec(t[o]))||void 0===e?void 0:e[1];s&&i.push(new h.PublicKey(s))}return new eP(i)}}class ek 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=eP.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: (.*)$/,o=n.exec(t[r+2])[1],s=n.exec(t[r+4])[1];e=[new h.PublicKey(o),new h.PublicKey(s)],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 o=/^Program log: AnchorError occurred\. Error Code: (.*)\. Error Number: (\d*)\. Error Message: (.*)\./.exec(n),s=/^Program log: AnchorError thrown in (.*):(\d*)\. Error Code: (.*)\. Error Number: (\d*)\. Error Message: (.*)\./.exec(n),a=/^Program log: AnchorError caused by account: (.*)\. Error Code: (.*)\. Error Number: (\d*)\. Error Message: (.*)\./.exec(n);if(o){let[r,n,s]=o.slice(1,4);return new ek({code:r,number:parseInt(n)},s,i,t,void 0,e)}if(s){let[r,n,o,a,c]=s.slice(1,6);return new ek({code:o,number:parseInt(a)},c,i,t,{file:r,line:parseInt(n)},e)}if(!a)return null;{let[r,n,o,s]=a.slice(1,5);return new ek({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 ex extends Error{constructor(t,e,r){super(),this.code=t,this.msg=e,this.logs=r,r&&(this._programErrorStack=eP.parse(r))}static parse(t,e){let r,n;let 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=eB.get(n))?new ex(n,o,t.logs):null}get program(){var t;return null===(t=this._programErrorStack)||void 0===t?void 0:t.stack[this._programErrorStack.stack.length-1]}get programErrorStack(){var t;return null===(t=this._programErrorStack)||void 0===t?void 0:t.stack}toString(){return this.msg}}function eM(t,e){eH("debug-logs")&&console.log("Translating error:",t);let r=ek.parse(t.logs);return r?r:ex.parse(t,e)||(t.logs?(t.programErrorStack=eP.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 eB=new Map([[tA,"Instruction discriminator not provided"],[ty,"Fallback functions are not supported"],[tm,"The program could not deserialize the given instruction"],[tN,"The program could not serialize the given instruction"],[tg,"The program was compiled without idl instructions"],[tT,"The transaction was given an invalid program for the IDL instruction"],[tv,"IDL account must be empty in order to resize, try closing first"],[tI,"The program was compiled without `event-cpi` feature"],[tw,"A mut constraint was violated"],[tC,"A has one constraint was violated"],[tS,"A signer constraint was violated"],[tb,"A raw constraint was violated"],[tL,"An owner constraint was violated"],[tH,"A rent exemption constraint was violated"],[tD,"A seeds constraint was violated"],[tU,"An executable constraint was violated"],[tP,"Deprecated Error, feel free to replace with something else"],[tk,"An associated constraint was violated"],[tx,"An associated init constraint was violated"],[tM,"A close constraint was violated"],[tB,"An address constraint was violated"],[tG,"Expected zero account discriminant"],[t$,"A token mint constraint was violated"],[tK,"A token owner constraint was violated"],[tV,"A mint mint authority constraint was violated"],[tz,"A mint freeze authority constraint was violated"],[tj,"A mint decimals constraint was violated"],[tY,"A space constraint was violated"],[tX,"A required account for the constraint is None"],[tF,"A token account token program constraint was violated"],[tW,"A mint token program constraint was violated"],[tq,"An associated token account token program constraint was violated"],[tZ,"A group pointer extension constraint was violated"],[tQ,"A group pointer extension authority constraint was violated"],[tJ,"A group pointer extension group address constraint was violated"],[t0,"A group member pointer extension constraint was violated"],[t1,"A group member pointer extension authority constraint was violated"],[t2,"A group member pointer extension group address constraint was violated"],[t3,"A metadata pointer extension constraint was violated"],[t6,"A metadata pointer extension authority constraint was violated"],[t8,"A metadata pointer extension metadata address constraint was violated"],[t4,"A close authority constraint was violated"],[t5,"A close authority extension authority constraint was violated"],[t9,"A permanent delegate extension constraint was violated"],[t7,"A permanent delegate extension delegate constraint was violated"],[et,"A transfer hook extension constraint was violated"],[ee,"A transfer hook extension authority constraint was violated"],[er,"A transfer hook extension transfer hook program id constraint was violated"],[en,"A require expression was violated"],[tO,"A require_eq expression was violated"],[ei,"A require_keys_eq expression was violated"],[eo,"A require_neq expression was violated"],[es,"A require_keys_neq expression was violated"],[ea,"A require_gt expression was violated"],[ec,"A require_gte expression was violated"],[eu,"The account discriminator was already set on this account"],[el,"No discriminator was found on the account"],[ed,"Account discriminator did not match what was expected"],[e_,"Failed to deserialize the account"],[eh,"Failed to serialize the account"],[ef,"Not enough account keys given to the instruction"],[ep,"The given account is not mutable"],[eR,"The given account is owned by a different program than expected"],[eO,"Program ID was not as expected"],[eE,"Program account is not executable"],[eA,"The given account did not sign"],[ey,"The given account is not owned by the system program"],[em,"The program expected this account to be already initialized"],[eN,"The given account is not a program data account"],[eg,"The given account is not the associated token account"],[eT,"The given public key does not match the required sysvar"],[ev,"The account reallocation exceeds the MAX_PERMITTED_DATA_INCREASE limit"],[eI,"The account was duplicated for more than one reallocation"],[ew,"The declared program id does not match the actual program id"],[eC,"You cannot/should not initialize the payer account as a program account"],[eS,"The program could not perform the numeric conversion, out of range integral type conversion attempted"],[tE,"The API being used is deprecated and should no longer be used"]]);class eG{static fieldLayout(t,e=[],r){let n=t.name;switch(t.type){case"bool":return y.bool(n);case"u8":return y.u8(n);case"i8":return y.i8(n);case"u16":return y.u16(n);case"i16":return y.i16(n);case"u32":return y.u32(n);case"i32":return y.i32(n);case"f32":return y.f32(n);case"u64":return y.u64(n);case"i64":return y.i64(n);case"f64":return y.f64(n);case"u128":return y.u128(n);case"i128":return y.i128(n);case"u256":return y.u256(n);case"i256":return y.i256(n);case"bytes":return y.vecU8(n);case"string":return y.str(n);case"pubkey":return y.publicKey(n);default:if("option"in t.type)return y.option(eG.fieldLayout({type:t.type.option},e,r),n);if("vec"in t.type)return y.vec(eG.fieldLayout({type:t.type.vec},e,r),n);if("array"in t.type){let[i,o]=t.type.array;
1return o=eG.resolveArrayLen(o,r),y.array(eG.fieldLayout({type:i},e,r),o,n)}if("defined"in t.type){if(!e)throw new eU("User defined types not provided");let i=t.type.defined.name,o=e.find(t=>t.name===i);if(!o)throw new eU(`Type not found: ${t.name}`);return eG.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 eU(`Invalid generic field: ${t.name}`);return eG.fieldLayout({...t,type:n.type},e)}throw new eU(`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=U(t.type.fields,()=>[],r=>r.map(r=>{let i=n?eG.resolveGenericArgs({type:r.type,typeDef:t,genericArgs:n}):n;return eG.fieldLayout(r,e,i)}),r=>r.map((r,i)=>{let o=n?eG.resolveGenericArgs({type:r,typeDef:t,genericArgs:n}):n;return eG.fieldLayout({name:i.toString(),type:r},e,o)}));return y.struct(i,r)}case"enum":{let i=t.type.variants.map(r=>{let i=U(r.fields,()=>[],r=>r.map(r=>{let i=n?eG.resolveGenericArgs({type:r.type,typeDef:t,genericArgs:n}):n;return eG.fieldLayout(r,e,i)}),r=>r.map((r,i)=>{let o=n?eG.resolveGenericArgs({type:r,typeDef:t,genericArgs:n}):n;return eG.fieldLayout({name:i.toString(),type:r},e,o)}));return y.struct(i,r.name)});if(void 0!==r)return y.rustEnum(i).replicate(r);return y.rustEnum(i,r)}case"type":return eG.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+eG.typeSize(t.option,e,r);if("coption"in t)return 4+eG.typeSize(t.coption,e,r);if("vec"in t)return 1;if("array"in t){let[n,i]=t.array;return i=eG.resolveArrayLen(i,r),eG.typeSize(n,e,r)*i}if("defined"in t){let i=null===(n=e.types)||void 0===n?void 0:n.find(e=>e.name===t.defined.name);if(!i)throw new eU(`Type not found: ${JSON.stringify(t)}`);let o=n=>{let o=null!=r?r:t.defined.generics,s=o?eG.resolveGenericArgs({type:n,typeDef:i,genericArgs:o}):o;return eG.typeSize(n,e,s)};switch(i.type.kind){case"struct":return U(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=>U(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 eG.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 eU(`Invalid generic: ${t.generic}`);return eG.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 eU("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=eG.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=eG.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=eG.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 eG.resolveGenericArgs({type:t.type,typeDef:e,genericArgs:r,isDefined:!0});case"const":return[t]}}).filter(t=>null!==t)}}return null}}class e${constructor(t){this.idl=t;let e=t.instructions.map(e=>{let r=e.name,n=e.args.map(e=>eG.fieldLayout(e,t.types)),i=y.struct(n,r);return[r,{discriminator:e.discriminator,layout:i,args:e.args}]});this.ixLayouts=new Map(e)}encode(t,e){let r=R.Buffer.alloc(1e3),n=this.ixLayouts.get(t);if(!n)throw Error(`Unknown method: ${t}`);if(n.args.length>0&&(null===e||"object"!=typeof e||Array.isArray(e))){let r=n.args.map(t=>t.name).join(", ");throw Error(`Invalid arguments for instruction "${t}": expected an object with fields { ${r} }, got ${null===e?"null":Array.isArray(e)?"array":typeof e}.`)}let i=n.args.filter(t=>!e$.isOption(t.type,this.idl.types)).map(t=>t.name).filter(t=>!e.hasOwnProperty(t));if(i.length>0)throw Error(`Invalid arguments for instruction "${t}": missing field${i.length>
11?"s":""} ${i.map(t=>`\`${t}\``).join(", ")}.`);let o=e$.convertUndefinedOptions(n.args,e,this.idl.types),s=n.layout.encode(o,r),a=r.slice(0,s);return R.Buffer.concat([R.Buffer.from(n.discriminator),a])}static isOption(t,e=[],r=new Set){if("object"!=typeof t)return!1;if("option"in t)return!0;if("defined"in t){let n=t.defined.name;if(r.has(n))return!1;let i=e.find(t=>t.name===n);if((null==i?void 0:i.type.kind)!=="type")return!1;let o=e$.resolveGenericType(i.type.alias,i,t.defined.generics);return e$.isOption(o,e,new Set([...r,n]))}return!1}static convertUndefinedOptions(t,e,r=[]){let n={...e};return t.forEach(t=>{n[t.name]=e$.convertUndefinedOption(t.type,e[t.name],r)}),n}static convertUndefinedOption(t,e,r){if("string"==typeof t)return e;if("option"in t)return null==e?null:e$.convertUndefinedOption(t.option,e,r);if("vec"in t)return Array.isArray(e)?e.map(e=>e$.convertUndefinedOption(t.vec,e,r)):e;if("array"in t)return Array.isArray(e)?e.map(e=>e$.convertUndefinedOption(t.array[0],e,r)):e;if("defined"in t){let n=r.find(e=>e.name===t.defined.name);if(!n)return e;let i=t.defined.generics;return e$.convertUndefinedOptionDefined(n,e,r,i)}return e}static convertUndefinedOptionDefined(t,e,r,n){if("type"===t.type.kind){let i=e$.resolveGenericType(t.type.alias,t,n);return e$.convertUndefinedOption(i,e,r)}if(null==e||"object"!=typeof e)return e;switch(t.type.kind){case"struct":return U(t.type.fields,()=>e,i=>{let o={...e};return i.forEach(i=>{let s=e$.resolveGenericType(i.type,t,n);o[i.name]=e$.convertUndefinedOption(s,e[i.name],r)}),o},i=>{let o=Array.isArray(e)?[...e]:{...e};return i.forEach((i,s)=>{let a=e$.resolveGenericType(i,t,n);o[s]=e$.convertUndefinedOption(a,e[s],r)}),o});case"enum":{let i=Object.keys(e)[0],o=t.type.variants.find(t=>t.name===i);if(!o)return e;return{...e,[i]:U(o.fields,()=>e[i],o=>{let s={...e[i]};return o.forEach(o=>{let a=e$.resolveGenericType(o.type,t,n);s[o.name]=e$.convertUndefinedOption(a,e[i][o.name],r)}),s},o=>{let s=Array.isArray(e[i])?[...e[i]]:{...e[i]};return o.forEach((o,a)=>{let c=e$.resolveGenericType(o,t,n);s[a]=e$.convertUndefinedOption(c,e[i][a],r)}),s})}}}}static resolveGenericType(t,e,r){var n,i;if(!r||"object"!=typeof t)return t;if("generic"in t){let i=null===(n=e.generics)||void 0===n?void 0:n.findIndex(e=>"type"===e.kind&&e.name===t.generic);if(void 0===i||i<0)return t;let o=r[i];return(null==o?void 0:o.kind)==="type"?o.type:t}return"option"in t?{option:e$.resolveGenericType(t.option,e,r)}:"vec"in t?{vec:e$.resolveGenericType(t.vec,e,r)}:"array"in t?{array:[e$.resolveGenericType(t.array[0],e,r),t.array[1]]}:"defined"in t?{defined:{...t.defined,generics:null===(i=t.defined.generics)||void 0===i?void 0:i.map(t=>"type"===t.kind?{...t,type:e$.resolveGenericType(t.type,e,r)}:t)}}:t}decode(t,e="hex"){for(let[r,n]of("string"==typeof t&&(t="hex"===e?R.Buffer.from(t,"hex"):E().decode(t)),this.ixLayouts)){let e=t.subarray(0,n.discriminator.length);if(e.equals(R.Buffer.from(n.discriminator)))return{name:r,data:n.layout.decode(t.subarray(e.length))}}return null}format(t,e){return eK.format(t,e,this.idl)}}class eK{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:eK.formatIdlType(e.type),data:eK.formatIdlData(e,t.data[e.name],r.types)})),o=eK.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 eK.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 eK.formatIdlDataDefined(i,e,r)}return"unknown"}static formatIdlDataDefined(t,e,r){switch(t.type.kind){case"struct":return"{ "+U(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+": "+eK.formatIdlData(i,n,r)}).join(", "),t=>Object.entries(e).map(([e,n])=>e+": "+eK.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 U(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+": "+eK.formatIdlData(i,n,r)}).join(", ");return`${n} { ${e} }`},t=>{let e=Object.entries(o).map(([e,n])=>e+": "+eK.formatIdlData({name:"",type:t[e]},n,r)).join(", ");return`${n} { ${e} }`})}case"type":return eK.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 eK.flattenIdlAccounts(t.accounts,n)}}).flat()}}class eV{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:eG.typeDefLayout({typeDef:r,types:e})}]});this.accountLayouts=new Map(r)}async encode(t,e){let r=R.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),s=this.accountDiscriminator(t);return R.Buffer.concat([s,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(R.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:E().encode(e?R.Buffer.concat([r,e]):r)}}size(t){return this.accountDiscriminator(t).length+eG.typeSize({defined:{name:t}},this.idl)}accountDiscriminator(t){var e;let r=null===(e=this.idl.accounts)||void 0===e?void 0:e.find(e=>e.name===t);if(!r)throw Error(`Account not found: ${t}`);return R.Buffer.from(r.discriminator)}}class ez{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:eG.typeDefLayout({typeDef:r,types:e})}]});this.layouts=new Map(r)}decode(t){let e;try{e=b(t)}catch(t){return null}for(let[t,r]of this.layouts){let n=e.subarray(0,r.discriminator.length);if(n.equals(R.Buffer.from(r.discriminator)))return{name:t,data:r.layout.decode(e.subarray(n.length))}}return null}}class ej{constructor(t){let e=t.types;if(!e){this.typeLayouts=new Map;return}let r=e.filter(t=>!t.generics).map(t=>[t.name,eG.typeDefLayout({typeDef:t,types:e})]);this.typeLayouts=new Map(r)}encode(t,e){let r=R.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 eY{constructor(t){this.instruction=new e$(t),this.accounts=new eV(t),this.events=new ez(t),this.types=new ej(t)}}class eX{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 eF=eX;class eW extends eX{isCount(){throw Error("ExternalLayout is abstract")}}class eq extends eW{constructor(t,e,r){if(!(t instanceof eX))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 eZ||this.layout instanceof eQ}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 eZ extends eX{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 eQ extends eX{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 eJ(t){let e=Math.floor(t/4294967296);return{hi32:e,lo32:t-4294967296*e}}
1function e0(t,e){return 4294967296*t+e}class e1 extends eX{constructor(t){super(8,t)}decode(t,e){void 0===e&&(e=0);let r=t.readUInt32LE(e);return e0(t.readUInt32LE(e+4),r)}encode(t,e,r){void 0===r&&(r=0);let n=eJ(t);return e.writeUInt32LE(n.lo32,r),e.writeUInt32LE(n.hi32,r+4),8}}class e2 extends eX{constructor(t){super(8,t)}decode(t,e){void 0===e&&(e=0);let r=t.readUInt32LE(e);return e0(t.readInt32LE(e+4),r)}encode(t,e,r){void 0===r&&(r=0);let n=eJ(t);return e.writeUInt32LE(n.lo32,r),e.writeInt32LE(n.hi32,r+4),8}}class e3 extends eX{constructor(t,e,r){if(!(Array.isArray(t)&&t.reduce((t,e)=>t&&e instanceof eX,!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>n.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 e6{constructor(t){this.property=t}decode(){throw Error("UnionDiscriminator is abstract")}encode(){throw Error("UnionDiscriminator is abstract")}}class e8 extends e6{constructor(t,e){if(!(t instanceof eW&&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 e4 extends eX{constructor(t,e,r){let n=t instanceof eZ||t instanceof eQ;if(n)t=new e8(new eq(t));else if(t instanceof eW&&t.isCount())t=new e8(t);else if(!(t instanceof e6))throw TypeError("discr must be a UnionDiscriminator or an unsigned integer layout");if(void 0===e&&(e=null),!(null===e||e instanceof eX))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 e5(this,t,e,r);return this.registry[t]=n,n}getVariant(t,e){let r=t;return v.isBuffer(t)&&(void 0===e&&(e=0),r=this.discriminator.decode(t,e)),this.registry[r]}}class e5 extends eX{constructor(t,e,r,n){if(!(t instanceof e4))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 eX))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 e9 extends eX{constructor(t,e){if(!(t instanceof eW&&t.isCount()||Number.isInteger(t)&&0<=t))throw TypeError("length must be positive integer or an unsigned integer ExternalLayout");let r=-1;t instanceof eW||(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 eW&&(n=t.length),!(v.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 eW&&this.length.encode(n,e,r),n}}var e7=(t,e,r)=>new eq(t,e,r),rt=t=>new eZ(1,t),re=t=>new eZ(4,t),rr=t=>new e2(t),rn=(t,e,r)=>new e3(t,e,r),ri=(t,e,r)=>new e4(t,e,r),ro=(t,e)=>new e9(t,e);class rs extends eF{constructor(t){super(-1,t),this.property=t,this.layout=rn([re("length"),re("lengthPadding"),ro(e7(re(),-8),"chars")],this.property)}encode(t,e,r=0){if(null==t)return this.layout.span;let n={chars:v.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 re().span+re().span+new(p())(new Uint8Array(t).slice(e,e+4),10,"le").toNumber()}}function ra(t){return new rs(t)}function rc(t){return ro(32,t)}let ru=ri(re("instruction"));ru.addVariant(0,rn([rr("lamports"),rr("space"),rc("owner")]),"createAccount"),ru.addVariant(1,rn([rc("owner")]),"assign"),ru.addVariant(2,rn([rr("lamports")]),"transfer"),ru.addVariant(3,rn([rc("base"),ra("seed"),rr("lamports"),rr("space"),rc("owner")]),"createAccountWithSeed"),ru.addVariant(4,rn([rc("authorized")]),"advanceNonceAccount"),ru.addVariant(5,rn([rr("lamports")]),"withdrawNonceAccount"),ru.addVariant(6,rn([rc("authorized")]),"initializeNonceAccount"),ru.addVariant(7,rn([rc("authorized")]),"authorizeNonceAccount"),ru.addVariant(8,rn([rr("space")]),"allocate"),ru.addVariant(9,rn([rc("base"),ra("seed"),rr("space"),rc("owner")]),"allocateWithSeed"),ru.addVariant(10,rn([rc("base"),ra("seed"),rc("owner")]),"assignWithSeed"),ru.addVariant(11,rn([rr("lamports"),ra("seed"),rc("owner")]),"transferWithSeed"),Object.values(ru.registry).map(t=>t.span);class rl extends eF{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 rd(t){return new rl(ro(32),t=>new h.PublicKey(t),t=>t.toBuffer(),t)}rn([re("version"),re("state"),rd("authorizedPubkey"),rd("nonce"),rn([new e1("lamportsPerSignature")
1],"feeCalculator")]);var r_=Object.freeze({__proto__:null,hash:function(t){return(0,N.ci)((0,m.JQ)(t))}}),rh=Object.freeze({__proto__:null,createWithSeedSync:function(t,e,r){let n=v.concat([t.toBuffer(),v.from(e),r.toBuffer()]);return new h.PublicKey((0,m.JQ)(n))}});let rf=new h.PublicKey("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"),rp=new h.PublicKey("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL");var rR=Object.freeze({__proto__:null,TOKEN_PROGRAM_ID:rf,ASSOCIATED_PROGRAM_ID:rp,associatedAddress:function({mint:t,owner:e}){return h.PublicKey.findProgramAddressSync([e.toBuffer(),rf.toBuffer(),t.toBuffer()],rp)[0]}});async function rO(t){try{let e=await fetch(`https://verify.osec.io/status/${t.toString()}`);if(!e.ok)return null;let r=await e.json();return r.is_verified?r:null}catch{return null}}async function rE(t,e){let r=await t.getAccountInfo(e);if(null===r)throw Error("program account not found");let{program:n}=ry(r.data),i=await t.getAccountInfo(n.programdataAddress);if(null===i)throw Error("program data account not found");let{programData:o}=ry(i.data);return o}let rA=y.rustEnum([y.struct([],"uninitialized"),y.struct([y.option(y.publicKey(),"authorityAddress")],"buffer"),y.struct([y.publicKey("programdataAddress")],"program"),y.struct([y.u64("slot"),y.option(y.publicKey(),"upgradeAuthorityAddress")],"programData")],void 0,y.u32());function ry(t){return rA.decode(t)}var rm=Object.freeze({__proto__:null,sha256:r_,rpc:tc,publicKey:rh,bytes:L,token:rR,features:eD,registry:Object.freeze({__proto__:null,verifiedBuild:rO,fetchData:rE,decodeUpgradeableLoaderState:ry})});let rN="Program log: ",rg="Program data: ",rT=rN.length,rv=rg.length;class rI{constructor(t,e,r){this._programId=t,this._provider=e,this._eventParser=new rw(t,r),this._eventCallbacks=new Map,this._eventListeners=new Map,this._listenerIdCount=0}addEventListener(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))&&void 0!==n?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 rw{constructor(t,e){this.coder=e,this.programId=t}*parseLogs(t,e=!1){let r=new rS([...t]),n=new rC,i=r.next();if(null===i)return;let o=rw.INVOKE_RE.exec(i);if(!o||o[2]!==rw.ROOT_DEPTH)throw Error(`Unexpected first log line: ${i}`);for(n.push(o[1]);null!==r.peek();){let t=r.next();if(null===t)break;let[i,o,s]=this.handleLog(n,t,e);if(i&&(yield i),o&&n.push(o),s){n.pop();let t=r.peek();if(t&&t.endsWith("invoke [1]")){let e=rw.INVOKE_RE.exec(t);e&&n.push(e[1])}}}}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(rN)||t.startsWith(rg)))return[null,...this.handleSystemLog(t)];{let r=t.startsWith(rN)?t.slice(rT):t.slice(rv),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=rw.INVOKE_RE.exec(t);return e&&e[1]===this.programId.toString()||t.startsWith(`Program ${this.programId.toString()} log: `)?[this.programId.toString(),!1]:e&&e[2]!==rw.ROOT_DEPTH?["cpi",!1]:/^Program ([1-9A-HJ-NP-Za-km-z]+) success$/.test(t)?[null,!0]:[null,!1]}}rw.INVOKE_RE=/^Program ([1-9A-HJ-NP-Za-km-z]+) invoke \[(\d+)\]$/,rw.ROOT_DEPTH="1";class rC{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 rS{constructor(t){this.logs=t,this.logs=this.logs.filter(t=>t.startsWith("Program "))}next(){if(0===this.logs.length)return null;let t=this.logs[0];return this.logs=this.logs.slice(1),t}peek(){return this.logs.length>0?this.logs[0]:null}}function rb(t,e){var r,n;let i={},o=t.args?t.args.length:0;if(e.length>
1o){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?void 0:r.map(t=>t.name))&&void 0!==n?n:[]}`);i=e.pop()}return[e,i]}class rL{static build(t,e,r){if("_inner"===t.name)throw new eU("the _inner name is reserved");let n=(...i)=>{let[o,s]=rb(t,[...i]);!function t(e,r={}){e.forEach(e=>{if(H(e))t(e.accounts,r[e.name]);else if(!r[e.name])throw Error(`Account \`${e.name}\` not provided.`)})}(t.accounts,s.accounts),[...i];let a=n.accounts(s.accounts);return void 0!==s.remainingAccounts&&a.push(...s.remainingAccounts),eH("debug-logs")&&console.log("Outgoing account metas:",a),new h.TransactionInstruction({keys:a,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,...o))})};return n.accounts=e=>rL.accountsArray(e,t.accounts,r,t.name),n}static accountsArray(t,e,r,n){return t?e.map(e=>{let i;if(H(e)){let i=t[e.name];return rL.accountsArray(i,e.accounts,r,n).flat()}try{i=P(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 rH{static build(t,e){return(...r)=>{var n,i,o;let[,s]=rb(t,[...r]),a=new h.Transaction;if(s.preInstructions&&s.instructions)throw Error("instructions is deprecated, use preInstructions");return null===(n=s.preInstructions)||void 0===n||n.forEach(t=>a.add(t)),null===(i=s.instructions)||void 0===i||i.forEach(t=>a.add(t)),a.add(e(...r)),null===(o=s.postInstructions)||void 0===o||o.forEach(t=>a.add(t)),a}}}class rD{static build(t,e,r,n){return async(...i)=>{var o;let s=e(...i),[,a]=rb(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)&&void 0!==o?o:[],a.options)}catch(t){throw eM(t,r)}}}}class rU{static build(t,e,r,n){var i;return(null!==(i=t.accounts)&&void 0!==i?i:[]).reduce((i,o)=>(i[o.name]=new rP(t,o,r,n,e),i),{})}}class rP{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:tf(),this._coder=null!=i?i:new eY(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 tr(this._provider.connection,t.map(t=>P(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 v?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=rk.get(t.toString());if(r)return r.ee;let n=new(T());t=P(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 rk.set(t.toString(),{ee:n,listener:i}),n}async unsubscribe(t){let e=rk.get(t.toString());if(!e){console.warn("Address is not subscribed");return}rk&&await this._provider.connection.removeAccountChangeListener(e.listener).then(()=>{rk.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 h.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(P(t),e)}async getAccountInfoAndContext(t,e){return await this._provider.connection.getAccountInfoAndContext(P(t),e)}}let rk=new Map;class rx{static build(t,e,r,n,i,o,s){return async(...a)=>{var c;let u;let l=e(...a),[,d]=rb(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?void 0:c.commitment)}catch(t){throw eM(t,r)}if(void 0===u)throw Error("Unable to simulate transaction");let _=u.logs;if(!_)throw Error("Simulated logs not found");let h=[];if(s.events)for(let t of new rw(o,i).parseLogs(_))h.push(t);return{events:h,raw:_}}}}function rM(t){return new rG(ro(8),t=>rK.fromBuffer(t),t=>t.toBuffer(),t)}function rB(t){return new rG(ro(32),t=>new h.PublicKey(t),t=>t.toBuffer(),t)}class rG extends eF{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 r$ extends eF{constructor(t,e){super(-1,e),this.layout=t,this.discriminator=re()}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 rK extends p(){toBuffer(){let t=super.toArray().reverse(),e=v.from(t);if(8===e.length)return e;if(e.length>=8)throw Error("u64 too large");let r=v.alloc(8);return e.copy(r),r}static fromBuffer(t){if(8!==t.length)throw Error(`Invalid buffer length: ${t.length}`);return new rK([...t].reverse().map(t=>`00${t.toString(16)}`.slice(-2)).join(""),16)}}let rV=rn([rB("mint"),rB("owner"),rM("amount"),new r$(rB(),"delegate"),
1(t=>{let e=ri(rt("discriminator"),null,t);return e.addVariant(0,rn([]),"uninitialized"),e.addVariant(1,rn([]),"initialized"),e.addVariant(2,rn([]),"frozen"),e})("state"),new r$(rM(),"isNative"),rM("delegatedAmount"),new r$(rB(),"closeAuthority")]);class rz{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 rj(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=this._idlIx.accounts.filter(this.isResolvable.bind(this)),e=this.getPaths(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: ${e}`)}}isResolvable(t){return H(t)?t.accounts.some(this.isResolvable.bind(this)):!!(t.address||t.pda||t.relations)}getPaths(t,e=[],r=[]){for(let n of t)H(n)?r.push(...this.getPaths(n.accounts,[...e,n.name])):r.push([...e,n.name]);return 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])&&void 0!==o?o:{},r=r[n]})}resolveOptionalsHelper(t,e){let r={};for(let n of e){let e=n.name,i=t[e];void 0!==i&&(rX(i)?H(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]=rX(o)?t(o,!0):P(o)}return n}(i,!0):null!==i?r[e]=P(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];H(n)&&this.resolveEventCpi(n.accounts,[...e,n.name]);let i=+r+1;if(i===t.length)return;let o=t[r].name,s=t[i].name;if("eventAuthority"===o&&"program"===s){let t=[...e,o],r=[...e,s];this.get(t)||this.set(t,h.PublicKey.findProgramAddressSync([v.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(H(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],P(r.address))}}}async resolvePdasAndRelations(t,e=[]){let r=0;for(let n of t){let t=n.name;if(H(n))r+=await this.resolvePdasAndRelations(n.accounts,[...e,t]);else if((n.pda||n.relations)&&!this.get([...e,t])){if(r++,await this.resolvePda(n,e,t))continue;await this.resolveRelation(n,e,t)}}return r}async resolvePda(t,e,r){if(!t.pda)return!1;try{let n=await Promise.all(t.pda.seeds.map(t=>this.toBuffer(t,e)));if(n.some(t=>!t))return!0;let i=await this.parseProgramId(t,e),[o]=h.PublicKey.findProgramAddressSync(n,i);this.set([...e,r],o)}catch{}return!1}async resolveRelation(t,e,r){if(t.relations)try{let n=this.get([...e,t.relations[0]]);if(n){let t=await this._accountStore.fetchAccount({publicKey:n});this.set([...e,r],t[r])}}catch{}}async parseProgramId(t,e=[]){var r;if(!(null===(r=t.pda)||void 0===r?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 h.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 v.from([e]);case"u16":case"i16":return new(p())(e).toArrayLike(v,"le",2);case"u32":case"i32":return new(p())(e).toArrayLike(v,"le",4);case"u64":case"i64":return new(p())(e).toArrayLike(v,"le",8);case"u128":case"i128":return new(p())(e).toArrayLike(v,"le",16);case"u256":case"i256":return new(p())(e).toArrayLike(v,"le",32);case"string":case"bytes":return v.from(e);case"pubkey":return e.toBuffer();default:if(null==t?void 0:t.array)return v.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?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 rj{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,rV.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 rZ.fetchIdl(t,this._provider);if(r){let t=new rZ(r,this._provider);this._idls[e]=t.account}}return this._idls[e]}}class rY{static build(t,e,r,n,i,o,s,a,c,u,l){return(...d)=>new rF(d,n,i,o,s,a,t,e,r,c,u,l)}}function rX(t){return"object"==typeof t&&null!==t&&!("_bn"in t)}class rF{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 rz(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 rW{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=b(a.slice(s.length)),u=e.returns;if(!u)throw Error("View expected return type");return eG.fieldLayout({type:u},n.types).decode(c)}}}class rq{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)&&void 0!==r?r:t.name;e.set(t.code,n)}),e}(t),_=t.accounts?rU.build(t,e,r,n):{};return t.instructions.forEach(h=>{let f=rL.build(h,(t,r)=>e.instruction.encode(t,r),r),p=rH.build(h,f),R=rD.build(h,p,d,n),O=rx.build(h,p,d,n,e,r,t),E=rW.build(r,h,O,t),A=rY.build(n,r,h,f,p,R,O,E,_,t.types||[],null==i?void 0:i(h)),y=h.name;s[y]=f,a[y]=p,o[y]=R,c[y]=O,u[y]=A,E&&(l[y]=E)}),[o,s,a,_,c,u,l]}}class rZ{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=tf(),r,n){this._idl=function(t){let e=["name","path","account","relations","generic"],r=t=>t.split(".").map(t=>(function(t){if(!t)return t;let e=t.replace(/[^A-Za-z0-9]+/g," ").replace(/([a-z][\d]*)([A-Z])/g,"$1 $2").replace(/([A-Z][A-Z\d]*)([A-Z][a-z])/g,"$1 $2").trim();return e?e.split(/\s+/).map((t,e)=>0===e?t.toLowerCase():t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()).join(""):""})(t)).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=P(t.address),this._coder=null!=r?r:new eY(this._idl),this._events=new rI(this._programId,e,this._coder);let[i,o,s,a,c,u,l]=rq.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=l}static async at(t,e){let r=P(t),n=await rZ.fetchIdl(r,e);if(!n)throw Error(`IDL not found for program: ${t.toString()}`);return new rZ(n,e)}static async fetchIdl(t,e){var r;e=null!=e?e:tf();let n=(r=P(t),h.PublicKey.findProgramAddressSync([r.toBuffer(),R.Buffer.alloc(0),function(t){let e=R.Buffer.from(C("idl"));if(e.length>16)throw Error("Metadata seed 'idl' exceeds 16 bytes");let r=R.Buffer.alloc(16);return e.copy(r),r}(0)],D)[0]),i=await e.connection.getAccountInfo(n);return i?function(t){let{data:e,compression:r,encoding:n}=function(t){if(t.length<96)throw Error("Metadata account is too small");let e=0,r=t.readUInt8(e);if(2!==r)throw Error(`Invalid metadata account discriminator: ${r.toString()}`);e+=1;let n=new h.PublicKey(t.subarray(e,e+32));e+=32;let i=t.subarray(e,e+32),o=i.every(t=>0===t)?null:new h.PublicKey(i);e+=32;let s=!!t.readUInt8(e);e+=1;let a=!!t.readUInt8(e);e+=1;let c=w(t.subarray(e,e+16));e+=16;let u=t.readUInt8(e);e+=1;let l=t.readUInt8(e);e+=1;let d=t.readUInt8(e);if(d!==_.Json)throw Error(`IDL has data format '${d}', only JSON IDLs (${_.Json}) are supported`);e+=1;let f=t.readUInt8(e);if(0!==f)throw Error(`IDL has source '${f}', only directly embedded data (0) is supported`);e+=1;let p=t.readUInt32LE(e);if(e+=9,t.length<e+p)throw Error("Metadata account data is truncated");return{discriminator:r,program:n,authority:o,mutable:s,canonical:a,seed:c,encoding:u,compression:l,format:d,dataSource:f,dataLength:p,data:t.subarray(e,e+p)}}(t);return JSON.parse(function(t,e){switch(e){case d.None:return t.toString("hex");case d.Utf8:return w(t);case d.Base58:return S(t);case d.Base64:return t.toString("base64");default:throw Error(`Unsupported metadata encoding: ${String(e)}`)}}(function(t,e){switch(e){case l.None:return t;case l.Gzip:return R.Buffer.from((0,A.ec)(t));case l.Zlib:return R.Buffer.from((0,A.rr)(t));default:throw Error(`Unsupported metadata compression: ${String(e)}`)}}(e,r),n))}(i.data):null}addEventListener(t,e,r){return this._events.addEventListener(t,e,r)}async removeEventListener(t){return await this._events.removeEventListener(t)}}new h.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.