@lightprotocol/compressed-token 0.23.0-beta.1 → 0.23.0-beta.11

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