@bonfida/spl-name-service 2.3.3-alpha.2 → 2.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/favorite-domain.d.ts +11 -2
- package/dist/index.cjs +10 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.mjs +10 -10
- package/dist/index.mjs.map +1 -1
- package/dist/instructions.d.ts +35 -6
- package/dist/int.d.ts +2 -2
- package/dist/nft/name-tokenizer.d.ts +24 -2
- package/dist/resolve.d.ts +2 -0
- package/dist/state.d.ts +22 -2
- package/dist/twitter_bindings.d.ts +11 -2
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("@solana/web3.js"),e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function r(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("@solana/web3.js"),e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function r(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}for(var n={},o={byteLength:function(t){var e=f(t),r=e[0],n=e[1];return 3*(r+n)/4-n},toByteArray:function(t){var e,r,n=f(t),o=n[0],i=n[1],c=new a(function(t,e,r){return 3*(e+r)/4-r}(0,o,i)),u=0,h=i>0?o-4:o;for(r=0;r<h;r+=4)e=s[t.charCodeAt(r)]<<18|s[t.charCodeAt(r+1)]<<12|s[t.charCodeAt(r+2)]<<6|s[t.charCodeAt(r+3)],c[u++]=e>>16&255,c[u++]=e>>8&255,c[u++]=255&e;2===i&&(e=s[t.charCodeAt(r)]<<2|s[t.charCodeAt(r+1)]>>4,c[u++]=255&e);1===i&&(e=s[t.charCodeAt(r)]<<10|s[t.charCodeAt(r+1)]<<4|s[t.charCodeAt(r+2)]>>2,c[u++]=e>>8&255,c[u++]=255&e);return c},fromByteArray:function(t){for(var e,r=t.length,n=r%3,o=[],s=16383,a=0,c=r-n;a<c;a+=s)o.push(h(t,a,a+s>c?c:a+s));1===n?(e=t[r-1],o.push(i[e>>2]+i[e<<4&63]+"==")):2===n&&(e=(t[r-2]<<8)+t[r-1],o.push(i[e>>10]+i[e>>4&63]+i[e<<2&63]+"="));return o.join("")}},i=[],s=[],a="undefined"!=typeof Uint8Array?Uint8Array:Array,c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",u=0;u<64;++u)i[u]=c[u],s[c.charCodeAt(u)]=u;function f(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function h(t,e,r){for(var n,o,s=[],a=e;a<r;a+=3)n=(t[a]<<16&16711680)+(t[a+1]<<8&65280)+(255&t[a+2]),s.push(i[(o=n)>>18&63]+i[o>>12&63]+i[o>>6&63]+i[63&o]);return s.join("")}s["-".charCodeAt(0)]=62,s["_".charCodeAt(0)]=63;var d={
|
|
2
2
|
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
3
|
-
read:function(t,e,r,n,
|
|
3
|
+
read:function(t,e,r,n,o){var i,s,a=8*o-n-1,c=(1<<a)-1,u=c>>1,f=-7,h=r?o-1:0,d=r?-1:1,p=t[e+h];for(h+=d,i=p&(1<<-f)-1,p>>=-f,f+=a;f>0;i=256*i+t[e+h],h+=d,f-=8);for(s=i&(1<<-f)-1,i>>=-f,f+=n;f>0;s=256*s+t[e+h],h+=d,f-=8);if(0===i)i=1-u;else{if(i===c)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,n),i-=u}return(p?-1:1)*s*Math.pow(2,i-n)},write:function(t,e,r,n,o,i){var s,a,c,u=8*i-o-1,f=(1<<u)-1,h=f>>1,d=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,l=n?1:-1,y=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=f):(s=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-s))<1&&(s--,c*=2),(e+=s+h>=1?d/c:d*Math.pow(2,1-h))*c>=2&&(s++,c/=2),s+h>=f?(a=0,s=f):s+h>=1?(a=(e*c-1)*Math.pow(2,o),s+=h):(a=e*Math.pow(2,h-1)*Math.pow(2,o),s=0));o>=8;t[r+p]=255&a,p+=l,a/=256,o-=8);for(s=s<<o|a,u+=o;u>0;t[r+p]=255&s,p+=l,s/=256,u-=8);t[r+p-l]|=128*y}};
|
|
4
4
|
/*!
|
|
5
5
|
* The buffer module from node.js, for the browser.
|
|
6
6
|
*
|
|
7
7
|
* @author Feross Aboukhadijeh <https://feross.org>
|
|
8
8
|
* @license MIT
|
|
9
9
|
*/
|
|
10
|
-
!function(t){const e=o,r=d,n="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;t.Buffer=a,t.SlowBuffer=function(t){+t!=t&&(t=0);return a.alloc(+t)},t.INSPECT_MAX_BYTES=50;const i=2147483647;function s(t){if(t>i)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,a.prototype),e}function a(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return f(t)}return u(t,e,r)}function u(t,e,r){if("string"==typeof t)return function(t,e){"string"==typeof e&&""!==e||(e="utf8");if(!a.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const r=0|y(t,e);let n=s(r);const i=n.write(t,e);i!==r&&(n=n.slice(0,i));return n}(t,e);if(ArrayBuffer.isView(t))return function(t){if($(t,Uint8Array)){const e=new Uint8Array(t);return l(e.buffer,e.byteOffset,e.byteLength)}return h(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if($(t,ArrayBuffer)||t&&$(t.buffer,ArrayBuffer))return l(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&($(t,SharedArrayBuffer)||t&&$(t.buffer,SharedArrayBuffer)))return l(t,e,r);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return a.from(n,e,r);const i=function(t){if(a.isBuffer(t)){const e=0|p(t.length),r=s(e);return 0===r.length||t.copy(r,0,0,e),r}if(void 0!==t.length)return"number"!=typeof t.length||Y(t.length)?s(0):h(t);if("Buffer"===t.type&&Array.isArray(t.data))return h(t.data)}(t);if(i)return i;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return a.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function c(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function f(t){return c(t),s(t<0?0:0|p(t))}function h(t){const e=t.length<0?0:0|p(t.length),r=s(e);for(let n=0;n<e;n+=1)r[n]=255&t[n];return r}function l(t,e,r){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(r||0))throw new RangeError('"length" is outside of buffer bounds');let n;return n=void 0===e&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,e):new Uint8Array(t,e,r),Object.setPrototypeOf(n,a.prototype),n}function p(t){if(t>=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return 0|t}function y(t,e){if(a.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||$(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;let i=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return G(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return q(t).length;default:if(i)return n?-1:G(t).length;e=(""+e).toLowerCase(),i=!0}}function g(t,e,r){let n=!1;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 _(this,e,r);case"utf8":case"utf-8":return I(this,e,r);case"ascii":return R(this,e,r);case"latin1":case"binary":return k(this,e,r);case"base64":return S(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return P(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function w(t,e,r){const n=t[e];t[e]=t[r],t[r]=n}function m(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),Y(r=+r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof e&&(e=a.from(e,n)),a.isBuffer(e))return 0===e.length?-1:b(t,e,r,n,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):b(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function b(t,e,r,n,i){let o,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(i){let n=-1;for(o=r;o<a;o++)if(c(t,o)===c(e,-1===n?0:o-n)){if(-1===n&&(n=o),o-n+1===u)return n*s}else-1!==n&&(o-=o-n),n=-1}else for(r+u>a&&(r=a-u),o=r;o>=0;o--){let r=!0;for(let n=0;n<u;n++)if(c(t,o+n)!==c(e,n)){r=!1;break}if(r)return o}return-1}function v(t,e,r,n){r=Number(r)||0;const i=t.length-r;n?(n=Number(n))>i&&(n=i):n=i;const o=e.length;let s;for(n>o/2&&(n=o/2),s=0;s<n;++s){const n=parseInt(e.substr(2*s,2),16);if(Y(n))return s;t[r+s]=n}return s}function E(t,e,r,n){return Z(G(e,t.length-r),t,r,n)}function x(t,e,r,n){return Z(function(t){const e=[];for(let r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,n)}function A(t,e,r,n){return Z(q(e),t,r,n)}function B(t,e,r,n){return Z(function(t,e){let r,n,i;const o=[];for(let s=0;s<t.length&&!((e-=2)<0);++s)r=t.charCodeAt(s),n=r>>8,i=r%256,o.push(i),o.push(n);return o}(e,t.length-r),t,r,n)}function S(t,r,n){return 0===r&&n===t.length?e.fromByteArray(t):e.fromByteArray(t.slice(r,n))}function I(t,e,r){r=Math.min(t.length,r);const n=[];let i=e;for(;i<r;){const e=t[i];let o=null,s=e>239?4:e>223?3:e>191?2:1;if(i+s<=r){let r,n,a,u;switch(s){case 1:e<128&&(o=e);break;case 2:r=t[i+1],128==(192&r)&&(u=(31&e)<<6|63&r,u>127&&(o=u));break;case 3:r=t[i+1],n=t[i+2],128==(192&r)&&128==(192&n)&&(u=(15&e)<<12|(63&r)<<6|63&n,u>2047&&(u<55296||u>57343)&&(o=u));break;case 4:r=t[i+1],n=t[i+2],a=t[i+3],128==(192&r)&&128==(192&n)&&128==(192&a)&&(u=(15&e)<<18|(63&r)<<12|(63&n)<<6|63&a,u>65535&&u<1114112&&(o=u))}}null===o?(o=65533,s=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|1023&o),n.push(o),i+=s}return function(t){const e=t.length;if(e<=M)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=M));return r}(n)}t.kMaxLength=i,a.TYPED_ARRAY_SUPPORT=function(){try{const t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),42===t.foo()}catch(t){return!1}}(),a.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(a.prototype,"parent",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.buffer}}),Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.byteOffset}}),a.poolSize=8192,a.from=function(t,e,r){return u(t,e,r)},Object.setPrototypeOf(a.prototype,Uint8Array.prototype),Object.setPrototypeOf(a,Uint8Array),a.alloc=function(t,e,r){return function(t,e,r){return c(t),t<=0?s(t):void 0!==e?"string"==typeof r?s(t).fill(e,r):s(t).fill(e):s(t)}(t,e,r)},a.allocUnsafe=function(t){return f(t)},a.allocUnsafeSlow=function(t){return f(t)},a.isBuffer=function(t){return null!=t&&!0===t._isBuffer&&t!==a.prototype},a.compare=function(t,e){if($(t,Uint8Array)&&(t=a.from(t,t.offset,t.byteLength)),$(e,Uint8Array)&&(e=a.from(e,e.offset,e.byteLength)),!a.isBuffer(t)||!a.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;let r=t.length,n=e.length;for(let i=0,o=Math.min(r,n);i<o;++i)if(t[i]!==e[i]){r=t[i],n=e[i];break}return r<n?-1:n<r?1:0},a.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!0;default:return!1}},a.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return a.alloc(0);let r;if(void 0===e)for(e=0,r=0;r<t.length;++r)e+=t[r].length;const n=a.allocUnsafe(e);let i=0;for(r=0;r<t.length;++r){let e=t[r];if($(e,Uint8Array))i+e.length>n.length?(a.isBuffer(e)||(e=a.from(e)),e.copy(n,i)):Uint8Array.prototype.set.call(n,e,i);else{if(!a.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(n,i)}i+=e.length}return n},a.byteLength=y,a.prototype._isBuffer=!0,a.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;e<t;e+=2)w(this,e,e+1);return this},a.prototype.swap32=function(){const t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let e=0;e<t;e+=4)w(this,e,e+3),w(this,e+1,e+2);return this},a.prototype.swap64=function(){const t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let e=0;e<t;e+=8)w(this,e,e+7),w(this,e+1,e+6),w(this,e+2,e+5),w(this,e+3,e+4);return this},a.prototype.toString=function(){const t=this.length;return 0===t?"":0===arguments.length?I(this,0,t):g.apply(this,arguments)},a.prototype.toLocaleString=a.prototype.toString,a.prototype.equals=function(t){if(!a.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===a.compare(this,t)},a.prototype.inspect=function(){let e="";const r=t.INSPECT_MAX_BYTES;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"},n&&(a.prototype[n]=a.prototype.inspect),a.prototype.compare=function(t,e,r,n,i){if($(t,Uint8Array)&&(t=a.from(t,t.offset,t.byteLength)),!a.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&e>=r)return 0;if(n>=i)return-1;if(e>=r)return 1;if(this===t)return 0;let o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(e>>>=0);const u=Math.min(o,s),c=this.slice(n,i),f=t.slice(e,r);for(let t=0;t<u;++t)if(c[t]!==f[t]){o=c[t],s=f[t];break}return o<s?-1:s<o?1:0},a.prototype.includes=function(t,e,r){return-1!==this.indexOf(t,e,r)},a.prototype.indexOf=function(t,e,r){return m(this,t,e,r,!0)},a.prototype.lastIndexOf=function(t,e,r){return m(this,t,e,r,!1)},a.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)}const i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let o=!1;for(;;)switch(n){case"hex":return v(this,t,e,r);case"utf8":case"utf-8":return E(this,t,e,r);case"ascii":case"latin1":case"binary":return x(this,t,e,r);case"base64":return A(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return B(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const M=4096;function R(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(127&t[i]);return n}function k(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(t[i]);return n}function _(t,e,r){const n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);let i="";for(let n=e;n<r;++n)i+=X[t[n]];return i}function P(t,e,r){const n=t.slice(e,r);let i="";for(let t=0;t<n.length-1;t+=2)i+=String.fromCharCode(n[t]+256*n[t+1]);return i}function T(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 U(t,e,r,n,i,o){if(!a.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<o)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}function L(t,e,r,n,i){F(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r++]=o,o>>=8,t[r++]=o,o>>=8,t[r++]=o,o>>=8,t[r++]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=s,s>>=8,t[r++]=s,s>>=8,t[r++]=s,s>>=8,t[r++]=s,r}function O(t,e,r,n,i){F(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r+7]=o,o>>=8,t[r+6]=o,o>>=8,t[r+5]=o,o>>=8,t[r+4]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=s,s>>=8,t[r+2]=s,s>>=8,t[r+1]=s,s>>=8,t[r]=s,r+8}function C(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function N(t,e,n,i,o){return e=+e,n>>>=0,o||C(t,0,n,4),r.write(t,e,n,i,23,4),n+4}function D(t,e,n,i,o){return e=+e,n>>>=0,o||C(t,0,n,8),r.write(t,e,n,i,52,8),n+8}a.prototype.slice=function(t,e){const r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e<t&&(e=t);const n=this.subarray(t,e);return Object.setPrototypeOf(n,a.prototype),n},a.prototype.readUintLE=a.prototype.readUIntLE=function(t,e,r){t>>>=0,e>>>=0,r||T(t,e,this.length);let n=this[t],i=1,o=0;for(;++o<e&&(i*=256);)n+=this[t+o]*i;return n},a.prototype.readUintBE=a.prototype.readUIntBE=function(t,e,r){t>>>=0,e>>>=0,r||T(t,e,this.length);let n=this[t+--e],i=1;for(;e>0&&(i*=256);)n+=this[t+--e]*i;return n},a.prototype.readUint8=a.prototype.readUInt8=function(t,e){return t>>>=0,e||T(t,1,this.length),this[t]},a.prototype.readUint16LE=a.prototype.readUInt16LE=function(t,e){return t>>>=0,e||T(t,2,this.length),this[t]|this[t+1]<<8},a.prototype.readUint16BE=a.prototype.readUInt16BE=function(t,e){return t>>>=0,e||T(t,2,this.length),this[t]<<8|this[t+1]},a.prototype.readUint32LE=a.prototype.readUInt32LE=function(t,e){return t>>>=0,e||T(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},a.prototype.readUint32BE=a.prototype.readUInt32BE=function(t,e){return t>>>=0,e||T(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},a.prototype.readBigUInt64LE=Q((function(t){j(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||K(t,this.length-8);const n=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,i=this[++t]+256*this[++t]+65536*this[++t]+r*2**24;return BigInt(n)+(BigInt(i)<<BigInt(32))})),a.prototype.readBigUInt64BE=Q((function(t){j(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||K(t,this.length-8);const n=e*2**24+65536*this[++t]+256*this[++t]+this[++t],i=this[++t]*2**24+65536*this[++t]+256*this[++t]+r;return(BigInt(n)<<BigInt(32))+BigInt(i)})),a.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||T(t,e,this.length);let n=this[t],i=1,o=0;for(;++o<e&&(i*=256);)n+=this[t+o]*i;return i*=128,n>=i&&(n-=Math.pow(2,8*e)),n},a.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||T(t,e,this.length);let n=e,i=1,o=this[t+--n];for(;n>0&&(i*=256);)o+=this[t+--n]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*e)),o},a.prototype.readInt8=function(t,e){return t>>>=0,e||T(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},a.prototype.readInt16LE=function(t,e){t>>>=0,e||T(t,2,this.length);const r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},a.prototype.readInt16BE=function(t,e){t>>>=0,e||T(t,2,this.length);const r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},a.prototype.readInt32LE=function(t,e){return t>>>=0,e||T(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},a.prototype.readInt32BE=function(t,e){return t>>>=0,e||T(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},a.prototype.readBigInt64LE=Q((function(t){j(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||K(t,this.length-8);const n=this[t+4]+256*this[t+5]+65536*this[t+6]+(r<<24);return(BigInt(n)<<BigInt(32))+BigInt(e+256*this[++t]+65536*this[++t]+this[++t]*2**24)})),a.prototype.readBigInt64BE=Q((function(t){j(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||K(t,this.length-8);const n=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(n)<<BigInt(32))+BigInt(this[++t]*2**24+65536*this[++t]+256*this[++t]+r)})),a.prototype.readFloatLE=function(t,e){return t>>>=0,e||T(t,4,this.length),r.read(this,t,!0,23,4)},a.prototype.readFloatBE=function(t,e){return t>>>=0,e||T(t,4,this.length),r.read(this,t,!1,23,4)},a.prototype.readDoubleLE=function(t,e){return t>>>=0,e||T(t,8,this.length),r.read(this,t,!0,52,8)},a.prototype.readDoubleBE=function(t,e){return t>>>=0,e||T(t,8,this.length),r.read(this,t,!1,52,8)},a.prototype.writeUintLE=a.prototype.writeUIntLE=function(t,e,r,n){if(t=+t,e>>>=0,r>>>=0,!n){U(this,t,e,r,Math.pow(2,8*r)-1,0)}let i=1,o=0;for(this[e]=255&t;++o<r&&(i*=256);)this[e+o]=t/i&255;return e+r},a.prototype.writeUintBE=a.prototype.writeUIntBE=function(t,e,r,n){if(t=+t,e>>>=0,r>>>=0,!n){U(this,t,e,r,Math.pow(2,8*r)-1,0)}let i=r-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+r},a.prototype.writeUint8=a.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,1,255,0),this[e]=255&t,e+1},a.prototype.writeUint16LE=a.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},a.prototype.writeUint16BE=a.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},a.prototype.writeUint32LE=a.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},a.prototype.writeUint32BE=a.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},a.prototype.writeBigUInt64LE=Q((function(t,e=0){return L(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),a.prototype.writeBigUInt64BE=Q((function(t,e=0){return O(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),a.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);U(this,t,e,r,n-1,-n)}let i=0,o=1,s=0;for(this[e]=255&t;++i<r&&(o*=256);)t<0&&0===s&&0!==this[e+i-1]&&(s=1),this[e+i]=(t/o>>0)-s&255;return e+r},a.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);U(this,t,e,r,n-1,-n)}let i=r-1,o=1,s=0;for(this[e+i]=255&t;--i>=0&&(o*=256);)t<0&&0===s&&0!==this[e+i+1]&&(s=1),this[e+i]=(t/o>>0)-s&255;return e+r},a.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},a.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},a.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},a.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},a.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},a.prototype.writeBigInt64LE=Q((function(t,e=0){return L(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),a.prototype.writeBigInt64BE=Q((function(t,e=0){return O(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),a.prototype.writeFloatLE=function(t,e,r){return N(this,t,e,!0,r)},a.prototype.writeFloatBE=function(t,e,r){return N(this,t,e,!1,r)},a.prototype.writeDoubleLE=function(t,e,r){return D(this,t,e,!0,r)},a.prototype.writeDoubleBE=function(t,e,r){return D(this,t,e,!1,r)},a.prototype.copy=function(t,e,r,n){if(!a.isBuffer(t))throw new TypeError("argument should be a Buffer");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("Index out of range");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);const i=n-r;return this===t&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(e,r,n):Uint8Array.prototype.set.call(t,this.subarray(r,n),e),i},a.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),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!a.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){const e=t.charCodeAt(0);("utf8"===n&&e<128||"latin1"===n)&&(t=e)}}else"number"==typeof t?t&=255:"boolean"==typeof t&&(t=Number(t));if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;let 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{const o=a.isBuffer(t)?t:a.from(t,n),s=o.length;if(0===s)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(i=0;i<r-e;++i)this[i+e]=o[i%s]}return this};const z={};function V(t,e,r){z[t]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${t}]`,this.stack,delete this.name}get code(){return t}set code(t){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:t,writable:!0})}toString(){return`${this.name} [${t}]: ${this.message}`}}}function W(t){let e="",r=t.length;const n="-"===t[0]?1:0;for(;r>=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function F(t,e,r,n,i,o){if(t>r||t<e){const n="bigint"==typeof e?"n":"";let i;throw i=o>3?0===e||e===BigInt(0)?`>= 0${n} and < 2${n} ** ${8*(o+1)}${n}`:`>= -(2${n} ** ${8*(o+1)-1}${n}) and < 2 ** ${8*(o+1)-1}${n}`:`>= ${e}${n} and <= ${r}${n}`,new z.ERR_OUT_OF_RANGE("value",i,t)}!function(t,e,r){j(e,"offset"),void 0!==t[e]&&void 0!==t[e+r]||K(e,t.length-(r+1))}(n,i,o)}function j(t,e){if("number"!=typeof t)throw new z.ERR_INVALID_ARG_TYPE(e,"number",t)}function K(t,e,r){if(Math.floor(t)!==t)throw j(t,r),new z.ERR_OUT_OF_RANGE(r||"offset","an integer",t);if(e<0)throw new z.ERR_BUFFER_OUT_OF_BOUNDS;throw new z.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}V("ERR_BUFFER_OUT_OF_BOUNDS",(function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),V("ERR_INVALID_ARG_TYPE",(function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`}),TypeError),V("ERR_OUT_OF_RANGE",(function(t,e,r){let n=`The value of "${t}" is out of range.`,i=r;return Number.isInteger(r)&&Math.abs(r)>2**32?i=W(String(r)):"bigint"==typeof r&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=W(i)),i+="n"),n+=` It must be ${e}. Received ${i}`,n}),RangeError);const H=/[^+/0-9A-Za-z-_]/g;function G(t,e){let r;e=e||1/0;const n=t.length;let i=null;const o=[];for(let s=0;s<n;++s){if(r=t.charCodeAt(s),r>55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;o.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;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function q(t){return e.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(H,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function Z(t,e,r,n){let i;for(i=0;i<n&&!(i+r>=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function $(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function Y(t){return t!=t}const X=function(){const t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){const n=16*r;for(let i=0;i<16;++i)e[n+i]=t[r]+t[i]}return e}();function Q(t){return"undefined"==typeof BigInt?J:t}function J(){throw new Error("BigInt not supported")}}(i);const p=new t.PublicKey("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA");new t.PublicKey("TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb");const y=new t.PublicKey("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL");new t.PublicKey("So11111111111111111111111111111111111111112"),new t.PublicKey("9pan9bMn5HatX4EJdBwg9VgCa7Uz5HL8N1m5D3NdXejP");var g={};Object.defineProperty(g,"__esModule",{value:!0}),g.s16=g.s8=g.nu64be=g.u48be=g.u40be=g.u32be=g.u24be=g.u16be=g.nu64=g.u48=g.u40=et=g.u32=g.u24=g.u16=tt=g.u8=g.offset=g.greedy=g.Constant=g.UTF8=g.CString=g.Blob=g.Boolean=g.BitField=g.BitStructure=g.VariantLayout=g.Union=g.UnionLayoutDiscriminator=g.UnionDiscriminator=g.Structure=g.Sequence=g.DoubleBE=g.Double=g.FloatBE=g.Float=g.NearInt64BE=g.NearInt64=g.NearUInt64BE=g.NearUInt64=g.IntBE=g.Int=g.UIntBE=g.UInt=g.OffsetLayout=g.GreedyCount=g.ExternalLayout=g.bindConstructorLayout=g.nameWithProperty=g.Layout=g.uint8ArrayToBuffer=g.checkUint8Array=void 0,g.constant=g.utf8=g.cstr=nt=g.blob=g.unionLayoutDiscriminator=g.union=g.seq=g.bits=rt=g.struct=g.f64be=g.f64=g.f32be=g.f32=g.ns64be=g.s48be=g.s40be=g.s32be=g.s24be=g.s16be=g.ns64=g.s48=g.s40=g.s32=g.s24=void 0;const w=i;function m(t){if(!(t instanceof Uint8Array))throw new TypeError("b must be a Uint8Array")}function b(t){return m(t),w.Buffer.from(t.buffer,t.byteOffset,t.length)}g.checkUint8Array=m,g.uint8ArrayToBuffer=b;class v{constructor(t,e){if(!Number.isInteger(t))throw new TypeError("span must be an integer");this.span=t,this.property=e}makeDestinationObject(){return{}}getSpan(t,e){if(0>this.span)throw new RangeError("indeterminate span");return this.span}replicate(t){const e=Object.create(this.constructor.prototype);return Object.assign(e,this),e.property=t,e}fromArray(t){}}function E(t,e){return e.property?t+"["+e.property+"]":t}g.Layout=v,g.nameWithProperty=E,g.bindConstructorLayout=function(t,e){if("function"!=typeof t)throw new TypeError("Class must be constructor");if(Object.prototype.hasOwnProperty.call(t,"layout_"))throw new Error("Class is already bound to a layout");if(!(e&&e instanceof v))throw new TypeError("layout must be a Layout");if(Object.prototype.hasOwnProperty.call(e,"boundConstructor_"))throw new Error("layout is already bound to a constructor");t.layout_=e,e.boundConstructor_=t,e.makeDestinationObject=()=>new t,Object.defineProperty(t.prototype,"encode",{value(t,r){return e.encode(this,t,r)},writable:!0}),Object.defineProperty(t,"decode",{value:(t,r)=>e.decode(t,r),writable:!0})};class x extends v{isCount(){throw new Error("ExternalLayout is abstract")}}g.ExternalLayout=x;class A extends x{constructor(t=1,e){if(!Number.isInteger(t)||0>=t)throw new TypeError("elementSpan must be a (positive) integer");super(-1,e),this.elementSpan=t}isCount(){return!0}decode(t,e=0){m(t);const r=t.length-e;return Math.floor(r/this.elementSpan)}encode(t,e,r){return 0}}g.GreedyCount=A;class B extends x{constructor(t,e=0,r){if(!(t instanceof v))throw new TypeError("layout must be a Layout");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 S||this.layout instanceof I}decode(t,e=0){return this.layout.decode(t,e+this.offset)}encode(t,e,r=0){return this.layout.encode(t,e,r+this.offset)}}g.OffsetLayout=B;class S extends v{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return b(t).readUIntLE(e,this.span)}encode(t,e,r=0){return b(e).writeUIntLE(t,r,this.span),this.span}}g.UInt=S;class I extends v{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return b(t).readUIntBE(e,this.span)}encode(t,e,r=0){return b(e).writeUIntBE(t,r,this.span),this.span}}g.UIntBE=I;class M extends v{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return b(t).readIntLE(e,this.span)}encode(t,e,r=0){return b(e).writeIntLE(t,r,this.span),this.span}}g.Int=M;class R extends v{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return b(t).readIntBE(e,this.span)}encode(t,e,r=0){return b(e).writeIntBE(t,r,this.span),this.span}}g.IntBE=R;const k=Math.pow(2,32);function _(t){const e=Math.floor(t/k);return{hi32:e,lo32:t-e*k}}function P(t,e){return t*k+e}class T extends v{constructor(t){super(8,t)}decode(t,e=0){const r=b(t),n=r.readUInt32LE(e);return P(r.readUInt32LE(e+4),n)}encode(t,e,r=0){const n=_(t),i=b(e);return i.writeUInt32LE(n.lo32,r),i.writeUInt32LE(n.hi32,r+4),8}}g.NearUInt64=T;class U extends v{constructor(t){super(8,t)}decode(t,e=0){const r=b(t);return P(r.readUInt32BE(e),r.readUInt32BE(e+4))}encode(t,e,r=0){const n=_(t),i=b(e);return i.writeUInt32BE(n.hi32,r),i.writeUInt32BE(n.lo32,r+4),8}}g.NearUInt64BE=U;class L extends v{constructor(t){super(8,t)}decode(t,e=0){const r=b(t),n=r.readUInt32LE(e);return P(r.readInt32LE(e+4),n)}encode(t,e,r=0){const n=_(t),i=b(e);return i.writeUInt32LE(n.lo32,r),i.writeInt32LE(n.hi32,r+4),8}}g.NearInt64=L;class O extends v{constructor(t){super(8,t)}decode(t,e=0){const r=b(t);return P(r.readInt32BE(e),r.readUInt32BE(e+4))}encode(t,e,r=0){const n=_(t),i=b(e);return i.writeInt32BE(n.hi32,r),i.writeUInt32BE(n.lo32,r+4),8}}g.NearInt64BE=O;class C extends v{constructor(t){super(4,t)}decode(t,e=0){return b(t).readFloatLE(e)}encode(t,e,r=0){return b(e).writeFloatLE(t,r),4}}g.Float=C;class N extends v{constructor(t){super(4,t)}decode(t,e=0){return b(t).readFloatBE(e)}encode(t,e,r=0){return b(e).writeFloatBE(t,r),4}}g.FloatBE=N;class D extends v{constructor(t){super(8,t)}decode(t,e=0){return b(t).readDoubleLE(e)}encode(t,e,r=0){return b(e).writeDoubleLE(t,r),8}}g.Double=D;class z extends v{constructor(t){super(8,t)}decode(t,e=0){return b(t).readDoubleBE(e)}encode(t,e,r=0){return b(e).writeDoubleBE(t,r),8}}g.DoubleBE=z;class V extends v{constructor(t,e,r){if(!(t instanceof v))throw new TypeError("elementLayout must be a Layout");if(!(e instanceof x&&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 x)&&0<t.span&&(n=e*t.span),super(n,r),this.elementLayout=t,this.count=e}getSpan(t,e=0){if(0<=this.span)return this.span;let r=0,n=this.count;if(n instanceof x&&(n=n.decode(t,e)),0<this.elementLayout.span)r=n*this.elementLayout.span;else{let i=0;for(;i<n;)r+=this.elementLayout.getSpan(t,e+r),++i}return r}decode(t,e=0){const r=[];let n=0,i=this.count;for(i instanceof x&&(i=i.decode(t,e));n<i;)r.push(this.elementLayout.decode(t,e)),e+=this.elementLayout.getSpan(t,e),n+=1;return r}encode(t,e,r=0){const n=this.elementLayout,i=t.reduce(((t,i)=>t+n.encode(i,e,r+t)),0);return this.count instanceof x&&this.count.encode(t.length,e,r),i}}g.Sequence=V;class W extends v{constructor(t,e,r){if(!Array.isArray(t)||!t.reduce(((t,e)=>t&&e instanceof v),!0))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=0){if(0<=this.span)return this.span;let r=0;try{r=this.fields.reduce(((r,n)=>{const i=n.getSpan(t,e);return e+=i,r+i}),0)}catch(t){throw new RangeError("indeterminate span")}return r}decode(t,e=0){m(t);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=0){const n=r;let i=0,o=0;for(const n of this.fields){let s=n.span;if(o=0<s?s:0,void 0!==n.property){const i=t[n.property];void 0!==i&&(o=n.encode(i,e,r),0>s&&(s=n.getSpan(e,r)))}i=r,r+=s}return i+o-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)}}}g.Structure=W;class F{constructor(t){this.property=t}decode(t,e){throw new Error("UnionDiscriminator is abstract")}encode(t,e,r){throw new Error("UnionDiscriminator is abstract")}}g.UnionDiscriminator=F;class j extends F{constructor(t,e){if(!(t instanceof x&&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)}}g.UnionLayoutDiscriminator=j;class K extends v{constructor(t,e,r){let n;if(t instanceof S||t instanceof I)n=new j(new B(t));else if(t instanceof x&&t.isCount())n=new j(t);else{if(!(t instanceof F))throw new TypeError("discr must be a UnionDiscriminator or an unsigned integer layout");n=t}if(void 0===e&&(e=null),!(null===e||e instanceof v))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 i=-1;e&&(i=e.span,0<=i&&(t instanceof S||t instanceof I)&&(i+=n.layout.span)),super(i,r),this.discriminator=n,this.usesPrefixDiscriminator=t instanceof S||t instanceof I,this.defaultLayout=e,this.registry={};let o=this.defaultGetSourceVariant.bind(this);this.getSourceVariant=function(t){return o(t)},this.configGetSourceVariant=function(t){o=t.bind(this)}}getSpan(t,e=0){if(0<=this.span)return this.span;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(Object.prototype.hasOwnProperty.call(t,this.discriminator.property)){if(this.defaultLayout&&this.defaultLayout.property&&Object.prototype.hasOwnProperty.call(t,this.defaultLayout.property))return;const e=this.registry[t[this.discriminator.property]];if(e&&(!e.layout||e.property&&Object.prototype.hasOwnProperty.call(t,e.property)))return e}else for(const e in this.registry){const r=this.registry[e];if(r.property&&Object.prototype.hasOwnProperty.call(t,r.property))return r}throw new Error("unable to infer src variant")}decode(t,e=0){let r;const n=this.discriminator,i=n.decode(t,e),o=this.registry[i];if(void 0===o){const o=this.defaultLayout;let s=0;this.usesPrefixDiscriminator&&(s=n.layout.span),r=this.makeDestinationObject(),r[n.property]=i,r[o.property]=o.decode(t,e+s)}else r=o.decode(t,e);return r}encode(t,e,r=0){const n=this.getSourceVariant(t);if(void 0===n){const n=this.discriminator,i=this.defaultLayout;let o=0;return this.usesPrefixDiscriminator&&(o=n.layout.span),n.encode(t[n.property],e,r),o+i.encode(t[i.property],e,r+o)}return n.encode(t,e,r)}addVariant(t,e,r){const n=new H(this,t,e,r);return this.registry[t]=n,n}getVariant(t,e=0){let r;return r=t instanceof Uint8Array?this.discriminator.decode(t,e):t,this.registry[r]}}g.Union=K;class H extends v{constructor(t,e,r,n){if(!(t instanceof K))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 v))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 i=t.span;0>t.span&&(i=r?r.span:0,0<=i&&t.usesPrefixDiscriminator&&(i+=t.discriminator.layout.span)),super(i,n),this.union=t,this.variant=e,this.layout=r||null}getSpan(t,e=0){if(0<=this.span)return this.span;let r=0;this.union.usesPrefixDiscriminator&&(r=this.union.discriminator.layout.span);let n=0;return this.layout&&(n=this.layout.getSpan(t,e+r)),r+n}decode(t,e=0){const r=this.makeDestinationObject();if(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]=!0:this.union.usesPrefixDiscriminator&&(r[this.union.discriminator.property]=this.variant),r}encode(t,e,r=0){let n=0;if(this.union.usesPrefixDiscriminator&&(n=this.union.discriminator.layout.span),this.layout&&!Object.prototype.hasOwnProperty.call(t,this.property))throw new TypeError("variant lacks property "+this.property);this.union.discriminator.encode(this.variant,e,r);let i=n;if(this.layout&&(this.layout.encode(t[this.property],e,r+n),i+=this.layout.getSpan(e,r+n),0<=this.union.span&&i>this.union.span))throw new Error("encoded variant overruns containing union");return i}fromArray(t){if(this.layout)return this.layout.fromArray(t)}}function G(t){return 0>t&&(t+=4294967296),t}g.VariantLayout=H;class q extends v{constructor(t,e,r){if(!(t instanceof S||t instanceof I))throw new TypeError("word must be a UInt or UIntBE layout");if("string"==typeof e&&void 0===r&&(r=e,e=!1),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=G(t),this},this._packedGetValue=function(){return n}}decode(t,e=0){const r=this.makeDestinationObject(),n=this.word.decode(t,e);this._packedSetValue(n);for(const e of this.fields)void 0!==e.property&&(r[e.property]=e.decode(t));return r}encode(t,e,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 Z(this,t,e);return this.fields.push(r),r}addBoolean(t){const e=new $(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}}g.BitStructure=q;class Z{constructor(t,e,r){if(!(t instanceof q))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,i=t.fields.reduce(((t,e)=>t+e.bits),0);if(e+i>n)throw new Error("bits too long for span remainder ("+(n-i)+" of "+n+" remain)");this.container=t,this.bits=e,this.valueMask=(1<<e)-1,32===e&&(this.valueMask=4294967295),this.start=i,this.container.msb&&(this.start=n-i-e),this.wordMask=G(this.valueMask<<this.start),this.property=r}decode(t,e){return G(this.container._packedGetValue()&this.wordMask)>>>this.start}encode(t){if("number"!=typeof t||!Number.isInteger(t)||t!==G(t&this.valueMask))throw new TypeError(E("BitField.encode",this)+" value must be integer not exceeding "+this.valueMask);const e=this.container._packedGetValue(),r=G(t<<this.start);this.container._packedSetValue(G(e&~this.wordMask)|r)}}g.BitField=Z;class $ extends Z{constructor(t,e){super(t,1,e)}decode(t,e){return!!super.decode(t,e)}encode(t){"boolean"==typeof t&&(t=+t),super.encode(t)}}g.Boolean=$;class Y extends v{constructor(t,e){if(!(t instanceof x&&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 x||(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=0){let r=this.span;return 0>r&&(r=this.length.decode(t,e)),b(t).slice(e,e+r)}encode(t,e,r){let n=this.length;if(this.length instanceof x&&(n=t.length),!(t instanceof Uint8Array&&n===t.length))throw new TypeError(E("Blob.encode",this)+" requires (length "+n+") Uint8Array as src");if(r+n>e.length)throw new RangeError("encoding overruns Uint8Array");const i=b(t);return b(e).write(i.toString("hex"),r,n,"hex"),this.length instanceof x&&this.length.encode(n,e,r),n}}g.Blob=Y;class X extends v{constructor(t){super(-1,t)}getSpan(t,e=0){m(t);let r=e;for(;r<t.length&&0!==t[r];)r+=1;return 1+r-e}decode(t,e=0){const r=this.getSpan(t,e);return b(t).slice(e,e+r-1).toString("utf-8")}encode(t,e,r=0){"string"!=typeof t&&(t=String(t));const n=w.Buffer.from(t,"utf8"),i=n.length;if(r+i>e.length)throw new RangeError("encoding overruns Buffer");const o=b(e);return n.copy(o,r),o[r+i]=0,i+1}}g.CString=X;class Q extends v{constructor(t,e){if("string"==typeof t&&void 0===e&&(e=t,t=void 0),void 0===t)t=-1;else if(!Number.isInteger(t))throw new TypeError("maxSpan must be an integer");super(-1,e),this.maxSpan=t}getSpan(t,e=0){return m(t),t.length-e}decode(t,e=0){const r=this.getSpan(t,e);if(0<=this.maxSpan&&this.maxSpan<r)throw new RangeError("text length exceeds maxSpan");return b(t).slice(e,e+r).toString("utf-8")}encode(t,e,r=0){"string"!=typeof t&&(t=String(t));const n=w.Buffer.from(t,"utf8"),i=n.length;if(0<=this.maxSpan&&this.maxSpan<i)throw new RangeError("text length exceeds maxSpan");if(r+i>e.length)throw new RangeError("encoding overruns Buffer");return n.copy(b(e),r),i}}g.UTF8=Q;class J extends v{constructor(t,e){super(0,e),this.value=t}decode(t,e){return this.value}encode(t,e,r){return 0}}g.Constant=J,g.greedy=(t,e)=>new A(t,e),g.offset=(t,e,r)=>new B(t,e,r);var tt=g.u8=t=>new S(1,t);g.u16=t=>new S(2,t),g.u24=t=>new S(3,t);var et=g.u32=t=>new S(4,t);g.u40=t=>new S(5,t),g.u48=t=>new S(6,t),g.nu64=t=>new T(t),g.u16be=t=>new I(2,t),g.u24be=t=>new I(3,t),g.u32be=t=>new I(4,t),g.u40be=t=>new I(5,t),g.u48be=t=>new I(6,t),g.nu64be=t=>new U(t),g.s8=t=>new M(1,t),g.s16=t=>new M(2,t),g.s24=t=>new M(3,t),g.s32=t=>new M(4,t),g.s40=t=>new M(5,t),g.s48=t=>new M(6,t),g.ns64=t=>new L(t),g.s16be=t=>new R(2,t),g.s24be=t=>new R(3,t),g.s32be=t=>new R(4,t),g.s40be=t=>new R(5,t),g.s48be=t=>new R(6,t),g.ns64be=t=>new O(t),g.f32=t=>new C(t),g.f32be=t=>new N(t),g.f64=t=>new D(t),g.f64be=t=>new z(t);var rt=g.struct=(t,e,r)=>new W(t,e,r);g.bits=(t,e,r)=>new q(t,e,r),g.seq=(t,e,r)=>new V(t,e,r),g.union=(t,e,r)=>new K(t,e,r),g.unionLayoutDiscriminator=(t,e)=>new j(t,e);var nt=g.blob=(t,e)=>new Y(t,e);g.cstr=t=>new X(t),g.utf8=(t,e)=>new Q(t,e),g.constant=(t,e)=>new J(t,e);const it=t=>({decode:t.decode.bind(t),encode:t.encode.bind(t)});var ot={};Object.defineProperty(ot,"__esModule",{value:!0});var st=ot.toBigIntLE=function(t){{const e=Buffer.from(t);e.reverse();const r=e.toString("hex");return 0===r.length?BigInt(0):BigInt(`0x${r}`)}};ot.toBigIntBE=function(t){{const e=t.toString("hex");return 0===e.length?BigInt(0):BigInt(`0x${e}`)}};var at=ot.toBufferLE=function(t,e){{const r=t.toString(16),n=Buffer.from(r.padStart(2*e,"0").slice(0,2*e),"hex");return n.reverse(),n}};ot.toBufferBE=function(t,e){{const r=t.toString(16);return Buffer.from(r.padStart(2*e,"0").slice(0,2*e),"hex")}};const ut=(ct=8,t=>{const e=nt(ct,t),{encode:r,decode:n}=it(e),i=e;return i.decode=(t,e)=>{const r=n(t,e);return st(Buffer.from(r))},i.encode=(t,e,n)=>{const i=at(t,ct);return r(i,e,n)},i});var ct;const ft=t=>{const e=tt(t),{encode:r,decode:n}=it(e),i=e;return i.decode=(t,e)=>!!n(t,e),i.encode=(t,e,n)=>{const i=Number(t);return r(i,e,n)},i},ht=e=>{const r=nt(32,e),{encode:n,decode:i}=it(r),o=r;return o.decode=(e,r)=>{const n=i(e,r);return new t.PublicKey(n)},o.encode=(t,e,r)=>{const i=t.toBuffer();return n(i,e,r)},o};class lt extends Error{constructor(t){super(t)}}class dt extends lt{constructor(){super(...arguments),this.name="TokenAccountNotFoundError"}}class pt extends lt{constructor(){super(...arguments),this.name="TokenInvalidAccountOwnerError"}}class yt extends lt{constructor(){super(...arguments),this.name="TokenInvalidAccountSizeError"}}class gt extends lt{constructor(){super(...arguments),this.name="TokenInvalidMintError"}}class wt extends lt{constructor(){super(...arguments),this.name="TokenOwnerOffCurveError"}}var mt;!function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Mint=1]="Mint",t[t.Account=2]="Account"}(mt||(mt={}));const bt=1,vt=rt([tt("m"),tt("n"),ft("isInitialized"),ht("signer1"),ht("signer2"),ht("signer3"),ht("signer4"),ht("signer5"),ht("signer6"),ht("signer7"),ht("signer8"),ht("signer9"),ht("signer10"),ht("signer11")]).span;var Et;!function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Initialized=1]="Initialized",t[t.Frozen=2]="Frozen"}(Et||(Et={}));const xt=rt([ht("mint"),ht("owner"),ut("amount"),et("delegateOption"),ht("delegate"),tt("state"),et("isNativeOption"),ut("isNative"),ut("delegatedAmount"),et("closeAuthorityOption"),ht("closeAuthority")]),At=xt.span,Bt=rt([et("mintAuthorityOption"),ht("mintAuthority"),ut("supply"),tt("decimals"),ft("isInitialized"),et("freezeAuthorityOption"),ht("freezeAuthority")]),St=Bt.span;async function It(t,e,r,n=p){return function(t,e,r=p){if(!e)throw new dt;if(!e.owner.equals(r))throw new pt;if(e.data.length<St)throw new yt;const n=Bt.decode(e.data.slice(0,St));let i=Buffer.alloc(0);if(e.data.length>St){if(e.data.length<=At)throw new yt;if(e.data.length===vt)throw new yt;if(e.data[At]!=mt.Mint)throw new gt;i=e.data.slice(At+bt)}return{address:t,mintAuthority:n.mintAuthorityOption?n.mintAuthority:null,supply:n.supply,decimals:n.decimals,isInitialized:n.isInitialized,freezeAuthority:n.freezeAuthorityOption?n.freezeAuthority:null,tlvData:i}}(e,await t.getAccountInfo(e,r),n)}function Mt(e,r,n=!1,i=p,o=y){if(!n&&!t.PublicKey.isOnCurve(r.toBuffer()))throw new wt;const[s]=t.PublicKey.findProgramAddressSync([r.toBuffer(),i.toBuffer(),e.toBuffer()],o);return s}function Rt(e,r,n,i,o=p,s=y){return function(e,r,n,i,o,s=p,a=y){const u=[{pubkey:e,isSigner:!0,isWritable:!0},{pubkey:r,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!1,isWritable:!1},{pubkey:i,isSigner:!1,isWritable:!1},{pubkey:t.SystemProgram.programId,isSigner:!1,isWritable:!1},{pubkey:s,isSigner:!1,isWritable:!1}];return new t.TransactionInstruction({keys:u,programId:a,data:o})}(e,r,n,i,Buffer.from([1]),o,s)}var kt;exports.ErrorType=void 0,(kt=exports.ErrorType||(exports.ErrorType={})).SymbolNotFound="SymbolNotFound",kt.InvalidSubdomain="InvalidSubdomain",kt.FavouriteDomainNotFound="FavouriteDomainNotFound",kt.MissingParentOwner="MissingParentOwner",kt.U32Overflow="U32Overflow",kt.InvalidBufferLength="InvalidBufferLength",kt.U64Overflow="U64Overflow",kt.NoRecordData="NoRecordData",kt.InvalidRecordData="InvalidRecordData",kt.UnsupportedRecord="UnsupportedRecord",kt.InvalidEvmAddress="InvalidEvmAddress",kt.InvalidInjectiveAddress="InvalidInjectiveAddress",kt.InvalidARecord="InvalidARecord",kt.InvalidAAAARecord="InvalidAAAARecord",kt.InvalidRecordInput="InvalidRecordInput",kt.InvalidSignature="InvalidSignature",kt.AccountDoesNotExist="AccountDoesNotExist",kt.MultipleRegistries="MultipleRegistries",kt.InvalidReverseTwitter="InvalidReverseTwitter",kt.NoAccountData="NoAccountData",kt.InvalidInput="InvalidInput",kt.InvalidDomain="InvalidDomain",kt.InvalidCustomBg="InvalidCustomBackground",kt.UnsupportedSignature="UnsupportedSignature",kt.RecordDoestNotSupportGuardianSig="RecordDoestNotSupportGuardianSig",kt.RecordIsNotSigned="RecordIsNotSigned",kt.UnsupportedSignatureType="UnsupportedSignatureType",kt.InvalidSolRecordV2="InvalidSolRecordV2",kt.MissingVerifier="MissingVerifier",kt.PythFeedNotFound="PythFeedNotFound";class _t extends Error{constructor(t,e){super(e),this.name="SNSError",this.type=t,Error.captureStackTrace&&Error.captureStackTrace(this,_t)}}class Pt{constructor(t){this.value=t}toBuffer(){const t=i.Buffer.alloc(4);return t.writeUInt32LE(Number(this.value)),t}static fromBuffer(t){if(4!==t.length)throw new _t(exports.ErrorType.InvalidBufferLength,`Invalid buffer length: ${t.length}`);const e=BigInt(t.readUInt32LE(0));return new Pt(e)}toNumber(){return Number(this.value)}toString(){return String(this.value)}}class Tt{constructor(t){this.value=t}toBuffer(){const t=i.Buffer.alloc(8);return t.writeBigUInt64LE(this.value),t}static fromBuffer(t){if(8!==t.length)throw new _t(exports.ErrorType.U64Overflow,`Invalid buffer length: ${t.length}`);const e=t.readBigUInt64LE(0);return new Tt(e)}toNumber(){return Number(this.value)}toString(){return String(this.value)}}var Ut={},Lt={exports:{}},Ot=n(Object.freeze({__proto__:null,default:{}}));!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 i(t,e,r){if(i.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 o;"object"==typeof t?t.exports=i:e.BN=i,i.BN=i,i.wordSize=26;try{o="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:Ot.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(!1,"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,i){for(var o=0,s=0,a=Math.min(t.length,n),u=e;u<a;u++){var c=t.charCodeAt(u)-48;o*=i,s=c>=49?c-49+10:c>=17?c-17+10:c,r(c>=0&&s<i,"Invalid character"),o+=s}return o}function c(t,e){t.words=e.words,t.length=e.length,t.negative=e.negative,t.red=e.red}if(i.isBN=function(t){return t instanceof i||null!==t&&"object"==typeof t&&t.constructor.wordSize===i.wordSize&&Array.isArray(t.words)},i.max=function(t,e){return t.cmp(e)>0?t:e},i.min=function(t,e){return t.cmp(e)<0?t:e},i.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 i=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&(i++,this.negative=1),i<t.length&&(16===e?this._parseHex(t,i,n):(this._parseBase(t,e,i),"le"===n&&this._initArray(this.toArray(),e,n)))},i.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)},i.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 i=0;i<this.length;i++)this.words[i]=0;var o,s,a=0;if("be"===n)for(i=t.length-1,o=0;i>=0;i-=3)s=t[i]|t[i-1]<<8|t[i-2]<<16,this.words[o]|=s<<a&67108863,this.words[o+1]=s>>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);else if("le"===n)for(i=0,o=0;i<t.length;i+=3)s=t[i]|t[i+1]<<8|t[i+2]<<16,this.words[o]|=s<<a&67108863,this.words[o+1]=s>>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);return this._strip()},i.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 i,o=0,s=0;if("be"===r)for(n=t.length-1;n>=e;n-=2)i=a(t,e,n)<<o,this.words[s]|=67108863&i,o>=18?(o-=18,s+=1,this.words[s]|=i>>>26):o+=8;else for(n=(t.length-e)%2==0?e+1:e;n<t.length;n+=2)i=a(t,e,n)<<o,this.words[s]|=67108863&i,o>=18?(o-=18,s+=1,this.words[s]|=i>>>26):o+=8;this._strip()},i.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var n=0,i=1;i<=67108863;i*=e)n++;n--,i=i/e|0;for(var o=t.length-r,s=o%n,a=Math.min(o,o-s)+r,c=0,f=r;f<a;f+=n)c=u(t,f,f+n,e),this.imuln(i),this.words[0]+c<67108864?this.words[0]+=c:this._iaddn(c);if(0!==s){var h=1;for(c=u(t,f,t.length,e),f=0;f<s;f++)h*=e;this.imuln(h),this.words[0]+c<67108864?this.words[0]+=c:this._iaddn(c)}this._strip()},i.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},i.prototype._move=function(t){c(t,this)},i.prototype.clone=function(){var t=new i(null);return this.copy(t),t},i.prototype._expand=function(t){for(;this.length<t;)this.words[this.length++]=0;return this},i.prototype._strip=function(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign()},i.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},"undefined"!=typeof Symbol&&"function"==typeof Symbol.for)try{i.prototype[Symbol.for("nodejs.util.inspect.custom")]=f}catch(t){i.prototype.inspect=f}else i.prototype.inspect=f;function f(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var h=["","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"],l=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],d=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function p(t,e,r){r.negative=e.negative^t.negative;var n=t.length+e.length|0;r.length=n,n=n-1|0;var i=0|t.words[0],o=0|e.words[0],s=i*o,a=67108863&s,u=s/67108864|0;r.words[0]=a;for(var c=1;c<n;c++){for(var f=u>>>26,h=67108863&u,l=Math.min(c,e.length-1),d=Math.max(0,c-t.length+1);d<=l;d++){var p=c-d|0;f+=(s=(i=0|t.words[p])*(o=0|e.words[d])+h)/67108864|0,h=67108863&s}r.words[c]=0|h,u=0|f}return 0!==u?r.words[c]=0|u:r.length--,r._strip()}i.prototype.toString=function(t,e){var n;if(e=0|e||1,16===(t=t||10)||"hex"===t){n="";for(var i=0,o=0,s=0;s<this.length;s++){var a=this.words[s],u=(16777215&(a<<i|o)).toString(16);o=a>>>24-i&16777215,(i+=2)>=26&&(i-=26,s--),n=0!==o||s!==this.length-1?h[6-u.length]+u+n:u+n}for(0!==o&&(n=o.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=l[t],f=d[t];n="";var p=this.clone();for(p.negative=0;!p.isZero();){var y=p.modrn(f).toString(t);n=(p=p.idivn(f)).isZero()?y+n:h[c-y.length]+y+n}for(this.isZero()&&(n="0"+n);n.length%e!=0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}r(!1,"Base should be between 2 and 36")},i.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(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},i.prototype.toJSON=function(){return this.toString(16,2)},o&&(i.prototype.toBuffer=function(t,e){return this.toArrayLike(o,t,e)}),i.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},i.prototype.toArrayLike=function(t,e,n){this._strip();var i=this.byteLength(),o=n||Math.max(1,i);r(i<=o,"byte array longer than desired length"),r(o>0,"Requested array length <= 0");var s=function(t,e){return t.allocUnsafe?t.allocUnsafe(e):new t(e)}(t,o);return this["_toArrayLike"+("le"===e?"LE":"BE")](s,i),s},i.prototype._toArrayLikeLE=function(t,e){for(var r=0,n=0,i=0,o=0;i<this.length;i++){var s=this.words[i]<<o|n;t[r++]=255&s,r<t.length&&(t[r++]=s>>8&255),r<t.length&&(t[r++]=s>>16&255),6===o?(r<t.length&&(t[r++]=s>>24&255),n=0,o=0):(n=s>>>24,o+=2)}if(r<t.length)for(t[r++]=n;r<t.length;)t[r++]=0},i.prototype._toArrayLikeBE=function(t,e){for(var r=t.length-1,n=0,i=0,o=0;i<this.length;i++){var s=this.words[i]<<o|n;t[r--]=255&s,r>=0&&(t[r--]=s>>8&255),r>=0&&(t[r--]=s>>16&255),6===o?(r>=0&&(t[r--]=s>>24&255),n=0,o=0):(n=s>>>24,o+=2)}if(r>=0)for(t[r--]=n;r>=0;)t[r--]=0},Math.clz32?i.prototype._countBits=function(t){return 32-Math.clz32(t)}:i.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},i.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},i.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},i.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},i.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},i.prototype.toTwos=function(t){return 0!==this.negative?this.abs().inotn(t).iaddn(1):this.clone()},i.prototype.fromTwos=function(t){return this.testn(t-1)?this.notn(t).iaddn(1).ineg():this.clone()},i.prototype.isNeg=function(){return 0!==this.negative},i.prototype.neg=function(){return this.clone().ineg()},i.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},i.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()},i.prototype.ior=function(t){return r(0==(this.negative|t.negative)),this.iuor(t)},i.prototype.or=function(t){return this.length>t.length?this.clone().ior(t):t.clone().ior(this)},i.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},i.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()},i.prototype.iand=function(t){return r(0==(this.negative|t.negative)),this.iuand(t)},i.prototype.and=function(t){return this.length>t.length?this.clone().iand(t):t.clone().iand(this)},i.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},i.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()},i.prototype.ixor=function(t){return r(0==(this.negative|t.negative)),this.iuxor(t)},i.prototype.xor=function(t){return this.length>t.length?this.clone().ixor(t):t.clone().ixor(this)},i.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},i.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 i=0;i<e;i++)this.words[i]=67108863&~this.words[i];return n>0&&(this.words[i]=~this.words[i]&67108863>>26-n),this._strip()},i.prototype.notn=function(t){return this.clone().inotn(t)},i.prototype.setn=function(t,e){r("number"==typeof t&&t>=0);var n=t/26|0,i=t%26;return this._expand(n+1),this.words[n]=e?this.words[n]|1<<i:this.words[n]&~(1<<i),this._strip()},i.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 i=0,o=0;o<n.length;o++)e=(0|r.words[o])+(0|n.words[o])+i,this.words[o]=67108863&e,i=e>>>26;for(;0!==i&&o<r.length;o++)e=(0|r.words[o])+i,this.words[o]=67108863&e,i=e>>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;o<r.length;o++)this.words[o]=r.words[o];return this},i.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)},i.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,i=this.cmp(t);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(r=this,n=t):(r=t,n=this);for(var o=0,s=0;s<n.length;s++)o=(e=(0|r.words[s])-(0|n.words[s])+o)>>26,this.words[s]=67108863&e;for(;0!==o&&s<r.length;s++)o=(e=(0|r.words[s])+o)>>26,this.words[s]=67108863&e;if(0===o&&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()},i.prototype.sub=function(t){return this.clone().isub(t)};var y=function(t,e,r){var n,i,o,s=t.words,a=e.words,u=r.words,c=0,f=0|s[0],h=8191&f,l=f>>>13,d=0|s[1],p=8191&d,y=d>>>13,g=0|s[2],w=8191&g,m=g>>>13,b=0|s[3],v=8191&b,E=b>>>13,x=0|s[4],A=8191&x,B=x>>>13,S=0|s[5],I=8191&S,M=S>>>13,R=0|s[6],k=8191&R,_=R>>>13,P=0|s[7],T=8191&P,U=P>>>13,L=0|s[8],O=8191&L,C=L>>>13,N=0|s[9],D=8191&N,z=N>>>13,V=0|a[0],W=8191&V,F=V>>>13,j=0|a[1],K=8191&j,H=j>>>13,G=0|a[2],q=8191&G,Z=G>>>13,$=0|a[3],Y=8191&$,X=$>>>13,Q=0|a[4],J=8191&Q,tt=Q>>>13,et=0|a[5],rt=8191&et,nt=et>>>13,it=0|a[6],ot=8191&it,st=it>>>13,at=0|a[7],ut=8191&at,ct=at>>>13,ft=0|a[8],ht=8191&ft,lt=ft>>>13,dt=0|a[9],pt=8191&dt,yt=dt>>>13;r.negative=t.negative^e.negative,r.length=19;var gt=(c+(n=Math.imul(h,W))|0)+((8191&(i=(i=Math.imul(h,F))+Math.imul(l,W)|0))<<13)|0;c=((o=Math.imul(l,F))+(i>>>13)|0)+(gt>>>26)|0,gt&=67108863,n=Math.imul(p,W),i=(i=Math.imul(p,F))+Math.imul(y,W)|0,o=Math.imul(y,F);var wt=(c+(n=n+Math.imul(h,K)|0)|0)+((8191&(i=(i=i+Math.imul(h,H)|0)+Math.imul(l,K)|0))<<13)|0;c=((o=o+Math.imul(l,H)|0)+(i>>>13)|0)+(wt>>>26)|0,wt&=67108863,n=Math.imul(w,W),i=(i=Math.imul(w,F))+Math.imul(m,W)|0,o=Math.imul(m,F),n=n+Math.imul(p,K)|0,i=(i=i+Math.imul(p,H)|0)+Math.imul(y,K)|0,o=o+Math.imul(y,H)|0;var mt=(c+(n=n+Math.imul(h,q)|0)|0)+((8191&(i=(i=i+Math.imul(h,Z)|0)+Math.imul(l,q)|0))<<13)|0;c=((o=o+Math.imul(l,Z)|0)+(i>>>13)|0)+(mt>>>26)|0,mt&=67108863,n=Math.imul(v,W),i=(i=Math.imul(v,F))+Math.imul(E,W)|0,o=Math.imul(E,F),n=n+Math.imul(w,K)|0,i=(i=i+Math.imul(w,H)|0)+Math.imul(m,K)|0,o=o+Math.imul(m,H)|0,n=n+Math.imul(p,q)|0,i=(i=i+Math.imul(p,Z)|0)+Math.imul(y,q)|0,o=o+Math.imul(y,Z)|0;var bt=(c+(n=n+Math.imul(h,Y)|0)|0)+((8191&(i=(i=i+Math.imul(h,X)|0)+Math.imul(l,Y)|0))<<13)|0;c=((o=o+Math.imul(l,X)|0)+(i>>>13)|0)+(bt>>>26)|0,bt&=67108863,n=Math.imul(A,W),i=(i=Math.imul(A,F))+Math.imul(B,W)|0,o=Math.imul(B,F),n=n+Math.imul(v,K)|0,i=(i=i+Math.imul(v,H)|0)+Math.imul(E,K)|0,o=o+Math.imul(E,H)|0,n=n+Math.imul(w,q)|0,i=(i=i+Math.imul(w,Z)|0)+Math.imul(m,q)|0,o=o+Math.imul(m,Z)|0,n=n+Math.imul(p,Y)|0,i=(i=i+Math.imul(p,X)|0)+Math.imul(y,Y)|0,o=o+Math.imul(y,X)|0;var vt=(c+(n=n+Math.imul(h,J)|0)|0)+((8191&(i=(i=i+Math.imul(h,tt)|0)+Math.imul(l,J)|0))<<13)|0;c=((o=o+Math.imul(l,tt)|0)+(i>>>13)|0)+(vt>>>26)|0,vt&=67108863,n=Math.imul(I,W),i=(i=Math.imul(I,F))+Math.imul(M,W)|0,o=Math.imul(M,F),n=n+Math.imul(A,K)|0,i=(i=i+Math.imul(A,H)|0)+Math.imul(B,K)|0,o=o+Math.imul(B,H)|0,n=n+Math.imul(v,q)|0,i=(i=i+Math.imul(v,Z)|0)+Math.imul(E,q)|0,o=o+Math.imul(E,Z)|0,n=n+Math.imul(w,Y)|0,i=(i=i+Math.imul(w,X)|0)+Math.imul(m,Y)|0,o=o+Math.imul(m,X)|0,n=n+Math.imul(p,J)|0,i=(i=i+Math.imul(p,tt)|0)+Math.imul(y,J)|0,o=o+Math.imul(y,tt)|0;var Et=(c+(n=n+Math.imul(h,rt)|0)|0)+((8191&(i=(i=i+Math.imul(h,nt)|0)+Math.imul(l,rt)|0))<<13)|0;c=((o=o+Math.imul(l,nt)|0)+(i>>>13)|0)+(Et>>>26)|0,Et&=67108863,n=Math.imul(k,W),i=(i=Math.imul(k,F))+Math.imul(_,W)|0,o=Math.imul(_,F),n=n+Math.imul(I,K)|0,i=(i=i+Math.imul(I,H)|0)+Math.imul(M,K)|0,o=o+Math.imul(M,H)|0,n=n+Math.imul(A,q)|0,i=(i=i+Math.imul(A,Z)|0)+Math.imul(B,q)|0,o=o+Math.imul(B,Z)|0,n=n+Math.imul(v,Y)|0,i=(i=i+Math.imul(v,X)|0)+Math.imul(E,Y)|0,o=o+Math.imul(E,X)|0,n=n+Math.imul(w,J)|0,i=(i=i+Math.imul(w,tt)|0)+Math.imul(m,J)|0,o=o+Math.imul(m,tt)|0,n=n+Math.imul(p,rt)|0,i=(i=i+Math.imul(p,nt)|0)+Math.imul(y,rt)|0,o=o+Math.imul(y,nt)|0;var xt=(c+(n=n+Math.imul(h,ot)|0)|0)+((8191&(i=(i=i+Math.imul(h,st)|0)+Math.imul(l,ot)|0))<<13)|0;c=((o=o+Math.imul(l,st)|0)+(i>>>13)|0)+(xt>>>26)|0,xt&=67108863,n=Math.imul(T,W),i=(i=Math.imul(T,F))+Math.imul(U,W)|0,o=Math.imul(U,F),n=n+Math.imul(k,K)|0,i=(i=i+Math.imul(k,H)|0)+Math.imul(_,K)|0,o=o+Math.imul(_,H)|0,n=n+Math.imul(I,q)|0,i=(i=i+Math.imul(I,Z)|0)+Math.imul(M,q)|0,o=o+Math.imul(M,Z)|0,n=n+Math.imul(A,Y)|0,i=(i=i+Math.imul(A,X)|0)+Math.imul(B,Y)|0,o=o+Math.imul(B,X)|0,n=n+Math.imul(v,J)|0,i=(i=i+Math.imul(v,tt)|0)+Math.imul(E,J)|0,o=o+Math.imul(E,tt)|0,n=n+Math.imul(w,rt)|0,i=(i=i+Math.imul(w,nt)|0)+Math.imul(m,rt)|0,o=o+Math.imul(m,nt)|0,n=n+Math.imul(p,ot)|0,i=(i=i+Math.imul(p,st)|0)+Math.imul(y,ot)|0,o=o+Math.imul(y,st)|0;var At=(c+(n=n+Math.imul(h,ut)|0)|0)+((8191&(i=(i=i+Math.imul(h,ct)|0)+Math.imul(l,ut)|0))<<13)|0;c=((o=o+Math.imul(l,ct)|0)+(i>>>13)|0)+(At>>>26)|0,At&=67108863,n=Math.imul(O,W),i=(i=Math.imul(O,F))+Math.imul(C,W)|0,o=Math.imul(C,F),n=n+Math.imul(T,K)|0,i=(i=i+Math.imul(T,H)|0)+Math.imul(U,K)|0,o=o+Math.imul(U,H)|0,n=n+Math.imul(k,q)|0,i=(i=i+Math.imul(k,Z)|0)+Math.imul(_,q)|0,o=o+Math.imul(_,Z)|0,n=n+Math.imul(I,Y)|0,i=(i=i+Math.imul(I,X)|0)+Math.imul(M,Y)|0,o=o+Math.imul(M,X)|0,n=n+Math.imul(A,J)|0,i=(i=i+Math.imul(A,tt)|0)+Math.imul(B,J)|0,o=o+Math.imul(B,tt)|0,n=n+Math.imul(v,rt)|0,i=(i=i+Math.imul(v,nt)|0)+Math.imul(E,rt)|0,o=o+Math.imul(E,nt)|0,n=n+Math.imul(w,ot)|0,i=(i=i+Math.imul(w,st)|0)+Math.imul(m,ot)|0,o=o+Math.imul(m,st)|0,n=n+Math.imul(p,ut)|0,i=(i=i+Math.imul(p,ct)|0)+Math.imul(y,ut)|0,o=o+Math.imul(y,ct)|0;var Bt=(c+(n=n+Math.imul(h,ht)|0)|0)+((8191&(i=(i=i+Math.imul(h,lt)|0)+Math.imul(l,ht)|0))<<13)|0;c=((o=o+Math.imul(l,lt)|0)+(i>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,n=Math.imul(D,W),i=(i=Math.imul(D,F))+Math.imul(z,W)|0,o=Math.imul(z,F),n=n+Math.imul(O,K)|0,i=(i=i+Math.imul(O,H)|0)+Math.imul(C,K)|0,o=o+Math.imul(C,H)|0,n=n+Math.imul(T,q)|0,i=(i=i+Math.imul(T,Z)|0)+Math.imul(U,q)|0,o=o+Math.imul(U,Z)|0,n=n+Math.imul(k,Y)|0,i=(i=i+Math.imul(k,X)|0)+Math.imul(_,Y)|0,o=o+Math.imul(_,X)|0,n=n+Math.imul(I,J)|0,i=(i=i+Math.imul(I,tt)|0)+Math.imul(M,J)|0,o=o+Math.imul(M,tt)|0,n=n+Math.imul(A,rt)|0,i=(i=i+Math.imul(A,nt)|0)+Math.imul(B,rt)|0,o=o+Math.imul(B,nt)|0,n=n+Math.imul(v,ot)|0,i=(i=i+Math.imul(v,st)|0)+Math.imul(E,ot)|0,o=o+Math.imul(E,st)|0,n=n+Math.imul(w,ut)|0,i=(i=i+Math.imul(w,ct)|0)+Math.imul(m,ut)|0,o=o+Math.imul(m,ct)|0,n=n+Math.imul(p,ht)|0,i=(i=i+Math.imul(p,lt)|0)+Math.imul(y,ht)|0,o=o+Math.imul(y,lt)|0;var St=(c+(n=n+Math.imul(h,pt)|0)|0)+((8191&(i=(i=i+Math.imul(h,yt)|0)+Math.imul(l,pt)|0))<<13)|0;c=((o=o+Math.imul(l,yt)|0)+(i>>>13)|0)+(St>>>26)|0,St&=67108863,n=Math.imul(D,K),i=(i=Math.imul(D,H))+Math.imul(z,K)|0,o=Math.imul(z,H),n=n+Math.imul(O,q)|0,i=(i=i+Math.imul(O,Z)|0)+Math.imul(C,q)|0,o=o+Math.imul(C,Z)|0,n=n+Math.imul(T,Y)|0,i=(i=i+Math.imul(T,X)|0)+Math.imul(U,Y)|0,o=o+Math.imul(U,X)|0,n=n+Math.imul(k,J)|0,i=(i=i+Math.imul(k,tt)|0)+Math.imul(_,J)|0,o=o+Math.imul(_,tt)|0,n=n+Math.imul(I,rt)|0,i=(i=i+Math.imul(I,nt)|0)+Math.imul(M,rt)|0,o=o+Math.imul(M,nt)|0,n=n+Math.imul(A,ot)|0,i=(i=i+Math.imul(A,st)|0)+Math.imul(B,ot)|0,o=o+Math.imul(B,st)|0,n=n+Math.imul(v,ut)|0,i=(i=i+Math.imul(v,ct)|0)+Math.imul(E,ut)|0,o=o+Math.imul(E,ct)|0,n=n+Math.imul(w,ht)|0,i=(i=i+Math.imul(w,lt)|0)+Math.imul(m,ht)|0,o=o+Math.imul(m,lt)|0;var It=(c+(n=n+Math.imul(p,pt)|0)|0)+((8191&(i=(i=i+Math.imul(p,yt)|0)+Math.imul(y,pt)|0))<<13)|0;c=((o=o+Math.imul(y,yt)|0)+(i>>>13)|0)+(It>>>26)|0,It&=67108863,n=Math.imul(D,q),i=(i=Math.imul(D,Z))+Math.imul(z,q)|0,o=Math.imul(z,Z),n=n+Math.imul(O,Y)|0,i=(i=i+Math.imul(O,X)|0)+Math.imul(C,Y)|0,o=o+Math.imul(C,X)|0,n=n+Math.imul(T,J)|0,i=(i=i+Math.imul(T,tt)|0)+Math.imul(U,J)|0,o=o+Math.imul(U,tt)|0,n=n+Math.imul(k,rt)|0,i=(i=i+Math.imul(k,nt)|0)+Math.imul(_,rt)|0,o=o+Math.imul(_,nt)|0,n=n+Math.imul(I,ot)|0,i=(i=i+Math.imul(I,st)|0)+Math.imul(M,ot)|0,o=o+Math.imul(M,st)|0,n=n+Math.imul(A,ut)|0,i=(i=i+Math.imul(A,ct)|0)+Math.imul(B,ut)|0,o=o+Math.imul(B,ct)|0,n=n+Math.imul(v,ht)|0,i=(i=i+Math.imul(v,lt)|0)+Math.imul(E,ht)|0,o=o+Math.imul(E,lt)|0;var Mt=(c+(n=n+Math.imul(w,pt)|0)|0)+((8191&(i=(i=i+Math.imul(w,yt)|0)+Math.imul(m,pt)|0))<<13)|0;c=((o=o+Math.imul(m,yt)|0)+(i>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,n=Math.imul(D,Y),i=(i=Math.imul(D,X))+Math.imul(z,Y)|0,o=Math.imul(z,X),n=n+Math.imul(O,J)|0,i=(i=i+Math.imul(O,tt)|0)+Math.imul(C,J)|0,o=o+Math.imul(C,tt)|0,n=n+Math.imul(T,rt)|0,i=(i=i+Math.imul(T,nt)|0)+Math.imul(U,rt)|0,o=o+Math.imul(U,nt)|0,n=n+Math.imul(k,ot)|0,i=(i=i+Math.imul(k,st)|0)+Math.imul(_,ot)|0,o=o+Math.imul(_,st)|0,n=n+Math.imul(I,ut)|0,i=(i=i+Math.imul(I,ct)|0)+Math.imul(M,ut)|0,o=o+Math.imul(M,ct)|0,n=n+Math.imul(A,ht)|0,i=(i=i+Math.imul(A,lt)|0)+Math.imul(B,ht)|0,o=o+Math.imul(B,lt)|0;var Rt=(c+(n=n+Math.imul(v,pt)|0)|0)+((8191&(i=(i=i+Math.imul(v,yt)|0)+Math.imul(E,pt)|0))<<13)|0;c=((o=o+Math.imul(E,yt)|0)+(i>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,n=Math.imul(D,J),i=(i=Math.imul(D,tt))+Math.imul(z,J)|0,o=Math.imul(z,tt),n=n+Math.imul(O,rt)|0,i=(i=i+Math.imul(O,nt)|0)+Math.imul(C,rt)|0,o=o+Math.imul(C,nt)|0,n=n+Math.imul(T,ot)|0,i=(i=i+Math.imul(T,st)|0)+Math.imul(U,ot)|0,o=o+Math.imul(U,st)|0,n=n+Math.imul(k,ut)|0,i=(i=i+Math.imul(k,ct)|0)+Math.imul(_,ut)|0,o=o+Math.imul(_,ct)|0,n=n+Math.imul(I,ht)|0,i=(i=i+Math.imul(I,lt)|0)+Math.imul(M,ht)|0,o=o+Math.imul(M,lt)|0;var kt=(c+(n=n+Math.imul(A,pt)|0)|0)+((8191&(i=(i=i+Math.imul(A,yt)|0)+Math.imul(B,pt)|0))<<13)|0;c=((o=o+Math.imul(B,yt)|0)+(i>>>13)|0)+(kt>>>26)|0,kt&=67108863,n=Math.imul(D,rt),i=(i=Math.imul(D,nt))+Math.imul(z,rt)|0,o=Math.imul(z,nt),n=n+Math.imul(O,ot)|0,i=(i=i+Math.imul(O,st)|0)+Math.imul(C,ot)|0,o=o+Math.imul(C,st)|0,n=n+Math.imul(T,ut)|0,i=(i=i+Math.imul(T,ct)|0)+Math.imul(U,ut)|0,o=o+Math.imul(U,ct)|0,n=n+Math.imul(k,ht)|0,i=(i=i+Math.imul(k,lt)|0)+Math.imul(_,ht)|0,o=o+Math.imul(_,lt)|0;var _t=(c+(n=n+Math.imul(I,pt)|0)|0)+((8191&(i=(i=i+Math.imul(I,yt)|0)+Math.imul(M,pt)|0))<<13)|0;c=((o=o+Math.imul(M,yt)|0)+(i>>>13)|0)+(_t>>>26)|0,_t&=67108863,n=Math.imul(D,ot),i=(i=Math.imul(D,st))+Math.imul(z,ot)|0,o=Math.imul(z,st),n=n+Math.imul(O,ut)|0,i=(i=i+Math.imul(O,ct)|0)+Math.imul(C,ut)|0,o=o+Math.imul(C,ct)|0,n=n+Math.imul(T,ht)|0,i=(i=i+Math.imul(T,lt)|0)+Math.imul(U,ht)|0,o=o+Math.imul(U,lt)|0;var Pt=(c+(n=n+Math.imul(k,pt)|0)|0)+((8191&(i=(i=i+Math.imul(k,yt)|0)+Math.imul(_,pt)|0))<<13)|0;c=((o=o+Math.imul(_,yt)|0)+(i>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,n=Math.imul(D,ut),i=(i=Math.imul(D,ct))+Math.imul(z,ut)|0,o=Math.imul(z,ct),n=n+Math.imul(O,ht)|0,i=(i=i+Math.imul(O,lt)|0)+Math.imul(C,ht)|0,o=o+Math.imul(C,lt)|0;var Tt=(c+(n=n+Math.imul(T,pt)|0)|0)+((8191&(i=(i=i+Math.imul(T,yt)|0)+Math.imul(U,pt)|0))<<13)|0;c=((o=o+Math.imul(U,yt)|0)+(i>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,n=Math.imul(D,ht),i=(i=Math.imul(D,lt))+Math.imul(z,ht)|0,o=Math.imul(z,lt);var Ut=(c+(n=n+Math.imul(O,pt)|0)|0)+((8191&(i=(i=i+Math.imul(O,yt)|0)+Math.imul(C,pt)|0))<<13)|0;c=((o=o+Math.imul(C,yt)|0)+(i>>>13)|0)+(Ut>>>26)|0,Ut&=67108863;var Lt=(c+(n=Math.imul(D,pt))|0)+((8191&(i=(i=Math.imul(D,yt))+Math.imul(z,pt)|0))<<13)|0;return c=((o=Math.imul(z,yt))+(i>>>13)|0)+(Lt>>>26)|0,Lt&=67108863,u[0]=gt,u[1]=wt,u[2]=mt,u[3]=bt,u[4]=vt,u[5]=Et,u[6]=xt,u[7]=At,u[8]=Bt,u[9]=St,u[10]=It,u[11]=Mt,u[12]=Rt,u[13]=kt,u[14]=_t,u[15]=Pt,u[16]=Tt,u[17]=Ut,u[18]=Lt,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,i=0,o=0;o<r.length-1;o++){var s=i;i=0;for(var a=67108863&n,u=Math.min(o,e.length-1),c=Math.max(0,o-t.length+1);c<=u;c++){var f=o-c,h=(0|t.words[f])*(0|e.words[c]),l=67108863&h;a=67108863&(l=l+a|0),i+=(s=(s=s+(h/67108864|0)|0)+(l>>>26)|0)>>>26,s&=67108863}r.words[o]=a,n=s,s=i}return 0!==n?r.words[o]=n:r.length--,r._strip()}function w(t,e,r){return g(t,e,r)}Math.imul||(y=p),i.prototype.mulTo=function(t,e){var r=this.length+t.length;return 10===this.length&&10===t.length?y(this,t,e):r<63?p(this,t,e):r<1024?g(this,t,e):w(this,t,e)},i.prototype.mul=function(t){var e=new i(null);return e.words=new Array(this.length+t.length),this.mulTo(t,e)},i.prototype.mulf=function(t){var e=new i(null);return e.words=new Array(this.length+t.length),w(this,t,e)},i.prototype.imul=function(t){return this.clone().mulTo(t,this)},i.prototype.imuln=function(t){var e=t<0;e&&(t=-t),r("number"==typeof t),r(t<67108864);for(var n=0,i=0;i<this.length;i++){var o=(0|this.words[i])*t,s=(67108863&o)+(67108863&n);n>>=26,n+=o/67108864|0,n+=s>>>26,this.words[i]=67108863&s}return 0!==n&&(this.words[i]=n,this.length++),e?this.ineg():this},i.prototype.muln=function(t){return this.clone().imuln(t)},i.prototype.sqr=function(){return this.mul(this)},i.prototype.isqr=function(){return this.imul(this.clone())},i.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,i=r%26;e[r]=t.words[n]>>>i&1}return e}(t);if(0===e.length)return new i(1);for(var r=this,n=0;n<e.length&&0===e[n];n++,r=r.sqr());if(++n<e.length)for(var o=r.sqr();n<e.length;n++,o=o.sqr())0!==e[n]&&(r=r.mul(o));return r},i.prototype.iushln=function(t){r("number"==typeof t&&t>=0);var e,n=t%26,i=(t-n)/26,o=67108863>>>26-n<<26-n;if(0!==n){var s=0;for(e=0;e<this.length;e++){var a=this.words[e]&o,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!==i){for(e=this.length-1;e>=0;e--)this.words[e+i]=this.words[e];for(e=0;e<i;e++)this.words[e]=0;this.length+=i}return this._strip()},i.prototype.ishln=function(t){return r(0===this.negative),this.iushln(t)},i.prototype.iushrn=function(t,e,n){var i;r("number"==typeof t&&t>=0),i=e?(e-e%26)/26:0;var o=t%26,s=Math.min((t-o)/26,this.length),a=67108863^67108863>>>o<<o,u=n;if(i-=s,i=Math.max(0,i),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 f=0;for(c=this.length-1;c>=0&&(0!==f||c>=i);c--){var h=0|this.words[c];this.words[c]=f<<26-o|h>>>o,f=h&a}return u&&0!==f&&(u.words[u.length++]=f),0===this.length&&(this.words[0]=0,this.length=1),this._strip()},i.prototype.ishrn=function(t,e,n){return r(0===this.negative),this.iushrn(t,e,n)},i.prototype.shln=function(t){return this.clone().ishln(t)},i.prototype.ushln=function(t){return this.clone().iushln(t)},i.prototype.shrn=function(t){return this.clone().ishrn(t)},i.prototype.ushrn=function(t){return this.clone().iushrn(t)},i.prototype.testn=function(t){r("number"==typeof t&&t>=0);var e=t%26,n=(t-e)/26,i=1<<e;return!(this.length<=n||!(this.words[n]&i))},i.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 i=67108863^67108863>>>e<<e;this.words[this.length-1]&=i}return this._strip()},i.prototype.maskn=function(t){return this.clone().imaskn(t)},i.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)},i.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},i.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()},i.prototype.addn=function(t){return this.clone().iaddn(t)},i.prototype.subn=function(t){return this.clone().isubn(t)},i.prototype.iabs=function(){return this.negative=0,this},i.prototype.abs=function(){return this.clone().iabs()},i.prototype._ishlnsubmul=function(t,e,n){var i,o,s=t.length+n;this._expand(s);var a=0;for(i=0;i<t.length;i++){o=(0|this.words[i+n])+a;var u=(0|t.words[i])*e;a=((o-=67108863&u)>>26)-(u/67108864|0),this.words[i+n]=67108863&o}for(;i<this.length-n;i++)a=(o=(0|this.words[i+n])+a)>>26,this.words[i+n]=67108863&o;if(0===a)return this._strip();for(r(-1===a),a=0,i=0;i<this.length;i++)a=(o=-(0|this.words[i])+a)>>26,this.words[i]=67108863&o;return this.negative=1,this._strip()},i.prototype._wordDiv=function(t,e){var r=(this.length,t.length),n=this.clone(),o=t,s=0|o.words[o.length-1];0!=(r=26-this._countBits(s))&&(o=o.ushln(r),n.iushln(r),s=0|o.words[o.length-1]);var a,u=n.length-o.length;if("mod"!==e){(a=new i(null)).length=u+1,a.words=new Array(a.length);for(var c=0;c<a.length;c++)a.words[c]=0}var f=n.clone()._ishlnsubmul(o,1,u);0===f.negative&&(n=f,a&&(a.words[u]=1));for(var h=u-1;h>=0;h--){var l=67108864*(0|n.words[o.length+h])+(0|n.words[o.length+h-1]);for(l=Math.min(l/s|0,67108863),n._ishlnsubmul(o,l,h);0!==n.negative;)l--,n.negative=0,n._ishlnsubmul(o,1,h),n.isZero()||(n.negative^=1);a&&(a.words[h]=l)}return a&&a._strip(),n._strip(),"div"!==e&&0!==r&&n.iushrn(r),{div:a||null,mod:n}},i.prototype.divmod=function(t,e,n){return r(!t.isZero()),this.isZero()?{div:new i(0),mod:new i(0)}:0!==this.negative&&0===t.negative?(a=this.neg().divmod(t,e),"mod"!==e&&(o=a.div.neg()),"div"!==e&&(s=a.mod.neg(),n&&0!==s.negative&&s.iadd(t)),{div:o,mod:s}):0===this.negative&&0!==t.negative?(a=this.divmod(t.neg(),e),"mod"!==e&&(o=a.div.neg()),{div:o,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 i(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new i(this.modrn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new i(this.modrn(t.words[0]))}:this._wordDiv(t,e);var o,s,a},i.prototype.div=function(t){return this.divmod(t,"div",!1).div},i.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},i.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},i.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),i=t.andln(1),o=r.cmp(n);return o<0||1===i&&0===o?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},i.prototype.modrn=function(t){var e=t<0;e&&(t=-t),r(t<=67108863);for(var n=(1<<26)%t,i=0,o=this.length-1;o>=0;o--)i=(n*i+(0|this.words[o]))%t;return e?-i:i},i.prototype.modn=function(t){return this.modrn(t)},i.prototype.idivn=function(t){var e=t<0;e&&(t=-t),r(t<=67108863);for(var n=0,i=this.length-1;i>=0;i--){var o=(0|this.words[i])+67108864*n;this.words[i]=o/t|0,n=o%t}return this._strip(),e?this.ineg():this},i.prototype.divn=function(t){return this.clone().idivn(t)},i.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 o=new i(1),s=new i(0),a=new i(0),u=new i(1),c=0;e.isEven()&&n.isEven();)e.iushrn(1),n.iushrn(1),++c;for(var f=n.clone(),h=e.clone();!e.isZero();){for(var l=0,d=1;0==(e.words[0]&d)&&l<26;++l,d<<=1);if(l>0)for(e.iushrn(l);l-- >0;)(o.isOdd()||s.isOdd())&&(o.iadd(f),s.isub(h)),o.iushrn(1),s.iushrn(1);for(var p=0,y=1;0==(n.words[0]&y)&&p<26;++p,y<<=1);if(p>0)for(n.iushrn(p);p-- >0;)(a.isOdd()||u.isOdd())&&(a.iadd(f),u.isub(h)),a.iushrn(1),u.iushrn(1);e.cmp(n)>=0?(e.isub(n),o.isub(a),s.isub(u)):(n.isub(e),a.isub(o),u.isub(s))}return{a:a,b:u,gcd:n.iushln(c)}},i.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 o,s=new i(1),a=new i(0),u=n.clone();e.cmpn(1)>0&&n.cmpn(1)>0;){for(var c=0,f=1;0==(e.words[0]&f)&&c<26;++c,f<<=1);if(c>0)for(e.iushrn(c);c-- >0;)s.isOdd()&&s.iadd(u),s.iushrn(1);for(var h=0,l=1;0==(n.words[0]&l)&&h<26;++h,l<<=1);if(h>0)for(n.iushrn(h);h-- >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(o=0===e.cmpn(1)?s:a).cmpn(0)<0&&o.iadd(t),o},i.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 i=e.cmp(r);if(i<0){var o=e;e=r,r=o}else if(0===i||0===r.cmpn(1))break;e.isub(r)}return r.iushln(n)},i.prototype.invm=function(t){return this.egcd(t).a.umod(t)},i.prototype.isEven=function(){return 0==(1&this.words[0])},i.prototype.isOdd=function(){return 1==(1&this.words[0])},i.prototype.andln=function(t){return this.words[0]&t},i.prototype.bincn=function(t){r("number"==typeof t);var e=t%26,n=(t-e)/26,i=1<<e;if(this.length<=n)return this._expand(n+1),this.words[n]|=i,this;for(var o=i,s=n;0!==o&&s<this.length;s++){var a=0|this.words[s];o=(a+=o)>>>26,a&=67108863,this.words[s]=a}return 0!==o&&(this.words[s]=o,this.length++),this},i.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},i.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 i=0|this.words[0];e=i===t?0:i<t?-1:1}return 0!==this.negative?0|-e:e},i.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},i.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],i=0|t.words[r];if(n!==i){n<i?e=-1:n>i&&(e=1);break}}return e},i.prototype.gtn=function(t){return 1===this.cmpn(t)},i.prototype.gt=function(t){return 1===this.cmp(t)},i.prototype.gten=function(t){return this.cmpn(t)>=0},i.prototype.gte=function(t){return this.cmp(t)>=0},i.prototype.ltn=function(t){return-1===this.cmpn(t)},i.prototype.lt=function(t){return-1===this.cmp(t)},i.prototype.lten=function(t){return this.cmpn(t)<=0},i.prototype.lte=function(t){return this.cmp(t)<=0},i.prototype.eqn=function(t){return 0===this.cmpn(t)},i.prototype.eq=function(t){return 0===this.cmp(t)},i.red=function(t){return new B(t)},i.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)},i.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},i.prototype._forceRed=function(t){return this.red=t,this},i.prototype.forceRed=function(t){return r(!this.red,"Already a number in reduction context"),this._forceRed(t)},i.prototype.redAdd=function(t){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},i.prototype.redIAdd=function(t){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},i.prototype.redSub=function(t){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},i.prototype.redISub=function(t){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},i.prototype.redShl=function(t){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},i.prototype.redMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},i.prototype.redIMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},i.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},i.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},i.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},i.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},i.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},i.prototype.redPow=function(t){return r(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var m={k256:null,p224:null,p192:null,p25519:null};function b(t,e){this.name=t,this.p=new i(e,16),this.n=this.p.bitLength(),this.k=new i(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function v(){b.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function E(){b.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function x(){b.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function A(){b.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function B(t){if("string"==typeof t){var e=i._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){B.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new i(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}b.prototype._tmp=function(){var t=new i(null);return t.words=new Array(Math.ceil(this.n/13)),t},b.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},b.prototype.split=function(t,e){t.iushrn(this.n,0,e)},b.prototype.imulK=function(t){return t.imul(this.k)},n(v,b),v.prototype.split=function(t,e){for(var r=4194303,n=Math.min(t.length,9),i=0;i<n;i++)e.words[i]=t.words[i];if(e.length=n,t.length<=9)return t.words[0]=0,void(t.length=1);var o=t.words[9];for(e.words[e.length++]=o&r,i=10;i<t.length;i++){var s=0|t.words[i];t.words[i-10]=(s&r)<<4|o>>>22,o=s}o>>>=22,t.words[i-10]=o,0===o&&t.length>10?t.length-=10:t.length-=9},v.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(E,b),n(x,b),n(A,b),A.prototype.imulK=function(t){for(var e=0,r=0;r<t.length;r++){var n=19*(0|t.words[r])+e,i=67108863&n;n>>>=26,t.words[r]=i,e=n}return 0!==e&&(t.words[t.length++]=e),t},i._prime=function(t){if(m[t])return m[t];var e;if("k256"===t)e=new v;else if("p224"===t)e=new E;else if("p192"===t)e=new x;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new A}return m[t]=e,e},B.prototype._verify1=function(t){r(0===t.negative,"red works only with positives"),r(t.red,"red works only with red numbers")},B.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")},B.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):(c(t,t.umod(this.m)._forceRed(this)),t)},B.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},B.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)},B.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},B.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)},B.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},B.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},B.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},B.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},B.prototype.isqr=function(t){return this.imul(t,t.clone())},B.prototype.sqr=function(t){return this.mul(t,t)},B.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 i(1)).iushrn(2);return this.pow(t,n)}for(var o=this.m.subn(1),s=0;!o.isZero()&&0===o.andln(1);)s++,o.iushrn(1);r(!o.isZero());var a=new i(1).toRed(this),u=a.redNeg(),c=this.m.subn(1).iushrn(1),f=this.m.bitLength();for(f=new i(2*f*f).toRed(this);0!==this.pow(f,c).cmp(u);)f.redIAdd(u);for(var h=this.pow(f,o),l=this.pow(t,o.addn(1).iushrn(1)),d=this.pow(t,o),p=s;0!==d.cmp(a);){for(var y=d,g=0;0!==y.cmp(a);g++)y=y.redSqr();r(g<p);var w=this.pow(h,new i(1).iushln(p-g-1));l=l.redMul(w),h=w.redSqr(),d=d.redMul(h),p=g}return l},B.prototype.invm=function(t){var e=t._invmp(this.m);return 0!==e.negative?(e.negative=0,this.imod(e).redNeg()):this.imod(e)},B.prototype.pow=function(t,e){if(e.isZero())return new i(1).toRed(this);if(0===e.cmpn(1))return t.clone();var r=new Array(16);r[0]=new i(1).toRed(this),r[1]=t;for(var n=2;n<r.length;n++)r[n]=this.mul(r[n-1],t);var o=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],f=u-1;f>=0;f--){var h=c>>f&1;o!==r[0]&&(o=this.sqr(o)),0!==h||0!==s?(s<<=1,s|=h,(4==++a||0===n&&0===f)&&(o=this.mul(o,r[s]),a=0,s=0)):a=0}u=26}return o},B.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},B.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},i.mont=function(t){return new S(t)},n(S,B),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),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},S.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new i(0)._forceRed(this);var r=t.mul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),o=r.isub(n).iushrn(this.shift),s=o;return o.cmp(this.m)>=0?s=o.isub(this.m):o.cmpn(0)<0&&(s=o.iadd(this.m)),s._forceRed(this)},S.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(Lt,e);var Ct=Lt.exports,Nt={exports:{}};!function(t,e){var r=i,n=r.Buffer;function o(t,e){for(var r in t)e[r]=t[r]}function s(t,e,r){return n(t,e,r)}n.from&&n.alloc&&n.allocUnsafe&&n.allocUnsafeSlow?t.exports=r:(o(r,e),e.Buffer=s),s.prototype=Object.create(n.prototype),o(n,s),s.from=function(t,e,r){if("number"==typeof t)throw new TypeError("Argument must not be a number");return n(t,e,r)},s.alloc=function(t,e,r){if("number"!=typeof t)throw new TypeError("Argument must be a number");var i=n(t);return void 0!==e?"string"==typeof r?i.fill(e,r):i.fill(e):i.fill(0),i},s.allocUnsafe=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return n(t)},s.allocUnsafeSlow=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return r.SlowBuffer(t)}}(Nt,Nt.exports);var Dt=Nt.exports.Buffer;var zt=function(t){if(t.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),r=0;r<e.length;r++)e[r]=255;for(var n=0;n<t.length;n++){var i=t.charAt(n),o=i.charCodeAt(0);if(255!==e[o])throw new TypeError(i+" is ambiguous");e[o]=n}var s=t.length,a=t.charAt(0),u=Math.log(s)/Math.log(256),c=Math.log(256)/Math.log(s);function f(t){if("string"!=typeof t)throw new TypeError("Expected String");if(0===t.length)return Dt.alloc(0);for(var r=0,n=0,i=0;t[r]===a;)n++,r++;for(var o=(t.length-r)*u+1>>>0,c=new Uint8Array(o);t[r];){var f=e[t.charCodeAt(r)];if(255===f)return;for(var h=0,l=o-1;(0!==f||h<i)&&-1!==l;l--,h++)f+=s*c[l]>>>0,c[l]=f%256>>>0,f=f/256>>>0;if(0!==f)throw new Error("Non-zero carry");i=h,r++}for(var d=o-i;d!==o&&0===c[d];)d++;var p=Dt.allocUnsafe(n+(o-d));p.fill(0,0,n);for(var y=n;d!==o;)p[y++]=c[d++];return p}return{encode:function(e){if((Array.isArray(e)||e instanceof Uint8Array)&&(e=Dt.from(e)),!Dt.isBuffer(e))throw new TypeError("Expected Buffer");if(0===e.length)return"";for(var r=0,n=0,i=0,o=e.length;i!==o&&0===e[i];)i++,r++;for(var u=(o-i)*c+1>>>0,f=new Uint8Array(u);i!==o;){for(var h=e[i],l=0,d=u-1;(0!==h||l<n)&&-1!==d;d--,l++)h+=256*f[d]>>>0,f[d]=h%s>>>0,h=h/s>>>0;if(0!==h)throw new Error("Non-zero carry");n=l,i++}for(var p=u-n;p!==u&&0===f[p];)p++;for(var y=a.repeat(r);p<u;++p)y+=t.charAt(f[p]);return y},decodeUnsafe:f,decode:function(t){var e=f(t);if(e)return e;throw new Error("Non-base"+s+" character")}}},Vt=zt("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");function Wt(t,e,r){return e<=t&&t<=r}function Ft(t){if(void 0===t)return{};if(t===Object(t))return t;throw TypeError("Could not convert argument to dictionary")}function jt(t){this.tokens=[].slice.call(t)}jt.prototype={endOfStream:function(){return!this.tokens.length},read:function(){return this.tokens.length?this.tokens.shift():-1},prepend:function(t){if(Array.isArray(t))for(var e=t;e.length;)this.tokens.unshift(e.pop());else this.tokens.unshift(t)},push:function(t){if(Array.isArray(t))for(var e=t;e.length;)this.tokens.push(e.shift());else this.tokens.push(t)}};var Kt=-1;function Ht(t,e){if(t)throw TypeError("Decoder error");return e||65533}var Gt="utf-8";function qt(t,e){if(!(this instanceof qt))return new qt(t,e);if((t=void 0!==t?String(t).toLowerCase():Gt)!==Gt)throw new Error("Encoding not supported. Only utf-8 is supported");e=Ft(e),this._streaming=!1,this._BOMseen=!1,this._decoder=null,this._fatal=Boolean(e.fatal),this._ignoreBOM=Boolean(e.ignoreBOM),Object.defineProperty(this,"encoding",{value:"utf-8"}),Object.defineProperty(this,"fatal",{value:this._fatal}),Object.defineProperty(this,"ignoreBOM",{value:this._ignoreBOM})}function Zt(t,e){if(!(this instanceof Zt))return new Zt(t,e);if((t=void 0!==t?String(t).toLowerCase():Gt)!==Gt)throw new Error("Encoding not supported. Only utf-8 is supported");e=Ft(e),this._streaming=!1,this._encoder=null,this._options={fatal:Boolean(e.fatal)},Object.defineProperty(this,"encoding",{value:"utf-8"})}function $t(t){var e=t.fatal,r=0,n=0,i=0,o=128,s=191;this.handler=function(t,a){if(-1===a&&0!==i)return i=0,Ht(e);if(-1===a)return Kt;if(0===i){if(Wt(a,0,127))return a;if(Wt(a,194,223))i=1,r=a-192;else if(Wt(a,224,239))224===a&&(o=160),237===a&&(s=159),i=2,r=a-224;else{if(!Wt(a,240,244))return Ht(e);240===a&&(o=144),244===a&&(s=143),i=3,r=a-240}return r<<=6*i,null}if(!Wt(a,o,s))return r=i=n=0,o=128,s=191,t.prepend(a),Ht(e);if(o=128,s=191,r+=a-128<<6*(i-(n+=1)),n!==i)return null;var u=r;return r=i=n=0,u}}function Yt(t){t.fatal,this.handler=function(t,e){if(-1===e)return Kt;if(Wt(e,0,127))return e;var r,n;Wt(e,128,2047)?(r=1,n=192):Wt(e,2048,65535)?(r=2,n=224):Wt(e,65536,1114111)&&(r=3,n=240);for(var i=[(e>>6*r)+n];r>0;){var o=e>>6*(r-1);i.push(128|63&o),r-=1}return i}}qt.prototype={decode:function(t,e){var r;r="object"==typeof t&&t instanceof ArrayBuffer?new Uint8Array(t):"object"==typeof t&&"buffer"in t&&t.buffer instanceof ArrayBuffer?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):new Uint8Array(0),e=Ft(e),this._streaming||(this._decoder=new $t({fatal:this._fatal}),this._BOMseen=!1),this._streaming=Boolean(e.stream);for(var n,i=new jt(r),o=[];!i.endOfStream()&&(n=this._decoder.handler(i,i.read()))!==Kt;)null!==n&&(Array.isArray(n)?o.push.apply(o,n):o.push(n));if(!this._streaming){do{if((n=this._decoder.handler(i,i.read()))===Kt)break;null!==n&&(Array.isArray(n)?o.push.apply(o,n):o.push(n))}while(!i.endOfStream());this._decoder=null}return o.length&&(-1===["utf-8"].indexOf(this.encoding)||this._ignoreBOM||this._BOMseen||(65279===o[0]?(this._BOMseen=!0,o.shift()):this._BOMseen=!0)),function(t){for(var e="",r=0;r<t.length;++r){var n=t[r];n<=65535?e+=String.fromCharCode(n):(n-=65536,e+=String.fromCharCode(55296+(n>>10),56320+(1023&n)))}return e}(o)}},Zt.prototype={encode:function(t,e){t=t?String(t):"",e=Ft(e),this._streaming||(this._encoder=new Yt(this._options)),this._streaming=Boolean(e.stream);for(var r,n=[],i=new jt(function(t){for(var e=String(t),r=e.length,n=0,i=[];n<r;){var o=e.charCodeAt(n);if(o<55296||o>57343)i.push(o);else if(56320<=o&&o<=57343)i.push(65533);else if(55296<=o&&o<=56319)if(n===r-1)i.push(65533);else{var s=t.charCodeAt(n+1);if(56320<=s&&s<=57343){var a=1023&o,u=1023&s;i.push(65536+(a<<10)+u),n+=1}else i.push(65533)}n+=1}return i}(t));!i.endOfStream()&&(r=this._encoder.handler(i,i.read()))!==Kt;)Array.isArray(r)?n.push.apply(n,r):n.push(r);if(!this._streaming){for(;(r=this._encoder.handler(i,i.read()))!==Kt;)Array.isArray(r)?n.push.apply(n,r):n.push(r);this._encoder=null}return new Uint8Array(n)}};var Xt=n(Object.freeze({__proto__:null,TextEncoder:Zt,TextDecoder:qt})),Qt=e&&e.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r),Object.defineProperty(t,n,{enumerable:!0,get:function(){return e[r]}})}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),Jt=e&&e.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),te=e&&e.__decorate||function(t,e,r,n){var i,o=arguments.length,s=o<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(o<3?i(s):o>3?i(e,r,s):i(e,r))||s);return o>3&&s&&Object.defineProperty(e,r,s),s},ee=e&&e.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var r in t)"default"!==r&&Object.hasOwnProperty.call(t,r)&&Qt(e,t,r);return Jt(e,t),e},re=e&&e.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Ut,"__esModule",{value:!0});var ne=Ut.deserializeUnchecked=be=Ut.deserialize=ge=Ut.serialize=Ut.BinaryReader=Ut.BinaryWriter=Ut.BorshError=Ut.baseDecode=Ut.baseEncode=void 0;const ie=re(Ct),oe=re(Vt),se=ee(Xt),ae=new("function"!=typeof TextDecoder?se.TextDecoder:TextDecoder)("utf-8",{fatal:!0});Ut.baseEncode=function(t){return"string"==typeof t&&(t=Buffer.from(t,"utf8")),oe.default.encode(Buffer.from(t))},Ut.baseDecode=function(t){return Buffer.from(oe.default.decode(t))};const ue=1024;class ce extends Error{constructor(t){super(t),this.fieldPath=[],this.originalMessage=t}addToFieldPath(t){this.fieldPath.splice(0,0,t),this.message=this.originalMessage+": "+this.fieldPath.join(".")}}Ut.BorshError=ce;class fe{constructor(){this.buf=Buffer.alloc(ue),this.length=0}maybeResize(){this.buf.length<16+this.length&&(this.buf=Buffer.concat([this.buf,Buffer.alloc(ue)]))}writeU8(t){this.maybeResize(),this.buf.writeUInt8(t,this.length),this.length+=1}writeU16(t){this.maybeResize(),this.buf.writeUInt16LE(t,this.length),this.length+=2}writeU32(t){this.maybeResize(),this.buf.writeUInt32LE(t,this.length),this.length+=4}writeU64(t){this.maybeResize(),this.writeBuffer(Buffer.from(new ie.default(t).toArray("le",8)))}writeU128(t){this.maybeResize(),this.writeBuffer(Buffer.from(new ie.default(t).toArray("le",16)))}writeU256(t){this.maybeResize(),this.writeBuffer(Buffer.from(new ie.default(t).toArray("le",32)))}writeU512(t){this.maybeResize(),this.writeBuffer(Buffer.from(new ie.default(t).toArray("le",64)))}writeBuffer(t){this.buf=Buffer.concat([Buffer.from(this.buf.subarray(0,this.length)),t,Buffer.alloc(ue)]),this.length+=t.length}writeString(t){this.maybeResize();const e=Buffer.from(t,"utf8");this.writeU32(e.length),this.writeBuffer(e)}writeFixedArray(t){this.writeBuffer(Buffer.from(t))}writeArray(t,e){this.maybeResize(),this.writeU32(t.length);for(const r of t)this.maybeResize(),e(r)}toArray(){return this.buf.subarray(0,this.length)}}function he(t,e,r){const n=r.value;r.value=function(...t){try{return n.apply(this,t)}catch(t){if(t instanceof RangeError){const e=t.code;if(["ERR_BUFFER_OUT_OF_BOUNDS","ERR_OUT_OF_RANGE"].indexOf(e)>=0)throw new ce("Reached the end of buffer when deserializing")}throw t}}}Ut.BinaryWriter=fe;class le{constructor(t){this.buf=t,this.offset=0}readU8(){const t=this.buf.readUInt8(this.offset);return this.offset+=1,t}readU16(){const t=this.buf.readUInt16LE(this.offset);return this.offset+=2,t}readU32(){const t=this.buf.readUInt32LE(this.offset);return this.offset+=4,t}readU64(){const t=this.readBuffer(8);return new ie.default(t,"le")}readU128(){const t=this.readBuffer(16);return new ie.default(t,"le")}readU256(){const t=this.readBuffer(32);return new ie.default(t,"le")}readU512(){const t=this.readBuffer(64);return new ie.default(t,"le")}readBuffer(t){if(this.offset+t>this.buf.length)throw new ce(`Expected buffer length ${t} isn't within bounds`);const e=this.buf.slice(this.offset,this.offset+t);return this.offset+=t,e}readString(){const t=this.readU32(),e=this.readBuffer(t);try{return ae.decode(e)}catch(t){throw new ce(`Error decoding UTF-8 string: ${t}`)}}readFixedArray(t){return new Uint8Array(this.readBuffer(t))}readArray(t){const e=this.readU32(),r=Array();for(let n=0;n<e;++n)r.push(t());return r}}function de(t){return t.charAt(0).toUpperCase()+t.slice(1)}function pe(t,e,r,n,i){try{if("string"==typeof n)i[`write${de(n)}`](r);else if(n instanceof Array)if("number"==typeof n[0]){if(r.length!==n[0])throw new ce(`Expecting byte array of length ${n[0]}, but got ${r.length} bytes`);i.writeFixedArray(r)}else if(2===n.length&&"number"==typeof n[1]){if(r.length!==n[1])throw new ce(`Expecting byte array of length ${n[1]}, but got ${r.length} bytes`);for(let e=0;e<n[1];e++)pe(t,null,r[e],n[0],i)}else i.writeArray(r,(r=>{pe(t,e,r,n[0],i)}));else if(void 0!==n.kind)switch(n.kind){case"option":null==r?i.writeU8(0):(i.writeU8(1),pe(t,e,r,n.type,i));break;case"map":i.writeU32(r.size),r.forEach(((r,o)=>{pe(t,e,o,n.key,i),pe(t,e,r,n.value,i)}));break;default:throw new ce(`FieldType ${n} unrecognized`)}else ye(t,r,i)}catch(t){throw t instanceof ce&&t.addToFieldPath(e),t}}function ye(t,e,r){if("function"==typeof e.borshSerialize)return void e.borshSerialize(r);const n=t.get(e.constructor);if(!n)throw new ce(`Class ${e.constructor.name} is missing in schema`);if("struct"===n.kind)n.fields.map((([n,i])=>{pe(t,n,e[n],i,r)}));else{if("enum"!==n.kind)throw new ce(`Unexpected schema kind: ${n.kind} for ${e.constructor.name}`);{const i=e[n.field];for(let o=0;o<n.values.length;++o){const[s,a]=n.values[o];if(s===i){r.writeU8(o),pe(t,s,e[s],a,r);break}}}}}te([he],le.prototype,"readU8",null),te([he],le.prototype,"readU16",null),te([he],le.prototype,"readU32",null),te([he],le.prototype,"readU64",null),te([he],le.prototype,"readU128",null),te([he],le.prototype,"readU256",null),te([he],le.prototype,"readU512",null),te([he],le.prototype,"readString",null),te([he],le.prototype,"readFixedArray",null),te([he],le.prototype,"readArray",null),Ut.BinaryReader=le;var ge=Ut.serialize=function(t,e,r=fe){const n=new r;return ye(t,e,n),n.toArray()};function we(t,e,r,n){try{if("string"==typeof r)return n[`read${de(r)}`]();if(r instanceof Array){if("number"==typeof r[0])return n.readFixedArray(r[0]);if("number"==typeof r[1]){const e=[];for(let i=0;i<r[1];i++)e.push(we(t,null,r[0],n));return e}return n.readArray((()=>we(t,e,r[0],n)))}if("option"===r.kind){return n.readU8()?we(t,e,r.type,n):void 0}if("map"===r.kind){let i=new Map;const o=n.readU32();for(let s=0;s<o;s++){const o=we(t,e,r.key,n),s=we(t,e,r.value,n);i.set(o,s)}return i}return me(t,r,n)}catch(t){throw t instanceof ce&&t.addToFieldPath(e),t}}function me(t,e,r){if("function"==typeof e.borshDeserialize)return e.borshDeserialize(r);const n=t.get(e);if(!n)throw new ce(`Class ${e.name} is missing in schema`);if("struct"===n.kind){const n={};for(const[i,o]of t.get(e).fields)n[i]=we(t,i,o,r);return new e(n)}if("enum"===n.kind){const i=r.readU8();if(i>=n.values.length)throw new ce(`Enum index: ${i} is out of range`);const[o,s]=n.values[i];return new e({[o]:we(t,o,s,r)})}throw new ce(`Unexpected schema kind: ${n.kind} for ${e.constructor.name}`)}var be=Ut.deserialize=function(t,e,r,n=le){const i=new n(r),o=me(t,e,i);if(i.offset<r.length)throw new ce(`Unexpected ${r.length-i.offset} bytes after deserialized data`);return o};function ve(e,r,n,o,s,a,u,c,f,h,l){const d=[i.Buffer.from(Int8Array.from([0])),new Pt(BigInt(a.length)).toBuffer(),a,u.toBuffer(),c.toBuffer()],p=i.Buffer.concat(d),y=[{pubkey:r,isSigner:!1,isWritable:!1},{pubkey:s,isSigner:!0,isWritable:!0},{pubkey:n,isSigner:!1,isWritable:!0},{pubkey:o,isSigner:!1,isWritable:!1}];return f?y.push({pubkey:f,isSigner:!0,isWritable:!1}):y.push({pubkey:new t.PublicKey(i.Buffer.alloc(32)),isSigner:!1,isWritable:!1}),h?y.push({pubkey:h,isSigner:!1,isWritable:!1}):y.push({pubkey:new t.PublicKey(i.Buffer.alloc(32)),isSigner:!1,isWritable:!1}),l&&y.push({pubkey:l,isSigner:!0,isWritable:!1}),new t.TransactionInstruction({keys:y,programId:e,data:p})}function Ee(e,r,n,o,s){const a=[i.Buffer.from(Int8Array.from([1])),n.toBuffer(),new Pt(BigInt(o.length)).toBuffer(),o],u=i.Buffer.concat(a),c=[{pubkey:r,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!0,isWritable:!1}];return new t.TransactionInstruction({keys:c,programId:e,data:u})}function xe(e,r,n,o,s,a,u){const c=[i.Buffer.from(Int8Array.from([2])),n.toBuffer()],f=i.Buffer.concat(c),h=[{pubkey:r,isSigner:!1,isWritable:!0},{pubkey:u||o,isSigner:!0,isWritable:!1}];return s&&h.push({pubkey:s,isSigner:!0,isWritable:!1}),u&&a&&(s||h.push({pubkey:t.PublicKey.default,isSigner:!1,isWritable:!1}),h.push({pubkey:a,isSigner:!1,isWritable:!1})),new t.TransactionInstruction({keys:h,programId:e,data:f})}function Ae(e,r,n,o){const s=[i.Buffer.from(Int8Array.from([3]))],a=i.Buffer.concat(s),u=[{pubkey:r,isSigner:!1,isWritable:!0},{pubkey:o,isSigner:!0,isWritable:!1},{pubkey:n,isSigner:!1,isWritable:!0}];return new t.TransactionInstruction({keys:u,programId:e,data:a})}ne=Ut.deserializeUnchecked=function(t,e,r,n=le){return me(t,e,new n(r))};class Be{constructor(t){this.tag=9,this.name=t.name,this.space=t.space}serialize(){return ge(Be.schema,this)}getInstruction(e,r,n,o,s,a,u,c,f,h,l){const d=i.Buffer.from(this.serialize()),y=[{pubkey:r,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!1,isWritable:!1},{pubkey:o,isSigner:!1,isWritable:!1},{pubkey:s,isSigner:!1,isWritable:!0},{pubkey:a,isSigner:!1,isWritable:!0},{pubkey:t.SystemProgram.programId,isSigner:!1,isWritable:!1},{pubkey:u,isSigner:!1,isWritable:!1},{pubkey:c,isSigner:!0,isWritable:!0},{pubkey:f,isSigner:!1,isWritable:!0},{pubkey:h,isSigner:!1,isWritable:!0},{pubkey:p,isSigner:!1,isWritable:!1},{pubkey:l,isSigner:!1,isWritable:!1}];return new t.TransactionInstruction({keys:y,programId:e,data:d})}}Be.schema=new Map([[Be,{kind:"struct",fields:[["tag","u8"],["name","string"],["space","u32"]]}]]);class Se{constructor(t){this.tag=12,this.name=t.name}serialize(){return ge(Se.schema,this)}getInstruction(e,r,n,o,s,a,u,c,f,h){const l=i.Buffer.from(this.serialize());let d=[];return d.push({pubkey:r,isSigner:!1,isWritable:!1}),d.push({pubkey:n,isSigner:!1,isWritable:!1}),d.push({pubkey:o,isSigner:!1,isWritable:!0}),d.push({pubkey:s,isSigner:!1,isWritable:!1}),d.push({pubkey:a,isSigner:!1,isWritable:!1}),d.push({pubkey:u,isSigner:!0,isWritable:!0}),d.push({pubkey:c,isSigner:!1,isWritable:!1}),f&&d.push({pubkey:f,isSigner:!1,isWritable:!0}),h&&d.push({pubkey:h,isSigner:!0,isWritable:!0}),new t.TransactionInstruction({keys:d,programId:e,data:l})}}Se.schema=new Map([[Se,{kind:"struct",fields:[["tag","u8"],["name","string"]]}]]);class Ie{constructor(t){this.tag=13,this.name=t.name,this.space=t.space,this.referrerIdxOpt=t.referrerIdxOpt}serialize(){return ge(Ie.schema,this)}getInstruction(e,r,n,o,s,a,u,c,f,h,l,d,p,y,g,w,m){const b=i.Buffer.from(this.serialize());let v=[];return v.push({pubkey:r,isSigner:!1,isWritable:!1}),v.push({pubkey:n,isSigner:!1,isWritable:!1}),v.push({pubkey:o,isSigner:!1,isWritable:!0}),v.push({pubkey:s,isSigner:!1,isWritable:!0}),v.push({pubkey:a,isSigner:!1,isWritable:!1}),v.push({pubkey:u,isSigner:!1,isWritable:!1}),v.push({pubkey:c,isSigner:!0,isWritable:!0}),v.push({pubkey:f,isSigner:!1,isWritable:!0}),v.push({pubkey:h,isSigner:!1,isWritable:!1}),v.push({pubkey:l,isSigner:!1,isWritable:!1}),v.push({pubkey:d,isSigner:!1,isWritable:!1}),v.push({pubkey:p,isSigner:!1,isWritable:!0}),v.push({pubkey:y,isSigner:!1,isWritable:!1}),v.push({pubkey:g,isSigner:!1,isWritable:!1}),v.push({pubkey:w,isSigner:!1,isWritable:!1}),m&&v.push({pubkey:m,isSigner:!1,isWritable:!0}),new t.TransactionInstruction({keys:v,programId:e,data:b})}}Ie.schema=new Map([[Ie,{kind:"struct",fields:[["tag","u8"],["name","string"],["space","u32"],["referrerIdxOpt",{kind:"option",type:"u16"}]]}]]);class Me{constructor(t){this.tag=17,this.name=t.name,this.space=t.space}serialize(){return ge(Me.schema,this)}getInstruction(e,r,n,o,s,a,u,c,f,h,l,d,p,y,g,w,m){const b=i.Buffer.from(this.serialize());let v=[];return v.push({pubkey:r,isSigner:!1,isWritable:!1}),v.push({pubkey:n,isSigner:!1,isWritable:!1}),v.push({pubkey:o,isSigner:!1,isWritable:!0}),v.push({pubkey:s,isSigner:!1,isWritable:!0}),v.push({pubkey:a,isSigner:!1,isWritable:!1}),v.push({pubkey:u,isSigner:!1,isWritable:!1}),v.push({pubkey:c,isSigner:!0,isWritable:!0}),v.push({pubkey:f,isSigner:!1,isWritable:!0}),v.push({pubkey:h,isSigner:!1,isWritable:!0}),v.push({pubkey:l,isSigner:!1,isWritable:!0}),v.push({pubkey:d,isSigner:!1,isWritable:!0}),v.push({pubkey:p,isSigner:!1,isWritable:!0}),v.push({pubkey:y,isSigner:!1,isWritable:!1}),v.push({pubkey:g,isSigner:!1,isWritable:!1}),v.push({pubkey:w,isSigner:!1,isWritable:!1}),v.push({pubkey:m,isSigner:!1,isWritable:!1}),new t.TransactionInstruction({keys:v,programId:e,data:b})}}Me.schema=new Map([[Me,{kind:"struct",fields:[["tag","u8"],["name","string"],["space","u32"]]}]]);class Re{constructor(){this.tag=16}serialize(){return ge(Re.schema,this)}getInstruction(e,r,n,o,s,a,u,c,f,h){const l=i.Buffer.from(this.serialize());let d=[];return d.push({pubkey:r,isSigner:!1,isWritable:!1}),d.push({pubkey:n,isSigner:!1,isWritable:!1}),d.push({pubkey:o,isSigner:!1,isWritable:!0}),d.push({pubkey:s,isSigner:!1,isWritable:!0}),d.push({pubkey:a,isSigner:!1,isWritable:!0}),d.push({pubkey:u,isSigner:!1,isWritable:!0}),d.push({pubkey:c,isSigner:!1,isWritable:!1}),d.push({pubkey:f,isSigner:!0,isWritable:!1}),d.push({pubkey:h,isSigner:!1,isWritable:!0}),new t.TransactionInstruction({keys:d,programId:e,data:l})}}Re.schema=new Map([[Re,{kind:"struct",fields:[["tag","u8"]]}]]);const ke=new t.PublicKey("nftD3vbNkNqfj2Sd3HZwbpw4BxxKWr4AjGb9X38JeZk"),_e=i.Buffer.from("tokenized_name");var Pe;!function(t){t[t.Uninitialized=0]="Uninitialized",t[t.CentralState=1]="CentralState",t[t.ActiveRecord=2]="ActiveRecord",t[t.InactiveRecord=3]="InactiveRecord"}(Pe||(Pe={}));class Te{constructor(e){this.tag=e.tag,this.nonce=e.nonce,this.nameAccount=new t.PublicKey(e.nameAccount),this.owner=new t.PublicKey(e.owner),this.nftMint=new t.PublicKey(e.nftMint)}static deserialize(t){return be(this.schema,Te,t)}static async retrieve(t,e){const r=await t.getAccountInfo(e);if(!r||!r.data)throw new Error("NFT record not found");return this.deserialize(r.data)}static async findKey(e,r){return await t.PublicKey.findProgramAddress([i.Buffer.from("nft_record"),e.toBuffer()],r)}}Te.schema=new Map([[Te,{kind:"struct",fields:[["tag","u8"],["nonce","u8"],["nameAccount",[32]],["owner",[32]],["nftMint",[32]]]}]]);const Ue=async(e,r)=>{try{const[n]=await t.PublicKey.findProgramAddress([_e,r.toBuffer()],ke);if("0"===(await It(e,n)).supply.toString())return;const i=[{memcmp:{offset:0,bytes:n.toBase58()}},{memcmp:{offset:64,bytes:"2"}},{dataSize:165}],o=await e.getProgramAccounts(p,{filters:i});if(1!=o.length)return;return new t.PublicKey(o[0].account.data.slice(32,64))}catch{return}},Le=t=>[{memcmp:{offset:32,bytes:t}},{memcmp:{offset:64,bytes:"2"}}],Oe=async(t,e)=>{const r=await(async(t,e)=>{const r=[{memcmp:{offset:0,bytes:"3"}},{memcmp:{offset:66,bytes:e.toBase58()}}];return await t.getProgramAccounts(ke,{filters:r})})(t,e.mint);if(1===r.length)return Te.deserialize(r[0].account.data)},Ce=async(t,e)=>{const r=[...Le(e.toBase58()),{dataSize:165}],n=(await t.getProgramAccounts(p,{filters:r})).map((t=>xt.decode(t.account.data))).map((e=>Oe(t,e)));return(await Promise.all(n)).filter((t=>void 0!==t))};class Ne{constructor(e){this.parentName=new t.PublicKey(e.parentName),this.owner=new t.PublicKey(e.owner),this.class=new t.PublicKey(e.class)}static deserialize(t){let e=ne(this.schema,Ne,t);return e.data=null==t?void 0:t.slice(this.HEADER_LEN),e}static async retrieve(t,e){var r;const n=await t.getAccountInfo(e);if(!n)throw new _t(exports.ErrorType.AccountDoesNotExist);let i=ne(this.schema,Ne,n.data);i.data=null===(r=n.data)||void 0===r?void 0:r.slice(this.HEADER_LEN);return{registry:i,nftOwner:await Ue(t,e)}}static async _retrieveBatch(t,e){const r=await t.getMultipleAccountsInfo(e),n=t=>{if(!t)return;const e=ne(this.schema,Ne,t);return e.data=null==t?void 0:t.slice(this.HEADER_LEN),e};return r.map((t=>n(null==t?void 0:t.data)))}static async retrieveBatch(t,e){let r=[];const n=[...e];for(;n.length>0;)r.push(...await this._retrieveBatch(t,n.splice(0,100)));return r}}function De(t,...e){if(!function(t){return t instanceof Uint8Array||null!=t&&"object"==typeof t&&"Uint8Array"===t.constructor.name}(t))throw new Error("Expected Uint8Array");if(e.length>0&&!e.includes(t.length))throw new Error(`Expected Uint8Array of length ${e}, not of length=${t.length}`)}function ze(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}Ne.HEADER_LEN=96,Ne.schema=new Map([[Ne,{kind:"struct",fields:[["parentName",[32]],["owner",[32]],["class",[32]]]}]]);const Ve="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0;
|
|
11
|
-
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function We(t){return t instanceof Uint8Array||null!=t&&"object"==typeof t&&"Uint8Array"===t.constructor.name}const Fe=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),je=(t,e)=>t<<32-e|t>>>e;if(!(68===new Uint8Array(new Uint32Array([287454020]).buffer)[0]))throw new Error("Non little-endian hardware is not supported");function Ke(t){if("string"!=typeof t)throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array((new TextEncoder).encode(t))}function He(t){if("string"==typeof t&&(t=Ke(t)),!We(t))throw new Error("expected Uint8Array, got "+typeof t);return t}class Ge{clone(){return this._cloneInto()}}function qe(t){const e=e=>t().update(He(e)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}class Ze extends Ge{constructor(t,e,r,n){super(),this.blockLen=t,this.outputLen=e,this.padOffset=r,this.isLE=n,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=Fe(this.buffer)}update(t){ze(this);const{view:e,buffer:r,blockLen:n}=this,i=(t=He(t)).length;for(let o=0;o<i;){const s=Math.min(n-this.pos,i-o);if(s!==n)r.set(t.subarray(o,o+s),this.pos),this.pos+=s,o+=s,this.pos===n&&(this.process(e,0),this.pos=0);else{const e=Fe(t);for(;n<=i-o;o+=n)this.process(e,o)}}return this.length+=t.length,this.roundClean(),this}digestInto(t){ze(this),function(t,e){De(t);const r=e.outputLen;if(t.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}(t,this),this.finished=!0;const{buffer:e,view:r,blockLen:n,isLE:i}=this;let{pos:o}=this;e[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>n-o&&(this.process(r,0),o=0);for(let t=o;t<n;t++)e[t]=0;!function(t,e,r,n){if("function"==typeof t.setBigUint64)return t.setBigUint64(e,r,n);const i=BigInt(32),o=BigInt(4294967295),s=Number(r>>i&o),a=Number(r&o),u=n?4:0,c=n?0:4;t.setUint32(e+u,s,n),t.setUint32(e+c,a,n)}(r,n-8,BigInt(8*this.length),i),this.process(r,0);const s=Fe(t),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const u=a/4,c=this.get();if(u>c.length)throw new Error("_sha2: outputLen bigger than state");for(let t=0;t<u;t++)s.setUint32(4*t,c[t],i)}digest(){const{buffer:t,outputLen:e}=this;this.digestInto(t);const r=t.slice(0,e);return this.destroy(),r}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:e,buffer:r,length:n,finished:i,destroyed:o,pos:s}=this;return t.length=n,t.pos=s,t.finished=i,t.destroyed=o,n%e&&t.buffer.set(r),t}}const $e=(t,e,r)=>t&e^~t&r,Ye=(t,e,r)=>t&e^t&r^e&r,Xe=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Qe=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Je=new Uint32Array(64);class tr extends Ze{constructor(){super(64,32,8,!1),this.A=0|Qe[0],this.B=0|Qe[1],this.C=0|Qe[2],this.D=0|Qe[3],this.E=0|Qe[4],this.F=0|Qe[5],this.G=0|Qe[6],this.H=0|Qe[7]}get(){const{A:t,B:e,C:r,D:n,E:i,F:o,G:s,H:a}=this;return[t,e,r,n,i,o,s,a]}set(t,e,r,n,i,o,s,a){this.A=0|t,this.B=0|e,this.C=0|r,this.D=0|n,this.E=0|i,this.F=0|o,this.G=0|s,this.H=0|a}process(t,e){for(let r=0;r<16;r++,e+=4)Je[r]=t.getUint32(e,!1);for(let t=16;t<64;t++){const e=Je[t-15],r=Je[t-2],n=je(e,7)^je(e,18)^e>>>3,i=je(r,17)^je(r,19)^r>>>10;Je[t]=i+Je[t-7]+n+Je[t-16]|0}let{A:r,B:n,C:i,D:o,E:s,F:a,G:u,H:c}=this;for(let t=0;t<64;t++){const e=c+(je(s,6)^je(s,11)^je(s,25))+$e(s,a,u)+Xe[t]+Je[t]|0,f=(je(r,2)^je(r,13)^je(r,22))+Ye(r,n,i)|0;c=u,u=a,a=s,s=o+e|0,o=i,i=n,n=r,r=e+f|0}r=r+this.A|0,n=n+this.B|0,i=i+this.C|0,o=o+this.D|0,s=s+this.E|0,a=a+this.F|0,u=u+this.G|0,c=c+this.H|0,this.set(r,n,i,o,s,a,u,c)}roundClean(){Je.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const er=qe((()=>new tr)),rr=new t.PublicKey("namesLPneVptA9Z5rqUDD9tMTWEJwofgaYwp8cawRkX"),nr="SPL Name Service",ir=new t.PublicKey("58PwtjSDuFHuUkYjH9BYnnQKHfwo9reZhC2zMJv9JPkx"),or=new t.PublicKey("jCebN34bUfdeUYJT13J1yG16XWQpt5PDx6Mse9GUqhR"),sr=new t.PublicKey("ETp9eKXVv1dWwHSpsXRUuXHmw24PwRkttCGVgpZEY9zF"),ar=new t.PublicKey("AUoZ3YAhV3b2rZeEH93UMZHXUZcTramBvb4d9YEVySkc"),ur=new t.PublicKey("33m47vH6Eav6jr5Ry86XjhRft2jRBLDnDgPSHoquXi2Z"),cr=new t.PublicKey("FvPH7PrVrLGKPfqaf3xJodFTjZriqrAXXLTVWEorTFBi"),fr=new t.PublicKey("4YcexoW3r78zz16J2aqmukBLRwGq6rAvWzJpkYAXqebv"),hr=new t.PublicKey("DmSyHDSM9eSLyvoLsPvDr5fRRFZ7Bfr3h3ULvWpgQaq7"),lr=new t.PublicKey("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"),dr=[new t.PublicKey("3ogYncmMM5CmytsGCqKHydmXmKUZ6sGWvizkzqwT7zb1"),new t.PublicKey("DM1jJCkZZEwY5tmWbgvKRxsDFzXCdbfrYCCH1CtwguEs"),new t.PublicKey("ADCp4QXFajHrhy4f43pD6GJFtQLkdBY2mjS9DfCk7tNW"),new t.PublicKey("2XTgjw8yi1E3Etgj4CUyRD7Zk49gynH2U9gA5N2MY4NP"),new t.PublicKey("5oDWj8vr3vbcq9JZTtwXqrkCMZggMsDzNietvbr1BNfe"),new t.PublicKey("8kJqxAbqbPLGLMgB6FhLcnw2SiUEavx2aEGM3WQGhtJF"),new t.PublicKey("HemvJzwxvVpWBjPETpaseAH395WAxb2G73MeUfjVkK1u"),new t.PublicKey("7hMiiUtkH4StMPJxyAtvzXTUjecTniQ8czkCPusf5eSW"),new t.PublicKey("DGpjHo4yYA3NgHvhHTp3XfBFrESsx1DnhfTr8D881ZBM")],pr=new Map([["EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v","USDC"],["Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB","USDT"],["So11111111111111111111111111111111111111112","SOL"],["EchesyfXePKdLtoiZSL8pBe8Myagyy8ZRqsACNCFGnvp","FIDA"],["mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So","MSOL"],["DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263","BONK"],["EPeUFDgHRxs9xxEPVaL6kfGQvCon7jmAWKVUHuux1Tpz","BAT"],["HZ1JovNiVvGrGNiiYvEozEVgZ58xaU3RKwX8eACQBCt3","PYTH"],["bSo13r4TkiE4KumL71LsHTPpL2euBYLFx6h9HP3piy1","BSOL"],["6McPRfPV6bY1e9hLxWyG54W9i9Epq75QBvXg2oetBVTB","INJ"]]),yr=new Map([["EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",{price:"Gnt27xtC473ZT2Mw5u8wZ68Z3gULkSTb5DuxJy7eJotD",product:"8GWTTbNiXdmyZREXbjsZBmCRuzdPrW55dnZGDkTRjWvb"}],["Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB",{price:"3vxLXJqLqF3JG5TCbYycbKWRBbCJQLxQmBGCkyqEEefL",product:"Av6XyAMJnyi68FdsKSPYgzfXGjYrrt6jcAMwtvzLCqaM"}],["So11111111111111111111111111111111111111112",{price:"H6ARHf6YXhGYeQfUzQNGk6rDNnLBQKrenN712K4AQJEG",product:"ALP8SdU9oARYVLgLR7LrqMNCYBnhtnQz1cj6bwgwQmgj"}],["EchesyfXePKdLtoiZSL8pBe8Myagyy8ZRqsACNCFGnvp",{price:"ETp9eKXVv1dWwHSpsXRUuXHmw24PwRkttCGVgpZEY9zF",product:"HyEB4Goiv7QyfFStaBn49JqQzSTV1ybtVikwsMLH1f2M"}],["mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So",{price:"E4v1BBgoso9s64TQvmyownAVJbhbEPGyzA3qn4n46qj9",product:"BS2iAqT67j8hA9Jji4B8UpL3Nfw9kwPfU5s4qeaf1e7r"}],["DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263",{price:"8ihFLu5FimgTQ1Unh4dVyEHUGodJ5gJQCrQf4KUVB9bN",product:"FerFD54J6RgmQVCR5oNgpzXmz8BW2eBNhhirb1d5oifo"}],["EPeUFDgHRxs9xxEPVaL6kfGQvCon7jmAWKVUHuux1Tpz",{price:"AbMTYZ82Xfv9PtTQ5e1fJXemXjzqEEFHP3oDLRTae6yz",product:"8xTEctXKo6Xo3EzNhSNp4TUe8mgfwWFbDUXJhuubvrKx"}],["HZ1JovNiVvGrGNiiYvEozEVgZ58xaU3RKwX8eACQBCt3",{price:"nrYkQQQur7z8rYTST3G9GqATviK5SxTDkrqd21MW6Ue",product:"AiQB4WngNPKDe3iWAwZmMzbULDAAfUD6Sr1knfZNJj3y"}],["bSo13r4TkiE4KumL71LsHTPpL2euBYLFx6h9HP3piy1",{price:"AFrYBhb5wKQtxRS9UA9YRS4V3dwFm7SqmS6DHKq6YVgo",product:"3RtUHQR2LQ7su5R4zWwjupx72sWRGvLA4cFmnbHnT9M7"}],["6McPRfPV6bY1e9hLxWyG54W9i9Epq75QBvXg2oetBVTB",{price:"9EdtbaivHQYA4Nh3XzGR6DwRaoorqXYnmpfsnFhvwuVj",product:"5Q5kyCVzssrGMd2BniSdVeRwjNWrGGrFhMrgGt4zURyA"}]]),gr=new t.PublicKey("AHtgzX45WTKfkPG53L6WYhGEXwQkN1BVknET3sVsLL8J"),wr=new t.PublicKey("GcWEQ9K78FV7LEHteFVciYApERk5YvQuFDQPk1yYJVXi"),mr=new t.PublicKey("BPeXUQDqGbzxeK1LJby6ugvCBuo7kRSEUkjD726mUVsz"),br=new t.PublicKey("72aLKvXeV4aansAQtxKymeXDevT5ed6sCuz9iN62ugPT"),vr=new t.PublicKey("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s");async function Er(t,e){if(!await t.getAccountInfo(e))throw new _t(exports.ErrorType.AccountDoesNotExist);return Ne.retrieve(t,e)}async function xr(t){const e=nr+t,r=er(i.Buffer.from(e,"utf8"));return i.Buffer.from(r)}async function Ar(e,r,n){const o=[e];r?o.push(r.toBuffer()):o.push(i.Buffer.alloc(32)),n?o.push(n.toBuffer()):o.push(i.Buffer.alloc(32));const[s]=await t.PublicKey.findProgramAddress(o,rr);return s}const Br=async(t,e=ir)=>{let r=await xr(t);return{pubkey:await Ar(r,void 0,e),hashed:r}},Sr=async(t,e=!1)=>{t.endsWith(".sol")&&(t=t.slice(0,-4));const r=t.split(".");if(2===r.length){const t=i.Buffer.from([e?1:0]).toString().concat(r[0]),{pubkey:n}=await Br(r[1]);return{...await Br(t,n),isSub:!0,parent:n}}if(3===r.length&&e){const{pubkey:t}=await Br(r[2]),{pubkey:e}=await Br("\0".concat(r[1]),t),n=i.Buffer.from([1]).toString();return{...await Br(n.concat(r[0]),e),isSub:!0,parent:t,isSubRecord:!0}}if(r.length>=3)throw new _t(exports.ErrorType.InvalidInput);return{...await Br(t,ir),isSub:!1,parent:void 0}};var Ir,Mr=["u8","u16","u32","u64","u128","i8","i16","i32","i64","i128","f32","f64"],Rr=function(){function t(){this.offset=0,this.buffer_size=256,this.buffer=new ArrayBuffer(this.buffer_size),this.view=new DataView(this.buffer)}return t.prototype.resize_if_necessary=function(t){if(this.buffer_size-this.offset<t){this.buffer_size=Math.max(2*this.buffer_size,this.buffer_size+t);var e=new ArrayBuffer(this.buffer_size);new Uint8Array(e).set(new Uint8Array(this.buffer)),this.buffer=e,this.view=new DataView(e)}},t.prototype.get_used_buffer=function(){return new Uint8Array(this.buffer).slice(0,this.offset)},t.prototype.store_value=function(t,e){var r=e.substring(1),n=parseInt(r)/8;this.resize_if_necessary(n);var i="f"===e[0]?"setFloat".concat(r):"i"===e[0]?"setInt".concat(r):"setUint".concat(r);this.view[i](this.offset,t,!0),this.offset+=n},t.prototype.store_bytes=function(t){this.resize_if_necessary(t.length),new Uint8Array(this.buffer).set(new Uint8Array(t),this.offset),this.offset+=t.length},t}(),kr=function(){function t(t){this.offset=0,this.buffer_size=t.length,this.buffer=new ArrayBuffer(t.length),new Uint8Array(this.buffer).set(t),this.view=new DataView(this.buffer)}return t.prototype.assert_enough_buffer=function(t){if(this.offset+t>this.buffer.byteLength)throw new Error("Error in schema, the buffer is smaller than expected")},t.prototype.consume_value=function(t){var e=t.substring(1),r=parseInt(e)/8;this.assert_enough_buffer(r);var n="f"===t[0]?"getFloat".concat(e):"i"===t[0]?"getInt".concat(e):"getUint".concat(e),i=this.view[n](this.offset,!0);return this.offset+=r,i},t.prototype.consume_bytes=function(t){this.assert_enough_buffer(t);var e=this.buffer.slice(this.offset,this.offset+t);return this.offset+=t,e},t}(),_r=(Ir=function(t,e){return Ir=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},Ir(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}Ir(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)});function Pr(t,e,r){if(typeof t!==e)throw new Error("Expected ".concat(e," not ").concat(typeof t,"(").concat(t,") at ").concat(r.join(".")))}function Tr(t,e,r){if(t!==e)throw new Error("Array length ".concat(t," does not match schema length ").concat(e," at ").concat(r.join(".")))}var Ur=Mr.concat(["bool","string"]),Lr=["option","enum","array","set","map","struct"],Or=function(t){function e(e,r){var n="Invalid schema: ".concat(JSON.stringify(e)," expected ").concat(r);return t.call(this,n)||this}return _r(e,t),e}(Error);function Cr(t){if("string"!=typeof t||!Ur.includes(t)){if(t&&"object"==typeof t){var e=Object.keys(t);if(1===e.length&&Lr.includes(e[0])){var r=e[0];if("option"===r)return Cr(t[r]);if("enum"===r)return function(t){if(!Array.isArray(t))throw new Or(t,"Array");for(var e=0,r=t;e<r.length;e++){var n=r[e];if("object"!=typeof n||!("struct"in n))throw new Error('Missing "struct" key in enum schema');if("object"!=typeof n.struct||1!==Object.keys(n.struct).length)throw new Error('The "struct" in each enum must have a single key');Cr({struct:n.struct})}}(t[r]);if("array"===r)return function(t){if("object"!=typeof t)throw new Or(t,"{ type, len? }");if(t.len&&"number"!=typeof t.len)throw new Error("Invalid schema: ".concat(t));if("type"in t)return Cr(t.type);throw new Or(t,"{ type, len? }")}(t[r]);if("set"===r)return Cr(t[r]);if("map"===r)return function(t){if("object"!=typeof t||!("key"in t)||!("value"in t))throw new Or(t,"{ key, value }");Cr(t.key),Cr(t.value)}(t[r]);if("struct"===r)return function(t){if("object"!=typeof t)throw new Or(t,"object");for(var e in t)Cr(t[e])}(t[r])}}throw new Or(t,Lr.join(", ")+" or "+Ur.join(", "))}}var Nr=function(){function t(t){this.encoded=new Rr,this.fieldPath=["value"],this.checkTypes=t}return t.prototype.encode=function(t,e){return this.encode_value(t,e),this.encoded.get_used_buffer()},t.prototype.encode_value=function(t,e){if("string"==typeof e){if(Mr.includes(e))return this.encode_integer(t,e);if("string"===e)return this.encode_string(t);if("bool"===e)return this.encode_boolean(t)}if("object"==typeof e){if("option"in e)return this.encode_option(t,e);if("enum"in e)return this.encode_enum(t,e);if("array"in e)return this.encode_array(t,e);if("set"in e)return this.encode_set(t,e);if("map"in e)return this.encode_map(t,e);if("struct"in e)return this.encode_struct(t,e)}},t.prototype.encode_integer=function(t,e){var r=parseInt(e.substring(1));r<=32||"f64"==e?(this.checkTypes&&Pr(t,"number",this.fieldPath),this.encoded.store_value(t,e)):(this.checkTypes&&function(t,e){if(!(["number","string","bigint","boolean"].includes(typeof t)||"object"==typeof t&&null!==t&&"toString"in t))throw new Error("Expected bigint, number, boolean or string not ".concat(typeof t,"(").concat(t,") at ").concat(e.join(".")))}(t,this.fieldPath),this.encode_bigint(BigInt(t),r))},t.prototype.encode_bigint=function(t,e){for(var r=e/8,n=new Uint8Array(r),i=0;i<r;i++)n[i]=Number(t&BigInt(255)),t>>=BigInt(8);this.encoded.store_bytes(new Uint8Array(n))},t.prototype.encode_string=function(t){this.checkTypes&&Pr(t,"string",this.fieldPath);var e=t;this.encoded.store_value(e.length,"u32");for(var r=0;r<e.length;r++)this.encoded.store_value(e.charCodeAt(r),"u8")},t.prototype.encode_boolean=function(t){this.checkTypes&&Pr(t,"boolean",this.fieldPath),this.encoded.store_value(t?1:0,"u8")},t.prototype.encode_option=function(t,e){null==t?this.encoded.store_value(0,"u8"):(this.encoded.store_value(1,"u8"),this.encode_value(t,e.option))},t.prototype.encode_enum=function(t,e){this.checkTypes&&function(t,e){if("object"!=typeof t||null===t)throw new Error("Expected object not ".concat(typeof t,"(").concat(t,") at ").concat(e.join(".")))}(t,this.fieldPath);for(var r=Object.keys(t)[0],n=0;n<e.enum.length;n++){var i=e.enum[n];if(r===Object.keys(i.struct)[0])return this.encoded.store_value(n,"u8"),this.encode_struct(t,i)}throw new Error("Enum key (".concat(r,") not found in enum schema: ").concat(JSON.stringify(e)," at ").concat(this.fieldPath.join(".")))},t.prototype.encode_array=function(t,e){if(function(t){return Array.isArray(t)||!!t&&"object"==typeof t&&"length"in t&&"number"==typeof t.length&&(0===t.length||t.length>0&&t.length-1 in t)}(t))return this.encode_arraylike(t,e);if(t instanceof ArrayBuffer)return this.encode_buffer(t,e);throw new Error("Expected Array-like not ".concat(typeof t,"(").concat(t,") at ").concat(this.fieldPath.join(".")))},t.prototype.encode_arraylike=function(t,e){e.array.len?Tr(t.length,e.array.len,this.fieldPath):this.encoded.store_value(t.length,"u32");for(var r=0;r<t.length;r++)this.encode_value(t[r],e.array.type)},t.prototype.encode_buffer=function(t,e){e.array.len?Tr(t.byteLength,e.array.len,this.fieldPath):this.encoded.store_value(t.byteLength,"u32"),this.encoded.store_bytes(new Uint8Array(t))},t.prototype.encode_set=function(t,e){this.checkTypes&&Pr(t,"object",this.fieldPath);var r=t instanceof Set?Array.from(t.values()):Object.values(t);this.encoded.store_value(r.length,"u32");for(var n=0,i=r;n<i.length;n++){var o=i[n];this.encode_value(o,e.set)}},t.prototype.encode_map=function(t,e){this.checkTypes&&Pr(t,"object",this.fieldPath);var r=t instanceof Map,n=r?Array.from(t.keys()):Object.keys(t);this.encoded.store_value(n.length,"u32");for(var i=0,o=n;i<o.length;i++){var s=o[i];this.encode_value(s,e.map.key),this.encode_value(r?t.get(s):t[s],e.map.value)}},t.prototype.encode_struct=function(t,e){this.checkTypes&&Pr(t,"object",this.fieldPath);for(var r=0,n=Object.keys(e.struct);r<n.length;r++){var i=n[r];this.fieldPath.push(i),this.encode_value(t[i],e.struct[i]),this.fieldPath.pop()}},t}(),Dr=function(){function t(t){this.buffer=new kr(t)}return t.prototype.decode=function(t){return this.decode_value(t)},t.prototype.decode_value=function(t){if("string"==typeof t){if(Mr.includes(t))return this.decode_integer(t);if("string"===t)return this.decode_string();if("bool"===t)return this.decode_boolean()}if("object"==typeof t){if("option"in t)return this.decode_option(t);if("enum"in t)return this.decode_enum(t);if("array"in t)return this.decode_array(t);if("set"in t)return this.decode_set(t);if("map"in t)return this.decode_map(t);if("struct"in t)return this.decode_struct(t)}throw new Error("Unsupported type: ".concat(t))},t.prototype.decode_integer=function(t){var e=parseInt(t.substring(1));return e<=32||"f64"==t?this.buffer.consume_value(t):this.decode_bigint(e,t.startsWith("i"))},t.prototype.decode_bigint=function(t,e){void 0===e&&(e=!1);var r=t/8,n=new Uint8Array(this.buffer.consume_bytes(r)),i=n.reduceRight((function(t,e){return t+e.toString(16).padStart(2,"0")}),"");return e&&n[r-1]?BigInt.asIntN(t,BigInt("0x".concat(i))):BigInt("0x".concat(i))},t.prototype.decode_string=function(){var t=this.decode_integer("u32"),e=new Uint8Array(this.buffer.consume_bytes(t));return String.fromCharCode.apply(null,e)},t.prototype.decode_boolean=function(){return this.buffer.consume_value("u8")>0},t.prototype.decode_option=function(t){var e=this.buffer.consume_value("u8");if(1===e)return this.decode_value(t.option);if(0!==e)throw new Error("Invalid option ".concat(e));return null},t.prototype.decode_enum=function(t){var e,r=this.buffer.consume_value("u8");if(r>t.enum.length)throw new Error("Enum option ".concat(r," is not available"));var n=t.enum[r].struct,i=Object.keys(n)[0];return(e={})[i]=this.decode_value(n[i]),e},t.prototype.decode_array=function(t){for(var e=[],r=t.array.len?t.array.len:this.decode_integer("u32"),n=0;n<r;++n)e.push(this.decode_value(t.array.type));return e},t.prototype.decode_set=function(t){for(var e=this.decode_integer("u32"),r=new Set,n=0;n<e;++n)r.add(this.decode_value(t.set));return r},t.prototype.decode_map=function(t){for(var e=this.decode_integer("u32"),r=new Map,n=0;n<e;++n){var i=this.decode_value(t.map.key),o=this.decode_value(t.map.value);r.set(i,o)}return r},t.prototype.decode_struct=function(t){var e={};for(var r in t.struct)e[r]=this.decode_value(t.struct[r]);return e},t}();function zr(t,e,r){return void 0===r&&(r=!0),r&&Cr(t),new Nr(r).encode(e,t)}class Vr{constructor(t){this.tag=1,this.record=t.record,this.content=t.content}serialize(){return zr(Vr.schema,this)}getInstruction(e,r,n,i,o,s,a,u){const c=Buffer.from(this.serialize());let f=[];return f.push({pubkey:r,isSigner:!1,isWritable:!1}),f.push({pubkey:n,isSigner:!1,isWritable:!1}),f.push({pubkey:i,isSigner:!0,isWritable:!0}),f.push({pubkey:o,isSigner:!1,isWritable:!0}),f.push({pubkey:s,isSigner:!1,isWritable:!0}),f.push({pubkey:a,isSigner:!0,isWritable:!0}),f.push({pubkey:u,isSigner:!1,isWritable:!1}),new t.TransactionInstruction({keys:f,programId:e,data:c})}}Vr.schema={struct:{tag:"u8",record:"string",content:{array:{type:"u8"}}}};class Wr{constructor(t){this.tag=4,this.validation=t.validation,this.signature=t.signature,this.expectedPubkey=t.expectedPubkey}serialize(){return zr(Wr.schema,this)}getInstruction(e,r,n,i,o,s,a,u){const c=Buffer.from(this.serialize());let f=[];return f.push({pubkey:r,isSigner:!1,isWritable:!1}),f.push({pubkey:n,isSigner:!1,isWritable:!1}),f.push({pubkey:i,isSigner:!0,isWritable:!0}),f.push({pubkey:o,isSigner:!1,isWritable:!0}),f.push({pubkey:s,isSigner:!1,isWritable:!0}),f.push({pubkey:a,isSigner:!0,isWritable:!0}),f.push({pubkey:u,isSigner:!1,isWritable:!1}),new t.TransactionInstruction({keys:f,programId:e,data:c})}}Wr.schema={struct:{tag:"u8",validation:"u8",signature:{array:{type:"u8"}},expectedPubkey:{array:{type:"u8"}}}};class Fr{constructor(t){this.tag=3,this.staleness=t.staleness}serialize(){return zr(Fr.schema,this)}getInstruction(e,r,n,i,o,s,a,u,c){const f=Buffer.from(this.serialize());let h=[];return h.push({pubkey:r,isSigner:!1,isWritable:!1}),h.push({pubkey:n,isSigner:!1,isWritable:!1}),h.push({pubkey:i,isSigner:!0,isWritable:!0}),h.push({pubkey:o,isSigner:!1,isWritable:!0}),h.push({pubkey:s,isSigner:!1,isWritable:!0}),h.push({pubkey:a,isSigner:!1,isWritable:!0}),h.push({pubkey:u,isSigner:!1,isWritable:!1}),h.push({pubkey:c,isSigner:!0,isWritable:!0}),new t.TransactionInstruction({keys:h,programId:e,data:f})}}Fr.schema={struct:{tag:"u8",staleness:"bool"}};class jr{constructor(t){this.tag=2,this.record=t.record,this.content=t.content}serialize(){return zr(jr.schema,this)}getInstruction(e,r,n,i,o,s,a,u){const c=Buffer.from(this.serialize());let f=[];return f.push({pubkey:r,isSigner:!1,isWritable:!1}),f.push({pubkey:n,isSigner:!1,isWritable:!1}),f.push({pubkey:i,isSigner:!0,isWritable:!0}),f.push({pubkey:o,isSigner:!1,isWritable:!0}),f.push({pubkey:s,isSigner:!1,isWritable:!0}),f.push({pubkey:a,isSigner:!0,isWritable:!0}),f.push({pubkey:u,isSigner:!1,isWritable:!1}),new t.TransactionInstruction({keys:f,programId:e,data:c})}}jr.schema={struct:{tag:"u8",record:"string",content:{array:{type:"u8"}}}};class Kr{constructor(){this.tag=5}serialize(){return zr(Kr.schema,this)}getInstruction(e,r,n,i,o,s,a,u){const c=Buffer.from(this.serialize());let f=[];return f.push({pubkey:r,isSigner:!1,isWritable:!1}),f.push({pubkey:n,isSigner:!1,isWritable:!1}),f.push({pubkey:i,isSigner:!0,isWritable:!0}),f.push({pubkey:o,isSigner:!1,isWritable:!0}),f.push({pubkey:s,isSigner:!1,isWritable:!0}),f.push({pubkey:a,isSigner:!0,isWritable:!0}),f.push({pubkey:u,isSigner:!1,isWritable:!1}),new t.TransactionInstruction({keys:f,programId:e,data:c})}}Kr.schema={struct:{tag:"u8"}};class Hr{constructor(t){this.tag=6,this.roaId=t.roaId}serialize(){return zr(Hr.schema,this)}getInstruction(e,r,n,i,o,s,a,u){const c=Buffer.from(this.serialize());let f=[];return f.push({pubkey:r,isSigner:!1,isWritable:!1}),f.push({pubkey:n,isSigner:!1,isWritable:!1}),f.push({pubkey:i,isSigner:!0,isWritable:!0}),f.push({pubkey:o,isSigner:!1,isWritable:!0}),f.push({pubkey:s,isSigner:!1,isWritable:!0}),f.push({pubkey:a,isSigner:!0,isWritable:!0}),f.push({pubkey:u,isSigner:!1,isWritable:!1}),new t.TransactionInstruction({keys:f,programId:e,data:c})}}Hr.schema={struct:{tag:"u8",roaId:{array:{type:"u8"}}}};const Gr=new t.PublicKey("HP3D4D1ZCmohQGFVms2SS4LCANgJyksBf5s1F77FuFjZ"),[qr]=t.PublicKey.findProgramAddressSync([Gr.toBuffer()],Gr);var Zr,$r;($r=Zr||(Zr={}))[$r.None=0]="None",$r[$r.Solana=1]="Solana",$r[$r.Ethereum=2]="Ethereum",$r[$r.UnverifiedSolana=3]="UnverifiedSolana";const Yr=t=>{switch(t){case Zr.None:return 0;case Zr.Ethereum:return 20;case Zr.Solana:case Zr.UnverifiedSolana:return 32;default:throw new Error("Invalid validation enum")}};class Xr{constructor(t){this.stalenessValidation=t.stalenessValidation,this.rightOfAssociationValidation=t.rightOfAssociationValidation,this.contentLength=t.contentLength}static deserialize(t){return new Xr((e=this.schema,r=t,void 0===(n=!0)&&(n=!0),n&&Cr(e),new Dr(r).decode(e)));var e,r,n}static async retrieve(t,e){const r=await t.getAccountInfo(e);if(!r||!r.data)throw new Error("Record header account not found");return this.deserialize(r.data.slice(96,96+this.LEN))}}Xr.LEN=8,Xr.schema={struct:{stalenessValidation:"u16",rightOfAssociationValidation:"u16",contentLength:"u32"}};class Qr{constructor(t,e){this.data=e,this.header=t}static deserialize(t){const e=Xr.deserialize(t.slice(96,96+Xr.LEN)),r=t.slice(96+Xr.LEN);return new Qr(e,r)}static async retrieve(t,e){const r=await t.getAccountInfo(e);if(!r||!r.data)throw new Error("Record header account not found");return this.deserialize(r.data)}static async retrieveBatch(t,e){return(await t.getMultipleAccountsInfo(e)).map((t=>{if(null==t?void 0:t.data)return this.deserialize(t.data)}))}getContent(){let t=Yr(this.header.stalenessValidation)+Yr(this.header.rightOfAssociationValidation);return this.data.slice(t)}getStalenessId(){let t=Yr(this.header.stalenessValidation);return this.data.slice(0,t)}getRoAId(){let t=Yr(this.header.stalenessValidation),e=t+Yr(this.header.rightOfAssociationValidation);return this.data.slice(t,e)}}var Jr;exports.Record=void 0,(Jr=exports.Record||(exports.Record={})).IPFS="IPFS",Jr.ARWV="ARWV",Jr.SOL="SOL",Jr.ETH="ETH",Jr.BTC="BTC",Jr.LTC="LTC",Jr.DOGE="DOGE",Jr.Email="email",Jr.Url="url",Jr.Discord="discord",Jr.Github="github",Jr.Reddit="reddit",Jr.Twitter="twitter",Jr.Telegram="telegram",Jr.Pic="pic",Jr.SHDW="SHDW",Jr.POINT="POINT",Jr.BSC="BSC",Jr.Injective="INJ",Jr.Backpack="backpack",Jr.A="A",Jr.AAAA="AAAA",Jr.CNAME="CNAME",Jr.TXT="TXT",Jr.Background="background";const tn=new Map([[exports.Record.SOL,96],[exports.Record.ETH,20],[exports.Record.BSC,20],[exports.Record.Injective,20],[exports.Record.A,4],[exports.Record.AAAA,16],[exports.Record.Background,32]]);var en;exports.RecordVersion=void 0,(en=exports.RecordVersion||(exports.RecordVersion={}))[en.V1=1]="V1",en[en.V2=2]="V2";var rn="ABAOAAAAAACwiAAAAYkHdvjtnH+IFkUYxx/v3vPe7uw8UkjsD43ChKICDQsT3iIJy4gSiZAjkn5JUFlaiFmjccT9ESkpGBGVIlQgWSkY/QDBoMgrQv0jRJDAfkCXhUmgRX23d4ebnndmd3Z3ZnfVeeDDzM7MPs8zv57Zd2+5hd1Ed4ClYAisBuuUsqLpMHgJjIBNFu1fBW8l1O8AO8Ee8Cn4HIyCg+CI0u4Y+AmMgVPgDOhuEHWBPjAZXAy2gjfA9kb73hlx+i7SK8AHYDf4BOwHB8AoOAyOguPgB/ArOKlcnwHdPe32/Uin9LTvvwTph0gv62nbubKnXT+nZ1z/DcjfFF8vQno7uEaxH923BGVXN9v5Zcgvj/VFPIT8Y/H1k0jXxPn1SEfARjBdab8V+TfB22CXUh5xd3OcZTH3g6di1LZJbLNs55q96M9n4J9Gm6hsfzQvcT8fbfy//TyUf8vG4Lses/5jcd2PSE/IcQan4/o/UXYadE0kaoJBMG1ivNbidNbETr1XoWyuplwyHFN0fFai/8/EY7BIKY/68EpCvwP+mc/m/2vNGnBhp1eZ51bCmgsEAoFAIBAIBAKBQKAO3Irfrg3lfc4qi/cXd+Kee5TfvAd6ieY0ie5D2cNx+eNInwZLmu33gWuRn4/8C3H9CNJNYEt8/TrS35HuSPktvRP1z0LPOvAceB4IsB5saIa6UBfqQl2oc123AjwBVjWrP7MCgcC5y/ue/56yqXv87+qcIU2Z+ny8tuHHpyxsvrDNITDXgqkDRJcPdJY/wMo24/oQmDqZaPHkdplAuhv8ApqDRDeCVj/OAvD9BUSX9qF8Qpt7lTxnZ7+5TmVtrGMM7XchP3sS0SNgGzg4yU5HIBAIBM5NfsO5QDgfjuM54STOw7/Az/F3QtfhfF4Qn9F/gxMouxm/WU7F9afBQuUM7+rtPF+jb0b6ese/I7sI+emadhEzUT5bqbsW+esNbSMWoG6hWo/8gOLPUqUu+v5rKEHX8oS6iEXQexd7XlmBe1aCNWAp6kSsYyjHc82Liv2Xkd/C/HkN1w/Geren+KryToa2PtlQg2c9zijGZnGJ9kaibzZh84jmmfx4TeYpK9H3usMKqxnDCWxsdLY/3ygy9h+l/LYbYHtuXw2/rfsSPo0a/Jrn6PvPrzL2+7CmfV88lkc9j+F7cRzYU4N48DF8uA3n/T7Fly9q4Jdvoth0uLf9LORC11hvO/0D6RnQfRa99+2Hr1NS/M26VvfEe2jaWTAOvG8zzgKf8zCrYL++qUEfbumeQAjTVnQp+QmW99gQpDoJ4+9uHZe5/l3OW/M8x6WUZaduUvUc5p13NTXlz3VpGbCVrGNe5zOnjvGlrDWY1IdWShuuQ9fWh6h+VSV1Wit1lvNhHFz1zeUYtCg5ntvOSStDW5cITRnF5RJ+rcasJHExztwu910tl6LzLYsvuvvzilB0mvSaxt/V+SY0EMurfkjbrTjfInf+FJGkNdzSlOukZaDo3snqs7RZpqj2Gx7sS52D5O79k+93W2W/T3NhQxe3VeF16pwn4eI8qev7Sl1s0PnPy5PalSV57Pp6XuDxrypR9wBR8nOCzm/eXuYp5d4s/lV1XvL+lG2b+2AaQ1nPr23Hrc7z0WT5qvZL0v7QtdX5zdu6HMei+gV1ri8et4XSVpCfdeB7fRWNRy79UP0RCT4Jyre/88bbKsQUawUrV69dxjd+nlXxbCKos79pz1BpOqucz0gEdZ5hMk+aa7Wdy/7xZ5Yqhc+nyHivrkyQ/reM7tziuFojfM7zxtq0505XYutvHrtVnzNl2ONrTGdPkLv9ZjNHOoShnCh5nLLYKOKfK4qK7bjx/gqyj9lFJc2Wz/HIqyMSYaGnqM8+xp6vB1/6feg22UmLFUno1rurvelz7yT1UVfORW3L7+d6fMcAXdzxIVK3TNNioZpSyj2242izpky6y5S0fpr6q5ZXJT7O1qrmQRVB+rkQ1Dk3vvYttyGoc+51/mUVkYLtXvTx7MCvbUnzW2czyR8pql4XUlbcN9l1pSfPfOl0JV2bylyKoM4959sHQfr9Vpbk2V8u4ry0ndcvH5I1xggP9qVem/PHZL+qeGLrc945tLnHtG/LEtdjr4urxMpM92X1RZDd+pLtsorUydeCaiuvbtdSpQ9l2M4SU01nvI1e35L3uS5Jlw8pe1ykCKo2JtrGK9O9ujOlimcD6Y9LEWQ+7019d2VDLVPrTCLrsvjsQ1TfJVJM12pZmm5b4Xptx6HM9SpFkP2c6drJa5/iSr+pD7r+CNLvATVfpST1RYog/fwKTdsyxLVNQfnWrkyziGltJK2hLLptzjHXIsh+/HytmyQfpPA5VNtzXWWLzbiVsc9sbWSJ7UWE69KNh6v9kya2c6TzMa0fwpD37TtvQ6wuiw9CA9cny33Mj2pLte9Kp6996HO/83HPQ5r+ov5mvU9Qte/fIrGJP7axPO/9eXX6kjLPKZNd17iyZdOHLP31JSbfXY6hC59c+ZZ136TZ9SFlj6cvmVkSrkSQn3NG5KBqEVSeH6Ji/vvnhFWjSlfFNDwzyMgqLvvKxXffbeASBWo+Zj4p2x6TfwE=",nn="AAACAAAAAACAOAAAAbYBSf7t2S1IBEEYBuDVDZ7FYrQMNsFiu3hgEYOI0SCXRIUrB8JhEZtgs5gEg1GMFk02m82oGI02m+9xezCOczv/uwv3fvAwc/PzfXOzcdqzWdaBDdiGPdiHdjE+DS3RNDuCfsn8idQ/g3OH3BdwKf0e96/gumTfYcncLdzBPTzAo+RZ+f0Cr/AG7/AJX4738x1wtz9FO5PX/50n6UXMNdfg/0lERERERERERERERETpdedHBvDRql4nq0cXtW9af98qdRby0Vvp8K4W0V+C5Xw0t4J2bfjeBp3cnEu1brnnCTYNa7eKdz91XP7WO9Lb4GqRb7cY6xbtAdqeVOsY/QGcevw/tb6OT85YhvfKYEx9CMuxKsKnrs+eJtVInVvHJ0eVYVvTZk2siFVLOCjb61PTZX3MdVWEyP7fjzpmMxdzTyq2Ebue6x61nXRGnzndWpf1an7dXmGYE4Y1ptqqKsK1nu26Ju0ty+maV2Rpvk+qnDZjKUIobUiesdAQE/jmCTmHmsskpFZsVYbtmXRcaoSGUPomunW2derQhDPFjtT1Q/eb8vnm990fq35oHVt11bU9m89c7DNI8Qs=",on=0,sn=-3;function an(){this.table=new Uint16Array(16),this.trans=new Uint16Array(288)}function un(t,e){this.source=t,this.sourceIndex=0,this.tag=0,this.bitcount=0,this.dest=e,this.destLen=0,this.ltree=new an,this.dtree=new an}var cn=new an,fn=new an,hn=new Uint8Array(30),ln=new Uint16Array(30),dn=new Uint8Array(30),pn=new Uint16Array(30),yn=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),gn=new an,wn=new Uint8Array(320);function mn(t,e,r,n){var i,o;for(i=0;i<r;++i)t[i]=0;for(i=0;i<30-r;++i)t[i+r]=i/r|0;for(o=n,i=0;i<30;++i)e[i]=o,o+=1<<t[i]}var bn=new Uint16Array(16);function vn(t,e,r,n){var i,o;for(i=0;i<16;++i)t.table[i]=0;for(i=0;i<n;++i)t.table[e[r+i]]++;for(t.table[0]=0,o=0,i=0;i<16;++i)bn[i]=o,o+=t.table[i];for(i=0;i<n;++i)e[r+i]&&(t.trans[bn[e[r+i]]++]=i)}function En(t){t.bitcount--||(t.tag=t.source[t.sourceIndex++],t.bitcount=7);var e=1&t.tag;return t.tag>>>=1,e}function xn(t,e,r){if(!e)return r;for(;t.bitcount<24;)t.tag|=t.source[t.sourceIndex++]<<t.bitcount,t.bitcount+=8;var n=t.tag&65535>>>16-e;return t.tag>>>=e,t.bitcount-=e,n+r}function An(t,e){for(;t.bitcount<24;)t.tag|=t.source[t.sourceIndex++]<<t.bitcount,t.bitcount+=8;var r=0,n=0,i=0,o=t.tag;do{n=2*n+(1&o),o>>>=1,++i,r+=e.table[i],n-=e.table[i]}while(n>=0);return t.tag=o,t.bitcount-=i,e.trans[r+n]}function Bn(t,e,r){var n,i,o,s,a,u;for(n=xn(t,5,257),i=xn(t,5,1),o=xn(t,4,4),s=0;s<19;++s)wn[s]=0;for(s=0;s<o;++s){var c=xn(t,3,0);wn[yn[s]]=c}for(vn(gn,wn,0,19),a=0;a<n+i;){var f=An(t,gn);switch(f){case 16:var h=wn[a-1];for(u=xn(t,2,3);u;--u)wn[a++]=h;break;case 17:for(u=xn(t,3,3);u;--u)wn[a++]=0;break;case 18:for(u=xn(t,7,11);u;--u)wn[a++]=0;break;default:wn[a++]=f}}vn(e,wn,0,n),vn(r,wn,n,i)}function Sn(t,e,r){for(;;){var n,i,o,s,a=An(t,e);if(256===a)return on;if(a<256)t.dest[t.destLen++]=a;else for(n=xn(t,hn[a-=257],ln[a]),i=An(t,r),s=o=t.destLen-xn(t,dn[i],pn[i]);s<o+n;++s)t.dest[t.destLen++]=t.dest[s]}}function In(t){for(var e,r;t.bitcount>8;)t.sourceIndex--,t.bitcount-=8;if((e=256*(e=t.source[t.sourceIndex+1])+t.source[t.sourceIndex])!==(65535&~(256*t.source[t.sourceIndex+3]+t.source[t.sourceIndex+2])))return sn;for(t.sourceIndex+=4,r=e;r;--r)t.dest[t.destLen++]=t.source[t.sourceIndex++];return t.bitcount=0,on}!function(t,e){var r;for(r=0;r<7;++r)t.table[r]=0;for(t.table[7]=24,t.table[8]=152,t.table[9]=112,r=0;r<24;++r)t.trans[r]=256+r;for(r=0;r<144;++r)t.trans[24+r]=r;for(r=0;r<8;++r)t.trans[168+r]=280+r;for(r=0;r<112;++r)t.trans[176+r]=144+r;for(r=0;r<5;++r)e.table[r]=0;for(e.table[5]=32,r=0;r<32;++r)e.trans[r]=r}(cn,fn),mn(hn,ln,4,3),mn(dn,pn,2,1),hn[28]=0,ln[28]=258;var Mn=function(t,e){var r,n,i=new un(t,e);do{switch(r=En(i),xn(i,2,0)){case 0:n=In(i);break;case 1:n=Sn(i,cn,fn);break;case 2:Bn(i,i.ltree,i.dtree),n=Sn(i,i.ltree,i.dtree);break;default:n=sn}if(n!==on)throw new Error("Data error")}while(!r);return i.destLen<i.dest.length?"function"==typeof i.dest.slice?i.dest.slice(0,i.destLen):i.dest.subarray(0,i.destLen):i.dest};const Rn=18===new Uint8Array(new Uint32Array([305419896]).buffer)[0],kn=(t,e,r)=>{let n=t[e];t[e]=t[r],t[r]=n};var _n={swap32LE:t=>{Rn&&(t=>{const e=t.length;for(let r=0;r<e;r+=4)kn(t,r,r+3),kn(t,r+1,r+2)})(t)}};const Pn=Mn,{swap32LE:Tn}=_n;var Un=class{constructor(t){const e="function"==typeof t.readUInt32BE&&"function"==typeof t.slice;if(e||t instanceof Uint8Array){let r;if(e)this.highStart=t.readUInt32LE(0),this.errorValue=t.readUInt32LE(4),r=t.readUInt32LE(8),t=t.slice(12);else{const e=new DataView(t.buffer);this.highStart=e.getUint32(0,!0),this.errorValue=e.getUint32(4,!0),r=e.getUint32(8,!0),t=t.subarray(12)}t=Pn(t,new Uint8Array(r)),t=Pn(t,new Uint8Array(r)),Tn(t),this.data=new Uint32Array(t.buffer)}else({data:this.data,highStart:this.highStart,errorValue:this.errorValue}=t)}get(t){let e;return t<0||t>1114111?this.errorValue:t<55296||t>56319&&t<=65535?(e=(this.data[t>>5]<<2)+(31&t),this.data[e]):t<=65535?(e=(this.data[2048+(t-55296>>5)]<<2)+(31&t),this.data[e]):t<this.highStart?(e=this.data[2080+(t>>11)],e=this.data[e+(t>>5&63)],e=(e<<2)+(31&t),this.data[e]):this.data[this.data.length-4]}},Ln={exports:{}};"undefined"!=typeof self?self:"undefined"!=typeof window&&window,Ln.exports=function(){var t="3.7.5",e=t,r="function"==typeof atob,n="function"==typeof btoa,i="function"==typeof Buffer,o="function"==typeof TextDecoder?new TextDecoder:void 0,s="function"==typeof TextEncoder?new TextEncoder:void 0,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",u=Array.prototype.slice.call(a),c=function(t){var e={};return t.forEach((function(t,r){return e[t]=r})),e}(u),f=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,h=String.fromCharCode.bind(String),l="function"==typeof Uint8Array.from?Uint8Array.from.bind(Uint8Array):function(t){return new Uint8Array(Array.prototype.slice.call(t,0))},d=function(t){return t.replace(/=/g,"").replace(/[+\/]/g,(function(t){return"+"==t?"-":"_"}))},p=function(t){return t.replace(/[^A-Za-z0-9\+\/]/g,"")},y=function(t){for(var e,r,n,i,o="",s=t.length%3,a=0;a<t.length;){if((r=t.charCodeAt(a++))>255||(n=t.charCodeAt(a++))>255||(i=t.charCodeAt(a++))>255)throw new TypeError("invalid character found");o+=u[(e=r<<16|n<<8|i)>>18&63]+u[e>>12&63]+u[e>>6&63]+u[63&e]}return s?o.slice(0,s-3)+"===".substring(s):o},g=n?function(t){return btoa(t)}:i?function(t){return Buffer.from(t,"binary").toString("base64")}:y,w=i?function(t){return Buffer.from(t).toString("base64")}:function(t){for(var e=4096,r=[],n=0,i=t.length;n<i;n+=e)r.push(h.apply(null,t.subarray(n,n+e)));return g(r.join(""))},m=function(t,e){return void 0===e&&(e=!1),e?d(w(t)):w(t)},b=function(t){if(t.length<2)return(e=t.charCodeAt(0))<128?t:e<2048?h(192|e>>>6)+h(128|63&e):h(224|e>>>12&15)+h(128|e>>>6&63)+h(128|63&e);var e=65536+1024*(t.charCodeAt(0)-55296)+(t.charCodeAt(1)-56320);return h(240|e>>>18&7)+h(128|e>>>12&63)+h(128|e>>>6&63)+h(128|63&e)},v=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,E=function(t){return t.replace(v,b)},x=i?function(t){return Buffer.from(t,"utf8").toString("base64")}:s?function(t){return w(s.encode(t))}:function(t){return g(E(t))},A=function(t,e){return void 0===e&&(e=!1),e?d(x(t)):x(t)},B=function(t){return A(t,!0)},S=/[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g,I=function(t){switch(t.length){case 4:var e=((7&t.charCodeAt(0))<<18|(63&t.charCodeAt(1))<<12|(63&t.charCodeAt(2))<<6|63&t.charCodeAt(3))-65536;return h(55296+(e>>>10))+h(56320+(1023&e));case 3:return h((15&t.charCodeAt(0))<<12|(63&t.charCodeAt(1))<<6|63&t.charCodeAt(2));default:return h((31&t.charCodeAt(0))<<6|63&t.charCodeAt(1))}},M=function(t){return t.replace(S,I)},R=function(t){if(t=t.replace(/\s+/g,""),!f.test(t))throw new TypeError("malformed base64.");t+="==".slice(2-(3&t.length));for(var e,r,n,i="",o=0;o<t.length;)e=c[t.charAt(o++)]<<18|c[t.charAt(o++)]<<12|(r=c[t.charAt(o++)])<<6|(n=c[t.charAt(o++)]),i+=64===r?h(e>>16&255):64===n?h(e>>16&255,e>>8&255):h(e>>16&255,e>>8&255,255&e);return i},k=r?function(t){return atob(p(t))}:i?function(t){return Buffer.from(t,"base64").toString("binary")}:R,_=i?function(t){return l(Buffer.from(t,"base64"))}:function(t){return l(k(t).split("").map((function(t){return t.charCodeAt(0)})))},P=function(t){return _(U(t))},T=i?function(t){return Buffer.from(t,"base64").toString("utf8")}:o?function(t){return o.decode(_(t))}:function(t){return M(k(t))},U=function(t){return p(t.replace(/[-_]/g,(function(t){return"-"==t?"+":"/"})))},L=function(t){return T(U(t))},O=function(t){if("string"!=typeof t)return!1;var e=t.replace(/\s+/g,"").replace(/={0,2}$/,"");return!/[^\s0-9a-zA-Z\+/]/.test(e)||!/[^\s0-9a-zA-Z\-_]/.test(e)},C=function(t){return{value:t,enumerable:!1,writable:!0,configurable:!0}},N=function(){var t=function(t,e){return Object.defineProperty(String.prototype,t,C(e))};t("fromBase64",(function(){return L(this)})),t("toBase64",(function(t){return A(this,t)})),t("toBase64URI",(function(){return A(this,!0)})),t("toBase64URL",(function(){return A(this,!0)})),t("toUint8Array",(function(){return P(this)}))},D=function(){var t=function(t,e){return Object.defineProperty(Uint8Array.prototype,t,C(e))};t("toBase64",(function(t){return m(this,t)})),t("toBase64URI",(function(){return m(this,!0)})),t("toBase64URL",(function(){return m(this,!0)}))},z=function(){N(),D()},V={version:t,VERSION:e,atob:k,atobPolyfill:R,btoa:g,btoaPolyfill:y,fromBase64:L,toBase64:A,encode:A,encodeURI:B,encodeURL:B,utob:E,btou:M,decode:L,isValid:O,fromUint8Array:m,toUint8Array:P,extendString:N,extendUint8Array:D,extendBuiltins:z,Base64:{}};return Object.keys(V).forEach((function(t){return V.Base64[t]=V[t]})),V}();const On={Other:0,CR:1,LF:2,Control:4,Extend:8,ZWJ:16,Regional_Indicator:32,Prepend:64,SpacingMark:128,L:256,V:512,T:1024,LV:2048,LVT:4096,Extended_Pictographic:8192},Cn=rn,Nn=nn,Dn=Un,zn=Ln.exports.Base64,Vn=new Dn(zn.toUint8Array(Cn)),Wn=new Dn(zn.toUint8Array(Nn));function Fn(t,e){return 0!=(t&e)}const jn=0,Kn=1,Hn=2;function Gn(t,e){const r=t.length;let n=0,i=jn;for(let o=e;o+1<r;o++){const r=t[o+0],s=t[o+1];switch(Fn(r,On.Regional_Indicator)||(n=0),i){case Hn:case jn:i=Fn(r,On.Extended_Pictographic)?Kn:jn;break;case Kn:i=Fn(r,On.Extend)?Kn:Fn(r,On.ZWJ)&&Fn(s,On.Extended_Pictographic)?Hn:jn}if(!Fn(r,On.CR)||!Fn(s,On.LF)){if(Fn(r,On.Control|On.CR|On.LF))return o+1-e;if(Fn(s,On.Control|On.CR|On.LF))return o+1-e;if(!(Fn(r,On.L)&&Fn(s,On.L|On.V|On.LV|On.LVT)||Fn(r,On.LV|On.V)&&Fn(s,On.V|On.T)||Fn(r,On.LVT|On.T)&&Fn(s,On.T)||Fn(s,On.Extend|On.ZWJ)||Fn(s,On.SpacingMark)||Fn(r,On.Prepend)||i===Hn)){if(!Fn(r,On.Regional_Indicator)||!Fn(s,On.Regional_Indicator)||n%2!=0)return o+1-e;n++}}}return r-e}var qn=function(t){const e=[],r=[0],n=[];for(let e=0;e<t.length;){const i=t.codePointAt(e);n.push(Vn.get(i)|Wn.get(i)),e+=i>65535?2:1,r.push(e)}for(let i=0;i<n.length;){const o=Gn(n,i),s=r[i],a=r[i+o];e.push(t.slice(s,a)),i+=o}return e},Zn=r(qn);const $n=t=>{const e=nr+t,r=er(i.Buffer.from(e,"utf8"));return i.Buffer.from(r)},Yn=(e,r,n)=>{const o=[e];r?o.push(r.toBuffer()):o.push(i.Buffer.alloc(32)),n?o.push(n.toBuffer()):o.push(i.Buffer.alloc(32));const[s]=t.PublicKey.findProgramAddressSync(o,rr);return s};async function Xn(t,e){const r=$n(e.toBase58()),n=Yn(r,ur),{registry:i}=await Ne.retrieve(t,n);if(!i.data)throw new _t(exports.ErrorType.NoAccountData);return oi(i.data)}async function Qn(t,e){let r=[];for(let t of e){const e=$n(t.toBase58()),n=Yn(e,ur);r.push(n)}return(await Ne.retrieveBatch(t,r)).map((t=>{if(void 0!==t&&void 0!==t.data)return oi(t.data)}))}const Jn=(t,e=ir,r)=>{let n=$n(t);return{pubkey:Yn(n,r,e),hashed:n}},ti=(t,e)=>{t.endsWith(".sol")&&(t=t.slice(0,-4));const r=e===exports.RecordVersion.V2?qr:void 0,n=t.split(".");if(2===n.length){const t=i.Buffer.from([e||0]).toString().concat(n[0]),{pubkey:o}=Jn(n[1]);return{...Jn(t,o,r),isSub:!0,parent:o}}if(3===n.length&&e){const{pubkey:t}=Jn(n[2]),{pubkey:i}=Jn("\0".concat(n[1]),t),o=e===exports.RecordVersion.V2?"":"";return{...Jn(o.concat(n[0]),i,r),isSub:!0,parent:t,isSubRecord:!0}}if(n.length>=3)throw new _t(exports.ErrorType.InvalidInput);return{...Jn(t,ir),isSub:!1,parent:void 0}};async function ei(t,e){const r=[{memcmp:{offset:32,bytes:e.toBase58()}},{memcmp:{offset:0,bytes:ir.toBase58()}}];return(await t.getProgramAccounts(rr,{filters:r})).map((t=>t.pubkey))}const ri=(t,e)=>{const{pubkey:r,parent:n}=ti(t),i=$n(r.toBase58());return Yn(i,ur,e?n:void 0)},ni=(t,e)=>{const r=$n(t.toBase58());return Yn(r,ur,e)},ii=(t,e)=>{if(!t)throw new _t(e)};function oi(t){if(!t)return;const e=t.slice(0,4).readUInt32LE(0);return t.slice(4,4+e).toString()}var si=function(t){if(t.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),r=0;r<e.length;r++)e[r]=255;for(var n=0;n<t.length;n++){var i=t.charAt(n),o=i.charCodeAt(0);if(255!==e[o])throw new TypeError(i+" is ambiguous");e[o]=n}var s=t.length,a=t.charAt(0),u=Math.log(s)/Math.log(256),c=Math.log(256)/Math.log(s);function f(t){if("string"!=typeof t)throw new TypeError("Expected String");if(0===t.length)return new Uint8Array;for(var r=0,n=0,i=0;t[r]===a;)n++,r++;for(var o=(t.length-r)*u+1>>>0,c=new Uint8Array(o);t[r];){var f=e[t.charCodeAt(r)];if(255===f)return;for(var h=0,l=o-1;(0!==f||h<i)&&-1!==l;l--,h++)f+=s*c[l]>>>0,c[l]=f%256>>>0,f=f/256>>>0;if(0!==f)throw new Error("Non-zero carry");i=h,r++}for(var d=o-i;d!==o&&0===c[d];)d++;for(var p=new Uint8Array(n+(o-d)),y=n;d!==o;)p[y++]=c[d++];return p}return{encode:function(e){if(e instanceof Uint8Array||(ArrayBuffer.isView(e)?e=new Uint8Array(e.buffer,e.byteOffset,e.byteLength):Array.isArray(e)&&(e=Uint8Array.from(e))),!(e instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===e.length)return"";for(var r=0,n=0,i=0,o=e.length;i!==o&&0===e[i];)i++,r++;for(var u=(o-i)*c+1>>>0,f=new Uint8Array(u);i!==o;){for(var h=e[i],l=0,d=u-1;(0!==h||l<n)&&-1!==d;d--,l++)h+=256*f[d]>>>0,f[d]=h%s>>>0,h=h/s>>>0;if(0!==h)throw new Error("Non-zero carry");n=l,i++}for(var p=u-n;p!==u&&0===f[p];)p++;for(var y=a.repeat(r);p<u;++p)y+=t.charAt(f[p]);return y},decodeUnsafe:f,decode:function(t){var e=f(t);if(e)return e;throw new Error("Non-base"+s+" character")}}};var ai,ui=r(si("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")),ci={exports:{}};ai=ci,function(t){const e="(0?\\d+|0x[a-f0-9]+)",r={fourOctet:new RegExp(`^${e}\\.${e}\\.${e}\\.${e}$`,"i"),threeOctet:new RegExp(`^${e}\\.${e}\\.${e}$`,"i"),twoOctet:new RegExp(`^${e}\\.${e}$`,"i"),longValue:new RegExp(`^${e}$`,"i")},n=new RegExp("^0[0-7]+$","i"),i=new RegExp("^0x[a-f0-9]+$","i"),o="%[0-9a-z]{1,}",s="(?:[0-9a-f]+::?)+",a={zoneIndex:new RegExp(o,"i"),native:new RegExp(`^(::)?(${s})?([0-9a-f]+)?(::)?(${o})?$`,"i"),deprecatedTransitional:new RegExp(`^(?:::)(${e}\\.${e}\\.${e}\\.${e}(${o})?)$`,"i"),transitional:new RegExp(`^((?:${s})|(?:::)(?:${s})?)${e}\\.${e}\\.${e}\\.${e}(${o})?$`,"i")};function u(t,e){if(t.indexOf("::")!==t.lastIndexOf("::"))return null;let r,n,i=0,o=-1,s=(t.match(a.zoneIndex)||[])[0];for(s&&(s=s.substring(1),t=t.replace(/%.+$/,""));(o=t.indexOf(":",o+1))>=0;)i++;if("::"===t.substr(0,2)&&i--,"::"===t.substr(-2,2)&&i--,i>e)return null;for(n=e-i,r=":";n--;)r+="0:";return":"===(t=t.replace("::",r))[0]&&(t=t.slice(1)),":"===t[t.length-1]&&(t=t.slice(0,-1)),e=function(){const e=t.split(":"),r=[];for(let t=0;t<e.length;t++)r.push(parseInt(e[t],16));return r}(),{parts:e,zoneId:s}}function c(t,e,r,n){if(t.length!==e.length)throw new Error("ipaddr: cannot match CIDR for objects with different lengths");let i,o=0;for(;n>0;){if(i=r-n,i<0&&(i=0),t[o]>>i!=e[o]>>i)return!1;n-=r,o+=1}return!0}function f(t){if(i.test(t))return parseInt(t,16);if("0"===t[0]&&!isNaN(parseInt(t[1],10))){if(n.test(t))return parseInt(t,8);throw new Error(`ipaddr: cannot parse ${t} as octal`)}return parseInt(t,10)}function h(t,e){for(;t.length<e;)t=`0${t}`;return t}const l={};l.IPv4=function(){function t(t){if(4!==t.length)throw new Error("ipaddr: ipv4 octet count should be 4");let e,r;for(e=0;e<t.length;e++)if(r=t[e],!(0<=r&&r<=255))throw new Error("ipaddr: ipv4 octet should fit in 8 bits");this.octets=t}return t.prototype.SpecialRanges={unspecified:[[new t([0,0,0,0]),8]],broadcast:[[new t([255,255,255,255]),32]],multicast:[[new t([224,0,0,0]),4]],linkLocal:[[new t([169,254,0,0]),16]],loopback:[[new t([127,0,0,0]),8]],carrierGradeNat:[[new t([100,64,0,0]),10]],private:[[new t([10,0,0,0]),8],[new t([172,16,0,0]),12],[new t([192,168,0,0]),16]],reserved:[[new t([192,0,0,0]),24],[new t([192,0,2,0]),24],[new t([192,88,99,0]),24],[new t([198,18,0,0]),15],[new t([198,51,100,0]),24],[new t([203,0,113,0]),24],[new t([240,0,0,0]),4]]},t.prototype.kind=function(){return"ipv4"},t.prototype.match=function(t,e){let r;if(void 0===e&&(r=t,t=r[0],e=r[1]),"ipv4"!==t.kind())throw new Error("ipaddr: cannot match ipv4 address with non-ipv4 one");return c(this.octets,t.octets,8,e)},t.prototype.prefixLengthFromSubnetMask=function(){let t=0,e=!1;const r={0:8,128:7,192:6,224:5,240:4,248:3,252:2,254:1,255:0};let n,i,o;for(n=3;n>=0;n-=1){if(i=this.octets[n],!(i in r))return null;if(o=r[i],e&&0!==o)return null;8!==o&&(e=!0),t+=o}return 32-t},t.prototype.range=function(){return l.subnetMatch(this,this.SpecialRanges)},t.prototype.toByteArray=function(){return this.octets.slice(0)},t.prototype.toIPv4MappedAddress=function(){return l.IPv6.parse(`::ffff:${this.toString()}`)},t.prototype.toNormalizedString=function(){return this.toString()},t.prototype.toString=function(){return this.octets.join(".")},t}(),l.IPv4.broadcastAddressFromCIDR=function(t){try{const e=this.parseCIDR(t),r=e[0].toByteArray(),n=this.subnetMaskFromPrefixLength(e[1]).toByteArray(),i=[];let o=0;for(;o<4;)i.push(parseInt(r[o],10)|255^parseInt(n[o],10)),o++;return new this(i)}catch(t){throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},l.IPv4.isIPv4=function(t){return null!==this.parser(t)},l.IPv4.isValid=function(t){try{return new this(this.parser(t)),!0}catch(t){return!1}},l.IPv4.isValidFourPartDecimal=function(t){return!(!l.IPv4.isValid(t)||!t.match(/^(0|[1-9]\d*)(\.(0|[1-9]\d*)){3}$/))},l.IPv4.networkAddressFromCIDR=function(t){let e,r,n,i,o;try{for(e=this.parseCIDR(t),n=e[0].toByteArray(),o=this.subnetMaskFromPrefixLength(e[1]).toByteArray(),i=[],r=0;r<4;)i.push(parseInt(n[r],10)&parseInt(o[r],10)),r++;return new this(i)}catch(t){throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},l.IPv4.parse=function(t){const e=this.parser(t);if(null===e)throw new Error("ipaddr: string is not formatted like an IPv4 Address");return new this(e)},l.IPv4.parseCIDR=function(t){let e;if(e=t.match(/^(.+)\/(\d+)$/)){const t=parseInt(e[2]);if(t>=0&&t<=32){const r=[this.parse(e[1]),t];return Object.defineProperty(r,"toString",{value:function(){return this.join("/")}}),r}}throw new Error("ipaddr: string is not formatted like an IPv4 CIDR range")},l.IPv4.parser=function(t){let e,n,i;if(e=t.match(r.fourOctet))return function(){const t=e.slice(1,6),r=[];for(let e=0;e<t.length;e++)n=t[e],r.push(f(n));return r}();if(e=t.match(r.longValue)){if(i=f(e[1]),i>4294967295||i<0)throw new Error("ipaddr: address outside defined range");return function(){const t=[];let e;for(e=0;e<=24;e+=8)t.push(i>>e&255);return t}().reverse()}return(e=t.match(r.twoOctet))?function(){const t=e.slice(1,4),r=[];if(i=f(t[1]),i>16777215||i<0)throw new Error("ipaddr: address outside defined range");return r.push(f(t[0])),r.push(i>>16&255),r.push(i>>8&255),r.push(255&i),r}():(e=t.match(r.threeOctet))?function(){const t=e.slice(1,5),r=[];if(i=f(t[2]),i>65535||i<0)throw new Error("ipaddr: address outside defined range");return r.push(f(t[0])),r.push(f(t[1])),r.push(i>>8&255),r.push(255&i),r}():null},l.IPv4.subnetMaskFromPrefixLength=function(t){if((t=parseInt(t))<0||t>32)throw new Error("ipaddr: invalid IPv4 prefix length");const e=[0,0,0,0];let r=0;const n=Math.floor(t/8);for(;r<n;)e[r]=255,r++;return n<4&&(e[n]=Math.pow(2,t%8)-1<<8-t%8),new this(e)},l.IPv6=function(){function t(t,e){let r,n;if(16===t.length)for(this.parts=[],r=0;r<=14;r+=2)this.parts.push(t[r]<<8|t[r+1]);else{if(8!==t.length)throw new Error("ipaddr: ipv6 part count should be 8 or 16");this.parts=t}for(r=0;r<this.parts.length;r++)if(n=this.parts[r],!(0<=n&&n<=65535))throw new Error("ipaddr: ipv6 part should fit in 16 bits");e&&(this.zoneId=e)}return t.prototype.SpecialRanges={unspecified:[new t([0,0,0,0,0,0,0,0]),128],linkLocal:[new t([65152,0,0,0,0,0,0,0]),10],multicast:[new t([65280,0,0,0,0,0,0,0]),8],loopback:[new t([0,0,0,0,0,0,0,1]),128],uniqueLocal:[new t([64512,0,0,0,0,0,0,0]),7],ipv4Mapped:[new t([0,0,0,0,0,65535,0,0]),96],rfc6145:[new t([0,0,0,0,65535,0,0,0]),96],rfc6052:[new t([100,65435,0,0,0,0,0,0]),96],"6to4":[new t([8194,0,0,0,0,0,0,0]),16],teredo:[new t([8193,0,0,0,0,0,0,0]),32],reserved:[[new t([8193,3512,0,0,0,0,0,0]),32]],benchmarking:[new t([8193,2,0,0,0,0,0,0]),48],amt:[new t([8193,3,0,0,0,0,0,0]),32],as112v6:[new t([8193,4,274,0,0,0,0,0]),48],deprecated:[new t([8193,16,0,0,0,0,0,0]),28],orchid2:[new t([8193,32,0,0,0,0,0,0]),28]},t.prototype.isIPv4MappedAddress=function(){return"ipv4Mapped"===this.range()},t.prototype.kind=function(){return"ipv6"},t.prototype.match=function(t,e){let r;if(void 0===e&&(r=t,t=r[0],e=r[1]),"ipv6"!==t.kind())throw new Error("ipaddr: cannot match ipv6 address with non-ipv6 one");return c(this.parts,t.parts,16,e)},t.prototype.prefixLengthFromSubnetMask=function(){let t=0,e=!1;const r={0:16,32768:15,49152:14,57344:13,61440:12,63488:11,64512:10,65024:9,65280:8,65408:7,65472:6,65504:5,65520:4,65528:3,65532:2,65534:1,65535:0};let n,i;for(let o=7;o>=0;o-=1){if(n=this.parts[o],!(n in r))return null;if(i=r[n],e&&0!==i)return null;16!==i&&(e=!0),t+=i}return 128-t},t.prototype.range=function(){return l.subnetMatch(this,this.SpecialRanges)},t.prototype.toByteArray=function(){let t;const e=[],r=this.parts;for(let n=0;n<r.length;n++)t=r[n],e.push(t>>8),e.push(255&t);return e},t.prototype.toFixedLengthString=function(){const t=function(){const t=[];for(let e=0;e<this.parts.length;e++)t.push(h(this.parts[e].toString(16),4));return t}.call(this).join(":");let e="";return this.zoneId&&(e=`%${this.zoneId}`),t+e},t.prototype.toIPv4Address=function(){if(!this.isIPv4MappedAddress())throw new Error("ipaddr: trying to convert a generic ipv6 address to ipv4");const t=this.parts.slice(-2),e=t[0],r=t[1];return new l.IPv4([e>>8,255&e,r>>8,255&r])},t.prototype.toNormalizedString=function(){const t=function(){const t=[];for(let e=0;e<this.parts.length;e++)t.push(this.parts[e].toString(16));return t}.call(this).join(":");let e="";return this.zoneId&&(e=`%${this.zoneId}`),t+e},t.prototype.toRFC5952String=function(){const t=/((^|:)(0(:|$)){2,})/g,e=this.toNormalizedString();let r,n=0,i=-1;for(;r=t.exec(e);)r[0].length>i&&(n=r.index,i=r[0].length);return i<0?e:`${e.substring(0,n)}::${e.substring(n+i)}`},t.prototype.toString=function(){return this.toRFC5952String()},t}(),l.IPv6.broadcastAddressFromCIDR=function(t){try{const e=this.parseCIDR(t),r=e[0].toByteArray(),n=this.subnetMaskFromPrefixLength(e[1]).toByteArray(),i=[];let o=0;for(;o<16;)i.push(parseInt(r[o],10)|255^parseInt(n[o],10)),o++;return new this(i)}catch(t){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${t})`)}},l.IPv6.isIPv6=function(t){return null!==this.parser(t)},l.IPv6.isValid=function(t){if("string"==typeof t&&-1===t.indexOf(":"))return!1;try{const e=this.parser(t);return new this(e.parts,e.zoneId),!0}catch(t){return!1}},l.IPv6.networkAddressFromCIDR=function(t){let e,r,n,i,o;try{for(e=this.parseCIDR(t),n=e[0].toByteArray(),o=this.subnetMaskFromPrefixLength(e[1]).toByteArray(),i=[],r=0;r<16;)i.push(parseInt(n[r],10)&parseInt(o[r],10)),r++;return new this(i)}catch(t){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${t})`)}},l.IPv6.parse=function(t){const e=this.parser(t);if(null===e.parts)throw new Error("ipaddr: string is not formatted like an IPv6 Address");return new this(e.parts,e.zoneId)},l.IPv6.parseCIDR=function(t){let e,r,n;if((r=t.match(/^(.+)\/(\d+)$/))&&(e=parseInt(r[2]),e>=0&&e<=128))return n=[this.parse(r[1]),e],Object.defineProperty(n,"toString",{value:function(){return this.join("/")}}),n;throw new Error("ipaddr: string is not formatted like an IPv6 CIDR range")},l.IPv6.parser=function(t){let e,r,n,i,o,s;if(n=t.match(a.deprecatedTransitional))return this.parser(`::ffff:${n[1]}`);if(a.native.test(t))return u(t,8);if((n=t.match(a.transitional))&&(s=n[6]||"",e=u(n[1].slice(0,-1)+s,6),e.parts)){for(o=[parseInt(n[2]),parseInt(n[3]),parseInt(n[4]),parseInt(n[5])],r=0;r<o.length;r++)if(i=o[r],!(0<=i&&i<=255))return null;return e.parts.push(o[0]<<8|o[1]),e.parts.push(o[2]<<8|o[3]),{parts:e.parts,zoneId:e.zoneId}}return null},l.IPv6.subnetMaskFromPrefixLength=function(t){if((t=parseInt(t))<0||t>128)throw new Error("ipaddr: invalid IPv6 prefix length");const e=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];let r=0;const n=Math.floor(t/8);for(;r<n;)e[r]=255,r++;return n<16&&(e[n]=Math.pow(2,t%8)-1<<8-t%8),new this(e)},l.fromByteArray=function(t){const e=t.length;if(4===e)return new l.IPv4(t);if(16===e)return new l.IPv6(t);throw new Error("ipaddr: the binary input is neither an IPv6 nor IPv4 address")},l.isValid=function(t){return l.IPv6.isValid(t)||l.IPv4.isValid(t)},l.parse=function(t){if(l.IPv6.isValid(t))return l.IPv6.parse(t);if(l.IPv4.isValid(t))return l.IPv4.parse(t);throw new Error("ipaddr: the address has neither IPv6 nor IPv4 format")},l.parseCIDR=function(t){try{return l.IPv6.parseCIDR(t)}catch(e){try{return l.IPv4.parseCIDR(t)}catch(t){throw new Error("ipaddr: the address has neither IPv6 nor IPv4 CIDR format")}}},l.process=function(t){const e=this.parse(t);return"ipv6"===e.kind()&&e.isIPv4MappedAddress()?e.toIPv4Address():e},l.subnetMatch=function(t,e,r){let n,i,o,s;for(i in null==r&&(r="unicast"),e)if(Object.prototype.hasOwnProperty.call(e,i))for(o=e[i],!o[0]||o[0]instanceof Array||(o=[o]),n=0;n<o.length;n++)if(s=o[n],t.kind()===s[0].kind()&&t.match.apply(t,s))return i;return r},ai.exports?ai.exports=l:t.ipaddr=l}(e);var fi=ci.exports;const hi=2147483647,li=36,di={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},pi=Math.floor,yi=String.fromCharCode;function gi(t){throw new RangeError(di[t])}const wi=function(t,e){return t+22+75*(t<26)-((0!=e)<<5)},mi=function(t,e,r){let n=0;for(t=r?pi(t/700):t>>1,t+=pi(t/e);t>455;n+=li)t=pi(t/35);return pi(n+36*t/(t+38))},bi=function(t){const e=[];t=function(t){const e=[];let r=0;const n=t.length;for(;r<n;){const i=t.charCodeAt(r++);if(i>=55296&&i<=56319&&r<n){const n=t.charCodeAt(r++);56320==(64512&n)?e.push(((1023&i)<<10)+(1023&n)+65536):(e.push(i),r--)}else e.push(i)}return e}(t);const r=t.length;let n=128,i=0,o=72;for(const r of t)r<128&&e.push(yi(r));const s=e.length;let a=s;for(s&&e.push("-");a<r;){let r=hi;for(const e of t)e>=n&&e<r&&(r=e);const u=a+1;r-n>pi((hi-i)/u)&&gi("overflow"),i+=(r-n)*u,n=r;for(const r of t)if(r<n&&++i>hi&&gi("overflow"),r===n){let t=i;for(let r=li;;r+=li){const n=r<=o?1:r>=o+26?26:r-o;if(t<n)break;const i=t-n,s=li-n;e.push(yi(wi(n+i%s,0))),t=pi(i/s)}e.push(yi(wi(t,0))),o=mi(i,u,a===s),i=0,++a}++i,++n}return e.join("")},vi=BigInt(2**32-1),Ei=BigInt(32);function xi(t,e=!1){return e?{h:Number(t&vi),l:Number(t>>Ei&vi)}:{h:0|Number(t>>Ei&vi),l:0|Number(t&vi)}}const Ai={fromBig:xi,split:function(t,e=!1){let r=new Uint32Array(t.length),n=new Uint32Array(t.length);for(let i=0;i<t.length;i++){const{h:o,l:s}=xi(t[i],e);[r[i],n[i]]=[o,s]}return[r,n]},toBig:(t,e)=>BigInt(t>>>0)<<Ei|BigInt(e>>>0),shrSH:(t,e,r)=>t>>>r,shrSL:(t,e,r)=>t<<32-r|e>>>r,rotrSH:(t,e,r)=>t>>>r|e<<32-r,rotrSL:(t,e,r)=>t<<32-r|e>>>r,rotrBH:(t,e,r)=>t<<64-r|e>>>r-32,rotrBL:(t,e,r)=>t>>>r-32|e<<64-r,rotr32H:(t,e)=>e,rotr32L:(t,e)=>t,rotlSH:(t,e,r)=>t<<r|e>>>32-r,rotlSL:(t,e,r)=>e<<r|t>>>32-r,rotlBH:(t,e,r)=>e<<r-32|t>>>64-r,rotlBL:(t,e,r)=>t<<r-32|e>>>64-r,add:function(t,e,r,n){const i=(e>>>0)+(n>>>0);return{h:t+r+(i/2**32|0)|0,l:0|i}},add3L:(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0),add3H:(t,e,r,n)=>e+r+n+(t/2**32|0)|0,add4L:(t,e,r,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0),add4H:(t,e,r,n,i)=>e+r+n+i+(t/2**32|0)|0,add5H:(t,e,r,n,i,o)=>e+r+n+i+o+(t/2**32|0)|0,add5L:(t,e,r,n,i)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(i>>>0)};var Bi=Ai;const[Si,Ii]=(()=>Bi.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map((t=>BigInt(t)))))(),Mi=new Uint32Array(80),Ri=new Uint32Array(80);class ki extends Ze{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){const{Ah:t,Al:e,Bh:r,Bl:n,Ch:i,Cl:o,Dh:s,Dl:a,Eh:u,El:c,Fh:f,Fl:h,Gh:l,Gl:d,Hh:p,Hl:y}=this;return[t,e,r,n,i,o,s,a,u,c,f,h,l,d,p,y]}set(t,e,r,n,i,o,s,a,u,c,f,h,l,d,p,y){this.Ah=0|t,this.Al=0|e,this.Bh=0|r,this.Bl=0|n,this.Ch=0|i,this.Cl=0|o,this.Dh=0|s,this.Dl=0|a,this.Eh=0|u,this.El=0|c,this.Fh=0|f,this.Fl=0|h,this.Gh=0|l,this.Gl=0|d,this.Hh=0|p,this.Hl=0|y}process(t,e){for(let r=0;r<16;r++,e+=4)Mi[r]=t.getUint32(e),Ri[r]=t.getUint32(e+=4);for(let t=16;t<80;t++){const e=0|Mi[t-15],r=0|Ri[t-15],n=Bi.rotrSH(e,r,1)^Bi.rotrSH(e,r,8)^Bi.shrSH(e,r,7),i=Bi.rotrSL(e,r,1)^Bi.rotrSL(e,r,8)^Bi.shrSL(e,r,7),o=0|Mi[t-2],s=0|Ri[t-2],a=Bi.rotrSH(o,s,19)^Bi.rotrBH(o,s,61)^Bi.shrSH(o,s,6),u=Bi.rotrSL(o,s,19)^Bi.rotrBL(o,s,61)^Bi.shrSL(o,s,6),c=Bi.add4L(i,u,Ri[t-7],Ri[t-16]),f=Bi.add4H(c,n,a,Mi[t-7],Mi[t-16]);Mi[t]=0|f,Ri[t]=0|c}let{Ah:r,Al:n,Bh:i,Bl:o,Ch:s,Cl:a,Dh:u,Dl:c,Eh:f,El:h,Fh:l,Fl:d,Gh:p,Gl:y,Hh:g,Hl:w}=this;for(let t=0;t<80;t++){const e=Bi.rotrSH(f,h,14)^Bi.rotrSH(f,h,18)^Bi.rotrBH(f,h,41),m=Bi.rotrSL(f,h,14)^Bi.rotrSL(f,h,18)^Bi.rotrBL(f,h,41),b=f&l^~f&p,v=h&d^~h&y,E=Bi.add5L(w,m,v,Ii[t],Ri[t]),x=Bi.add5H(E,g,e,b,Si[t],Mi[t]),A=0|E,B=Bi.rotrSH(r,n,28)^Bi.rotrBH(r,n,34)^Bi.rotrBH(r,n,39),S=Bi.rotrSL(r,n,28)^Bi.rotrBL(r,n,34)^Bi.rotrBL(r,n,39),I=r&i^r&s^i&s,M=n&o^n&a^o&a;g=0|p,w=0|y,p=0|l,y=0|d,l=0|f,d=0|h,({h:f,l:h}=Bi.add(0|u,0|c,0|x,0|A)),u=0|s,c=0|a,s=0|i,a=0|o,i=0|r,o=0|n;const R=Bi.add3L(A,S,M);r=Bi.add3H(R,x,B,I),n=0|R}({h:r,l:n}=Bi.add(0|this.Ah,0|this.Al,0|r,0|n)),({h:i,l:o}=Bi.add(0|this.Bh,0|this.Bl,0|i,0|o)),({h:s,l:a}=Bi.add(0|this.Ch,0|this.Cl,0|s,0|a)),({h:u,l:c}=Bi.add(0|this.Dh,0|this.Dl,0|u,0|c)),({h:f,l:h}=Bi.add(0|this.Eh,0|this.El,0|f,0|h)),({h:l,l:d}=Bi.add(0|this.Fh,0|this.Fl,0|l,0|d)),({h:p,l:y}=Bi.add(0|this.Gh,0|this.Gl,0|p,0|y)),({h:g,l:w}=Bi.add(0|this.Hh,0|this.Hl,0|g,0|w)),this.set(r,n,i,o,s,a,u,c,f,h,l,d,p,y,g,w)}roundClean(){Mi.fill(0),Ri.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const _i=qe((()=>new ki));
|
|
12
|
-
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */BigInt(0);const
|
|
13
|
-
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const
|
|
10
|
+
!function(t){const e=o,r=d,n="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;t.Buffer=a,t.SlowBuffer=function(t){+t!=t&&(t=0);return a.alloc(+t)},t.INSPECT_MAX_BYTES=50;const i=2147483647;function s(t){if(t>i)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,a.prototype),e}function a(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return f(t)}return c(t,e,r)}function c(t,e,r){if("string"==typeof t)return function(t,e){"string"==typeof e&&""!==e||(e="utf8");if(!a.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const r=0|y(t,e);let n=s(r);const o=n.write(t,e);o!==r&&(n=n.slice(0,o));return n}(t,e);if(ArrayBuffer.isView(t))return function(t){if($(t,Uint8Array)){const e=new Uint8Array(t);return p(e.buffer,e.byteOffset,e.byteLength)}return h(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if($(t,ArrayBuffer)||t&&$(t.buffer,ArrayBuffer))return p(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&($(t,SharedArrayBuffer)||t&&$(t.buffer,SharedArrayBuffer)))return p(t,e,r);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return a.from(n,e,r);const o=function(t){if(a.isBuffer(t)){const e=0|l(t.length),r=s(e);return 0===r.length||t.copy(r,0,0,e),r}if(void 0!==t.length)return"number"!=typeof t.length||Z(t.length)?s(0):h(t);if("Buffer"===t.type&&Array.isArray(t.data))return h(t.data)}(t);if(o)return o;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return a.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function u(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function f(t){return u(t),s(t<0?0:0|l(t))}function h(t){const e=t.length<0?0:0|l(t.length),r=s(e);for(let n=0;n<e;n+=1)r[n]=255&t[n];return r}function p(t,e,r){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(r||0))throw new RangeError('"length" is outside of buffer bounds');let n;return n=void 0===e&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,e):new Uint8Array(t,e,r),Object.setPrototypeOf(n,a.prototype),n}function l(t){if(t>=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return 0|t}function y(t,e){if(a.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||$(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;let o=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return G(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return q(t).length;default:if(o)return n?-1:G(t).length;e=(""+e).toLowerCase(),o=!0}}function g(t,e,r){let n=!1;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 T(this,e,r);case"utf8":case"utf-8":return B(this,e,r);case"ascii":return P(this,e,r);case"latin1":case"binary":return k(this,e,r);case"base64":return S(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return _(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function w(t,e,r){const n=t[e];t[e]=t[r],t[r]=n}function b(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),Z(r=+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=a.from(e,n)),a.isBuffer(e))return 0===e.length?-1:m(t,e,r,n,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):m(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function m(t,e,r,n,o){let i,s=1,a=t.length,c=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,c/=2,r/=2}function u(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(o){let n=-1;for(i=r;i<a;i++)if(u(t,i)===u(e,-1===n?0:i-n)){if(-1===n&&(n=i),i-n+1===c)return n*s}else-1!==n&&(i-=i-n),n=-1}else for(r+c>a&&(r=a-c),i=r;i>=0;i--){let r=!0;for(let n=0;n<c;n++)if(u(t,i+n)!==u(e,n)){r=!1;break}if(r)return i}return-1}function v(t,e,r,n){r=Number(r)||0;const o=t.length-r;n?(n=Number(n))>o&&(n=o):n=o;const i=e.length;let s;for(n>i/2&&(n=i/2),s=0;s<n;++s){const n=parseInt(e.substr(2*s,2),16);if(Z(n))return s;t[r+s]=n}return s}function E(t,e,r,n){return Y(G(e,t.length-r),t,r,n)}function x(t,e,r,n){return Y(function(t){const e=[];for(let r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,n)}function A(t,e,r,n){return Y(q(e),t,r,n)}function I(t,e,r,n){return Y(function(t,e){let r,n,o;const i=[];for(let s=0;s<t.length&&!((e-=2)<0);++s)r=t.charCodeAt(s),n=r>>8,o=r%256,i.push(o),i.push(n);return i}(e,t.length-r),t,r,n)}function S(t,r,n){return 0===r&&n===t.length?e.fromByteArray(t):e.fromByteArray(t.slice(r,n))}function B(t,e,r){r=Math.min(t.length,r);const n=[];let o=e;for(;o<r;){const e=t[o];let i=null,s=e>239?4:e>223?3:e>191?2:1;if(o+s<=r){let r,n,a,c;switch(s){case 1:e<128&&(i=e);break;case 2:r=t[o+1],128==(192&r)&&(c=(31&e)<<6|63&r,c>127&&(i=c));break;case 3:r=t[o+1],n=t[o+2],128==(192&r)&&128==(192&n)&&(c=(15&e)<<12|(63&r)<<6|63&n,c>2047&&(c<55296||c>57343)&&(i=c));break;case 4:r=t[o+1],n=t[o+2],a=t[o+3],128==(192&r)&&128==(192&n)&&128==(192&a)&&(c=(15&e)<<18|(63&r)<<12|(63&n)<<6|63&a,c>65535&&c<1114112&&(i=c))}}null===i?(i=65533,s=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|1023&i),n.push(i),o+=s}return function(t){const e=t.length;if(e<=R)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=R));return r}(n)}t.kMaxLength=i,a.TYPED_ARRAY_SUPPORT=function(){try{const t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),42===t.foo()}catch(t){return!1}}(),a.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(a.prototype,"parent",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.buffer}}),Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.byteOffset}}),a.poolSize=8192,a.from=function(t,e,r){return c(t,e,r)},Object.setPrototypeOf(a.prototype,Uint8Array.prototype),Object.setPrototypeOf(a,Uint8Array),a.alloc=function(t,e,r){return function(t,e,r){return u(t),t<=0?s(t):void 0!==e?"string"==typeof r?s(t).fill(e,r):s(t).fill(e):s(t)}(t,e,r)},a.allocUnsafe=function(t){return f(t)},a.allocUnsafeSlow=function(t){return f(t)},a.isBuffer=function(t){return null!=t&&!0===t._isBuffer&&t!==a.prototype},a.compare=function(t,e){if($(t,Uint8Array)&&(t=a.from(t,t.offset,t.byteLength)),$(e,Uint8Array)&&(e=a.from(e,e.offset,e.byteLength)),!a.isBuffer(t)||!a.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;let r=t.length,n=e.length;for(let 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},a.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!0;default:return!1}},a.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return a.alloc(0);let r;if(void 0===e)for(e=0,r=0;r<t.length;++r)e+=t[r].length;const n=a.allocUnsafe(e);let o=0;for(r=0;r<t.length;++r){let e=t[r];if($(e,Uint8Array))o+e.length>n.length?(a.isBuffer(e)||(e=a.from(e)),e.copy(n,o)):Uint8Array.prototype.set.call(n,e,o);else{if(!a.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(n,o)}o+=e.length}return n},a.byteLength=y,a.prototype._isBuffer=!0,a.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;e<t;e+=2)w(this,e,e+1);return this},a.prototype.swap32=function(){const t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let e=0;e<t;e+=4)w(this,e,e+3),w(this,e+1,e+2);return this},a.prototype.swap64=function(){const t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let e=0;e<t;e+=8)w(this,e,e+7),w(this,e+1,e+6),w(this,e+2,e+5),w(this,e+3,e+4);return this},a.prototype.toString=function(){const t=this.length;return 0===t?"":0===arguments.length?B(this,0,t):g.apply(this,arguments)},a.prototype.toLocaleString=a.prototype.toString,a.prototype.equals=function(t){if(!a.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===a.compare(this,t)},a.prototype.inspect=function(){let e="";const r=t.INSPECT_MAX_BYTES;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"},n&&(a.prototype[n]=a.prototype.inspect),a.prototype.compare=function(t,e,r,n,o){if($(t,Uint8Array)&&(t=a.from(t,t.offset,t.byteLength)),!a.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);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;let i=(o>>>=0)-(n>>>=0),s=(r>>>=0)-(e>>>=0);const c=Math.min(i,s),u=this.slice(n,o),f=t.slice(e,r);for(let t=0;t<c;++t)if(u[t]!==f[t]){i=u[t],s=f[t];break}return i<s?-1:s<i?1:0},a.prototype.includes=function(t,e,r){return-1!==this.indexOf(t,e,r)},a.prototype.indexOf=function(t,e,r){return b(this,t,e,r,!0)},a.prototype.lastIndexOf=function(t,e,r){return b(this,t,e,r,!1)},a.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)}const 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");let i=!1;for(;;)switch(n){case"hex":return v(this,t,e,r);case"utf8":case"utf-8":return E(this,t,e,r);case"ascii":case"latin1":case"binary":return x(this,t,e,r);case"base64":return A(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return I(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const R=4096;function P(t,e,r){let n="";r=Math.min(t.length,r);for(let o=e;o<r;++o)n+=String.fromCharCode(127&t[o]);return n}function k(t,e,r){let n="";r=Math.min(t.length,r);for(let o=e;o<r;++o)n+=String.fromCharCode(t[o]);return n}function T(t,e,r){const n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);let o="";for(let n=e;n<r;++n)o+=X[t[n]];return o}function _(t,e,r){const n=t.slice(e,r);let o="";for(let t=0;t<n.length-1;t+=2)o+=String.fromCharCode(n[t]+256*n[t+1]);return o}function U(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 L(t,e,r,n,o,i){if(!a.isBuffer(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 C(t,e,r,n,o){j(e,n,o,t,r,7);let i=Number(e&BigInt(4294967295));t[r++]=i,i>>=8,t[r++]=i,i>>=8,t[r++]=i,i>>=8,t[r++]=i;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=s,s>>=8,t[r++]=s,s>>=8,t[r++]=s,s>>=8,t[r++]=s,r}function O(t,e,r,n,o){j(e,n,o,t,r,7);let i=Number(e&BigInt(4294967295));t[r+7]=i,i>>=8,t[r+6]=i,i>>=8,t[r+5]=i,i>>=8,t[r+4]=i;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=s,s>>=8,t[r+2]=s,s>>=8,t[r+1]=s,s>>=8,t[r]=s,r+8}function N(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function D(t,e,n,o,i){return e=+e,n>>>=0,i||N(t,0,n,4),r.write(t,e,n,o,23,4),n+4}function M(t,e,n,o,i){return e=+e,n>>>=0,i||N(t,0,n,8),r.write(t,e,n,o,52,8),n+8}a.prototype.slice=function(t,e){const r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e<t&&(e=t);const n=this.subarray(t,e);return Object.setPrototypeOf(n,a.prototype),n},a.prototype.readUintLE=a.prototype.readUIntLE=function(t,e,r){t>>>=0,e>>>=0,r||U(t,e,this.length);let n=this[t],o=1,i=0;for(;++i<e&&(o*=256);)n+=this[t+i]*o;return n},a.prototype.readUintBE=a.prototype.readUIntBE=function(t,e,r){t>>>=0,e>>>=0,r||U(t,e,this.length);let n=this[t+--e],o=1;for(;e>0&&(o*=256);)n+=this[t+--e]*o;return n},a.prototype.readUint8=a.prototype.readUInt8=function(t,e){return t>>>=0,e||U(t,1,this.length),this[t]},a.prototype.readUint16LE=a.prototype.readUInt16LE=function(t,e){return t>>>=0,e||U(t,2,this.length),this[t]|this[t+1]<<8},a.prototype.readUint16BE=a.prototype.readUInt16BE=function(t,e){return t>>>=0,e||U(t,2,this.length),this[t]<<8|this[t+1]},a.prototype.readUint32LE=a.prototype.readUInt32LE=function(t,e){return t>>>=0,e||U(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},a.prototype.readUint32BE=a.prototype.readUInt32BE=function(t,e){return t>>>=0,e||U(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},a.prototype.readBigUInt64LE=Q((function(t){F(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||K(t,this.length-8);const n=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,o=this[++t]+256*this[++t]+65536*this[++t]+r*2**24;return BigInt(n)+(BigInt(o)<<BigInt(32))})),a.prototype.readBigUInt64BE=Q((function(t){F(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||K(t,this.length-8);const n=e*2**24+65536*this[++t]+256*this[++t]+this[++t],o=this[++t]*2**24+65536*this[++t]+256*this[++t]+r;return(BigInt(n)<<BigInt(32))+BigInt(o)})),a.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||U(t,e,this.length);let n=this[t],o=1,i=0;for(;++i<e&&(o*=256);)n+=this[t+i]*o;return o*=128,n>=o&&(n-=Math.pow(2,8*e)),n},a.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||U(t,e,this.length);let n=e,o=1,i=this[t+--n];for(;n>0&&(o*=256);)i+=this[t+--n]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*e)),i},a.prototype.readInt8=function(t,e){return t>>>=0,e||U(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},a.prototype.readInt16LE=function(t,e){t>>>=0,e||U(t,2,this.length);const r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},a.prototype.readInt16BE=function(t,e){t>>>=0,e||U(t,2,this.length);const r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},a.prototype.readInt32LE=function(t,e){return t>>>=0,e||U(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},a.prototype.readInt32BE=function(t,e){return t>>>=0,e||U(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},a.prototype.readBigInt64LE=Q((function(t){F(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||K(t,this.length-8);const n=this[t+4]+256*this[t+5]+65536*this[t+6]+(r<<24);return(BigInt(n)<<BigInt(32))+BigInt(e+256*this[++t]+65536*this[++t]+this[++t]*2**24)})),a.prototype.readBigInt64BE=Q((function(t){F(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||K(t,this.length-8);const n=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(n)<<BigInt(32))+BigInt(this[++t]*2**24+65536*this[++t]+256*this[++t]+r)})),a.prototype.readFloatLE=function(t,e){return t>>>=0,e||U(t,4,this.length),r.read(this,t,!0,23,4)},a.prototype.readFloatBE=function(t,e){return t>>>=0,e||U(t,4,this.length),r.read(this,t,!1,23,4)},a.prototype.readDoubleLE=function(t,e){return t>>>=0,e||U(t,8,this.length),r.read(this,t,!0,52,8)},a.prototype.readDoubleBE=function(t,e){return t>>>=0,e||U(t,8,this.length),r.read(this,t,!1,52,8)},a.prototype.writeUintLE=a.prototype.writeUIntLE=function(t,e,r,n){if(t=+t,e>>>=0,r>>>=0,!n){L(this,t,e,r,Math.pow(2,8*r)-1,0)}let o=1,i=0;for(this[e]=255&t;++i<r&&(o*=256);)this[e+i]=t/o&255;return e+r},a.prototype.writeUintBE=a.prototype.writeUIntBE=function(t,e,r,n){if(t=+t,e>>>=0,r>>>=0,!n){L(this,t,e,r,Math.pow(2,8*r)-1,0)}let o=r-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+r},a.prototype.writeUint8=a.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||L(this,t,e,1,255,0),this[e]=255&t,e+1},a.prototype.writeUint16LE=a.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||L(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},a.prototype.writeUint16BE=a.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||L(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},a.prototype.writeUint32LE=a.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||L(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},a.prototype.writeUint32BE=a.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||L(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},a.prototype.writeBigUInt64LE=Q((function(t,e=0){return C(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),a.prototype.writeBigUInt64BE=Q((function(t,e=0){return O(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),a.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);L(this,t,e,r,n-1,-n)}let o=0,i=1,s=0;for(this[e]=255&t;++o<r&&(i*=256);)t<0&&0===s&&0!==this[e+o-1]&&(s=1),this[e+o]=(t/i>>0)-s&255;return e+r},a.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);L(this,t,e,r,n-1,-n)}let o=r-1,i=1,s=0;for(this[e+o]=255&t;--o>=0&&(i*=256);)t<0&&0===s&&0!==this[e+o+1]&&(s=1),this[e+o]=(t/i>>0)-s&255;return e+r},a.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||L(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},a.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||L(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},a.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||L(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},a.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||L(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},a.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||L(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},a.prototype.writeBigInt64LE=Q((function(t,e=0){return C(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),a.prototype.writeBigInt64BE=Q((function(t,e=0){return O(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),a.prototype.writeFloatLE=function(t,e,r){return D(this,t,e,!0,r)},a.prototype.writeFloatBE=function(t,e,r){return D(this,t,e,!1,r)},a.prototype.writeDoubleLE=function(t,e,r){return M(this,t,e,!0,r)},a.prototype.writeDoubleBE=function(t,e,r){return M(this,t,e,!1,r)},a.prototype.copy=function(t,e,r,n){if(!a.isBuffer(t))throw new TypeError("argument should be a Buffer");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("Index out of range");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);const o=n-r;return this===t&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(e,r,n):Uint8Array.prototype.set.call(t,this.subarray(r,n),e),o},a.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),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!a.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){const e=t.charCodeAt(0);("utf8"===n&&e<128||"latin1"===n)&&(t=e)}}else"number"==typeof t?t&=255:"boolean"==typeof t&&(t=Number(t));if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;let o;if(e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o<r;++o)this[o]=t;else{const i=a.isBuffer(t)?t:a.from(t,n),s=i.length;if(0===s)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(o=0;o<r-e;++o)this[o+e]=i[o%s]}return this};const V={};function z(t,e,r){V[t]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${t}]`,this.stack,delete this.name}get code(){return t}set code(t){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:t,writable:!0})}toString(){return`${this.name} [${t}]: ${this.message}`}}}function W(t){let e="",r=t.length;const n="-"===t[0]?1:0;for(;r>=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function j(t,e,r,n,o,i){if(t>r||t<e){const n="bigint"==typeof e?"n":"";let o;throw o=i>3?0===e||e===BigInt(0)?`>= 0${n} and < 2${n} ** ${8*(i+1)}${n}`:`>= -(2${n} ** ${8*(i+1)-1}${n}) and < 2 ** ${8*(i+1)-1}${n}`:`>= ${e}${n} and <= ${r}${n}`,new V.ERR_OUT_OF_RANGE("value",o,t)}!function(t,e,r){F(e,"offset"),void 0!==t[e]&&void 0!==t[e+r]||K(e,t.length-(r+1))}(n,o,i)}function F(t,e){if("number"!=typeof t)throw new V.ERR_INVALID_ARG_TYPE(e,"number",t)}function K(t,e,r){if(Math.floor(t)!==t)throw F(t,r),new V.ERR_OUT_OF_RANGE(r||"offset","an integer",t);if(e<0)throw new V.ERR_BUFFER_OUT_OF_BOUNDS;throw new V.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}z("ERR_BUFFER_OUT_OF_BOUNDS",(function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),z("ERR_INVALID_ARG_TYPE",(function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`}),TypeError),z("ERR_OUT_OF_RANGE",(function(t,e,r){let n=`The value of "${t}" is out of range.`,o=r;return Number.isInteger(r)&&Math.abs(r)>2**32?o=W(String(r)):"bigint"==typeof r&&(o=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(o=W(o)),o+="n"),n+=` It must be ${e}. Received ${o}`,n}),RangeError);const H=/[^+/0-9A-Za-z-_]/g;function G(t,e){let r;e=e||1/0;const n=t.length;let o=null;const i=[];for(let s=0;s<n;++s){if(r=t.charCodeAt(s),r>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 q(t){return e.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(H,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function Y(t,e,r,n){let o;for(o=0;o<n&&!(o+r>=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function $(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function Z(t){return t!=t}const X=function(){const t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){const n=16*r;for(let o=0;o<16;++o)e[n+o]=t[r]+t[o]}return e}();function Q(t){return"undefined"==typeof BigInt?J:t}function J(){throw new Error("BigInt not supported")}}(n);const p=new t.PublicKey("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA");new t.PublicKey("TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb");const l=new t.PublicKey("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL");new t.PublicKey("So11111111111111111111111111111111111111112"),new t.PublicKey("9pan9bMn5HatX4EJdBwg9VgCa7Uz5HL8N1m5D3NdXejP");var y={};Object.defineProperty(y,"__esModule",{value:!0}),y.s16=y.s8=y.nu64be=y.u48be=y.u40be=y.u32be=y.u24be=y.u16be=y.nu64=y.u48=y.u40=tt=y.u32=y.u24=y.u16=J=y.u8=y.offset=y.greedy=y.Constant=y.UTF8=y.CString=y.Blob=y.Boolean=y.BitField=y.BitStructure=y.VariantLayout=y.Union=y.UnionLayoutDiscriminator=y.UnionDiscriminator=y.Structure=y.Sequence=y.DoubleBE=y.Double=y.FloatBE=y.Float=y.NearInt64BE=y.NearInt64=y.NearUInt64BE=y.NearUInt64=y.IntBE=y.Int=y.UIntBE=y.UInt=y.OffsetLayout=y.GreedyCount=y.ExternalLayout=y.bindConstructorLayout=y.nameWithProperty=y.Layout=y.uint8ArrayToBuffer=y.checkUint8Array=void 0,y.constant=y.utf8=y.cstr=rt=y.blob=y.unionLayoutDiscriminator=y.union=y.seq=y.bits=et=y.struct=y.f64be=y.f64=y.f32be=y.f32=y.ns64be=y.s48be=y.s40be=y.s32be=y.s24be=y.s16be=y.ns64=y.s48=y.s40=y.s32=y.s24=void 0;const g=n;function w(t){if(!(t instanceof Uint8Array))throw new TypeError("b must be a Uint8Array")}function b(t){return w(t),g.Buffer.from(t.buffer,t.byteOffset,t.length)}y.checkUint8Array=w,y.uint8ArrayToBuffer=b;class m{constructor(t,e){if(!Number.isInteger(t))throw new TypeError("span must be an integer");this.span=t,this.property=e}makeDestinationObject(){return{}}getSpan(t,e){if(0>this.span)throw new RangeError("indeterminate span");return this.span}replicate(t){const e=Object.create(this.constructor.prototype);return Object.assign(e,this),e.property=t,e}fromArray(t){}}function v(t,e){return e.property?t+"["+e.property+"]":t}y.Layout=m,y.nameWithProperty=v,y.bindConstructorLayout=function(t,e){if("function"!=typeof t)throw new TypeError("Class must be constructor");if(Object.prototype.hasOwnProperty.call(t,"layout_"))throw new Error("Class is already bound to a layout");if(!(e&&e instanceof m))throw new TypeError("layout must be a Layout");if(Object.prototype.hasOwnProperty.call(e,"boundConstructor_"))throw new Error("layout is already bound to a constructor");t.layout_=e,e.boundConstructor_=t,e.makeDestinationObject=()=>new t,Object.defineProperty(t.prototype,"encode",{value(t,r){return e.encode(this,t,r)},writable:!0}),Object.defineProperty(t,"decode",{value:(t,r)=>e.decode(t,r),writable:!0})};class E extends m{isCount(){throw new Error("ExternalLayout is abstract")}}y.ExternalLayout=E;class x extends E{constructor(t=1,e){if(!Number.isInteger(t)||0>=t)throw new TypeError("elementSpan must be a (positive) integer");super(-1,e),this.elementSpan=t}isCount(){return!0}decode(t,e=0){w(t);const r=t.length-e;return Math.floor(r/this.elementSpan)}encode(t,e,r){return 0}}y.GreedyCount=x;class A extends E{constructor(t,e=0,r){if(!(t instanceof m))throw new TypeError("layout must be a Layout");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 I||this.layout instanceof S}decode(t,e=0){return this.layout.decode(t,e+this.offset)}encode(t,e,r=0){return this.layout.encode(t,e,r+this.offset)}}y.OffsetLayout=A;class I extends m{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return b(t).readUIntLE(e,this.span)}encode(t,e,r=0){return b(e).writeUIntLE(t,r,this.span),this.span}}y.UInt=I;class S extends m{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return b(t).readUIntBE(e,this.span)}encode(t,e,r=0){return b(e).writeUIntBE(t,r,this.span),this.span}}y.UIntBE=S;class B extends m{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return b(t).readIntLE(e,this.span)}encode(t,e,r=0){return b(e).writeIntLE(t,r,this.span),this.span}}y.Int=B;class R extends m{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return b(t).readIntBE(e,this.span)}encode(t,e,r=0){return b(e).writeIntBE(t,r,this.span),this.span}}y.IntBE=R;const P=Math.pow(2,32);function k(t){const e=Math.floor(t/P);return{hi32:e,lo32:t-e*P}}function T(t,e){return t*P+e}class _ extends m{constructor(t){super(8,t)}decode(t,e=0){const r=b(t),n=r.readUInt32LE(e);return T(r.readUInt32LE(e+4),n)}encode(t,e,r=0){const n=k(t),o=b(e);return o.writeUInt32LE(n.lo32,r),o.writeUInt32LE(n.hi32,r+4),8}}y.NearUInt64=_;class U extends m{constructor(t){super(8,t)}decode(t,e=0){const r=b(t);return T(r.readUInt32BE(e),r.readUInt32BE(e+4))}encode(t,e,r=0){const n=k(t),o=b(e);return o.writeUInt32BE(n.hi32,r),o.writeUInt32BE(n.lo32,r+4),8}}y.NearUInt64BE=U;class L extends m{constructor(t){super(8,t)}decode(t,e=0){const r=b(t),n=r.readUInt32LE(e);return T(r.readInt32LE(e+4),n)}encode(t,e,r=0){const n=k(t),o=b(e);return o.writeUInt32LE(n.lo32,r),o.writeInt32LE(n.hi32,r+4),8}}y.NearInt64=L;class C extends m{constructor(t){super(8,t)}decode(t,e=0){const r=b(t);return T(r.readInt32BE(e),r.readUInt32BE(e+4))}encode(t,e,r=0){const n=k(t),o=b(e);return o.writeInt32BE(n.hi32,r),o.writeUInt32BE(n.lo32,r+4),8}}y.NearInt64BE=C;class O extends m{constructor(t){super(4,t)}decode(t,e=0){return b(t).readFloatLE(e)}encode(t,e,r=0){return b(e).writeFloatLE(t,r),4}}y.Float=O;class N extends m{constructor(t){super(4,t)}decode(t,e=0){return b(t).readFloatBE(e)}encode(t,e,r=0){return b(e).writeFloatBE(t,r),4}}y.FloatBE=N;class D extends m{constructor(t){super(8,t)}decode(t,e=0){return b(t).readDoubleLE(e)}encode(t,e,r=0){return b(e).writeDoubleLE(t,r),8}}y.Double=D;class M extends m{constructor(t){super(8,t)}decode(t,e=0){return b(t).readDoubleBE(e)}encode(t,e,r=0){return b(e).writeDoubleBE(t,r),8}}y.DoubleBE=M;class V extends m{constructor(t,e,r){if(!(t instanceof m))throw new TypeError("elementLayout must be a Layout");if(!(e instanceof E&&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 E)&&0<t.span&&(n=e*t.span),super(n,r),this.elementLayout=t,this.count=e}getSpan(t,e=0){if(0<=this.span)return this.span;let r=0,n=this.count;if(n instanceof E&&(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=0){const r=[];let n=0,o=this.count;for(o instanceof E&&(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=0){const n=this.elementLayout,o=t.reduce(((t,o)=>t+n.encode(o,e,r+t)),0);return this.count instanceof E&&this.count.encode(t.length,e,r),o}}y.Sequence=V;class z extends m{constructor(t,e,r){if(!Array.isArray(t)||!t.reduce(((t,e)=>t&&e instanceof m),!0))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=0){if(0<=this.span)return this.span;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=0){w(t);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=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)}}}y.Structure=z;class W{constructor(t){this.property=t}decode(t,e){throw new Error("UnionDiscriminator is abstract")}encode(t,e,r){throw new Error("UnionDiscriminator is abstract")}}y.UnionDiscriminator=W;class j extends W{constructor(t,e){if(!(t instanceof E&&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)}}y.UnionLayoutDiscriminator=j;class F extends m{constructor(t,e,r){let n;if(t instanceof I||t instanceof S)n=new j(new A(t));else if(t instanceof E&&t.isCount())n=new j(t);else{if(!(t instanceof W))throw new TypeError("discr must be a UnionDiscriminator or an unsigned integer layout");n=t}if(void 0===e&&(e=null),!(null===e||e instanceof m))throw new TypeError("defaultLayout must be null or a Layout");if(null!==e){if(0>e.span)throw new Error("defaultLayout must have constant span");void 0===e.property&&(e=e.replicate("content"))}let o=-1;e&&(o=e.span,0<=o&&(t instanceof I||t instanceof S)&&(o+=n.layout.span)),super(o,r),this.discriminator=n,this.usesPrefixDiscriminator=t instanceof I||t instanceof S,this.defaultLayout=e,this.registry={};let i=this.defaultGetSourceVariant.bind(this);this.getSourceVariant=function(t){return i(t)},this.configGetSourceVariant=function(t){i=t.bind(this)}}getSpan(t,e=0){if(0<=this.span)return this.span;const 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(Object.prototype.hasOwnProperty.call(t,this.discriminator.property)){if(this.defaultLayout&&this.defaultLayout.property&&Object.prototype.hasOwnProperty.call(t,this.defaultLayout.property))return;const e=this.registry[t[this.discriminator.property]];if(e&&(!e.layout||e.property&&Object.prototype.hasOwnProperty.call(t,e.property)))return e}else for(const e in this.registry){const r=this.registry[e];if(r.property&&Object.prototype.hasOwnProperty.call(t,r.property))return r}throw new Error("unable to infer src variant")}decode(t,e=0){let r;const n=this.discriminator,o=n.decode(t,e),i=this.registry[o];if(void 0===i){const i=this.defaultLayout;let s=0;this.usesPrefixDiscriminator&&(s=n.layout.span),r=this.makeDestinationObject(),r[n.property]=o,r[i.property]=i.decode(t,e+s)}else r=i.decode(t,e);return r}encode(t,e,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 K(this,t,e,r);return this.registry[t]=n,n}getVariant(t,e=0){let r;return r=t instanceof Uint8Array?this.discriminator.decode(t,e):t,this.registry[r]}}y.Union=F;class K extends m{constructor(t,e,r,n){if(!(t instanceof F))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 m))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=0){if(0<=this.span)return this.span;let r=0;this.union.usesPrefixDiscriminator&&(r=this.union.discriminator.layout.span);let n=0;return this.layout&&(n=this.layout.getSpan(t,e+r)),r+n}decode(t,e=0){const r=this.makeDestinationObject();if(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]=!0:this.union.usesPrefixDiscriminator&&(r[this.union.discriminator.property]=this.variant),r}encode(t,e,r=0){let n=0;if(this.union.usesPrefixDiscriminator&&(n=this.union.discriminator.layout.span),this.layout&&!Object.prototype.hasOwnProperty.call(t,this.property))throw new TypeError("variant lacks property "+this.property);this.union.discriminator.encode(this.variant,e,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 H(t){return 0>t&&(t+=4294967296),t}y.VariantLayout=K;class G extends m{constructor(t,e,r){if(!(t instanceof I||t instanceof S))throw new TypeError("word must be a UInt or UIntBE layout");if("string"==typeof e&&void 0===r&&(r=e,e=!1),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=H(t),this},this._packedGetValue=function(){return n}}decode(t,e=0){const r=this.makeDestinationObject(),n=this.word.decode(t,e);this._packedSetValue(n);for(const e of this.fields)void 0!==e.property&&(r[e.property]=e.decode(t));return r}encode(t,e,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 q(this,t,e);return this.fields.push(r),r}addBoolean(t){const e=new Y(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}}y.BitStructure=G;class q{constructor(t,e,r){if(!(t instanceof G))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=H(this.valueMask<<this.start),this.property=r}decode(t,e){return H(this.container._packedGetValue()&this.wordMask)>>>this.start}encode(t){if("number"!=typeof t||!Number.isInteger(t)||t!==H(t&this.valueMask))throw new TypeError(v("BitField.encode",this)+" value must be integer not exceeding "+this.valueMask);const e=this.container._packedGetValue(),r=H(t<<this.start);this.container._packedSetValue(H(e&~this.wordMask)|r)}}y.BitField=q;class Y extends q{constructor(t,e){super(t,1,e)}decode(t,e){return!!super.decode(t,e)}encode(t){"boolean"==typeof t&&(t=+t),super.encode(t)}}y.Boolean=Y;class $ extends m{constructor(t,e){if(!(t instanceof E&&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 E||(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=0){let r=this.span;return 0>r&&(r=this.length.decode(t,e)),b(t).slice(e,e+r)}encode(t,e,r){let n=this.length;if(this.length instanceof E&&(n=t.length),!(t instanceof Uint8Array&&n===t.length))throw new TypeError(v("Blob.encode",this)+" requires (length "+n+") Uint8Array as src");if(r+n>e.length)throw new RangeError("encoding overruns Uint8Array");const o=b(t);return b(e).write(o.toString("hex"),r,n,"hex"),this.length instanceof E&&this.length.encode(n,e,r),n}}y.Blob=$;class Z extends m{constructor(t){super(-1,t)}getSpan(t,e=0){w(t);let r=e;for(;r<t.length&&0!==t[r];)r+=1;return 1+r-e}decode(t,e=0){const r=this.getSpan(t,e);return b(t).slice(e,e+r-1).toString("utf-8")}encode(t,e,r=0){"string"!=typeof t&&(t=String(t));const n=g.Buffer.from(t,"utf8"),o=n.length;if(r+o>e.length)throw new RangeError("encoding overruns Buffer");const i=b(e);return n.copy(i,r),i[r+o]=0,o+1}}y.CString=Z;class X extends m{constructor(t,e){if("string"==typeof t&&void 0===e&&(e=t,t=void 0),void 0===t)t=-1;else if(!Number.isInteger(t))throw new TypeError("maxSpan must be an integer");super(-1,e),this.maxSpan=t}getSpan(t,e=0){return w(t),t.length-e}decode(t,e=0){const r=this.getSpan(t,e);if(0<=this.maxSpan&&this.maxSpan<r)throw new RangeError("text length exceeds maxSpan");return b(t).slice(e,e+r).toString("utf-8")}encode(t,e,r=0){"string"!=typeof t&&(t=String(t));const n=g.Buffer.from(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(b(e),r),o}}y.UTF8=X;class Q extends m{constructor(t,e){super(0,e),this.value=t}decode(t,e){return this.value}encode(t,e,r){return 0}}y.Constant=Q,y.greedy=(t,e)=>new x(t,e),y.offset=(t,e,r)=>new A(t,e,r);var J=y.u8=t=>new I(1,t);y.u16=t=>new I(2,t),y.u24=t=>new I(3,t);var tt=y.u32=t=>new I(4,t);y.u40=t=>new I(5,t),y.u48=t=>new I(6,t),y.nu64=t=>new _(t),y.u16be=t=>new S(2,t),y.u24be=t=>new S(3,t),y.u32be=t=>new S(4,t),y.u40be=t=>new S(5,t),y.u48be=t=>new S(6,t),y.nu64be=t=>new U(t),y.s8=t=>new B(1,t),y.s16=t=>new B(2,t),y.s24=t=>new B(3,t),y.s32=t=>new B(4,t),y.s40=t=>new B(5,t),y.s48=t=>new B(6,t),y.ns64=t=>new L(t),y.s16be=t=>new R(2,t),y.s24be=t=>new R(3,t),y.s32be=t=>new R(4,t),y.s40be=t=>new R(5,t),y.s48be=t=>new R(6,t),y.ns64be=t=>new C(t),y.f32=t=>new O(t),y.f32be=t=>new N(t),y.f64=t=>new D(t),y.f64be=t=>new M(t);var et=y.struct=(t,e,r)=>new z(t,e,r);y.bits=(t,e,r)=>new G(t,e,r),y.seq=(t,e,r)=>new V(t,e,r),y.union=(t,e,r)=>new F(t,e,r),y.unionLayoutDiscriminator=(t,e)=>new j(t,e);var rt=y.blob=(t,e)=>new $(t,e);y.cstr=t=>new Z(t),y.utf8=(t,e)=>new X(t,e),y.constant=(t,e)=>new Q(t,e);const nt=t=>({decode:t.decode.bind(t),encode:t.encode.bind(t)});var ot={};Object.defineProperty(ot,"__esModule",{value:!0});var it=ot.toBigIntLE=function(t){{const e=Buffer.from(t);e.reverse();const r=e.toString("hex");return 0===r.length?BigInt(0):BigInt(`0x${r}`)}};ot.toBigIntBE=function(t){{const e=t.toString("hex");return 0===e.length?BigInt(0):BigInt(`0x${e}`)}};var st=ot.toBufferLE=function(t,e){{const r=t.toString(16),n=Buffer.from(r.padStart(2*e,"0").slice(0,2*e),"hex");return n.reverse(),n}};ot.toBufferBE=function(t,e){{const r=t.toString(16);return Buffer.from(r.padStart(2*e,"0").slice(0,2*e),"hex")}};const at=(ct=8,t=>{const e=rt(ct,t),{encode:r,decode:n}=nt(e),o=e;return o.decode=(t,e)=>{const r=n(t,e);return it(Buffer.from(r))},o.encode=(t,e,n)=>{const o=st(t,ct);return r(o,e,n)},o});var ct;const ut=t=>{const e=J(t),{encode:r,decode:n}=nt(e),o=e;return o.decode=(t,e)=>!!n(t,e),o.encode=(t,e,n)=>{const o=Number(t);return r(o,e,n)},o},ft=e=>{const r=rt(32,e),{encode:n,decode:o}=nt(r),i=r;return i.decode=(e,r)=>{const n=o(e,r);return new t.PublicKey(n)},i.encode=(t,e,r)=>{const o=t.toBuffer();return n(o,e,r)},i};class ht extends Error{constructor(t){super(t)}}class dt extends ht{constructor(){super(...arguments),this.name="TokenAccountNotFoundError"}}class pt extends ht{constructor(){super(...arguments),this.name="TokenInvalidAccountOwnerError"}}class lt extends ht{constructor(){super(...arguments),this.name="TokenInvalidAccountSizeError"}}class yt extends ht{constructor(){super(...arguments),this.name="TokenInvalidMintError"}}class gt extends ht{constructor(){super(...arguments),this.name="TokenOwnerOffCurveError"}}var wt;!function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Mint=1]="Mint",t[t.Account=2]="Account"}(wt||(wt={}));const bt=1,mt=et([J("m"),J("n"),ut("isInitialized"),ft("signer1"),ft("signer2"),ft("signer3"),ft("signer4"),ft("signer5"),ft("signer6"),ft("signer7"),ft("signer8"),ft("signer9"),ft("signer10"),ft("signer11")]).span;var vt;!function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Initialized=1]="Initialized",t[t.Frozen=2]="Frozen"}(vt||(vt={}));const Et=et([ft("mint"),ft("owner"),at("amount"),tt("delegateOption"),ft("delegate"),J("state"),tt("isNativeOption"),at("isNative"),at("delegatedAmount"),tt("closeAuthorityOption"),ft("closeAuthority")]),xt=Et.span,At=et([tt("mintAuthorityOption"),ft("mintAuthority"),at("supply"),J("decimals"),ut("isInitialized"),tt("freezeAuthorityOption"),ft("freezeAuthority")]),It=At.span;async function St(t,e,r,n=p){return function(t,e,r=p){if(!e)throw new dt;if(!e.owner.equals(r))throw new pt;if(e.data.length<It)throw new lt;const n=At.decode(e.data.slice(0,It));let o=Buffer.alloc(0);if(e.data.length>It){if(e.data.length<=xt)throw new lt;if(e.data.length===mt)throw new lt;if(e.data[xt]!=wt.Mint)throw new yt;o=e.data.slice(xt+bt)}return{address:t,mintAuthority:n.mintAuthorityOption?n.mintAuthority:null,supply:n.supply,decimals:n.decimals,isInitialized:n.isInitialized,freezeAuthority:n.freezeAuthorityOption?n.freezeAuthority:null,tlvData:o}}(e,await t.getAccountInfo(e,r),n)}function Bt(e,r,n=!1,o=p,i=l){if(!n&&!t.PublicKey.isOnCurve(r.toBuffer()))throw new gt;const[s]=t.PublicKey.findProgramAddressSync([r.toBuffer(),o.toBuffer(),e.toBuffer()],i);return s}function Rt(e,r,n,o,i=p,s=l){return function(e,r,n,o,i,s=p,a=l){const c=[{pubkey:e,isSigner:!0,isWritable:!0},{pubkey:r,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!1,isWritable:!1},{pubkey:o,isSigner:!1,isWritable:!1},{pubkey:t.SystemProgram.programId,isSigner:!1,isWritable:!1},{pubkey:s,isSigner:!1,isWritable:!1}];return new t.TransactionInstruction({keys:c,programId:a,data:i})}(e,r,n,o,Buffer.from([1]),i,s)}var Pt;exports.ErrorType=void 0,(Pt=exports.ErrorType||(exports.ErrorType={})).SymbolNotFound="SymbolNotFound",Pt.InvalidSubdomain="InvalidSubdomain",Pt.FavouriteDomainNotFound="FavouriteDomainNotFound",Pt.MissingParentOwner="MissingParentOwner",Pt.U32Overflow="U32Overflow",Pt.InvalidBufferLength="InvalidBufferLength",Pt.U64Overflow="U64Overflow",Pt.NoRecordData="NoRecordData",Pt.InvalidRecordData="InvalidRecordData",Pt.UnsupportedRecord="UnsupportedRecord",Pt.InvalidEvmAddress="InvalidEvmAddress",Pt.InvalidInjectiveAddress="InvalidInjectiveAddress",Pt.InvalidARecord="InvalidARecord",Pt.InvalidAAAARecord="InvalidAAAARecord",Pt.InvalidRecordInput="InvalidRecordInput",Pt.InvalidSignature="InvalidSignature",Pt.AccountDoesNotExist="AccountDoesNotExist",Pt.MultipleRegistries="MultipleRegistries",Pt.InvalidReverseTwitter="InvalidReverseTwitter",Pt.NoAccountData="NoAccountData",Pt.InvalidInput="InvalidInput",Pt.InvalidDomain="InvalidDomain",Pt.InvalidCustomBg="InvalidCustomBackground",Pt.UnsupportedSignature="UnsupportedSignature",Pt.RecordDoestNotSupportGuardianSig="RecordDoestNotSupportGuardianSig",Pt.RecordIsNotSigned="RecordIsNotSigned",Pt.UnsupportedSignatureType="UnsupportedSignatureType",Pt.InvalidSolRecordV2="InvalidSolRecordV2",Pt.MissingVerifier="MissingVerifier",Pt.PythFeedNotFound="PythFeedNotFound";class kt extends Error{constructor(t,e){super(e),this.name="SNSError",this.type=t,Error.captureStackTrace&&Error.captureStackTrace(this,kt)}}class Tt{constructor(t){this.value=BigInt(t)}toBuffer(){const t=n.Buffer.alloc(4);return t.writeUInt32LE(Number(this.value)),t}static fromBuffer(t){if(4!==t.length)throw new kt(exports.ErrorType.InvalidBufferLength,`Invalid buffer length: ${t.length}`);const e=BigInt(t.readUInt32LE(0));return new Tt(e)}toNumber(){return Number(this.value)}toString(){return String(this.value)}}class _t{constructor(t){this.value=BigInt(t)}toBuffer(){const t=n.Buffer.alloc(8);return t.writeBigUInt64LE(this.value),t}static fromBuffer(t){if(8!==t.length)throw new kt(exports.ErrorType.U64Overflow,`Invalid buffer length: ${t.length}`);const e=t.readBigUInt64LE(0);return new _t(e)}toNumber(){return Number(this.value)}toString(){return String(this.value)}}var Ut,Lt=["u8","u16","u32","u64","u128","i8","i16","i32","i64","i128","f32","f64"],Ct=function(){function t(){this.offset=0,this.buffer_size=256,this.buffer=new ArrayBuffer(this.buffer_size),this.view=new DataView(this.buffer)}return t.prototype.resize_if_necessary=function(t){if(this.buffer_size-this.offset<t){this.buffer_size=Math.max(2*this.buffer_size,this.buffer_size+t);var e=new ArrayBuffer(this.buffer_size);new Uint8Array(e).set(new Uint8Array(this.buffer)),this.buffer=e,this.view=new DataView(e)}},t.prototype.get_used_buffer=function(){return new Uint8Array(this.buffer).slice(0,this.offset)},t.prototype.store_value=function(t,e){var r=e.substring(1),n=parseInt(r)/8;this.resize_if_necessary(n);var o="f"===e[0]?"setFloat".concat(r):"i"===e[0]?"setInt".concat(r):"setUint".concat(r);this.view[o](this.offset,t,!0),this.offset+=n},t.prototype.store_bytes=function(t){this.resize_if_necessary(t.length),new Uint8Array(this.buffer).set(new Uint8Array(t),this.offset),this.offset+=t.length},t}(),Ot=function(){function t(t){this.offset=0,this.buffer_size=t.length,this.buffer=new ArrayBuffer(t.length),new Uint8Array(this.buffer).set(t),this.view=new DataView(this.buffer)}return t.prototype.assert_enough_buffer=function(t){if(this.offset+t>this.buffer.byteLength)throw new Error("Error in schema, the buffer is smaller than expected")},t.prototype.consume_value=function(t){var e=t.substring(1),r=parseInt(e)/8;this.assert_enough_buffer(r);var n="f"===t[0]?"getFloat".concat(e):"i"===t[0]?"getInt".concat(e):"getUint".concat(e),o=this.view[n](this.offset,!0);return this.offset+=r,o},t.prototype.consume_bytes=function(t){this.assert_enough_buffer(t);var e=this.buffer.slice(this.offset,this.offset+t);return this.offset+=t,e},t}(),Nt=(Ut=function(t,e){return Ut=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},Ut(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}Ut(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)});function Dt(t,e,r){if(typeof t!==e)throw new Error("Expected ".concat(e," not ").concat(typeof t,"(").concat(t,") at ").concat(r.join(".")))}function Mt(t,e,r){if(t!==e)throw new Error("Array length ".concat(t," does not match schema length ").concat(e," at ").concat(r.join(".")))}var Vt=Lt.concat(["bool","string"]),zt=["option","enum","array","set","map","struct"],Wt=function(t){function e(e,r){var n="Invalid schema: ".concat(JSON.stringify(e)," expected ").concat(r);return t.call(this,n)||this}return Nt(e,t),e}(Error);function jt(t){if("string"!=typeof t||!Vt.includes(t)){if(t&&"object"==typeof t){var e=Object.keys(t);if(1===e.length&&zt.includes(e[0])){var r=e[0];if("option"===r)return jt(t[r]);if("enum"===r)return function(t){if(!Array.isArray(t))throw new Wt(t,"Array");for(var e=0,r=t;e<r.length;e++){var n=r[e];if("object"!=typeof n||!("struct"in n))throw new Error('Missing "struct" key in enum schema');if("object"!=typeof n.struct||1!==Object.keys(n.struct).length)throw new Error('The "struct" in each enum must have a single key');jt({struct:n.struct})}}(t[r]);if("array"===r)return function(t){if("object"!=typeof t)throw new Wt(t,"{ type, len? }");if(t.len&&"number"!=typeof t.len)throw new Error("Invalid schema: ".concat(t));if("type"in t)return jt(t.type);throw new Wt(t,"{ type, len? }")}(t[r]);if("set"===r)return jt(t[r]);if("map"===r)return function(t){if("object"!=typeof t||!("key"in t)||!("value"in t))throw new Wt(t,"{ key, value }");jt(t.key),jt(t.value)}(t[r]);if("struct"===r)return function(t){if("object"!=typeof t)throw new Wt(t,"object");for(var e in t)jt(t[e])}(t[r])}}throw new Wt(t,zt.join(", ")+" or "+Vt.join(", "))}}var Ft=function(){function t(t){this.encoded=new Ct,this.fieldPath=["value"],this.checkTypes=t}return t.prototype.encode=function(t,e){return this.encode_value(t,e),this.encoded.get_used_buffer()},t.prototype.encode_value=function(t,e){if("string"==typeof e){if(Lt.includes(e))return this.encode_integer(t,e);if("string"===e)return this.encode_string(t);if("bool"===e)return this.encode_boolean(t)}if("object"==typeof e){if("option"in e)return this.encode_option(t,e);if("enum"in e)return this.encode_enum(t,e);if("array"in e)return this.encode_array(t,e);if("set"in e)return this.encode_set(t,e);if("map"in e)return this.encode_map(t,e);if("struct"in e)return this.encode_struct(t,e)}},t.prototype.encode_integer=function(t,e){var r=parseInt(e.substring(1));r<=32||"f64"==e?(this.checkTypes&&Dt(t,"number",this.fieldPath),this.encoded.store_value(t,e)):(this.checkTypes&&function(t,e){if(!(["number","string","bigint","boolean"].includes(typeof t)||"object"==typeof t&&null!==t&&"toString"in t))throw new Error("Expected bigint, number, boolean or string not ".concat(typeof t,"(").concat(t,") at ").concat(e.join(".")))}(t,this.fieldPath),this.encode_bigint(BigInt(t),r))},t.prototype.encode_bigint=function(t,e){for(var r=e/8,n=new Uint8Array(r),o=0;o<r;o++)n[o]=Number(t&BigInt(255)),t>>=BigInt(8);this.encoded.store_bytes(new Uint8Array(n))},t.prototype.encode_string=function(t){this.checkTypes&&Dt(t,"string",this.fieldPath);for(var e=t,r=[],n=0;n<e.length;n++){var o=e.charCodeAt(n);o<128?r.push(o):o<2048?r.push(192|o>>6,128|63&o):o<55296||o>=57344?r.push(224|o>>12,128|o>>6&63,128|63&o):(n++,o=65536+((1023&o)<<10|1023&e.charCodeAt(n)),r.push(240|o>>18,128|o>>12&63,128|o>>6&63,128|63&o))}this.encoded.store_value(r.length,"u32"),this.encoded.store_bytes(new Uint8Array(r))},t.prototype.encode_boolean=function(t){this.checkTypes&&Dt(t,"boolean",this.fieldPath),this.encoded.store_value(t?1:0,"u8")},t.prototype.encode_option=function(t,e){null==t?this.encoded.store_value(0,"u8"):(this.encoded.store_value(1,"u8"),this.encode_value(t,e.option))},t.prototype.encode_enum=function(t,e){this.checkTypes&&function(t,e){if("object"!=typeof t||null===t)throw new Error("Expected object not ".concat(typeof t,"(").concat(t,") at ").concat(e.join(".")))}(t,this.fieldPath);for(var r=Object.keys(t)[0],n=0;n<e.enum.length;n++){var o=e.enum[n];if(r===Object.keys(o.struct)[0])return this.encoded.store_value(n,"u8"),this.encode_struct(t,o)}throw new Error("Enum key (".concat(r,") not found in enum schema: ").concat(JSON.stringify(e)," at ").concat(this.fieldPath.join(".")))},t.prototype.encode_array=function(t,e){if(function(t){return Array.isArray(t)||!!t&&"object"==typeof t&&"length"in t&&"number"==typeof t.length&&(0===t.length||t.length>0&&t.length-1 in t)}(t))return this.encode_arraylike(t,e);if(t instanceof ArrayBuffer)return this.encode_buffer(t,e);throw new Error("Expected Array-like not ".concat(typeof t,"(").concat(t,") at ").concat(this.fieldPath.join(".")))},t.prototype.encode_arraylike=function(t,e){e.array.len?Mt(t.length,e.array.len,this.fieldPath):this.encoded.store_value(t.length,"u32");for(var r=0;r<t.length;r++)this.encode_value(t[r],e.array.type)},t.prototype.encode_buffer=function(t,e){e.array.len?Mt(t.byteLength,e.array.len,this.fieldPath):this.encoded.store_value(t.byteLength,"u32"),this.encoded.store_bytes(new Uint8Array(t))},t.prototype.encode_set=function(t,e){this.checkTypes&&Dt(t,"object",this.fieldPath);var r=t instanceof Set?Array.from(t.values()):Object.values(t);this.encoded.store_value(r.length,"u32");for(var n=0,o=r;n<o.length;n++){var i=o[n];this.encode_value(i,e.set)}},t.prototype.encode_map=function(t,e){this.checkTypes&&Dt(t,"object",this.fieldPath);var r=t instanceof Map,n=r?Array.from(t.keys()):Object.keys(t);this.encoded.store_value(n.length,"u32");for(var o=0,i=n;o<i.length;o++){var s=i[o];this.encode_value(s,e.map.key),this.encode_value(r?t.get(s):t[s],e.map.value)}},t.prototype.encode_struct=function(t,e){this.checkTypes&&Dt(t,"object",this.fieldPath);for(var r=0,n=Object.keys(e.struct);r<n.length;r++){var o=n[r];this.fieldPath.push(o),this.encode_value(t[o],e.struct[o]),this.fieldPath.pop()}},t}(),Kt=function(){function t(t){this.buffer=new Ot(t)}return t.prototype.decode=function(t){return this.decode_value(t)},t.prototype.decode_value=function(t){if("string"==typeof t){if(Lt.includes(t))return this.decode_integer(t);if("string"===t)return this.decode_string();if("bool"===t)return this.decode_boolean()}if("object"==typeof t){if("option"in t)return this.decode_option(t);if("enum"in t)return this.decode_enum(t);if("array"in t)return this.decode_array(t);if("set"in t)return this.decode_set(t);if("map"in t)return this.decode_map(t);if("struct"in t)return this.decode_struct(t)}throw new Error("Unsupported type: ".concat(t))},t.prototype.decode_integer=function(t){var e=parseInt(t.substring(1));return e<=32||"f64"==t?this.buffer.consume_value(t):this.decode_bigint(e,t.startsWith("i"))},t.prototype.decode_bigint=function(t,e){void 0===e&&(e=!1);var r=t/8,n=new Uint8Array(this.buffer.consume_bytes(r)),o=n.reduceRight((function(t,e){return t+e.toString(16).padStart(2,"0")}),"");return e&&n[r-1]?BigInt.asIntN(t,BigInt("0x".concat(o))):BigInt("0x".concat(o))},t.prototype.decode_string=function(){for(var t=this.decode_integer("u32"),e=new Uint8Array(this.buffer.consume_bytes(t)),r=[],n=0;n<t;++n){var o=e[n];if(o<128)r.push(o);else if(o<224)r.push((31&o)<<6|63&e[++n]);else if(o<240)r.push((15&o)<<12|(63&e[++n])<<6|63&e[++n]);else{var i=(7&o)<<18|(63&e[++n])<<12|(63&e[++n])<<6|63&e[++n];r.push(i)}}return String.fromCodePoint.apply(String,r)},t.prototype.decode_boolean=function(){return this.buffer.consume_value("u8")>0},t.prototype.decode_option=function(t){var e=this.buffer.consume_value("u8");if(1===e)return this.decode_value(t.option);if(0!==e)throw new Error("Invalid option ".concat(e));return null},t.prototype.decode_enum=function(t){var e,r=this.buffer.consume_value("u8");if(r>t.enum.length)throw new Error("Enum option ".concat(r," is not available"));var n=t.enum[r].struct,o=Object.keys(n)[0];return(e={})[o]=this.decode_value(n[o]),e},t.prototype.decode_array=function(t){for(var e=[],r=t.array.len?t.array.len:this.decode_integer("u32"),n=0;n<r;++n)e.push(this.decode_value(t.array.type));return e},t.prototype.decode_set=function(t){for(var e=this.decode_integer("u32"),r=new Set,n=0;n<e;++n)r.add(this.decode_value(t.set));return r},t.prototype.decode_map=function(t){for(var e=this.decode_integer("u32"),r=new Map,n=0;n<e;++n){var o=this.decode_value(t.map.key),i=this.decode_value(t.map.value);r.set(o,i)}return r},t.prototype.decode_struct=function(t){var e={};for(var r in t.struct)e[r]=this.decode_value(t.struct[r]);return e},t}();function Ht(t,e,r){return void 0===r&&(r=!0),r&&jt(t),new Ft(r).encode(e,t)}function Gt(t,e,r){return void 0===r&&(r=!0),r&&jt(t),new Kt(e).decode(t)}function qt(e,r,o,i,s,a,c,u,f,h,d){const p=[n.Buffer.from(Int8Array.from([0])),new Tt(a.length).toBuffer(),a,c.toBuffer(),u.toBuffer()],l=n.Buffer.concat(p),y=[{pubkey:r,isSigner:!1,isWritable:!1},{pubkey:s,isSigner:!0,isWritable:!0},{pubkey:o,isSigner:!1,isWritable:!0},{pubkey:i,isSigner:!1,isWritable:!1}];return f?y.push({pubkey:f,isSigner:!0,isWritable:!1}):y.push({pubkey:new t.PublicKey(n.Buffer.alloc(32)),isSigner:!1,isWritable:!1}),h?y.push({pubkey:h,isSigner:!1,isWritable:!1}):y.push({pubkey:new t.PublicKey(n.Buffer.alloc(32)),isSigner:!1,isWritable:!1}),d&&y.push({pubkey:d,isSigner:!0,isWritable:!1}),new t.TransactionInstruction({keys:y,programId:e,data:l})}function Yt(e,r,o,i,s){const a=[n.Buffer.from(Int8Array.from([1])),o.toBuffer(),new Tt(i.length).toBuffer(),i],c=n.Buffer.concat(a),u=[{pubkey:r,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!0,isWritable:!1}];return new t.TransactionInstruction({keys:u,programId:e,data:c})}function $t(e,r,o,i,s,a,c){const u=[n.Buffer.from(Int8Array.from([2])),o.toBuffer()],f=n.Buffer.concat(u),h=[{pubkey:r,isSigner:!1,isWritable:!0},{pubkey:c||i,isSigner:!0,isWritable:!1}];return s&&h.push({pubkey:s,isSigner:!0,isWritable:!1}),c&&a&&(s||h.push({pubkey:t.PublicKey.default,isSigner:!1,isWritable:!1}),h.push({pubkey:a,isSigner:!1,isWritable:!1})),new t.TransactionInstruction({keys:h,programId:e,data:f})}function Zt(e,r,o,i){const s=[n.Buffer.from(Int8Array.from([3]))],a=n.Buffer.concat(s),c=[{pubkey:r,isSigner:!1,isWritable:!0},{pubkey:i,isSigner:!0,isWritable:!1},{pubkey:o,isSigner:!1,isWritable:!0}];return new t.TransactionInstruction({keys:c,programId:e,data:a})}class Xt{constructor(t){this.tag=9,this.name=t.name,this.space=t.space}serialize(){return Ht(Xt.schema,this)}getInstruction(e,r,o,i,s,a,c,u,f,h,d){const l=n.Buffer.from(this.serialize()),y=[{pubkey:r,isSigner:!1,isWritable:!1},{pubkey:o,isSigner:!1,isWritable:!1},{pubkey:i,isSigner:!1,isWritable:!1},{pubkey:s,isSigner:!1,isWritable:!0},{pubkey:a,isSigner:!1,isWritable:!0},{pubkey:t.SystemProgram.programId,isSigner:!1,isWritable:!1},{pubkey:c,isSigner:!1,isWritable:!1},{pubkey:u,isSigner:!0,isWritable:!0},{pubkey:f,isSigner:!1,isWritable:!0},{pubkey:h,isSigner:!1,isWritable:!0},{pubkey:p,isSigner:!1,isWritable:!1},{pubkey:d,isSigner:!1,isWritable:!1}];return new t.TransactionInstruction({keys:y,programId:e,data:l})}}Xt.schema={struct:{tag:"u8",name:"string",space:"u32"}};class Qt{constructor(t){this.tag=12,this.name=t.name}serialize(){return Ht(Qt.schema,this)}getInstruction(e,r,o,i,s,a,c,u,f,h){const d=n.Buffer.from(this.serialize());let p=[];return p.push({pubkey:r,isSigner:!1,isWritable:!1}),p.push({pubkey:o,isSigner:!1,isWritable:!1}),p.push({pubkey:i,isSigner:!1,isWritable:!0}),p.push({pubkey:s,isSigner:!1,isWritable:!1}),p.push({pubkey:a,isSigner:!1,isWritable:!1}),p.push({pubkey:c,isSigner:!0,isWritable:!0}),p.push({pubkey:u,isSigner:!1,isWritable:!1}),f&&p.push({pubkey:f,isSigner:!1,isWritable:!0}),h&&p.push({pubkey:h,isSigner:!0,isWritable:!0}),new t.TransactionInstruction({keys:p,programId:e,data:d})}}Qt.schema={struct:{tag:"u8",name:"string"}};class Jt{constructor(t){this.tag=13,this.name=t.name,this.space=t.space,this.referrerIdxOpt=t.referrerIdxOpt}serialize(){return Ht(Jt.schema,this)}getInstruction(e,r,o,i,s,a,c,u,f,h,d,p,l,y,g,w,b){const m=n.Buffer.from(this.serialize());let v=[];return v.push({pubkey:r,isSigner:!1,isWritable:!1}),v.push({pubkey:o,isSigner:!1,isWritable:!1}),v.push({pubkey:i,isSigner:!1,isWritable:!0}),v.push({pubkey:s,isSigner:!1,isWritable:!0}),v.push({pubkey:a,isSigner:!1,isWritable:!1}),v.push({pubkey:c,isSigner:!1,isWritable:!1}),v.push({pubkey:u,isSigner:!0,isWritable:!0}),v.push({pubkey:f,isSigner:!1,isWritable:!0}),v.push({pubkey:h,isSigner:!1,isWritable:!1}),v.push({pubkey:d,isSigner:!1,isWritable:!1}),v.push({pubkey:p,isSigner:!1,isWritable:!1}),v.push({pubkey:l,isSigner:!1,isWritable:!0}),v.push({pubkey:y,isSigner:!1,isWritable:!1}),v.push({pubkey:g,isSigner:!1,isWritable:!1}),v.push({pubkey:w,isSigner:!1,isWritable:!1}),b&&v.push({pubkey:b,isSigner:!1,isWritable:!0}),new t.TransactionInstruction({keys:v,programId:e,data:m})}}Jt.schema={struct:{tag:"u8",name:"string",space:"u32",referrerIdxOpt:{option:"u16"}}};class te{constructor(t){this.tag=17,this.name=t.name,this.space=t.space}serialize(){return Ht(te.schema,this)}getInstruction(e,r,o,i,s,a,c,u,f,h,d,p,l,y,g,w,b){const m=n.Buffer.from(this.serialize());let v=[];return v.push({pubkey:r,isSigner:!1,isWritable:!1}),v.push({pubkey:o,isSigner:!1,isWritable:!1}),v.push({pubkey:i,isSigner:!1,isWritable:!0}),v.push({pubkey:s,isSigner:!1,isWritable:!0}),v.push({pubkey:a,isSigner:!1,isWritable:!1}),v.push({pubkey:c,isSigner:!1,isWritable:!1}),v.push({pubkey:u,isSigner:!0,isWritable:!0}),v.push({pubkey:f,isSigner:!1,isWritable:!0}),v.push({pubkey:h,isSigner:!1,isWritable:!0}),v.push({pubkey:d,isSigner:!1,isWritable:!0}),v.push({pubkey:p,isSigner:!1,isWritable:!0}),v.push({pubkey:l,isSigner:!1,isWritable:!0}),v.push({pubkey:y,isSigner:!1,isWritable:!1}),v.push({pubkey:g,isSigner:!1,isWritable:!1}),v.push({pubkey:w,isSigner:!1,isWritable:!1}),v.push({pubkey:b,isSigner:!1,isWritable:!1}),new t.TransactionInstruction({keys:v,programId:e,data:m})}}te.schema={struct:{tag:"u8",name:"string",space:"u32"}};class ee{constructor(){this.tag=16}serialize(){return Ht(ee.schema,this)}getInstruction(e,r,o,i,s,a,c,u,f,h){const d=n.Buffer.from(this.serialize());let p=[];return p.push({pubkey:r,isSigner:!1,isWritable:!1}),p.push({pubkey:o,isSigner:!1,isWritable:!1}),p.push({pubkey:i,isSigner:!1,isWritable:!0}),p.push({pubkey:s,isSigner:!1,isWritable:!0}),p.push({pubkey:a,isSigner:!1,isWritable:!0}),p.push({pubkey:c,isSigner:!1,isWritable:!0}),p.push({pubkey:u,isSigner:!1,isWritable:!1}),p.push({pubkey:f,isSigner:!0,isWritable:!1}),p.push({pubkey:h,isSigner:!1,isWritable:!0}),new t.TransactionInstruction({keys:p,programId:e,data:d})}}ee.schema={struct:{tag:"u8"}};const re=new t.PublicKey("nftD3vbNkNqfj2Sd3HZwbpw4BxxKWr4AjGb9X38JeZk"),ne=n.Buffer.from("tokenized_name"),oe=e=>{const[r]=t.PublicKey.findProgramAddressSync([ne,e.toBuffer()],re);return r};var ie;!function(t){t[t.Uninitialized=0]="Uninitialized",t[t.CentralState=1]="CentralState",t[t.ActiveRecord=2]="ActiveRecord",t[t.InactiveRecord=3]="InactiveRecord"}(ie||(ie={}));class se{constructor(e){this.tag=e.tag,this.nonce=e.nonce,this.nameAccount=new t.PublicKey(e.nameAccount),this.owner=new t.PublicKey(e.owner),this.nftMint=new t.PublicKey(e.nftMint)}static deserialize(t){return new se(Gt(this.schema,t))}static async retrieve(t,e){const r=await t.getAccountInfo(e);if(!r||!r.data)throw new Error("NFT record not found");return this.deserialize(r.data)}static async findKey(e,r){return await t.PublicKey.findProgramAddress([n.Buffer.from("nft_record"),e.toBuffer()],r)}}se.schema={struct:{tag:"u8",nonce:"u8",nameAccount:{array:{type:"u8",len:32}},owner:{array:{type:"u8",len:32}},nftMint:{array:{type:"u8",len:32}}}};const ae=async(e,r)=>{try{const[n]=await t.PublicKey.findProgramAddress([ne,r.toBuffer()],re);if("0"===(await St(e,n)).supply.toString())return;const o=[{memcmp:{offset:0,bytes:n.toBase58()}},{memcmp:{offset:64,bytes:"2"}},{dataSize:165}],i=await e.getProgramAccounts(p,{filters:o});if(1!=i.length)return;return new t.PublicKey(i[0].account.data.slice(32,64))}catch{return}},ce=t=>[{memcmp:{offset:32,bytes:t}},{memcmp:{offset:64,bytes:"2"}}],ue=async(t,e)=>{const r=await(async(t,e)=>{const r=[{memcmp:{offset:0,bytes:"3"}},{memcmp:{offset:66,bytes:e.toBase58()}}];return await t.getProgramAccounts(re,{filters:r})})(t,e.mint);if(1===r.length)return se.deserialize(r[0].account.data)},fe=async(t,e)=>{const r=[...ce(e.toBase58()),{dataSize:165}],n=(await t.getProgramAccounts(p,{filters:r})).map((t=>Et.decode(t.account.data))).map((e=>ue(t,e)));return(await Promise.all(n)).filter((t=>void 0!==t))};class he{constructor(e){this.parentName=new t.PublicKey(e.parentName),this.owner=new t.PublicKey(e.owner),this.class=new t.PublicKey(e.class)}static deserialize(t){const e=new he(Gt(this.schema,t));return e.data=null==t?void 0:t.slice(this.HEADER_LEN),e}static async retrieve(t,e){var r;const n=await t.getAccountInfo(e);if(!n)throw new kt(exports.ErrorType.AccountDoesNotExist);const o=new he(Gt(this.schema,n.data));o.data=null===(r=n.data)||void 0===r?void 0:r.slice(this.HEADER_LEN);return{registry:o,nftOwner:await ae(t,e)}}static async _retrieveBatch(t,e){const r=await t.getMultipleAccountsInfo(e),n=t=>{if(!t)return;const e=new he(Gt(this.schema,t));return e.data=null==t?void 0:t.slice(this.HEADER_LEN),e};return r.map((t=>n(null==t?void 0:t.data)))}static async retrieveBatch(t,e){let r=[];const n=[...e];for(;n.length>0;)r.push(...await this._retrieveBatch(t,n.splice(0,100)));return r}}function de(t,...e){if(!function(t){return t instanceof Uint8Array||null!=t&&"object"==typeof t&&"Uint8Array"===t.constructor.name}(t))throw new Error("Expected Uint8Array");if(e.length>0&&!e.includes(t.length))throw new Error(`Expected Uint8Array of length ${e}, not of length=${t.length}`)}function pe(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}he.HEADER_LEN=96,he.schema={struct:{parentName:{array:{type:"u8",len:32}},owner:{array:{type:"u8",len:32}},class:{array:{type:"u8",len:32}}}};const le="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0;
|
|
11
|
+
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function ye(t){return t instanceof Uint8Array||null!=t&&"object"==typeof t&&"Uint8Array"===t.constructor.name}const ge=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),we=(t,e)=>t<<32-e|t>>>e;if(!(68===new Uint8Array(new Uint32Array([287454020]).buffer)[0]))throw new Error("Non little-endian hardware is not supported");function be(t){if("string"!=typeof t)throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array((new TextEncoder).encode(t))}function me(t){if("string"==typeof t&&(t=be(t)),!ye(t))throw new Error("expected Uint8Array, got "+typeof t);return t}class ve{clone(){return this._cloneInto()}}function Ee(t){const e=e=>t().update(me(e)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}class xe extends ve{constructor(t,e,r,n){super(),this.blockLen=t,this.outputLen=e,this.padOffset=r,this.isLE=n,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=ge(this.buffer)}update(t){pe(this);const{view:e,buffer:r,blockLen:n}=this,o=(t=me(t)).length;for(let i=0;i<o;){const s=Math.min(n-this.pos,o-i);if(s!==n)r.set(t.subarray(i,i+s),this.pos),this.pos+=s,i+=s,this.pos===n&&(this.process(e,0),this.pos=0);else{const e=ge(t);for(;n<=o-i;i+=n)this.process(e,i)}}return this.length+=t.length,this.roundClean(),this}digestInto(t){pe(this),function(t,e){de(t);const r=e.outputLen;if(t.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}(t,this),this.finished=!0;const{buffer:e,view:r,blockLen:n,isLE:o}=this;let{pos:i}=this;e[i++]=128,this.buffer.subarray(i).fill(0),this.padOffset>n-i&&(this.process(r,0),i=0);for(let t=i;t<n;t++)e[t]=0;!function(t,e,r,n){if("function"==typeof t.setBigUint64)return t.setBigUint64(e,r,n);const o=BigInt(32),i=BigInt(4294967295),s=Number(r>>o&i),a=Number(r&i),c=n?4:0,u=n?0:4;t.setUint32(e+c,s,n),t.setUint32(e+u,a,n)}(r,n-8,BigInt(8*this.length),o),this.process(r,0);const s=ge(t),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const c=a/4,u=this.get();if(c>u.length)throw new Error("_sha2: outputLen bigger than state");for(let t=0;t<c;t++)s.setUint32(4*t,u[t],o)}digest(){const{buffer:t,outputLen:e}=this;this.digestInto(t);const r=t.slice(0,e);return this.destroy(),r}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:e,buffer:r,length:n,finished:o,destroyed:i,pos:s}=this;return t.length=n,t.pos=s,t.finished=o,t.destroyed=i,n%e&&t.buffer.set(r),t}}const Ae=(t,e,r)=>t&e^~t&r,Ie=(t,e,r)=>t&e^t&r^e&r,Se=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Be=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Re=new Uint32Array(64);class Pe extends xe{constructor(){super(64,32,8,!1),this.A=0|Be[0],this.B=0|Be[1],this.C=0|Be[2],this.D=0|Be[3],this.E=0|Be[4],this.F=0|Be[5],this.G=0|Be[6],this.H=0|Be[7]}get(){const{A:t,B:e,C:r,D:n,E:o,F:i,G:s,H:a}=this;return[t,e,r,n,o,i,s,a]}set(t,e,r,n,o,i,s,a){this.A=0|t,this.B=0|e,this.C=0|r,this.D=0|n,this.E=0|o,this.F=0|i,this.G=0|s,this.H=0|a}process(t,e){for(let r=0;r<16;r++,e+=4)Re[r]=t.getUint32(e,!1);for(let t=16;t<64;t++){const e=Re[t-15],r=Re[t-2],n=we(e,7)^we(e,18)^e>>>3,o=we(r,17)^we(r,19)^r>>>10;Re[t]=o+Re[t-7]+n+Re[t-16]|0}let{A:r,B:n,C:o,D:i,E:s,F:a,G:c,H:u}=this;for(let t=0;t<64;t++){const e=u+(we(s,6)^we(s,11)^we(s,25))+Ae(s,a,c)+Se[t]+Re[t]|0,f=(we(r,2)^we(r,13)^we(r,22))+Ie(r,n,o)|0;u=c,c=a,a=s,s=i+e|0,i=o,o=n,n=r,r=e+f|0}r=r+this.A|0,n=n+this.B|0,o=o+this.C|0,i=i+this.D|0,s=s+this.E|0,a=a+this.F|0,c=c+this.G|0,u=u+this.H|0,this.set(r,n,o,i,s,a,c,u)}roundClean(){Re.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const ke=Ee((()=>new Pe)),Te=new t.PublicKey("namesLPneVptA9Z5rqUDD9tMTWEJwofgaYwp8cawRkX"),_e="SPL Name Service",Ue=new t.PublicKey("58PwtjSDuFHuUkYjH9BYnnQKHfwo9reZhC2zMJv9JPkx"),Le=new t.PublicKey("jCebN34bUfdeUYJT13J1yG16XWQpt5PDx6Mse9GUqhR"),Ce=new t.PublicKey("ETp9eKXVv1dWwHSpsXRUuXHmw24PwRkttCGVgpZEY9zF"),Oe=new t.PublicKey("AUoZ3YAhV3b2rZeEH93UMZHXUZcTramBvb4d9YEVySkc"),Ne=new t.PublicKey("33m47vH6Eav6jr5Ry86XjhRft2jRBLDnDgPSHoquXi2Z"),De=new t.PublicKey("FvPH7PrVrLGKPfqaf3xJodFTjZriqrAXXLTVWEorTFBi"),Me=new t.PublicKey("4YcexoW3r78zz16J2aqmukBLRwGq6rAvWzJpkYAXqebv"),Ve=new t.PublicKey("DmSyHDSM9eSLyvoLsPvDr5fRRFZ7Bfr3h3ULvWpgQaq7"),ze=new t.PublicKey("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"),We=[new t.PublicKey("3ogYncmMM5CmytsGCqKHydmXmKUZ6sGWvizkzqwT7zb1"),new t.PublicKey("DM1jJCkZZEwY5tmWbgvKRxsDFzXCdbfrYCCH1CtwguEs"),new t.PublicKey("ADCp4QXFajHrhy4f43pD6GJFtQLkdBY2mjS9DfCk7tNW"),new t.PublicKey("2XTgjw8yi1E3Etgj4CUyRD7Zk49gynH2U9gA5N2MY4NP"),new t.PublicKey("5oDWj8vr3vbcq9JZTtwXqrkCMZggMsDzNietvbr1BNfe"),new t.PublicKey("8kJqxAbqbPLGLMgB6FhLcnw2SiUEavx2aEGM3WQGhtJF"),new t.PublicKey("HemvJzwxvVpWBjPETpaseAH395WAxb2G73MeUfjVkK1u"),new t.PublicKey("7hMiiUtkH4StMPJxyAtvzXTUjecTniQ8czkCPusf5eSW"),new t.PublicKey("DGpjHo4yYA3NgHvhHTp3XfBFrESsx1DnhfTr8D881ZBM")],je=new Map([["EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v","USDC"],["Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB","USDT"],["So11111111111111111111111111111111111111112","SOL"],["EchesyfXePKdLtoiZSL8pBe8Myagyy8ZRqsACNCFGnvp","FIDA"],["mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So","MSOL"],["DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263","BONK"],["EPeUFDgHRxs9xxEPVaL6kfGQvCon7jmAWKVUHuux1Tpz","BAT"],["HZ1JovNiVvGrGNiiYvEozEVgZ58xaU3RKwX8eACQBCt3","PYTH"],["bSo13r4TkiE4KumL71LsHTPpL2euBYLFx6h9HP3piy1","BSOL"],["6McPRfPV6bY1e9hLxWyG54W9i9Epq75QBvXg2oetBVTB","INJ"]]),Fe=new Map([["EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",{price:"Gnt27xtC473ZT2Mw5u8wZ68Z3gULkSTb5DuxJy7eJotD",product:"8GWTTbNiXdmyZREXbjsZBmCRuzdPrW55dnZGDkTRjWvb"}],["Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB",{price:"3vxLXJqLqF3JG5TCbYycbKWRBbCJQLxQmBGCkyqEEefL",product:"Av6XyAMJnyi68FdsKSPYgzfXGjYrrt6jcAMwtvzLCqaM"}],["So11111111111111111111111111111111111111112",{price:"H6ARHf6YXhGYeQfUzQNGk6rDNnLBQKrenN712K4AQJEG",product:"ALP8SdU9oARYVLgLR7LrqMNCYBnhtnQz1cj6bwgwQmgj"}],["EchesyfXePKdLtoiZSL8pBe8Myagyy8ZRqsACNCFGnvp",{price:"ETp9eKXVv1dWwHSpsXRUuXHmw24PwRkttCGVgpZEY9zF",product:"HyEB4Goiv7QyfFStaBn49JqQzSTV1ybtVikwsMLH1f2M"}],["mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So",{price:"E4v1BBgoso9s64TQvmyownAVJbhbEPGyzA3qn4n46qj9",product:"BS2iAqT67j8hA9Jji4B8UpL3Nfw9kwPfU5s4qeaf1e7r"}],["DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263",{price:"8ihFLu5FimgTQ1Unh4dVyEHUGodJ5gJQCrQf4KUVB9bN",product:"FerFD54J6RgmQVCR5oNgpzXmz8BW2eBNhhirb1d5oifo"}],["EPeUFDgHRxs9xxEPVaL6kfGQvCon7jmAWKVUHuux1Tpz",{price:"AbMTYZ82Xfv9PtTQ5e1fJXemXjzqEEFHP3oDLRTae6yz",product:"8xTEctXKo6Xo3EzNhSNp4TUe8mgfwWFbDUXJhuubvrKx"}],["HZ1JovNiVvGrGNiiYvEozEVgZ58xaU3RKwX8eACQBCt3",{price:"nrYkQQQur7z8rYTST3G9GqATviK5SxTDkrqd21MW6Ue",product:"AiQB4WngNPKDe3iWAwZmMzbULDAAfUD6Sr1knfZNJj3y"}],["bSo13r4TkiE4KumL71LsHTPpL2euBYLFx6h9HP3piy1",{price:"AFrYBhb5wKQtxRS9UA9YRS4V3dwFm7SqmS6DHKq6YVgo",product:"3RtUHQR2LQ7su5R4zWwjupx72sWRGvLA4cFmnbHnT9M7"}],["6McPRfPV6bY1e9hLxWyG54W9i9Epq75QBvXg2oetBVTB",{price:"9EdtbaivHQYA4Nh3XzGR6DwRaoorqXYnmpfsnFhvwuVj",product:"5Q5kyCVzssrGMd2BniSdVeRwjNWrGGrFhMrgGt4zURyA"}]]),Ke=new t.PublicKey("AHtgzX45WTKfkPG53L6WYhGEXwQkN1BVknET3sVsLL8J"),He=new t.PublicKey("GcWEQ9K78FV7LEHteFVciYApERk5YvQuFDQPk1yYJVXi"),Ge=new t.PublicKey("BPeXUQDqGbzxeK1LJby6ugvCBuo7kRSEUkjD726mUVsz"),qe=new t.PublicKey("72aLKvXeV4aansAQtxKymeXDevT5ed6sCuz9iN62ugPT"),Ye=new t.PublicKey("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s");async function $e(t,e){if(!await t.getAccountInfo(e))throw new kt(exports.ErrorType.AccountDoesNotExist);return he.retrieve(t,e)}async function Ze(t){const e=_e+t,r=ke(n.Buffer.from(e,"utf8"));return n.Buffer.from(r)}async function Xe(e,r,o){const i=[e];r?i.push(r.toBuffer()):i.push(n.Buffer.alloc(32)),o?i.push(o.toBuffer()):i.push(n.Buffer.alloc(32));const[s]=await t.PublicKey.findProgramAddress(i,Te);return s}const Qe=async(t,e=Ue)=>{let r=await Ze(t);return{pubkey:await Xe(r,void 0,e),hashed:r}},Je=async(t,e=!1)=>{t.endsWith(".sol")&&(t=t.slice(0,-4));const r=t.split(".");if(2===r.length){const t=n.Buffer.from([e?1:0]).toString().concat(r[0]),{pubkey:o}=await Qe(r[1]);return{...await Qe(t,o),isSub:!0,parent:o}}if(3===r.length&&e){const{pubkey:t}=await Qe(r[2]),{pubkey:e}=await Qe("\0".concat(r[1]),t),o=n.Buffer.from([1]).toString();return{...await Qe(o.concat(r[0]),e),isSub:!0,parent:t,isSubRecord:!0}}if(r.length>=3)throw new kt(exports.ErrorType.InvalidInput);return{...await Qe(t,Ue),isSub:!1,parent:void 0}};var tr,er=["u8","u16","u32","u64","u128","i8","i16","i32","i64","i128","f32","f64"],rr=function(){function t(){this.offset=0,this.buffer_size=256,this.buffer=new ArrayBuffer(this.buffer_size),this.view=new DataView(this.buffer)}return t.prototype.resize_if_necessary=function(t){if(this.buffer_size-this.offset<t){this.buffer_size=Math.max(2*this.buffer_size,this.buffer_size+t);var e=new ArrayBuffer(this.buffer_size);new Uint8Array(e).set(new Uint8Array(this.buffer)),this.buffer=e,this.view=new DataView(e)}},t.prototype.get_used_buffer=function(){return new Uint8Array(this.buffer).slice(0,this.offset)},t.prototype.store_value=function(t,e){var r=e.substring(1),n=parseInt(r)/8;this.resize_if_necessary(n);var o="f"===e[0]?"setFloat".concat(r):"i"===e[0]?"setInt".concat(r):"setUint".concat(r);this.view[o](this.offset,t,!0),this.offset+=n},t.prototype.store_bytes=function(t){this.resize_if_necessary(t.length),new Uint8Array(this.buffer).set(new Uint8Array(t),this.offset),this.offset+=t.length},t}(),nr=function(){function t(t){this.offset=0,this.buffer_size=t.length,this.buffer=new ArrayBuffer(t.length),new Uint8Array(this.buffer).set(t),this.view=new DataView(this.buffer)}return t.prototype.assert_enough_buffer=function(t){if(this.offset+t>this.buffer.byteLength)throw new Error("Error in schema, the buffer is smaller than expected")},t.prototype.consume_value=function(t){var e=t.substring(1),r=parseInt(e)/8;this.assert_enough_buffer(r);var n="f"===t[0]?"getFloat".concat(e):"i"===t[0]?"getInt".concat(e):"getUint".concat(e),o=this.view[n](this.offset,!0);return this.offset+=r,o},t.prototype.consume_bytes=function(t){this.assert_enough_buffer(t);var e=this.buffer.slice(this.offset,this.offset+t);return this.offset+=t,e},t}(),or=(tr=function(t,e){return tr=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},tr(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}tr(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)});function ir(t,e,r){if(typeof t!==e)throw new Error("Expected ".concat(e," not ").concat(typeof t,"(").concat(t,") at ").concat(r.join(".")))}function sr(t,e,r){if(t!==e)throw new Error("Array length ".concat(t," does not match schema length ").concat(e," at ").concat(r.join(".")))}var ar=er.concat(["bool","string"]),cr=["option","enum","array","set","map","struct"],ur=function(t){function e(e,r){var n="Invalid schema: ".concat(JSON.stringify(e)," expected ").concat(r);return t.call(this,n)||this}return or(e,t),e}(Error);function fr(t){if("string"!=typeof t||!ar.includes(t)){if(t&&"object"==typeof t){var e=Object.keys(t);if(1===e.length&&cr.includes(e[0])){var r=e[0];if("option"===r)return fr(t[r]);if("enum"===r)return function(t){if(!Array.isArray(t))throw new ur(t,"Array");for(var e=0,r=t;e<r.length;e++){var n=r[e];if("object"!=typeof n||!("struct"in n))throw new Error('Missing "struct" key in enum schema');if("object"!=typeof n.struct||1!==Object.keys(n.struct).length)throw new Error('The "struct" in each enum must have a single key');fr({struct:n.struct})}}(t[r]);if("array"===r)return function(t){if("object"!=typeof t)throw new ur(t,"{ type, len? }");if(t.len&&"number"!=typeof t.len)throw new Error("Invalid schema: ".concat(t));if("type"in t)return fr(t.type);throw new ur(t,"{ type, len? }")}(t[r]);if("set"===r)return fr(t[r]);if("map"===r)return function(t){if("object"!=typeof t||!("key"in t)||!("value"in t))throw new ur(t,"{ key, value }");fr(t.key),fr(t.value)}(t[r]);if("struct"===r)return function(t){if("object"!=typeof t)throw new ur(t,"object");for(var e in t)fr(t[e])}(t[r])}}throw new ur(t,cr.join(", ")+" or "+ar.join(", "))}}var hr=function(){function t(t){this.encoded=new rr,this.fieldPath=["value"],this.checkTypes=t}return t.prototype.encode=function(t,e){return this.encode_value(t,e),this.encoded.get_used_buffer()},t.prototype.encode_value=function(t,e){if("string"==typeof e){if(er.includes(e))return this.encode_integer(t,e);if("string"===e)return this.encode_string(t);if("bool"===e)return this.encode_boolean(t)}if("object"==typeof e){if("option"in e)return this.encode_option(t,e);if("enum"in e)return this.encode_enum(t,e);if("array"in e)return this.encode_array(t,e);if("set"in e)return this.encode_set(t,e);if("map"in e)return this.encode_map(t,e);if("struct"in e)return this.encode_struct(t,e)}},t.prototype.encode_integer=function(t,e){var r=parseInt(e.substring(1));r<=32||"f64"==e?(this.checkTypes&&ir(t,"number",this.fieldPath),this.encoded.store_value(t,e)):(this.checkTypes&&function(t,e){if(!(["number","string","bigint","boolean"].includes(typeof t)||"object"==typeof t&&null!==t&&"toString"in t))throw new Error("Expected bigint, number, boolean or string not ".concat(typeof t,"(").concat(t,") at ").concat(e.join(".")))}(t,this.fieldPath),this.encode_bigint(BigInt(t),r))},t.prototype.encode_bigint=function(t,e){for(var r=e/8,n=new Uint8Array(r),o=0;o<r;o++)n[o]=Number(t&BigInt(255)),t>>=BigInt(8);this.encoded.store_bytes(new Uint8Array(n))},t.prototype.encode_string=function(t){this.checkTypes&&ir(t,"string",this.fieldPath);var e=t;this.encoded.store_value(e.length,"u32");for(var r=0;r<e.length;r++)this.encoded.store_value(e.charCodeAt(r),"u8")},t.prototype.encode_boolean=function(t){this.checkTypes&&ir(t,"boolean",this.fieldPath),this.encoded.store_value(t?1:0,"u8")},t.prototype.encode_option=function(t,e){null==t?this.encoded.store_value(0,"u8"):(this.encoded.store_value(1,"u8"),this.encode_value(t,e.option))},t.prototype.encode_enum=function(t,e){this.checkTypes&&function(t,e){if("object"!=typeof t||null===t)throw new Error("Expected object not ".concat(typeof t,"(").concat(t,") at ").concat(e.join(".")))}(t,this.fieldPath);for(var r=Object.keys(t)[0],n=0;n<e.enum.length;n++){var o=e.enum[n];if(r===Object.keys(o.struct)[0])return this.encoded.store_value(n,"u8"),this.encode_struct(t,o)}throw new Error("Enum key (".concat(r,") not found in enum schema: ").concat(JSON.stringify(e)," at ").concat(this.fieldPath.join(".")))},t.prototype.encode_array=function(t,e){if(function(t){return Array.isArray(t)||!!t&&"object"==typeof t&&"length"in t&&"number"==typeof t.length&&(0===t.length||t.length>0&&t.length-1 in t)}(t))return this.encode_arraylike(t,e);if(t instanceof ArrayBuffer)return this.encode_buffer(t,e);throw new Error("Expected Array-like not ".concat(typeof t,"(").concat(t,") at ").concat(this.fieldPath.join(".")))},t.prototype.encode_arraylike=function(t,e){e.array.len?sr(t.length,e.array.len,this.fieldPath):this.encoded.store_value(t.length,"u32");for(var r=0;r<t.length;r++)this.encode_value(t[r],e.array.type)},t.prototype.encode_buffer=function(t,e){e.array.len?sr(t.byteLength,e.array.len,this.fieldPath):this.encoded.store_value(t.byteLength,"u32"),this.encoded.store_bytes(new Uint8Array(t))},t.prototype.encode_set=function(t,e){this.checkTypes&&ir(t,"object",this.fieldPath);var r=t instanceof Set?Array.from(t.values()):Object.values(t);this.encoded.store_value(r.length,"u32");for(var n=0,o=r;n<o.length;n++){var i=o[n];this.encode_value(i,e.set)}},t.prototype.encode_map=function(t,e){this.checkTypes&&ir(t,"object",this.fieldPath);var r=t instanceof Map,n=r?Array.from(t.keys()):Object.keys(t);this.encoded.store_value(n.length,"u32");for(var o=0,i=n;o<i.length;o++){var s=i[o];this.encode_value(s,e.map.key),this.encode_value(r?t.get(s):t[s],e.map.value)}},t.prototype.encode_struct=function(t,e){this.checkTypes&&ir(t,"object",this.fieldPath);for(var r=0,n=Object.keys(e.struct);r<n.length;r++){var o=n[r];this.fieldPath.push(o),this.encode_value(t[o],e.struct[o]),this.fieldPath.pop()}},t}(),dr=function(){function t(t){this.buffer=new nr(t)}return t.prototype.decode=function(t){return this.decode_value(t)},t.prototype.decode_value=function(t){if("string"==typeof t){if(er.includes(t))return this.decode_integer(t);if("string"===t)return this.decode_string();if("bool"===t)return this.decode_boolean()}if("object"==typeof t){if("option"in t)return this.decode_option(t);if("enum"in t)return this.decode_enum(t);if("array"in t)return this.decode_array(t);if("set"in t)return this.decode_set(t);if("map"in t)return this.decode_map(t);if("struct"in t)return this.decode_struct(t)}throw new Error("Unsupported type: ".concat(t))},t.prototype.decode_integer=function(t){var e=parseInt(t.substring(1));return e<=32||"f64"==t?this.buffer.consume_value(t):this.decode_bigint(e,t.startsWith("i"))},t.prototype.decode_bigint=function(t,e){void 0===e&&(e=!1);var r=t/8,n=new Uint8Array(this.buffer.consume_bytes(r)),o=n.reduceRight((function(t,e){return t+e.toString(16).padStart(2,"0")}),"");return e&&n[r-1]?BigInt.asIntN(t,BigInt("0x".concat(o))):BigInt("0x".concat(o))},t.prototype.decode_string=function(){var t=this.decode_integer("u32"),e=new Uint8Array(this.buffer.consume_bytes(t));return String.fromCharCode.apply(null,e)},t.prototype.decode_boolean=function(){return this.buffer.consume_value("u8")>0},t.prototype.decode_option=function(t){var e=this.buffer.consume_value("u8");if(1===e)return this.decode_value(t.option);if(0!==e)throw new Error("Invalid option ".concat(e));return null},t.prototype.decode_enum=function(t){var e,r=this.buffer.consume_value("u8");if(r>t.enum.length)throw new Error("Enum option ".concat(r," is not available"));var n=t.enum[r].struct,o=Object.keys(n)[0];return(e={})[o]=this.decode_value(n[o]),e},t.prototype.decode_array=function(t){for(var e=[],r=t.array.len?t.array.len:this.decode_integer("u32"),n=0;n<r;++n)e.push(this.decode_value(t.array.type));return e},t.prototype.decode_set=function(t){for(var e=this.decode_integer("u32"),r=new Set,n=0;n<e;++n)r.add(this.decode_value(t.set));return r},t.prototype.decode_map=function(t){for(var e=this.decode_integer("u32"),r=new Map,n=0;n<e;++n){var o=this.decode_value(t.map.key),i=this.decode_value(t.map.value);r.set(o,i)}return r},t.prototype.decode_struct=function(t){var e={};for(var r in t.struct)e[r]=this.decode_value(t.struct[r]);return e},t}();function pr(t,e,r){return void 0===r&&(r=!0),r&&fr(t),new hr(r).encode(e,t)}class lr{constructor(t){this.tag=1,this.record=t.record,this.content=t.content}serialize(){return pr(lr.schema,this)}getInstruction(e,r,n,o,i,s,a,c){const u=Buffer.from(this.serialize());let f=[];return f.push({pubkey:r,isSigner:!1,isWritable:!1}),f.push({pubkey:n,isSigner:!1,isWritable:!1}),f.push({pubkey:o,isSigner:!0,isWritable:!0}),f.push({pubkey:i,isSigner:!1,isWritable:!0}),f.push({pubkey:s,isSigner:!1,isWritable:!0}),f.push({pubkey:a,isSigner:!0,isWritable:!0}),f.push({pubkey:c,isSigner:!1,isWritable:!1}),new t.TransactionInstruction({keys:f,programId:e,data:u})}}lr.schema={struct:{tag:"u8",record:"string",content:{array:{type:"u8"}}}};class yr{constructor(t){this.tag=4,this.validation=t.validation,this.signature=t.signature,this.expectedPubkey=t.expectedPubkey}serialize(){return pr(yr.schema,this)}getInstruction(e,r,n,o,i,s,a,c){const u=Buffer.from(this.serialize());let f=[];return f.push({pubkey:r,isSigner:!1,isWritable:!1}),f.push({pubkey:n,isSigner:!1,isWritable:!1}),f.push({pubkey:o,isSigner:!0,isWritable:!0}),f.push({pubkey:i,isSigner:!1,isWritable:!0}),f.push({pubkey:s,isSigner:!1,isWritable:!0}),f.push({pubkey:a,isSigner:!0,isWritable:!0}),f.push({pubkey:c,isSigner:!1,isWritable:!1}),new t.TransactionInstruction({keys:f,programId:e,data:u})}}yr.schema={struct:{tag:"u8",validation:"u8",signature:{array:{type:"u8"}},expectedPubkey:{array:{type:"u8"}}}};class gr{constructor(t){this.tag=3,this.staleness=t.staleness}serialize(){return pr(gr.schema,this)}getInstruction(e,r,n,o,i,s,a,c,u){const f=Buffer.from(this.serialize());let h=[];return h.push({pubkey:r,isSigner:!1,isWritable:!1}),h.push({pubkey:n,isSigner:!1,isWritable:!1}),h.push({pubkey:o,isSigner:!0,isWritable:!0}),h.push({pubkey:i,isSigner:!1,isWritable:!0}),h.push({pubkey:s,isSigner:!1,isWritable:!0}),h.push({pubkey:a,isSigner:!1,isWritable:!0}),h.push({pubkey:c,isSigner:!1,isWritable:!1}),h.push({pubkey:u,isSigner:!0,isWritable:!0}),new t.TransactionInstruction({keys:h,programId:e,data:f})}}gr.schema={struct:{tag:"u8",staleness:"bool"}};class wr{constructor(t){this.tag=2,this.record=t.record,this.content=t.content}serialize(){return pr(wr.schema,this)}getInstruction(e,r,n,o,i,s,a,c){const u=Buffer.from(this.serialize());let f=[];return f.push({pubkey:r,isSigner:!1,isWritable:!1}),f.push({pubkey:n,isSigner:!1,isWritable:!1}),f.push({pubkey:o,isSigner:!0,isWritable:!0}),f.push({pubkey:i,isSigner:!1,isWritable:!0}),f.push({pubkey:s,isSigner:!1,isWritable:!0}),f.push({pubkey:a,isSigner:!0,isWritable:!0}),f.push({pubkey:c,isSigner:!1,isWritable:!1}),new t.TransactionInstruction({keys:f,programId:e,data:u})}}wr.schema={struct:{tag:"u8",record:"string",content:{array:{type:"u8"}}}};class br{constructor(){this.tag=5}serialize(){return pr(br.schema,this)}getInstruction(e,r,n,o,i,s,a,c){const u=Buffer.from(this.serialize());let f=[];return f.push({pubkey:r,isSigner:!1,isWritable:!1}),f.push({pubkey:n,isSigner:!1,isWritable:!1}),f.push({pubkey:o,isSigner:!0,isWritable:!0}),f.push({pubkey:i,isSigner:!1,isWritable:!0}),f.push({pubkey:s,isSigner:!1,isWritable:!0}),f.push({pubkey:a,isSigner:!0,isWritable:!0}),f.push({pubkey:c,isSigner:!1,isWritable:!1}),new t.TransactionInstruction({keys:f,programId:e,data:u})}}br.schema={struct:{tag:"u8"}};class mr{constructor(t){this.tag=6,this.roaId=t.roaId}serialize(){return pr(mr.schema,this)}getInstruction(e,r,n,o,i,s,a,c){const u=Buffer.from(this.serialize());let f=[];return f.push({pubkey:r,isSigner:!1,isWritable:!1}),f.push({pubkey:n,isSigner:!1,isWritable:!1}),f.push({pubkey:o,isSigner:!0,isWritable:!0}),f.push({pubkey:i,isSigner:!1,isWritable:!0}),f.push({pubkey:s,isSigner:!1,isWritable:!0}),f.push({pubkey:a,isSigner:!0,isWritable:!0}),f.push({pubkey:c,isSigner:!1,isWritable:!1}),new t.TransactionInstruction({keys:f,programId:e,data:u})}}mr.schema={struct:{tag:"u8",roaId:{array:{type:"u8"}}}};const vr=new t.PublicKey("HP3D4D1ZCmohQGFVms2SS4LCANgJyksBf5s1F77FuFjZ"),[Er]=t.PublicKey.findProgramAddressSync([vr.toBuffer()],vr);var xr,Ar;(Ar=xr||(xr={}))[Ar.None=0]="None",Ar[Ar.Solana=1]="Solana",Ar[Ar.Ethereum=2]="Ethereum",Ar[Ar.UnverifiedSolana=3]="UnverifiedSolana";const Ir=t=>{switch(t){case xr.None:return 0;case xr.Ethereum:return 20;case xr.Solana:case xr.UnverifiedSolana:return 32;default:throw new Error("Invalid validation enum")}};class Sr{constructor(t){this.stalenessValidation=t.stalenessValidation,this.rightOfAssociationValidation=t.rightOfAssociationValidation,this.contentLength=t.contentLength}static deserialize(t){return new Sr((e=this.schema,r=t,void 0===(n=!0)&&(n=!0),n&&fr(e),new dr(r).decode(e)));var e,r,n}static async retrieve(t,e){const r=await t.getAccountInfo(e);if(!r||!r.data)throw new Error("Record header account not found");return this.deserialize(r.data.slice(96,96+this.LEN))}}Sr.LEN=8,Sr.schema={struct:{stalenessValidation:"u16",rightOfAssociationValidation:"u16",contentLength:"u32"}};class Br{constructor(t,e){this.data=e,this.header=t}static deserialize(t){const e=Sr.deserialize(t.slice(96,96+Sr.LEN)),r=t.slice(96+Sr.LEN);return new Br(e,r)}static async retrieve(t,e){const r=await t.getAccountInfo(e);if(!r||!r.data)throw new Error("Record header account not found");return this.deserialize(r.data)}static async retrieveBatch(t,e){return(await t.getMultipleAccountsInfo(e)).map((t=>{if(null==t?void 0:t.data)return this.deserialize(t.data)}))}getContent(){let t=Ir(this.header.stalenessValidation)+Ir(this.header.rightOfAssociationValidation);return this.data.slice(t)}getStalenessId(){let t=Ir(this.header.stalenessValidation);return this.data.slice(0,t)}getRoAId(){let t=Ir(this.header.stalenessValidation),e=t+Ir(this.header.rightOfAssociationValidation);return this.data.slice(t,e)}}var Rr;exports.Record=void 0,(Rr=exports.Record||(exports.Record={})).IPFS="IPFS",Rr.ARWV="ARWV",Rr.SOL="SOL",Rr.ETH="ETH",Rr.BTC="BTC",Rr.LTC="LTC",Rr.DOGE="DOGE",Rr.Email="email",Rr.Url="url",Rr.Discord="discord",Rr.Github="github",Rr.Reddit="reddit",Rr.Twitter="twitter",Rr.Telegram="telegram",Rr.Pic="pic",Rr.SHDW="SHDW",Rr.POINT="POINT",Rr.BSC="BSC",Rr.Injective="INJ",Rr.Backpack="backpack",Rr.A="A",Rr.AAAA="AAAA",Rr.CNAME="CNAME",Rr.TXT="TXT",Rr.Background="background";const Pr=new Map([[exports.Record.SOL,96],[exports.Record.ETH,20],[exports.Record.BSC,20],[exports.Record.Injective,20],[exports.Record.A,4],[exports.Record.AAAA,16],[exports.Record.Background,32]]);var kr;exports.RecordVersion=void 0,(kr=exports.RecordVersion||(exports.RecordVersion={}))[kr.V1=1]="V1",kr[kr.V2=2]="V2";var Tr="ABAOAAAAAACwiAAAAYkHdvjtnH+IFkUYxx/v3vPe7uw8UkjsD43ChKICDQsT3iIJy4gSiZAjkn5JUFlaiFmjccT9ESkpGBGVIlQgWSkY/QDBoMgrQv0jRJDAfkCXhUmgRX23d4ebnndmd3Z3ZnfVeeDDzM7MPs8zv57Zd2+5hd1Ed4ClYAisBuuUsqLpMHgJjIBNFu1fBW8l1O8AO8Ee8Cn4HIyCg+CI0u4Y+AmMgVPgDOhuEHWBPjAZXAy2gjfA9kb73hlx+i7SK8AHYDf4BOwHB8AoOAyOguPgB/ArOKlcnwHdPe32/Uin9LTvvwTph0gv62nbubKnXT+nZ1z/DcjfFF8vQno7uEaxH923BGVXN9v5Zcgvj/VFPIT8Y/H1k0jXxPn1SEfARjBdab8V+TfB22CXUh5xd3OcZTH3g6di1LZJbLNs55q96M9n4J9Gm6hsfzQvcT8fbfy//TyUf8vG4Lses/5jcd2PSE/IcQan4/o/UXYadE0kaoJBMG1ivNbidNbETr1XoWyuplwyHFN0fFai/8/EY7BIKY/68EpCvwP+mc/m/2vNGnBhp1eZ51bCmgsEAoFAIBAIBAKBQKAO3Irfrg3lfc4qi/cXd+Kee5TfvAd6ieY0ie5D2cNx+eNInwZLmu33gWuRn4/8C3H9CNJNYEt8/TrS35HuSPktvRP1z0LPOvAceB4IsB5saIa6UBfqQl2oc123AjwBVjWrP7MCgcC5y/ue/56yqXv87+qcIU2Z+ny8tuHHpyxsvrDNITDXgqkDRJcPdJY/wMo24/oQmDqZaPHkdplAuhv8ApqDRDeCVj/OAvD9BUSX9qF8Qpt7lTxnZ7+5TmVtrGMM7XchP3sS0SNgGzg4yU5HIBAIBM5NfsO5QDgfjuM54STOw7/Az/F3QtfhfF4Qn9F/gxMouxm/WU7F9afBQuUM7+rtPF+jb0b6ese/I7sI+emadhEzUT5bqbsW+esNbSMWoG6hWo/8gOLPUqUu+v5rKEHX8oS6iEXQexd7XlmBe1aCNWAp6kSsYyjHc82Liv2Xkd/C/HkN1w/Geren+KryToa2PtlQg2c9zijGZnGJ9kaibzZh84jmmfx4TeYpK9H3usMKqxnDCWxsdLY/3ygy9h+l/LYbYHtuXw2/rfsSPo0a/Jrn6PvPrzL2+7CmfV88lkc9j+F7cRzYU4N48DF8uA3n/T7Fly9q4Jdvoth0uLf9LORC11hvO/0D6RnQfRa99+2Hr1NS/M26VvfEe2jaWTAOvG8zzgKf8zCrYL++qUEfbumeQAjTVnQp+QmW99gQpDoJ4+9uHZe5/l3OW/M8x6WUZaduUvUc5p13NTXlz3VpGbCVrGNe5zOnjvGlrDWY1IdWShuuQ9fWh6h+VSV1Wit1lvNhHFz1zeUYtCg5ntvOSStDW5cITRnF5RJ+rcasJHExztwu910tl6LzLYsvuvvzilB0mvSaxt/V+SY0EMurfkjbrTjfInf+FJGkNdzSlOukZaDo3snqs7RZpqj2Gx7sS52D5O79k+93W2W/T3NhQxe3VeF16pwn4eI8qev7Sl1s0PnPy5PalSV57Pp6XuDxrypR9wBR8nOCzm/eXuYp5d4s/lV1XvL+lG2b+2AaQ1nPr23Hrc7z0WT5qvZL0v7QtdX5zdu6HMei+gV1ri8et4XSVpCfdeB7fRWNRy79UP0RCT4Jyre/88bbKsQUawUrV69dxjd+nlXxbCKos79pz1BpOqucz0gEdZ5hMk+aa7Wdy/7xZ5Yqhc+nyHivrkyQ/reM7tziuFojfM7zxtq0505XYutvHrtVnzNl2ONrTGdPkLv9ZjNHOoShnCh5nLLYKOKfK4qK7bjx/gqyj9lFJc2Wz/HIqyMSYaGnqM8+xp6vB1/6feg22UmLFUno1rurvelz7yT1UVfORW3L7+d6fMcAXdzxIVK3TNNioZpSyj2242izpky6y5S0fpr6q5ZXJT7O1qrmQRVB+rkQ1Dk3vvYttyGoc+51/mUVkYLtXvTx7MCvbUnzW2czyR8pql4XUlbcN9l1pSfPfOl0JV2bylyKoM4959sHQfr9Vpbk2V8u4ry0ndcvH5I1xggP9qVem/PHZL+qeGLrc945tLnHtG/LEtdjr4urxMpM92X1RZDd+pLtsorUydeCaiuvbtdSpQ9l2M4SU01nvI1e35L3uS5Jlw8pe1ykCKo2JtrGK9O9ujOlimcD6Y9LEWQ+7019d2VDLVPrTCLrsvjsQ1TfJVJM12pZmm5b4Xptx6HM9SpFkP2c6drJa5/iSr+pD7r+CNLvATVfpST1RYog/fwKTdsyxLVNQfnWrkyziGltJK2hLLptzjHXIsh+/HytmyQfpPA5VNtzXWWLzbiVsc9sbWSJ7UWE69KNh6v9kya2c6TzMa0fwpD37TtvQ6wuiw9CA9cny33Mj2pLte9Kp6996HO/83HPQ5r+ov5mvU9Qte/fIrGJP7axPO/9eXX6kjLPKZNd17iyZdOHLP31JSbfXY6hC59c+ZZ136TZ9SFlj6cvmVkSrkSQn3NG5KBqEVSeH6Ji/vvnhFWjSlfFNDwzyMgqLvvKxXffbeASBWo+Zj4p2x6TfwE=",_r="AAACAAAAAACAOAAAAbYBSf7t2S1IBEEYBuDVDZ7FYrQMNsFiu3hgEYOI0SCXRIUrB8JhEZtgs5gEg1GMFk02m82oGI02m+9xezCOczv/uwv3fvAwc/PzfXOzcdqzWdaBDdiGPdiHdjE+DS3RNDuCfsn8idQ/g3OH3BdwKf0e96/gumTfYcncLdzBPTzAo+RZ+f0Cr/AG7/AJX4738x1wtz9FO5PX/50n6UXMNdfg/0lERERERERERERERETpdedHBvDRql4nq0cXtW9af98qdRby0Vvp8K4W0V+C5Xw0t4J2bfjeBp3cnEu1brnnCTYNa7eKdz91XP7WO9Lb4GqRb7cY6xbtAdqeVOsY/QGcevw/tb6OT85YhvfKYEx9CMuxKsKnrs+eJtVInVvHJ0eVYVvTZk2siFVLOCjb61PTZX3MdVWEyP7fjzpmMxdzTyq2Ebue6x61nXRGnzndWpf1an7dXmGYE4Y1ptqqKsK1nu26Ju0ty+maV2Rpvk+qnDZjKUIobUiesdAQE/jmCTmHmsskpFZsVYbtmXRcaoSGUPomunW2derQhDPFjtT1Q/eb8vnm990fq35oHVt11bU9m89c7DNI8Qs=",Ur=0,Lr=-3;function Cr(){this.table=new Uint16Array(16),this.trans=new Uint16Array(288)}function Or(t,e){this.source=t,this.sourceIndex=0,this.tag=0,this.bitcount=0,this.dest=e,this.destLen=0,this.ltree=new Cr,this.dtree=new Cr}var Nr=new Cr,Dr=new Cr,Mr=new Uint8Array(30),Vr=new Uint16Array(30),zr=new Uint8Array(30),Wr=new Uint16Array(30),jr=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Fr=new Cr,Kr=new Uint8Array(320);function Hr(t,e,r,n){var o,i;for(o=0;o<r;++o)t[o]=0;for(o=0;o<30-r;++o)t[o+r]=o/r|0;for(i=n,o=0;o<30;++o)e[o]=i,i+=1<<t[o]}var Gr=new Uint16Array(16);function qr(t,e,r,n){var o,i;for(o=0;o<16;++o)t.table[o]=0;for(o=0;o<n;++o)t.table[e[r+o]]++;for(t.table[0]=0,i=0,o=0;o<16;++o)Gr[o]=i,i+=t.table[o];for(o=0;o<n;++o)e[r+o]&&(t.trans[Gr[e[r+o]]++]=o)}function Yr(t){t.bitcount--||(t.tag=t.source[t.sourceIndex++],t.bitcount=7);var e=1&t.tag;return t.tag>>>=1,e}function $r(t,e,r){if(!e)return r;for(;t.bitcount<24;)t.tag|=t.source[t.sourceIndex++]<<t.bitcount,t.bitcount+=8;var n=t.tag&65535>>>16-e;return t.tag>>>=e,t.bitcount-=e,n+r}function Zr(t,e){for(;t.bitcount<24;)t.tag|=t.source[t.sourceIndex++]<<t.bitcount,t.bitcount+=8;var r=0,n=0,o=0,i=t.tag;do{n=2*n+(1&i),i>>>=1,++o,r+=e.table[o],n-=e.table[o]}while(n>=0);return t.tag=i,t.bitcount-=o,e.trans[r+n]}function Xr(t,e,r){var n,o,i,s,a,c;for(n=$r(t,5,257),o=$r(t,5,1),i=$r(t,4,4),s=0;s<19;++s)Kr[s]=0;for(s=0;s<i;++s){var u=$r(t,3,0);Kr[jr[s]]=u}for(qr(Fr,Kr,0,19),a=0;a<n+o;){var f=Zr(t,Fr);switch(f){case 16:var h=Kr[a-1];for(c=$r(t,2,3);c;--c)Kr[a++]=h;break;case 17:for(c=$r(t,3,3);c;--c)Kr[a++]=0;break;case 18:for(c=$r(t,7,11);c;--c)Kr[a++]=0;break;default:Kr[a++]=f}}qr(e,Kr,0,n),qr(r,Kr,n,o)}function Qr(t,e,r){for(;;){var n,o,i,s,a=Zr(t,e);if(256===a)return Ur;if(a<256)t.dest[t.destLen++]=a;else for(n=$r(t,Mr[a-=257],Vr[a]),o=Zr(t,r),s=i=t.destLen-$r(t,zr[o],Wr[o]);s<i+n;++s)t.dest[t.destLen++]=t.dest[s]}}function Jr(t){for(var e,r;t.bitcount>8;)t.sourceIndex--,t.bitcount-=8;if((e=256*(e=t.source[t.sourceIndex+1])+t.source[t.sourceIndex])!==(65535&~(256*t.source[t.sourceIndex+3]+t.source[t.sourceIndex+2])))return Lr;for(t.sourceIndex+=4,r=e;r;--r)t.dest[t.destLen++]=t.source[t.sourceIndex++];return t.bitcount=0,Ur}!function(t,e){var r;for(r=0;r<7;++r)t.table[r]=0;for(t.table[7]=24,t.table[8]=152,t.table[9]=112,r=0;r<24;++r)t.trans[r]=256+r;for(r=0;r<144;++r)t.trans[24+r]=r;for(r=0;r<8;++r)t.trans[168+r]=280+r;for(r=0;r<112;++r)t.trans[176+r]=144+r;for(r=0;r<5;++r)e.table[r]=0;for(e.table[5]=32,r=0;r<32;++r)e.trans[r]=r}(Nr,Dr),Hr(Mr,Vr,4,3),Hr(zr,Wr,2,1),Mr[28]=0,Vr[28]=258;var tn=function(t,e){var r,n,o=new Or(t,e);do{switch(r=Yr(o),$r(o,2,0)){case 0:n=Jr(o);break;case 1:n=Qr(o,Nr,Dr);break;case 2:Xr(o,o.ltree,o.dtree),n=Qr(o,o.ltree,o.dtree);break;default:n=Lr}if(n!==Ur)throw new Error("Data error")}while(!r);return o.destLen<o.dest.length?"function"==typeof o.dest.slice?o.dest.slice(0,o.destLen):o.dest.subarray(0,o.destLen):o.dest};const en=18===new Uint8Array(new Uint32Array([305419896]).buffer)[0],rn=(t,e,r)=>{let n=t[e];t[e]=t[r],t[r]=n};var nn={swap32LE:t=>{en&&(t=>{const e=t.length;for(let r=0;r<e;r+=4)rn(t,r,r+3),rn(t,r+1,r+2)})(t)}};const on=tn,{swap32LE:sn}=nn;var an=class{constructor(t){const e="function"==typeof t.readUInt32BE&&"function"==typeof t.slice;if(e||t instanceof Uint8Array){let r;if(e)this.highStart=t.readUInt32LE(0),this.errorValue=t.readUInt32LE(4),r=t.readUInt32LE(8),t=t.slice(12);else{const e=new DataView(t.buffer);this.highStart=e.getUint32(0,!0),this.errorValue=e.getUint32(4,!0),r=e.getUint32(8,!0),t=t.subarray(12)}t=on(t,new Uint8Array(r)),t=on(t,new Uint8Array(r)),sn(t),this.data=new Uint32Array(t.buffer)}else({data:this.data,highStart:this.highStart,errorValue:this.errorValue}=t)}get(t){let e;return t<0||t>1114111?this.errorValue:t<55296||t>56319&&t<=65535?(e=(this.data[t>>5]<<2)+(31&t),this.data[e]):t<=65535?(e=(this.data[2048+(t-55296>>5)]<<2)+(31&t),this.data[e]):t<this.highStart?(e=this.data[2080+(t>>11)],e=this.data[e+(t>>5&63)],e=(e<<2)+(31&t),this.data[e]):this.data[this.data.length-4]}},cn={exports:{}};"undefined"!=typeof self?self:"undefined"!=typeof window&&window,cn.exports=function(){var t="3.7.5",e=t,r="function"==typeof atob,n="function"==typeof btoa,o="function"==typeof Buffer,i="function"==typeof TextDecoder?new TextDecoder:void 0,s="function"==typeof TextEncoder?new TextEncoder:void 0,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",c=Array.prototype.slice.call(a),u=function(t){var e={};return t.forEach((function(t,r){return e[t]=r})),e}(c),f=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,h=String.fromCharCode.bind(String),d="function"==typeof Uint8Array.from?Uint8Array.from.bind(Uint8Array):function(t){return new Uint8Array(Array.prototype.slice.call(t,0))},p=function(t){return t.replace(/=/g,"").replace(/[+\/]/g,(function(t){return"+"==t?"-":"_"}))},l=function(t){return t.replace(/[^A-Za-z0-9\+\/]/g,"")},y=function(t){for(var e,r,n,o,i="",s=t.length%3,a=0;a<t.length;){if((r=t.charCodeAt(a++))>255||(n=t.charCodeAt(a++))>255||(o=t.charCodeAt(a++))>255)throw new TypeError("invalid character found");i+=c[(e=r<<16|n<<8|o)>>18&63]+c[e>>12&63]+c[e>>6&63]+c[63&e]}return s?i.slice(0,s-3)+"===".substring(s):i},g=n?function(t){return btoa(t)}:o?function(t){return Buffer.from(t,"binary").toString("base64")}:y,w=o?function(t){return Buffer.from(t).toString("base64")}:function(t){for(var e=4096,r=[],n=0,o=t.length;n<o;n+=e)r.push(h.apply(null,t.subarray(n,n+e)));return g(r.join(""))},b=function(t,e){return void 0===e&&(e=!1),e?p(w(t)):w(t)},m=function(t){if(t.length<2)return(e=t.charCodeAt(0))<128?t:e<2048?h(192|e>>>6)+h(128|63&e):h(224|e>>>12&15)+h(128|e>>>6&63)+h(128|63&e);var e=65536+1024*(t.charCodeAt(0)-55296)+(t.charCodeAt(1)-56320);return h(240|e>>>18&7)+h(128|e>>>12&63)+h(128|e>>>6&63)+h(128|63&e)},v=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,E=function(t){return t.replace(v,m)},x=o?function(t){return Buffer.from(t,"utf8").toString("base64")}:s?function(t){return w(s.encode(t))}:function(t){return g(E(t))},A=function(t,e){return void 0===e&&(e=!1),e?p(x(t)):x(t)},I=function(t){return A(t,!0)},S=/[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g,B=function(t){switch(t.length){case 4:var e=((7&t.charCodeAt(0))<<18|(63&t.charCodeAt(1))<<12|(63&t.charCodeAt(2))<<6|63&t.charCodeAt(3))-65536;return h(55296+(e>>>10))+h(56320+(1023&e));case 3:return h((15&t.charCodeAt(0))<<12|(63&t.charCodeAt(1))<<6|63&t.charCodeAt(2));default:return h((31&t.charCodeAt(0))<<6|63&t.charCodeAt(1))}},R=function(t){return t.replace(S,B)},P=function(t){if(t=t.replace(/\s+/g,""),!f.test(t))throw new TypeError("malformed base64.");t+="==".slice(2-(3&t.length));for(var e,r,n,o="",i=0;i<t.length;)e=u[t.charAt(i++)]<<18|u[t.charAt(i++)]<<12|(r=u[t.charAt(i++)])<<6|(n=u[t.charAt(i++)]),o+=64===r?h(e>>16&255):64===n?h(e>>16&255,e>>8&255):h(e>>16&255,e>>8&255,255&e);return o},k=r?function(t){return atob(l(t))}:o?function(t){return Buffer.from(t,"base64").toString("binary")}:P,T=o?function(t){return d(Buffer.from(t,"base64"))}:function(t){return d(k(t).split("").map((function(t){return t.charCodeAt(0)})))},_=function(t){return T(L(t))},U=o?function(t){return Buffer.from(t,"base64").toString("utf8")}:i?function(t){return i.decode(T(t))}:function(t){return R(k(t))},L=function(t){return l(t.replace(/[-_]/g,(function(t){return"-"==t?"+":"/"})))},C=function(t){return U(L(t))},O=function(t){if("string"!=typeof t)return!1;var e=t.replace(/\s+/g,"").replace(/={0,2}$/,"");return!/[^\s0-9a-zA-Z\+/]/.test(e)||!/[^\s0-9a-zA-Z\-_]/.test(e)},N=function(t){return{value:t,enumerable:!1,writable:!0,configurable:!0}},D=function(){var t=function(t,e){return Object.defineProperty(String.prototype,t,N(e))};t("fromBase64",(function(){return C(this)})),t("toBase64",(function(t){return A(this,t)})),t("toBase64URI",(function(){return A(this,!0)})),t("toBase64URL",(function(){return A(this,!0)})),t("toUint8Array",(function(){return _(this)}))},M=function(){var t=function(t,e){return Object.defineProperty(Uint8Array.prototype,t,N(e))};t("toBase64",(function(t){return b(this,t)})),t("toBase64URI",(function(){return b(this,!0)})),t("toBase64URL",(function(){return b(this,!0)}))},V=function(){D(),M()},z={version:t,VERSION:e,atob:k,atobPolyfill:P,btoa:g,btoaPolyfill:y,fromBase64:C,toBase64:A,encode:A,encodeURI:I,encodeURL:I,utob:E,btou:R,decode:C,isValid:O,fromUint8Array:b,toUint8Array:_,extendString:D,extendUint8Array:M,extendBuiltins:V,Base64:{}};return Object.keys(z).forEach((function(t){return z.Base64[t]=z[t]})),z}();const un={Other:0,CR:1,LF:2,Control:4,Extend:8,ZWJ:16,Regional_Indicator:32,Prepend:64,SpacingMark:128,L:256,V:512,T:1024,LV:2048,LVT:4096,Extended_Pictographic:8192},fn=Tr,hn=_r,dn=an,pn=cn.exports.Base64,ln=new dn(pn.toUint8Array(fn)),yn=new dn(pn.toUint8Array(hn));function gn(t,e){return 0!=(t&e)}const wn=0,bn=1,mn=2;function vn(t,e){const r=t.length;let n=0,o=wn;for(let i=e;i+1<r;i++){const r=t[i+0],s=t[i+1];switch(gn(r,un.Regional_Indicator)||(n=0),o){case mn:case wn:o=gn(r,un.Extended_Pictographic)?bn:wn;break;case bn:o=gn(r,un.Extend)?bn:gn(r,un.ZWJ)&&gn(s,un.Extended_Pictographic)?mn:wn}if(!gn(r,un.CR)||!gn(s,un.LF)){if(gn(r,un.Control|un.CR|un.LF))return i+1-e;if(gn(s,un.Control|un.CR|un.LF))return i+1-e;if(!(gn(r,un.L)&&gn(s,un.L|un.V|un.LV|un.LVT)||gn(r,un.LV|un.V)&&gn(s,un.V|un.T)||gn(r,un.LVT|un.T)&&gn(s,un.T)||gn(s,un.Extend|un.ZWJ)||gn(s,un.SpacingMark)||gn(r,un.Prepend)||o===mn)){if(!gn(r,un.Regional_Indicator)||!gn(s,un.Regional_Indicator)||n%2!=0)return i+1-e;n++}}}return r-e}var En=function(t){const e=[],r=[0],n=[];for(let e=0;e<t.length;){const o=t.codePointAt(e);n.push(ln.get(o)|yn.get(o)),e+=o>65535?2:1,r.push(e)}for(let o=0;o<n.length;){const i=vn(n,o),s=r[o],a=r[o+i];e.push(t.slice(s,a)),o+=i}return e},xn=r(En);const An=t=>{const e=_e+t,r=ke(n.Buffer.from(e,"utf8"));return n.Buffer.from(r)},In=(e,r,o)=>{const i=[e];r?i.push(r.toBuffer()):i.push(n.Buffer.alloc(32)),o?i.push(o.toBuffer()):i.push(n.Buffer.alloc(32));const[s]=t.PublicKey.findProgramAddressSync(i,Te);return s};async function Sn(t,e){const r=An(e.toBase58()),n=In(r,Ne),{registry:o}=await he.retrieve(t,n);if(!o.data)throw new kt(exports.ErrorType.NoAccountData);return Ln(o.data)}async function Bn(t,e){let r=[];for(let t of e){const e=An(t.toBase58()),n=In(e,Ne);r.push(n)}return(await he.retrieveBatch(t,r)).map((t=>{if(void 0!==t&&void 0!==t.data)return Ln(t.data)}))}const Rn=(t,e=Ue,r)=>{let n=An(t);return{pubkey:In(n,r,e),hashed:n}},Pn=(t,e)=>{t.endsWith(".sol")&&(t=t.slice(0,-4));const r=e===exports.RecordVersion.V2?Er:void 0,o=t.split(".");if(2===o.length){const t=n.Buffer.from([e||0]).toString().concat(o[0]),{pubkey:i}=Rn(o[1]);return{...Rn(t,i,r),isSub:!0,parent:i}}if(3===o.length&&e){const{pubkey:t}=Rn(o[2]),{pubkey:n}=Rn("\0".concat(o[1]),t),i=e===exports.RecordVersion.V2?"":"";return{...Rn(i.concat(o[0]),n,r),isSub:!0,parent:t,isSubRecord:!0}}if(o.length>=3)throw new kt(exports.ErrorType.InvalidInput);return{...Rn(t,Ue),isSub:!1,parent:void 0}};async function kn(t,e){const r=[{memcmp:{offset:32,bytes:e.toBase58()}},{memcmp:{offset:0,bytes:Ue.toBase58()}}];return(await t.getProgramAccounts(Te,{filters:r})).map((t=>t.pubkey))}const Tn=(t,e)=>{const{pubkey:r,parent:n}=Pn(t),o=An(r.toBase58());return In(o,Ne,e?n:void 0)},_n=(t,e)=>{const r=An(t.toBase58());return In(r,Ne,e)},Un=(t,e)=>{if(!t)throw new kt(e)};function Ln(t){if(!t)return;const e=t.slice(0,4).readUInt32LE(0);return t.slice(4,4+e).toString()}var Cn=function(t){if(t.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),r=0;r<e.length;r++)e[r]=255;for(var n=0;n<t.length;n++){var o=t.charAt(n),i=o.charCodeAt(0);if(255!==e[i])throw new TypeError(o+" is ambiguous");e[i]=n}var s=t.length,a=t.charAt(0),c=Math.log(s)/Math.log(256),u=Math.log(256)/Math.log(s);function f(t){if("string"!=typeof t)throw new TypeError("Expected String");if(0===t.length)return new Uint8Array;for(var r=0,n=0,o=0;t[r]===a;)n++,r++;for(var i=(t.length-r)*c+1>>>0,u=new Uint8Array(i);t[r];){var f=e[t.charCodeAt(r)];if(255===f)return;for(var h=0,d=i-1;(0!==f||h<o)&&-1!==d;d--,h++)f+=s*u[d]>>>0,u[d]=f%256>>>0,f=f/256>>>0;if(0!==f)throw new Error("Non-zero carry");o=h,r++}for(var p=i-o;p!==i&&0===u[p];)p++;for(var l=new Uint8Array(n+(i-p)),y=n;p!==i;)l[y++]=u[p++];return l}return{encode:function(e){if(e instanceof Uint8Array||(ArrayBuffer.isView(e)?e=new Uint8Array(e.buffer,e.byteOffset,e.byteLength):Array.isArray(e)&&(e=Uint8Array.from(e))),!(e instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===e.length)return"";for(var r=0,n=0,o=0,i=e.length;o!==i&&0===e[o];)o++,r++;for(var c=(i-o)*u+1>>>0,f=new Uint8Array(c);o!==i;){for(var h=e[o],d=0,p=c-1;(0!==h||d<n)&&-1!==p;p--,d++)h+=256*f[p]>>>0,f[p]=h%s>>>0,h=h/s>>>0;if(0!==h)throw new Error("Non-zero carry");n=d,o++}for(var l=c-n;l!==c&&0===f[l];)l++;for(var y=a.repeat(r);l<c;++l)y+=t.charAt(f[l]);return y},decodeUnsafe:f,decode:function(t){var e=f(t);if(e)return e;throw new Error("Non-base"+s+" character")}}};var On,Nn=Cn("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),Dn={exports:{}};On=Dn,function(t){const e="(0?\\d+|0x[a-f0-9]+)",r={fourOctet:new RegExp(`^${e}\\.${e}\\.${e}\\.${e}$`,"i"),threeOctet:new RegExp(`^${e}\\.${e}\\.${e}$`,"i"),twoOctet:new RegExp(`^${e}\\.${e}$`,"i"),longValue:new RegExp(`^${e}$`,"i")},n=new RegExp("^0[0-7]+$","i"),o=new RegExp("^0x[a-f0-9]+$","i"),i="%[0-9a-z]{1,}",s="(?:[0-9a-f]+::?)+",a={zoneIndex:new RegExp(i,"i"),native:new RegExp(`^(::)?(${s})?([0-9a-f]+)?(::)?(${i})?$`,"i"),deprecatedTransitional:new RegExp(`^(?:::)(${e}\\.${e}\\.${e}\\.${e}(${i})?)$`,"i"),transitional:new RegExp(`^((?:${s})|(?:::)(?:${s})?)${e}\\.${e}\\.${e}\\.${e}(${i})?$`,"i")};function c(t,e){if(t.indexOf("::")!==t.lastIndexOf("::"))return null;let r,n,o=0,i=-1,s=(t.match(a.zoneIndex)||[])[0];for(s&&(s=s.substring(1),t=t.replace(/%.+$/,""));(i=t.indexOf(":",i+1))>=0;)o++;if("::"===t.substr(0,2)&&o--,"::"===t.substr(-2,2)&&o--,o>e)return null;for(n=e-o,r=":";n--;)r+="0:";return":"===(t=t.replace("::",r))[0]&&(t=t.slice(1)),":"===t[t.length-1]&&(t=t.slice(0,-1)),e=function(){const e=t.split(":"),r=[];for(let t=0;t<e.length;t++)r.push(parseInt(e[t],16));return r}(),{parts:e,zoneId:s}}function u(t,e,r,n){if(t.length!==e.length)throw new Error("ipaddr: cannot match CIDR for objects with different lengths");let o,i=0;for(;n>0;){if(o=r-n,o<0&&(o=0),t[i]>>o!=e[i]>>o)return!1;n-=r,i+=1}return!0}function f(t){if(o.test(t))return parseInt(t,16);if("0"===t[0]&&!isNaN(parseInt(t[1],10))){if(n.test(t))return parseInt(t,8);throw new Error(`ipaddr: cannot parse ${t} as octal`)}return parseInt(t,10)}function h(t,e){for(;t.length<e;)t=`0${t}`;return t}const d={};d.IPv4=function(){function t(t){if(4!==t.length)throw new Error("ipaddr: ipv4 octet count should be 4");let e,r;for(e=0;e<t.length;e++)if(r=t[e],!(0<=r&&r<=255))throw new Error("ipaddr: ipv4 octet should fit in 8 bits");this.octets=t}return t.prototype.SpecialRanges={unspecified:[[new t([0,0,0,0]),8]],broadcast:[[new t([255,255,255,255]),32]],multicast:[[new t([224,0,0,0]),4]],linkLocal:[[new t([169,254,0,0]),16]],loopback:[[new t([127,0,0,0]),8]],carrierGradeNat:[[new t([100,64,0,0]),10]],private:[[new t([10,0,0,0]),8],[new t([172,16,0,0]),12],[new t([192,168,0,0]),16]],reserved:[[new t([192,0,0,0]),24],[new t([192,0,2,0]),24],[new t([192,88,99,0]),24],[new t([198,18,0,0]),15],[new t([198,51,100,0]),24],[new t([203,0,113,0]),24],[new t([240,0,0,0]),4]]},t.prototype.kind=function(){return"ipv4"},t.prototype.match=function(t,e){let r;if(void 0===e&&(r=t,t=r[0],e=r[1]),"ipv4"!==t.kind())throw new Error("ipaddr: cannot match ipv4 address with non-ipv4 one");return u(this.octets,t.octets,8,e)},t.prototype.prefixLengthFromSubnetMask=function(){let t=0,e=!1;const r={0:8,128:7,192:6,224:5,240:4,248:3,252:2,254:1,255:0};let n,o,i;for(n=3;n>=0;n-=1){if(o=this.octets[n],!(o in r))return null;if(i=r[o],e&&0!==i)return null;8!==i&&(e=!0),t+=i}return 32-t},t.prototype.range=function(){return d.subnetMatch(this,this.SpecialRanges)},t.prototype.toByteArray=function(){return this.octets.slice(0)},t.prototype.toIPv4MappedAddress=function(){return d.IPv6.parse(`::ffff:${this.toString()}`)},t.prototype.toNormalizedString=function(){return this.toString()},t.prototype.toString=function(){return this.octets.join(".")},t}(),d.IPv4.broadcastAddressFromCIDR=function(t){try{const e=this.parseCIDR(t),r=e[0].toByteArray(),n=this.subnetMaskFromPrefixLength(e[1]).toByteArray(),o=[];let i=0;for(;i<4;)o.push(parseInt(r[i],10)|255^parseInt(n[i],10)),i++;return new this(o)}catch(t){throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},d.IPv4.isIPv4=function(t){return null!==this.parser(t)},d.IPv4.isValid=function(t){try{return new this(this.parser(t)),!0}catch(t){return!1}},d.IPv4.isValidFourPartDecimal=function(t){return!(!d.IPv4.isValid(t)||!t.match(/^(0|[1-9]\d*)(\.(0|[1-9]\d*)){3}$/))},d.IPv4.networkAddressFromCIDR=function(t){let e,r,n,o,i;try{for(e=this.parseCIDR(t),n=e[0].toByteArray(),i=this.subnetMaskFromPrefixLength(e[1]).toByteArray(),o=[],r=0;r<4;)o.push(parseInt(n[r],10)&parseInt(i[r],10)),r++;return new this(o)}catch(t){throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},d.IPv4.parse=function(t){const e=this.parser(t);if(null===e)throw new Error("ipaddr: string is not formatted like an IPv4 Address");return new this(e)},d.IPv4.parseCIDR=function(t){let e;if(e=t.match(/^(.+)\/(\d+)$/)){const t=parseInt(e[2]);if(t>=0&&t<=32){const r=[this.parse(e[1]),t];return Object.defineProperty(r,"toString",{value:function(){return this.join("/")}}),r}}throw new Error("ipaddr: string is not formatted like an IPv4 CIDR range")},d.IPv4.parser=function(t){let e,n,o;if(e=t.match(r.fourOctet))return function(){const t=e.slice(1,6),r=[];for(let e=0;e<t.length;e++)n=t[e],r.push(f(n));return r}();if(e=t.match(r.longValue)){if(o=f(e[1]),o>4294967295||o<0)throw new Error("ipaddr: address outside defined range");return function(){const t=[];let e;for(e=0;e<=24;e+=8)t.push(o>>e&255);return t}().reverse()}return(e=t.match(r.twoOctet))?function(){const t=e.slice(1,4),r=[];if(o=f(t[1]),o>16777215||o<0)throw new Error("ipaddr: address outside defined range");return r.push(f(t[0])),r.push(o>>16&255),r.push(o>>8&255),r.push(255&o),r}():(e=t.match(r.threeOctet))?function(){const t=e.slice(1,5),r=[];if(o=f(t[2]),o>65535||o<0)throw new Error("ipaddr: address outside defined range");return r.push(f(t[0])),r.push(f(t[1])),r.push(o>>8&255),r.push(255&o),r}():null},d.IPv4.subnetMaskFromPrefixLength=function(t){if((t=parseInt(t))<0||t>32)throw new Error("ipaddr: invalid IPv4 prefix length");const e=[0,0,0,0];let r=0;const n=Math.floor(t/8);for(;r<n;)e[r]=255,r++;return n<4&&(e[n]=Math.pow(2,t%8)-1<<8-t%8),new this(e)},d.IPv6=function(){function t(t,e){let r,n;if(16===t.length)for(this.parts=[],r=0;r<=14;r+=2)this.parts.push(t[r]<<8|t[r+1]);else{if(8!==t.length)throw new Error("ipaddr: ipv6 part count should be 8 or 16");this.parts=t}for(r=0;r<this.parts.length;r++)if(n=this.parts[r],!(0<=n&&n<=65535))throw new Error("ipaddr: ipv6 part should fit in 16 bits");e&&(this.zoneId=e)}return t.prototype.SpecialRanges={unspecified:[new t([0,0,0,0,0,0,0,0]),128],linkLocal:[new t([65152,0,0,0,0,0,0,0]),10],multicast:[new t([65280,0,0,0,0,0,0,0]),8],loopback:[new t([0,0,0,0,0,0,0,1]),128],uniqueLocal:[new t([64512,0,0,0,0,0,0,0]),7],ipv4Mapped:[new t([0,0,0,0,0,65535,0,0]),96],rfc6145:[new t([0,0,0,0,65535,0,0,0]),96],rfc6052:[new t([100,65435,0,0,0,0,0,0]),96],"6to4":[new t([8194,0,0,0,0,0,0,0]),16],teredo:[new t([8193,0,0,0,0,0,0,0]),32],reserved:[[new t([8193,3512,0,0,0,0,0,0]),32]],benchmarking:[new t([8193,2,0,0,0,0,0,0]),48],amt:[new t([8193,3,0,0,0,0,0,0]),32],as112v6:[new t([8193,4,274,0,0,0,0,0]),48],deprecated:[new t([8193,16,0,0,0,0,0,0]),28],orchid2:[new t([8193,32,0,0,0,0,0,0]),28]},t.prototype.isIPv4MappedAddress=function(){return"ipv4Mapped"===this.range()},t.prototype.kind=function(){return"ipv6"},t.prototype.match=function(t,e){let r;if(void 0===e&&(r=t,t=r[0],e=r[1]),"ipv6"!==t.kind())throw new Error("ipaddr: cannot match ipv6 address with non-ipv6 one");return u(this.parts,t.parts,16,e)},t.prototype.prefixLengthFromSubnetMask=function(){let t=0,e=!1;const r={0:16,32768:15,49152:14,57344:13,61440:12,63488:11,64512:10,65024:9,65280:8,65408:7,65472:6,65504:5,65520:4,65528:3,65532:2,65534:1,65535:0};let n,o;for(let i=7;i>=0;i-=1){if(n=this.parts[i],!(n in r))return null;if(o=r[n],e&&0!==o)return null;16!==o&&(e=!0),t+=o}return 128-t},t.prototype.range=function(){return d.subnetMatch(this,this.SpecialRanges)},t.prototype.toByteArray=function(){let t;const e=[],r=this.parts;for(let n=0;n<r.length;n++)t=r[n],e.push(t>>8),e.push(255&t);return e},t.prototype.toFixedLengthString=function(){const t=function(){const t=[];for(let e=0;e<this.parts.length;e++)t.push(h(this.parts[e].toString(16),4));return t}.call(this).join(":");let e="";return this.zoneId&&(e=`%${this.zoneId}`),t+e},t.prototype.toIPv4Address=function(){if(!this.isIPv4MappedAddress())throw new Error("ipaddr: trying to convert a generic ipv6 address to ipv4");const t=this.parts.slice(-2),e=t[0],r=t[1];return new d.IPv4([e>>8,255&e,r>>8,255&r])},t.prototype.toNormalizedString=function(){const t=function(){const t=[];for(let e=0;e<this.parts.length;e++)t.push(this.parts[e].toString(16));return t}.call(this).join(":");let e="";return this.zoneId&&(e=`%${this.zoneId}`),t+e},t.prototype.toRFC5952String=function(){const t=/((^|:)(0(:|$)){2,})/g,e=this.toNormalizedString();let r,n=0,o=-1;for(;r=t.exec(e);)r[0].length>o&&(n=r.index,o=r[0].length);return o<0?e:`${e.substring(0,n)}::${e.substring(n+o)}`},t.prototype.toString=function(){return this.toRFC5952String()},t}(),d.IPv6.broadcastAddressFromCIDR=function(t){try{const e=this.parseCIDR(t),r=e[0].toByteArray(),n=this.subnetMaskFromPrefixLength(e[1]).toByteArray(),o=[];let i=0;for(;i<16;)o.push(parseInt(r[i],10)|255^parseInt(n[i],10)),i++;return new this(o)}catch(t){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${t})`)}},d.IPv6.isIPv6=function(t){return null!==this.parser(t)},d.IPv6.isValid=function(t){if("string"==typeof t&&-1===t.indexOf(":"))return!1;try{const e=this.parser(t);return new this(e.parts,e.zoneId),!0}catch(t){return!1}},d.IPv6.networkAddressFromCIDR=function(t){let e,r,n,o,i;try{for(e=this.parseCIDR(t),n=e[0].toByteArray(),i=this.subnetMaskFromPrefixLength(e[1]).toByteArray(),o=[],r=0;r<16;)o.push(parseInt(n[r],10)&parseInt(i[r],10)),r++;return new this(o)}catch(t){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${t})`)}},d.IPv6.parse=function(t){const e=this.parser(t);if(null===e.parts)throw new Error("ipaddr: string is not formatted like an IPv6 Address");return new this(e.parts,e.zoneId)},d.IPv6.parseCIDR=function(t){let e,r,n;if((r=t.match(/^(.+)\/(\d+)$/))&&(e=parseInt(r[2]),e>=0&&e<=128))return n=[this.parse(r[1]),e],Object.defineProperty(n,"toString",{value:function(){return this.join("/")}}),n;throw new Error("ipaddr: string is not formatted like an IPv6 CIDR range")},d.IPv6.parser=function(t){let e,r,n,o,i,s;if(n=t.match(a.deprecatedTransitional))return this.parser(`::ffff:${n[1]}`);if(a.native.test(t))return c(t,8);if((n=t.match(a.transitional))&&(s=n[6]||"",e=c(n[1].slice(0,-1)+s,6),e.parts)){for(i=[parseInt(n[2]),parseInt(n[3]),parseInt(n[4]),parseInt(n[5])],r=0;r<i.length;r++)if(o=i[r],!(0<=o&&o<=255))return null;return e.parts.push(i[0]<<8|i[1]),e.parts.push(i[2]<<8|i[3]),{parts:e.parts,zoneId:e.zoneId}}return null},d.IPv6.subnetMaskFromPrefixLength=function(t){if((t=parseInt(t))<0||t>128)throw new Error("ipaddr: invalid IPv6 prefix length");const e=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];let r=0;const n=Math.floor(t/8);for(;r<n;)e[r]=255,r++;return n<16&&(e[n]=Math.pow(2,t%8)-1<<8-t%8),new this(e)},d.fromByteArray=function(t){const e=t.length;if(4===e)return new d.IPv4(t);if(16===e)return new d.IPv6(t);throw new Error("ipaddr: the binary input is neither an IPv6 nor IPv4 address")},d.isValid=function(t){return d.IPv6.isValid(t)||d.IPv4.isValid(t)},d.parse=function(t){if(d.IPv6.isValid(t))return d.IPv6.parse(t);if(d.IPv4.isValid(t))return d.IPv4.parse(t);throw new Error("ipaddr: the address has neither IPv6 nor IPv4 format")},d.parseCIDR=function(t){try{return d.IPv6.parseCIDR(t)}catch(e){try{return d.IPv4.parseCIDR(t)}catch(t){throw new Error("ipaddr: the address has neither IPv6 nor IPv4 CIDR format")}}},d.process=function(t){const e=this.parse(t);return"ipv6"===e.kind()&&e.isIPv4MappedAddress()?e.toIPv4Address():e},d.subnetMatch=function(t,e,r){let n,o,i,s;for(o in null==r&&(r="unicast"),e)if(Object.prototype.hasOwnProperty.call(e,o))for(i=e[o],!i[0]||i[0]instanceof Array||(i=[i]),n=0;n<i.length;n++)if(s=i[n],t.kind()===s[0].kind()&&t.match.apply(t,s))return o;return r},On.exports?On.exports=d:t.ipaddr=d}(e);var Mn=Dn.exports;const Vn=2147483647,zn=36,Wn={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},jn=Math.floor,Fn=String.fromCharCode;function Kn(t){throw new RangeError(Wn[t])}const Hn=function(t,e){return t+22+75*(t<26)-((0!=e)<<5)},Gn=function(t,e,r){let n=0;for(t=r?jn(t/700):t>>1,t+=jn(t/e);t>455;n+=zn)t=jn(t/35);return jn(n+36*t/(t+38))},qn=function(t){const e=[];t=function(t){const e=[];let r=0;const n=t.length;for(;r<n;){const o=t.charCodeAt(r++);if(o>=55296&&o<=56319&&r<n){const n=t.charCodeAt(r++);56320==(64512&n)?e.push(((1023&o)<<10)+(1023&n)+65536):(e.push(o),r--)}else e.push(o)}return e}(t);const r=t.length;let n=128,o=0,i=72;for(const r of t)r<128&&e.push(Fn(r));const s=e.length;let a=s;for(s&&e.push("-");a<r;){let r=Vn;for(const e of t)e>=n&&e<r&&(r=e);const c=a+1;r-n>jn((Vn-o)/c)&&Kn("overflow"),o+=(r-n)*c,n=r;for(const r of t)if(r<n&&++o>Vn&&Kn("overflow"),r===n){let t=o;for(let r=zn;;r+=zn){const n=r<=i?1:r>=i+26?26:r-i;if(t<n)break;const o=t-n,s=zn-n;e.push(Fn(Hn(n+o%s,0))),t=jn(o/s)}e.push(Fn(Hn(t,0))),i=Gn(o,c,a===s),o=0,++a}++o,++n}return e.join("")},Yn=BigInt(2**32-1),$n=BigInt(32);function Zn(t,e=!1){return e?{h:Number(t&Yn),l:Number(t>>$n&Yn)}:{h:0|Number(t>>$n&Yn),l:0|Number(t&Yn)}}const Xn={fromBig:Zn,split:function(t,e=!1){let r=new Uint32Array(t.length),n=new Uint32Array(t.length);for(let o=0;o<t.length;o++){const{h:i,l:s}=Zn(t[o],e);[r[o],n[o]]=[i,s]}return[r,n]},toBig:(t,e)=>BigInt(t>>>0)<<$n|BigInt(e>>>0),shrSH:(t,e,r)=>t>>>r,shrSL:(t,e,r)=>t<<32-r|e>>>r,rotrSH:(t,e,r)=>t>>>r|e<<32-r,rotrSL:(t,e,r)=>t<<32-r|e>>>r,rotrBH:(t,e,r)=>t<<64-r|e>>>r-32,rotrBL:(t,e,r)=>t>>>r-32|e<<64-r,rotr32H:(t,e)=>e,rotr32L:(t,e)=>t,rotlSH:(t,e,r)=>t<<r|e>>>32-r,rotlSL:(t,e,r)=>e<<r|t>>>32-r,rotlBH:(t,e,r)=>e<<r-32|t>>>64-r,rotlBL:(t,e,r)=>t<<r-32|e>>>64-r,add:function(t,e,r,n){const o=(e>>>0)+(n>>>0);return{h:t+r+(o/2**32|0)|0,l:0|o}},add3L:(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0),add3H:(t,e,r,n)=>e+r+n+(t/2**32|0)|0,add4L:(t,e,r,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0),add4H:(t,e,r,n,o)=>e+r+n+o+(t/2**32|0)|0,add5H:(t,e,r,n,o,i)=>e+r+n+o+i+(t/2**32|0)|0,add5L:(t,e,r,n,o)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(o>>>0)};var Qn=Xn;const[Jn,to]=(()=>Qn.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map((t=>BigInt(t)))))(),eo=new Uint32Array(80),ro=new Uint32Array(80);class no extends xe{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){const{Ah:t,Al:e,Bh:r,Bl:n,Ch:o,Cl:i,Dh:s,Dl:a,Eh:c,El:u,Fh:f,Fl:h,Gh:d,Gl:p,Hh:l,Hl:y}=this;return[t,e,r,n,o,i,s,a,c,u,f,h,d,p,l,y]}set(t,e,r,n,o,i,s,a,c,u,f,h,d,p,l,y){this.Ah=0|t,this.Al=0|e,this.Bh=0|r,this.Bl=0|n,this.Ch=0|o,this.Cl=0|i,this.Dh=0|s,this.Dl=0|a,this.Eh=0|c,this.El=0|u,this.Fh=0|f,this.Fl=0|h,this.Gh=0|d,this.Gl=0|p,this.Hh=0|l,this.Hl=0|y}process(t,e){for(let r=0;r<16;r++,e+=4)eo[r]=t.getUint32(e),ro[r]=t.getUint32(e+=4);for(let t=16;t<80;t++){const e=0|eo[t-15],r=0|ro[t-15],n=Qn.rotrSH(e,r,1)^Qn.rotrSH(e,r,8)^Qn.shrSH(e,r,7),o=Qn.rotrSL(e,r,1)^Qn.rotrSL(e,r,8)^Qn.shrSL(e,r,7),i=0|eo[t-2],s=0|ro[t-2],a=Qn.rotrSH(i,s,19)^Qn.rotrBH(i,s,61)^Qn.shrSH(i,s,6),c=Qn.rotrSL(i,s,19)^Qn.rotrBL(i,s,61)^Qn.shrSL(i,s,6),u=Qn.add4L(o,c,ro[t-7],ro[t-16]),f=Qn.add4H(u,n,a,eo[t-7],eo[t-16]);eo[t]=0|f,ro[t]=0|u}let{Ah:r,Al:n,Bh:o,Bl:i,Ch:s,Cl:a,Dh:c,Dl:u,Eh:f,El:h,Fh:d,Fl:p,Gh:l,Gl:y,Hh:g,Hl:w}=this;for(let t=0;t<80;t++){const e=Qn.rotrSH(f,h,14)^Qn.rotrSH(f,h,18)^Qn.rotrBH(f,h,41),b=Qn.rotrSL(f,h,14)^Qn.rotrSL(f,h,18)^Qn.rotrBL(f,h,41),m=f&d^~f&l,v=h&p^~h&y,E=Qn.add5L(w,b,v,to[t],ro[t]),x=Qn.add5H(E,g,e,m,Jn[t],eo[t]),A=0|E,I=Qn.rotrSH(r,n,28)^Qn.rotrBH(r,n,34)^Qn.rotrBH(r,n,39),S=Qn.rotrSL(r,n,28)^Qn.rotrBL(r,n,34)^Qn.rotrBL(r,n,39),B=r&o^r&s^o&s,R=n&i^n&a^i&a;g=0|l,w=0|y,l=0|d,y=0|p,d=0|f,p=0|h,({h:f,l:h}=Qn.add(0|c,0|u,0|x,0|A)),c=0|s,u=0|a,s=0|o,a=0|i,o=0|r,i=0|n;const P=Qn.add3L(A,S,R);r=Qn.add3H(P,x,I,B),n=0|P}({h:r,l:n}=Qn.add(0|this.Ah,0|this.Al,0|r,0|n)),({h:o,l:i}=Qn.add(0|this.Bh,0|this.Bl,0|o,0|i)),({h:s,l:a}=Qn.add(0|this.Ch,0|this.Cl,0|s,0|a)),({h:c,l:u}=Qn.add(0|this.Dh,0|this.Dl,0|c,0|u)),({h:f,l:h}=Qn.add(0|this.Eh,0|this.El,0|f,0|h)),({h:d,l:p}=Qn.add(0|this.Fh,0|this.Fl,0|d,0|p)),({h:l,l:y}=Qn.add(0|this.Gh,0|this.Gl,0|l,0|y)),({h:g,l:w}=Qn.add(0|this.Hh,0|this.Hl,0|g,0|w)),this.set(r,n,o,i,s,a,c,u,f,h,d,p,l,y,g,w)}roundClean(){eo.fill(0),ro.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const oo=Ee((()=>new no));
|
|
12
|
+
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */BigInt(0);const io=BigInt(1),so=BigInt(2);function ao(t){return t instanceof Uint8Array||null!=t&&"object"==typeof t&&"Uint8Array"===t.constructor.name}const co=Array.from({length:256},((t,e)=>e.toString(16).padStart(2,"0")));function uo(t){if(!ao(t))throw new Error("Uint8Array expected");let e="";for(let r=0;r<t.length;r++)e+=co[t[r]];return e}function fo(t){if("string"!=typeof t)throw new Error("hex string expected, got "+typeof t);return BigInt(""===t?"0":`0x${t}`)}const ho={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function po(t){return t>=ho._0&&t<=ho._9?t-ho._0:t>=ho._A&&t<=ho._F?t-(ho._A-10):t>=ho._a&&t<=ho._f?t-(ho._a-10):void 0}function lo(t){if("string"!=typeof t)throw new Error("hex string expected, got "+typeof t);const e=t.length,r=e/2;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);const n=new Uint8Array(r);for(let e=0,o=0;e<r;e++,o+=2){const r=po(t.charCodeAt(o)),i=po(t.charCodeAt(o+1));if(void 0===r||void 0===i){const e=t[o]+t[o+1];throw new Error('hex string expected, got non-hex character "'+e+'" at index '+o)}n[e]=16*r+i}return n}function yo(t){if(!ao(t))throw new Error("Uint8Array expected");return fo(uo(Uint8Array.from(t).reverse()))}function go(t,e){return lo(t.toString(16).padStart(2*e,"0"))}function wo(t,e){return go(t,e).reverse()}function bo(t,e,r){let n;if("string"==typeof e)try{n=lo(e)}catch(r){throw new Error(`${t} must be valid hex string, got "${e}". Cause: ${r}`)}else{if(!ao(e))throw new Error(`${t} must be hex string or Uint8Array`);n=Uint8Array.from(e)}const o=n.length;if("number"==typeof r&&o!==r)throw new Error(`${t} expected ${r} bytes, got ${o}`);return n}function mo(...t){let e=0;for(let r=0;r<t.length;r++){const n=t[r];if(!ao(n))throw new Error("Uint8Array expected");e+=n.length}let r=new Uint8Array(e),n=0;for(let e=0;e<t.length;e++){const o=t[e];r.set(o,n),n+=o.length}return r}const vo=t=>(so<<BigInt(t-1))-io,Eo={bigint:t=>"bigint"==typeof t,function:t=>"function"==typeof t,boolean:t=>"boolean"==typeof t,string:t=>"string"==typeof t,stringOrUint8Array:t=>"string"==typeof t||ao(t),isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>"function"==typeof t&&Number.isSafeInteger(t.outputLen)};function xo(t,e,r={}){const n=(e,r,n)=>{const o=Eo[r];if("function"!=typeof o)throw new Error(`Invalid validator "${r}", expected function`);const i=t[e];if(!(n&&void 0===i||o(i,t)))throw new Error(`Invalid param ${String(e)}=${i} (${typeof i}), expected ${r}`)};for(const[t,r]of Object.entries(e))n(t,r,!1);for(const[t,e]of Object.entries(r))n(t,e,!0);return t}
|
|
13
|
+
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Ao=BigInt(0),Io=BigInt(1),So=BigInt(2),Bo=BigInt(3),Ro=BigInt(4),Po=BigInt(5),ko=BigInt(8);function To(t,e){const r=t%e;return r>=Ao?r:e+r}function _o(t,e,r){if(r<=Ao||e<Ao)throw new Error("Expected power/modulo > 0");if(r===Io)return Ao;let n=Io;for(;e>Ao;)e&Io&&(n=n*t%r),t=t*t%r,e>>=Io;return n}function Uo(t,e,r){let n=t;for(;e-- >Ao;)n*=n,n%=r;return n}function Lo(t,e){if(t===Ao||e<=Ao)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let r=To(t,e),n=e,o=Ao,i=Io;for(;r!==Ao;){const t=n%r,e=o-i*(n/r);n=r,r=t,o=i,i=e}if(n!==Io)throw new Error("invert: does not exist");return To(o,e)}function Co(t){if(t%Ro===Bo){const e=(t+Io)/Ro;return function(t,r){const n=t.pow(r,e);if(!t.eql(t.sqr(n),r))throw new Error("Cannot find square root");return n}}if(t%ko===Po){const e=(t-Po)/ko;return function(t,r){const n=t.mul(r,So),o=t.pow(n,e),i=t.mul(r,o),s=t.mul(t.mul(i,So),o),a=t.mul(i,t.sub(s,t.ONE));if(!t.eql(t.sqr(a),r))throw new Error("Cannot find square root");return a}}return function(t){const e=(t-Io)/So;let r,n,o;for(r=t-Io,n=0;r%So===Ao;r/=So,n++);for(o=So;o<t&&_o(o,e,t)!==t-Io;o++);if(1===n){const e=(t+Io)/Ro;return function(t,r){const n=t.pow(r,e);if(!t.eql(t.sqr(n),r))throw new Error("Cannot find square root");return n}}const i=(r+Io)/So;return function(t,s){if(t.pow(s,e)===t.neg(t.ONE))throw new Error("Cannot find square root");let a=n,c=t.pow(t.mul(t.ONE,o),r),u=t.pow(s,i),f=t.pow(s,r);for(;!t.eql(f,t.ONE);){if(t.eql(f,t.ZERO))return t.ZERO;let e=1;for(let r=t.sqr(f);e<a&&!t.eql(r,t.ONE);e++)r=t.sqr(r);const r=t.pow(c,Io<<BigInt(a-e-1));c=t.sqr(r),u=t.mul(u,r),f=t.mul(f,c),a=e}return u}}(t)}BigInt(9),BigInt(16);const Oo=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function No(t,e){const r=void 0!==e?e:t.toString(2).length;return{nBitLength:r,nByteLength:Math.ceil(r/8)}}
|
|
14
14
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
15
|
-
const
|
|
16
|
-
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const
|
|
17
|
-
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const
|
|
15
|
+
const Do=BigInt(0),Mo=BigInt(1);function Vo(t){return xo(t.Fp,Oo.reduce(((t,e)=>(t[e]="function",t)),{ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"})),xo(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...No(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}
|
|
16
|
+
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const zo=BigInt(0),Wo=BigInt(1),jo=BigInt(2),Fo=BigInt(8),Ko={zip215:!0};function Ho(t){const e=function(t){const e=Vo(t);return xo(t,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}(t),{Fp:r,n:n,prehash:o,hash:i,randomBytes:s,nByteLength:a,h:c}=e,u=jo<<BigInt(8*a)-Wo,f=r.create,h=e.uvRatio||((t,e)=>{try{return{isValid:!0,value:r.sqrt(t*r.inv(e))}}catch(t){return{isValid:!1,value:zo}}}),d=e.adjustScalarBytes||(t=>t),p=e.domain||((t,e,r)=>{if(e.length||r)throw new Error("Contexts/pre-hash are not supported");return t}),l=t=>"bigint"==typeof t&&zo<t,y=(t,e)=>l(t)&&l(e)&&t<e,g=t=>t===zo||y(t,u);function w(t,e){if(y(t,e))return t;throw new Error(`Expected valid scalar < ${e}, got ${typeof t} ${t}`)}function b(t){return t===zo?t:w(t,n)}const m=new Map;function v(t){if(!(t instanceof E))throw new Error("ExtendedPoint expected")}class E{constructor(t,e,r,n){if(this.ex=t,this.ey=e,this.ez=r,this.et=n,!g(t))throw new Error("x required");if(!g(e))throw new Error("y required");if(!g(r))throw new Error("z required");if(!g(n))throw new Error("t required")}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(t){if(t instanceof E)throw new Error("extended point not allowed");const{x:e,y:r}=t||{};if(!g(e)||!g(r))throw new Error("invalid affine point");return new E(e,r,Wo,f(e*r))}static normalizeZ(t){const e=r.invertBatch(t.map((t=>t.ez)));return t.map(((t,r)=>t.toAffine(e[r]))).map(E.fromAffine)}_setWindowSize(t){this._WINDOW_SIZE=t,m.delete(this)}assertValidity(){const{a:t,d:r}=e;if(this.is0())throw new Error("bad point: ZERO");const{ex:n,ey:o,ez:i,et:s}=this,a=f(n*n),c=f(o*o),u=f(i*i),h=f(u*u),d=f(a*t);if(f(u*f(d+c))!==f(h+f(r*f(a*c))))throw new Error("bad point: equation left != right (1)");if(f(n*o)!==f(i*s))throw new Error("bad point: equation left != right (2)")}equals(t){v(t);const{ex:e,ey:r,ez:n}=this,{ex:o,ey:i,ez:s}=t,a=f(e*s),c=f(o*n),u=f(r*s),h=f(i*n);return a===c&&u===h}is0(){return this.equals(E.ZERO)}negate(){return new E(f(-this.ex),this.ey,this.ez,f(-this.et))}double(){const{a:t}=e,{ex:r,ey:n,ez:o}=this,i=f(r*r),s=f(n*n),a=f(jo*f(o*o)),c=f(t*i),u=r+n,h=f(f(u*u)-i-s),d=c+s,p=d-a,l=c-s,y=f(h*p),g=f(d*l),w=f(h*l),b=f(p*d);return new E(y,g,b,w)}add(t){v(t);const{a:r,d:n}=e,{ex:o,ey:i,ez:s,et:a}=this,{ex:c,ey:u,ez:h,et:d}=t;if(r===BigInt(-1)){const t=f((i-o)*(u+c)),e=f((i+o)*(u-c)),r=f(e-t);if(r===zo)return this.double();const n=f(s*jo*d),p=f(a*jo*h),l=p+n,y=e+t,g=p-n,w=f(l*r),b=f(y*g),m=f(l*g),v=f(r*y);return new E(w,b,v,m)}const p=f(o*c),l=f(i*u),y=f(a*n*d),g=f(s*h),w=f((o+i)*(c+u)-p-l),b=g-y,m=g+y,x=f(l-r*p),A=f(w*b),I=f(m*x),S=f(w*x),B=f(b*m);return new E(A,I,B,S)}subtract(t){return this.add(t.negate())}wNAF(t){return I.wNAFCached(this,m,t,E.normalizeZ)}multiply(t){const{p:e,f:r}=this.wNAF(w(t,n));return E.normalizeZ([e,r])[0]}multiplyUnsafe(t){let e=b(t);return e===zo?A:this.equals(A)||e===Wo?this:this.equals(x)?this.wNAF(e).p:I.unsafeLadder(this,e)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return I.unsafeLadder(this,n).is0()}toAffine(t){const{ex:e,ey:n,ez:o}=this,i=this.is0();null==t&&(t=i?Fo:r.inv(o));const s=f(e*t),a=f(n*t),c=f(o*t);if(i)return{x:zo,y:Wo};if(c!==Wo)throw new Error("invZ was invalid");return{x:s,y:a}}clearCofactor(){const{h:t}=e;return t===Wo?this:this.multiplyUnsafe(t)}static fromHex(t,n=!1){const{d:o,a:i}=e,s=r.BYTES,a=(t=bo("pointHex",t,s)).slice(),c=t[s-1];a[s-1]=-129&c;const d=yo(a);d===zo||w(d,n?u:r.ORDER);const p=f(d*d),l=f(p-Wo),y=f(o*p-i);let{isValid:g,value:b}=h(l,y);if(!g)throw new Error("Point.fromHex: invalid y coordinate");const m=(b&Wo)===Wo,v=0!=(128&c);if(!n&&b===zo&&v)throw new Error("Point.fromHex: x=0 and x_0=1");return v!==m&&(b=f(-b)),E.fromAffine({x:b,y:d})}static fromPrivateKey(t){return R(t).point}toRawBytes(){const{x:t,y:e}=this.toAffine(),n=wo(e,r.BYTES);return n[n.length-1]|=t&Wo?128:0,n}toHex(){return uo(this.toRawBytes())}}E.BASE=new E(e.Gx,e.Gy,Wo,f(e.Gx*e.Gy)),E.ZERO=new E(zo,Wo,Wo,zo);const{BASE:x,ZERO:A}=E,I=function(t,e){const r=(t,e)=>{const r=e.negate();return t?r:e},n=t=>({windows:Math.ceil(e/t)+1,windowSize:2**(t-1)});return{constTimeNegate:r,unsafeLadder(e,r){let n=t.ZERO,o=e;for(;r>Do;)r&Mo&&(n=n.add(o)),o=o.double(),r>>=Mo;return n},precomputeWindow(t,e){const{windows:r,windowSize:o}=n(e),i=[];let s=t,a=s;for(let t=0;t<r;t++){a=s,i.push(a);for(let t=1;t<o;t++)a=a.add(s),i.push(a);s=a.double()}return i},wNAF(e,o,i){const{windows:s,windowSize:a}=n(e);let c=t.ZERO,u=t.BASE;const f=BigInt(2**e-1),h=2**e,d=BigInt(e);for(let t=0;t<s;t++){const e=t*a;let n=Number(i&f);i>>=d,n>a&&(n-=h,i+=Mo);const s=e,p=e+Math.abs(n)-1,l=t%2!=0,y=n<0;0===n?u=u.add(r(l,o[s])):c=c.add(r(y,o[p]))}return{p:c,f:u}},wNAFCached(t,e,r,n){const o=t._WINDOW_SIZE||1;let i=e.get(t);return i||(i=this.precomputeWindow(t,o),1!==o&&e.set(t,n(i))),this.wNAF(o,i,r)}}}(E,8*a);function S(t){return To(t,n)}function B(t){return S(yo(t))}function R(t){const e=a;t=bo("private key",t,e);const r=bo("hashed private key",i(t),2*e),n=d(r.slice(0,e)),o=r.slice(e,2*e),s=B(n),c=x.multiply(s),u=c.toRawBytes();return{head:n,prefix:o,scalar:s,point:c,pointBytes:u}}function P(t=new Uint8Array,...e){const r=mo(...e);return B(i(p(r,bo("context",t),!!o)))}const k=Ko;x._setWindowSize(8);return{CURVE:e,getPublicKey:function(t){return R(t).pointBytes},sign:function(t,e,n={}){t=bo("message",t),o&&(t=o(t));const{prefix:i,scalar:s,pointBytes:c}=R(e),u=P(n.context,i,t),f=x.multiply(u).toRawBytes(),h=S(u+P(n.context,f,c,t)*s);return b(h),bo("result",mo(f,wo(h,r.BYTES)),2*a)},verify:function(t,e,n,i=k){const{context:s,zip215:a}=i,c=r.BYTES;t=bo("signature",t,2*c),e=bo("message",e),o&&(e=o(e));const u=yo(t.slice(c,2*c));let f,h,d;try{f=E.fromHex(n,a),h=E.fromHex(t.slice(0,c),a),d=x.multiplyUnsafe(u)}catch(t){return!1}if(!a&&f.isSmallOrder())return!1;const p=P(s,h.toRawBytes(),f.toRawBytes(),e);return h.add(f.multiplyUnsafe(p)).subtract(d).clearCofactor().equals(E.ZERO)},ExtendedPoint:E,utils:{getExtendedPublicKey:R,randomPrivateKey:()=>s(r.BYTES),precompute:(t=8,e=E.BASE)=>(e._setWindowSize(t),e.multiply(BigInt(3)),e)}}}
|
|
17
|
+
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Go=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),qo=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");BigInt(0);const Yo=BigInt(1),$o=BigInt(2),Zo=BigInt(5),Xo=BigInt(10),Qo=BigInt(20),Jo=BigInt(40),ti=BigInt(80);const ei=function(t,e,r=!1,n={}){if(t<=Ao)throw new Error(`Expected Field ORDER > 0, got ${t}`);const{nBitLength:o,nByteLength:i}=No(t,e);if(i>2048)throw new Error("Field lengths over 2048 bytes are not supported");const s=Co(t),a=Object.freeze({ORDER:t,BITS:o,BYTES:i,MASK:vo(o),ZERO:Ao,ONE:Io,create:e=>To(e,t),isValid:e=>{if("bigint"!=typeof e)throw new Error("Invalid field element: expected bigint, got "+typeof e);return Ao<=e&&e<t},is0:t=>t===Ao,isOdd:t=>(t&Io)===Io,neg:e=>To(-e,t),eql:(t,e)=>t===e,sqr:e=>To(e*e,t),add:(e,r)=>To(e+r,t),sub:(e,r)=>To(e-r,t),mul:(e,r)=>To(e*r,t),pow:(t,e)=>function(t,e,r){if(r<Ao)throw new Error("Expected power > 0");if(r===Ao)return t.ONE;if(r===Io)return e;let n=t.ONE,o=e;for(;r>Ao;)r&Io&&(n=t.mul(n,o)),o=t.sqr(o),r>>=Io;return n}(a,t,e),div:(e,r)=>To(e*Lo(r,t),t),sqrN:t=>t*t,addN:(t,e)=>t+e,subN:(t,e)=>t-e,mulN:(t,e)=>t*e,inv:e=>Lo(e,t),sqrt:n.sqrt||(t=>s(a,t)),invertBatch:t=>function(t,e){const r=new Array(e.length),n=e.reduce(((e,n,o)=>t.is0(n)?e:(r[o]=e,t.mul(e,n))),t.ONE),o=t.inv(n);return e.reduceRight(((e,n,o)=>t.is0(n)?e:(r[o]=t.mul(e,r[o]),t.mul(e,n))),o),r}(a,t),cmov:(t,e,r)=>r?e:t,toBytes:t=>r?wo(t,i):go(t,i),fromBytes:t=>{if(t.length!==i)throw new Error(`Fp.fromBytes: expected ${i}, got ${t.length}`);return r?yo(t):function(t){return fo(uo(t))}(t)}});return Object.freeze(a)}(Go,void 0,!0),ri={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:ei,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:BigInt(8),Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:oo,randomBytes:function(t=32){if(le&&"function"==typeof le.getRandomValues)return le.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")},adjustScalarBytes:function(t){return t[0]&=248,t[31]&=127,t[31]|=64,t},uvRatio:function(t,e){const r=Go,n=To(e*e*e,r),o=function(t){const e=Go,r=t*t%e*t%e,n=Uo(r,$o,e)*r%e,o=Uo(n,Yo,e)*t%e,i=Uo(o,Zo,e)*o%e,s=Uo(i,Xo,e)*i%e,a=Uo(s,Qo,e)*s%e,c=Uo(a,Jo,e)*a%e,u=Uo(c,ti,e)*c%e,f=Uo(u,ti,e)*c%e,h=Uo(f,Xo,e)*i%e;return{pow_p_5_8:Uo(h,$o,e)*t%e,b2:r}}(t*To(n*n*e,r)).pow_p_5_8;let i=To(t*n*o,r);const s=To(e*i*i,r),a=i,c=To(i*qo,r),u=s===t,f=s===To(-t,r),h=s===To(-t*qo,r);return u&&(i=a),(f||h)&&(i=c),(To(i,r)&Io)===Io&&(i=To(-i,r)),{isValid:u||f,value:i}}},ni=Ho(ri);const oi=(ei.ORDER+BigInt(3))/BigInt(8);
|
|
18
18
|
/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
19
|
-
function Po(t){if(!Number.isSafeInteger(t))throw new Error(`Wrong integer: ${t}`)}function To(...t){const e=t=>t,r=(t,e)=>r=>t(e(r));return{encode:t.map((t=>t.encode)).reduceRight(r,e),decode:t.map((t=>t.decode)).reduce(r,e)}}function Uo(t){return{encode:e=>{if(!Array.isArray(e)||e.length&&"number"!=typeof e[0])throw new Error("alphabet.encode input should be an array of numbers");return e.map((e=>{if(Po(e),e<0||e>=t.length)throw new Error(`Digit index outside alphabet: ${e} (alphabet: ${t.length})`);return t[e]}))},decode:e=>{if(!Array.isArray(e)||e.length&&"string"!=typeof e[0])throw new Error("alphabet.decode input should be array of strings");return e.map((e=>{if("string"!=typeof e)throw new Error(`alphabet.decode: not string element=${e}`);const r=t.indexOf(e);if(-1===r)throw new Error(`Unknown letter: "${e}". Allowed: ${t}`);return r}))}}}function Lo(t=""){if("string"!=typeof t)throw new Error("join separator should be string");return{encode:e=>{if(!Array.isArray(e)||e.length&&"string"!=typeof e[0])throw new Error("join.encode input should be array of strings");for(let t of e)if("string"!=typeof t)throw new Error(`join.encode: non-string input=${t}`);return e.join(t)},decode:e=>{if("string"!=typeof e)throw new Error("join.decode input should be string");return e.split(t)}}}function Oo(t,e="="){if(Po(t),"string"!=typeof e)throw new Error("padding chr should be string");return{encode(r){if(!Array.isArray(r)||r.length&&"string"!=typeof r[0])throw new Error("padding.encode input should be array of strings");for(let t of r)if("string"!=typeof t)throw new Error(`padding.encode: non-string input=${t}`);for(;r.length*t%8;)r.push(e);return r},decode(r){if(!Array.isArray(r)||r.length&&"string"!=typeof r[0])throw new Error("padding.encode input should be array of strings");for(let t of r)if("string"!=typeof t)throw new Error(`padding.decode: non-string input=${t}`);let n=r.length;if(n*t%8)throw new Error("Invalid padding: string should have whole number of bytes");for(;n>0&&r[n-1]===e;n--)if(!((n-1)*t%8))throw new Error("Invalid padding: string has too much padding");return r.slice(0,n)}}}function Co(t){if("function"!=typeof t)throw new Error("normalize fn should be function");return{encode:t=>t,decode:e=>t(e)}}Mo.pow(Eo,_o),Mo.sqrt(Mo.neg(Mo.ONE)),Mo.ORDER,BigInt(5),BigInt(8),BigInt(486662),function(t,e){if(!t.isOdd)throw new Error("Field doesn't have isOdd");const r=t.sqrt(e);t.isOdd(r)&&t.neg(r)}(Mo,Mo.neg(BigInt(486664))),BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");const No=(t,e)=>e?No(e,t%e):t,Do=(t,e)=>t+(e-No(t,e));function zo(t,e,r,n){if(!Array.isArray(t))throw new Error("convertRadix2: data should be array");if(e<=0||e>32)throw new Error(`convertRadix2: wrong from=${e}`);if(r<=0||r>32)throw new Error(`convertRadix2: wrong to=${r}`);if(Do(e,r)>32)throw new Error(`convertRadix2: carry overflow from=${e} to=${r} carryBits=${Do(e,r)}`);let i=0,o=0;const s=2**r-1,a=[];for(const n of t){if(Po(n),n>=2**e)throw new Error(`convertRadix2: invalid data word=${n} from=${e}`);if(i=i<<e|n,o+e>32)throw new Error(`convertRadix2: carry overflow pos=${o} from=${e}`);for(o+=e;o>=r;o-=r)a.push((i>>o-r&s)>>>0);i&=2**o-1}if(i=i<<r-o&s,!n&&o>=e)throw new Error("Excess padding");if(!n&&i)throw new Error(`Non-zero padding: ${i}`);return n&&o>0&&a.push(i>>>0),a}function Vo(t,e=!1){if(Po(t),t<=0||t>32)throw new Error("radix2: bits should be in (0..32]");if(Do(8,t)>32||Do(t,8)>32)throw new Error("radix2: carry overflow");return{encode:r=>{if(!function(t){return t instanceof Uint8Array||null!=t&&"object"==typeof t&&"Uint8Array"===t.constructor.name}(r))throw new Error("radix2.encode input should be Uint8Array");return zo(Array.from(r),8,t,!e)},decode:r=>{if(!Array.isArray(r)||r.length&&"number"!=typeof r[0])throw new Error("radix2.decode input should be array of numbers");return Uint8Array.from(zo(r,t,8,e))}}}function Wo(t){if("function"!=typeof t)throw new Error("unsafeWrapper fn should be function");return function(...e){try{return t.apply(null,e)}catch(t){}}}Vo(4),Uo("0123456789ABCDEF"),Lo(""),Vo(5),Uo("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),Oo(5),Lo(""),Vo(5),Uo("0123456789ABCDEFGHIJKLMNOPQRSTUV"),Oo(5),Lo(""),Vo(5),Uo("0123456789ABCDEFGHJKMNPQRSTVWXYZ"),Lo(""),Co((t=>t.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1"))),Vo(6),Uo("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),Oo(6),Lo(""),Vo(6),Uo("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),Oo(6),Lo(""),Vo(6),Uo("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),Lo("");const Fo=To(Uo("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),Lo("")),jo=[996825010,642813549,513874426,1027748829,705979059];function Ko(t){const e=t>>25;let r=(33554431&t)<<5;for(let t=0;t<jo.length;t++)1==(e>>t&1)&&(r^=jo[t]);return r}function Ho(t,e,r=1){const n=t.length;let i=1;for(let e=0;e<n;e++){const r=t.charCodeAt(e);if(r<33||r>126)throw new Error(`Invalid prefix (${t})`);i=Ko(i)^r>>5}i=Ko(i);for(let e=0;e<n;e++)i=Ko(i)^31&t.charCodeAt(e);for(let t of e)i=Ko(i)^t;for(let t=0;t<6;t++)i=Ko(i);return i^=r,Fo.encode(zo([i%2**30],30,5,!1))}function Go(t){const e="bech32"===t?1:734539939,r=Vo(5),n=r.decode,i=r.encode,o=Wo(n);function s(t,r=90){if("string"!=typeof t)throw new Error("bech32.decode input should be string, not "+typeof t);if(t.length<8||!1!==r&&t.length>r)throw new TypeError(`Wrong string length: ${t.length} (${t}). Expected (8..${r})`);const n=t.toLowerCase();if(t!==n&&t!==t.toUpperCase())throw new Error("String must be lowercase or uppercase");const i=(t=n).lastIndexOf("1");if(0===i||-1===i)throw new Error('Letter "1" must be present between prefix and data only');const o=t.slice(0,i),s=t.slice(i+1);if(s.length<6)throw new Error("Data must be at least 6 characters long");const a=Fo.decode(s).slice(0,-6),u=Ho(o,a,e);if(!s.endsWith(u))throw new Error(`Invalid checksum in ${t}: expected "${u}"`);return{prefix:o,words:a}}return{encode:function(t,r,n=90){if("string"!=typeof t)throw new Error("bech32.encode prefix should be string, not "+typeof t);if(!Array.isArray(r)||r.length&&"number"!=typeof r[0])throw new Error("bech32.encode words should be array of numbers, not "+typeof r);const i=t.length+7+r.length;if(!1!==n&&i>n)throw new TypeError(`Length ${i} exceeds limit ${n}`);const o=t.toLowerCase(),s=Ho(o,r,e);return`${o}1${Fo.encode(r)}${s}`},decode:s,decodeToBytes:function(t){const{prefix:e,words:r}=s(t,!1);return{prefix:e,words:r,bytes:n(r)}},decodeUnsafe:Wo(s),fromWords:n,fromWordsUnsafe:o,toWords:i}}const qo=Go("bech32");Vo(4),Uo("0123456789abcdef"),Lo(""),Co((t=>{if("string"!=typeof t||t.length%2)throw new TypeError(`hex.decode: expected string, got ${typeof t} with length ${t.length}`);return t.toLowerCase()}));const Zo=(t,e,r)=>ko.verify(e,t,r.toBytes()),$o=(t,e)=>{const{pubkey:r}=ti(e+"."+t,exports.RecordVersion.V1);return r};async function Yo(t,e,r,n){const i=$o(e,r);let{registry:o}=await Ne.retrieve(t,i);if(!o.data)throw new _t(exports.ErrorType.NoRecordData);if(n)return Qo(o,r,i);const s=tn.get(r);return o.data=o.data.slice(0,s),o}const Xo=async(t,e)=>await Yo(t,e,exports.Record.SOL),Qo=(e,r,n)=>{const o=null==e?void 0:e.data;if(!o)return;if(0===o.compare(i.Buffer.alloc(o.length)))return;const s=tn.get(r),a=(t=>{const e=Array.from(t);return e.length-1-e.reverse().findIndex((t=>0!==t))+1})(o);if(!s)return o.slice(0,a).toString("utf-8");if(r===exports.Record.SOL){const t=new TextEncoder,r=i.Buffer.concat([o.slice(0,32),n.toBuffer()]),s=t.encode(r.toString("hex"));if(Zo(s,o.slice(32,96),e.owner))return ui.encode(o.slice(0,32))}if(s&&a!==s){const t=o.slice(0,a).toString("utf-8");if(r===exports.Record.Injective){const e=qo.decodeToBytes(t);if("inj"===e.prefix&&20===e.bytes.length)return t}else if(r===exports.Record.BSC||r===exports.Record.ETH){const e=t.slice(0,2),r=t.slice(2);if("0x"===e&&20===i.Buffer.from(r,"hex").length)return t}else if((r===exports.Record.A||r===exports.Record.AAAA)&&fi.isValid(t))return t;throw new _t(exports.ErrorType.InvalidRecordData)}if(r===exports.Record.ETH||r===exports.Record.BSC)return"0x"+o.slice(0,s).toString("hex");if(r===exports.Record.Injective)return qo.encode("inj",qo.toWords(o.slice(0,s)));if(r===exports.Record.A||r===exports.Record.AAAA)return fi.fromByteArray([...o.slice(0,s)]).toString();if(r===exports.Record.Background)return new t.PublicKey(o.slice(0,s)).toString();throw new _t(exports.ErrorType.InvalidRecordData)},Jo=(e,r)=>{if(!tn.get(r))return r!==exports.Record.CNAME&&r!==exports.Record.TXT||(e=bi(e)),i.Buffer.from(e,"utf-8");if(r===exports.Record.SOL)throw new _t(exports.ErrorType.UnsupportedRecord,"Use `serializeSolRecord` for SOL record");if(r===exports.Record.ETH||r===exports.Record.BSC)return ii("0x"===e.slice(0,2),exports.ErrorType.InvalidEvmAddress),i.Buffer.from(e.slice(2),"hex");if(r===exports.Record.Injective){const t=qo.decodeToBytes(e);return ii("inj"===t.prefix,exports.ErrorType.InvalidInjectiveAddress),ii(20===t.bytes.length,exports.ErrorType.InvalidInjectiveAddress),i.Buffer.from(t.bytes)}if(r===exports.Record.A){const t=fi.parse(e).toByteArray();return ii(4===t.length,exports.ErrorType.InvalidARecord),i.Buffer.from(t)}if(r===exports.Record.AAAA){const t=fi.parse(e).toByteArray();return ii(16===t.length,exports.ErrorType.InvalidAAAARecord),i.Buffer.from(t)}if(r===exports.Record.Background)return new t.PublicKey(e).toBuffer();throw new _t(exports.ErrorType.InvalidRecordInput)},ts=(t,e,r,n)=>{const o=i.Buffer.concat([t.toBuffer(),e.toBuffer()]),s=(new TextEncoder).encode(o.toString("hex")),a=Zo(s,n,r);return ii(a,exports.ErrorType.InvalidSignature),i.Buffer.concat([t.toBuffer(),n])},es=new Map([[exports.Record.Url,new t.PublicKey("ExXjtfdQe8JacoqP9Z535WzQKjF4CzW1TTRKRgpxvya3")]]),rs=new Set([exports.Record.ETH,exports.Record.Injective,exports.Record.BSC]),ns=new Set([exports.Record.IPFS,exports.Record.ARWV,exports.Record.LTC,exports.Record.DOGE,exports.Record.Email,exports.Record.Url,exports.Record.Discord,exports.Record.Github,exports.Record.Reddit,exports.Record.Twitter,exports.Record.Telegram,exports.Record.Pic,exports.Record.SHDW,exports.Record.POINT,exports.Record.Backpack,exports.Record.TXT,exports.Record.CNAME,exports.Record.BTC]),is=new Set([exports.Record.ETH,exports.Record.Injective,exports.Record.SOL]),os=(e,r)=>{if(ns.has(r)){const t=e.toString("utf-8");return r===exports.Record.CNAME||r===exports.Record.TXT?function(t){const e=[],r=t.length;let n=0,i=128,o=72,s=t.lastIndexOf("-");s<0&&(s=0);for(let r=0;r<s;++r)t.charCodeAt(r)>=128&&gi("not-basic"),e.push(t.charCodeAt(r));for(let u=s>0?s+1:0;u<r;){const s=n;for(let e=1,i=li;;i+=li){u>=r&&gi("invalid-input");const s=(a=t.charCodeAt(u++))>=48&&a<58?a-48+26:a>=65&&a<91?a-65:a>=97&&a<123?a-97:li;s>=li&&gi("invalid-input"),s>pi((hi-n)/e)&&gi("overflow"),n+=s*e;const c=i<=o?1:i>=o+26?26:i-o;if(s<c)break;const f=li-c;e>pi(hi/f)&&gi("overflow"),e*=f}const c=e.length+1;o=mi(n-s,c,0==s),pi(n/c)>hi-i&&gi("overflow"),i+=pi(n/c),n%=c,e.splice(n++,0,i)}var a;return String.fromCodePoint(...e)}(t):t}if(r===exports.Record.SOL)return new t.PublicKey(e).toBase58();if(r===exports.Record.ETH||r===exports.Record.BSC)return"0x"+e.toString("hex");if(r===exports.Record.Injective)return qo.encode("inj",qo.toWords(e));if(r===exports.Record.A||r===exports.Record.AAAA)return fi.fromByteArray([...e]).toString();throw new _t(exports.ErrorType.InvalidARecord)},ss=(e,r)=>{if(ns.has(r))return r!==exports.Record.CNAME&&r!==exports.Record.TXT||(e=bi(e)),Buffer.from(e,"utf-8");if(r===exports.Record.SOL)return new t.PublicKey(e).toBuffer();if(r===exports.Record.ETH||r===exports.Record.BSC)return ii("0x"===e.slice(0,2),exports.ErrorType.InvalidEvmAddress),Buffer.from(e.slice(2),"hex");if(r===exports.Record.Injective){const t=qo.decodeToBytes(e);return ii("inj"===t.prefix,exports.ErrorType.InvalidInjectiveAddress),ii(20===t.bytes.length,exports.ErrorType.InvalidInjectiveAddress),Buffer.from(t.bytes)}if(r===exports.Record.A){const t=fi.parse(e).toByteArray();return ii(4===t.length,exports.ErrorType.InvalidARecord),Buffer.from(t)}if(r===exports.Record.AAAA){const t=fi.parse(e).toByteArray();return ii(16===t.length,exports.ErrorType.InvalidAAAARecord),Buffer.from(t)}throw new _t(exports.ErrorType.InvalidARecord)},as=(t,e)=>{const{pubkey:r}=ti(t),n=$n("".concat(e));return Yn(n,qr,r)};async function us(e,r,n,i,o,s,a,u){const c=$n(r),f=Yn(c,a,u),h=s||await e.getMinimumBalanceForRentExemption(n);let l;if(u){const{registry:t}=await Er(e,u);l=t.owner}return ve(rr,t.SystemProgram.programId,f,o,i,c,new Tt(BigInt(h)),new Pt(BigInt(n)),a,u,l)}async function cs(t,e,r,n,i){const o=$n(e),s=Yn(o,n,i);let a;a=n||(await Ne.retrieve(t,s)).registry.owner;return Ae(rr,s,r,a)}const fs=async(e,r,n,i,o)=>{let[s]=await t.PublicKey.findProgramAddress([or.toBuffer()],or),a=$n(e.toBase58()),u=Yn(a,s,i);return[[],[new Se({name:r}).getInstruction(or,rr,ir,u,t.SystemProgram.programId,s,n,t.SYSVAR_RENT_PUBKEY,i,o)]]},hs=async(e,r,n,i,o,s)=>{ii(n!==exports.Record.SOL,exports.ErrorType.UnsupportedRecord);const{pubkey:a,hashed:u,parent:c}=ti(`${n}.${r}`,exports.RecordVersion.V1),f=Jo(i,n).length,h=await e.getMinimumBalanceForRentExemption(f+Ne.HEADER_LEN);return ve(rr,t.SystemProgram.programId,a,o,s,u,new Tt(BigInt(h)),new Pt(BigInt(f)),void 0,c,o)},ls=async(e,r,n,i,o,s)=>{const{pubkey:a,hashed:u,parent:c}=ti(`${exports.Record.SOL}.${r}`,exports.RecordVersion.V1),f=ts(n,a,i,o).length,h=await e.getMinimumBalanceForRentExemption(f+Ne.HEADER_LEN);return[ve(rr,t.SystemProgram.programId,a,i,s,u,new Tt(BigInt(h)),new Pt(BigInt(f)),void 0,c,i)]};class ds{constructor(t){this.twitterRegistryKey=t.twitterRegistryKey,this.twitterHandle=t.twitterHandle}static async retrieve(t,e){let r=await t.getAccountInfo(e,"processed");if(!r)throw new _t(exports.ErrorType.InvalidReverseTwitter);return ne(this.schema,ds,r.data.slice(Ne.HEADER_LEN))}}async function ps(e,r,n,o,s){const a=$n(o.toString()),u=Yn(a,cr,fr);let c=ge(ds.schema,new ds({twitterRegistryKey:n.toBytes(),twitterHandle:r}));return[ve(rr,t.SystemProgram.programId,u,o,s,a,new Tt(BigInt(await e.getMinimumBalanceForRentExemption(c.length+Ne.HEADER_LEN))),new Pt(BigInt(c.length)),cr,fr,cr),Ee(rr,u,new Pt(BigInt(0)),i.Buffer.from(c),cr)]}ds.schema=new Map([[ds,{kind:"struct",fields:[["twitterRegistryKey",[32]],["twitterHandle","string"]]}]]);const ys=async(t,e)=>{const{pubkey:r}=ti(e),{registry:n,nftOwner:i}=await Ne.retrieve(t,r);if(i)return i;try{const r=await ws(t,n.owner,e);if(void 0!==r)return r;return await gs(t,n.owner,e)}catch(t){if(t instanceof Error&&"FetchError"===t.name)throw t}return n.owner},gs=async(e,r,n)=>{const o=$o(n,exports.Record.SOL),s=await Xo(e,n);if(!(null==s?void 0:s.data))throw new _t(exports.ErrorType.NoRecordData);const a=new TextEncoder,u=i.Buffer.concat([s.data.slice(0,32),o.toBuffer()]),c=a.encode(u.toString("hex"));if(!Zo(c,s.data.slice(32),r))throw new _t(exports.ErrorType.InvalidSignature);return new t.PublicKey(s.data.slice(0,32))},ws=async(e,r,n)=>{try{const i=as(n,exports.Record.SOL),o=await Qr.retrieve(e,i),s=o.getStalenessId(),a=o.getRoAId(),u=o.getContent();if(0===s.compare(r.toBuffer())&&o.header.stalenessValidation===Zr.Solana&&0===a.compare(u)&&o.header.rightOfAssociationValidation===Zr.Solana)return new t.PublicKey(u)}catch(t){if(t instanceof Error&&"FetchError"===t.name)throw t}},ms=new t.PublicKey("85iDfUvr3HJyLM2zcq5BXSiDvUWfw6cSE1FfNBo8Ap29");class bs{constructor(e){this.tag=e.tag,this.nameAccount=new t.PublicKey(e.nameAccount)}static deserialize(t){return be(this.schema,bs,t)}static async retrieve(t,e){const r=await t.getAccountInfo(e);if(!r||!r.data)throw new _t(exports.ErrorType.FavouriteDomainNotFound);return this.deserialize(r.data)}static async getKey(e,r){return await t.PublicKey.findProgramAddress([i.Buffer.from("favourite_domain"),r.toBuffer()],e)}static getKeySync(e,r){return t.PublicKey.findProgramAddressSync([i.Buffer.from("favourite_domain"),r.toBuffer()],e)}}bs.schema=new Map([[bs,{kind:"struct",fields:[["tag","u8"],["nameAccount",[32]]]}]]);var vs;exports.CustomBg=void 0,(vs=exports.CustomBg||(exports.CustomBg={})).DegenPoet1="DegenPoet#1",vs.Rgb0x001="rgb0x00#1";const Es=new t.PublicKey("ART5dr4bDic2sQVZoFheEmUxwQq5VGSx9he7JxHcXNQD"),xs=new t.PublicKey("CSWvuDHXExVGEMR9kP8xYAHuNjXogeRck9Cnr312CC9g"),As={NAME_PROGRAM_ID:new t.PublicKey("namesLPneVptA9Z5rqUDD9tMTWEJwofgaYwp8cawRkX"),HASH_PREFIX:"SPL Name Service",ROOT_DOMAIN_ACCOUNT:new t.PublicKey("5eoDkP6vCQBXqDV9YN2NdUs3nmML3dMRNmEYpiyVNBm2"),REGISTER_PROGRAM_ID:new t.PublicKey("snshBoEQ9jx4QoHBpZDQPYdNCtw7RMxJvYrKFEhwaPJ"),REVERSE_LOOKUP_CLASS:new t.PublicKey("7NbD1vprif6apthEZAqhRfYuhrqnuderB8qpnfXGCc8H"),USDC_MINT:new t.PublicKey("4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU"),REFERRERS:[new t.PublicKey("3ogYncmMM5CmytsGCqKHydmXmKUZ6sGWvizkzqwT7zb1")],TOKENS_SYM_MINT:new Map([["4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU","USDC"],["EJwZgeZrdC8TXTQbQBoL6bfuAnFUUy1PVCMB4DYPzVaS","USDT"],["So11111111111111111111111111111111111111112","SOL"],["fidaWCioBQjieRrUQDxxS5Uxmq1CLi2VuVRyv4dEBey","FIDA"],["DL4ivZm3NVHWk9ZvtcqTchxoKArDK4rT3vbDx2gYVr7P","INJ"]]),PYTH_FEEDS:new Map([["4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU",{price:"5SSkXsEKQepHHAewytPVwdej4epN1nxgLVM84L4KXgy7",product:"6NpdXrQEpmDZ3jZKmM2rhdmkd3H6QAk23j2x8bkXcHKA"}],["EJwZgeZrdC8TXTQbQBoL6bfuAnFUUy1PVCMB4DYPzVaS",{price:"38xoQ4oeJCBrcVvca2cGk7iV1dAfrmTR1kmhSCJQ8Jto",product:"C5wDxND9E61RZ1wZhaSTWkoA8udumaHnoQY6BBsiaVpn"}],["So11111111111111111111111111111111111111112",{price:"J83w4HKfqxwcq3BEMMkPFSppX3gqekLyLJBexebFVkix",product:"3Mnn2fX6rQyUsyELYms1sBJyChWofzSNRoqYzvgMVz5E"}],["EchesyfXePKdLtoiZSL8pBe8Myagyy8ZRqsACNCFGnvp",{price:"7teETxN9Y8VK6uJxsctHEwST75mKLLwPH1jaFdvTQCpD",product:"5kWV4bhHeZANzg5MWaYCQYEEKHjur5uz1mu5vuLHwiLB"}],["DL4ivZm3NVHWk9ZvtcqTchxoKArDK4rT3vbDx2gYVr7P",{price:"44uRsNnT35kjkscSu59MxRr9CfkLZWf6gny8bWqUbVxE",product:"7UHB783Nh4avW3Yw9yoktf2KjxipU56KPahA51RnCCYE"}]]),PYTH_MAPPING_ACC:new t.PublicKey("BmA9Z6FjioHJPpjT39QazZyhDRUdZy2ezwx4GiDdE2u2"),VAULT_OWNER:new t.PublicKey("SNSaTJbEv2iT3CUrCQYa9zpGjbBVWhFCPaSJHkaJX34")},Bs=(e,r,n)=>{const o=[e];r?o.push(r.toBuffer()):o.push(i.Buffer.alloc(32)),n?o.push(n.toBuffer()):o.push(i.Buffer.alloc(32));const[s]=t.PublicKey.findProgramAddressSync(o,As.NAME_PROGRAM_ID);return s},Ss=(t,e=As.ROOT_DOMAIN_ACCOUNT,r)=>{let n=$n(t);return{pubkey:Bs(n,r,e),hashed:n}},Is=t=>{t.endsWith(".sol")&&(t=t.slice(0,-4));const e=t.split(".");if(2===e.length){const t="\0".concat(e[0]),{pubkey:r}=Ss(e[1]);return{...Ss(t,r),isSub:!0,parent:r}}if(e.length>=3)throw new _t(exports.ErrorType.InvalidInput);return{...Ss(t,As.ROOT_DOMAIN_ACCOUNT),isSub:!1,parent:void 0}},Ms=(t,e)=>{const{pubkey:r,parent:n}=Is(t),i=$n(r.toBase58());return Bs(i,As.REVERSE_LOOKUP_CLASS,e?n:void 0)};async function Rs(e,r,n,i,o,s,a,u){const c=await xr(r),f=await Bs(c,a,u),h=s||await e.getMinimumBalanceForRentExemption(n);let l;if(u){const{registry:t}=await Er(e,u);l=t.owner}return ve(As.NAME_PROGRAM_ID,t.SystemProgram.programId,f,o,i,c,new Tt(BigInt(h)),new Pt(BigInt(n)),a,u,l)}const ks=async(e,r,n,i,o)=>{let[s]=await t.PublicKey.findProgramAddress([As.REGISTER_PROGRAM_ID.toBuffer()],As.REGISTER_PROGRAM_ID),a=await xr(e.toBase58()),u=Bs(a,s,i);return[[],[new Se({name:r}).getInstruction(As.REGISTER_PROGRAM_ID,As.NAME_PROGRAM_ID,As.ROOT_DOMAIN_ACCOUNT,u,t.SystemProgram.programId,s,n,t.SYSVAR_RENT_PUBKEY,i,o)]]},_s={utils:{getNameAccountKeySync:Bs,reverseLookup:async(t,e)=>{const r=$n(e.toBase58()),n=Bs(r,As.REVERSE_LOOKUP_CLASS),{registry:i}=await Ne.retrieve(t,n);if(!i.data)throw new _t(exports.ErrorType.NoAccountData);return oi(i.data)},_deriveSync:Ss,getDomainKeySync:Is,getReverseKeySync:Ms},constants:As,bindings:{createNameRegistry:Rs,updateNameRegistryData:async function(t,e,r,n,i,o){const s=await xr(e),a=Bs(s,i,o);let u;return u=i||(await Ne.retrieve(t,a)).registry.owner,Ee(As.NAME_PROGRAM_ID,a,new Pt(BigInt(r)),n,u)},transferNameOwnership:async function(t,e,r,n,i,o){const s=await xr(e),a=Bs(s,n,i);let u;return u=n||(await Ne.retrieve(t,a)).registry.owner,xe(As.NAME_PROGRAM_ID,a,r,u,n,i,o)},deleteNameRegistry:async function(t,e,r,n,i){const o=await xr(e),s=Bs(o,n,i);let a;return a=n||(await Ne.retrieve(t,s)).registry.owner,Ae(As.NAME_PROGRAM_ID,s,r,a)},registerDomainName:async(e,r,n,i,o,s=As.USDC_MINT,a)=>{if(r.includes(".")||r.trim().toLowerCase()!==r)throw new _t(exports.ErrorType.InvalidDomain);const[u]=t.PublicKey.findProgramAddressSync([As.REGISTER_PROGRAM_ID.toBuffer()],As.REGISTER_PROGRAM_ID),c=$n(r),f=Bs(c,void 0,As.ROOT_DOMAIN_ACCOUNT),h=$n(f.toBase58()),l=Bs(h,u),[d]=t.PublicKey.findProgramAddressSync([f.toBuffer()],As.REGISTER_PROGRAM_ID),y=As.REFERRERS.findIndex((t=>null==a?void 0:a.equals(t)));let g;const w=[];if(-1!==y&&a){g=Mt(s,a,!0);const t=await e.getAccountInfo(g);if(!(null==t?void 0:t.data)){const t=Rt(i,g,a,s);w.push(t)}}const m=Mt(s,As.VAULT_OWNER),b=_s.constants.PYTH_FEEDS.get(s.toBase58());if(!b)throw new _t(exports.ErrorType.PythFeedNotFound);const v=new Ie({name:r,space:n,referrerIdxOpt:-1!=y?y:null}).getInstruction(As.REGISTER_PROGRAM_ID,As.NAME_PROGRAM_ID,As.ROOT_DOMAIN_ACCOUNT,f,l,t.SystemProgram.programId,u,i,o,As.PYTH_MAPPING_ACC,new t.PublicKey(b.product),new t.PublicKey(b.price),m,p,t.SYSVAR_RENT_PUBKEY,d,g);return w.push(v),[[],w]},createReverseName:ks,createSubdomain:async(t,e,r,n=2e3)=>{const i=[],o=e.split(".")[0];if(!o)throw new _t(exports.ErrorType.InvalidSubdomain);const{parent:s,pubkey:a}=Is(e),u=await t.getMinimumBalanceForRentExemption(n+Ne.HEADER_LEN),c=await Rs(t,"\0".concat(o),n,r,r,u,void 0,s);i.push(c);const f=Ms(e,!0),h=await t.getAccountInfo(f);if(!(null==h?void 0:h.data)){const[,t]=await ks(a,"\0".concat(o),r,s,r);i.push(...t)}return[[],i]},burnDomain:(e,r,n)=>{const{pubkey:i}=Is(e),[o]=t.PublicKey.findProgramAddressSync([i.toBuffer()],As.REGISTER_PROGRAM_ID),[s]=t.PublicKey.findProgramAddressSync([i.toBuffer(),Uint8Array.from([1,1])],As.REGISTER_PROGRAM_ID);return(new Re).getInstruction(As.REGISTER_PROGRAM_ID,As.NAME_PROGRAM_ID,t.SystemProgram.programId,i,Ms(e),s,o,As.REVERSE_LOOKUP_CLASS,r,n)},transferSubdomain:async(t,e,r,n,i)=>{const{pubkey:o,isSub:s,parent:a}=Is(e);if(!a||!s)throw new _t(exports.ErrorType.InvalidSubdomain);if(!i){const{registry:e}=await Ne.retrieve(t,o);i=e.owner}let u,c;n&&(u=a,c=(await Ne.retrieve(t,a)).registry.owner);return xe(As.NAME_PROGRAM_ID,o,r,i,void 0,u,c)}}};exports.BONFIDA_FIDA_BNB=ar,exports.BONFIDA_USDC_BNB=hr,exports.CUSTOM_BG_TLD=mr,exports.ETH_ROA_RECORDS=rs,exports.FavouriteDomain=bs,exports.GUARDIANS=es,exports.HASH_PREFIX=nr,exports.METAPLEX_ID=vr,exports.NAME_OFFERS_ID=ms,exports.NAME_PROGRAM_ID=rr,exports.NameRegistryState=Ne,exports.Numberu32=Pt,exports.Numberu64=Tt,exports.PYTH_FEEDS=yr,exports.PYTH_FIDA_PRICE_ACC=sr,exports.PYTH_MAPPING_ACC=gr,exports.RECORD_V1_SIZE=tn,exports.REFERRERS=dr,exports.REGISTER_PROGRAM_ID=or,exports.REVERSE_LOOKUP_CLASS=ur,exports.ROOT_DOMAIN_ACCOUNT=ir,exports.ReverseTwitterRegistryState=ds,exports.SELF_SIGNED=is,exports.SNSError=_t,exports.SOL_RECORD_SIG_LEN=96,exports.TOKENS_SYM_MINT=pr,exports.TWITTER_ROOT_PARENT_REGISTRY_KEY=fr,exports.TWITTER_VERIFICATION_AUTHORITY=cr,exports.USDC_MINT=lr,exports.UTF8_ENCODED=ns,exports.VAULT_OWNER=wr,exports.WOLVES_COLLECTION_METADATA=br,exports.burnDomain=(e,r,n)=>{const{pubkey:i}=ti(e),[o]=t.PublicKey.findProgramAddressSync([i.toBuffer()],or),[s]=t.PublicKey.findProgramAddressSync([i.toBuffer(),Uint8Array.from([1,1])],or);return(new Re).getInstruction(or,rr,t.SystemProgram.programId,i,ri(e),s,o,ur,r,n)},exports.burnInstruction=Re,exports.changeTwitterRegistryData=async function(t,e,r,n){const i=$n(t),o=Yn(i,void 0,fr);return[Ee(rr,o,new Pt(BigInt(r)),n,e)]},exports.changeVerifiedPubkey=async function(t,e,r,n,i){const o=$n(e),s=Yn(o,void 0,fr);let a=[xe(rr,s,n,r,void 0)];return a.push(await cs(t,r.toString(),i,cr,fr)),a=a.concat(await ps(t,e,s,n,i)),a},exports.check=ii,exports.checkSolRecord=Zo,exports.createInstruction=ve,exports.createInstructionV3=Ie,exports.createNameRegistry=us,exports.createRecordInstruction=hs,exports.createRecordV2Instruction=(e,r,n,i,o)=>{let{pubkey:s,parent:a,isSub:u}=ti(`${r}.${e}`,exports.RecordVersion.V2);if(u&&(a=ti(e).pubkey),!a)throw new Error("Invalid parent");const c=((e,r,n,i,o,s,a,u)=>new Vr({record:s,content:Array.from(a)}).getInstruction(u,t.SystemProgram.programId,o,e,r,n,i,qr))(o,s,a,i,rr,"".concat(r),ss(n,r),Gr);return c},exports.createReverseInstruction=Se,exports.createReverseName=fs,exports.createReverseTwitterRegistry=ps,exports.createSolRecordInstruction=ls,exports.createSubdomain=async(t,e,r,n=2e3)=>{const i=[],o=e.split(".")[0];if(!o)throw new _t(exports.ErrorType.InvalidSubdomain);const{parent:s,pubkey:a}=ti(e),u=await t.getMinimumBalanceForRentExemption(n+Ne.HEADER_LEN),c=await us(t,"\0".concat(o),n,r,r,u,void 0,s);i.push(c);const f=ri(e,!0),h=await t.getAccountInfo(f);if(!(null==h?void 0:h.data)){const[,t]=await fs(a,"\0".concat(o),r,s,r);i.push(...t)}return[[],i]},exports.createV2Instruction=Be,exports.createVerifiedTwitterRegistry=async function(e,r,n,i,o){const s=$n(r),a=Yn(s,void 0,fr),u=await e.getMinimumBalanceForRentExemption(i+Ne.HEADER_LEN);let c=[ve(rr,t.SystemProgram.programId,a,n,o,s,new Tt(BigInt(u)),new Pt(BigInt(i)),void 0,fr,cr)];return c=c.concat(await ps(e,r,a,n,o)),c},exports.createWithNftInstruction=Me,exports.deleteInstruction=Ae,exports.deleteNameRegistry=cs,exports.deleteRecordV2=(e,r,n,i)=>{let{pubkey:o,parent:s,isSub:a}=ti(`${r}.${e}`,exports.RecordVersion.V2);if(a&&(s=ti(e).pubkey),!s)throw new Error("Invalid parent");const u=((e,r,n,i,o,s)=>(new Kr).getInstruction(s,t.SystemProgram.programId,o,e,i,r,n,qr))(i,s,n,o,rr,Gr);return u},exports.deleteTwitterRegistry=async function(t,e){const r=$n(t),n=Yn(r,void 0,fr),i=$n(e.toString()),o=Yn(i,cr,fr);return[Ae(rr,n,e,e),Ae(rr,o,e,e)]},exports.deserializeRecord=Qo,exports.deserializeRecordV2Content=os,exports.deserializeReverse=oi,exports.devnet=_s,exports.ethValidateRecordV2Content=(e,r,n,i,o,s)=>{let{pubkey:a,parent:u,isSub:c}=ti(`${r}.${e}`,exports.RecordVersion.V2);if(c&&(u=ti(e).pubkey),!u)throw new Error("Invalid parent");const f=((e,r,n,i,o,s,a,u,c)=>new Wr({validation:s,signature:Array.from(a),expectedPubkey:Array.from(u)}).getInstruction(c,t.SystemProgram.programId,o,e,r,n,i,qr))(i,a,u,n,rr,Zr.Ethereum,o,s,Gr);return f},exports.findSubdomains=async(t,e)=>{const r=[{memcmp:{offset:0,bytes:e.toBase58()}},{memcmp:{offset:64,bytes:ur.toBase58()}}],n=await t.getProgramAccounts(rr,{filters:r}),i=[{memcmp:{offset:0,bytes:e.toBase58()}}],o=await t.getProgramAccounts(rr,{filters:i,dataSlice:{offset:0,length:0}}),s=new Map(n.map((t=>[t.pubkey.toBase58(),oi(t.account.data.slice(96))]))),a=[];return o.forEach((t=>{const r=ni(t.pubkey,e).toBase58(),n=s.get(r);n&&a.push(n.replace("\0",""))})),a},exports.getAllDomains=ei,exports.getAllRegisteredDomains=async t=>{const e=[{memcmp:{offset:0,bytes:ir.toBase58()}}];return await t.getProgramAccounts(rr,{dataSlice:{offset:32,length:32},filters:e})},exports.getArtistPubkey=t=>{switch(t){case exports.CustomBg.DegenPoet1:return Es;case exports.CustomBg.Rgb0x001:return xs;default:throw new _t(exports.ErrorType.InvalidCustomBg)}},exports.getArweaveRecord=async(t,e)=>await Yo(t,e,exports.Record.ARWV,!0),exports.getBackgroundRecord=async(t,e)=>await Yo(t,e,exports.Record.Background,!0),exports.getBackpackRecord=async(t,e)=>await Yo(t,e,exports.Record.Backpack,!0),exports.getBscRecord=async(t,e)=>await Yo(t,e,exports.Record.BSC,!0),exports.getBtcRecord=async(t,e)=>await Yo(t,e,exports.Record.BTC,!0),exports.getCustomBgKeys=(t,e)=>{const r=$n(e),n=$n(t),i=Yn(n,void 0,mr);return{domainKey:i,bgKey:Yn(r,void 0,i)}},exports.getDiscordRecord=async(t,e)=>await Yo(t,e,exports.Record.Discord,!0),exports.getDogeRecord=async(t,e)=>await Yo(t,e,exports.Record.DOGE,!0),exports.getDomainKey=Sr,exports.getDomainKeySync=ti,exports.getDomainKeysWithReverses=async function(t,e){const r=await ei(t,e),n=await Qn(t,r);return r.map(((t,e)=>({pubKey:t,domain:n[e]})))},exports.getDomainPriceFromName=t=>{switch(Zn(t).length){case 1:return 750;case 2:return 700;case 3:return 640;case 4:return 160;default:return 20}},exports.getEmailRecord=async(t,e)=>await Yo(t,e,exports.Record.Email,!0),exports.getEthRecord=async(t,e)=>await Yo(t,e,exports.Record.ETH,!0),exports.getFavoriteDomain=async(e,r)=>{const[n]=bs.getKeySync(ms,new t.PublicKey(r)),i=await bs.retrieve(e,n),o=await Xn(e,i.nameAccount),s=await ys(e,o);return{domain:i.nameAccount,reverse:o,stale:!r.equals(s)}},exports.getGithubRecord=async(t,e)=>await Yo(t,e,exports.Record.Github,!0),exports.getHandleAndRegistryKey=async function(e,r){const n=$n(r.toString()),i=Yn(n,cr,fr);let o=await ds.retrieve(e,i);return[o.twitterHandle,new t.PublicKey(o.twitterRegistryKey)]},exports.getHashedName=xr,exports.getHashedNameSync=$n,exports.getInjectiveRecord=async(t,e)=>await Yo(t,e,exports.Record.Injective,!0),exports.getIpfsRecord=async(t,e)=>await Yo(t,e,exports.Record.IPFS,!0),exports.getLtcRecord=async(t,e)=>await Yo(t,e,exports.Record.LTC,!0),exports.getMultipleFavoriteDomains=async(e,r)=>{const n=[],i=r.map((t=>bs.getKeySync(ms,t)[0])),o=(await e.getMultipleAccountsInfo(i)).map((e=>(null==e?void 0:e.data)?bs.deserialize(null==e?void 0:e.data).nameAccount:t.PublicKey.default)),s=o.map((t=>ni(t))),a=o.map(((e,n)=>Mt((e=>{const[r]=t.PublicKey.findProgramAddressSync([_e,e.toBuffer()],ke);return r})(e),r[n],!0))),[u,c,f]=await Promise.all([e.getMultipleAccountsInfo(o),e.getMultipleAccountsInfo(s),e.getMultipleAccountsInfo(a)]);for(let e=0;e<r.length;e++){const i=u[e],o=c[e],s=f[e];if(!i||!o){n.push(void 0);continue}if(new t.PublicKey(null==i?void 0:i.data.slice(32,64)).equals(r[e])){n.push(oi(null==o?void 0:o.data.slice(96)));continue}if(!s){n.push(void 0);continue}const a=xt.decode(s.data);1!==Number(a.amount)?n.push(void 0):n.push(oi(null==o?void 0:o.data.slice(96)))}return n},exports.getMultipleRecordsV2=async function(t,e,r,n={}){const i=r.map((t=>as(e,t))),o=await Qr.retrieveBatch(t,i);return n.deserialize?o.map(((t,e)=>{if(t)return{retrievedRecord:t,record:r[e],deserializedContent:os(t.getContent(),r[e])}})):o.map(((t,e)=>{if(t)return{retrievedRecord:t,record:r[e]}}))},exports.getNameAccountKey=Ar,exports.getNameAccountKeySync=Yn,exports.getNameOwner=Er,exports.getPicRecord=async(t,e)=>await Yo(t,e,exports.Record.Pic,!0),exports.getPointRecord=async(t,e)=>await Yo(t,e,exports.Record.POINT,!0),exports.getRecord=Yo,exports.getRecordKeySync=$o,exports.getRecordV2=async function(t,e,r,n={}){const i=as(e,r),o=await Qr.retrieve(t,i);return n.deserialize?{retrievedRecord:o,deserializedContent:os(o.getContent(),r)}:{retrievedRecord:o}},exports.getRecordV2Key=as,exports.getRecords=async function(t,e,r,n){const i=r.map((t=>$o(e,t))),o=await Ne.retrieveBatch(t,i);return n?o.map(((t,n)=>{if(t)return Qo(t,r[n],$o(e,r[n]))})):o},exports.getRedditRecord=async(t,e)=>await Yo(t,e,exports.Record.Reddit,!0),exports.getReverseKey=async(t,e)=>{const{pubkey:r,parent:n}=await Sr(t),i=await xr(r.toBase58());return await Ar(i,ur,e?n:void 0)},exports.getReverseKeyFromDomainKey=ni,exports.getReverseKeySync=ri,exports.getShdwRecord=async(t,e)=>await Yo(t,e,exports.Record.SHDW,!0),exports.getSolRecord=Xo,exports.getTelegramRecord=async(t,e)=>await Yo(t,e,exports.Record.Telegram,!0),exports.getTokenizedDomains=async(t,e)=>{const r=await Ce(t,e),n=await Qn(t,r.map((t=>t.nameAccount)));return n.map(((t,e)=>({key:r[e].nameAccount,mint:r[e].nftMint,reverse:t}))).filter((t=>!!t.reverse))},exports.getTwitterHandleandRegistryKeyViaFilters=async function(e,r){const n=[{memcmp:{offset:0,bytes:fr.toBase58()}},{memcmp:{offset:32,bytes:r.toBase58()}},{memcmp:{offset:64,bytes:cr.toBase58()}}],i=await e.getProgramAccounts(rr,{filters:n});for(const e of i)if(e.account.data.length>Ne.HEADER_LEN+32){let r=e.account.data.slice(Ne.HEADER_LEN),n=ne(ds.schema,ds,r);return[n.twitterHandle,new t.PublicKey(n.twitterRegistryKey)]}throw new _t(exports.ErrorType.AccountDoesNotExist)},exports.getTwitterRecord=async(t,e)=>await Yo(t,e,exports.Record.Twitter,!0),exports.getTwitterRegistry=async function(t,e){const r=$n(e),n=Yn(r,void 0,fr),{registry:i}=await Ne.retrieve(t,n);return i},exports.getTwitterRegistryData=async function(e,r){const n=[{memcmp:{offset:0,bytes:fr.toBase58()}},{memcmp:{offset:32,bytes:r.toBase58()}},{memcmp:{offset:64,bytes:new t.PublicKey(i.Buffer.alloc(32,0)).toBase58()}}],o=await e.getProgramAccounts(rr,{filters:n});if(o.length>1)throw new _t(exports.ErrorType.MultipleRegistries);return o[0].account.data.slice(Ne.HEADER_LEN)},exports.getTwitterRegistryKey=async function(t){const e=$n(t);return Yn(e,void 0,fr)},exports.getUrlRecord=async(t,e)=>await Yo(t,e,exports.Record.Url,!0),exports.performReverseLookup=async function(t,e){const r=await xr(e.toBase58()),n=await Ar(r,ur),{registry:i}=await Ne.retrieve(t,n);if(!i.data)throw new _t(exports.ErrorType.NoAccountData);const o=i.data.slice(0,4).readUInt32LE(0);return i.data.slice(4,4+o).toString()},exports.performReverseLookupBatch=async function(t,e){let r=[];for(let t of e){const e=await xr(t.toBase58()),n=await Ar(e,ur);r.push(n)}return(await Ne.retrieveBatch(t,r)).map((t=>{if(void 0===t||void 0===t.data)return;const e=t.data.slice(0,4).readUInt32LE(0);return t.data.slice(4,4+e).toString()}))},exports.reallocInstruction=function(e,r,n,o,s,a){const u=[i.Buffer.from(Int8Array.from([4])),a.toBuffer()],c=i.Buffer.concat(u),f=[{pubkey:r,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!0},{pubkey:o,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!0,isWritable:!1}];return new t.TransactionInstruction({keys:f,programId:e,data:c})},exports.registerDomainName=async(e,r,n,i,o,s=lr,a)=>{if(r.includes(".")||r.trim().toLowerCase()!==r)throw new _t(exports.ErrorType.InvalidDomain);const[u]=t.PublicKey.findProgramAddressSync([or.toBuffer()],or),c=$n(r),f=Yn(c,void 0,ir),h=$n(f.toBase58()),l=Yn(h,u),[d]=t.PublicKey.findProgramAddressSync([f.toBuffer()],or),y=dr.findIndex((t=>null==a?void 0:a.equals(t)));let g;const w=[];if(-1!==y&&a){g=Mt(s,a,!0);const t=await e.getAccountInfo(g);if(!(null==t?void 0:t.data)){const t=Rt(i,g,a,s);w.push(t)}}const m=Mt(s,wr),b=yr.get(s.toBase58());if(!b)throw new _t(exports.ErrorType.PythFeedNotFound);const v=new Ie({name:r,space:n,referrerIdxOpt:-1!=y?y:null}).getInstruction(or,rr,ir,f,l,t.SystemProgram.programId,u,i,o,gr,new t.PublicKey(b.product),new t.PublicKey(b.price),m,p,t.SYSVAR_RENT_PUBKEY,d,g);return w.push(v),[[],w]},exports.registerWithNft=(e,r,n,i,o,s,a,u,c)=>{const[f]=t.PublicKey.findProgramAddressSync([n.toBuffer()],or);return new Me({space:r,name:e}).getInstruction(or,rr,ir,n,i,t.SystemProgram.programId,ur,o,s,a,u,c,br,p,t.SYSVAR_RENT_PUBKEY,f,vr)},exports.resolve=ys,exports.retrieveNftOwner=Ue,exports.retrieveNfts=async e=>{const r=await e.getProgramAccounts(ke,{filters:[{memcmp:{offset:0,bytes:"3"}}]});return r.map((e=>new t.PublicKey(e.account.data.slice(66,98))))},exports.retrieveRecords=Ce,exports.reverseLookup=Xn,exports.reverseLookupBatch=Qn,exports.serializeRecord=Jo,exports.serializeRecordV2Content=ss,exports.serializeSolRecord=ts,exports.transferInstruction=xe,exports.transferNameOwnership=async function(t,e,r,n,i,o){const s=$n(e),a=Yn(s,n,i);let u;return u=n||(await Ne.retrieve(t,a)).registry.owner,xe(rr,a,r,u,n,i,o)},exports.transferSubdomain=async(t,e,r,n,i)=>{const{pubkey:o,isSub:s,parent:a}=ti(e);if(!a||!s)throw new _t(exports.ErrorType.InvalidSubdomain);if(!i){const{registry:e}=await Ne.retrieve(t,o);i=e.owner}let u,c;n&&(u=a,c=(await Ne.retrieve(t,a)).registry.owner);return xe(rr,o,r,i,void 0,u,c)},exports.updateInstruction=Ee,exports.updateNameRegistryData=async function(t,e,r,n,i,o){const s=$n(e),a=Yn(s,i,o);let u;return u=i||(await Ne.retrieve(t,a)).registry.owner,Ee(rr,a,new Pt(BigInt(r)),n,u)},exports.updateRecordInstruction=async(t,e,r,n,i,o)=>{ii(r!==exports.Record.SOL,exports.ErrorType.UnsupportedRecord);const{pubkey:s}=ti(`${r}.${e}`,exports.RecordVersion.V1),a=await t.getAccountInfo(s);ii(!!(null==a?void 0:a.data),exports.ErrorType.AccountDoesNotExist);const u=Jo(n,r);if((null==a?void 0:a.data.slice(96).length)!==u.length)return[Ae(rr,s,o,i),await hs(t,e,r,n,i,o)];return[Ee(rr,s,new Pt(BigInt(0)),u,i)]},exports.updateRecordV2Instruction=(e,r,n,i,o)=>{let{pubkey:s,parent:a,isSub:u}=ti(`${r}.${e}`,exports.RecordVersion.V2);if(u&&(a=ti(e).pubkey),!a)throw new Error("Invalid parent");const c=((e,r,n,i,o,s,a,u)=>new jr({record:s,content:Array.from(a)}).getInstruction(u,t.SystemProgram.programId,o,e,r,n,i,qr))(o,s,a,i,rr,"".concat(r),ss(n,r),Gr);return c},exports.updateSolRecordInstruction=async(t,e,r,n,i,o)=>{const{pubkey:s}=ti(`${exports.Record.SOL}.${e}`,exports.RecordVersion.V1),a=await t.getAccountInfo(s);if(ii(!!(null==a?void 0:a.data),exports.ErrorType.AccountDoesNotExist),96!==(null==a?void 0:a.data.length))return[Ae(rr,s,o,n),await ls(t,e,r,n,i,o)];const u=ts(r,s,n,i);return[Ee(rr,s,new Pt(BigInt(0)),u,n)]},exports.validateRecordV2Content=(e,r,n,i,o,s)=>{let{pubkey:a,parent:u,isSub:c}=ti(`${n}.${r}`,exports.RecordVersion.V2);if(c&&(u=ti(r).pubkey),!u)throw new Error("Invalid parent");const f=((e,r,n,i,o,s,a,u)=>new Fr({staleness:a}).getInstruction(u,t.SystemProgram.programId,s,e,r,n,i,qr,o))(o,a,u,i,s,rr,e,Gr);return f},exports.verifyRightOfAssociation=async(t,e,r,n)=>{var i;const o=as(r,e),s=await Qr.retrieve(t,o),a=s.getRoAId(),u=rs.has(e)?Zr.Ethereum:Zr.Solana;if(!(n=null!=n?n:null===(i=es.get(e))||void 0===i?void 0:i.toBuffer()))throw new _t(exports.ErrorType.MissingVerifier);return 0===n.compare(a)&&s.header.rightOfAssociationValidation===u},exports.verifyStaleness=async(e,r,n)=>{const i=as(n,r),o=await ys(e,n),s=await Qr.retrieve(e,i),a=s.getStalenessId();return o.equals(new t.PublicKey(a))&&s.header.stalenessValidation===Zr.Solana},exports.writRoaRecordV2=(e,r,n,i,o)=>{let{pubkey:s,parent:a,isSub:u}=ti(`${r}.${e}`,exports.RecordVersion.V2);if(u&&(a=ti(e).pubkey),!a)throw new Error("Invalid parent");const c=((e,r,n,i,o,s,a)=>new Hr({roaId:Array.from(s.toBuffer())}).getInstruction(a,t.SystemProgram.programId,r,e,n,i,o,qr))(i,rr,s,a,n,o,Gr);return c};
|
|
19
|
+
function ii(t){if(!Number.isSafeInteger(t))throw new Error(`Wrong integer: ${t}`)}function si(...t){const e=t=>t,r=(t,e)=>r=>t(e(r));return{encode:t.map((t=>t.encode)).reduceRight(r,e),decode:t.map((t=>t.decode)).reduce(r,e)}}function ai(t){return{encode:e=>{if(!Array.isArray(e)||e.length&&"number"!=typeof e[0])throw new Error("alphabet.encode input should be an array of numbers");return e.map((e=>{if(ii(e),e<0||e>=t.length)throw new Error(`Digit index outside alphabet: ${e} (alphabet: ${t.length})`);return t[e]}))},decode:e=>{if(!Array.isArray(e)||e.length&&"string"!=typeof e[0])throw new Error("alphabet.decode input should be array of strings");return e.map((e=>{if("string"!=typeof e)throw new Error(`alphabet.decode: not string element=${e}`);const r=t.indexOf(e);if(-1===r)throw new Error(`Unknown letter: "${e}". Allowed: ${t}`);return r}))}}}function ci(t=""){if("string"!=typeof t)throw new Error("join separator should be string");return{encode:e=>{if(!Array.isArray(e)||e.length&&"string"!=typeof e[0])throw new Error("join.encode input should be array of strings");for(let t of e)if("string"!=typeof t)throw new Error(`join.encode: non-string input=${t}`);return e.join(t)},decode:e=>{if("string"!=typeof e)throw new Error("join.decode input should be string");return e.split(t)}}}function ui(t,e="="){if(ii(t),"string"!=typeof e)throw new Error("padding chr should be string");return{encode(r){if(!Array.isArray(r)||r.length&&"string"!=typeof r[0])throw new Error("padding.encode input should be array of strings");for(let t of r)if("string"!=typeof t)throw new Error(`padding.encode: non-string input=${t}`);for(;r.length*t%8;)r.push(e);return r},decode(r){if(!Array.isArray(r)||r.length&&"string"!=typeof r[0])throw new Error("padding.encode input should be array of strings");for(let t of r)if("string"!=typeof t)throw new Error(`padding.decode: non-string input=${t}`);let n=r.length;if(n*t%8)throw new Error("Invalid padding: string should have whole number of bytes");for(;n>0&&r[n-1]===e;n--)if(!((n-1)*t%8))throw new Error("Invalid padding: string has too much padding");return r.slice(0,n)}}}function fi(t){if("function"!=typeof t)throw new Error("normalize fn should be function");return{encode:t=>t,decode:e=>t(e)}}ei.pow($o,oi),ei.sqrt(ei.neg(ei.ONE)),ei.ORDER,BigInt(5),BigInt(8),BigInt(486662),function(t,e){if(!t.isOdd)throw new Error("Field doesn't have isOdd");const r=t.sqrt(e);t.isOdd(r)&&t.neg(r)}(ei,ei.neg(BigInt(486664))),BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");const hi=(t,e)=>e?hi(e,t%e):t,di=(t,e)=>t+(e-hi(t,e));function pi(t,e,r,n){if(!Array.isArray(t))throw new Error("convertRadix2: data should be array");if(e<=0||e>32)throw new Error(`convertRadix2: wrong from=${e}`);if(r<=0||r>32)throw new Error(`convertRadix2: wrong to=${r}`);if(di(e,r)>32)throw new Error(`convertRadix2: carry overflow from=${e} to=${r} carryBits=${di(e,r)}`);let o=0,i=0;const s=2**r-1,a=[];for(const n of t){if(ii(n),n>=2**e)throw new Error(`convertRadix2: invalid data word=${n} from=${e}`);if(o=o<<e|n,i+e>32)throw new Error(`convertRadix2: carry overflow pos=${i} from=${e}`);for(i+=e;i>=r;i-=r)a.push((o>>i-r&s)>>>0);o&=2**i-1}if(o=o<<r-i&s,!n&&i>=e)throw new Error("Excess padding");if(!n&&o)throw new Error(`Non-zero padding: ${o}`);return n&&i>0&&a.push(o>>>0),a}function li(t,e=!1){if(ii(t),t<=0||t>32)throw new Error("radix2: bits should be in (0..32]");if(di(8,t)>32||di(t,8)>32)throw new Error("radix2: carry overflow");return{encode:r=>{if(!function(t){return t instanceof Uint8Array||null!=t&&"object"==typeof t&&"Uint8Array"===t.constructor.name}(r))throw new Error("radix2.encode input should be Uint8Array");return pi(Array.from(r),8,t,!e)},decode:r=>{if(!Array.isArray(r)||r.length&&"number"!=typeof r[0])throw new Error("radix2.decode input should be array of numbers");return Uint8Array.from(pi(r,t,8,e))}}}function yi(t){if("function"!=typeof t)throw new Error("unsafeWrapper fn should be function");return function(...e){try{return t.apply(null,e)}catch(t){}}}li(4),ai("0123456789ABCDEF"),ci(""),li(5),ai("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),ui(5),ci(""),li(5),ai("0123456789ABCDEFGHIJKLMNOPQRSTUV"),ui(5),ci(""),li(5),ai("0123456789ABCDEFGHJKMNPQRSTVWXYZ"),ci(""),fi((t=>t.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1"))),li(6),ai("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),ui(6),ci(""),li(6),ai("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),ui(6),ci(""),li(6),ai("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),ci("");const gi=si(ai("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),ci("")),wi=[996825010,642813549,513874426,1027748829,705979059];function bi(t){const e=t>>25;let r=(33554431&t)<<5;for(let t=0;t<wi.length;t++)1==(e>>t&1)&&(r^=wi[t]);return r}function mi(t,e,r=1){const n=t.length;let o=1;for(let e=0;e<n;e++){const r=t.charCodeAt(e);if(r<33||r>126)throw new Error(`Invalid prefix (${t})`);o=bi(o)^r>>5}o=bi(o);for(let e=0;e<n;e++)o=bi(o)^31&t.charCodeAt(e);for(let t of e)o=bi(o)^t;for(let t=0;t<6;t++)o=bi(o);return o^=r,gi.encode(pi([o%2**30],30,5,!1))}function vi(t){const e="bech32"===t?1:734539939,r=li(5),n=r.decode,o=r.encode,i=yi(n);function s(t,r=90){if("string"!=typeof t)throw new Error("bech32.decode input should be string, not "+typeof t);if(t.length<8||!1!==r&&t.length>r)throw new TypeError(`Wrong string length: ${t.length} (${t}). Expected (8..${r})`);const n=t.toLowerCase();if(t!==n&&t!==t.toUpperCase())throw new Error("String must be lowercase or uppercase");const o=(t=n).lastIndexOf("1");if(0===o||-1===o)throw new Error('Letter "1" must be present between prefix and data only');const i=t.slice(0,o),s=t.slice(o+1);if(s.length<6)throw new Error("Data must be at least 6 characters long");const a=gi.decode(s).slice(0,-6),c=mi(i,a,e);if(!s.endsWith(c))throw new Error(`Invalid checksum in ${t}: expected "${c}"`);return{prefix:i,words:a}}return{encode:function(t,r,n=90){if("string"!=typeof t)throw new Error("bech32.encode prefix should be string, not "+typeof t);if(!Array.isArray(r)||r.length&&"number"!=typeof r[0])throw new Error("bech32.encode words should be array of numbers, not "+typeof r);const o=t.length+7+r.length;if(!1!==n&&o>n)throw new TypeError(`Length ${o} exceeds limit ${n}`);const i=t.toLowerCase(),s=mi(i,r,e);return`${i}1${gi.encode(r)}${s}`},decode:s,decodeToBytes:function(t){const{prefix:e,words:r}=s(t,!1);return{prefix:e,words:r,bytes:n(r)}},decodeUnsafe:yi(s),fromWords:n,fromWordsUnsafe:i,toWords:o}}const Ei=vi("bech32");li(4),ai("0123456789abcdef"),ci(""),fi((t=>{if("string"!=typeof t||t.length%2)throw new TypeError(`hex.decode: expected string, got ${typeof t} with length ${t.length}`);return t.toLowerCase()}));const xi=(t,e,r)=>ni.verify(e,t,r.toBytes()),Ai=(t,e)=>{const{pubkey:r}=Pn(e+"."+t,exports.RecordVersion.V1);return r};async function Ii(t,e,r,n){const o=Ai(e,r);let{registry:i}=await he.retrieve(t,o);if(!i.data)throw new kt(exports.ErrorType.NoRecordData);if(n)return Bi(i,r,o);const s=Pr.get(r);return i.data=i.data.slice(0,s),i}const Si=async(t,e)=>await Ii(t,e,exports.Record.SOL),Bi=(e,r,o)=>{const i=null==e?void 0:e.data;if(!i)return;if(0===i.compare(n.Buffer.alloc(i.length)))return;const s=Pr.get(r),a=(t=>{const e=Array.from(t);return e.length-1-e.reverse().findIndex((t=>0!==t))+1})(i);if(!s)return i.slice(0,a).toString("utf-8");if(r===exports.Record.SOL){const t=new TextEncoder,r=n.Buffer.concat([i.slice(0,32),o.toBuffer()]),s=t.encode(r.toString("hex"));if(xi(s,i.slice(32,96),e.owner))return Nn.encode(i.slice(0,32))}if(s&&a!==s){const t=i.slice(0,a).toString("utf-8");if(r===exports.Record.Injective){const e=Ei.decodeToBytes(t);if("inj"===e.prefix&&20===e.bytes.length)return t}else if(r===exports.Record.BSC||r===exports.Record.ETH){const e=t.slice(0,2),r=t.slice(2);if("0x"===e&&20===n.Buffer.from(r,"hex").length)return t}else if((r===exports.Record.A||r===exports.Record.AAAA)&&Mn.isValid(t))return t;throw new kt(exports.ErrorType.InvalidRecordData)}if(r===exports.Record.ETH||r===exports.Record.BSC)return"0x"+i.slice(0,s).toString("hex");if(r===exports.Record.Injective)return Ei.encode("inj",Ei.toWords(i.slice(0,s)));if(r===exports.Record.A||r===exports.Record.AAAA)return Mn.fromByteArray([...i.slice(0,s)]).toString();if(r===exports.Record.Background)return new t.PublicKey(i.slice(0,s)).toString();throw new kt(exports.ErrorType.InvalidRecordData)},Ri=(e,r)=>{if(!Pr.get(r))return r!==exports.Record.CNAME&&r!==exports.Record.TXT||(e=qn(e)),n.Buffer.from(e,"utf-8");if(r===exports.Record.SOL)throw new kt(exports.ErrorType.UnsupportedRecord,"Use `serializeSolRecord` for SOL record");if(r===exports.Record.ETH||r===exports.Record.BSC)return Un("0x"===e.slice(0,2),exports.ErrorType.InvalidEvmAddress),n.Buffer.from(e.slice(2),"hex");if(r===exports.Record.Injective){const t=Ei.decodeToBytes(e);return Un("inj"===t.prefix,exports.ErrorType.InvalidInjectiveAddress),Un(20===t.bytes.length,exports.ErrorType.InvalidInjectiveAddress),n.Buffer.from(t.bytes)}if(r===exports.Record.A){const t=Mn.parse(e).toByteArray();return Un(4===t.length,exports.ErrorType.InvalidARecord),n.Buffer.from(t)}if(r===exports.Record.AAAA){const t=Mn.parse(e).toByteArray();return Un(16===t.length,exports.ErrorType.InvalidAAAARecord),n.Buffer.from(t)}if(r===exports.Record.Background)return new t.PublicKey(e).toBuffer();throw new kt(exports.ErrorType.InvalidRecordInput)},Pi=(t,e,r,o)=>{const i=n.Buffer.concat([t.toBuffer(),e.toBuffer()]),s=(new TextEncoder).encode(i.toString("hex")),a=xi(s,o,r);return Un(a,exports.ErrorType.InvalidSignature),n.Buffer.concat([t.toBuffer(),o])},ki=new Map([[exports.Record.Url,new t.PublicKey("ExXjtfdQe8JacoqP9Z535WzQKjF4CzW1TTRKRgpxvya3")]]),Ti=new Set([exports.Record.ETH,exports.Record.Injective,exports.Record.BSC]),_i=new Set([exports.Record.IPFS,exports.Record.ARWV,exports.Record.LTC,exports.Record.DOGE,exports.Record.Email,exports.Record.Url,exports.Record.Discord,exports.Record.Github,exports.Record.Reddit,exports.Record.Twitter,exports.Record.Telegram,exports.Record.Pic,exports.Record.SHDW,exports.Record.POINT,exports.Record.Backpack,exports.Record.TXT,exports.Record.CNAME,exports.Record.BTC]),Ui=new Set([exports.Record.ETH,exports.Record.Injective,exports.Record.SOL]),Li=(e,r)=>{if(_i.has(r)){const t=e.toString("utf-8");return r===exports.Record.CNAME||r===exports.Record.TXT?function(t){const e=[],r=t.length;let n=0,o=128,i=72,s=t.lastIndexOf("-");s<0&&(s=0);for(let r=0;r<s;++r)t.charCodeAt(r)>=128&&Kn("not-basic"),e.push(t.charCodeAt(r));for(let c=s>0?s+1:0;c<r;){const s=n;for(let e=1,o=zn;;o+=zn){c>=r&&Kn("invalid-input");const s=(a=t.charCodeAt(c++))>=48&&a<58?a-48+26:a>=65&&a<91?a-65:a>=97&&a<123?a-97:zn;s>=zn&&Kn("invalid-input"),s>jn((Vn-n)/e)&&Kn("overflow"),n+=s*e;const u=o<=i?1:o>=i+26?26:o-i;if(s<u)break;const f=zn-u;e>jn(Vn/f)&&Kn("overflow"),e*=f}const u=e.length+1;i=Gn(n-s,u,0==s),jn(n/u)>Vn-o&&Kn("overflow"),o+=jn(n/u),n%=u,e.splice(n++,0,o)}var a;return String.fromCodePoint(...e)}(t):t}if(r===exports.Record.SOL)return new t.PublicKey(e).toBase58();if(r===exports.Record.ETH||r===exports.Record.BSC)return"0x"+e.toString("hex");if(r===exports.Record.Injective)return Ei.encode("inj",Ei.toWords(e));if(r===exports.Record.A||r===exports.Record.AAAA)return Mn.fromByteArray([...e]).toString();throw new kt(exports.ErrorType.InvalidARecord)},Ci=(e,r)=>{if(_i.has(r))return r!==exports.Record.CNAME&&r!==exports.Record.TXT||(e=qn(e)),Buffer.from(e,"utf-8");if(r===exports.Record.SOL)return new t.PublicKey(e).toBuffer();if(r===exports.Record.ETH||r===exports.Record.BSC)return Un("0x"===e.slice(0,2),exports.ErrorType.InvalidEvmAddress),Buffer.from(e.slice(2),"hex");if(r===exports.Record.Injective){const t=Ei.decodeToBytes(e);return Un("inj"===t.prefix,exports.ErrorType.InvalidInjectiveAddress),Un(20===t.bytes.length,exports.ErrorType.InvalidInjectiveAddress),Buffer.from(t.bytes)}if(r===exports.Record.A){const t=Mn.parse(e).toByteArray();return Un(4===t.length,exports.ErrorType.InvalidARecord),Buffer.from(t)}if(r===exports.Record.AAAA){const t=Mn.parse(e).toByteArray();return Un(16===t.length,exports.ErrorType.InvalidAAAARecord),Buffer.from(t)}throw new kt(exports.ErrorType.InvalidARecord)},Oi=(t,e)=>{const{pubkey:r}=Pn(t),n=An("".concat(e));return In(n,Er,r)};async function Ni(e,r,n,o,i,s,a,c){const u=An(r),f=In(u,a,c),h=s||await e.getMinimumBalanceForRentExemption(n);let d;if(c){const{registry:t}=await $e(e,c);d=t.owner}return qt(Te,t.SystemProgram.programId,f,i,o,u,new _t(h),new Tt(n),a,c,d)}async function Di(t,e,r,n,o){const i=An(e),s=In(i,n,o);let a;a=n||(await he.retrieve(t,s)).registry.owner;return Zt(Te,s,r,a)}const Mi=async(e,r,n,o,i)=>{let[s]=await t.PublicKey.findProgramAddress([Le.toBuffer()],Le),a=An(e.toBase58()),c=In(a,s,o);return[[],[new Qt({name:r}).getInstruction(Le,Te,Ue,c,t.SystemProgram.programId,s,n,t.SYSVAR_RENT_PUBKEY,o,i)]]},Vi=async(e,r,n,o,i,s)=>{Un(n!==exports.Record.SOL,exports.ErrorType.UnsupportedRecord);const{pubkey:a,hashed:c,parent:u}=Pn(`${n}.${r}`,exports.RecordVersion.V1),f=Ri(o,n).length,h=await e.getMinimumBalanceForRentExemption(f+he.HEADER_LEN);return qt(Te,t.SystemProgram.programId,a,i,s,c,new _t(h),new Tt(f),void 0,u,i)},zi=async(e,r,n,o,i,s)=>{const{pubkey:a,hashed:c,parent:u}=Pn(`${exports.Record.SOL}.${r}`,exports.RecordVersion.V1),f=Pi(n,a,o,i).length,h=await e.getMinimumBalanceForRentExemption(f+he.HEADER_LEN);return[qt(Te,t.SystemProgram.programId,a,o,s,c,new _t(h),new Tt(f),void 0,u,o)]};class Wi{constructor(t){this.twitterRegistryKey=t.twitterRegistryKey,this.twitterHandle=t.twitterHandle}static async retrieve(t,e){let r=await t.getAccountInfo(e,"processed");if(!r)throw new kt(exports.ErrorType.InvalidReverseTwitter);return new Wi(Gt(Wi.schema,r.data.slice(he.HEADER_LEN)))}}async function ji(e,r,o,i,s){const a=An(i.toString()),c=In(a,De,Me);let u=Ht(Wi.schema,new Wi({twitterRegistryKey:o.toBytes(),twitterHandle:r}));return[qt(Te,t.SystemProgram.programId,c,i,s,a,new _t(await e.getMinimumBalanceForRentExemption(u.length+he.HEADER_LEN)),new Tt(u.length),De,Me,De),Yt(Te,c,new Tt(0),n.Buffer.from(u),De)]}Wi.schema={struct:{twitterRegistryKey:{array:{type:"u8",len:32}},twitterHandle:"string"}};const Fi=async(t,e)=>{const{pubkey:r}=Pn(e),{registry:n,nftOwner:o}=await he.retrieve(t,r);if(o)return o;try{const r=await Hi(t,n.owner,e);if(void 0!==r)return r;return await Ki(t,n.owner,e)}catch(t){if(t instanceof Error&&"FetchError"===t.name)throw t}return n.owner},Ki=async(e,r,o)=>{const i=Ai(o,exports.Record.SOL),s=await Si(e,o);if(!(null==s?void 0:s.data))throw new kt(exports.ErrorType.NoRecordData);const a=new TextEncoder,c=n.Buffer.concat([s.data.slice(0,32),i.toBuffer()]),u=a.encode(c.toString("hex"));if(!xi(u,s.data.slice(32),r))throw new kt(exports.ErrorType.InvalidSignature);return new t.PublicKey(s.data.slice(0,32))},Hi=async(e,r,n)=>{try{const o=Oi(n,exports.Record.SOL),i=await Br.retrieve(e,o),s=i.getStalenessId(),a=i.getRoAId(),c=i.getContent();if(0===s.compare(r.toBuffer())&&i.header.stalenessValidation===xr.Solana&&0===a.compare(c)&&i.header.rightOfAssociationValidation===xr.Solana)return new t.PublicKey(c)}catch(t){if(t instanceof Error&&"FetchError"===t.name)throw t}},Gi=new t.PublicKey("85iDfUvr3HJyLM2zcq5BXSiDvUWfw6cSE1FfNBo8Ap29");class qi{constructor(e){this.tag=e.tag,this.nameAccount=new t.PublicKey(e.nameAccount)}static deserialize(t){return new qi(Gt(this.schema,t))}static async retrieve(t,e){const r=await t.getAccountInfo(e);if(!r||!r.data)throw new kt(exports.ErrorType.FavouriteDomainNotFound);return this.deserialize(r.data)}static async getKey(e,r){return await t.PublicKey.findProgramAddress([n.Buffer.from("favourite_domain"),r.toBuffer()],e)}static getKeySync(e,r){return t.PublicKey.findProgramAddressSync([n.Buffer.from("favourite_domain"),r.toBuffer()],e)}}qi.schema={struct:{tag:"u8",nameAccount:{array:{type:"u8",len:32}}}};var Yi;exports.CustomBg=void 0,(Yi=exports.CustomBg||(exports.CustomBg={})).DegenPoet1="DegenPoet#1",Yi.Rgb0x001="rgb0x00#1";const $i=new t.PublicKey("ART5dr4bDic2sQVZoFheEmUxwQq5VGSx9he7JxHcXNQD"),Zi=new t.PublicKey("CSWvuDHXExVGEMR9kP8xYAHuNjXogeRck9Cnr312CC9g"),Xi={NAME_PROGRAM_ID:new t.PublicKey("namesLPneVptA9Z5rqUDD9tMTWEJwofgaYwp8cawRkX"),HASH_PREFIX:"SPL Name Service",ROOT_DOMAIN_ACCOUNT:new t.PublicKey("5eoDkP6vCQBXqDV9YN2NdUs3nmML3dMRNmEYpiyVNBm2"),REGISTER_PROGRAM_ID:new t.PublicKey("snshBoEQ9jx4QoHBpZDQPYdNCtw7RMxJvYrKFEhwaPJ"),REVERSE_LOOKUP_CLASS:new t.PublicKey("7NbD1vprif6apthEZAqhRfYuhrqnuderB8qpnfXGCc8H"),USDC_MINT:new t.PublicKey("4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU"),REFERRERS:[new t.PublicKey("3ogYncmMM5CmytsGCqKHydmXmKUZ6sGWvizkzqwT7zb1")],TOKENS_SYM_MINT:new Map([["4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU","USDC"],["EJwZgeZrdC8TXTQbQBoL6bfuAnFUUy1PVCMB4DYPzVaS","USDT"],["So11111111111111111111111111111111111111112","SOL"],["fidaWCioBQjieRrUQDxxS5Uxmq1CLi2VuVRyv4dEBey","FIDA"],["DL4ivZm3NVHWk9ZvtcqTchxoKArDK4rT3vbDx2gYVr7P","INJ"]]),PYTH_FEEDS:new Map([["4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU",{price:"5SSkXsEKQepHHAewytPVwdej4epN1nxgLVM84L4KXgy7",product:"6NpdXrQEpmDZ3jZKmM2rhdmkd3H6QAk23j2x8bkXcHKA"}],["EJwZgeZrdC8TXTQbQBoL6bfuAnFUUy1PVCMB4DYPzVaS",{price:"38xoQ4oeJCBrcVvca2cGk7iV1dAfrmTR1kmhSCJQ8Jto",product:"C5wDxND9E61RZ1wZhaSTWkoA8udumaHnoQY6BBsiaVpn"}],["So11111111111111111111111111111111111111112",{price:"J83w4HKfqxwcq3BEMMkPFSppX3gqekLyLJBexebFVkix",product:"3Mnn2fX6rQyUsyELYms1sBJyChWofzSNRoqYzvgMVz5E"}],["EchesyfXePKdLtoiZSL8pBe8Myagyy8ZRqsACNCFGnvp",{price:"7teETxN9Y8VK6uJxsctHEwST75mKLLwPH1jaFdvTQCpD",product:"5kWV4bhHeZANzg5MWaYCQYEEKHjur5uz1mu5vuLHwiLB"}],["DL4ivZm3NVHWk9ZvtcqTchxoKArDK4rT3vbDx2gYVr7P",{price:"44uRsNnT35kjkscSu59MxRr9CfkLZWf6gny8bWqUbVxE",product:"7UHB783Nh4avW3Yw9yoktf2KjxipU56KPahA51RnCCYE"}]]),PYTH_MAPPING_ACC:new t.PublicKey("BmA9Z6FjioHJPpjT39QazZyhDRUdZy2ezwx4GiDdE2u2"),VAULT_OWNER:new t.PublicKey("SNSaTJbEv2iT3CUrCQYa9zpGjbBVWhFCPaSJHkaJX34")},Qi=(e,r,o)=>{const i=[e];r?i.push(r.toBuffer()):i.push(n.Buffer.alloc(32)),o?i.push(o.toBuffer()):i.push(n.Buffer.alloc(32));const[s]=t.PublicKey.findProgramAddressSync(i,Xi.NAME_PROGRAM_ID);return s},Ji=(t,e=Xi.ROOT_DOMAIN_ACCOUNT,r)=>{let n=An(t);return{pubkey:Qi(n,r,e),hashed:n}},ts=t=>{t.endsWith(".sol")&&(t=t.slice(0,-4));const e=t.split(".");if(2===e.length){const t="\0".concat(e[0]),{pubkey:r}=Ji(e[1]);return{...Ji(t,r),isSub:!0,parent:r}}if(e.length>=3)throw new kt(exports.ErrorType.InvalidInput);return{...Ji(t,Xi.ROOT_DOMAIN_ACCOUNT),isSub:!1,parent:void 0}},es=(t,e)=>{const{pubkey:r,parent:n}=ts(t),o=An(r.toBase58());return Qi(o,Xi.REVERSE_LOOKUP_CLASS,e?n:void 0)};async function rs(e,r,n,o,i,s,a,c){const u=await Ze(r),f=await Qi(u,a,c),h=s||await e.getMinimumBalanceForRentExemption(n);let d;if(c){const{registry:t}=await $e(e,c);d=t.owner}return qt(Xi.NAME_PROGRAM_ID,t.SystemProgram.programId,f,i,o,u,new _t(h),new Tt(n),a,c,d)}const ns=async(e,r,n,o,i)=>{let[s]=await t.PublicKey.findProgramAddress([Xi.REGISTER_PROGRAM_ID.toBuffer()],Xi.REGISTER_PROGRAM_ID),a=await Ze(e.toBase58()),c=Qi(a,s,o);return[[],[new Qt({name:r}).getInstruction(Xi.REGISTER_PROGRAM_ID,Xi.NAME_PROGRAM_ID,Xi.ROOT_DOMAIN_ACCOUNT,c,t.SystemProgram.programId,s,n,t.SYSVAR_RENT_PUBKEY,o,i)]]},os={utils:{getNameAccountKeySync:Qi,reverseLookup:async(t,e)=>{const r=An(e.toBase58()),n=Qi(r,Xi.REVERSE_LOOKUP_CLASS),{registry:o}=await he.retrieve(t,n);if(!o.data)throw new kt(exports.ErrorType.NoAccountData);return Ln(o.data)},_deriveSync:Ji,getDomainKeySync:ts,getReverseKeySync:es},constants:Xi,bindings:{createNameRegistry:rs,updateNameRegistryData:async function(t,e,r,n,o,i){const s=await Ze(e),a=Qi(s,o,i);let c;return c=o||(await he.retrieve(t,a)).registry.owner,Yt(Xi.NAME_PROGRAM_ID,a,new Tt(r),n,c)},transferNameOwnership:async function(t,e,r,n,o,i){const s=await Ze(e),a=Qi(s,n,o);let c;return c=n||(await he.retrieve(t,a)).registry.owner,$t(Xi.NAME_PROGRAM_ID,a,r,c,n,o,i)},deleteNameRegistry:async function(t,e,r,n,o){const i=await Ze(e),s=Qi(i,n,o);let a;return a=n||(await he.retrieve(t,s)).registry.owner,Zt(Xi.NAME_PROGRAM_ID,s,r,a)},registerDomainName:async(e,r,n,o,i,s=Xi.USDC_MINT,a)=>{if(r.includes(".")||r.trim().toLowerCase()!==r)throw new kt(exports.ErrorType.InvalidDomain);const[c]=t.PublicKey.findProgramAddressSync([Xi.REGISTER_PROGRAM_ID.toBuffer()],Xi.REGISTER_PROGRAM_ID),u=An(r),f=Qi(u,void 0,Xi.ROOT_DOMAIN_ACCOUNT),h=An(f.toBase58()),d=Qi(h,c),[l]=t.PublicKey.findProgramAddressSync([f.toBuffer()],Xi.REGISTER_PROGRAM_ID),y=Xi.REFERRERS.findIndex((t=>null==a?void 0:a.equals(t)));let g;const w=[];if(-1!==y&&a){g=Bt(s,a,!0);const t=await e.getAccountInfo(g);if(!(null==t?void 0:t.data)){const t=Rt(o,g,a,s);w.push(t)}}const b=Bt(s,Xi.VAULT_OWNER),m=os.constants.PYTH_FEEDS.get(s.toBase58());if(!m)throw new kt(exports.ErrorType.PythFeedNotFound);const v=new Jt({name:r,space:n,referrerIdxOpt:-1!=y?y:null}).getInstruction(Xi.REGISTER_PROGRAM_ID,Xi.NAME_PROGRAM_ID,Xi.ROOT_DOMAIN_ACCOUNT,f,d,t.SystemProgram.programId,c,o,i,Xi.PYTH_MAPPING_ACC,new t.PublicKey(m.product),new t.PublicKey(m.price),b,p,t.SYSVAR_RENT_PUBKEY,l,g);return w.push(v),[[],w]},createReverseName:ns,createSubdomain:async(t,e,r,n=2e3)=>{const o=[],i=e.split(".")[0];if(!i)throw new kt(exports.ErrorType.InvalidSubdomain);const{parent:s,pubkey:a}=ts(e),c=await t.getMinimumBalanceForRentExemption(n+he.HEADER_LEN),u=await rs(t,"\0".concat(i),n,r,r,c,void 0,s);o.push(u);const f=es(e,!0),h=await t.getAccountInfo(f);if(!(null==h?void 0:h.data)){const[,t]=await ns(a,"\0".concat(i),r,s,r);o.push(...t)}return[[],o]},burnDomain:(e,r,n)=>{const{pubkey:o}=ts(e),[i]=t.PublicKey.findProgramAddressSync([o.toBuffer()],Xi.REGISTER_PROGRAM_ID),[s]=t.PublicKey.findProgramAddressSync([o.toBuffer(),Uint8Array.from([1,1])],Xi.REGISTER_PROGRAM_ID);return(new ee).getInstruction(Xi.REGISTER_PROGRAM_ID,Xi.NAME_PROGRAM_ID,t.SystemProgram.programId,o,es(e),s,i,Xi.REVERSE_LOOKUP_CLASS,r,n)},transferSubdomain:async(t,e,r,n,o)=>{const{pubkey:i,isSub:s,parent:a}=ts(e);if(!a||!s)throw new kt(exports.ErrorType.InvalidSubdomain);if(!o){const{registry:e}=await he.retrieve(t,i);o=e.owner}let c,u;n&&(c=a,u=(await he.retrieve(t,a)).registry.owner);return $t(Xi.NAME_PROGRAM_ID,i,r,o,void 0,c,u)}}};exports.BONFIDA_FIDA_BNB=Oe,exports.BONFIDA_USDC_BNB=Ve,exports.CUSTOM_BG_TLD=Ge,exports.ETH_ROA_RECORDS=Ti,exports.FavouriteDomain=qi,exports.GUARDIANS=ki,exports.HASH_PREFIX=_e,exports.METAPLEX_ID=Ye,exports.NAME_OFFERS_ID=Gi,exports.NAME_PROGRAM_ID=Te,exports.NameRegistryState=he,exports.Numberu32=Tt,exports.Numberu64=_t,exports.PYTH_FEEDS=Fe,exports.PYTH_FIDA_PRICE_ACC=Ce,exports.PYTH_MAPPING_ACC=Ke,exports.RECORD_V1_SIZE=Pr,exports.REFERRERS=We,exports.REGISTER_PROGRAM_ID=Le,exports.REVERSE_LOOKUP_CLASS=Ne,exports.ROOT_DOMAIN_ACCOUNT=Ue,exports.ReverseTwitterRegistryState=Wi,exports.SELF_SIGNED=Ui,exports.SNSError=kt,exports.SOL_RECORD_SIG_LEN=96,exports.TOKENS_SYM_MINT=je,exports.TWITTER_ROOT_PARENT_REGISTRY_KEY=Me,exports.TWITTER_VERIFICATION_AUTHORITY=De,exports.USDC_MINT=ze,exports.UTF8_ENCODED=_i,exports.VAULT_OWNER=He,exports.WOLVES_COLLECTION_METADATA=qe,exports.burnDomain=(e,r,n)=>{const{pubkey:o}=Pn(e),[i]=t.PublicKey.findProgramAddressSync([o.toBuffer()],Le),[s]=t.PublicKey.findProgramAddressSync([o.toBuffer(),Uint8Array.from([1,1])],Le);return(new ee).getInstruction(Le,Te,t.SystemProgram.programId,o,Tn(e),s,i,Ne,r,n)},exports.burnInstruction=ee,exports.changeTwitterRegistryData=async function(t,e,r,n){const o=An(t),i=In(o,void 0,Me);return[Yt(Te,i,new Tt(r),n,e)]},exports.changeVerifiedPubkey=async function(t,e,r,n,o){const i=An(e),s=In(i,void 0,Me);let a=[$t(Te,s,n,r,void 0)];return a.push(await Di(t,r.toString(),o,De,Me)),a=a.concat(await ji(t,e,s,n,o)),a},exports.check=Un,exports.checkSolRecord=xi,exports.createInstruction=qt,exports.createInstructionV3=Jt,exports.createNameRegistry=Ni,exports.createRecordInstruction=Vi,exports.createRecordV2Instruction=(e,r,n,o,i)=>{let{pubkey:s,parent:a,isSub:c}=Pn(`${r}.${e}`,exports.RecordVersion.V2);if(c&&(a=Pn(e).pubkey),!a)throw new Error("Invalid parent");const u=((e,r,n,o,i,s,a,c)=>new lr({record:s,content:Array.from(a)}).getInstruction(c,t.SystemProgram.programId,i,e,r,n,o,Er))(i,s,a,o,Te,"".concat(r),Ci(n,r),vr);return u},exports.createReverseInstruction=Qt,exports.createReverseName=Mi,exports.createReverseTwitterRegistry=ji,exports.createSolRecordInstruction=zi,exports.createSubdomain=async(t,e,r,n=2e3)=>{const o=[],i=e.split(".")[0];if(!i)throw new kt(exports.ErrorType.InvalidSubdomain);const{parent:s,pubkey:a}=Pn(e),c=await t.getMinimumBalanceForRentExemption(n+he.HEADER_LEN),u=await Ni(t,"\0".concat(i),n,r,r,c,void 0,s);o.push(u);const f=Tn(e,!0),h=await t.getAccountInfo(f);if(!(null==h?void 0:h.data)){const[,t]=await Mi(a,"\0".concat(i),r,s,r);o.push(...t)}return[[],o]},exports.createV2Instruction=Xt,exports.createVerifiedTwitterRegistry=async function(e,r,n,o,i){const s=An(r),a=In(s,void 0,Me),c=await e.getMinimumBalanceForRentExemption(o+he.HEADER_LEN);let u=[qt(Te,t.SystemProgram.programId,a,n,i,s,new _t(c),new Tt(o),void 0,Me,De)];return u=u.concat(await ji(e,r,a,n,i)),u},exports.createWithNftInstruction=te,exports.deleteInstruction=Zt,exports.deleteNameRegistry=Di,exports.deleteRecordV2=(e,r,n,o)=>{let{pubkey:i,parent:s,isSub:a}=Pn(`${r}.${e}`,exports.RecordVersion.V2);if(a&&(s=Pn(e).pubkey),!s)throw new Error("Invalid parent");const c=((e,r,n,o,i,s)=>(new br).getInstruction(s,t.SystemProgram.programId,i,e,o,r,n,Er))(o,s,n,i,Te,vr);return c},exports.deleteTwitterRegistry=async function(t,e){const r=An(t),n=In(r,void 0,Me),o=An(e.toString()),i=In(o,De,Me);return[Zt(Te,n,e,e),Zt(Te,i,e,e)]},exports.deserializeRecord=Bi,exports.deserializeRecordV2Content=Li,exports.deserializeReverse=Ln,exports.devnet=os,exports.ethValidateRecordV2Content=(e,r,n,o,i,s)=>{let{pubkey:a,parent:c,isSub:u}=Pn(`${r}.${e}`,exports.RecordVersion.V2);if(u&&(c=Pn(e).pubkey),!c)throw new Error("Invalid parent");const f=((e,r,n,o,i,s,a,c,u)=>new yr({validation:s,signature:Array.from(a),expectedPubkey:Array.from(c)}).getInstruction(u,t.SystemProgram.programId,i,e,r,n,o,Er))(o,a,c,n,Te,xr.Ethereum,i,s,vr);return f},exports.findSubdomains=async(t,e)=>{const r=[{memcmp:{offset:0,bytes:e.toBase58()}},{memcmp:{offset:64,bytes:Ne.toBase58()}}],n=await t.getProgramAccounts(Te,{filters:r}),o=[{memcmp:{offset:0,bytes:e.toBase58()}}],i=await t.getProgramAccounts(Te,{filters:o,dataSlice:{offset:0,length:0}}),s=new Map(n.map((t=>[t.pubkey.toBase58(),Ln(t.account.data.slice(96))]))),a=[];return i.forEach((t=>{const r=_n(t.pubkey,e).toBase58(),n=s.get(r);n&&a.push(n.replace("\0",""))})),a},exports.getAllDomains=kn,exports.getAllRegisteredDomains=async t=>{const e=[{memcmp:{offset:0,bytes:Ue.toBase58()}}];return await t.getProgramAccounts(Te,{dataSlice:{offset:32,length:32},filters:e})},exports.getArtistPubkey=t=>{switch(t){case exports.CustomBg.DegenPoet1:return $i;case exports.CustomBg.Rgb0x001:return Zi;default:throw new kt(exports.ErrorType.InvalidCustomBg)}},exports.getArweaveRecord=async(t,e)=>await Ii(t,e,exports.Record.ARWV,!0),exports.getBackgroundRecord=async(t,e)=>await Ii(t,e,exports.Record.Background,!0),exports.getBackpackRecord=async(t,e)=>await Ii(t,e,exports.Record.Backpack,!0),exports.getBscRecord=async(t,e)=>await Ii(t,e,exports.Record.BSC,!0),exports.getBtcRecord=async(t,e)=>await Ii(t,e,exports.Record.BTC,!0),exports.getCustomBgKeys=(t,e)=>{const r=An(e),n=An(t),o=In(n,void 0,Ge);return{domainKey:o,bgKey:In(r,void 0,o)}},exports.getDiscordRecord=async(t,e)=>await Ii(t,e,exports.Record.Discord,!0),exports.getDogeRecord=async(t,e)=>await Ii(t,e,exports.Record.DOGE,!0),exports.getDomainKey=Je,exports.getDomainKeySync=Pn,exports.getDomainKeysWithReverses=async function(t,e){const r=await kn(t,e),n=await Bn(t,r);return r.map(((t,e)=>({pubKey:t,domain:n[e]})))},exports.getDomainMint=oe,exports.getDomainPriceFromName=t=>{switch(xn(t).length){case 1:return 750;case 2:return 700;case 3:return 640;case 4:return 160;default:return 20}},exports.getEmailRecord=async(t,e)=>await Ii(t,e,exports.Record.Email,!0),exports.getEthRecord=async(t,e)=>await Ii(t,e,exports.Record.ETH,!0),exports.getFavoriteDomain=async(e,r)=>{const[n]=qi.getKeySync(Gi,new t.PublicKey(r)),o=await qi.retrieve(e,n),i=await Sn(e,o.nameAccount),s=await Fi(e,i);return{domain:o.nameAccount,reverse:i,stale:!r.equals(s)}},exports.getGithubRecord=async(t,e)=>await Ii(t,e,exports.Record.Github,!0),exports.getHandleAndRegistryKey=async function(e,r){const n=An(r.toString()),o=In(n,De,Me);let i=await Wi.retrieve(e,o);return[i.twitterHandle,new t.PublicKey(i.twitterRegistryKey)]},exports.getHashedName=Ze,exports.getHashedNameSync=An,exports.getInjectiveRecord=async(t,e)=>await Ii(t,e,exports.Record.Injective,!0),exports.getIpfsRecord=async(t,e)=>await Ii(t,e,exports.Record.IPFS,!0),exports.getLtcRecord=async(t,e)=>await Ii(t,e,exports.Record.LTC,!0),exports.getMultipleFavoriteDomains=async(e,r)=>{const n=[],o=r.map((t=>qi.getKeySync(Gi,t)[0])),i=(await e.getMultipleAccountsInfo(o)).map((e=>(null==e?void 0:e.data)?qi.deserialize(null==e?void 0:e.data).nameAccount:t.PublicKey.default)),s=i.map((t=>_n(t))),a=i.map(((t,e)=>Bt(oe(t),r[e],!0))),[c,u,f]=await Promise.all([e.getMultipleAccountsInfo(i),e.getMultipleAccountsInfo(s),e.getMultipleAccountsInfo(a)]);for(let e=0;e<r.length;e++){const o=c[e],i=u[e],s=f[e];if(!o||!i){n.push(void 0);continue}if(new t.PublicKey(null==o?void 0:o.data.slice(32,64)).equals(r[e])){n.push(Ln(null==i?void 0:i.data.slice(96)));continue}if(!s){n.push(void 0);continue}const a=Et.decode(s.data);1!==Number(a.amount)?n.push(void 0):n.push(Ln(null==i?void 0:i.data.slice(96)))}return n},exports.getMultipleRecordsV2=async function(t,e,r,n={}){const o=r.map((t=>Oi(e,t))),i=await Br.retrieveBatch(t,o);return n.deserialize?i.map(((t,e)=>{if(t)return{retrievedRecord:t,record:r[e],deserializedContent:Li(t.getContent(),r[e])}})):i.map(((t,e)=>{if(t)return{retrievedRecord:t,record:r[e]}}))},exports.getNameAccountKey=Xe,exports.getNameAccountKeySync=In,exports.getNameOwner=$e,exports.getPicRecord=async(t,e)=>await Ii(t,e,exports.Record.Pic,!0),exports.getPointRecord=async(t,e)=>await Ii(t,e,exports.Record.POINT,!0),exports.getRecord=Ii,exports.getRecordKeySync=Ai,exports.getRecordV2=async function(t,e,r,n={}){const o=Oi(e,r),i=await Br.retrieve(t,o);return n.deserialize?{retrievedRecord:i,deserializedContent:Li(i.getContent(),r)}:{retrievedRecord:i}},exports.getRecordV2Key=Oi,exports.getRecords=async function(t,e,r,n){const o=r.map((t=>Ai(e,t))),i=await he.retrieveBatch(t,o);return n?i.map(((t,n)=>{if(t)return Bi(t,r[n],Ai(e,r[n]))})):i},exports.getRedditRecord=async(t,e)=>await Ii(t,e,exports.Record.Reddit,!0),exports.getReverseKey=async(t,e)=>{const{pubkey:r,parent:n}=await Je(t),o=await Ze(r.toBase58());return await Xe(o,Ne,e?n:void 0)},exports.getReverseKeyFromDomainKey=_n,exports.getReverseKeySync=Tn,exports.getShdwRecord=async(t,e)=>await Ii(t,e,exports.Record.SHDW,!0),exports.getSolRecord=Si,exports.getTelegramRecord=async(t,e)=>await Ii(t,e,exports.Record.Telegram,!0),exports.getTokenizedDomains=async(t,e)=>{const r=await fe(t,e),n=await Bn(t,r.map((t=>t.nameAccount)));return n.map(((t,e)=>({key:r[e].nameAccount,mint:r[e].nftMint,reverse:t}))).filter((t=>!!t.reverse))},exports.getTwitterHandleandRegistryKeyViaFilters=async function(e,r){const n=[{memcmp:{offset:0,bytes:Me.toBase58()}},{memcmp:{offset:32,bytes:r.toBase58()}},{memcmp:{offset:64,bytes:De.toBase58()}}],o=await e.getProgramAccounts(Te,{filters:n});for(const e of o)if(e.account.data.length>he.HEADER_LEN+32){const r=e.account.data.slice(he.HEADER_LEN),n=new Wi(Gt(Wi.schema,r));return[n.twitterHandle,new t.PublicKey(n.twitterRegistryKey)]}throw new kt(exports.ErrorType.AccountDoesNotExist)},exports.getTwitterRecord=async(t,e)=>await Ii(t,e,exports.Record.Twitter,!0),exports.getTwitterRegistry=async function(t,e){const r=An(e),n=In(r,void 0,Me),{registry:o}=await he.retrieve(t,n);return o},exports.getTwitterRegistryData=async function(e,r){const o=[{memcmp:{offset:0,bytes:Me.toBase58()}},{memcmp:{offset:32,bytes:r.toBase58()}},{memcmp:{offset:64,bytes:new t.PublicKey(n.Buffer.alloc(32,0)).toBase58()}}],i=await e.getProgramAccounts(Te,{filters:o});if(i.length>1)throw new kt(exports.ErrorType.MultipleRegistries);return i[0].account.data.slice(he.HEADER_LEN)},exports.getTwitterRegistryKey=async function(t){const e=An(t);return In(e,void 0,Me)},exports.getUrlRecord=async(t,e)=>await Ii(t,e,exports.Record.Url,!0),exports.performReverseLookup=async function(t,e){const r=await Ze(e.toBase58()),n=await Xe(r,Ne),{registry:o}=await he.retrieve(t,n);if(!o.data)throw new kt(exports.ErrorType.NoAccountData);const i=o.data.slice(0,4).readUInt32LE(0);return o.data.slice(4,4+i).toString()},exports.performReverseLookupBatch=async function(t,e){let r=[];for(let t of e){const e=await Ze(t.toBase58()),n=await Xe(e,Ne);r.push(n)}return(await he.retrieveBatch(t,r)).map((t=>{if(void 0===t||void 0===t.data)return;const e=t.data.slice(0,4).readUInt32LE(0);return t.data.slice(4,4+e).toString()}))},exports.reallocInstruction=function(e,r,o,i,s,a){const c=[n.Buffer.from(Int8Array.from([4])),a.toBuffer()],u=n.Buffer.concat(c),f=[{pubkey:r,isSigner:!1,isWritable:!1},{pubkey:o,isSigner:!0,isWritable:!0},{pubkey:i,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!0,isWritable:!1}];return new t.TransactionInstruction({keys:f,programId:e,data:u})},exports.registerDomainName=async(e,r,n,o,i,s=ze,a)=>{if(r.includes(".")||r.trim().toLowerCase()!==r)throw new kt(exports.ErrorType.InvalidDomain);const[c]=t.PublicKey.findProgramAddressSync([Le.toBuffer()],Le),u=An(r),f=In(u,void 0,Ue),h=An(f.toBase58()),d=In(h,c),[l]=t.PublicKey.findProgramAddressSync([f.toBuffer()],Le),y=We.findIndex((t=>null==a?void 0:a.equals(t)));let g;const w=[];if(-1!==y&&a){g=Bt(s,a,!0);const t=await e.getAccountInfo(g);if(!(null==t?void 0:t.data)){const t=Rt(o,g,a,s);w.push(t)}}const b=Bt(s,He),m=Fe.get(s.toBase58());if(!m)throw new kt(exports.ErrorType.PythFeedNotFound);const v=new Jt({name:r,space:n,referrerIdxOpt:-1!=y?y:null}).getInstruction(Le,Te,Ue,f,d,t.SystemProgram.programId,c,o,i,Ke,new t.PublicKey(m.product),new t.PublicKey(m.price),b,p,t.SYSVAR_RENT_PUBKEY,l,g);return w.push(v),[[],w]},exports.registerWithNft=(e,r,n,o,i,s,a,c,u)=>{const[f]=t.PublicKey.findProgramAddressSync([n.toBuffer()],Le);return new te({space:r,name:e}).getInstruction(Le,Te,Ue,n,o,t.SystemProgram.programId,Ne,i,s,a,c,u,qe,p,t.SYSVAR_RENT_PUBKEY,f,Ye)},exports.resolve=Fi,exports.resolveSolRecordV1=Ki,exports.resolveSolRecordV2=Hi,exports.retrieveNftOwner=ae,exports.retrieveNfts=async e=>{const r=await e.getProgramAccounts(re,{filters:[{memcmp:{offset:0,bytes:"3"}}]});return r.map((e=>new t.PublicKey(e.account.data.slice(66,98))))},exports.retrieveRecords=fe,exports.reverseLookup=Sn,exports.reverseLookupBatch=Bn,exports.serializeRecord=Ri,exports.serializeRecordV2Content=Ci,exports.serializeSolRecord=Pi,exports.transferInstruction=$t,exports.transferNameOwnership=async function(t,e,r,n,o,i){const s=An(e),a=In(s,n,o);let c;return c=n||(await he.retrieve(t,a)).registry.owner,$t(Te,a,r,c,n,o,i)},exports.transferSubdomain=async(t,e,r,n,o)=>{const{pubkey:i,isSub:s,parent:a}=Pn(e);if(!a||!s)throw new kt(exports.ErrorType.InvalidSubdomain);if(!o){const{registry:e}=await he.retrieve(t,i);o=e.owner}let c,u;n&&(c=a,u=(await he.retrieve(t,a)).registry.owner);return $t(Te,i,r,o,void 0,c,u)},exports.updateInstruction=Yt,exports.updateNameRegistryData=async function(t,e,r,n,o,i){const s=An(e),a=In(s,o,i);let c;return c=o||(await he.retrieve(t,a)).registry.owner,Yt(Te,a,new Tt(r),n,c)},exports.updateRecordInstruction=async(t,e,r,n,o,i)=>{Un(r!==exports.Record.SOL,exports.ErrorType.UnsupportedRecord);const{pubkey:s}=Pn(`${r}.${e}`,exports.RecordVersion.V1),a=await t.getAccountInfo(s);Un(!!(null==a?void 0:a.data),exports.ErrorType.AccountDoesNotExist);const c=Ri(n,r);if((null==a?void 0:a.data.slice(96).length)!==c.length)return[Zt(Te,s,i,o),await Vi(t,e,r,n,o,i)];return[Yt(Te,s,new Tt(0),c,o)]},exports.updateRecordV2Instruction=(e,r,n,o,i)=>{let{pubkey:s,parent:a,isSub:c}=Pn(`${r}.${e}`,exports.RecordVersion.V2);if(c&&(a=Pn(e).pubkey),!a)throw new Error("Invalid parent");const u=((e,r,n,o,i,s,a,c)=>new wr({record:s,content:Array.from(a)}).getInstruction(c,t.SystemProgram.programId,i,e,r,n,o,Er))(i,s,a,o,Te,"".concat(r),Ci(n,r),vr);return u},exports.updateSolRecordInstruction=async(t,e,r,n,o,i)=>{const{pubkey:s}=Pn(`${exports.Record.SOL}.${e}`,exports.RecordVersion.V1),a=await t.getAccountInfo(s);if(Un(!!(null==a?void 0:a.data),exports.ErrorType.AccountDoesNotExist),96!==(null==a?void 0:a.data.length))return[Zt(Te,s,i,n),await zi(t,e,r,n,o,i)];const c=Pi(r,s,n,o);return[Yt(Te,s,new Tt(0),c,n)]},exports.validateRecordV2Content=(e,r,n,o,i,s)=>{let{pubkey:a,parent:c,isSub:u}=Pn(`${n}.${r}`,exports.RecordVersion.V2);if(u&&(c=Pn(r).pubkey),!c)throw new Error("Invalid parent");const f=((e,r,n,o,i,s,a,c)=>new gr({staleness:a}).getInstruction(c,t.SystemProgram.programId,s,e,r,n,o,Er,i))(i,a,c,o,s,Te,e,vr);return f},exports.verifyRightOfAssociation=async(t,e,r,n)=>{var o;const i=Oi(r,e),s=await Br.retrieve(t,i),a=s.getRoAId(),c=Ti.has(e)?xr.Ethereum:xr.Solana;if(!(n=null!=n?n:null===(o=ki.get(e))||void 0===o?void 0:o.toBuffer()))throw new kt(exports.ErrorType.MissingVerifier);return 0===n.compare(a)&&s.header.rightOfAssociationValidation===c},exports.verifyStaleness=async(e,r,n)=>{const o=Oi(n,r),i=await Fi(e,n),s=await Br.retrieve(e,o),a=s.getStalenessId();return i.equals(new t.PublicKey(a))&&s.header.stalenessValidation===xr.Solana},exports.writRoaRecordV2=(e,r,n,o,i)=>{let{pubkey:s,parent:a,isSub:c}=Pn(`${r}.${e}`,exports.RecordVersion.V2);if(c&&(a=Pn(e).pubkey),!a)throw new Error("Invalid parent");const u=((e,r,n,o,i,s,a)=>new mr({roaId:Array.from(s.toBuffer())}).getInstruction(a,t.SystemProgram.programId,r,e,n,o,i,Er))(o,Te,s,a,n,i,vr);return u};
|
|
20
20
|
//# sourceMappingURL=index.cjs.map
|