@lightprotocol/compressed-token 0.23.0-beta.7 → 0.23.0-beta.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +0,0 @@
1
- import{bn as t,featureFlags as e,TreeType as n,getIndexOrAdd as r,padOutputStateMerkleTrees as o,batchMerkleTree1 as i,batchQueue1 as s,batchCpiContext1 as a,defaultStaticAccountsStruct as u,toArray as c,LightSystemProgram as l,defaultTestStateTreeAccounts as p,sumUpLamports as d,validateSufficientBalance as h,validateSameOwner as m,deriveAddressV2 as f,LIGHT_TOKEN_PROGRAM_ID as g,getOutputQueue as y,getDefaultAddressTreeInfo as w,assertBetaEnabled as b,dedupeSigner as k,buildAndSignTx as I,sendAndConfirmTx as v,packDecompressAccountsIdempotent as M,getBatchAddressTreeInfo as A,selectStateTreeInfo as P,DerivationMode as S}from"@lightprotocol/stateless.js";import{PublicKey as x,SystemProgram as C,TransactionInstruction as T,AddressLookupTableProgram as E,ComputeBudgetProgram as B,Keypair as U,Transaction as _,sendAndConfirmTransaction as L}from"@solana/web3.js";import{unpackAccount as W,MINT_SIZE as D,createInitializeMint2Instruction as O,createMintToInstruction as R,TOKEN_PROGRAM_ID as q,TOKEN_2022_PROGRAM_ID as K,ASSOCIATED_TOKEN_PROGRAM_ID as V,getAssociatedTokenAddressSync as z,createAssociatedTokenAccountInstruction as F,createAssociatedTokenAccountIdempotentInstruction as N,AccountState as $,TokenAccountNotFoundError as Y,getMint as j,MintLayout as H,unpackMint as Z,TokenInvalidAccountOwnerError as G,TokenInvalidMintError as Q,TokenInvalidOwnerError as X,createTransferCheckedInstruction as J,getAssociatedTokenAddress as tt,getOrCreateAssociatedTokenAccount as et}from"@solana/spl-token";import{struct as nt,array as rt,u8 as ot,publicKey as it,u64 as st,option as at,vecU8 as ut,u32 as ct,bool as lt,u16 as pt,vec as dt,rustEnum as ht}from"@coral-xyz/borsh";var mt="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},ft=[],gt=[],yt="undefined"!=typeof Uint8Array?Uint8Array:Array,wt=0;function bt(){wt=1;for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",e=0;e<64;++e)ft[e]=t[e],gt[t.charCodeAt(e)]=e;gt["-".charCodeAt(0)]=62,gt["_".charCodeAt(0)]=63}function kt(t,e,n){for(var r,o,i=[],s=e;s<n;s+=3)r=(t[s]<<16)+(t[s+1]<<8)+t[s+2],i.push(ft[(o=r)>>18&63]+ft[o>>12&63]+ft[o>>6&63]+ft[63&o]);return i.join("")}function It(t){var e;wt||bt();for(var n=t.length,r=n%3,o="",i=[],s=16383,a=0,u=n-r;a<u;a+=s)i.push(kt(t,a,a+s>u?u:a+s));return 1===r?(e=t[n-1],o+=ft[e>>2],o+=ft[e<<4&63],o+="=="):2===r&&(e=(t[n-2]<<8)+t[n-1],o+=ft[e>>10],o+=ft[e>>4&63],o+=ft[e<<2&63],o+="="),i.push(o),i.join("")}function vt(t,e,n,r,o){var i,s,a=8*o-r-1,u=(1<<a)-1,c=u>>1,l=-7,p=n?o-1:0,d=n?-1:1,h=t[e+p];for(p+=d,i=h&(1<<-l)-1,h>>=-l,l+=a;l>0;i=256*i+t[e+p],p+=d,l-=8);for(s=i&(1<<-l)-1,i>>=-l,l+=r;l>0;s=256*s+t[e+p],p+=d,l-=8);if(0===i)i=1-c;else{if(i===u)return s?NaN:Infinity*(h?-1:1);s+=Math.pow(2,r),i-=c}return(h?-1:1)*s*Math.pow(2,i-r)}function Mt(t,e,n,r,o,i){var s,a,u,c=8*i-o-1,l=(1<<c)-1,p=l>>1,d=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,h=r?0:i-1,m=r?1:-1,f=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||Infinity===e?(a=isNaN(e)?1:0,s=l):(s=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-s))<1&&(s--,u*=2),(e+=s+p>=1?d/u:d*Math.pow(2,1-p))*u>=2&&(s++,u/=2),s+p>=l?(a=0,s=l):s+p>=1?(a=(e*u-1)*Math.pow(2,o),s+=p):(a=e*Math.pow(2,p-1)*Math.pow(2,o),s=0));o>=8;t[n+h]=255&a,h+=m,a/=256,o-=8);for(s=s<<o|a,c+=o;c>0;t[n+h]=255&s,h+=m,s/=256,c-=8);t[n+h-m]|=128*f}var At={}.toString,Pt=Array.isArray||function(t){return"[object Array]"==At.call(t)};Tt.TYPED_ARRAY_SUPPORT=void 0!==mt.TYPED_ARRAY_SUPPORT?mt.TYPED_ARRAY_SUPPORT:1;var St=xt();function xt(){return Tt.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function Ct(t,e){if(xt()<e)throw new RangeError("Invalid typed array length");return Tt.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(e)).__proto__=Tt.prototype:(null===t&&(t=new Tt(e)),t.length=e),t}function Tt(t,e,n){if(!(Tt.TYPED_ARRAY_SUPPORT||this instanceof Tt))return new Tt(t,e,n);if("number"==typeof t){if("string"==typeof e)throw new Error("If encoding is specified then the first argument must be a string");return Ut(this,t)}return Et(this,t,e,n)}function Et(t,e,n,r){if("number"==typeof e)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer?function(t,e,n,r){if(e.byteLength,n<0||e.byteLength<n)throw new RangeError("'offset' is out of bounds");if(e.byteLength<n+(r||0))throw new RangeError("'length' is out of bounds");return e=void 0===n&&void 0===r?new Uint8Array(e):void 0===r?new Uint8Array(e,n):new Uint8Array(e,n,r),Tt.TYPED_ARRAY_SUPPORT?(t=e).__proto__=Tt.prototype:t=_t(t,e),t}(t,e,n,r):"string"==typeof e?function(t,e,n){if("string"==typeof n&&""!==n||(n="utf8"),!Tt.isEncoding(n))throw new TypeError('"encoding" must be a valid string encoding');var r=0|Dt(e,n),o=(t=Ct(t,r)).write(e,n);return o!==r&&(t=t.slice(0,o)),t}(t,e,n):function(t,e){if(Wt(e)){var n=0|Lt(e.length);return 0===(t=Ct(t,n)).length||e.copy(t,0,0,n),t}if(e){if("undefined"!=typeof ArrayBuffer&&e.buffer instanceof ArrayBuffer||"length"in e)return"number"!=typeof e.length||(r=e.length)!=r?Ct(t,0):_t(t,e);if("Buffer"===e.type&&Pt(e.data))return _t(t,e.data)}var r;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(t,e)}function Bt(t){if("number"!=typeof t)throw new TypeError('"size" argument must be a number');if(t<0)throw new RangeError('"size" argument must not be negative')}function Ut(t,e){if(Bt(e),t=Ct(t,e<0?0:0|Lt(e)),!Tt.TYPED_ARRAY_SUPPORT)for(var n=0;n<e;++n)t[n]=0;return t}function _t(t,e){var n=e.length<0?0:0|Lt(e.length);t=Ct(t,n);for(var r=0;r<n;r+=1)t[r]=255&e[r];return t}function Lt(t){if(t>=xt())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+xt().toString(16)+" bytes");return 0|t}function Wt(t){return!(null==t||!t._isBuffer)}function Dt(t,e){if(Wt(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var n=t.length;if(0===n)return 0;for(var r=0;;)switch(e){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return ue(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return ce(t).length;default:if(r)return ue(t).length;e=(""+e).toLowerCase(),r=1}}function Ot(t,e,n){var r=0;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return Xt(this,e,n);case"utf8":case"utf-8":return Ht(this,e,n);case"ascii":return Gt(this,e,n);case"latin1":case"binary":return Qt(this,e,n);case"base64":return jt(this,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Jt(this,e,n);default:if(r)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),r=1}}function Rt(t,e,n){var r=t[e];t[e]=t[n],t[n]=r}function qt(t,e,n,r,o){if(0===t.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=o?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(o)return-1;n=t.length-1}else if(n<0){if(!o)return-1;n=0}if("string"==typeof e&&(e=Tt.from(e,r)),Wt(e))return 0===e.length?-1:Kt(t,e,n,r,o);if("number"==typeof e)return e&=255,Tt.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,n):Uint8Array.prototype.lastIndexOf.call(t,e,n):Kt(t,[e],n,r,o);throw new TypeError("val must be string, number or Buffer")}function Kt(t,e,n,r,o){var i,s=1,a=t.length,u=e.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(t.length<2||e.length<2)return-1;s=2,a/=2,u/=2,n/=2}function c(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(o){var l=-1;for(i=n;i<a;i++)if(c(t,i)===c(e,-1===l?0:i-l)){if(-1===l&&(l=i),i-l+1===u)return l*s}else-1!==l&&(i-=i-l),l=-1}else for(n+u>a&&(n=a-u),i=n;i>=0;i--){for(var p=1,d=0;d<u;d++)if(c(t,i+d)!==c(e,d)){p=0;break}if(p)return i}return-1}function Vt(t,e,n,r){n=Number(n)||0;var o=t.length-n;r?(r=Number(r))>o&&(r=o):r=o;var i=e.length;if(i%2!=0)throw new TypeError("Invalid hex string");r>i/2&&(r=i/2);for(var s=0;s<r;++s){var a=parseInt(e.substr(2*s,2),16);if(isNaN(a))return s;t[n+s]=a}return s}function zt(t,e,n,r){return le(ue(e,t.length-n),t,n,r)}function Ft(t,e,n,r){return le(function(t){for(var e=[],n=0;n<t.length;++n)e.push(255&t.charCodeAt(n));return e}(e),t,n,r)}function Nt(t,e,n,r){return Ft(t,e,n,r)}function $t(t,e,n,r){return le(ce(e),t,n,r)}function Yt(t,e,n,r){return le(function(t,e){for(var n,r,o,i=[],s=0;s<t.length&&!((e-=2)<0);++s)r=(n=t.charCodeAt(s))>>8,o=n%256,i.push(o),i.push(r);return i}(e,t.length-n),t,n,r)}function jt(t,e,n){return 0===e&&n===t.length?It(t):It(t.slice(e,n))}function Ht(t,e,n){n=Math.min(t.length,n);for(var r=[],o=e;o<n;){var i,s,a,u,c=t[o],l=null,p=c>239?4:c>223?3:c>191?2:1;if(o+p<=n)switch(p){case 1:c<128&&(l=c);break;case 2:128==(192&(i=t[o+1]))&&(u=(31&c)<<6|63&i)>127&&(l=u);break;case 3:i=t[o+1],s=t[o+2],128==(192&i)&&128==(192&s)&&(u=(15&c)<<12|(63&i)<<6|63&s)>2047&&(u<55296||u>57343)&&(l=u);break;case 4:i=t[o+1],s=t[o+2],a=t[o+3],128==(192&i)&&128==(192&s)&&128==(192&a)&&(u=(15&c)<<18|(63&i)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(l=u)}null===l?(l=65533,p=1):l>65535&&(l-=65536,r.push(l>>>10&1023|55296),l=56320|1023&l),r.push(l),o+=p}return function(t){var e=t.length;if(e<=Zt)return String.fromCharCode.apply(String,t);for(var n="",r=0;r<e;)n+=String.fromCharCode.apply(String,t.slice(r,r+=Zt));return n}(r)}Tt.poolSize=8192,Tt._augment=function(t){return t.__proto__=Tt.prototype,t},Tt.from=function(t,e,n){return Et(null,t,e,n)},Tt.TYPED_ARRAY_SUPPORT&&(Tt.prototype.__proto__=Uint8Array.prototype,Tt.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&Tt[Symbol.species]),Tt.alloc=function(t,e,n){return function(t,e,n,r){return Bt(e),e<=0?Ct(t,e):void 0!==n?"string"==typeof r?Ct(t,e).fill(n,r):Ct(t,e).fill(n):Ct(t,e)}(null,t,e,n)},Tt.allocUnsafe=function(t){return Ut(null,t)},Tt.allocUnsafeSlow=function(t){return Ut(null,t)},Tt.isBuffer=pe,Tt.compare=function(t,e){if(!Wt(t)||!Wt(e))throw new TypeError("Arguments must be Buffers");if(t===e)return 0;for(var n=t.length,r=e.length,o=0,i=Math.min(n,r);o<i;++o)if(t[o]!==e[o]){n=t[o],r=e[o];break}return n<r?-1:r<n?1:0},Tt.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 1;default:return 0}},Tt.concat=function(t,e){if(!Pt(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return Tt.alloc(0);var n;if(void 0===e)for(e=0,n=0;n<t.length;++n)e+=t[n].length;var r=Tt.allocUnsafe(e),o=0;for(n=0;n<t.length;++n){var i=t[n];if(!Wt(i))throw new TypeError('"list" argument must be an Array of Buffers');i.copy(r,o),o+=i.length}return r},Tt.byteLength=Dt,Tt.prototype._isBuffer=1,Tt.prototype.swap16=function(){var t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)Rt(this,e,e+1);return this},Tt.prototype.swap32=function(){var t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)Rt(this,e,e+3),Rt(this,e+1,e+2);return this},Tt.prototype.swap64=function(){var t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)Rt(this,e,e+7),Rt(this,e+1,e+6),Rt(this,e+2,e+5),Rt(this,e+3,e+4);return this},Tt.prototype.toString=function(){var t=0|this.length;return 0===t?"":0===arguments.length?Ht(this,0,t):Ot.apply(this,arguments)},Tt.prototype.equals=function(t){if(!Wt(t))throw new TypeError("Argument must be a Buffer");return this===t?1:0===Tt.compare(this,t)},Tt.prototype.inspect=function(){var t="";return this.length>0&&(t=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(t+=" ... ")),"<Buffer "+t+">"},Tt.prototype.compare=function(t,e,n,r,o){if(!Wt(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===n&&(n=t?t.length:0),void 0===r&&(r=0),void 0===o&&(o=this.length),e<0||n>t.length||r<0||o>this.length)throw new RangeError("out of range index");if(r>=o&&e>=n)return 0;if(r>=o)return-1;if(e>=n)return 1;if(this===t)return 0;for(var i=(o>>>=0)-(r>>>=0),s=(n>>>=0)-(e>>>=0),a=Math.min(i,s),u=this.slice(r,o),c=t.slice(e,n),l=0;l<a;++l)if(u[l]!==c[l]){i=u[l],s=c[l];break}return i<s?-1:s<i?1:0},Tt.prototype.includes=function(t,e,n){return-1!==this.indexOf(t,e,n)},Tt.prototype.indexOf=function(t,e,n){return qt(this,t,e,n,1)},Tt.prototype.lastIndexOf=function(t,e,n){return qt(this,t,e,n,0)},Tt.prototype.write=function(t,e,n,r){if(void 0===e)r="utf8",n=this.length,e=0;else if(void 0===n&&"string"==typeof e)r=e,n=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e|=0,isFinite(n)?(n|=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}var o=this.length-e;if((void 0===n||n>o)&&(n=o),t.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var i=0;;)switch(r){case"hex":return Vt(this,t,e,n);case"utf8":case"utf-8":return zt(this,t,e,n);case"ascii":return Ft(this,t,e,n);case"latin1":case"binary":return Nt(this,t,e,n);case"base64":return $t(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Yt(this,t,e,n);default:if(i)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),i=1}},Tt.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var Zt=4096;function Gt(t,e,n){var r="";n=Math.min(t.length,n);for(var o=e;o<n;++o)r+=String.fromCharCode(127&t[o]);return r}function Qt(t,e,n){var r="";n=Math.min(t.length,n);for(var o=e;o<n;++o)r+=String.fromCharCode(t[o]);return r}function Xt(t,e,n){var r,o=t.length;(!e||e<0)&&(e=0),(!n||n<0||n>o)&&(n=o);for(var i="",s=e;s<n;++s)i+=(r=t[s])<16?"0"+r.toString(16):r.toString(16);return i}function Jt(t,e,n){for(var r=t.slice(e,n),o="",i=0;i<r.length;i+=2)o+=String.fromCharCode(r[i]+256*r[i+1]);return o}function te(t,e,n){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>n)throw new RangeError("Trying to access beyond buffer length")}function ee(t,e,n,r,o,i){if(!Wt(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||e<i)throw new RangeError('"value" argument is out of bounds');if(n+r>t.length)throw new RangeError("Index out of range")}function ne(t,e,n,r){e<0&&(e=65535+e+1);for(var o=0,i=Math.min(t.length-n,2);o<i;++o)t[n+o]=(e&255<<8*(r?o:1-o))>>>8*(r?o:1-o)}function re(t,e,n,r){e<0&&(e=4294967295+e+1);for(var o=0,i=Math.min(t.length-n,4);o<i;++o)t[n+o]=e>>>8*(r?o:3-o)&255}function oe(t,e,n,r){if(n+r>t.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function ie(t,e,n,r,o){return o||oe(t,0,n,4),Mt(t,e,n,r,23,4),n+4}function se(t,e,n,r,o){return o||oe(t,0,n,8),Mt(t,e,n,r,52,8),n+8}Tt.prototype.slice=function(t,e){var n,r=this.length;if((t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e<t&&(e=t),Tt.TYPED_ARRAY_SUPPORT)(n=this.subarray(t,e)).__proto__=Tt.prototype;else{var o=e-t;n=new Tt(o,void 0);for(var i=0;i<o;++i)n[i]=this[i+t]}return n},Tt.prototype.readUIntLE=function(t,e,n){t|=0,e|=0,n||te(t,e,this.length);for(var r=this[t],o=1,i=0;++i<e&&(o*=256);)r+=this[t+i]*o;return r},Tt.prototype.readUIntBE=function(t,e,n){t|=0,e|=0,n||te(t,e,this.length);for(var r=this[t+--e],o=1;e>0&&(o*=256);)r+=this[t+--e]*o;return r},Tt.prototype.readUInt8=function(t,e){return e||te(t,1,this.length),this[t]},Tt.prototype.readUInt16LE=function(t,e){return e||te(t,2,this.length),this[t]|this[t+1]<<8},Tt.prototype.readUInt16BE=function(t,e){return e||te(t,2,this.length),this[t]<<8|this[t+1]},Tt.prototype.readUInt32LE=function(t,e){return e||te(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},Tt.prototype.readUInt32BE=function(t,e){return e||te(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},Tt.prototype.readIntLE=function(t,e,n){t|=0,e|=0,n||te(t,e,this.length);for(var r=this[t],o=1,i=0;++i<e&&(o*=256);)r+=this[t+i]*o;return r>=(o*=128)&&(r-=Math.pow(2,8*e)),r},Tt.prototype.readIntBE=function(t,e,n){t|=0,e|=0,n||te(t,e,this.length);for(var r=e,o=1,i=this[t+--r];r>0&&(o*=256);)i+=this[t+--r]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*e)),i},Tt.prototype.readInt8=function(t,e){return e||te(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},Tt.prototype.readInt16LE=function(t,e){e||te(t,2,this.length);var n=this[t]|this[t+1]<<8;return 32768&n?4294901760|n:n},Tt.prototype.readInt16BE=function(t,e){e||te(t,2,this.length);var n=this[t+1]|this[t]<<8;return 32768&n?4294901760|n:n},Tt.prototype.readInt32LE=function(t,e){return e||te(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},Tt.prototype.readInt32BE=function(t,e){return e||te(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},Tt.prototype.readFloatLE=function(t,e){return e||te(t,4,this.length),vt(this,t,1,23,4)},Tt.prototype.readFloatBE=function(t,e){return e||te(t,4,this.length),vt(this,t,0,23,4)},Tt.prototype.readDoubleLE=function(t,e){return e||te(t,8,this.length),vt(this,t,1,52,8)},Tt.prototype.readDoubleBE=function(t,e){return e||te(t,8,this.length),vt(this,t,0,52,8)},Tt.prototype.writeUIntLE=function(t,e,n,r){t=+t,e|=0,n|=0,r||ee(this,t,e,n,Math.pow(2,8*n)-1,0);var o=1,i=0;for(this[e]=255&t;++i<n&&(o*=256);)this[e+i]=t/o&255;return e+n},Tt.prototype.writeUIntBE=function(t,e,n,r){t=+t,e|=0,n|=0,r||ee(this,t,e,n,Math.pow(2,8*n)-1,0);var o=n-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+n},Tt.prototype.writeUInt8=function(t,e,n){return t=+t,e|=0,n||ee(this,t,e,1,255,0),Tt.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},Tt.prototype.writeUInt16LE=function(t,e,n){return t=+t,e|=0,n||ee(this,t,e,2,65535,0),Tt.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):ne(this,t,e,1),e+2},Tt.prototype.writeUInt16BE=function(t,e,n){return t=+t,e|=0,n||ee(this,t,e,2,65535,0),Tt.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):ne(this,t,e,0),e+2},Tt.prototype.writeUInt32LE=function(t,e,n){return t=+t,e|=0,n||ee(this,t,e,4,4294967295,0),Tt.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):re(this,t,e,1),e+4},Tt.prototype.writeUInt32BE=function(t,e,n){return t=+t,e|=0,n||ee(this,t,e,4,4294967295,0),Tt.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):re(this,t,e,0),e+4},Tt.prototype.writeIntLE=function(t,e,n,r){if(t=+t,e|=0,!r){var o=Math.pow(2,8*n-1);ee(this,t,e,n,o-1,-o)}var i=0,s=1,a=0;for(this[e]=255&t;++i<n&&(s*=256);)t<0&&0===a&&0!==this[e+i-1]&&(a=1),this[e+i]=(t/s>>0)-a&255;return e+n},Tt.prototype.writeIntBE=function(t,e,n,r){if(t=+t,e|=0,!r){var o=Math.pow(2,8*n-1);ee(this,t,e,n,o-1,-o)}var i=n-1,s=1,a=0;for(this[e+i]=255&t;--i>=0&&(s*=256);)t<0&&0===a&&0!==this[e+i+1]&&(a=1),this[e+i]=(t/s>>0)-a&255;return e+n},Tt.prototype.writeInt8=function(t,e,n){return t=+t,e|=0,n||ee(this,t,e,1,127,-128),Tt.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},Tt.prototype.writeInt16LE=function(t,e,n){return t=+t,e|=0,n||ee(this,t,e,2,32767,-32768),Tt.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):ne(this,t,e,1),e+2},Tt.prototype.writeInt16BE=function(t,e,n){return t=+t,e|=0,n||ee(this,t,e,2,32767,-32768),Tt.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):ne(this,t,e,0),e+2},Tt.prototype.writeInt32LE=function(t,e,n){return t=+t,e|=0,n||ee(this,t,e,4,2147483647,-2147483648),Tt.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):re(this,t,e,1),e+4},Tt.prototype.writeInt32BE=function(t,e,n){return t=+t,e|=0,n||ee(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),Tt.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):re(this,t,e,0),e+4},Tt.prototype.writeFloatLE=function(t,e,n){return ie(this,t,e,1,n)},Tt.prototype.writeFloatBE=function(t,e,n){return ie(this,t,e,0,n)},Tt.prototype.writeDoubleLE=function(t,e,n){return se(this,t,e,1,n)},Tt.prototype.writeDoubleBE=function(t,e,n){return se(this,t,e,0,n)},Tt.prototype.copy=function(t,e,n,r){if(n||(n=0),r||0===r||(r=this.length),e>=t.length&&(e=t.length),e||(e=0),r>0&&r<n&&(r=n),r===n)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),t.length-e<r-n&&(r=t.length-e+n);var o,i=r-n;if(this===t&&n<e&&e<r)for(o=i-1;o>=0;--o)t[o+e]=this[o+n];else if(i<1e3||!Tt.TYPED_ARRAY_SUPPORT)for(o=0;o<i;++o)t[o+e]=this[o+n];else Uint8Array.prototype.set.call(t,this.subarray(n,n+i),e);return i},Tt.prototype.fill=function(t,e,n,r){if("string"==typeof t){if("string"==typeof e?(r=e,e=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),1===t.length){var o=t.charCodeAt(0);o<256&&(t=o)}if(void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!Tt.isEncoding(r))throw new TypeError("Unknown encoding: "+r)}else"number"==typeof t&&(t&=255);if(e<0||this.length<e||this.length<n)throw new RangeError("Out of range index");if(n<=e)return this;var i;if(e>>>=0,n=void 0===n?this.length:n>>>0,t||(t=0),"number"==typeof t)for(i=e;i<n;++i)this[i]=t;else{var s=Wt(t)?t:ue(new Tt(t,r).toString()),a=s.length;for(i=0;i<n-e;++i)this[i+e]=s[i%a]}return this};var ae=/[^+\/0-9A-Za-z-_]/g;function ue(t,e){var n;e=e||Infinity;for(var r=t.length,o=null,i=[],s=0;s<r;++s){if((n=t.charCodeAt(s))>55295&&n<57344){if(!o){if(n>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(s+1===r){(e-=3)>-1&&i.push(239,191,189);continue}o=n;continue}if(n<56320){(e-=3)>-1&&i.push(239,191,189),o=n;continue}n=65536+(o-55296<<10|n-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,n<128){if((e-=1)<0)break;i.push(n)}else if(n<2048){if((e-=2)<0)break;i.push(n>>6|192,63&n|128)}else if(n<65536){if((e-=3)<0)break;i.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return i}function ce(t){return function(t){var e,n,r,o,i,s;wt||bt();var a=t.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");i="="===t[a-2]?2:"="===t[a-1]?1:0,s=new yt(3*a/4-i),r=i>0?a-4:a;var u=0;for(e=0,n=0;e<r;e+=4,n+=3)o=gt[t.charCodeAt(e)]<<18|gt[t.charCodeAt(e+1)]<<12|gt[t.charCodeAt(e+2)]<<6|gt[t.charCodeAt(e+3)],s[u++]=o>>16&255,s[u++]=o>>8&255,s[u++]=255&o;return 2===i?(o=gt[t.charCodeAt(e)]<<2|gt[t.charCodeAt(e+1)]>>4,s[u++]=255&o):1===i&&(o=gt[t.charCodeAt(e)]<<10|gt[t.charCodeAt(e+1)]<<4|gt[t.charCodeAt(e+2)]>>2,s[u++]=o>>8&255,s[u++]=255&o),s}(function(t){if((t=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}(t).replace(ae,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function le(t,e,n,r){for(var o=0;o<r&&!(o+n>=e.length||o>=t.length);++o)e[o+n]=t[o];return o}function pe(t){return null!=t&&(!!t._isBuffer||de(t)||function(t){return"function"==typeof t.readFloatLE&&"function"==typeof t.slice&&de(t.slice(0,0))}(t))}function de(t){return!!t.constructor&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)}var he=Object.freeze({__proto__:null,Buffer:Tt,INSPECT_MAX_BYTES:50,SlowBuffer:function(t){return+t!=t&&(t=0),Tt.alloc(+t)},isBuffer:pe,kMaxLength:St});const me=new x("ACXg8a7VaqecBWrSbdu73W4Pg9gsqXJ3EXAqkHyhvVXg"),fe=new x("r18WwUxfG8kQ69bQPAB2jV6zGNKy3GosFGctjQoV4ti");var ge;!function(t){t[t.V1=1]="V1",t[t.V2=2]="V2",t[t.ShaFlat=3]="ShaFlat"}(ge||(ge={}));const ye=Tt.from("pool"),we=Tt.from("cpi_authority"),be=1461600,ke=Tt.from([23,169,27,122,147,169,209,152]),Ie=Tt.from([241,34,48,186,37,179,123,192]),ve=Tt.from([65,206,101,37,147,42,221,144]),Me=Tt.from([163,52,200,231,140,3,69,186]),Ae=Tt.from([112,230,105,101,145,202,157,97]),Pe=Tt.from([69,74,217,36,115,117,97,76]),Se=Tt.from([170,23,31,34,133,173,93,242]),xe=Tt.from([114,143,210,73,96,115,1,228]),Ce=Tt.from([107]),Te=128,Ee=1,Be=13500,Ue=1e4,_e=1e3,Le=11e3,We=272;function De(t){return Te+t*Ee}const Oe=De(272),Re=16,qe=766;function Ke(t=16,e=272){return 11e3+t*De(e)}function Ve(t){return{mint:t.mint,tokenPoolPda:t.splInterfacePda,splInterfacePda:t.splInterfacePda,tokenProgram:t.tokenProgram,activity:t.activity,isInitialized:t.isInitialized,balance:t.balance,poolIndex:t.poolIndex,bump:t.bump}}function ze(t){return{mint:t.mint,splInterfacePda:t.tokenPoolPda??t.splInterfacePda,tokenProgram:t.tokenProgram,activity:t.activity,isInitialized:t.isInitialized,balance:t.balance,poolIndex:t.poolIndex,bump:t.bump}}function Fe(e,n,r=0){const[o,i]=rr.deriveSplInterfacePdaWithIndex(e,r);return{mint:e,splInterfacePda:o,tokenProgram:n,activity:void 0,balance:t(0),isInitialized:1,poolIndex:r,bump:i}}function Ne(t,e){const n="tokenPoolPda"in t?ze(t):t;if(!n.mint.equals(e))throw new Error("SplInterface mint does not match the provided mint.");if(!n.isInitialized)throw new Error(`SplInterface is not initialized. Please create an SPL interface for mint: ${e.toBase58()} via createSplInterface().`);return 1}async function $e(e,n,r){const o=Array.from({length:5},((t,e)=>rr.deriveSplInterfacePdaWithIndex(n,e))),i=await e.getMultipleAccountsInfo(o.map((t=>t[0])),r);if(null===i[0])throw new Error(`SplInterface not found. Please create an SPL interface for mint: ${n.toBase58()} via createSplInterface().`);const s=o.map(((t,e)=>i[e]?W(t[0],i[e],i[e].owner):null)),a=i[0].owner;return s.map(((e,r)=>e?{mint:n,splInterfacePda:e.address,tokenProgram:a,activity:void 0,balance:t(e.amount.toString()),isInitialized:1,poolIndex:r,bump:o[r][1]}:{mint:n,splInterfacePda:o[r][0],tokenProgram:a,activity:void 0,balance:t(0),isInitialized:0,poolIndex:r,bump:o[r][1]}))}var Ye;!function(t){t[t.Compress=1]="Compress",t[t.Decompress=2]="Decompress",t[t.Transfer=3]="Transfer"}(Ye||(Ye={}));const je=t=>{for(let e=t.length-1;e>0;e--){const n=Math.floor(Math.random()*(e+1));[t[e],t[n]]=[t[n],t[e]]}return t};function He(t){const e=je(t).filter((t=>t.isInitialized));if(0===e.length)throw new Error("Please pass at least one initialized SPL interface info.");return e[0]}function Ze(e,n){if(0===e.length)throw new Error("Please pass at least one SPL interface info.");const r=(e=je(e)).find((e=>e.balance.gte(t(n).mul(t(10)))));if((e=e.filter((t=>t.isInitialized)).sort(((t,e)=>t.poolIndex-e.poolIndex))).every((t=>t.balance.isZero())))throw new Error("All provided SPL interface balances are zero. Please pass recent SPL interface infos.");return r?[r]:e}function Ge(t,e,n=0){return Ve(Fe(t,e,n))}function Qe(t,e){return Ne(ze(t),e)}async function Xe(t,e,n){return(await $e(t,e,n)).map(Ve)}function Je(t){return Ve(He(t.map(ze)))}function tn(t,e){return Ze(t.map(ze),e).map(Ve)}const en="Could not find accounts to select for transfer.",nn="Cannot select accounts from different tree types (V1/V2) in the same batch. Filter accounts by tree type first.";function rn(t,e){return e?t.filter((t=>t.compressedAccount.treeInfo.treeType===e)):t}function on(t){if(t.length<=1)return;const e=t.filter((t=>void 0!==t.compressedAccount?.treeInfo?.treeType));if(e.length<=1)return;const n=e[0].compressedAccount.treeInfo.treeType;if(e.some((t=>t.compressedAccount.treeInfo.treeType!==n)))throw new Error(nn)}function sn(t){const e=new Map;for(const n of t){const t=n.compressedAccount.treeInfo.treeType,r=e.get(t)||[];r.push(n),e.set(t,r)}return e}function an(r,o){const i=e.isV2()?n.StateV2:n.StateV1,s=sn(r);let a=i,u=s.get(i)||[],c=u.reduce(((t,e)=>t.add(e.parsed.amount)),t(0));if(o&&c.lt(o)){const e=i===n.StateV2?n.StateV1:n.StateV2,r=s.get(e)||[],l=r.reduce(((t,e)=>t.add(e.parsed.amount)),t(0));l.gte(o)&&(a=e,u=r,c=l)}return{accounts:u,treeType:a,totalBalance:c}}function un(t,e,n=4,r){const o=rn(t,r?.treeType),i=o.find((t=>t.parsed.amount.eq(e)));return i?[[i],i.parsed.amount,i.compressedAccount.lamports,i.parsed.amount]:ln(o,e,n,r)}function cn(t,e,n=4,r){const[o,i,s,a]=ln(t,e,n,r);return{selectedAccounts:o,total:i,totalLamports:s,maxPossibleAmount:a}}function ln(e,n,r=4,o){const i=rn(e,o?.treeType),[s,a,u,c]=pn(i,n,r);if(on(s),a.lt(t(n))){const e=i.reduce(((t,e)=>t.add(e.parsed.amount)),t(0));throw s.length>=r?new Error(`Account limit exceeded: max ${c.toString()} (${r} accounts) per transaction. Total balance: ${e.toString()} (${i.length} accounts). Consider multiple transfers to spend full balance.`):new Error(`Insufficient balance for transfer. Required: ${n.toString()}, available: ${e.toString()}.`)}if(0===s.length)throw new Error(en);return[s,a,u,c]}function pn(e,n,r=4){if(0===e.length)throw new Error(en);let o=t(0),i=t(0),s=t(0);const a=[];e.sort(((t,e)=>e.parsed.amount.cmp(t.parsed.amount)));for(const s of e){if(a.length>=r)break;if(o.gte(t(n)))break;s.parsed.amount.isZero()&&s.compressedAccount.lamports.isZero()||(o=o.add(s.parsed.amount),i=i.add(s.compressedAccount.lamports),a.push(s))}if(s=e.slice(0,r).reduce(((t,e)=>t.add(e.parsed.amount)),t(0)),o.lt(t(n))&&console.log(`Insufficient balance for transfer. Requested: ${n.toString()}, Returns max available: ${s.toString()}.`),0===a.length)throw new Error(en);return[a,o,i,s]}function dn(e,n,r=4,o){const i=rn(e,o?.treeType),[s,a,u,c]=hn(i,n,r);if(on(s),a.lt(t(n))){const e=i.reduce(((t,e)=>t.add(e.parsed.amount)),t(0));throw s.length>=r?new Error(`Account limit exceeded: max ${c.toString()} (${r} accounts) per transaction. Total balance: ${e.toString()} (${i.length} accounts). Consider multiple transfers to spend full balance.`):new Error(`Insufficient balance. Required: ${n.toString()}, available: ${e.toString()}.`)}if(0===s.length)throw new Error(en);return[s,a,u,c]}function hn(e,n,r=4){if(0===e.length)throw new Error(en);let o=t(0),i=t(0);const s=[],a=e.filter((t=>!t.parsed.amount.isZero()||!t.compressedAccount.lamports.isZero()));a.sort(((t,e)=>e.parsed.amount.cmp(t.parsed.amount)));for(const e of a){if(s.length>=r)break;if(o=o.add(e.parsed.amount),i=i.add(e.compressedAccount.lamports),s.push(e),o.gte(t(n))){const t=a.slice(s.length);if(t.length>0){const e=t.reduce(((t,e)=>e.parsed.amount.lt(t.parsed.amount)?e:t));s.length<r&&(s.push(e),o=o.add(e.parsed.amount),i=i.add(e.compressedAccount.lamports))}break}}const u=a.slice(0,r).reduce(((t,e)=>t.add(e.parsed.amount)),t(0));if(0===s.length)throw new Error(en);return[s,o,i,u]}function mn(i){const{inputCompressedTokenAccounts:s,outputStateTreeInfo:a,remainingAccounts:u=[],rootIndices:c,tokenTransferOutputs:l}=i,p=u.slice();let d=null;s.length>0&&s[0].parsed.delegate&&(d=r(p,s[0].parsed.delegate));const h=[];let m;if(s.forEach(((e,n)=>{const o=r(p,e.compressedAccount.treeInfo.tree),i=r(p,e.compressedAccount.treeInfo.queue);h.push({amount:e.parsed.amount,delegateIndex:d,merkleContext:{merkleTreePubkeyIndex:o,queuePubkeyIndex:i,leafIndex:e.compressedAccount.leafIndex,proveByIndex:e.compressedAccount.proveByIndex},rootIndex:c[n],lamports:e.compressedAccount.lamports.eq(t(0))?null:e.compressedAccount.lamports,tlv:null})})),a)m=a;else{if(!(s.length>0))throw new Error("Either input accounts or outputStateTreeInfo must be provided");m=s[0].compressedAccount.treeInfo}const f=m.nextTreeInfo||m;let g=f.tree;if(f.treeType===n.StateV2){if(!e.isV2())throw new Error("V2 trees are not supported yet");g=f.queue}const y=o(g,l.length),w=[];y.forEach(((e,n)=>{const o=r(p,e);w.push({owner:l[n].owner,amount:l[n].amount,lamports:l[n].lamports?.eq(t(0))?null:l[n].lamports,merkleTreeIndex:o,tlv:null})}));const b=p.map((t=>({pubkey:t,isWritable:1,isSigner:0})));return{inputTokenDataWithContext:h,remainingAccountMetas:b,packedOutputTokenData:w}}function fn(t,e){if(!t.every((t=>t.parsed.mint.equals(e))))throw new Error("All input accounts must belong to the same mint");return 1}const gn=nt([rt(ot(),32,"a"),rt(ot(),64,"b"),rt(ot(),32,"c")]),yn=nt([it("owner"),st("amount"),at(st(),"lamports"),ot("merkleTreeIndex"),at(ut(),"tlv")]),wn=nt([st("amount"),at(ot(),"delegateIndex"),nt([ot("merkleTreePubkeyIndex"),ot("queuePubkeyIndex"),ct("leafIndex"),lt("proveByIndex")],"merkleContext"),pt("rootIndex"),at(st(),"lamports"),at(ut(),"tlv")]),bn=nt([it("owner"),at(ot(),"delegateChangeAccountIndex")]),kn=nt([lt("setContext"),lt("firstSetContext"),ot("cpiContextAccountIndex")]),In=nt([at(gn,"proof"),it("mint"),at(bn,"delegatedTransfer"),dt(wn,"inputTokenDataWithContext"),dt(yn,"outputCompressedAccounts"),lt("isCompress"),at(st(),"compressOrDecompressAmount"),at(kn,"cpiContext"),at(ot(),"lamportsChangeAccountMerkleTreeIndex")]),vn=nt([dt(it(),"recipients"),dt(st(),"amounts"),at(st(),"lamports")]),Mn=nt([dt(it(),"pubkeys"),at(dt(st(),"amounts"),"amounts"),at(st(),"lamports"),at(st(),"amount"),ot("index"),ot("bump")]),An=nt([it("owner"),at(st(),"remainingAmount"),at(kn,"cpiContext")]);function Pn(t){const e=Tt.alloc(1e3),n=vn.encode({recipients:t.recipients,amounts:t.amounts,lamports:t.lamports},e);return Tt.concat([new Uint8Array(Ie),new Uint8Array(e.subarray(0,n))])}function Sn(t){return vn.decode(t.subarray(Ie.length))}function xn(t){const e=Tt.alloc(1e3),n=Mn.encode(t,e),r=Tt.alloc(4);r.writeUInt32LE(n,0);const o=e.subarray(0,n);return Tt.concat([new Uint8Array(ve),new Uint8Array(r),new Uint8Array(o)])}function Cn(t){return Mn.decode(t.subarray(ve.length+4))}function Tn(t){const e=Tt.alloc(1e3),n=An.encode({owner:t.owner,remainingAmount:t.remainingAmount,cpiContext:t.cpiContext},e);return Tt.concat([new Uint8Array(Ae),new Uint8Array(e.subarray(0,n))])}function En(t){const e=An.decode(t.subarray(Ae.length));return{owner:e.owner,remainingAmount:e.remainingAmount,cpiContext:e.cpiContext}}function Bn(t){const e=Tt.alloc(1e3),n=In.encode(t,e),r=Tt.alloc(4);r.writeUInt32LE(n,0);const o=e.subarray(0,n);return Tt.concat([new Uint8Array(Me),new Uint8Array(r),new Uint8Array(o)])}function Un(t){return In.decode(t.slice(Me.length+4))}const _n=t=>{const{feePayer:e,tokenPoolPda:n,systemProgram:r,mint:o,tokenProgram:i,cpiAuthorityPda:s}=t;return[{pubkey:e,isSigner:1,isWritable:1},{pubkey:n,isSigner:0,isWritable:1},{pubkey:r,isSigner:0,isWritable:0},{pubkey:o,isSigner:0,isWritable:1},{pubkey:i,isSigner:0,isWritable:0},{pubkey:s,isSigner:0,isWritable:0}]},Ln=t=>{const{feePayer:e,tokenPoolPda:n,systemProgram:r,mint:o,tokenProgram:i,cpiAuthorityPda:s,existingTokenPoolPda:a}=t;return[{pubkey:e,isSigner:1,isWritable:1},{pubkey:n,isSigner:0,isWritable:1},{pubkey:a,isSigner:0,isWritable:0},{pubkey:r,isSigner:0,isWritable:0},{pubkey:o,isSigner:0,isWritable:1},{pubkey:i,isSigner:0,isWritable:0},{pubkey:s,isSigner:0,isWritable:0}]},Wn=t=>{const e=rr.programId,{feePayer:n,authority:r,cpiAuthorityPda:o,mint:i,tokenPoolPda:s,tokenProgram:a,lightSystemProgram:u,registeredProgramPda:c,noopProgram:l,accountCompressionAuthority:p,accountCompressionProgram:d,merkleTree:h,selfProgram:m,systemProgram:f,solPoolPda:g}=t;return[{pubkey:n,isSigner:1,isWritable:1},{pubkey:r,isSigner:1,isWritable:0},{pubkey:o,isSigner:0,isWritable:0},{pubkey:i,isSigner:0,isWritable:1},{pubkey:s,isSigner:0,isWritable:1},{pubkey:a,isSigner:0,isWritable:0},{pubkey:u,isSigner:0,isWritable:0},{pubkey:c,isSigner:0,isWritable:0},{pubkey:l,isSigner:0,isWritable:0},{pubkey:p,isSigner:0,isWritable:0},{pubkey:d,isSigner:0,isWritable:0},{pubkey:h,isSigner:0,isWritable:1},{pubkey:m,isSigner:0,isWritable:0},{pubkey:f,isSigner:0,isWritable:0},{pubkey:g??e,isSigner:0,isWritable:1}]},Dn=t=>{const e=rr.programId,{feePayer:n,authority:r,cpiAuthorityPda:o,lightSystemProgram:i,registeredProgramPda:s,noopProgram:a,accountCompressionAuthority:u,accountCompressionProgram:c,selfProgram:l,tokenPoolPda:p,compressOrDecompressTokenAccount:d,tokenProgram:h,systemProgram:m}=t;return[{pubkey:n,isSigner:1,isWritable:1},{pubkey:r,isSigner:1,isWritable:0},{pubkey:o,isSigner:0,isWritable:0},{pubkey:i,isSigner:0,isWritable:0},{pubkey:s,isSigner:0,isWritable:0},{pubkey:a,isSigner:0,isWritable:0},{pubkey:u,isSigner:0,isWritable:0},{pubkey:c,isSigner:0,isWritable:0},{pubkey:l,isSigner:0,isWritable:0},{pubkey:p??e,isSigner:0,isWritable:1},{pubkey:d??e,isSigner:0,isWritable:1},{pubkey:h??e,isSigner:0,isWritable:0},{pubkey:m,isSigner:0,isWritable:0}]},On=t=>{const{feePayer:e,authority:n,cpiAuthorityPda:r,lightSystemProgram:o,registeredProgramPda:i,noopProgram:s,accountCompressionAuthority:a,accountCompressionProgram:u,selfProgram:c,systemProgram:l}=t;return[{pubkey:e,isSigner:1,isWritable:1},{pubkey:n,isSigner:1,isWritable:0},{pubkey:r,isSigner:0,isWritable:0},{pubkey:o,isSigner:0,isWritable:0},{pubkey:i,isSigner:0,isWritable:0},{pubkey:s,isSigner:0,isWritable:0},{pubkey:a,isSigner:0,isWritable:0},{pubkey:u,isSigner:0,isWritable:0},{pubkey:c,isSigner:0,isWritable:0},{pubkey:l,isSigner:0,isWritable:0}]},Rn=On,qn=t=>{const{feePayer:e,authority:n,cpiAuthorityPda:r,lightSystemProgram:o,registeredProgramPda:i,noopProgram:s,accountCompressionAuthority:a,accountCompressionProgram:u,selfProgram:c,systemProgram:l,mint:p}=t;return[{pubkey:e,isSigner:1,isWritable:1},{pubkey:n,isSigner:1,isWritable:0},{pubkey:r,isSigner:0,isWritable:0},{pubkey:o,isSigner:0,isWritable:0},{pubkey:i,isSigner:0,isWritable:0},{pubkey:s,isSigner:0,isWritable:0},{pubkey:a,isSigner:0,isWritable:0},{pubkey:u,isSigner:0,isWritable:0},{pubkey:c,isSigner:0,isWritable:0},{pubkey:l,isSigner:0,isWritable:0},{pubkey:p,isSigner:0,isWritable:0}]},Kn=qn,Vn=nt([nt([rt(ot(),32,"a"),rt(ot(),64,"b"),rt(ot(),32,"c")],"proof"),it("mint"),dt(wn,"inputTokenDataWithContext"),at(kn,"cpiContext"),it("delegate"),st("delegatedAmount"),ot("delegateMerkleTreeIndex"),ot("changeAccountMerkleTreeIndex"),at(st(),"delegateLamports")]),zn=nt([nt([rt(ot(),32,"a"),rt(ot(),64,"b"),rt(ot(),32,"c")],"proof"),it("mint"),dt(wn,"inputTokenDataWithContext"),at(kn,"cpiContext"),ot("outputAccountMerkleTreeIndex")]),Fn={a:new Array(32).fill(0),b:new Array(64).fill(0),c:new Array(32).fill(0)};function Nn(t){return t.a.every((t=>0===t))&&t.b.every((t=>0===t))&&t.c.every((t=>0===t))}function $n(t){const e=Tt.alloc(1e3),n=t.proof??Fn,r=Vn.encode({...t,proof:n},e),o=Tt.alloc(4);o.writeUInt32LE(r,0);const i=e.subarray(0,r);return Tt.concat([new Uint8Array(Pe),new Uint8Array(o),new Uint8Array(i)])}function Yn(t){const e=Vn.decode(t.subarray(Pe.length));return{...e,proof:Nn(e.proof)?null:e.proof}}function jn(t){const e=Tt.alloc(1e3),n=t.proof??Fn,r=zn.encode({...t,proof:n},e),o=Tt.alloc(4);o.writeUInt32LE(r,0);const i=e.subarray(0,r);return Tt.concat([new Uint8Array(Se),new Uint8Array(o),new Uint8Array(i)])}function Hn(t){const e=zn.decode(t.subarray(Se.length));return{...e,proof:Nn(e.proof)?null:e.proof}}const Zn={tree:new x(i),queue:new x(s),cpiContext:new x(a),treeType:n.StateV2,nextTreeInfo:null};function Gn(t){return"tokenPoolPda"in t?t.tokenPoolPda??t.splInterfacePda:t.splInterfacePda}const Qn=e=>e.reduce(((t,e)=>t.add(e.parsed.amount)),t(0)),Xn=t=>{const e=t[0].parsed.owner;t.forEach((t=>{if(!t.parsed.owner.equals(e))throw new Error("Token accounts must be owned by the same owner")}))},Jn=t=>({mint:t[0].parsed.mint,currentOwner:t[0].parsed.owner,delegate:t[0].parsed.delegate}),tr=(t,e)=>{if(t.length<1)throw new Error("Must supply at least one input token account.");const n=t[0].parsed.owner,r=t.findIndex((t=>t.parsed.delegate));if(-1===r)return{delegatedTransfer:null,authority:n};const o=t[r].parsed.delegate;return{delegatedTransfer:{owner:n,delegateChangeAccountIndex:e.length<=1?null:0},authority:o}};function er(e,n,r){r=t(r);const o=Qn(e),i=d(e.map((t=>t.compressedAccount))),s=o.sub(r);return h(s),s.eq(t(0))&&i.eq(t(0))?[{owner:n,amount:r,lamports:i,tlv:null}]:(m(e.map((t=>t.compressedAccount))),Xn(e),[{owner:e[0].parsed.owner,amount:s,lamports:i,tlv:null},{owner:n,amount:r,lamports:t(0),tlv:null}])}function nr(e,n){n=t(n);const r=d(e.map((t=>t.compressedAccount))),o=Qn(e).sub(n);return h(o),o.eq(t(0))&&r.eq(t(0))?[]:(m(e.map((t=>t.compressedAccount))),Xn(e),[{owner:e[0].parsed.owner,amount:o,lamports:r,tlv:null}])}class rr{constructor(){}static programId=new x("cTokenmWW8bLPjZEBAUgYy3zKxQZW6VKi7bqNFEVv3m");static setProgramId(t){this.programId="string"==typeof t?new x(t):t}static deriveSplInterfacePda(t){const e=[ye,t.toBuffer()],[n,r]=x.findProgramAddressSync(e,this.programId);return n}static deriveTokenPoolPda(t){return this.deriveSplInterfacePda(t)}static findSplInterfaceIndexAndBump(t,e){for(let n=0;n<5;n++){const r=rr.deriveSplInterfacePdaWithIndex(e,n);if(r[0].equals(t))return[n,r[1]]}throw new Error("SPL interface not found")}static findTokenPoolIndexAndBump(t,e){return this.findSplInterfaceIndexAndBump(t,e)}static deriveSplInterfacePdaWithIndex(t,e){let n=[];n=0===e?[Tt.from("pool"),t.toBuffer(),Tt.from([])]:[Tt.from("pool"),t.toBuffer(),Tt.from([e])];const[r,o]=x.findProgramAddressSync(n,this.programId);return[r,o]}static deriveTokenPoolPdaWithIndex(t,e){return this.deriveSplInterfacePdaWithIndex(t,e)}static get deriveCpiAuthorityPda(){const[t,e]=x.findProgramAddressSync([we],this.programId);return t}static async createMint({feePayer:t,mint:e,authority:n,freezeAuthority:r,decimals:o,rentExemptBalance:i,tokenProgramId:s,mintSize:a}){const u=s??q;return[C.createAccount({fromPubkey:t,lamports:i,newAccountPubkey:e,programId:u,space:a??D}),O(e,o,n,r,u),await this.createSplInterface({feePayer:t,mint:e,tokenProgramId:u})]}static async createSplInterface({feePayer:t,mint:e,tokenProgramId:n}){const r=n??q,o=this.deriveSplInterfacePdaWithIndex(e,0),i=_n({mint:e,feePayer:t,tokenPoolPda:o[0],tokenProgram:r,cpiAuthorityPda:this.deriveCpiAuthorityPda,systemProgram:C.programId});return new T({programId:this.programId,keys:i,data:ke})}static async createTokenPool(t){return this.createSplInterface(t)}static async addTokenPool({feePayer:t,mint:e,poolIndex:n,tokenProgramId:r}){if(n<=0)throw new Error("Pool index must be greater than 0. For 0, use CreateTokenPool instead.");if(n>3)throw new Error(`Invalid poolIndex ${n}. Max 4 pools per mint.`);const o=r??q,i=this.deriveSplInterfacePdaWithIndex(e,n-1),s=this.deriveSplInterfacePdaWithIndex(e,n),a=Ln({mint:e,feePayer:t,tokenPoolPda:s[0],existingTokenPoolPda:i[0],tokenProgram:o,cpiAuthorityPda:this.deriveCpiAuthorityPda,systemProgram:C.programId});return new T({programId:this.programId,keys:a,data:Tt.concat([new Uint8Array(xe),new Uint8Array(Tt.from([n]))])})}static async mintTo({feePayer:e,mint:r,authority:o,toPubkey:i,amount:s,outputStateTreeInfo:a,tokenPoolInfo:p}){const d=u(),h=p.tokenProgram;Ne(p,r);const m=c(s).map((e=>t(e))),f=c(i);if(m.length!==f.length)throw new Error("Amount and toPubkey arrays must have the same length");const g=Wn({mint:r,feePayer:e,authority:o,cpiAuthorityPda:this.deriveCpiAuthorityPda,tokenProgram:h,tokenPoolPda:Gn(p),lightSystemProgram:l.programId,registeredProgramPda:d.registeredProgramPda,noopProgram:d.noopProgram,accountCompressionAuthority:d.accountCompressionAuthority,accountCompressionProgram:d.accountCompressionProgram,merkleTree:a.treeType===n.StateV2?a.queue:a.tree,selfProgram:this.programId,systemProgram:C.programId,solPoolPda:null}),y=Pn({recipients:f,amounts:m,lamports:null});return new T({programId:this.programId,keys:g,data:y})}static async approveAndMintTo({feePayer:t,mint:e,authority:n,authorityTokenAccount:r,toPubkey:o,amount:i,outputStateTreeInfo:s,tokenPoolInfo:a}){const u=BigInt(i.toString());return[R(e,r,n,u,[],a.tokenProgram),await this.compress({payer:t,owner:n,source:r,toAddress:o,mint:e,amount:i,outputStateTreeInfo:s,tokenPoolInfo:a})]}static async transfer({payer:t,inputCompressedTokenAccounts:r,toAddress:o,amount:i,recentValidityProof:s,recentInputStateRootIndices:a}){const c=er(r,o,i),p=r[0]?.compressedAccount.treeInfo.treeType,d=p===n.StateV1&&e.isV2()?Zn:void 0,{inputTokenDataWithContext:h,packedOutputTokenData:m,remainingAccountMetas:f}=mn({inputCompressedTokenAccounts:r,rootIndices:a,tokenTransferOutputs:c,outputStateTreeInfo:d}),{mint:g}=Jn(r),{delegatedTransfer:y,authority:w}=tr(r,c),b=Bn({proof:s,mint:g,delegatedTransfer:y,inputTokenDataWithContext:h,outputCompressedAccounts:m,compressOrDecompressAmount:null,isCompress:0,cpiContext:null,lamportsChangeAccountMerkleTreeIndex:null}),{accountCompressionAuthority:k,noopProgram:I,registeredProgramPda:v,accountCompressionProgram:M}=u(),A=Dn({feePayer:t,authority:w,cpiAuthorityPda:this.deriveCpiAuthorityPda,lightSystemProgram:l.programId,registeredProgramPda:v,noopProgram:I,accountCompressionAuthority:k,accountCompressionProgram:M,selfProgram:this.programId,tokenPoolPda:void 0,compressOrDecompressTokenAccount:void 0,tokenProgram:void 0,systemProgram:C.programId});return A.push(...f),new T({programId:this.programId,keys:A,data:b})}static async createTokenProgramLookupTable({payer:t,authority:e,mints:n,recentSlot:r,remainingAccounts:o}){const[i,s]=E.createLookupTable({authority:e,payer:e,recentSlot:r});let a=[];n&&(a=[...n,...n.map((t=>this.deriveSplInterfacePda(t)))]);const c=[i,E.extendLookupTable({payer:t,authority:e,lookupTable:s,addresses:[C.programId,B.programId,this.deriveCpiAuthorityPda,l.programId,rr.programId,u().registeredProgramPda,u().noopProgram,u().accountCompressionAuthority,u().accountCompressionProgram,p().merkleTree,p().nullifierQueue,p().addressTree,p().addressQueue,this.programId,q,K,e,...a]})];if(o&&o.length>0)for(let n=0;n<o.length;n+=25){const r=o.slice(n,n+25),i=E.extendLookupTable({payer:t,authority:e,lookupTable:s,addresses:r});c.push(i)}return{instructions:c,address:s}}static async compress({payer:n,owner:r,source:o,toAddress:i,amount:s,mint:a,outputStateTreeInfo:p,tokenPoolInfo:d}){let h;const m=c(s),f=c(i);if(Ne(d,a),m.length!==f.length)throw new Error("Amount and toAddress arrays must have the same length");if(e.isV2()){const[e,i]=this.findSplInterfaceIndexAndBump(Gn(d),a),s=xn({pubkeys:f,amounts:m.length>1?m.map((e=>t(e))):null,lamports:null,amount:1===m.length?t(m[0]):null,index:e,bump:i}),c=Wn({mint:a,feePayer:n,authority:r,cpiAuthorityPda:this.deriveCpiAuthorityPda,tokenProgram:d.tokenProgram,tokenPoolPda:Gn(d),lightSystemProgram:l.programId,...u(),merkleTree:p.queue,selfProgram:this.programId,systemProgram:C.programId,solPoolPda:null});return c.push({pubkey:o,isWritable:1,isSigner:0}),new T({programId:this.programId,keys:c,data:s})}{h=m.map(((e,n)=>{const r=t(e);return{owner:f[n],amount:r,lamports:null,tlv:null}}));const{inputTokenDataWithContext:e,packedOutputTokenData:i,remainingAccountMetas:c}=mn({inputCompressedTokenAccounts:[],outputStateTreeInfo:p,rootIndices:[],tokenTransferOutputs:h}),g=Bn({proof:null,mint:a,delegatedTransfer:null,inputTokenDataWithContext:e,outputCompressedAccounts:i,compressOrDecompressAmount:Array.isArray(s)?s.map((e=>t(e))).reduce(((t,e)=>t.add(e)),t(0)):t(s),isCompress:1,cpiContext:null,lamportsChangeAccountMerkleTreeIndex:null}),y=Dn({...u(),feePayer:n,authority:r,cpiAuthorityPda:this.deriveCpiAuthorityPda,lightSystemProgram:l.programId,selfProgram:this.programId,systemProgram:C.programId,tokenPoolPda:Gn(d),compressOrDecompressTokenAccount:o,tokenProgram:d.tokenProgram});return y.push(...c),new T({programId:this.programId,keys:y,data:g})}}static async decompress({payer:e,inputCompressedTokenAccounts:n,toAddress:r,amount:o,recentValidityProof:i,recentInputStateRootIndices:s,tokenPoolInfos:a}){const p=t(o),d=c(a),h=nr(n,p),{inputTokenDataWithContext:m,packedOutputTokenData:f,remainingAccountMetas:g}=mn({inputCompressedTokenAccounts:n,rootIndices:s,tokenTransferOutputs:h,remainingAccounts:d.slice(1).map((t=>Gn(t)))}),{mint:y}=Jn(n),{delegatedTransfer:w,authority:b}=tr(n,h),k=Bn({proof:i,mint:y,delegatedTransfer:w,inputTokenDataWithContext:m,outputCompressedAccounts:f,compressOrDecompressAmount:p,isCompress:0,cpiContext:null,lamportsChangeAccountMerkleTreeIndex:null}),I=d[0].tokenProgram,{accountCompressionAuthority:v,noopProgram:M,registeredProgramPda:A,accountCompressionProgram:P}=u(),S=Dn({feePayer:e,authority:b,cpiAuthorityPda:this.deriveCpiAuthorityPda,lightSystemProgram:l.programId,registeredProgramPda:A,noopProgram:M,accountCompressionAuthority:v,accountCompressionProgram:P,selfProgram:this.programId,tokenPoolPda:Gn(d[0]),compressOrDecompressTokenAccount:r,tokenProgram:I,systemProgram:C.programId});return S.push(...g),new T({programId:this.programId,keys:S,data:k})}static async mergeTokenAccounts({payer:n,owner:r,inputCompressedTokenAccounts:o,mint:i,recentValidityProof:s,recentInputStateRootIndices:a}){const u=e.isV2()?8:4;if(o.length>u)throw new Error(`Cannot merge more than ${u} token accounts at once`);return fn(o,i),[await this.transfer({payer:n,inputCompressedTokenAccounts:o,toAddress:r,amount:o.reduce(((t,e)=>t.add(e.parsed.amount)),t(0)),recentInputStateRootIndices:a,recentValidityProof:s})]}static async compressSplTokenAccount({feePayer:t,authority:e,tokenAccount:r,mint:o,remainingAmount:i,outputStateTreeInfo:s,tokenPoolInfo:a}){Ne(a,o);const c=[{pubkey:s.treeType===n.StateV2?s.queue:s.tree,isSigner:0,isWritable:1}],p=Tn({owner:e,remainingAmount:i??null,cpiContext:null}),{accountCompressionAuthority:d,noopProgram:h,registeredProgramPda:m,accountCompressionProgram:f}=u(),g=Dn({feePayer:t,authority:e,cpiAuthorityPda:this.deriveCpiAuthorityPda,lightSystemProgram:l.programId,registeredProgramPda:m,noopProgram:h,accountCompressionAuthority:d,accountCompressionProgram:f,selfProgram:this.programId,tokenPoolPda:Gn(a),compressOrDecompressTokenAccount:r,tokenProgram:a.tokenProgram,systemProgram:C.programId});return g.push(...c),new T({programId:this.programId,keys:g,data:p})}static async getMintProgramId(t,e){return(await e.getAccountInfo(t))?.owner}static async approve({payer:e,inputCompressedTokenAccounts:r,toAddress:o,amount:i,recentValidityProof:s,recentInputStateRootIndices:a}){const{inputTokenDataWithContext:c,remainingAccountMetas:p}=mn({inputCompressedTokenAccounts:r,rootIndices:a,tokenTransferOutputs:[]}),{mint:d,currentOwner:h}=Jn(r),m=r[0].compressedAccount.treeInfo.treeType===n.StateV2?1:0,f=$n({proof:s,mint:d,inputTokenDataWithContext:c,cpiContext:null,delegate:o,delegatedAmount:t(i),delegateMerkleTreeIndex:m,changeAccountMerkleTreeIndex:m,delegateLamports:null}),{accountCompressionAuthority:g,noopProgram:y,registeredProgramPda:w,accountCompressionProgram:b}=u(),k=On({feePayer:e,authority:h,cpiAuthorityPda:this.deriveCpiAuthorityPda,lightSystemProgram:l.programId,registeredProgramPda:w,noopProgram:y,accountCompressionAuthority:g,accountCompressionProgram:b,selfProgram:this.programId,systemProgram:C.programId});return k.push(...p),new T({programId:this.programId,keys:k,data:f})}static async revoke({payer:t,inputCompressedTokenAccounts:e,recentValidityProof:r,recentInputStateRootIndices:o}){Xn(e);const{inputTokenDataWithContext:i,remainingAccountMetas:s}=mn({inputCompressedTokenAccounts:e,rootIndices:o,tokenTransferOutputs:[]}),{mint:a,currentOwner:c}=Jn(e),p=jn({proof:r,mint:a,inputTokenDataWithContext:i,cpiContext:null,outputAccountMerkleTreeIndex:e[0].compressedAccount.treeInfo.treeType===n.StateV2?2:1}),{accountCompressionAuthority:d,noopProgram:h,registeredProgramPda:m,accountCompressionProgram:f}=u(),g=Rn({feePayer:t,authority:c,cpiAuthorityPda:this.deriveCpiAuthorityPda,lightSystemProgram:l.programId,registeredProgramPda:m,noopProgram:h,accountCompressionAuthority:d,accountCompressionProgram:f,selfProgram:this.programId,systemProgram:C.programId});return g.push(...s),new T({programId:this.programId,keys:g,data:p})}}function or(t,e){const n=f(sr(t)[0].toBytes(),e.tree,g);return Array.from(n.toBytes())}const ir=Tt.from([99,111,109,112,114,101,115,115,101,100,95,109,105,110,116]);function sr(t){const[e,n]=x.findProgramAddressSync([ir,t.toBuffer()],g);return[e,n]}function ar(t,e){return x.findProgramAddressSync([t.toBuffer(),g.toBuffer(),e.toBuffer()],g)}function ur(t,e){return x.findProgramAddressSync([t.toBuffer(),g.toBuffer(),e.toBuffer()],g)[0]}const cr=Tt.from([103]),lr=nt([it("recipient"),st("amount")]),pr=nt([ot("tokenAccountVersion"),dt(lr,"recipients")]),dr=nt([at(it(),"newAuthority")]),hr=nt([ot("accountIndex"),st("amount")]),mr=nt([ot("extensionIndex"),ot("fieldType"),ut("key"),ut("value")]),fr=nt([ot("extensionIndex"),it("newAuthority")]),gr=nt([ot("extensionIndex"),ut("key"),ot("idempotent")]),yr=nt([ot("rentPayment"),ct("writeTopUp")]),wr=nt([ot("idempotent")]),br=ht([pr.replicate("mintToCompressed"),dr.replicate("updateMintAuthority"),dr.replicate("updateFreezeAuthority"),hr.replicate("mintToCToken"),mr.replicate("updateMetadataField"),fr.replicate("updateMetadataAuthority"),gr.replicate("removeMetadataKey"),yr.replicate("decompressMint"),wr.replicate("compressAndCloseCMint")]),kr=nt([rt(ot(),32,"a"),rt(ot(),64,"b"),rt(ot(),32,"c")]),Ir=nt([lt("setContext"),lt("firstSetContext"),ot("inTreeIndex"),ot("inQueueIndex"),ot("outQueueIndex"),ot("tokenOutQueueIndex"),ot("assignedAccountIndex"),rt(ot(),4,"readOnlyAddressTrees"),rt(ot(),32,"addressTreePubkey")]),vr=nt([rt(ot(),4,"readOnlyAddressTrees"),rt(pt(),4,"readOnlyAddressTreeRootIndices")]),Mr=nt([ut("key"),ut("value")]),Ar=nt([at(it(),"updateAuthority"),ut("name"),ut("symbol"),ut("uri"),at(dt(Mr),"additionalMetadata")]),Pr=nt([]),Sr=ht([Pr.replicate("placeholder0"),Pr.replicate("placeholder1"),Pr.replicate("placeholder2"),Pr.replicate("placeholder3"),Pr.replicate("placeholder4"),Pr.replicate("placeholder5"),Pr.replicate("placeholder6"),Pr.replicate("placeholder7"),Pr.replicate("placeholder8"),Pr.replicate("placeholder9"),Pr.replicate("placeholder10"),Pr.replicate("placeholder11"),Pr.replicate("placeholder12"),Pr.replicate("placeholder13"),Pr.replicate("placeholder14"),Pr.replicate("placeholder15"),Pr.replicate("placeholder16"),Pr.replicate("placeholder17"),Pr.replicate("placeholder18"),Ar.replicate("tokenMetadata")]),xr=nt([ot("version"),lt("cmintDecompressed"),it("mint"),rt(ot(),32,"mintSigner"),ot("bump")]),Cr=nt([st("supply"),ot("decimals"),xr.replicate("metadata"),at(it(),"mintAuthority"),at(it(),"freezeAuthority"),at(dt(Sr),"extensions")]),Tr=nt([ct("leafIndex"),lt("proveByIndex"),pt("rootIndex"),pt("maxTopUp"),at(vr,"createMint"),dt(br,"actions"),at(kr,"proof"),at(Ir,"cpiContext"),at(Cr,"mint")]);function Er(e){const n=e.actions.map((e=>"mintToCompressed"in e&&e.mintToCompressed?{mintToCompressed:{...e.mintToCompressed,recipients:e.mintToCompressed.recipients.map((e=>({...e,amount:t(e.amount.toString())})))}}:"mintToCToken"in e&&e.mintToCToken?{mintToCToken:{...e.mintToCToken,amount:t(e.mintToCToken.amount.toString())}}:e)),r=Tt.alloc(1e4),o={...e,actions:n,mint:e.mint?{...e.mint,supply:t(e.mint.supply.toString())}:null},i=Tr.encode(o,r);return Tt.concat([cr,r.subarray(0,i)])}function Br(t,e,n,r,o=null){return{name:t,symbol:e,uri:n,updateAuthority:r??null,additionalMetadata:o??null}}function Ur(t,e,n,r,o,i,s,a,c){return function(t,e,n,r,o,i){const s=u(),[a]=sr(t),c=[{pubkey:l.programId,isSigner:0,isWritable:0},{pubkey:t,isSigner:1,isWritable:0},{pubkey:e,isSigner:1,isWritable:0},{pubkey:me,isSigner:0,isWritable:0},{pubkey:a,isSigner:0,isWritable:1},{pubkey:fe,isSigner:0,isWritable:1},{pubkey:n,isSigner:1,isWritable:1},{pubkey:rr.deriveCpiAuthorityPda,isSigner:0,isWritable:0},{pubkey:s.registeredProgramPda,isSigner:0,isWritable:0},{pubkey:s.accountCompressionAuthority,isSigner:0,isWritable:0},{pubkey:s.accountCompressionProgram,isSigner:0,isWritable:0},{pubkey:C.programId,isSigner:0,isWritable:0},{pubkey:r.queue,isSigner:0,isWritable:1},{pubkey:o.tree,isSigner:0,isWritable:1}];return new T({programId:g,keys:c,data:i})}(t,n,o,a,s,function(t){const[e,n]=sr(t.mintSigner);let r=null;t.metadata&&(r=[{tokenMetadata:{updateAuthority:t.metadata.updateAuthority??null,name:Tt.from(t.metadata.name),symbol:Tt.from(t.metadata.symbol),uri:Tt.from(t.metadata.uri),additionalMetadata:t.metadata.additionalMetadata}}]);const o=function(t){if(!t)return null;if(32!==t.a.length)throw new Error(`Invalid proof.a length: expected 32, got ${t.a.length}`);if(64!==t.b.length)throw new Error(`Invalid proof.b length: expected 64, got ${t.b.length}`);if(32!==t.c.length)throw new Error(`Invalid proof.c length: expected 32, got ${t.c.length}`);return t}(t.proof);return Er({leafIndex:0,proveByIndex:0,rootIndex:t.rootIndex,maxTopUp:0,createMint:{readOnlyAddressTrees:[0,0,0,0],readOnlyAddressTreeRootIndices:[0,0,0,0]},actions:[{decompressMint:{rentPayment:16,writeTopUp:766}}],proof:o,cpiContext:null,mint:{supply:BigInt(0),decimals:t.decimals,metadata:{version:ge.ShaFlat,cmintDecompressed:0,mint:e,mintSigner:Array.from(t.mintSigner.toBytes()),bump:n},mintAuthority:t.mintAuthority,freezeAuthority:t.freezeAuthority,extensions:r}})}({mintSigner:t,mintAuthority:n,freezeAuthority:r,decimals:e,addressTree:s.tree,outputQueue:a.queue,rootIndex:i.rootIndices[0],proof:i.compressedProof,metadata:c}))}function _r(t){const e="mintAuthority"===t.actionType?{updateMintAuthority:{newAuthority:t.newAuthority}}:{updateFreezeAuthority:{newAuthority:t.newAuthority}},n=t.mintInterface.mintContext?.cmintDecompressed??0;let r=null;return!n&&t.mintInterface.tokenMetadata&&(r=[{tokenMetadata:{updateAuthority:t.mintInterface.tokenMetadata.updateAuthority??null,name:Tt.from(t.mintInterface.tokenMetadata.name),symbol:Tt.from(t.mintInterface.tokenMetadata.symbol),uri:Tt.from(t.mintInterface.tokenMetadata.uri),additionalMetadata:null}}]),Er({leafIndex:t.leafIndex,proveByIndex:t.proveByIndex,rootIndex:t.rootIndex,maxTopUp:0,createMint:null,actions:[e],proof:t.proof,cpiContext:null,mint:n?null:{supply:t.mintInterface.mint.supply,decimals:t.mintInterface.mint.decimals,metadata:{version:t.mintInterface.mintContext.version,cmintDecompressed:t.mintInterface.mintContext.cmintDecompressed,mint:t.mintInterface.mintContext.splMint,mintSigner:Array.from(t.mintInterface.mintContext.mintSigner),bump:t.mintInterface.mintContext.bump},mintAuthority:t.mintInterface.mint.mintAuthority,freezeAuthority:t.mintInterface.mint.freezeAuthority,extensions:r}})}function Lr(t,e,n,r,o){if(!t.merkleContext)throw new Error("MintInterface must have merkleContext for compressed mint operations");if(!t.mintContext)throw new Error("MintInterface must have mintContext for compressed mint operations");const i=t.merkleContext,s=y(i),a=t.mintContext.cmintDecompressed??0,c=w(),p=_r({splMint:t.mintContext.splMint,addressTree:c.tree,leafIndex:i.leafIndex,proveByIndex:1,rootIndex:o?.rootIndices[0]??0,proof:a?null:o?.compressedProof??null,mintInterface:t,newAuthority:n,actionType:"mintAuthority"}),d=u(),h=[{pubkey:l.programId,isSigner:0,isWritable:0},{pubkey:e,isSigner:1,isWritable:0},...a?[{pubkey:t.mint.address,isSigner:0,isWritable:1}]:[],{pubkey:r,isSigner:1,isWritable:1},{pubkey:rr.deriveCpiAuthorityPda,isSigner:0,isWritable:0},{pubkey:d.registeredProgramPda,isSigner:0,isWritable:0},{pubkey:d.accountCompressionAuthority,isSigner:0,isWritable:0},{pubkey:d.accountCompressionProgram,isSigner:0,isWritable:0},{pubkey:C.programId,isSigner:0,isWritable:0},{pubkey:s,isSigner:0,isWritable:1},{pubkey:i.treeInfo.tree,isSigner:0,isWritable:1},{pubkey:i.treeInfo.queue,isSigner:0,isWritable:1}];return new T({programId:g,keys:h,data:p})}function Wr(t,e,n,r,o){if(!t.merkleContext)throw new Error("MintInterface must have merkleContext for compressed mint operations");if(!t.mintContext)throw new Error("MintInterface must have mintContext for compressed mint operations");const i=t.merkleContext,s=y(i),a=t.mintContext.cmintDecompressed??0,c=w(),p=_r({splMint:t.mintContext.splMint,addressTree:c.tree,leafIndex:i.leafIndex,proveByIndex:1,rootIndex:o?.rootIndices[0]??0,proof:a?null:o?.compressedProof??null,mintInterface:t,newAuthority:n,actionType:"freezeAuthority"}),d=u(),h=[{pubkey:l.programId,isSigner:0,isWritable:0},{pubkey:e,isSigner:1,isWritable:0},...a?[{pubkey:t.mint.address,isSigner:0,isWritable:1}]:[],{pubkey:r,isSigner:1,isWritable:1},{pubkey:rr.deriveCpiAuthorityPda,isSigner:0,isWritable:0},{pubkey:d.registeredProgramPda,isSigner:0,isWritable:0},{pubkey:d.accountCompressionAuthority,isSigner:0,isWritable:0},{pubkey:d.accountCompressionProgram,isSigner:0,isWritable:0},{pubkey:C.programId,isSigner:0,isWritable:0},{pubkey:s,isSigner:0,isWritable:1},{pubkey:i.treeInfo.tree,isSigner:0,isWritable:1},{pubkey:i.treeInfo.queue,isSigner:0,isWritable:1}];return new T({programId:g,keys:h,data:p})}function Dr(t,e,n,r,o){if(!t.merkleContext)throw new Error("MintInterface must have merkleContext for compressed mint operations");if(!t.mintContext)throw new Error("MintInterface must have mintContext for compressed mint operations");if(!t.tokenMetadata)throw new Error("MintInterface must have tokenMetadata for metadata operations");const i=t.merkleContext,s=y(i),a=t.mintContext.cmintDecompressed??0,c=w(),p=function(t){const e=t.mintInterface;if(!e.tokenMetadata)throw new Error("MintInterface must have tokenMetadata for metadata operations");const n=e.mintContext?.cmintDecompressed??0;var r;return Er({leafIndex:t.leafIndex,proveByIndex:null===t.proof,rootIndex:t.rootIndex,maxTopUp:0,createMint:null,actions:[(r=t.action,"updateField"===r.type?{updateMetadataField:{extensionIndex:r.extensionIndex,fieldType:r.fieldType,key:Tt.from(r.key),value:Tt.from(r.value)}}:"updateAuthority"===r.type?{updateMetadataAuthority:{extensionIndex:r.extensionIndex,newAuthority:r.newAuthority}}:{removeMetadataKey:{extensionIndex:r.extensionIndex,key:Tt.from(r.key),idempotent:r.idempotent?1:0}})],proof:t.proof,cpiContext:null,mint:n?null:{supply:e.mint.supply,decimals:e.mint.decimals,metadata:{version:e.mintContext.version,cmintDecompressed:e.mintContext.cmintDecompressed,mint:e.mintContext.splMint,mintSigner:Array.from(e.mintContext.mintSigner),bump:e.mintContext.bump},mintAuthority:e.mint.mintAuthority,freezeAuthority:e.mint.freezeAuthority,extensions:[{tokenMetadata:{updateAuthority:e.tokenMetadata.updateAuthority??null,name:Tt.from(e.tokenMetadata.name),symbol:Tt.from(e.tokenMetadata.symbol),uri:Tt.from(e.tokenMetadata.uri),additionalMetadata:null}}]}})}({splMint:t.mintContext.splMint,addressTree:c.tree,leafIndex:i.leafIndex,rootIndex:r?.rootIndices[0]??0,proof:a?null:r?.compressedProof??null,mintInterface:t,action:o}),d=u(),h=[{pubkey:l.programId,isSigner:0,isWritable:0},{pubkey:e,isSigner:1,isWritable:0},...a?[{pubkey:t.mint.address,isSigner:0,isWritable:1}]:[],{pubkey:n,isSigner:1,isWritable:1},{pubkey:rr.deriveCpiAuthorityPda,isSigner:0,isWritable:0},{pubkey:d.registeredProgramPda,isSigner:0,isWritable:0},{pubkey:d.accountCompressionAuthority,isSigner:0,isWritable:0},{pubkey:d.accountCompressionProgram,isSigner:0,isWritable:0},{pubkey:C.programId,isSigner:0,isWritable:0},{pubkey:s,isSigner:0,isWritable:1},{pubkey:i.treeInfo.tree,isSigner:0,isWritable:1},{pubkey:i.treeInfo.queue,isSigner:0,isWritable:1}];return new T({programId:g,keys:h,data:p})}function Or(t,e,n,r,o,i,s,a=0){return Dr(t,e,n,r,{type:"updateField",extensionIndex:a,fieldType:"name"===o?0:"symbol"===o?1:"uri"===o?2:3,key:s||"",value:i})}function Rr(t,e,n,r,o,i=0){return Dr(t,e,r,o,{type:"updateAuthority",extensionIndex:i,newAuthority:n})}function qr(t,e,n,r,o,i=0,s=0){return Dr(t,e,n,r,{type:"removeKey",extensionIndex:s,key:o,idempotent:i})}const Kr=Tt.from([100]),Vr=Tt.from([102]),zr=nt([ot("bump"),rt(ot(),32,"programId"),dt(dt(ot()),"seeds")]),Fr=nt([ot("tokenAccountVersion"),ot("rentPayment"),ot("compressionOnly"),ct("writeTopUp"),at(zr,"compressToAccountPubkey")]),Nr=nt([at(Fr,"compressibleConfig")]),$r={tokenAccountVersion:3,rentPayment:16,compressionOnly:1,writeTopUp:766,compressToAccountPubkey:null};function Yr(t,e){return x.findProgramAddressSync([t.toBuffer(),g.toBuffer(),e.toBuffer()],g)[0]}function jr(t,e){const n=Tt.alloc(2e3),r=Nr.encode({compressibleConfig:t.compressibleConfig||null},n),o=e?Vr:Kr;return Tt.concat([o,n.subarray(0,r)])}function Hr(t,e,n,r=$r,o=me,i=fe){const s=Yr(e,n),a=jr({compressibleConfig:r},0),u=[{pubkey:e,isSigner:0,isWritable:0},{pubkey:n,isSigner:0,isWritable:0},{pubkey:t,isSigner:1,isWritable:1},{pubkey:s,isSigner:0,isWritable:1},{pubkey:C.programId,isSigner:0,isWritable:0}];return r&&u.push({pubkey:o,isSigner:0,isWritable:0},{pubkey:i,isSigner:0,isWritable:1}),new T({programId:g,keys:u,data:a})}function Zr(t,e,n,r=$r,o=me,i=fe){const s=Yr(e,n),a=jr({compressibleConfig:r},1),u=[{pubkey:e,isSigner:0,isWritable:0},{pubkey:n,isSigner:0,isWritable:0},{pubkey:t,isSigner:1,isWritable:1},{pubkey:s,isSigner:0,isWritable:1},{pubkey:C.programId,isSigner:0,isWritable:0}];return r&&u.push({pubkey:o,isSigner:0,isWritable:0},{pubkey:i,isSigner:0,isWritable:1}),new T({programId:g,keys:u,data:a})}function Gr(t){return t.equals(g)?g:V}function Qr(t,e,n,r,o=0){if(r){const i=z(e,n,o,r,Gr(r));if(t.equals(i))return{valid:1,type:Xr(r),programId:r};throw new Error(`ATA address mismatch for ${r.toBase58()}. Expected: ${i.toBase58()}, got: ${t.toBase58()}`)}let i,s,a;if(i=z(e,n,o,g,Gr(g)),t.equals(i))return{valid:1,type:"ctoken",programId:g};if(s=z(e,n,o,q,Gr(q)),t.equals(s))return{valid:1,type:"spl",programId:q};if(a=z(e,n,o,K,Gr(K)),t.equals(a))return{valid:1,type:"token2022",programId:K};throw new Error(`ATA address does not match any valid derivation from mint+owner. Got: ${t.toBase58()}, expected one of: c-token=${i.toBase58()}, SPL=${s.toBase58()}, T22=${a.toBase58()}`)}function Xr(t){if(t.equals(g))return"ctoken";if(t.equals(q))return"spl";if(t.equals(K))return"token2022";throw new Error(`Unknown program ID: ${t.toBase58()}`)}function Jr(t,e,n,r,o=q,i,s){const a=i??Gr(o);return o.equals(g)?Hr(t,n,r,s?.compressibleConfig,s?.configAccount,s?.rentPayerPda):F(t,e,n,r,o,a)}function to(t,e,n,r,o=q,i,s){const a=i??Gr(o);return o.equals(g)?Zr(t,n,r,s?.compressibleConfig,s?.configAccount,s?.rentPayerPda):N(t,e,n,r,o,a)}const eo=to;function no(t){const{mint:e,destination:n,amount:r,authority:o,maxTopUp:i,feePayer:s}=t,a=[{pubkey:e,isSigner:0,isWritable:1},{pubkey:n,isSigner:0,isWritable:1},{pubkey:o,isSigner:1,isWritable:void 0!==i&&!s},{pubkey:C.programId,isSigner:0,isWritable:0}];s&&a.push({pubkey:s,isSigner:1,isWritable:1});const u=BigInt(r.toString()),c=void 0!==i?11:9,l=Tt.alloc(c);return l.writeUInt8(7,0),l.writeBigUInt64LE(u,1),void 0!==i&&l.writeUInt16LE(i,9),new T({programId:g,keys:a,data:l})}function ro(t,e,n,r,o,i,s,a=ge.ShaFlat){const c=function(t){if(t.mintData.metadata)throw new Error("TokenMetadata extension not supported in mintTo instruction");return Er({leafIndex:t.leafIndex,proveByIndex:1,rootIndex:t.rootIndex,maxTopUp:0,createMint:null,actions:[{mintToCompressed:{tokenAccountVersion:t.tokenAccountVersion,recipients:t.recipients.map((t=>({recipient:t.recipient,amount:BigInt(t.amount.toString())})))}}],proof:t.proof,cpiContext:null,mint:{supply:t.mintData.supply,decimals:t.mintData.decimals,metadata:{version:t.mintData.version,cmintDecompressed:t.mintData.cmintDecompressed,mint:t.mintData.splMint,mintSigner:Array.from(t.mintData.mintSigner),bump:t.mintData.bump},mintAuthority:t.mintData.mintAuthority,freezeAuthority:t.mintData.freezeAuthority,extensions:null}})}({addressTree:w().tree,leafIndex:r.leafIndex,rootIndex:n.rootIndices[0],proof:n.compressedProof,mintData:o,recipients:i,tokenAccountVersion:a}),p=s?.queue??y(r),d=u(),h=[{pubkey:l.programId,isSigner:0,isWritable:0},{pubkey:t,isSigner:1,isWritable:0},{pubkey:e,isSigner:1,isWritable:1},{pubkey:rr.deriveCpiAuthorityPda,isSigner:0,isWritable:0},{pubkey:d.registeredProgramPda,isSigner:0,isWritable:0},{pubkey:d.accountCompressionAuthority,isSigner:0,isWritable:0},{pubkey:d.accountCompressionProgram,isSigner:0,isWritable:0},{pubkey:C.programId,isSigner:0,isWritable:0},{pubkey:p,isSigner:0,isWritable:1},{pubkey:r.treeInfo.tree,isSigner:0,isWritable:1},{pubkey:r.treeInfo.queue,isSigner:0,isWritable:1},{pubkey:p,isSigner:0,isWritable:1}];return new T({programId:g,keys:h,data:c})}function oo(t,e,n,r,o,i,s=[]){const a=t.mint.address,u=t.programId;if(!t.merkleContext)return R(a,e,n,BigInt(o.toString()),s,u);if(!t.mintContext)throw new Error("mintContext required for CToken mint-to");const c=n.equals(r)?void 0:r;return no({mint:a,destination:e,amount:o,authority:n,feePayer:c})}const io=3;function so(t,e,n,r,o){const i=Buffer.alloc(9);i.writeUInt8(io,0),i.writeBigUInt64LE(BigInt(r),1);const s=o??n,a=[{pubkey:t,isSigner:0,isWritable:1},{pubkey:e,isSigner:0,isWritable:1},{pubkey:n,isSigner:1,isWritable:1},{pubkey:C.programId,isSigner:0,isWritable:0},{pubkey:s,isSigner:!s.equals(n),isWritable:1}];return new T({programId:g,keys:a,data:i})}const ao=Tt.from([101]),uo=19,co=31,lo=32,po=0,ho=1,mo=nt([dt(ot(),"key"),dt(ot(),"value")]),fo=nt([at(rt(ot(),32),"updateAuthority"),dt(ot(),"name"),dt(ot(),"symbol"),dt(ot(),"uri"),at(dt(mo),"additionalMetadata")]),go=nt([st("delegatedAmount"),st("withheldTransferFee"),lt("isFrozen"),ot("compressionIndex"),lt("isAta"),ot("bump"),ot("ownerIndex")]);nt([ot("bump"),rt(ot(),32,"programId"),dt(dt(ot()),"seeds")]);const yo=nt([pt("baseRent"),pt("compressionCost"),ot("lamportsPerBytePerEpoch"),ot("maxFundedEpochs"),pt("maxTopUp")]),wo=nt([pt("configAccountVersion"),ot("compressToPubkey"),ot("accountVersion"),ct("lamportsPerWrite"),rt(ot(),32,"compressionAuthority"),rt(ot(),32,"rentSponsor"),st("lastClaimedSlot"),ct("rentExemptionPaid"),ct("reserved"),yo.replicate("rentConfig")]);function bo(e){const n=Tt.alloc(1024);let r=0;if("TokenMetadata"===e.type){n.writeUInt8(uo,r),r+=1;const t={updateAuthority:e.data.updateAuthority?Array.from(e.data.updateAuthority.toBytes()):null,name:Array.from(e.data.name),symbol:Array.from(e.data.symbol),uri:Array.from(e.data.uri),additionalMetadata:e.data.additionalMetadata?e.data.additionalMetadata.map((t=>({key:Array.from(t.key),value:Array.from(t.value)}))):null};r+=fo.encode(t,n,r)}else if("CompressedOnly"===e.type){n.writeUInt8(co,r),r+=1;const o={delegatedAmount:t(e.data.delegatedAmount.toString()),withheldTransferFee:t(e.data.withheldTransferFee.toString()),isFrozen:e.data.isFrozen,compressionIndex:e.data.compressionIndex,isAta:e.data.isAta,bump:e.data.bump,ownerIndex:e.data.ownerIndex};r+=go.encode(o,n,r)}else if("Compressible"===e.type){n.writeUInt8(lo,r),r+=1;const o={configAccountVersion:e.data.configAccountVersion,compressToPubkey:e.data.compressToPubkey,accountVersion:e.data.accountVersion,lamportsPerWrite:e.data.lamportsPerWrite,compressionAuthority:Array.from(e.data.compressionAuthority.toBytes()),rentSponsor:Array.from(e.data.rentSponsor.toBytes()),lastClaimedSlot:t(e.data.lastClaimedSlot.toString()),rentExemptionPaid:e.data.rentExemptionPaid,reserved:e.data.reserved,rentConfig:e.data.rentConfig};r+=wo.encode(o,n,r)}return n.subarray(0,r)}function ko(t){if(null===t)return null;const e=[],n=Tt.alloc(4);n.writeUInt32LE(t.length,0),e.push(n);for(const n of t){const t=Tt.alloc(4);t.writeUInt32LE(n.length,0),e.push(t);for(const t of n)e.push(bo(t))}return Tt.concat(e)}const Io=nt([ot("mode"),st("amount"),ot("mint"),ot("sourceOrRecipient"),ot("authority"),ot("poolAccountIndex"),ot("poolIndex"),ot("bump"),ot("decimals")]),vo=nt([ot("merkleTreePubkeyIndex"),ot("queuePubkeyIndex"),ct("leafIndex"),lt("proveByIndex")]),Mo=nt([ot("owner"),st("amount"),lt("hasDelegate"),ot("delegate"),ot("mint"),ot("version"),vo.replicate("merkleContext"),pt("rootIndex")]),Ao=nt([ot("owner"),st("amount"),lt("hasDelegate"),ot("delegate"),ot("mint"),ot("version")]),Po=nt([lt("setContext"),lt("firstSetContext"),ot("cpiContextAccountIndex")]),So=nt([rt(ot(),32,"a"),rt(ot(),64,"b"),rt(ot(),32,"c")]),xo=nt([lt("withTransactionHash"),lt("withLamportsChangeAccountMerkleTreeIndex"),ot("lamportsChangeAccountMerkleTreeIndex"),ot("lamportsChangeAccountOwnerIndex"),ot("outputQueue"),pt("maxTopUp"),at(Po,"cpiContext"),at(dt(Io),"compressions"),at(So,"proof"),dt(Mo,"inTokenData"),dt(Ao,"outTokenData"),at(dt(st()),"inLamports"),at(dt(st()),"outLamports")]);function Co(e){const n={withTransactionHash:e.withTransactionHash,withLamportsChangeAccountMerkleTreeIndex:e.withLamportsChangeAccountMerkleTreeIndex,lamportsChangeAccountMerkleTreeIndex:e.lamportsChangeAccountMerkleTreeIndex,lamportsChangeAccountOwnerIndex:e.lamportsChangeAccountOwnerIndex,outputQueue:e.outputQueue,maxTopUp:e.maxTopUp,cpiContext:e.cpiContext,compressions:e.compressions?.map((e=>({...e,amount:t(e.amount.toString())})))??null,proof:e.proof,inTokenData:e.inTokenData.map((e=>({...e,amount:t(e.amount.toString())}))),outTokenData:e.outTokenData.map((e=>({...e,amount:t(e.amount.toString())}))),inLamports:e.inLamports?.map((e=>t(e.toString())))??null,outLamports:e.outLamports?.map((e=>t(e.toString())))??null},r=Tt.alloc(4e3),o=xo.encode(n,r),i=[ao,r.subarray(0,o)];if(null===e.inTlv)i.push(Tt.from([0]));else{i.push(Tt.from([1]));const t=ko(e.inTlv);t&&i.push(Tt.from(t))}if(null===e.outTlv)i.push(Tt.from([0]));else{i.push(Tt.from([1]));const t=ko(e.outTlv);t&&i.push(Tt.from(t))}return Tt.concat(i)}function To(t,e,n,r,o,i,s,a){return{mode:po,amount:t,mint:e,sourceOrRecipient:n,authority:r,poolAccountIndex:o,poolIndex:i,bump:s,decimals:a}}function Eo(t,e,n,r){return{mode:ho,amount:t,mint:e,sourceOrRecipient:n,authority:0,poolAccountIndex:r,poolIndex:0,bump:0,decimals:0}}function Bo(t,e,n,r,o){return{mode:po,amount:t,mint:e,sourceOrRecipient:n,authority:r,poolAccountIndex:o,poolIndex:0,bump:0,decimals:0}}function Uo(t,e,n,r,o,i,s){return{mode:ho,amount:t,mint:e,sourceOrRecipient:n,authority:0,poolAccountIndex:r,poolIndex:o,bump:i,decimals:s}}function _o(t){return!t||t.length<8?ge.ShaFlat:2===t[0]?ge.V1:3===t[7]?ge.V2:ge.ShaFlat}function Lo(t,e,n,r,o,i,s){if(0===e.length)throw new Error("No input compressed token accounts provided");const a=e[0].parsed.mint,c=e[0].parsed.owner,p=new Map,d=[],h=new Set,m=new Set;for(const t of e)h.add(t.compressedAccount.treeInfo.tree.toBase58()),m.add(t.compressedAccount.treeInfo.queue.toBase58());for(const t of h)p.set(t,d.length),d.push(new x(t));let f=0,g=1;for(const t of m)g&&(f=d.length,g=0),p.set(t,d.length),d.push(new x(t));const y=d.length;p.set(a.toBase58(),y),d.push(a);const w=d.length;p.set(c.toBase58(),w),d.push(c);const b=d.length;p.set(n.toBase58(),b),d.push(n);for(const t of e)if(t.parsed.delegate){const e=t.parsed.delegate.toBase58();p.has(e)||(p.set(e,d.length),d.push(t.parsed.delegate))}let k=0,I=0,v=0,M=0;i&&(k=d.length,p.set(i.splInterfacePda.toBase58(),k),d.push(i.splInterfacePda),M=d.length,p.set(i.tokenProgram.toBase58(),M),d.push(i.tokenProgram),I=i.poolIndex,v=i.bump);const A=function(t,e,n){return t.map(((t,r)=>{const o=t.parsed.owner.toBase58(),i=t.parsed.mint.toBase58(),s=_o(t.compressedAccount.data?.discriminator);return{owner:n.get(o),amount:BigInt(t.parsed.amount.toString()),hasDelegate:null!==t.parsed.delegate,delegate:t.parsed.delegate?n.get(t.parsed.delegate.toBase58())??0:0,mint:n.get(i),version:s,merkleContext:{merkleTreePubkeyIndex:n.get(t.compressedAccount.treeInfo.tree.toBase58()),queuePubkeyIndex:n.get(t.compressedAccount.treeInfo.queue.toBase58()),leafIndex:t.compressedAccount.leafIndex,proveByIndex:t.compressedAccount.proveByIndex},rootIndex:e[r]}}))}(e,o.rootIndices,p),P=e.reduce(((t,e)=>t+BigInt(e.parsed.amount.toString())),BigInt(0))-r,S=[];if(P>0){const t=_o(e[0].compressedAccount.data?.discriminator);S.push({owner:w,amount:P,hasDelegate:0,delegate:0,mint:y,version:t})}const E=Co({withTransactionHash:0,withLamportsChangeAccountMerkleTreeIndex:0,lamportsChangeAccountMerkleTreeIndex:0,lamportsChangeAccountOwnerIndex:0,outputQueue:f,maxTopUp:0,cpiContext:null,compressions:[{mode:ho,amount:r,mint:y,sourceOrRecipient:b,authority:0,poolAccountIndex:i?k:0,poolIndex:i?I:0,bump:i?v:0,decimals:s}],proof:o.compressedProof?{a:Array.from(o.compressedProof.a),b:Array.from(o.compressedProof.b),c:Array.from(o.compressedProof.c)}:null,inTokenData:A,outTokenData:S,inLamports:null,outLamports:null,inTlv:null,outTlv:null}),{accountCompressionAuthority:B,registeredProgramPda:U,accountCompressionProgram:_}=u(),L=[{pubkey:l.programId,isSigner:0,isWritable:0},{pubkey:t,isSigner:1,isWritable:1},{pubkey:rr.deriveCpiAuthorityPda,isSigner:0,isWritable:0},{pubkey:U,isSigner:0,isWritable:0},{pubkey:B,isSigner:0,isWritable:0},{pubkey:_,isSigner:0,isWritable:0},{pubkey:C.programId,isSigner:0,isWritable:0},...d.map(((t,e)=>{const r=e<h.size+m.size,o=t.equals(n),s=void 0!==i&&t.equals(i.splInterfacePda);return{pubkey:t,isSigner:e===w,isWritable:r||o||s}}))];return new T({programId:rr.programId,keys:L,data:E})}var Wo="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function Do(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function Oo(t){if(t.__esModule)return t;var e=t.default;if("function"==typeof e){var n=function t(){return this instanceof t?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};n.prototype=e.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:1}),Object.keys(t).forEach((function(e){var r=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(n,e,r.get?r:{enumerable:1,get:function(){return t[e]}})})),n}var Ro={exports:{}},qo=Oo(he);!function(t,e){function n(t,e){if(!t)throw new Error(e||"Assertion failed")}function r(t,e){t.super_=e;var n=function(){};n.prototype=e.prototype,t.prototype=new n,t.prototype.constructor=t}function o(t,e,n){if(o.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==e&&"be"!==e||(n=e,e=10),this._init(t||0,e||10,n||"be"))}var i;"object"==typeof Ro?Ro.exports=o:e.BN=o,o.BN=o,o.wordSize=26;try{i="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:qo.Buffer}catch(t){}function s(t,e){var r=t.charCodeAt(e);return r>=48&&r<=57?r-48:r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:void n(0,"Invalid character in "+t)}function a(t,e,n){var r=s(t,n);return n-1>=e&&(r|=s(t,n-1)<<4),r}function u(t,e,r,o){for(var i=0,s=0,a=Math.min(t.length,r),u=e;u<a;u++){var c=t.charCodeAt(u)-48;i*=o,s=c>=49?c-49+10:c>=17?c-17+10:c,n(c>=0&&s<o,"Invalid character"),i+=s}return i}function c(t,e){t.words=e.words,t.length=e.length,t.negative=e.negative,t.red=e.red}if(o.isBN=function(t){return t instanceof o?1:null!==t&&"object"==typeof t&&t.constructor.wordSize===o.wordSize&&Array.isArray(t.words)},o.max=function(t,e){return t.cmp(e)>0?t:e},o.min=function(t,e){return t.cmp(e)<0?t:e},o.prototype._init=function(t,e,r){if("number"==typeof t)return this._initNumber(t,e,r);if("object"==typeof t)return this._initArray(t,e,r);"hex"===e&&(e=16),n(e===(0|e)&&e>=2&&e<=36);var o=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&(o++,this.negative=1),o<t.length&&(16===e?this._parseHex(t,o,r):(this._parseBase(t,e,o),"le"===r&&this._initArray(this.toArray(),e,r)))},o.prototype._initNumber=function(t,e,r){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(n(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===r&&this._initArray(this.toArray(),e,r)},o.prototype._initArray=function(t,e,r){if(n("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var o=0;o<this.length;o++)this.words[o]=0;var i,s,a=0;if("be"===r)for(o=t.length-1,i=0;o>=0;o-=3)s=t[o]|t[o-1]<<8|t[o-2]<<16,this.words[i]|=s<<a&67108863,this.words[i+1]=s>>>26-a&67108863,(a+=24)>=26&&(a-=26,i++);else if("le"===r)for(o=0,i=0;o<t.length;o+=3)s=t[o]|t[o+1]<<8|t[o+2]<<16,this.words[i]|=s<<a&67108863,this.words[i+1]=s>>>26-a&67108863,(a+=24)>=26&&(a-=26,i++);return this._strip()},o.prototype._parseHex=function(t,e,n){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var r=0;r<this.length;r++)this.words[r]=0;var o,i=0,s=0;if("be"===n)for(r=t.length-1;r>=e;r-=2)o=a(t,e,r)<<i,this.words[s]|=67108863&o,i>=18?(i-=18,s+=1,this.words[s]|=o>>>26):i+=8;else for(r=(t.length-e)%2==0?e+1:e;r<t.length;r+=2)o=a(t,e,r)<<i,this.words[s]|=67108863&o,i>=18?(i-=18,s+=1,this.words[s]|=o>>>26):i+=8;this._strip()},o.prototype._parseBase=function(t,e,n){this.words=[0],this.length=1;for(var r=0,o=1;o<=67108863;o*=e)r++;r--,o=o/e|0;for(var i=t.length-n,s=i%r,a=Math.min(i,i-s)+n,c=0,l=n;l<a;l+=r)c=u(t,l,l+r,e),this.imuln(o),this.words[0]+c<67108864?this.words[0]+=c:this._iaddn(c);if(0!==s){var p=1;for(c=u(t,l,t.length,e),l=0;l<s;l++)p*=e;this.imuln(p),this.words[0]+c<67108864?this.words[0]+=c:this._iaddn(c)}this._strip()},o.prototype.copy=function(t){t.words=new Array(this.length);for(var e=0;e<this.length;e++)t.words[e]=this.words[e];t.length=this.length,t.negative=this.negative,t.red=this.red},o.prototype._move=function(t){c(t,this)},o.prototype.clone=function(){var t=new o(null);return this.copy(t),t},o.prototype._expand=function(t){for(;this.length<t;)this.words[this.length++]=0;return this},o.prototype._strip=function(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign()},o.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},"undefined"!=typeof Symbol&&"function"==typeof Symbol.for)try{o.prototype[Symbol.for("nodejs.util.inspect.custom")]=l}catch(t){o.prototype.inspect=l}else o.prototype.inspect=l;function l(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var p=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],d=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],h=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function m(t,e,n){n.negative=e.negative^t.negative;var r=t.length+e.length|0;n.length=r,r=r-1|0;var o=0|t.words[0],i=0|e.words[0],s=o*i,a=67108863&s,u=s/67108864|0;n.words[0]=a;for(var c=1;c<r;c++){for(var l=u>>>26,p=67108863&u,d=Math.min(c,e.length-1),h=Math.max(0,c-t.length+1);h<=d;h++){var m=c-h|0;l+=(s=(o=0|t.words[m])*(i=0|e.words[h])+p)/67108864|0,p=67108863&s}n.words[c]=0|p,u=0|l}return 0!==u?n.words[c]=0|u:n.length--,n._strip()}o.prototype.toString=function(t,e){var r;if(e=0|e||1,16===(t=t||10)||"hex"===t){r="";for(var o=0,i=0,s=0;s<this.length;s++){var a=this.words[s],u=(16777215&(a<<o|i)).toString(16);i=a>>>24-o&16777215,(o+=2)>=26&&(o-=26,s--),r=0!==i||s!==this.length-1?p[6-u.length]+u+r:u+r}for(0!==i&&(r=i.toString(16)+r);r.length%e!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}if(t===(0|t)&&t>=2&&t<=36){var c=d[t],l=h[t];r="";var m=this.clone();for(m.negative=0;!m.isZero();){var f=m.modrn(l).toString(t);r=(m=m.idivn(l)).isZero()?f+r:p[c-f.length]+f+r}for(this.isZero()&&(r="0"+r);r.length%e!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}n(0,"Base should be between 2 and 36")},o.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&n(0,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},o.prototype.toJSON=function(){return this.toString(16,2)},i&&(o.prototype.toBuffer=function(t,e){return this.toArrayLike(i,t,e)}),o.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},o.prototype.toArrayLike=function(t,e,r){this._strip();var o=this.byteLength(),i=r||Math.max(1,o);n(o<=i,"byte array longer than desired length"),n(i>0,"Requested array length <= 0");var s=function(t,e){return t.allocUnsafe?t.allocUnsafe(e):new t(e)}(t,i);return this["_toArrayLike"+("le"===e?"LE":"BE")](s,o),s},o.prototype._toArrayLikeLE=function(t){for(var e=0,n=0,r=0,o=0;r<this.length;r++){var i=this.words[r]<<o|n;t[e++]=255&i,e<t.length&&(t[e++]=i>>8&255),e<t.length&&(t[e++]=i>>16&255),6===o?(e<t.length&&(t[e++]=i>>24&255),n=0,o=0):(n=i>>>24,o+=2)}if(e<t.length)for(t[e++]=n;e<t.length;)t[e++]=0},o.prototype._toArrayLikeBE=function(t){for(var e=t.length-1,n=0,r=0,o=0;r<this.length;r++){var i=this.words[r]<<o|n;t[e--]=255&i,e>=0&&(t[e--]=i>>8&255),e>=0&&(t[e--]=i>>16&255),6===o?(e>=0&&(t[e--]=i>>24&255),n=0,o=0):(n=i>>>24,o+=2)}if(e>=0)for(t[e--]=n;e>=0;)t[e--]=0},Math.clz32?o.prototype._countBits=function(t){return 32-Math.clz32(t)}:o.prototype._countBits=function(t){var e=t,n=0;return e>=4096&&(n+=13,e>>>=13),e>=64&&(n+=7,e>>>=7),e>=8&&(n+=4,e>>>=4),e>=2&&(n+=2,e>>>=2),n+e},o.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,n=0;return 0==(8191&e)&&(n+=13,e>>>=13),0==(127&e)&&(n+=7,e>>>=7),0==(15&e)&&(n+=4,e>>>=4),0==(3&e)&&(n+=2,e>>>=2),0==(1&e)&&n++,n},o.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},o.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;e<this.length;e++){var n=this._zeroBits(this.words[e]);if(t+=n,26!==n)break}return t},o.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},o.prototype.toTwos=function(t){return 0!==this.negative?this.abs().inotn(t).iaddn(1):this.clone()},o.prototype.fromTwos=function(t){return this.testn(t-1)?this.notn(t).iaddn(1).ineg():this.clone()},o.prototype.isNeg=function(){return 0!==this.negative},o.prototype.neg=function(){return this.clone().ineg()},o.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},o.prototype.iuor=function(t){for(;this.length<t.length;)this.words[this.length++]=0;for(var e=0;e<t.length;e++)this.words[e]=this.words[e]|t.words[e];return this._strip()},o.prototype.ior=function(t){return n(0==(this.negative|t.negative)),this.iuor(t)},o.prototype.or=function(t){return this.length>t.length?this.clone().ior(t):t.clone().ior(this)},o.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},o.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var n=0;n<e.length;n++)this.words[n]=this.words[n]&t.words[n];return this.length=e.length,this._strip()},o.prototype.iand=function(t){return n(0==(this.negative|t.negative)),this.iuand(t)},o.prototype.and=function(t){return this.length>t.length?this.clone().iand(t):t.clone().iand(this)},o.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},o.prototype.iuxor=function(t){var e,n;this.length>t.length?(e=this,n=t):(e=t,n=this);for(var r=0;r<n.length;r++)this.words[r]=e.words[r]^n.words[r];if(this!==e)for(;r<e.length;r++)this.words[r]=e.words[r];return this.length=e.length,this._strip()},o.prototype.ixor=function(t){return n(0==(this.negative|t.negative)),this.iuxor(t)},o.prototype.xor=function(t){return this.length>t.length?this.clone().ixor(t):t.clone().ixor(this)},o.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},o.prototype.inotn=function(t){n("number"==typeof t&&t>=0);var e=0|Math.ceil(t/26),r=t%26;this._expand(e),r>0&&e--;for(var o=0;o<e;o++)this.words[o]=67108863&~this.words[o];return r>0&&(this.words[o]=~this.words[o]&67108863>>26-r),this._strip()},o.prototype.notn=function(t){return this.clone().inotn(t)},o.prototype.setn=function(t,e){n("number"==typeof t&&t>=0);var r=t/26|0,o=t%26;return this._expand(r+1),this.words[r]=e?this.words[r]|1<<o:this.words[r]&~(1<<o),this._strip()},o.prototype.iadd=function(t){var e,n,r;if(0!==this.negative&&0===t.negative)return this.negative=0,e=this.isub(t),this.negative^=1,this._normSign();if(0===this.negative&&0!==t.negative)return t.negative=0,e=this.isub(t),t.negative=1,e._normSign();this.length>t.length?(n=this,r=t):(n=t,r=this);for(var o=0,i=0;i<r.length;i++)e=(0|n.words[i])+(0|r.words[i])+o,this.words[i]=67108863&e,o=e>>>26;for(;0!==o&&i<n.length;i++)e=(0|n.words[i])+o,this.words[i]=67108863&e,o=e>>>26;if(this.length=n.length,0!==o)this.words[this.length]=o,this.length++;else if(n!==this)for(;i<n.length;i++)this.words[i]=n.words[i];return this},o.prototype.add=function(t){var e;return 0!==t.negative&&0===this.negative?(t.negative=0,e=this.sub(t),t.negative^=1,e):0===t.negative&&0!==this.negative?(this.negative=0,e=t.sub(this),this.negative=1,e):this.length>t.length?this.clone().iadd(t):t.clone().iadd(this)},o.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var n,r,o=this.cmp(t);if(0===o)return this.negative=0,this.length=1,this.words[0]=0,this;o>0?(n=this,r=t):(n=t,r=this);for(var i=0,s=0;s<r.length;s++)i=(e=(0|n.words[s])-(0|r.words[s])+i)>>26,this.words[s]=67108863&e;for(;0!==i&&s<n.length;s++)i=(e=(0|n.words[s])+i)>>26,this.words[s]=67108863&e;if(0===i&&s<n.length&&n!==this)for(;s<n.length;s++)this.words[s]=n.words[s];return this.length=Math.max(this.length,s),n!==this&&(this.negative=1),this._strip()},o.prototype.sub=function(t){return this.clone().isub(t)};var f=function(t,e,n){var r,o,i,s=t.words,a=e.words,u=n.words,c=0,l=0|s[0],p=8191&l,d=l>>>13,h=0|s[1],m=8191&h,f=h>>>13,g=0|s[2],y=8191&g,w=g>>>13,b=0|s[3],k=8191&b,I=b>>>13,v=0|s[4],M=8191&v,A=v>>>13,P=0|s[5],S=8191&P,x=P>>>13,C=0|s[6],T=8191&C,E=C>>>13,B=0|s[7],U=8191&B,_=B>>>13,L=0|s[8],W=8191&L,D=L>>>13,O=0|s[9],R=8191&O,q=O>>>13,K=0|a[0],V=8191&K,z=K>>>13,F=0|a[1],N=8191&F,$=F>>>13,Y=0|a[2],j=8191&Y,H=Y>>>13,Z=0|a[3],G=8191&Z,Q=Z>>>13,X=0|a[4],J=8191&X,tt=X>>>13,et=0|a[5],nt=8191&et,rt=et>>>13,ot=0|a[6],it=8191&ot,st=ot>>>13,at=0|a[7],ut=8191&at,ct=at>>>13,lt=0|a[8],pt=8191&lt,dt=lt>>>13,ht=0|a[9],mt=8191&ht,ft=ht>>>13;n.negative=t.negative^e.negative,n.length=19;var gt=(c+(r=Math.imul(p,V))|0)+((8191&(o=(o=Math.imul(p,z))+Math.imul(d,V)|0))<<13)|0;c=((i=Math.imul(d,z))+(o>>>13)|0)+(gt>>>26)|0,gt&=67108863,r=Math.imul(m,V),o=(o=Math.imul(m,z))+Math.imul(f,V)|0,i=Math.imul(f,z);var yt=(c+(r=r+Math.imul(p,N)|0)|0)+((8191&(o=(o=o+Math.imul(p,$)|0)+Math.imul(d,N)|0))<<13)|0;c=((i=i+Math.imul(d,$)|0)+(o>>>13)|0)+(yt>>>26)|0,yt&=67108863,r=Math.imul(y,V),o=(o=Math.imul(y,z))+Math.imul(w,V)|0,i=Math.imul(w,z),r=r+Math.imul(m,N)|0,o=(o=o+Math.imul(m,$)|0)+Math.imul(f,N)|0,i=i+Math.imul(f,$)|0;var wt=(c+(r=r+Math.imul(p,j)|0)|0)+((8191&(o=(o=o+Math.imul(p,H)|0)+Math.imul(d,j)|0))<<13)|0;c=((i=i+Math.imul(d,H)|0)+(o>>>13)|0)+(wt>>>26)|0,wt&=67108863,r=Math.imul(k,V),o=(o=Math.imul(k,z))+Math.imul(I,V)|0,i=Math.imul(I,z),r=r+Math.imul(y,N)|0,o=(o=o+Math.imul(y,$)|0)+Math.imul(w,N)|0,i=i+Math.imul(w,$)|0,r=r+Math.imul(m,j)|0,o=(o=o+Math.imul(m,H)|0)+Math.imul(f,j)|0,i=i+Math.imul(f,H)|0;var bt=(c+(r=r+Math.imul(p,G)|0)|0)+((8191&(o=(o=o+Math.imul(p,Q)|0)+Math.imul(d,G)|0))<<13)|0;c=((i=i+Math.imul(d,Q)|0)+(o>>>13)|0)+(bt>>>26)|0,bt&=67108863,r=Math.imul(M,V),o=(o=Math.imul(M,z))+Math.imul(A,V)|0,i=Math.imul(A,z),r=r+Math.imul(k,N)|0,o=(o=o+Math.imul(k,$)|0)+Math.imul(I,N)|0,i=i+Math.imul(I,$)|0,r=r+Math.imul(y,j)|0,o=(o=o+Math.imul(y,H)|0)+Math.imul(w,j)|0,i=i+Math.imul(w,H)|0,r=r+Math.imul(m,G)|0,o=(o=o+Math.imul(m,Q)|0)+Math.imul(f,G)|0,i=i+Math.imul(f,Q)|0;var kt=(c+(r=r+Math.imul(p,J)|0)|0)+((8191&(o=(o=o+Math.imul(p,tt)|0)+Math.imul(d,J)|0))<<13)|0;c=((i=i+Math.imul(d,tt)|0)+(o>>>13)|0)+(kt>>>26)|0,kt&=67108863,r=Math.imul(S,V),o=(o=Math.imul(S,z))+Math.imul(x,V)|0,i=Math.imul(x,z),r=r+Math.imul(M,N)|0,o=(o=o+Math.imul(M,$)|0)+Math.imul(A,N)|0,i=i+Math.imul(A,$)|0,r=r+Math.imul(k,j)|0,o=(o=o+Math.imul(k,H)|0)+Math.imul(I,j)|0,i=i+Math.imul(I,H)|0,r=r+Math.imul(y,G)|0,o=(o=o+Math.imul(y,Q)|0)+Math.imul(w,G)|0,i=i+Math.imul(w,Q)|0,r=r+Math.imul(m,J)|0,o=(o=o+Math.imul(m,tt)|0)+Math.imul(f,J)|0,i=i+Math.imul(f,tt)|0;var It=(c+(r=r+Math.imul(p,nt)|0)|0)+((8191&(o=(o=o+Math.imul(p,rt)|0)+Math.imul(d,nt)|0))<<13)|0;c=((i=i+Math.imul(d,rt)|0)+(o>>>13)|0)+(It>>>26)|0,It&=67108863,r=Math.imul(T,V),o=(o=Math.imul(T,z))+Math.imul(E,V)|0,i=Math.imul(E,z),r=r+Math.imul(S,N)|0,o=(o=o+Math.imul(S,$)|0)+Math.imul(x,N)|0,i=i+Math.imul(x,$)|0,r=r+Math.imul(M,j)|0,o=(o=o+Math.imul(M,H)|0)+Math.imul(A,j)|0,i=i+Math.imul(A,H)|0,r=r+Math.imul(k,G)|0,o=(o=o+Math.imul(k,Q)|0)+Math.imul(I,G)|0,i=i+Math.imul(I,Q)|0,r=r+Math.imul(y,J)|0,o=(o=o+Math.imul(y,tt)|0)+Math.imul(w,J)|0,i=i+Math.imul(w,tt)|0,r=r+Math.imul(m,nt)|0,o=(o=o+Math.imul(m,rt)|0)+Math.imul(f,nt)|0,i=i+Math.imul(f,rt)|0;var vt=(c+(r=r+Math.imul(p,it)|0)|0)+((8191&(o=(o=o+Math.imul(p,st)|0)+Math.imul(d,it)|0))<<13)|0;c=((i=i+Math.imul(d,st)|0)+(o>>>13)|0)+(vt>>>26)|0,vt&=67108863,r=Math.imul(U,V),o=(o=Math.imul(U,z))+Math.imul(_,V)|0,i=Math.imul(_,z),r=r+Math.imul(T,N)|0,o=(o=o+Math.imul(T,$)|0)+Math.imul(E,N)|0,i=i+Math.imul(E,$)|0,r=r+Math.imul(S,j)|0,o=(o=o+Math.imul(S,H)|0)+Math.imul(x,j)|0,i=i+Math.imul(x,H)|0,r=r+Math.imul(M,G)|0,o=(o=o+Math.imul(M,Q)|0)+Math.imul(A,G)|0,i=i+Math.imul(A,Q)|0,r=r+Math.imul(k,J)|0,o=(o=o+Math.imul(k,tt)|0)+Math.imul(I,J)|0,i=i+Math.imul(I,tt)|0,r=r+Math.imul(y,nt)|0,o=(o=o+Math.imul(y,rt)|0)+Math.imul(w,nt)|0,i=i+Math.imul(w,rt)|0,r=r+Math.imul(m,it)|0,o=(o=o+Math.imul(m,st)|0)+Math.imul(f,it)|0,i=i+Math.imul(f,st)|0;var Mt=(c+(r=r+Math.imul(p,ut)|0)|0)+((8191&(o=(o=o+Math.imul(p,ct)|0)+Math.imul(d,ut)|0))<<13)|0;c=((i=i+Math.imul(d,ct)|0)+(o>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,r=Math.imul(W,V),o=(o=Math.imul(W,z))+Math.imul(D,V)|0,i=Math.imul(D,z),r=r+Math.imul(U,N)|0,o=(o=o+Math.imul(U,$)|0)+Math.imul(_,N)|0,i=i+Math.imul(_,$)|0,r=r+Math.imul(T,j)|0,o=(o=o+Math.imul(T,H)|0)+Math.imul(E,j)|0,i=i+Math.imul(E,H)|0,r=r+Math.imul(S,G)|0,o=(o=o+Math.imul(S,Q)|0)+Math.imul(x,G)|0,i=i+Math.imul(x,Q)|0,r=r+Math.imul(M,J)|0,o=(o=o+Math.imul(M,tt)|0)+Math.imul(A,J)|0,i=i+Math.imul(A,tt)|0,r=r+Math.imul(k,nt)|0,o=(o=o+Math.imul(k,rt)|0)+Math.imul(I,nt)|0,i=i+Math.imul(I,rt)|0,r=r+Math.imul(y,it)|0,o=(o=o+Math.imul(y,st)|0)+Math.imul(w,it)|0,i=i+Math.imul(w,st)|0,r=r+Math.imul(m,ut)|0,o=(o=o+Math.imul(m,ct)|0)+Math.imul(f,ut)|0,i=i+Math.imul(f,ct)|0;var At=(c+(r=r+Math.imul(p,pt)|0)|0)+((8191&(o=(o=o+Math.imul(p,dt)|0)+Math.imul(d,pt)|0))<<13)|0;c=((i=i+Math.imul(d,dt)|0)+(o>>>13)|0)+(At>>>26)|0,At&=67108863,r=Math.imul(R,V),o=(o=Math.imul(R,z))+Math.imul(q,V)|0,i=Math.imul(q,z),r=r+Math.imul(W,N)|0,o=(o=o+Math.imul(W,$)|0)+Math.imul(D,N)|0,i=i+Math.imul(D,$)|0,r=r+Math.imul(U,j)|0,o=(o=o+Math.imul(U,H)|0)+Math.imul(_,j)|0,i=i+Math.imul(_,H)|0,r=r+Math.imul(T,G)|0,o=(o=o+Math.imul(T,Q)|0)+Math.imul(E,G)|0,i=i+Math.imul(E,Q)|0,r=r+Math.imul(S,J)|0,o=(o=o+Math.imul(S,tt)|0)+Math.imul(x,J)|0,i=i+Math.imul(x,tt)|0,r=r+Math.imul(M,nt)|0,o=(o=o+Math.imul(M,rt)|0)+Math.imul(A,nt)|0,i=i+Math.imul(A,rt)|0,r=r+Math.imul(k,it)|0,o=(o=o+Math.imul(k,st)|0)+Math.imul(I,it)|0,i=i+Math.imul(I,st)|0,r=r+Math.imul(y,ut)|0,o=(o=o+Math.imul(y,ct)|0)+Math.imul(w,ut)|0,i=i+Math.imul(w,ct)|0,r=r+Math.imul(m,pt)|0,o=(o=o+Math.imul(m,dt)|0)+Math.imul(f,pt)|0,i=i+Math.imul(f,dt)|0;var Pt=(c+(r=r+Math.imul(p,mt)|0)|0)+((8191&(o=(o=o+Math.imul(p,ft)|0)+Math.imul(d,mt)|0))<<13)|0;c=((i=i+Math.imul(d,ft)|0)+(o>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,r=Math.imul(R,N),o=(o=Math.imul(R,$))+Math.imul(q,N)|0,i=Math.imul(q,$),r=r+Math.imul(W,j)|0,o=(o=o+Math.imul(W,H)|0)+Math.imul(D,j)|0,i=i+Math.imul(D,H)|0,r=r+Math.imul(U,G)|0,o=(o=o+Math.imul(U,Q)|0)+Math.imul(_,G)|0,i=i+Math.imul(_,Q)|0,r=r+Math.imul(T,J)|0,o=(o=o+Math.imul(T,tt)|0)+Math.imul(E,J)|0,i=i+Math.imul(E,tt)|0,r=r+Math.imul(S,nt)|0,o=(o=o+Math.imul(S,rt)|0)+Math.imul(x,nt)|0,i=i+Math.imul(x,rt)|0,r=r+Math.imul(M,it)|0,o=(o=o+Math.imul(M,st)|0)+Math.imul(A,it)|0,i=i+Math.imul(A,st)|0,r=r+Math.imul(k,ut)|0,o=(o=o+Math.imul(k,ct)|0)+Math.imul(I,ut)|0,i=i+Math.imul(I,ct)|0,r=r+Math.imul(y,pt)|0,o=(o=o+Math.imul(y,dt)|0)+Math.imul(w,pt)|0,i=i+Math.imul(w,dt)|0;var St=(c+(r=r+Math.imul(m,mt)|0)|0)+((8191&(o=(o=o+Math.imul(m,ft)|0)+Math.imul(f,mt)|0))<<13)|0;c=((i=i+Math.imul(f,ft)|0)+(o>>>13)|0)+(St>>>26)|0,St&=67108863,r=Math.imul(R,j),o=(o=Math.imul(R,H))+Math.imul(q,j)|0,i=Math.imul(q,H),r=r+Math.imul(W,G)|0,o=(o=o+Math.imul(W,Q)|0)+Math.imul(D,G)|0,i=i+Math.imul(D,Q)|0,r=r+Math.imul(U,J)|0,o=(o=o+Math.imul(U,tt)|0)+Math.imul(_,J)|0,i=i+Math.imul(_,tt)|0,r=r+Math.imul(T,nt)|0,o=(o=o+Math.imul(T,rt)|0)+Math.imul(E,nt)|0,i=i+Math.imul(E,rt)|0,r=r+Math.imul(S,it)|0,o=(o=o+Math.imul(S,st)|0)+Math.imul(x,it)|0,i=i+Math.imul(x,st)|0,r=r+Math.imul(M,ut)|0,o=(o=o+Math.imul(M,ct)|0)+Math.imul(A,ut)|0,i=i+Math.imul(A,ct)|0,r=r+Math.imul(k,pt)|0,o=(o=o+Math.imul(k,dt)|0)+Math.imul(I,pt)|0,i=i+Math.imul(I,dt)|0;var xt=(c+(r=r+Math.imul(y,mt)|0)|0)+((8191&(o=(o=o+Math.imul(y,ft)|0)+Math.imul(w,mt)|0))<<13)|0;c=((i=i+Math.imul(w,ft)|0)+(o>>>13)|0)+(xt>>>26)|0,xt&=67108863,r=Math.imul(R,G),o=(o=Math.imul(R,Q))+Math.imul(q,G)|0,i=Math.imul(q,Q),r=r+Math.imul(W,J)|0,o=(o=o+Math.imul(W,tt)|0)+Math.imul(D,J)|0,i=i+Math.imul(D,tt)|0,r=r+Math.imul(U,nt)|0,o=(o=o+Math.imul(U,rt)|0)+Math.imul(_,nt)|0,i=i+Math.imul(_,rt)|0,r=r+Math.imul(T,it)|0,o=(o=o+Math.imul(T,st)|0)+Math.imul(E,it)|0,i=i+Math.imul(E,st)|0,r=r+Math.imul(S,ut)|0,o=(o=o+Math.imul(S,ct)|0)+Math.imul(x,ut)|0,i=i+Math.imul(x,ct)|0,r=r+Math.imul(M,pt)|0,o=(o=o+Math.imul(M,dt)|0)+Math.imul(A,pt)|0,i=i+Math.imul(A,dt)|0;var Ct=(c+(r=r+Math.imul(k,mt)|0)|0)+((8191&(o=(o=o+Math.imul(k,ft)|0)+Math.imul(I,mt)|0))<<13)|0;c=((i=i+Math.imul(I,ft)|0)+(o>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,r=Math.imul(R,J),o=(o=Math.imul(R,tt))+Math.imul(q,J)|0,i=Math.imul(q,tt),r=r+Math.imul(W,nt)|0,o=(o=o+Math.imul(W,rt)|0)+Math.imul(D,nt)|0,i=i+Math.imul(D,rt)|0,r=r+Math.imul(U,it)|0,o=(o=o+Math.imul(U,st)|0)+Math.imul(_,it)|0,i=i+Math.imul(_,st)|0,r=r+Math.imul(T,ut)|0,o=(o=o+Math.imul(T,ct)|0)+Math.imul(E,ut)|0,i=i+Math.imul(E,ct)|0,r=r+Math.imul(S,pt)|0,o=(o=o+Math.imul(S,dt)|0)+Math.imul(x,pt)|0,i=i+Math.imul(x,dt)|0;var Tt=(c+(r=r+Math.imul(M,mt)|0)|0)+((8191&(o=(o=o+Math.imul(M,ft)|0)+Math.imul(A,mt)|0))<<13)|0;c=((i=i+Math.imul(A,ft)|0)+(o>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,r=Math.imul(R,nt),o=(o=Math.imul(R,rt))+Math.imul(q,nt)|0,i=Math.imul(q,rt),r=r+Math.imul(W,it)|0,o=(o=o+Math.imul(W,st)|0)+Math.imul(D,it)|0,i=i+Math.imul(D,st)|0,r=r+Math.imul(U,ut)|0,o=(o=o+Math.imul(U,ct)|0)+Math.imul(_,ut)|0,i=i+Math.imul(_,ct)|0,r=r+Math.imul(T,pt)|0,o=(o=o+Math.imul(T,dt)|0)+Math.imul(E,pt)|0,i=i+Math.imul(E,dt)|0;var Et=(c+(r=r+Math.imul(S,mt)|0)|0)+((8191&(o=(o=o+Math.imul(S,ft)|0)+Math.imul(x,mt)|0))<<13)|0;c=((i=i+Math.imul(x,ft)|0)+(o>>>13)|0)+(Et>>>26)|0,Et&=67108863,r=Math.imul(R,it),o=(o=Math.imul(R,st))+Math.imul(q,it)|0,i=Math.imul(q,st),r=r+Math.imul(W,ut)|0,o=(o=o+Math.imul(W,ct)|0)+Math.imul(D,ut)|0,i=i+Math.imul(D,ct)|0,r=r+Math.imul(U,pt)|0,o=(o=o+Math.imul(U,dt)|0)+Math.imul(_,pt)|0,i=i+Math.imul(_,dt)|0;var Bt=(c+(r=r+Math.imul(T,mt)|0)|0)+((8191&(o=(o=o+Math.imul(T,ft)|0)+Math.imul(E,mt)|0))<<13)|0;c=((i=i+Math.imul(E,ft)|0)+(o>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,r=Math.imul(R,ut),o=(o=Math.imul(R,ct))+Math.imul(q,ut)|0,i=Math.imul(q,ct),r=r+Math.imul(W,pt)|0,o=(o=o+Math.imul(W,dt)|0)+Math.imul(D,pt)|0,i=i+Math.imul(D,dt)|0;var Ut=(c+(r=r+Math.imul(U,mt)|0)|0)+((8191&(o=(o=o+Math.imul(U,ft)|0)+Math.imul(_,mt)|0))<<13)|0;c=((i=i+Math.imul(_,ft)|0)+(o>>>13)|0)+(Ut>>>26)|0,Ut&=67108863,r=Math.imul(R,pt),o=(o=Math.imul(R,dt))+Math.imul(q,pt)|0,i=Math.imul(q,dt);var _t=(c+(r=r+Math.imul(W,mt)|0)|0)+((8191&(o=(o=o+Math.imul(W,ft)|0)+Math.imul(D,mt)|0))<<13)|0;c=((i=i+Math.imul(D,ft)|0)+(o>>>13)|0)+(_t>>>26)|0,_t&=67108863;var Lt=(c+(r=Math.imul(R,mt))|0)+((8191&(o=(o=Math.imul(R,ft))+Math.imul(q,mt)|0))<<13)|0;return c=((i=Math.imul(q,ft))+(o>>>13)|0)+(Lt>>>26)|0,Lt&=67108863,u[0]=gt,u[1]=yt,u[2]=wt,u[3]=bt,u[4]=kt,u[5]=It,u[6]=vt,u[7]=Mt,u[8]=At,u[9]=Pt,u[10]=St,u[11]=xt,u[12]=Ct,u[13]=Tt,u[14]=Et,u[15]=Bt,u[16]=Ut,u[17]=_t,u[18]=Lt,0!==c&&(u[19]=c,n.length++),n};function g(t,e,n){n.negative=e.negative^t.negative,n.length=t.length+e.length;for(var r=0,o=0,i=0;i<n.length-1;i++){var s=o;o=0;for(var a=67108863&r,u=Math.min(i,e.length-1),c=Math.max(0,i-t.length+1);c<=u;c++){var l=i-c,p=(0|t.words[l])*(0|e.words[c]),d=67108863&p;a=67108863&(d=d+a|0),o+=(s=(s=s+(p/67108864|0)|0)+(d>>>26)|0)>>>26,s&=67108863}n.words[i]=a,r=s,s=o}return 0!==r?n.words[i]=r:n.length--,n._strip()}function y(t,e,n){return g(t,e,n)}Math.imul||(f=m),o.prototype.mulTo=function(t,e){var n=this.length+t.length;return 10===this.length&&10===t.length?f(this,t,e):n<63?m(this,t,e):n<1024?g(this,t,e):y(this,t,e)},o.prototype.mul=function(t){var e=new o(null);return e.words=new Array(this.length+t.length),this.mulTo(t,e)},o.prototype.mulf=function(t){var e=new o(null);return e.words=new Array(this.length+t.length),y(this,t,e)},o.prototype.imul=function(t){return this.clone().mulTo(t,this)},o.prototype.imuln=function(t){var e=t<0;e&&(t=-t),n("number"==typeof t),n(t<67108864);for(var r=0,o=0;o<this.length;o++){var i=(0|this.words[o])*t,s=(67108863&i)+(67108863&r);r>>=26,r+=i/67108864|0,r+=s>>>26,this.words[o]=67108863&s}return 0!==r&&(this.words[o]=r,this.length++),e?this.ineg():this},o.prototype.muln=function(t){return this.clone().imuln(t)},o.prototype.sqr=function(){return this.mul(this)},o.prototype.isqr=function(){return this.imul(this.clone())},o.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),n=0;n<e.length;n++){var r=n/26|0,o=n%26;e[n]=t.words[r]>>>o&1}return e}(t);if(0===e.length)return new o(1);for(var n=this,r=0;r<e.length&&0===e[r];r++,n=n.sqr());if(++r<e.length)for(var i=n.sqr();r<e.length;r++,i=i.sqr())0!==e[r]&&(n=n.mul(i));return n},o.prototype.iushln=function(t){n("number"==typeof t&&t>=0);var e,r=t%26,o=(t-r)/26,i=67108863>>>26-r<<26-r;if(0!==r){var s=0;for(e=0;e<this.length;e++){var a=this.words[e]&i,u=(0|this.words[e])-a<<r;this.words[e]=u|s,s=a>>>26-r}s&&(this.words[e]=s,this.length++)}if(0!==o){for(e=this.length-1;e>=0;e--)this.words[e+o]=this.words[e];for(e=0;e<o;e++)this.words[e]=0;this.length+=o}return this._strip()},o.prototype.ishln=function(t){return n(0===this.negative),this.iushln(t)},o.prototype.iushrn=function(t,e,r){var o;n("number"==typeof t&&t>=0),o=e?(e-e%26)/26:0;var i=t%26,s=Math.min((t-i)/26,this.length),a=67108863^67108863>>>i<<i,u=r;if(o-=s,o=Math.max(0,o),u){for(var c=0;c<s;c++)u.words[c]=this.words[c];u.length=s}if(0===s);else if(this.length>s)for(this.length-=s,c=0;c<this.length;c++)this.words[c]=this.words[c+s];else this.words[0]=0,this.length=1;var l=0;for(c=this.length-1;c>=0&&(0!==l||c>=o);c--){var p=0|this.words[c];this.words[c]=l<<26-i|p>>>i,l=p&a}return u&&0!==l&&(u.words[u.length++]=l),0===this.length&&(this.words[0]=0,this.length=1),this._strip()},o.prototype.ishrn=function(t,e,r){return n(0===this.negative),this.iushrn(t,e,r)},o.prototype.shln=function(t){return this.clone().ishln(t)},o.prototype.ushln=function(t){return this.clone().iushln(t)},o.prototype.shrn=function(t){return this.clone().ishrn(t)},o.prototype.ushrn=function(t){return this.clone().iushrn(t)},o.prototype.testn=function(t){n("number"==typeof t&&t>=0);var e=t%26,r=(t-e)/26,o=1<<e;return this.length<=r?0:!!(this.words[r]&o)},o.prototype.imaskn=function(t){n("number"==typeof t&&t>=0);var e=t%26,r=(t-e)/26;if(n(0===this.negative,"imaskn works only with positive numbers"),this.length<=r)return this;if(0!==e&&r++,this.length=Math.min(r,this.length),0!==e){var o=67108863^67108863>>>e<<e;this.words[this.length-1]&=o}return this._strip()},o.prototype.maskn=function(t){return this.clone().imaskn(t)},o.prototype.iaddn=function(t){return n("number"==typeof t),n(t<67108864),t<0?this.isubn(-t):0!==this.negative?1===this.length&&(0|this.words[0])<=t?(this.words[0]=t-(0|this.words[0]),this.negative=0,this):(this.negative=0,this.isubn(t),this.negative=1,this):this._iaddn(t)},o.prototype._iaddn=function(t){this.words[0]+=t;for(var e=0;e<this.length&&this.words[e]>=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},o.prototype.isubn=function(t){if(n("number"==typeof t),n(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e<this.length&&this.words[e]<0;e++)this.words[e]+=67108864,this.words[e+1]-=1;return this._strip()},o.prototype.addn=function(t){return this.clone().iaddn(t)},o.prototype.subn=function(t){return this.clone().isubn(t)},o.prototype.iabs=function(){return this.negative=0,this},o.prototype.abs=function(){return this.clone().iabs()},o.prototype._ishlnsubmul=function(t,e,r){var o,i,s=t.length+r;this._expand(s);var a=0;for(o=0;o<t.length;o++){i=(0|this.words[o+r])+a;var u=(0|t.words[o])*e;a=((i-=67108863&u)>>26)-(u/67108864|0),this.words[o+r]=67108863&i}for(;o<this.length-r;o++)a=(i=(0|this.words[o+r])+a)>>26,this.words[o+r]=67108863&i;if(0===a)return this._strip();for(n(-1===a),a=0,o=0;o<this.length;o++)a=(i=-(0|this.words[o])+a)>>26,this.words[o]=67108863&i;return this.negative=1,this._strip()},o.prototype._wordDiv=function(t,e){var n=(this.length,t.length),r=this.clone(),i=t,s=0|i.words[i.length-1];0!=(n=26-this._countBits(s))&&(i=i.ushln(n),r.iushln(n),s=0|i.words[i.length-1]);var a,u=r.length-i.length;if("mod"!==e){(a=new o(null)).length=u+1,a.words=new Array(a.length);for(var c=0;c<a.length;c++)a.words[c]=0}var l=r.clone()._ishlnsubmul(i,1,u);0===l.negative&&(r=l,a&&(a.words[u]=1));for(var p=u-1;p>=0;p--){var d=67108864*(0|r.words[i.length+p])+(0|r.words[i.length+p-1]);for(d=Math.min(d/s|0,67108863),r._ishlnsubmul(i,d,p);0!==r.negative;)d--,r.negative=0,r._ishlnsubmul(i,1,p),r.isZero()||(r.negative^=1);a&&(a.words[p]=d)}return a&&a._strip(),r._strip(),"div"!==e&&0!==n&&r.iushrn(n),{div:a||null,mod:r}},o.prototype.divmod=function(t,e,r){return n(!t.isZero()),this.isZero()?{div:new o(0),mod:new o(0)}:0!==this.negative&&0===t.negative?(a=this.neg().divmod(t,e),"mod"!==e&&(i=a.div.neg()),"div"!==e&&(s=a.mod.neg(),r&&0!==s.negative&&s.iadd(t)),{div:i,mod:s}):0===this.negative&&0!==t.negative?(a=this.divmod(t.neg(),e),"mod"!==e&&(i=a.div.neg()),{div:i,mod:a.mod}):0!=(this.negative&t.negative)?(a=this.neg().divmod(t.neg(),e),"div"!==e&&(s=a.mod.neg(),r&&0!==s.negative&&s.isub(t)),{div:a.div,mod:s}):t.length>this.length||this.cmp(t)<0?{div:new o(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new o(this.modrn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new o(this.modrn(t.words[0]))}:this._wordDiv(t,e);var i,s,a},o.prototype.div=function(t){return this.divmod(t,"div",0).div},o.prototype.mod=function(t){return this.divmod(t,"mod",0).mod},o.prototype.umod=function(t){return this.divmod(t,"mod",1).mod},o.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var n=0!==e.div.negative?e.mod.isub(t):e.mod,r=t.ushrn(1),o=t.andln(1),i=n.cmp(r);return i<0||1===o&&0===i?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},o.prototype.modrn=function(t){var e=t<0;e&&(t=-t),n(t<=67108863);for(var r=(1<<26)%t,o=0,i=this.length-1;i>=0;i--)o=(r*o+(0|this.words[i]))%t;return e?-o:o},o.prototype.modn=function(t){return this.modrn(t)},o.prototype.idivn=function(t){var e=t<0;e&&(t=-t),n(t<=67108863);for(var r=0,o=this.length-1;o>=0;o--){var i=(0|this.words[o])+67108864*r;this.words[o]=i/t|0,r=i%t}return this._strip(),e?this.ineg():this},o.prototype.divn=function(t){return this.clone().idivn(t)},o.prototype.egcd=function(t){n(0===t.negative),n(!t.isZero());var e=this,r=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var i=new o(1),s=new o(0),a=new o(0),u=new o(1),c=0;e.isEven()&&r.isEven();)e.iushrn(1),r.iushrn(1),++c;for(var l=r.clone(),p=e.clone();!e.isZero();){for(var d=0,h=1;0==(e.words[0]&h)&&d<26;++d,h<<=1);if(d>0)for(e.iushrn(d);d-- >0;)(i.isOdd()||s.isOdd())&&(i.iadd(l),s.isub(p)),i.iushrn(1),s.iushrn(1);for(var m=0,f=1;0==(r.words[0]&f)&&m<26;++m,f<<=1);if(m>0)for(r.iushrn(m);m-- >0;)(a.isOdd()||u.isOdd())&&(a.iadd(l),u.isub(p)),a.iushrn(1),u.iushrn(1);e.cmp(r)>=0?(e.isub(r),i.isub(a),s.isub(u)):(r.isub(e),a.isub(i),u.isub(s))}return{a:a,b:u,gcd:r.iushln(c)}},o.prototype._invmp=function(t){n(0===t.negative),n(!t.isZero());var e=this,r=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var i,s=new o(1),a=new o(0),u=r.clone();e.cmpn(1)>0&&r.cmpn(1)>0;){for(var c=0,l=1;0==(e.words[0]&l)&&c<26;++c,l<<=1);if(c>0)for(e.iushrn(c);c-- >0;)s.isOdd()&&s.iadd(u),s.iushrn(1);for(var p=0,d=1;0==(r.words[0]&d)&&p<26;++p,d<<=1);if(p>0)for(r.iushrn(p);p-- >0;)a.isOdd()&&a.iadd(u),a.iushrn(1);e.cmp(r)>=0?(e.isub(r),s.isub(a)):(r.isub(e),a.isub(s))}return(i=0===e.cmpn(1)?s:a).cmpn(0)<0&&i.iadd(t),i},o.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),n=t.clone();e.negative=0,n.negative=0;for(var r=0;e.isEven()&&n.isEven();r++)e.iushrn(1),n.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;n.isEven();)n.iushrn(1);var o=e.cmp(n);if(o<0){var i=e;e=n,n=i}else if(0===o||0===n.cmpn(1))break;e.isub(n)}return n.iushln(r)},o.prototype.invm=function(t){return this.egcd(t).a.umod(t)},o.prototype.isEven=function(){return 0==(1&this.words[0])},o.prototype.isOdd=function(){return 1==(1&this.words[0])},o.prototype.andln=function(t){return this.words[0]&t},o.prototype.bincn=function(t){n("number"==typeof t);var e=t%26,r=(t-e)/26,o=1<<e;if(this.length<=r)return this._expand(r+1),this.words[r]|=o,this;for(var i=o,s=r;0!==i&&s<this.length;s++){var a=0|this.words[s];i=(a+=i)>>>26,a&=67108863,this.words[s]=a}return 0!==i&&(this.words[s]=i,this.length++),this},o.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},o.prototype.cmpn=function(t){var e,r=t<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this._strip(),this.length>1)e=1;else{r&&(t=-t),n(t<=67108863,"Number is too big");var o=0|this.words[0];e=o===t?0:o<t?-1:1}return 0!==this.negative?0|-e:e},o.prototype.cmp=function(t){if(0!==this.negative&&0===t.negative)return-1;if(0===this.negative&&0!==t.negative)return 1;var e=this.ucmp(t);return 0!==this.negative?0|-e:e},o.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length<t.length)return-1;for(var e=0,n=this.length-1;n>=0;n--){var r=0|this.words[n],o=0|t.words[n];if(r!==o){r<o?e=-1:r>o&&(e=1);break}}return e},o.prototype.gtn=function(t){return 1===this.cmpn(t)},o.prototype.gt=function(t){return 1===this.cmp(t)},o.prototype.gten=function(t){return this.cmpn(t)>=0},o.prototype.gte=function(t){return this.cmp(t)>=0},o.prototype.ltn=function(t){return-1===this.cmpn(t)},o.prototype.lt=function(t){return-1===this.cmp(t)},o.prototype.lten=function(t){return this.cmpn(t)<=0},o.prototype.lte=function(t){return this.cmp(t)<=0},o.prototype.eqn=function(t){return 0===this.cmpn(t)},o.prototype.eq=function(t){return 0===this.cmp(t)},o.red=function(t){return new A(t)},o.prototype.toRed=function(t){return n(!this.red,"Already a number in reduction context"),n(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},o.prototype.fromRed=function(){return n(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},o.prototype._forceRed=function(t){return this.red=t,this},o.prototype.forceRed=function(t){return n(!this.red,"Already a number in reduction context"),this._forceRed(t)},o.prototype.redAdd=function(t){return n(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},o.prototype.redIAdd=function(t){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},o.prototype.redSub=function(t){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},o.prototype.redISub=function(t){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},o.prototype.redShl=function(t){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},o.prototype.redMul=function(t){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},o.prototype.redIMul=function(t){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},o.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(t){return n(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var w={k256:null,p224:null,p192:null,p25519:null};function b(t,e){this.name=t,this.p=new o(e,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function k(){b.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function I(){b.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function v(){b.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function M(){b.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function A(t){if("string"==typeof t){var e=o._prime(t);this.m=e.p,this.prime=e}else n(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function P(t){A.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new o(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}b.prototype._tmp=function(){var t=new o(null);return t.words=new Array(Math.ceil(this.n/13)),t},b.prototype.ireduce=function(t){var e,n=t;do{this.split(n,this.tmp),e=(n=(n=this.imulK(n)).iadd(this.tmp)).bitLength()}while(e>this.n);var r=e<this.n?-1:n.ucmp(this.p);return 0===r?(n.words[0]=0,n.length=1):r>0?n.isub(this.p):void 0!==n.strip?n.strip():n._strip(),n},b.prototype.split=function(t,e){t.iushrn(this.n,0,e)},b.prototype.imulK=function(t){return t.imul(this.k)},r(k,b),k.prototype.split=function(t,e){for(var n=4194303,r=Math.min(t.length,9),o=0;o<r;o++)e.words[o]=t.words[o];if(e.length=r,t.length<=9)return t.words[0]=0,void(t.length=1);var i=t.words[9];for(e.words[e.length++]=i&n,o=10;o<t.length;o++){var s=0|t.words[o];t.words[o-10]=(s&n)<<4|i>>>22,i=s}i>>>=22,t.words[o-10]=i,0===i&&t.length>10?t.length-=10:t.length-=9},k.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,n=0;n<t.length;n++){var r=0|t.words[n];e+=977*r,t.words[n]=67108863&e,e=64*r+(e/67108864|0)}return 0===t.words[t.length-1]&&(t.length--,0===t.words[t.length-1]&&t.length--),t},r(I,b),r(v,b),r(M,b),M.prototype.imulK=function(t){for(var e=0,n=0;n<t.length;n++){var r=19*(0|t.words[n])+e,o=67108863&r;r>>>=26,t.words[n]=o,e=r}return 0!==e&&(t.words[t.length++]=e),t},o._prime=function(t){if(w[t])return w[t];var e;if("k256"===t)e=new k;else if("p224"===t)e=new I;else if("p192"===t)e=new v;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new M}return w[t]=e,e},A.prototype._verify1=function(t){n(0===t.negative,"red works only with positives"),n(t.red,"red works only with red numbers")},A.prototype._verify2=function(t,e){n(0==(t.negative|e.negative),"red works only with positives"),n(t.red&&t.red===e.red,"red works only with red numbers")},A.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):(c(t,t.umod(this.m)._forceRed(this)),t)},A.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},A.prototype.add=function(t,e){this._verify2(t,e);var n=t.add(e);return n.cmp(this.m)>=0&&n.isub(this.m),n._forceRed(this)},A.prototype.iadd=function(t,e){this._verify2(t,e);var n=t.iadd(e);return n.cmp(this.m)>=0&&n.isub(this.m),n},A.prototype.sub=function(t,e){this._verify2(t,e);var n=t.sub(e);return n.cmpn(0)<0&&n.iadd(this.m),n._forceRed(this)},A.prototype.isub=function(t,e){this._verify2(t,e);var n=t.isub(e);return n.cmpn(0)<0&&n.iadd(this.m),n},A.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},A.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},A.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},A.prototype.isqr=function(t){return this.imul(t,t.clone())},A.prototype.sqr=function(t){return this.mul(t,t)},A.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(n(e%2==1),3===e){var r=this.m.add(new o(1)).iushrn(2);return this.pow(t,r)}for(var i=this.m.subn(1),s=0;!i.isZero()&&0===i.andln(1);)s++,i.iushrn(1);n(!i.isZero());var a=new o(1).toRed(this),u=a.redNeg(),c=this.m.subn(1).iushrn(1),l=this.m.bitLength();for(l=new o(2*l*l).toRed(this);0!==this.pow(l,c).cmp(u);)l.redIAdd(u);for(var p=this.pow(l,i),d=this.pow(t,i.addn(1).iushrn(1)),h=this.pow(t,i),m=s;0!==h.cmp(a);){for(var f=h,g=0;0!==f.cmp(a);g++)f=f.redSqr();n(g<m);var y=this.pow(p,new o(1).iushln(m-g-1));d=d.redMul(y),p=y.redSqr(),h=h.redMul(p),m=g}return d},A.prototype.invm=function(t){var e=t._invmp(this.m);return 0!==e.negative?(e.negative=0,this.imod(e).redNeg()):this.imod(e)},A.prototype.pow=function(t,e){if(e.isZero())return new o(1).toRed(this);if(0===e.cmpn(1))return t.clone();var n=new Array(16);n[0]=new o(1).toRed(this),n[1]=t;for(var r=2;r<n.length;r++)n[r]=this.mul(n[r-1],t);var i=n[0],s=0,a=0,u=e.bitLength()%26;for(0===u&&(u=26),r=e.length-1;r>=0;r--){for(var c=e.words[r],l=u-1;l>=0;l--){var p=c>>l&1;i!==n[0]&&(i=this.sqr(i)),0!==p||0!==s?(s<<=1,s|=p,(4==++a||0===r&&0===l)&&(i=this.mul(i,n[s]),a=0,s=0)):a=0}u=26}return i},A.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},A.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},o.mont=function(t){return new P(t)},r(P,A),P.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},P.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},P.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var n=t.imul(e),r=n.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),o=n.isub(r).iushrn(this.shift),i=o;return o.cmp(this.m)>=0?i=o.isub(this.m):o.cmpn(0)<0&&(i=o.iadd(this.m)),i._forceRed(this)},P.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new o(0)._forceRed(this);var n=t.mul(e),r=n.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=n.isub(r).iushrn(this.shift),s=i;return i.cmp(this.m)>=0?s=i.isub(this.m):i.cmpn(0)<0&&(s=i.iadd(this.m)),s._forceRed(this)},P.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(0,Wo);var Ko=Do(Ro.exports);const Vo={Spl:"spl",Token2022:"token2022",SplCold:"spl-cold",Token2022Cold:"token2022-cold",CTokenHot:"ctoken-hot",CTokenCold:"ctoken-cold"};function zo(t){if(!t||0===t.length)return null;try{let e=0;const n=new x(t.slice(e,e+32));e+=32;const r=new x(t.slice(e,e+32));e+=32;const o=new Ko(t.slice(e,e+8),"le");e+=8;const i=t[e];e+=1;const s=i?new x(t.slice(e,e+32)):null;e+=32;const a=t[e];e+=1;const u=t[e];return e+=1,{mint:n,owner:r,amount:o,delegate:s,state:a,tlv:u?t.slice(e):null}}catch(t){return console.error("Token data parsing error:",t),null}}function Fo(t,e){return{address:t,mint:e.mint,owner:e.owner,amount:BigInt(e.amount.toString()),delegate:e.delegate,delegatedAmount:BigInt(0),isInitialized:e.state!==$.Uninitialized,isFrozen:e.state===$.Frozen,isNative:0,rentExemptReserve:null,closeAuthority:null,tlvData:e.tlv?Tt.from(e.tlv):Tt.alloc(0)}}function No(t){const e=Tt.from(t.data.discriminator),n=Tt.from(t.data.data),r=Tt.concat([e,n]);return{executable:0,owner:t.owner,lamports:t.lamports.toNumber(),data:r,rentEpoch:void 0}}function $o(t,e){const n=zo(e.data);if(!n)throw new Error("Invalid token data");return{accountInfo:e,loadContext:void 0,parsed:Fo(t,n),isCold:0}}function Yo(t,e){const n=zo(e.data.data);if(!n)throw new Error("Invalid token data");return{accountInfo:No(e),loadContext:{treeInfo:e.treeInfo,hash:e.hash,leafIndex:e.leafIndex,proveByIndex:e.proveByIndex},parsed:Fo(t,n),isCold:1}}async function jo(t,e,n,r){return b(),Zo(t,e,n,r,void 0)}async function Ho(t,e,n,r,o,i,s=0,a=0){b();const u=Qr(e,r,n,i,a);if(s&&"ctoken"!==u.type)throw new Error(`For wrap=true, ata must be the c-token ATA. Got ${u.type} ATA instead.`);const c=await Zo(t,e,o,i,{owner:n,mint:r},s);return c._isAta=1,c._owner=n,c._mint=r,c}async function Zo(t,e,n,r,o,i=0){if(!e&&!o)throw new Error("One of address or fetchByOwner is required");if(!r)return async function(t,e,n,r,o){const i=e??z(r.mint,r.owner,0,g,Gr(g)),s=[],a=[],u=[];if(s.push(async function(t,e,n){const r=await t.getAccountInfo(e,n);if(!r||!r.owner.equals(g))throw new Error("Not a CTOKEN onchain account");return $o(e,r)}(t,i,n)),a.push(Vo.CTokenHot),u.push(i),o){if(!r)throw new Error("fetchByOwner is required for wrap=true to derive SPL/T22 addresses");const e=z(r.mint,r.owner,0,q,Gr(q)),o=z(r.mint,r.owner,0,K,Gr(K));s.push(async function(t,e,n){const r=await t.getAccountInfo(e,n);if(!r||!r.owner.equals(q))throw new Error("Not a TOKEN_PROGRAM_ID account");return{accountInfo:r,parsed:W(e,r,q),isCold:0,loadContext:void 0}}(t,e,n)),a.push(Vo.Spl),u.push(e),s.push(async function(t,e,n){const r=await t.getAccountInfo(e,n);if(!r||!r.owner.equals(K))throw new Error("Not a TOKEN_2022_PROGRAM_ID account");return{accountInfo:r,parsed:W(e,r,K),isCold:0,loadContext:void 0}}(t,o,n)),a.push(Vo.Token2022),u.push(o)}const c=r?t.getCompressedTokenAccountsByOwner(r.owner,{mint:r.mint}):t.getCompressedTokenAccountsByOwner(e),[l,p]=await Promise.all([Promise.allSettled(s),c.catch((()=>({items:[]})))]),d=[];for(let t=0;t<l.length;t++){const e=l[t];if("fulfilled"===e.status){const n=e.value;d.push({type:a[t],address:u[t],amount:n.parsed.amount,accountInfo:n.accountInfo,loadContext:n.loadContext,parsed:n.parsed})}}for(const t of p.items){const e=t.compressedAccount;if(e&&e.data&&e.data.data.length>0&&e.owner.equals(g)){const t=Yo(i,e);d.push({type:Vo.CTokenCold,address:i,amount:t.parsed.amount,accountInfo:t.accountInfo,loadContext:t.loadContext,parsed:t.parsed})}}if(0===d.length)throw new Y;const h=[Vo.CTokenHot,Vo.CTokenCold,Vo.Spl,Vo.Token2022];return d.sort(((t,e)=>h.indexOf(t.type)-h.indexOf(e.type))),Go(d,i)}(t,e,n,o,i);if(r.equals(g))return async function(t,e,n,r){if(!e){if(!r)throw new Error("fetchByOwner is required");e=z(r.mint,r.owner,0,g,Gr(g))}const[o,i]=await Promise.allSettled([t.getAccountInfo(e,n),r?t.getCompressedTokenAccountsByOwner(r.owner,{mint:r.mint}):t.getCompressedTokenAccountsByOwner(e)]),s="fulfilled"===o.status?o.value:null,a="fulfilled"===i.status?i.value.items.map((t=>t.compressedAccount)):[],u=[];if(s&&s.owner.equals(g)){const t=$o(e,s);u.push({type:Vo.CTokenHot,address:e,amount:t.parsed.amount,accountInfo:s,parsed:t.parsed})}for(const t of a)if(t&&t.data&&t.data.data.length>0&&t.owner.equals(g)){const n=Yo(e,t);u.push({type:Vo.CTokenCold,address:e,amount:n.parsed.amount,accountInfo:n.accountInfo,loadContext:n.loadContext,parsed:n.parsed})}if(0===u.length)throw new Y;return u.sort(((t,e)=>"ctoken-hot"===t.type&&"ctoken-cold"===e.type?-1:"ctoken-cold"===t.type&&"ctoken-hot"===e.type?1:0)),Go(u,e)}(t,e,n,o);if(r.equals(q)||r.equals(K))return async function(t,e,n,r,o){if(!e){if(!o)throw new Error("fetchByOwner is required");e=z(o.mint,o.owner,0,r,Gr(r))}const i=r.equals(q)?Vo.Spl:Vo.Token2022,s=r.equals(q)?Vo.SplCold:Vo.Token2022Cold,a=t.getAccountInfo(e,n).catch((()=>null)),u=o?t.getCompressedTokenAccountsByOwner(o.owner,{mint:o.mint}).catch((()=>({items:[]}))):Promise.resolve({items:[]}),[c,l]=await Promise.all([a,u]),p=[];if(c)try{const t=W(e,c,r);p.push({type:i,address:e,amount:t.amount,accountInfo:c,parsed:t})}catch{}for(const t of l.items){const n=t.compressedAccount;if(n&&n.data&&n.data.data.length>0&&n.owner.equals(g)){const t=Yo(e,n);p.push({type:s,address:e,amount:t.parsed.amount,accountInfo:t.accountInfo,loadContext:t.loadContext,parsed:t.parsed})}}if(0===p.length)throw new Y;return Go(p,e)}(t,e,n,r,o);throw new Error(`Unsupported program ID: ${r.toBase58()}`)}function Go(t,e){const n=t.reduce(((t,e)=>t+e.amount),BigInt(0)),r=t[0],o=t.some((t=>null!==t.parsed.delegate)),i=t.some((t=>t.parsed.isFrozen)),s=t.length>1,a={...r.parsed,address:e,amount:n};return{accountInfo:r.accountInfo,parsed:a,isCold:["ctoken-cold","spl-cold","token2022-cold"].includes(r.type),loadContext:r.loadContext,_sources:t,_needsConsolidation:s,_hasDelegate:o,_anyFrozen:i}}function Qo(t,e,n=0,r=g,o){const i=o??Gr(r);return z(t,e,n,r,i)}function Xo(t,e,n,r,o,i,s,a=n){const u=Co({withTransactionHash:0,withLamportsChangeAccountMerkleTreeIndex:0,lamportsChangeAccountMerkleTreeIndex:0,lamportsChangeAccountOwnerIndex:0,outputQueue:0,maxTopUp:0,cpiContext:null,compressions:[To(o,0,2,1,4,i.poolIndex,i.bump,s),Eo(o,0,3,6)],proof:null,inTokenData:[],outTokenData:[],inLamports:null,outLamports:null,inTlv:null,outTlv:null}),c=[{pubkey:rr.deriveCpiAuthorityPda,isSigner:0,isWritable:0},{pubkey:a,isSigner:1,isWritable:1},{pubkey:r,isSigner:0,isWritable:0},{pubkey:n,isSigner:1,isWritable:0},{pubkey:t,isSigner:0,isWritable:1},{pubkey:e,isSigner:0,isWritable:1},{pubkey:i.splInterfacePda,isSigner:0,isWritable:1},{pubkey:i.tokenProgram,isSigner:0,isWritable:0},{pubkey:g,isSigner:0,isWritable:0},{pubkey:C.programId,isSigner:0,isWritable:0}];return new T({programId:rr.programId,keys:c,data:u})}const Jo=8,ti=new Set([Vo.CTokenCold,Vo.SplCold,Vo.Token2022Cold]),ei=[8,4,3,2,1],ni=[8,7,6,5,4,3,2,1];function ri(t,e){if(0===t.length||e<=BigInt(0))return[];const n=[...t].sort(((t,e)=>{const n=BigInt(t.parsed.amount.toString()),r=BigInt(e.parsed.amount.toString());return r>n?1:r<n?-1:0}));let r=BigInt(0),o=0;for(const t of n)if(o++,r+=BigInt(t.parsed.amount.toString()),r>=e)break;const i=Math.min(Math.max(o,Jo),n.length);return n.slice(0,i)}function oi(t,e){const n=[];let r=0,o=t.length;for(const i of e)for(;o>=i;)n.push(t.slice(r,r+i)),r+=i,o-=i;return n}function ii(t){const e=[],r=[];for(const o of t)o.compressedAccount.treeInfo.treeType===n.StateV1?e.push(o):r.push(o);return[...oi(r,ni),...oi(e,ei)]}function si(t){const e=new Set;for(const n of t)for(const t of n){const n=t.compressedAccount.hash.toString();if(e.has(n))throw new Error(`Duplicate compressed account hash across chunks: ${n}. Each compressed account must appear in exactly one chunk.`);e.add(n)}}async function ai(t,e,n,r,o,i){if(0===n.length)return[];const s=[],a=ii(n);si(a);const u=await Promise.all(a.map((async e=>{const n=e.map((t=>({hash:t.compressedAccount.hash,tree:t.compressedAccount.treeInfo.tree,queue:t.compressedAccount.treeInfo.queue})));return t.getValidityProofV0(n)})));for(let t=0;t<a.length;t++){const n=a[t],c=u[t],l=n.reduce(((t,e)=>t+BigInt(e.parsed.amount.toString())),BigInt(0)),p=Lo(e,n,r,l,c,o,i);s.push(p)}return s}function ui(e){const n=new Set([Vo.CTokenCold,Vo.SplCold,Vo.Token2022Cold]);return e.filter((t=>void 0!==t.loadContext)).filter((t=>n.has(t.type))).filter((t=>!t.parsed.isFrozen)).map((e=>{const n=e.accountInfo.data,r=n.subarray(0,Math.min(8,n.length)),o=n.length>8?n.subarray(8):Buffer.alloc(0),i={treeInfo:e.loadContext.treeInfo,hash:e.loadContext.hash,leafIndex:e.loadContext.leafIndex,proveByIndex:e.loadContext.proveByIndex,owner:e.accountInfo.owner,lamports:t(e.accountInfo.lamports),address:null,data:0===n.length?null:{discriminator:Array.from(r),data:Buffer.from(o),dataHash:new Array(32).fill(0)},readOnly:0},s=e.parsed.isInitialized?e.parsed.isFrozen?2:1:0;return{compressedAccount:i,parsed:{mint:e.parsed.mint,owner:e.parsed.owner,amount:t(e.parsed.amount.toString()),delegate:e.parsed.delegate,state:s,tlv:e.parsed.tlvData.length>0?e.parsed.tlvData:null}}}))}async function ci(t,e,n,r,o=0,i){if(!n._isAta||!n._owner||!n._mint)throw new Error("AccountInterface must be from getAtaInterface (requires _isAta, _owner, _mint)");const s=[],a=n._owner,u=n._mint,c=n._sources??[];ui(c);const l=Qo(u,a),p=z(u,a,0,q,Gr(q)),d=z(u,a,0,K,Gr(K));let h="ctoken";if(i&&(h=Qr(i,u,a).type,o&&"ctoken"!==h))throw new Error(`For wrap=true, targetAta must be c-token ATA. Got ${h} ATA.`);const m=c.find((t=>"spl"===t.type&&!t.parsed.isFrozen)),f=c.find((t=>"token2022"===t.type&&!t.parsed.isFrozen)),y=c.find((t=>"ctoken-hot"===t.type)),w=c.filter((t=>ti.has(t.type)&&!t.parsed.isFrozen)),b=m?.amount??BigInt(0),k=f?.amount??BigInt(0),I=w.reduce(((t,e)=>t+e.amount),BigInt(0));if(b===BigInt(0)&&k===BigInt(0)&&I===BigInt(0))return[];let v,M=0;if(o||"spl"===h||"token2022"===h||b>BigInt(0)||k>BigInt(0))try{v=(r?.splInterfaceInfos??await $e(t,u)).find((t=>t.isInitialized)),v&&(M=(await j(t,u,void 0,v.tokenProgram)).decimals)}catch{}if(o){if(y||s.push(to(e,l,a,u,g)),b>BigInt(0)&&v&&s.push(Xo(p,l,a,u,b,v,M,e)),k>BigInt(0)&&v&&s.push(Xo(d,l,a,u,k,v,M,e)),I>BigInt(0)&&w.length>0){const n=ui(c);if(n.length>0){const r=await ai(t,e,n,l,void 0,M);s.push(...r)}}}else if(I>BigInt(0)&&w.length>0){const n=ui(c);if(n.length>0)if("ctoken"===h){y||s.push(to(e,l,a,u,g));const r=await ai(t,e,n,l,void 0,M);s.push(...r)}else if("spl"===h&&v){m||s.push(N(e,p,a,u,q));const r=await ai(t,e,n,p,v,M);s.push(...r)}else if("token2022"===h&&v){f||s.push(N(e,d,a,u,K));const r=await ai(t,e,n,d,v,M);s.push(...r)}}return s}async function li(t,e,n,r,o,i,s=0){let a;b(),o??=n;try{a=await Ho(t,e,n,r,void 0,void 0,s)}catch(t){if(t instanceof Y)return[];throw t}return(await di(t,o,a,i,s,e)).map((t=>t.instructions))}function pi(t){let e=0;if(t.hasAtaCreation&&(e+=3e4),e+=5e4*t.wrapCount,t.compressedAccounts.length>0){e+=5e4,t.compressedAccounts.some((t=>!t.compressedAccount.proveByIndex))&&(e+=1e5);for(const n of t.compressedAccounts)e+=n.compressedAccount.proveByIndex?1e4:3e4}return e=Math.ceil(1.3*e),Math.max(5e4,Math.min(14e5,e))}async function di(t,e,n,r,o,i,s){if(!n._isAta||!n._owner||!n._mint)throw new Error("AccountInterface must be from getAtaInterface (requires _isAta, _owner, _mint)");const a=n._owner,u=n._mint,c=n._sources??[],l=ui(c),p=Qo(u,a),d=z(u,a,0,q,Gr(q)),h=z(u,a,0,K,Gr(K));let m="ctoken";if(m=Qr(i,u,a).type,o&&"ctoken"!==m)throw new Error(`For wrap=true, targetAta must be c-token ATA. Got ${m} ATA.`);const f=c.find((t=>"spl"===t.type&&!t.parsed.isFrozen)),y=c.find((t=>"token2022"===t.type&&!t.parsed.isFrozen)),w=c.find((t=>"ctoken-hot"===t.type)),b=c.filter((t=>ti.has(t.type)&&!t.parsed.isFrozen)),k=f?.amount??BigInt(0),I=y?.amount??BigInt(0),v=b.reduce(((t,e)=>t+e.amount),BigInt(0));if(k===BigInt(0)&&I===BigInt(0)&&v===BigInt(0))return[];let M,A=0;if(o||"spl"===m||"token2022"===m||k>BigInt(0)||I>BigInt(0))try{M=(r?.splInterfaceInfos??await $e(t,u)).find((t=>t.isInitialized)),M&&(A=(await j(t,u,void 0,M.tokenProgram)).decimals)}catch{}const P=[];let S,x=0,C=0,T=p,E=0;o?(T=p,S=void 0,E=1,w||(C=1,P.push(to(e,p,a,u,g))),k>BigInt(0)&&M&&(P.push(Xo(d,p,a,u,k,M,A,e)),x++),I>BigInt(0)&&M&&(P.push(Xo(h,p,a,u,I,M,A,e)),x++)):"ctoken"===m?(T=p,S=void 0,E=1,w||(C=1,P.push(to(e,p,a,u,g)))):"spl"===m&&M?(T=d,S=M,E=1,f||(C=1,P.push(N(e,d,a,u,q)))):"token2022"===m&&M&&(T=h,S=M,E=1,y||(C=1,P.push(N(e,h,a,u,K))));let B=l;if(void 0!==s&&E&&l.length>0){const t=w?.amount??BigInt(0);let e;e=o?t+k+I:"ctoken"===m?t:"spl"===m?k:I;const n=s>e?s-e:BigInt(0);B=n===BigInt(0)?[]:ri(l,n)}if(!E||0===B.length)return 0===P.length?[]:[{instructions:P,compressedAccounts:[],wrapCount:x,hasAtaCreation:C}];const U=ii(B);si(U);const _=await Promise.all(U.map((async e=>{const n=e.map((t=>({hash:t.compressedAccount.hash,tree:t.compressedAccount.treeInfo.tree,queue:t.compressedAccount.treeInfo.queue})));return t.getValidityProofV0(n)}))),L=o||"ctoken"===m?to(e,p,a,u,g):"spl"===m?N(e,d,a,u,q):N(e,h,a,u,K),W=[];for(let t=0;t<U.length;t++){const n=U[t],r=_[t],o=n.reduce(((t,e)=>t+BigInt(e.parsed.amount.toString())),BigInt(0)),i=[];let s=0,a=0;0===t?(i.push(...P),s=x,a=C):(i.push(L),a=1),i.push(Lo(e,n,T,o,r,S,A)),W.push({instructions:i,compressedAccounts:n,wrapCount:s,hasAtaCreation:a})}return W}async function hi(t,e,n,r,o,i,s,a=0){let u;b(),o??=n;try{u=await Ho(t,e,n.publicKey,r,void 0,void 0,a)}catch(t){if(t instanceof Y)return null;throw t}const c=await di(t,o.publicKey,u,s,a,e);if(0===c.length)return null;const l=k(o,[n]),p=c.map((async e=>{const{blockhash:n}=await t.getLatestBlockhash(),r=pi(e),s=I([B.setComputeUnitLimit({units:r}),...e.instructions],o,n,l);return v(t,s,i)})),d=await Promise.all(p);return d[d.length-1]}async function mi(t,e,n,r=[],o=[],i){let s=null;const a=r.filter((t=>void 0!==t.info.loadContext));if(a.length>0){const e=a.map((t=>({hash:t.info.loadContext.hash,tree:t.info.loadContext.treeInfo.tree,queue:t.info.loadContext.treeInfo.queue}))),r=await t.getValidityProofV0(e,[]),o=a.map((t=>{if("cTokenData"===t.accountType){if(!t.tokenVariant)throw new Error('tokenVariant is required when accountType is "cTokenData"');return{key:"cTokenData",data:{variant:{[t.tokenVariant]:{}},tokenData:t.info.parsed},treeInfo:t.info.loadContext.treeInfo}}return{key:t.accountType,data:t.info.parsed,treeInfo:t.info.loadContext.treeInfo}})),i=a.map((t=>t.address)),u=a.map((t=>t.info.loadContext.treeInfo)),c=await M(n,{compressedProof:r.compressedProof,treeInfos:u},o,i);s={proofOption:c.proofOption,compressedAccounts:c.compressedAccounts,systemAccountsOffset:c.systemAccountsOffset,remainingAccounts:c.remainingAccounts}}const u=[];for(const n of o){const r=await ci(t,e,n,i);u.push(...r)}return{decompressParams:s,ataInstructions:u}}function fi(t,e){let n=5e4;return e&&(n+=1e5),n+=3e4*t,n}function gi(t,e,n,r,o,i,s,a=n){const u=Co({withTransactionHash:0,withLamportsChangeAccountMerkleTreeIndex:0,lamportsChangeAccountMerkleTreeIndex:0,lamportsChangeAccountOwnerIndex:0,outputQueue:0,maxTopUp:0,cpiContext:null,compressions:[Bo(o,0,2,1,6),Uo(o,0,3,4,i.poolIndex,i.bump,s)],proof:null,inTokenData:[],outTokenData:[],inLamports:null,outLamports:null,inTlv:null,outTlv:null}),c=[{pubkey:rr.deriveCpiAuthorityPda,isSigner:0,isWritable:0},{pubkey:a,isSigner:1,isWritable:1},{pubkey:r,isSigner:0,isWritable:0},{pubkey:n,isSigner:1,isWritable:0},{pubkey:t,isSigner:0,isWritable:1},{pubkey:e,isSigner:0,isWritable:1},{pubkey:i.splInterfacePda,isSigner:0,isWritable:1},{pubkey:i.tokenProgram,isSigner:0,isWritable:0},{pubkey:g,isSigner:0,isWritable:0},{pubkey:C.programId,isSigner:0,isWritable:0}];return new T({programId:rr.programId,keys:c,data:u})}async function yi(t,e,n,r,o=U.generate(),i,s,a){const u=await t.getMinimumBalanceForRentExemption(D),c=1==s?K:s||q,l=await rr.createMint({feePayer:e.publicKey,mint:o.publicKey,decimals:r,authority:"secretKey"in n?n.publicKey:n,freezeAuthority:a&&"secretKey"in a?a.publicKey:a??null,rentExemptBalance:u,tokenProgramId:c}),{blockhash:p}=await t.getLatestBlockhash(),d=k(e,[n,a??null].filter((t=>null!=t&&"secretKey"in t))),h=I(l,e,p,[...d,o]),m=await v(t,h,i);return{mint:o.publicKey,transactionSignature:m}}async function wi(t,e,n,r,o,i=U.generate(),s,a=g,u,c,l){if(b(),a.equals(q)||a.equals(K))return yi(t,e,n,o,i,s,a,r);if(!("secretKey"in n))throw new Error("mintAuthority must be a Signer for compressed token mints");if(l&&!l.tree.equals(w().tree))throw new Error(`addressTreeInfo ${l?.tree.toString()} must be the default address tree info: ${w().tree.toString()}`);const p=r&&"secretKey"in r?r.publicKey:r;l=l??A(),c=c??P(await t.getStateTreeInfos());const d=or(i.publicKey,l),h=await t.getValidityProofV2([],[{address:Uint8Array.from(d),treeInfo:l}],S.standard),m=Ur(i.publicKey,o,n.publicKey,p,e.publicKey,h,l,c,u),f=k(e,[i,n]),{blockhash:y}=await t.getLatestBlockhash(),M=I([B.setComputeUnitLimit({units:5e5}),m],e,y,f),x=await v(t,M);return console.log("txId",x),{mint:sr(i.publicKey)[0],transactionSignature:x}}var bi={};Object.defineProperty(bi,"__esModule",{value:1}),bi.s16=bi.s8=bi.nu64be=bi.u48be=bi.u40be=bi.u32be=bi.u24be=bi.u16be=bi.nu64=bi.u48=bi.u40=bi.u32=bi.u24=bi.u16=rs=bi.u8=bi.offset=bi.greedy=bi.Constant=bi.UTF8=bi.CString=bi.Blob=bi.Boolean=bi.BitField=bi.BitStructure=bi.VariantLayout=bi.Union=bi.UnionLayoutDiscriminator=bi.UnionDiscriminator=bi.Structure=bi.Sequence=bi.DoubleBE=bi.Double=bi.FloatBE=bi.Float=bi.NearInt64BE=bi.NearInt64=bi.NearUInt64BE=bi.NearUInt64=bi.IntBE=bi.Int=bi.UIntBE=bi.UInt=bi.OffsetLayout=bi.GreedyCount=bi.ExternalLayout=bi.bindConstructorLayout=bi.nameWithProperty=bi.Layout=bi.uint8ArrayToBuffer=bi.checkUint8Array=void 0,bi.constant=bi.utf8=bi.cstr=is=bi.blob=bi.unionLayoutDiscriminator=bi.union=bi.seq=bi.bits=os=bi.struct=bi.f64be=bi.f64=bi.f32be=bi.f32=bi.ns64be=bi.s48be=bi.s40be=bi.s32be=bi.s24be=bi.s16be=bi.ns64=bi.s48=bi.s40=bi.s32=bi.s24=void 0;const ki=qo;function Ii(t){if(!(t instanceof Uint8Array))throw new TypeError("b must be a Uint8Array")}function vi(t){return Ii(t),ki.Buffer.from(t.buffer,t.byteOffset,t.length)}bi.checkUint8Array=Ii,bi.uint8ArrayToBuffer=vi;class Mi{constructor(t,e){if(!Number.isInteger(t))throw new TypeError("span must be an integer");this.span=t,this.property=e}makeDestinationObject(){return{}}getSpan(t,e){if(0>this.span)throw new RangeError("indeterminate span");return this.span}replicate(t){const e=Object.create(this.constructor.prototype);return Object.assign(e,this),e.property=t,e}fromArray(t){}}function Ai(t,e){return e.property?t+"["+e.property+"]":t}bi.Layout=Mi,bi.nameWithProperty=Ai,bi.bindConstructorLayout=function(t,e){if("function"!=typeof t)throw new TypeError("Class must be constructor");if(Object.prototype.hasOwnProperty.call(t,"layout_"))throw new Error("Class is already bound to a layout");if(!(e&&e instanceof Mi))throw new TypeError("layout must be a Layout");if(Object.prototype.hasOwnProperty.call(e,"boundConstructor_"))throw new Error("layout is already bound to a constructor");t.layout_=e,e.boundConstructor_=t,e.makeDestinationObject=()=>new t,Object.defineProperty(t.prototype,"encode",{value(t,n){return e.encode(this,t,n)},writable:1}),Object.defineProperty(t,"decode",{value:(t,n)=>e.decode(t,n),writable:1})};class Pi extends Mi{isCount(){throw new Error("ExternalLayout is abstract")}}bi.ExternalLayout=Pi;class Si extends Pi{constructor(t=1,e){if(!Number.isInteger(t)||0>=t)throw new TypeError("elementSpan must be a (positive) integer");super(-1,e),this.elementSpan=t}isCount(){return 1}decode(t,e=0){Ii(t);const n=t.length-e;return Math.floor(n/this.elementSpan)}encode(t,e,n){return 0}}bi.GreedyCount=Si;class xi extends Pi{constructor(t,e=0,n){if(!(t instanceof Mi))throw new TypeError("layout must be a Layout");if(!Number.isInteger(e))throw new TypeError("offset must be integer or undefined");super(t.span,n||t.property),this.layout=t,this.offset=e}isCount(){return this.layout instanceof Ci||this.layout instanceof Ti}decode(t,e=0){return this.layout.decode(t,e+this.offset)}encode(t,e,n=0){return this.layout.encode(t,e,n+this.offset)}}bi.OffsetLayout=xi;class Ci extends Mi{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return vi(t).readUIntLE(e,this.span)}encode(t,e,n=0){return vi(e).writeUIntLE(t,n,this.span),this.span}}bi.UInt=Ci;class Ti extends Mi{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return vi(t).readUIntBE(e,this.span)}encode(t,e,n=0){return vi(e).writeUIntBE(t,n,this.span),this.span}}bi.UIntBE=Ti;class Ei extends Mi{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return vi(t).readIntLE(e,this.span)}encode(t,e,n=0){return vi(e).writeIntLE(t,n,this.span),this.span}}bi.Int=Ei;class Bi extends Mi{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return vi(t).readIntBE(e,this.span)}encode(t,e,n=0){return vi(e).writeIntBE(t,n,this.span),this.span}}bi.IntBE=Bi;const Ui=Math.pow(2,32);function _i(t){const e=Math.floor(t/Ui);return{hi32:e,lo32:t-e*Ui}}function Li(t,e){return t*Ui+e}class Wi extends Mi{constructor(t){super(8,t)}decode(t,e=0){const n=vi(t),r=n.readUInt32LE(e);return Li(n.readUInt32LE(e+4),r)}encode(t,e,n=0){const r=_i(t),o=vi(e);return o.writeUInt32LE(r.lo32,n),o.writeUInt32LE(r.hi32,n+4),8}}bi.NearUInt64=Wi;class Di extends Mi{constructor(t){super(8,t)}decode(t,e=0){const n=vi(t);return Li(n.readUInt32BE(e),n.readUInt32BE(e+4))}encode(t,e,n=0){const r=_i(t),o=vi(e);return o.writeUInt32BE(r.hi32,n),o.writeUInt32BE(r.lo32,n+4),8}}bi.NearUInt64BE=Di;class Oi extends Mi{constructor(t){super(8,t)}decode(t,e=0){const n=vi(t),r=n.readUInt32LE(e);return Li(n.readInt32LE(e+4),r)}encode(t,e,n=0){const r=_i(t),o=vi(e);return o.writeUInt32LE(r.lo32,n),o.writeInt32LE(r.hi32,n+4),8}}bi.NearInt64=Oi;class Ri extends Mi{constructor(t){super(8,t)}decode(t,e=0){const n=vi(t);return Li(n.readInt32BE(e),n.readUInt32BE(e+4))}encode(t,e,n=0){const r=_i(t),o=vi(e);return o.writeInt32BE(r.hi32,n),o.writeUInt32BE(r.lo32,n+4),8}}bi.NearInt64BE=Ri;class qi extends Mi{constructor(t){super(4,t)}decode(t,e=0){return vi(t).readFloatLE(e)}encode(t,e,n=0){return vi(e).writeFloatLE(t,n),4}}bi.Float=qi;class Ki extends Mi{constructor(t){super(4,t)}decode(t,e=0){return vi(t).readFloatBE(e)}encode(t,e,n=0){return vi(e).writeFloatBE(t,n),4}}bi.FloatBE=Ki;class Vi extends Mi{constructor(t){super(8,t)}decode(t,e=0){return vi(t).readDoubleLE(e)}encode(t,e,n=0){return vi(e).writeDoubleLE(t,n),8}}bi.Double=Vi;class zi extends Mi{constructor(t){super(8,t)}decode(t,e=0){return vi(t).readDoubleBE(e)}encode(t,e,n=0){return vi(e).writeDoubleBE(t,n),8}}bi.DoubleBE=zi;class Fi extends Mi{constructor(t,e,n){if(!(t instanceof Mi))throw new TypeError("elementLayout must be a Layout");if(!(e instanceof Pi&&e.isCount()||Number.isInteger(e)&&0<=e))throw new TypeError("count must be non-negative integer or an unsigned integer ExternalLayout");let r=-1;!(e instanceof Pi)&&0<t.span&&(r=e*t.span),super(r,n),this.elementLayout=t,this.count=e}getSpan(t,e=0){if(0<=this.span)return this.span;let n=0,r=this.count;if(r instanceof Pi&&(r=r.decode(t,e)),0<this.elementLayout.span)n=r*this.elementLayout.span;else{let o=0;for(;o<r;)n+=this.elementLayout.getSpan(t,e+n),++o}return n}decode(t,e=0){const n=[];let r=0,o=this.count;for(o instanceof Pi&&(o=o.decode(t,e));r<o;)n.push(this.elementLayout.decode(t,e)),e+=this.elementLayout.getSpan(t,e),r+=1;return n}encode(t,e,n=0){const r=this.elementLayout,o=t.reduce(((t,o)=>t+r.encode(o,e,n+t)),0);return this.count instanceof Pi&&this.count.encode(t.length,e,n),o}}bi.Sequence=Fi;class Ni extends Mi{constructor(t,e,n){if(!Array.isArray(t)||!t.reduce(((t,e)=>t&&e instanceof Mi),1))throw new TypeError("fields must be array of Layout instances");"boolean"==typeof e&&void 0===n&&(n=e,e=void 0);for(const e of t)if(0>e.span&&void 0===e.property)throw new Error("fields cannot contain unnamed variable-length layout");let r=-1;try{r=t.reduce(((t,e)=>t+e.getSpan()),0)}catch(t){}super(r,e),this.fields=t,this.decodePrefixes=!!n}getSpan(t,e=0){if(0<=this.span)return this.span;let n=0;try{n=this.fields.reduce(((n,r)=>{const o=r.getSpan(t,e);return e+=o,n+o}),0)}catch(t){throw new RangeError("indeterminate span")}return n}decode(t,e=0){Ii(t);const n=this.makeDestinationObject();for(const r of this.fields)if(void 0!==r.property&&(n[r.property]=r.decode(t,e)),e+=r.getSpan(t,e),this.decodePrefixes&&t.length===e)break;return n}encode(t,e,n=0){const r=n;let o=0,i=0;for(const r of this.fields){let s=r.span;if(i=0<s?s:0,void 0!==r.property){const o=t[r.property];void 0!==o&&(i=r.encode(o,e,n),0>s&&(s=r.getSpan(e,n)))}o=n,n+=s}return o+i-r}fromArray(t){const e=this.makeDestinationObject();for(const n of this.fields)void 0!==n.property&&0<t.length&&(e[n.property]=t.shift());return e}layoutFor(t){if("string"!=typeof t)throw new TypeError("property must be string");for(const e of this.fields)if(e.property===t)return e}offsetOf(t){if("string"!=typeof t)throw new TypeError("property must be string");let e=0;for(const n of this.fields){if(n.property===t)return e;0>n.span?e=-1:0<=e&&(e+=n.span)}}}bi.Structure=Ni;class $i{constructor(t){this.property=t}decode(t,e){throw new Error("UnionDiscriminator is abstract")}encode(t,e,n){throw new Error("UnionDiscriminator is abstract")}}bi.UnionDiscriminator=$i;class Yi extends $i{constructor(t,e){if(!(t instanceof Pi&&t.isCount()))throw new 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,n){return this.layout.encode(t,e,n)}}bi.UnionLayoutDiscriminator=Yi;class ji extends Mi{constructor(t,e,n){let r;if(t instanceof Ci||t instanceof Ti)r=new Yi(new xi(t));else if(t instanceof Pi&&t.isCount())r=new Yi(t);else{if(!(t instanceof $i))throw new TypeError("discr must be a UnionDiscriminator or an unsigned integer layout");r=t}if(void 0===e&&(e=null),!(null===e||e instanceof Mi))throw new TypeError("defaultLayout must be null or a Layout");if(null!==e){if(0>e.span)throw new Error("defaultLayout must have constant span");void 0===e.property&&(e=e.replicate("content"))}let o=-1;e&&(o=e.span,0<=o&&(t instanceof Ci||t instanceof Ti)&&(o+=r.layout.span)),super(o,n),this.discriminator=r,this.usesPrefixDiscriminator=t instanceof Ci||t instanceof Ti,this.defaultLayout=e,this.registry={};let i=this.defaultGetSourceVariant.bind(this);this.getSourceVariant=function(t){return i(t)},this.configGetSourceVariant=function(t){i=t.bind(this)}}getSpan(t,e=0){if(0<=this.span)return this.span;const n=this.getVariant(t,e);if(!n)throw new Error("unable to determine span for unrecognized variant");return n.getSpan(t,e)}defaultGetSourceVariant(t){if(Object.prototype.hasOwnProperty.call(t,this.discriminator.property)){if(this.defaultLayout&&this.defaultLayout.property&&Object.prototype.hasOwnProperty.call(t,this.defaultLayout.property))return;const e=this.registry[t[this.discriminator.property]];if(e&&(!e.layout||e.property&&Object.prototype.hasOwnProperty.call(t,e.property)))return e}else for(const e in this.registry){const n=this.registry[e];if(n.property&&Object.prototype.hasOwnProperty.call(t,n.property))return n}throw new Error("unable to infer src variant")}decode(t,e=0){let n;const r=this.discriminator,o=r.decode(t,e),i=this.registry[o];if(void 0===i){const i=this.defaultLayout;let s=0;this.usesPrefixDiscriminator&&(s=r.layout.span),n=this.makeDestinationObject(),n[r.property]=o,n[i.property]=i.decode(t,e+s)}else n=i.decode(t,e);return n}encode(t,e,n=0){const r=this.getSourceVariant(t);if(void 0===r){const r=this.discriminator,o=this.defaultLayout;let i=0;return this.usesPrefixDiscriminator&&(i=r.layout.span),r.encode(t[r.property],e,n),i+o.encode(t[o.property],e,n+i)}return r.encode(t,e,n)}addVariant(t,e,n){const r=new Hi(this,t,e,n);return this.registry[t]=r,r}getVariant(t,e=0){let n;return n=t instanceof Uint8Array?this.discriminator.decode(t,e):t,this.registry[n]}}bi.Union=ji;class Hi extends Mi{constructor(t,e,n,r){if(!(t instanceof ji))throw new TypeError("union must be a Union");if(!Number.isInteger(e)||0>e)throw new TypeError("variant must be a (non-negative) integer");if("string"==typeof n&&void 0===r&&(r=n,n=null),n){if(!(n instanceof Mi))throw new TypeError("layout must be a Layout");if(null!==t.defaultLayout&&0<=n.span&&n.span>t.defaultLayout.span)throw new Error("variant span exceeds span of containing union");if("string"!=typeof r)throw new TypeError("variant must have a String property")}let o=t.span;0>t.span&&(o=n?n.span:0,0<=o&&t.usesPrefixDiscriminator&&(o+=t.discriminator.layout.span)),super(o,r),this.union=t,this.variant=e,this.layout=n||null}getSpan(t,e=0){if(0<=this.span)return this.span;let n=0;this.union.usesPrefixDiscriminator&&(n=this.union.discriminator.layout.span);let r=0;return this.layout&&(r=this.layout.getSpan(t,e+n)),n+r}decode(t,e=0){const n=this.makeDestinationObject();if(this!==this.union.getVariant(t,e))throw new Error("variant mismatch");let r=0;return this.union.usesPrefixDiscriminator&&(r=this.union.discriminator.layout.span),this.layout?n[this.property]=this.layout.decode(t,e+r):this.property?n[this.property]=1:this.union.usesPrefixDiscriminator&&(n[this.union.discriminator.property]=this.variant),n}encode(t,e,n=0){let r=0;if(this.union.usesPrefixDiscriminator&&(r=this.union.discriminator.layout.span),this.layout&&!Object.prototype.hasOwnProperty.call(t,this.property))throw new TypeError("variant lacks property "+this.property);this.union.discriminator.encode(this.variant,e,n);let o=r;if(this.layout&&(this.layout.encode(t[this.property],e,n+r),o+=this.layout.getSpan(e,n+r),0<=this.union.span&&o>this.union.span))throw new Error("encoded variant overruns containing union");return o}fromArray(t){if(this.layout)return this.layout.fromArray(t)}}function Zi(t){return 0>t&&(t+=4294967296),t}bi.VariantLayout=Hi;class Gi extends Mi{constructor(t,e,n){if(!(t instanceof Ci||t instanceof Ti))throw new TypeError("word must be a UInt or UIntBE layout");if("string"==typeof e&&void 0===n&&(n=e,e=0),4<t.span)throw new RangeError("word cannot exceed 32 bits");super(t.span,n),this.word=t,this.msb=!!e,this.fields=[];let r=0;this._packedSetValue=function(t){return r=Zi(t),this},this._packedGetValue=function(){return r}}decode(t,e=0){const n=this.makeDestinationObject(),r=this.word.decode(t,e);this._packedSetValue(r);for(const e of this.fields)void 0!==e.property&&(n[e.property]=e.decode(t));return n}encode(t,e,n=0){const r=this.word.decode(e,n);this._packedSetValue(r);for(const e of this.fields)if(void 0!==e.property){const n=t[e.property];void 0!==n&&e.encode(n)}return this.word.encode(this._packedGetValue(),e,n)}addField(t,e){const n=new Qi(this,t,e);return this.fields.push(n),n}addBoolean(t){const e=new Xi(this,t);return this.fields.push(e),e}fieldFor(t){if("string"!=typeof t)throw new TypeError("property must be string");for(const e of this.fields)if(e.property===t)return e}}bi.BitStructure=Gi;class Qi{constructor(t,e,n){if(!(t instanceof Gi))throw new TypeError("container must be a BitStructure");if(!Number.isInteger(e)||0>=e)throw new TypeError("bits must be positive integer");const r=8*t.span,o=t.fields.reduce(((t,e)=>t+e.bits),0);if(e+o>r)throw new Error("bits too long for span remainder ("+(r-o)+" of "+r+" remain)");this.container=t,this.bits=e,this.valueMask=(1<<e)-1,32===e&&(this.valueMask=4294967295),this.start=o,this.container.msb&&(this.start=r-o-e),this.wordMask=Zi(this.valueMask<<this.start),this.property=n}decode(t,e){return Zi(this.container._packedGetValue()&this.wordMask)>>>this.start}encode(t){if("number"!=typeof t||!Number.isInteger(t)||t!==Zi(t&this.valueMask))throw new TypeError(Ai("BitField.encode",this)+" value must be integer not exceeding "+this.valueMask);const e=this.container._packedGetValue(),n=Zi(t<<this.start);this.container._packedSetValue(Zi(e&~this.wordMask)|n)}}bi.BitField=Qi;class Xi extends Qi{constructor(t,e){super(t,1,e)}decode(t,e){return!!super.decode(t,e)}encode(t){"boolean"==typeof t&&(t=+t),super.encode(t)}}bi.Boolean=Xi;class Ji extends Mi{constructor(t,e){if(!(t instanceof Pi&&t.isCount()||Number.isInteger(t)&&0<=t))throw new TypeError("length must be positive integer or an unsigned integer ExternalLayout");let n=-1;t instanceof Pi||(n=t),super(n,e),this.length=t}getSpan(t,e){let n=this.span;return 0>n&&(n=this.length.decode(t,e)),n}decode(t,e=0){let n=this.span;return 0>n&&(n=this.length.decode(t,e)),vi(t).slice(e,e+n)}encode(t,e,n){let r=this.length;if(this.length instanceof Pi&&(r=t.length),!(t instanceof Uint8Array&&r===t.length))throw new TypeError(Ai("Blob.encode",this)+" requires (length "+r+") Uint8Array as src");if(n+r>e.length)throw new RangeError("encoding overruns Uint8Array");const o=vi(t);return vi(e).write(o.toString("hex"),n,r,"hex"),this.length instanceof Pi&&this.length.encode(r,e,n),r}}bi.Blob=Ji;class ts extends Mi{constructor(t){super(-1,t)}getSpan(t,e=0){Ii(t);let n=e;for(;n<t.length&&0!==t[n];)n+=1;return 1+n-e}decode(t,e=0){const n=this.getSpan(t,e);return vi(t).slice(e,e+n-1).toString("utf-8")}encode(t,e,n=0){"string"!=typeof t&&(t=String(t));const r=ki.Buffer.from(t,"utf8"),o=r.length;if(n+o>e.length)throw new RangeError("encoding overruns Buffer");const i=vi(e);return r.copy(i,n),i[n+o]=0,o+1}}bi.CString=ts;class es extends Mi{constructor(t,e){if("string"==typeof t&&void 0===e&&(e=t,t=void 0),void 0===t)t=-1;else if(!Number.isInteger(t))throw new TypeError("maxSpan must be an integer");super(-1,e),this.maxSpan=t}getSpan(t,e=0){return Ii(t),t.length-e}decode(t,e=0){const n=this.getSpan(t,e);if(0<=this.maxSpan&&this.maxSpan<n)throw new RangeError("text length exceeds maxSpan");return vi(t).slice(e,e+n).toString("utf-8")}encode(t,e,n=0){"string"!=typeof t&&(t=String(t));const r=ki.Buffer.from(t,"utf8"),o=r.length;if(0<=this.maxSpan&&this.maxSpan<o)throw new RangeError("text length exceeds maxSpan");if(n+o>e.length)throw new RangeError("encoding overruns Buffer");return r.copy(vi(e),n),o}}bi.UTF8=es;class ns extends Mi{constructor(t,e){super(0,e),this.value=t}decode(t,e){return this.value}encode(t,e,n){return 0}}bi.Constant=ns,bi.greedy=(t,e)=>new Si(t,e),bi.offset=(t,e,n)=>new xi(t,e,n);var rs=bi.u8=t=>new Ci(1,t);bi.u16=t=>new Ci(2,t),bi.u24=t=>new Ci(3,t),bi.u32=t=>new Ci(4,t),bi.u40=t=>new Ci(5,t),bi.u48=t=>new Ci(6,t),bi.nu64=t=>new Wi(t),bi.u16be=t=>new Ti(2,t),bi.u24be=t=>new Ti(3,t),bi.u32be=t=>new Ti(4,t),bi.u40be=t=>new Ti(5,t),bi.u48be=t=>new Ti(6,t),bi.nu64be=t=>new Di(t),bi.s8=t=>new Ei(1,t),bi.s16=t=>new Ei(2,t),bi.s24=t=>new Ei(3,t),bi.s32=t=>new Ei(4,t),bi.s40=t=>new Ei(5,t),bi.s48=t=>new Ei(6,t),bi.ns64=t=>new Oi(t),bi.s16be=t=>new Bi(2,t),bi.s24be=t=>new Bi(3,t),bi.s32be=t=>new Bi(4,t),bi.s40be=t=>new Bi(5,t),bi.s48be=t=>new Bi(6,t),bi.ns64be=t=>new Ri(t),bi.f32=t=>new qi(t),bi.f32be=t=>new Ki(t),bi.f64=t=>new Vi(t),bi.f64be=t=>new zi(t);var os=bi.struct=(t,e,n)=>new Ni(t,e,n);bi.bits=(t,e,n)=>new Gi(t,e,n),bi.seq=(t,e,n)=>new Fi(t,e,n),bi.union=(t,e,n)=>new ji(t,e,n),bi.unionLayoutDiscriminator=(t,e)=>new Yi(t,e);var is=bi.blob=(t,e)=>new Ji(t,e);bi.cstr=t=>new ts(t),bi.utf8=(t,e)=>new es(t,e),bi.constant=(t,e)=>new ns(t,e);const ss=nt([it("updateAuthority"),it("mint"),ut("name"),ut("symbol"),ut("uri"),dt(nt([ut("key"),ut("value")]),"additionalMetadata")]),as=os([rs("version"),rs("cmintDecompressed"),(()=>{const t=is(32,"splMint"),{encode:e,decode:n}=(t=>({decode:t.decode.bind(t),encode:t.encode.bind(t)}))(t),r=t;return r.decode=(t,e)=>{const r=n(t,e);return new x(r)},r.encode=(t,n,r)=>{const o=t.toBuffer();return e(o,n,r)},r})()]),us=as.span,cs=32,ls=1,ps=16,ds=1;function hs(t,e,n){return t===gs.TokenMetadata?function(t,e){let n=e;n+=32,n+=32,n+=4+t.readUInt32LE(n),n+=4+t.readUInt32LE(n),n+=4+t.readUInt32LE(n);const r=t.readUInt32LE(n);n+=4;for(let e=0;e<r;e++)n+=4+t.readUInt32LE(n),n+=4+t.readUInt32LE(n);return n-e}(e,n):e.length-n}function ms(t){const e=t instanceof Tt?t:Tt.from(t);let n=0;const r=H.decode(e.slice(n,n+D));n+=D;const o=as.decode(e.slice(n,n+us));n+=us;const i=e.slice(n,n+cs);n+=cs;const s=e.readUInt8(n);n+=ls;const a=e.slice(n,n+ps);n+=ps;const u=e.readUInt8(n);n+=ds;const[c,l]=function(t,e){const n=e,r=t.readUInt16LE(e);e+=2;const o=t.readUInt8(e);e+=1;const i=t.readUInt8(e);e+=1;const s=t.readUInt32LE(e);e+=4;const a=new x(t.slice(e,e+32));e+=32;const u=new x(t.slice(e,e+32));e+=32;const c=t.readBigUInt64LE(e);e+=8;const l=t.readUInt32LE(e);e+=4;const p=t.readUInt32LE(e);e+=4;const d=t.readUInt16LE(e);e+=2;const h=t.readUInt16LE(e);e+=2;const m=t.readUInt8(e);e+=1;const f=t.readUInt8(e);return e+=1,[{configAccountVersion:r,compressToPubkey:o,accountVersion:i,lamportsPerWrite:s,compressionAuthority:a,rentSponsor:u,lastClaimedSlot:c,rentExemptionPaid:l,reserved:p,rentConfig:{baseRent:d,compressionCost:h,lamportsPerBytePerEpoch:m,maxFundedEpochs:f,maxTopUp:t.readUInt16LE(e)}},(e+=2)-n]}(e,n);n+=l;const p=1===e.readUInt8(n);n+=1;let d=null;if(p){const t=e.readUInt32LE(n);n+=4,d=[];for(let r=0;r<t;r++){const t=e.readUInt8(n);n+=1;const r=hs(t,e,n),o=e.slice(n,n+r);n+=r,d.push({extensionType:t,data:o})}}return{base:{mintAuthority:1===r.mintAuthorityOption?r.mintAuthority:null,supply:r.supply,decimals:r.decimals,isInitialized:r.isInitialized,freezeAuthority:1===r.freezeAuthorityOption?r.freezeAuthority:null},mintContext:{version:o.version,cmintDecompressed:0!==o.cmintDecompressed,splMint:o.splMint,mintSigner:i,bump:s},reserved:a,accountType:u,compression:c,extensions:d}}function fs(t){const e=[],n=Tt.alloc(D);H.encode({mintAuthorityOption:t.base.mintAuthority?1:0,mintAuthority:t.base.mintAuthority||new x(0),supply:t.base.supply,decimals:t.base.decimals,isInitialized:t.base.isInitialized,freezeAuthorityOption:t.base.freezeAuthority?1:0,freezeAuthority:t.base.freezeAuthority||new x(0)},n),e.push(n);const r=Tt.alloc(us);as.encode({version:t.mintContext.version,cmintDecompressed:t.mintContext.cmintDecompressed?1:0,splMint:t.mintContext.splMint},r),e.push(r),e.push(Tt.from(t.mintContext.mintSigner)),e.push(Tt.from([t.mintContext.bump]));const o=t.reserved??new Uint8Array(ps);e.push(Tt.from(o));const i=t.accountType??1;if(e.push(Tt.from([i])),t.compression?e.push(function(t){const e=Tt.alloc(96);let n=0;return e.writeUInt16LE(t.configAccountVersion,n),n+=2,e.writeUInt8(t.compressToPubkey,n),n+=1,e.writeUInt8(t.accountVersion,n),n+=1,e.writeUInt32LE(t.lamportsPerWrite,n),n+=4,t.compressionAuthority.toBuffer().copy(e,n),n+=32,t.rentSponsor.toBuffer().copy(e,n),n+=32,e.writeBigUInt64LE(t.lastClaimedSlot,n),n+=8,e.writeUInt32LE(t.rentExemptionPaid,n),n+=4,e.writeUInt32LE(t.reserved,n),n+=4,e.writeUInt16LE(t.rentConfig.baseRent,n),n+=2,e.writeUInt16LE(t.rentConfig.compressionCost,n),n+=2,e.writeUInt8(t.rentConfig.lamportsPerBytePerEpoch,n),n+=1,e.writeUInt8(t.rentConfig.maxFundedEpochs,n),n+=1,e.writeUInt16LE(t.rentConfig.maxTopUp,n),n+=2,e}(t.compression)):e.push(Tt.alloc(96)),t.extensions&&t.extensions.length>0){e.push(Tt.from([1]));const n=Tt.alloc(4);n.writeUInt32LE(t.extensions.length),e.push(n);for(const n of t.extensions)e.push(Tt.from([n.extensionType])),e.push(Tt.from(n.data))}else e.push(Tt.from([0]));return Tt.concat(e)}var gs;function ys(t){try{const e=Tt.from(t);if(e.length<80)return null;const n=ss.decode(e),r=n.updateAuthority.toBuffer().every((t=>0===t))?void 0:n.updateAuthority,o=Tt.from(n.name).toString("utf-8"),i=Tt.from(n.symbol).toString("utf-8"),s=Tt.from(n.uri).toString("utf-8");let a;return n.additionalMetadata&&n.additionalMetadata.length>0&&(a=n.additionalMetadata.map((t=>({key:Tt.from(t.key).toString("utf-8"),value:Tt.from(t.value).toString("utf-8")})))),{updateAuthority:r,mint:n.mint,name:o,symbol:i,uri:s,additionalMetadata:a}}catch(t){return console.error("Failed to decode TokenMetadata:",t),null}}function ws(t){const e=Tt.alloc(2e3),n=t.updateAuthority||new x(0),r=ss.encode({updateAuthority:n,mint:t.mint,name:Tt.from(t.name),symbol:Tt.from(t.symbol),uri:Tt.from(t.uri),additionalMetadata:t.additionalMetadata?t.additionalMetadata.map((t=>({key:Tt.from(t.key),value:Tt.from(t.value)}))):[]},e);return e.subarray(0,r)}!function(t){t[t.TokenMetadata=19]="TokenMetadata"}(gs||(gs={}));const bs=ys;function ks(t){if(!t)return null;const e=t.find((t=>t.extensionType===gs.TokenMetadata));return e?bs(e.data):null}async function Is(e,n,r,o){if(b(),!o){const[t,o,i]=await Promise.allSettled([Is(e,n,r,q),Is(e,n,r,K),Is(e,n,r,g)]);if("fulfilled"===t.status)return t.value;if("fulfilled"===o.status)return o.value;if("fulfilled"===i.status)return i.value;throw new Error(`Mint not found: ${n.toString()}. Tried TOKEN_PROGRAM_ID, TOKEN_2022_PROGRAM_ID, and LIGHT_TOKEN_PROGRAM_ID.`)}if(o.equals(g)){const r=w().tree,i=f(n.toBytes(),r,g),s=await e.getCompressedAccount(t(i.toBytes()));if(!s?.data?.data)throw new Error(`Compressed mint not found for ${n.toString()}`);const a=Tt.from(s.data.data),u=64;let c;if(a.length<u){const t=await e.getAccountInfo(n);if(!t?.data)throw new Error(`Decompressed CMint account not found on-chain for ${n.toString()}`);c=ms(Tt.from(t.data))}else c=ms(a);const l={address:n,mintAuthority:c.base.mintAuthority,supply:c.base.supply,decimals:c.base.decimals,isInitialized:c.base.isInitialized,freezeAuthority:c.base.freezeAuthority,tlvData:Tt.alloc(0)},p={treeInfo:s.treeInfo,hash:s.hash,leafIndex:s.leafIndex,proveByIndex:s.proveByIndex},d=ks(c.extensions),h={mint:l,programId:o,merkleContext:p,mintContext:c.mintContext,tokenMetadata:d||void 0,extensions:c.extensions||void 0,compression:c.compression};if(o.equals(g)){if(!h.merkleContext)throw new Error("Invalid compressed mint: merkleContext is required for LIGHT_TOKEN_PROGRAM_ID");if(!h.mintContext)throw new Error("Invalid compressed mint: mintContext is required for LIGHT_TOKEN_PROGRAM_ID")}return h}return{mint:await j(e,n,r,o),programId:o}}function vs(t,e,n=q){const r=e instanceof Tt?e:e instanceof Uint8Array?Tt.from(e):e.data;if(n.equals(g)){const e=ms(r),o={address:t,mintAuthority:e.base.mintAuthority,supply:e.base.supply,decimals:e.base.decimals,isInitialized:e.base.isInitialized,freezeAuthority:e.base.freezeAuthority,tlvData:Tt.alloc(0)},i=ks(e.extensions),s={mint:o,programId:n,mintContext:e.mintContext,tokenMetadata:i||void 0,extensions:e.extensions||void 0,compression:e.compression};if(n.equals(g)&&!s.mintContext)throw new Error("Invalid compressed mint: mintContext is required for LIGHT_TOKEN_PROGRAM_ID");return s}return{mint:Z(t,e,n),programId:n}}function Ms(t){const e=ms(t instanceof Tt?t:Tt.from(t)),n=ks(e.extensions);return{mintContext:e.mintContext,tokenMetadata:n||void 0,extensions:e.extensions||void 0}}async function As(e,n,r,o,i,s){b();const a=await Is(e,r,s?.commitment,g);if(!a.merkleContext)throw new Error("Mint does not have MerkleContext");const u=a.mintContext?.cmintDecompressed?null:await e.getValidityProofV2([{hash:t(a.merkleContext.hash),leafIndex:a.merkleContext.leafIndex,treeInfo:a.merkleContext.treeInfo,proveByIndex:a.merkleContext.proveByIndex}],[],S.compressible),c=Lr(a,o.publicKey,i,n.publicKey,u),l=o.publicKey.equals(n.publicKey)?[]:[o],{blockhash:p}=await e.getLatestBlockhash(),d=I([B.setComputeUnitLimit({units:5e5}),c],n,p,l);return await v(e,d,s)}async function Ps(e,n,r,o,i,s){b();const a=await Is(e,r,s?.commitment,g);if(!a.merkleContext)throw new Error("Mint does not have MerkleContext");const u=a.mintContext?.cmintDecompressed?null:await e.getValidityProofV2([{hash:t(a.merkleContext.hash),leafIndex:a.merkleContext.leafIndex,treeInfo:a.merkleContext.treeInfo,proveByIndex:a.merkleContext.proveByIndex}],[],S.compressible),c=Wr(a,o.publicKey,i,n.publicKey,u),l=o.publicKey.equals(n.publicKey)?[]:[o],{blockhash:p}=await e.getLatestBlockhash(),d=I([B.setComputeUnitLimit({units:5e5}),c],n,p,l);return await v(e,d,s)}async function Ss(e,n,r,o,i,s,a,u=0,c){b();const l=await Is(e,r,c?.commitment,g);if(!l.tokenMetadata||!l.merkleContext)throw new Error("Mint does not have TokenMetadata extension");const p=l.mintContext?.cmintDecompressed?null:await e.getValidityProofV2([{hash:t(l.merkleContext.hash),leafIndex:l.merkleContext.leafIndex,treeInfo:l.merkleContext.treeInfo,proveByIndex:l.merkleContext.proveByIndex}],[],S.compressible),d=Or(l,o.publicKey,n.publicKey,p,i,s,a,u),h=o.publicKey.equals(n.publicKey)?[]:[o],{blockhash:m}=await e.getLatestBlockhash(),f=I([B.setComputeUnitLimit({units:5e5}),d],n,m,h);return await v(e,f,c)}async function xs(e,n,r,o,i,s=0,a){b();const u=await Is(e,r,a?.commitment,g);if(!u.tokenMetadata||!u.merkleContext)throw new Error("Mint does not have TokenMetadata extension");const c=u.mintContext?.cmintDecompressed?null:await e.getValidityProofV2([{hash:t(u.merkleContext.hash),leafIndex:u.merkleContext.leafIndex,treeInfo:u.merkleContext.treeInfo,proveByIndex:u.merkleContext.proveByIndex}],[],S.compressible),l=Rr(u,o.publicKey,i,n.publicKey,c,s),p=o.publicKey.equals(n.publicKey)?[]:[o],{blockhash:d}=await e.getLatestBlockhash(),h=I([B.setComputeUnitLimit({units:5e5}),l],n,d,p);return await v(e,h,a)}async function Cs(e,n,r,o,i,s=0,a=0,u){b();const c=await Is(e,r,u?.commitment,g);if(!c.tokenMetadata||!c.merkleContext)throw new Error("Mint does not have TokenMetadata extension");const l=c.mintContext?.cmintDecompressed?null:await e.getValidityProofV2([{hash:t(c.merkleContext.hash),leafIndex:c.merkleContext.leafIndex,treeInfo:c.merkleContext.treeInfo,proveByIndex:c.merkleContext.proveByIndex}],[],S.compressible),p=qr(c,o.publicKey,n.publicKey,l,i,s,a),d=o.publicKey.equals(n.publicKey)?[]:[o],{blockhash:h}=await e.getLatestBlockhash(),m=I([B.setComputeUnitLimit({units:5e5}),p],n,h,d);return await v(e,m,u)}async function Ts(t,e,n,r,o=0,i,s=g,a,u){b();const c=a??Gr(s),l=Qo(n,r,o,s,c),p=Jr(e.publicKey,l,r,n,s,c,u);if(s.equals(g)){const{blockhash:n}=await t.getLatestBlockhash(),r=I([B.setComputeUnitLimit({units:3e4}),p],e,n,[]);await v(t,r,i)}else{const n=(new _).add(p);await L(t,n,[e],i)}return l}async function Es(t,e,n,r,o=0,i,s=g,a,u){b();const c=a??Gr(s),l=Qo(n,r,o,s,c),p=to(e.publicKey,l,r,n,s,c,u);if(s.equals(g)){const{blockhash:n}=await t.getLatestBlockhash(),r=I([B.setComputeUnitLimit({units:3e4}),p],e,n,[]);await v(t,r,i)}else{const n=(new _).add(p);await L(t,n,[e],i)}return l}async function Bs(t,e,n,r,o,i,s,a){b();const u=o.publicKey.equals(e.publicKey)?void 0:e.publicKey,c=no({mint:n,destination:r,amount:i,authority:o.publicKey,maxTopUp:s,feePayer:u}),l=o.publicKey.equals(e.publicKey)?[]:[o],{blockhash:p}=await t.getLatestBlockhash(),d=I([B.setComputeUnitLimit({units:2e5}),c],e,p,l);return await v(t,d,a)}async function Us(e,n,r,o,i,s,a=3,u){b();const c=await Is(e,r,u?.commitment,g);if(!c.merkleContext)throw new Error("Mint does not have MerkleContext");if(!s){const t=await e.getStateTreeInfos();s=P(t)}const l=await e.getValidityProofV2([{hash:t(c.merkleContext.hash),leafIndex:c.merkleContext.leafIndex,treeInfo:c.merkleContext.treeInfo,proveByIndex:c.merkleContext.proveByIndex}],[],S.compressible),p=ro(o.publicKey,n.publicKey,l,c.merkleContext,{supply:c.mint.supply,decimals:c.mint.decimals,mintAuthority:c.mint.mintAuthority,freezeAuthority:c.mint.freezeAuthority,splMint:c.mintContext.splMint,cmintDecompressed:c.mintContext.cmintDecompressed,version:c.mintContext.version,mintSigner:c.mintContext.mintSigner,bump:c.mintContext.bump,metadata:c.tokenMetadata?{updateAuthority:c.tokenMetadata.updateAuthority||null,name:c.tokenMetadata.name,symbol:c.tokenMetadata.symbol,uri:c.tokenMetadata.uri}:void 0},i,s,a),d=o.publicKey.equals(n.publicKey)?[]:[o],{blockhash:h}=await e.getLatestBlockhash(),m=I([B.setComputeUnitLimit({units:5e5}),p],n,h,d);return await v(e,m,u)}async function _s(t,e,n,r,o,i,s=[],a,u){b();const c=await Is(t,n,a?.commitment,u),l=o instanceof x?o:o.publicKey,p=s.map((t=>t.publicKey)),d=oo(c,r,l,e.publicKey,i,0,p),h=[];o instanceof x||o.publicKey.equals(e.publicKey)||h.push(o),h.push(...s);const{blockhash:m}=await t.getLatestBlockhash(),f=I([B.setComputeUnitLimit({units:2e5}),d],e,m,h);return await v(t,f,a)}async function Ls(t,e,n,r,o=0,i,s,a=g,u=Gr(a)){return b(),Os(t,e,n,r,o,i,s,a,u,0)}function Ws(t){if(!("publicKey"in t)||!("secretKey"in t))return 0;const e=t;return e.secretKey instanceof Uint8Array&&e.secretKey.length>0}function Ds(t){return Ws(t)?t.publicKey:t}async function Os(t,e,n,r,o,i,s,a,u,c){const l=Ds(r),p=z(n,l,o,a,u);return a.equals(g)?async function(t,e,n,r,o,i,s,a=0,u=0){const c=Ds(r);let l;Ws(r);let p=0;try{l=await Ho(t,o,c,n,i,g,a,u),p=l._sources?.some((t=>t.type===Vo.CTokenHot))??0}catch(r){if(!(r instanceof Y||r instanceof G))throw r;await Rs(t,e,n,c,o,s),l=await Ho(t,o,c,n,i,g,a,u),p=1}if(p||await Rs(t,e,n,c,o,s),Ws(r)){const p=l._sources??[],d=p.some((t=>t.type===Vo.CTokenCold&&t.amount>BigInt(0))),h=a&&p.some((t=>(t.type===Vo.Spl||t.type===Vo.Token2022)&&t.amount>BigInt(0)));if(d||h){if(!(r.secretKey instanceof Uint8Array)||0===r.secretKey.length)throw new Error("Owner must be a valid Signer with secretKey to auto-load");await hi(t,o,r,n,e,s,void 0,a),l=await Ho(t,o,c,n,i,g,a,u)}}const d=l.parsed;if(!d.mint.equals(n))throw new Q;if(!d.owner.equals(c))throw new X;return l}(t,e,n,r,p,i,s,c,o):async function(t,e,n,r,o,i,s,a,u){let c;try{c=await jo(t,o,a,i)}catch(l){if(!(l instanceof Y||l instanceof G))throw l;try{const a=(new _).add(Jr(e.publicKey,o,r,n,i,s));await L(t,a,[e],u)}catch{}c=await jo(t,o,a,i)}const l=c.parsed;if(!l.mint.equals(n))throw new Q;if(!l.owner.equals(r))throw new X;return c}(t,e,n,l,p,a,u,i,s)}async function Rs(t,e,n,r,o,i){try{const s=to(e.publicKey,o,r,n,g),{blockhash:a}=await t.getLatestBlockhash(),u=I([B.setComputeUnitLimit({units:2e5}),s],e,a,[]);await v(t,u,i)}catch{}}const qs=1232,Ks=900,Vs=1e3;function zs(t){return t<128?1:t<16384?2:3}function Fs(t,e){const n=new Set;for(const e of t){n.add(e.programId.toBase58());for(const t of e.keys)n.add(t.pubkey.toBase58())}const r=n.size,o=zs(e)+64*e,i=zs(r)+32*r;let s=zs(t.length);for(const e of t)s+=1,s+=zs(e.keys.length),s+=e.keys.length,s+=zs(e.data.length),s+=e.data.length;return o+1+3+i+32+s+zs(0)}async function Ns(t,e,n,r,o,i,s,a=g,u,c,l=0){b();const p=Qo(r,i.publicKey,0,a);if(!n.equals(p))throw new Error(`Source mismatch. Expected ${p.toBase58()}, got ${n.toBase58()}`);const d=BigInt(s.toString()),h=await Hs(t,e.publicKey,r,d,i.publicKey,o,{...c,wrap:l,programId:a,ensureRecipientAta:1}),m=k(e,[i]),{rest:f,last:y}=$s(h);f.length>0&&await Promise.all(f.map((async n=>{const{blockhash:r}=await t.getLatestBlockhash(),o=I(n,e,r,m);return v(t,o,u)})));const{blockhash:w}=await t.getLatestBlockhash(),M=I(y,e,w,m);return v(t,M,u)}function $s(t){if(0===t.length)throw new Error("sliceLast: array must not be empty");return{rest:t.slice(0,-1),last:t.at(-1)}}function Ys(t){let e=1e4;if(t&&(t.hasAtaCreation&&(e+=3e4),e+=5e4*t.wrapCount,t.compressedAccounts.length>0)){e+=5e4,t.compressedAccounts.some((t=>!t.compressedAccount.proveByIndex))&&(e+=1e5);for(const n of t.compressedAccounts)e+=n.compressedAccount.proveByIndex?1e4:3e4}return e=Math.ceil(1.3*e),Math.max(5e4,Math.min(14e5,e))}function js(t,e){const n=Fs(t,e);if(n>qs)throw new Error(`Batch exceeds max transaction size: ${n} > ${qs}. This indicates a bug in batch assembly.`)}async function Hs(t,e,n,r,o,i,s){b();const a=BigInt(r.toString());if(a<=BigInt(0))throw new Error("Transfer amount must be greater than zero.");const{wrap:u=0,programId:c=g,ensureRecipientAta:l=1,...p}=s??{};if(!x.isOnCurve(i.toBytes()))throw new Error(`Recipient must be a wallet public key (on-curve), not a PDA or ATA. Got: ${i.toBase58()}`);const d=c.equals(q)||c.equals(K),h=Qo(n,o,0,c),m=Qo(n,i,0,c);let f;try{f=await Ho(t,h,o,n,void 0,c.equals(g)?void 0:c,u)}catch(t){if(t instanceof Y)throw new Error("Sender has no token accounts for this mint.");throw t}const y=f._sources??[],w=d&&!u?c.equals(q)?Vo.Spl:Vo.Token2022:Vo.CTokenHot,k=y.find((t=>t.type===w));if(k?.parsed.isFrozen)throw new Error("Cannot transfer: sender token account is frozen.");const I=y.filter((t=>!t.parsed.isFrozen)).reduce(((t,e)=>t+e.amount),BigInt(0));if(I<a){const t=f.parsed.amount-I,e=t>BigInt(0)?` (${t} frozen, not usable)`:"";throw new Error(`Insufficient balance. Required: ${a}, Available (unfrozen): ${I}${e}`)}const v=await di(t,e,f,p,u,h,a);let M;if(d&&!u){const e=await j(t,n,void 0,c);M=J(h,n,m,o,a,e.decimals,[],c)}else M=so(h,m,o,a);const A=[];l&&A.push(to(e,m,i,n,c,void 0,c.equals(g)?{compressibleConfig:$r}:void 0));const P=e.equals(o)?1:2;if(0===v.length){const t=Ys(null),e=[B.setComputeUnitLimit({units:t}),...A,M];return js(e,P),[e]}if(1===v.length){const t=v[0],e=Ys(t),n=[B.setComputeUnitLimit({units:e}),...A,...t.instructions,M];return js(n,P),[n]}const S=[];for(let t=0;t<v.length-1;t++){const e=v[t],n=pi(e),r=[B.setComputeUnitLimit({units:n}),...e.instructions];js(r,P),S.push(r)}const C=v[v.length-1],T=Ys(C),E=[B.setComputeUnitLimit({units:T}),...A,...C.instructions,M];return js(E,P),S.push(E),S}async function Zs(t,e,r,o,i,s,a,u,c){b();const l=void 0!==u,p=(await t.getCompressedTokenAccountsByOwner(r.publicKey,{mint:o})).items;if(0===p.length)return null;!function(t){const e=t.filter((t=>t.compressedAccount.treeInfo.treeType===n.StateV1)).length;if(e>0)throw new Error(`v3 interface does not support V1 compressed accounts. Found ${e} V1 account(s). Use the main SDK actions (transfer, decompress, merge) to migrate V1 accounts to V2.`)}(p);const d=p.reduce(((t,e)=>t+BigInt(e.parsed.amount.toString())),BigInt(0)),h=i?BigInt(i.toString()):d;if(h>d)throw new Error(`Insufficient compressed balance. Requested: ${h}, Available: ${d}`);const m=[];let f=BigInt(0);for(const t of p){if(f>=h)break;m.push(t),f+=BigInt(t.parsed.amount.toString())}const y=await t.getValidityProofV0(m.map((t=>({hash:t.compressedAccount.hash,tree:t.compressedAccount.treeInfo.tree,queue:t.compressedAccount.treeInfo.queue})))),w=a??r.publicKey;let M;M=l?s??await tt(o,w,0,u.tokenProgram):s??Qo(o,w);const A=[];await t.getAccountInfo(M)||(l?A.push(N(e.publicKey,M,w,o,u.tokenProgram)):A.push(to(e.publicKey,M,w,o,g)));let P=5e4;null!==y.compressedProof&&(P+=1e5);for(const t of m)P+=t.compressedAccount.proveByIndex?1e4:3e4;l&&(P+=5e4);let S=0;l&&(S=(await j(t,o,void 0,u.tokenProgram)).decimals),A.push(Lo(e.publicKey,m,M,h,y,u,S));const{blockhash:x}=await t.getLatestBlockhash(),C=k(e,[r]),T=I([B.setComputeUnitLimit({units:P}),...A],e,x,C);return v(t,T,c)}async function Gs(t,e,n,r,o,i,s,a,u){b();let c=a;if(!c&&(c=(await $e(t,i)).find((t=>t.isInitialized)),!c))throw new Error(`No initialized SPL interface found for mint: ${i.toBase58()}. Please create an SPL interface via createSplInterface().`);const l=await j(t,i,void 0,c.tokenProgram),p=Xo(n,r,o.publicKey,i,s,c,l.decimals,e.publicKey),{blockhash:d}=await t.getLatestBlockhash(),h=k(e,[o]),m=I([B.setComputeUnitLimit({units:2e5}),p],e,d,h);return await v(t,m,u)}async function Qs(t,e,n,r,o,i,s,a,u=0){b(),i??=n;let c=s;if(!c&&(c=(await $e(t,r)).find((t=>t.isInitialized)),!c))throw new Error(`No initialized SPL interface found for mint: ${r.toBase58()}. Please create an SPL interface via createSplInterface().`);if(!await t.getAccountInfo(e))throw new Error(`Destination account does not exist: ${e.toBase58()}. Create it first using getOrCreateAssociatedTokenAccount or createAssociatedTokenAccountIdempotentInstruction.`);const l=Qo(r,n);let p;try{p=await Ho(t,l,n,r,void 0,void 0,u)}catch(t){if(t instanceof Y)throw new Error("No c-token balance to unwrap");throw t}const d=p.parsed.amount;if(d===BigInt(0))throw new Error("No c-token balance to unwrap");const h=o?BigInt(o.toString()):d;if(h>d)throw new Error(`Insufficient c-token balance. Requested: ${h}, Available: ${d}`);const m=await di(t,i,p,a,u,l,void 0!==o?h:void 0),f=gi(l,e,n,r,h,c,(await j(t,r,void 0,c.tokenProgram)).decimals,i),g=[B.setComputeUnitLimit({units:2e5}),f],y=i.equals(n)?1:2,w=[];for(const t of m){const e=pi(t),n=[B.setComputeUnitLimit({units:e}),...t.instructions];Xs(n,y),w.push(n)}return Xs(g,y),w.push(g),w}function Xs(t,e){const n=Fs(t,e);if(n>qs)throw new Error(`Unwrap batch exceeds max transaction size: ${n} > ${qs}. This indicates a bug in batch assembly.`)}async function Js(t,e,n,r,o,i,s,a){const u=await Qs(t,n,r.publicKey,o,i,e.publicKey,s);let c="";for(const n of u){const{blockhash:o}=await t.getLatestBlockhash(),i=k(e,[r]),s=I(n,e,o,i);c=await v(t,s,a)}return c}function ta(t){const e={name:t.name,symbol:t.symbol};return void 0!==t.description&&(e.description=t.description),void 0!==t.image&&(e.image=t.image),void 0!==t.additionalMetadata&&t.additionalMetadata.length>0&&(e.additionalMetadata=t.additionalMetadata),e}nt([rt(ot(),32,"a"),rt(ot(),64,"b"),rt(ot(),32,"c")]);const ea=nt([pt("rootIndex"),lt("proveByIndex"),ot("merkleTreePubkeyIndex"),ot("queuePubkeyIndex"),ct("leafIndex")]);async function na(e,n,r,o,i,s,a){o=t(o);const u=await e.getCompressedTokenAccountsByOwner(i.publicKey,{mint:r}),{accounts:c}=an(u.items,o),[l]=un(c,o),p=await e.getValidityProofV0(l.map((t=>({hash:t.compressedAccount.hash,tree:t.compressedAccount.treeInfo.tree,queue:t.compressedAccount.treeInfo.queue})))),d=await rr.approve({payer:n.publicKey,inputCompressedTokenAccounts:l,toAddress:s,amount:o,recentInputStateRootIndices:p.rootIndices,recentValidityProof:p.compressedProof}),{blockhash:h}=await e.getLatestBlockhash(),m=k(n,[i]),f=I([B.setComputeUnitLimit({units:35e4}),d],n,h,m);return v(e,f,a)}async function ra(t,e,n,r,o,i,s,a,u){s=s??P(await t.getStateTreeInfos()),a=a??He(await $e(t,n));const l=await et(t,e,n,o.publicKey,void 0,void 0,u,a.tokenProgram),p=await rr.approveAndMintTo({feePayer:e.publicKey,mint:n,authority:o.publicKey,authorityTokenAccount:l.address,amount:i,toPubkey:r,outputStateTreeInfo:s,tokenPoolInfo:a}),{blockhash:d}=await t.getLatestBlockhash(),h=k(e,[o]),m=I([B.setComputeUnitLimit({units:15e4+2e4*c(i).length}),...p],e,d,h);return await v(t,m,u)}async function oa(t,e,n,r,o,i,s,a,u,l){a=a??P(await t.getStateTreeInfos()),u=u??He(await $e(t,n));const p=await rr.compress({payer:e.publicKey,owner:o.publicKey,source:i,toAddress:s,amount:r,mint:n,outputStateTreeInfo:a,tokenPoolInfo:u}),d=await t.getLatestBlockhash(),h=k(e,[o]),m=I([B.setComputeUnitLimit({units:13e4+2e4*c(r).length}),p],e,d.blockhash,h);return await v(t,m,l,d)}async function ia(t,e,n,r,o,i,s,a,u){s=s??P(await t.getStateTreeInfos()),a=a??He(await $e(t,n));const c=await rr.compressSplTokenAccount({feePayer:e.publicKey,authority:r.publicKey,tokenAccount:o,mint:n,remainingAmount:i,outputStateTreeInfo:s,tokenPoolInfo:a}),l=await t.getLatestBlockhash(),p=k(e,[r]),d=I([B.setComputeUnitLimit({units:15e4}),c],e,l.blockhash,p);return await v(t,d,u,l)}async function sa(t,e,n,r,o){o=o||await rr.getMintProgramId(n,t);const i=await rr.createSplInterface({feePayer:e.publicKey,mint:n,tokenProgramId:o}),{blockhash:s}=await t.getLatestBlockhash(),a=I([i],e,s);return await v(t,a,r)}nt([ea.replicate("treeInfo"),at(rt(ot(),32),"address"),at(st(),"lamports"),ot("outputStateTreeIndex")]);const aa=sa;async function ua(t,e,n,r,o,i){i=i||await rr.getMintProgramId(n,t);const s=[],a=(await $e(t,n)).slice(0,4),u=[];for(let t=0;t<a.length;t++)a[t].isInitialized||u.push(t);for(let t=0;t<r&&!(t>=u.length);t++)s.push(await rr.addTokenPool({mint:n,feePayer:e.publicKey,tokenProgramId:i,poolIndex:u[t]}));const{blockhash:c}=await t.getLatestBlockhash(),l=I(s,e,c);return await v(t,l,o)}const ca=ua;async function la(t,e,n,r,o){const i=await t.getSlot("finalized"),{instructions:s,address:a}=await rr.createTokenProgramLookupTable({payer:e.publicKey,authority:n.publicKey,mints:r,remainingAccounts:o,recentSlot:i}),u=k(e,[n]),c=[];for(const n of s){const r=await t.getLatestBlockhash(),o=I([n],e,r.blockhash,u),i=await v(t,o,{commitment:"finalized"},r);c.push(i)}return{txIds:c,address:a}}async function pa(e,n,r,o,i,s,a,u){o=t(o);const c=await e.getCompressedTokenAccountsByOwner(i.publicKey,{mint:r}),{accounts:l}=an(c.items,o),[p]=ln(l,o),d=await e.getValidityProofV0(p.map((t=>({hash:t.compressedAccount.hash,tree:t.compressedAccount.treeInfo.tree,queue:t.compressedAccount.treeInfo.queue})))),h=Ze(a=a??await $e(e,r),o),m=await rr.decompress({payer:n.publicKey,inputCompressedTokenAccounts:p,toAddress:s,amount:o,tokenPoolInfos:h,recentInputStateRootIndices:d.rootIndices,recentValidityProof:d.compressedProof}),{blockhash:f}=await e.getLatestBlockhash(),g=k(n,[i]),y=I([B.setComputeUnitLimit({units:35e4}),m],n,f,g);return await v(e,y,u)}async function da(e,r,o,i,s){const a=await e.getCompressedTokenAccountsByOwner(i.publicKey,{mint:o});if(0===a.items.length)throw new Error(`No compressed token accounts found for mint ${o.toBase58()}`);if(1===a.items.length)throw new Error("Only one token account exists, nothing to merge");const{accounts:u,treeType:c}=an(a.items);let l=u,p=c;if(l.length<2){const t=c===n.StateV2?n.StateV1:n.StateV2,e=a.items.filter((e=>e.compressedAccount.treeInfo.treeType===t));if(!(e.length>=2))throw 1===l.length&&1===e.length?new Error("Cannot merge accounts from different tree types (V1/V2). You have 1 V1 and 1 V2 account - nothing to merge within same type."):new Error(`Not enough accounts of the same tree type to merge. Found: ${l.length} ${p===n.StateV1?"V1":"V2"} accounts.`);l=e,p=t}const d=l.slice(0,4),h=await e.getValidityProof(d.map((e=>t(e.compressedAccount.hash)))),m=await rr.mergeTokenAccounts({payer:r.publicKey,owner:i.publicKey,inputCompressedTokenAccounts:d,mint:o,recentValidityProof:h.compressedProof,recentInputStateRootIndices:h.rootIndices}),f=[B.setComputeUnitLimit({units:1e6}),...m],{blockhash:g}=await e.getLatestBlockhash(),y=k(r,[i]),w=I(f,r,g,y);return v(e,w,s)}async function ha(t,e,n,r,o,i,s,a,u){s=s??P(await t.getStateTreeInfos()),a=a??He(await $e(t,n));const c=await rr.mintTo({feePayer:e.publicKey,mint:n,authority:o.publicKey,amount:i,toPubkey:r,outputStateTreeInfo:s,tokenPoolInfo:a}),{blockhash:l}=await t.getLatestBlockhash(),p=k(e,[o]),d=I([B.setComputeUnitLimit({units:1e6}),c],e,l,p);return v(t,d,u)}async function ma(t,e,n,r,o){if(sn(n).size>1)throw new Error("Cannot revoke accounts from different tree types (V1/V2) in the same transaction. Revoke V1 and V2 accounts separately.");const i=await t.getValidityProofV0(n.map((t=>({hash:t.compressedAccount.hash,tree:t.compressedAccount.treeInfo.tree,queue:t.compressedAccount.treeInfo.queue}))));!function(t,e){if(!t.publicKey.equals(e[0].parsed.owner))throw new Error(`Owner ${t.publicKey.toBase58()} does not match account ${e[0].parsed.owner.toBase58()}`)}(r,n),function(t){if(t.some((t=>null===t.parsed.delegate)))throw new Error("Account is not delegated")}(n);const s=await rr.revoke({payer:e.publicKey,inputCompressedTokenAccounts:n,recentInputStateRootIndices:i.rootIndices,recentValidityProof:i.compressedProof}),{blockhash:a}=await t.getLatestBlockhash(),u=k(e,[r]),c=I([B.setComputeUnitLimit({units:5e5}),s],e,a,u);return v(t,c,o)}async function fa(e,n,r,o,i,s,a){o=t(o);const u=await e.getCompressedTokenAccountsByOwner(i.publicKey,{mint:r}),{accounts:c}=an(u.items,o),[l]=ln(c,o),p=await e.getValidityProofV0(l.map((t=>({hash:t.compressedAccount.hash,tree:t.compressedAccount.treeInfo.tree,queue:t.compressedAccount.treeInfo.queue})))),d=await rr.transfer({payer:n.publicKey,inputCompressedTokenAccounts:l,toAddress:s,amount:o,recentInputStateRootIndices:p.rootIndices,recentValidityProof:p.compressedProof}),{blockhash:h}=await e.getLatestBlockhash(),m=k(n,[i]),f=I([B.setComputeUnitLimit({units:5e5}),d],n,h,m);return v(e,f,a)}async function ga(e,n,r,o,i,s,a){o=t(o);const u=await e.getCompressedTokenAccountsByDelegate(i.publicKey,{mint:r}),{accounts:c}=an(u.items,o),[l]=ln(c,o),p=await e.getValidityProofV0(l.map((t=>({hash:t.compressedAccount.hash,tree:t.compressedAccount.treeInfo.tree,queue:t.compressedAccount.treeInfo.queue})))),d=await rr.transfer({payer:n.publicKey,inputCompressedTokenAccounts:l,toAddress:s,amount:o,recentInputStateRootIndices:p.rootIndices,recentValidityProof:p.compressedProof}),{blockhash:h}=await e.getLatestBlockhash(),m=k(n,[i]),f=I([B.setComputeUnitLimit({units:5e5}),d],n,h,m);return v(e,f,a)}async function ya(e,n,r,o,i,s,a,u){o=t(o);const c=await e.getCompressedTokenAccountsByDelegate(i.publicKey,{mint:r}),{accounts:l}=an(c.items,o),[p]=ln(l,o),d=await e.getValidityProofV0(p.map((t=>({hash:t.compressedAccount.hash,tree:t.compressedAccount.treeInfo.tree,queue:t.compressedAccount.treeInfo.queue})))),h=a??Ze(await $e(e,r),o),m=await rr.decompress({payer:n.publicKey,inputCompressedTokenAccounts:p,toAddress:s,amount:o,recentInputStateRootIndices:d.rootIndices,recentValidityProof:d.compressedProof,tokenPoolInfos:h}),{blockhash:f}=await e.getLatestBlockhash(),g=k(n,[i]),y=I([B.setComputeUnitLimit({units:35e4}),m],n,f,g);return v(e,y,u)}const wa={version:"1.2.0",name:"light_compressed_token",instructions:[{name:"createTokenPool",docs:["This instruction creates a token pool for a given mint. Every spl mint","can have one token pool. When a token is compressed the tokens are","transferrred to the token pool, and their compressed equivalent is","minted into a Merkle tree."],accounts:[{name:"feePayer",isMut:1,isSigner:1,docs:["UNCHECKED: only pays fees."]},{name:"tokenPoolPda",isMut:1,isSigner:0},{name:"systemProgram",isMut:0,isSigner:0},{name:"mint",isMut:1,isSigner:0},{name:"tokenProgram",isMut:0,isSigner:0},{name:"cpiAuthorityPda",isMut:0,isSigner:0}],args:[]},{name:"addTokenPool",docs:["This instruction creates an additional token pool for a given mint.","The maximum number of token pools per mint is 5."],accounts:[{name:"feePayer",isMut:1,isSigner:1,docs:["UNCHECKED: only pays fees."]},{name:"tokenPoolPda",isMut:1,isSigner:0},{name:"existingTokenPoolPda",isMut:0,isSigner:0},{name:"systemProgram",isMut:0,isSigner:0},{name:"mint",isMut:1,isSigner:0},{name:"tokenProgram",isMut:0,isSigner:0},{name:"cpiAuthorityPda",isMut:0,isSigner:0}],args:[{name:"tokenPoolIndex",type:"u8"}]},{name:"mintTo",docs:["Mints tokens from an spl token mint to a list of compressed accounts.","Minted tokens are transferred to a pool account owned by the compressed","token program. The instruction creates one compressed output account for","every amount and pubkey input pair. A constant amount of lamports can be","transferred to each output account to enable. A use case to add lamports","to a compressed token account is to prevent spam. This is the only way","to add lamports to a compressed token account."],accounts:[{name:"feePayer",isMut:1,isSigner:1,docs:["UNCHECKED: only pays fees."]},{name:"authority",isMut:0,isSigner:1},{name:"cpiAuthorityPda",isMut:0,isSigner:0},{name:"mint",isMut:1,isSigner:0},{name:"tokenPoolPda",isMut:1,isSigner:0},{name:"tokenProgram",isMut:0,isSigner:0},{name:"lightSystemProgram",isMut:0,isSigner:0},{name:"registeredProgramPda",isMut:0,isSigner:0},{name:"noopProgram",isMut:0,isSigner:0,docs:["programs"]},{name:"accountCompressionAuthority",isMut:0,isSigner:0},{name:"accountCompressionProgram",isMut:0,isSigner:0},{name:"merkleTree",isMut:1,isSigner:0},{name:"selfProgram",isMut:0,isSigner:0},{name:"systemProgram",isMut:0,isSigner:0},{name:"solPoolPda",isMut:1,isSigner:0,isOptional:1}],args:[{name:"publicKeys",type:{vec:"publicKey"}},{name:"amounts",type:{vec:"u64"}},{name:"lamports",type:{option:"u64"}}]},{name:"compressSplTokenAccount",docs:["Compresses the balance of an spl token account sub an optional remaining","amount. This instruction does not close the spl token account. To close","the account bundle a close spl account instruction in your transaction."],accounts:[{name:"feePayer",isMut:1,isSigner:1,docs:["UNCHECKED: only pays fees."]},{name:"authority",isMut:0,isSigner:1,docs:["Authority is verified through proof since both owner and delegate","are included in the token data hash, which is a public input to the","validity proof."]},{name:"cpiAuthorityPda",isMut:0,isSigner:0},{name:"lightSystemProgram",isMut:0,isSigner:0},{name:"registeredProgramPda",isMut:0,isSigner:0},{name:"noopProgram",isMut:0,isSigner:0},{name:"accountCompressionAuthority",isMut:0,isSigner:0},{name:"accountCompressionProgram",isMut:0,isSigner:0},{name:"selfProgram",isMut:0,isSigner:0,docs:["this program is the signer of the cpi."]},{name:"tokenPoolPda",isMut:1,isSigner:0,isOptional:1},{name:"compressOrDecompressTokenAccount",isMut:1,isSigner:0,isOptional:1},{name:"tokenProgram",isMut:0,isSigner:0,isOptional:1},{name:"systemProgram",isMut:0,isSigner:0}],args:[{name:"owner",type:"publicKey"},{name:"remainingAmount",type:{option:"u64"}},{name:"cpiContext",type:{option:{defined:"CompressedCpiContext"}}}]},{name:"transfer",docs:["Transfers compressed tokens from one account to another. All accounts","must be of the same mint. Additional spl tokens can be compressed or","decompressed. In one transaction only compression or decompression is","possible. Lamports can be transferred alongside tokens. If output token","accounts specify less lamports than inputs the remaining lamports are","transferred to an output compressed account. Signer must be owner or","delegate. If a delegated token account is transferred the delegate is","not preserved."],accounts:[{name:"feePayer",isMut:1,isSigner:1,docs:["UNCHECKED: only pays fees."]},{name:"authority",isMut:0,isSigner:1,docs:["Authority is verified through proof since both owner and delegate","are included in the token data hash, which is a public input to the","validity proof."]},{name:"cpiAuthorityPda",isMut:0,isSigner:0},{name:"lightSystemProgram",isMut:0,isSigner:0},{name:"registeredProgramPda",isMut:0,isSigner:0},{name:"noopProgram",isMut:0,isSigner:0},{name:"accountCompressionAuthority",isMut:0,isSigner:0},{name:"accountCompressionProgram",isMut:0,isSigner:0},{name:"selfProgram",isMut:0,isSigner:0,docs:["this program is the signer of the cpi."]},{name:"tokenPoolPda",isMut:1,isSigner:0,isOptional:1},{name:"compressOrDecompressTokenAccount",isMut:1,isSigner:0,isOptional:1},{name:"tokenProgram",isMut:0,isSigner:0,isOptional:1},{name:"systemProgram",isMut:0,isSigner:0}],args:[{name:"inputs",type:"bytes"}]},{name:"approve",docs:["Delegates an amount to a delegate. A compressed token account is either","completely delegated or not. Prior delegates are not preserved. Cannot","be called by a delegate.","The instruction creates two output accounts:","1. one account with delegated amount","2. one account with remaining(change) amount"],accounts:[{name:"feePayer",isMut:1,isSigner:1,docs:["UNCHECKED: only pays fees."]},{name:"authority",isMut:0,isSigner:1,docs:["Authority is verified through proof since both owner and delegate","are included in the token data hash, which is a public input to the","validity proof."]},{name:"cpiAuthorityPda",isMut:0,isSigner:0},{name:"lightSystemProgram",isMut:0,isSigner:0},{name:"registeredProgramPda",isMut:0,isSigner:0},{name:"noopProgram",isMut:0,isSigner:0},{name:"accountCompressionAuthority",isMut:0,isSigner:0},{name:"accountCompressionProgram",isMut:0,isSigner:0},{name:"selfProgram",isMut:0,isSigner:0,docs:["this program is the signer of the cpi."]},{name:"systemProgram",isMut:0,isSigner:0}],args:[{name:"inputs",type:"bytes"}]},{name:"revoke",docs:["Revokes a delegation. The instruction merges all inputs into one output","account. Cannot be called by a delegate. Delegates are not preserved."],accounts:[{name:"feePayer",isMut:1,isSigner:1,docs:["UNCHECKED: only pays fees."]},{name:"authority",isMut:0,isSigner:1,docs:["Authority is verified through proof since both owner and delegate","are included in the token data hash, which is a public input to the","validity proof."]},{name:"cpiAuthorityPda",isMut:0,isSigner:0},{name:"lightSystemProgram",isMut:0,isSigner:0},{name:"registeredProgramPda",isMut:0,isSigner:0},{name:"noopProgram",isMut:0,isSigner:0},{name:"accountCompressionAuthority",isMut:0,isSigner:0},{name:"accountCompressionProgram",isMut:0,isSigner:0},{name:"selfProgram",isMut:0,isSigner:0,docs:["this program is the signer of the cpi."]},{name:"systemProgram",isMut:0,isSigner:0}],args:[{name:"inputs",type:"bytes"}]},{name:"freeze",docs:["Freezes compressed token accounts. Inputs must not be frozen. Creates as","many outputs as inputs. Balances and delegates are preserved."],accounts:[{name:"feePayer",isMut:1,isSigner:1,docs:["UNCHECKED: only pays fees."]},{name:"authority",isMut:0,isSigner:1},{name:"cpiAuthorityPda",isMut:0,isSigner:0},{name:"lightSystemProgram",isMut:0,isSigner:0},{name:"registeredProgramPda",isMut:0,isSigner:0},{name:"noopProgram",isMut:0,isSigner:0},{name:"accountCompressionAuthority",isMut:0,isSigner:0},{name:"accountCompressionProgram",isMut:0,isSigner:0},{name:"selfProgram",isMut:0,isSigner:0,docs:["that this program is the signer of the cpi."]},{name:"systemProgram",isMut:0,isSigner:0},{name:"mint",isMut:0,isSigner:0}],args:[{name:"inputs",type:"bytes"}]},{name:"thaw",docs:["Thaws frozen compressed token accounts. Inputs must be frozen. Creates","as many outputs as inputs. Balances and delegates are preserved."],accounts:[{name:"feePayer",isMut:1,isSigner:1,docs:["UNCHECKED: only pays fees."]},{name:"authority",isMut:0,isSigner:1},{name:"cpiAuthorityPda",isMut:0,isSigner:0},{name:"lightSystemProgram",isMut:0,isSigner:0},{name:"registeredProgramPda",isMut:0,isSigner:0},{name:"noopProgram",isMut:0,isSigner:0},{name:"accountCompressionAuthority",isMut:0,isSigner:0},{name:"accountCompressionProgram",isMut:0,isSigner:0},{name:"selfProgram",isMut:0,isSigner:0,docs:["that this program is the signer of the cpi."]},{name:"systemProgram",isMut:0,isSigner:0},{name:"mint",isMut:0,isSigner:0}],args:[{name:"inputs",type:"bytes"}]},{name:"burn",docs:["Burns compressed tokens and spl tokens from the pool account. Delegates","can burn tokens. The output compressed token account remains delegated.","Creates one output compressed token account."],accounts:[{name:"feePayer",isMut:1,isSigner:1,docs:["UNCHECKED: only pays fees."]},{name:"authority",isMut:0,isSigner:1,docs:["Authority is verified through proof since both owner and delegate","are included in the token data hash, which is a public input to the","validity proof."]},{name:"cpiAuthorityPda",isMut:0,isSigner:0},{name:"mint",isMut:1,isSigner:0},{name:"tokenPoolPda",isMut:1,isSigner:0},{name:"tokenProgram",isMut:0,isSigner:0},{name:"lightSystemProgram",isMut:0,isSigner:0},{name:"registeredProgramPda",isMut:0,isSigner:0},{name:"noopProgram",isMut:0,isSigner:0},{name:"accountCompressionAuthority",isMut:0,isSigner:0},{name:"accountCompressionProgram",isMut:0,isSigner:0},{name:"selfProgram",isMut:0,isSigner:0},{name:"systemProgram",isMut:0,isSigner:0}],args:[{name:"inputs",type:"bytes"}]},{name:"stubIdlBuild",docs:["This function is a stub to allow Anchor to include the input types in","the IDL. It should not be included in production builds nor be called in","practice."],accounts:[{name:"feePayer",isMut:1,isSigner:1,docs:["UNCHECKED: only pays fees."]},{name:"authority",isMut:0,isSigner:1,docs:["Authority is verified through proof since both owner and delegate","are included in the token data hash, which is a public input to the","validity proof."]},{name:"cpiAuthorityPda",isMut:0,isSigner:0},{name:"lightSystemProgram",isMut:0,isSigner:0},{name:"registeredProgramPda",isMut:0,isSigner:0},{name:"noopProgram",isMut:0,isSigner:0},{name:"accountCompressionAuthority",isMut:0,isSigner:0},{name:"accountCompressionProgram",isMut:0,isSigner:0},{name:"selfProgram",isMut:0,isSigner:0,docs:["this program is the signer of the cpi."]},{name:"tokenPoolPda",isMut:1,isSigner:0,isOptional:1},{name:"compressOrDecompressTokenAccount",isMut:1,isSigner:0,isOptional:1},{name:"tokenProgram",isMut:0,isSigner:0,isOptional:1},{name:"systemProgram",isMut:0,isSigner:0}],args:[{name:"inputs1",type:{defined:"CompressedTokenInstructionDataTransfer"}},{name:"inputs2",type:{defined:"TokenData"}}]}],types:[{name:"AccountState",type:{kind:"enum",variants:[{name:"Initialized"},{name:"Frozen"}]}},{name:"CompressedAccount",type:{kind:"struct",fields:[{name:"owner",type:"publicKey"},{name:"lamports",type:"u64"},{name:"address",type:{option:{array:["u8",32]}}},{name:"data",type:{option:{defined:"CompressedAccountData"}}}]}},{name:"CompressedAccountData",type:{kind:"struct",fields:[{name:"discriminator",type:{array:["u8",8]}},{name:"data",type:"bytes"},{name:"dataHash",type:{array:["u8",32]}}]}},{name:"CompressedCpiContext",type:{kind:"struct",fields:[{name:"setContext",docs:["Is set by the program that is invoking the CPI to signal that is should","set the cpi context."],type:"bool"},{name:"firstSetContext",docs:["Is set to wipe the cpi context since someone could have set it before","with unrelated data."],type:"bool"},{name:"cpiContextAccountIndex",docs:["Index of cpi context account in remaining accounts."],type:"u8"}]}},{name:"CompressedProof",type:{kind:"struct",fields:[{name:"a",type:{array:["u8",32]}},{name:"b",type:{array:["u8",64]}},{name:"c",type:{array:["u8",32]}}]}},{name:"CompressedTokenInstructionDataTransfer",type:{kind:"struct",fields:[{name:"proof",type:{option:{defined:"CompressedProof"}}},{name:"mint",type:"publicKey"},{name:"delegatedTransfer",docs:["Is required if the signer is delegate,","-> delegate is authority account,","owner = Some(owner) is the owner of the token account."],type:{option:{defined:"DelegatedTransfer"}}},{name:"inputTokenDataWithContext",type:{vec:{defined:"InputTokenDataWithContext"}}},{name:"outputCompressedAccounts",type:{vec:{defined:"PackedTokenTransferOutputData"}}},{name:"isCompress",type:"bool"},{name:"compressOrDecompressAmount",type:{option:"u64"}},{name:"cpiContext",type:{option:{defined:"CompressedCpiContext"}}},{name:"lamportsChangeAccountMerkleTreeIndex",type:{option:"u8"}}]}},{name:"CompressedTokenInstructionDataRevoke",type:{kind:"struct",fields:[{name:"proof",type:{option:{defined:"CompressedProof"}}},{name:"mint",type:"publicKey"},{name:"inputTokenDataWithContext",type:{vec:{defined:"InputTokenDataWithContext"}}},{name:"cpiContext",type:{option:{defined:"CompressedCpiContext"}}},{name:"outputAccountMerkleTreeIndex",type:"u8"}]}},{name:"CompressedTokenInstructionDataApprove",type:{kind:"struct",fields:[{name:"proof",type:{option:{defined:"CompressedProof"}}},{name:"mint",type:"publicKey"},{name:"inputTokenDataWithContext",type:{vec:{defined:"InputTokenDataWithContext"}}},{name:"cpiContext",type:{option:{defined:"CompressedCpiContext"}}},{name:"delegate",type:"publicKey"},{name:"delegatedAmount",type:"u64"},{name:"delegateMerkleTreeIndex",type:"u8"},{name:"changeAccountMerkleTreeIndex",type:"u8"},{name:"delegateLamports",type:{option:"u64"}}]}},{name:"DelegatedTransfer",docs:["Struct to provide the owner when the delegate is signer of the transaction."],type:{kind:"struct",fields:[{name:"owner",type:"publicKey"},{name:"delegateChangeAccountIndex",docs:["Index of change compressed account in output compressed accounts. In","case that the delegate didn't spend the complete delegated compressed","account balance the change compressed account will be delegated to her","as well."],type:{option:"u8"}}]}},{name:"InputTokenDataWithContext",type:{kind:"struct",fields:[{name:"amount",type:"u64"},{name:"delegateIndex",type:{option:"u8"}},{name:"merkleContext",type:{defined:"PackedMerkleContext"}},{name:"rootIndex",type:"u16"},{name:"lamports",type:{option:"u64"}},{name:"tlv",docs:["Placeholder for TokenExtension tlv data (unimplemented)"],type:{option:"bytes"}}]}},{name:"InstructionDataInvoke",type:{kind:"struct",fields:[{name:"proof",type:{option:{defined:"CompressedProof"}}},{name:"inputCompressedAccountsWithMerkleContext",type:{vec:{defined:"PackedCompressedAccountWithMerkleContext"}}},{name:"outputCompressedAccounts",type:{vec:{defined:"OutputCompressedAccountWithPackedContext"}}},{name:"relayFee",type:{option:"u64"}},{name:"newAddressParams",type:{vec:{defined:"NewAddressParamsPacked"}}},{name:"compressOrDecompressLamports",type:{option:"u64"}},{name:"isCompress",type:"bool"}]}},{name:"InstructionDataInvokeCpi",type:{kind:"struct",fields:[{name:"proof",type:{option:{defined:"CompressedProof"}}},{name:"newAddressParams",type:{vec:{defined:"NewAddressParamsPacked"}}},{name:"inputCompressedAccountsWithMerkleContext",type:{vec:{defined:"PackedCompressedAccountWithMerkleContext"}}},{name:"outputCompressedAccounts",type:{vec:{defined:"OutputCompressedAccountWithPackedContext"}}},{name:"relayFee",type:{option:"u64"}},{name:"compressOrDecompressLamports",type:{option:"u64"}},{name:"isCompress",type:"bool"},{name:"cpiContext",type:{option:{defined:"CompressedCpiContext"}}}]}},{name:"MerkleTreeSequenceNumber",type:{kind:"struct",fields:[{name:"pubkey",type:"publicKey"},{name:"seq",type:"u64"}]}},{name:"NewAddressParamsPacked",type:{kind:"struct",fields:[{name:"seed",type:{array:["u8",32]}},{name:"addressQueueAccountIndex",type:"u8"},{name:"addressMerkleTreeAccountIndex",type:"u8"},{name:"addressMerkleTreeRootIndex",type:"u16"}]}},{name:"OutputCompressedAccountWithPackedContext",type:{kind:"struct",fields:[{name:"compressedAccount",type:{defined:"CompressedAccount"}},{name:"merkleTreeIndex",type:"u8"}]}},{name:"PackedCompressedAccountWithMerkleContext",type:{kind:"struct",fields:[{name:"compressedAccount",type:{defined:"CompressedAccount"}},{name:"merkleContext",type:{defined:"PackedMerkleContext"}},{name:"rootIndex",docs:["Index of root used in inclusion validity proof."],type:"u16"},{name:"readOnly",docs:["Placeholder to mark accounts read-only unimplemented set to false."],type:"bool"}]}},{name:"PackedMerkleContext",type:{kind:"struct",fields:[{name:"merkleTreePubkeyIndex",type:"u8"},{name:"queuePubkeyIndex",type:"u8"},{name:"leafIndex",type:"u32"},{name:"proveByIndex",type:"bool"}]}},{name:"PackedTokenTransferOutputData",type:{kind:"struct",fields:[{name:"owner",type:"publicKey"},{name:"amount",type:"u64"},{name:"lamports",type:{option:"u64"}},{name:"merkleTreeIndex",type:"u8"},{name:"tlv",docs:["Placeholder for TokenExtension tlv data (unimplemented)"],type:{option:"bytes"}}]}},{name:"PublicTransactionEvent",type:{kind:"struct",fields:[{name:"inputCompressedAccountHashes",type:{vec:{array:["u8",32]}}},{name:"outputCompressedAccountHashes",type:{vec:{array:["u8",32]}}},{name:"outputCompressedAccounts",type:{vec:{defined:"OutputCompressedAccountWithPackedContext"}}},{name:"outputLeafIndices",type:{vec:"u32"}},{name:"sequenceNumbers",type:{vec:{defined:"MerkleTreeSequenceNumber"}}},{name:"relayFee",type:{option:"u64"}},{name:"isCompress",type:"bool"},{name:"compressOrDecompressLamports",type:{option:"u64"}},{name:"pubkeyArray",type:{vec:"publicKey"}},{name:"message",type:{option:"bytes"}}]}},{name:"QueueIndex",type:{kind:"struct",fields:[{name:"queueId",docs:["Id of queue in queue account."],type:"u8"},{name:"index",docs:["Index of compressed account hash in queue."],type:"u16"}]}},{name:"TokenData",type:{kind:"struct",fields:[{name:"mint",docs:["The mint associated with this account"],type:"publicKey"},{name:"owner",docs:["The owner of this account."],type:"publicKey"},{name:"amount",docs:["The amount of tokens this account holds."],type:"u64"},{name:"delegate",docs:["If `delegate` is `Some` then `delegated_amount` represents","the amount authorized by the delegate"],type:{option:"publicKey"}},{name:"state",docs:["The account's state"],type:{defined:"AccountState"}},{name:"tlv",docs:["Placeholder for TokenExtension tlv data (unimplemented)"],type:{option:"bytes"}}]}}],errors:[{code:6e3,name:"PublicKeyAmountMissmatch",msg:"public keys and amounts must be of same length"},{code:6001,name:"ComputeInputSumFailed",msg:"ComputeInputSumFailed"},{code:6002,name:"ComputeOutputSumFailed",msg:"ComputeOutputSumFailed"},{code:6003,name:"ComputeCompressSumFailed",msg:"ComputeCompressSumFailed"},{code:6004,name:"ComputeDecompressSumFailed",msg:"ComputeDecompressSumFailed"},{code:6005,name:"SumCheckFailed",msg:"SumCheckFailed"},{code:6006,name:"DecompressRecipientUndefinedForDecompress",msg:"DecompressRecipientUndefinedForDecompress"},{code:6007,name:"CompressedPdaUndefinedForDecompress",msg:"CompressedPdaUndefinedForDecompress"},{code:6008,name:"DeCompressAmountUndefinedForDecompress",msg:"DeCompressAmountUndefinedForDecompress"},{code:6009,name:"CompressedPdaUndefinedForCompress",msg:"CompressedPdaUndefinedForCompress"},{code:6010,name:"DeCompressAmountUndefinedForCompress",msg:"DeCompressAmountUndefinedForCompress"},{code:6011,name:"DelegateSignerCheckFailed",msg:"DelegateSignerCheckFailed"},{code:6012,name:"MintTooLarge",msg:"Minted amount greater than u64::MAX"},{code:6013,name:"SplTokenSupplyMismatch",msg:"SplTokenSupplyMismatch"},{code:6014,name:"HeapMemoryCheckFailed",msg:"HeapMemoryCheckFailed"},{code:6015,name:"InstructionNotCallable",msg:"The instruction is not callable"},{code:6016,name:"ArithmeticUnderflow",msg:"ArithmeticUnderflow"},{code:6017,name:"HashToFieldError",msg:"HashToFieldError"},{code:6018,name:"InvalidAuthorityMint",msg:"Expected the authority to be also a mint authority"},{code:6019,name:"InvalidFreezeAuthority",msg:"Provided authority is not the freeze authority"},{code:6020,name:"InvalidDelegateIndex"},{code:6021,name:"TokenPoolPdaUndefined"},{code:6022,name:"IsTokenPoolPda",msg:"Compress or decompress recipient is the same account as the token pool pda."},{code:6023,name:"InvalidTokenPoolPda"},{code:6024,name:"NoInputTokenAccountsProvided"},{code:6025,name:"NoInputsProvided"},{code:6026,name:"MintHasNoFreezeAuthority"},{code:6027,name:"MintWithInvalidExtension"},{code:6028,name:"InsufficientTokenAccountBalance",msg:"The token account balance is less than the remaining amount."},{code:6029,name:"InvalidTokenPoolBump",msg:"Max number of token pools reached."},{code:6030,name:"FailedToDecompress"},{code:6031,name:"FailedToBurnSplTokensFromTokenPool"},{code:6032,name:"NoMatchingBumpFound"}]};function ba(t){return!Array.isArray(t)}const ka=ba;export{Ms as $,gi as A,Qs as B,rr as C,Lo as D,so as E,$r as F,wi as G,Ts as H,Es as I,Qo as J,Ls as K,Ns as L,qs as M,Hs as N,$s as O,Zs as P,Gs as Q,Bs as R,Us as S,_s as T,As as U,Ps as V,Ss as W,xs as X,Cs as Y,Is as Z,vs as _,mi as a,Ae as a$,jo as a0,$o as a1,Yo as a2,No as a3,Fo as a4,ms as a5,fs as a6,ys as a7,ws as a8,ks as a9,Ge as aA,Qe as aB,Xe as aC,Je as aD,tn as aE,en as aF,nn as aG,sn as aH,an as aI,un as aJ,cn as aK,ln as aL,pn as aM,dn as aN,hn as aO,mn as aP,fn as aQ,me as aR,fe as aS,ge as aT,ye as aU,we as aV,be as aW,ke as aX,Ie as aY,ve as aZ,Me as a_,gs as aa,ta as ab,na as ac,ra as ad,oa as ae,ia as af,yi as ag,sa as ah,aa as ai,ua as aj,ca as ak,la as al,pa as am,da as an,ha as ao,ma as ap,fa as aq,ga as ar,ya as as,Ve as at,Fe as au,Ne as av,$e as aw,Ye as ax,He as ay,Ze as az,ci as b,Pe as b0,Se as b1,xe as b2,Ce as b3,Te as b4,Ee as b5,Be as b6,Ue as b7,_e as b8,Le as b9,Rn as bA,qn as bB,Kn as bC,Vn as bD,zn as bE,$n as bF,Yn as bG,jn as bH,Hn as bI,Qn as bJ,Xn as bK,Jn as bL,tr as bM,er as bN,nr as bO,ba as bP,ka as bQ,Os as bR,Gr as bS,Js as bT,or as bU,ir as bV,sr as bW,ar as bX,ur as bY,We as ba,De as bb,Oe as bc,Re as bd,qe as be,Ke as bf,wa as bg,bn as bh,kn as bi,In as bj,vn as bk,Mn as bl,An as bm,Pn as bn,Sn as bo,xn as bp,Cn as bq,Tn as br,En as bs,Bn as bt,Un as bu,_n as bv,Ln as bw,Wn as bx,Dn as by,On as bz,li as c,fi as d,Fs as e,Ks as f,Ho as g,Vs as h,Ur as i,Br as j,Hr as k,hi as l,Zr as m,Jr as n,to as o,eo as p,no as q,ro as r,ri as s,oo as t,Lr as u,Wr as v,Or as w,Rr as x,qr as y,Xo as z};
2
- //# sourceMappingURL=types-MLa8Txs3.js.map