@lightprotocol/compressed-token 0.22.1-alpha.0 → 0.22.1-alpha.3
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/README.md +5 -1
- package/dist/cjs/browser/index.cjs +1 -1
- package/dist/cjs/browser/index.cjs.map +1 -1
- package/dist/cjs/browser/types-DZs1jl_2.cjs +2 -0
- package/dist/cjs/browser/types-DZs1jl_2.cjs.map +1 -0
- package/dist/cjs/browser/unified/index.cjs +2 -0
- package/dist/cjs/browser/unified/index.cjs.map +1 -0
- package/dist/cjs/node/index.cjs +1 -1
- package/dist/cjs/node/index.cjs.map +1 -1
- package/dist/cjs/node/types-CxnYquyR.cjs +2 -0
- package/dist/cjs/node/types-CxnYquyR.cjs.map +1 -0
- package/dist/cjs/node/unified/index.cjs +2 -0
- package/dist/cjs/node/unified/index.cjs.map +1 -0
- package/dist/es/browser/index.js +2 -0
- package/dist/es/browser/index.js.map +1 -0
- package/dist/es/browser/types-Drp6Yu8A.js +2 -0
- package/dist/es/browser/types-Drp6Yu8A.js.map +1 -0
- package/dist/es/browser/unified/index.js +2 -0
- package/dist/es/browser/unified/index.js.map +1 -0
- package/dist/types/index.d.ts +2212 -121
- package/dist/types/unified/index.d.ts +5392 -0
- package/package.json +57 -13
package/README.md
CHANGED
|
@@ -14,6 +14,9 @@
|
|
|
14
14
|
</a>
|
|
15
15
|
<img src="https://img.shields.io/npm/l/%40lightprotocol%2Fcompressed-token" alt="package license" height="18">
|
|
16
16
|
<img src="https://img.shields.io/npm/dw/%40lightprotocol%2Fcompressed-token" alt="package weekly downloads" height="18" />
|
|
17
|
+
<a href="https://deepwiki.com/Lightprotocol/light-protocol/3.1-javascripttypescript-sdks">
|
|
18
|
+
<img src="https://deepwiki.com/badge.svg" alt="Ask DeepWiki" height="18" />
|
|
19
|
+
</a>
|
|
17
20
|
</p>
|
|
18
21
|
|
|
19
22
|
### Installation
|
|
@@ -29,7 +32,8 @@ npm install --save \
|
|
|
29
32
|
### Documentation and examples
|
|
30
33
|
|
|
31
34
|
- [Latest Source code](https://github.com/lightprotocol/light-protocol/tree/main/js/compressed-token)
|
|
32
|
-
- [
|
|
35
|
+
- [Compressed Token Guides](https://www.zkcompression.com/compressed-tokens/guides)
|
|
36
|
+
- [Other Libraries](https://lightprotocol.github.io/light-protocol/)
|
|
33
37
|
|
|
34
38
|
### Getting help
|
|
35
39
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var t=require("@solana/web3.js"),e=require("@lightprotocol/stateless.js"),r=require("@solana/spl-token"),n="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},o=[],i=[],s="undefined"!=typeof Uint8Array?Uint8Array:Array,a=0;function u(){a=1;for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",e=0;e<64;++e)o[e]=t[e],i[t.charCodeAt(e)]=e;i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63}function c(t,e,r){for(var n,i,s=[],a=e;a<r;a+=3)n=(t[a]<<16)+(t[a+1]<<8)+t[a+2],s.push(o[(i=n)>>18&63]+o[i>>12&63]+o[i>>6&63]+o[63&i]);return s.join("")}function h(t){var e;a||u();for(var r=t.length,n=r%3,i="",s=[],h=16383,l=0,d=r-n;l<d;l+=h)s.push(c(t,l,l+h>d?d:l+h));return 1===n?(e=t[r-1],i+=o[e>>2],i+=o[e<<4&63],i+="=="):2===n&&(e=(t[r-2]<<8)+t[r-1],i+=o[e>>10],i+=o[e>>4&63],i+=o[e<<2&63],i+="="),s.push(i),s.join("")}function l(t,e,r,n,o){var i,s,a=8*o-n-1,u=(1<<a)-1,c=u>>1,h=-7,l=r?o-1:0,d=r?-1:1,p=t[e+l];for(l+=d,i=p&(1<<-h)-1,p>>=-h,h+=a;h>0;i=256*i+t[e+l],l+=d,h-=8);for(s=i&(1<<-h)-1,i>>=-h,h+=n;h>0;s=256*s+t[e+l],l+=d,h-=8);if(0===i)i=1-c;else{if(i===u)return s?NaN:Infinity*(p?-1:1);s+=Math.pow(2,n),i-=c}return(p?-1:1)*s*Math.pow(2,i-n)}function d(t,e,r,n,o,i){var s,a,u,c=8*i-o-1,h=(1<<c)-1,l=h>>1,d=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,m=n?1:-1,f=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||Infinity===e?(a=isNaN(e)?1:0,s=h):(s=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-s))<1&&(s--,u*=2),(e+=s+l>=1?d/u:d*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=h?(a=0,s=h):s+l>=1?(a=(e*u-1)*Math.pow(2,o),s+=l):(a=e*Math.pow(2,l-1)*Math.pow(2,o),s=0));o>=8;t[r+p]=255&a,p+=m,a/=256,o-=8);for(s=s<<o|a,c+=o;c>0;t[r+p]=255&s,p+=m,s/=256,c-=8);t[r+p-m]|=128*f}var p={}.toString,m=Array.isArray||function(t){return"[object Array]"==p.call(t)};w.TYPED_ARRAY_SUPPORT=void 0!==n.TYPED_ARRAY_SUPPORT?n.TYPED_ARRAY_SUPPORT:1;var f=g();function g(){return w.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function y(t,e){if(g()<e)throw new RangeError("Invalid typed array length");return w.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(e)).__proto__=w.prototype:(null===t&&(t=new w(e)),t.length=e),t}function w(t,e,r){if(!(w.TYPED_ARRAY_SUPPORT||this instanceof w))return new w(t,e,r);if("number"==typeof t){if("string"==typeof e)throw new Error("If encoding is specified then the first argument must be a string");return M(this,t)}return v(this,t,e,r)}function v(t,e,r,n){if("number"==typeof e)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer?function(t,e,r,n){if(e.byteLength,r<0||e.byteLength<r)throw new RangeError("'offset' is out of bounds");if(e.byteLength<r+(n||0))throw new RangeError("'length' is out of bounds");return e=void 0===r&&void 0===n?new Uint8Array(e):void 0===n?new Uint8Array(e,r):new Uint8Array(e,r,n),w.TYPED_ARRAY_SUPPORT?(t=e).__proto__=w.prototype:t=P(t,e),t}(t,e,r,n):"string"==typeof e?function(t,e,r){if("string"==typeof r&&""!==r||(r="utf8"),!w.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var n=0|S(e,r),o=(t=y(t,n)).write(e,r);return o!==n&&(t=t.slice(0,o)),t}(t,e,r):function(t,e){if(A(e)){var r=0|k(e.length);return 0===(t=y(t,r)).length||e.copy(t,0,0,r),t}if(e){if("undefined"!=typeof ArrayBuffer&&e.buffer instanceof ArrayBuffer||"length"in e)return"number"!=typeof e.length||(n=e.length)!=n?y(t,0):P(t,e);if("Buffer"===e.type&&m(e.data))return P(t,e.data)}var n;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(t,e)}function b(t){if("number"!=typeof t)throw new TypeError('"size" argument must be a number');if(t<0)throw new RangeError('"size" argument must not be negative')}function M(t,e){if(b(e),t=y(t,e<0?0:0|k(e)),!w.TYPED_ARRAY_SUPPORT)for(var r=0;r<e;++r)t[r]=0;return t}function P(t,e){var r=e.length<0?0:0|k(e.length);t=y(t,r);for(var n=0;n<r;n+=1)t[n]=255&e[n];return t}function k(t){if(t>=g())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+g().toString(16)+" bytes");return 0|t}function A(t){return!(null==t||!t._isBuffer)}function S(t,e){if(A(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var r=t.length;if(0===r)return 0;for(var n=0;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return Q(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return X(t).length;default:if(n)return Q(t).length;e=(""+e).toLowerCase(),n=1}}function T(t,e,r){var n=0;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return q(this,e,r);case"utf8":case"utf-8":return U(this,e,r);case"ascii":return W(this,e,r);case"latin1":case"binary":return N(this,e,r);case"base64":return L(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return F(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=1}}function I(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function C(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=o?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=w.from(e,n)),A(e))return 0===e.length?-1:x(t,e,r,n,o);if("number"==typeof e)return e&=255,w.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):x(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function x(t,e,r,n,o){var i,s=1,a=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;s=2,a/=2,u/=2,r/=2}function c(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(o){var h=-1;for(i=r;i<a;i++)if(c(t,i)===c(e,-1===h?0:i-h)){if(-1===h&&(h=i),i-h+1===u)return h*s}else-1!==h&&(i-=i-h),h=-1}else for(r+u>a&&(r=a-u),i=r;i>=0;i--){for(var l=1,d=0;d<u;d++)if(c(t,i+d)!==c(e,d)){l=0;break}if(l)return i}return-1}function E(t,e,r,n){r=Number(r)||0;var o=t.length-r;n?(n=Number(n))>o&&(n=o):n=o;var i=e.length;if(i%2!=0)throw new TypeError("Invalid hex string");n>i/2&&(n=i/2);for(var s=0;s<n;++s){var a=parseInt(e.substr(2*s,2),16);if(isNaN(a))return s;t[r+s]=a}return s}function _(t,e,r,n){return J(Q(e,t.length-r),t,r,n)}function O(t,e,r,n){return J(function(t){for(var e=[],r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,n)}function R(t,e,r,n){return O(t,e,r,n)}function D(t,e,r,n){return J(X(e),t,r,n)}function B(t,e,r,n){return J(function(t,e){for(var r,n,o,i=[],s=0;s<t.length&&!((e-=2)<0);++s)n=(r=t.charCodeAt(s))>>8,o=r%256,i.push(o),i.push(n);return i}(e,t.length-r),t,r,n)}function L(t,e,r){return 0===e&&r===t.length?h(t):h(t.slice(e,r))}function U(t,e,r){r=Math.min(t.length,r);for(var n=[],o=e;o<r;){var i,s,a,u,c=t[o],h=null,l=c>239?4:c>223?3:c>191?2:1;if(o+l<=r)switch(l){case 1:c<128&&(h=c);break;case 2:128==(192&(i=t[o+1]))&&(u=(31&c)<<6|63&i)>127&&(h=u);break;case 3:i=t[o+1],s=t[o+2],128==(192&i)&&128==(192&s)&&(u=(15&c)<<12|(63&i)<<6|63&s)>2047&&(u<55296||u>57343)&&(h=u);break;case 4:i=t[o+1],s=t[o+2],a=t[o+3],128==(192&i)&&128==(192&s)&&128==(192&a)&&(u=(15&c)<<18|(63&i)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(h=u)}null===h?(h=65533,l=1):h>65535&&(h-=65536,n.push(h>>>10&1023|55296),h=56320|1023&h),n.push(h),o+=l}return function(t){var e=t.length;if(e<=K)return String.fromCharCode.apply(String,t);for(var r="",n=0;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=K));return r}(n)}w.poolSize=8192,w._augment=function(t){return t.__proto__=w.prototype,t},w.from=function(t,e,r){return v(null,t,e,r)},w.TYPED_ARRAY_SUPPORT&&(w.prototype.__proto__=Uint8Array.prototype,w.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&w[Symbol.species]),w.alloc=function(t,e,r){return function(t,e,r,n){return b(e),e<=0?y(t,e):void 0!==r?"string"==typeof n?y(t,e).fill(r,n):y(t,e).fill(r):y(t,e)}(null,t,e,r)},w.allocUnsafe=function(t){return M(null,t)},w.allocUnsafeSlow=function(t){return M(null,t)},w.isBuffer=tt,w.compare=function(t,e){if(!A(t)||!A(e))throw new TypeError("Arguments must be Buffers");if(t===e)return 0;for(var r=t.length,n=e.length,o=0,i=Math.min(r,n);o<i;++o)if(t[o]!==e[o]){r=t[o],n=e[o];break}return r<n?-1:n<r?1:0},w.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 1;default:return 0}},w.concat=function(t,e){if(!m(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return w.alloc(0);var r;if(void 0===e)for(e=0,r=0;r<t.length;++r)e+=t[r].length;var n=w.allocUnsafe(e),o=0;for(r=0;r<t.length;++r){var i=t[r];if(!A(i))throw new TypeError('"list" argument must be an Array of Buffers');i.copy(n,o),o+=i.length}return n},w.byteLength=S,w.prototype._isBuffer=1,w.prototype.swap16=function(){var t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)I(this,e,e+1);return this},w.prototype.swap32=function(){var t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)I(this,e,e+3),I(this,e+1,e+2);return this},w.prototype.swap64=function(){var t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)I(this,e,e+7),I(this,e+1,e+6),I(this,e+2,e+5),I(this,e+3,e+4);return this},w.prototype.toString=function(){var t=0|this.length;return 0===t?"":0===arguments.length?U(this,0,t):T.apply(this,arguments)},w.prototype.equals=function(t){if(!A(t))throw new TypeError("Argument must be a Buffer");return this===t?1:0===w.compare(this,t)},w.prototype.inspect=function(){var t="";return this.length>0&&(t=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(t+=" ... ")),"<Buffer "+t+">"},w.prototype.compare=function(t,e,r,n,o){if(!A(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&e>=r)return 0;if(n>=o)return-1;if(e>=r)return 1;if(this===t)return 0;for(var i=(o>>>=0)-(n>>>=0),s=(r>>>=0)-(e>>>=0),a=Math.min(i,s),u=this.slice(n,o),c=t.slice(e,r),h=0;h<a;++h)if(u[h]!==c[h]){i=u[h],s=c[h];break}return i<s?-1:s<i?1:0},w.prototype.includes=function(t,e,r){return-1!==this.indexOf(t,e,r)},w.prototype.indexOf=function(t,e,r){return C(this,t,e,r,1)},w.prototype.lastIndexOf=function(t,e,r){return C(this,t,e,r,0)},w.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e|=0,isFinite(r)?(r|=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i=0;;)switch(n){case"hex":return E(this,t,e,r);case"utf8":case"utf-8":return _(this,t,e,r);case"ascii":return O(this,t,e,r);case"latin1":case"binary":return R(this,t,e,r);case"base64":return D(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return B(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=1}},w.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var K=4096;function W(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;o<r;++o)n+=String.fromCharCode(127&t[o]);return n}function N(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;o<r;++o)n+=String.fromCharCode(t[o]);return n}function q(t,e,r){var n,o=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>o)&&(r=o);for(var i="",s=e;s<r;++s)i+=(n=t[s])<16?"0"+n.toString(16):n.toString(16);return i}function F(t,e,r){for(var n=t.slice(e,r),o="",i=0;i<n.length;i+=2)o+=String.fromCharCode(n[i]+256*n[i+1]);return o}function V(t,e,r){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function j(t,e,r,n,o,i){if(!A(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||e<i)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}function Y(t,e,r,n){e<0&&(e=65535+e+1);for(var o=0,i=Math.min(t.length-r,2);o<i;++o)t[r+o]=(e&255<<8*(n?o:1-o))>>>8*(n?o:1-o)}function z(t,e,r,n){e<0&&(e=4294967295+e+1);for(var o=0,i=Math.min(t.length-r,4);o<i;++o)t[r+o]=e>>>8*(n?o:3-o)&255}function Z(t,e,r,n){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function H(t,e,r,n,o){return o||Z(t,0,r,4),d(t,e,r,n,23,4),r+4}function G(t,e,r,n,o){return o||Z(t,0,r,8),d(t,e,r,n,52,8),r+8}w.prototype.slice=function(t,e){var r,n=this.length;if((t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(e=void 0===e?n:~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),e<t&&(e=t),w.TYPED_ARRAY_SUPPORT)(r=this.subarray(t,e)).__proto__=w.prototype;else{var o=e-t;r=new w(o,void 0);for(var i=0;i<o;++i)r[i]=this[i+t]}return r},w.prototype.readUIntLE=function(t,e,r){t|=0,e|=0,r||V(t,e,this.length);for(var n=this[t],o=1,i=0;++i<e&&(o*=256);)n+=this[t+i]*o;return n},w.prototype.readUIntBE=function(t,e,r){t|=0,e|=0,r||V(t,e,this.length);for(var n=this[t+--e],o=1;e>0&&(o*=256);)n+=this[t+--e]*o;return n},w.prototype.readUInt8=function(t,e){return e||V(t,1,this.length),this[t]},w.prototype.readUInt16LE=function(t,e){return e||V(t,2,this.length),this[t]|this[t+1]<<8},w.prototype.readUInt16BE=function(t,e){return e||V(t,2,this.length),this[t]<<8|this[t+1]},w.prototype.readUInt32LE=function(t,e){return e||V(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},w.prototype.readUInt32BE=function(t,e){return e||V(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},w.prototype.readIntLE=function(t,e,r){t|=0,e|=0,r||V(t,e,this.length);for(var n=this[t],o=1,i=0;++i<e&&(o*=256);)n+=this[t+i]*o;return n>=(o*=128)&&(n-=Math.pow(2,8*e)),n},w.prototype.readIntBE=function(t,e,r){t|=0,e|=0,r||V(t,e,this.length);for(var n=e,o=1,i=this[t+--n];n>0&&(o*=256);)i+=this[t+--n]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*e)),i},w.prototype.readInt8=function(t,e){return e||V(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},w.prototype.readInt16LE=function(t,e){e||V(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},w.prototype.readInt16BE=function(t,e){e||V(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},w.prototype.readInt32LE=function(t,e){return e||V(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},w.prototype.readInt32BE=function(t,e){return e||V(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},w.prototype.readFloatLE=function(t,e){return e||V(t,4,this.length),l(this,t,1,23,4)},w.prototype.readFloatBE=function(t,e){return e||V(t,4,this.length),l(this,t,0,23,4)},w.prototype.readDoubleLE=function(t,e){return e||V(t,8,this.length),l(this,t,1,52,8)},w.prototype.readDoubleBE=function(t,e){return e||V(t,8,this.length),l(this,t,0,52,8)},w.prototype.writeUIntLE=function(t,e,r,n){t=+t,e|=0,r|=0,n||j(this,t,e,r,Math.pow(2,8*r)-1,0);var o=1,i=0;for(this[e]=255&t;++i<r&&(o*=256);)this[e+i]=t/o&255;return e+r},w.prototype.writeUIntBE=function(t,e,r,n){t=+t,e|=0,r|=0,n||j(this,t,e,r,Math.pow(2,8*r)-1,0);var o=r-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+r},w.prototype.writeUInt8=function(t,e,r){return t=+t,e|=0,r||j(this,t,e,1,255,0),w.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},w.prototype.writeUInt16LE=function(t,e,r){return t=+t,e|=0,r||j(this,t,e,2,65535,0),w.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):Y(this,t,e,1),e+2},w.prototype.writeUInt16BE=function(t,e,r){return t=+t,e|=0,r||j(this,t,e,2,65535,0),w.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):Y(this,t,e,0),e+2},w.prototype.writeUInt32LE=function(t,e,r){return t=+t,e|=0,r||j(this,t,e,4,4294967295,0),w.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):z(this,t,e,1),e+4},w.prototype.writeUInt32BE=function(t,e,r){return t=+t,e|=0,r||j(this,t,e,4,4294967295,0),w.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):z(this,t,e,0),e+4},w.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e|=0,!n){var o=Math.pow(2,8*r-1);j(this,t,e,r,o-1,-o)}var i=0,s=1,a=0;for(this[e]=255&t;++i<r&&(s*=256);)t<0&&0===a&&0!==this[e+i-1]&&(a=1),this[e+i]=(t/s>>0)-a&255;return e+r},w.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e|=0,!n){var o=Math.pow(2,8*r-1);j(this,t,e,r,o-1,-o)}var i=r-1,s=1,a=0;for(this[e+i]=255&t;--i>=0&&(s*=256);)t<0&&0===a&&0!==this[e+i+1]&&(a=1),this[e+i]=(t/s>>0)-a&255;return e+r},w.prototype.writeInt8=function(t,e,r){return t=+t,e|=0,r||j(this,t,e,1,127,-128),w.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},w.prototype.writeInt16LE=function(t,e,r){return t=+t,e|=0,r||j(this,t,e,2,32767,-32768),w.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):Y(this,t,e,1),e+2},w.prototype.writeInt16BE=function(t,e,r){return t=+t,e|=0,r||j(this,t,e,2,32767,-32768),w.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):Y(this,t,e,0),e+2},w.prototype.writeInt32LE=function(t,e,r){return t=+t,e|=0,r||j(this,t,e,4,2147483647,-2147483648),w.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):z(this,t,e,1),e+4},w.prototype.writeInt32BE=function(t,e,r){return t=+t,e|=0,r||j(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),w.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):z(this,t,e,0),e+4},w.prototype.writeFloatLE=function(t,e,r){return H(this,t,e,1,r)},w.prototype.writeFloatBE=function(t,e,r){return H(this,t,e,0,r)},w.prototype.writeDoubleLE=function(t,e,r){return G(this,t,e,1,r)},w.prototype.writeDoubleBE=function(t,e,r){return G(this,t,e,0,r)},w.prototype.copy=function(t,e,r,n){if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e<n-r&&(n=t.length-e+r);var o,i=n-r;if(this===t&&r<e&&e<n)for(o=i-1;o>=0;--o)t[o+e]=this[o+r];else if(i<1e3||!w.TYPED_ARRAY_SUPPORT)for(o=0;o<i;++o)t[o+e]=this[o+r];else Uint8Array.prototype.set.call(t,this.subarray(r,r+i),e);return i},w.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),1===t.length){var o=t.charCodeAt(0);o<256&&(t=o)}if(void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!w.isEncoding(n))throw new TypeError("Unknown encoding: "+n)}else"number"==typeof t&&(t&=255);if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;var i;if(e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(i=e;i<r;++i)this[i]=t;else{var s=A(t)?t:Q(new w(t,n).toString()),a=s.length;for(i=0;i<r-e;++i)this[i+e]=s[i%a]}return this};var $=/[^+\/0-9A-Za-z-_]/g;function Q(t,e){var r;e=e||Infinity;for(var n=t.length,o=null,i=[],s=0;s<n;++s){if((r=t.charCodeAt(s))>55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(s+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function X(t){return function(t){var e,r,n,o,c,h;a||u();var l=t.length;if(l%4>0)throw new Error("Invalid string. Length must be a multiple of 4");c="="===t[l-2]?2:"="===t[l-1]?1:0,h=new s(3*l/4-c),n=c>0?l-4:l;var d=0;for(e=0,r=0;e<n;e+=4,r+=3)o=i[t.charCodeAt(e)]<<18|i[t.charCodeAt(e+1)]<<12|i[t.charCodeAt(e+2)]<<6|i[t.charCodeAt(e+3)],h[d++]=o>>16&255,h[d++]=o>>8&255,h[d++]=255&o;return 2===c?(o=i[t.charCodeAt(e)]<<2|i[t.charCodeAt(e+1)]>>4,h[d++]=255&o):1===c&&(o=i[t.charCodeAt(e)]<<10|i[t.charCodeAt(e+1)]<<4|i[t.charCodeAt(e+2)]>>2,h[d++]=o>>8&255,h[d++]=255&o),h}(function(t){if((t=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}(t).replace($,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function J(t,e,r,n){for(var o=0;o<n&&!(o+r>=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function tt(t){return null!=t&&(!!t._isBuffer||et(t)||function(t){return"function"==typeof t.readFloatLE&&"function"==typeof t.slice&&et(t.slice(0,0))}(t))}function et(t){return!!t.constructor&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)}var rt=Object.freeze({__proto__:null,Buffer:w,INSPECT_MAX_BYTES:50,SlowBuffer:function(t){return+t!=t&&(t=0),w.alloc(+t)},isBuffer:tt,kMaxLength:f});const nt=w.from("pool"),ot=w.from("cpi_authority"),it=w.from([23,169,27,122,147,169,209,152]),st=w.from([241,34,48,186,37,179,123,192]),at=w.from([65,206,101,37,147,42,221,144]),ut=w.from([163,52,200,231,140,3,69,186]),ct=w.from([112,230,105,101,145,202,157,97]),ht=w.from([69,74,217,36,115,117,97,76]),lt=w.from([170,23,31,34,133,173,93,242]),dt=w.from([114,143,210,73,96,115,1,228]);function pt(t,e){if(!t.mint.equals(e))throw new Error("TokenPool mint does not match the provided mint.");if(!t.isInitialized)throw new Error(`TokenPool is not initialized. Please create a compressed token pool for mint: ${e.toBase58()} via createTokenPool().`);return 1}async function mt(t,n,o){const i=Array.from({length:5},((t,e)=>ze.deriveTokenPoolPdaWithIndex(n,e))),s=await t.getMultipleAccountsInfo(i.map((t=>t[0])),o);if(null===s[0])throw new Error(`TokenPool not found. Please create a compressed token pool for mint: ${n.toBase58()} via createTokenPool().`);const a=i.map(((t,e)=>s[e]?r.unpackAccount(t[0],s[e],s[e].owner):null)),u=s[0].owner;return a.map(((t,r)=>t?{mint:n,tokenPoolPda:t.address,tokenProgram:u,activity:void 0,balance:e.bn(t.amount.toString()),isInitialized:1,poolIndex:r,bump:i[r][1]}:{mint:n,tokenPoolPda:i[r][0],tokenProgram:u,activity:void 0,balance:e.bn(0),isInitialized:0,poolIndex:r,bump:i[r][1]}))}var ft;exports.Action=void 0,(ft=exports.Action||(exports.Action={}))[ft.Compress=1]="Compress",ft[ft.Decompress=2]="Decompress",ft[ft.Transfer=3]="Transfer";const gt=t=>{for(let e=t.length-1;e>0;e--){const r=Math.floor(Math.random()*(e+1));[t[e],t[r]]=[t[r],t[e]]}return t};function yt(t){const e=gt(t).filter((t=>t.isInitialized));if(0===e.length)throw new Error("Please pass at least one initialized token pool info.");return e[0]}function wt(t,r){if(0===t.length)throw new Error("Please pass at least one token pool info.");const n=(t=gt(t)).find((t=>t.balance.gte(e.bn(r).mul(e.bn(10)))));if((t=t.filter((t=>t.isInitialized)).sort(((t,e)=>t.poolIndex-e.poolIndex))).every((t=>t.balance.isZero())))throw new Error("All provided token pool balances are zero. Please pass recent token pool infos.");return n?[n]:t}const vt="Could not find accounts to select for transfer.";function bt(t,e,r=4){const n=t.find((t=>t.parsed.amount.eq(e)));return n?[[n],n.parsed.amount,n.compressedAccount.lamports,n.parsed.amount]:Mt(t,e,r)}function Mt(t,r,n=4){const[o,i,s,a]=Pt(t,r,n);if(i.lt(e.bn(r))){const i=t.reduce(((t,e)=>t.add(e.parsed.amount)),e.bn(0));throw o.length>=n?new Error(`Account limit exceeded: max ${a.toString()} (${n} accounts) per transaction. Total balance: ${i.toString()} (${t.length} accounts). Consider multiple transfers to spend full balance.`):new Error(`Insufficient balance for transfer. Required: ${r.toString()}, available: ${i.toString()}.`)}if(0===o.length)throw new Error(vt);return[o,i,s,a]}function Pt(t,r,n=4){if(0===t.length)throw new Error(vt);let o=e.bn(0),i=e.bn(0),s=e.bn(0);const a=[];t.sort(((t,e)=>e.parsed.amount.cmp(t.parsed.amount)));for(const s of t){if(a.length>=n)break;if(o.gte(e.bn(r)))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,n).reduce(((t,e)=>t.add(e.parsed.amount)),e.bn(0)),o.lt(e.bn(r))&&console.log(`Insufficient balance for transfer. Requested: ${r.toString()}, Returns max available: ${s.toString()}.`),0===a.length)throw new Error(vt);return[a,o,i,s]}function kt(t,r,n=4){if(0===t.length)throw new Error(vt);let o=e.bn(0),i=e.bn(0);const s=[],a=t.filter((t=>!t.parsed.amount.isZero()||!t.compressedAccount.lamports.isZero()));a.sort(((t,e)=>e.parsed.amount.cmp(t.parsed.amount)));for(const t of a){if(s.length>=n)break;if(o=o.add(t.parsed.amount),i=i.add(t.compressedAccount.lamports),s.push(t),o.gte(e.bn(r))){const t=a.slice(s.length);if(t.length>0){const e=t.reduce(((t,e)=>e.parsed.amount.lt(t.parsed.amount)?e:t));s.length<n&&(s.push(e),o=o.add(e.parsed.amount),i=i.add(e.compressedAccount.lamports))}break}}const u=a.slice(0,n).reduce(((t,e)=>t.add(e.parsed.amount)),e.bn(0));if(0===s.length)throw new Error(vt);return[s,o,i,u]}function At(t){const{inputCompressedTokenAccounts:r,outputStateTreeInfo:n,remainingAccounts:o=[],rootIndices:i,tokenTransferOutputs:s}=t,a=o.slice();let u=null;r.length>0&&r[0].parsed.delegate&&(u=e.getIndexOrAdd(a,r[0].parsed.delegate));const c=[];if(r.forEach(((t,r)=>{const n=e.getIndexOrAdd(a,t.compressedAccount.treeInfo.tree),o=e.getIndexOrAdd(a,t.compressedAccount.treeInfo.queue);c.push({amount:t.parsed.amount,delegateIndex:u,merkleContext:{merkleTreePubkeyIndex:n,queuePubkeyIndex:o,leafIndex:t.compressedAccount.leafIndex,proveByIndex:t.compressedAccount.proveByIndex},rootIndex:i[r],lamports:t.compressedAccount.lamports.eq(e.bn(0))?null:t.compressedAccount.lamports,tlv:null})})),r.length>0&&n)throw new Error("Cannot specify both input accounts and outputStateTreeInfo");let h;if(r.length>0)h=r[0].compressedAccount.treeInfo;else{if(!n)throw new Error("Neither input accounts nor outputStateTreeInfo are available");h=n}const l=h.nextTreeInfo||h;let d=l.tree;if(l.treeType===e.TreeType.StateV2){if(!e.featureFlags.isV2())throw new Error("V2 trees are not supported yet");d=l.queue}const p=e.padOutputStateMerkleTrees(d,s.length),m=[];p.forEach(((t,r)=>{var n;const o=e.getIndexOrAdd(a,t);m.push({owner:s[r].owner,amount:s[r].amount,lamports:(null===(n=s[r].lamports)||void 0===n?void 0:n.eq(e.bn(0)))?null:s[r].lamports,merkleTreeIndex:o,tlv:null})}));const f=a.map((t=>({pubkey:t,isWritable:1,isSigner:0})));return{inputTokenDataWithContext:c,remainingAccountMetas:f,packedOutputTokenData:m}}function St(t,e){if(!t.every((t=>t.parsed.mint.equals(e))))throw new Error("All input accounts must belong to the same mint");return 1}var Tt="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function It(t){if(t.__esModule)return t;var e=t.default;if("function"==typeof e){var r=function t(){return this instanceof t?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};r.prototype=e.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:1}),Object.keys(t).forEach((function(e){var n=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(r,e,n.get?n:{enumerable:1,get:function(){return t[e]}})})),r}var Ct={},xt={};class Et{constructor(t,e){if(!Number.isInteger(t))throw new TypeError("span must be an integer");this.span=t,this.property=e}makeDestinationObject(){return{}}decode(t,e){throw new Error("Layout is abstract")}encode(t,e,r){throw new Error("Layout is abstract")}getSpan(t,e){if(0>this.span)throw new RangeError("indeterminate span");return this.span}replicate(t){const e=Object.create(this.constructor.prototype);return Object.assign(e,this),e.property=t,e}fromArray(t){}}function _t(t,e){return e.property?t+"["+e.property+"]":t}xt.Layout=Et,xt.nameWithProperty=_t,xt.bindConstructorLayout=function(t,e){if("function"!=typeof t)throw new TypeError("Class must be constructor");if(t.hasOwnProperty("layout_"))throw new Error("Class is already bound to a layout");if(!(e&&e instanceof Et))throw new TypeError("layout must be a Layout");if(e.hasOwnProperty("boundConstructor_"))throw new Error("layout is already bound to a constructor");t.layout_=e,e.boundConstructor_=t,e.makeDestinationObject=()=>new t,Object.defineProperty(t.prototype,"encode",{value:function(t,r){return e.encode(this,t,r)},writable:1}),Object.defineProperty(t,"decode",{value:function(t,r){return e.decode(t,r)},writable:1})};class Ot extends Et{isCount(){throw new Error("ExternalLayout is abstract")}}class Rt extends Ot{constructor(t,e){if(void 0===t&&(t=1),!Number.isInteger(t)||0>=t)throw new TypeError("elementSpan must be a (positive) integer");super(-1,e),this.elementSpan=t}isCount(){return 1}decode(t,e){void 0===e&&(e=0);const r=t.length-e;return Math.floor(r/this.elementSpan)}encode(t,e,r){return 0}}class Dt extends Ot{constructor(t,e,r){if(!(t instanceof Et))throw new TypeError("layout must be a Layout");if(void 0===e)e=0;else if(!Number.isInteger(e))throw new TypeError("offset must be integer or undefined");super(t.span,r||t.property),this.layout=t,this.offset=e}isCount(){return this.layout instanceof Bt||this.layout instanceof Lt}decode(t,e){return void 0===e&&(e=0),this.layout.decode(t,e+this.offset)}encode(t,e,r){return void 0===r&&(r=0),this.layout.encode(t,e,r+this.offset)}}class Bt extends Et{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e){return void 0===e&&(e=0),t.readUIntLE(e,this.span)}encode(t,e,r){return void 0===r&&(r=0),e.writeUIntLE(t,r,this.span),this.span}}class Lt extends Et{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e){return void 0===e&&(e=0),t.readUIntBE(e,this.span)}encode(t,e,r){return void 0===r&&(r=0),e.writeUIntBE(t,r,this.span),this.span}}class Ut extends Et{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e){return void 0===e&&(e=0),t.readIntLE(e,this.span)}encode(t,e,r){return void 0===r&&(r=0),e.writeIntLE(t,r,this.span),this.span}}class Kt extends Et{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e){return void 0===e&&(e=0),t.readIntBE(e,this.span)}encode(t,e,r){return void 0===r&&(r=0),e.writeIntBE(t,r,this.span),this.span}}const Wt=Math.pow(2,32);function Nt(t){const e=Math.floor(t/Wt);return{hi32:e,lo32:t-e*Wt}}function qt(t,e){return t*Wt+e}class Ft extends Et{constructor(t){super(8,t)}decode(t,e){void 0===e&&(e=0);const r=t.readUInt32LE(e);return qt(t.readUInt32LE(e+4),r)}encode(t,e,r){void 0===r&&(r=0);const n=Nt(t);return e.writeUInt32LE(n.lo32,r),e.writeUInt32LE(n.hi32,r+4),8}}class Vt extends Et{constructor(t){super(8,t)}decode(t,e){return void 0===e&&(e=0),qt(t.readUInt32BE(e),t.readUInt32BE(e+4))}encode(t,e,r){void 0===r&&(r=0);const n=Nt(t);return e.writeUInt32BE(n.hi32,r),e.writeUInt32BE(n.lo32,r+4),8}}class jt extends Et{constructor(t){super(8,t)}decode(t,e){void 0===e&&(e=0);const r=t.readUInt32LE(e);return qt(t.readInt32LE(e+4),r)}encode(t,e,r){void 0===r&&(r=0);const n=Nt(t);return e.writeUInt32LE(n.lo32,r),e.writeInt32LE(n.hi32,r+4),8}}class Yt extends Et{constructor(t){super(8,t)}decode(t,e){return void 0===e&&(e=0),qt(t.readInt32BE(e),t.readUInt32BE(e+4))}encode(t,e,r){void 0===r&&(r=0);const n=Nt(t);return e.writeInt32BE(n.hi32,r),e.writeUInt32BE(n.lo32,r+4),8}}class zt extends Et{constructor(t){super(4,t)}decode(t,e){return void 0===e&&(e=0),t.readFloatLE(e)}encode(t,e,r){return void 0===r&&(r=0),e.writeFloatLE(t,r),4}}class Zt extends Et{constructor(t){super(4,t)}decode(t,e){return void 0===e&&(e=0),t.readFloatBE(e)}encode(t,e,r){return void 0===r&&(r=0),e.writeFloatBE(t,r),4}}class Ht extends Et{constructor(t){super(8,t)}decode(t,e){return void 0===e&&(e=0),t.readDoubleLE(e)}encode(t,e,r){return void 0===r&&(r=0),e.writeDoubleLE(t,r),8}}class Gt extends Et{constructor(t){super(8,t)}decode(t,e){return void 0===e&&(e=0),t.readDoubleBE(e)}encode(t,e,r){return void 0===r&&(r=0),e.writeDoubleBE(t,r),8}}class $t extends Et{constructor(t,e,r){if(!(t instanceof Et))throw new TypeError("elementLayout must be a Layout");if(!(e instanceof Ot&&e.isCount()||Number.isInteger(e)&&0<=e))throw new TypeError("count must be non-negative integer or an unsigned integer ExternalLayout");let n=-1;!(e instanceof Ot)&&0<t.span&&(n=e*t.span),super(n,r),this.elementLayout=t,this.count=e}getSpan(t,e){if(0<=this.span)return this.span;void 0===e&&(e=0);let r=0,n=this.count;if(n instanceof Ot&&(n=n.decode(t,e)),0<this.elementLayout.span)r=n*this.elementLayout.span;else{let o=0;for(;o<n;)r+=this.elementLayout.getSpan(t,e+r),++o}return r}decode(t,e){void 0===e&&(e=0);const r=[];let n=0,o=this.count;for(o instanceof Ot&&(o=o.decode(t,e));n<o;)r.push(this.elementLayout.decode(t,e)),e+=this.elementLayout.getSpan(t,e),n+=1;return r}encode(t,e,r){void 0===r&&(r=0);const n=this.elementLayout,o=t.reduce(((t,o)=>t+n.encode(o,e,r+t)),0);return this.count instanceof Ot&&this.count.encode(t.length,e,r),o}}class Qt extends Et{constructor(t,e,r){if(!Array.isArray(t)||!t.reduce(((t,e)=>t&&e instanceof Et),1))throw new TypeError("fields must be array of Layout instances");"boolean"==typeof e&&void 0===r&&(r=e,e=void 0);for(const e of t)if(0>e.span&&void 0===e.property)throw new Error("fields cannot contain unnamed variable-length layout");let n=-1;try{n=t.reduce(((t,e)=>t+e.getSpan()),0)}catch(t){}super(n,e),this.fields=t,this.decodePrefixes=!!r}getSpan(t,e){if(0<=this.span)return this.span;void 0===e&&(e=0);let r=0;try{r=this.fields.reduce(((r,n)=>{const o=n.getSpan(t,e);return e+=o,r+o}),0)}catch(t){throw new RangeError("indeterminate span")}return r}decode(t,e){void 0===e&&(e=0);const r=this.makeDestinationObject();for(const n of this.fields)if(void 0!==n.property&&(r[n.property]=n.decode(t,e)),e+=n.getSpan(t,e),this.decodePrefixes&&t.length===e)break;return r}encode(t,e,r){void 0===r&&(r=0);const n=r;let o=0,i=0;for(const n of this.fields){let s=n.span;if(i=0<s?s:0,void 0!==n.property){const o=t[n.property];void 0!==o&&(i=n.encode(o,e,r),0>s&&(s=n.getSpan(e,r)))}o=r,r+=s}return o+i-n}fromArray(t){const e=this.makeDestinationObject();for(const r of this.fields)void 0!==r.property&&0<t.length&&(e[r.property]=t.shift());return e}layoutFor(t){if("string"!=typeof t)throw new TypeError("property must be string");for(const e of this.fields)if(e.property===t)return e}offsetOf(t){if("string"!=typeof t)throw new TypeError("property must be string");let e=0;for(const r of this.fields){if(r.property===t)return e;0>r.span?e=-1:0<=e&&(e+=r.span)}}}class Xt{constructor(t){this.property=t}decode(){throw new Error("UnionDiscriminator is abstract")}encode(){throw new Error("UnionDiscriminator is abstract")}}class Jt extends Xt{constructor(t,e){if(!(t instanceof Ot&&t.isCount()))throw new TypeError("layout must be an unsigned integer ExternalLayout");super(e||t.property||"variant"),this.layout=t}decode(t,e){return this.layout.decode(t,e)}encode(t,e,r){return this.layout.encode(t,e,r)}}class te extends Et{constructor(t,e,r){const n=t instanceof Bt||t instanceof Lt;if(n)t=new Jt(new Dt(t));else if(t instanceof Ot&&t.isCount())t=new Jt(t);else if(!(t instanceof Xt))throw new TypeError("discr must be a UnionDiscriminator or an unsigned integer layout");if(void 0===e&&(e=null),!(null===e||e instanceof Et))throw new TypeError("defaultLayout must be null or a Layout");if(null!==e){if(0>e.span)throw new Error("defaultLayout must have constant span");void 0===e.property&&(e=e.replicate("content"))}let o=-1;e&&(o=e.span,0<=o&&n&&(o+=t.layout.span)),super(o,r),this.discriminator=t,this.usesPrefixDiscriminator=n,this.defaultLayout=e,this.registry={};let i=this.defaultGetSourceVariant.bind(this);this.getSourceVariant=function(t){return i(t)},this.configGetSourceVariant=function(t){i=t.bind(this)}}getSpan(t,e){if(0<=this.span)return this.span;void 0===e&&(e=0);const r=this.getVariant(t,e);if(!r)throw new Error("unable to determine span for unrecognized variant");return r.getSpan(t,e)}defaultGetSourceVariant(t){if(t.hasOwnProperty(this.discriminator.property)){if(this.defaultLayout&&t.hasOwnProperty(this.defaultLayout.property))return;const e=this.registry[t[this.discriminator.property]];if(e&&(!e.layout||t.hasOwnProperty(e.property)))return e}else for(const e in this.registry){const r=this.registry[e];if(t.hasOwnProperty(r.property))return r}throw new Error("unable to infer src variant")}decode(t,e){let r;void 0===e&&(e=0);const n=this.discriminator,o=n.decode(t,e);let i=this.registry[o];if(void 0===i){let s=0;i=this.defaultLayout,this.usesPrefixDiscriminator&&(s=n.layout.span),r=this.makeDestinationObject(),r[n.property]=o,r[i.property]=this.defaultLayout.decode(t,e+s)}else r=i.decode(t,e);return r}encode(t,e,r){void 0===r&&(r=0);const n=this.getSourceVariant(t);if(void 0===n){const n=this.discriminator,o=this.defaultLayout;let i=0;return this.usesPrefixDiscriminator&&(i=n.layout.span),n.encode(t[n.property],e,r),i+o.encode(t[o.property],e,r+i)}return n.encode(t,e,r)}addVariant(t,e,r){const n=new ee(this,t,e,r);return this.registry[t]=n,n}getVariant(t,e){let r=t;return Buffer.isBuffer(t)&&(void 0===e&&(e=0),r=this.discriminator.decode(t,e)),this.registry[r]}}class ee extends Et{constructor(t,e,r,n){if(!(t instanceof te))throw new TypeError("union must be a Union");if(!Number.isInteger(e)||0>e)throw new TypeError("variant must be a (non-negative) integer");if("string"==typeof r&&void 0===n&&(n=r,r=null),r){if(!(r instanceof Et))throw new TypeError("layout must be a Layout");if(null!==t.defaultLayout&&0<=r.span&&r.span>t.defaultLayout.span)throw new Error("variant span exceeds span of containing union");if("string"!=typeof n)throw new TypeError("variant must have a String property")}let o=t.span;0>t.span&&(o=r?r.span:0,0<=o&&t.usesPrefixDiscriminator&&(o+=t.discriminator.layout.span)),super(o,n),this.union=t,this.variant=e,this.layout=r||null}getSpan(t,e){if(0<=this.span)return this.span;void 0===e&&(e=0);let r=0;return this.union.usesPrefixDiscriminator&&(r=this.union.discriminator.layout.span),r+this.layout.getSpan(t,e+r)}decode(t,e){const r=this.makeDestinationObject();if(void 0===e&&(e=0),this!==this.union.getVariant(t,e))throw new Error("variant mismatch");let n=0;return this.union.usesPrefixDiscriminator&&(n=this.union.discriminator.layout.span),this.layout?r[this.property]=this.layout.decode(t,e+n):this.property?r[this.property]=1:this.union.usesPrefixDiscriminator&&(r[this.union.discriminator.property]=this.variant),r}encode(t,e,r){void 0===r&&(r=0);let n=0;if(this.union.usesPrefixDiscriminator&&(n=this.union.discriminator.layout.span),this.layout&&!t.hasOwnProperty(this.property))throw new TypeError("variant lacks property "+this.property);this.union.discriminator.encode(this.variant,e,r);let o=n;if(this.layout&&(this.layout.encode(t[this.property],e,r+n),o+=this.layout.getSpan(e,r+n),0<=this.union.span&&o>this.union.span))throw new Error("encoded variant overruns containing union");return o}fromArray(t){if(this.layout)return this.layout.fromArray(t)}}function re(t){return 0>t&&(t+=4294967296),t}class ne extends Et{constructor(t,e,r){if(!(t instanceof Bt||t instanceof Lt))throw new TypeError("word must be a UInt or UIntBE layout");if("string"==typeof e&&void 0===r&&(r=e,e=void 0),4<t.span)throw new RangeError("word cannot exceed 32 bits");super(t.span,r),this.word=t,this.msb=!!e,this.fields=[];let n=0;this._packedSetValue=function(t){return n=re(t),this},this._packedGetValue=function(){return n}}decode(t,e){const r=this.makeDestinationObject();void 0===e&&(e=0);const n=this.word.decode(t,e);this._packedSetValue(n);for(const t of this.fields)void 0!==t.property&&(r[t.property]=t.decode(n));return r}encode(t,e,r){void 0===r&&(r=0);const n=this.word.decode(e,r);this._packedSetValue(n);for(const e of this.fields)if(void 0!==e.property){const r=t[e.property];void 0!==r&&e.encode(r)}return this.word.encode(this._packedGetValue(),e,r)}addField(t,e){const r=new oe(this,t,e);return this.fields.push(r),r}addBoolean(t){const e=new ie(this,t);return this.fields.push(e),e}fieldFor(t){if("string"!=typeof t)throw new TypeError("property must be string");for(const e of this.fields)if(e.property===t)return e}}class oe{constructor(t,e,r){if(!(t instanceof ne))throw new TypeError("container must be a BitStructure");if(!Number.isInteger(e)||0>=e)throw new TypeError("bits must be positive integer");const n=8*t.span,o=t.fields.reduce(((t,e)=>t+e.bits),0);if(e+o>n)throw new Error("bits too long for span remainder ("+(n-o)+" of "+n+" remain)");this.container=t,this.bits=e,this.valueMask=(1<<e)-1,32===e&&(this.valueMask=4294967295),this.start=o,this.container.msb&&(this.start=n-o-e),this.wordMask=re(this.valueMask<<this.start),this.property=r}decode(){return re(this.container._packedGetValue()&this.wordMask)>>>this.start}encode(t){if(!Number.isInteger(t)||t!==re(t&this.valueMask))throw new TypeError(_t("BitField.encode",this)+" value must be integer not exceeding "+this.valueMask);const e=this.container._packedGetValue(),r=re(t<<this.start);this.container._packedSetValue(re(e&~this.wordMask)|r)}}class ie extends oe{constructor(t,e){super(t,1,e)}decode(t,e){return!!oe.prototype.decode.call(this,t,e)}encode(t){return"boolean"==typeof t&&(t=+t),oe.prototype.encode.call(this,t)}}class se extends Et{constructor(t,e){if(!(t instanceof Ot&&t.isCount()||Number.isInteger(t)&&0<=t))throw new TypeError("length must be positive integer or an unsigned integer ExternalLayout");let r=-1;t instanceof Ot||(r=t),super(r,e),this.length=t}getSpan(t,e){let r=this.span;return 0>r&&(r=this.length.decode(t,e)),r}decode(t,e){void 0===e&&(e=0);let r=this.span;return 0>r&&(r=this.length.decode(t,e)),t.slice(e,e+r)}encode(t,e,r){let n=this.length;if(this.length instanceof Ot&&(n=t.length),!Buffer.isBuffer(t)||n!==t.length)throw new TypeError(_t("Blob.encode",this)+" requires (length "+n+") Buffer as src");if(r+n>e.length)throw new RangeError("encoding overruns Buffer");return e.write(t.toString("hex"),r,n,"hex"),this.length instanceof Ot&&this.length.encode(n,e,r),n}}class ae extends Et{constructor(t){super(-1,t)}getSpan(t,e){if(!Buffer.isBuffer(t))throw new TypeError("b must be a Buffer");void 0===e&&(e=0);let r=e;for(;r<t.length&&0!==t[r];)r+=1;return 1+r-e}decode(t,e,r){void 0===e&&(e=0);let n=this.getSpan(t,e);return t.slice(e,e+n-1).toString("utf-8")}encode(t,e,r){void 0===r&&(r=0),"string"!=typeof t&&(t=t.toString());const n=new Buffer(t,"utf8"),o=n.length;if(r+o>e.length)throw new RangeError("encoding overruns Buffer");return n.copy(e,r),e[r+o]=0,o+1}}class ue extends Et{constructor(t,e){if("string"==typeof t&&void 0===e&&(e=t,t=void 0),void 0===t)t=-1;else if(!Number.isInteger(t))throw new TypeError("maxSpan must be an integer");super(-1,e),this.maxSpan=t}getSpan(t,e){if(!Buffer.isBuffer(t))throw new TypeError("b must be a Buffer");return void 0===e&&(e=0),t.length-e}decode(t,e,r){void 0===e&&(e=0);let n=this.getSpan(t,e);if(0<=this.maxSpan&&this.maxSpan<n)throw new RangeError("text length exceeds maxSpan");return t.slice(e,e+n).toString("utf-8")}encode(t,e,r){void 0===r&&(r=0),"string"!=typeof t&&(t=t.toString());const n=new Buffer(t,"utf8"),o=n.length;if(0<=this.maxSpan&&this.maxSpan<o)throw new RangeError("text length exceeds maxSpan");if(r+o>e.length)throw new RangeError("encoding overruns Buffer");return n.copy(e,r),o}}class ce extends Et{constructor(t,e){super(0,e),this.value=t}decode(t,e,r){return this.value}encode(t,e,r){return 0}}xt.ExternalLayout=Ot,xt.GreedyCount=Rt,xt.OffsetLayout=Dt,xt.UInt=Bt,xt.UIntBE=Lt,xt.Int=Ut,xt.IntBE=Kt,xt.Float=zt,xt.FloatBE=Zt,xt.Double=Ht,xt.DoubleBE=Gt,xt.Sequence=$t,xt.Structure=Qt,xt.UnionDiscriminator=Xt,xt.UnionLayoutDiscriminator=Jt,xt.Union=te,xt.VariantLayout=ee,xt.BitStructure=ne,xt.BitField=oe,xt.Boolean=ie,xt.Blob=se,xt.CString=ae,xt.UTF8=ue,xt.Constant=ce,xt.greedy=(t,e)=>new Rt(t,e),xt.offset=(t,e,r)=>new Dt(t,e,r),xt.u8=t=>new Bt(1,t),xt.u16=t=>new Bt(2,t),xt.u24=t=>new Bt(3,t),xt.u32=t=>new Bt(4,t),xt.u40=t=>new Bt(5,t),xt.u48=t=>new Bt(6,t),xt.nu64=t=>new Ft(t),xt.u16be=t=>new Lt(2,t),xt.u24be=t=>new Lt(3,t),xt.u32be=t=>new Lt(4,t),xt.u40be=t=>new Lt(5,t),xt.u48be=t=>new Lt(6,t),xt.nu64be=t=>new Vt(t),xt.s8=t=>new Ut(1,t),xt.s16=t=>new Ut(2,t),xt.s24=t=>new Ut(3,t),xt.s32=t=>new Ut(4,t),xt.s40=t=>new Ut(5,t),xt.s48=t=>new Ut(6,t),xt.ns64=t=>new jt(t),xt.s16be=t=>new Kt(2,t),xt.s24be=t=>new Kt(3,t),xt.s32be=t=>new Kt(4,t),xt.s40be=t=>new Kt(5,t),xt.s48be=t=>new Kt(6,t),xt.ns64be=t=>new Yt(t),xt.f32=t=>new zt(t),xt.f32be=t=>new Zt(t),xt.f64=t=>new Ht(t),xt.f64be=t=>new Gt(t),xt.struct=(t,e,r)=>new Qt(t,e,r),xt.bits=(t,e,r)=>new ne(t,e,r),xt.seq=(t,e,r)=>new $t(t,e,r),xt.union=(t,e,r)=>new te(t,e,r),xt.unionLayoutDiscriminator=(t,e)=>new Jt(t,e),xt.blob=(t,e)=>new se(t,e),xt.cstr=t=>new ae(t),xt.utf8=(t,e)=>new ue(t,e),xt.const=(t,e)=>new ce(t,e);var he={exports:{}},le=It(rt);!function(t,e){function r(t,e){if(!t)throw new Error(e||"Assertion failed")}function n(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}function o(t,e,r){if(o.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==e&&"be"!==e||(r=e,e=10),this._init(t||0,e||10,r||"be"))}var i;"object"==typeof he?he.exports=o:e.BN=o,o.BN=o,o.wordSize=26;try{i="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:le.Buffer}catch(t){}function s(t,e){var n=t.charCodeAt(e);return n>=48&&n<=57?n-48:n>=65&&n<=70?n-55:n>=97&&n<=102?n-87:void r(0,"Invalid character in "+t)}function a(t,e,r){var n=s(t,r);return r-1>=e&&(n|=s(t,r-1)<<4),n}function u(t,e,n,o){for(var i=0,s=0,a=Math.min(t.length,n),u=e;u<a;u++){var c=t.charCodeAt(u)-48;i*=o,s=c>=49?c-49+10:c>=17?c-17+10:c,r(c>=0&&s<o,"Invalid character"),i+=s}return i}function c(t,e){t.words=e.words,t.length=e.length,t.negative=e.negative,t.red=e.red}if(o.isBN=function(t){return t instanceof o?1:null!==t&&"object"==typeof t&&t.constructor.wordSize===o.wordSize&&Array.isArray(t.words)},o.max=function(t,e){return t.cmp(e)>0?t:e},o.min=function(t,e){return t.cmp(e)<0?t:e},o.prototype._init=function(t,e,n){if("number"==typeof t)return this._initNumber(t,e,n);if("object"==typeof t)return this._initArray(t,e,n);"hex"===e&&(e=16),r(e===(0|e)&&e>=2&&e<=36);var o=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&(o++,this.negative=1),o<t.length&&(16===e?this._parseHex(t,o,n):(this._parseBase(t,e,o),"le"===n&&this._initArray(this.toArray(),e,n)))},o.prototype._initNumber=function(t,e,n){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(r(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===n&&this._initArray(this.toArray(),e,n)},o.prototype._initArray=function(t,e,n){if(r("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var o=0;o<this.length;o++)this.words[o]=0;var i,s,a=0;if("be"===n)for(o=t.length-1,i=0;o>=0;o-=3)s=t[o]|t[o-1]<<8|t[o-2]<<16,this.words[i]|=s<<a&67108863,this.words[i+1]=s>>>26-a&67108863,(a+=24)>=26&&(a-=26,i++);else if("le"===n)for(o=0,i=0;o<t.length;o+=3)s=t[o]|t[o+1]<<8|t[o+2]<<16,this.words[i]|=s<<a&67108863,this.words[i+1]=s>>>26-a&67108863,(a+=24)>=26&&(a-=26,i++);return this._strip()},o.prototype._parseHex=function(t,e,r){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var n=0;n<this.length;n++)this.words[n]=0;var o,i=0,s=0;if("be"===r)for(n=t.length-1;n>=e;n-=2)o=a(t,e,n)<<i,this.words[s]|=67108863&o,i>=18?(i-=18,s+=1,this.words[s]|=o>>>26):i+=8;else for(n=(t.length-e)%2==0?e+1:e;n<t.length;n+=2)o=a(t,e,n)<<i,this.words[s]|=67108863&o,i>=18?(i-=18,s+=1,this.words[s]|=o>>>26):i+=8;this._strip()},o.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var n=0,o=1;o<=67108863;o*=e)n++;n--,o=o/e|0;for(var i=t.length-r,s=i%n,a=Math.min(i,i-s)+r,c=0,h=r;h<a;h+=n)c=u(t,h,h+n,e),this.imuln(o),this.words[0]+c<67108864?this.words[0]+=c:this._iaddn(c);if(0!==s){var l=1;for(c=u(t,h,t.length,e),h=0;h<s;h++)l*=e;this.imuln(l),this.words[0]+c<67108864?this.words[0]+=c:this._iaddn(c)}this._strip()},o.prototype.copy=function(t){t.words=new Array(this.length);for(var e=0;e<this.length;e++)t.words[e]=this.words[e];t.length=this.length,t.negative=this.negative,t.red=this.red},o.prototype._move=function(t){c(t,this)},o.prototype.clone=function(){var t=new o(null);return this.copy(t),t},o.prototype._expand=function(t){for(;this.length<t;)this.words[this.length++]=0;return this},o.prototype._strip=function(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign()},o.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},"undefined"!=typeof Symbol&&"function"==typeof Symbol.for)try{o.prototype[Symbol.for("nodejs.util.inspect.custom")]=h}catch(t){o.prototype.inspect=h}else o.prototype.inspect=h;function h(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var l=["","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],p=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function m(t,e,r){r.negative=e.negative^t.negative;var n=t.length+e.length|0;r.length=n,n=n-1|0;var o=0|t.words[0],i=0|e.words[0],s=o*i,a=67108863&s,u=s/67108864|0;r.words[0]=a;for(var c=1;c<n;c++){for(var h=u>>>26,l=67108863&u,d=Math.min(c,e.length-1),p=Math.max(0,c-t.length+1);p<=d;p++){var m=c-p|0;h+=(s=(o=0|t.words[m])*(i=0|e.words[p])+l)/67108864|0,l=67108863&s}r.words[c]=0|l,u=0|h}return 0!==u?r.words[c]=0|u:r.length--,r._strip()}o.prototype.toString=function(t,e){var n;if(e=0|e||1,16===(t=t||10)||"hex"===t){n="";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--),n=0!==i||s!==this.length-1?l[6-u.length]+u+n:u+n}for(0!==i&&(n=i.toString(16)+n);n.length%e!=0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}if(t===(0|t)&&t>=2&&t<=36){var c=d[t],h=p[t];n="";var m=this.clone();for(m.negative=0;!m.isZero();){var f=m.modrn(h).toString(t);n=(m=m.idivn(h)).isZero()?f+n:l[c-f.length]+f+n}for(this.isZero()&&(n="0"+n);n.length%e!=0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}r(0,"Base should be between 2 and 36")},o.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&r(0,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},o.prototype.toJSON=function(){return this.toString(16,2)},i&&(o.prototype.toBuffer=function(t,e){return this.toArrayLike(i,t,e)}),o.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},o.prototype.toArrayLike=function(t,e,n){this._strip();var o=this.byteLength(),i=n||Math.max(1,o);r(o<=i,"byte array longer than desired length"),r(i>0,"Requested array length <= 0");var s=function(t,e){return t.allocUnsafe?t.allocUnsafe(e):new t(e)}(t,i);return this["_toArrayLike"+("le"===e?"LE":"BE")](s,o),s},o.prototype._toArrayLikeLE=function(t){for(var e=0,r=0,n=0,o=0;n<this.length;n++){var i=this.words[n]<<o|r;t[e++]=255&i,e<t.length&&(t[e++]=i>>8&255),e<t.length&&(t[e++]=i>>16&255),6===o?(e<t.length&&(t[e++]=i>>24&255),r=0,o=0):(r=i>>>24,o+=2)}if(e<t.length)for(t[e++]=r;e<t.length;)t[e++]=0},o.prototype._toArrayLikeBE=function(t){for(var e=t.length-1,r=0,n=0,o=0;n<this.length;n++){var i=this.words[n]<<o|r;t[e--]=255&i,e>=0&&(t[e--]=i>>8&255),e>=0&&(t[e--]=i>>16&255),6===o?(e>=0&&(t[e--]=i>>24&255),r=0,o=0):(r=i>>>24,o+=2)}if(e>=0)for(t[e--]=r;e>=0;)t[e--]=0},Math.clz32?o.prototype._countBits=function(t){return 32-Math.clz32(t)}:o.prototype._countBits=function(t){var e=t,r=0;return e>=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},o.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return 0==(8191&e)&&(r+=13,e>>>=13),0==(127&e)&&(r+=7,e>>>=7),0==(15&e)&&(r+=4,e>>>=4),0==(3&e)&&(r+=2,e>>>=2),0==(1&e)&&r++,r},o.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},o.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;e<this.length;e++){var r=this._zeroBits(this.words[e]);if(t+=r,26!==r)break}return t},o.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},o.prototype.toTwos=function(t){return 0!==this.negative?this.abs().inotn(t).iaddn(1):this.clone()},o.prototype.fromTwos=function(t){return this.testn(t-1)?this.notn(t).iaddn(1).ineg():this.clone()},o.prototype.isNeg=function(){return 0!==this.negative},o.prototype.neg=function(){return this.clone().ineg()},o.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},o.prototype.iuor=function(t){for(;this.length<t.length;)this.words[this.length++]=0;for(var e=0;e<t.length;e++)this.words[e]=this.words[e]|t.words[e];return this._strip()},o.prototype.ior=function(t){return r(0==(this.negative|t.negative)),this.iuor(t)},o.prototype.or=function(t){return this.length>t.length?this.clone().ior(t):t.clone().ior(this)},o.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},o.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var r=0;r<e.length;r++)this.words[r]=this.words[r]&t.words[r];return this.length=e.length,this._strip()},o.prototype.iand=function(t){return r(0==(this.negative|t.negative)),this.iuand(t)},o.prototype.and=function(t){return this.length>t.length?this.clone().iand(t):t.clone().iand(this)},o.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},o.prototype.iuxor=function(t){var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var n=0;n<r.length;n++)this.words[n]=e.words[n]^r.words[n];if(this!==e)for(;n<e.length;n++)this.words[n]=e.words[n];return this.length=e.length,this._strip()},o.prototype.ixor=function(t){return r(0==(this.negative|t.negative)),this.iuxor(t)},o.prototype.xor=function(t){return this.length>t.length?this.clone().ixor(t):t.clone().ixor(this)},o.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},o.prototype.inotn=function(t){r("number"==typeof t&&t>=0);var e=0|Math.ceil(t/26),n=t%26;this._expand(e),n>0&&e--;for(var o=0;o<e;o++)this.words[o]=67108863&~this.words[o];return n>0&&(this.words[o]=~this.words[o]&67108863>>26-n),this._strip()},o.prototype.notn=function(t){return this.clone().inotn(t)},o.prototype.setn=function(t,e){r("number"==typeof t&&t>=0);var n=t/26|0,o=t%26;return this._expand(n+1),this.words[n]=e?this.words[n]|1<<o:this.words[n]&~(1<<o),this._strip()},o.prototype.iadd=function(t){var e,r,n;if(0!==this.negative&&0===t.negative)return this.negative=0,e=this.isub(t),this.negative^=1,this._normSign();if(0===this.negative&&0!==t.negative)return t.negative=0,e=this.isub(t),t.negative=1,e._normSign();this.length>t.length?(r=this,n=t):(r=t,n=this);for(var o=0,i=0;i<n.length;i++)e=(0|r.words[i])+(0|n.words[i])+o,this.words[i]=67108863&e,o=e>>>26;for(;0!==o&&i<r.length;i++)e=(0|r.words[i])+o,this.words[i]=67108863&e,o=e>>>26;if(this.length=r.length,0!==o)this.words[this.length]=o,this.length++;else if(r!==this)for(;i<r.length;i++)this.words[i]=r.words[i];return this},o.prototype.add=function(t){var e;return 0!==t.negative&&0===this.negative?(t.negative=0,e=this.sub(t),t.negative^=1,e):0===t.negative&&0!==this.negative?(this.negative=0,e=t.sub(this),this.negative=1,e):this.length>t.length?this.clone().iadd(t):t.clone().iadd(this)},o.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,n,o=this.cmp(t);if(0===o)return this.negative=0,this.length=1,this.words[0]=0,this;o>0?(r=this,n=t):(r=t,n=this);for(var i=0,s=0;s<n.length;s++)i=(e=(0|r.words[s])-(0|n.words[s])+i)>>26,this.words[s]=67108863&e;for(;0!==i&&s<r.length;s++)i=(e=(0|r.words[s])+i)>>26,this.words[s]=67108863&e;if(0===i&&s<r.length&&r!==this)for(;s<r.length;s++)this.words[s]=r.words[s];return this.length=Math.max(this.length,s),r!==this&&(this.negative=1),this._strip()},o.prototype.sub=function(t){return this.clone().isub(t)};var f=function(t,e,r){var n,o,i,s=t.words,a=e.words,u=r.words,c=0,h=0|s[0],l=8191&h,d=h>>>13,p=0|s[1],m=8191&p,f=p>>>13,g=0|s[2],y=8191&g,w=g>>>13,v=0|s[3],b=8191&v,M=v>>>13,P=0|s[4],k=8191&P,A=P>>>13,S=0|s[5],T=8191&S,I=S>>>13,C=0|s[6],x=8191&C,E=C>>>13,_=0|s[7],O=8191&_,R=_>>>13,D=0|s[8],B=8191&D,L=D>>>13,U=0|s[9],K=8191&U,W=U>>>13,N=0|a[0],q=8191&N,F=N>>>13,V=0|a[1],j=8191&V,Y=V>>>13,z=0|a[2],Z=8191&z,H=z>>>13,G=0|a[3],$=8191&G,Q=G>>>13,X=0|a[4],J=8191&X,tt=X>>>13,et=0|a[5],rt=8191&et,nt=et>>>13,ot=0|a[6],it=8191&ot,st=ot>>>13,at=0|a[7],ut=8191&at,ct=at>>>13,ht=0|a[8],lt=8191&ht,dt=ht>>>13,pt=0|a[9],mt=8191&pt,ft=pt>>>13;r.negative=t.negative^e.negative,r.length=19;var gt=(c+(n=Math.imul(l,q))|0)+((8191&(o=(o=Math.imul(l,F))+Math.imul(d,q)|0))<<13)|0;c=((i=Math.imul(d,F))+(o>>>13)|0)+(gt>>>26)|0,gt&=67108863,n=Math.imul(m,q),o=(o=Math.imul(m,F))+Math.imul(f,q)|0,i=Math.imul(f,F);var yt=(c+(n=n+Math.imul(l,j)|0)|0)+((8191&(o=(o=o+Math.imul(l,Y)|0)+Math.imul(d,j)|0))<<13)|0;c=((i=i+Math.imul(d,Y)|0)+(o>>>13)|0)+(yt>>>26)|0,yt&=67108863,n=Math.imul(y,q),o=(o=Math.imul(y,F))+Math.imul(w,q)|0,i=Math.imul(w,F),n=n+Math.imul(m,j)|0,o=(o=o+Math.imul(m,Y)|0)+Math.imul(f,j)|0,i=i+Math.imul(f,Y)|0;var wt=(c+(n=n+Math.imul(l,Z)|0)|0)+((8191&(o=(o=o+Math.imul(l,H)|0)+Math.imul(d,Z)|0))<<13)|0;c=((i=i+Math.imul(d,H)|0)+(o>>>13)|0)+(wt>>>26)|0,wt&=67108863,n=Math.imul(b,q),o=(o=Math.imul(b,F))+Math.imul(M,q)|0,i=Math.imul(M,F),n=n+Math.imul(y,j)|0,o=(o=o+Math.imul(y,Y)|0)+Math.imul(w,j)|0,i=i+Math.imul(w,Y)|0,n=n+Math.imul(m,Z)|0,o=(o=o+Math.imul(m,H)|0)+Math.imul(f,Z)|0,i=i+Math.imul(f,H)|0;var vt=(c+(n=n+Math.imul(l,$)|0)|0)+((8191&(o=(o=o+Math.imul(l,Q)|0)+Math.imul(d,$)|0))<<13)|0;c=((i=i+Math.imul(d,Q)|0)+(o>>>13)|0)+(vt>>>26)|0,vt&=67108863,n=Math.imul(k,q),o=(o=Math.imul(k,F))+Math.imul(A,q)|0,i=Math.imul(A,F),n=n+Math.imul(b,j)|0,o=(o=o+Math.imul(b,Y)|0)+Math.imul(M,j)|0,i=i+Math.imul(M,Y)|0,n=n+Math.imul(y,Z)|0,o=(o=o+Math.imul(y,H)|0)+Math.imul(w,Z)|0,i=i+Math.imul(w,H)|0,n=n+Math.imul(m,$)|0,o=(o=o+Math.imul(m,Q)|0)+Math.imul(f,$)|0,i=i+Math.imul(f,Q)|0;var bt=(c+(n=n+Math.imul(l,J)|0)|0)+((8191&(o=(o=o+Math.imul(l,tt)|0)+Math.imul(d,J)|0))<<13)|0;c=((i=i+Math.imul(d,tt)|0)+(o>>>13)|0)+(bt>>>26)|0,bt&=67108863,n=Math.imul(T,q),o=(o=Math.imul(T,F))+Math.imul(I,q)|0,i=Math.imul(I,F),n=n+Math.imul(k,j)|0,o=(o=o+Math.imul(k,Y)|0)+Math.imul(A,j)|0,i=i+Math.imul(A,Y)|0,n=n+Math.imul(b,Z)|0,o=(o=o+Math.imul(b,H)|0)+Math.imul(M,Z)|0,i=i+Math.imul(M,H)|0,n=n+Math.imul(y,$)|0,o=(o=o+Math.imul(y,Q)|0)+Math.imul(w,$)|0,i=i+Math.imul(w,Q)|0,n=n+Math.imul(m,J)|0,o=(o=o+Math.imul(m,tt)|0)+Math.imul(f,J)|0,i=i+Math.imul(f,tt)|0;var Mt=(c+(n=n+Math.imul(l,rt)|0)|0)+((8191&(o=(o=o+Math.imul(l,nt)|0)+Math.imul(d,rt)|0))<<13)|0;c=((i=i+Math.imul(d,nt)|0)+(o>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,n=Math.imul(x,q),o=(o=Math.imul(x,F))+Math.imul(E,q)|0,i=Math.imul(E,F),n=n+Math.imul(T,j)|0,o=(o=o+Math.imul(T,Y)|0)+Math.imul(I,j)|0,i=i+Math.imul(I,Y)|0,n=n+Math.imul(k,Z)|0,o=(o=o+Math.imul(k,H)|0)+Math.imul(A,Z)|0,i=i+Math.imul(A,H)|0,n=n+Math.imul(b,$)|0,o=(o=o+Math.imul(b,Q)|0)+Math.imul(M,$)|0,i=i+Math.imul(M,Q)|0,n=n+Math.imul(y,J)|0,o=(o=o+Math.imul(y,tt)|0)+Math.imul(w,J)|0,i=i+Math.imul(w,tt)|0,n=n+Math.imul(m,rt)|0,o=(o=o+Math.imul(m,nt)|0)+Math.imul(f,rt)|0,i=i+Math.imul(f,nt)|0;var Pt=(c+(n=n+Math.imul(l,it)|0)|0)+((8191&(o=(o=o+Math.imul(l,st)|0)+Math.imul(d,it)|0))<<13)|0;c=((i=i+Math.imul(d,st)|0)+(o>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,n=Math.imul(O,q),o=(o=Math.imul(O,F))+Math.imul(R,q)|0,i=Math.imul(R,F),n=n+Math.imul(x,j)|0,o=(o=o+Math.imul(x,Y)|0)+Math.imul(E,j)|0,i=i+Math.imul(E,Y)|0,n=n+Math.imul(T,Z)|0,o=(o=o+Math.imul(T,H)|0)+Math.imul(I,Z)|0,i=i+Math.imul(I,H)|0,n=n+Math.imul(k,$)|0,o=(o=o+Math.imul(k,Q)|0)+Math.imul(A,$)|0,i=i+Math.imul(A,Q)|0,n=n+Math.imul(b,J)|0,o=(o=o+Math.imul(b,tt)|0)+Math.imul(M,J)|0,i=i+Math.imul(M,tt)|0,n=n+Math.imul(y,rt)|0,o=(o=o+Math.imul(y,nt)|0)+Math.imul(w,rt)|0,i=i+Math.imul(w,nt)|0,n=n+Math.imul(m,it)|0,o=(o=o+Math.imul(m,st)|0)+Math.imul(f,it)|0,i=i+Math.imul(f,st)|0;var kt=(c+(n=n+Math.imul(l,ut)|0)|0)+((8191&(o=(o=o+Math.imul(l,ct)|0)+Math.imul(d,ut)|0))<<13)|0;c=((i=i+Math.imul(d,ct)|0)+(o>>>13)|0)+(kt>>>26)|0,kt&=67108863,n=Math.imul(B,q),o=(o=Math.imul(B,F))+Math.imul(L,q)|0,i=Math.imul(L,F),n=n+Math.imul(O,j)|0,o=(o=o+Math.imul(O,Y)|0)+Math.imul(R,j)|0,i=i+Math.imul(R,Y)|0,n=n+Math.imul(x,Z)|0,o=(o=o+Math.imul(x,H)|0)+Math.imul(E,Z)|0,i=i+Math.imul(E,H)|0,n=n+Math.imul(T,$)|0,o=(o=o+Math.imul(T,Q)|0)+Math.imul(I,$)|0,i=i+Math.imul(I,Q)|0,n=n+Math.imul(k,J)|0,o=(o=o+Math.imul(k,tt)|0)+Math.imul(A,J)|0,i=i+Math.imul(A,tt)|0,n=n+Math.imul(b,rt)|0,o=(o=o+Math.imul(b,nt)|0)+Math.imul(M,rt)|0,i=i+Math.imul(M,nt)|0,n=n+Math.imul(y,it)|0,o=(o=o+Math.imul(y,st)|0)+Math.imul(w,it)|0,i=i+Math.imul(w,st)|0,n=n+Math.imul(m,ut)|0,o=(o=o+Math.imul(m,ct)|0)+Math.imul(f,ut)|0,i=i+Math.imul(f,ct)|0;var At=(c+(n=n+Math.imul(l,lt)|0)|0)+((8191&(o=(o=o+Math.imul(l,dt)|0)+Math.imul(d,lt)|0))<<13)|0;c=((i=i+Math.imul(d,dt)|0)+(o>>>13)|0)+(At>>>26)|0,At&=67108863,n=Math.imul(K,q),o=(o=Math.imul(K,F))+Math.imul(W,q)|0,i=Math.imul(W,F),n=n+Math.imul(B,j)|0,o=(o=o+Math.imul(B,Y)|0)+Math.imul(L,j)|0,i=i+Math.imul(L,Y)|0,n=n+Math.imul(O,Z)|0,o=(o=o+Math.imul(O,H)|0)+Math.imul(R,Z)|0,i=i+Math.imul(R,H)|0,n=n+Math.imul(x,$)|0,o=(o=o+Math.imul(x,Q)|0)+Math.imul(E,$)|0,i=i+Math.imul(E,Q)|0,n=n+Math.imul(T,J)|0,o=(o=o+Math.imul(T,tt)|0)+Math.imul(I,J)|0,i=i+Math.imul(I,tt)|0,n=n+Math.imul(k,rt)|0,o=(o=o+Math.imul(k,nt)|0)+Math.imul(A,rt)|0,i=i+Math.imul(A,nt)|0,n=n+Math.imul(b,it)|0,o=(o=o+Math.imul(b,st)|0)+Math.imul(M,it)|0,i=i+Math.imul(M,st)|0,n=n+Math.imul(y,ut)|0,o=(o=o+Math.imul(y,ct)|0)+Math.imul(w,ut)|0,i=i+Math.imul(w,ct)|0,n=n+Math.imul(m,lt)|0,o=(o=o+Math.imul(m,dt)|0)+Math.imul(f,lt)|0,i=i+Math.imul(f,dt)|0;var St=(c+(n=n+Math.imul(l,mt)|0)|0)+((8191&(o=(o=o+Math.imul(l,ft)|0)+Math.imul(d,mt)|0))<<13)|0;c=((i=i+Math.imul(d,ft)|0)+(o>>>13)|0)+(St>>>26)|0,St&=67108863,n=Math.imul(K,j),o=(o=Math.imul(K,Y))+Math.imul(W,j)|0,i=Math.imul(W,Y),n=n+Math.imul(B,Z)|0,o=(o=o+Math.imul(B,H)|0)+Math.imul(L,Z)|0,i=i+Math.imul(L,H)|0,n=n+Math.imul(O,$)|0,o=(o=o+Math.imul(O,Q)|0)+Math.imul(R,$)|0,i=i+Math.imul(R,Q)|0,n=n+Math.imul(x,J)|0,o=(o=o+Math.imul(x,tt)|0)+Math.imul(E,J)|0,i=i+Math.imul(E,tt)|0,n=n+Math.imul(T,rt)|0,o=(o=o+Math.imul(T,nt)|0)+Math.imul(I,rt)|0,i=i+Math.imul(I,nt)|0,n=n+Math.imul(k,it)|0,o=(o=o+Math.imul(k,st)|0)+Math.imul(A,it)|0,i=i+Math.imul(A,st)|0,n=n+Math.imul(b,ut)|0,o=(o=o+Math.imul(b,ct)|0)+Math.imul(M,ut)|0,i=i+Math.imul(M,ct)|0,n=n+Math.imul(y,lt)|0,o=(o=o+Math.imul(y,dt)|0)+Math.imul(w,lt)|0,i=i+Math.imul(w,dt)|0;var Tt=(c+(n=n+Math.imul(m,mt)|0)|0)+((8191&(o=(o=o+Math.imul(m,ft)|0)+Math.imul(f,mt)|0))<<13)|0;c=((i=i+Math.imul(f,ft)|0)+(o>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,n=Math.imul(K,Z),o=(o=Math.imul(K,H))+Math.imul(W,Z)|0,i=Math.imul(W,H),n=n+Math.imul(B,$)|0,o=(o=o+Math.imul(B,Q)|0)+Math.imul(L,$)|0,i=i+Math.imul(L,Q)|0,n=n+Math.imul(O,J)|0,o=(o=o+Math.imul(O,tt)|0)+Math.imul(R,J)|0,i=i+Math.imul(R,tt)|0,n=n+Math.imul(x,rt)|0,o=(o=o+Math.imul(x,nt)|0)+Math.imul(E,rt)|0,i=i+Math.imul(E,nt)|0,n=n+Math.imul(T,it)|0,o=(o=o+Math.imul(T,st)|0)+Math.imul(I,it)|0,i=i+Math.imul(I,st)|0,n=n+Math.imul(k,ut)|0,o=(o=o+Math.imul(k,ct)|0)+Math.imul(A,ut)|0,i=i+Math.imul(A,ct)|0,n=n+Math.imul(b,lt)|0,o=(o=o+Math.imul(b,dt)|0)+Math.imul(M,lt)|0,i=i+Math.imul(M,dt)|0;var It=(c+(n=n+Math.imul(y,mt)|0)|0)+((8191&(o=(o=o+Math.imul(y,ft)|0)+Math.imul(w,mt)|0))<<13)|0;c=((i=i+Math.imul(w,ft)|0)+(o>>>13)|0)+(It>>>26)|0,It&=67108863,n=Math.imul(K,$),o=(o=Math.imul(K,Q))+Math.imul(W,$)|0,i=Math.imul(W,Q),n=n+Math.imul(B,J)|0,o=(o=o+Math.imul(B,tt)|0)+Math.imul(L,J)|0,i=i+Math.imul(L,tt)|0,n=n+Math.imul(O,rt)|0,o=(o=o+Math.imul(O,nt)|0)+Math.imul(R,rt)|0,i=i+Math.imul(R,nt)|0,n=n+Math.imul(x,it)|0,o=(o=o+Math.imul(x,st)|0)+Math.imul(E,it)|0,i=i+Math.imul(E,st)|0,n=n+Math.imul(T,ut)|0,o=(o=o+Math.imul(T,ct)|0)+Math.imul(I,ut)|0,i=i+Math.imul(I,ct)|0,n=n+Math.imul(k,lt)|0,o=(o=o+Math.imul(k,dt)|0)+Math.imul(A,lt)|0,i=i+Math.imul(A,dt)|0;var Ct=(c+(n=n+Math.imul(b,mt)|0)|0)+((8191&(o=(o=o+Math.imul(b,ft)|0)+Math.imul(M,mt)|0))<<13)|0;c=((i=i+Math.imul(M,ft)|0)+(o>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,n=Math.imul(K,J),o=(o=Math.imul(K,tt))+Math.imul(W,J)|0,i=Math.imul(W,tt),n=n+Math.imul(B,rt)|0,o=(o=o+Math.imul(B,nt)|0)+Math.imul(L,rt)|0,i=i+Math.imul(L,nt)|0,n=n+Math.imul(O,it)|0,o=(o=o+Math.imul(O,st)|0)+Math.imul(R,it)|0,i=i+Math.imul(R,st)|0,n=n+Math.imul(x,ut)|0,o=(o=o+Math.imul(x,ct)|0)+Math.imul(E,ut)|0,i=i+Math.imul(E,ct)|0,n=n+Math.imul(T,lt)|0,o=(o=o+Math.imul(T,dt)|0)+Math.imul(I,lt)|0,i=i+Math.imul(I,dt)|0;var xt=(c+(n=n+Math.imul(k,mt)|0)|0)+((8191&(o=(o=o+Math.imul(k,ft)|0)+Math.imul(A,mt)|0))<<13)|0;c=((i=i+Math.imul(A,ft)|0)+(o>>>13)|0)+(xt>>>26)|0,xt&=67108863,n=Math.imul(K,rt),o=(o=Math.imul(K,nt))+Math.imul(W,rt)|0,i=Math.imul(W,nt),n=n+Math.imul(B,it)|0,o=(o=o+Math.imul(B,st)|0)+Math.imul(L,it)|0,i=i+Math.imul(L,st)|0,n=n+Math.imul(O,ut)|0,o=(o=o+Math.imul(O,ct)|0)+Math.imul(R,ut)|0,i=i+Math.imul(R,ct)|0,n=n+Math.imul(x,lt)|0,o=(o=o+Math.imul(x,dt)|0)+Math.imul(E,lt)|0,i=i+Math.imul(E,dt)|0;var Et=(c+(n=n+Math.imul(T,mt)|0)|0)+((8191&(o=(o=o+Math.imul(T,ft)|0)+Math.imul(I,mt)|0))<<13)|0;c=((i=i+Math.imul(I,ft)|0)+(o>>>13)|0)+(Et>>>26)|0,Et&=67108863,n=Math.imul(K,it),o=(o=Math.imul(K,st))+Math.imul(W,it)|0,i=Math.imul(W,st),n=n+Math.imul(B,ut)|0,o=(o=o+Math.imul(B,ct)|0)+Math.imul(L,ut)|0,i=i+Math.imul(L,ct)|0,n=n+Math.imul(O,lt)|0,o=(o=o+Math.imul(O,dt)|0)+Math.imul(R,lt)|0,i=i+Math.imul(R,dt)|0;var _t=(c+(n=n+Math.imul(x,mt)|0)|0)+((8191&(o=(o=o+Math.imul(x,ft)|0)+Math.imul(E,mt)|0))<<13)|0;c=((i=i+Math.imul(E,ft)|0)+(o>>>13)|0)+(_t>>>26)|0,_t&=67108863,n=Math.imul(K,ut),o=(o=Math.imul(K,ct))+Math.imul(W,ut)|0,i=Math.imul(W,ct),n=n+Math.imul(B,lt)|0,o=(o=o+Math.imul(B,dt)|0)+Math.imul(L,lt)|0,i=i+Math.imul(L,dt)|0;var Ot=(c+(n=n+Math.imul(O,mt)|0)|0)+((8191&(o=(o=o+Math.imul(O,ft)|0)+Math.imul(R,mt)|0))<<13)|0;c=((i=i+Math.imul(R,ft)|0)+(o>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,n=Math.imul(K,lt),o=(o=Math.imul(K,dt))+Math.imul(W,lt)|0,i=Math.imul(W,dt);var Rt=(c+(n=n+Math.imul(B,mt)|0)|0)+((8191&(o=(o=o+Math.imul(B,ft)|0)+Math.imul(L,mt)|0))<<13)|0;c=((i=i+Math.imul(L,ft)|0)+(o>>>13)|0)+(Rt>>>26)|0,Rt&=67108863;var Dt=(c+(n=Math.imul(K,mt))|0)+((8191&(o=(o=Math.imul(K,ft))+Math.imul(W,mt)|0))<<13)|0;return c=((i=Math.imul(W,ft))+(o>>>13)|0)+(Dt>>>26)|0,Dt&=67108863,u[0]=gt,u[1]=yt,u[2]=wt,u[3]=vt,u[4]=bt,u[5]=Mt,u[6]=Pt,u[7]=kt,u[8]=At,u[9]=St,u[10]=Tt,u[11]=It,u[12]=Ct,u[13]=xt,u[14]=Et,u[15]=_t,u[16]=Ot,u[17]=Rt,u[18]=Dt,0!==c&&(u[19]=c,r.length++),r};function g(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var n=0,o=0,i=0;i<r.length-1;i++){var s=o;o=0;for(var a=67108863&n,u=Math.min(i,e.length-1),c=Math.max(0,i-t.length+1);c<=u;c++){var h=i-c,l=(0|t.words[h])*(0|e.words[c]),d=67108863&l;a=67108863&(d=d+a|0),o+=(s=(s=s+(l/67108864|0)|0)+(d>>>26)|0)>>>26,s&=67108863}r.words[i]=a,n=s,s=o}return 0!==n?r.words[i]=n:r.length--,r._strip()}function y(t,e,r){return g(t,e,r)}Math.imul||(f=m),o.prototype.mulTo=function(t,e){var r=this.length+t.length;return 10===this.length&&10===t.length?f(this,t,e):r<63?m(this,t,e):r<1024?g(this,t,e):y(this,t,e)},o.prototype.mul=function(t){var e=new o(null);return e.words=new Array(this.length+t.length),this.mulTo(t,e)},o.prototype.mulf=function(t){var e=new o(null);return e.words=new Array(this.length+t.length),y(this,t,e)},o.prototype.imul=function(t){return this.clone().mulTo(t,this)},o.prototype.imuln=function(t){var e=t<0;e&&(t=-t),r("number"==typeof t),r(t<67108864);for(var n=0,o=0;o<this.length;o++){var i=(0|this.words[o])*t,s=(67108863&i)+(67108863&n);n>>=26,n+=i/67108864|0,n+=s>>>26,this.words[o]=67108863&s}return 0!==n&&(this.words[o]=n,this.length++),e?this.ineg():this},o.prototype.muln=function(t){return this.clone().imuln(t)},o.prototype.sqr=function(){return this.mul(this)},o.prototype.isqr=function(){return this.imul(this.clone())},o.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),r=0;r<e.length;r++){var n=r/26|0,o=r%26;e[r]=t.words[n]>>>o&1}return e}(t);if(0===e.length)return new o(1);for(var r=this,n=0;n<e.length&&0===e[n];n++,r=r.sqr());if(++n<e.length)for(var i=r.sqr();n<e.length;n++,i=i.sqr())0!==e[n]&&(r=r.mul(i));return r},o.prototype.iushln=function(t){r("number"==typeof t&&t>=0);var e,n=t%26,o=(t-n)/26,i=67108863>>>26-n<<26-n;if(0!==n){var s=0;for(e=0;e<this.length;e++){var a=this.words[e]&i,u=(0|this.words[e])-a<<n;this.words[e]=u|s,s=a>>>26-n}s&&(this.words[e]=s,this.length++)}if(0!==o){for(e=this.length-1;e>=0;e--)this.words[e+o]=this.words[e];for(e=0;e<o;e++)this.words[e]=0;this.length+=o}return this._strip()},o.prototype.ishln=function(t){return r(0===this.negative),this.iushln(t)},o.prototype.iushrn=function(t,e,n){var o;r("number"==typeof t&&t>=0),o=e?(e-e%26)/26:0;var i=t%26,s=Math.min((t-i)/26,this.length),a=67108863^67108863>>>i<<i,u=n;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 h=0;for(c=this.length-1;c>=0&&(0!==h||c>=o);c--){var l=0|this.words[c];this.words[c]=h<<26-i|l>>>i,h=l&a}return u&&0!==h&&(u.words[u.length++]=h),0===this.length&&(this.words[0]=0,this.length=1),this._strip()},o.prototype.ishrn=function(t,e,n){return r(0===this.negative),this.iushrn(t,e,n)},o.prototype.shln=function(t){return this.clone().ishln(t)},o.prototype.ushln=function(t){return this.clone().iushln(t)},o.prototype.shrn=function(t){return this.clone().ishrn(t)},o.prototype.ushrn=function(t){return this.clone().iushrn(t)},o.prototype.testn=function(t){r("number"==typeof t&&t>=0);var e=t%26,n=(t-e)/26,o=1<<e;return this.length<=n?0:!!(this.words[n]&o)},o.prototype.imaskn=function(t){r("number"==typeof t&&t>=0);var e=t%26,n=(t-e)/26;if(r(0===this.negative,"imaskn works only with positive numbers"),this.length<=n)return this;if(0!==e&&n++,this.length=Math.min(n,this.length),0!==e){var o=67108863^67108863>>>e<<e;this.words[this.length-1]&=o}return this._strip()},o.prototype.maskn=function(t){return this.clone().imaskn(t)},o.prototype.iaddn=function(t){return r("number"==typeof t),r(t<67108864),t<0?this.isubn(-t):0!==this.negative?1===this.length&&(0|this.words[0])<=t?(this.words[0]=t-(0|this.words[0]),this.negative=0,this):(this.negative=0,this.isubn(t),this.negative=1,this):this._iaddn(t)},o.prototype._iaddn=function(t){this.words[0]+=t;for(var e=0;e<this.length&&this.words[e]>=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},o.prototype.isubn=function(t){if(r("number"==typeof t),r(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e<this.length&&this.words[e]<0;e++)this.words[e]+=67108864,this.words[e+1]-=1;return this._strip()},o.prototype.addn=function(t){return this.clone().iaddn(t)},o.prototype.subn=function(t){return this.clone().isubn(t)},o.prototype.iabs=function(){return this.negative=0,this},o.prototype.abs=function(){return this.clone().iabs()},o.prototype._ishlnsubmul=function(t,e,n){var o,i,s=t.length+n;this._expand(s);var a=0;for(o=0;o<t.length;o++){i=(0|this.words[o+n])+a;var u=(0|t.words[o])*e;a=((i-=67108863&u)>>26)-(u/67108864|0),this.words[o+n]=67108863&i}for(;o<this.length-n;o++)a=(i=(0|this.words[o+n])+a)>>26,this.words[o+n]=67108863&i;if(0===a)return this._strip();for(r(-1===a),a=0,o=0;o<this.length;o++)a=(i=-(0|this.words[o])+a)>>26,this.words[o]=67108863&i;return this.negative=1,this._strip()},o.prototype._wordDiv=function(t,e){var r=(this.length,t.length),n=this.clone(),i=t,s=0|i.words[i.length-1];0!=(r=26-this._countBits(s))&&(i=i.ushln(r),n.iushln(r),s=0|i.words[i.length-1]);var a,u=n.length-i.length;if("mod"!==e){(a=new o(null)).length=u+1,a.words=new Array(a.length);for(var c=0;c<a.length;c++)a.words[c]=0}var h=n.clone()._ishlnsubmul(i,1,u);0===h.negative&&(n=h,a&&(a.words[u]=1));for(var l=u-1;l>=0;l--){var d=67108864*(0|n.words[i.length+l])+(0|n.words[i.length+l-1]);for(d=Math.min(d/s|0,67108863),n._ishlnsubmul(i,d,l);0!==n.negative;)d--,n.negative=0,n._ishlnsubmul(i,1,l),n.isZero()||(n.negative^=1);a&&(a.words[l]=d)}return a&&a._strip(),n._strip(),"div"!==e&&0!==r&&n.iushrn(r),{div:a||null,mod:n}},o.prototype.divmod=function(t,e,n){return r(!t.isZero()),this.isZero()?{div:new o(0),mod:new o(0)}:0!==this.negative&&0===t.negative?(a=this.neg().divmod(t,e),"mod"!==e&&(i=a.div.neg()),"div"!==e&&(s=a.mod.neg(),n&&0!==s.negative&&s.iadd(t)),{div:i,mod:s}):0===this.negative&&0!==t.negative?(a=this.divmod(t.neg(),e),"mod"!==e&&(i=a.div.neg()),{div:i,mod:a.mod}):0!=(this.negative&t.negative)?(a=this.neg().divmod(t.neg(),e),"div"!==e&&(s=a.mod.neg(),n&&0!==s.negative&&s.isub(t)),{div:a.div,mod:s}):t.length>this.length||this.cmp(t)<0?{div:new o(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new o(this.modrn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new o(this.modrn(t.words[0]))}:this._wordDiv(t,e);var i,s,a},o.prototype.div=function(t){return this.divmod(t,"div",0).div},o.prototype.mod=function(t){return this.divmod(t,"mod",0).mod},o.prototype.umod=function(t){return this.divmod(t,"mod",1).mod},o.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,n=t.ushrn(1),o=t.andln(1),i=r.cmp(n);return i<0||1===o&&0===i?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},o.prototype.modrn=function(t){var e=t<0;e&&(t=-t),r(t<=67108863);for(var n=(1<<26)%t,o=0,i=this.length-1;i>=0;i--)o=(n*o+(0|this.words[i]))%t;return e?-o:o},o.prototype.modn=function(t){return this.modrn(t)},o.prototype.idivn=function(t){var e=t<0;e&&(t=-t),r(t<=67108863);for(var n=0,o=this.length-1;o>=0;o--){var i=(0|this.words[o])+67108864*n;this.words[o]=i/t|0,n=i%t}return this._strip(),e?this.ineg():this},o.prototype.divn=function(t){return this.clone().idivn(t)},o.prototype.egcd=function(t){r(0===t.negative),r(!t.isZero());var e=this,n=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var i=new o(1),s=new o(0),a=new o(0),u=new o(1),c=0;e.isEven()&&n.isEven();)e.iushrn(1),n.iushrn(1),++c;for(var h=n.clone(),l=e.clone();!e.isZero();){for(var d=0,p=1;0==(e.words[0]&p)&&d<26;++d,p<<=1);if(d>0)for(e.iushrn(d);d-- >0;)(i.isOdd()||s.isOdd())&&(i.iadd(h),s.isub(l)),i.iushrn(1),s.iushrn(1);for(var m=0,f=1;0==(n.words[0]&f)&&m<26;++m,f<<=1);if(m>0)for(n.iushrn(m);m-- >0;)(a.isOdd()||u.isOdd())&&(a.iadd(h),u.isub(l)),a.iushrn(1),u.iushrn(1);e.cmp(n)>=0?(e.isub(n),i.isub(a),s.isub(u)):(n.isub(e),a.isub(i),u.isub(s))}return{a:a,b:u,gcd:n.iushln(c)}},o.prototype._invmp=function(t){r(0===t.negative),r(!t.isZero());var e=this,n=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var i,s=new o(1),a=new o(0),u=n.clone();e.cmpn(1)>0&&n.cmpn(1)>0;){for(var c=0,h=1;0==(e.words[0]&h)&&c<26;++c,h<<=1);if(c>0)for(e.iushrn(c);c-- >0;)s.isOdd()&&s.iadd(u),s.iushrn(1);for(var l=0,d=1;0==(n.words[0]&d)&&l<26;++l,d<<=1);if(l>0)for(n.iushrn(l);l-- >0;)a.isOdd()&&a.iadd(u),a.iushrn(1);e.cmp(n)>=0?(e.isub(n),s.isub(a)):(n.isub(e),a.isub(s))}return(i=0===e.cmpn(1)?s:a).cmpn(0)<0&&i.iadd(t),i},o.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var n=0;e.isEven()&&r.isEven();n++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var o=e.cmp(r);if(o<0){var i=e;e=r,r=i}else if(0===o||0===r.cmpn(1))break;e.isub(r)}return r.iushln(n)},o.prototype.invm=function(t){return this.egcd(t).a.umod(t)},o.prototype.isEven=function(){return 0==(1&this.words[0])},o.prototype.isOdd=function(){return 1==(1&this.words[0])},o.prototype.andln=function(t){return this.words[0]&t},o.prototype.bincn=function(t){r("number"==typeof t);var e=t%26,n=(t-e)/26,o=1<<e;if(this.length<=n)return this._expand(n+1),this.words[n]|=o,this;for(var i=o,s=n;0!==i&&s<this.length;s++){var a=0|this.words[s];i=(a+=i)>>>26,a&=67108863,this.words[s]=a}return 0!==i&&(this.words[s]=i,this.length++),this},o.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},o.prototype.cmpn=function(t){var e,n=t<0;if(0!==this.negative&&!n)return-1;if(0===this.negative&&n)return 1;if(this._strip(),this.length>1)e=1;else{n&&(t=-t),r(t<=67108863,"Number is too big");var o=0|this.words[0];e=o===t?0:o<t?-1:1}return 0!==this.negative?0|-e:e},o.prototype.cmp=function(t){if(0!==this.negative&&0===t.negative)return-1;if(0===this.negative&&0!==t.negative)return 1;var e=this.ucmp(t);return 0!==this.negative?0|-e:e},o.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length<t.length)return-1;for(var e=0,r=this.length-1;r>=0;r--){var n=0|this.words[r],o=0|t.words[r];if(n!==o){n<o?e=-1:n>o&&(e=1);break}}return e},o.prototype.gtn=function(t){return 1===this.cmpn(t)},o.prototype.gt=function(t){return 1===this.cmp(t)},o.prototype.gten=function(t){return this.cmpn(t)>=0},o.prototype.gte=function(t){return this.cmp(t)>=0},o.prototype.ltn=function(t){return-1===this.cmpn(t)},o.prototype.lt=function(t){return-1===this.cmp(t)},o.prototype.lten=function(t){return this.cmpn(t)<=0},o.prototype.lte=function(t){return this.cmp(t)<=0},o.prototype.eqn=function(t){return 0===this.cmpn(t)},o.prototype.eq=function(t){return 0===this.cmp(t)},o.red=function(t){return new A(t)},o.prototype.toRed=function(t){return r(!this.red,"Already a number in reduction context"),r(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},o.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},o.prototype._forceRed=function(t){return this.red=t,this},o.prototype.forceRed=function(t){return r(!this.red,"Already a number in reduction context"),this._forceRed(t)},o.prototype.redAdd=function(t){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},o.prototype.redIAdd=function(t){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},o.prototype.redSub=function(t){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},o.prototype.redISub=function(t){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},o.prototype.redShl=function(t){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},o.prototype.redMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},o.prototype.redIMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},o.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(t){return r(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var w={k256:null,p224:null,p192:null,p25519:null};function v(t,e){this.name=t,this.p=new o(e,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function b(){v.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function M(){v.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function P(){v.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function k(){v.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function A(t){if("string"==typeof t){var e=o._prime(t);this.m=e.p,this.prime=e}else r(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function S(t){A.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new o(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}v.prototype._tmp=function(){var t=new o(null);return t.words=new Array(Math.ceil(this.n/13)),t},v.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var n=e<this.n?-1:r.ucmp(this.p);return 0===n?(r.words[0]=0,r.length=1):n>0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},v.prototype.split=function(t,e){t.iushrn(this.n,0,e)},v.prototype.imulK=function(t){return t.imul(this.k)},n(b,v),b.prototype.split=function(t,e){for(var r=4194303,n=Math.min(t.length,9),o=0;o<n;o++)e.words[o]=t.words[o];if(e.length=n,t.length<=9)return t.words[0]=0,void(t.length=1);var i=t.words[9];for(e.words[e.length++]=i&r,o=10;o<t.length;o++){var s=0|t.words[o];t.words[o-10]=(s&r)<<4|i>>>22,i=s}i>>>=22,t.words[o-10]=i,0===i&&t.length>10?t.length-=10:t.length-=9},b.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r<t.length;r++){var n=0|t.words[r];e+=977*n,t.words[r]=67108863&e,e=64*n+(e/67108864|0)}return 0===t.words[t.length-1]&&(t.length--,0===t.words[t.length-1]&&t.length--),t},n(M,v),n(P,v),n(k,v),k.prototype.imulK=function(t){for(var e=0,r=0;r<t.length;r++){var n=19*(0|t.words[r])+e,o=67108863&n;n>>>=26,t.words[r]=o,e=n}return 0!==e&&(t.words[t.length++]=e),t},o._prime=function(t){if(w[t])return w[t];var e;if("k256"===t)e=new b;else if("p224"===t)e=new M;else if("p192"===t)e=new P;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new k}return w[t]=e,e},A.prototype._verify1=function(t){r(0===t.negative,"red works only with positives"),r(t.red,"red works only with red numbers")},A.prototype._verify2=function(t,e){r(0==(t.negative|e.negative),"red works only with positives"),r(t.red&&t.red===e.red,"red works only with red numbers")},A.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):(c(t,t.umod(this.m)._forceRed(this)),t)},A.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},A.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},A.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},A.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},A.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},A.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},A.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},A.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},A.prototype.isqr=function(t){return this.imul(t,t.clone())},A.prototype.sqr=function(t){return this.mul(t,t)},A.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(r(e%2==1),3===e){var n=this.m.add(new o(1)).iushrn(2);return this.pow(t,n)}for(var i=this.m.subn(1),s=0;!i.isZero()&&0===i.andln(1);)s++,i.iushrn(1);r(!i.isZero());var a=new o(1).toRed(this),u=a.redNeg(),c=this.m.subn(1).iushrn(1),h=this.m.bitLength();for(h=new o(2*h*h).toRed(this);0!==this.pow(h,c).cmp(u);)h.redIAdd(u);for(var l=this.pow(h,i),d=this.pow(t,i.addn(1).iushrn(1)),p=this.pow(t,i),m=s;0!==p.cmp(a);){for(var f=p,g=0;0!==f.cmp(a);g++)f=f.redSqr();r(g<m);var y=this.pow(l,new o(1).iushln(m-g-1));d=d.redMul(y),l=y.redSqr(),p=p.redMul(l),m=g}return d},A.prototype.invm=function(t){var e=t._invmp(this.m);return 0!==e.negative?(e.negative=0,this.imod(e).redNeg()):this.imod(e)},A.prototype.pow=function(t,e){if(e.isZero())return new o(1).toRed(this);if(0===e.cmpn(1))return t.clone();var r=new Array(16);r[0]=new o(1).toRed(this),r[1]=t;for(var n=2;n<r.length;n++)r[n]=this.mul(r[n-1],t);var i=r[0],s=0,a=0,u=e.bitLength()%26;for(0===u&&(u=26),n=e.length-1;n>=0;n--){for(var c=e.words[n],h=u-1;h>=0;h--){var l=c>>h&1;i!==r[0]&&(i=this.sqr(i)),0!==l||0!==s?(s<<=1,s|=l,(4==++a||0===n&&0===h)&&(i=this.mul(i,r[s]),a=0,s=0)):a=0}u=26}return i},A.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},A.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},o.mont=function(t){return new S(t)},n(S,A),S.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},S.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},S.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),o=r.isub(n).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)},S.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new o(0)._forceRed(this);var r=t.mul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).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)},S.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(0,Tt);var de=he.exports;!function(e){var r=Tt&&Tt.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:1}),e.map=e.array=e.rustEnum=e.str=e.vecU8=e.tagged=e.vec=e.bool=e.option=e.publicKey=e.i256=e.u256=e.i128=e.u128=e.i64=e.u64=e.struct=e.f64=e.f32=e.i32=e.u32=e.i16=e.u16=e.i8=e.u8=void 0;const n=xt,o=t,i=r(de);var s=xt;Object.defineProperty(e,"u8",{enumerable:1,get:function(){return s.u8}}),Object.defineProperty(e,"i8",{enumerable:1,get:function(){return s.s8}}),Object.defineProperty(e,"u16",{enumerable:1,get:function(){return s.u16}}),Object.defineProperty(e,"i16",{enumerable:1,get:function(){return s.s16}}),Object.defineProperty(e,"u32",{enumerable:1,get:function(){return s.u32}}),Object.defineProperty(e,"i32",{enumerable:1,get:function(){return s.s32}}),Object.defineProperty(e,"f32",{enumerable:1,get:function(){return s.f32}}),Object.defineProperty(e,"f64",{enumerable:1,get:function(){return s.f64}}),Object.defineProperty(e,"struct",{enumerable:1,get:function(){return s.struct}});class a extends n.Layout{constructor(t,e,r){super(t,r),this.blob=(0,n.blob)(t),this.signed=e}decode(t,e=0){const r=new i.default(this.blob.decode(t,e),10,"le");return this.signed?r.fromTwos(8*this.span).clone():r}encode(t,e,r=0){return this.signed&&(t=t.toTwos(8*this.span)),this.blob.encode(t.toArrayLike(Buffer,"le",this.span),e,r)}}function u(t){return new a(8,0,t)}e.u64=u,e.i64=function(t){return new a(8,1,t)},e.u128=function(t){return new a(16,0,t)},e.i128=function(t){return new a(16,1,t)},e.u256=function(t){return new a(32,0,t)},e.i256=function(t){return new a(32,1,t)};class c extends n.Layout{constructor(t,e,r,n){super(t.span,n),this.layout=t,this.decoder=e,this.encoder=r}decode(t,e){return this.decoder(this.layout.decode(t,e))}encode(t,e,r){return this.layout.encode(this.encoder(t),e,r)}getSpan(t,e){return this.layout.getSpan(t,e)}}e.publicKey=function(t){return new c((0,n.blob)(32),(t=>new o.PublicKey(t)),(t=>t.toBuffer()),t)};class h extends n.Layout{constructor(t,e){super(-1,e),this.layout=t,this.discriminator=(0,n.u8)()}encode(t,e,r=0){return null==t?this.discriminator.encode(0,e,r):(this.discriminator.encode(1,e,r),this.layout.encode(t,e,r+1)+1)}decode(t,e=0){const r=this.discriminator.decode(t,e);if(0===r)return null;if(1===r)return this.layout.decode(t,e+1);throw new Error("Invalid option "+this.property)}getSpan(t,e=0){const r=this.discriminator.decode(t,e);if(0===r)return 1;if(1===r)return this.layout.getSpan(t,e+1)+1;throw new Error("Invalid option "+this.property)}}function l(t){if(0===t)return 0;if(1===t)return 1;throw new Error("Invalid bool: "+t)}function d(t){return t?1:0}function p(t){const e=(0,n.u32)("length"),r=(0,n.struct)([e,(0,n.blob)((0,n.offset)(e,-e.span),"data")]);return new c(r,(({data:t})=>t),(t=>({data:t})),t)}e.option=function(t,e){return new h(t,e)},e.bool=function(t){return new c((0,n.u8)(),l,d,t)},e.vec=function(t,e){const r=(0,n.u32)("length"),o=(0,n.struct)([r,(0,n.seq)(t,(0,n.offset)(r,-r.span),"values")]);return new c(o,(({values:t})=>t),(t=>({values:t})),e)},e.tagged=function(t,e,r){const o=(0,n.struct)([u("tag"),e.replicate("data")]);return new c(o,(function({tag:e,data:r}){if(!e.eq(t))throw new Error("Invalid tag, expected: "+t.toString("hex")+", got: "+e.toString("hex"));return r}),(e=>({tag:t,data:e})),r)},e.vecU8=p,e.str=function(t){return new c(p(),(t=>t.toString("utf-8")),(t=>Buffer.from(t,"utf-8")),t)},e.rustEnum=function(t,e,r){const o=(0,n.union)(null!=r?r:(0,n.u8)(),e);return t.forEach(((t,e)=>o.addVariant(e,t,t.property))),o},e.array=function(t,e,r){const o=(0,n.struct)([(0,n.seq)(t,e,"values")]);return new c(o,(({values:t})=>t),(t=>({values:t})),r)};class m extends n.Layout{constructor(t,e,r){super(t.span+e.span,r),this.keyLayout=t,this.valueLayout=e}decode(t,e){return e=e||0,[this.keyLayout.decode(t,e),this.valueLayout.decode(t,e+this.keyLayout.getSpan(t,e))]}encode(t,e,r){r=r||0;const n=this.keyLayout.encode(t[0],e,r);return n+this.valueLayout.encode(t[1],e,r+n)}getSpan(t,e){return this.keyLayout.getSpan(t,e)+this.valueLayout.getSpan(t,e)}}e.map=function(t,e,r){const o=(0,n.u32)("length"),i=(0,n.struct)([o,(0,n.seq)(new m(t,e),(0,n.offset)(o,-o.span),"values")]);return new c(i,(({values:t})=>new Map(t)),(t=>({values:Array.from(t.entries())})),r)}}(Ct);const pe=Ct.struct([Ct.array(Ct.u8(),32,"a"),Ct.array(Ct.u8(),64,"b"),Ct.array(Ct.u8(),32,"c")]),me=Ct.struct([Ct.publicKey("owner"),Ct.u64("amount"),Ct.option(Ct.u64(),"lamports"),Ct.u8("merkleTreeIndex"),Ct.option(Ct.vecU8(),"tlv")]),fe=Ct.struct([Ct.u64("amount"),Ct.option(Ct.u8(),"delegateIndex"),Ct.struct([Ct.u8("merkleTreePubkeyIndex"),Ct.u8("queuePubkeyIndex"),Ct.u32("leafIndex"),Ct.bool("proveByIndex")],"merkleContext"),Ct.u16("rootIndex"),Ct.option(Ct.u64(),"lamports"),Ct.option(Ct.vecU8(),"tlv")]),ge=Ct.struct([Ct.publicKey("owner"),Ct.option(Ct.u8(),"delegateChangeAccountIndex")]),ye=Ct.struct([Ct.bool("setContext"),Ct.bool("firstSetContext"),Ct.u8("cpiContextAccountIndex")]),we=Ct.struct([Ct.option(pe,"proof"),Ct.publicKey("mint"),Ct.option(ge,"delegatedTransfer"),Ct.vec(fe,"inputTokenDataWithContext"),Ct.vec(me,"outputCompressedAccounts"),Ct.bool("isCompress"),Ct.option(Ct.u64(),"compressOrDecompressAmount"),Ct.option(ye,"cpiContext"),Ct.option(Ct.u8(),"lamportsChangeAccountMerkleTreeIndex")]),ve=Ct.struct([Ct.vec(Ct.publicKey(),"recipients"),Ct.vec(Ct.u64(),"amounts"),Ct.option(Ct.u64(),"lamports")]),be=Ct.struct([Ct.vec(Ct.publicKey(),"pubkeys"),Ct.option(Ct.vec(Ct.u64(),"amounts"),"amounts"),Ct.option(Ct.u64(),"lamports"),Ct.option(Ct.u64(),"amount"),Ct.u8("index"),Ct.u8("bump")]),Me=Ct.struct([Ct.publicKey("owner"),Ct.option(Ct.u64(),"remainingAmount"),Ct.option(ye,"cpiContext")]);function Pe(t){const e=w.alloc(1e3),r=ve.encode({recipients:t.recipients,amounts:t.amounts,lamports:t.lamports},e);return w.concat([new Uint8Array(st),new Uint8Array(e.subarray(0,r))])}function ke(t){const e=w.alloc(1e3),r=be.encode(t,e),n=w.alloc(4);n.writeUInt32LE(r,0);const o=e.subarray(0,r);return w.concat([new Uint8Array(at),new Uint8Array(n),new Uint8Array(o)])}function Ae(t){const e=w.alloc(1e3),r=Me.encode({owner:t.owner,remainingAmount:t.remainingAmount,cpiContext:t.cpiContext},e);return w.concat([new Uint8Array(ct),new Uint8Array(e.subarray(0,r))])}function Se(t){const e=w.alloc(1e3),r=we.encode(t,e),n=w.alloc(4);n.writeUInt32LE(r,0);const o=e.subarray(0,r);return w.concat([new Uint8Array(ut),new Uint8Array(n),new Uint8Array(o)])}const Te=t=>{const{feePayer:e,tokenPoolPda:r,systemProgram:n,mint:o,tokenProgram:i,cpiAuthorityPda:s}=t;return[{pubkey:e,isSigner:1,isWritable:1},{pubkey:r,isSigner:0,isWritable:1},{pubkey:n,isSigner:0,isWritable:0},{pubkey:o,isSigner:0,isWritable:1},{pubkey:i,isSigner:0,isWritable:0},{pubkey:s,isSigner:0,isWritable:0}]},Ie=t=>{const{feePayer:e,tokenPoolPda:r,systemProgram:n,mint:o,tokenProgram:i,cpiAuthorityPda:s,existingTokenPoolPda:a}=t;return[{pubkey:e,isSigner:1,isWritable:1},{pubkey:r,isSigner:0,isWritable:1},{pubkey:a,isSigner:0,isWritable:0},{pubkey:n,isSigner:0,isWritable:0},{pubkey:o,isSigner:0,isWritable:1},{pubkey:i,isSigner:0,isWritable:0},{pubkey:s,isSigner:0,isWritable:0}]},Ce=t=>{const e=ze.programId,{feePayer:r,authority:n,cpiAuthorityPda:o,mint:i,tokenPoolPda:s,tokenProgram:a,lightSystemProgram:u,registeredProgramPda:c,noopProgram:h,accountCompressionAuthority:l,accountCompressionProgram:d,merkleTree:p,selfProgram:m,systemProgram:f,solPoolPda:g}=t;return[{pubkey:r,isSigner:1,isWritable:1},{pubkey:n,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:h,isSigner:0,isWritable:0},{pubkey:l,isSigner:0,isWritable:0},{pubkey:d,isSigner:0,isWritable:0},{pubkey:p,isSigner:0,isWritable:1},{pubkey:m,isSigner:0,isWritable:0},{pubkey:f,isSigner:0,isWritable:0},{pubkey:null!=g?g:e,isSigner:0,isWritable:1}]},xe=t=>{const e=ze.programId,{feePayer:r,authority:n,cpiAuthorityPda:o,lightSystemProgram:i,registeredProgramPda:s,noopProgram:a,accountCompressionAuthority:u,accountCompressionProgram:c,selfProgram:h,tokenPoolPda:l,compressOrDecompressTokenAccount:d,tokenProgram:p,systemProgram:m}=t;return[{pubkey:r,isSigner:1,isWritable:1},{pubkey:n,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:h,isSigner:0,isWritable:0},{pubkey:null!=l?l:e,isSigner:0,isWritable:1},{pubkey:null!=d?d:e,isSigner:0,isWritable:1},{pubkey:null!=p?p:e,isSigner:0,isWritable:0},{pubkey:m,isSigner:0,isWritable:0}]},Ee=t=>{const{feePayer:e,authority:r,cpiAuthorityPda:n,lightSystemProgram:o,registeredProgramPda:i,noopProgram:s,accountCompressionAuthority:a,accountCompressionProgram:u,selfProgram:c,systemProgram:h}=t;return[{pubkey:e,isSigner:1,isWritable:1},{pubkey:r,isSigner:1,isWritable:0},{pubkey:n,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:h,isSigner:0,isWritable:0}]},_e=Ee,Oe=t=>{const{feePayer:e,authority:r,cpiAuthorityPda:n,lightSystemProgram:o,registeredProgramPda:i,noopProgram:s,accountCompressionAuthority:a,accountCompressionProgram:u,selfProgram:c,systemProgram:h,mint:l}=t;return[{pubkey:e,isSigner:1,isWritable:1},{pubkey:r,isSigner:1,isWritable:0},{pubkey:n,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:h,isSigner:0,isWritable:0},{pubkey:l,isSigner:0,isWritable:0}]},Re=Oe,De=Ct.struct([Ct.struct([Ct.array(Ct.u8(),32,"a"),Ct.array(Ct.u8(),64,"b"),Ct.array(Ct.u8(),32,"c")],"proof"),Ct.publicKey("mint"),Ct.vec(fe,"inputTokenDataWithContext"),Ct.option(ye,"cpiContext"),Ct.publicKey("delegate"),Ct.u64("delegatedAmount"),Ct.u8("delegateMerkleTreeIndex"),Ct.u8("changeAccountMerkleTreeIndex"),Ct.option(Ct.u64(),"delegateLamports")]),Be=Ct.struct([Ct.struct([Ct.array(Ct.u8(),32,"a"),Ct.array(Ct.u8(),64,"b"),Ct.array(Ct.u8(),32,"c")],"proof"),Ct.publicKey("mint"),Ct.vec(fe,"inputTokenDataWithContext"),Ct.option(ye,"cpiContext"),Ct.u8("outputAccountMerkleTreeIndex")]),Le={a:new Array(32).fill(0),b:new Array(64).fill(0),c:new Array(32).fill(0)};function Ue(t){return t.a.every((t=>0===t))&&t.b.every((t=>0===t))&&t.c.every((t=>0===t))}function Ke(t){var e;const r=w.alloc(1e3),n=null!==(e=t.proof)&&void 0!==e?e:Le,o=De.encode(Object.assign(Object.assign({},t),{proof:n}),r),i=w.alloc(4);i.writeUInt32LE(o,0);const s=r.subarray(0,o);return w.concat([new Uint8Array(ht),new Uint8Array(i),new Uint8Array(s)])}function We(t){var e;const r=w.alloc(1e3),n=null!==(e=t.proof)&&void 0!==e?e:Le,o=Be.encode(Object.assign(Object.assign({},t),{proof:n}),r),i=w.alloc(4);i.writeUInt32LE(o,0);const s=r.subarray(0,o);return w.concat([new Uint8Array(lt),new Uint8Array(i),new Uint8Array(s)])}const Ne=t=>t.reduce(((t,e)=>t.add(e.parsed.amount)),e.bn(0)),qe=t=>{const e=t[0].parsed.owner;t.forEach((t=>{if(!t.parsed.owner.equals(e))throw new Error("Token accounts must be owned by the same owner")}))},Fe=t=>({mint:t[0].parsed.mint,currentOwner:t[0].parsed.owner,delegate:t[0].parsed.delegate}),Ve=(t,e)=>{if(t.length<1)throw new Error("Must supply at least one input token account.");const r=t[0].parsed.owner,n=t.findIndex((t=>t.parsed.delegate));if(-1===n)return{delegatedTransfer:null,authority:r};const o=t[n].parsed.delegate;return{delegatedTransfer:{owner:r,delegateChangeAccountIndex:e.length<=1?null:0},authority:o}};function je(t,r,n){n=e.bn(n);const o=Ne(t),i=e.sumUpLamports(t.map((t=>t.compressedAccount))),s=o.sub(n);return e.validateSufficientBalance(s),s.eq(e.bn(0))&&i.eq(e.bn(0))?[{owner:r,amount:n,lamports:i,tlv:null}]:(e.validateSameOwner(t.map((t=>t.compressedAccount))),qe(t),[{owner:t[0].parsed.owner,amount:s,lamports:i,tlv:null},{owner:r,amount:n,lamports:e.bn(0),tlv:null}])}function Ye(t,r){r=e.bn(r);const n=e.sumUpLamports(t.map((t=>t.compressedAccount))),o=Ne(t).sub(r);return e.validateSufficientBalance(o),o.eq(e.bn(0))&&n.eq(e.bn(0))?[]:(e.validateSameOwner(t.map((t=>t.compressedAccount))),qe(t),[{owner:t[0].parsed.owner,amount:o,lamports:n,tlv:null}])}class ze{constructor(){}static setProgramId(e){this.programId="string"==typeof e?new t.PublicKey(e):e}static deriveTokenPoolPda(e){const r=[nt,e.toBuffer()],[n,o]=t.PublicKey.findProgramAddressSync(r,this.programId);return n}static findTokenPoolIndexAndBump(t,e){for(let r=0;r<5;r++){const n=ze.deriveTokenPoolPdaWithIndex(e,r);if(n[0].equals(t))return[r,n[1]]}throw new Error("Token pool not found")}static deriveTokenPoolPdaWithIndex(e,r){let n=[];n=0===r?[w.from("pool"),e.toBuffer(),w.from([])]:[w.from("pool"),e.toBuffer(),w.from([r])];const[o,i]=t.PublicKey.findProgramAddressSync(n,this.programId);return[o,i]}static get deriveCpiAuthorityPda(){const[e,r]=t.PublicKey.findProgramAddressSync([ot],this.programId);return e}static async createMint({feePayer:e,mint:n,authority:o,freezeAuthority:i,decimals:s,rentExemptBalance:a,tokenProgramId:u,mintSize:c}){const h=null!=u?u:r.TOKEN_PROGRAM_ID;return[t.SystemProgram.createAccount({fromPubkey:e,lamports:a,newAccountPubkey:n,programId:h,space:null!=c?c:r.MINT_SIZE}),r.createInitializeMint2Instruction(n,s,o,i,h),await this.createTokenPool({feePayer:e,mint:n,tokenProgramId:h})]}static async createTokenPool({feePayer:e,mint:n,tokenProgramId:o}){const i=null!=o?o:r.TOKEN_PROGRAM_ID,s=this.deriveTokenPoolPdaWithIndex(n,0),a=Te({mint:n,feePayer:e,tokenPoolPda:s[0],tokenProgram:i,cpiAuthorityPda:this.deriveCpiAuthorityPda,systemProgram:t.SystemProgram.programId});return new t.TransactionInstruction({programId:this.programId,keys:a,data:it})}static async addTokenPool({feePayer:e,mint:n,poolIndex:o,tokenProgramId:i}){if(o<=0)throw new Error("Pool index must be greater than 0. For 0, use CreateTokenPool instead.");if(o>3)throw new Error(`Invalid poolIndex ${o}. Max 4 pools per mint.`);const s=null!=i?i:r.TOKEN_PROGRAM_ID,a=this.deriveTokenPoolPdaWithIndex(n,o-1),u=this.deriveTokenPoolPdaWithIndex(n,o),c=Ie({mint:n,feePayer:e,tokenPoolPda:u[0],existingTokenPoolPda:a[0],tokenProgram:s,cpiAuthorityPda:this.deriveCpiAuthorityPda,systemProgram:t.SystemProgram.programId});return new t.TransactionInstruction({programId:this.programId,keys:c,data:w.concat([new Uint8Array(dt),new Uint8Array(w.from([o]))])})}static async mintTo({feePayer:r,mint:n,authority:o,toPubkey:i,amount:s,outputStateTreeInfo:a,tokenPoolInfo:u}){const c=e.defaultStaticAccountsStruct(),h=u.tokenProgram;pt(u,n);const l=e.toArray(s).map((t=>e.bn(t))),d=e.toArray(i);if(l.length!==d.length)throw new Error("Amount and toPubkey arrays must have the same length");const p=Ce({mint:n,feePayer:r,authority:o,cpiAuthorityPda:this.deriveCpiAuthorityPda,tokenProgram:h,tokenPoolPda:u.tokenPoolPda,lightSystemProgram:e.LightSystemProgram.programId,registeredProgramPda:c.registeredProgramPda,noopProgram:c.noopProgram,accountCompressionAuthority:c.accountCompressionAuthority,accountCompressionProgram:c.accountCompressionProgram,merkleTree:a.treeType===e.TreeType.StateV2?a.queue:a.tree,selfProgram:this.programId,systemProgram:t.SystemProgram.programId,solPoolPda:null}),m=Pe({recipients:d,amounts:l,lamports:null});return new t.TransactionInstruction({programId:this.programId,keys:p,data:m})}static async approveAndMintTo({feePayer:t,mint:e,authority:n,authorityTokenAccount:o,toPubkey:i,amount:s,outputStateTreeInfo:a,tokenPoolInfo:u}){const c=BigInt(s.toString());return[r.createMintToInstruction(e,o,n,c,[],u.tokenProgram),await this.compress({payer:t,owner:n,source:o,toAddress:i,mint:e,amount:s,outputStateTreeInfo:a,tokenPoolInfo:u})]}static async transfer({payer:r,inputCompressedTokenAccounts:n,toAddress:o,amount:i,recentValidityProof:s,recentInputStateRootIndices:a}){const u=je(n,o,i),{inputTokenDataWithContext:c,packedOutputTokenData:h,remainingAccountMetas:l}=At({inputCompressedTokenAccounts:n,rootIndices:a,tokenTransferOutputs:u}),{mint:d}=Fe(n),{delegatedTransfer:p,authority:m}=Ve(n,u),f=Se({proof:s,mint:d,delegatedTransfer:p,inputTokenDataWithContext:c,outputCompressedAccounts:h,compressOrDecompressAmount:null,isCompress:0,cpiContext:null,lamportsChangeAccountMerkleTreeIndex:null}),{accountCompressionAuthority:g,noopProgram:y,registeredProgramPda:w,accountCompressionProgram:v}=e.defaultStaticAccountsStruct(),b=xe({feePayer:r,authority:m,cpiAuthorityPda:this.deriveCpiAuthorityPda,lightSystemProgram:e.LightSystemProgram.programId,registeredProgramPda:w,noopProgram:y,accountCompressionAuthority:g,accountCompressionProgram:v,selfProgram:this.programId,tokenPoolPda:void 0,compressOrDecompressTokenAccount:void 0,tokenProgram:void 0,systemProgram:t.SystemProgram.programId});return b.push(...l),new t.TransactionInstruction({programId:this.programId,keys:b,data:f})}static async createTokenProgramLookupTable({payer:n,authority:o,mints:i,recentSlot:s,remainingAccounts:a}){let u=[t.SystemProgram.programId,t.ComputeBudgetProgram.programId,this.deriveCpiAuthorityPda,e.LightSystemProgram.programId,ze.programId,e.defaultStaticAccountsStruct().registeredProgramPda,e.defaultStaticAccountsStruct().noopProgram,e.defaultStaticAccountsStruct().accountCompressionAuthority,e.defaultStaticAccountsStruct().accountCompressionProgram,e.defaultTestStateTreeAccounts().merkleTree,e.defaultTestStateTreeAccounts().nullifierQueue,e.defaultTestStateTreeAccounts().addressTree,e.defaultTestStateTreeAccounts().addressQueue,this.programId,r.TOKEN_PROGRAM_ID,r.TOKEN_2022_PROGRAM_ID,o];i&&u.push(...i,...i.map((t=>this.deriveTokenPoolPda(t)))),a&&a.length>0&&u.push(...a);const c=new Set,h=u.filter((t=>{const e=t.toBase58();return c.has(e)?0:(c.add(e),1)})),[l,d]=t.AddressLookupTableProgram.createLookupTable({authority:o,payer:o,recentSlot:s}),p=[l];for(let e=0;e<h.length;e+=25){const r=h.slice(e,e+25),i=t.AddressLookupTableProgram.extendLookupTable({payer:n,authority:o,lookupTable:d,addresses:r});p.push(i)}return{instructions:p,address:d}}static async compress({payer:r,owner:n,source:o,toAddress:i,amount:s,mint:a,outputStateTreeInfo:u,tokenPoolInfo:c}){let h;const l=e.toArray(s),d=e.toArray(i);if(pt(c,a),l.length!==d.length)throw new Error("Amount and toAddress arrays must have the same length");if(e.featureFlags.isV2()){const[i,s]=this.findTokenPoolIndexAndBump(c.tokenPoolPda,a),h=ke({pubkeys:d,amounts:l.length>1?l.map((t=>e.bn(t))):null,lamports:null,amount:1===l.length?e.bn(l[0]):null,index:i,bump:s}),p=Ce(Object.assign(Object.assign({mint:a,feePayer:r,authority:n,cpiAuthorityPda:this.deriveCpiAuthorityPda,tokenProgram:c.tokenProgram,tokenPoolPda:c.tokenPoolPda,lightSystemProgram:e.LightSystemProgram.programId},e.defaultStaticAccountsStruct()),{merkleTree:u.queue,selfProgram:this.programId,systemProgram:t.SystemProgram.programId,solPoolPda:null}));return p.push({pubkey:o,isWritable:1,isSigner:0}),new t.TransactionInstruction({programId:this.programId,keys:p,data:h})}{h=l.map(((t,r)=>{const n=e.bn(t);return{owner:d[r],amount:n,lamports:null,tlv:null}}));const{inputTokenDataWithContext:i,packedOutputTokenData:p,remainingAccountMetas:m}=At({inputCompressedTokenAccounts:[],outputStateTreeInfo:u,rootIndices:[],tokenTransferOutputs:h}),f=Se({proof:null,mint:a,delegatedTransfer:null,inputTokenDataWithContext:i,outputCompressedAccounts:p,compressOrDecompressAmount:Array.isArray(s)?s.map((t=>e.bn(t))).reduce(((t,e)=>t.add(e)),e.bn(0)):e.bn(s),isCompress:1,cpiContext:null,lamportsChangeAccountMerkleTreeIndex:null}),g=xe(Object.assign(Object.assign({},e.defaultStaticAccountsStruct()),{feePayer:r,authority:n,cpiAuthorityPda:this.deriveCpiAuthorityPda,lightSystemProgram:e.LightSystemProgram.programId,selfProgram:this.programId,systemProgram:t.SystemProgram.programId,tokenPoolPda:c.tokenPoolPda,compressOrDecompressTokenAccount:o,tokenProgram:c.tokenProgram}));return g.push(...m),new t.TransactionInstruction({programId:this.programId,keys:g,data:f})}}static async decompress({payer:r,inputCompressedTokenAccounts:n,toAddress:o,amount:i,recentValidityProof:s,recentInputStateRootIndices:a,tokenPoolInfos:u}){const c=e.bn(i),h=e.toArray(u),l=Ye(n,c),{inputTokenDataWithContext:d,packedOutputTokenData:p,remainingAccountMetas:m}=At({inputCompressedTokenAccounts:n,rootIndices:a,tokenTransferOutputs:l,remainingAccounts:h.slice(1).map((t=>t.tokenPoolPda))}),{mint:f}=Fe(n),{delegatedTransfer:g,authority:y}=Ve(n,l),w=Se({proof:s,mint:f,delegatedTransfer:g,inputTokenDataWithContext:d,outputCompressedAccounts:p,compressOrDecompressAmount:c,isCompress:0,cpiContext:null,lamportsChangeAccountMerkleTreeIndex:null}),v=h[0].tokenProgram,{accountCompressionAuthority:b,noopProgram:M,registeredProgramPda:P,accountCompressionProgram:k}=e.defaultStaticAccountsStruct(),A=xe({feePayer:r,authority:y,cpiAuthorityPda:this.deriveCpiAuthorityPda,lightSystemProgram:e.LightSystemProgram.programId,registeredProgramPda:P,noopProgram:M,accountCompressionAuthority:b,accountCompressionProgram:k,selfProgram:this.programId,tokenPoolPda:h[0].tokenPoolPda,compressOrDecompressTokenAccount:o,tokenProgram:v,systemProgram:t.SystemProgram.programId});return A.push(...m),new t.TransactionInstruction({programId:this.programId,keys:A,data:w})}static async mergeTokenAccounts({payer:t,owner:r,inputCompressedTokenAccounts:n,mint:o,recentValidityProof:i,recentInputStateRootIndices:s}){if(n.length>4)throw new Error("Cannot merge more than 4 token accounts at once");return St(n,o),[await this.transfer({payer:t,inputCompressedTokenAccounts:n,toAddress:r,amount:n.reduce(((t,e)=>t.add(e.parsed.amount)),e.bn(0)),recentInputStateRootIndices:s,recentValidityProof:i})]}static async compressSplTokenAccount({feePayer:r,authority:n,tokenAccount:o,mint:i,remainingAmount:s,outputStateTreeInfo:a,tokenPoolInfo:u}){pt(u,i);const c=[{pubkey:a.treeType===e.TreeType.StateV2?a.queue:a.tree,isSigner:0,isWritable:1}],h=Ae({owner:n,remainingAmount:null!=s?s:null,cpiContext:null}),{accountCompressionAuthority:l,noopProgram:d,registeredProgramPda:p,accountCompressionProgram:m}=e.defaultStaticAccountsStruct(),f=xe({feePayer:r,authority:n,cpiAuthorityPda:this.deriveCpiAuthorityPda,lightSystemProgram:e.LightSystemProgram.programId,registeredProgramPda:p,noopProgram:d,accountCompressionAuthority:l,accountCompressionProgram:m,selfProgram:this.programId,tokenPoolPda:u.tokenPoolPda,compressOrDecompressTokenAccount:o,tokenProgram:u.tokenProgram,systemProgram:t.SystemProgram.programId});return f.push(...c),new t.TransactionInstruction({programId:this.programId,keys:f,data:h})}static async getMintProgramId(t,e){var r;return null===(r=await e.getAccountInfo(t))||void 0===r?void 0:r.owner}static async approve({payer:r,inputCompressedTokenAccounts:n,toAddress:o,amount:i,recentValidityProof:s,recentInputStateRootIndices:a}){const{inputTokenDataWithContext:u,remainingAccountMetas:c}=At({inputCompressedTokenAccounts:n,rootIndices:a,tokenTransferOutputs:[]}),{mint:h,currentOwner:l}=Fe(n),d=n[0].compressedAccount.treeInfo.treeType===e.TreeType.StateV2?1:0,p=Ke({proof:s,mint:h,inputTokenDataWithContext:u,cpiContext:null,delegate:o,delegatedAmount:e.bn(i),delegateMerkleTreeIndex:d,changeAccountMerkleTreeIndex:d,delegateLamports:null}),{accountCompressionAuthority:m,noopProgram:f,registeredProgramPda:g,accountCompressionProgram:y}=e.defaultStaticAccountsStruct(),w=Ee({feePayer:r,authority:l,cpiAuthorityPda:this.deriveCpiAuthorityPda,lightSystemProgram:e.LightSystemProgram.programId,registeredProgramPda:g,noopProgram:f,accountCompressionAuthority:m,accountCompressionProgram:y,selfProgram:this.programId,systemProgram:t.SystemProgram.programId});return w.push(...c),new t.TransactionInstruction({programId:this.programId,keys:w,data:p})}static async revoke({payer:r,inputCompressedTokenAccounts:n,recentValidityProof:o,recentInputStateRootIndices:i}){qe(n);const{inputTokenDataWithContext:s,remainingAccountMetas:a}=At({inputCompressedTokenAccounts:n,rootIndices:i,tokenTransferOutputs:[]}),{mint:u,currentOwner:c}=Fe(n),h=We({proof:o,mint:u,inputTokenDataWithContext:s,cpiContext:null,outputAccountMerkleTreeIndex:n[0].compressedAccount.treeInfo.treeType===e.TreeType.StateV2?2:1}),{accountCompressionAuthority:l,noopProgram:d,registeredProgramPda:p,accountCompressionProgram:m}=e.defaultStaticAccountsStruct(),f=_e({feePayer:r,authority:c,cpiAuthorityPda:this.deriveCpiAuthorityPda,lightSystemProgram:e.LightSystemProgram.programId,registeredProgramPda:p,noopProgram:d,accountCompressionAuthority:l,accountCompressionProgram:m,selfProgram:this.programId,systemProgram:t.SystemProgram.programId});return f.push(...a),new t.TransactionInstruction({programId:this.programId,keys:f,data:h})}}ze.programId=new t.PublicKey("cTokenmWW8bLPjZEBAUgYy3zKxQZW6VKi7bqNFEVv3m");const Ze=Buffer.from([99,111,109,112,114,101,115,115,101,100,95,109,105,110,116]);function He(r){const[n,o]=t.PublicKey.findProgramAddressSync([Ze,r.toBuffer()],e.COMPRESSED_TOKEN_PROGRAM_ID);return[n,o]}exports.ADD_TOKEN_POOL_DISCRIMINATOR=dt,exports.APPROVE_DISCRIMINATOR=ht,exports.BATCH_COMPRESS_DISCRIMINATOR=at,exports.COMPRESSED_MINT_SEED=Ze,exports.COMPRESS_SPL_TOKEN_ACCOUNT_DISCRIMINATOR=ct,exports.CPI_AUTHORITY_SEED=ot,exports.CREATE_TOKEN_POOL_DISCRIMINATOR=it,exports.CompressedTokenInstructionDataApproveLayout=De,exports.CompressedTokenInstructionDataRevokeLayout=Be,exports.CompressedTokenInstructionDataTransferLayout=we,exports.CompressedTokenProgram=ze,exports.CpiContextLayout=ye,exports.DelegatedTransferLayout=ge,exports.ERROR_NO_ACCOUNTS_FOUND=vt,exports.IDL={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"}]},exports.MINT_TO_DISCRIMINATOR=st,exports.POOL_SEED=nt,exports.REVOKE_DISCRIMINATOR=lt,exports.SPL_TOKEN_MINT_RENT_EXEMPT_BALANCE=1461600,exports.TRANSFER_DISCRIMINATOR=ut,exports.addTokenPoolAccountsLayout=Ie,exports.addTokenPools=async function(t,r,n,o,i,s){s=s||await ze.getMintProgramId(n,t);const a=[],u=(await mt(t,n)).slice(0,4),c=[];for(let t=0;t<u.length;t++)u[t].isInitialized||c.push(t);for(let t=0;t<o&&!(t>=c.length);t++)a.push(await ze.addTokenPool({mint:n,feePayer:r.publicKey,tokenProgramId:s,poolIndex:c[t]}));const{blockhash:h}=await t.getLatestBlockhash(),l=e.buildAndSignTx(a,r,h);return await e.sendAndConfirmTx(t,l,i)},exports.approve=async function(r,n,o,i,s,a,u){i=e.bn(i);const c=await r.getCompressedTokenAccountsByOwner(s.publicKey,{mint:o}),[h]=bt(c.items,i),l=await r.getValidityProofV0(h.map((t=>({hash:t.compressedAccount.hash,tree:t.compressedAccount.treeInfo.tree,queue:t.compressedAccount.treeInfo.queue})))),d=await ze.approve({payer:n.publicKey,inputCompressedTokenAccounts:h,toAddress:a,amount:i,recentInputStateRootIndices:l.rootIndices,recentValidityProof:l.compressedProof}),{blockhash:p}=await r.getLatestBlockhash(),m=e.dedupeSigner(n,[s]),f=e.buildAndSignTx([t.ComputeBudgetProgram.setComputeUnitLimit({units:35e4}),d],n,p,m);return e.sendAndConfirmTx(r,f,u)},exports.approveAccountsLayout=Ee,exports.approveAndMintTo=async function(n,o,i,s,a,u,c,h,l){c=null!=c?c:e.selectStateTreeInfo(await n.getStateTreeInfos()),h=null!=h?h:yt(await mt(n,i));const d=await r.getOrCreateAssociatedTokenAccount(n,o,i,a.publicKey,void 0,void 0,l,h.tokenProgram),p=await ze.approveAndMintTo({feePayer:o.publicKey,mint:i,authority:a.publicKey,authorityTokenAccount:d.address,amount:u,toPubkey:s,outputStateTreeInfo:c,tokenPoolInfo:h}),{blockhash:m}=await n.getLatestBlockhash(),f=e.dedupeSigner(o,[a]),g=e.buildAndSignTx([t.ComputeBudgetProgram.setComputeUnitLimit({units:15e4+2e4*e.toArray(u).length}),...p],o,m,f);return await e.sendAndConfirmTx(n,g,l)},exports.batchCompressLayout=be,exports.checkMint=St,exports.checkTokenPoolInfo=pt,exports.compress=async function(r,n,o,i,s,a,u,c,h,l){c=null!=c?c:e.selectStateTreeInfo(await r.getStateTreeInfos()),h=null!=h?h:yt(await mt(r,o));const d=await ze.compress({payer:n.publicKey,owner:s.publicKey,source:a,toAddress:u,amount:i,mint:o,outputStateTreeInfo:c,tokenPoolInfo:h}),p=await r.getLatestBlockhash(),m=e.dedupeSigner(n,[s]),f=e.buildAndSignTx([t.ComputeBudgetProgram.setComputeUnitLimit({units:13e4+2e4*e.toArray(i).length}),d],n,p.blockhash,m);return await e.sendAndConfirmTx(r,f,l,p)},exports.compressSplTokenAccount=async function(r,n,o,i,s,a,u,c,h){u=null!=u?u:e.selectStateTreeInfo(await r.getStateTreeInfos()),c=null!=c?c:yt(await mt(r,o));const l=await ze.compressSplTokenAccount({feePayer:n.publicKey,authority:i.publicKey,tokenAccount:s,mint:o,remainingAmount:a,outputStateTreeInfo:u,tokenPoolInfo:c}),d=await r.getLatestBlockhash(),p=e.dedupeSigner(n,[i]),m=e.buildAndSignTx([t.ComputeBudgetProgram.setComputeUnitLimit({units:15e4}),l],n,d.blockhash,p);return await e.sendAndConfirmTx(r,m,h,d)},exports.compressSplTokenAccountInstructionDataLayout=Me,exports.createDecompressOutputState=Ye,exports.createMint=async function(n,o,i,s,a=t.Keypair.generate(),u,c,h){const l=await n.getMinimumBalanceForRentExemption(r.MINT_SIZE),d=1==c?r.TOKEN_2022_PROGRAM_ID:c||r.TOKEN_PROGRAM_ID,p=await ze.createMint({feePayer:o.publicKey,mint:a.publicKey,decimals:s,authority:"secretKey"in i?i.publicKey:i,freezeAuthority:h&&"secretKey"in h?h.publicKey:null!=h?h:null,rentExemptBalance:l,tokenProgramId:d}),{blockhash:m}=await n.getLatestBlockhash(),f=e.dedupeSigner(o,[i,h].filter((t=>null!=t&&"secretKey"in t))),g=e.buildAndSignTx(p,o,m,[...f,a]),y=await e.sendAndConfirmTx(n,g,u);return{mint:a.publicKey,transactionSignature:y}},exports.createTokenPool=async function(t,r,n,o,i){i=i||await ze.getMintProgramId(n,t);const s=await ze.createTokenPool({feePayer:r.publicKey,mint:n,tokenProgramId:i}),{blockhash:a}=await t.getLatestBlockhash(),u=e.buildAndSignTx([s],r,a);return await e.sendAndConfirmTx(t,u,o)},exports.createTokenPoolAccountsLayout=Te,exports.createTokenProgramLookupTable=async function(t,r,n,o,i){const s=await t.getSlot("finalized"),{instructions:a,address:u}=await ze.createTokenProgramLookupTable({payer:r.publicKey,authority:n.publicKey,mints:o,remainingAccounts:i,recentSlot:s}),c=e.dedupeSigner(r,[n]),h=[];for(const n of a){const o=await t.getLatestBlockhash(),i=e.buildAndSignTx([n],r,o.blockhash,c),s=await e.sendAndConfirmTx(t,i,{commitment:"finalized"},o);h.push(s)}return{txIds:h,address:u}},exports.createTransferOutputState=je,exports.decodeApproveInstructionData=function(t){const e=De.decode(t.subarray(ht.length));return Object.assign(Object.assign({},e),{proof:Ue(e.proof)?null:e.proof})},exports.decodeBatchCompressInstructionData=function(t){return be.decode(t.subarray(at.length+4))},exports.decodeCompressSplTokenAccountInstructionData=function(t){const e=Me.decode(t.subarray(ct.length));return{owner:e.owner,remainingAmount:e.remainingAmount,cpiContext:e.cpiContext}},exports.decodeMintToInstructionData=function(t){return ve.decode(t.subarray(st.length))},exports.decodeRevokeInstructionData=function(t){const e=Be.decode(t.subarray(lt.length));return Object.assign(Object.assign({},e),{proof:Ue(e.proof)?null:e.proof})},exports.decodeTransferInstructionData=function(t){return we.decode(t.slice(ut.length+4))},exports.decompress=async function(r,n,o,i,s,a,u,c){i=e.bn(i);const h=await r.getCompressedTokenAccountsByOwner(s.publicKey,{mint:o}),[l]=Mt(h.items,i),d=await r.getValidityProofV0(l.map((t=>({hash:t.compressedAccount.hash,tree:t.compressedAccount.treeInfo.tree,queue:t.compressedAccount.treeInfo.queue})))),p=wt(u=null!=u?u:await mt(r,o),i),m=await ze.decompress({payer:n.publicKey,inputCompressedTokenAccounts:l,toAddress:a,amount:i,tokenPoolInfos:p,recentInputStateRootIndices:d.rootIndices,recentValidityProof:d.compressedProof}),{blockhash:f}=await r.getLatestBlockhash(),g=e.dedupeSigner(n,[s]),y=e.buildAndSignTx([t.ComputeBudgetProgram.setComputeUnitLimit({units:35e4}),m],n,f,g);return await e.sendAndConfirmTx(r,y,c)},exports.decompressDelegated=async function(r,n,o,i,s,a,u,c){i=e.bn(i);const h=await r.getCompressedTokenAccountsByDelegate(s.publicKey,{mint:o}),[l]=Mt(h.items,i),d=await r.getValidityProofV0(l.map((t=>({hash:t.compressedAccount.hash,tree:t.compressedAccount.treeInfo.tree,queue:t.compressedAccount.treeInfo.queue})))),p=null!=u?u:wt(await mt(r,o),i),m=await ze.decompress({payer:n.publicKey,inputCompressedTokenAccounts:l,toAddress:a,amount:i,recentInputStateRootIndices:d.rootIndices,recentValidityProof:d.compressedProof,tokenPoolInfos:p}),{blockhash:f}=await r.getLatestBlockhash(),g=e.dedupeSigner(n,[s]),y=e.buildAndSignTx([t.ComputeBudgetProgram.setComputeUnitLimit({units:35e4}),m],n,f,g);return e.sendAndConfirmTx(r,y,c)},exports.deriveCompressedMintAddress=function(t,r){const n=e.deriveAddressV2(He(t)[0].toBytes(),r.tree.toBytes(),e.COMPRESSED_TOKEN_PROGRAM_ID.toBytes());return Array.from(n)},exports.encodeApproveInstructionData=Ke,exports.encodeBatchCompressInstructionData=ke,exports.encodeCompressSplTokenAccountInstructionData=Ae,exports.encodeMintToInstructionData=Pe,exports.encodeRevokeInstructionData=We,exports.encodeTransferInstructionData=Se,exports.findMintAddress=He,exports.freezeAccountsLayout=Oe,exports.getAssociatedCTokenAddress=function(r,n){return t.PublicKey.findProgramAddressSync([r.toBuffer(),e.COMPRESSED_TOKEN_PROGRAM_ID.toBuffer(),n.toBuffer()],e.COMPRESSED_TOKEN_PROGRAM_ID)[0]},exports.getAssociatedCTokenAddressAndBump=function(r,n){return t.PublicKey.findProgramAddressSync([r.toBuffer(),e.COMPRESSED_TOKEN_PROGRAM_ID.toBuffer(),n.toBuffer()],e.COMPRESSED_TOKEN_PROGRAM_ID)},exports.getTokenPoolInfos=mt,exports.isSingleTokenPoolInfo=function(t){return!Array.isArray(t)},exports.mergeTokenAccounts=async function(r,n,o,i,s){const a=await r.getCompressedTokenAccountsByOwner(i.publicKey,{mint:o});if(0===a.items.length)throw new Error(`No compressed token accounts found for mint ${o.toBase58()}`);const u=[t.ComputeBudgetProgram.setComputeUnitLimit({units:1e6})];for(let t=0;t<a.items.slice(0,8).length;t+=4){const s=a.items.slice(t,t+4),c=await r.getValidityProof(s.map((t=>e.bn(t.compressedAccount.hash)))),h=await ze.mergeTokenAccounts({payer:n.publicKey,owner:i.publicKey,inputCompressedTokenAccounts:s,mint:o,recentValidityProof:c.compressedProof,recentInputStateRootIndices:c.rootIndices});u.push(...h)}const{blockhash:c}=await r.getLatestBlockhash(),h=e.dedupeSigner(n,[i]),l=e.buildAndSignTx(u,n,c,h);return e.sendAndConfirmTx(r,l,s)},exports.mintTo=async function(r,n,o,i,s,a,u,c,h){u=null!=u?u:e.selectStateTreeInfo(await r.getStateTreeInfos()),c=null!=c?c:yt(await mt(r,o));const l=await ze.mintTo({feePayer:n.publicKey,mint:o,authority:s.publicKey,amount:a,toPubkey:i,outputStateTreeInfo:u,tokenPoolInfo:c}),{blockhash:d}=await r.getLatestBlockhash(),p=e.dedupeSigner(n,[s]),m=e.buildAndSignTx([t.ComputeBudgetProgram.setComputeUnitLimit({units:1e6}),l],n,d,p);return e.sendAndConfirmTx(r,m,h)},exports.mintToAccountsLayout=Ce,exports.mintToLayout=ve,exports.packCompressedTokenAccounts=At,exports.parseMaybeDelegatedTransfer=Ve,exports.parseTokenData=Fe,exports.revoke=async function(r,n,o,i,s){const a=await r.getValidityProofV0(o.map((t=>({hash:t.compressedAccount.hash,tree:t.compressedAccount.treeInfo.tree,queue:t.compressedAccount.treeInfo.queue}))));!function(t,e){if(!t.publicKey.equals(e[0].parsed.owner))throw new Error(`Owner ${t.publicKey.toBase58()} does not match account ${e[0].parsed.owner.toBase58()}`)}(i,o),function(t){if(t.some((t=>null===t.parsed.delegate)))throw new Error("Account is not delegated")}(o);const u=await ze.revoke({payer:n.publicKey,inputCompressedTokenAccounts:o,recentInputStateRootIndices:a.rootIndices,recentValidityProof:a.compressedProof}),{blockhash:c}=await r.getLatestBlockhash(),h=e.dedupeSigner(n,[i]),l=e.buildAndSignTx([t.ComputeBudgetProgram.setComputeUnitLimit({units:5e5}),u],n,c,h);return e.sendAndConfirmTx(r,l,s)},exports.revokeAccountsLayout=_e,exports.selectMinCompressedTokenAccountsForDecompression=function(t,e,r=4){const[n,o,i,s]=Mt(t,e,r);return{selectedAccounts:n,total:o,totalLamports:i,maxPossibleAmount:s}},exports.selectMinCompressedTokenAccountsForTransfer=Mt,exports.selectMinCompressedTokenAccountsForTransferOrPartial=Pt,exports.selectSmartCompressedTokenAccountsForTransfer=function(t,r,n=4){const[o,i,s,a]=kt(t,r,n);if(i.lt(e.bn(r))){const i=t.reduce(((t,e)=>t.add(e.parsed.amount)),e.bn(0));throw o.length>=n?new Error(`Account limit exceeded: max ${a.toString()} (${n} accounts) per transaction. Total balance: ${i.toString()} (${t.length} accounts). Consider multiple transfers to spend full balance.`):new Error(`Insufficient balance. Required: ${r.toString()}, available: ${i.toString()}.`)}if(0===o.length)throw new Error(vt);return[o,i,s,a]},exports.selectSmartCompressedTokenAccountsForTransferOrPartial=kt,exports.selectTokenAccountsForApprove=bt,exports.selectTokenPoolInfo=yt,exports.selectTokenPoolInfosForDecompression=wt,exports.sumUpTokenAmount=Ne,exports.thawAccountsLayout=Re,exports.transfer=async function(r,n,o,i,s,a,u){i=e.bn(i);const c=await r.getCompressedTokenAccountsByOwner(s.publicKey,{mint:o}),[h]=Mt(c.items,i),l=await r.getValidityProofV0(h.map((t=>({hash:t.compressedAccount.hash,tree:t.compressedAccount.treeInfo.tree,queue:t.compressedAccount.treeInfo.queue})))),d=await ze.transfer({payer:n.publicKey,inputCompressedTokenAccounts:h,toAddress:a,amount:i,recentInputStateRootIndices:l.rootIndices,recentValidityProof:l.compressedProof}),{blockhash:p}=await r.getLatestBlockhash(),m=e.dedupeSigner(n,[s]),f=e.buildAndSignTx([t.ComputeBudgetProgram.setComputeUnitLimit({units:5e5}),d],n,p,m);return e.sendAndConfirmTx(r,f,u)},exports.transferAccountsLayout=xe,exports.transferDelegated=async function(r,n,o,i,s,a,u){i=e.bn(i);const c=await r.getCompressedTokenAccountsByDelegate(s.publicKey,{mint:o}),[h]=Mt(c.items,i),l=await r.getValidityProofV0(h.map((t=>({hash:t.compressedAccount.hash,tree:t.compressedAccount.treeInfo.tree,queue:t.compressedAccount.treeInfo.queue})))),d=await ze.transfer({payer:n.publicKey,inputCompressedTokenAccounts:h,toAddress:a,amount:i,recentInputStateRootIndices:l.rootIndices,recentValidityProof:l.compressedProof}),{blockhash:p}=await r.getLatestBlockhash(),m=e.dedupeSigner(n,[s]),f=e.buildAndSignTx([t.ComputeBudgetProgram.setComputeUnitLimit({units:5e5}),d],n,p,m);return e.sendAndConfirmTx(r,f,u)},exports.validateSameTokenOwner=qe;
|
|
1
|
+
"use strict";var e=require("./types-DZs1jl_2.cjs");require("@solana/web3.js"),require("@lightprotocol/stateless.js");var t=require("@solana/spl-token");require("@coral-xyz/borsh"),exports.ADD_TOKEN_POOL_DISCRIMINATOR=e.ADD_TOKEN_POOL_DISCRIMINATOR,exports.APPROVE_DISCRIMINATOR=e.APPROVE_DISCRIMINATOR,Object.defineProperty(exports,"Action",{enumerable:1,get:function(){return e.Action}}),exports.BATCH_COMPRESS_DISCRIMINATOR=e.BATCH_COMPRESS_DISCRIMINATOR,exports.COMPRESS_SPL_TOKEN_ACCOUNT_DISCRIMINATOR=e.COMPRESS_SPL_TOKEN_ACCOUNT_DISCRIMINATOR,exports.CPI_AUTHORITY_SEED=e.CPI_AUTHORITY_SEED,exports.CREATE_TOKEN_POOL_DISCRIMINATOR=e.CREATE_TOKEN_POOL_DISCRIMINATOR,exports.CompressedTokenInstructionDataApproveLayout=e.CompressedTokenInstructionDataApproveLayout,exports.CompressedTokenInstructionDataRevokeLayout=e.CompressedTokenInstructionDataRevokeLayout,exports.CompressedTokenInstructionDataTransferLayout=e.CompressedTokenInstructionDataTransferLayout,exports.CompressedTokenProgram=e.CompressedTokenProgram,exports.CpiContextLayout=e.CpiContextLayout,exports.DECOMPRESS_ACCOUNTS_IDEMPOTENT_DISCRIMINATOR=e.DECOMPRESS_ACCOUNTS_IDEMPOTENT_DISCRIMINATOR,exports.DelegatedTransferLayout=e.DelegatedTransferLayout,exports.ERROR_NO_ACCOUNTS_FOUND=e.ERROR_NO_ACCOUNTS_FOUND,Object.defineProperty(exports,"ExtensionType",{enumerable:1,get:function(){return e.ExtensionType}}),exports.IDL=e.IDL,exports.MINT_TO_DISCRIMINATOR=e.MINT_TO_DISCRIMINATOR,exports.POOL_SEED=e.POOL_SEED,exports.REVOKE_DISCRIMINATOR=e.REVOKE_DISCRIMINATOR,exports.SPL_TOKEN_MINT_RENT_EXEMPT_BALANCE=e.SPL_TOKEN_MINT_RENT_EXEMPT_BALANCE,exports.TRANSFER_DISCRIMINATOR=e.TRANSFER_DISCRIMINATOR,Object.defineProperty(exports,"TokenDataVersion",{enumerable:1,get:function(){return e.TokenDataVersion}}),exports.addSplInterfaces=e.addSplInterfaces,exports.addTokenPoolAccountsLayout=e.addTokenPoolAccountsLayout,exports.addTokenPools=e.addTokenPools,exports.approve=e.approve,exports.approveAccountsLayout=e.approveAccountsLayout,exports.approveAndMintTo=e.approveAndMintTo,exports.batchCompressLayout=e.batchCompressLayout,exports.calculateCompressibleLoadComputeUnits=e.calculateCompressibleLoadComputeUnits,exports.checkMint=e.checkMint,exports.checkSplInterfaceInfo=e.checkSplInterfaceInfo,exports.checkTokenPoolInfo=e.checkTokenPoolInfo,exports.compress=e.compress,exports.compressSplTokenAccount=e.compressSplTokenAccount,exports.compressSplTokenAccountInstructionDataLayout=e.compressSplTokenAccountInstructionDataLayout,exports.convertTokenDataToAccount=e.convertTokenDataToAccount,exports.createAssociatedCTokenAccountIdempotentInstruction=e.createAssociatedCTokenAccountIdempotentInstruction,exports.createAssociatedCTokenAccountInstruction=e.createAssociatedCTokenAccountInstruction,exports.createAssociatedTokenAccountInterfaceIdempotentInstruction=e.createAssociatedTokenAccountInterfaceIdempotentInstruction,exports.createAssociatedTokenAccountInterfaceInstruction=e.createAssociatedTokenAccountInterfaceInstruction,exports.createAtaInterface=e.createAtaInterface,exports.createAtaInterfaceIdempotent=e.createAtaInterfaceIdempotent,exports.createAtaInterfaceIdempotentInstruction=e.createAtaInterfaceIdempotentInstruction,exports.createCTokenTransferInstruction=e.createCTokenTransferInstruction,exports.createDecompressInterfaceInstruction=e.createDecompressInterfaceInstruction,exports.createDecompressOutputState=e.createDecompressOutputState,exports.createLoadAccountsParams=e.createLoadAccountsParams,exports.createLoadAtaInstructionsFromInterface=e.createLoadAtaInstructionsFromInterface,exports.createMint=e.createMint,exports.createMintInstruction=e.createMintInstruction,exports.createMintInterface=e.createMintInterface,exports.createMintToCompressedInstruction=e.createMintToCompressedInstruction,exports.createMintToInstruction=e.createMintToInstruction,exports.createMintToInterfaceInstruction=e.createMintToInterfaceInstruction,exports.createRemoveMetadataKeyInstruction=e.createRemoveMetadataKeyInstruction,exports.createSplInterface=e.createSplInterface,exports.createTokenMetadata=e.createTokenMetadata,exports.createTokenPool=e.createTokenPool,exports.createTokenPoolAccountsLayout=e.createTokenPoolAccountsLayout,exports.createTokenProgramLookupTable=e.createTokenProgramLookupTable,exports.createTransferInterfaceInstruction=e.createTransferInterfaceInstruction,exports.createTransferOutputState=e.createTransferOutputState,exports.createUpdateFreezeAuthorityInstruction=e.createUpdateFreezeAuthorityInstruction,exports.createUpdateMetadataAuthorityInstruction=e.createUpdateMetadataAuthorityInstruction,exports.createUpdateMetadataFieldInstruction=e.createUpdateMetadataFieldInstruction,exports.createUpdateMintAuthorityInstruction=e.createUpdateMintAuthorityInstruction,exports.createWrapInstruction=e.createWrapInstruction,exports.decodeApproveInstructionData=e.decodeApproveInstructionData,exports.decodeBatchCompressInstructionData=e.decodeBatchCompressInstructionData,exports.decodeCompressSplTokenAccountInstructionData=e.decodeCompressSplTokenAccountInstructionData,exports.decodeMintToInstructionData=e.decodeMintToInstructionData,exports.decodeRevokeInstructionData=e.decodeRevokeInstructionData,exports.decodeTokenMetadata=e.decodeTokenMetadata,exports.decodeTransferInstructionData=e.decodeTransferInstructionData,exports.decompress=e.decompress,exports.decompressDelegated=e.decompressDelegated,exports.decompressInterface=e.decompressInterface,exports.deriveSplInterfaceInfo=e.deriveSplInterfaceInfo,exports.deriveTokenPoolInfo=e.deriveTokenPoolInfo,exports.deserializeMint=e.deserializeMint,exports.encodeApproveInstructionData=e.encodeApproveInstructionData,exports.encodeBatchCompressInstructionData=e.encodeBatchCompressInstructionData,exports.encodeCompressSplTokenAccountInstructionData=e.encodeCompressSplTokenAccountInstructionData,exports.encodeMintToInstructionData=e.encodeMintToInstructionData,exports.encodeRevokeInstructionData=e.encodeRevokeInstructionData,exports.encodeTokenMetadata=e.encodeTokenMetadata,exports.encodeTransferInstructionData=e.encodeTransferInstructionData,exports.extractTokenMetadata=e.extractTokenMetadata,exports.freezeAccountsLayout=e.freezeAccountsLayout,exports.getAccountInterface=e.getAccountInterface,exports.getAssociatedTokenAddressInterface=e.getAssociatedTokenAddressInterface,exports.getMintInterface=e.getMintInterface,exports.getOrCreateAtaInterface=e.getOrCreateAtaInterface,exports.getSplInterfaceInfos=e.getSplInterfaceInfos,exports.getTokenPoolInfos=e.getTokenPoolInfos,exports.isSingleSplInterfaceInfo=e.isSingleSplInterfaceInfo,exports.isSingleTokenPoolInfo=e.isSingleTokenPoolInfo,exports.mergeTokenAccounts=e.mergeTokenAccounts,exports.mintTo=e.mintTo$1,exports.mintToAccountsLayout=e.mintToAccountsLayout,exports.mintToCToken=e.mintTo,exports.mintToCompressed=e.mintToCompressed,exports.mintToInterface=e.mintToInterface,exports.mintToLayout=e.mintToLayout,exports.packCompressedTokenAccounts=e.packCompressedTokenAccounts,exports.parseCTokenCold=e.parseCTokenCold,exports.parseCTokenHot=e.parseCTokenHot,exports.parseMaybeDelegatedTransfer=e.parseMaybeDelegatedTransfer,exports.parseTokenData=e.parseTokenData,exports.removeMetadataKey=e.removeMetadataKey,exports.revoke=e.revoke,exports.revokeAccountsLayout=e.revokeAccountsLayout,exports.selectMinCompressedTokenAccountsForDecompression=e.selectMinCompressedTokenAccountsForDecompression,exports.selectMinCompressedTokenAccountsForTransfer=e.selectMinCompressedTokenAccountsForTransfer,exports.selectMinCompressedTokenAccountsForTransferOrPartial=e.selectMinCompressedTokenAccountsForTransferOrPartial,exports.selectSmartCompressedTokenAccountsForTransfer=e.selectSmartCompressedTokenAccountsForTransfer,exports.selectSmartCompressedTokenAccountsForTransferOrPartial=e.selectSmartCompressedTokenAccountsForTransferOrPartial,exports.selectSplInterfaceInfo=e.selectSplInterfaceInfo,exports.selectSplInterfaceInfosForDecompression=e.selectSplInterfaceInfosForDecompression,exports.selectTokenAccountsForApprove=e.selectTokenAccountsForApprove,exports.selectTokenPoolInfo=e.selectTokenPoolInfo,exports.selectTokenPoolInfosForDecompression=e.selectTokenPoolInfosForDecompression,exports.serializeMint=e.serializeMint,exports.sumUpTokenAmount=e.sumUpTokenAmount,exports.thawAccountsLayout=e.thawAccountsLayout,exports.toAccountInfo=e.toAccountInfo,exports.toOffChainMetadataJson=e.toOffChainMetadataJson,exports.toTokenPoolInfo=e.toTokenPoolInfo,exports.transfer=e.transfer,exports.transferAccountsLayout=e.transferAccountsLayout,exports.transferDelegated=e.transferDelegated,exports.transferInterface=e.transferInterface,exports.unpackMintData=e.unpackMintData,exports.unpackMintInterface=e.unpackMintInterface,exports.updateFreezeAuthority=e.updateFreezeAuthority,exports.updateMetadataAuthority=e.updateMetadataAuthority,exports.updateMetadataField=e.updateMetadataField,exports.updateMintAuthority=e.updateMintAuthority,exports.validateSameTokenOwner=e.validateSameTokenOwner,exports.wrap=e.wrap,Object.defineProperty(exports,"AccountState",{enumerable:1,get:function(){return t.AccountState}}),exports.createLoadAtaInstructions=async function(t,o,r,n,s,a){return e.createLoadAtaInstructions(t,o,r,n,s,a,0)},exports.getAtaInterface=async function(t,o,r,n,s,a){return e.getAtaInterface(t,o,r,n,s,a)},exports.loadAta=async function(t,o,r,n,s,a,c){return e.loadAta(t,o,r,n,s,a,c,0)};
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|