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