@lightprotocol/compressed-token 0.22.1-alpha.0 → 0.22.1-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -1
- package/dist/cjs/browser/index.cjs +1 -1
- package/dist/cjs/browser/index.cjs.map +1 -1
- package/dist/cjs/browser/types-DZs1jl_2.cjs +2 -0
- package/dist/cjs/browser/types-DZs1jl_2.cjs.map +1 -0
- package/dist/cjs/browser/unified/index.cjs +2 -0
- package/dist/cjs/browser/unified/index.cjs.map +1 -0
- package/dist/cjs/node/index.cjs +1 -1
- package/dist/cjs/node/index.cjs.map +1 -1
- package/dist/cjs/node/types-CxnYquyR.cjs +2 -0
- package/dist/cjs/node/types-CxnYquyR.cjs.map +1 -0
- package/dist/cjs/node/unified/index.cjs +2 -0
- package/dist/cjs/node/unified/index.cjs.map +1 -0
- package/dist/es/browser/index.js +2 -0
- package/dist/es/browser/index.js.map +1 -0
- package/dist/es/browser/types-Drp6Yu8A.js +2 -0
- package/dist/es/browser/types-Drp6Yu8A.js.map +1 -0
- package/dist/es/browser/unified/index.js +2 -0
- package/dist/es/browser/unified/index.js.map +1 -0
- package/dist/types/index.d.ts +2212 -121
- package/dist/types/unified/index.d.ts +5392 -0
- package/package.json +57 -13
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{bn as t,getIndexOrAdd as e,TreeType as n,featureFlags as r,padOutputStateMerkleTrees as o,defaultStaticAccountsStruct as i,toArray as s,LightSystemProgram as a,defaultTestStateTreeAccounts as u,sumUpLamports as c,validateSufficientBalance as l,validateSameOwner as d,deriveAddressV2 as p,CTOKEN_PROGRAM_ID as h,getOutputQueue as m,getDefaultAddressTreeInfo as f,getOutputTreeInfo as y,dedupeSigner as g,buildAndSignTx as w,sendAndConfirmTx as b,packDecompressAccountsIdempotent as k,getBatchAddressTreeInfo as v,selectStateTreeInfo as I,DerivationMode as M}from"@lightprotocol/stateless.js";import{PublicKey as P,SystemProgram as A,TransactionInstruction as x,AddressLookupTableProgram as S,ComputeBudgetProgram as C,Keypair as T,Transaction as E,sendAndConfirmTransaction as B}from"@solana/web3.js";import{unpackAccount as _,MINT_SIZE as L,createInitializeMint2Instruction as U,createMintToInstruction as W,TOKEN_PROGRAM_ID as D,TOKEN_2022_PROGRAM_ID as O,ASSOCIATED_TOKEN_PROGRAM_ID as R,getAssociatedTokenAddressSync as q,createAssociatedTokenAccountInstruction as K,createAssociatedTokenAccountIdempotentInstruction as z,createTransferInstruction as V,AccountState as N,TokenAccountNotFoundError as F,MintLayout as $,getMint as Y,unpackMint as j,TokenInvalidAccountOwnerError as Z,TokenInvalidMintError as H,TokenInvalidOwnerError as G,getAssociatedTokenAddress as Q,getOrCreateAssociatedTokenAccount as J}from"@solana/spl-token";import{struct as X,array as tt,u8 as et,publicKey as nt,u64 as rt,option as ot,vecU8 as it,u32 as st,bool as at,u16 as ut,vec as ct,rustEnum as lt}from"@coral-xyz/borsh";var dt="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},pt=[],ht=[],mt="undefined"!=typeof Uint8Array?Uint8Array:Array,ft=0;function yt(){ft=1;for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",e=0;e<64;++e)pt[e]=t[e],ht[t.charCodeAt(e)]=e;ht["-".charCodeAt(0)]=62,ht["_".charCodeAt(0)]=63}function gt(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(pt[(o=r)>>18&63]+pt[o>>12&63]+pt[o>>6&63]+pt[63&o]);return i.join("")}function wt(t){var e;ft||yt();for(var n=t.length,r=n%3,o="",i=[],s=16383,a=0,u=n-r;a<u;a+=s)i.push(gt(t,a,a+s>u?u:a+s));return 1===r?(e=t[n-1],o+=pt[e>>2],o+=pt[e<<4&63],o+="=="):2===r&&(e=(t[n-2]<<8)+t[n-1],o+=pt[e>>10],o+=pt[e>>4&63],o+=pt[e<<2&63],o+="="),i.push(o),i.join("")}function bt(t,e,n,r,o){var i,s,a=8*o-r-1,u=(1<<a)-1,c=u>>1,l=-7,d=n?o-1:0,p=n?-1:1,h=t[e+d];for(d+=p,i=h&(1<<-l)-1,h>>=-l,l+=a;l>0;i=256*i+t[e+d],d+=p,l-=8);for(s=i&(1<<-l)-1,i>>=-l,l+=r;l>0;s=256*s+t[e+d],d+=p,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 kt(t,e,n,r,o,i){var s,a,u,c=8*i-o-1,l=(1<<c)-1,d=l>>1,p=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+d>=1?p/u:p*Math.pow(2,1-d))*u>=2&&(s++,u/=2),s+d>=l?(a=0,s=l):s+d>=1?(a=(e*u-1)*Math.pow(2,o),s+=d):(a=e*Math.pow(2,d-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 vt={}.toString,It=Array.isArray||function(t){return"[object Array]"==vt.call(t)};xt.TYPED_ARRAY_SUPPORT=void 0!==dt.TYPED_ARRAY_SUPPORT?dt.TYPED_ARRAY_SUPPORT:1;var Mt=Pt();function Pt(){return xt.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function At(t,e){if(Pt()<e)throw new RangeError("Invalid typed array length");return xt.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(e)).__proto__=xt.prototype:(null===t&&(t=new xt(e)),t.length=e),t}function xt(t,e,n){if(!(xt.TYPED_ARRAY_SUPPORT||this instanceof xt))return new xt(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 Tt(this,t)}return St(this,t,e,n)}function St(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),xt.TYPED_ARRAY_SUPPORT?(t=e).__proto__=xt.prototype:t=Et(t,e),t}(t,e,n,r):"string"==typeof e?function(t,e,n){if("string"==typeof n&&""!==n||(n="utf8"),!xt.isEncoding(n))throw new TypeError('"encoding" must be a valid string encoding');var r=0|Lt(e,n),o=(t=At(t,r)).write(e,n);return o!==r&&(t=t.slice(0,o)),t}(t,e,n):function(t,e){if(_t(e)){var n=0|Bt(e.length);return 0===(t=At(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?At(t,0):Et(t,e);if("Buffer"===e.type&&It(e.data))return Et(t,e.data)}var r;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(t,e)}function Ct(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 Tt(t,e){if(Ct(e),t=At(t,e<0?0:0|Bt(e)),!xt.TYPED_ARRAY_SUPPORT)for(var n=0;n<e;++n)t[n]=0;return t}function Et(t,e){var n=e.length<0?0:0|Bt(e.length);t=At(t,n);for(var r=0;r<n;r+=1)t[r]=255&e[r];return t}function Bt(t){if(t>=Pt())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Pt().toString(16)+" bytes");return 0|t}function _t(t){return!(null==t||!t._isBuffer)}function Lt(t,e){if(_t(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 ie(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return se(t).length;default:if(r)return ie(t).length;e=(""+e).toLowerCase(),r=1}}function Ut(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 Ht(this,e,n);case"utf8":case"utf-8":return $t(this,e,n);case"ascii":return jt(this,e,n);case"latin1":case"binary":return Zt(this,e,n);case"base64":return Ft(this,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Gt(this,e,n);default:if(r)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),r=1}}function Wt(t,e,n){var r=t[e];t[e]=t[n],t[n]=r}function Dt(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=xt.from(e,r)),_t(e))return 0===e.length?-1:Ot(t,e,n,r,o);if("number"==typeof e)return e&=255,xt.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,n):Uint8Array.prototype.lastIndexOf.call(t,e,n):Ot(t,[e],n,r,o);throw new TypeError("val must be string, number or Buffer")}function Ot(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 d=1,p=0;p<u;p++)if(c(t,i+p)!==c(e,p)){d=0;break}if(d)return i}return-1}function Rt(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 qt(t,e,n,r){return ae(ie(e,t.length-n),t,n,r)}function Kt(t,e,n,r){return ae(function(t){for(var e=[],n=0;n<t.length;++n)e.push(255&t.charCodeAt(n));return e}(e),t,n,r)}function zt(t,e,n,r){return Kt(t,e,n,r)}function Vt(t,e,n,r){return ae(se(e),t,n,r)}function Nt(t,e,n,r){return ae(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 Ft(t,e,n){return 0===e&&n===t.length?wt(t):wt(t.slice(e,n))}function $t(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,d=c>239?4:c>223?3:c>191?2:1;if(o+d<=n)switch(d){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,d=1):l>65535&&(l-=65536,r.push(l>>>10&1023|55296),l=56320|1023&l),r.push(l),o+=d}return function(t){var e=t.length;if(e<=Yt)return String.fromCharCode.apply(String,t);for(var n="",r=0;r<e;)n+=String.fromCharCode.apply(String,t.slice(r,r+=Yt));return n}(r)}xt.poolSize=8192,xt._augment=function(t){return t.__proto__=xt.prototype,t},xt.from=function(t,e,n){return St(null,t,e,n)},xt.TYPED_ARRAY_SUPPORT&&(xt.prototype.__proto__=Uint8Array.prototype,xt.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&xt[Symbol.species]),xt.alloc=function(t,e,n){return function(t,e,n,r){return Ct(e),e<=0?At(t,e):void 0!==n?"string"==typeof r?At(t,e).fill(n,r):At(t,e).fill(n):At(t,e)}(null,t,e,n)},xt.allocUnsafe=function(t){return Tt(null,t)},xt.allocUnsafeSlow=function(t){return Tt(null,t)},xt.isBuffer=ue,xt.compare=function(t,e){if(!_t(t)||!_t(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},xt.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}},xt.concat=function(t,e){if(!It(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return xt.alloc(0);var n;if(void 0===e)for(e=0,n=0;n<t.length;++n)e+=t[n].length;var r=xt.allocUnsafe(e),o=0;for(n=0;n<t.length;++n){var i=t[n];if(!_t(i))throw new TypeError('"list" argument must be an Array of Buffers');i.copy(r,o),o+=i.length}return r},xt.byteLength=Lt,xt.prototype._isBuffer=1,xt.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)Wt(this,e,e+1);return this},xt.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)Wt(this,e,e+3),Wt(this,e+1,e+2);return this},xt.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)Wt(this,e,e+7),Wt(this,e+1,e+6),Wt(this,e+2,e+5),Wt(this,e+3,e+4);return this},xt.prototype.toString=function(){var t=0|this.length;return 0===t?"":0===arguments.length?$t(this,0,t):Ut.apply(this,arguments)},xt.prototype.equals=function(t){if(!_t(t))throw new TypeError("Argument must be a Buffer");return this===t?1:0===xt.compare(this,t)},xt.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+">"},xt.prototype.compare=function(t,e,n,r,o){if(!_t(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},xt.prototype.includes=function(t,e,n){return-1!==this.indexOf(t,e,n)},xt.prototype.indexOf=function(t,e,n){return Dt(this,t,e,n,1)},xt.prototype.lastIndexOf=function(t,e,n){return Dt(this,t,e,n,0)},xt.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 Rt(this,t,e,n);case"utf8":case"utf-8":return qt(this,t,e,n);case"ascii":return Kt(this,t,e,n);case"latin1":case"binary":return zt(this,t,e,n);case"base64":return Vt(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Nt(this,t,e,n);default:if(i)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),i=1}},xt.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var Yt=4096;function jt(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 Zt(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 Ht(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 Gt(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 Qt(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 Jt(t,e,n,r,o,i){if(!_t(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 Xt(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 te(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 ee(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 ne(t,e,n,r,o){return o||ee(t,0,n,4),kt(t,e,n,r,23,4),n+4}function re(t,e,n,r,o){return o||ee(t,0,n,8),kt(t,e,n,r,52,8),n+8}xt.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),xt.TYPED_ARRAY_SUPPORT)(n=this.subarray(t,e)).__proto__=xt.prototype;else{var o=e-t;n=new xt(o,void 0);for(var i=0;i<o;++i)n[i]=this[i+t]}return n},xt.prototype.readUIntLE=function(t,e,n){t|=0,e|=0,n||Qt(t,e,this.length);for(var r=this[t],o=1,i=0;++i<e&&(o*=256);)r+=this[t+i]*o;return r},xt.prototype.readUIntBE=function(t,e,n){t|=0,e|=0,n||Qt(t,e,this.length);for(var r=this[t+--e],o=1;e>0&&(o*=256);)r+=this[t+--e]*o;return r},xt.prototype.readUInt8=function(t,e){return e||Qt(t,1,this.length),this[t]},xt.prototype.readUInt16LE=function(t,e){return e||Qt(t,2,this.length),this[t]|this[t+1]<<8},xt.prototype.readUInt16BE=function(t,e){return e||Qt(t,2,this.length),this[t]<<8|this[t+1]},xt.prototype.readUInt32LE=function(t,e){return e||Qt(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},xt.prototype.readUInt32BE=function(t,e){return e||Qt(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},xt.prototype.readIntLE=function(t,e,n){t|=0,e|=0,n||Qt(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},xt.prototype.readIntBE=function(t,e,n){t|=0,e|=0,n||Qt(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},xt.prototype.readInt8=function(t,e){return e||Qt(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},xt.prototype.readInt16LE=function(t,e){e||Qt(t,2,this.length);var n=this[t]|this[t+1]<<8;return 32768&n?4294901760|n:n},xt.prototype.readInt16BE=function(t,e){e||Qt(t,2,this.length);var n=this[t+1]|this[t]<<8;return 32768&n?4294901760|n:n},xt.prototype.readInt32LE=function(t,e){return e||Qt(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},xt.prototype.readInt32BE=function(t,e){return e||Qt(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},xt.prototype.readFloatLE=function(t,e){return e||Qt(t,4,this.length),bt(this,t,1,23,4)},xt.prototype.readFloatBE=function(t,e){return e||Qt(t,4,this.length),bt(this,t,0,23,4)},xt.prototype.readDoubleLE=function(t,e){return e||Qt(t,8,this.length),bt(this,t,1,52,8)},xt.prototype.readDoubleBE=function(t,e){return e||Qt(t,8,this.length),bt(this,t,0,52,8)},xt.prototype.writeUIntLE=function(t,e,n,r){t=+t,e|=0,n|=0,r||Jt(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},xt.prototype.writeUIntBE=function(t,e,n,r){t=+t,e|=0,n|=0,r||Jt(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},xt.prototype.writeUInt8=function(t,e,n){return t=+t,e|=0,n||Jt(this,t,e,1,255,0),xt.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},xt.prototype.writeUInt16LE=function(t,e,n){return t=+t,e|=0,n||Jt(this,t,e,2,65535,0),xt.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):Xt(this,t,e,1),e+2},xt.prototype.writeUInt16BE=function(t,e,n){return t=+t,e|=0,n||Jt(this,t,e,2,65535,0),xt.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):Xt(this,t,e,0),e+2},xt.prototype.writeUInt32LE=function(t,e,n){return t=+t,e|=0,n||Jt(this,t,e,4,4294967295,0),xt.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):te(this,t,e,1),e+4},xt.prototype.writeUInt32BE=function(t,e,n){return t=+t,e|=0,n||Jt(this,t,e,4,4294967295,0),xt.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):te(this,t,e,0),e+4},xt.prototype.writeIntLE=function(t,e,n,r){if(t=+t,e|=0,!r){var o=Math.pow(2,8*n-1);Jt(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},xt.prototype.writeIntBE=function(t,e,n,r){if(t=+t,e|=0,!r){var o=Math.pow(2,8*n-1);Jt(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},xt.prototype.writeInt8=function(t,e,n){return t=+t,e|=0,n||Jt(this,t,e,1,127,-128),xt.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},xt.prototype.writeInt16LE=function(t,e,n){return t=+t,e|=0,n||Jt(this,t,e,2,32767,-32768),xt.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):Xt(this,t,e,1),e+2},xt.prototype.writeInt16BE=function(t,e,n){return t=+t,e|=0,n||Jt(this,t,e,2,32767,-32768),xt.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):Xt(this,t,e,0),e+2},xt.prototype.writeInt32LE=function(t,e,n){return t=+t,e|=0,n||Jt(this,t,e,4,2147483647,-2147483648),xt.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):te(this,t,e,1),e+4},xt.prototype.writeInt32BE=function(t,e,n){return t=+t,e|=0,n||Jt(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),xt.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):te(this,t,e,0),e+4},xt.prototype.writeFloatLE=function(t,e,n){return ne(this,t,e,1,n)},xt.prototype.writeFloatBE=function(t,e,n){return ne(this,t,e,0,n)},xt.prototype.writeDoubleLE=function(t,e,n){return re(this,t,e,1,n)},xt.prototype.writeDoubleBE=function(t,e,n){return re(this,t,e,0,n)},xt.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||!xt.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},xt.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&&!xt.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=_t(t)?t:ie(new xt(t,r).toString()),a=s.length;for(i=0;i<n-e;++i)this[i+e]=s[i%a]}return this};var oe=/[^+\/0-9A-Za-z-_]/g;function ie(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 se(t){return function(t){var e,n,r,o,i,s;ft||yt();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 mt(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=ht[t.charCodeAt(e)]<<18|ht[t.charCodeAt(e+1)]<<12|ht[t.charCodeAt(e+2)]<<6|ht[t.charCodeAt(e+3)],s[u++]=o>>16&255,s[u++]=o>>8&255,s[u++]=255&o;return 2===i?(o=ht[t.charCodeAt(e)]<<2|ht[t.charCodeAt(e+1)]>>4,s[u++]=255&o):1===i&&(o=ht[t.charCodeAt(e)]<<10|ht[t.charCodeAt(e+1)]<<4|ht[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(oe,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function ae(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 ue(t){return null!=t&&(!!t._isBuffer||ce(t)||function(t){return"function"==typeof t.readFloatLE&&"function"==typeof t.slice&&ce(t.slice(0,0))}(t))}function ce(t){return!!t.constructor&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)}var le,de=Object.freeze({__proto__:null,Buffer:xt,INSPECT_MAX_BYTES:50,SlowBuffer:function(t){return+t!=t&&(t=0),xt.alloc(+t)},isBuffer:ue,kMaxLength:Mt});!function(t){t[t.V1=1]="V1",t[t.V2=2]="V2",t[t.ShaFlat=3]="ShaFlat"}(le||(le={}));const pe=xt.from("pool"),he=xt.from("cpi_authority"),me=1461600,fe=xt.from([23,169,27,122,147,169,209,152]),ye=xt.from([241,34,48,186,37,179,123,192]),ge=xt.from([65,206,101,37,147,42,221,144]),we=xt.from([163,52,200,231,140,3,69,186]),be=xt.from([112,230,105,101,145,202,157,97]),ke=xt.from([69,74,217,36,115,117,97,76]),ve=xt.from([170,23,31,34,133,173,93,242]),Ie=xt.from([114,143,210,73,96,115,1,228]),Me=xt.from([107]);function Pe(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 Ae(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 xe(e,n,r=0){const[o,i]=Un.deriveSplInterfacePdaWithIndex(e,r);return{mint:e,splInterfacePda:o,tokenProgram:n,activity:void 0,balance:t(0),isInitialized:1,poolIndex:r,bump:i}}function Se(t,e){const n="tokenPoolPda"in t?Ae(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 Ce(e,n,r){const o=Array.from({length:5},((t,e)=>Un.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]?_(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 Te;!function(t){t[t.Compress=1]="Compress",t[t.Decompress=2]="Decompress",t[t.Transfer=3]="Transfer"}(Te||(Te={}));const Ee=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 Be(t){const e=Ee(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 _e(e,n){if(0===e.length)throw new Error("Please pass at least one SPL interface info.");const r=(e=Ee(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 Le(t,e,n=0){return Pe(xe(t,e,n))}function Ue(t,e){return Se(Ae(t),e)}async function We(t,e,n){return(await Ce(t,e,n)).map(Pe)}function De(t){return Pe(Be(t.map(Ae)))}function Oe(t,e){return _e(t.map(Ae),e).map(Pe)}const Re="Could not find accounts to select for transfer.";function qe(t,e,n=4){const r=t.find((t=>t.parsed.amount.eq(e)));return r?[[r],r.parsed.amount,r.compressedAccount.lamports,r.parsed.amount]:ze(t,e,n)}function Ke(t,e,n=4){const[r,o,i,s]=ze(t,e,n);return{selectedAccounts:r,total:o,totalLamports:i,maxPossibleAmount:s}}function ze(e,n,r=4){const[o,i,s,a]=Ve(e,n,r);if(i.lt(t(n))){const i=e.reduce(((t,e)=>t.add(e.parsed.amount)),t(0));throw o.length>=r?new Error(`Account limit exceeded: max ${a.toString()} (${r} accounts) per transaction. Total balance: ${i.toString()} (${e.length} accounts). Consider multiple transfers to spend full balance.`):new Error(`Insufficient balance for transfer. Required: ${n.toString()}, available: ${i.toString()}.`)}if(0===o.length)throw new Error(Re);return[o,i,s,a]}function Ve(e,n,r=4){if(0===e.length)throw new Error(Re);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(Re);return[a,o,i,s]}function Ne(e,n,r=4){const[o,i,s,a]=Fe(e,n,r);if(i.lt(t(n))){const i=e.reduce(((t,e)=>t.add(e.parsed.amount)),t(0));throw o.length>=r?new Error(`Account limit exceeded: max ${a.toString()} (${r} accounts) per transaction. Total balance: ${i.toString()} (${e.length} accounts). Consider multiple transfers to spend full balance.`):new Error(`Insufficient balance. Required: ${n.toString()}, available: ${i.toString()}.`)}if(0===o.length)throw new Error(Re);return[o,i,s,a]}function Fe(e,n,r=4){if(0===e.length)throw new Error(Re);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(Re);return[s,o,i,u]}function $e(i){const{inputCompressedTokenAccounts:s,outputStateTreeInfo:a,remainingAccounts:u=[],rootIndices:c,tokenTransferOutputs:l}=i,d=u.slice();let p=null;s.length>0&&s[0].parsed.delegate&&(p=e(d,s[0].parsed.delegate));const h=[];if(s.forEach(((n,r)=>{const o=e(d,n.compressedAccount.treeInfo.tree),i=e(d,n.compressedAccount.treeInfo.queue);h.push({amount:n.parsed.amount,delegateIndex:p,merkleContext:{merkleTreePubkeyIndex:o,queuePubkeyIndex:i,leafIndex:n.compressedAccount.leafIndex,proveByIndex:n.compressedAccount.proveByIndex},rootIndex:c[r],lamports:n.compressedAccount.lamports.eq(t(0))?null:n.compressedAccount.lamports,tlv:null})})),s.length>0&&a)throw new Error("Cannot specify both input accounts and outputStateTreeInfo");let m;if(s.length>0)m=s[0].compressedAccount.treeInfo;else{if(!a)throw new Error("Neither input accounts nor outputStateTreeInfo are available");m=a}const f=m.nextTreeInfo||m;let y=f.tree;if(f.treeType===n.StateV2){if(!r.isV2())throw new Error("V2 trees are not supported yet");y=f.queue}const g=o(y,l.length),w=[];g.forEach(((n,r)=>{const o=e(d,n);w.push({owner:l[r].owner,amount:l[r].amount,lamports:l[r].lamports?.eq(t(0))?null:l[r].lamports,merkleTreeIndex:o,tlv:null})}));const b=d.map((t=>({pubkey:t,isWritable:1,isSigner:0})));return{inputTokenDataWithContext:h,remainingAccountMetas:b,packedOutputTokenData:w}}function Ye(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 je=X([tt(et(),32,"a"),tt(et(),64,"b"),tt(et(),32,"c")]),Ze=X([nt("owner"),rt("amount"),ot(rt(),"lamports"),et("merkleTreeIndex"),ot(it(),"tlv")]),He=X([rt("amount"),ot(et(),"delegateIndex"),X([et("merkleTreePubkeyIndex"),et("queuePubkeyIndex"),st("leafIndex"),at("proveByIndex")],"merkleContext"),ut("rootIndex"),ot(rt(),"lamports"),ot(it(),"tlv")]),Ge=X([nt("owner"),ot(et(),"delegateChangeAccountIndex")]),Qe=X([at("setContext"),at("firstSetContext"),et("cpiContextAccountIndex")]),Je=X([ot(je,"proof"),nt("mint"),ot(Ge,"delegatedTransfer"),ct(He,"inputTokenDataWithContext"),ct(Ze,"outputCompressedAccounts"),at("isCompress"),ot(rt(),"compressOrDecompressAmount"),ot(Qe,"cpiContext"),ot(et(),"lamportsChangeAccountMerkleTreeIndex")]),Xe=X([ct(nt(),"recipients"),ct(rt(),"amounts"),ot(rt(),"lamports")]),tn=X([ct(nt(),"pubkeys"),ot(ct(rt(),"amounts"),"amounts"),ot(rt(),"lamports"),ot(rt(),"amount"),et("index"),et("bump")]),en=X([nt("owner"),ot(rt(),"remainingAmount"),ot(Qe,"cpiContext")]);function nn(t){const e=xt.alloc(1e3),n=Xe.encode({recipients:t.recipients,amounts:t.amounts,lamports:t.lamports},e);return xt.concat([new Uint8Array(ye),new Uint8Array(e.subarray(0,n))])}function rn(t){return Xe.decode(t.subarray(ye.length))}function on(t){const e=xt.alloc(1e3),n=tn.encode(t,e),r=xt.alloc(4);r.writeUInt32LE(n,0);const o=e.subarray(0,n);return xt.concat([new Uint8Array(ge),new Uint8Array(r),new Uint8Array(o)])}function sn(t){return tn.decode(t.subarray(ge.length+4))}function an(t){const e=xt.alloc(1e3),n=en.encode({owner:t.owner,remainingAmount:t.remainingAmount,cpiContext:t.cpiContext},e);return xt.concat([new Uint8Array(be),new Uint8Array(e.subarray(0,n))])}function un(t){const e=en.decode(t.subarray(be.length));return{owner:e.owner,remainingAmount:e.remainingAmount,cpiContext:e.cpiContext}}function cn(t){const e=xt.alloc(1e3),n=Je.encode(t,e),r=xt.alloc(4);r.writeUInt32LE(n,0);const o=e.subarray(0,n);return xt.concat([new Uint8Array(we),new Uint8Array(r),new Uint8Array(o)])}function ln(t){return Je.decode(t.slice(we.length+4))}const dn=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}]},pn=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}]},hn=t=>{const e=Un.programId,{feePayer:n,authority:r,cpiAuthorityPda:o,mint:i,tokenPoolPda:s,tokenProgram:a,lightSystemProgram:u,registeredProgramPda:c,noopProgram:l,accountCompressionAuthority:d,accountCompressionProgram:p,merkleTree:h,selfProgram:m,systemProgram:f,solPoolPda:y}=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:d,isSigner:0,isWritable:0},{pubkey:p,isSigner:0,isWritable:0},{pubkey:h,isSigner:0,isWritable:1},{pubkey:m,isSigner:0,isWritable:0},{pubkey:f,isSigner:0,isWritable:0},{pubkey:y??e,isSigner:0,isWritable:1}]},mn=t=>{const e=Un.programId,{feePayer:n,authority:r,cpiAuthorityPda:o,lightSystemProgram:i,registeredProgramPda:s,noopProgram:a,accountCompressionAuthority:u,accountCompressionProgram:c,selfProgram:l,tokenPoolPda:d,compressOrDecompressTokenAccount:p,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:d??e,isSigner:0,isWritable:1},{pubkey:p??e,isSigner:0,isWritable:1},{pubkey:h??e,isSigner:0,isWritable:0},{pubkey:m,isSigner:0,isWritable:0}]},fn=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}]},yn=fn,gn=t=>{const{feePayer:e,authority:n,cpiAuthorityPda:r,lightSystemProgram:o,registeredProgramPda:i,noopProgram:s,accountCompressionAuthority:a,accountCompressionProgram:u,selfProgram:c,systemProgram:l,mint:d}=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:d,isSigner:0,isWritable:0}]},wn=gn,bn=X([X([tt(et(),32,"a"),tt(et(),64,"b"),tt(et(),32,"c")],"proof"),nt("mint"),ct(He,"inputTokenDataWithContext"),ot(Qe,"cpiContext"),nt("delegate"),rt("delegatedAmount"),et("delegateMerkleTreeIndex"),et("changeAccountMerkleTreeIndex"),ot(rt(),"delegateLamports")]),kn=X([X([tt(et(),32,"a"),tt(et(),64,"b"),tt(et(),32,"c")],"proof"),nt("mint"),ct(He,"inputTokenDataWithContext"),ot(Qe,"cpiContext"),et("outputAccountMerkleTreeIndex")]),vn={a:new Array(32).fill(0),b:new Array(64).fill(0),c:new Array(32).fill(0)};function In(t){return t.a.every((t=>0===t))&&t.b.every((t=>0===t))&&t.c.every((t=>0===t))}function Mn(t){const e=xt.alloc(1e3),n=t.proof??vn,r=bn.encode({...t,proof:n},e),o=xt.alloc(4);o.writeUInt32LE(r,0);const i=e.subarray(0,r);return xt.concat([new Uint8Array(ke),new Uint8Array(o),new Uint8Array(i)])}function Pn(t){const e=bn.decode(t.subarray(ke.length));return{...e,proof:In(e.proof)?null:e.proof}}function An(t){const e=xt.alloc(1e3),n=t.proof??vn,r=kn.encode({...t,proof:n},e),o=xt.alloc(4);o.writeUInt32LE(r,0);const i=e.subarray(0,r);return xt.concat([new Uint8Array(ve),new Uint8Array(o),new Uint8Array(i)])}function xn(t){const e=kn.decode(t.subarray(ve.length));return{...e,proof:In(e.proof)?null:e.proof}}function Sn(t){return"tokenPoolPda"in t?t.tokenPoolPda??t.splInterfacePda:t.splInterfacePda}const Cn=e=>e.reduce(((t,e)=>t.add(e.parsed.amount)),t(0)),Tn=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")}))},En=t=>({mint:t[0].parsed.mint,currentOwner:t[0].parsed.owner,delegate:t[0].parsed.delegate}),Bn=(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 _n(e,n,r){r=t(r);const o=Cn(e),i=c(e.map((t=>t.compressedAccount))),s=o.sub(r);return l(s),s.eq(t(0))&&i.eq(t(0))?[{owner:n,amount:r,lamports:i,tlv:null}]:(d(e.map((t=>t.compressedAccount))),Tn(e),[{owner:e[0].parsed.owner,amount:s,lamports:i,tlv:null},{owner:n,amount:r,lamports:t(0),tlv:null}])}function Ln(e,n){n=t(n);const r=c(e.map((t=>t.compressedAccount))),o=Cn(e).sub(n);return l(o),o.eq(t(0))&&r.eq(t(0))?[]:(d(e.map((t=>t.compressedAccount))),Tn(e),[{owner:e[0].parsed.owner,amount:o,lamports:r,tlv:null}])}class Un{constructor(){}static programId=new P("cTokenmWW8bLPjZEBAUgYy3zKxQZW6VKi7bqNFEVv3m");static setProgramId(t){this.programId="string"==typeof t?new P(t):t}static deriveSplInterfacePda(t){const e=[pe,t.toBuffer()],[n,r]=P.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=Un.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?[xt.from("pool"),t.toBuffer(),xt.from([])]:[xt.from("pool"),t.toBuffer(),xt.from([e])];const[r,o]=P.findProgramAddressSync(n,this.programId);return[r,o]}static deriveTokenPoolPdaWithIndex(t,e){return this.deriveSplInterfacePdaWithIndex(t,e)}static get deriveCpiAuthorityPda(){const[t,e]=P.findProgramAddressSync([he],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??D;return[A.createAccount({fromPubkey:t,lamports:i,newAccountPubkey:e,programId:u,space:a??L}),U(e,o,n,r,u),await this.createTokenPool({feePayer:t,mint:e,tokenProgramId:u})]}static async createTokenPool({feePayer:t,mint:e,tokenProgramId:n}){const r=n??D,o=this.deriveSplInterfacePdaWithIndex(e,0),i=dn({mint:e,feePayer:t,tokenPoolPda:o[0],tokenProgram:r,cpiAuthorityPda:this.deriveCpiAuthorityPda,systemProgram:A.programId});return new x({programId:this.programId,keys:i,data:fe})}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??D,i=this.deriveSplInterfacePdaWithIndex(e,n-1),s=this.deriveSplInterfacePdaWithIndex(e,n),a=pn({mint:e,feePayer:t,tokenPoolPda:s[0],existingTokenPoolPda:i[0],tokenProgram:o,cpiAuthorityPda:this.deriveCpiAuthorityPda,systemProgram:A.programId});return new x({programId:this.programId,keys:a,data:xt.concat([new Uint8Array(Ie),new Uint8Array(xt.from([n]))])})}static async mintTo({feePayer:e,mint:r,authority:o,toPubkey:u,amount:c,outputStateTreeInfo:l,tokenPoolInfo:d}){const p=i(),h=d.tokenProgram;Se(d,r);const m=s(c).map((e=>t(e))),f=s(u);if(m.length!==f.length)throw new Error("Amount and toPubkey arrays must have the same length");const y=hn({mint:r,feePayer:e,authority:o,cpiAuthorityPda:this.deriveCpiAuthorityPda,tokenProgram:h,tokenPoolPda:Sn(d),lightSystemProgram:a.programId,registeredProgramPda:p.registeredProgramPda,noopProgram:p.noopProgram,accountCompressionAuthority:p.accountCompressionAuthority,accountCompressionProgram:p.accountCompressionProgram,merkleTree:l.treeType===n.StateV2?l.queue:l.tree,selfProgram:this.programId,systemProgram:A.programId,solPoolPda:null}),g=nn({recipients:f,amounts:m,lamports:null});return new x({programId:this.programId,keys:y,data:g})}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[W(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:e,toAddress:n,amount:r,recentValidityProof:o,recentInputStateRootIndices:s}){const u=_n(e,n,r),{inputTokenDataWithContext:c,packedOutputTokenData:l,remainingAccountMetas:d}=$e({inputCompressedTokenAccounts:e,rootIndices:s,tokenTransferOutputs:u}),{mint:p}=En(e),{delegatedTransfer:h,authority:m}=Bn(e,u),f=cn({proof:o,mint:p,delegatedTransfer:h,inputTokenDataWithContext:c,outputCompressedAccounts:l,compressOrDecompressAmount:null,isCompress:0,cpiContext:null,lamportsChangeAccountMerkleTreeIndex:null}),{accountCompressionAuthority:y,noopProgram:g,registeredProgramPda:w,accountCompressionProgram:b}=i(),k=mn({feePayer:t,authority:m,cpiAuthorityPda:this.deriveCpiAuthorityPda,lightSystemProgram:a.programId,registeredProgramPda:w,noopProgram:g,accountCompressionAuthority:y,accountCompressionProgram:b,selfProgram:this.programId,tokenPoolPda:void 0,compressOrDecompressTokenAccount:void 0,tokenProgram:void 0,systemProgram:A.programId});return k.push(...d),new x({programId:this.programId,keys:k,data:f})}static async createTokenProgramLookupTable({payer:t,authority:e,mints:n,recentSlot:r,remainingAccounts:o}){const[s,c]=S.createLookupTable({authority:e,payer:e,recentSlot:r});let l=[];n&&(l=[...n,...n.map((t=>this.deriveSplInterfacePda(t)))]);const d=[s,S.extendLookupTable({payer:t,authority:e,lookupTable:c,addresses:[A.programId,C.programId,this.deriveCpiAuthorityPda,a.programId,Un.programId,i().registeredProgramPda,i().noopProgram,i().accountCompressionAuthority,i().accountCompressionProgram,u().merkleTree,u().nullifierQueue,u().addressTree,u().addressQueue,this.programId,D,O,e,...l]})];if(o&&o.length>0)for(let n=0;n<o.length;n+=25){const r=o.slice(n,n+25),i=S.extendLookupTable({payer:t,authority:e,lookupTable:c,addresses:r});d.push(i)}return{instructions:d,address:c}}static async compress({payer:e,owner:n,source:o,toAddress:u,amount:c,mint:l,outputStateTreeInfo:d,tokenPoolInfo:p}){let h;const m=s(c),f=s(u);if(Se(p,l),m.length!==f.length)throw new Error("Amount and toAddress arrays must have the same length");if(r.isV2()){const[r,s]=this.findSplInterfaceIndexAndBump(Sn(p),l),u=on({pubkeys:f,amounts:m.length>1?m.map((e=>t(e))):null,lamports:null,amount:1===m.length?t(m[0]):null,index:r,bump:s}),c=hn({mint:l,feePayer:e,authority:n,cpiAuthorityPda:this.deriveCpiAuthorityPda,tokenProgram:p.tokenProgram,tokenPoolPda:Sn(p),lightSystemProgram:a.programId,...i(),merkleTree:d.queue,selfProgram:this.programId,systemProgram:A.programId,solPoolPda:null});return c.push({pubkey:o,isWritable:1,isSigner:0}),new x({programId:this.programId,keys:c,data:u})}{h=m.map(((e,n)=>{const r=t(e);return{owner:f[n],amount:r,lamports:null,tlv:null}}));const{inputTokenDataWithContext:r,packedOutputTokenData:s,remainingAccountMetas:u}=$e({inputCompressedTokenAccounts:[],outputStateTreeInfo:d,rootIndices:[],tokenTransferOutputs:h}),y=cn({proof:null,mint:l,delegatedTransfer:null,inputTokenDataWithContext:r,outputCompressedAccounts:s,compressOrDecompressAmount:Array.isArray(c)?c.map((e=>t(e))).reduce(((t,e)=>t.add(e)),t(0)):t(c),isCompress:1,cpiContext:null,lamportsChangeAccountMerkleTreeIndex:null}),g=mn({...i(),feePayer:e,authority:n,cpiAuthorityPda:this.deriveCpiAuthorityPda,lightSystemProgram:a.programId,selfProgram:this.programId,systemProgram:A.programId,tokenPoolPda:Sn(p),compressOrDecompressTokenAccount:o,tokenProgram:p.tokenProgram});return g.push(...u),new x({programId:this.programId,keys:g,data:y})}}static async decompress({payer:e,inputCompressedTokenAccounts:n,toAddress:r,amount:o,recentValidityProof:u,recentInputStateRootIndices:c,tokenPoolInfos:l}){const d=t(o),p=s(l),h=Ln(n,d),{inputTokenDataWithContext:m,packedOutputTokenData:f,remainingAccountMetas:y}=$e({inputCompressedTokenAccounts:n,rootIndices:c,tokenTransferOutputs:h,remainingAccounts:p.slice(1).map((t=>Sn(t)))}),{mint:g}=En(n),{delegatedTransfer:w,authority:b}=Bn(n,h),k=cn({proof:u,mint:g,delegatedTransfer:w,inputTokenDataWithContext:m,outputCompressedAccounts:f,compressOrDecompressAmount:d,isCompress:0,cpiContext:null,lamportsChangeAccountMerkleTreeIndex:null}),v=p[0].tokenProgram,{accountCompressionAuthority:I,noopProgram:M,registeredProgramPda:P,accountCompressionProgram:S}=i(),C=mn({feePayer:e,authority:b,cpiAuthorityPda:this.deriveCpiAuthorityPda,lightSystemProgram:a.programId,registeredProgramPda:P,noopProgram:M,accountCompressionAuthority:I,accountCompressionProgram:S,selfProgram:this.programId,tokenPoolPda:Sn(p[0]),compressOrDecompressTokenAccount:r,tokenProgram:v,systemProgram:A.programId});return C.push(...y),new x({programId:this.programId,keys:C,data:k})}static async mergeTokenAccounts({payer:e,owner:n,inputCompressedTokenAccounts:r,mint:o,recentValidityProof:i,recentInputStateRootIndices:s}){if(r.length>4)throw new Error("Cannot merge more than 4 token accounts at once");return Ye(r,o),[await this.transfer({payer:e,inputCompressedTokenAccounts:r,toAddress:n,amount:r.reduce(((t,e)=>t.add(e.parsed.amount)),t(0)),recentInputStateRootIndices:s,recentValidityProof:i})]}static async compressSplTokenAccount({feePayer:t,authority:e,tokenAccount:r,mint:o,remainingAmount:s,outputStateTreeInfo:u,tokenPoolInfo:c}){Se(c,o);const l=[{pubkey:u.treeType===n.StateV2?u.queue:u.tree,isSigner:0,isWritable:1}],d=an({owner:e,remainingAmount:s??null,cpiContext:null}),{accountCompressionAuthority:p,noopProgram:h,registeredProgramPda:m,accountCompressionProgram:f}=i(),y=mn({feePayer:t,authority:e,cpiAuthorityPda:this.deriveCpiAuthorityPda,lightSystemProgram:a.programId,registeredProgramPda:m,noopProgram:h,accountCompressionAuthority:p,accountCompressionProgram:f,selfProgram:this.programId,tokenPoolPda:Sn(c),compressOrDecompressTokenAccount:r,tokenProgram:c.tokenProgram,systemProgram:A.programId});return y.push(...l),new x({programId:this.programId,keys:y,data:d})}static async getMintProgramId(t,e){return(await e.getAccountInfo(t))?.owner}static async approve({payer:e,inputCompressedTokenAccounts:r,toAddress:o,amount:s,recentValidityProof:u,recentInputStateRootIndices:c}){const{inputTokenDataWithContext:l,remainingAccountMetas:d}=$e({inputCompressedTokenAccounts:r,rootIndices:c,tokenTransferOutputs:[]}),{mint:p,currentOwner:h}=En(r),m=r[0].compressedAccount.treeInfo.treeType===n.StateV2?1:0,f=Mn({proof:u,mint:p,inputTokenDataWithContext:l,cpiContext:null,delegate:o,delegatedAmount:t(s),delegateMerkleTreeIndex:m,changeAccountMerkleTreeIndex:m,delegateLamports:null}),{accountCompressionAuthority:y,noopProgram:g,registeredProgramPda:w,accountCompressionProgram:b}=i(),k=fn({feePayer:e,authority:h,cpiAuthorityPda:this.deriveCpiAuthorityPda,lightSystemProgram:a.programId,registeredProgramPda:w,noopProgram:g,accountCompressionAuthority:y,accountCompressionProgram:b,selfProgram:this.programId,systemProgram:A.programId});return k.push(...d),new x({programId:this.programId,keys:k,data:f})}static async revoke({payer:t,inputCompressedTokenAccounts:e,recentValidityProof:r,recentInputStateRootIndices:o}){Tn(e);const{inputTokenDataWithContext:s,remainingAccountMetas:u}=$e({inputCompressedTokenAccounts:e,rootIndices:o,tokenTransferOutputs:[]}),{mint:c,currentOwner:l}=En(e),d=An({proof:r,mint:c,inputTokenDataWithContext:s,cpiContext:null,outputAccountMerkleTreeIndex:e[0].compressedAccount.treeInfo.treeType===n.StateV2?2:1}),{accountCompressionAuthority:p,noopProgram:h,registeredProgramPda:m,accountCompressionProgram:f}=i(),y=yn({feePayer:t,authority:l,cpiAuthorityPda:this.deriveCpiAuthorityPda,lightSystemProgram:a.programId,registeredProgramPda:m,noopProgram:h,accountCompressionAuthority:p,accountCompressionProgram:f,selfProgram:this.programId,systemProgram:A.programId});return y.push(...u),new x({programId:this.programId,keys:y,data:d})}}function Wn(t,e){const n=p(On(t)[0].toBytes(),e.tree,h);return Array.from(n.toBytes())}const Dn=xt.from([99,111,109,112,114,101,115,115,101,100,95,109,105,110,116]);function On(t){const[e,n]=P.findProgramAddressSync([Dn,t.toBuffer()],h);return[e,n]}function Rn(t,e){return P.findProgramAddressSync([t.toBuffer(),h.toBuffer(),e.toBuffer()],h)}function qn(t,e){return P.findProgramAddressSync([t.toBuffer(),h.toBuffer(),e.toBuffer()],h)[0]}const Kn=xt.from([103]),zn=X([nt("recipient"),rt("amount")]),Vn=X([et("tokenAccountVersion"),ct(zn,"recipients")]),Nn=X([ot(nt(),"newAuthority")]),Fn=X([et("mintBump")]),$n=X([et("accountIndex"),rt("amount")]),Yn=X([et("extensionIndex"),et("fieldType"),it("key"),it("value")]),jn=X([et("extensionIndex"),nt("newAuthority")]),Zn=X([et("extensionIndex"),it("key"),et("idempotent")]),Hn=lt([Vn.replicate("mintToCompressed"),Nn.replicate("updateMintAuthority"),Nn.replicate("updateFreezeAuthority"),Fn.replicate("createSplMint"),$n.replicate("mintToCToken"),Yn.replicate("updateMetadataField"),jn.replicate("updateMetadataAuthority"),Zn.replicate("removeMetadataKey")]),Gn=X([tt(et(),32,"a"),tt(et(),64,"b"),tt(et(),32,"c")]),Qn=X([at("setContext"),at("firstSetContext"),et("inTreeIndex"),et("inQueueIndex"),et("outQueueIndex"),et("tokenOutQueueIndex"),et("assignedAccountIndex"),tt(et(),4,"readOnlyAddressTrees"),tt(et(),32,"addressTreePubkey")]),Jn=X([tt(et(),4,"readOnlyAddressTrees"),tt(ut(),4,"readOnlyAddressTreeRootIndices")]),Xn=X([it("key"),it("value")]),tr=X([ot(nt(),"updateAuthority"),it("name"),it("symbol"),it("uri"),ot(ct(Xn),"additionalMetadata")]),er=X([]),nr=lt([er.replicate("placeholder0"),er.replicate("placeholder1"),er.replicate("placeholder2"),er.replicate("placeholder3"),er.replicate("placeholder4"),er.replicate("placeholder5"),er.replicate("placeholder6"),er.replicate("placeholder7"),er.replicate("placeholder8"),er.replicate("placeholder9"),er.replicate("placeholder10"),er.replicate("placeholder11"),er.replicate("placeholder12"),er.replicate("placeholder13"),er.replicate("placeholder14"),er.replicate("placeholder15"),er.replicate("placeholder16"),er.replicate("placeholder17"),er.replicate("placeholder18"),tr.replicate("tokenMetadata")]),rr=X([et("version"),at("splMintInitialized"),nt("mint")]),or=X([rt("supply"),et("decimals"),rr.replicate("metadata"),ot(nt(),"mintAuthority"),ot(nt(),"freezeAuthority"),ot(ct(nr),"extensions")]),ir=X([st("leafIndex"),at("proveByIndex"),ut("rootIndex"),tt(et(),32,"compressedAddress"),et("tokenPoolBump"),et("tokenPoolIndex"),ut("maxTopUp"),ot(Jn,"createMint"),ct(Hn,"actions"),ot(Gn,"proof"),ot(Qn,"cpiContext"),or.replicate("mint")]);function sr(e){const n={...e,mint:{...e.mint,supply:t(e.mint.supply.toString())},actions: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=xt.alloc(1e4),o=ir.encode(n,r);return xt.concat([Kn,r.subarray(0,o)])}function ar(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,s,u,c,l){const d=function(t){const[e]=On(t.mintSigner),n=p(e.toBytes(),t.addressTree,h);let r=null;t.metadata&&(r=[{tokenMetadata:{updateAuthority:t.metadata.updateAuthority??null,name:xt.from(t.metadata.name),symbol:xt.from(t.metadata.symbol),uri:xt.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 sr({leafIndex:0,proveByIndex:0,rootIndex:t.rootIndex,compressedAddress:Array.from(n.toBytes()),tokenPoolBump:0,tokenPoolIndex:0,maxTopUp:0,createMint:{readOnlyAddressTrees:[0,0,0,0],readOnlyAddressTreeRootIndices:[0,0,0,0]},actions:[],proof:o,cpiContext:null,mint:{supply:BigInt(0),decimals:t.decimals,metadata:{version:le.ShaFlat,splMintInitialized:0,mint:e},mintAuthority:t.mintAuthority,freezeAuthority:t.freezeAuthority,extensions:r}})}({mintSigner:t,mintAuthority:n,freezeAuthority:r,decimals:e,addressTree:u.tree,outputQueue:c.queue,rootIndex:s.rootIndices[0],proof:s.compressedProof,metadata:l}),m=i(),f=[{pubkey:a.programId,isSigner:0,isWritable:0},{pubkey:t,isSigner:1,isWritable:0},{pubkey:n,isSigner:1,isWritable:0},{pubkey:o,isSigner:1,isWritable:1},{pubkey:Un.deriveCpiAuthorityPda,isSigner:0,isWritable:0},{pubkey:m.registeredProgramPda,isSigner:0,isWritable:0},{pubkey:m.accountCompressionAuthority,isSigner:0,isWritable:0},{pubkey:m.accountCompressionProgram,isSigner:0,isWritable:0},{pubkey:A.programId,isSigner:0,isWritable:0},{pubkey:c.queue,isSigner:0,isWritable:1},{pubkey:u.tree,isSigner:0,isWritable:1}];return new x({programId:h,keys:f,data:d})}function cr(t){const e=p(t.splMint.toBytes(),t.addressTree,h),n="mintAuthority"===t.actionType?{updateMintAuthority:{newAuthority:t.newAuthority}}:{updateFreezeAuthority:{newAuthority:t.newAuthority}};let r=null;return t.mintInterface.tokenMetadata&&(r=[{tokenMetadata:{updateAuthority:t.mintInterface.tokenMetadata.updateAuthority??null,name:xt.from(t.mintInterface.tokenMetadata.name),symbol:xt.from(t.mintInterface.tokenMetadata.symbol),uri:xt.from(t.mintInterface.tokenMetadata.uri),additionalMetadata:null}}]),sr({leafIndex:t.leafIndex,proveByIndex:t.proveByIndex,rootIndex:t.rootIndex,compressedAddress:Array.from(e.toBytes()),tokenPoolBump:0,tokenPoolIndex:0,maxTopUp:0,createMint:null,actions:[n],proof:t.proof,cpiContext:null,mint:{supply:t.mintInterface.mint.supply,decimals:t.mintInterface.mint.decimals,metadata:{version:t.mintInterface.mintContext.version,splMintInitialized:t.mintInterface.mintContext.splMintInitialized,mint:t.mintInterface.mintContext.splMint},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 s=t.merkleContext,u=m(s),c=f(),l=cr({splMint:t.mintContext.splMint,addressTree:c.tree,leafIndex:s.leafIndex,proveByIndex:1,rootIndex:o.rootIndices[0],proof:o.compressedProof,mintInterface:t,newAuthority:n,actionType:"mintAuthority"}),d=i(),p=[{pubkey:a.programId,isSigner:0,isWritable:0},{pubkey:e,isSigner:1,isWritable:0},{pubkey:r,isSigner:1,isWritable:1},{pubkey:Un.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:A.programId,isSigner:0,isWritable:0},{pubkey:u,isSigner:0,isWritable:1},{pubkey:s.treeInfo.tree,isSigner:0,isWritable:1},{pubkey:s.treeInfo.queue,isSigner:0,isWritable:1}];return new x({programId:h,keys:p,data:l})}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");const s=t.merkleContext,u=m(s),c=f(),l=cr({splMint:t.mintContext.splMint,addressTree:c.tree,leafIndex:s.leafIndex,proveByIndex:1,rootIndex:o.rootIndices[0],proof:o.compressedProof,mintInterface:t,newAuthority:n,actionType:"freezeAuthority"}),d=i(),p=[{pubkey:a.programId,isSigner:0,isWritable:0},{pubkey:e,isSigner:1,isWritable:0},{pubkey:r,isSigner:1,isWritable:1},{pubkey:Un.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:A.programId,isSigner:0,isWritable:0},{pubkey:u,isSigner:0,isWritable:1},{pubkey:s.treeInfo.tree,isSigner:0,isWritable:1},{pubkey:s.treeInfo.queue,isSigner:0,isWritable:1}];return new x({programId:h,keys:p,data:l})}function pr(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 s=t.merkleContext,u=m(s),c=f(),l=function(t){const e=p(t.splMint.toBytes(),t.addressTree,h),n=t.mintInterface;if(!n.tokenMetadata)throw new Error("MintInterface must have tokenMetadata for metadata operations");var r;return sr({leafIndex:t.leafIndex,proveByIndex:null===t.proof,rootIndex:t.rootIndex,compressedAddress:Array.from(e.toBytes()),tokenPoolBump:0,tokenPoolIndex:0,maxTopUp:0,createMint:null,actions:[(r=t.action,"updateField"===r.type?{updateMetadataField:{extensionIndex:r.extensionIndex,fieldType:r.fieldType,key:xt.from(r.key),value:xt.from(r.value)}}:"updateAuthority"===r.type?{updateMetadataAuthority:{extensionIndex:r.extensionIndex,newAuthority:r.newAuthority}}:{removeMetadataKey:{extensionIndex:r.extensionIndex,key:xt.from(r.key),idempotent:r.idempotent?1:0}})],proof:t.proof,cpiContext:null,mint:{supply:n.mint.supply,decimals:n.mint.decimals,metadata:{version:n.mintContext.version,splMintInitialized:n.mintContext.splMintInitialized,mint:n.mintContext.splMint},mintAuthority:n.mint.mintAuthority,freezeAuthority:n.mint.freezeAuthority,extensions:[{tokenMetadata:{updateAuthority:n.tokenMetadata.updateAuthority??null,name:xt.from(n.tokenMetadata.name),symbol:xt.from(n.tokenMetadata.symbol),uri:xt.from(n.tokenMetadata.uri),additionalMetadata:null}}]}})}({splMint:t.mintContext.splMint,addressTree:c.tree,leafIndex:s.leafIndex,rootIndex:r.rootIndices[0],proof:r.compressedProof,mintInterface:t,action:o}),d=i(),y=[{pubkey:a.programId,isSigner:0,isWritable:0},{pubkey:e,isSigner:1,isWritable:0},{pubkey:n,isSigner:1,isWritable:1},{pubkey:Un.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:A.programId,isSigner:0,isWritable:0},{pubkey:u,isSigner:0,isWritable:1},{pubkey:s.treeInfo.tree,isSigner:0,isWritable:1},{pubkey:s.treeInfo.queue,isSigner:0,isWritable:1}];return new x({programId:h,keys:y,data:l})}function hr(t,e,n,r,o,i,s,a=0){return pr(t,e,n,r,{type:"updateField",extensionIndex:a,fieldType:"name"===o?0:"symbol"===o?1:"uri"===o?2:3,key:s||"",value:i})}function mr(t,e,n,r,o,i=0){return pr(t,e,r,o,{type:"updateAuthority",extensionIndex:i,newAuthority:n})}function fr(t,e,n,r,o,i=0,s=0){return pr(t,e,n,r,{type:"removeKey",extensionIndex:s,key:o,idempotent:i})}const yr=xt.from([100]),gr=xt.from([102]),wr=X([et("bump"),tt(et(),32,"programId"),ct(ct(et()),"seeds")]),br=X([et("tokenAccountVersion"),et("rentPayment"),et("hasTopUp"),et("compressionOnly"),st("writeTopUp"),ot(wr,"compressToAccountPubkey")]),kr=X([et("bump"),ot(br,"compressibleConfig")]);function vr(t,e){return P.findProgramAddressSync([t.toBuffer(),h.toBuffer(),e.toBuffer()],h)}function Ir(t,e){const n=xt.alloc(2e3),r=kr.encode({bump:t.bump,compressibleConfig:t.compressibleConfig||null},n),o=e?gr:yr;return xt.concat([o,n.subarray(0,r)])}function Mr(t,e,n,r,o,i){const[s,a]=vr(e,n),u=Ir({bump:a,compressibleConfig:r},0),c=[{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:A.programId,isSigner:0,isWritable:0}];return r&&o&&i&&c.push({pubkey:o,isSigner:0,isWritable:0},{pubkey:i,isSigner:0,isWritable:1}),new x({programId:h,keys:c,data:u})}function Pr(t,e,n,r,o,i){const[s,a]=vr(e,n),u=Ir({bump:a,compressibleConfig:r},1),c=[{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:A.programId,isSigner:0,isWritable:0}];return r&&o&&i&&c.push({pubkey:o,isSigner:0,isWritable:0},{pubkey:i,isSigner:0,isWritable:1}),new x({programId:h,keys:c,data:u})}function Ar(t){return t.equals(h)?h:R}function xr(t,e,n,r){if(r){const o=q(e,n,0,r,Ar(r));if(t.equals(o))return{valid:1,type:Sr(r),programId:r};throw new Error(`ATA address mismatch for ${r.toBase58()}. Expected: ${o.toBase58()}, got: ${t.toBase58()}`)}let o,i,s;if(o=q(e,n,0,h,Ar(h)),t.equals(o))return{valid:1,type:"ctoken",programId:h};if(i=q(e,n,0,D,Ar(D)),t.equals(i))return{valid:1,type:"spl",programId:D};if(s=q(e,n,0,O,Ar(O)),t.equals(s))return{valid:1,type:"token2022",programId:O};throw new Error(`ATA address does not match any valid derivation from mint+owner. Got: ${t.toBase58()}, expected one of: c-token=${o.toBase58()}, SPL=${i.toBase58()}, T22=${s.toBase58()}`)}function Sr(t){if(t.equals(h))return"ctoken";if(t.equals(D))return"spl";if(t.equals(O))return"token2022";throw new Error(`Unknown program ID: ${t.toBase58()}`)}function Cr(t,e,n,r,o=D,i,s){const a=i??Ar(o);return o.equals(h)?Mr(t,n,r,s?.compressibleConfig,s?.configAccount,s?.rentPayerPda):K(t,e,n,r,o,a)}function Tr(t,e,n,r,o=D,i,s){const a=i??Ar(o);return o.equals(h)?Pr(t,n,r,s?.compressibleConfig,s?.configAccount,s?.rentPayerPda):z(t,e,n,r,o,a)}const Er=Tr;function Br(t,e,n,r,o,s,u,c){const l=function(t){const e=p(t.mintData.splMint.toBytes(),t.addressTree,h);if(t.mintData.metadata)throw new Error("TokenMetadata extension not supported in mintTo instruction");return sr({leafIndex:t.leafIndex,proveByIndex:1,rootIndex:t.rootIndex,compressedAddress:Array.from(e.toBytes()),tokenPoolBump:0,tokenPoolIndex:0,maxTopUp:0,createMint:null,actions:[{mintToCToken:{accountIndex:t.recipientAccountIndex,amount:BigInt(t.amount.toString())}}],proof:t.proof,cpiContext:null,mint:{supply:t.mintData.supply,decimals:t.mintData.decimals,metadata:{version:t.mintData.version,splMintInitialized:t.mintData.splMintInitialized,mint:t.mintData.splMint},mintAuthority:t.mintData.mintAuthority,freezeAuthority:t.mintData.freezeAuthority,extensions:null}})}({addressTree:f().tree,leafIndex:r.leafIndex,rootIndex:n.rootIndices[0],proof:n.compressedProof,mintData:o,recipientAccountIndex:0,amount:c}),d=i(),m=[{pubkey:a.programId,isSigner:0,isWritable:0},{pubkey:t,isSigner:1,isWritable:0},{pubkey:e,isSigner:1,isWritable:1},{pubkey:Un.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:A.programId,isSigner:0,isWritable:0},{pubkey:s.queue,isSigner:0,isWritable:1},{pubkey:r.treeInfo.tree,isSigner:0,isWritable:1},{pubkey:r.treeInfo.queue,isSigner:0,isWritable:1}];return m.push({pubkey:u,isSigner:0,isWritable:1}),new x({programId:h,keys:m,data:l})}function _r(t,e,n,r,o,s,u,c=le.ShaFlat){const l=function(t){const e=p(t.mintData.splMint.toBytes(),t.addressTree,h);if(t.mintData.metadata)throw new Error("TokenMetadata extension not supported in mintTo instruction");return sr({leafIndex:t.leafIndex,proveByIndex:1,rootIndex:t.rootIndex,compressedAddress:Array.from(e.toBytes()),tokenPoolBump:0,tokenPoolIndex:0,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,splMintInitialized:t.mintData.splMintInitialized,mint:t.mintData.splMint},mintAuthority:t.mintData.mintAuthority,freezeAuthority:t.mintData.freezeAuthority,extensions:null}})}({addressTree:f().tree,leafIndex:r.leafIndex,rootIndex:n.rootIndices[0],proof:n.compressedProof,mintData:o,recipients:s,tokenAccountVersion:c}),d=u?.queue??m(r),y=i(),g=[{pubkey:a.programId,isSigner:0,isWritable:0},{pubkey:t,isSigner:1,isWritable:0},{pubkey:e,isSigner:1,isWritable:1},{pubkey:Un.deriveCpiAuthorityPda,isSigner:0,isWritable:0},{pubkey:y.registeredProgramPda,isSigner:0,isWritable:0},{pubkey:y.accountCompressionAuthority,isSigner:0,isWritable:0},{pubkey:y.accountCompressionProgram,isSigner:0,isWritable:0},{pubkey:A.programId,isSigner:0,isWritable:0},{pubkey:d,isSigner:0,isWritable:1},{pubkey:r.treeInfo.tree,isSigner:0,isWritable:1},{pubkey:r.treeInfo.queue,isSigner:0,isWritable:1},{pubkey:d,isSigner:0,isWritable:1}];return new x({programId:h,keys:g,data:l})}function Lr(t,e,n,r,o,i,s=[]){const a=t.mint.address,u=t.programId;if(!t.merkleContext)return W(a,e,n,BigInt(o.toString()),s,u);if(!i)throw new Error("Validity proof required for c-token mint-to");if(!t.mintContext)throw new Error("mintContext required for c-token mint-to");const c={supply:t.mint.supply,decimals:t.mint.decimals,mintAuthority:t.mint.mintAuthority,freezeAuthority:t.mint.freezeAuthority,splMint:t.mintContext.splMint,splMintInitialized:t.mintContext.splMintInitialized,version:t.mintContext.version,metadata:t.tokenMetadata?{updateAuthority:t.tokenMetadata.updateAuthority||null,name:t.tokenMetadata.name,symbol:t.tokenMetadata.symbol,uri:t.tokenMetadata.uri}:void 0};return Br(n,r,i,t.merkleContext,c,y(t.merkleContext),e,o)}const Ur=3;function Wr(t,e,n,r,o){const i=Buffer.alloc(10);i.writeUInt8(Ur,0),i.writeUInt8(0,1),i.writeBigUInt64LE(BigInt(r),2);const s=[{pubkey:t,isSigner:0,isWritable:1},{pubkey:e,isSigner:0,isWritable:1},{pubkey:n,isSigner:1,isWritable:0}];return o&&!o.equals(n)&&s.push({pubkey:o,isSigner:1,isWritable:1}),new x({programId:h,keys:s,data:i})}function Dr(t,e,n,r,o=[],i=h,s){if(i.equals(h)){if(o.length>0)throw new Error("c-token transfer does not support multi-signers. Use a single owner.");return Wr(t,e,n,r,s)}if(i.equals(D)||i.equals(O))return V(t,e,n,r,o.map((t=>t instanceof P?t:t.publicKey)),i);throw new Error(`Unsupported program ID: ${i.toBase58()}`)}const Or=xt.from([101]),Rr=0,qr=1,Kr=X([et("mode"),rt("amount"),et("mint"),et("sourceOrRecipient"),et("authority"),et("poolAccountIndex"),et("poolIndex"),et("bump"),et("decimals")]),zr=X([et("merkleTreePubkeyIndex"),et("queuePubkeyIndex"),st("leafIndex"),at("proveByIndex")]),Vr=X([et("owner"),rt("amount"),at("hasDelegate"),et("delegate"),et("mint"),et("version"),zr.replicate("merkleContext"),ut("rootIndex")]),Nr=X([et("owner"),rt("amount"),at("hasDelegate"),et("delegate"),et("mint"),et("version")]),Fr=X([at("setContext"),at("firstSetContext"),et("cpiContextAccountIndex")]),$r=X([tt(et(),32,"a"),tt(et(),64,"b"),tt(et(),32,"c")]),Yr=X([at("withTransactionHash"),at("withLamportsChangeAccountMerkleTreeIndex"),et("lamportsChangeAccountMerkleTreeIndex"),et("lamportsChangeAccountOwnerIndex"),et("outputQueue"),ut("maxTopUp"),ot(Fr,"cpiContext"),ot(ct(Kr),"compressions"),ot($r,"proof"),ct(Vr,"inTokenData"),ct(Nr,"outTokenData"),ot(ct(rt()),"inLamports"),ot(ct(rt()),"outLamports"),ot(ct(ct(et())),"inTlv"),ot(ct(ct(et())),"outTlv")]);function jr(e){const n={...e,compressions:e.compressions?.map((e=>({...e,amount:t(e.amount.toString())})))??null,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=xt.alloc(2e3),o=Yr.encode(n,r);return xt.concat([Or,r.subarray(0,o)])}function Zr(t,e,n,r,o,i,s){return{mode:Rr,amount:t,mint:e,sourceOrRecipient:n,authority:r,poolAccountIndex:o,poolIndex:i,bump:s,decimals:0}}function Hr(t,e,n,r){return{mode:qr,amount:t,mint:e,sourceOrRecipient:n,authority:0,poolAccountIndex:r,poolIndex:0,bump:0,decimals:0}}function Gr(t,e,n,r,o){return{mode:Rr,amount:t,mint:e,sourceOrRecipient:n,authority:r,poolAccountIndex:o,poolIndex:0,bump:0,decimals:0}}function Qr(t,e,n,r,o,i){return{mode:qr,amount:t,mint:e,sourceOrRecipient:n,authority:0,poolAccountIndex:r,poolIndex:o,bump:i,decimals:0}}function Jr(t){return!t||t.length<8?le.ShaFlat:2===t[0]?le.V1:3===t[7]?le.V2:le.ShaFlat}function Xr(t,e,n,r,o,s){if(0===e.length)throw new Error("No input compressed token accounts provided");const u=e[0].parsed.mint,c=e[0].parsed.owner,l=new Map,d=[],p=new Set,h=new Set;for(const t of e)p.add(t.compressedAccount.treeInfo.tree.toBase58()),h.add(t.compressedAccount.treeInfo.queue.toBase58());for(const t of p)l.set(t,d.length),d.push(new P(t));let m=0,f=1;for(const t of h)f&&(m=d.length,f=0),l.set(t,d.length),d.push(new P(t));const y=d.length;l.set(u.toBase58(),y),d.push(u);const g=d.length;l.set(c.toBase58(),g),d.push(c);const w=d.length;l.set(n.toBase58(),w),d.push(n);let b=0,k=0,v=0,I=0;s&&(b=d.length,l.set(s.splInterfacePda.toBase58(),b),d.push(s.splInterfacePda),I=d.length,l.set(s.tokenProgram.toBase58(),I),d.push(s.tokenProgram),k=s.poolIndex,v=s.bump);const M=function(t,e,n){return t.map(((t,r)=>{const o=t.parsed.owner.toBase58(),i=t.parsed.mint.toBase58(),s=Jr(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,l),S=e.reduce(((t,e)=>t+BigInt(e.parsed.amount.toString())),BigInt(0))-r,C=[];if(S>0){const t=Jr(e[0].compressedAccount.data?.discriminator);C.push({owner:g,amount:S,hasDelegate:0,delegate:0,mint:y,version:t})}const T=jr({withTransactionHash:0,withLamportsChangeAccountMerkleTreeIndex:0,lamportsChangeAccountMerkleTreeIndex:0,lamportsChangeAccountOwnerIndex:0,outputQueue:m,maxTopUp:0,cpiContext:null,compressions:[{mode:qr,amount:r,mint:y,sourceOrRecipient:w,authority:0,poolAccountIndex:s?b:0,poolIndex:s?k:0,bump:s?v:0,decimals:0}],proof:o.compressedProof?{a:Array.from(o.compressedProof.a),b:Array.from(o.compressedProof.b),c:Array.from(o.compressedProof.c)}:null,inTokenData:M,outTokenData:C,inLamports:null,outLamports:null,inTlv:null,outTlv:null}),{accountCompressionAuthority:E,registeredProgramPda:B,accountCompressionProgram:_}=i(),L=[{pubkey:a.programId,isSigner:0,isWritable:0},{pubkey:t,isSigner:1,isWritable:1},{pubkey:Un.deriveCpiAuthorityPda,isSigner:0,isWritable:0},{pubkey:B,isSigner:0,isWritable:0},{pubkey:E,isSigner:0,isWritable:0},{pubkey:_,isSigner:0,isWritable:0},{pubkey:A.programId,isSigner:0,isWritable:0},...d.map(((t,e)=>{const r=e<p.size+h.size,o=t.equals(n),i=void 0!==s&&t.equals(s.splInterfacePda);return{pubkey:t,isSigner:e===g,isWritable:r||o||i}}))];return new x({programId:Un.programId,keys:L,data:T})}var to="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function eo(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function no(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:{}},oo=no(de);!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:oo.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 d=1;for(c=u(t,l,t.length,e),l=0;l<s;l++)d*=e;this.imuln(d),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 d=["","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"],p=[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,d=67108863&u,p=Math.min(c,e.length-1),h=Math.max(0,c-t.length+1);h<=p;h++){var m=c-h|0;l+=(s=(o=0|t.words[m])*(i=0|e.words[h])+d)/67108864|0,d=67108863&s}n.words[c]=0|d,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?d[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=p[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:d[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],d=8191&l,p=l>>>13,h=0|s[1],m=8191&h,f=h>>>13,y=0|s[2],g=8191&y,w=y>>>13,b=0|s[3],k=8191&b,v=b>>>13,I=0|s[4],M=8191&I,P=I>>>13,A=0|s[5],x=8191&A,S=A>>>13,C=0|s[6],T=8191&C,E=C>>>13,B=0|s[7],_=8191&B,L=B>>>13,U=0|s[8],W=8191&U,D=U>>>13,O=0|s[9],R=8191&O,q=O>>>13,K=0|a[0],z=8191&K,V=K>>>13,N=0|a[1],F=8191&N,$=N>>>13,Y=0|a[2],j=8191&Y,Z=Y>>>13,H=0|a[3],G=8191&H,Q=H>>>13,J=0|a[4],X=8191&J,tt=J>>>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],dt=8191<,pt=lt>>>13,ht=0|a[9],mt=8191&ht,ft=ht>>>13;n.negative=t.negative^e.negative,n.length=19;var yt=(c+(r=Math.imul(d,z))|0)+((8191&(o=(o=Math.imul(d,V))+Math.imul(p,z)|0))<<13)|0;c=((i=Math.imul(p,V))+(o>>>13)|0)+(yt>>>26)|0,yt&=67108863,r=Math.imul(m,z),o=(o=Math.imul(m,V))+Math.imul(f,z)|0,i=Math.imul(f,V);var gt=(c+(r=r+Math.imul(d,F)|0)|0)+((8191&(o=(o=o+Math.imul(d,$)|0)+Math.imul(p,F)|0))<<13)|0;c=((i=i+Math.imul(p,$)|0)+(o>>>13)|0)+(gt>>>26)|0,gt&=67108863,r=Math.imul(g,z),o=(o=Math.imul(g,V))+Math.imul(w,z)|0,i=Math.imul(w,V),r=r+Math.imul(m,F)|0,o=(o=o+Math.imul(m,$)|0)+Math.imul(f,F)|0,i=i+Math.imul(f,$)|0;var wt=(c+(r=r+Math.imul(d,j)|0)|0)+((8191&(o=(o=o+Math.imul(d,Z)|0)+Math.imul(p,j)|0))<<13)|0;c=((i=i+Math.imul(p,Z)|0)+(o>>>13)|0)+(wt>>>26)|0,wt&=67108863,r=Math.imul(k,z),o=(o=Math.imul(k,V))+Math.imul(v,z)|0,i=Math.imul(v,V),r=r+Math.imul(g,F)|0,o=(o=o+Math.imul(g,$)|0)+Math.imul(w,F)|0,i=i+Math.imul(w,$)|0,r=r+Math.imul(m,j)|0,o=(o=o+Math.imul(m,Z)|0)+Math.imul(f,j)|0,i=i+Math.imul(f,Z)|0;var bt=(c+(r=r+Math.imul(d,G)|0)|0)+((8191&(o=(o=o+Math.imul(d,Q)|0)+Math.imul(p,G)|0))<<13)|0;c=((i=i+Math.imul(p,Q)|0)+(o>>>13)|0)+(bt>>>26)|0,bt&=67108863,r=Math.imul(M,z),o=(o=Math.imul(M,V))+Math.imul(P,z)|0,i=Math.imul(P,V),r=r+Math.imul(k,F)|0,o=(o=o+Math.imul(k,$)|0)+Math.imul(v,F)|0,i=i+Math.imul(v,$)|0,r=r+Math.imul(g,j)|0,o=(o=o+Math.imul(g,Z)|0)+Math.imul(w,j)|0,i=i+Math.imul(w,Z)|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(d,X)|0)|0)+((8191&(o=(o=o+Math.imul(d,tt)|0)+Math.imul(p,X)|0))<<13)|0;c=((i=i+Math.imul(p,tt)|0)+(o>>>13)|0)+(kt>>>26)|0,kt&=67108863,r=Math.imul(x,z),o=(o=Math.imul(x,V))+Math.imul(S,z)|0,i=Math.imul(S,V),r=r+Math.imul(M,F)|0,o=(o=o+Math.imul(M,$)|0)+Math.imul(P,F)|0,i=i+Math.imul(P,$)|0,r=r+Math.imul(k,j)|0,o=(o=o+Math.imul(k,Z)|0)+Math.imul(v,j)|0,i=i+Math.imul(v,Z)|0,r=r+Math.imul(g,G)|0,o=(o=o+Math.imul(g,Q)|0)+Math.imul(w,G)|0,i=i+Math.imul(w,Q)|0,r=r+Math.imul(m,X)|0,o=(o=o+Math.imul(m,tt)|0)+Math.imul(f,X)|0,i=i+Math.imul(f,tt)|0;var vt=(c+(r=r+Math.imul(d,nt)|0)|0)+((8191&(o=(o=o+Math.imul(d,rt)|0)+Math.imul(p,nt)|0))<<13)|0;c=((i=i+Math.imul(p,rt)|0)+(o>>>13)|0)+(vt>>>26)|0,vt&=67108863,r=Math.imul(T,z),o=(o=Math.imul(T,V))+Math.imul(E,z)|0,i=Math.imul(E,V),r=r+Math.imul(x,F)|0,o=(o=o+Math.imul(x,$)|0)+Math.imul(S,F)|0,i=i+Math.imul(S,$)|0,r=r+Math.imul(M,j)|0,o=(o=o+Math.imul(M,Z)|0)+Math.imul(P,j)|0,i=i+Math.imul(P,Z)|0,r=r+Math.imul(k,G)|0,o=(o=o+Math.imul(k,Q)|0)+Math.imul(v,G)|0,i=i+Math.imul(v,Q)|0,r=r+Math.imul(g,X)|0,o=(o=o+Math.imul(g,tt)|0)+Math.imul(w,X)|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 It=(c+(r=r+Math.imul(d,it)|0)|0)+((8191&(o=(o=o+Math.imul(d,st)|0)+Math.imul(p,it)|0))<<13)|0;c=((i=i+Math.imul(p,st)|0)+(o>>>13)|0)+(It>>>26)|0,It&=67108863,r=Math.imul(_,z),o=(o=Math.imul(_,V))+Math.imul(L,z)|0,i=Math.imul(L,V),r=r+Math.imul(T,F)|0,o=(o=o+Math.imul(T,$)|0)+Math.imul(E,F)|0,i=i+Math.imul(E,$)|0,r=r+Math.imul(x,j)|0,o=(o=o+Math.imul(x,Z)|0)+Math.imul(S,j)|0,i=i+Math.imul(S,Z)|0,r=r+Math.imul(M,G)|0,o=(o=o+Math.imul(M,Q)|0)+Math.imul(P,G)|0,i=i+Math.imul(P,Q)|0,r=r+Math.imul(k,X)|0,o=(o=o+Math.imul(k,tt)|0)+Math.imul(v,X)|0,i=i+Math.imul(v,tt)|0,r=r+Math.imul(g,nt)|0,o=(o=o+Math.imul(g,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(d,ut)|0)|0)+((8191&(o=(o=o+Math.imul(d,ct)|0)+Math.imul(p,ut)|0))<<13)|0;c=((i=i+Math.imul(p,ct)|0)+(o>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,r=Math.imul(W,z),o=(o=Math.imul(W,V))+Math.imul(D,z)|0,i=Math.imul(D,V),r=r+Math.imul(_,F)|0,o=(o=o+Math.imul(_,$)|0)+Math.imul(L,F)|0,i=i+Math.imul(L,$)|0,r=r+Math.imul(T,j)|0,o=(o=o+Math.imul(T,Z)|0)+Math.imul(E,j)|0,i=i+Math.imul(E,Z)|0,r=r+Math.imul(x,G)|0,o=(o=o+Math.imul(x,Q)|0)+Math.imul(S,G)|0,i=i+Math.imul(S,Q)|0,r=r+Math.imul(M,X)|0,o=(o=o+Math.imul(M,tt)|0)+Math.imul(P,X)|0,i=i+Math.imul(P,tt)|0,r=r+Math.imul(k,nt)|0,o=(o=o+Math.imul(k,rt)|0)+Math.imul(v,nt)|0,i=i+Math.imul(v,rt)|0,r=r+Math.imul(g,it)|0,o=(o=o+Math.imul(g,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 Pt=(c+(r=r+Math.imul(d,dt)|0)|0)+((8191&(o=(o=o+Math.imul(d,pt)|0)+Math.imul(p,dt)|0))<<13)|0;c=((i=i+Math.imul(p,pt)|0)+(o>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,r=Math.imul(R,z),o=(o=Math.imul(R,V))+Math.imul(q,z)|0,i=Math.imul(q,V),r=r+Math.imul(W,F)|0,o=(o=o+Math.imul(W,$)|0)+Math.imul(D,F)|0,i=i+Math.imul(D,$)|0,r=r+Math.imul(_,j)|0,o=(o=o+Math.imul(_,Z)|0)+Math.imul(L,j)|0,i=i+Math.imul(L,Z)|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(x,X)|0,o=(o=o+Math.imul(x,tt)|0)+Math.imul(S,X)|0,i=i+Math.imul(S,tt)|0,r=r+Math.imul(M,nt)|0,o=(o=o+Math.imul(M,rt)|0)+Math.imul(P,nt)|0,i=i+Math.imul(P,rt)|0,r=r+Math.imul(k,it)|0,o=(o=o+Math.imul(k,st)|0)+Math.imul(v,it)|0,i=i+Math.imul(v,st)|0,r=r+Math.imul(g,ut)|0,o=(o=o+Math.imul(g,ct)|0)+Math.imul(w,ut)|0,i=i+Math.imul(w,ct)|0,r=r+Math.imul(m,dt)|0,o=(o=o+Math.imul(m,pt)|0)+Math.imul(f,dt)|0,i=i+Math.imul(f,pt)|0;var At=(c+(r=r+Math.imul(d,mt)|0)|0)+((8191&(o=(o=o+Math.imul(d,ft)|0)+Math.imul(p,mt)|0))<<13)|0;c=((i=i+Math.imul(p,ft)|0)+(o>>>13)|0)+(At>>>26)|0,At&=67108863,r=Math.imul(R,F),o=(o=Math.imul(R,$))+Math.imul(q,F)|0,i=Math.imul(q,$),r=r+Math.imul(W,j)|0,o=(o=o+Math.imul(W,Z)|0)+Math.imul(D,j)|0,i=i+Math.imul(D,Z)|0,r=r+Math.imul(_,G)|0,o=(o=o+Math.imul(_,Q)|0)+Math.imul(L,G)|0,i=i+Math.imul(L,Q)|0,r=r+Math.imul(T,X)|0,o=(o=o+Math.imul(T,tt)|0)+Math.imul(E,X)|0,i=i+Math.imul(E,tt)|0,r=r+Math.imul(x,nt)|0,o=(o=o+Math.imul(x,rt)|0)+Math.imul(S,nt)|0,i=i+Math.imul(S,rt)|0,r=r+Math.imul(M,it)|0,o=(o=o+Math.imul(M,st)|0)+Math.imul(P,it)|0,i=i+Math.imul(P,st)|0,r=r+Math.imul(k,ut)|0,o=(o=o+Math.imul(k,ct)|0)+Math.imul(v,ut)|0,i=i+Math.imul(v,ct)|0,r=r+Math.imul(g,dt)|0,o=(o=o+Math.imul(g,pt)|0)+Math.imul(w,dt)|0,i=i+Math.imul(w,pt)|0;var xt=(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)+(xt>>>26)|0,xt&=67108863,r=Math.imul(R,j),o=(o=Math.imul(R,Z))+Math.imul(q,j)|0,i=Math.imul(q,Z),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(_,X)|0,o=(o=o+Math.imul(_,tt)|0)+Math.imul(L,X)|0,i=i+Math.imul(L,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(x,it)|0,o=(o=o+Math.imul(x,st)|0)+Math.imul(S,it)|0,i=i+Math.imul(S,st)|0,r=r+Math.imul(M,ut)|0,o=(o=o+Math.imul(M,ct)|0)+Math.imul(P,ut)|0,i=i+Math.imul(P,ct)|0,r=r+Math.imul(k,dt)|0,o=(o=o+Math.imul(k,pt)|0)+Math.imul(v,dt)|0,i=i+Math.imul(v,pt)|0;var St=(c+(r=r+Math.imul(g,mt)|0)|0)+((8191&(o=(o=o+Math.imul(g,ft)|0)+Math.imul(w,mt)|0))<<13)|0;c=((i=i+Math.imul(w,ft)|0)+(o>>>13)|0)+(St>>>26)|0,St&=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,X)|0,o=(o=o+Math.imul(W,tt)|0)+Math.imul(D,X)|0,i=i+Math.imul(D,tt)|0,r=r+Math.imul(_,nt)|0,o=(o=o+Math.imul(_,rt)|0)+Math.imul(L,nt)|0,i=i+Math.imul(L,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(x,ut)|0,o=(o=o+Math.imul(x,ct)|0)+Math.imul(S,ut)|0,i=i+Math.imul(S,ct)|0,r=r+Math.imul(M,dt)|0,o=(o=o+Math.imul(M,pt)|0)+Math.imul(P,dt)|0,i=i+Math.imul(P,pt)|0;var Ct=(c+(r=r+Math.imul(k,mt)|0)|0)+((8191&(o=(o=o+Math.imul(k,ft)|0)+Math.imul(v,mt)|0))<<13)|0;c=((i=i+Math.imul(v,ft)|0)+(o>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,r=Math.imul(R,X),o=(o=Math.imul(R,tt))+Math.imul(q,X)|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(_,it)|0,o=(o=o+Math.imul(_,st)|0)+Math.imul(L,it)|0,i=i+Math.imul(L,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(x,dt)|0,o=(o=o+Math.imul(x,pt)|0)+Math.imul(S,dt)|0,i=i+Math.imul(S,pt)|0;var Tt=(c+(r=r+Math.imul(M,mt)|0)|0)+((8191&(o=(o=o+Math.imul(M,ft)|0)+Math.imul(P,mt)|0))<<13)|0;c=((i=i+Math.imul(P,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(_,ut)|0,o=(o=o+Math.imul(_,ct)|0)+Math.imul(L,ut)|0,i=i+Math.imul(L,ct)|0,r=r+Math.imul(T,dt)|0,o=(o=o+Math.imul(T,pt)|0)+Math.imul(E,dt)|0,i=i+Math.imul(E,pt)|0;var Et=(c+(r=r+Math.imul(x,mt)|0)|0)+((8191&(o=(o=o+Math.imul(x,ft)|0)+Math.imul(S,mt)|0))<<13)|0;c=((i=i+Math.imul(S,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(_,dt)|0,o=(o=o+Math.imul(_,pt)|0)+Math.imul(L,dt)|0,i=i+Math.imul(L,pt)|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,dt)|0,o=(o=o+Math.imul(W,pt)|0)+Math.imul(D,dt)|0,i=i+Math.imul(D,pt)|0;var _t=(c+(r=r+Math.imul(_,mt)|0)|0)+((8191&(o=(o=o+Math.imul(_,ft)|0)+Math.imul(L,mt)|0))<<13)|0;c=((i=i+Math.imul(L,ft)|0)+(o>>>13)|0)+(_t>>>26)|0,_t&=67108863,r=Math.imul(R,dt),o=(o=Math.imul(R,pt))+Math.imul(q,dt)|0,i=Math.imul(q,pt);var Lt=(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)+(Lt>>>26)|0,Lt&=67108863;var Ut=(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)+(Ut>>>26)|0,Ut&=67108863,u[0]=yt,u[1]=gt,u[2]=wt,u[3]=bt,u[4]=kt,u[5]=vt,u[6]=It,u[7]=Mt,u[8]=Pt,u[9]=At,u[10]=xt,u[11]=St,u[12]=Ct,u[13]=Tt,u[14]=Et,u[15]=Bt,u[16]=_t,u[17]=Lt,u[18]=Ut,0!==c&&(u[19]=c,n.length++),n};function y(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,d=(0|t.words[l])*(0|e.words[c]),p=67108863&d;a=67108863&(p=p+a|0),o+=(s=(s=s+(d/67108864|0)|0)+(p>>>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 g(t,e,n){return y(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?y(this,t,e):g(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),g(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 d=0|this.words[c];this.words[c]=l<<26-i|d>>>i,l=d&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 d=u-1;d>=0;d--){var p=67108864*(0|r.words[i.length+d])+(0|r.words[i.length+d-1]);for(p=Math.min(p/s|0,67108863),r._ishlnsubmul(i,p,d);0!==r.negative;)p--,r.negative=0,r._ishlnsubmul(i,1,d),r.isZero()||(r.negative^=1);a&&(a.words[d]=p)}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(),d=e.clone();!e.isZero();){for(var p=0,h=1;0==(e.words[0]&h)&&p<26;++p,h<<=1);if(p>0)for(e.iushrn(p);p-- >0;)(i.isOdd()||s.isOdd())&&(i.iadd(l),s.isub(d)),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(d)),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 d=0,p=1;0==(r.words[0]&p)&&d<26;++d,p<<=1);if(d>0)for(r.iushrn(d);d-- >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 P(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 v(){b.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function I(){b.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function M(){b.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function P(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 A(t){P.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(v,b),r(I,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 v;else if("p192"===t)e=new I;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new M}return w[t]=e,e},P.prototype._verify1=function(t){n(0===t.negative,"red works only with positives"),n(t.red,"red works only with red numbers")},P.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")},P.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):(c(t,t.umod(this.m)._forceRed(this)),t)},P.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},P.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)},P.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},P.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)},P.prototype.isub=function(t,e){this._verify2(t,e);var n=t.isub(e);return n.cmpn(0)<0&&n.iadd(this.m),n},P.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},P.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},P.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},P.prototype.isqr=function(t){return this.imul(t,t.clone())},P.prototype.sqr=function(t){return this.mul(t,t)},P.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 d=this.pow(l,i),p=this.pow(t,i.addn(1).iushrn(1)),h=this.pow(t,i),m=s;0!==h.cmp(a);){for(var f=h,y=0;0!==f.cmp(a);y++)f=f.redSqr();n(y<m);var g=this.pow(d,new o(1).iushln(m-y-1));p=p.redMul(g),d=g.redSqr(),h=h.redMul(d),m=y}return p},P.prototype.invm=function(t){var e=t._invmp(this.m);return 0!==e.negative?(e.negative=0,this.imod(e).redNeg()):this.imod(e)},P.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 d=c>>l&1;i!==n[0]&&(i=this.sqr(i)),0!==d||0!==s?(s<<=1,s|=d,(4==++a||0===r&&0===l)&&(i=this.mul(i,n[s]),a=0,s=0)):a=0}u=26}return i},P.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},P.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},o.mont=function(t){return new A(t)},r(A,P),A.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},A.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},A.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)},A.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)},A.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(0,to);var io=eo(ro.exports);const so={Spl:"spl",Token2022:"token2022",SplCold:"spl-cold",Token2022Cold:"token2022-cold",CTokenHot:"ctoken-hot",CTokenCold:"ctoken-cold"};function ao(t){if(!t||0===t.length)return null;try{let e=0;const n=new P(t.slice(e,e+32));e+=32;const r=new P(t.slice(e,e+32));e+=32;const o=new io(t.slice(e,e+8),"le");e+=8;const i=t[e];e+=1;const s=i?new P(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 uo(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!==N.Uninitialized,isFrozen:e.state===N.Frozen,isNative:0,rentExemptReserve:null,closeAuthority:null,tlvData:e.tlv?xt.from(e.tlv):xt.alloc(0)}}function co(t){const e=xt.from(t.data.discriminator),n=xt.from(t.data.data),r=xt.concat([e,n]);return{executable:0,owner:t.owner,lamports:t.lamports.toNumber(),data:r,rentEpoch:void 0}}function lo(t,e){const n=ao(e.data);if(!n)throw new Error("Invalid token data");return{accountInfo:e,loadContext:void 0,parsed:uo(t,n),isCold:0}}function po(t,e){const n=ao(e.data.data);if(!n)throw new Error("Invalid token data");return{accountInfo:co(e),loadContext:{treeInfo:e.treeInfo,hash:e.hash,leafIndex:e.leafIndex,proveByIndex:e.proveByIndex},parsed:uo(t,n),isCold:1}}async function ho(t,e,n,r){return fo(t,e,n,r,void 0)}async function mo(t,e,n,r,o,i,s=0){const a=xr(e,r,n,i);if(s&&"ctoken"!==a.type)throw new Error(`For wrap=true, ata must be the c-token ATA. Got ${a.type} ATA instead.`);const u=await fo(t,e,o,i,{owner:n,mint:r},s);return u._isAta=1,u._owner=n,u._mint=r,u}async function fo(e,n,r,o,i,s=0){if(!n&&!i)throw new Error("One of address or fetchByOwner is required");if(!o)return async function(e,n,r,o,i){const s=n??q(o.mint,o.owner,0,h,Ar(h)),a=[],u=[],c=[];if(a.push(async function(t,e,n){const r=await t.getAccountInfo(e,n);if(!r||!r.owner.equals(h))throw new Error("Not a CTOKEN onchain account");return lo(e,r)}(e,s,r)),u.push(so.CTokenHot),c.push(s),a.push(o?async function(t,e,n,r){const o=await t.getCompressedTokenAccountsByOwner(e,{mint:n}),i=o.items.length>0?o.items[0].compressedAccount:null;if(!i?.data?.data.length)throw new Error("Not a compressed token account");if(!i.owner.equals(h))throw new Error("Invalid owner for compressed token");return po(r,i)}(e,o.owner,o.mint,s):async function(e,n){const r=f().tree,o=p(n.toBytes(),r,h),i=await e.getCompressedAccount(t(o.toBytes()));if(!i?.data?.data.length)throw new Error("Compressed token account not found at derived address. Note: getAccountInterface only finds compressed accounts that were compressed from on-chain (via compress_accounts_idempotent). For tokens minted compressed (via mintTo), use getAtaInterface with owner+mint.");if(!i.owner.equals(h))throw new Error("Invalid owner for compressed token");return po(n,i)}(e,n)),u.push(so.CTokenCold),c.push(s),i){if(!o)throw new Error("fetchByOwner is required for wrap=true to derive SPL/T22 addresses");const t=q(o.mint,o.owner,0,D,Ar(D)),n=q(o.mint,o.owner,0,O,Ar(O));a.push(async function(t,e,n){const r=await t.getAccountInfo(e,n);if(!r||!r.owner.equals(D))throw new Error("Not a TOKEN_PROGRAM_ID account");return{accountInfo:r,parsed:_(e,r,D),isCold:0,loadContext:void 0}}(e,t,r)),u.push(so.Spl),c.push(t),a.push(async function(t,e,n){const r=await t.getAccountInfo(e,n);if(!r||!r.owner.equals(O))throw new Error("Not a TOKEN_2022_PROGRAM_ID account");return{accountInfo:r,parsed:_(e,r,O),isCold:0,loadContext:void 0}}(e,n,r)),u.push(so.Token2022),c.push(n)}const l=await Promise.allSettled(a),d=[];for(let t=0;t<l.length;t++){const e=l[t];if("fulfilled"===e.status){const n=e.value;d.push({type:u[t],address:c[t],amount:n.parsed.amount,accountInfo:n.accountInfo,loadContext:n.loadContext,parsed:n.parsed})}}if(0===d.length)throw new Error(`Token account not found. Tried ${i?"TOKEN_PROGRAM_ID, TOKEN_2022_PROGRAM_ID, and CTOKEN_PROGRAM_ID (both onchain and compressed)":"CTOKEN_PROGRAM_ID (both onchain and compressed)"}.`);const m=[so.CTokenHot,so.CTokenCold,so.Spl,so.Token2022];return d.sort(((t,e)=>m.indexOf(t.type)-m.indexOf(e.type))),yo(d,s)}(e,n,r,i,s);if(o.equals(h))return async function(t,e,n,r){if(!e){if(!r)throw new Error("fetchByOwner is required");e=q(r.mint,r.owner,0,h,Ar(h))}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(h)){const t=lo(e,s);u.push({type:so.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(h)){const n=po(e,t);u.push({type:so.CTokenCold,address:e,amount:n.parsed.amount,accountInfo:n.accountInfo,loadContext:n.loadContext,parsed:n.parsed})}if(0===u.length)throw new F;return u.sort(((t,e)=>"ctoken-hot"===t.type&&"ctoken-cold"===e.type?-1:"ctoken-cold"===t.type&&"ctoken-hot"===e.type?1:0)),yo(u,e)}(e,n,r,i);if(o.equals(D)||o.equals(O))return async function(t,e,n,r,o){if(!e){if(!o)throw new Error("fetchByOwner is required");e=q(o.mint,o.owner,0,r,Ar(r))}const i=await t.getAccountInfo(e,n);if(!i)throw new F;const s=_(e,i,r),a=[{type:r.equals(D)?so.Spl:so.Token2022,address:e,amount:s.amount,accountInfo:i,parsed:s}];if(o){const n=(await t.getCompressedTokenAccountsByOwner(o.owner,{mint:o.mint})).items.map((t=>t.compressedAccount)),i=r.equals(D)?so.SplCold:so.Token2022Cold;for(const t of n)if(t&&t.data&&t.data.data.length>0&&t.owner.equals(h)){const n=po(e,t);a.push({type:i,address:e,amount:n.parsed.amount,accountInfo:n.accountInfo,loadContext:n.loadContext,parsed:n.parsed})}}return yo(a,e)}(e,n,r,o,i);throw new Error(`Unsupported program ID: ${o.toBase58()}`)}function yo(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 go(t,e,n=0,r=h,o){const i=o??Ar(r);return q(t,e,n,r,i)}function wo(t,e,n,r,o,i,s=n){const a=jr({withTransactionHash:0,withLamportsChangeAccountMerkleTreeIndex:0,lamportsChangeAccountMerkleTreeIndex:0,lamportsChangeAccountOwnerIndex:0,outputQueue:0,maxTopUp:0,cpiContext:null,compressions:[Zr(o,0,2,1,4,i.poolIndex,i.bump),Hr(o,0,3,6)],proof:null,inTokenData:[],outTokenData:[],inLamports:null,outLamports:null,inTlv:null,outTlv:null}),u=[{pubkey:Un.deriveCpiAuthorityPda,isSigner:0,isWritable:0},{pubkey:s,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:h,isSigner:0,isWritable:0}];return new x({programId:Un.programId,keys:u,data:a})}async function bo(t,e,n,r,o,i,s=0){return o??=n,ko(t,o,await mo(t,e,n,r,void 0,void 0,s),i,s,e)}async function ko(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??[],l=go(u,a),d=q(u,a,0,D,Ar(D)),p=q(u,a,0,O,Ar(O));let m="ctoken";if(i&&(m=xr(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)),y=c.find((t=>"token2022"===t.type)),g=c.find((t=>"ctoken-hot"===t.type)),w=c.find((t=>"ctoken-cold"===t.type)),b=f?.amount??BigInt(0),k=y?.amount??BigInt(0),v=w?.amount??BigInt(0);if(b===BigInt(0)&&k===BigInt(0)&&v===BigInt(0))return[];let I;if(o||"spl"===m||"token2022"===m||b>BigInt(0)||k>BigInt(0))try{I=(r?.splInterfaceInfos??await Ce(t,u)).find((t=>t.isInitialized))}catch{}if(o){if(g||s.push(Tr(e,l,a,u,h)),b>BigInt(0)&&I&&s.push(wo(d,l,a,u,b,I,e)),k>BigInt(0)&&I&&s.push(wo(p,l,a,u,k,I,e)),v>BigInt(0)&&w){const n=(await t.getCompressedTokenAccountsByOwner(a,{mint:u})).items;if(n.length>0){const r=await t.getValidityProofV0(n.map((t=>({hash:t.compressedAccount.hash,tree:t.compressedAccount.treeInfo.tree,queue:t.compressedAccount.treeInfo.queue}))));s.push(Xr(e,n,l,v,r))}}}else if(v>BigInt(0)&&w){const n=(await t.getCompressedTokenAccountsByOwner(a,{mint:u})).items;if(n.length>0){const r=await t.getValidityProofV0(n.map((t=>({hash:t.compressedAccount.hash,tree:t.compressedAccount.treeInfo.tree,queue:t.compressedAccount.treeInfo.queue}))));"ctoken"===m?(g||s.push(Tr(e,l,a,u,h)),s.push(Xr(e,n,l,v,r))):"spl"===m&&I?(f||s.push(z(e,d,a,u,D)),s.push(Xr(e,n,d,v,r,I))):"token2022"===m&&I&&(y||s.push(z(e,p,a,u,O)),s.push(Xr(e,n,p,v,r,I)))}}return s}async function vo(t,e,n,r,o,i,s,a=0){o??=n;const u=await bo(t,e,n.publicKey,r,o.publicKey,s,a);if(0===u.length)return null;const{blockhash:c}=await t.getLatestBlockhash(),l=g(o,[n]),d=w([C.setComputeUnitLimit({units:5e5}),...u],o,c,l);return b(t,d,i)}async function Io(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 k(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 ko(t,e,n,i);u.push(...r)}return{decompressParams:s,ataInstructions:u}}function Mo(t,e){let n=5e4;return e&&(n+=1e5),n+=3e4*t,n}async function Po(t,e,n,r,o=T.generate(),i,s,a){const u=await t.getMinimumBalanceForRentExemption(L),c=1==s?O:s||D,l=await Un.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:d}=await t.getLatestBlockhash(),p=g(e,[n,a??null].filter((t=>null!=t&&"secretKey"in t))),h=w(l,e,d,[...p,o]),m=await b(t,h,i);return{mint:o.publicKey,transactionSignature:m}}async function Ao(t,e,n,r,o,i=T.generate(),s,a=h,u,c,l){if(a.equals(D)||a.equals(O))return Po(t,e,n,o,i,s,a,r);if(!("secretKey"in n))throw new Error("mintAuthority must be a Signer for compressed token mints");const d=r&&"secretKey"in r?r.publicKey:r;l=l??v(),c=c??I(await t.getStateTreeInfos());const p=await t.getValidityProofV2([],[{address:On(i.publicKey)[0].toBytes(),treeInfo:l}],M.compressible),m=ur(i.publicKey,o,n.publicKey,d,e.publicKey,p,l,c,u),f=g(e,[i,n]),{blockhash:y}=await t.getLatestBlockhash(),k=w([C.setComputeUnitLimit({units:5e5}),m],e,y,f),P=await b(t,k,{...s,skipPreflight:1});return{mint:On(i.publicKey)[0],transactionSignature:P}}var xo={};Object.defineProperty(xo,"__esModule",{value:1}),xo.s16=xo.s8=xo.nu64be=xo.u48be=xo.u40be=xo.u32be=xo.u24be=xo.u16be=xo.nu64=xo.u48=xo.u40=xo.u32=xo.u24=xo.u16=li=xo.u8=xo.offset=xo.greedy=xo.Constant=xo.UTF8=xo.CString=xo.Blob=xo.Boolean=xo.BitField=xo.BitStructure=xo.VariantLayout=xo.Union=xo.UnionLayoutDiscriminator=xo.UnionDiscriminator=xo.Structure=xo.Sequence=xo.DoubleBE=xo.Double=xo.FloatBE=xo.Float=xo.NearInt64BE=xo.NearInt64=xo.NearUInt64BE=xo.NearUInt64=xo.IntBE=xo.Int=xo.UIntBE=xo.UInt=xo.OffsetLayout=xo.GreedyCount=xo.ExternalLayout=xo.bindConstructorLayout=xo.nameWithProperty=xo.Layout=xo.uint8ArrayToBuffer=xo.checkUint8Array=void 0,xo.constant=xo.utf8=xo.cstr=pi=xo.blob=xo.unionLayoutDiscriminator=xo.union=xo.seq=xo.bits=di=xo.struct=xo.f64be=xo.f64=xo.f32be=xo.f32=xo.ns64be=xo.s48be=xo.s40be=xo.s32be=xo.s24be=xo.s16be=xo.ns64=xo.s48=xo.s40=xo.s32=xo.s24=void 0;const So=oo;function Co(t){if(!(t instanceof Uint8Array))throw new TypeError("b must be a Uint8Array")}function To(t){return Co(t),So.Buffer.from(t.buffer,t.byteOffset,t.length)}xo.checkUint8Array=Co,xo.uint8ArrayToBuffer=To;class Eo{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 Bo(t,e){return e.property?t+"["+e.property+"]":t}xo.Layout=Eo,xo.nameWithProperty=Bo,xo.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 Eo))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 _o extends Eo{isCount(){throw new Error("ExternalLayout is abstract")}}xo.ExternalLayout=_o;class Lo extends _o{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){Co(t);const n=t.length-e;return Math.floor(n/this.elementSpan)}encode(t,e,n){return 0}}xo.GreedyCount=Lo;class Uo extends _o{constructor(t,e=0,n){if(!(t instanceof Eo))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 Wo||this.layout instanceof Do}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)}}xo.OffsetLayout=Uo;class Wo extends Eo{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return To(t).readUIntLE(e,this.span)}encode(t,e,n=0){return To(e).writeUIntLE(t,n,this.span),this.span}}xo.UInt=Wo;class Do extends Eo{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return To(t).readUIntBE(e,this.span)}encode(t,e,n=0){return To(e).writeUIntBE(t,n,this.span),this.span}}xo.UIntBE=Do;class Oo extends Eo{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return To(t).readIntLE(e,this.span)}encode(t,e,n=0){return To(e).writeIntLE(t,n,this.span),this.span}}xo.Int=Oo;class Ro extends Eo{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return To(t).readIntBE(e,this.span)}encode(t,e,n=0){return To(e).writeIntBE(t,n,this.span),this.span}}xo.IntBE=Ro;const qo=Math.pow(2,32);function Ko(t){const e=Math.floor(t/qo);return{hi32:e,lo32:t-e*qo}}function zo(t,e){return t*qo+e}class Vo extends Eo{constructor(t){super(8,t)}decode(t,e=0){const n=To(t),r=n.readUInt32LE(e);return zo(n.readUInt32LE(e+4),r)}encode(t,e,n=0){const r=Ko(t),o=To(e);return o.writeUInt32LE(r.lo32,n),o.writeUInt32LE(r.hi32,n+4),8}}xo.NearUInt64=Vo;class No extends Eo{constructor(t){super(8,t)}decode(t,e=0){const n=To(t);return zo(n.readUInt32BE(e),n.readUInt32BE(e+4))}encode(t,e,n=0){const r=Ko(t),o=To(e);return o.writeUInt32BE(r.hi32,n),o.writeUInt32BE(r.lo32,n+4),8}}xo.NearUInt64BE=No;class Fo extends Eo{constructor(t){super(8,t)}decode(t,e=0){const n=To(t),r=n.readUInt32LE(e);return zo(n.readInt32LE(e+4),r)}encode(t,e,n=0){const r=Ko(t),o=To(e);return o.writeUInt32LE(r.lo32,n),o.writeInt32LE(r.hi32,n+4),8}}xo.NearInt64=Fo;class $o extends Eo{constructor(t){super(8,t)}decode(t,e=0){const n=To(t);return zo(n.readInt32BE(e),n.readUInt32BE(e+4))}encode(t,e,n=0){const r=Ko(t),o=To(e);return o.writeInt32BE(r.hi32,n),o.writeUInt32BE(r.lo32,n+4),8}}xo.NearInt64BE=$o;class Yo extends Eo{constructor(t){super(4,t)}decode(t,e=0){return To(t).readFloatLE(e)}encode(t,e,n=0){return To(e).writeFloatLE(t,n),4}}xo.Float=Yo;class jo extends Eo{constructor(t){super(4,t)}decode(t,e=0){return To(t).readFloatBE(e)}encode(t,e,n=0){return To(e).writeFloatBE(t,n),4}}xo.FloatBE=jo;class Zo extends Eo{constructor(t){super(8,t)}decode(t,e=0){return To(t).readDoubleLE(e)}encode(t,e,n=0){return To(e).writeDoubleLE(t,n),8}}xo.Double=Zo;class Ho extends Eo{constructor(t){super(8,t)}decode(t,e=0){return To(t).readDoubleBE(e)}encode(t,e,n=0){return To(e).writeDoubleBE(t,n),8}}xo.DoubleBE=Ho;class Go extends Eo{constructor(t,e,n){if(!(t instanceof Eo))throw new TypeError("elementLayout must be a Layout");if(!(e instanceof _o&&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 _o)&&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 _o&&(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 _o&&(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 _o&&this.count.encode(t.length,e,n),o}}xo.Sequence=Go;class Qo extends Eo{constructor(t,e,n){if(!Array.isArray(t)||!t.reduce(((t,e)=>t&&e instanceof Eo),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){Co(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)}}}xo.Structure=Qo;class Jo{constructor(t){this.property=t}decode(t,e){throw new Error("UnionDiscriminator is abstract")}encode(t,e,n){throw new Error("UnionDiscriminator is abstract")}}xo.UnionDiscriminator=Jo;class Xo extends Jo{constructor(t,e){if(!(t instanceof _o&&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)}}xo.UnionLayoutDiscriminator=Xo;class ti extends Eo{constructor(t,e,n){let r;if(t instanceof Wo||t instanceof Do)r=new Xo(new Uo(t));else if(t instanceof _o&&t.isCount())r=new Xo(t);else{if(!(t instanceof Jo))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 Eo))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 Wo||t instanceof Do)&&(o+=r.layout.span)),super(o,n),this.discriminator=r,this.usesPrefixDiscriminator=t instanceof Wo||t instanceof Do,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 ei(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]}}xo.Union=ti;class ei extends Eo{constructor(t,e,n,r){if(!(t instanceof ti))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 Eo))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 ni(t){return 0>t&&(t+=4294967296),t}xo.VariantLayout=ei;class ri extends Eo{constructor(t,e,n){if(!(t instanceof Wo||t instanceof Do))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=ni(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 oi(this,t,e);return this.fields.push(n),n}addBoolean(t){const e=new ii(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}}xo.BitStructure=ri;class oi{constructor(t,e,n){if(!(t instanceof ri))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=ni(this.valueMask<<this.start),this.property=n}decode(t,e){return ni(this.container._packedGetValue()&this.wordMask)>>>this.start}encode(t){if("number"!=typeof t||!Number.isInteger(t)||t!==ni(t&this.valueMask))throw new TypeError(Bo("BitField.encode",this)+" value must be integer not exceeding "+this.valueMask);const e=this.container._packedGetValue(),n=ni(t<<this.start);this.container._packedSetValue(ni(e&~this.wordMask)|n)}}xo.BitField=oi;class ii extends oi{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)}}xo.Boolean=ii;class si extends Eo{constructor(t,e){if(!(t instanceof _o&&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 _o||(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)),To(t).slice(e,e+n)}encode(t,e,n){let r=this.length;if(this.length instanceof _o&&(r=t.length),!(t instanceof Uint8Array&&r===t.length))throw new TypeError(Bo("Blob.encode",this)+" requires (length "+r+") Uint8Array as src");if(n+r>e.length)throw new RangeError("encoding overruns Uint8Array");const o=To(t);return To(e).write(o.toString("hex"),n,r,"hex"),this.length instanceof _o&&this.length.encode(r,e,n),r}}xo.Blob=si;class ai extends Eo{constructor(t){super(-1,t)}getSpan(t,e=0){Co(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 To(t).slice(e,e+n-1).toString("utf-8")}encode(t,e,n=0){"string"!=typeof t&&(t=String(t));const r=So.Buffer.from(t,"utf8"),o=r.length;if(n+o>e.length)throw new RangeError("encoding overruns Buffer");const i=To(e);return r.copy(i,n),i[n+o]=0,o+1}}xo.CString=ai;class ui extends Eo{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 Co(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 To(t).slice(e,e+n).toString("utf-8")}encode(t,e,n=0){"string"!=typeof t&&(t=String(t));const r=So.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(To(e),n),o}}xo.UTF8=ui;class ci extends Eo{constructor(t,e){super(0,e),this.value=t}decode(t,e){return this.value}encode(t,e,n){return 0}}xo.Constant=ci,xo.greedy=(t,e)=>new Lo(t,e),xo.offset=(t,e,n)=>new Uo(t,e,n);var li=xo.u8=t=>new Wo(1,t);xo.u16=t=>new Wo(2,t),xo.u24=t=>new Wo(3,t),xo.u32=t=>new Wo(4,t),xo.u40=t=>new Wo(5,t),xo.u48=t=>new Wo(6,t),xo.nu64=t=>new Vo(t),xo.u16be=t=>new Do(2,t),xo.u24be=t=>new Do(3,t),xo.u32be=t=>new Do(4,t),xo.u40be=t=>new Do(5,t),xo.u48be=t=>new Do(6,t),xo.nu64be=t=>new No(t),xo.s8=t=>new Oo(1,t),xo.s16=t=>new Oo(2,t),xo.s24=t=>new Oo(3,t),xo.s32=t=>new Oo(4,t),xo.s40=t=>new Oo(5,t),xo.s48=t=>new Oo(6,t),xo.ns64=t=>new Fo(t),xo.s16be=t=>new Ro(2,t),xo.s24be=t=>new Ro(3,t),xo.s32be=t=>new Ro(4,t),xo.s40be=t=>new Ro(5,t),xo.s48be=t=>new Ro(6,t),xo.ns64be=t=>new $o(t),xo.f32=t=>new Yo(t),xo.f32be=t=>new jo(t),xo.f64=t=>new Zo(t),xo.f64be=t=>new Ho(t);var di=xo.struct=(t,e,n)=>new Qo(t,e,n);xo.bits=(t,e,n)=>new ri(t,e,n),xo.seq=(t,e,n)=>new Go(t,e,n),xo.union=(t,e,n)=>new ti(t,e,n),xo.unionLayoutDiscriminator=(t,e)=>new Xo(t,e);var pi=xo.blob=(t,e)=>new si(t,e);xo.cstr=t=>new ai(t),xo.utf8=(t,e)=>new ui(t,e),xo.constant=(t,e)=>new ci(t,e);const hi=X([nt("updateAuthority"),nt("mint"),it("name"),it("symbol"),it("uri"),ct(X([it("key"),it("value")]),"additionalMetadata")]),mi=di([li("version"),li("splMintInitialized"),(()=>{const t=pi(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 P(r)},r.encode=(t,n,r)=>{const o=t.toBuffer();return e(o,n,r)},r})()]),fi=mi.span;function yi(t,e,n){return t===bi.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 gi(t){const e=t instanceof xt?t:xt.from(t);let n=0;const r=$.decode(e.slice(n,n+L));n+=L;const o=mi.decode(e.slice(n,n+fi));n+=fi;const i=1===e.readUInt8(n);n+=1;let s=null;if(i){const t=e.readUInt32LE(n);n+=4,s=[];for(let r=0;r<t;r++){const t=e.readUInt8(n);n+=1;const r=yi(t,e,n),o=e.slice(n,n+r);n+=r,s.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,splMintInitialized:0!==o.splMintInitialized,splMint:o.splMint},extensions:s}}function wi(t){const e=[],n=xt.alloc(L);$.encode({mintAuthorityOption:t.base.mintAuthority?1:0,mintAuthority:t.base.mintAuthority||new P(0),supply:t.base.supply,decimals:t.base.decimals,isInitialized:t.base.isInitialized,freezeAuthorityOption:t.base.freezeAuthority?1:0,freezeAuthority:t.base.freezeAuthority||new P(0)},n),e.push(n);const r=xt.alloc(fi);if(mi.encode({version:t.mintContext.version,splMintInitialized:t.mintContext.splMintInitialized?1:0,splMint:t.mintContext.splMint},r),e.push(r),t.extensions&&t.extensions.length>0){e.push(xt.from([1]));const n=xt.alloc(4);n.writeUInt32LE(t.extensions.length),e.push(n);for(const n of t.extensions)e.push(xt.from([n.extensionType])),e.push(xt.from(n.data))}else e.push(xt.from([0]));return xt.concat(e)}var bi;function ki(t){try{const e=xt.from(t);if(e.length<80)return null;const n=hi.decode(e),r=n.updateAuthority.toBuffer().every((t=>0===t))?void 0:n.updateAuthority,o=xt.from(n.name).toString("utf-8"),i=xt.from(n.symbol).toString("utf-8"),s=xt.from(n.uri).toString("utf-8");let a;return n.additionalMetadata&&n.additionalMetadata.length>0&&(a=n.additionalMetadata.map((t=>({key:xt.from(t.key).toString("utf-8"),value:xt.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 vi(t){const e=xt.alloc(2e3),n=t.updateAuthority||new P(0),r=hi.encode({updateAuthority:n,mint:t.mint,name:xt.from(t.name),symbol:xt.from(t.symbol),uri:xt.from(t.uri),additionalMetadata:t.additionalMetadata?t.additionalMetadata.map((t=>({key:xt.from(t.key),value:xt.from(t.value)}))):[]},e);return e.subarray(0,r)}!function(t){t[t.TokenMetadata=19]="TokenMetadata"}(bi||(bi={}));const Ii=ki;function Mi(t){if(!t)return null;const e=t.find((t=>t.extensionType===bi.TokenMetadata));return e?Ii(e.data):null}async function Pi(e,n,r,o){if(!o){const[t,o,i]=await Promise.allSettled([Pi(e,n,r,D),Pi(e,n,r,O),Pi(e,n,r,h)]);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 CTOKEN_PROGRAM_ID.`)}if(o.equals(h)){const r=f().tree,i=p(n.toBytes(),r,h),s=await e.getCompressedAccount(t(i.toBytes()));if(!s?.data?.data)throw new Error(`Compressed mint not found for ${n.toString()}`);const a=gi(xt.from(s.data.data)),u={address:n,mintAuthority:a.base.mintAuthority,supply:a.base.supply,decimals:a.base.decimals,isInitialized:a.base.isInitialized,freezeAuthority:a.base.freezeAuthority,tlvData:xt.alloc(0)},c={treeInfo:s.treeInfo,hash:s.hash,leafIndex:s.leafIndex,proveByIndex:s.proveByIndex},l=Mi(a.extensions),d={mint:u,programId:o,merkleContext:c,mintContext:a.mintContext,tokenMetadata:l||void 0,extensions:a.extensions||void 0};if(o.equals(h)){if(!d.merkleContext)throw new Error("Invalid compressed mint: merkleContext is required for CTOKEN_PROGRAM_ID");if(!d.mintContext)throw new Error("Invalid compressed mint: mintContext is required for CTOKEN_PROGRAM_ID")}return d}return{mint:await Y(e,n,r,o),programId:o}}function Ai(t,e,n=D){const r=e instanceof xt?e:e instanceof Uint8Array?xt.from(e):e.data;if(n.equals(h)){const e=gi(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:xt.alloc(0)},i=Mi(e.extensions),s={mint:o,programId:n,mintContext:e.mintContext,tokenMetadata:i||void 0,extensions:e.extensions||void 0};if(n.equals(h)&&!s.mintContext)throw new Error("Invalid compressed mint: mintContext is required for CTOKEN_PROGRAM_ID");return s}return{mint:j(t,e,n),programId:n}}function xi(t){const e=gi(t instanceof xt?t:xt.from(t)),n=Mi(e.extensions);return{mintContext:e.mintContext,tokenMetadata:n||void 0,extensions:e.extensions||void 0}}async function Si(e,n,r,o,i,s){const a=await Pi(e,r,s?.commitment,h);if(!a.merkleContext)throw new Error("Mint does not have MerkleContext");const u=await e.getValidityProofV2([{hash:t(a.merkleContext.hash),leafIndex:a.merkleContext.leafIndex,treeInfo:a.merkleContext.treeInfo,proveByIndex:a.merkleContext.proveByIndex}],[],M.compressible),c=lr(a,o.publicKey,i,n.publicKey,u),l=o.publicKey.equals(n.publicKey)?[]:[o],{blockhash:d}=await e.getLatestBlockhash(),p=w([C.setComputeUnitLimit({units:5e5}),c],n,d,l);return await b(e,p,s)}async function Ci(e,n,r,o,i,s){const a=await Pi(e,r,s?.commitment,h);if(!a.merkleContext)throw new Error("Mint does not have MerkleContext");const u=await e.getValidityProofV2([{hash:t(a.merkleContext.hash),leafIndex:a.merkleContext.leafIndex,treeInfo:a.merkleContext.treeInfo,proveByIndex:a.merkleContext.proveByIndex}],[],M.compressible),c=dr(a,o.publicKey,i,n.publicKey,u),l=o.publicKey.equals(n.publicKey)?[]:[o],{blockhash:d}=await e.getLatestBlockhash(),p=w([C.setComputeUnitLimit({units:5e5}),c],n,d,l);return await b(e,p,s)}async function Ti(e,n,r,o,i,s,a,u=0,c){const l=await Pi(e,r,c?.commitment,h);if(!l.tokenMetadata||!l.merkleContext)throw new Error("Mint does not have TokenMetadata extension");const d=await e.getValidityProofV2([{hash:t(l.merkleContext.hash),leafIndex:l.merkleContext.leafIndex,treeInfo:l.merkleContext.treeInfo,proveByIndex:l.merkleContext.proveByIndex}],[],M.compressible),p=hr(l,o.publicKey,n.publicKey,d,i,s,a,u),m=o.publicKey.equals(n.publicKey)?[]:[o],{blockhash:f}=await e.getLatestBlockhash(),y=w([C.setComputeUnitLimit({units:5e5}),p],n,f,m);return await b(e,y,c)}async function Ei(e,n,r,o,i,s=0,a){const u=await Pi(e,r,a?.commitment,h);if(!u.tokenMetadata||!u.merkleContext)throw new Error("Mint does not have TokenMetadata extension");const c=await e.getValidityProofV2([{hash:t(u.merkleContext.hash),leafIndex:u.merkleContext.leafIndex,treeInfo:u.merkleContext.treeInfo,proveByIndex:u.merkleContext.proveByIndex}],[],M.compressible),l=mr(u,o.publicKey,i,n.publicKey,c,s),d=o.publicKey.equals(n.publicKey)?[]:[o],{blockhash:p}=await e.getLatestBlockhash(),m=w([C.setComputeUnitLimit({units:5e5}),l],n,p,d);return await b(e,m,a)}async function Bi(e,n,r,o,i,s=0,a=0,u){const c=await Pi(e,r,u?.commitment,h);if(!c.tokenMetadata||!c.merkleContext)throw new Error("Mint does not have TokenMetadata extension");const l=await e.getValidityProofV2([{hash:t(c.merkleContext.hash),leafIndex:c.merkleContext.leafIndex,treeInfo:c.merkleContext.treeInfo,proveByIndex:c.merkleContext.proveByIndex}],[],M.compressible),d=fr(c,o.publicKey,n.publicKey,l,i,s,a),p=o.publicKey.equals(n.publicKey)?[]:[o],{blockhash:m}=await e.getLatestBlockhash(),f=w([C.setComputeUnitLimit({units:5e5}),d],n,m,p);return await b(e,f,u)}async function _i(t,e,n,r,o=0,i,s=h,a,u){const c=a??Ar(s),l=go(n,r,o,s,c),d=Cr(e.publicKey,l,r,n,s,c,u);if(s.equals(h)){const{blockhash:n}=await t.getLatestBlockhash(),r=w([C.setComputeUnitLimit({units:3e4}),d],e,n,[]);await b(t,r,i)}else{const n=(new E).add(d);await B(t,n,[e],i)}return l}async function Li(t,e,n,r,o=0,i,s=h,a,u){const c=a??Ar(s),l=go(n,r,o,s,c),d=Tr(e.publicKey,l,r,n,s,c,u);if(s.equals(h)){const{blockhash:n}=await t.getLatestBlockhash(),r=w([C.setComputeUnitLimit({units:3e4}),d],e,n,[]);await b(t,r,i)}else{const n=(new E).add(d);await B(t,n,[e],i)}return l}async function Ui(e,n,r,o,i,s,a,u){const c=await Pi(e,r,u?.commitment,h);if(!c.merkleContext)throw new Error("Mint does not have MerkleContext");let l;if(a){if(l=(await e.getStateTreeInfos()).find((t=>t.queue.equals(a)||t.tree.equals(a))),!l)throw new Error("Could not find TreeInfo for provided outputQueue")}else{const t=await e.getStateTreeInfos();l=I(t)}const d=await e.getValidityProofV2([{hash:t(c.merkleContext.hash),leafIndex:c.merkleContext.leafIndex,treeInfo:c.merkleContext.treeInfo,proveByIndex:c.merkleContext.proveByIndex}],[],M.compressible),p=Br(i.publicKey,n.publicKey,d,c.merkleContext,{supply:c.mint.supply,decimals:c.mint.decimals,mintAuthority:c.mint.mintAuthority,freezeAuthority:c.mint.freezeAuthority,splMint:c.mintContext.splMint,splMintInitialized:c.mintContext.splMintInitialized,version:c.mintContext.version,metadata:c.tokenMetadata?{updateAuthority:c.tokenMetadata.updateAuthority||null,name:c.tokenMetadata.name,symbol:c.tokenMetadata.symbol,uri:c.tokenMetadata.uri}:void 0},l,o,s),m=i.publicKey.equals(n.publicKey)?[]:[i],{blockhash:f}=await e.getLatestBlockhash(),y=w([C.setComputeUnitLimit({units:5e5}),p],n,f,m);return await b(e,y,u)}async function Wi(e,n,r,o,i,s,a=3,u){const c=await Pi(e,r,u?.commitment,h);if(!c.merkleContext)throw new Error("Mint does not have MerkleContext");if(!s){const t=await e.getStateTreeInfos();s=I(t)}const l=await e.getValidityProofV2([{hash:t(c.merkleContext.hash),leafIndex:c.merkleContext.leafIndex,treeInfo:c.merkleContext.treeInfo,proveByIndex:c.merkleContext.proveByIndex}],[],M.compressible),d=_r(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,splMintInitialized:c.mintContext.splMintInitialized,version:c.mintContext.version,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),p=o.publicKey.equals(n.publicKey)?[]:[o],{blockhash:m}=await e.getLatestBlockhash(),f=w([C.setComputeUnitLimit({units:5e5}),d],n,m,p);return await b(e,f,u)}async function Di(e,n,r,o,i,s,a=[],u,c){const l=await Pi(e,r,u?.commitment,c);let d;l.merkleContext&&(d=await e.getValidityProofV2([{hash:t(l.merkleContext.hash),leafIndex:l.merkleContext.leafIndex,treeInfo:l.merkleContext.treeInfo,proveByIndex:l.merkleContext.proveByIndex}],[],M.compressible));const p=i instanceof P?i:i.publicKey,h=a.map((t=>t.publicKey)),m=Lr(l,o,p,n.publicKey,s,d,h),f=[];i instanceof P||i.publicKey.equals(n.publicKey)||f.push(i),f.push(...a);const{blockhash:y}=await e.getLatestBlockhash(),g=w([C.setComputeUnitLimit({units:5e5}),m],n,y,f);return await b(e,g,u)}async function Oi(t,e,n,r,o=0,i,s,a=D,u=Ar(a)){return Ki(t,e,n,r,o,i,s,a,u,0)}function Ri(t){if(!("publicKey"in t)||!("secretKey"in t))return 0;const e=t;return e.secretKey instanceof Uint8Array&&e.secretKey.length>0}function qi(t){return Ri(t)?t.publicKey:t}async function Ki(t,e,n,r,o,i,s,a,u,c){const l=qi(r),d=q(n,l,o,a,u);return a.equals(h)?async function(t,e,n,r,o,i,s,a=0){const u=qi(r);let c;Ri(r);let l=0;try{c=await mo(t,o,u,n,i,h,a),l=c._sources?.some((t=>t.type===so.CTokenHot))??0}catch(r){if(!(r instanceof F||r instanceof Z))throw r;await zi(t,e,n,u,o,s),c=await mo(t,o,u,n,i,h,a),l=1}if(l||await zi(t,e,n,u,o,s),Ri(r)){const l=c._sources??[],d=l.some((t=>t.type===so.CTokenCold&&t.amount>BigInt(0))),p=a&&l.some((t=>(t.type===so.Spl||t.type===so.Token2022)&&t.amount>BigInt(0)));if(d||p){if(!(r.secretKey instanceof Uint8Array)||0===r.secretKey.length)throw new Error("Owner must be a valid Signer with secretKey to auto-load");await vo(t,o,r,n,e,s,void 0,a),c=await mo(t,o,u,n,i,h,a)}}const d=c.parsed;if(!d.mint.equals(n))throw new H;if(!d.owner.equals(u))throw new G;return c}(t,e,n,r,d,i,s,c):async function(t,e,n,r,o,i,s,a,u){let c;try{c=await ho(t,o,a,i)}catch(l){if(!(l instanceof F||l instanceof Z))throw l;try{const a=(new E).add(Cr(e.publicKey,o,r,n,i,s));await B(t,a,[e],u)}catch{}c=await ho(t,o,a,i)}const l=c.parsed;if(!l.mint.equals(n))throw new H;if(!l.owner.equals(r))throw new G;return c}(t,e,n,l,d,a,u,i,s)}async function zi(t,e,n,r,o,i){try{const s=Tr(e.publicKey,o,r,n,h),{blockhash:a}=await t.getLatestBlockhash(),u=w([C.setComputeUnitLimit({units:2e5}),s],e,a,[]);await b(t,u,i)}catch{}}async function Vi(t,e,n,r,o,i,s,a=h,u,c,l=0){const d=BigInt(s.toString()),{splInterfaceInfos:p}=c??{},m=[];if(!a.equals(h)){const s=q(r,i.publicKey,0,a,Ar(a));if(!n.equals(s))throw new Error(`Source mismatch. Expected ${s.toBase58()}, got ${n.toBase58()}`);m.push(Dr(n,o,i.publicKey,d,[],a));const{blockhash:c}=await t.getLatestBlockhash(),l=w([C.setComputeUnitLimit({units:1e4}),...m],e,c,[i]);return b(t,l,u)}const f=go(r,i.publicKey);if(!n.equals(f))throw new Error(`Source mismatch. Expected ${f.toBase58()}, got ${n.toBase58()}`);const y=go(r,i.publicKey);let k,v;l&&(k=q(r,i.publicKey,0,D,Ar(D)),v=q(r,i.publicKey,0,O,Ar(O)));const I=[t.getAccountInfo(y),t.getCompressedTokenAccountsByOwner(i.publicKey,{mint:r})];l&&k&&v&&(I.push(t.getAccountInfo(k)),I.push(t.getAccountInfo(v)));const M=await Promise.all(I),P=M[0],A=M[1],x=l?M[2]:null,S=l?M[3]:null,T=A.items,E=P&&P.data.length>=72?P.data.readBigUInt64LE(64):BigInt(0),B=l&&x&&x.data.length>=72?x.data.readBigUInt64LE(64):BigInt(0),_=l&&S&&S.data.length>=72?S.data.readBigUInt64LE(64):BigInt(0),L=T.reduce(((t,e)=>t+BigInt(e.parsed.amount.toString())),BigInt(0)),U=E+B+_+L;if(U<d)throw new Error(`Insufficient balance. Required: ${d}, Available: ${U}`);let W=0,R=0,K=[];P||m.push(Tr(e.publicKey,y,i.publicKey,r,h));const z=(B>BigInt(0)||_>BigInt(0)||L>BigInt(0)?p??await Ce(t,r):[]).find((t=>t.isInitialized));if(l&&k&&B>BigInt(0)&&z&&(m.push(wo(k,y,i.publicKey,r,B,z,e.publicKey)),W++),l&&v&&_>BigInt(0)&&z&&(m.push(wo(v,y,i.publicKey,r,_,z,e.publicKey)),W++),L>BigInt(0)&&T.length>0){const n=await t.getValidityProofV0(T.map((t=>({hash:t.compressedAccount.hash,tree:t.compressedAccount.treeInfo.tree,queue:t.compressedAccount.treeInfo.queue}))));R=null!==n.compressedProof,K=T,m.push(Xr(e.publicKey,T,y,L,n))}m.push(Wr(n,o,i.publicKey,d,e.publicKey));const V=function(t,e,n){let r=5e3;if(t.length>0){e&&(r+=1e5);for(const e of t)r+=e.compressedAccount.proveByIndex?1e4:3e4}return r+=5e3*n,r}(K,R,W),{blockhash:N}=await t.getLatestBlockhash(),F=g(e,[i]),$=w([C.setComputeUnitLimit({units:V}),...m],e,N,F);return b(t,$,u)}async function Ni(t,e,n,r,o,i,s,a,u){const c=void 0!==a,l=(await t.getCompressedTokenAccountsByOwner(n.publicKey,{mint:r})).items;if(0===l.length)return null;const d=l.reduce(((t,e)=>t+BigInt(e.parsed.amount.toString())),BigInt(0)),p=o?BigInt(o.toString()):d;if(p>d)throw new Error(`Insufficient compressed balance. Requested: ${p}, Available: ${d}`);const m=[];let f=BigInt(0);for(const t of l){if(f>=p)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})))),k=s??n.publicKey;let v;v=c?i??await Q(r,k,0,a.tokenProgram):i??go(r,k);const I=[];await t.getAccountInfo(v)||(c?I.push(z(e.publicKey,v,k,r,a.tokenProgram)):I.push(Tr(e.publicKey,v,k,r,h)));let M=5e4;null!==y.compressedProof&&(M+=1e5);for(const t of m)M+=t.compressedAccount.proveByIndex?1e4:3e4;c&&(M+=5e4),I.push(Xr(e.publicKey,m,v,p,y,a));const{blockhash:P}=await t.getLatestBlockhash(),A=g(e,[n]),x=w([C.setComputeUnitLimit({units:M}),...I],e,P,A);return b(t,x,u)}async function Fi(t,e,n,r,o,i,s,a,u){let c=a;if(!c&&(c=(await Ce(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=wo(n,r,o.publicKey,i,s,c,e.publicKey),{blockhash:d}=await t.getLatestBlockhash(),p=g(e,[o]),h=w([C.setComputeUnitLimit({units:2e5}),l],e,d,p);return await b(t,h,u)}function $i(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}X([tt(et(),32,"a"),tt(et(),64,"b"),tt(et(),32,"c")]);const Yi=X([ut("rootIndex"),at("proveByIndex"),et("merkleTreePubkeyIndex"),et("queuePubkeyIndex"),st("leafIndex")]);async function ji(e,n,r,o,i,s,a){o=t(o);const u=await e.getCompressedTokenAccountsByOwner(i.publicKey,{mint:r}),[c]=qe(u.items,o),l=await e.getValidityProofV0(c.map((t=>({hash:t.compressedAccount.hash,tree:t.compressedAccount.treeInfo.tree,queue:t.compressedAccount.treeInfo.queue})))),d=await Un.approve({payer:n.publicKey,inputCompressedTokenAccounts:c,toAddress:s,amount:o,recentInputStateRootIndices:l.rootIndices,recentValidityProof:l.compressedProof}),{blockhash:p}=await e.getLatestBlockhash(),h=g(n,[i]),m=w([C.setComputeUnitLimit({units:35e4}),d],n,p,h);return b(e,m,a)}async function Zi(t,e,n,r,o,i,a,u,c){a=a??I(await t.getStateTreeInfos()),u=u??Be(await Ce(t,n));const l=await J(t,e,n,o.publicKey,void 0,void 0,c,u.tokenProgram),d=await Un.approveAndMintTo({feePayer:e.publicKey,mint:n,authority:o.publicKey,authorityTokenAccount:l.address,amount:i,toPubkey:r,outputStateTreeInfo:a,tokenPoolInfo:u}),{blockhash:p}=await t.getLatestBlockhash(),h=g(e,[o]),m=w([C.setComputeUnitLimit({units:15e4+2e4*s(i).length}),...d],e,p,h);return await b(t,m,c)}async function Hi(t,e,n,r,o,i,a,u,c,l){u=u??I(await t.getStateTreeInfos()),c=c??Be(await Ce(t,n));const d=await Un.compress({payer:e.publicKey,owner:o.publicKey,source:i,toAddress:a,amount:r,mint:n,outputStateTreeInfo:u,tokenPoolInfo:c}),p=await t.getLatestBlockhash(),h=g(e,[o]),m=w([C.setComputeUnitLimit({units:13e4+2e4*s(r).length}),d],e,p.blockhash,h);return await b(t,m,l,p)}async function Gi(t,e,n,r,o,i,s,a,u){s=s??I(await t.getStateTreeInfos()),a=a??Be(await Ce(t,n));const c=await Un.compressSplTokenAccount({feePayer:e.publicKey,authority:r.publicKey,tokenAccount:o,mint:n,remainingAmount:i,outputStateTreeInfo:s,tokenPoolInfo:a}),l=await t.getLatestBlockhash(),d=g(e,[r]),p=w([C.setComputeUnitLimit({units:15e4}),c],e,l.blockhash,d);return await b(t,p,u,l)}async function Qi(t,e,n,r,o){o=o||await Un.getMintProgramId(n,t);const i=await Un.createTokenPool({feePayer:e.publicKey,mint:n,tokenProgramId:o}),{blockhash:s}=await t.getLatestBlockhash(),a=w([i],e,s);return await b(t,a,r)}X([Yi.replicate("treeInfo"),ot(tt(et(),32),"address"),ot(rt(),"lamports"),et("outputStateTreeIndex")]);const Ji=Qi;async function Xi(t,e,n,r,o,i){i=i||await Un.getMintProgramId(n,t);const s=[],a=(await Ce(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 Un.addTokenPool({mint:n,feePayer:e.publicKey,tokenProgramId:i,poolIndex:u[t]}));const{blockhash:c}=await t.getLatestBlockhash(),l=w(s,e,c);return await b(t,l,o)}const ts=Xi;async function es(t,e,n,r,o){const i=await t.getSlot("finalized"),{instructions:s,address:a}=await Un.createTokenProgramLookupTable({payer:e.publicKey,authority:n.publicKey,mints:r,remainingAccounts:o,recentSlot:i}),u=g(e,[n]),c=[];for(const n of s){const r=await t.getLatestBlockhash(),o=w([n],e,r.blockhash,u),i=await b(t,o,{commitment:"finalized"},r);c.push(i)}return{txIds:c,address:a}}async function ns(e,n,r,o,i,s,a,u){o=t(o);const c=await e.getCompressedTokenAccountsByOwner(i.publicKey,{mint:r}),[l]=ze(c.items,o),d=await e.getValidityProofV0(l.map((t=>({hash:t.compressedAccount.hash,tree:t.compressedAccount.treeInfo.tree,queue:t.compressedAccount.treeInfo.queue})))),p=_e(a=a??await Ce(e,r),o),h=await Un.decompress({payer:n.publicKey,inputCompressedTokenAccounts:l,toAddress:s,amount:o,tokenPoolInfos:p,recentInputStateRootIndices:d.rootIndices,recentValidityProof:d.compressedProof}),{blockhash:m}=await e.getLatestBlockhash(),f=g(n,[i]),y=w([C.setComputeUnitLimit({units:35e4}),h],n,m,f);return await b(e,y,u)}async function rs(e,n,r,o,i){const s=await e.getCompressedTokenAccountsByOwner(o.publicKey,{mint:r});if(0===s.items.length)throw new Error(`No compressed token accounts found for mint ${r.toBase58()}`);const a=[C.setComputeUnitLimit({units:1e6})];for(let i=0;i<s.items.slice(0,8).length;i+=4){const u=s.items.slice(i,i+4),c=await e.getValidityProof(u.map((e=>t(e.compressedAccount.hash)))),l=await Un.mergeTokenAccounts({payer:n.publicKey,owner:o.publicKey,inputCompressedTokenAccounts:u,mint:r,recentValidityProof:c.compressedProof,recentInputStateRootIndices:c.rootIndices});a.push(...l)}const{blockhash:u}=await e.getLatestBlockhash(),c=g(n,[o]),l=w(a,n,u,c);return b(e,l,i)}async function os(t,e,n,r,o,i,s,a,u){s=s??I(await t.getStateTreeInfos()),a=a??Be(await Ce(t,n));const c=await Un.mintTo({feePayer:e.publicKey,mint:n,authority:o.publicKey,amount:i,toPubkey:r,outputStateTreeInfo:s,tokenPoolInfo:a}),{blockhash:l}=await t.getLatestBlockhash(),d=g(e,[o]),p=w([C.setComputeUnitLimit({units:1e6}),c],e,l,d);return b(t,p,u)}async function is(t,e,n,r,o){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 Un.revoke({payer:e.publicKey,inputCompressedTokenAccounts:n,recentInputStateRootIndices:i.rootIndices,recentValidityProof:i.compressedProof}),{blockhash:a}=await t.getLatestBlockhash(),u=g(e,[r]),c=w([C.setComputeUnitLimit({units:5e5}),s],e,a,u);return b(t,c,o)}async function ss(e,n,r,o,i,s,a){o=t(o);const u=await e.getCompressedTokenAccountsByOwner(i.publicKey,{mint:r}),[c]=ze(u.items,o),l=await e.getValidityProofV0(c.map((t=>({hash:t.compressedAccount.hash,tree:t.compressedAccount.treeInfo.tree,queue:t.compressedAccount.treeInfo.queue})))),d=await Un.transfer({payer:n.publicKey,inputCompressedTokenAccounts:c,toAddress:s,amount:o,recentInputStateRootIndices:l.rootIndices,recentValidityProof:l.compressedProof}),{blockhash:p}=await e.getLatestBlockhash(),h=g(n,[i]),m=w([C.setComputeUnitLimit({units:5e5}),d],n,p,h);return b(e,m,a)}async function as(e,n,r,o,i,s,a){o=t(o);const u=await e.getCompressedTokenAccountsByDelegate(i.publicKey,{mint:r}),[c]=ze(u.items,o),l=await e.getValidityProofV0(c.map((t=>({hash:t.compressedAccount.hash,tree:t.compressedAccount.treeInfo.tree,queue:t.compressedAccount.treeInfo.queue})))),d=await Un.transfer({payer:n.publicKey,inputCompressedTokenAccounts:c,toAddress:s,amount:o,recentInputStateRootIndices:l.rootIndices,recentValidityProof:l.compressedProof}),{blockhash:p}=await e.getLatestBlockhash(),h=g(n,[i]),m=w([C.setComputeUnitLimit({units:5e5}),d],n,p,h);return b(e,m,a)}async function us(e,n,r,o,i,s,a,u){o=t(o);const c=await e.getCompressedTokenAccountsByDelegate(i.publicKey,{mint:r}),[l]=ze(c.items,o),d=await e.getValidityProofV0(l.map((t=>({hash:t.compressedAccount.hash,tree:t.compressedAccount.treeInfo.tree,queue:t.compressedAccount.treeInfo.queue})))),p=a??_e(await Ce(e,r),o),h=await Un.decompress({payer:n.publicKey,inputCompressedTokenAccounts:l,toAddress:s,amount:o,recentInputStateRootIndices:d.rootIndices,recentValidityProof:d.compressedProof,tokenPoolInfos:p}),{blockhash:m}=await e.getLatestBlockhash(),f=g(n,[i]),y=w([C.setComputeUnitLimit({units:35e4}),h],n,m,f);return b(e,y,u)}const cs={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 ls(t){return!Array.isArray(t)}const ds=ls;export{Mi as $,_i as A,Li as B,go as C,Oi as D,Vi as E,Ni as F,Fi as G,Ui as H,Wi as I,Di as J,Si as K,Ci as L,Ti as M,Ei as N,Bi as O,Pi as P,Ai as Q,xi as R,ho as S,lo as T,po as U,co as V,uo as W,gi as X,wi as Y,ki as Z,vi as _,Io as a,sn as a$,bi as a0,$i as a1,ji as a2,Zi as a3,Hi as a4,Gi as a5,Po as a6,Qi as a7,Ji as a8,Xi as a9,Ne as aA,Fe as aB,$e as aC,Ye as aD,le as aE,pe as aF,he as aG,me as aH,fe as aI,ye as aJ,ge as aK,we as aL,be as aM,ke as aN,ve as aO,Ie as aP,Me as aQ,cs as aR,Ge as aS,Qe as aT,Je as aU,Xe as aV,tn as aW,en as aX,nn as aY,rn as aZ,on as a_,ts as aa,es as ab,ns as ac,rs as ad,os as ae,is as af,ss as ag,as as ah,us as ai,Pe as aj,xe as ak,Se as al,Ce as am,Te as an,Be as ao,_e as ap,Le as aq,Ue as ar,We as as,De as at,Oe as au,Re as av,qe as aw,Ke as ax,ze as ay,Ve as az,ko as b,an as b0,un as b1,cn as b2,ln as b3,dn as b4,pn as b5,hn as b6,mn as b7,fn as b8,yn as b9,qn as bA,gn as ba,wn as bb,bn as bc,kn as bd,Mn as be,Pn as bf,An as bg,xn as bh,Cn as bi,Tn as bj,En as bk,Bn as bl,_n as bm,Ln as bn,Un as bo,ls as bp,ds as bq,Gr as br,Qr as bs,jr as bt,Ki as bu,Ar as bv,Wn as bw,Dn as bx,On as by,Rn as bz,bo as c,Mo as d,ur as e,ar as f,mo as g,Mr as h,Pr as i,Cr as j,Tr as k,vo as l,Er as m,Br as n,_r as o,Lr as p,lr as q,dr as r,hr as s,mr as t,fr as u,wo as v,Xr as w,Dr as x,Wr as y,Ao as z};
|
|
2
|
+
//# sourceMappingURL=types-Drp6Yu8A.js.map
|