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