@lightprotocol/compressed-token 0.22.1-alpha.3 → 0.22.1-alpha.5
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/dist/cjs/browser/index.cjs +1 -1
- package/dist/cjs/browser/types-CJcjpvYl.cjs +2 -0
- package/dist/cjs/browser/types-CJcjpvYl.cjs.map +1 -0
- package/dist/cjs/browser/unified/index.cjs +1 -1
- package/dist/cjs/browser/unified/index.cjs.map +1 -1
- package/dist/cjs/node/index.cjs +1 -1
- package/dist/cjs/node/types-BPweZlnn.cjs +2 -0
- package/dist/cjs/node/types-BPweZlnn.cjs.map +1 -0
- package/dist/cjs/node/unified/index.cjs +1 -1
- package/dist/cjs/node/unified/index.cjs.map +1 -1
- package/dist/es/browser/index.js +1 -1
- package/dist/es/browser/types-CUGXWKP-.js +2 -0
- package/dist/es/browser/types-CUGXWKP-.js.map +1 -0
- package/dist/es/browser/unified/index.js +1 -1
- package/dist/es/browser/unified/index.js.map +1 -1
- package/dist/types/index.d.ts +10 -10
- package/dist/types/unified/index.d.ts +10 -10
- package/package.json +8 -7
- package/dist/cjs/browser/types-DZs1jl_2.cjs +0 -2
- package/dist/cjs/browser/types-DZs1jl_2.cjs.map +0 -1
- package/dist/cjs/node/types-CxnYquyR.cjs +0 -2
- package/dist/cjs/node/types-CxnYquyR.cjs.map +0 -1
- package/dist/es/browser/types-Drp6Yu8A.js +0 -2
- package/dist/es/browser/types-Drp6Yu8A.js.map +0 -1
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{bn as e,getIndexOrAdd as t,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 D,createInitializeMint2Instruction as L,createMintToInstruction as U,TOKEN_PROGRAM_ID as W,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 ee,u8 as te,publicKey as ne,u64 as re,option as oe,vecU8 as ie,u32 as se,bool as ae,u16 as ue,vec as ce,rustEnum as le}from"@coral-xyz/borsh";var de="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},pe=[],he=[],me="undefined"!=typeof Uint8Array?Uint8Array:Array,fe=0;function ye(){fe=1;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)pe[t]=e[t],he[e.charCodeAt(t)]=t;he["-".charCodeAt(0)]=62,he["_".charCodeAt(0)]=63}function ge(e,t,n){for(var r,o,i=[],s=t;s<n;s+=3)r=(e[s]<<16)+(e[s+1]<<8)+e[s+2],i.push(pe[(o=r)>>18&63]+pe[o>>12&63]+pe[o>>6&63]+pe[63&o]);return i.join("")}function we(e){var t;fe||ye();for(var n=e.length,r=n%3,o="",i=[],s=16383,a=0,u=n-r;a<u;a+=s)i.push(ge(e,a,a+s>u?u:a+s));return 1===r?(t=e[n-1],o+=pe[t>>2],o+=pe[t<<4&63],o+="=="):2===r&&(t=(e[n-2]<<8)+e[n-1],o+=pe[t>>10],o+=pe[t>>4&63],o+=pe[t<<2&63],o+="="),i.push(o),i.join("")}function be(e,t,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=e[t+d];for(d+=p,i=h&(1<<-l)-1,h>>=-l,l+=a;l>0;i=256*i+e[t+d],d+=p,l-=8);for(s=i&(1<<-l)-1,i>>=-l,l+=r;l>0;s=256*s+e[t+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 ke(e,t,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=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||Infinity===t?(a=isNaN(t)?1:0,s=l):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=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=(t*u-1)*Math.pow(2,o),s+=d):(a=t*Math.pow(2,d-1)*Math.pow(2,o),s=0));o>=8;e[n+h]=255&a,h+=m,a/=256,o-=8);for(s=s<<o|a,c+=o;c>0;e[n+h]=255&s,h+=m,s/=256,c-=8);e[n+h-m]|=128*f}var ve={}.toString,Ie=Array.isArray||function(e){return"[object Array]"==ve.call(e)};xe.TYPED_ARRAY_SUPPORT=void 0!==de.TYPED_ARRAY_SUPPORT?de.TYPED_ARRAY_SUPPORT:1;var Me=Pe();function Pe(){return xe.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function Ae(e,t){if(Pe()<t)throw new RangeError("Invalid typed array length");return xe.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=xe.prototype:(null===e&&(e=new xe(t)),e.length=t),e}function xe(e,t,n){if(!(xe.TYPED_ARRAY_SUPPORT||this instanceof xe))return new xe(e,t,n);if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return Te(this,e)}return Se(this,e,t,n)}function Se(e,t,n,r){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?function(e,t,n,r){if(t.byteLength,n<0||t.byteLength<n)throw new RangeError("'offset' is out of bounds");if(t.byteLength<n+(r||0))throw new RangeError("'length' is out of bounds");return t=void 0===n&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,n):new Uint8Array(t,n,r),xe.TYPED_ARRAY_SUPPORT?(e=t).__proto__=xe.prototype:e=Ee(e,t),e}(e,t,n,r):"string"==typeof t?function(e,t,n){if("string"==typeof n&&""!==n||(n="utf8"),!xe.isEncoding(n))throw new TypeError('"encoding" must be a valid string encoding');var r=0|De(t,n),o=(e=Ae(e,r)).write(t,n);return o!==r&&(e=e.slice(0,o)),e}(e,t,n):function(e,t){if(_e(t)){var n=0|Be(t.length);return 0===(e=Ae(e,n)).length||t.copy(e,0,0,n),e}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return"number"!=typeof t.length||(r=t.length)!=r?Ae(e,0):Ee(e,t);if("Buffer"===t.type&&Ie(t.data))return Ee(e,t.data)}var r;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function Ce(e){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function Te(e,t){if(Ce(t),e=Ae(e,t<0?0:0|Be(t)),!xe.TYPED_ARRAY_SUPPORT)for(var n=0;n<t;++n)e[n]=0;return e}function Ee(e,t){var n=t.length<0?0:0|Be(t.length);e=Ae(e,n);for(var r=0;r<n;r+=1)e[r]=255&t[r];return e}function Be(e){if(e>=Pe())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Pe().toString(16)+" bytes");return 0|e}function _e(e){return!(null==e||!e._isBuffer)}function De(e,t){if(_e(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var n=e.length;if(0===n)return 0;for(var r=0;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return it(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return st(e).length;default:if(r)return it(e).length;t=(""+t).toLowerCase(),r=1}}function Le(e,t,n){var r=0;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return He(this,t,n);case"utf8":case"utf-8":return $e(this,t,n);case"ascii":return je(this,t,n);case"latin1":case"binary":return Ze(this,t,n);case"base64":return Fe(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ge(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=1}}function Ue(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function We(e,t,n,r,o){if(0===e.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:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(o)return-1;n=e.length-1}else if(n<0){if(!o)return-1;n=0}if("string"==typeof t&&(t=xe.from(t,r)),_e(t))return 0===t.length?-1:Oe(e,t,n,r,o);if("number"==typeof t)return t&=255,xe.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):Oe(e,[t],n,r,o);throw new TypeError("val must be string, number or Buffer")}function Oe(e,t,n,r,o){var i,s=1,a=e.length,u=t.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,n/=2}function c(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(o){var l=-1;for(i=n;i<a;i++)if(c(e,i)===c(t,-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(e,i+p)!==c(t,p)){d=0;break}if(d)return i}return-1}function Re(e,t,n,r){n=Number(n)||0;var o=e.length-n;r?(r=Number(r))>o&&(r=o):r=o;var i=t.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(t.substr(2*s,2),16);if(isNaN(a))return s;e[n+s]=a}return s}function qe(e,t,n,r){return at(it(t,e.length-n),e,n,r)}function Ke(e,t,n,r){return at(function(e){for(var t=[],n=0;n<e.length;++n)t.push(255&e.charCodeAt(n));return t}(t),e,n,r)}function ze(e,t,n,r){return Ke(e,t,n,r)}function Ve(e,t,n,r){return at(st(t),e,n,r)}function Ne(e,t,n,r){return at(function(e,t){for(var n,r,o,i=[],s=0;s<e.length&&!((t-=2)<0);++s)r=(n=e.charCodeAt(s))>>8,o=n%256,i.push(o),i.push(r);return i}(t,e.length-n),e,n,r)}function Fe(e,t,n){return 0===t&&n===e.length?we(e):we(e.slice(t,n))}function $e(e,t,n){n=Math.min(e.length,n);for(var r=[],o=t;o<n;){var i,s,a,u,c=e[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=e[o+1]))&&(u=(31&c)<<6|63&i)>127&&(l=u);break;case 3:i=e[o+1],s=e[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=e[o+1],s=e[o+2],a=e[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(e){var t=e.length;if(t<=Ye)return String.fromCharCode.apply(String,e);for(var n="",r=0;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=Ye));return n}(r)}xe.poolSize=8192,xe._augment=function(e){return e.__proto__=xe.prototype,e},xe.from=function(e,t,n){return Se(null,e,t,n)},xe.TYPED_ARRAY_SUPPORT&&(xe.prototype.__proto__=Uint8Array.prototype,xe.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&xe[Symbol.species]),xe.alloc=function(e,t,n){return function(e,t,n,r){return Ce(t),t<=0?Ae(e,t):void 0!==n?"string"==typeof r?Ae(e,t).fill(n,r):Ae(e,t).fill(n):Ae(e,t)}(null,e,t,n)},xe.allocUnsafe=function(e){return Te(null,e)},xe.allocUnsafeSlow=function(e){return Te(null,e)},xe.isBuffer=ut,xe.compare=function(e,t){if(!_e(e)||!_e(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var n=e.length,r=t.length,o=0,i=Math.min(n,r);o<i;++o)if(e[o]!==t[o]){n=e[o],r=t[o];break}return n<r?-1:r<n?1:0},xe.isEncoding=function(e){switch(String(e).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}},xe.concat=function(e,t){if(!Ie(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return xe.alloc(0);var n;if(void 0===t)for(t=0,n=0;n<e.length;++n)t+=e[n].length;var r=xe.allocUnsafe(t),o=0;for(n=0;n<e.length;++n){var i=e[n];if(!_e(i))throw new TypeError('"list" argument must be an Array of Buffers');i.copy(r,o),o+=i.length}return r},xe.byteLength=De,xe.prototype._isBuffer=1,xe.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)Ue(this,t,t+1);return this},xe.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)Ue(this,t,t+3),Ue(this,t+1,t+2);return this},xe.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)Ue(this,t,t+7),Ue(this,t+1,t+6),Ue(this,t+2,t+5),Ue(this,t+3,t+4);return this},xe.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?$e(this,0,e):Le.apply(this,arguments)},xe.prototype.equals=function(e){if(!_e(e))throw new TypeError("Argument must be a Buffer");return this===e?1:0===xe.compare(this,e)},xe.prototype.inspect=function(){var e="";return this.length>0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),"<Buffer "+e+">"},xe.prototype.compare=function(e,t,n,r,o){if(!_e(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===r&&(r=0),void 0===o&&(o=this.length),t<0||n>e.length||r<0||o>this.length)throw new RangeError("out of range index");if(r>=o&&t>=n)return 0;if(r>=o)return-1;if(t>=n)return 1;if(this===e)return 0;for(var i=(o>>>=0)-(r>>>=0),s=(n>>>=0)-(t>>>=0),a=Math.min(i,s),u=this.slice(r,o),c=e.slice(t,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},xe.prototype.includes=function(e,t,n){return-1!==this.indexOf(e,t,n)},xe.prototype.indexOf=function(e,t,n){return We(this,e,t,n,1)},xe.prototype.lastIndexOf=function(e,t,n){return We(this,e,t,n,0)},xe.prototype.write=function(e,t,n,r){if(void 0===t)r="utf8",n=this.length,t=0;else if(void 0===n&&"string"==typeof t)r=t,n=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t|=0,isFinite(n)?(n|=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}var o=this.length-t;if((void 0===n||n>o)&&(n=o),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var i=0;;)switch(r){case"hex":return Re(this,e,t,n);case"utf8":case"utf-8":return qe(this,e,t,n);case"ascii":return Ke(this,e,t,n);case"latin1":case"binary":return ze(this,e,t,n);case"base64":return Ve(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ne(this,e,t,n);default:if(i)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),i=1}},xe.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var Ye=4096;function je(e,t,n){var r="";n=Math.min(e.length,n);for(var o=t;o<n;++o)r+=String.fromCharCode(127&e[o]);return r}function Ze(e,t,n){var r="";n=Math.min(e.length,n);for(var o=t;o<n;++o)r+=String.fromCharCode(e[o]);return r}function He(e,t,n){var r,o=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>o)&&(n=o);for(var i="",s=t;s<n;++s)i+=(r=e[s])<16?"0"+r.toString(16):r.toString(16);return i}function Ge(e,t,n){for(var r=e.slice(t,n),o="",i=0;i<r.length;i+=2)o+=String.fromCharCode(r[i]+256*r[i+1]);return o}function Qe(e,t,n){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>n)throw new RangeError("Trying to access beyond buffer length")}function Je(e,t,n,r,o,i){if(!_e(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>o||t<i)throw new RangeError('"value" argument is out of bounds');if(n+r>e.length)throw new RangeError("Index out of range")}function Xe(e,t,n,r){t<0&&(t=65535+t+1);for(var o=0,i=Math.min(e.length-n,2);o<i;++o)e[n+o]=(t&255<<8*(r?o:1-o))>>>8*(r?o:1-o)}function et(e,t,n,r){t<0&&(t=4294967295+t+1);for(var o=0,i=Math.min(e.length-n,4);o<i;++o)e[n+o]=t>>>8*(r?o:3-o)&255}function tt(e,t,n,r){if(n+r>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function nt(e,t,n,r,o){return o||tt(e,0,n,4),ke(e,t,n,r,23,4),n+4}function rt(e,t,n,r,o){return o||tt(e,0,n,8),ke(e,t,n,r,52,8),n+8}xe.prototype.slice=function(e,t){var n,r=this.length;if((e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t<e&&(t=e),xe.TYPED_ARRAY_SUPPORT)(n=this.subarray(e,t)).__proto__=xe.prototype;else{var o=t-e;n=new xe(o,void 0);for(var i=0;i<o;++i)n[i]=this[i+e]}return n},xe.prototype.readUIntLE=function(e,t,n){e|=0,t|=0,n||Qe(e,t,this.length);for(var r=this[e],o=1,i=0;++i<t&&(o*=256);)r+=this[e+i]*o;return r},xe.prototype.readUIntBE=function(e,t,n){e|=0,t|=0,n||Qe(e,t,this.length);for(var r=this[e+--t],o=1;t>0&&(o*=256);)r+=this[e+--t]*o;return r},xe.prototype.readUInt8=function(e,t){return t||Qe(e,1,this.length),this[e]},xe.prototype.readUInt16LE=function(e,t){return t||Qe(e,2,this.length),this[e]|this[e+1]<<8},xe.prototype.readUInt16BE=function(e,t){return t||Qe(e,2,this.length),this[e]<<8|this[e+1]},xe.prototype.readUInt32LE=function(e,t){return t||Qe(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},xe.prototype.readUInt32BE=function(e,t){return t||Qe(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},xe.prototype.readIntLE=function(e,t,n){e|=0,t|=0,n||Qe(e,t,this.length);for(var r=this[e],o=1,i=0;++i<t&&(o*=256);)r+=this[e+i]*o;return r>=(o*=128)&&(r-=Math.pow(2,8*t)),r},xe.prototype.readIntBE=function(e,t,n){e|=0,t|=0,n||Qe(e,t,this.length);for(var r=t,o=1,i=this[e+--r];r>0&&(o*=256);)i+=this[e+--r]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*t)),i},xe.prototype.readInt8=function(e,t){return t||Qe(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},xe.prototype.readInt16LE=function(e,t){t||Qe(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},xe.prototype.readInt16BE=function(e,t){t||Qe(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},xe.prototype.readInt32LE=function(e,t){return t||Qe(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},xe.prototype.readInt32BE=function(e,t){return t||Qe(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},xe.prototype.readFloatLE=function(e,t){return t||Qe(e,4,this.length),be(this,e,1,23,4)},xe.prototype.readFloatBE=function(e,t){return t||Qe(e,4,this.length),be(this,e,0,23,4)},xe.prototype.readDoubleLE=function(e,t){return t||Qe(e,8,this.length),be(this,e,1,52,8)},xe.prototype.readDoubleBE=function(e,t){return t||Qe(e,8,this.length),be(this,e,0,52,8)},xe.prototype.writeUIntLE=function(e,t,n,r){e=+e,t|=0,n|=0,r||Je(this,e,t,n,Math.pow(2,8*n)-1,0);var o=1,i=0;for(this[t]=255&e;++i<n&&(o*=256);)this[t+i]=e/o&255;return t+n},xe.prototype.writeUIntBE=function(e,t,n,r){e=+e,t|=0,n|=0,r||Je(this,e,t,n,Math.pow(2,8*n)-1,0);var o=n-1,i=1;for(this[t+o]=255&e;--o>=0&&(i*=256);)this[t+o]=e/i&255;return t+n},xe.prototype.writeUInt8=function(e,t,n){return e=+e,t|=0,n||Je(this,e,t,1,255,0),xe.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},xe.prototype.writeUInt16LE=function(e,t,n){return e=+e,t|=0,n||Je(this,e,t,2,65535,0),xe.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Xe(this,e,t,1),t+2},xe.prototype.writeUInt16BE=function(e,t,n){return e=+e,t|=0,n||Je(this,e,t,2,65535,0),xe.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Xe(this,e,t,0),t+2},xe.prototype.writeUInt32LE=function(e,t,n){return e=+e,t|=0,n||Je(this,e,t,4,4294967295,0),xe.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):et(this,e,t,1),t+4},xe.prototype.writeUInt32BE=function(e,t,n){return e=+e,t|=0,n||Je(this,e,t,4,4294967295,0),xe.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):et(this,e,t,0),t+4},xe.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t|=0,!r){var o=Math.pow(2,8*n-1);Je(this,e,t,n,o-1,-o)}var i=0,s=1,a=0;for(this[t]=255&e;++i<n&&(s*=256);)e<0&&0===a&&0!==this[t+i-1]&&(a=1),this[t+i]=(e/s>>0)-a&255;return t+n},xe.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t|=0,!r){var o=Math.pow(2,8*n-1);Je(this,e,t,n,o-1,-o)}var i=n-1,s=1,a=0;for(this[t+i]=255&e;--i>=0&&(s*=256);)e<0&&0===a&&0!==this[t+i+1]&&(a=1),this[t+i]=(e/s>>0)-a&255;return t+n},xe.prototype.writeInt8=function(e,t,n){return e=+e,t|=0,n||Je(this,e,t,1,127,-128),xe.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},xe.prototype.writeInt16LE=function(e,t,n){return e=+e,t|=0,n||Je(this,e,t,2,32767,-32768),xe.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Xe(this,e,t,1),t+2},xe.prototype.writeInt16BE=function(e,t,n){return e=+e,t|=0,n||Je(this,e,t,2,32767,-32768),xe.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Xe(this,e,t,0),t+2},xe.prototype.writeInt32LE=function(e,t,n){return e=+e,t|=0,n||Je(this,e,t,4,2147483647,-2147483648),xe.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):et(this,e,t,1),t+4},xe.prototype.writeInt32BE=function(e,t,n){return e=+e,t|=0,n||Je(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),xe.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):et(this,e,t,0),t+4},xe.prototype.writeFloatLE=function(e,t,n){return nt(this,e,t,1,n)},xe.prototype.writeFloatBE=function(e,t,n){return nt(this,e,t,0,n)},xe.prototype.writeDoubleLE=function(e,t,n){return rt(this,e,t,1,n)},xe.prototype.writeDoubleBE=function(e,t,n){return rt(this,e,t,0,n)},xe.prototype.copy=function(e,t,n,r){if(n||(n=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&r<n&&(r=n),r===n)return 0;if(0===e.length||0===this.length)return 0;if(t<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),e.length-t<r-n&&(r=e.length-t+n);var o,i=r-n;if(this===e&&n<t&&t<r)for(o=i-1;o>=0;--o)e[o+t]=this[o+n];else if(i<1e3||!xe.TYPED_ARRAY_SUPPORT)for(o=0;o<i;++o)e[o+t]=this[o+n];else Uint8Array.prototype.set.call(e,this.subarray(n,n+i),t);return i},xe.prototype.fill=function(e,t,n,r){if("string"==typeof e){if("string"==typeof t?(r=t,t=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),1===e.length){var o=e.charCodeAt(0);o<256&&(e=o)}if(void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!xe.isEncoding(r))throw new TypeError("Unknown encoding: "+r)}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<n)throw new RangeError("Out of range index");if(n<=t)return this;var i;if(t>>>=0,n=void 0===n?this.length:n>>>0,e||(e=0),"number"==typeof e)for(i=t;i<n;++i)this[i]=e;else{var s=_e(e)?e:it(new xe(e,r).toString()),a=s.length;for(i=0;i<n-t;++i)this[i+t]=s[i%a]}return this};var ot=/[^+\/0-9A-Za-z-_]/g;function it(e,t){var n;t=t||Infinity;for(var r=e.length,o=null,i=[],s=0;s<r;++s){if((n=e.charCodeAt(s))>55295&&n<57344){if(!o){if(n>56319){(t-=3)>-1&&i.push(239,191,189);continue}if(s+1===r){(t-=3)>-1&&i.push(239,191,189);continue}o=n;continue}if(n<56320){(t-=3)>-1&&i.push(239,191,189),o=n;continue}n=65536+(o-55296<<10|n-56320)}else o&&(t-=3)>-1&&i.push(239,191,189);if(o=null,n<128){if((t-=1)<0)break;i.push(n)}else if(n<2048){if((t-=2)<0)break;i.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=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((t-=4)<0)break;i.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return i}function st(e){return function(e){var t,n,r,o,i,s;fe||ye();var a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");i="="===e[a-2]?2:"="===e[a-1]?1:0,s=new me(3*a/4-i),r=i>0?a-4:a;var u=0;for(t=0,n=0;t<r;t+=4,n+=3)o=he[e.charCodeAt(t)]<<18|he[e.charCodeAt(t+1)]<<12|he[e.charCodeAt(t+2)]<<6|he[e.charCodeAt(t+3)],s[u++]=o>>16&255,s[u++]=o>>8&255,s[u++]=255&o;return 2===i?(o=he[e.charCodeAt(t)]<<2|he[e.charCodeAt(t+1)]>>4,s[u++]=255&o):1===i&&(o=he[e.charCodeAt(t)]<<10|he[e.charCodeAt(t+1)]<<4|he[e.charCodeAt(t+2)]>>2,s[u++]=o>>8&255,s[u++]=255&o),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(ot,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function at(e,t,n,r){for(var o=0;o<r&&!(o+n>=t.length||o>=e.length);++o)t[o+n]=e[o];return o}function ut(e){return null!=e&&(!!e._isBuffer||ct(e)||function(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&ct(e.slice(0,0))}(e))}function ct(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}var lt,dt=Object.freeze({__proto__:null,Buffer:xe,INSPECT_MAX_BYTES:50,SlowBuffer:function(e){return+e!=e&&(e=0),xe.alloc(+e)},isBuffer:ut,kMaxLength:Me});!function(e){e[e.V1=1]="V1",e[e.V2=2]="V2",e[e.ShaFlat=3]="ShaFlat"}(lt||(lt={}));const pt=xe.from("pool"),ht=xe.from("cpi_authority"),mt=1461600,ft=xe.from([23,169,27,122,147,169,209,152]),yt=xe.from([241,34,48,186,37,179,123,192]),gt=xe.from([65,206,101,37,147,42,221,144]),wt=xe.from([163,52,200,231,140,3,69,186]),bt=xe.from([112,230,105,101,145,202,157,97]),kt=xe.from([69,74,217,36,115,117,97,76]),vt=xe.from([170,23,31,34,133,173,93,242]),It=xe.from([114,143,210,73,96,115,1,228]),Mt=xe.from([107]);function Pt(e){return{mint:e.mint,tokenPoolPda:e.splInterfacePda,splInterfacePda:e.splInterfacePda,tokenProgram:e.tokenProgram,activity:e.activity,isInitialized:e.isInitialized,balance:e.balance,poolIndex:e.poolIndex,bump:e.bump}}function At(e){return{mint:e.mint,splInterfacePda:e.tokenPoolPda??e.splInterfacePda,tokenProgram:e.tokenProgram,activity:e.activity,isInitialized:e.isInitialized,balance:e.balance,poolIndex:e.poolIndex,bump:e.bump}}function xt(t,n,r=0){const[o,i]=Ln.deriveSplInterfacePdaWithIndex(t,r);return{mint:t,splInterfacePda:o,tokenProgram:n,activity:void 0,balance:e(0),isInitialized:1,poolIndex:r,bump:i}}function St(e,t){const n="tokenPoolPda"in e?At(e):e;if(!n.mint.equals(t))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: ${t.toBase58()} via createSplInterface().`);return 1}async function Ct(t,n,r){const o=Array.from({length:5},((e,t)=>Ln.deriveSplInterfacePdaWithIndex(n,t))),i=await t.getMultipleAccountsInfo(o.map((e=>e[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(((e,t)=>i[t]?_(e[0],i[t],i[t].owner):null)),a=i[0].owner;return s.map(((t,r)=>t?{mint:n,splInterfacePda:t.address,tokenProgram:a,activity:void 0,balance:e(t.amount.toString()),isInitialized:1,poolIndex:r,bump:o[r][1]}:{mint:n,splInterfacePda:o[r][0],tokenProgram:a,activity:void 0,balance:e(0),isInitialized:0,poolIndex:r,bump:o[r][1]}))}var Tt;!function(e){e[e.Compress=1]="Compress",e[e.Decompress=2]="Decompress",e[e.Transfer=3]="Transfer"}(Tt||(Tt={}));const Et=e=>{for(let t=e.length-1;t>0;t--){const n=Math.floor(Math.random()*(t+1));[e[t],e[n]]=[e[n],e[t]]}return e};function Bt(e){const t=Et(e).filter((e=>e.isInitialized));if(0===t.length)throw new Error("Please pass at least one initialized SPL interface info.");return t[0]}function _t(t,n){if(0===t.length)throw new Error("Please pass at least one SPL interface info.");const r=(t=Et(t)).find((t=>t.balance.gte(e(n).mul(e(10)))));if((t=t.filter((e=>e.isInitialized)).sort(((e,t)=>e.poolIndex-t.poolIndex))).every((e=>e.balance.isZero())))throw new Error("All provided SPL interface balances are zero. Please pass recent SPL interface infos.");return r?[r]:t}function Dt(e,t,n=0){return Pt(xt(e,t,n))}function Lt(e,t){return St(At(e),t)}async function Ut(e,t,n){return(await Ct(e,t,n)).map(Pt)}function Wt(e){return Pt(Bt(e.map(At)))}function Ot(e,t){return _t(e.map(At),t).map(Pt)}const Rt="Could not find accounts to select for transfer.";function qt(e,t,n=4){const r=e.find((e=>e.parsed.amount.eq(t)));return r?[[r],r.parsed.amount,r.compressedAccount.lamports,r.parsed.amount]:zt(e,t,n)}function Kt(e,t,n=4){const[r,o,i,s]=zt(e,t,n);return{selectedAccounts:r,total:o,totalLamports:i,maxPossibleAmount:s}}function zt(t,n,r=4){const[o,i,s,a]=Vt(t,n,r);if(i.lt(e(n))){const i=t.reduce(((e,t)=>e.add(t.parsed.amount)),e(0));throw o.length>=r?new Error(`Account limit exceeded: max ${a.toString()} (${r} accounts) per transaction. Total balance: ${i.toString()} (${t.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(Rt);return[o,i,s,a]}function Vt(t,n,r=4){if(0===t.length)throw new Error(Rt);let o=e(0),i=e(0),s=e(0);const a=[];t.sort(((e,t)=>t.parsed.amount.cmp(e.parsed.amount)));for(const s of t){if(a.length>=r)break;if(o.gte(e(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=t.slice(0,r).reduce(((e,t)=>e.add(t.parsed.amount)),e(0)),o.lt(e(n))&&console.log(`Insufficient balance for transfer. Requested: ${n.toString()}, Returns max available: ${s.toString()}.`),0===a.length)throw new Error(Rt);return[a,o,i,s]}function Nt(t,n,r=4){const[o,i,s,a]=Ft(t,n,r);if(i.lt(e(n))){const i=t.reduce(((e,t)=>e.add(t.parsed.amount)),e(0));throw o.length>=r?new Error(`Account limit exceeded: max ${a.toString()} (${r} accounts) per transaction. Total balance: ${i.toString()} (${t.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(Rt);return[o,i,s,a]}function Ft(t,n,r=4){if(0===t.length)throw new Error(Rt);let o=e(0),i=e(0);const s=[],a=t.filter((e=>!e.parsed.amount.isZero()||!e.compressedAccount.lamports.isZero()));a.sort(((e,t)=>t.parsed.amount.cmp(e.parsed.amount)));for(const t of a){if(s.length>=r)break;if(o=o.add(t.parsed.amount),i=i.add(t.compressedAccount.lamports),s.push(t),o.gte(e(n))){const e=a.slice(s.length);if(e.length>0){const t=e.reduce(((e,t)=>t.parsed.amount.lt(e.parsed.amount)?t:e));s.length<r&&(s.push(t),o=o.add(t.parsed.amount),i=i.add(t.compressedAccount.lamports))}break}}const u=a.slice(0,r).reduce(((e,t)=>e.add(t.parsed.amount)),e(0));if(0===s.length)throw new Error(Rt);return[s,o,i,u]}function $t(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=t(d,s[0].parsed.delegate));const h=[];if(s.forEach(((n,r)=>{const o=t(d,n.compressedAccount.treeInfo.tree),i=t(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(e(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=t(d,n);w.push({owner:l[r].owner,amount:l[r].amount,lamports:l[r].lamports?.eq(e(0))?null:l[r].lamports,merkleTreeIndex:o,tlv:null})}));const b=d.map((e=>({pubkey:e,isWritable:1,isSigner:0})));return{inputTokenDataWithContext:h,remainingAccountMetas:b,packedOutputTokenData:w}}function Yt(e,t){if(!e.every((e=>e.parsed.mint.equals(t))))throw new Error("All input accounts must belong to the same mint");return 1}const jt=X([ee(te(),32,"a"),ee(te(),64,"b"),ee(te(),32,"c")]),Zt=X([ne("owner"),re("amount"),oe(re(),"lamports"),te("merkleTreeIndex"),oe(ie(),"tlv")]),Ht=X([re("amount"),oe(te(),"delegateIndex"),X([te("merkleTreePubkeyIndex"),te("queuePubkeyIndex"),se("leafIndex"),ae("proveByIndex")],"merkleContext"),ue("rootIndex"),oe(re(),"lamports"),oe(ie(),"tlv")]),Gt=X([ne("owner"),oe(te(),"delegateChangeAccountIndex")]),Qt=X([ae("setContext"),ae("firstSetContext"),te("cpiContextAccountIndex")]),Jt=X([oe(jt,"proof"),ne("mint"),oe(Gt,"delegatedTransfer"),ce(Ht,"inputTokenDataWithContext"),ce(Zt,"outputCompressedAccounts"),ae("isCompress"),oe(re(),"compressOrDecompressAmount"),oe(Qt,"cpiContext"),oe(te(),"lamportsChangeAccountMerkleTreeIndex")]),Xt=X([ce(ne(),"recipients"),ce(re(),"amounts"),oe(re(),"lamports")]),en=X([ce(ne(),"pubkeys"),oe(ce(re(),"amounts"),"amounts"),oe(re(),"lamports"),oe(re(),"amount"),te("index"),te("bump")]),tn=X([ne("owner"),oe(re(),"remainingAmount"),oe(Qt,"cpiContext")]);function nn(e){const t=xe.alloc(1e3),n=Xt.encode({recipients:e.recipients,amounts:e.amounts,lamports:e.lamports},t);return xe.concat([new Uint8Array(yt),new Uint8Array(t.subarray(0,n))])}function rn(e){return Xt.decode(e.subarray(yt.length))}function on(e){const t=xe.alloc(1e3),n=en.encode(e,t),r=xe.alloc(4);r.writeUInt32LE(n,0);const o=t.subarray(0,n);return xe.concat([new Uint8Array(gt),new Uint8Array(r),new Uint8Array(o)])}function sn(e){return en.decode(e.subarray(gt.length+4))}function an(e){const t=xe.alloc(1e3),n=tn.encode({owner:e.owner,remainingAmount:e.remainingAmount,cpiContext:e.cpiContext},t);return xe.concat([new Uint8Array(bt),new Uint8Array(t.subarray(0,n))])}function un(e){const t=tn.decode(e.subarray(bt.length));return{owner:t.owner,remainingAmount:t.remainingAmount,cpiContext:t.cpiContext}}function cn(e){const t=xe.alloc(1e3),n=Jt.encode(e,t),r=xe.alloc(4);r.writeUInt32LE(n,0);const o=t.subarray(0,n);return xe.concat([new Uint8Array(wt),new Uint8Array(r),new Uint8Array(o)])}function ln(e){return Jt.decode(e.slice(wt.length+4))}const dn=e=>{const{feePayer:t,tokenPoolPda:n,systemProgram:r,mint:o,tokenProgram:i,cpiAuthorityPda:s}=e;return[{pubkey:t,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=e=>{const{feePayer:t,tokenPoolPda:n,systemProgram:r,mint:o,tokenProgram:i,cpiAuthorityPda:s,existingTokenPoolPda:a}=e;return[{pubkey:t,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=e=>{const t=Ln.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}=e;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??t,isSigner:0,isWritable:1}]},mn=e=>{const t=Ln.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}=e;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??t,isSigner:0,isWritable:1},{pubkey:p??t,isSigner:0,isWritable:1},{pubkey:h??t,isSigner:0,isWritable:0},{pubkey:m,isSigner:0,isWritable:0}]},fn=e=>{const{feePayer:t,authority:n,cpiAuthorityPda:r,lightSystemProgram:o,registeredProgramPda:i,noopProgram:s,accountCompressionAuthority:a,accountCompressionProgram:u,selfProgram:c,systemProgram:l}=e;return[{pubkey:t,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=e=>{const{feePayer:t,authority:n,cpiAuthorityPda:r,lightSystemProgram:o,registeredProgramPda:i,noopProgram:s,accountCompressionAuthority:a,accountCompressionProgram:u,selfProgram:c,systemProgram:l,mint:d}=e;return[{pubkey:t,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([ee(te(),32,"a"),ee(te(),64,"b"),ee(te(),32,"c")],"proof"),ne("mint"),ce(Ht,"inputTokenDataWithContext"),oe(Qt,"cpiContext"),ne("delegate"),re("delegatedAmount"),te("delegateMerkleTreeIndex"),te("changeAccountMerkleTreeIndex"),oe(re(),"delegateLamports")]),kn=X([X([ee(te(),32,"a"),ee(te(),64,"b"),ee(te(),32,"c")],"proof"),ne("mint"),ce(Ht,"inputTokenDataWithContext"),oe(Qt,"cpiContext"),te("outputAccountMerkleTreeIndex")]),vn={a:new Array(32).fill(0),b:new Array(64).fill(0),c:new Array(32).fill(0)};function In(e){return e.a.every((e=>0===e))&&e.b.every((e=>0===e))&&e.c.every((e=>0===e))}function Mn(e){const t=xe.alloc(1e3),n=e.proof??vn,r=bn.encode({...e,proof:n},t),o=xe.alloc(4);o.writeUInt32LE(r,0);const i=t.subarray(0,r);return xe.concat([new Uint8Array(kt),new Uint8Array(o),new Uint8Array(i)])}function Pn(e){const t=bn.decode(e.subarray(kt.length));return{...t,proof:In(t.proof)?null:t.proof}}function An(e){const t=xe.alloc(1e3),n=e.proof??vn,r=kn.encode({...e,proof:n},t),o=xe.alloc(4);o.writeUInt32LE(r,0);const i=t.subarray(0,r);return xe.concat([new Uint8Array(vt),new Uint8Array(o),new Uint8Array(i)])}function xn(e){const t=kn.decode(e.subarray(vt.length));return{...t,proof:In(t.proof)?null:t.proof}}function Sn(e){return"tokenPoolPda"in e?e.tokenPoolPda??e.splInterfacePda:e.splInterfacePda}const Cn=t=>t.reduce(((e,t)=>e.add(t.parsed.amount)),e(0)),Tn=e=>{const t=e[0].parsed.owner;e.forEach((e=>{if(!e.parsed.owner.equals(t))throw new Error("Token accounts must be owned by the same owner")}))},En=e=>({mint:e[0].parsed.mint,currentOwner:e[0].parsed.owner,delegate:e[0].parsed.delegate}),Bn=(e,t)=>{if(e.length<1)throw new Error("Must supply at least one input token account.");const n=e[0].parsed.owner,r=e.findIndex((e=>e.parsed.delegate));if(-1===r)return{delegatedTransfer:null,authority:n};const o=e[r].parsed.delegate;return{delegatedTransfer:{owner:n,delegateChangeAccountIndex:t.length<=1?null:0},authority:o}};function _n(t,n,r){r=e(r);const o=Cn(t),i=c(t.map((e=>e.compressedAccount))),s=o.sub(r);return l(s),s.eq(e(0))&&i.eq(e(0))?[{owner:n,amount:r,lamports:i,tlv:null}]:(d(t.map((e=>e.compressedAccount))),Tn(t),[{owner:t[0].parsed.owner,amount:s,lamports:i,tlv:null},{owner:n,amount:r,lamports:e(0),tlv:null}])}function Dn(t,n){n=e(n);const r=c(t.map((e=>e.compressedAccount))),o=Cn(t).sub(n);return l(o),o.eq(e(0))&&r.eq(e(0))?[]:(d(t.map((e=>e.compressedAccount))),Tn(t),[{owner:t[0].parsed.owner,amount:o,lamports:r,tlv:null}])}class Ln{constructor(){}static programId=new P("cTokenmWW8bLPjZEBAUgYy3zKxQZW6VKi7bqNFEVv3m");static setProgramId(e){this.programId="string"==typeof e?new P(e):e}static deriveSplInterfacePda(e){const t=[pt,e.toBuffer()],[n,r]=P.findProgramAddressSync(t,this.programId);return n}static deriveTokenPoolPda(e){return this.deriveSplInterfacePda(e)}static findSplInterfaceIndexAndBump(e,t){for(let n=0;n<5;n++){const r=Ln.deriveSplInterfacePdaWithIndex(t,n);if(r[0].equals(e))return[n,r[1]]}throw new Error("SPL interface not found")}static findTokenPoolIndexAndBump(e,t){return this.findSplInterfaceIndexAndBump(e,t)}static deriveSplInterfacePdaWithIndex(e,t){let n=[];n=0===t?[xe.from("pool"),e.toBuffer(),xe.from([])]:[xe.from("pool"),e.toBuffer(),xe.from([t])];const[r,o]=P.findProgramAddressSync(n,this.programId);return[r,o]}static deriveTokenPoolPdaWithIndex(e,t){return this.deriveSplInterfacePdaWithIndex(e,t)}static get deriveCpiAuthorityPda(){const[e,t]=P.findProgramAddressSync([ht],this.programId);return e}static async createMint({feePayer:e,mint:t,authority:n,freezeAuthority:r,decimals:o,rentExemptBalance:i,tokenProgramId:s,mintSize:a}){const u=s??W;return[A.createAccount({fromPubkey:e,lamports:i,newAccountPubkey:t,programId:u,space:a??D}),L(t,o,n,r,u),await this.createTokenPool({feePayer:e,mint:t,tokenProgramId:u})]}static async createTokenPool({feePayer:e,mint:t,tokenProgramId:n}){const r=n??W,o=this.deriveSplInterfacePdaWithIndex(t,0),i=dn({mint:t,feePayer:e,tokenPoolPda:o[0],tokenProgram:r,cpiAuthorityPda:this.deriveCpiAuthorityPda,systemProgram:A.programId});return new x({programId:this.programId,keys:i,data:ft})}static async addTokenPool({feePayer:e,mint:t,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??W,i=this.deriveSplInterfacePdaWithIndex(t,n-1),s=this.deriveSplInterfacePdaWithIndex(t,n),a=pn({mint:t,feePayer:e,tokenPoolPda:s[0],existingTokenPoolPda:i[0],tokenProgram:o,cpiAuthorityPda:this.deriveCpiAuthorityPda,systemProgram:A.programId});return new x({programId:this.programId,keys:a,data:xe.concat([new Uint8Array(It),new Uint8Array(xe.from([n]))])})}static async mintTo({feePayer:t,mint:r,authority:o,toPubkey:u,amount:c,outputStateTreeInfo:l,tokenPoolInfo:d}){const p=i(),h=d.tokenProgram;St(d,r);const m=s(c).map((t=>e(t))),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:t,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:e,mint:t,authority:n,authorityTokenAccount:r,toPubkey:o,amount:i,outputStateTreeInfo:s,tokenPoolInfo:a}){const u=BigInt(i.toString());return[U(t,r,n,u,[],a.tokenProgram),await this.compress({payer:e,owner:n,source:r,toAddress:o,mint:t,amount:i,outputStateTreeInfo:s,tokenPoolInfo:a})]}static async transfer({payer:e,inputCompressedTokenAccounts:t,toAddress:n,amount:r,recentValidityProof:o,recentInputStateRootIndices:s}){const u=_n(t,n,r),{inputTokenDataWithContext:c,packedOutputTokenData:l,remainingAccountMetas:d}=$t({inputCompressedTokenAccounts:t,rootIndices:s,tokenTransferOutputs:u}),{mint:p}=En(t),{delegatedTransfer:h,authority:m}=Bn(t,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:e,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:e,authority:t,mints:n,recentSlot:r,remainingAccounts:o}){const[s,c]=S.createLookupTable({authority:t,payer:t,recentSlot:r});let l=[];n&&(l=[...n,...n.map((e=>this.deriveSplInterfacePda(e)))]);const d=[s,S.extendLookupTable({payer:e,authority:t,lookupTable:c,addresses:[A.programId,C.programId,this.deriveCpiAuthorityPda,a.programId,Ln.programId,i().registeredProgramPda,i().noopProgram,i().accountCompressionAuthority,i().accountCompressionProgram,u().merkleTree,u().nullifierQueue,u().addressTree,u().addressQueue,this.programId,W,O,t,...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:e,authority:t,lookupTable:c,addresses:r});d.push(i)}return{instructions:d,address:c}}static async compress({payer:t,owner:n,source:o,toAddress:u,amount:c,mint:l,outputStateTreeInfo:d,tokenPoolInfo:p}){let h;const m=s(c),f=s(u);if(St(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((t=>e(t))):null,lamports:null,amount:1===m.length?e(m[0]):null,index:r,bump:s}),c=hn({mint:l,feePayer:t,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(((t,n)=>{const r=e(t);return{owner:f[n],amount:r,lamports:null,tlv:null}}));const{inputTokenDataWithContext:r,packedOutputTokenData:s,remainingAccountMetas:u}=$t({inputCompressedTokenAccounts:[],outputStateTreeInfo:d,rootIndices:[],tokenTransferOutputs:h}),y=cn({proof:null,mint:l,delegatedTransfer:null,inputTokenDataWithContext:r,outputCompressedAccounts:s,compressOrDecompressAmount:Array.isArray(c)?c.map((t=>e(t))).reduce(((e,t)=>e.add(t)),e(0)):e(c),isCompress:1,cpiContext:null,lamportsChangeAccountMerkleTreeIndex:null}),g=mn({...i(),feePayer:t,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:t,inputCompressedTokenAccounts:n,toAddress:r,amount:o,recentValidityProof:u,recentInputStateRootIndices:c,tokenPoolInfos:l}){const d=e(o),p=s(l),h=Dn(n,d),{inputTokenDataWithContext:m,packedOutputTokenData:f,remainingAccountMetas:y}=$t({inputCompressedTokenAccounts:n,rootIndices:c,tokenTransferOutputs:h,remainingAccounts:p.slice(1).map((e=>Sn(e)))}),{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:t,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:t,owner:n,inputCompressedTokenAccounts:o,mint:i,recentValidityProof:s,recentInputStateRootIndices:a}){const u=r.isV2()?8:4;if(o.length>u)throw new Error(`Cannot merge more than ${u} token accounts at once`);return Yt(o,i),[await this.transfer({payer:t,inputCompressedTokenAccounts:o,toAddress:n,amount:o.reduce(((e,t)=>e.add(t.parsed.amount)),e(0)),recentInputStateRootIndices:a,recentValidityProof:s})]}static async compressSplTokenAccount({feePayer:e,authority:t,tokenAccount:r,mint:o,remainingAmount:s,outputStateTreeInfo:u,tokenPoolInfo:c}){St(c,o);const l=[{pubkey:u.treeType===n.StateV2?u.queue:u.tree,isSigner:0,isWritable:1}],d=an({owner:t,remainingAmount:s??null,cpiContext:null}),{accountCompressionAuthority:p,noopProgram:h,registeredProgramPda:m,accountCompressionProgram:f}=i(),y=mn({feePayer:e,authority:t,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(e,t){return(await t.getAccountInfo(e))?.owner}static async approve({payer:t,inputCompressedTokenAccounts:r,toAddress:o,amount:s,recentValidityProof:u,recentInputStateRootIndices:c}){const{inputTokenDataWithContext:l,remainingAccountMetas:d}=$t({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:e(s),delegateMerkleTreeIndex:m,changeAccountMerkleTreeIndex:m,delegateLamports:null}),{accountCompressionAuthority:y,noopProgram:g,registeredProgramPda:w,accountCompressionProgram:b}=i(),k=fn({feePayer:t,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:e,inputCompressedTokenAccounts:t,recentValidityProof:r,recentInputStateRootIndices:o}){Tn(t);const{inputTokenDataWithContext:s,remainingAccountMetas:u}=$t({inputCompressedTokenAccounts:t,rootIndices:o,tokenTransferOutputs:[]}),{mint:c,currentOwner:l}=En(t),d=An({proof:r,mint:c,inputTokenDataWithContext:s,cpiContext:null,outputAccountMerkleTreeIndex:t[0].compressedAccount.treeInfo.treeType===n.StateV2?2:1}),{accountCompressionAuthority:p,noopProgram:h,registeredProgramPda:m,accountCompressionProgram:f}=i(),y=yn({feePayer:e,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 Un(e,t){const n=p(On(e)[0].toBytes(),t.tree,h);return Array.from(n.toBytes())}const Wn=xe.from([99,111,109,112,114,101,115,115,101,100,95,109,105,110,116]);function On(e){const[t,n]=P.findProgramAddressSync([Wn,e.toBuffer()],h);return[t,n]}function Rn(e,t){return P.findProgramAddressSync([e.toBuffer(),h.toBuffer(),t.toBuffer()],h)}function qn(e,t){return P.findProgramAddressSync([e.toBuffer(),h.toBuffer(),t.toBuffer()],h)[0]}const Kn=xe.from([103]),zn=X([ne("recipient"),re("amount")]),Vn=X([te("tokenAccountVersion"),ce(zn,"recipients")]),Nn=X([oe(ne(),"newAuthority")]),Fn=X([te("mintBump")]),$n=X([te("accountIndex"),re("amount")]),Yn=X([te("extensionIndex"),te("fieldType"),ie("key"),ie("value")]),jn=X([te("extensionIndex"),ne("newAuthority")]),Zn=X([te("extensionIndex"),ie("key"),te("idempotent")]),Hn=X([te("cmintBump"),te("rentPayment"),se("writeTopUp")]),Gn=X([te("idempotent")]),Qn=le([Vn.replicate("mintToCompressed"),Nn.replicate("updateMintAuthority"),Nn.replicate("updateFreezeAuthority"),Fn.replicate("createSplMint"),$n.replicate("mintToCToken"),Yn.replicate("updateMetadataField"),jn.replicate("updateMetadataAuthority"),Zn.replicate("removeMetadataKey"),Hn.replicate("decompressMint"),Gn.replicate("compressAndCloseCMint")]),Jn=X([ee(te(),32,"a"),ee(te(),64,"b"),ee(te(),32,"c")]),Xn=X([ae("setContext"),ae("firstSetContext"),te("inTreeIndex"),te("inQueueIndex"),te("outQueueIndex"),te("tokenOutQueueIndex"),te("assignedAccountIndex"),ee(te(),4,"readOnlyAddressTrees"),ee(te(),32,"addressTreePubkey")]),er=X([ee(te(),4,"readOnlyAddressTrees"),ee(ue(),4,"readOnlyAddressTreeRootIndices")]),tr=X([ie("key"),ie("value")]),nr=X([oe(ne(),"updateAuthority"),ie("name"),ie("symbol"),ie("uri"),oe(ce(tr),"additionalMetadata")]),rr=X([]),or=le([rr.replicate("placeholder0"),rr.replicate("placeholder1"),rr.replicate("placeholder2"),rr.replicate("placeholder3"),rr.replicate("placeholder4"),rr.replicate("placeholder5"),rr.replicate("placeholder6"),rr.replicate("placeholder7"),rr.replicate("placeholder8"),rr.replicate("placeholder9"),rr.replicate("placeholder10"),rr.replicate("placeholder11"),rr.replicate("placeholder12"),rr.replicate("placeholder13"),rr.replicate("placeholder14"),rr.replicate("placeholder15"),rr.replicate("placeholder16"),rr.replicate("placeholder17"),rr.replicate("placeholder18"),nr.replicate("tokenMetadata")]),ir=X([te("version"),ae("cmintDecompressed"),ne("mint")]),sr=X([re("supply"),te("decimals"),ir.replicate("metadata"),oe(ne(),"mintAuthority"),oe(ne(),"freezeAuthority"),oe(ce(or),"extensions")]),ar=X([se("leafIndex"),ae("proveByIndex"),ue("rootIndex"),ee(te(),32,"compressedAddress"),te("tokenPoolBump"),te("tokenPoolIndex"),ue("maxTopUp"),oe(er,"createMint"),ce(Qn,"actions"),oe(Jn,"proof"),oe(Xn,"cpiContext"),oe(sr,"mint")]);function ur(t){const n={...t,mint:t.mint?{...t.mint,supply:e(t.mint.supply.toString())}:null,actions:t.actions.map((t=>"mintToCompressed"in t&&t.mintToCompressed?{mintToCompressed:{...t.mintToCompressed,recipients:t.mintToCompressed.recipients.map((t=>({...t,amount:e(t.amount.toString())})))}}:"mintToCToken"in t&&t.mintToCToken?{mintToCToken:{...t.mintToCToken,amount:e(t.mintToCToken.amount.toString())}}:t))},r=xe.alloc(1e4),o=ar.encode(n,r);return xe.concat([Kn,r.subarray(0,o)])}function cr(e,t,n,r,o=null){return{name:e,symbol:t,uri:n,updateAuthority:r??null,additionalMetadata:o??null}}function lr(e,t,n,r,o,s,u,c,l){const d=function(e){const[t]=On(e.mintSigner),n=p(t.toBytes(),e.addressTree,h);let r=null;e.metadata&&(r=[{tokenMetadata:{updateAuthority:e.metadata.updateAuthority??null,name:xe.from(e.metadata.name),symbol:xe.from(e.metadata.symbol),uri:xe.from(e.metadata.uri),additionalMetadata:e.metadata.additionalMetadata}}]);const o=function(e){if(!e)return null;if(32!==e.a.length)throw new Error(`Invalid proof.a length: expected 32, got ${e.a.length}`);if(64!==e.b.length)throw new Error(`Invalid proof.b length: expected 64, got ${e.b.length}`);if(32!==e.c.length)throw new Error(`Invalid proof.c length: expected 32, got ${e.c.length}`);return e}(e.proof);return ur({leafIndex:0,proveByIndex:0,rootIndex:e.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:e.decimals,metadata:{version:lt.ShaFlat,cmintDecompressed:0,mint:t},mintAuthority:e.mintAuthority,freezeAuthority:e.freezeAuthority,extensions:r}})}({mintSigner:e,mintAuthority:n,freezeAuthority:r,decimals:t,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:e,isSigner:1,isWritable:0},{pubkey:n,isSigner:1,isWritable:0},{pubkey:o,isSigner:1,isWritable:1},{pubkey:Ln.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 dr(e){const t=p(e.splMint.toBytes(),e.addressTree,h),n="mintAuthority"===e.actionType?{updateMintAuthority:{newAuthority:e.newAuthority}}:{updateFreezeAuthority:{newAuthority:e.newAuthority}};let r=null;return e.mintInterface.tokenMetadata&&(r=[{tokenMetadata:{updateAuthority:e.mintInterface.tokenMetadata.updateAuthority??null,name:xe.from(e.mintInterface.tokenMetadata.name),symbol:xe.from(e.mintInterface.tokenMetadata.symbol),uri:xe.from(e.mintInterface.tokenMetadata.uri),additionalMetadata:null}}]),ur({leafIndex:e.leafIndex,proveByIndex:e.proveByIndex,rootIndex:e.rootIndex,compressedAddress:Array.from(t.toBytes()),tokenPoolBump:0,tokenPoolIndex:0,maxTopUp:0,createMint:null,actions:[n],proof:e.proof,cpiContext:null,mint:{supply:e.mintInterface.mint.supply,decimals:e.mintInterface.mint.decimals,metadata:{version:e.mintInterface.mintContext.version,cmintDecompressed:e.mintInterface.mintContext.cmintDecompressed,mint:e.mintInterface.mintContext.splMint},mintAuthority:e.mintInterface.mint.mintAuthority,freezeAuthority:e.mintInterface.mint.freezeAuthority,extensions:r}})}function pr(e,t,n,r,o){if(!e.merkleContext)throw new Error("MintInterface must have merkleContext for compressed mint operations");if(!e.mintContext)throw new Error("MintInterface must have mintContext for compressed mint operations");const s=e.merkleContext,u=m(s),c=f(),l=dr({splMint:e.mintContext.splMint,addressTree:c.tree,leafIndex:s.leafIndex,proveByIndex:1,rootIndex:o.rootIndices[0],proof:o.compressedProof,mintInterface:e,newAuthority:n,actionType:"mintAuthority"}),d=i(),p=[{pubkey:a.programId,isSigner:0,isWritable:0},{pubkey:t,isSigner:1,isWritable:0},{pubkey:r,isSigner:1,isWritable:1},{pubkey:Ln.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 hr(e,t,n,r,o){if(!e.merkleContext)throw new Error("MintInterface must have merkleContext for compressed mint operations");if(!e.mintContext)throw new Error("MintInterface must have mintContext for compressed mint operations");const s=e.merkleContext,u=m(s),c=f(),l=dr({splMint:e.mintContext.splMint,addressTree:c.tree,leafIndex:s.leafIndex,proveByIndex:1,rootIndex:o.rootIndices[0],proof:o.compressedProof,mintInterface:e,newAuthority:n,actionType:"freezeAuthority"}),d=i(),p=[{pubkey:a.programId,isSigner:0,isWritable:0},{pubkey:t,isSigner:1,isWritable:0},{pubkey:r,isSigner:1,isWritable:1},{pubkey:Ln.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 mr(e,t,n,r,o){if(!e.merkleContext)throw new Error("MintInterface must have merkleContext for compressed mint operations");if(!e.mintContext)throw new Error("MintInterface must have mintContext for compressed mint operations");if(!e.tokenMetadata)throw new Error("MintInterface must have tokenMetadata for metadata operations");const s=e.merkleContext,u=m(s),c=f(),l=function(e){const t=p(e.splMint.toBytes(),e.addressTree,h),n=e.mintInterface;if(!n.tokenMetadata)throw new Error("MintInterface must have tokenMetadata for metadata operations");var r;return ur({leafIndex:e.leafIndex,proveByIndex:null===e.proof,rootIndex:e.rootIndex,compressedAddress:Array.from(t.toBytes()),tokenPoolBump:0,tokenPoolIndex:0,maxTopUp:0,createMint:null,actions:[(r=e.action,"updateField"===r.type?{updateMetadataField:{extensionIndex:r.extensionIndex,fieldType:r.fieldType,key:xe.from(r.key),value:xe.from(r.value)}}:"updateAuthority"===r.type?{updateMetadataAuthority:{extensionIndex:r.extensionIndex,newAuthority:r.newAuthority}}:{removeMetadataKey:{extensionIndex:r.extensionIndex,key:xe.from(r.key),idempotent:r.idempotent?1:0}})],proof:e.proof,cpiContext:null,mint:{supply:n.mint.supply,decimals:n.mint.decimals,metadata:{version:n.mintContext.version,cmintDecompressed:n.mintContext.cmintDecompressed,mint:n.mintContext.splMint},mintAuthority:n.mint.mintAuthority,freezeAuthority:n.mint.freezeAuthority,extensions:[{tokenMetadata:{updateAuthority:n.tokenMetadata.updateAuthority??null,name:xe.from(n.tokenMetadata.name),symbol:xe.from(n.tokenMetadata.symbol),uri:xe.from(n.tokenMetadata.uri),additionalMetadata:null}}]}})}({splMint:e.mintContext.splMint,addressTree:c.tree,leafIndex:s.leafIndex,rootIndex:r.rootIndices[0],proof:r.compressedProof,mintInterface:e,action:o}),d=i(),y=[{pubkey:a.programId,isSigner:0,isWritable:0},{pubkey:t,isSigner:1,isWritable:0},{pubkey:n,isSigner:1,isWritable:1},{pubkey:Ln.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 fr(e,t,n,r,o,i,s,a=0){return mr(e,t,n,r,{type:"updateField",extensionIndex:a,fieldType:"name"===o?0:"symbol"===o?1:"uri"===o?2:3,key:s||"",value:i})}function yr(e,t,n,r,o,i=0){return mr(e,t,r,o,{type:"updateAuthority",extensionIndex:i,newAuthority:n})}function gr(e,t,n,r,o,i=0,s=0){return mr(e,t,n,r,{type:"removeKey",extensionIndex:s,key:o,idempotent:i})}const wr=xe.from([100]),br=xe.from([102]),kr=X([te("bump"),ee(te(),32,"programId"),ce(ce(te()),"seeds")]),vr=X([te("tokenAccountVersion"),te("rentPayment"),te("hasTopUp"),te("compressionOnly"),se("writeTopUp"),oe(kr,"compressToAccountPubkey")]),Ir=X([te("bump"),oe(vr,"compressibleConfig")]);function Mr(e,t){return P.findProgramAddressSync([e.toBuffer(),h.toBuffer(),t.toBuffer()],h)}function Pr(e,t){const n=xe.alloc(2e3),r=Ir.encode({bump:e.bump,compressibleConfig:e.compressibleConfig||null},n),o=t?br:wr;return xe.concat([o,n.subarray(0,r)])}function Ar(e,t,n,r,o,i){const[s,a]=Mr(t,n),u=Pr({bump:a,compressibleConfig:r},0),c=[{pubkey:t,isSigner:0,isWritable:0},{pubkey:n,isSigner:0,isWritable:0},{pubkey:e,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 xr(e,t,n,r,o,i){const[s,a]=Mr(t,n),u=Pr({bump:a,compressibleConfig:r},1),c=[{pubkey:t,isSigner:0,isWritable:0},{pubkey:n,isSigner:0,isWritable:0},{pubkey:e,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 Sr(e){return e.equals(h)?h:R}function Cr(e,t,n,r,o=0){if(r){const i=q(t,n,o,r,Sr(r));if(e.equals(i))return{valid:1,type:Tr(r),programId:r};throw new Error(`ATA address mismatch for ${r.toBase58()}. Expected: ${i.toBase58()}, got: ${e.toBase58()}`)}let i,s,a;if(i=q(t,n,o,h,Sr(h)),e.equals(i))return{valid:1,type:"ctoken",programId:h};if(s=q(t,n,o,W,Sr(W)),e.equals(s))return{valid:1,type:"spl",programId:W};if(a=q(t,n,o,O,Sr(O)),e.equals(a))return{valid:1,type:"token2022",programId:O};throw new Error(`ATA address does not match any valid derivation from mint+owner. Got: ${e.toBase58()}, expected one of: c-token=${i.toBase58()}, SPL=${s.toBase58()}, T22=${a.toBase58()}`)}function Tr(e){if(e.equals(h))return"ctoken";if(e.equals(W))return"spl";if(e.equals(O))return"token2022";throw new Error(`Unknown program ID: ${e.toBase58()}`)}function Er(e,t,n,r,o=W,i,s){const a=i??Sr(o);return o.equals(h)?Ar(e,n,r,s?.compressibleConfig,s?.configAccount,s?.rentPayerPda):K(e,t,n,r,o,a)}function Br(e,t,n,r,o=W,i,s){const a=i??Sr(o);return o.equals(h)?xr(e,n,r,s?.compressibleConfig,s?.configAccount,s?.rentPayerPda):z(e,t,n,r,o,a)}const _r=Br;function Dr(e,t,n,r,o,s,u,c){const l=function(e){const t=p(e.mintData.splMint.toBytes(),e.addressTree,h);if(e.mintData.metadata)throw new Error("TokenMetadata extension not supported in mintTo instruction");return ur({leafIndex:e.leafIndex,proveByIndex:1,rootIndex:e.rootIndex,compressedAddress:Array.from(t.toBytes()),tokenPoolBump:0,tokenPoolIndex:0,maxTopUp:0,createMint:null,actions:[{mintToCToken:{accountIndex:e.recipientAccountIndex,amount:BigInt(e.amount.toString())}}],proof:e.proof,cpiContext:null,mint:{supply:e.mintData.supply,decimals:e.mintData.decimals,metadata:{version:e.mintData.version,cmintDecompressed:e.mintData.cmintDecompressed,mint:e.mintData.splMint},mintAuthority:e.mintData.mintAuthority,freezeAuthority:e.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:e,isSigner:1,isWritable:0},{pubkey:t,isSigner:1,isWritable:1},{pubkey:Ln.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 Lr(e,t,n,r,o,s,u,c=lt.ShaFlat){const l=function(e){const t=p(e.mintData.splMint.toBytes(),e.addressTree,h);if(e.mintData.metadata)throw new Error("TokenMetadata extension not supported in mintTo instruction");return ur({leafIndex:e.leafIndex,proveByIndex:1,rootIndex:e.rootIndex,compressedAddress:Array.from(t.toBytes()),tokenPoolBump:0,tokenPoolIndex:0,maxTopUp:0,createMint:null,actions:[{mintToCompressed:{tokenAccountVersion:e.tokenAccountVersion,recipients:e.recipients.map((e=>({recipient:e.recipient,amount:BigInt(e.amount.toString())})))}}],proof:e.proof,cpiContext:null,mint:{supply:e.mintData.supply,decimals:e.mintData.decimals,metadata:{version:e.mintData.version,cmintDecompressed:e.mintData.cmintDecompressed,mint:e.mintData.splMint},mintAuthority:e.mintData.mintAuthority,freezeAuthority:e.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:e,isSigner:1,isWritable:0},{pubkey:t,isSigner:1,isWritable:1},{pubkey:Ln.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 Ur(e,t,n,r,o,i,s=[]){const a=e.mint.address,u=e.programId;if(!e.merkleContext)return U(a,t,n,BigInt(o.toString()),s,u);if(!i)throw new Error("Validity proof required for c-token mint-to");if(!e.mintContext)throw new Error("mintContext required for c-token mint-to");const c={supply:e.mint.supply,decimals:e.mint.decimals,mintAuthority:e.mint.mintAuthority,freezeAuthority:e.mint.freezeAuthority,splMint:e.mintContext.splMint,cmintDecompressed:e.mintContext.cmintDecompressed,version:e.mintContext.version,metadata:e.tokenMetadata?{updateAuthority:e.tokenMetadata.updateAuthority||null,name:e.tokenMetadata.name,symbol:e.tokenMetadata.symbol,uri:e.tokenMetadata.uri}:void 0};return Dr(n,r,i,e.merkleContext,c,y(e.merkleContext),t,o)}const Wr=3;function Or(e,t,n,r){const o=Buffer.alloc(9);return o.writeUInt8(Wr,0),o.writeBigUInt64LE(BigInt(r),1),new x({programId:h,keys:[{pubkey:e,isSigner:0,isWritable:1},{pubkey:t,isSigner:0,isWritable:1},{pubkey:n,isSigner:1,isWritable:1}],data:o})}function Rr(e,t,n,r,o=[],i=h){if(i.equals(h)){if(o.length>0)throw new Error("c-token transfer does not support multi-signers. Use a single owner.");return Or(e,t,n,r)}if(i.equals(W)||i.equals(O))return V(e,t,n,r,o.map((e=>e instanceof P?e:e.publicKey)),i);throw new Error(`Unsupported program ID: ${i.toBase58()}`)}const qr=xe.from([101]),Kr=0,zr=1,Vr=X([te("mode"),re("amount"),te("mint"),te("sourceOrRecipient"),te("authority"),te("poolAccountIndex"),te("poolIndex"),te("bump"),te("decimals")]),Nr=X([te("merkleTreePubkeyIndex"),te("queuePubkeyIndex"),se("leafIndex"),ae("proveByIndex")]),Fr=X([te("owner"),re("amount"),ae("hasDelegate"),te("delegate"),te("mint"),te("version"),Nr.replicate("merkleContext"),ue("rootIndex")]),$r=X([te("owner"),re("amount"),ae("hasDelegate"),te("delegate"),te("mint"),te("version")]),Yr=X([ae("setContext"),ae("firstSetContext"),te("cpiContextAccountIndex")]),jr=X([ee(te(),32,"a"),ee(te(),64,"b"),ee(te(),32,"c")]),Zr=X([ae("withTransactionHash"),ae("withLamportsChangeAccountMerkleTreeIndex"),te("lamportsChangeAccountMerkleTreeIndex"),te("lamportsChangeAccountOwnerIndex"),te("outputQueue"),ue("maxTopUp"),oe(Yr,"cpiContext"),oe(ce(Vr),"compressions"),oe(jr,"proof"),ce(Fr,"inTokenData"),ce($r,"outTokenData"),oe(ce(re()),"inLamports"),oe(ce(re()),"outLamports"),oe(ce(ce(te())),"inTlv"),oe(ce(ce(te())),"outTlv")]);function Hr(t){const n={...t,compressions:t.compressions?.map((t=>({...t,amount:e(t.amount.toString())})))??null,inTokenData:t.inTokenData.map((t=>({...t,amount:e(t.amount.toString())}))),outTokenData:t.outTokenData.map((t=>({...t,amount:e(t.amount.toString())}))),inLamports:t.inLamports?.map((t=>e(t.toString())))??null,outLamports:t.outLamports?.map((t=>e(t.toString())))??null},r=xe.alloc(2e3),o=Zr.encode(n,r);return xe.concat([qr,r.subarray(0,o)])}function Gr(e,t,n,r,o,i,s){return{mode:Kr,amount:e,mint:t,sourceOrRecipient:n,authority:r,poolAccountIndex:o,poolIndex:i,bump:s,decimals:0}}function Qr(e,t,n,r){return{mode:zr,amount:e,mint:t,sourceOrRecipient:n,authority:0,poolAccountIndex:r,poolIndex:0,bump:0,decimals:0}}function Jr(e,t,n,r,o){return{mode:Kr,amount:e,mint:t,sourceOrRecipient:n,authority:r,poolAccountIndex:o,poolIndex:0,bump:0,decimals:0}}function Xr(e,t,n,r,o,i){return{mode:zr,amount:e,mint:t,sourceOrRecipient:n,authority:0,poolAccountIndex:r,poolIndex:o,bump:i,decimals:0}}function eo(e){return!e||e.length<8?lt.ShaFlat:2===e[0]?lt.V1:3===e[7]?lt.V2:lt.ShaFlat}function to(e,t,n,r,o,s){if(0===t.length)throw new Error("No input compressed token accounts provided");const u=t[0].parsed.mint,c=t[0].parsed.owner,l=new Map,d=[],p=new Set,h=new Set;for(const e of t)p.add(e.compressedAccount.treeInfo.tree.toBase58()),h.add(e.compressedAccount.treeInfo.queue.toBase58());for(const e of p)l.set(e,d.length),d.push(new P(e));let m=0,f=1;for(const e of h)f&&(m=d.length,f=0),l.set(e,d.length),d.push(new P(e));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(e,t,n){return e.map(((e,r)=>{const o=e.parsed.owner.toBase58(),i=e.parsed.mint.toBase58(),s=eo(e.compressedAccount.data?.discriminator);return{owner:n.get(o),amount:BigInt(e.parsed.amount.toString()),hasDelegate:null!==e.parsed.delegate,delegate:e.parsed.delegate?n.get(e.parsed.delegate.toBase58())??0:0,mint:n.get(i),version:s,merkleContext:{merkleTreePubkeyIndex:n.get(e.compressedAccount.treeInfo.tree.toBase58()),queuePubkeyIndex:n.get(e.compressedAccount.treeInfo.queue.toBase58()),leafIndex:e.compressedAccount.leafIndex,proveByIndex:e.compressedAccount.proveByIndex},rootIndex:t[r]}}))}(t,o.rootIndices,l),S=t.reduce(((e,t)=>e+BigInt(t.parsed.amount.toString())),BigInt(0))-r,C=[];if(S>0){const e=eo(t[0].compressedAccount.data?.discriminator);C.push({owner:g,amount:S,hasDelegate:0,delegate:0,mint:y,version:e})}const T=Hr({withTransactionHash:0,withLamportsChangeAccountMerkleTreeIndex:0,lamportsChangeAccountMerkleTreeIndex:0,lamportsChangeAccountOwnerIndex:0,outputQueue:m,maxTopUp:0,cpiContext:null,compressions:[{mode:zr,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(),D=[{pubkey:a.programId,isSigner:0,isWritable:0},{pubkey:e,isSigner:1,isWritable:1},{pubkey:Ln.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(((e,t)=>{const r=t<p.size+h.size,o=e.equals(n),i=void 0!==s&&e.equals(s.splInterfacePda);return{pubkey:e,isSigner:t===g,isWritable:r||o||i}}))];return new x({programId:Ln.programId,keys:D,data:T})}var no="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function ro(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function oo(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var n=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:1}),Object.keys(e).forEach((function(t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:1,get:function(){return e[t]}})})),n}var io={exports:{}},so=oo(dt);!function(e,t){function n(e,t){if(!e)throw new Error(t||"Assertion failed")}function r(e,t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}function o(e,t,n){if(o.isBN(e))return e;this.negative=0,this.words=null,this.length=0,this.red=null,null!==e&&("le"!==t&&"be"!==t||(n=t,t=10),this._init(e||0,t||10,n||"be"))}var i;"object"==typeof io?io.exports=o:t.BN=o,o.BN=o,o.wordSize=26;try{i="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:so.Buffer}catch(e){}function s(e,t){var r=e.charCodeAt(t);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 "+e)}function a(e,t,n){var r=s(e,n);return n-1>=t&&(r|=s(e,n-1)<<4),r}function u(e,t,r,o){for(var i=0,s=0,a=Math.min(e.length,r),u=t;u<a;u++){var c=e.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(e,t){e.words=t.words,e.length=t.length,e.negative=t.negative,e.red=t.red}if(o.isBN=function(e){return e instanceof o?1:null!==e&&"object"==typeof e&&e.constructor.wordSize===o.wordSize&&Array.isArray(e.words)},o.max=function(e,t){return e.cmp(t)>0?e:t},o.min=function(e,t){return e.cmp(t)<0?e:t},o.prototype._init=function(e,t,r){if("number"==typeof e)return this._initNumber(e,t,r);if("object"==typeof e)return this._initArray(e,t,r);"hex"===t&&(t=16),n(t===(0|t)&&t>=2&&t<=36);var o=0;"-"===(e=e.toString().replace(/\s+/g,""))[0]&&(o++,this.negative=1),o<e.length&&(16===t?this._parseHex(e,o,r):(this._parseBase(e,t,o),"le"===r&&this._initArray(this.toArray(),t,r)))},o.prototype._initNumber=function(e,t,r){e<0&&(this.negative=1,e=-e),e<67108864?(this.words=[67108863&e],this.length=1):e<4503599627370496?(this.words=[67108863&e,e/67108864&67108863],this.length=2):(n(e<9007199254740992),this.words=[67108863&e,e/67108864&67108863,1],this.length=3),"le"===r&&this._initArray(this.toArray(),t,r)},o.prototype._initArray=function(e,t,r){if(n("number"==typeof e.length),e.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(e.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=e.length-1,i=0;o>=0;o-=3)s=e[o]|e[o-1]<<8|e[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<e.length;o+=3)s=e[o]|e[o+1]<<8|e[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(e,t,n){this.length=Math.ceil((e.length-t)/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=e.length-1;r>=t;r-=2)o=a(e,t,r)<<i,this.words[s]|=67108863&o,i>=18?(i-=18,s+=1,this.words[s]|=o>>>26):i+=8;else for(r=(e.length-t)%2==0?t+1:t;r<e.length;r+=2)o=a(e,t,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(e,t,n){this.words=[0],this.length=1;for(var r=0,o=1;o<=67108863;o*=t)r++;r--,o=o/t|0;for(var i=e.length-n,s=i%r,a=Math.min(i,i-s)+n,c=0,l=n;l<a;l+=r)c=u(e,l,l+r,t),this.imuln(o),this.words[0]+c<67108864?this.words[0]+=c:this._iaddn(c);if(0!==s){var d=1;for(c=u(e,l,e.length,t),l=0;l<s;l++)d*=t;this.imuln(d),this.words[0]+c<67108864?this.words[0]+=c:this._iaddn(c)}this._strip()},o.prototype.copy=function(e){e.words=new Array(this.length);for(var t=0;t<this.length;t++)e.words[t]=this.words[t];e.length=this.length,e.negative=this.negative,e.red=this.red},o.prototype._move=function(e){c(e,this)},o.prototype.clone=function(){var e=new o(null);return this.copy(e),e},o.prototype._expand=function(e){for(;this.length<e;)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(e){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(e,t,n){n.negative=t.negative^e.negative;var r=e.length+t.length|0;n.length=r,r=r-1|0;var o=0|e.words[0],i=0|t.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,t.length-1),h=Math.max(0,c-e.length+1);h<=p;h++){var m=c-h|0;l+=(s=(o=0|e.words[m])*(i=0|t.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(e,t){var r;if(t=0|t||1,16===(e=e||10)||"hex"===e){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%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}if(e===(0|e)&&e>=2&&e<=36){var c=p[e],l=h[e];r="";var m=this.clone();for(m.negative=0;!m.isZero();){var f=m.modrn(l).toString(e);r=(m=m.idivn(l)).isZero()?f+r:d[c-f.length]+f+r}for(this.isZero()&&(r="0"+r);r.length%t!=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 e=this.words[0];return 2===this.length?e+=67108864*this.words[1]:3===this.length&&1===this.words[2]?e+=4503599627370496+67108864*this.words[1]:this.length>2&&n(0,"Number can only safely store up to 53 bits"),0!==this.negative?-e:e},o.prototype.toJSON=function(){return this.toString(16,2)},i&&(o.prototype.toBuffer=function(e,t){return this.toArrayLike(i,e,t)}),o.prototype.toArray=function(e,t){return this.toArrayLike(Array,e,t)},o.prototype.toArrayLike=function(e,t,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(e,t){return e.allocUnsafe?e.allocUnsafe(t):new e(t)}(e,i);return this["_toArrayLike"+("le"===t?"LE":"BE")](s,o),s},o.prototype._toArrayLikeLE=function(e){for(var t=0,n=0,r=0,o=0;r<this.length;r++){var i=this.words[r]<<o|n;e[t++]=255&i,t<e.length&&(e[t++]=i>>8&255),t<e.length&&(e[t++]=i>>16&255),6===o?(t<e.length&&(e[t++]=i>>24&255),n=0,o=0):(n=i>>>24,o+=2)}if(t<e.length)for(e[t++]=n;t<e.length;)e[t++]=0},o.prototype._toArrayLikeBE=function(e){for(var t=e.length-1,n=0,r=0,o=0;r<this.length;r++){var i=this.words[r]<<o|n;e[t--]=255&i,t>=0&&(e[t--]=i>>8&255),t>=0&&(e[t--]=i>>16&255),6===o?(t>=0&&(e[t--]=i>>24&255),n=0,o=0):(n=i>>>24,o+=2)}if(t>=0)for(e[t--]=n;t>=0;)e[t--]=0},Math.clz32?o.prototype._countBits=function(e){return 32-Math.clz32(e)}:o.prototype._countBits=function(e){var t=e,n=0;return t>=4096&&(n+=13,t>>>=13),t>=64&&(n+=7,t>>>=7),t>=8&&(n+=4,t>>>=4),t>=2&&(n+=2,t>>>=2),n+t},o.prototype._zeroBits=function(e){if(0===e)return 26;var t=e,n=0;return 0==(8191&t)&&(n+=13,t>>>=13),0==(127&t)&&(n+=7,t>>>=7),0==(15&t)&&(n+=4,t>>>=4),0==(3&t)&&(n+=2,t>>>=2),0==(1&t)&&n++,n},o.prototype.bitLength=function(){var e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},o.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,t=0;t<this.length;t++){var n=this._zeroBits(this.words[t]);if(e+=n,26!==n)break}return e},o.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},o.prototype.toTwos=function(e){return 0!==this.negative?this.abs().inotn(e).iaddn(1):this.clone()},o.prototype.fromTwos=function(e){return this.testn(e-1)?this.notn(e).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(e){for(;this.length<e.length;)this.words[this.length++]=0;for(var t=0;t<e.length;t++)this.words[t]=this.words[t]|e.words[t];return this._strip()},o.prototype.ior=function(e){return n(0==(this.negative|e.negative)),this.iuor(e)},o.prototype.or=function(e){return this.length>e.length?this.clone().ior(e):e.clone().ior(this)},o.prototype.uor=function(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},o.prototype.iuand=function(e){var t;t=this.length>e.length?e:this;for(var n=0;n<t.length;n++)this.words[n]=this.words[n]&e.words[n];return this.length=t.length,this._strip()},o.prototype.iand=function(e){return n(0==(this.negative|e.negative)),this.iuand(e)},o.prototype.and=function(e){return this.length>e.length?this.clone().iand(e):e.clone().iand(this)},o.prototype.uand=function(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},o.prototype.iuxor=function(e){var t,n;this.length>e.length?(t=this,n=e):(t=e,n=this);for(var r=0;r<n.length;r++)this.words[r]=t.words[r]^n.words[r];if(this!==t)for(;r<t.length;r++)this.words[r]=t.words[r];return this.length=t.length,this._strip()},o.prototype.ixor=function(e){return n(0==(this.negative|e.negative)),this.iuxor(e)},o.prototype.xor=function(e){return this.length>e.length?this.clone().ixor(e):e.clone().ixor(this)},o.prototype.uxor=function(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},o.prototype.inotn=function(e){n("number"==typeof e&&e>=0);var t=0|Math.ceil(e/26),r=e%26;this._expand(t),r>0&&t--;for(var o=0;o<t;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(e){return this.clone().inotn(e)},o.prototype.setn=function(e,t){n("number"==typeof e&&e>=0);var r=e/26|0,o=e%26;return this._expand(r+1),this.words[r]=t?this.words[r]|1<<o:this.words[r]&~(1<<o),this._strip()},o.prototype.iadd=function(e){var t,n,r;if(0!==this.negative&&0===e.negative)return this.negative=0,t=this.isub(e),this.negative^=1,this._normSign();if(0===this.negative&&0!==e.negative)return e.negative=0,t=this.isub(e),e.negative=1,t._normSign();this.length>e.length?(n=this,r=e):(n=e,r=this);for(var o=0,i=0;i<r.length;i++)t=(0|n.words[i])+(0|r.words[i])+o,this.words[i]=67108863&t,o=t>>>26;for(;0!==o&&i<n.length;i++)t=(0|n.words[i])+o,this.words[i]=67108863&t,o=t>>>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(e){var t;return 0!==e.negative&&0===this.negative?(e.negative=0,t=this.sub(e),e.negative^=1,t):0===e.negative&&0!==this.negative?(this.negative=0,t=e.sub(this),this.negative=1,t):this.length>e.length?this.clone().iadd(e):e.clone().iadd(this)},o.prototype.isub=function(e){if(0!==e.negative){e.negative=0;var t=this.iadd(e);return e.negative=1,t._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var n,r,o=this.cmp(e);if(0===o)return this.negative=0,this.length=1,this.words[0]=0,this;o>0?(n=this,r=e):(n=e,r=this);for(var i=0,s=0;s<r.length;s++)i=(t=(0|n.words[s])-(0|r.words[s])+i)>>26,this.words[s]=67108863&t;for(;0!==i&&s<n.length;s++)i=(t=(0|n.words[s])+i)>>26,this.words[s]=67108863&t;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(e){return this.clone().isub(e)};var f=function(e,t,n){var r,o,i,s=e.words,a=t.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,D=B>>>13,L=0|s[8],U=8191&L,W=L>>>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,ee=J>>>13,te=0|a[5],ne=8191&te,re=te>>>13,oe=0|a[6],ie=8191&oe,se=oe>>>13,ae=0|a[7],ue=8191&ae,ce=ae>>>13,le=0|a[8],de=8191&le,pe=le>>>13,he=0|a[9],me=8191&he,fe=he>>>13;n.negative=e.negative^t.negative,n.length=19;var ye=(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)+(ye>>>26)|0,ye&=67108863,r=Math.imul(m,z),o=(o=Math.imul(m,V))+Math.imul(f,z)|0,i=Math.imul(f,V);var ge=(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)+(ge>>>26)|0,ge&=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 we=(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)+(we>>>26)|0,we&=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 be=(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)+(be>>>26)|0,be&=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 ke=(c+(r=r+Math.imul(d,X)|0)|0)+((8191&(o=(o=o+Math.imul(d,ee)|0)+Math.imul(p,X)|0))<<13)|0;c=((i=i+Math.imul(p,ee)|0)+(o>>>13)|0)+(ke>>>26)|0,ke&=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,ee)|0)+Math.imul(f,X)|0,i=i+Math.imul(f,ee)|0;var ve=(c+(r=r+Math.imul(d,ne)|0)|0)+((8191&(o=(o=o+Math.imul(d,re)|0)+Math.imul(p,ne)|0))<<13)|0;c=((i=i+Math.imul(p,re)|0)+(o>>>13)|0)+(ve>>>26)|0,ve&=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,ee)|0)+Math.imul(w,X)|0,i=i+Math.imul(w,ee)|0,r=r+Math.imul(m,ne)|0,o=(o=o+Math.imul(m,re)|0)+Math.imul(f,ne)|0,i=i+Math.imul(f,re)|0;var Ie=(c+(r=r+Math.imul(d,ie)|0)|0)+((8191&(o=(o=o+Math.imul(d,se)|0)+Math.imul(p,ie)|0))<<13)|0;c=((i=i+Math.imul(p,se)|0)+(o>>>13)|0)+(Ie>>>26)|0,Ie&=67108863,r=Math.imul(_,z),o=(o=Math.imul(_,V))+Math.imul(D,z)|0,i=Math.imul(D,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,ee)|0)+Math.imul(v,X)|0,i=i+Math.imul(v,ee)|0,r=r+Math.imul(g,ne)|0,o=(o=o+Math.imul(g,re)|0)+Math.imul(w,ne)|0,i=i+Math.imul(w,re)|0,r=r+Math.imul(m,ie)|0,o=(o=o+Math.imul(m,se)|0)+Math.imul(f,ie)|0,i=i+Math.imul(f,se)|0;var Me=(c+(r=r+Math.imul(d,ue)|0)|0)+((8191&(o=(o=o+Math.imul(d,ce)|0)+Math.imul(p,ue)|0))<<13)|0;c=((i=i+Math.imul(p,ce)|0)+(o>>>13)|0)+(Me>>>26)|0,Me&=67108863,r=Math.imul(U,z),o=(o=Math.imul(U,V))+Math.imul(W,z)|0,i=Math.imul(W,V),r=r+Math.imul(_,F)|0,o=(o=o+Math.imul(_,$)|0)+Math.imul(D,F)|0,i=i+Math.imul(D,$)|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,ee)|0)+Math.imul(P,X)|0,i=i+Math.imul(P,ee)|0,r=r+Math.imul(k,ne)|0,o=(o=o+Math.imul(k,re)|0)+Math.imul(v,ne)|0,i=i+Math.imul(v,re)|0,r=r+Math.imul(g,ie)|0,o=(o=o+Math.imul(g,se)|0)+Math.imul(w,ie)|0,i=i+Math.imul(w,se)|0,r=r+Math.imul(m,ue)|0,o=(o=o+Math.imul(m,ce)|0)+Math.imul(f,ue)|0,i=i+Math.imul(f,ce)|0;var Pe=(c+(r=r+Math.imul(d,de)|0)|0)+((8191&(o=(o=o+Math.imul(d,pe)|0)+Math.imul(p,de)|0))<<13)|0;c=((i=i+Math.imul(p,pe)|0)+(o>>>13)|0)+(Pe>>>26)|0,Pe&=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(U,F)|0,o=(o=o+Math.imul(U,$)|0)+Math.imul(W,F)|0,i=i+Math.imul(W,$)|0,r=r+Math.imul(_,j)|0,o=(o=o+Math.imul(_,Z)|0)+Math.imul(D,j)|0,i=i+Math.imul(D,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,ee)|0)+Math.imul(S,X)|0,i=i+Math.imul(S,ee)|0,r=r+Math.imul(M,ne)|0,o=(o=o+Math.imul(M,re)|0)+Math.imul(P,ne)|0,i=i+Math.imul(P,re)|0,r=r+Math.imul(k,ie)|0,o=(o=o+Math.imul(k,se)|0)+Math.imul(v,ie)|0,i=i+Math.imul(v,se)|0,r=r+Math.imul(g,ue)|0,o=(o=o+Math.imul(g,ce)|0)+Math.imul(w,ue)|0,i=i+Math.imul(w,ce)|0,r=r+Math.imul(m,de)|0,o=(o=o+Math.imul(m,pe)|0)+Math.imul(f,de)|0,i=i+Math.imul(f,pe)|0;var Ae=(c+(r=r+Math.imul(d,me)|0)|0)+((8191&(o=(o=o+Math.imul(d,fe)|0)+Math.imul(p,me)|0))<<13)|0;c=((i=i+Math.imul(p,fe)|0)+(o>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,r=Math.imul(R,F),o=(o=Math.imul(R,$))+Math.imul(q,F)|0,i=Math.imul(q,$),r=r+Math.imul(U,j)|0,o=(o=o+Math.imul(U,Z)|0)+Math.imul(W,j)|0,i=i+Math.imul(W,Z)|0,r=r+Math.imul(_,G)|0,o=(o=o+Math.imul(_,Q)|0)+Math.imul(D,G)|0,i=i+Math.imul(D,Q)|0,r=r+Math.imul(T,X)|0,o=(o=o+Math.imul(T,ee)|0)+Math.imul(E,X)|0,i=i+Math.imul(E,ee)|0,r=r+Math.imul(x,ne)|0,o=(o=o+Math.imul(x,re)|0)+Math.imul(S,ne)|0,i=i+Math.imul(S,re)|0,r=r+Math.imul(M,ie)|0,o=(o=o+Math.imul(M,se)|0)+Math.imul(P,ie)|0,i=i+Math.imul(P,se)|0,r=r+Math.imul(k,ue)|0,o=(o=o+Math.imul(k,ce)|0)+Math.imul(v,ue)|0,i=i+Math.imul(v,ce)|0,r=r+Math.imul(g,de)|0,o=(o=o+Math.imul(g,pe)|0)+Math.imul(w,de)|0,i=i+Math.imul(w,pe)|0;var xe=(c+(r=r+Math.imul(m,me)|0)|0)+((8191&(o=(o=o+Math.imul(m,fe)|0)+Math.imul(f,me)|0))<<13)|0;c=((i=i+Math.imul(f,fe)|0)+(o>>>13)|0)+(xe>>>26)|0,xe&=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(U,G)|0,o=(o=o+Math.imul(U,Q)|0)+Math.imul(W,G)|0,i=i+Math.imul(W,Q)|0,r=r+Math.imul(_,X)|0,o=(o=o+Math.imul(_,ee)|0)+Math.imul(D,X)|0,i=i+Math.imul(D,ee)|0,r=r+Math.imul(T,ne)|0,o=(o=o+Math.imul(T,re)|0)+Math.imul(E,ne)|0,i=i+Math.imul(E,re)|0,r=r+Math.imul(x,ie)|0,o=(o=o+Math.imul(x,se)|0)+Math.imul(S,ie)|0,i=i+Math.imul(S,se)|0,r=r+Math.imul(M,ue)|0,o=(o=o+Math.imul(M,ce)|0)+Math.imul(P,ue)|0,i=i+Math.imul(P,ce)|0,r=r+Math.imul(k,de)|0,o=(o=o+Math.imul(k,pe)|0)+Math.imul(v,de)|0,i=i+Math.imul(v,pe)|0;var Se=(c+(r=r+Math.imul(g,me)|0)|0)+((8191&(o=(o=o+Math.imul(g,fe)|0)+Math.imul(w,me)|0))<<13)|0;c=((i=i+Math.imul(w,fe)|0)+(o>>>13)|0)+(Se>>>26)|0,Se&=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(U,X)|0,o=(o=o+Math.imul(U,ee)|0)+Math.imul(W,X)|0,i=i+Math.imul(W,ee)|0,r=r+Math.imul(_,ne)|0,o=(o=o+Math.imul(_,re)|0)+Math.imul(D,ne)|0,i=i+Math.imul(D,re)|0,r=r+Math.imul(T,ie)|0,o=(o=o+Math.imul(T,se)|0)+Math.imul(E,ie)|0,i=i+Math.imul(E,se)|0,r=r+Math.imul(x,ue)|0,o=(o=o+Math.imul(x,ce)|0)+Math.imul(S,ue)|0,i=i+Math.imul(S,ce)|0,r=r+Math.imul(M,de)|0,o=(o=o+Math.imul(M,pe)|0)+Math.imul(P,de)|0,i=i+Math.imul(P,pe)|0;var Ce=(c+(r=r+Math.imul(k,me)|0)|0)+((8191&(o=(o=o+Math.imul(k,fe)|0)+Math.imul(v,me)|0))<<13)|0;c=((i=i+Math.imul(v,fe)|0)+(o>>>13)|0)+(Ce>>>26)|0,Ce&=67108863,r=Math.imul(R,X),o=(o=Math.imul(R,ee))+Math.imul(q,X)|0,i=Math.imul(q,ee),r=r+Math.imul(U,ne)|0,o=(o=o+Math.imul(U,re)|0)+Math.imul(W,ne)|0,i=i+Math.imul(W,re)|0,r=r+Math.imul(_,ie)|0,o=(o=o+Math.imul(_,se)|0)+Math.imul(D,ie)|0,i=i+Math.imul(D,se)|0,r=r+Math.imul(T,ue)|0,o=(o=o+Math.imul(T,ce)|0)+Math.imul(E,ue)|0,i=i+Math.imul(E,ce)|0,r=r+Math.imul(x,de)|0,o=(o=o+Math.imul(x,pe)|0)+Math.imul(S,de)|0,i=i+Math.imul(S,pe)|0;var Te=(c+(r=r+Math.imul(M,me)|0)|0)+((8191&(o=(o=o+Math.imul(M,fe)|0)+Math.imul(P,me)|0))<<13)|0;c=((i=i+Math.imul(P,fe)|0)+(o>>>13)|0)+(Te>>>26)|0,Te&=67108863,r=Math.imul(R,ne),o=(o=Math.imul(R,re))+Math.imul(q,ne)|0,i=Math.imul(q,re),r=r+Math.imul(U,ie)|0,o=(o=o+Math.imul(U,se)|0)+Math.imul(W,ie)|0,i=i+Math.imul(W,se)|0,r=r+Math.imul(_,ue)|0,o=(o=o+Math.imul(_,ce)|0)+Math.imul(D,ue)|0,i=i+Math.imul(D,ce)|0,r=r+Math.imul(T,de)|0,o=(o=o+Math.imul(T,pe)|0)+Math.imul(E,de)|0,i=i+Math.imul(E,pe)|0;var Ee=(c+(r=r+Math.imul(x,me)|0)|0)+((8191&(o=(o=o+Math.imul(x,fe)|0)+Math.imul(S,me)|0))<<13)|0;c=((i=i+Math.imul(S,fe)|0)+(o>>>13)|0)+(Ee>>>26)|0,Ee&=67108863,r=Math.imul(R,ie),o=(o=Math.imul(R,se))+Math.imul(q,ie)|0,i=Math.imul(q,se),r=r+Math.imul(U,ue)|0,o=(o=o+Math.imul(U,ce)|0)+Math.imul(W,ue)|0,i=i+Math.imul(W,ce)|0,r=r+Math.imul(_,de)|0,o=(o=o+Math.imul(_,pe)|0)+Math.imul(D,de)|0,i=i+Math.imul(D,pe)|0;var Be=(c+(r=r+Math.imul(T,me)|0)|0)+((8191&(o=(o=o+Math.imul(T,fe)|0)+Math.imul(E,me)|0))<<13)|0;c=((i=i+Math.imul(E,fe)|0)+(o>>>13)|0)+(Be>>>26)|0,Be&=67108863,r=Math.imul(R,ue),o=(o=Math.imul(R,ce))+Math.imul(q,ue)|0,i=Math.imul(q,ce),r=r+Math.imul(U,de)|0,o=(o=o+Math.imul(U,pe)|0)+Math.imul(W,de)|0,i=i+Math.imul(W,pe)|0;var _e=(c+(r=r+Math.imul(_,me)|0)|0)+((8191&(o=(o=o+Math.imul(_,fe)|0)+Math.imul(D,me)|0))<<13)|0;c=((i=i+Math.imul(D,fe)|0)+(o>>>13)|0)+(_e>>>26)|0,_e&=67108863,r=Math.imul(R,de),o=(o=Math.imul(R,pe))+Math.imul(q,de)|0,i=Math.imul(q,pe);var De=(c+(r=r+Math.imul(U,me)|0)|0)+((8191&(o=(o=o+Math.imul(U,fe)|0)+Math.imul(W,me)|0))<<13)|0;c=((i=i+Math.imul(W,fe)|0)+(o>>>13)|0)+(De>>>26)|0,De&=67108863;var Le=(c+(r=Math.imul(R,me))|0)+((8191&(o=(o=Math.imul(R,fe))+Math.imul(q,me)|0))<<13)|0;return c=((i=Math.imul(q,fe))+(o>>>13)|0)+(Le>>>26)|0,Le&=67108863,u[0]=ye,u[1]=ge,u[2]=we,u[3]=be,u[4]=ke,u[5]=ve,u[6]=Ie,u[7]=Me,u[8]=Pe,u[9]=Ae,u[10]=xe,u[11]=Se,u[12]=Ce,u[13]=Te,u[14]=Ee,u[15]=Be,u[16]=_e,u[17]=De,u[18]=Le,0!==c&&(u[19]=c,n.length++),n};function y(e,t,n){n.negative=t.negative^e.negative,n.length=e.length+t.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,t.length-1),c=Math.max(0,i-e.length+1);c<=u;c++){var l=i-c,d=(0|e.words[l])*(0|t.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(e,t,n){return y(e,t,n)}Math.imul||(f=m),o.prototype.mulTo=function(e,t){var n=this.length+e.length;return 10===this.length&&10===e.length?f(this,e,t):n<63?m(this,e,t):n<1024?y(this,e,t):g(this,e,t)},o.prototype.mul=function(e){var t=new o(null);return t.words=new Array(this.length+e.length),this.mulTo(e,t)},o.prototype.mulf=function(e){var t=new o(null);return t.words=new Array(this.length+e.length),g(this,e,t)},o.prototype.imul=function(e){return this.clone().mulTo(e,this)},o.prototype.imuln=function(e){var t=e<0;t&&(e=-e),n("number"==typeof e),n(e<67108864);for(var r=0,o=0;o<this.length;o++){var i=(0|this.words[o])*e,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++),t?this.ineg():this},o.prototype.muln=function(e){return this.clone().imuln(e)},o.prototype.sqr=function(){return this.mul(this)},o.prototype.isqr=function(){return this.imul(this.clone())},o.prototype.pow=function(e){var t=function(e){for(var t=new Array(e.bitLength()),n=0;n<t.length;n++){var r=n/26|0,o=n%26;t[n]=e.words[r]>>>o&1}return t}(e);if(0===t.length)return new o(1);for(var n=this,r=0;r<t.length&&0===t[r];r++,n=n.sqr());if(++r<t.length)for(var i=n.sqr();r<t.length;r++,i=i.sqr())0!==t[r]&&(n=n.mul(i));return n},o.prototype.iushln=function(e){n("number"==typeof e&&e>=0);var t,r=e%26,o=(e-r)/26,i=67108863>>>26-r<<26-r;if(0!==r){var s=0;for(t=0;t<this.length;t++){var a=this.words[t]&i,u=(0|this.words[t])-a<<r;this.words[t]=u|s,s=a>>>26-r}s&&(this.words[t]=s,this.length++)}if(0!==o){for(t=this.length-1;t>=0;t--)this.words[t+o]=this.words[t];for(t=0;t<o;t++)this.words[t]=0;this.length+=o}return this._strip()},o.prototype.ishln=function(e){return n(0===this.negative),this.iushln(e)},o.prototype.iushrn=function(e,t,r){var o;n("number"==typeof e&&e>=0),o=t?(t-t%26)/26:0;var i=e%26,s=Math.min((e-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(e,t,r){return n(0===this.negative),this.iushrn(e,t,r)},o.prototype.shln=function(e){return this.clone().ishln(e)},o.prototype.ushln=function(e){return this.clone().iushln(e)},o.prototype.shrn=function(e){return this.clone().ishrn(e)},o.prototype.ushrn=function(e){return this.clone().iushrn(e)},o.prototype.testn=function(e){n("number"==typeof e&&e>=0);var t=e%26,r=(e-t)/26,o=1<<t;return this.length<=r?0:!!(this.words[r]&o)},o.prototype.imaskn=function(e){n("number"==typeof e&&e>=0);var t=e%26,r=(e-t)/26;if(n(0===this.negative,"imaskn works only with positive numbers"),this.length<=r)return this;if(0!==t&&r++,this.length=Math.min(r,this.length),0!==t){var o=67108863^67108863>>>t<<t;this.words[this.length-1]&=o}return this._strip()},o.prototype.maskn=function(e){return this.clone().imaskn(e)},o.prototype.iaddn=function(e){return n("number"==typeof e),n(e<67108864),e<0?this.isubn(-e):0!==this.negative?1===this.length&&(0|this.words[0])<=e?(this.words[0]=e-(0|this.words[0]),this.negative=0,this):(this.negative=0,this.isubn(e),this.negative=1,this):this._iaddn(e)},o.prototype._iaddn=function(e){this.words[0]+=e;for(var t=0;t<this.length&&this.words[t]>=67108864;t++)this.words[t]-=67108864,t===this.length-1?this.words[t+1]=1:this.words[t+1]++;return this.length=Math.max(this.length,t+1),this},o.prototype.isubn=function(e){if(n("number"==typeof e),n(e<67108864),e<0)return this.iaddn(-e);if(0!==this.negative)return this.negative=0,this.iaddn(e),this.negative=1,this;if(this.words[0]-=e,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var t=0;t<this.length&&this.words[t]<0;t++)this.words[t]+=67108864,this.words[t+1]-=1;return this._strip()},o.prototype.addn=function(e){return this.clone().iaddn(e)},o.prototype.subn=function(e){return this.clone().isubn(e)},o.prototype.iabs=function(){return this.negative=0,this},o.prototype.abs=function(){return this.clone().iabs()},o.prototype._ishlnsubmul=function(e,t,r){var o,i,s=e.length+r;this._expand(s);var a=0;for(o=0;o<e.length;o++){i=(0|this.words[o+r])+a;var u=(0|e.words[o])*t;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(e,t){var n=(this.length,e.length),r=this.clone(),i=e,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"!==t){(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"!==t&&0!==n&&r.iushrn(n),{div:a||null,mod:r}},o.prototype.divmod=function(e,t,r){return n(!e.isZero()),this.isZero()?{div:new o(0),mod:new o(0)}:0!==this.negative&&0===e.negative?(a=this.neg().divmod(e,t),"mod"!==t&&(i=a.div.neg()),"div"!==t&&(s=a.mod.neg(),r&&0!==s.negative&&s.iadd(e)),{div:i,mod:s}):0===this.negative&&0!==e.negative?(a=this.divmod(e.neg(),t),"mod"!==t&&(i=a.div.neg()),{div:i,mod:a.mod}):0!=(this.negative&e.negative)?(a=this.neg().divmod(e.neg(),t),"div"!==t&&(s=a.mod.neg(),r&&0!==s.negative&&s.isub(e)),{div:a.div,mod:s}):e.length>this.length||this.cmp(e)<0?{div:new o(0),mod:this}:1===e.length?"div"===t?{div:this.divn(e.words[0]),mod:null}:"mod"===t?{div:null,mod:new o(this.modrn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new o(this.modrn(e.words[0]))}:this._wordDiv(e,t);var i,s,a},o.prototype.div=function(e){return this.divmod(e,"div",0).div},o.prototype.mod=function(e){return this.divmod(e,"mod",0).mod},o.prototype.umod=function(e){return this.divmod(e,"mod",1).mod},o.prototype.divRound=function(e){var t=this.divmod(e);if(t.mod.isZero())return t.div;var n=0!==t.div.negative?t.mod.isub(e):t.mod,r=e.ushrn(1),o=e.andln(1),i=n.cmp(r);return i<0||1===o&&0===i?t.div:0!==t.div.negative?t.div.isubn(1):t.div.iaddn(1)},o.prototype.modrn=function(e){var t=e<0;t&&(e=-e),n(e<=67108863);for(var r=(1<<26)%e,o=0,i=this.length-1;i>=0;i--)o=(r*o+(0|this.words[i]))%e;return t?-o:o},o.prototype.modn=function(e){return this.modrn(e)},o.prototype.idivn=function(e){var t=e<0;t&&(e=-e),n(e<=67108863);for(var r=0,o=this.length-1;o>=0;o--){var i=(0|this.words[o])+67108864*r;this.words[o]=i/e|0,r=i%e}return this._strip(),t?this.ineg():this},o.prototype.divn=function(e){return this.clone().idivn(e)},o.prototype.egcd=function(e){n(0===e.negative),n(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var i=new o(1),s=new o(0),a=new o(0),u=new o(1),c=0;t.isEven()&&r.isEven();)t.iushrn(1),r.iushrn(1),++c;for(var l=r.clone(),d=t.clone();!t.isZero();){for(var p=0,h=1;0==(t.words[0]&h)&&p<26;++p,h<<=1);if(p>0)for(t.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);t.cmp(r)>=0?(t.isub(r),i.isub(a),s.isub(u)):(r.isub(t),a.isub(i),u.isub(s))}return{a:a,b:u,gcd:r.iushln(c)}},o.prototype._invmp=function(e){n(0===e.negative),n(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var i,s=new o(1),a=new o(0),u=r.clone();t.cmpn(1)>0&&r.cmpn(1)>0;){for(var c=0,l=1;0==(t.words[0]&l)&&c<26;++c,l<<=1);if(c>0)for(t.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);t.cmp(r)>=0?(t.isub(r),s.isub(a)):(r.isub(t),a.isub(s))}return(i=0===t.cmpn(1)?s:a).cmpn(0)<0&&i.iadd(e),i},o.prototype.gcd=function(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var t=this.clone(),n=e.clone();t.negative=0,n.negative=0;for(var r=0;t.isEven()&&n.isEven();r++)t.iushrn(1),n.iushrn(1);for(;;){for(;t.isEven();)t.iushrn(1);for(;n.isEven();)n.iushrn(1);var o=t.cmp(n);if(o<0){var i=t;t=n,n=i}else if(0===o||0===n.cmpn(1))break;t.isub(n)}return n.iushln(r)},o.prototype.invm=function(e){return this.egcd(e).a.umod(e)},o.prototype.isEven=function(){return 0==(1&this.words[0])},o.prototype.isOdd=function(){return 1==(1&this.words[0])},o.prototype.andln=function(e){return this.words[0]&e},o.prototype.bincn=function(e){n("number"==typeof e);var t=e%26,r=(e-t)/26,o=1<<t;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(e){var t,r=e<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this._strip(),this.length>1)t=1;else{r&&(e=-e),n(e<=67108863,"Number is too big");var o=0|this.words[0];t=o===e?0:o<e?-1:1}return 0!==this.negative?0|-t:t},o.prototype.cmp=function(e){if(0!==this.negative&&0===e.negative)return-1;if(0===this.negative&&0!==e.negative)return 1;var t=this.ucmp(e);return 0!==this.negative?0|-t:t},o.prototype.ucmp=function(e){if(this.length>e.length)return 1;if(this.length<e.length)return-1;for(var t=0,n=this.length-1;n>=0;n--){var r=0|this.words[n],o=0|e.words[n];if(r!==o){r<o?t=-1:r>o&&(t=1);break}}return t},o.prototype.gtn=function(e){return 1===this.cmpn(e)},o.prototype.gt=function(e){return 1===this.cmp(e)},o.prototype.gten=function(e){return this.cmpn(e)>=0},o.prototype.gte=function(e){return this.cmp(e)>=0},o.prototype.ltn=function(e){return-1===this.cmpn(e)},o.prototype.lt=function(e){return-1===this.cmp(e)},o.prototype.lten=function(e){return this.cmpn(e)<=0},o.prototype.lte=function(e){return this.cmp(e)<=0},o.prototype.eqn=function(e){return 0===this.cmpn(e)},o.prototype.eq=function(e){return 0===this.cmp(e)},o.red=function(e){return new P(e)},o.prototype.toRed=function(e){return n(!this.red,"Already a number in reduction context"),n(0===this.negative,"red works only with positives"),e.convertTo(this)._forceRed(e)},o.prototype.fromRed=function(){return n(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},o.prototype._forceRed=function(e){return this.red=e,this},o.prototype.forceRed=function(e){return n(!this.red,"Already a number in reduction context"),this._forceRed(e)},o.prototype.redAdd=function(e){return n(this.red,"redAdd works only with red numbers"),this.red.add(this,e)},o.prototype.redIAdd=function(e){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)},o.prototype.redSub=function(e){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,e)},o.prototype.redISub=function(e){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,e)},o.prototype.redShl=function(e){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,e)},o.prototype.redMul=function(e){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.mul(this,e)},o.prototype.redIMul=function(e){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.imul(this,e)},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(e){return n(this.red&&!e.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,e)};var w={k256:null,p224:null,p192:null,p25519:null};function b(e,t){this.name=e,this.p=new o(t,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(e){if("string"==typeof e){var t=o._prime(e);this.m=t.p,this.prime=t}else n(e.gtn(1),"modulus must be greater than 1"),this.m=e,this.prime=null}function A(e){P.call(this,e),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 e=new o(null);return e.words=new Array(Math.ceil(this.n/13)),e},b.prototype.ireduce=function(e){var t,n=e;do{this.split(n,this.tmp),t=(n=(n=this.imulK(n)).iadd(this.tmp)).bitLength()}while(t>this.n);var r=t<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(e,t){e.iushrn(this.n,0,t)},b.prototype.imulK=function(e){return e.imul(this.k)},r(k,b),k.prototype.split=function(e,t){for(var n=4194303,r=Math.min(e.length,9),o=0;o<r;o++)t.words[o]=e.words[o];if(t.length=r,e.length<=9)return e.words[0]=0,void(e.length=1);var i=e.words[9];for(t.words[t.length++]=i&n,o=10;o<e.length;o++){var s=0|e.words[o];e.words[o-10]=(s&n)<<4|i>>>22,i=s}i>>>=22,e.words[o-10]=i,0===i&&e.length>10?e.length-=10:e.length-=9},k.prototype.imulK=function(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var t=0,n=0;n<e.length;n++){var r=0|e.words[n];t+=977*r,e.words[n]=67108863&t,t=64*r+(t/67108864|0)}return 0===e.words[e.length-1]&&(e.length--,0===e.words[e.length-1]&&e.length--),e},r(v,b),r(I,b),r(M,b),M.prototype.imulK=function(e){for(var t=0,n=0;n<e.length;n++){var r=19*(0|e.words[n])+t,o=67108863&r;r>>>=26,e.words[n]=o,t=r}return 0!==t&&(e.words[e.length++]=t),e},o._prime=function(e){if(w[e])return w[e];var t;if("k256"===e)t=new k;else if("p224"===e)t=new v;else if("p192"===e)t=new I;else{if("p25519"!==e)throw new Error("Unknown prime "+e);t=new M}return w[e]=t,t},P.prototype._verify1=function(e){n(0===e.negative,"red works only with positives"),n(e.red,"red works only with red numbers")},P.prototype._verify2=function(e,t){n(0==(e.negative|t.negative),"red works only with positives"),n(e.red&&e.red===t.red,"red works only with red numbers")},P.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):(c(e,e.umod(this.m)._forceRed(this)),e)},P.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},P.prototype.add=function(e,t){this._verify2(e,t);var n=e.add(t);return n.cmp(this.m)>=0&&n.isub(this.m),n._forceRed(this)},P.prototype.iadd=function(e,t){this._verify2(e,t);var n=e.iadd(t);return n.cmp(this.m)>=0&&n.isub(this.m),n},P.prototype.sub=function(e,t){this._verify2(e,t);var n=e.sub(t);return n.cmpn(0)<0&&n.iadd(this.m),n._forceRed(this)},P.prototype.isub=function(e,t){this._verify2(e,t);var n=e.isub(t);return n.cmpn(0)<0&&n.iadd(this.m),n},P.prototype.shl=function(e,t){return this._verify1(e),this.imod(e.ushln(t))},P.prototype.imul=function(e,t){return this._verify2(e,t),this.imod(e.imul(t))},P.prototype.mul=function(e,t){return this._verify2(e,t),this.imod(e.mul(t))},P.prototype.isqr=function(e){return this.imul(e,e.clone())},P.prototype.sqr=function(e){return this.mul(e,e)},P.prototype.sqrt=function(e){if(e.isZero())return e.clone();var t=this.m.andln(3);if(n(t%2==1),3===t){var r=this.m.add(new o(1)).iushrn(2);return this.pow(e,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(e,i.addn(1).iushrn(1)),h=this.pow(e,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(e){var t=e._invmp(this.m);return 0!==t.negative?(t.negative=0,this.imod(t).redNeg()):this.imod(t)},P.prototype.pow=function(e,t){if(t.isZero())return new o(1).toRed(this);if(0===t.cmpn(1))return e.clone();var n=new Array(16);n[0]=new o(1).toRed(this),n[1]=e;for(var r=2;r<n.length;r++)n[r]=this.mul(n[r-1],e);var i=n[0],s=0,a=0,u=t.bitLength()%26;for(0===u&&(u=26),r=t.length-1;r>=0;r--){for(var c=t.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(e){var t=e.umod(this.m);return t===e?t.clone():t},P.prototype.convertFrom=function(e){var t=e.clone();return t.red=null,t},o.mont=function(e){return new A(e)},r(A,P),A.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},A.prototype.convertFrom=function(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},A.prototype.imul=function(e,t){if(e.isZero()||t.isZero())return e.words[0]=0,e.length=1,e;var n=e.imul(t),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(e,t){if(e.isZero()||t.isZero())return new o(0)._forceRed(this);var n=e.mul(t),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(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}}(0,no);var ao=ro(io.exports);const uo={Spl:"spl",Token2022:"token2022",SplCold:"spl-cold",Token2022Cold:"token2022-cold",CTokenHot:"ctoken-hot",CTokenCold:"ctoken-cold"};function co(e){if(!e||0===e.length)return null;try{let t=0;const n=new P(e.slice(t,t+32));t+=32;const r=new P(e.slice(t,t+32));t+=32;const o=new ao(e.slice(t,t+8),"le");t+=8;const i=e[t];t+=1;const s=i?new P(e.slice(t,t+32)):null;t+=32;const a=e[t];t+=1;const u=e[t];return t+=1,{mint:n,owner:r,amount:o,delegate:s,state:a,tlv:u?e.slice(t):null}}catch(e){return console.error("Token data parsing error:",e),null}}function lo(e,t){return{address:e,mint:t.mint,owner:t.owner,amount:BigInt(t.amount.toString()),delegate:t.delegate,delegatedAmount:BigInt(0),isInitialized:t.state!==N.Uninitialized,isFrozen:t.state===N.Frozen,isNative:0,rentExemptReserve:null,closeAuthority:null,tlvData:t.tlv?xe.from(t.tlv):xe.alloc(0)}}function po(e){const t=xe.from(e.data.discriminator),n=xe.from(e.data.data),r=xe.concat([t,n]);return{executable:0,owner:e.owner,lamports:e.lamports.toNumber(),data:r,rentEpoch:void 0}}function ho(e,t){const n=co(t.data);if(!n)throw new Error("Invalid token data");return{accountInfo:t,loadContext:void 0,parsed:lo(e,n),isCold:0}}function mo(e,t){const n=co(t.data.data);if(!n)throw new Error("Invalid token data");return{accountInfo:po(t),loadContext:{treeInfo:t.treeInfo,hash:t.hash,leafIndex:t.leafIndex,proveByIndex:t.proveByIndex},parsed:lo(e,n),isCold:1}}async function fo(e,t,n,r){return go(e,t,n,r,void 0)}async function yo(e,t,n,r,o,i,s=0,a=0){const u=Cr(t,r,n,i,a);if(s&&"ctoken"!==u.type)throw new Error(`For wrap=true, ata must be the c-token ATA. Got ${u.type} ATA instead.`);const c=await go(e,t,o,i,{owner:n,mint:r},s);return c._isAta=1,c._owner=n,c._mint=r,c}async function go(t,n,r,o,i,s=0){if(!n&&!i)throw new Error("One of address or fetchByOwner is required");if(!o)return async function(t,n,r,o,i){const s=n??q(o.mint,o.owner,0,h,Sr(h)),a=[],u=[],c=[];if(a.push(async function(e,t,n){const r=await e.getAccountInfo(t,n);if(!r||!r.owner.equals(h))throw new Error("Not a CTOKEN onchain account");return ho(t,r)}(t,s,r)),u.push(uo.CTokenHot),c.push(s),a.push(o?async function(e,t,n,r){const o=await e.getCompressedTokenAccountsByOwner(t,{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 mo(r,i)}(t,o.owner,o.mint,s):async function(t,n){const r=f().tree,o=p(n.toBytes(),r,h),i=await t.getCompressedAccount(e(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 mo(n,i)}(t,n)),u.push(uo.CTokenCold),c.push(s),i){if(!o)throw new Error("fetchByOwner is required for wrap=true to derive SPL/T22 addresses");const e=q(o.mint,o.owner,0,W,Sr(W)),n=q(o.mint,o.owner,0,O,Sr(O));a.push(async function(e,t,n){const r=await e.getAccountInfo(t,n);if(!r||!r.owner.equals(W))throw new Error("Not a TOKEN_PROGRAM_ID account");return{accountInfo:r,parsed:_(t,r,W),isCold:0,loadContext:void 0}}(t,e,r)),u.push(uo.Spl),c.push(e),a.push(async function(e,t,n){const r=await e.getAccountInfo(t,n);if(!r||!r.owner.equals(O))throw new Error("Not a TOKEN_2022_PROGRAM_ID account");return{accountInfo:r,parsed:_(t,r,O),isCold:0,loadContext:void 0}}(t,n,r)),u.push(uo.Token2022),c.push(n)}const l=await Promise.allSettled(a),d=[];for(let e=0;e<l.length;e++){const t=l[e];if("fulfilled"===t.status){const n=t.value;d.push({type:u[e],address:c[e],amount:n.parsed.amount,accountInfo:n.accountInfo,loadContext:n.loadContext,parsed:n.parsed})}}if(0===d.length)throw new F;const m=[uo.CTokenHot,uo.CTokenCold,uo.Spl,uo.Token2022];return d.sort(((e,t)=>m.indexOf(e.type)-m.indexOf(t.type))),wo(d,s)}(t,n,r,i,s);if(o.equals(h))return async function(e,t,n,r){if(!t){if(!r)throw new Error("fetchByOwner is required");t=q(r.mint,r.owner,0,h,Sr(h))}const[o,i]=await Promise.allSettled([e.getAccountInfo(t,n),r?e.getCompressedTokenAccountsByOwner(r.owner,{mint:r.mint}):e.getCompressedTokenAccountsByOwner(t)]),s="fulfilled"===o.status?o.value:null,a="fulfilled"===i.status?i.value.items.map((e=>e.compressedAccount)):[],u=[];if(s&&s.owner.equals(h)){const e=ho(t,s);u.push({type:uo.CTokenHot,address:t,amount:e.parsed.amount,accountInfo:s,parsed:e.parsed})}for(const e of a)if(e&&e.data&&e.data.data.length>0&&e.owner.equals(h)){const n=mo(t,e);u.push({type:uo.CTokenCold,address:t,amount:n.parsed.amount,accountInfo:n.accountInfo,loadContext:n.loadContext,parsed:n.parsed})}if(0===u.length)throw new F;return u.sort(((e,t)=>"ctoken-hot"===e.type&&"ctoken-cold"===t.type?-1:"ctoken-cold"===e.type&&"ctoken-hot"===t.type?1:0)),wo(u,t)}(t,n,r,i);if(o.equals(W)||o.equals(O))return async function(e,t,n,r,o){if(!t){if(!o)throw new Error("fetchByOwner is required");t=q(o.mint,o.owner,0,r,Sr(r))}const i=await e.getAccountInfo(t,n);if(!i)throw new F;const s=_(t,i,r),a=[{type:r.equals(W)?uo.Spl:uo.Token2022,address:t,amount:s.amount,accountInfo:i,parsed:s}];if(o){const n=(await e.getCompressedTokenAccountsByOwner(o.owner,{mint:o.mint})).items.map((e=>e.compressedAccount)),i=r.equals(W)?uo.SplCold:uo.Token2022Cold;for(const e of n)if(e&&e.data&&e.data.data.length>0&&e.owner.equals(h)){const n=mo(t,e);a.push({type:i,address:t,amount:n.parsed.amount,accountInfo:n.accountInfo,loadContext:n.loadContext,parsed:n.parsed})}}return wo(a,t)}(t,n,r,o,i);throw new Error(`Unsupported program ID: ${o.toBase58()}`)}function wo(e,t){const n=e.reduce(((e,t)=>e+t.amount),BigInt(0)),r=e[0],o=e.some((e=>null!==e.parsed.delegate)),i=e.some((e=>e.parsed.isFrozen)),s=e.length>1,a={...r.parsed,address:t,amount:n};return{accountInfo:r.accountInfo,parsed:a,isCold:["ctoken-cold","spl-cold","token2022-cold"].includes(r.type),loadContext:r.loadContext,_sources:e,_needsConsolidation:s,_hasDelegate:o,_anyFrozen:i}}function bo(e,t,n=0,r=h,o){const i=o??Sr(r);return q(e,t,n,r,i)}function ko(e,t,n,r,o,i,s=n){const a=Hr({withTransactionHash:0,withLamportsChangeAccountMerkleTreeIndex:0,lamportsChangeAccountMerkleTreeIndex:0,lamportsChangeAccountOwnerIndex:0,outputQueue:0,maxTopUp:0,cpiContext:null,compressions:[Gr(o,0,2,1,4,i.poolIndex,i.bump),Qr(o,0,3,6)],proof:null,inTokenData:[],outTokenData:[],inLamports:null,outLamports:null,inTlv:null,outTlv:null}),u=[{pubkey:Ln.deriveCpiAuthorityPda,isSigner:0,isWritable:0},{pubkey:s,isSigner:1,isWritable:1},{pubkey:r,isSigner:0,isWritable:0},{pubkey:n,isSigner:1,isWritable:0},{pubkey:e,isSigner:0,isWritable:1},{pubkey:t,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:Ln.programId,keys:u,data:a})}function vo(t){const n=new Set([uo.CTokenCold,uo.SplCold,uo.Token2022Cold]);return t.filter((e=>void 0!==e.loadContext)).filter((e=>n.has(e.type))).map((t=>{const n=t.accountInfo.data,r=n.subarray(0,Math.min(8,n.length)),o=n.length>8?n.subarray(8):Buffer.alloc(0),i={treeInfo:t.loadContext.treeInfo,hash:t.loadContext.hash,leafIndex:t.loadContext.leafIndex,proveByIndex:t.loadContext.proveByIndex,owner:t.accountInfo.owner,lamports:e(t.accountInfo.lamports),address:null,data:0===n.length?null:{discriminator:Array.from(r),data:Buffer.from(o),dataHash:new Array(32).fill(0)},readOnly:0},s=t.parsed.isInitialized?t.parsed.isFrozen?2:1:0;return{compressedAccount:i,parsed:{mint:t.parsed.mint,owner:t.parsed.owner,amount:e(t.parsed.amount.toString()),delegate:t.parsed.delegate,state:s,tlv:t.parsed.tlvData.length>0?t.parsed.tlvData:null}}}))}async function Io(e,t,n,r,o,i,s=0){o??=n;try{return Mo(e,o,await yo(e,t,n,r,void 0,void 0,s),i,s,t)}catch(e){if(e instanceof F)return[];throw e}}async function Mo(e,t,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=bo(u,a),d=q(u,a,0,W,Sr(W)),p=q(u,a,0,O,Sr(O));let m="ctoken";if(i&&(m=Cr(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((e=>"spl"===e.type)),y=c.find((e=>"token2022"===e.type)),g=c.find((e=>"ctoken-hot"===e.type)),w=c.find((e=>"ctoken-cold"===e.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 Ct(e,u)).find((e=>e.isInitialized))}catch{}if(o){if(g||s.push(Br(t,l,a,u,h)),b>BigInt(0)&&I&&s.push(ko(d,l,a,u,b,I,t)),k>BigInt(0)&&I&&s.push(ko(p,l,a,u,k,I,t)),v>BigInt(0)&&w){const n=vo(c);if(n.length>0){const r=await e.getValidityProofV0(n.map((e=>({hash:e.compressedAccount.hash,tree:e.compressedAccount.treeInfo.tree,queue:e.compressedAccount.treeInfo.queue}))));s.push(to(t,n,l,v,r))}}}else if(v>BigInt(0)&&w){const n=vo(c);if(n.length>0){const r=await e.getValidityProofV0(n.map((e=>({hash:e.compressedAccount.hash,tree:e.compressedAccount.treeInfo.tree,queue:e.compressedAccount.treeInfo.queue}))));"ctoken"===m?(g||s.push(Br(t,l,a,u,h)),s.push(to(t,n,l,v,r))):"spl"===m&&I?(f||s.push(z(t,d,a,u,W)),s.push(to(t,n,d,v,r,I))):"token2022"===m&&I&&(y||s.push(z(t,p,a,u,O)),s.push(to(t,n,p,v,r,I)))}}return s}async function Po(e,t,n,r,o,i,s,a=0){o??=n;const u=await Io(e,t,n.publicKey,r,o.publicKey,s,a);if(0===u.length)return null;const{blockhash:c}=await e.getLatestBlockhash(),l=g(o,[n]),d=w([C.setComputeUnitLimit({units:5e5}),...u],o,c,l);return b(e,d,i)}async function Ao(e,t,n,r=[],o=[],i){let s=null;const a=r.filter((e=>void 0!==e.info.loadContext));if(a.length>0){const t=a.map((e=>({hash:e.info.loadContext.hash,tree:e.info.loadContext.treeInfo.tree,queue:e.info.loadContext.treeInfo.queue}))),r=await e.getValidityProofV0(t,[]),o=a.map((e=>{if("cTokenData"===e.accountType){if(!e.tokenVariant)throw new Error('tokenVariant is required when accountType is "cTokenData"');return{key:"cTokenData",data:{variant:{[e.tokenVariant]:{}},tokenData:e.info.parsed},treeInfo:e.info.loadContext.treeInfo}}return{key:e.accountType,data:e.info.parsed,treeInfo:e.info.loadContext.treeInfo}})),i=a.map((e=>e.address)),u=a.map((e=>e.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 Mo(e,t,n,i);u.push(...r)}return{decompressParams:s,ataInstructions:u}}function xo(e,t){let n=5e4;return t&&(n+=1e5),n+=3e4*e,n}async function So(e,t,n,r,o=T.generate(),i,s,a){const u=await e.getMinimumBalanceForRentExemption(D),c=1==s?O:s||W,l=await Ln.createMint({feePayer:t.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 e.getLatestBlockhash(),p=g(t,[n,a??null].filter((e=>null!=e&&"secretKey"in e))),h=w(l,t,d,[...p,o]),m=await b(e,h,i);return{mint:o.publicKey,transactionSignature:m}}async function Co(e,t,n,r,o,i=T.generate(),s,a=h,u,c,l){if(a.equals(W)||a.equals(O))return So(e,t,n,o,i,s,a,r);if(!("secretKey"in n))throw new Error("mintAuthority must be a Signer for compressed token mints");if(l&&!l.tree.equals(f().tree))throw new Error(`addressTreeInfo ${l?.tree.toString()} must be the default address tree info: ${f().tree.toString()}`);const d=r&&"secretKey"in r?r.publicKey:r;l=l??v(),c=c??I(await e.getStateTreeInfos());const p=Un(i.publicKey,l),m=await e.getValidityProofV2([],[{address:Uint8Array.from(p),treeInfo:l}],M.standard),y=lr(i.publicKey,o,n.publicKey,d,t.publicKey,m,l,c,u),k=g(t,[i,n]),{blockhash:P}=await e.getLatestBlockhash(),A=w([C.setComputeUnitLimit({units:5e5}),y],t,P,k),x=await b(e,A);return console.log("txId",x),{mint:On(i.publicKey)[0],transactionSignature:x}}var To={};Object.defineProperty(To,"__esModule",{value:1}),To.s16=To.s8=To.nu64be=To.u48be=To.u40be=To.u32be=To.u24be=To.u16be=To.nu64=To.u48=To.u40=To.u32=To.u24=To.u16=hi=To.u8=To.offset=To.greedy=To.Constant=To.UTF8=To.CString=To.Blob=To.Boolean=To.BitField=To.BitStructure=To.VariantLayout=To.Union=To.UnionLayoutDiscriminator=To.UnionDiscriminator=To.Structure=To.Sequence=To.DoubleBE=To.Double=To.FloatBE=To.Float=To.NearInt64BE=To.NearInt64=To.NearUInt64BE=To.NearUInt64=To.IntBE=To.Int=To.UIntBE=To.UInt=To.OffsetLayout=To.GreedyCount=To.ExternalLayout=To.bindConstructorLayout=To.nameWithProperty=To.Layout=To.uint8ArrayToBuffer=To.checkUint8Array=void 0,To.constant=To.utf8=To.cstr=fi=To.blob=To.unionLayoutDiscriminator=To.union=To.seq=To.bits=mi=To.struct=To.f64be=To.f64=To.f32be=To.f32=To.ns64be=To.s48be=To.s40be=To.s32be=To.s24be=To.s16be=To.ns64=To.s48=To.s40=To.s32=To.s24=void 0;const Eo=so;function Bo(e){if(!(e instanceof Uint8Array))throw new TypeError("b must be a Uint8Array")}function _o(e){return Bo(e),Eo.Buffer.from(e.buffer,e.byteOffset,e.length)}To.checkUint8Array=Bo,To.uint8ArrayToBuffer=_o;class Do{constructor(e,t){if(!Number.isInteger(e))throw new TypeError("span must be an integer");this.span=e,this.property=t}makeDestinationObject(){return{}}getSpan(e,t){if(0>this.span)throw new RangeError("indeterminate span");return this.span}replicate(e){const t=Object.create(this.constructor.prototype);return Object.assign(t,this),t.property=e,t}fromArray(e){}}function Lo(e,t){return t.property?e+"["+t.property+"]":e}To.Layout=Do,To.nameWithProperty=Lo,To.bindConstructorLayout=function(e,t){if("function"!=typeof e)throw new TypeError("Class must be constructor");if(Object.prototype.hasOwnProperty.call(e,"layout_"))throw new Error("Class is already bound to a layout");if(!(t&&t instanceof Do))throw new TypeError("layout must be a Layout");if(Object.prototype.hasOwnProperty.call(t,"boundConstructor_"))throw new Error("layout is already bound to a constructor");e.layout_=t,t.boundConstructor_=e,t.makeDestinationObject=()=>new e,Object.defineProperty(e.prototype,"encode",{value(e,n){return t.encode(this,e,n)},writable:1}),Object.defineProperty(e,"decode",{value:(e,n)=>t.decode(e,n),writable:1})};class Uo extends Do{isCount(){throw new Error("ExternalLayout is abstract")}}To.ExternalLayout=Uo;class Wo extends Uo{constructor(e=1,t){if(!Number.isInteger(e)||0>=e)throw new TypeError("elementSpan must be a (positive) integer");super(-1,t),this.elementSpan=e}isCount(){return 1}decode(e,t=0){Bo(e);const n=e.length-t;return Math.floor(n/this.elementSpan)}encode(e,t,n){return 0}}To.GreedyCount=Wo;class Oo extends Uo{constructor(e,t=0,n){if(!(e instanceof Do))throw new TypeError("layout must be a Layout");if(!Number.isInteger(t))throw new TypeError("offset must be integer or undefined");super(e.span,n||e.property),this.layout=e,this.offset=t}isCount(){return this.layout instanceof Ro||this.layout instanceof qo}decode(e,t=0){return this.layout.decode(e,t+this.offset)}encode(e,t,n=0){return this.layout.encode(e,t,n+this.offset)}}To.OffsetLayout=Oo;class Ro extends Do{constructor(e,t){if(super(e,t),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(e,t=0){return _o(e).readUIntLE(t,this.span)}encode(e,t,n=0){return _o(t).writeUIntLE(e,n,this.span),this.span}}To.UInt=Ro;class qo extends Do{constructor(e,t){if(super(e,t),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(e,t=0){return _o(e).readUIntBE(t,this.span)}encode(e,t,n=0){return _o(t).writeUIntBE(e,n,this.span),this.span}}To.UIntBE=qo;class Ko extends Do{constructor(e,t){if(super(e,t),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(e,t=0){return _o(e).readIntLE(t,this.span)}encode(e,t,n=0){return _o(t).writeIntLE(e,n,this.span),this.span}}To.Int=Ko;class zo extends Do{constructor(e,t){if(super(e,t),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(e,t=0){return _o(e).readIntBE(t,this.span)}encode(e,t,n=0){return _o(t).writeIntBE(e,n,this.span),this.span}}To.IntBE=zo;const Vo=Math.pow(2,32);function No(e){const t=Math.floor(e/Vo);return{hi32:t,lo32:e-t*Vo}}function Fo(e,t){return e*Vo+t}class $o extends Do{constructor(e){super(8,e)}decode(e,t=0){const n=_o(e),r=n.readUInt32LE(t);return Fo(n.readUInt32LE(t+4),r)}encode(e,t,n=0){const r=No(e),o=_o(t);return o.writeUInt32LE(r.lo32,n),o.writeUInt32LE(r.hi32,n+4),8}}To.NearUInt64=$o;class Yo extends Do{constructor(e){super(8,e)}decode(e,t=0){const n=_o(e);return Fo(n.readUInt32BE(t),n.readUInt32BE(t+4))}encode(e,t,n=0){const r=No(e),o=_o(t);return o.writeUInt32BE(r.hi32,n),o.writeUInt32BE(r.lo32,n+4),8}}To.NearUInt64BE=Yo;class jo extends Do{constructor(e){super(8,e)}decode(e,t=0){const n=_o(e),r=n.readUInt32LE(t);return Fo(n.readInt32LE(t+4),r)}encode(e,t,n=0){const r=No(e),o=_o(t);return o.writeUInt32LE(r.lo32,n),o.writeInt32LE(r.hi32,n+4),8}}To.NearInt64=jo;class Zo extends Do{constructor(e){super(8,e)}decode(e,t=0){const n=_o(e);return Fo(n.readInt32BE(t),n.readUInt32BE(t+4))}encode(e,t,n=0){const r=No(e),o=_o(t);return o.writeInt32BE(r.hi32,n),o.writeUInt32BE(r.lo32,n+4),8}}To.NearInt64BE=Zo;class Ho extends Do{constructor(e){super(4,e)}decode(e,t=0){return _o(e).readFloatLE(t)}encode(e,t,n=0){return _o(t).writeFloatLE(e,n),4}}To.Float=Ho;class Go extends Do{constructor(e){super(4,e)}decode(e,t=0){return _o(e).readFloatBE(t)}encode(e,t,n=0){return _o(t).writeFloatBE(e,n),4}}To.FloatBE=Go;class Qo extends Do{constructor(e){super(8,e)}decode(e,t=0){return _o(e).readDoubleLE(t)}encode(e,t,n=0){return _o(t).writeDoubleLE(e,n),8}}To.Double=Qo;class Jo extends Do{constructor(e){super(8,e)}decode(e,t=0){return _o(e).readDoubleBE(t)}encode(e,t,n=0){return _o(t).writeDoubleBE(e,n),8}}To.DoubleBE=Jo;class Xo extends Do{constructor(e,t,n){if(!(e instanceof Do))throw new TypeError("elementLayout must be a Layout");if(!(t instanceof Uo&&t.isCount()||Number.isInteger(t)&&0<=t))throw new TypeError("count must be non-negative integer or an unsigned integer ExternalLayout");let r=-1;!(t instanceof Uo)&&0<e.span&&(r=t*e.span),super(r,n),this.elementLayout=e,this.count=t}getSpan(e,t=0){if(0<=this.span)return this.span;let n=0,r=this.count;if(r instanceof Uo&&(r=r.decode(e,t)),0<this.elementLayout.span)n=r*this.elementLayout.span;else{let o=0;for(;o<r;)n+=this.elementLayout.getSpan(e,t+n),++o}return n}decode(e,t=0){const n=[];let r=0,o=this.count;for(o instanceof Uo&&(o=o.decode(e,t));r<o;)n.push(this.elementLayout.decode(e,t)),t+=this.elementLayout.getSpan(e,t),r+=1;return n}encode(e,t,n=0){const r=this.elementLayout,o=e.reduce(((e,o)=>e+r.encode(o,t,n+e)),0);return this.count instanceof Uo&&this.count.encode(e.length,t,n),o}}To.Sequence=Xo;class ei extends Do{constructor(e,t,n){if(!Array.isArray(e)||!e.reduce(((e,t)=>e&&t instanceof Do),1))throw new TypeError("fields must be array of Layout instances");"boolean"==typeof t&&void 0===n&&(n=t,t=void 0);for(const t of e)if(0>t.span&&void 0===t.property)throw new Error("fields cannot contain unnamed variable-length layout");let r=-1;try{r=e.reduce(((e,t)=>e+t.getSpan()),0)}catch(e){}super(r,t),this.fields=e,this.decodePrefixes=!!n}getSpan(e,t=0){if(0<=this.span)return this.span;let n=0;try{n=this.fields.reduce(((n,r)=>{const o=r.getSpan(e,t);return t+=o,n+o}),0)}catch(e){throw new RangeError("indeterminate span")}return n}decode(e,t=0){Bo(e);const n=this.makeDestinationObject();for(const r of this.fields)if(void 0!==r.property&&(n[r.property]=r.decode(e,t)),t+=r.getSpan(e,t),this.decodePrefixes&&e.length===t)break;return n}encode(e,t,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=e[r.property];void 0!==o&&(i=r.encode(o,t,n),0>s&&(s=r.getSpan(t,n)))}o=n,n+=s}return o+i-r}fromArray(e){const t=this.makeDestinationObject();for(const n of this.fields)void 0!==n.property&&0<e.length&&(t[n.property]=e.shift());return t}layoutFor(e){if("string"!=typeof e)throw new TypeError("property must be string");for(const t of this.fields)if(t.property===e)return t}offsetOf(e){if("string"!=typeof e)throw new TypeError("property must be string");let t=0;for(const n of this.fields){if(n.property===e)return t;0>n.span?t=-1:0<=t&&(t+=n.span)}}}To.Structure=ei;class ti{constructor(e){this.property=e}decode(e,t){throw new Error("UnionDiscriminator is abstract")}encode(e,t,n){throw new Error("UnionDiscriminator is abstract")}}To.UnionDiscriminator=ti;class ni extends ti{constructor(e,t){if(!(e instanceof Uo&&e.isCount()))throw new TypeError("layout must be an unsigned integer ExternalLayout");super(t||e.property||"variant"),this.layout=e}decode(e,t){return this.layout.decode(e,t)}encode(e,t,n){return this.layout.encode(e,t,n)}}To.UnionLayoutDiscriminator=ni;class ri extends Do{constructor(e,t,n){let r;if(e instanceof Ro||e instanceof qo)r=new ni(new Oo(e));else if(e instanceof Uo&&e.isCount())r=new ni(e);else{if(!(e instanceof ti))throw new TypeError("discr must be a UnionDiscriminator or an unsigned integer layout");r=e}if(void 0===t&&(t=null),!(null===t||t instanceof Do))throw new TypeError("defaultLayout must be null or a Layout");if(null!==t){if(0>t.span)throw new Error("defaultLayout must have constant span");void 0===t.property&&(t=t.replicate("content"))}let o=-1;t&&(o=t.span,0<=o&&(e instanceof Ro||e instanceof qo)&&(o+=r.layout.span)),super(o,n),this.discriminator=r,this.usesPrefixDiscriminator=e instanceof Ro||e instanceof qo,this.defaultLayout=t,this.registry={};let i=this.defaultGetSourceVariant.bind(this);this.getSourceVariant=function(e){return i(e)},this.configGetSourceVariant=function(e){i=e.bind(this)}}getSpan(e,t=0){if(0<=this.span)return this.span;const n=this.getVariant(e,t);if(!n)throw new Error("unable to determine span for unrecognized variant");return n.getSpan(e,t)}defaultGetSourceVariant(e){if(Object.prototype.hasOwnProperty.call(e,this.discriminator.property)){if(this.defaultLayout&&this.defaultLayout.property&&Object.prototype.hasOwnProperty.call(e,this.defaultLayout.property))return;const t=this.registry[e[this.discriminator.property]];if(t&&(!t.layout||t.property&&Object.prototype.hasOwnProperty.call(e,t.property)))return t}else for(const t in this.registry){const n=this.registry[t];if(n.property&&Object.prototype.hasOwnProperty.call(e,n.property))return n}throw new Error("unable to infer src variant")}decode(e,t=0){let n;const r=this.discriminator,o=r.decode(e,t),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(e,t+s)}else n=i.decode(e,t);return n}encode(e,t,n=0){const r=this.getSourceVariant(e);if(void 0===r){const r=this.discriminator,o=this.defaultLayout;let i=0;return this.usesPrefixDiscriminator&&(i=r.layout.span),r.encode(e[r.property],t,n),i+o.encode(e[o.property],t,n+i)}return r.encode(e,t,n)}addVariant(e,t,n){const r=new oi(this,e,t,n);return this.registry[e]=r,r}getVariant(e,t=0){let n;return n=e instanceof Uint8Array?this.discriminator.decode(e,t):e,this.registry[n]}}To.Union=ri;class oi extends Do{constructor(e,t,n,r){if(!(e instanceof ri))throw new TypeError("union must be a Union");if(!Number.isInteger(t)||0>t)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 Do))throw new TypeError("layout must be a Layout");if(null!==e.defaultLayout&&0<=n.span&&n.span>e.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=e.span;0>e.span&&(o=n?n.span:0,0<=o&&e.usesPrefixDiscriminator&&(o+=e.discriminator.layout.span)),super(o,r),this.union=e,this.variant=t,this.layout=n||null}getSpan(e,t=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(e,t+n)),n+r}decode(e,t=0){const n=this.makeDestinationObject();if(this!==this.union.getVariant(e,t))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(e,t+r):this.property?n[this.property]=1:this.union.usesPrefixDiscriminator&&(n[this.union.discriminator.property]=this.variant),n}encode(e,t,n=0){let r=0;if(this.union.usesPrefixDiscriminator&&(r=this.union.discriminator.layout.span),this.layout&&!Object.prototype.hasOwnProperty.call(e,this.property))throw new TypeError("variant lacks property "+this.property);this.union.discriminator.encode(this.variant,t,n);let o=r;if(this.layout&&(this.layout.encode(e[this.property],t,n+r),o+=this.layout.getSpan(t,n+r),0<=this.union.span&&o>this.union.span))throw new Error("encoded variant overruns containing union");return o}fromArray(e){if(this.layout)return this.layout.fromArray(e)}}function ii(e){return 0>e&&(e+=4294967296),e}To.VariantLayout=oi;class si extends Do{constructor(e,t,n){if(!(e instanceof Ro||e instanceof qo))throw new TypeError("word must be a UInt or UIntBE layout");if("string"==typeof t&&void 0===n&&(n=t,t=0),4<e.span)throw new RangeError("word cannot exceed 32 bits");super(e.span,n),this.word=e,this.msb=!!t,this.fields=[];let r=0;this._packedSetValue=function(e){return r=ii(e),this},this._packedGetValue=function(){return r}}decode(e,t=0){const n=this.makeDestinationObject(),r=this.word.decode(e,t);this._packedSetValue(r);for(const t of this.fields)void 0!==t.property&&(n[t.property]=t.decode(e));return n}encode(e,t,n=0){const r=this.word.decode(t,n);this._packedSetValue(r);for(const t of this.fields)if(void 0!==t.property){const n=e[t.property];void 0!==n&&t.encode(n)}return this.word.encode(this._packedGetValue(),t,n)}addField(e,t){const n=new ai(this,e,t);return this.fields.push(n),n}addBoolean(e){const t=new ui(this,e);return this.fields.push(t),t}fieldFor(e){if("string"!=typeof e)throw new TypeError("property must be string");for(const t of this.fields)if(t.property===e)return t}}To.BitStructure=si;class ai{constructor(e,t,n){if(!(e instanceof si))throw new TypeError("container must be a BitStructure");if(!Number.isInteger(t)||0>=t)throw new TypeError("bits must be positive integer");const r=8*e.span,o=e.fields.reduce(((e,t)=>e+t.bits),0);if(t+o>r)throw new Error("bits too long for span remainder ("+(r-o)+" of "+r+" remain)");this.container=e,this.bits=t,this.valueMask=(1<<t)-1,32===t&&(this.valueMask=4294967295),this.start=o,this.container.msb&&(this.start=r-o-t),this.wordMask=ii(this.valueMask<<this.start),this.property=n}decode(e,t){return ii(this.container._packedGetValue()&this.wordMask)>>>this.start}encode(e){if("number"!=typeof e||!Number.isInteger(e)||e!==ii(e&this.valueMask))throw new TypeError(Lo("BitField.encode",this)+" value must be integer not exceeding "+this.valueMask);const t=this.container._packedGetValue(),n=ii(e<<this.start);this.container._packedSetValue(ii(t&~this.wordMask)|n)}}To.BitField=ai;class ui extends ai{constructor(e,t){super(e,1,t)}decode(e,t){return!!super.decode(e,t)}encode(e){"boolean"==typeof e&&(e=+e),super.encode(e)}}To.Boolean=ui;class ci extends Do{constructor(e,t){if(!(e instanceof Uo&&e.isCount()||Number.isInteger(e)&&0<=e))throw new TypeError("length must be positive integer or an unsigned integer ExternalLayout");let n=-1;e instanceof Uo||(n=e),super(n,t),this.length=e}getSpan(e,t){let n=this.span;return 0>n&&(n=this.length.decode(e,t)),n}decode(e,t=0){let n=this.span;return 0>n&&(n=this.length.decode(e,t)),_o(e).slice(t,t+n)}encode(e,t,n){let r=this.length;if(this.length instanceof Uo&&(r=e.length),!(e instanceof Uint8Array&&r===e.length))throw new TypeError(Lo("Blob.encode",this)+" requires (length "+r+") Uint8Array as src");if(n+r>t.length)throw new RangeError("encoding overruns Uint8Array");const o=_o(e);return _o(t).write(o.toString("hex"),n,r,"hex"),this.length instanceof Uo&&this.length.encode(r,t,n),r}}To.Blob=ci;class li extends Do{constructor(e){super(-1,e)}getSpan(e,t=0){Bo(e);let n=t;for(;n<e.length&&0!==e[n];)n+=1;return 1+n-t}decode(e,t=0){const n=this.getSpan(e,t);return _o(e).slice(t,t+n-1).toString("utf-8")}encode(e,t,n=0){"string"!=typeof e&&(e=String(e));const r=Eo.Buffer.from(e,"utf8"),o=r.length;if(n+o>t.length)throw new RangeError("encoding overruns Buffer");const i=_o(t);return r.copy(i,n),i[n+o]=0,o+1}}To.CString=li;class di extends Do{constructor(e,t){if("string"==typeof e&&void 0===t&&(t=e,e=void 0),void 0===e)e=-1;else if(!Number.isInteger(e))throw new TypeError("maxSpan must be an integer");super(-1,t),this.maxSpan=e}getSpan(e,t=0){return Bo(e),e.length-t}decode(e,t=0){const n=this.getSpan(e,t);if(0<=this.maxSpan&&this.maxSpan<n)throw new RangeError("text length exceeds maxSpan");return _o(e).slice(t,t+n).toString("utf-8")}encode(e,t,n=0){"string"!=typeof e&&(e=String(e));const r=Eo.Buffer.from(e,"utf8"),o=r.length;if(0<=this.maxSpan&&this.maxSpan<o)throw new RangeError("text length exceeds maxSpan");if(n+o>t.length)throw new RangeError("encoding overruns Buffer");return r.copy(_o(t),n),o}}To.UTF8=di;class pi extends Do{constructor(e,t){super(0,t),this.value=e}decode(e,t){return this.value}encode(e,t,n){return 0}}To.Constant=pi,To.greedy=(e,t)=>new Wo(e,t),To.offset=(e,t,n)=>new Oo(e,t,n);var hi=To.u8=e=>new Ro(1,e);To.u16=e=>new Ro(2,e),To.u24=e=>new Ro(3,e),To.u32=e=>new Ro(4,e),To.u40=e=>new Ro(5,e),To.u48=e=>new Ro(6,e),To.nu64=e=>new $o(e),To.u16be=e=>new qo(2,e),To.u24be=e=>new qo(3,e),To.u32be=e=>new qo(4,e),To.u40be=e=>new qo(5,e),To.u48be=e=>new qo(6,e),To.nu64be=e=>new Yo(e),To.s8=e=>new Ko(1,e),To.s16=e=>new Ko(2,e),To.s24=e=>new Ko(3,e),To.s32=e=>new Ko(4,e),To.s40=e=>new Ko(5,e),To.s48=e=>new Ko(6,e),To.ns64=e=>new jo(e),To.s16be=e=>new zo(2,e),To.s24be=e=>new zo(3,e),To.s32be=e=>new zo(4,e),To.s40be=e=>new zo(5,e),To.s48be=e=>new zo(6,e),To.ns64be=e=>new Zo(e),To.f32=e=>new Ho(e),To.f32be=e=>new Go(e),To.f64=e=>new Qo(e),To.f64be=e=>new Jo(e);var mi=To.struct=(e,t,n)=>new ei(e,t,n);To.bits=(e,t,n)=>new si(e,t,n),To.seq=(e,t,n)=>new Xo(e,t,n),To.union=(e,t,n)=>new ri(e,t,n),To.unionLayoutDiscriminator=(e,t)=>new ni(e,t);var fi=To.blob=(e,t)=>new ci(e,t);To.cstr=e=>new li(e),To.utf8=(e,t)=>new di(e,t),To.constant=(e,t)=>new pi(e,t);const yi=X([ne("updateAuthority"),ne("mint"),ie("name"),ie("symbol"),ie("uri"),ce(X([ie("key"),ie("value")]),"additionalMetadata")]),gi=mi([hi("version"),hi("cmintDecompressed"),(()=>{const e=fi(32,"splMint"),{encode:t,decode:n}=(e=>({decode:e.decode.bind(e),encode:e.encode.bind(e)}))(e),r=e;return r.decode=(e,t)=>{const r=n(e,t);return new P(r)},r.encode=(e,n,r)=>{const o=e.toBuffer();return t(o,n,r)},r})()]),wi=gi.span;function bi(e,t,n){return e===Ii.TokenMetadata?function(e,t){let n=t;n+=32,n+=32,n+=4+e.readUInt32LE(n),n+=4+e.readUInt32LE(n),n+=4+e.readUInt32LE(n);const r=e.readUInt32LE(n);n+=4;for(let t=0;t<r;t++)n+=4+e.readUInt32LE(n),n+=4+e.readUInt32LE(n);return n-t}(t,n):t.length-n}function ki(e){const t=e instanceof xe?e:xe.from(e);let n=0;const r=$.decode(t.slice(n,n+D));n+=D;const o=gi.decode(t.slice(n,n+wi));n+=wi;const i=1===t.readUInt8(n);n+=1;let s=null;if(i){const e=t.readUInt32LE(n);n+=4,s=[];for(let r=0;r<e;r++){const e=t.readUInt8(n);n+=1;const r=bi(e,t,n),o=t.slice(n,n+r);n+=r,s.push({extensionType:e,data:o})}}return{base:{mintAuthority:1===r.mintAuthorityOption?r.mintAuthority:null,supply:r.supply,decimals:r.decimals,isInitialized:r.isInitialized,freezeAuthority:1===r.freezeAuthorityOption?r.freezeAuthority:null},mintContext:{version:o.version,cmintDecompressed:0!==o.cmintDecompressed,splMint:o.splMint},extensions:s}}function vi(e){const t=[],n=xe.alloc(D);$.encode({mintAuthorityOption:e.base.mintAuthority?1:0,mintAuthority:e.base.mintAuthority||new P(0),supply:e.base.supply,decimals:e.base.decimals,isInitialized:e.base.isInitialized,freezeAuthorityOption:e.base.freezeAuthority?1:0,freezeAuthority:e.base.freezeAuthority||new P(0)},n),t.push(n);const r=xe.alloc(wi);if(gi.encode({version:e.mintContext.version,cmintDecompressed:e.mintContext.cmintDecompressed?1:0,splMint:e.mintContext.splMint},r),t.push(r),e.extensions&&e.extensions.length>0){t.push(xe.from([1]));const n=xe.alloc(4);n.writeUInt32LE(e.extensions.length),t.push(n);for(const n of e.extensions)t.push(xe.from([n.extensionType])),t.push(xe.from(n.data))}else t.push(xe.from([0]));return xe.concat(t)}var Ii;function Mi(e){try{const t=xe.from(e);if(t.length<80)return null;const n=yi.decode(t),r=n.updateAuthority.toBuffer().every((e=>0===e))?void 0:n.updateAuthority,o=xe.from(n.name).toString("utf-8"),i=xe.from(n.symbol).toString("utf-8"),s=xe.from(n.uri).toString("utf-8");let a;return n.additionalMetadata&&n.additionalMetadata.length>0&&(a=n.additionalMetadata.map((e=>({key:xe.from(e.key).toString("utf-8"),value:xe.from(e.value).toString("utf-8")})))),{updateAuthority:r,mint:n.mint,name:o,symbol:i,uri:s,additionalMetadata:a}}catch(e){return console.error("Failed to decode TokenMetadata:",e),null}}function Pi(e){const t=xe.alloc(2e3),n=e.updateAuthority||new P(0),r=yi.encode({updateAuthority:n,mint:e.mint,name:xe.from(e.name),symbol:xe.from(e.symbol),uri:xe.from(e.uri),additionalMetadata:e.additionalMetadata?e.additionalMetadata.map((e=>({key:xe.from(e.key),value:xe.from(e.value)}))):[]},t);return t.subarray(0,r)}!function(e){e[e.TokenMetadata=19]="TokenMetadata"}(Ii||(Ii={}));const Ai=Mi;function xi(e){if(!e)return null;const t=e.find((e=>e.extensionType===Ii.TokenMetadata));return t?Ai(t.data):null}async function Si(t,n,r,o){if(!o){const[e,o,i]=await Promise.allSettled([Si(t,n,r,W),Si(t,n,r,O),Si(t,n,r,h)]);if("fulfilled"===e.status)return e.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 t.getCompressedAccount(e(i.toBytes()));if(!s?.data?.data)throw new Error(`Compressed mint not found for ${n.toString()}`);const a=ki(xe.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:xe.alloc(0)},c={treeInfo:s.treeInfo,hash:s.hash,leafIndex:s.leafIndex,proveByIndex:s.proveByIndex},l=xi(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(t,n,r,o),programId:o}}function Ci(e,t,n=W){const r=t instanceof xe?t:t instanceof Uint8Array?xe.from(t):t.data;if(n.equals(h)){const t=ki(r),o={address:e,mintAuthority:t.base.mintAuthority,supply:t.base.supply,decimals:t.base.decimals,isInitialized:t.base.isInitialized,freezeAuthority:t.base.freezeAuthority,tlvData:xe.alloc(0)},i=xi(t.extensions),s={mint:o,programId:n,mintContext:t.mintContext,tokenMetadata:i||void 0,extensions:t.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(e,t,n),programId:n}}function Ti(e){const t=ki(e instanceof xe?e:xe.from(e)),n=xi(t.extensions);return{mintContext:t.mintContext,tokenMetadata:n||void 0,extensions:t.extensions||void 0}}async function Ei(t,n,r,o,i,s){const a=await Si(t,r,s?.commitment,h);if(!a.merkleContext)throw new Error("Mint does not have MerkleContext");const u=await t.getValidityProofV2([{hash:e(a.merkleContext.hash),leafIndex:a.merkleContext.leafIndex,treeInfo:a.merkleContext.treeInfo,proveByIndex:a.merkleContext.proveByIndex}],[],M.compressible),c=pr(a,o.publicKey,i,n.publicKey,u),l=o.publicKey.equals(n.publicKey)?[]:[o],{blockhash:d}=await t.getLatestBlockhash(),p=w([C.setComputeUnitLimit({units:5e5}),c],n,d,l);return await b(t,p,s)}async function Bi(t,n,r,o,i,s){const a=await Si(t,r,s?.commitment,h);if(!a.merkleContext)throw new Error("Mint does not have MerkleContext");const u=await t.getValidityProofV2([{hash:e(a.merkleContext.hash),leafIndex:a.merkleContext.leafIndex,treeInfo:a.merkleContext.treeInfo,proveByIndex:a.merkleContext.proveByIndex}],[],M.compressible),c=hr(a,o.publicKey,i,n.publicKey,u),l=o.publicKey.equals(n.publicKey)?[]:[o],{blockhash:d}=await t.getLatestBlockhash(),p=w([C.setComputeUnitLimit({units:5e5}),c],n,d,l);return await b(t,p,s)}async function _i(t,n,r,o,i,s,a,u=0,c){const l=await Si(t,r,c?.commitment,h);if(!l.tokenMetadata||!l.merkleContext)throw new Error("Mint does not have TokenMetadata extension");const d=await t.getValidityProofV2([{hash:e(l.merkleContext.hash),leafIndex:l.merkleContext.leafIndex,treeInfo:l.merkleContext.treeInfo,proveByIndex:l.merkleContext.proveByIndex}],[],M.compressible),p=fr(l,o.publicKey,n.publicKey,d,i,s,a,u),m=o.publicKey.equals(n.publicKey)?[]:[o],{blockhash:f}=await t.getLatestBlockhash(),y=w([C.setComputeUnitLimit({units:5e5}),p],n,f,m);return await b(t,y,c)}async function Di(t,n,r,o,i,s=0,a){const u=await Si(t,r,a?.commitment,h);if(!u.tokenMetadata||!u.merkleContext)throw new Error("Mint does not have TokenMetadata extension");const c=await t.getValidityProofV2([{hash:e(u.merkleContext.hash),leafIndex:u.merkleContext.leafIndex,treeInfo:u.merkleContext.treeInfo,proveByIndex:u.merkleContext.proveByIndex}],[],M.compressible),l=yr(u,o.publicKey,i,n.publicKey,c,s),d=o.publicKey.equals(n.publicKey)?[]:[o],{blockhash:p}=await t.getLatestBlockhash(),m=w([C.setComputeUnitLimit({units:5e5}),l],n,p,d);return await b(t,m,a)}async function Li(t,n,r,o,i,s=0,a=0,u){const c=await Si(t,r,u?.commitment,h);if(!c.tokenMetadata||!c.merkleContext)throw new Error("Mint does not have TokenMetadata extension");const l=await t.getValidityProofV2([{hash:e(c.merkleContext.hash),leafIndex:c.merkleContext.leafIndex,treeInfo:c.merkleContext.treeInfo,proveByIndex:c.merkleContext.proveByIndex}],[],M.compressible),d=gr(c,o.publicKey,n.publicKey,l,i,s,a),p=o.publicKey.equals(n.publicKey)?[]:[o],{blockhash:m}=await t.getLatestBlockhash(),f=w([C.setComputeUnitLimit({units:5e5}),d],n,m,p);return await b(t,f,u)}async function Ui(e,t,n,r,o=0,i,s=h,a,u){const c=a??Sr(s),l=bo(n,r,o,s,c),d=Er(t.publicKey,l,r,n,s,c,u);if(s.equals(h)){const{blockhash:n}=await e.getLatestBlockhash(),r=w([C.setComputeUnitLimit({units:3e4}),d],t,n,[]);await b(e,r,i)}else{const n=(new E).add(d);await B(e,n,[t],i)}return l}async function Wi(e,t,n,r,o=0,i,s=h,a,u){const c=a??Sr(s),l=bo(n,r,o,s,c),d=Br(t.publicKey,l,r,n,s,c,u);if(s.equals(h)){const{blockhash:n}=await e.getLatestBlockhash(),r=w([C.setComputeUnitLimit({units:3e4}),d],t,n,[]);await b(e,r,i)}else{const n=(new E).add(d);await B(e,n,[t],i)}return l}async function Oi(t,n,r,o,i,s,a,u){const c=await Si(t,r,u?.commitment,h);if(!c.merkleContext)throw new Error("Mint does not have MerkleContext");let l;if(a){if(l=(await t.getStateTreeInfos()).find((e=>e.queue.equals(a)||e.tree.equals(a))),!l)throw new Error("Could not find TreeInfo for provided outputQueue")}else{const e=await t.getStateTreeInfos();l=I(e)}const d=await t.getValidityProofV2([{hash:e(c.merkleContext.hash),leafIndex:c.merkleContext.leafIndex,treeInfo:c.merkleContext.treeInfo,proveByIndex:c.merkleContext.proveByIndex}],[],M.compressible),p=Dr(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,cmintDecompressed:c.mintContext.cmintDecompressed,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 t.getLatestBlockhash(),y=w([C.setComputeUnitLimit({units:5e5}),p],n,f,m);return await b(t,y,u)}async function Ri(t,n,r,o,i,s,a=3,u){const c=await Si(t,r,u?.commitment,h);if(!c.merkleContext)throw new Error("Mint does not have MerkleContext");if(!s){const e=await t.getStateTreeInfos();s=I(e)}const l=await t.getValidityProofV2([{hash:e(c.merkleContext.hash),leafIndex:c.merkleContext.leafIndex,treeInfo:c.merkleContext.treeInfo,proveByIndex:c.merkleContext.proveByIndex}],[],M.compressible),d=Lr(o.publicKey,n.publicKey,l,c.merkleContext,{supply:c.mint.supply,decimals:c.mint.decimals,mintAuthority:c.mint.mintAuthority,freezeAuthority:c.mint.freezeAuthority,splMint:c.mintContext.splMint,cmintDecompressed:c.mintContext.cmintDecompressed,version:c.mintContext.version,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 t.getLatestBlockhash(),f=w([C.setComputeUnitLimit({units:5e5}),d],n,m,p);return await b(t,f,u)}async function qi(t,n,r,o,i,s,a=[],u,c){const l=await Si(t,r,u?.commitment,c);let d;l.merkleContext&&(d=await t.getValidityProofV2([{hash:e(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((e=>e.publicKey)),m=Ur(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 t.getLatestBlockhash(),g=w([C.setComputeUnitLimit({units:5e5}),m],n,y,f);return await b(t,g,u)}async function Ki(e,t,n,r,o=0,i,s,a=h,u=Sr(a)){return Ni(e,t,n,r,o,i,s,a,u,0)}function zi(e){if(!("publicKey"in e)||!("secretKey"in e))return 0;const t=e;return t.secretKey instanceof Uint8Array&&t.secretKey.length>0}function Vi(e){return zi(e)?e.publicKey:e}async function Ni(e,t,n,r,o,i,s,a,u,c){const l=Vi(r),d=q(n,l,o,a,u);return a.equals(h)?async function(e,t,n,r,o,i,s,a=0,u=0){const c=Vi(r);let l;zi(r);let d=0;try{l=await yo(e,o,c,n,i,h,a,u),d=l._sources?.some((e=>e.type===uo.CTokenHot))??0}catch(r){if(!(r instanceof F||r instanceof Z))throw r;await Fi(e,t,n,c,o,s),l=await yo(e,o,c,n,i,h,a,u),d=1}if(d||await Fi(e,t,n,c,o,s),zi(r)){const d=l._sources??[],p=d.some((e=>e.type===uo.CTokenCold&&e.amount>BigInt(0))),m=a&&d.some((e=>(e.type===uo.Spl||e.type===uo.Token2022)&&e.amount>BigInt(0)));if(p||m){if(!(r.secretKey instanceof Uint8Array)||0===r.secretKey.length)throw new Error("Owner must be a valid Signer with secretKey to auto-load");await Po(e,o,r,n,t,s,void 0,a),l=await yo(e,o,c,n,i,h,a,u)}}const p=l.parsed;if(!p.mint.equals(n))throw new H;if(!p.owner.equals(c))throw new G;return l}(e,t,n,r,d,i,s,c,o):async function(e,t,n,r,o,i,s,a,u){let c;try{c=await fo(e,o,a,i)}catch(l){if(!(l instanceof F||l instanceof Z))throw l;try{const a=(new E).add(Er(t.publicKey,o,r,n,i,s));await B(e,a,[t],u)}catch{}c=await fo(e,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}(e,t,n,l,d,a,u,i,s)}async function Fi(e,t,n,r,o,i){try{const s=Br(t.publicKey,o,r,n,h),{blockhash:a}=await e.getLatestBlockhash(),u=w([C.setComputeUnitLimit({units:2e5}),s],t,a,[]);await b(e,u,i)}catch{}}async function $i(e,t,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,Sr(a));if(!n.equals(s))throw new Error(`Source mismatch. Expected ${s.toBase58()}, got ${n.toBase58()}`);m.push(Rr(n,o,i.publicKey,d,[],a));const{blockhash:c}=await e.getLatestBlockhash(),l=w([C.setComputeUnitLimit({units:1e4}),...m],t,c,[i]);return b(e,l,u)}const f=bo(r,i.publicKey);if(!n.equals(f))throw new Error(`Source mismatch. Expected ${f.toBase58()}, got ${n.toBase58()}`);const y=bo(r,i.publicKey);let k,v;l&&(k=q(r,i.publicKey,0,W,Sr(W)),v=q(r,i.publicKey,0,O,Sr(O)));const I=[e.getAccountInfo(y),e.getCompressedTokenAccountsByOwner(i.publicKey,{mint:r})];l&&k&&v&&(I.push(e.getAccountInfo(k)),I.push(e.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),D=T.reduce(((e,t)=>e+BigInt(t.parsed.amount.toString())),BigInt(0)),L=E+B+_+D;if(L<d)throw new Error(`Insufficient balance. Required: ${d}, Available: ${L}`);let U=[];P||m.push(Br(t.publicKey,y,i.publicKey,r,h));const R=(B>BigInt(0)||_>BigInt(0)||D>BigInt(0)?p??await Ct(e,r):[]).find((e=>e.isInitialized));if(l&&k&&B>BigInt(0)&&R&&m.push(ko(k,y,i.publicKey,r,B,R,t.publicKey)),l&&v&&_>BigInt(0)&&R&&m.push(ko(v,y,i.publicKey,r,_,R,t.publicKey)),D>BigInt(0)&&T.length>0){const n=await e.getValidityProofV0(T.map((e=>({hash:e.compressedAccount.hash,tree:e.compressedAccount.treeInfo.tree,queue:e.compressedAccount.treeInfo.queue}))));n.compressedProof,U=T,m.push(to(t.publicKey,T,y,D,n))}m.push(Or(n,o,i.publicKey,d));const K=function(e){if(e.length>0)for(const t of e)t.compressedAccount.proveByIndex;return 2e5}(U),{blockhash:z}=await e.getLatestBlockhash(),V=g(t,[i]),N=w([C.setComputeUnitLimit({units:K}),...m],t,z,V);return b(e,N,u)}async function Yi(e,t,n,r,o,i,s,a,u){const c=void 0!==a,l=(await e.getCompressedTokenAccountsByOwner(n.publicKey,{mint:r})).items;if(0===l.length)return null;const d=l.reduce(((e,t)=>e+BigInt(t.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 e of l){if(f>=p)break;m.push(e),f+=BigInt(e.parsed.amount.toString())}const y=await e.getValidityProofV0(m.map((e=>({hash:e.compressedAccount.hash,tree:e.compressedAccount.treeInfo.tree,queue:e.compressedAccount.treeInfo.queue})))),k=s??n.publicKey;let v;v=c?i??await Q(r,k,0,a.tokenProgram):i??bo(r,k);const I=[];await e.getAccountInfo(v)||(c?I.push(z(t.publicKey,v,k,r,a.tokenProgram)):I.push(Br(t.publicKey,v,k,r,h)));let M=5e4;null!==y.compressedProof&&(M+=1e5);for(const e of m)M+=e.compressedAccount.proveByIndex?1e4:3e4;c&&(M+=5e4),I.push(to(t.publicKey,m,v,p,y,a));const{blockhash:P}=await e.getLatestBlockhash(),A=g(t,[n]),x=w([C.setComputeUnitLimit({units:M}),...I],t,P,A);return b(e,x,u)}async function ji(e,t,n,r,o,i,s,a,u){let c=a;if(!c&&(c=(await Ct(e,i)).find((e=>e.isInitialized)),!c))throw new Error(`No initialized SPL interface found for mint: ${i.toBase58()}. Please create an SPL interface via createSplInterface().`);const l=ko(n,r,o.publicKey,i,s,c,t.publicKey),{blockhash:d}=await e.getLatestBlockhash(),p=g(t,[o]),h=w([C.setComputeUnitLimit({units:2e5}),l],t,d,p);return await b(e,h,u)}function Zi(e){const t={name:e.name,symbol:e.symbol};return void 0!==e.description&&(t.description=e.description),void 0!==e.image&&(t.image=e.image),void 0!==e.additionalMetadata&&e.additionalMetadata.length>0&&(t.additionalMetadata=e.additionalMetadata),t}X([ee(te(),32,"a"),ee(te(),64,"b"),ee(te(),32,"c")]);const Hi=X([ue("rootIndex"),ae("proveByIndex"),te("merkleTreePubkeyIndex"),te("queuePubkeyIndex"),se("leafIndex")]);async function Gi(t,n,r,o,i,s,a){o=e(o);const u=await t.getCompressedTokenAccountsByOwner(i.publicKey,{mint:r}),[c]=qt(u.items,o),l=await t.getValidityProofV0(c.map((e=>({hash:e.compressedAccount.hash,tree:e.compressedAccount.treeInfo.tree,queue:e.compressedAccount.treeInfo.queue})))),d=await Ln.approve({payer:n.publicKey,inputCompressedTokenAccounts:c,toAddress:s,amount:o,recentInputStateRootIndices:l.rootIndices,recentValidityProof:l.compressedProof}),{blockhash:p}=await t.getLatestBlockhash(),h=g(n,[i]),m=w([C.setComputeUnitLimit({units:35e4}),d],n,p,h);return b(t,m,a)}async function Qi(e,t,n,r,o,i,a,u,c){a=a??I(await e.getStateTreeInfos()),u=u??Bt(await Ct(e,n));const l=await J(e,t,n,o.publicKey,void 0,void 0,c,u.tokenProgram),d=await Ln.approveAndMintTo({feePayer:t.publicKey,mint:n,authority:o.publicKey,authorityTokenAccount:l.address,amount:i,toPubkey:r,outputStateTreeInfo:a,tokenPoolInfo:u}),{blockhash:p}=await e.getLatestBlockhash(),h=g(t,[o]),m=w([C.setComputeUnitLimit({units:15e4+2e4*s(i).length}),...d],t,p,h);return await b(e,m,c)}async function Ji(e,t,n,r,o,i,a,u,c,l){u=u??I(await e.getStateTreeInfos()),c=c??Bt(await Ct(e,n));const d=await Ln.compress({payer:t.publicKey,owner:o.publicKey,source:i,toAddress:a,amount:r,mint:n,outputStateTreeInfo:u,tokenPoolInfo:c}),p=await e.getLatestBlockhash(),h=g(t,[o]),m=w([C.setComputeUnitLimit({units:13e4+2e4*s(r).length}),d],t,p.blockhash,h);return await b(e,m,l,p)}async function Xi(e,t,n,r,o,i,s,a,u){s=s??I(await e.getStateTreeInfos()),a=a??Bt(await Ct(e,n));const c=await Ln.compressSplTokenAccount({feePayer:t.publicKey,authority:r.publicKey,tokenAccount:o,mint:n,remainingAmount:i,outputStateTreeInfo:s,tokenPoolInfo:a}),l=await e.getLatestBlockhash(),d=g(t,[r]),p=w([C.setComputeUnitLimit({units:15e4}),c],t,l.blockhash,d);return await b(e,p,u,l)}async function es(e,t,n,r,o){o=o||await Ln.getMintProgramId(n,e);const i=await Ln.createTokenPool({feePayer:t.publicKey,mint:n,tokenProgramId:o}),{blockhash:s}=await e.getLatestBlockhash(),a=w([i],t,s);return await b(e,a,r)}X([Hi.replicate("treeInfo"),oe(ee(te(),32),"address"),oe(re(),"lamports"),te("outputStateTreeIndex")]);const ts=es;async function ns(e,t,n,r,o,i){i=i||await Ln.getMintProgramId(n,e);const s=[],a=(await Ct(e,n)).slice(0,4),u=[];for(let e=0;e<a.length;e++)a[e].isInitialized||u.push(e);for(let e=0;e<r&&!(e>=u.length);e++)s.push(await Ln.addTokenPool({mint:n,feePayer:t.publicKey,tokenProgramId:i,poolIndex:u[e]}));const{blockhash:c}=await e.getLatestBlockhash(),l=w(s,t,c);return await b(e,l,o)}const rs=ns;async function os(e,t,n,r,o){const i=await e.getSlot("finalized"),{instructions:s,address:a}=await Ln.createTokenProgramLookupTable({payer:t.publicKey,authority:n.publicKey,mints:r,remainingAccounts:o,recentSlot:i}),u=g(t,[n]),c=[];for(const n of s){const r=await e.getLatestBlockhash(),o=w([n],t,r.blockhash,u),i=await b(e,o,{commitment:"finalized"},r);c.push(i)}return{txIds:c,address:a}}async function is(t,n,r,o,i,s,a,u){o=e(o);const c=await t.getCompressedTokenAccountsByOwner(i.publicKey,{mint:r}),[l]=zt(c.items,o),d=await t.getValidityProofV0(l.map((e=>({hash:e.compressedAccount.hash,tree:e.compressedAccount.treeInfo.tree,queue:e.compressedAccount.treeInfo.queue})))),p=_t(a=a??await Ct(t,r),o),h=await Ln.decompress({payer:n.publicKey,inputCompressedTokenAccounts:l,toAddress:s,amount:o,tokenPoolInfos:p,recentInputStateRootIndices:d.rootIndices,recentValidityProof:d.compressedProof}),{blockhash:m}=await t.getLatestBlockhash(),f=g(n,[i]),y=w([C.setComputeUnitLimit({units:35e4}),h],n,m,f);return await b(t,y,u)}async function ss(t,n,r,o,i){const s=await t.getCompressedTokenAccountsByOwner(o.publicKey,{mint:r});if(0===s.items.length)throw new Error(`No compressed token accounts found for mint ${r.toBase58()}`);if(1===s.items.length)throw new Error("Only one token account exists, nothing to merge");const a=s.items.slice(0,4),u=await t.getValidityProof(a.map((t=>e(t.compressedAccount.hash)))),c=await Ln.mergeTokenAccounts({payer:n.publicKey,owner:o.publicKey,inputCompressedTokenAccounts:a,mint:r,recentValidityProof:u.compressedProof,recentInputStateRootIndices:u.rootIndices}),l=[C.setComputeUnitLimit({units:1e6}),...c],{blockhash:d}=await t.getLatestBlockhash(),p=g(n,[o]),h=w(l,n,d,p);return b(t,h,i)}async function as(e,t,n,r,o,i,s,a,u){s=s??I(await e.getStateTreeInfos()),a=a??Bt(await Ct(e,n));const c=await Ln.mintTo({feePayer:t.publicKey,mint:n,authority:o.publicKey,amount:i,toPubkey:r,outputStateTreeInfo:s,tokenPoolInfo:a}),{blockhash:l}=await e.getLatestBlockhash(),d=g(t,[o]),p=w([C.setComputeUnitLimit({units:1e6}),c],t,l,d);return b(e,p,u)}async function us(e,t,n,r,o){const i=await e.getValidityProofV0(n.map((e=>({hash:e.compressedAccount.hash,tree:e.compressedAccount.treeInfo.tree,queue:e.compressedAccount.treeInfo.queue}))));!function(e,t){if(!e.publicKey.equals(t[0].parsed.owner))throw new Error(`Owner ${e.publicKey.toBase58()} does not match account ${t[0].parsed.owner.toBase58()}`)}(r,n),function(e){if(e.some((e=>null===e.parsed.delegate)))throw new Error("Account is not delegated")}(n);const s=await Ln.revoke({payer:t.publicKey,inputCompressedTokenAccounts:n,recentInputStateRootIndices:i.rootIndices,recentValidityProof:i.compressedProof}),{blockhash:a}=await e.getLatestBlockhash(),u=g(t,[r]),c=w([C.setComputeUnitLimit({units:5e5}),s],t,a,u);return b(e,c,o)}async function cs(t,n,r,o,i,s,a){o=e(o);const u=await t.getCompressedTokenAccountsByOwner(i.publicKey,{mint:r}),[c]=zt(u.items,o),l=await t.getValidityProofV0(c.map((e=>({hash:e.compressedAccount.hash,tree:e.compressedAccount.treeInfo.tree,queue:e.compressedAccount.treeInfo.queue})))),d=await Ln.transfer({payer:n.publicKey,inputCompressedTokenAccounts:c,toAddress:s,amount:o,recentInputStateRootIndices:l.rootIndices,recentValidityProof:l.compressedProof}),{blockhash:p}=await t.getLatestBlockhash(),h=g(n,[i]),m=w([C.setComputeUnitLimit({units:5e5}),d],n,p,h);return b(t,m,a)}async function ls(t,n,r,o,i,s,a){o=e(o);const u=await t.getCompressedTokenAccountsByDelegate(i.publicKey,{mint:r}),[c]=zt(u.items,o),l=await t.getValidityProofV0(c.map((e=>({hash:e.compressedAccount.hash,tree:e.compressedAccount.treeInfo.tree,queue:e.compressedAccount.treeInfo.queue})))),d=await Ln.transfer({payer:n.publicKey,inputCompressedTokenAccounts:c,toAddress:s,amount:o,recentInputStateRootIndices:l.rootIndices,recentValidityProof:l.compressedProof}),{blockhash:p}=await t.getLatestBlockhash(),h=g(n,[i]),m=w([C.setComputeUnitLimit({units:5e5}),d],n,p,h);return b(t,m,a)}async function ds(t,n,r,o,i,s,a,u){o=e(o);const c=await t.getCompressedTokenAccountsByDelegate(i.publicKey,{mint:r}),[l]=zt(c.items,o),d=await t.getValidityProofV0(l.map((e=>({hash:e.compressedAccount.hash,tree:e.compressedAccount.treeInfo.tree,queue:e.compressedAccount.treeInfo.queue})))),p=a??_t(await Ct(t,r),o),h=await Ln.decompress({payer:n.publicKey,inputCompressedTokenAccounts:l,toAddress:s,amount:o,recentInputStateRootIndices:d.rootIndices,recentValidityProof:d.compressedProof,tokenPoolInfos:p}),{blockhash:m}=await t.getLatestBlockhash(),f=g(n,[i]),y=w([C.setComputeUnitLimit({units:35e4}),h],n,m,f);return b(t,y,u)}const ps={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 hs(e){return!Array.isArray(e)}const ms=hs;export{xi as $,Ui as A,Wi as B,bo as C,Ki as D,$i as E,Yi as F,ji as G,Oi as H,Ri as I,qi as J,Ei as K,Bi as L,_i as M,Di as N,Li as O,Si as P,Ci as Q,Ti as R,fo as S,ho as T,mo as U,po as V,lo as W,ki as X,vi as Y,Mi as Z,Pi as _,Ao as a,sn as a$,Ii as a0,Zi as a1,Gi as a2,Qi as a3,Ji as a4,Xi as a5,So as a6,es as a7,ts as a8,ns as a9,Nt as aA,Ft as aB,$t as aC,Yt as aD,lt as aE,pt as aF,ht as aG,mt as aH,ft as aI,yt as aJ,gt as aK,wt as aL,bt as aM,kt as aN,vt as aO,It as aP,Mt as aQ,ps as aR,Gt as aS,Qt as aT,Jt as aU,Xt as aV,en as aW,tn as aX,nn as aY,rn as aZ,on as a_,rs as aa,os as ab,is as ac,ss as ad,as as ae,us as af,cs as ag,ls as ah,ds as ai,Pt as aj,xt as ak,St as al,Ct as am,Tt as an,Bt as ao,_t as ap,Dt as aq,Lt as ar,Ut as as,Wt as at,Ot as au,Rt as av,qt as aw,Kt as ax,zt as ay,Vt as az,Mo 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,Dn as bn,Ln as bo,hs as bp,ms as bq,Jr as br,Xr as bs,Hr as bt,Ni as bu,Sr as bv,Un as bw,Wn as bx,On as by,Rn as bz,Io as c,xo as d,lr as e,cr as f,yo as g,Ar as h,xr as i,Er as j,Br as k,Po as l,_r as m,Dr as n,Lr as o,Ur as p,pr as q,hr as r,fr as s,yr as t,gr as u,ko as v,to as w,Rr as x,Or as y,Co as z};
|
|
2
|
+
//# sourceMappingURL=types-CUGXWKP-.js.map
|