minterjs-util
Version:
Utils for Minter
1 lines • 358 kB
JavaScript
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).minterUtil={})}(this,(function(t){"use strict";var e=1e6,r=1e6,n="[big.js] ",i=n+"Invalid ",o=i+"decimal places",a=i+"rounding mode",s=n+"Division by zero",f={},u=void 0,h=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;function c(t,e,r,n){var i=t.c;if(r===u&&(r=t.constructor.RM),0!==r&&1!==r&&2!==r&&3!==r)throw Error(a);if(e<1)n=3===r&&(n||!!i[0])||0===e&&(1===r&&i[0]>=5||2===r&&(i[0]>5||5===i[0]&&(n||i[1]!==u))),i.length=1,n?(t.e=t.e-e+1,i[0]=1):i[0]=t.e=0;else if(e<i.length){if(n=1===r&&i[e]>=5||2===r&&(i[e]>5||5===i[e]&&(n||i[e+1]!==u||1&i[e-1]))||3===r&&(n||!!i[0]),i.length=e,n)for(;++i[--e]>9;)if(i[e]=0,0===e){++t.e,i.unshift(1);break}for(e=i.length;!i[--e];)i.pop()}return t}function d(t,e,r){var n=t.e,i=t.c.join(""),o=i.length;if(e)i=i.charAt(0)+(o>1?"."+i.slice(1):"")+(n<0?"e":"e+")+n;else if(n<0){for(;++n;)i="0"+i;i="0."+i}else if(n>0)if(++n>o)for(n-=o;n--;)i+="0";else n<o&&(i=i.slice(0,n)+"."+i.slice(n));else o>1&&(i=i.charAt(0)+"."+i.slice(1));return t.s<0&&r?"-"+i:i}f.abs=function(){var t=new this.constructor(this);return t.s=1,t},f.cmp=function(t){var e,r=this,n=r.c,i=(t=new r.constructor(t)).c,o=r.s,a=t.s,s=r.e,f=t.e;if(!n[0]||!i[0])return n[0]?o:i[0]?-a:0;if(o!=a)return o;if(e=o<0,s!=f)return s>f^e?1:-1;for(a=(s=n.length)<(f=i.length)?s:f,o=-1;++o<a;)if(n[o]!=i[o])return n[o]>i[o]^e?1:-1;return s==f?0:s>f^e?1:-1},f.div=function(t){var r=this,n=r.constructor,i=r.c,a=(t=new n(t)).c,f=r.s==t.s?1:-1,h=n.DP;if(h!==~~h||h<0||h>e)throw Error(o);if(!a[0])throw Error(s);if(!i[0])return t.s=f,t.c=[t.e=0],t;var d,l,p,b,m,g=a.slice(),v=d=a.length,y=i.length,w=i.slice(0,d),_=w.length,M=t,S=M.c=[],E=0,A=h+(M.e=r.e-t.e)+1;for(M.s=f,f=A<0?0:A,g.unshift(0);_++<d;)w.push(0);do{for(p=0;p<10;p++){if(d!=(_=w.length))b=d>_?1:-1;else for(m=-1,b=0;++m<d;)if(a[m]!=w[m]){b=a[m]>w[m]?1:-1;break}if(!(b<0))break;for(l=_==d?a:g;_;){if(w[--_]<l[_]){for(m=_;m&&!w[--m];)w[m]=9;--w[m],w[_]+=10}w[_]-=l[_]}for(;!w[0];)w.shift()}S[E++]=b?p:++p,w[0]&&b?w[_]=i[v]||0:w=[i[v]]}while((v++<y||w[0]!==u)&&f--);return S[0]||1==E||(S.shift(),M.e--,A--),E>A&&c(M,A,n.RM,w[0]!==u),M},f.eq=function(t){return 0===this.cmp(t)},f.gt=function(t){return this.cmp(t)>0},f.gte=function(t){return this.cmp(t)>-1},f.lt=function(t){return this.cmp(t)<0},f.lte=function(t){return this.cmp(t)<1},f.minus=f.sub=function(t){var e,r,n,i,o=this,a=o.constructor,s=o.s,f=(t=new a(t)).s;if(s!=f)return t.s=-f,o.plus(t);var u=o.c.slice(),h=o.e,c=t.c,d=t.e;if(!u[0]||!c[0])return c[0]?t.s=-f:u[0]?t=new a(o):t.s=1,t;if(s=h-d){for((i=s<0)?(s=-s,n=u):(d=h,n=c),n.reverse(),f=s;f--;)n.push(0);n.reverse()}else for(r=((i=u.length<c.length)?u:c).length,s=f=0;f<r;f++)if(u[f]!=c[f]){i=u[f]<c[f];break}if(i&&(n=u,u=c,c=n,t.s=-t.s),(f=(r=c.length)-(e=u.length))>0)for(;f--;)u[e++]=0;for(f=e;r>s;){if(u[--r]<c[r]){for(e=r;e&&!u[--e];)u[e]=9;--u[e],u[r]+=10}u[r]-=c[r]}for(;0===u[--f];)u.pop();for(;0===u[0];)u.shift(),--d;return u[0]||(t.s=1,u=[d=0]),t.c=u,t.e=d,t},f.mod=function(t){var e,r=this,n=r.constructor,i=r.s,o=(t=new n(t)).s;if(!t.c[0])throw Error(s);return r.s=t.s=1,e=1==t.cmp(r),r.s=i,t.s=o,e?new n(r):(i=n.DP,o=n.RM,n.DP=n.RM=0,r=r.div(t),n.DP=i,n.RM=o,this.minus(r.times(t)))},f.neg=function(){var t=new this.constructor(this);return t.s=-t.s,t},f.plus=f.add=function(t){var e,r,n,i=this,o=i.constructor;if(t=new o(t),i.s!=t.s)return t.s=-t.s,i.minus(t);var a=i.e,s=i.c,f=t.e,u=t.c;if(!s[0]||!u[0])return u[0]||(s[0]?t=new o(i):t.s=i.s),t;if(s=s.slice(),e=a-f){for(e>0?(f=a,n=u):(e=-e,n=s),n.reverse();e--;)n.push(0);n.reverse()}for(s.length-u.length<0&&(n=u,u=s,s=n),e=u.length,r=0;e;s[e]%=10)r=(s[--e]=s[e]+u[e]+r)/10|0;for(r&&(s.unshift(r),++f),e=s.length;0===s[--e];)s.pop();return t.c=s,t.e=f,t},f.pow=function(t){var e=this,n=new e.constructor("1"),o=n,a=t<0;if(t!==~~t||t<-1e6||t>r)throw Error(i+"exponent");for(a&&(t=-t);1&t&&(o=o.times(e)),t>>=1;)e=e.times(e);return a?n.div(o):o},f.prec=function(t,r){if(t!==~~t||t<1||t>e)throw Error(i+"precision");return c(new this.constructor(this),t,r)},f.round=function(t,r){if(t===u)t=0;else if(t!==~~t||t<-e||t>e)throw Error(o);return c(new this.constructor(this),t+this.e+1,r)},f.sqrt=function(){var t,e,r,i=this,o=i.constructor,a=i.s,s=i.e,f=new o("0.5");if(!i.c[0])return new o(i);if(a<0)throw Error(n+"No square root");0===(a=Math.sqrt(i+""))||a===1/0?((e=i.c.join("")).length+s&1||(e+="0"),s=((s+1)/2|0)-(s<0||1&s),t=new o(((a=Math.sqrt(e))==1/0?"5e":(a=a.toExponential()).slice(0,a.indexOf("e")+1))+s)):t=new o(a+""),s=t.e+(o.DP+=4);do{r=t,t=f.times(r.plus(i.div(r)))}while(r.c.slice(0,s).join("")!==t.c.slice(0,s).join(""));return c(t,(o.DP-=4)+t.e+1,o.RM)},f.times=f.mul=function(t){var e,r=this,n=r.constructor,i=r.c,o=(t=new n(t)).c,a=i.length,s=o.length,f=r.e,u=t.e;if(t.s=r.s==t.s?1:-1,!i[0]||!o[0])return t.c=[t.e=0],t;for(t.e=f+u,a<s&&(e=i,i=o,o=e,u=a,a=s,s=u),e=new Array(u=a+s);u--;)e[u]=0;for(f=s;f--;){for(s=0,u=a+f;u>f;)s=e[u]+o[f]*i[u-f-1]+s,e[u--]=s%10,s=s/10|0;e[u]=s}for(s?++t.e:e.shift(),f=e.length;!e[--f];)e.pop();return t.c=e,t},f.toExponential=function(t,r){var n=this,i=n.c[0];if(t!==u){if(t!==~~t||t<0||t>e)throw Error(o);for(n=c(new n.constructor(n),++t,r);n.c.length<t;)n.c.push(0)}return d(n,!0,!!i)},f.toFixed=function(t,r){var n=this,i=n.c[0];if(t!==u){if(t!==~~t||t<0||t>e)throw Error(o);for(t=t+(n=c(new n.constructor(n),t+n.e+1,r)).e+1;n.c.length<t;)n.c.push(0)}return d(n,!1,!!i)},f[Symbol.for("nodejs.util.inspect.custom")]=f.toJSON=f.toString=function(){var t=this,e=t.constructor;return d(t,t.e<=e.NE||t.e>=e.PE,!!t.c[0])},f.toNumber=function(){var t=Number(d(this,!0,!0));if(!0===this.constructor.strict&&!this.eq(t.toString()))throw Error(n+"Imprecise conversion");return t},f.toPrecision=function(t,r){var n=this,o=n.constructor,a=n.c[0];if(t!==u){if(t!==~~t||t<1||t>e)throw Error(i+"precision");for(n=c(new o(n),t,r);n.c.length<t;)n.c.push(0)}return d(n,t<=n.e||n.e<=o.NE||n.e>=o.PE,!!a)},f.valueOf=function(){var t=this,e=t.constructor;if(!0===e.strict)throw Error(n+"valueOf disallowed");return d(t,t.e<=e.NE||t.e>=e.PE,!0)};var l=function t(){function e(r){var n=this;if(!(n instanceof e))return r===u?t():new e(r);if(r instanceof e)n.s=r.s,n.e=r.e,n.c=r.c.slice();else{if("string"!=typeof r){if(!0===e.strict&&"bigint"!=typeof r)throw TypeError(i+"value");r=0===r&&1/r<0?"-0":String(r)}!function(t,e){var r,n,o;if(!h.test(e))throw Error(i+"number");t.s="-"==e.charAt(0)?(e=e.slice(1),-1):1,(r=e.indexOf("."))>-1&&(e=e.replace(".",""));(n=e.search(/e/i))>0?(r<0&&(r=n),r+=+e.slice(n+1),e=e.substring(0,n)):r<0&&(r=e.length);for(o=e.length,n=0;n<o&&"0"==e.charAt(n);)++n;if(n==o)t.c=[t.e=0];else{for(;o>0&&"0"==e.charAt(--o););for(t.e=r-n-1,t.c=[],r=0;n<=o;)t.c[r++]=+e.charAt(n++)}}(n,r)}n.constructor=e}return e.prototype=f,e.DP=20,e.RM=1,e.NE=-7,e.PE=21,e.strict=false,e.roundDown=0,e.roundHalfUp=1,e.roundHalfEven=2,e.roundUp=3,e}();l.DP=34,l.RM=2,l.prototype.toString=function(){var t,e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:18,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:l.RM;return"string"==typeof(t=this.toFixed(r,n))&&(e||-1===t.indexOf(".")||(t=/[eE]/.test(t)?t.replace(/\.?0*(?=[eE])/,""):t.replace(/\.?0*$/,"")),t=t.replace(/^0+(?!\.)(?!$)/,"")),t};var p="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},b=[],m=[],g="undefined"!=typeof Uint8Array?Uint8Array:Array,v=!1;function y(){v=!0;for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",e=0,r=t.length;e<r;++e)b[e]=t[e],m[t.charCodeAt(e)]=e;m["-".charCodeAt(0)]=62,m["_".charCodeAt(0)]=63}function w(t,e,r){for(var n,i,o=[],a=e;a<r;a+=3)n=(t[a]<<16)+(t[a+1]<<8)+t[a+2],o.push(b[(i=n)>>18&63]+b[i>>12&63]+b[i>>6&63]+b[63&i]);return o.join("")}function _(t){var e;v||y();for(var r=t.length,n=r%3,i="",o=[],a=16383,s=0,f=r-n;s<f;s+=a)o.push(w(t,s,s+a>f?f:s+a));return 1===n?(e=t[r-1],i+=b[e>>2],i+=b[e<<4&63],i+="=="):2===n&&(e=(t[r-2]<<8)+t[r-1],i+=b[e>>10],i+=b[e>>4&63],i+=b[e<<2&63],i+="="),o.push(i),o.join("")}function M(t,e,r,n,i){var o,a,s=8*i-n-1,f=(1<<s)-1,u=f>>1,h=-7,c=r?i-1:0,d=r?-1:1,l=t[e+c];for(c+=d,o=l&(1<<-h)-1,l>>=-h,h+=s;h>0;o=256*o+t[e+c],c+=d,h-=8);for(a=o&(1<<-h)-1,o>>=-h,h+=n;h>0;a=256*a+t[e+c],c+=d,h-=8);if(0===o)o=1-u;else{if(o===f)return a?NaN:1/0*(l?-1:1);a+=Math.pow(2,n),o-=u}return(l?-1:1)*a*Math.pow(2,o-n)}function S(t,e,r,n,i,o){var a,s,f,u=8*o-i-1,h=(1<<u)-1,c=h>>1,d=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,l=n?0:o-1,p=n?1:-1,b=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,a=h):(a=Math.floor(Math.log(e)/Math.LN2),e*(f=Math.pow(2,-a))<1&&(a--,f*=2),(e+=a+c>=1?d/f:d*Math.pow(2,1-c))*f>=2&&(a++,f/=2),a+c>=h?(s=0,a=h):a+c>=1?(s=(e*f-1)*Math.pow(2,i),a+=c):(s=e*Math.pow(2,c-1)*Math.pow(2,i),a=0));i>=8;t[r+l]=255&s,l+=p,s/=256,i-=8);for(a=a<<i|s,u+=i;u>0;t[r+l]=255&a,l+=p,a/=256,u-=8);t[r+l-p]|=128*b}var E={}.toString,A=Array.isArray||function(t){return"[object Array]"==E.call(t)};I.TYPED_ARRAY_SUPPORT=void 0===p.TYPED_ARRAY_SUPPORT||p.TYPED_ARRAY_SUPPORT;var x=R();function R(){return I.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function k(t,e){if(R()<e)throw new RangeError("Invalid typed array length");return I.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(e)).__proto__=I.prototype:(null===t&&(t=new I(e)),t.length=e),t}function I(t,e,r){if(!(I.TYPED_ARRAY_SUPPORT||this instanceof I))return new I(t,e,r);if("number"==typeof t){if("string"==typeof e)throw new Error("If encoding is specified then the first argument must be a string");return O(this,t)}return L(this,t,e,r)}function L(t,e,r,n){if("number"==typeof e)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer?function(t,e,r,n){if(e.byteLength,r<0||e.byteLength<r)throw new RangeError("'offset' is out of bounds");if(e.byteLength<r+(n||0))throw new RangeError("'length' is out of bounds");e=void 0===r&&void 0===n?new Uint8Array(e):void 0===n?new Uint8Array(e,r):new Uint8Array(e,r,n);I.TYPED_ARRAY_SUPPORT?(t=e).__proto__=I.prototype:t=P(t,e);return t}(t,e,r,n):"string"==typeof e?function(t,e,r){"string"==typeof r&&""!==r||(r="utf8");if(!I.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var n=0|C(e,r);t=k(t,n);var i=t.write(e,r);i!==n&&(t=t.slice(0,i));return t}(t,e,r):function(t,e){if(N(e)){var r=0|B(e.length);return 0===(t=k(t,r)).length||e.copy(t,0,0,r),t}if(e){if("undefined"!=typeof ArrayBuffer&&e.buffer instanceof ArrayBuffer||"length"in e)return"number"!=typeof e.length||(n=e.length)!=n?k(t,0):P(t,e);if("Buffer"===e.type&&A(e.data))return P(t,e.data)}var n;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(t,e)}function T(t){if("number"!=typeof t)throw new TypeError('"size" argument must be a number');if(t<0)throw new RangeError('"size" argument must not be negative')}function O(t,e){if(T(e),t=k(t,e<0?0:0|B(e)),!I.TYPED_ARRAY_SUPPORT)for(var r=0;r<e;++r)t[r]=0;return t}function P(t,e){var r=e.length<0?0:0|B(e.length);t=k(t,r);for(var n=0;n<r;n+=1)t[n]=255&e[n];return t}function B(t){if(t>=R())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+R().toString(16)+" bytes");return 0|t}function N(t){return dt(t)}function C(t,e){if(N(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var r=t.length;if(0===r)return 0;for(var n=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return ut(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return ht(t).length;default:if(n)return ut(t).length;e=(""+e).toLowerCase(),n=!0}}function z(t,e,r){var 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 Z(this,e,r);case"ascii":return J(this,e,r);case"latin1":case"binary":return G(this,e,r);case"base64":return V(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Q(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function j(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function q(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),r=+r,isNaN(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=I.from(e,n)),N(e))return 0===e.length?-1:D(t,e,r,n,i);if("number"==typeof e)return e&=255,I.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):D(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function D(t,e,r,n,i){var o,a=1,s=t.length,f=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;a=2,s/=2,f/=2,r/=2}function u(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(i){var h=-1;for(o=r;o<s;o++)if(u(t,o)===u(e,-1===h?0:o-h)){if(-1===h&&(h=o),o-h+1===f)return h*a}else-1!==h&&(o-=o-h),h=-1}else for(r+f>s&&(r=s-f),o=r;o>=0;o--){for(var c=!0,d=0;d<f;d++)if(u(t,o+d)!==u(e,d)){c=!1;break}if(c)return o}return-1}function U(t,e,r,n){r=Number(r)||0;var i=t.length-r;n?(n=Number(n))>i&&(n=i):n=i;var o=e.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var a=0;a<n;++a){var s=parseInt(e.substr(2*a,2),16);if(isNaN(s))return a;t[r+a]=s}return a}function F(t,e,r,n){return ct(ut(e,t.length-r),t,r,n)}function K(t,e,r,n){return ct(function(t){for(var e=[],r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,n)}function H(t,e,r,n){return K(t,e,r,n)}function W(t,e,r,n){return ct(ht(e),t,r,n)}function Y(t,e,r,n){return ct(function(t,e){for(var r,n,i,o=[],a=0;a<t.length&&!((e-=2)<0);++a)n=(r=t.charCodeAt(a))>>8,i=r%256,o.push(i),o.push(n);return o}(e,t.length-r),t,r,n)}function V(t,e,r){return 0===e&&r===t.length?_(t):_(t.slice(e,r))}function Z(t,e,r){r=Math.min(t.length,r);for(var n=[],i=e;i<r;){var o,a,s,f,u=t[i],h=null,c=u>239?4:u>223?3:u>191?2:1;if(i+c<=r)switch(c){case 1:u<128&&(h=u);break;case 2:128==(192&(o=t[i+1]))&&(f=(31&u)<<6|63&o)>127&&(h=f);break;case 3:o=t[i+1],a=t[i+2],128==(192&o)&&128==(192&a)&&(f=(15&u)<<12|(63&o)<<6|63&a)>2047&&(f<55296||f>57343)&&(h=f);break;case 4:o=t[i+1],a=t[i+2],s=t[i+3],128==(192&o)&&128==(192&a)&&128==(192&s)&&(f=(15&u)<<18|(63&o)<<12|(63&a)<<6|63&s)>65535&&f<1114112&&(h=f)}null===h?(h=65533,c=1):h>65535&&(h-=65536,n.push(h>>>10&1023|55296),h=56320|1023&h),n.push(h),i+=c}return function(t){var e=t.length;if(e<=X)return String.fromCharCode.apply(String,t);var r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=X));return r}(n)}I.poolSize=8192,I._augment=function(t){return t.__proto__=I.prototype,t},I.from=function(t,e,r){return L(null,t,e,r)},I.TYPED_ARRAY_SUPPORT&&(I.prototype.__proto__=Uint8Array.prototype,I.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&I[Symbol.species]),I.alloc=function(t,e,r){return function(t,e,r,n){return T(e),e<=0?k(t,e):void 0!==r?"string"==typeof n?k(t,e).fill(r,n):k(t,e).fill(r):k(t,e)}(null,t,e,r)},I.allocUnsafe=function(t){return O(null,t)},I.allocUnsafeSlow=function(t){return O(null,t)},I.isBuffer=dt,I.compare=function(t,e){if(!N(t)||!N(e))throw new TypeError("Arguments must be Buffers");if(t===e)return 0;for(var r=t.length,n=e.length,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},I.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}},I.concat=function(t,e){if(!A(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return I.alloc(0);var r;if(void 0===e)for(e=0,r=0;r<t.length;++r)e+=t[r].length;var n=I.allocUnsafe(e),i=0;for(r=0;r<t.length;++r){var o=t[r];if(!N(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(n,i),i+=o.length}return n},I.byteLength=C,I.prototype._isBuffer=!0,I.prototype.swap16=function(){var t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)j(this,e,e+1);return this},I.prototype.swap32=function(){var t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)j(this,e,e+3),j(this,e+1,e+2);return this},I.prototype.swap64=function(){var t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)j(this,e,e+7),j(this,e+1,e+6),j(this,e+2,e+5),j(this,e+3,e+4);return this},I.prototype.toString=function(){var t=0|this.length;return 0===t?"":0===arguments.length?Z(this,0,t):z.apply(this,arguments)},I.prototype.equals=function(t){if(!N(t))throw new TypeError("Argument must be a Buffer");return this===t||0===I.compare(this,t)},I.prototype.inspect=function(){var t="";return this.length>0&&(t=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(t+=" ... ")),"<Buffer "+t+">"},I.prototype.compare=function(t,e,r,n,i){if(!N(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===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;for(var o=(i>>>=0)-(n>>>=0),a=(r>>>=0)-(e>>>=0),s=Math.min(o,a),f=this.slice(n,i),u=t.slice(e,r),h=0;h<s;++h)if(f[h]!==u[h]){o=f[h],a=u[h];break}return o<a?-1:a<o?1:0},I.prototype.includes=function(t,e,r){return-1!==this.indexOf(t,e,r)},I.prototype.indexOf=function(t,e,r){return q(this,t,e,r,!0)},I.prototype.lastIndexOf=function(t,e,r){return q(this,t,e,r,!1)},I.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e|=0,isFinite(r)?(r|=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var 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");for(var o=!1;;)switch(n){case"hex":return U(this,t,e,r);case"utf8":case"utf-8":return F(this,t,e,r);case"ascii":return K(this,t,e,r);case"latin1":case"binary":return H(this,t,e,r);case"base64":return W(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Y(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},I.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var X=4096;function J(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;i<r;++i)n+=String.fromCharCode(127&t[i]);return n}function G(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;i<r;++i)n+=String.fromCharCode(t[i]);return n}function $(t,e,r){var n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);for(var i="",o=e;o<r;++o)i+=ft(t[o]);return i}function Q(t,e,r){for(var n=t.slice(e,r),i="",o=0;o<n.length;o+=2)i+=String.fromCharCode(n[o]+256*n[o+1]);return i}function tt(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 et(t,e,r,n,i,o){if(!N(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 rt(t,e,r,n){e<0&&(e=65535+e+1);for(var i=0,o=Math.min(t.length-r,2);i<o;++i)t[r+i]=(e&255<<8*(n?i:1-i))>>>8*(n?i:1-i)}function nt(t,e,r,n){e<0&&(e=4294967295+e+1);for(var i=0,o=Math.min(t.length-r,4);i<o;++i)t[r+i]=e>>>8*(n?i:3-i)&255}function it(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 ot(t,e,r,n,i){return i||it(t,0,r,4),S(t,e,r,n,23,4),r+4}function at(t,e,r,n,i){return i||it(t,0,r,8),S(t,e,r,n,52,8),r+8}I.prototype.slice=function(t,e){var r,n=this.length;if((t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(e=void 0===e?n:~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),e<t&&(e=t),I.TYPED_ARRAY_SUPPORT)(r=this.subarray(t,e)).__proto__=I.prototype;else{var i=e-t;r=new I(i,void 0);for(var o=0;o<i;++o)r[o]=this[o+t]}return r},I.prototype.readUIntLE=function(t,e,r){t|=0,e|=0,r||tt(t,e,this.length);for(var n=this[t],i=1,o=0;++o<e&&(i*=256);)n+=this[t+o]*i;return n},I.prototype.readUIntBE=function(t,e,r){t|=0,e|=0,r||tt(t,e,this.length);for(var n=this[t+--e],i=1;e>0&&(i*=256);)n+=this[t+--e]*i;return n},I.prototype.readUInt8=function(t,e){return e||tt(t,1,this.length),this[t]},I.prototype.readUInt16LE=function(t,e){return e||tt(t,2,this.length),this[t]|this[t+1]<<8},I.prototype.readUInt16BE=function(t,e){return e||tt(t,2,this.length),this[t]<<8|this[t+1]},I.prototype.readUInt32LE=function(t,e){return e||tt(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},I.prototype.readUInt32BE=function(t,e){return e||tt(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},I.prototype.readIntLE=function(t,e,r){t|=0,e|=0,r||tt(t,e,this.length);for(var n=this[t],i=1,o=0;++o<e&&(i*=256);)n+=this[t+o]*i;return n>=(i*=128)&&(n-=Math.pow(2,8*e)),n},I.prototype.readIntBE=function(t,e,r){t|=0,e|=0,r||tt(t,e,this.length);for(var n=e,i=1,o=this[t+--n];n>0&&(i*=256);)o+=this[t+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*e)),o},I.prototype.readInt8=function(t,e){return e||tt(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},I.prototype.readInt16LE=function(t,e){e||tt(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},I.prototype.readInt16BE=function(t,e){e||tt(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},I.prototype.readInt32LE=function(t,e){return e||tt(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},I.prototype.readInt32BE=function(t,e){return e||tt(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},I.prototype.readFloatLE=function(t,e){return e||tt(t,4,this.length),M(this,t,!0,23,4)},I.prototype.readFloatBE=function(t,e){return e||tt(t,4,this.length),M(this,t,!1,23,4)},I.prototype.readDoubleLE=function(t,e){return e||tt(t,8,this.length),M(this,t,!0,52,8)},I.prototype.readDoubleBE=function(t,e){return e||tt(t,8,this.length),M(this,t,!1,52,8)},I.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e|=0,r|=0,n)||et(this,t,e,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[e]=255&t;++o<r&&(i*=256);)this[e+o]=t/i&255;return e+r},I.prototype.writeUIntBE=function(t,e,r,n){(t=+t,e|=0,r|=0,n)||et(this,t,e,r,Math.pow(2,8*r)-1,0);var i=r-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+r},I.prototype.writeUInt8=function(t,e,r){return t=+t,e|=0,r||et(this,t,e,1,255,0),I.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},I.prototype.writeUInt16LE=function(t,e,r){return t=+t,e|=0,r||et(this,t,e,2,65535,0),I.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):rt(this,t,e,!0),e+2},I.prototype.writeUInt16BE=function(t,e,r){return t=+t,e|=0,r||et(this,t,e,2,65535,0),I.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):rt(this,t,e,!1),e+2},I.prototype.writeUInt32LE=function(t,e,r){return t=+t,e|=0,r||et(this,t,e,4,4294967295,0),I.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):nt(this,t,e,!0),e+4},I.prototype.writeUInt32BE=function(t,e,r){return t=+t,e|=0,r||et(this,t,e,4,4294967295,0),I.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):nt(this,t,e,!1),e+4},I.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e|=0,!n){var i=Math.pow(2,8*r-1);et(this,t,e,r,i-1,-i)}var o=0,a=1,s=0;for(this[e]=255&t;++o<r&&(a*=256);)t<0&&0===s&&0!==this[e+o-1]&&(s=1),this[e+o]=(t/a>>0)-s&255;return e+r},I.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e|=0,!n){var i=Math.pow(2,8*r-1);et(this,t,e,r,i-1,-i)}var o=r-1,a=1,s=0;for(this[e+o]=255&t;--o>=0&&(a*=256);)t<0&&0===s&&0!==this[e+o+1]&&(s=1),this[e+o]=(t/a>>0)-s&255;return e+r},I.prototype.writeInt8=function(t,e,r){return t=+t,e|=0,r||et(this,t,e,1,127,-128),I.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},I.prototype.writeInt16LE=function(t,e,r){return t=+t,e|=0,r||et(this,t,e,2,32767,-32768),I.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):rt(this,t,e,!0),e+2},I.prototype.writeInt16BE=function(t,e,r){return t=+t,e|=0,r||et(this,t,e,2,32767,-32768),I.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):rt(this,t,e,!1),e+2},I.prototype.writeInt32LE=function(t,e,r){return t=+t,e|=0,r||et(this,t,e,4,2147483647,-2147483648),I.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):nt(this,t,e,!0),e+4},I.prototype.writeInt32BE=function(t,e,r){return t=+t,e|=0,r||et(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),I.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):nt(this,t,e,!1),e+4},I.prototype.writeFloatLE=function(t,e,r){return ot(this,t,e,!0,r)},I.prototype.writeFloatBE=function(t,e,r){return ot(this,t,e,!1,r)},I.prototype.writeDoubleLE=function(t,e,r){return at(this,t,e,!0,r)},I.prototype.writeDoubleBE=function(t,e,r){return at(this,t,e,!1,r)},I.prototype.copy=function(t,e,r,n){if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e<n-r&&(n=t.length-e+r);var i,o=n-r;if(this===t&&r<e&&e<n)for(i=o-1;i>=0;--i)t[i+e]=this[i+r];else if(o<1e3||!I.TYPED_ARRAY_SUPPORT)for(i=0;i<o;++i)t[i+e]=this[i+r];else Uint8Array.prototype.set.call(t,this.subarray(r,r+o),e);return o},I.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),1===t.length){var i=t.charCodeAt(0);i<256&&(t=i)}if(void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!I.isEncoding(n))throw new TypeError("Unknown encoding: "+n)}else"number"==typeof t&&(t&=255);if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;var 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{var a=N(t)?t:ut(new I(t,n).toString()),s=a.length;for(o=0;o<r-e;++o)this[o+e]=a[o%s]}return this};var st=/[^+\/0-9A-Za-z-_]/g;function ft(t){return t<16?"0"+t.toString(16):t.toString(16)}function ut(t,e){var r;e=e||1/0;for(var n=t.length,i=null,o=[],a=0;a<n;++a){if((r=t.charCodeAt(a))>55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(a+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 ht(t){return function(t){var e,r,n,i,o,a;v||y();var s=t.length;if(s%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===t[s-2]?2:"="===t[s-1]?1:0,a=new g(3*s/4-o),n=o>0?s-4:s;var f=0;for(e=0,r=0;e<n;e+=4,r+=3)i=m[t.charCodeAt(e)]<<18|m[t.charCodeAt(e+1)]<<12|m[t.charCodeAt(e+2)]<<6|m[t.charCodeAt(e+3)],a[f++]=i>>16&255,a[f++]=i>>8&255,a[f++]=255&i;return 2===o?(i=m[t.charCodeAt(e)]<<2|m[t.charCodeAt(e+1)]>>4,a[f++]=255&i):1===o&&(i=m[t.charCodeAt(e)]<<10|m[t.charCodeAt(e+1)]<<4|m[t.charCodeAt(e+2)]>>2,a[f++]=i>>8&255,a[f++]=255&i),a}(function(t){if((t=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}(t).replace(st,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function ct(t,e,r,n){for(var i=0;i<n&&!(i+r>=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function dt(t){return null!=t&&(!!t._isBuffer||lt(t)||function(t){return"function"==typeof t.readFloatLE&&"function"==typeof t.slice&<(t.slice(0,0))}(t))}function lt(t){return!!t.constructor&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)}var pt="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function bt(t){if(t.__esModule)return t;var e=t.default;if("function"==typeof e){var r=function t(){if(this instanceof t){var r=[null];return r.push.apply(r,arguments),new(Function.bind.apply(e,r))}return e.apply(this,arguments)};r.prototype=e.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(t).forEach((function(e){var n=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(r,e,n.get?n:{enumerable:!0,get:function(){return t[e]}})})),r}function mt(t){return mt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},mt(t)}function gt(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function vt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,It(n.key),n)}}function yt(t,e,r){return e&&vt(t.prototype,e),r&&vt(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function wt(t,e,r){return(e=It(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function _t(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&St(t,e)}function Mt(t){return Mt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Mt(t)}function St(t,e){return St=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},St(t,e)}function Et(t,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function At(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var r,n=Mt(t);if(e){var i=Mt(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return Et(this,r)}}function xt(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,i,o,a,s=[],f=!0,u=!1;try{if(o=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;f=!1}else for(;!(f=(n=o.call(r)).done)&&(s.push(n.value),s.length!==e);f=!0);}catch(t){u=!0,i=t}finally{try{if(!f&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(u)throw i}}return s}}(t,e)||Rt(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Rt(t,e){if(t){if("string"==typeof t)return kt(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?kt(t,e):void 0}}function kt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function It(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}var Lt="Impossible case. Please create issue.",Tt="The tweak was out of range or the resulted private key is invalid",Ot="The tweak was out of range or equal to zero",Pt="Unknow error on context randomization",Bt="Private Key is invalid",Nt="Public Key could not be parsed",Ct="Public Key serialization error",zt="The sum of the public keys is not valid",jt="Signature could not be parsed",qt="The nonce generation function failed, or the private key was invalid",Dt="Public key could not be recover",Ut="Scalar was invalid (zero or overflow)";function Ft(t,e){if(!t)throw new Error(e)}function Kt(t,e,r){if(Ft(e instanceof Uint8Array,"Expected ".concat(t," to be an Uint8Array")),void 0!==r)if(Array.isArray(r)){var n=r.join(", "),i="Expected ".concat(t," to be an Uint8Array with length [").concat(n,"]");Ft(r.includes(e.length),i)}else{var o="Expected ".concat(t," to be an Uint8Array with length ").concat(r);Ft(e.length===r,o)}}function Ht(t){Ft("Boolean"===Yt(t),"Expected compressed to be a Boolean")}function Wt(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:function(t){return new Uint8Array(t)},e=arguments.length>1?arguments[1]:void 0;return"function"==typeof t&&(t=t(e)),Kt("output",t,e),t}function Yt(t){return Object.prototype.toString.call(t).slice(8,-1)}var Vt={},Zt="6.5.4",Xt={},Jt={},Gt={get exports(){return Jt},set exports(t){Jt=t}},$t=bt(Object.freeze({__proto__:null,Buffer:I,INSPECT_MAX_BYTES:50,SlowBuffer:function(t){return+t!=t&&(t=0),I.alloc(+t)},isBuffer:dt,kMaxLength:x}));!function(t){!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"===mt(t)?t.exports=i:e.BN=i,i.BN=i,i.wordSize=26;try{o="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:$t.Buffer}catch(t){}function a(t,e){var r=t.charCodeAt(e);return r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:r-48&15}function s(t,e,r){var n=a(t,r);return r-1>=e&&(n|=a(t,r-1)<<4),n}function f(t,e,r,n){for(var i=0,o=Math.min(t.length,r),a=e;a<o;a++){var s=t.charCodeAt(a)-48;i*=n,i+=s>=49?s-49+10:s>=17?s-17+10:s}return i}i.isBN=function(t){return t instanceof i||null!==t&&"object"===mt(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"===mt(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,a,s=0;if("be"===n)for(i=t.length-1,o=0;i>=0;i-=3)a=t[i]|t[i-1]<<8|t[i-2]<<16,this.words[o]|=a<<s&67108863,this.words[o+1]=a>>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);else if("le"===n)for(i=0,o=0;i<t.length;i+=3)a=t[i]|t[i+1]<<8|t[i+2]<<16,this.words[o]|=a<<s&67108863,this.words[o+1]=a>>>26-s&67108863,(s+=24)>=26&&(s-=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,a=0;if("be"===r)for(n=t.length-1;n>=e;n-=2)i=s(t,e,n)<<o,this.words[a]|=67108863&i,o>=18?(o-=18,a+=1,this.words[a]|=i>>>26):o+=8;else for(n=(t.length-e)%2==0?e+1:e;n<t.length;n+=2)i=s(t,e,n)<<o,this.words[a]|=67108863&i,o>=18?(o-=18,a+=1,this.words[a]|=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,a=o%n,s=Math.min(o,o-a)+r,u=0,h=r;h<s;h+=n)u=f(t,h,h+n,e),this.imuln(i),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u);if(0!==a){var c=1;for(u=f(t,h,t.length,e),h=0;h<a;h++)c*=e;this.imuln(c),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u)}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.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},i.prototype.inspect=function(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"};var u=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],h=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],c=[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 d(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],a=i*o,s=67108863&a,f=a/67108864|0;r.words[0]=s;for(var u=1;u<n;u++){for(var h=f>>>26,c=67108863&f,d=Math.min(u,e.length-1),l=Math.max(0,u-t.length+1);l<=d;l++){var p=u-l|0;h+=(a=(i=0|t.words[p])*(o=0|e.words[l])+c)/67108864|0,c=67108863&a}r.words[u]=0|c,f=0|h}return 0!==f?r.words[u]=0|f: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,a=0;a<this.length;a++){var s=this.words[a],f=(16777215&(s<<i|o)).toString(16);n=0!==(o=s>>>24-i&16777215)||a!==this.length-1?u[6-f.length]+f+n:f+n,(i+=2)>=26&&(i-=26,a--)}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 d=h[t],l=c[t];n="";var p=this.clone();for(p.negative=0;!p.isZero();){var b=p.modn(l).toString(t);n=(p=p.idivn(l)).isZero()?b+n:u[d-b.length]+b+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)},i.prototype.toBuffer=function(t,e){return r(void 0!==o),this.toArrayLike(o,t,e)},i.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},i.prototype.toArrayLike=function(t,e,n){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"),this.strip();var a,s,f="le"===e,u=new t(o),h=this.clone();if(f){for(s=0;!h.isZero();s++)a=h.andln(255),h.iushrn(8),u[s]=a;for(;s<o;s++)u[s]=0}else{for(s=0;s<o-i;s++)u[s]=0;for(s=0;!h.isZero();s++)a=h.andln(255),h.iushrn(8),u[o-s-1]=a}return u},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,a=0;a<n.length;a++)o=(e=(0|r.words[a])-(0|n.words[a])+o)>>26,this.words[a]=67108863&e;for(;0!==o&&a<r.length;a++)o=(e=(0|r.words[a])+o)>>26,this.words[a]=67108863&e;if(0===o&&a<r.length&&r!==this)for(;a<r.length;a++)this.words[a]=r.words[a];return this.length=Math.max(this.length,a),r!==this&&(this.negative=1),this.strip()},i.prototype.sub=function(t){return this.clone().isub(t)};var l=function(t,e,r){var n,i,o,a=t.words,s=e.words,f=r.words,u=0,h=0|a[0],c=8191&h,d=h>>>13,l=0|a[1],p=8191&l,b=l>>>13,m=0|a[2],g=8191&m,v=m>>>13,y=0|a[3],w=8191&y,_=y>>>13,M=0|a[4],S=8191&M,E=M>>>13,A=0|a[5],x=8191&A,R=A>>>13,k=0|a[6],I=8191&k,L=k>>>13,T=0|a[7],O=8191&T,P=T>>>13,B=0|a[8],N=8191&B,C=B>>>13,z=0|a[9],j=8191&z,q=z>>>13,D=0|s[0],U=8191&D,F=D>>>13,K=0|s[1],H=8191&K,W=K>>>13,Y=0|s[2],V=8191&Y,Z=Y>>>13,X=0|s[3],J=8191&X,G=X>>>13,$=0|s[4],Q=8191&$,tt=$>>>13,et=0|s[5],rt=8191&et,nt=et>>>13,it=0|s[6],ot=8191&it,at=it>>>13,st=0|s[7],ft=8191&st,ut=st>>>13,ht=0|s[8],ct=8191&ht,dt=ht>>>13,lt=0|s[9],pt=8191<,bt=lt>>>13;r.negative=t.negative^e.negative,r.length=19;var mt=(u+(n=Math.imul(c,U))|0)+((8191&(i=(i=Math.imul(c,F))+Math.imul(d,U)|0))<<13)|0;u=((o=Math.imul(d,F))+(i>>>13)|0)+(mt>>>26)|0,mt&=67108863,n=Math.imul(p,U),i=(i=Math.imul(p,F))+Math.imul(b,U)|0,o=Math.imul(b,F);var gt=(u+(n=n+Math.imul(c,H)|0)|0)+((8191&(i=(i=i+Math.imul(c,W)|0)+Math.imul(d,H)|0))<<13)|0;u=((o=o+Math.imul(d,W)|0)+(i>>>13)|0)+(gt>>>26)|0,gt&=67108863,n=Math.imul(g,U),i=(i=Math.imul(g,F))+Math.imul(v,U)|0,o=Math.imul(v,F),n=n+Math.imul(p,H)|0,i=(i=i+Math.imul(p,W)|0)+Math.imul(b,H)|0,o=o+Math.imul(b,W)|0;var vt=(u+(n=n+Math.imul(c,V)|0)|0)+((8191&(i=(i=i+Math.imul(c,Z)|0)+Math.imul(d,V)|0))<<13)|0;u=((o=o+Math.imul(d,Z)|0)+(i>>>13)|0)+(vt>>>26)|0,vt&=67108863,n=Math.imul(w,U),i=(i=Math.imul(w,F))+Math.imul(_,U)|0,o=Math.imul(_,F),n=n+Math.imul(g,H)|0,i=(i=i+Math.imul(g,W)|0)+Math.imul(v,H)|0,o=o+Math.imul(v,W)|0,n=n+Math.imul(p,V)|0,i=(i=i+Math.imul(p,Z)|0)+Math.imul(b,V)|0,o=o+Math.imul(b,Z)|0;var yt=(u+(n=n+Math.imul(c,J)|0)|0)+((8191&(i=(i=i+Math.imul(c,G)|0)+Math.imul(d,J)|0))<<13)|0;u=((o=o+Math.imul(d,G)|0)+(i>>>13)|0)+(yt>>>26)|0,yt&=67108863,n=Math.imul(S,U),i=(i=Math.imul(S,F))+Math.imul(E,U)|0,o=Math.imul(E,F),n=n+Math.imul(w,H)|0,i=(i=i+Math.imul(w,W)|0)+Math.imul(_,H)|0,o=o+Math.imul(_,W)|0,n=n+Math.imul(g,V)|0,i=(i=i+Math.imul(g,Z)|0)+Math.imul(v,V)|0,o=o+Math.imul(v,Z)|0,n=n+Math.imul(p,J)|0,i=(i=i+Math.imul(p,G)|0)+Math.imul(b,J)|0,o=o+Math.imul(b,G)|0;var wt=(u+(n=n+Math.imul(c,Q)|0)|0)+((8191&(i=(i=i+Math.imul(c,tt)|0)+Math.imul(d,Q)|0))<<13)|0;u=((o=o+Math.imul(d,tt)|0)+(i>>>13)|0)+(wt>>>26)|0,wt&=67108863,n=Math.imul(x,U),i=(i=Math.imul(x,F))+Math.imul(R,U)|0,o=Math.imul(R,F),n=n+Math.imul(S,H)|0,i=(i=i+Math.imul(S,W)|0)+Math.imul(E,H)|0,o=o+Math.imul(E,W)|0,n=n+Math.imul(w,V)|0,i=(i=i+Math.imul(w,Z)|0)+Math.imul(_,V)|0,o=o+Math.imul(_,Z)|0,n=n+Math.imul(g,J)|0,i=(i=i+Math.imul(g,G)|0)+Math.imul(v,J)|0,o=o+Math.imul(v,G)|0,n=n+Math.imul(p,Q)|0,i=(i=i+Math.imul(p,tt)|0)+Math.imul(b,Q)|0,o=o+Math.imul(b,tt)|0;var _t=(u+(n=n+Math.imul(c,rt)|0)|0)+((8191&(i=(i=i+Math.imul(c,nt)|0)+Math.imul(d,rt)|0))<<13)|0;u=((o=o+Math.imul(d,nt)|0)+(i>>>13)|0)+(_t>>>26)|0,_t&=67108863,n=Math.imul(I,U),i=(i=Math.imul(I,F))+Math.imul(L,U)|0,o=Math.imul(L,F),n=n+Math.imul(x,H)|0,i=(i=i+Math.imul(x,W)|0)+Math.imul(R,H)|0,o=o+Math.imul(R,W)|0,n=n+Math.imul(S,V)|0,i=(i=i+Math.imul(S,Z)|0)+Math.imul(E,V)|0,o=o+Math.imul(E,Z)|0,n=n+Math.imul(w,J)|0,i=(i=i+Math.imul(w,G)|0)+Math.imul(_,J)|0,o=o+Math.imul(_,G)|0,n=n+Math.imul(g,Q)|0,i=(i=i+Math.imul(g,tt)|0)+Math.imul(v,Q)|0,o=o+Math.imul(v,tt)|0,n=n+Math.imul(p,rt)|0,i=(i=i+Math.imul(p,nt)|0)+Math.imul(b,rt)|0,o=o+Math.imul(b,nt)|0;var Mt=(u+(n=n+Math.imul(c,ot)|0)|0)+((8191&(i=(i=i+Math.imul(c,at)|0)+Math.imul(d,ot)|0))<<13)|0;u=((o=o+Math.imul(d,at)|0)+(i>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,n=Math.imul(O,U),i=(i=Math.imul(O,F))+Math.imul(P,U)|0,o=Math.imul(P,F),n=n+Math.imul(I,H)|0,i=(i=i+Math.imul(I,W)|0)+Math.imul(L,H)|0,o=o+Math.imul(L,W)|0,n=n+Math.imul(x,V)|0,i=(i=i+Math.imul(x,Z)|0)+Math.imul(R,V)|0,o=o+Math.imul(R,Z)|0,n=n+Math.imul(S,J)|0,i=(i=i+Math.imul(S,G)|0)+Math.imul(E,J)|0,o=o+Math.imul(E,G)|0,n=n+Math.imul(w,Q)|0,i=(i=i+Math.imul(w,tt)|0)+Math.imul(_,Q)|0,o=o+Math.imul(_,tt)|0,n=n+Math.imul(g,rt)|0,i=(i=i+Math.imul(g,nt)|0)+Math.imul(v,rt)|0,o=o+Math.imul(v,nt)|0,n=n+Math.imul(p,ot)|0,i=(i=i+Math.imul(p,at)|0)+Math.imul(b,ot)|0,o=o+Math.imul(b,at)|0;var St=(u+(n=n+Math.imul(c,ft)|0)|0)+((8191&(i=(i=i+Math.imul(c,ut)|0)+Math.imul