libnemo
Version:
Nano cryptocurrency wallet library.
45 lines • 323 kB
JavaScript
var zc=Object.create;var Qn=Object.defineProperty;var Hc=Object.getOwnPropertyDescriptor;var Yc=Object.getOwnPropertyNames;var qc=Object.getPrototypeOf,Kc=Object.prototype.hasOwnProperty;var g=(r,e)=>()=>(r&&(e=r(r=0)),e);var E=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),Wc=(r,e)=>{for(var t in e)Qn(r,t,{get:e[t],enumerable:!0})},jc=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Yc(e))!Kc.call(r,i)&&i!==t&&Qn(r,i,{get:()=>e[i],enumerable:!(n=Hc(e,i))||n.enumerable});return r};var _n=(r,e,t)=>(t=r!=null?zc(qc(r)):{},jc(e||!r||!r.__esModule?Qn(t,"default",{value:r,enumerable:!0}):t,r));var Fo=E(Ur=>{"use strict";a();Ur.byteLength=Jc;Ur.toByteArray=ef;Ur.fromByteArray=nf;var Te=[],pe=[],Xc=typeof Uint8Array<"u"?Uint8Array:Array,Mn="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(ft=0,Ro=Mn.length;ft<Ro;++ft)Te[ft]=Mn[ft],pe[Mn.charCodeAt(ft)]=ft;var ft,Ro;pe[45]=62;pe[95]=63;function No(r){var e=r.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var t=r.indexOf("=");t===-1&&(t=e);var n=t===e?0:4-t%4;return[t,n]}function Jc(r){var e=No(r),t=e[0],n=e[1];return(t+n)*3/4-n}function Zc(r,e,t){return(e+t)*3/4-t}function ef(r){var e,t=No(r),n=t[0],i=t[1],o=new Xc(Zc(r,n,i)),v=0,s=i>0?n-4:n,u;for(u=0;u<s;u+=4)e=pe[r.charCodeAt(u)]<<18|pe[r.charCodeAt(u+1)]<<12|pe[r.charCodeAt(u+2)]<<6|pe[r.charCodeAt(u+3)],o[v++]=e>>16&255,o[v++]=e>>8&255,o[v++]=e&255;return i===2&&(e=pe[r.charCodeAt(u)]<<2|pe[r.charCodeAt(u+1)]>>4,o[v++]=e&255),i===1&&(e=pe[r.charCodeAt(u)]<<10|pe[r.charCodeAt(u+1)]<<4|pe[r.charCodeAt(u+2)]>>2,o[v++]=e>>8&255,o[v++]=e&255),o}function tf(r){return Te[r>>18&63]+Te[r>>12&63]+Te[r>>6&63]+Te[r&63]}function rf(r,e,t){for(var n,i=[],o=e;o<t;o+=3)n=(r[o]<<16&16711680)+(r[o+1]<<8&65280)+(r[o+2]&255),i.push(tf(n));return i.join("")}function nf(r){for(var e,t=r.length,n=t%3,i=[],o=16383,v=0,s=t-n;v<s;v+=o)i.push(rf(r,v,v+o>s?s:v+o));return n===1?(e=r[t-1],i.push(Te[e>>2]+Te[e<<4&63]+"==")):n===2&&(e=(r[t-2]<<8)+r[t-1],i.push(Te[e>>10]+Te[e>>4&63]+Te[e<<2&63]+"=")),i.join("")}});var ko=E(Gn=>{a();/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */Gn.read=function(r,e,t,n,i){var o,v,s=i*8-n-1,u=(1<<s)-1,c=u>>1,f=-7,p=t?i-1:0,m=t?-1:1,d=r[e+p];for(p+=m,o=d&(1<<-f)-1,d>>=-f,f+=s;f>0;o=o*256+r[e+p],p+=m,f-=8);for(v=o&(1<<-f)-1,o>>=-f,f+=n;f>0;v=v*256+r[e+p],p+=m,f-=8);if(o===0)o=1-c;else{if(o===u)return v?NaN:(d?-1:1)*(1/0);v=v+Math.pow(2,n),o=o-c}return(d?-1:1)*v*Math.pow(2,o-n)};Gn.write=function(r,e,t,n,i,o){var v,s,u,c=o*8-i-1,f=(1<<c)-1,p=f>>1,m=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,I=n?1:-1,B=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,v=f):(v=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-v))<1&&(v--,u*=2),v+p>=1?e+=m/u:e+=m*Math.pow(2,1-p),e*u>=2&&(v++,u/=2),v+p>=f?(s=0,v=f):v+p>=1?(s=(e*u-1)*Math.pow(2,i),v=v+p):(s=e*Math.pow(2,p-1)*Math.pow(2,i),v=0));i>=8;r[t+d]=s&255,d+=I,s/=256,i-=8);for(v=v<<i|s,c+=i;c>0;r[t+d]=v&255,d+=I,v/=256,c-=8);r[t+d-I]|=B*128}});var Jo=E(Lt=>{"use strict";a();/*!
* The buffer module from node.js, for the browser.
*
* @author Feross Aboukhadijeh <https://feross.org>
* @license MIT
*/var $n=Fo(),Ft=ko(),Lo=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;Lt.Buffer=h;Lt.SlowBuffer=cf;Lt.INSPECT_MAX_BYTES=50;var Tr=2147483647;Lt.kMaxLength=Tr;h.TYPED_ARRAY_SUPPORT=of();!h.TYPED_ARRAY_SUPPORT&&typeof console<"u";function of(){try{let r=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(r,e),r.foo()===42}catch{return!1}}Object.defineProperty(h.prototype,"parent",{enumerable:!0,get:function(){if(h.isBuffer(this))return this.buffer}});Object.defineProperty(h.prototype,"offset",{enumerable:!0,get:function(){if(h.isBuffer(this))return this.byteOffset}});function Me(r){if(r>Tr)throw new RangeError('The value "'+r+'" is invalid for option "size"');let e=new Uint8Array(r);return Object.setPrototypeOf(e,h.prototype),e}function h(r,e,t){if(typeof r=="number"){if(typeof e=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return Yn(r)}return Mo(r,e,t)}h.poolSize=8192;function Mo(r,e,t){if(typeof r=="string")return sf(r,e);if(ArrayBuffer.isView(r))return uf(r);if(r==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r);if(Pe(r,ArrayBuffer)||r&&Pe(r.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(Pe(r,SharedArrayBuffer)||r&&Pe(r.buffer,SharedArrayBuffer)))return zn(r,e,t);if(typeof r=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let n=r.valueOf&&r.valueOf();if(n!=null&&n!==r)return h.from(n,e,t);let i=af(r);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof r[Symbol.toPrimitive]=="function")return h.from(r[Symbol.toPrimitive]("string"),e,t);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r)}h.from=function(r,e,t){return Mo(r,e,t)};Object.setPrototypeOf(h.prototype,Uint8Array.prototype);Object.setPrototypeOf(h,Uint8Array);function Go(r){if(typeof r!="number")throw new TypeError('"size" argument must be of type number');if(r<0)throw new RangeError('The value "'+r+'" is invalid for option "size"')}function vf(r,e,t){return Go(r),r<=0?Me(r):e!==void 0?typeof t=="string"?Me(r).fill(e,t):Me(r).fill(e):Me(r)}h.alloc=function(r,e,t){return vf(r,e,t)};function Yn(r){return Go(r),Me(r<0?0:qn(r)|0)}h.allocUnsafe=function(r){return Yn(r)};h.allocUnsafeSlow=function(r){return Yn(r)};function sf(r,e){if((typeof e!="string"||e==="")&&(e="utf8"),!h.isEncoding(e))throw new TypeError("Unknown encoding: "+e);let t=$o(r,e)|0,n=Me(t),i=n.write(r,e);return i!==t&&(n=n.slice(0,i)),n}function Vn(r){let e=r.length<0?0:qn(r.length)|0,t=Me(e);for(let n=0;n<e;n+=1)t[n]=r[n]&255;return t}function uf(r){if(Pe(r,Uint8Array)){let e=new Uint8Array(r);return zn(e.buffer,e.byteOffset,e.byteLength)}return Vn(r)}function zn(r,e,t){if(e<0||r.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(r.byteLength<e+(t||0))throw new RangeError('"length" is outside of buffer bounds');let n;return e===void 0&&t===void 0?n=new Uint8Array(r):t===void 0?n=new Uint8Array(r,e):n=new Uint8Array(r,e,t),Object.setPrototypeOf(n,h.prototype),n}function af(r){if(h.isBuffer(r)){let e=qn(r.length)|0,t=Me(e);return t.length===0||r.copy(t,0,0,e),t}if(r.length!==void 0)return typeof r.length!="number"||Wn(r.length)?Me(0):Vn(r);if(r.type==="Buffer"&&Array.isArray(r.data))return Vn(r.data)}function qn(r){if(r>=Tr)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Tr.toString(16)+" bytes");return r|0}function cf(r){return+r!=r&&(r=0),h.alloc(+r)}h.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==h.prototype};h.compare=function(e,t){if(Pe(e,Uint8Array)&&(e=h.from(e,e.offset,e.byteLength)),Pe(t,Uint8Array)&&(t=h.from(t,t.offset,t.byteLength)),!h.isBuffer(e)||!h.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;let n=e.length,i=t.length;for(let o=0,v=Math.min(n,i);o<v;++o)if(e[o]!==t[o]){n=e[o],i=t[o];break}return n<i?-1:i<n?1:0};h.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};h.concat=function(e,t){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return h.alloc(0);let n;if(t===void 0)for(t=0,n=0;n<e.length;++n)t+=e[n].length;let i=h.allocUnsafe(t),o=0;for(n=0;n<e.length;++n){let v=e[n];if(Pe(v,Uint8Array))o+v.length>i.length?(h.isBuffer(v)||(v=h.from(v)),v.copy(i,o)):Uint8Array.prototype.set.call(i,v,o);else if(h.isBuffer(v))v.copy(i,o);else throw new TypeError('"list" argument must be an Array of Buffers');o+=v.length}return i};function $o(r,e){if(h.isBuffer(r))return r.length;if(ArrayBuffer.isView(r)||Pe(r,ArrayBuffer))return r.byteLength;if(typeof r!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof r);let t=r.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&t===0)return 0;let i=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return t;case"utf8":case"utf-8":return Hn(r).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return t*2;case"hex":return t>>>1;case"base64":return Xo(r).length;default:if(i)return n?-1:Hn(r).length;e=(""+e).toLowerCase(),i=!0}}h.byteLength=$o;function ff(r,e,t){let n=!1;if((e===void 0||e<0)&&(e=0),e>this.length||((t===void 0||t>this.length)&&(t=this.length),t<=0)||(t>>>=0,e>>>=0,t<=e))return"";for(r||(r="utf8");;)switch(r){case"hex":return wf(this,e,t);case"utf8":case"utf-8":return zo(this,e,t);case"ascii":return mf(this,e,t);case"latin1":case"binary":return Af(this,e,t);case"base64":return df(this,e,t);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ef(this,e,t);default:if(n)throw new TypeError("Unknown encoding: "+r);r=(r+"").toLowerCase(),n=!0}}h.prototype._isBuffer=!0;function lt(r,e,t){let n=r[e];r[e]=r[t],r[t]=n}h.prototype.swap16=function(){let e=this.length;if(e%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let t=0;t<e;t+=2)lt(this,t,t+1);return this};h.prototype.swap32=function(){let e=this.length;if(e%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let t=0;t<e;t+=4)lt(this,t,t+3),lt(this,t+1,t+2);return this};h.prototype.swap64=function(){let e=this.length;if(e%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let t=0;t<e;t+=8)lt(this,t,t+7),lt(this,t+1,t+6),lt(this,t+2,t+5),lt(this,t+3,t+4);return this};h.prototype.toString=function(){let e=this.length;return e===0?"":arguments.length===0?zo(this,0,e):ff.apply(this,arguments)};h.prototype.toLocaleString=h.prototype.toString;h.prototype.equals=function(e){if(!h.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:h.compare(this,e)===0};h.prototype.inspect=function(){let e="",t=Lt.INSPECT_MAX_BYTES;return e=this.toString("hex",0,t).replace(/(.{2})/g,"$1 ").trim(),this.length>t&&(e+=" ... "),"<Buffer "+e+">"};Lo&&(h.prototype[Lo]=h.prototype.inspect);h.prototype.compare=function(e,t,n,i,o){if(Pe(e,Uint8Array)&&(e=h.from(e,e.offset,e.byteLength)),!h.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(t===void 0&&(t=0),n===void 0&&(n=e?e.length:0),i===void 0&&(i=0),o===void 0&&(o=this.length),t<0||n>e.length||i<0||o>this.length)throw new RangeError("out of range index");if(i>=o&&t>=n)return 0;if(i>=o)return-1;if(t>=n)return 1;if(t>>>=0,n>>>=0,i>>>=0,o>>>=0,this===e)return 0;let v=o-i,s=n-t,u=Math.min(v,s),c=this.slice(i,o),f=e.slice(t,n);for(let p=0;p<u;++p)if(c[p]!==f[p]){v=c[p],s=f[p];break}return v<s?-1:s<v?1:0};function Vo(r,e,t,n,i){if(r.length===0)return-1;if(typeof t=="string"?(n=t,t=0):t>2147483647?t=2147483647:t<-2147483648&&(t=-2147483648),t=+t,Wn(t)&&(t=i?0:r.length-1),t<0&&(t=r.length+t),t>=r.length){if(i)return-1;t=r.length-1}else if(t<0)if(i)t=0;else return-1;if(typeof e=="string"&&(e=h.from(e,n)),h.isBuffer(e))return e.length===0?-1:Oo(r,e,t,n,i);if(typeof e=="number")return e=e&255,typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(r,e,t):Uint8Array.prototype.lastIndexOf.call(r,e,t):Oo(r,[e],t,n,i);throw new TypeError("val must be string, number or Buffer")}function Oo(r,e,t,n,i){let o=1,v=r.length,s=e.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(r.length<2||e.length<2)return-1;o=2,v/=2,s/=2,t/=2}function u(f,p){return o===1?f[p]:f.readUInt16BE(p*o)}let c;if(i){let f=-1;for(c=t;c<v;c++)if(u(r,c)===u(e,f===-1?0:c-f)){if(f===-1&&(f=c),c-f+1===s)return f*o}else f!==-1&&(c-=c-f),f=-1}else for(t+s>v&&(t=v-s),c=t;c>=0;c--){let f=!0;for(let p=0;p<s;p++)if(u(r,c+p)!==u(e,p)){f=!1;break}if(f)return c}return-1}h.prototype.includes=function(e,t,n){return this.indexOf(e,t,n)!==-1};h.prototype.indexOf=function(e,t,n){return Vo(this,e,t,n,!0)};h.prototype.lastIndexOf=function(e,t,n){return Vo(this,e,t,n,!1)};function lf(r,e,t,n){t=Number(t)||0;let i=r.length-t;n?(n=Number(n),n>i&&(n=i)):n=i;let o=e.length;n>o/2&&(n=o/2);let v;for(v=0;v<n;++v){let s=parseInt(e.substr(v*2,2),16);if(Wn(s))return v;r[t+v]=s}return v}function yf(r,e,t,n){return Pr(Hn(e,r.length-t),r,t,n)}function pf(r,e,t,n){return Pr(Sf(e),r,t,n)}function xf(r,e,t,n){return Pr(Xo(e),r,t,n)}function hf(r,e,t,n){return Pr(Df(e,r.length-t),r,t,n)}h.prototype.write=function(e,t,n,i){if(t===void 0)i="utf8",n=this.length,t=0;else if(n===void 0&&typeof t=="string")i=t,n=this.length,t=0;else if(isFinite(t))t=t>>>0,isFinite(n)?(n=n>>>0,i===void 0&&(i="utf8")):(i=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let o=this.length-t;if((n===void 0||n>o)&&(n=o),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");let v=!1;for(;;)switch(i){case"hex":return lf(this,e,t,n);case"utf8":case"utf-8":return yf(this,e,t,n);case"ascii":case"latin1":case"binary":return pf(this,e,t,n);case"base64":return xf(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return hf(this,e,t,n);default:if(v)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),v=!0}};h.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function df(r,e,t){return e===0&&t===r.length?$n.fromByteArray(r):$n.fromByteArray(r.slice(e,t))}function zo(r,e,t){t=Math.min(r.length,t);let n=[],i=e;for(;i<t;){let o=r[i],v=null,s=o>239?4:o>223?3:o>191?2:1;if(i+s<=t){let u,c,f,p;switch(s){case 1:o<128&&(v=o);break;case 2:u=r[i+1],(u&192)===128&&(p=(o&31)<<6|u&63,p>127&&(v=p));break;case 3:u=r[i+1],c=r[i+2],(u&192)===128&&(c&192)===128&&(p=(o&15)<<12|(u&63)<<6|c&63,p>2047&&(p<55296||p>57343)&&(v=p));break;case 4:u=r[i+1],c=r[i+2],f=r[i+3],(u&192)===128&&(c&192)===128&&(f&192)===128&&(p=(o&15)<<18|(u&63)<<12|(c&63)<<6|f&63,p>65535&&p<1114112&&(v=p))}}v===null?(v=65533,s=1):v>65535&&(v-=65536,n.push(v>>>10&1023|55296),v=56320|v&1023),n.push(v),i+=s}return gf(n)}var Qo=4096;function gf(r){let e=r.length;if(e<=Qo)return String.fromCharCode.apply(String,r);let t="",n=0;for(;n<e;)t+=String.fromCharCode.apply(String,r.slice(n,n+=Qo));return t}function mf(r,e,t){let n="";t=Math.min(r.length,t);for(let i=e;i<t;++i)n+=String.fromCharCode(r[i]&127);return n}function Af(r,e,t){let n="";t=Math.min(r.length,t);for(let i=e;i<t;++i)n+=String.fromCharCode(r[i]);return n}function wf(r,e,t){let n=r.length;(!e||e<0)&&(e=0),(!t||t<0||t>n)&&(t=n);let i="";for(let o=e;o<t;++o)i+=Cf[r[o]];return i}function Ef(r,e,t){let n=r.slice(e,t),i="";for(let o=0;o<n.length-1;o+=2)i+=String.fromCharCode(n[o]+n[o+1]*256);return i}h.prototype.slice=function(e,t){let n=this.length;e=~~e,t=t===void 0?n:~~t,e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),t<e&&(t=e);let i=this.subarray(e,t);return Object.setPrototypeOf(i,h.prototype),i};function q(r,e,t){if(r%1!==0||r<0)throw new RangeError("offset is not uint");if(r+e>t)throw new RangeError("Trying to access beyond buffer length")}h.prototype.readUintLE=h.prototype.readUIntLE=function(e,t,n){e=e>>>0,t=t>>>0,n||q(e,t,this.length);let i=this[e],o=1,v=0;for(;++v<t&&(o*=256);)i+=this[e+v]*o;return i};h.prototype.readUintBE=h.prototype.readUIntBE=function(e,t,n){e=e>>>0,t=t>>>0,n||q(e,t,this.length);let i=this[e+--t],o=1;for(;t>0&&(o*=256);)i+=this[e+--t]*o;return i};h.prototype.readUint8=h.prototype.readUInt8=function(e,t){return e=e>>>0,t||q(e,1,this.length),this[e]};h.prototype.readUint16LE=h.prototype.readUInt16LE=function(e,t){return e=e>>>0,t||q(e,2,this.length),this[e]|this[e+1]<<8};h.prototype.readUint16BE=h.prototype.readUInt16BE=function(e,t){return e=e>>>0,t||q(e,2,this.length),this[e]<<8|this[e+1]};h.prototype.readUint32LE=h.prototype.readUInt32LE=function(e,t){return e=e>>>0,t||q(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};h.prototype.readUint32BE=h.prototype.readUInt32BE=function(e,t){return e=e>>>0,t||q(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};h.prototype.readBigUInt64LE=et(function(e){e=e>>>0,kt(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&rr(e,this.length-8);let i=t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24,o=this[++e]+this[++e]*2**8+this[++e]*2**16+n*2**24;return BigInt(i)+(BigInt(o)<<BigInt(32))});h.prototype.readBigUInt64BE=et(function(e){e=e>>>0,kt(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&rr(e,this.length-8);let i=t*2**24+this[++e]*2**16+this[++e]*2**8+this[++e],o=this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n;return(BigInt(i)<<BigInt(32))+BigInt(o)});h.prototype.readIntLE=function(e,t,n){e=e>>>0,t=t>>>0,n||q(e,t,this.length);let i=this[e],o=1,v=0;for(;++v<t&&(o*=256);)i+=this[e+v]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*t)),i};h.prototype.readIntBE=function(e,t,n){e=e>>>0,t=t>>>0,n||q(e,t,this.length);let i=t,o=1,v=this[e+--i];for(;i>0&&(o*=256);)v+=this[e+--i]*o;return o*=128,v>=o&&(v-=Math.pow(2,8*t)),v};h.prototype.readInt8=function(e,t){return e=e>>>0,t||q(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};h.prototype.readInt16LE=function(e,t){e=e>>>0,t||q(e,2,this.length);let n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n};h.prototype.readInt16BE=function(e,t){e=e>>>0,t||q(e,2,this.length);let n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n};h.prototype.readInt32LE=function(e,t){return e=e>>>0,t||q(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};h.prototype.readInt32BE=function(e,t){return e=e>>>0,t||q(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};h.prototype.readBigInt64LE=et(function(e){e=e>>>0,kt(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&rr(e,this.length-8);let i=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(n<<24);return(BigInt(i)<<BigInt(32))+BigInt(t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24)});h.prototype.readBigInt64BE=et(function(e){e=e>>>0,kt(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&rr(e,this.length-8);let i=(t<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return(BigInt(i)<<BigInt(32))+BigInt(this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n)});h.prototype.readFloatLE=function(e,t){return e=e>>>0,t||q(e,4,this.length),Ft.read(this,e,!0,23,4)};h.prototype.readFloatBE=function(e,t){return e=e>>>0,t||q(e,4,this.length),Ft.read(this,e,!1,23,4)};h.prototype.readDoubleLE=function(e,t){return e=e>>>0,t||q(e,8,this.length),Ft.read(this,e,!0,52,8)};h.prototype.readDoubleBE=function(e,t){return e=e>>>0,t||q(e,8,this.length),Ft.read(this,e,!1,52,8)};function ne(r,e,t,n,i,o){if(!h.isBuffer(r))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(t+n>r.length)throw new RangeError("Index out of range")}h.prototype.writeUintLE=h.prototype.writeUIntLE=function(e,t,n,i){if(e=+e,t=t>>>0,n=n>>>0,!i){let s=Math.pow(2,8*n)-1;ne(this,e,t,n,s,0)}let o=1,v=0;for(this[t]=e&255;++v<n&&(o*=256);)this[t+v]=e/o&255;return t+n};h.prototype.writeUintBE=h.prototype.writeUIntBE=function(e,t,n,i){if(e=+e,t=t>>>0,n=n>>>0,!i){let s=Math.pow(2,8*n)-1;ne(this,e,t,n,s,0)}let o=n-1,v=1;for(this[t+o]=e&255;--o>=0&&(v*=256);)this[t+o]=e/v&255;return t+n};h.prototype.writeUint8=h.prototype.writeUInt8=function(e,t,n){return e=+e,t=t>>>0,n||ne(this,e,t,1,255,0),this[t]=e&255,t+1};h.prototype.writeUint16LE=h.prototype.writeUInt16LE=function(e,t,n){return e=+e,t=t>>>0,n||ne(this,e,t,2,65535,0),this[t]=e&255,this[t+1]=e>>>8,t+2};h.prototype.writeUint16BE=h.prototype.writeUInt16BE=function(e,t,n){return e=+e,t=t>>>0,n||ne(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=e&255,t+2};h.prototype.writeUint32LE=h.prototype.writeUInt32LE=function(e,t,n){return e=+e,t=t>>>0,n||ne(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=e&255,t+4};h.prototype.writeUint32BE=h.prototype.writeUInt32BE=function(e,t,n){return e=+e,t=t>>>0,n||ne(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4};function Ho(r,e,t,n,i){jo(e,n,i,r,t,7);let o=Number(e&BigInt(4294967295));r[t++]=o,o=o>>8,r[t++]=o,o=o>>8,r[t++]=o,o=o>>8,r[t++]=o;let v=Number(e>>BigInt(32)&BigInt(4294967295));return r[t++]=v,v=v>>8,r[t++]=v,v=v>>8,r[t++]=v,v=v>>8,r[t++]=v,t}function Yo(r,e,t,n,i){jo(e,n,i,r,t,7);let o=Number(e&BigInt(4294967295));r[t+7]=o,o=o>>8,r[t+6]=o,o=o>>8,r[t+5]=o,o=o>>8,r[t+4]=o;let v=Number(e>>BigInt(32)&BigInt(4294967295));return r[t+3]=v,v=v>>8,r[t+2]=v,v=v>>8,r[t+1]=v,v=v>>8,r[t]=v,t+8}h.prototype.writeBigUInt64LE=et(function(e,t=0){return Ho(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))});h.prototype.writeBigUInt64BE=et(function(e,t=0){return Yo(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))});h.prototype.writeIntLE=function(e,t,n,i){if(e=+e,t=t>>>0,!i){let u=Math.pow(2,8*n-1);ne(this,e,t,n,u-1,-u)}let o=0,v=1,s=0;for(this[t]=e&255;++o<n&&(v*=256);)e<0&&s===0&&this[t+o-1]!==0&&(s=1),this[t+o]=(e/v>>0)-s&255;return t+n};h.prototype.writeIntBE=function(e,t,n,i){if(e=+e,t=t>>>0,!i){let u=Math.pow(2,8*n-1);ne(this,e,t,n,u-1,-u)}let o=n-1,v=1,s=0;for(this[t+o]=e&255;--o>=0&&(v*=256);)e<0&&s===0&&this[t+o+1]!==0&&(s=1),this[t+o]=(e/v>>0)-s&255;return t+n};h.prototype.writeInt8=function(e,t,n){return e=+e,t=t>>>0,n||ne(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=e&255,t+1};h.prototype.writeInt16LE=function(e,t,n){return e=+e,t=t>>>0,n||ne(this,e,t,2,32767,-32768),this[t]=e&255,this[t+1]=e>>>8,t+2};h.prototype.writeInt16BE=function(e,t,n){return e=+e,t=t>>>0,n||ne(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=e&255,t+2};h.prototype.writeInt32LE=function(e,t,n){return e=+e,t=t>>>0,n||ne(this,e,t,4,2147483647,-2147483648),this[t]=e&255,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4};h.prototype.writeInt32BE=function(e,t,n){return e=+e,t=t>>>0,n||ne(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4};h.prototype.writeBigInt64LE=et(function(e,t=0){return Ho(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});h.prototype.writeBigInt64BE=et(function(e,t=0){return Yo(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function qo(r,e,t,n,i,o){if(t+n>r.length)throw new RangeError("Index out of range");if(t<0)throw new RangeError("Index out of range")}function Ko(r,e,t,n,i){return e=+e,t=t>>>0,i||qo(r,e,t,4,34028234663852886e22,-34028234663852886e22),Ft.write(r,e,t,n,23,4),t+4}h.prototype.writeFloatLE=function(e,t,n){return Ko(this,e,t,!0,n)};h.prototype.writeFloatBE=function(e,t,n){return Ko(this,e,t,!1,n)};function Wo(r,e,t,n,i){return e=+e,t=t>>>0,i||qo(r,e,t,8,17976931348623157e292,-17976931348623157e292),Ft.write(r,e,t,n,52,8),t+8}h.prototype.writeDoubleLE=function(e,t,n){return Wo(this,e,t,!0,n)};h.prototype.writeDoubleBE=function(e,t,n){return Wo(this,e,t,!1,n)};h.prototype.copy=function(e,t,n,i){if(!h.isBuffer(e))throw new TypeError("argument should be a Buffer");if(n||(n=0),!i&&i!==0&&(i=this.length),t>=e.length&&(t=e.length),t||(t=0),i>0&&i<n&&(i=n),i===n||e.length===0||this.length===0)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),e.length-t<i-n&&(i=e.length-t+n);let o=i-n;return this===e&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(t,n,i):Uint8Array.prototype.set.call(e,this.subarray(n,i),t),o};h.prototype.fill=function(e,t,n,i){if(typeof e=="string"){if(typeof t=="string"?(i=t,t=0,n=this.length):typeof n=="string"&&(i=n,n=this.length),i!==void 0&&typeof i!="string")throw new TypeError("encoding must be a string");if(typeof i=="string"&&!h.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(e.length===1){let v=e.charCodeAt(0);(i==="utf8"&&v<128||i==="latin1")&&(e=v)}}else typeof e=="number"?e=e&255:typeof e=="boolean"&&(e=Number(e));if(t<0||this.length<t||this.length<n)throw new RangeError("Out of range index");if(n<=t)return this;t=t>>>0,n=n===void 0?this.length:n>>>0,e||(e=0);let o;if(typeof e=="number")for(o=t;o<n;++o)this[o]=e;else{let v=h.isBuffer(e)?e:h.from(e,i),s=v.length;if(s===0)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(o=0;o<n-t;++o)this[o+t]=v[o%s]}return this};var Nt={};function Kn(r,e,t){Nt[r]=class extends t{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${r}]`,this.stack,delete this.name}get code(){return r}set code(i){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:i,writable:!0})}toString(){return`${this.name} [${r}]: ${this.message}`}}}Kn("ERR_BUFFER_OUT_OF_BOUNDS",function(r){return r?`${r} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);Kn("ERR_INVALID_ARG_TYPE",function(r,e){return`The "${r}" argument must be of type number. Received type ${typeof e}`},TypeError);Kn("ERR_OUT_OF_RANGE",function(r,e,t){let n=`The value of "${r}" is out of range.`,i=t;return Number.isInteger(t)&&Math.abs(t)>2**32?i=_o(String(t)):typeof t=="bigint"&&(i=String(t),(t>BigInt(2)**BigInt(32)||t<-(BigInt(2)**BigInt(32)))&&(i=_o(i)),i+="n"),n+=` It must be ${e}. Received ${i}`,n},RangeError);function _o(r){let e="",t=r.length,n=r[0]==="-"?1:0;for(;t>=n+4;t-=3)e=`_${r.slice(t-3,t)}${e}`;return`${r.slice(0,t)}${e}`}function If(r,e,t){kt(e,"offset"),(r[e]===void 0||r[e+t]===void 0)&&rr(e,r.length-(t+1))}function jo(r,e,t,n,i,o){if(r>t||r<e){let v=typeof e=="bigint"?"n":"",s;throw o>3?e===0||e===BigInt(0)?s=`>= 0${v} and < 2${v} ** ${(o+1)*8}${v}`:s=`>= -(2${v} ** ${(o+1)*8-1}${v}) and < 2 ** ${(o+1)*8-1}${v}`:s=`>= ${e}${v} and <= ${t}${v}`,new Nt.ERR_OUT_OF_RANGE("value",s,r)}If(n,i,o)}function kt(r,e){if(typeof r!="number")throw new Nt.ERR_INVALID_ARG_TYPE(e,"number",r)}function rr(r,e,t){throw Math.floor(r)!==r?(kt(r,t),new Nt.ERR_OUT_OF_RANGE(t||"offset","an integer",r)):e<0?new Nt.ERR_BUFFER_OUT_OF_BOUNDS:new Nt.ERR_OUT_OF_RANGE(t||"offset",`>= ${t?1:0} and <= ${e}`,r)}var bf=/[^+/0-9A-Za-z-_]/g;function Bf(r){if(r=r.split("=")[0],r=r.trim().replace(bf,""),r.length<2)return"";for(;r.length%4!==0;)r=r+"=";return r}function Hn(r,e){e=e||1/0;let t,n=r.length,i=null,o=[];for(let v=0;v<n;++v){if(t=r.charCodeAt(v),t>55295&&t<57344){if(!i){if(t>56319){(e-=3)>-1&&o.push(239,191,189);continue}else if(v+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=t;continue}if(t<56320){(e-=3)>-1&&o.push(239,191,189),i=t;continue}t=(i-55296<<10|t-56320)+65536}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,t<128){if((e-=1)<0)break;o.push(t)}else if(t<2048){if((e-=2)<0)break;o.push(t>>6|192,t&63|128)}else if(t<65536){if((e-=3)<0)break;o.push(t>>12|224,t>>6&63|128,t&63|128)}else if(t<1114112){if((e-=4)<0)break;o.push(t>>18|240,t>>12&63|128,t>>6&63|128,t&63|128)}else throw new Error("Invalid code point")}return o}function Sf(r){let e=[];for(let t=0;t<r.length;++t)e.push(r.charCodeAt(t)&255);return e}function Df(r,e){let t,n,i,o=[];for(let v=0;v<r.length&&!((e-=2)<0);++v)t=r.charCodeAt(v),n=t>>8,i=t%256,o.push(i),o.push(n);return o}function Xo(r){return $n.toByteArray(Bf(r))}function Pr(r,e,t,n){let i;for(i=0;i<n&&!(i+t>=e.length||i>=r.length);++i)e[i+t]=r[i];return i}function Pe(r,e){return r instanceof e||r!=null&&r.constructor!=null&&r.constructor.name!=null&&r.constructor.name===e.name}function Wn(r){return r!==r}var Cf=(function(){let r="0123456789abcdef",e=new Array(256);for(let t=0;t<16;++t){let n=t*16;for(let i=0;i<16;++i)e[n+i]=r[t]+r[i]}return e})();function et(r){return typeof BigInt>"u"?Uf:r}function Uf(){throw new Error("BigInt not supported")}});var Zo,y,a=g(()=>{"use strict";Zo=_n(Jo(),1);//! SPDX-FileCopyrightText: 2025 Chris Duncan <chris@zoso.dev>
//! SPDX-License-Identifier: GPL-3.0-or-later
y=Zo.default.Buffer});var Ge,Tf,jn,Pf,Xn,Jn,yt,Ot,Zn,ei,Ie,ev,be=g(()=>{"use strict";a();//! SPDX-FileCopyrightText: 2025 Chris Duncan <chris@zoso.dev>
//! SPDX-License-Identifier: GPL-3.0-or-later
Ge="13456789abcdefghijkmnopqrstuwxyz",Tf="nano_1111111111111111111111111111111111111111111111111111hifc8npp",jn="0000000000000000000000000000000000000000000000000000000000000000",Pf=0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFn,Xn=133248297920938463463374607431768211455n,Jn="0000000000000000000000000000000000000000000000000000000000000006",yt="nano_",Ot="xrb_",Zn=0xfffffe0000000000n,ei=0xfffffff800000000n,Ie=Object.freeze({RAW:0,RAI:24,NYANO:24,KRAI:27,PICO:27,MRAI:30,NANO:30,KNANO:33,MNANO:36}),ev=`
const ACCOUNT_KEY_BYTE_LENGTH = 32
const ACCOUNT_KEY_HEX_LENGTH = 64
const ADDRESS_GAP = 20
const ALPHABET = '${Ge}'
const BIP44_PURPOSE = 44
const BIP44_COIN_NANO = 165
const BURN_ADDRESS = '${Tf}'
const BURN_PUBLIC_KEY = '${jn}'
const HARDENED_OFFSET = ${2147483648}
const MAX_RAW = ${Pf}
const MAX_SUPPLY = ${Xn}
const NONCE_LENGTH = 24
const PBKDF2_ITERATIONS = 210000
const PREAMBLE = '${Jn}'
const PREFIX = '${yt}'
const PREFIX_LEGACY = '${Ot}'
const SEED_LENGTH_BIP44 = 128
const SEED_LENGTH_BLAKE2B = 64
const DIFFICULTY_RECEIVE = ${Zn}
const DIFFICULTY_SEND = ${ei}
const XNO = '\u04FE'
const UNITS = ${JSON.stringify(Ie)}
`});var tt,ti,S,G,C,ri,ce,Bx,ie=g(()=>{"use strict";a();be();//! SPDX-FileCopyrightText: 2025 Chris Duncan <chris@zoso.dev>
//! SPDX-License-Identifier: GPL-3.0-or-later
tt=class{static toBytes(e){let t=e.length*5%8,n=t===0?0:8-t,i=0,o=0,v=-1,s=0,u=new Uint8Array(Math.ceil(e.length*5/8));for(let c=0;c<e.length;c++){if(v=Ge.indexOf(e[c]),v<0)throw new RangeError("Invalid base32 character",{cause:e[c]});o=o<<5|v,i+=5,i>=8&&(u[s++]=o>>>i+n-8&255,i-=8)}return i>0&&(u[s++]=o<<i+n-8&255),t!==0&&(u=u.slice(1)),u}static toBuffer(e){return this.toBytes(e).buffer}},ti=class{static toBytes(e){let t=[];for(;e.length>0;){let n=e.substring(0,8);t.push(parseInt(n,2)),e=e.substring(8)}return new Uint8Array(t)}},S=class{static decoder=new TextDecoder;static erase(e){e!=null&&(e instanceof ArrayBuffer&&e.detached||e instanceof Uint8Array&&e.buffer.detached||(e=e instanceof ArrayBuffer?new Uint8Array(e):e,e.fill(0).buffer.transfer?.()))}static toBase32(e){e instanceof ArrayBuffer&&(e=new Uint8Array(e));let t=e.length*8%5,n=t===0?0:5-t,i=0,o="",v=0;for(let s=0;s<e.length;s++)for(i=i<<8|e[s],v+=8;v>=5;)o+=Ge[i>>>v+n-5&31],v-=5;return v>0&&(o+=Ge[i<<5-(v+n)&31]),o}static toBin(e){return[...e].map(t=>t.toString(2).padStart(8,"0")).join("")}static toDec(e){let t=0n;for(let n=e.byteLength;n>0;n--)t+=BigInt(e[n-1])<<BigInt(e.byteLength-n)*8n;return t>9007199254740991n?t:Number(t)}static toHex(e){return e instanceof ArrayBuffer&&(e=new Uint8Array(e)),e.buffer instanceof ArrayBuffer&&e.buffer.detached?"":[...e].map(t=>t.toString(16).padStart(2,"0")).join("").toUpperCase()}static toUtf8(e){return this.decoder.decode(e)}},G=class{static toBin(e,t=0){if(typeof t!="number")throw new TypeError("Invalid padding");try{return BigInt(e).toString(2).padStart(t,"0")}catch{throw new RangeError("Invalid decimal integer")}}static toBytes(e,t=0){if(e==null)throw new TypeError(`Failed to convert '${e}' from decimal to bytes`);if(typeof t!="number")throw new TypeError("Invalid padding");let n=BigInt(e),i=[];for(;n>0;){let v=BigInt.asUintN(8,n);i.push(Number(v)),n>>=8n}let o=new Uint8Array(Math.max(t,i.length));return o.set(i),o.reverse()}static toHex(e,t=0){if(e==null)throw new TypeError(`Failed to convert '${e}' from decimal to hex`);if(typeof t!="number")throw new TypeError("Invalid padding");try{return BigInt(e).toString(16).padStart(t,"0").toUpperCase()}catch{throw new RangeError("Invalid decimal integer")}}},C=class{static toArray(e,t=0){if(typeof e!="string"||!/^[A-Fa-f0-9]+$/i.test(e))throw new TypeError("Invalid string when converting hex to array",{cause:e});if(typeof t!="number")throw new TypeError("Invalid padding when converting hex to array",{cause:t});e.length%2===1&&(e=`0${e}`);let n=e.match(/.{2}/g);if(n==null)throw new RangeError("Invalid hex string when converting to array",{cause:n});for(let i=n.length;i<t;i++)n.unshift("0");return n.map(i=>parseInt(i,16))}static toBin(e){return[...e].map(t=>G.toBin(parseInt(t,16),4)).join("")}static toBuffer(e,t=0){return this.toBytes(e,t).buffer}static toBytes(e,t=0){return new Uint8Array(this.toArray(e,t))}},ri=class{static toBytes(e){let t=Object.keys(e).map(n=>+n).sort((n,i)=>n-i).map(n=>e[n]);return new Uint8Array(t)}},ce=class{static encoder=new TextEncoder;static toBuffer(e){return this.toBytes(e).buffer}static toBytes(e){return this.encoder.encode(e)}static toHex(e){return S.toHex(this.toBytes(e))}},Bx=`
const base32 = ${tt}
const bin = ${ti}
const bytes = ${S}
const dec = ${G}
const hex = ${C}
const obj = ${ri}
const utf8 = ${ce}
`});var oe,tv=g(()=>{"use strict";a();//! SPDX-FileCopyrightText: 2025 Chris Duncan <chris@zoso.dev>
//! SPDX-License-Identifier: GPL-3.0-or-later
oe=class{encoder=new TextEncoder;static checksum(e){let t=e.byteLength/4|0;return crypto.subtle.digest("SHA-256",e).then(n=>{let o=new Uint8Array(n)[0]>>8-t;return BigInt(o)})}static fromEntropy(e){if(e instanceof ArrayBuffer&&(e=new Uint8Array(e)),!(e instanceof Uint8Array))throw new TypeError("Invalid entropy");if(e.byteLength<16||e.byteLength>32)throw new RangeError("Entropy must be 16-32 bytes");if(e.byteLength%4!==0)throw new RangeError("Entropy must be a multiple of 4 bytes");let t=.75*e.byteLength;return this.checksum(e).then(n=>{let o=e.reduce((u,c)=>u=u<<8n|BigInt(c),0n)<<BigInt(e.byteLength)/4n|n,v=[];for(let u=0;u<t;u++){let c=o&2047n,f=Number(c);v.unshift(this.wordlist[f]),o>>=11n}let s=v.join(" ");return this.fromPhrase(s)})}static fromPhrase(e){let t=new this;return this.validate(e).then(n=>{if(n)return t.#i=e.normalize("NFKD").toLowerCase().split(" "),t;throw new Error("Invalid mnemonic phrase.")})}static validate(e){if(typeof e!="string"||!/^(?:[a-z]{3,8} ){11,23}[a-z]{3,8}$/i.test(e))return Promise.resolve(!1);let t=e.normalize("NFKD").split(" ");if(t.length%3!==0)return Promise.resolve(!1);let n=0n,i=0n;for(let f of t){if(this.wordlist.indexOf(f)===-1)return Promise.resolve(!1);n=n<<11n|BigInt(this.wordlist.indexOf(f)),i+=11n}if(Number(i)%33!==0)return Promise.resolve(!1);let o=i/33n,v=i-o,s=n>>o,u=n&(1n<<o)-1n;if(s==null||s<0n||s>(1n<<256n)-1n||v<128n||v>256n||Number(v)%32!==0)return Promise.resolve(!1);let c=new Uint8Array(Number(v)/8);for(let f=0;f<c.length;f++){let p=v-8n*BigInt(f+1),m=s>>p&255n;c[f]=Number(m)}return this.checksum(c).then(f=>f===u)}constructor(){}#e;#t;#i;get phrase(){return this.#i?.join(" ").normalize("NFKD")}destroy(){this.#e?.fill(0).buffer.transfer?.(),this.#t?.fill(0).buffer.transfer?.(),this.#e=void 0,this.#t=void 0,this.#i=void 0}toBip39Seed(e,t){if(this.phrase==null)throw new Error("BIP-39 mnemonic phrase not found");if(this.#e!=null){let n=t==="hex"?[...this.#e].map(i=>i.toString(16).padStart(2,"0")).join("").toUpperCase():this.#e;return Promise.resolve(n)}else{let n=typeof e=="string"?e:"",i=this.encoder.encode(this.phrase);return crypto.subtle.importKey("raw",i,"PBKDF2",!1,["deriveBits","deriveKey"]).then(o=>{let v={name:"PBKDF2",hash:"SHA-512",salt:this.encoder.encode(`mnemonic${n.normalize("NFKD")}`),iterations:2048};return crypto.subtle.deriveBits(v,o,512).then(s=>(this.#e=new Uint8Array(s),this.toBip39Seed(n,t)))})}}toBlake2bSeed(e){if(this.#i?.length!==24)throw new Error("BIP-39 mnemonic phrase must be 24 words to convert to BLAKE2b seed");if(this.#t==null){let t=0n;for(let n of this.#i){if(this.constructor.wordlist.indexOf(n)===-1)throw new RangeError("Word not found in BIP-39 list");t=t<<11n|BigInt(this.constructor.wordlist.indexOf(n))}t>>=8n,this.#t=new Uint8Array(32);for(let n=31;n>=0;n--)this.#t[n]=Number(t&255n),t>>=8n}return e==="hex"?[...this.#t].map(t=>t.toString(16).padStart(2,"0")).join("").toUpperCase():this.#t}static wordlist=Object.freeze(["abandon","ability","able","about","above","absent","absorb","abstract","absurd","abuse","access","accident","account","accuse","achieve","acid","acoustic","acquire","across","act","action","actor","actress","actual","adapt","add","addict","address","adjust","admit","adult","advance","advice","aerobic","affair","afford","afraid","again","age","agent","agree","ahead","aim","air","airport","aisle","alarm","album","alcohol","alert","alien","all","alley","allow","almost","alone","alpha","already","also","alter","always","amateur","amazing","among","amount","amused","analyst","anchor","ancient","anger","angle","angry","animal","ankle","announce","annual","another","answer","antenna","antique","anxiety","any","apart","apology","appear","apple","approve","april","arch","arctic","area","arena","argue","arm","armed","armor","army","around","arrange","arrest","arrive","arrow","art","artefact","artist","artwork","ask","aspect","assault","asset","assist","assume","asthma","athlete","atom","attack","attend","attitude","attract","auction","audit","august","aunt","author","auto","autumn","average","avocado","avoid","awake","aware","away","awesome","awful","awkward","axis","baby","bachelor","bacon","badge","bag","balance","balcony","ball","bamboo","banana","banner","bar","barely","bargain","barrel","base","basic","basket","battle","beach","bean","beauty","because","become","beef","before","begin","behave","behind","believe","below","belt","bench","benefit","best","betray","better","between","beyond","bicycle","bid","bike","bind","biology","bird","birth","bitter","black","blade","blame","blanket","blast","bleak","bless","blind","blood","blossom","blouse","blue","blur","blush","board","boat","body","boil","bomb","bone","bonus","book","boost","border","boring","borrow","boss","bottom","bounce","box","boy","bracket","brain","brand","brass","brave","bread","breeze","brick","bridge","brief","bright","bring","brisk","broccoli","broken","bronze","broom","brother","brown","brush","bubble","buddy","budget","buffalo","build","bulb","bulk","bullet","bundle","bunker","burden","burger","burst","bus","business","busy","butter","buyer","buzz","cabbage","cabin","cable","cactus","cage","cake","call","calm","camera","camp","can","canal","cancel","candy","cannon","canoe","canvas","canyon","capable","capital","captain","car","carbon","card","cargo","carpet","carry","cart","case","cash","casino","castle","casual","cat","catalog","catch","category","cattle","caught","cause","caution","cave","ceiling","celery","cement","census","century","cereal","certain","chair","chalk","champion","change","chaos","chapter","charge","chase","chat","cheap","check","cheese","chef","cherry","chest","chicken","chief","child","chimney","choice","choose","chronic","chuckle","chunk","churn","cigar","cinnamon","circle","citizen","city","civil","claim","clap","clarify","claw","clay","clean","clerk","clever","click","client","cliff","climb","clinic","clip","clock","clog","close","cloth","cloud","clown","club","clump","cluster","clutch","coach","coast","coconut","code","coffee","coil","coin","collect","color","column","combine","come","comfort","comic","common","company","concert","conduct","confirm","congress","connect","consider","control","convince","cook","cool","copper","copy","coral","core","corn","correct","cost","cotton","couch","country","couple","course","cousin","cover","coyote","crack","cradle","craft","cram","crane","crash","crater","crawl","crazy","cream","credit","creek","crew","cricket","crime","crisp","critic","crop","cross","crouch","crowd","crucial","cruel","cruise","crumble","crunch","crush","cry","crystal","cube","culture","cup","cupboard","curious","current","curtain","curve","cushion","custom","cute","cycle","dad","damage","damp","dance","danger","daring","dash","daughter","dawn","day","deal","debate","debris","decade","december","decide","decline","decorate","decrease","deer","defense","define","defy","degree","delay","deliver","demand","demise","denial","dentist","deny","depart","depend","deposit","depth","deputy","derive","describe","desert","design","desk","despair","destroy","detail","detect","develop","device","devote","diagram","dial","diamond","diary","dice","diesel","diet","differ","digital","dignity","dilemma","dinner","dinosaur","direct","dirt","disagree","discover","disease","dish","dismiss","disorder","display","distance","divert","divide","divorce","dizzy","doctor","document","dog","doll","dolphin","domain","donate","donkey","donor","door","dose","double","dove","draft","dragon","drama","drastic","draw","dream","dress","drift","drill","drink","drip","drive","drop","drum","dry","duck","dumb","dune","during","dust","dutch","duty","dwarf","dynamic","eager","eagle","early","earn","earth","easily","east","easy","echo","ecology","economy","edge","edit","educate","effort","egg","eight","either","elbow","elder","electric","elegant","element","elephant","elevator","elite","else","embark","embody","embrace","emerge","emotion","employ","empower","empty","enable","enact","end","endless","endorse","enemy","energy","enforce","engage","engine","enhance","enjoy","enlist","enough","enrich","enroll","ensure","enter","entire","entry","envelope","episode","equal","equip","era","erase","erode","erosion","error","erupt","escape","essay","essence","estate","eternal","ethics","evidence","evil","evoke","evolve","exact","example","excess","exchange","excite","exclude","excuse","execute","exercise","exhaust","exhibit","exile","exist","exit","exotic","expand","expect","expire","explain","expose","express","extend","extra","eye","eyebrow","fabric","face","faculty","fade","faint","faith","fall","false","fame","family","famous","fan","fancy","fantasy","farm","fashion","fat","fatal","father","fatigue","fault","favorite","feature","february","federal","fee","feed","feel","female","fence","festival","fetch","fever","few","fiber","fiction","field","figure","file","film","filter","final","find","fine","finger","finish","fire","firm","first","fiscal","fish","fit","fitness","fix","flag","flame","flash","flat","flavor","flee","flight","flip","float","flock","floor","flower","fluid","flush","fly","foam","focus","fog","foil","fold","follow","food","foot","force","forest","forget","fork","fortune","forum","forward","fossil","foster","found","fox","fragile","frame","frequent","fresh","friend","fringe","frog","front","frost","frown","frozen","fruit","fuel","fun","funny","furnace","fury","future","gadget","gain","galaxy","gallery","game","gap","garage","garbage","garden","garlic","garment","gas","gasp","gate","gather","gauge","gaze","general","genius","genre","gentle","genuine","gesture","ghost","giant","gift","giggle","ginger","giraffe","girl","give","glad","glance","glare","glass","glide","glimpse","globe","gloom","glory","glove","glow","glue","goat","goddess","gold","good","goose","gorilla","gospel","gossip","govern","gown","grab","grace","grain","grant","grape","grass","gravity","great","green","grid","grief","grit","grocery","group","grow","grunt","guard","guess","guide","guilt","guitar","gun","gym","habit","hair","half","hammer","hamster","hand","happy","harbor","hard","harsh","harvest","hat","have","hawk","hazard","head","health","heart","heavy","hedgehog","height","hello","helmet","help","hen","hero","hidden","high","hill","hint","hip","hire","history","hobby","hockey","hold","hole","holiday","hollow","home","honey","hood","hope","horn","horror","horse","hospital","host","hotel","hour","hover","hub","huge","human","humble","humor","hundred","hungry","hunt","hurdle","hurry","hurt","husband","hybrid","ice","icon","idea","identify","idle","ignore","ill","illegal","illness","image","imitate","immense","immune","impact","impose","improve","impulse","inch","include","income","increase","index","indicate","indoor","industry","infant","inflict","inform","inhale","inherit","initial","inject","injury","inmate","inner","innocent","input","inquiry","insane","insect","inside","inspire","install","intact","interest","into","invest","invite","involve","iron","island","isolate","issue","item","ivory","jacket","jaguar","jar","jazz","jealous","jeans","jelly","jewel","job","join","joke","journey","joy","judge","juice","jump","jungle","junior","junk","just","kangaroo","keen","keep","ketchup","key","kick","kid","kidney","kind","kingdom","kiss","kit","kitchen","kite","kitten","kiwi","knee","knife","knock","know","lab","label","labor","ladder","lady","lake","lamp","language","laptop","large","later","latin","laugh","laundry","lava","law","lawn","lawsuit","layer","lazy","leader","leaf","learn","leave","lecture","left","leg","legal","legend","leisure","lemon","lend","length","lens","leopard","lesson","letter","level","liar","liberty","library","license","life","lift","light","like","limb","limit","link","lion","liquid","list","little","live","lizard","load","loan","lobster","local","lock","logic","lonely","long","loop","lottery","loud","lounge","love","loyal","lucky","luggage","lumber","lunar","lunch","luxury","lyrics","machine","mad","magic","magnet","maid","mail","main","major","make","mammal","man","manage","mandate","mango","mansion","manual","maple","marble","march","margin","marine","market","marriage","mask","mass","master","match","material","math","matrix","matter","maximum","maze","meadow","mean","measure","meat","mechanic","medal","media","melody","melt","member","memory","mention","menu","mercy","merge","merit","merry","mesh","message","metal","method","middle","midnight","milk","million","mimic","mind","minimum","minor","minute","miracle","mirror","misery","miss","mistake","mix","mixed","mixture","mobile","model","modify","mom","moment","monitor","monkey","monster","month","moon","moral","more","morning","mosquito","mother","motion","motor","mountain","mouse","move","movie","much","muffin","mule","multiply","muscle","museum","mushroom","music","must","mutual","myself","mystery","myth","naive","name","napkin","narrow","nasty","nation","nature","near","neck","need","negative","neglect","neither","nephew","nerve","nest","net","network","neutral","never","news","next","nice","night","noble","noise","nominee","noodle","normal","north","nose","notable","note","nothing","notice","novel","now","nuclear","number","nurse","nut","oak","obey","object","oblige","obscure","observe","obtain","obvious","occur","ocean","october","odor","off","offer","office","often","oil","okay","old","olive","olympic","omit","once","one","onion","online","only","open","opera","opinion","oppose","option","orange","orbit","orchard","order","ordinary","organ","orient","original","orphan","ostrich","other","outdoor","outer","output","outside","oval","oven","over","own","owner","oxygen","oyster","ozone","pact","paddle","page","pair","palace","palm","panda","panel","panic","panther","paper","parade","parent","park","parrot","party","pass","patch","path","patient","patrol","pattern","pause","pave","payment","peace","peanut","pear","peasant","pelican","pen","penalty","pencil","people","pepper","perfect","permit","person","pet","phone","photo","phrase","physical","piano","picnic","picture","piece","pig","pigeon","pill","pilot","pink","pioneer","pipe","pistol","pitch","pizza","place","planet","plastic","plate","play","please","pledge","pluck","plug","plunge","poem","poet","point","polar","pole","police","pond","pony","pool","popular","portion","position","possible","post","potato","pottery","poverty","powder","power","practice","praise","predict","prefer","prepare","present","pretty","prevent","price","pride","primary","print","priority","prison","private","prize","problem","process","produce","profit","program","project","promote","proof","property","prosper","protect","proud","provide","public","pudding","pull","pulp","pulse","pumpkin","punch","pupil","puppy","purchase","purity","purpose","purse","push","put","puzzle","pyramid","quality","quantum","quarter","question","quick","quit","quiz","quote","rabbit","raccoon","race","rack","radar","radio","rail","rain","raise","rally","ramp","ranch","random","range","rapid","rare","rate","rather","raven","raw","razor","ready","real","reason","rebel","rebuild","recall","receive","recipe","record","recycle","reduce","reflect","reform","refuse","region","regret","regular","reject","relax","release","relief","rely","remain","remember","remind","remove","render","renew","rent","reopen","repair","repeat","replace","report","require","rescue","resemble","resist","resource","response","result","retire","retreat","return","reunion","reveal","review","reward","rhythm","rib","ribbon","rice","rich","ride","ridge","rifle","right","rigid","ring","riot","ripple","risk","ritual","rival","river","road","roast","robot","robust","rocket","romance","roof","rookie","room","rose","rotate","rough","round","route","royal","rubber","rude","rug","rule","run","runway","rural","sad","saddle","sadness","safe","sail","salad","salmon","salon","salt","salute","same","sample","sand","satisfy","satoshi","sauce","sausage","save","say","scale","scan","scare","scatter","scene","scheme","school","science","scissors","scorpion","scout","scrap","screen","script","scrub","sea","search","season","seat","second","secret","section","security","seed","seek","segment","select","sell","seminar","senior","sense","sentence","series","service","session","settle","setup","seven","shadow","shaft","shallow","share","shed","shell","sheriff","shield","shift","shine","ship","shiver","shock","shoe","shoot","shop","short","shoulder","shove","shrimp","shrug","shuffle","shy","sibling","sick","side","siege","sight","sign","silent","silk"