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