minter-js-sdk
Version:
JS SDK for Minter Blockchain
1 lines • 737 kB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).minterSDK={})}(this,(function(e){"use strict";var t=1e6,r=1e6,i="[big.js] ",n=i+"Invalid ",o=n+"decimal places",a=n+"rounding mode",s=i+"Division by zero",u={},c=void 0,l=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;function f(e,t,r,i){var n=e.c;if(r===c&&(r=e.constructor.RM),0!==r&&1!==r&&2!==r&&3!==r)throw Error(a);if(t<1)i=3===r&&(i||!!n[0])||0===t&&(1===r&&n[0]>=5||2===r&&(n[0]>5||5===n[0]&&(i||n[1]!==c))),n.length=1,i?(e.e=e.e-t+1,n[0]=1):n[0]=e.e=0;else if(t<n.length){if(i=1===r&&n[t]>=5||2===r&&(n[t]>5||5===n[t]&&(i||n[t+1]!==c||1&n[t-1]))||3===r&&(i||!!n[0]),n.length=t,i)for(;++n[--t]>9;)if(n[t]=0,0===t){++e.e,n.unshift(1);break}for(t=n.length;!n[--t];)n.pop()}return e}function d(e,t,r){var i=e.e,n=e.c.join(""),o=n.length;if(t)n=n.charAt(0)+(o>1?"."+n.slice(1):"")+(i<0?"e":"e+")+i;else if(i<0){for(;++i;)n="0"+n;n="0."+n}else if(i>0)if(++i>o)for(i-=o;i--;)n+="0";else i<o&&(n=n.slice(0,i)+"."+n.slice(i));else o>1&&(n=n.charAt(0)+"."+n.slice(1));return e.s<0&&r?"-"+n:n}u.abs=function(){var e=new this.constructor(this);return e.s=1,e},u.cmp=function(e){var t,r=this,i=r.c,n=(e=new r.constructor(e)).c,o=r.s,a=e.s,s=r.e,u=e.e;if(!i[0]||!n[0])return i[0]?o:n[0]?-a:0;if(o!=a)return o;if(t=o<0,s!=u)return s>u^t?1:-1;for(a=(s=i.length)<(u=n.length)?s:u,o=-1;++o<a;)if(i[o]!=n[o])return i[o]>n[o]^t?1:-1;return s==u?0:s>u^t?1:-1},u.div=function(e){var r=this,i=r.constructor,n=r.c,a=(e=new i(e)).c,u=r.s==e.s?1:-1,l=i.DP;if(l!==~~l||l<0||l>t)throw Error(o);if(!a[0])throw Error(s);if(!n[0])return e.s=u,e.c=[e.e=0],e;var d,h,p,m,b,v=a.slice(),g=d=a.length,y=n.length,w=n.slice(0,d),_=w.length,k=e,E=k.c=[],S=0,x=l+(k.e=r.e-e.e)+1;for(k.s=u,u=x<0?0:x,v.unshift(0);_++<d;)w.push(0);do{for(p=0;p<10;p++){if(d!=(_=w.length))m=d>_?1:-1;else for(b=-1,m=0;++b<d;)if(a[b]!=w[b]){m=a[b]>w[b]?1:-1;break}if(!(m<0))break;for(h=_==d?a:v;_;){if(w[--_]<h[_]){for(b=_;b&&!w[--b];)w[b]=9;--w[b],w[_]+=10}w[_]-=h[_]}for(;!w[0];)w.shift()}E[S++]=m?p:++p,w[0]&&m?w[_]=n[g]||0:w=[n[g]]}while((g++<y||w[0]!==c)&&u--);return E[0]||1==S||(E.shift(),k.e--,x--),S>x&&f(k,x,i.RM,w[0]!==c),k},u.eq=function(e){return 0===this.cmp(e)},u.gt=function(e){return this.cmp(e)>0},u.gte=function(e){return this.cmp(e)>-1},u.lt=function(e){return this.cmp(e)<0},u.lte=function(e){return this.cmp(e)<1},u.minus=u.sub=function(e){var t,r,i,n,o=this,a=o.constructor,s=o.s,u=(e=new a(e)).s;if(s!=u)return e.s=-u,o.plus(e);var c=o.c.slice(),l=o.e,f=e.c,d=e.e;if(!c[0]||!f[0])return f[0]?e.s=-u:c[0]?e=new a(o):e.s=1,e;if(s=l-d){for((n=s<0)?(s=-s,i=c):(d=l,i=f),i.reverse(),u=s;u--;)i.push(0);i.reverse()}else for(r=((n=c.length<f.length)?c:f).length,s=u=0;u<r;u++)if(c[u]!=f[u]){n=c[u]<f[u];break}if(n&&(i=c,c=f,f=i,e.s=-e.s),(u=(r=f.length)-(t=c.length))>0)for(;u--;)c[t++]=0;for(u=t;r>s;){if(c[--r]<f[r]){for(t=r;t&&!c[--t];)c[t]=9;--c[t],c[r]+=10}c[r]-=f[r]}for(;0===c[--u];)c.pop();for(;0===c[0];)c.shift(),--d;return c[0]||(e.s=1,c=[d=0]),e.c=c,e.e=d,e},u.mod=function(e){var t,r=this,i=r.constructor,n=r.s,o=(e=new i(e)).s;if(!e.c[0])throw Error(s);return r.s=e.s=1,t=1==e.cmp(r),r.s=n,e.s=o,t?new i(r):(n=i.DP,o=i.RM,i.DP=i.RM=0,r=r.div(e),i.DP=n,i.RM=o,this.minus(r.times(e)))},u.neg=function(){var e=new this.constructor(this);return e.s=-e.s,e},u.plus=u.add=function(e){var t,r,i,n=this,o=n.constructor;if(e=new o(e),n.s!=e.s)return e.s=-e.s,n.minus(e);var a=n.e,s=n.c,u=e.e,c=e.c;if(!s[0]||!c[0])return c[0]||(s[0]?e=new o(n):e.s=n.s),e;if(s=s.slice(),t=a-u){for(t>0?(u=a,i=c):(t=-t,i=s),i.reverse();t--;)i.push(0);i.reverse()}for(s.length-c.length<0&&(i=c,c=s,s=i),t=c.length,r=0;t;s[t]%=10)r=(s[--t]=s[t]+c[t]+r)/10|0;for(r&&(s.unshift(r),++u),t=s.length;0===s[--t];)s.pop();return e.c=s,e.e=u,e},u.pow=function(e){var t=this,i=new t.constructor("1"),o=i,a=e<0;if(e!==~~e||e<-1e6||e>r)throw Error(n+"exponent");for(a&&(e=-e);1&e&&(o=o.times(t)),e>>=1;)t=t.times(t);return a?i.div(o):o},u.prec=function(e,r){if(e!==~~e||e<1||e>t)throw Error(n+"precision");return f(new this.constructor(this),e,r)},u.round=function(e,r){if(e===c)e=0;else if(e!==~~e||e<-t||e>t)throw Error(o);return f(new this.constructor(this),e+this.e+1,r)},u.sqrt=function(){var e,t,r,n=this,o=n.constructor,a=n.s,s=n.e,u=new o("0.5");if(!n.c[0])return new o(n);if(a<0)throw Error(i+"No square root");0===(a=Math.sqrt(n+""))||a===1/0?((t=n.c.join("")).length+s&1||(t+="0"),s=((s+1)/2|0)-(s<0||1&s),e=new o(((a=Math.sqrt(t))==1/0?"5e":(a=a.toExponential()).slice(0,a.indexOf("e")+1))+s)):e=new o(a+""),s=e.e+(o.DP+=4);do{r=e,e=u.times(r.plus(n.div(r)))}while(r.c.slice(0,s).join("")!==e.c.slice(0,s).join(""));return f(e,(o.DP-=4)+e.e+1,o.RM)},u.times=u.mul=function(e){var t,r=this,i=r.constructor,n=r.c,o=(e=new i(e)).c,a=n.length,s=o.length,u=r.e,c=e.e;if(e.s=r.s==e.s?1:-1,!n[0]||!o[0])return e.c=[e.e=0],e;for(e.e=u+c,a<s&&(t=n,n=o,o=t,c=a,a=s,s=c),t=new Array(c=a+s);c--;)t[c]=0;for(u=s;u--;){for(s=0,c=a+u;c>u;)s=t[c]+o[u]*n[c-u-1]+s,t[c--]=s%10,s=s/10|0;t[c]=s}for(s?++e.e:t.shift(),u=t.length;!t[--u];)t.pop();return e.c=t,e},u.toExponential=function(e,r){var i=this,n=i.c[0];if(e!==c){if(e!==~~e||e<0||e>t)throw Error(o);for(i=f(new i.constructor(i),++e,r);i.c.length<e;)i.c.push(0)}return d(i,!0,!!n)},u.toFixed=function(e,r){var i=this,n=i.c[0];if(e!==c){if(e!==~~e||e<0||e>t)throw Error(o);for(e=e+(i=f(new i.constructor(i),e+i.e+1,r)).e+1;i.c.length<e;)i.c.push(0)}return d(i,!1,!!n)},u[Symbol.for("nodejs.util.inspect.custom")]=u.toJSON=u.toString=function(){var e=this,t=e.constructor;return d(e,e.e<=t.NE||e.e>=t.PE,!!e.c[0])},u.toNumber=function(){var e=Number(d(this,!0,!0));if(!0===this.constructor.strict&&!this.eq(e.toString()))throw Error(i+"Imprecise conversion");return e},u.toPrecision=function(e,r){var i=this,o=i.constructor,a=i.c[0];if(e!==c){if(e!==~~e||e<1||e>t)throw Error(n+"precision");for(i=f(new o(i),e,r);i.c.length<e;)i.c.push(0)}return d(i,e<=i.e||i.e<=o.NE||i.e>=o.PE,!!a)},u.valueOf=function(){var e=this,t=e.constructor;if(!0===t.strict)throw Error(i+"valueOf disallowed");return d(e,e.e<=t.NE||e.e>=t.PE,!0)};var h=function e(){function t(r){var i=this;if(!(i instanceof t))return r===c?e():new t(r);if(r instanceof t)i.s=r.s,i.e=r.e,i.c=r.c.slice();else{if("string"!=typeof r){if(!0===t.strict&&"bigint"!=typeof r)throw TypeError(n+"value");r=0===r&&1/r<0?"-0":String(r)}!function(e,t){var r,i,o;if(!l.test(t))throw Error(n+"number");e.s="-"==t.charAt(0)?(t=t.slice(1),-1):1,(r=t.indexOf("."))>-1&&(t=t.replace(".",""));(i=t.search(/e/i))>0?(r<0&&(r=i),r+=+t.slice(i+1),t=t.substring(0,i)):r<0&&(r=t.length);for(o=t.length,i=0;i<o&&"0"==t.charAt(i);)++i;if(i==o)e.c=[e.e=0];else{for(;o>0&&"0"==t.charAt(--o););for(e.e=r-i-1,e.c=[],r=0;i<=o;)e.c[r++]=+t.charAt(i++)}}(i,r)}i.constructor=t}return t.prototype=u,t.DP=20,t.RM=1,t.NE=-7,t.PE=21,t.strict=false,t.roundDown=0,t.roundHalfUp=1,t.roundHalfEven=2,t.roundUp=3,t}();var p=0;h.DP=34,h.RM=2,h.prototype.toString=function(){var e,t,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:18,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:h.RM;return"string"==typeof(e=this.toFixed(r,i))&&(t||-1===e.indexOf(".")||(e=/[eE]/.test(e)?e.replace(/\.?0*(?=[eE])/,""):e.replace(/\.?0*$/,"")),e=e.replace(/^0+(?!\.)(?!$)/,"")),e};var m="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},b=[],v=[],g="undefined"!=typeof Uint8Array?Uint8Array:Array,y=!1;function w(){y=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)b[t]=e[t],v[e.charCodeAt(t)]=t;v["-".charCodeAt(0)]=62,v["_".charCodeAt(0)]=63}function _(e,t,r){for(var i,n,o=[],a=t;a<r;a+=3)i=(e[a]<<16)+(e[a+1]<<8)+e[a+2],o.push(b[(n=i)>>18&63]+b[n>>12&63]+b[n>>6&63]+b[63&n]);return o.join("")}function k(e){var t;y||w();for(var r=e.length,i=r%3,n="",o=[],a=16383,s=0,u=r-i;s<u;s+=a)o.push(_(e,s,s+a>u?u:s+a));return 1===i?(t=e[r-1],n+=b[t>>2],n+=b[t<<4&63],n+="=="):2===i&&(t=(e[r-2]<<8)+e[r-1],n+=b[t>>10],n+=b[t>>4&63],n+=b[t<<2&63],n+="="),o.push(n),o.join("")}function E(e,t,r,i,n){var o,a,s=8*n-i-1,u=(1<<s)-1,c=u>>1,l=-7,f=r?n-1:0,d=r?-1:1,h=e[t+f];for(f+=d,o=h&(1<<-l)-1,h>>=-l,l+=s;l>0;o=256*o+e[t+f],f+=d,l-=8);for(a=o&(1<<-l)-1,o>>=-l,l+=i;l>0;a=256*a+e[t+f],f+=d,l-=8);if(0===o)o=1-c;else{if(o===u)return a?NaN:1/0*(h?-1:1);a+=Math.pow(2,i),o-=c}return(h?-1:1)*a*Math.pow(2,o-i)}function S(e,t,r,i,n,o){var a,s,u,c=8*o-n-1,l=(1<<c)-1,f=l>>1,d=23===n?Math.pow(2,-24)-Math.pow(2,-77):0,h=i?0:o-1,p=i?1:-1,m=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(s=isNaN(t)?1:0,a=l):(a=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-a))<1&&(a--,u*=2),(t+=a+f>=1?d/u:d*Math.pow(2,1-f))*u>=2&&(a++,u/=2),a+f>=l?(s=0,a=l):a+f>=1?(s=(t*u-1)*Math.pow(2,n),a+=f):(s=t*Math.pow(2,f-1)*Math.pow(2,n),a=0));n>=8;e[r+h]=255&s,h+=p,s/=256,n-=8);for(a=a<<n|s,c+=n;c>0;e[r+h]=255&a,h+=p,a/=256,c-=8);e[r+h-p]|=128*m}var x={}.toString,M=Array.isArray||function(e){return"[object Array]"==x.call(e)};z.TYPED_ARRAY_SUPPORT=void 0===m.TYPED_ARRAY_SUPPORT||m.TYPED_ARRAY_SUPPORT;var A=T();function T(){return z.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function O(e,t){if(T()<t)throw new RangeError("Invalid typed array length");return z.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=z.prototype:(null===e&&(e=new z(t)),e.length=t),e}function z(e,t,r){if(!(z.TYPED_ARRAY_SUPPORT||this instanceof z))return new z(e,t,r);if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return P(this,e)}return R(this,e,t,r)}function R(e,t,r,i){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?function(e,t,r,i){if(t.byteLength,r<0||t.byteLength<r)throw new RangeError("'offset' is out of bounds");if(t.byteLength<r+(i||0))throw new RangeError("'length' is out of bounds");t=void 0===r&&void 0===i?new Uint8Array(t):void 0===i?new Uint8Array(t,r):new Uint8Array(t,r,i);z.TYPED_ARRAY_SUPPORT?(e=t).__proto__=z.prototype:e=I(e,t);return e}(e,t,r,i):"string"==typeof t?function(e,t,r){"string"==typeof r&&""!==r||(r="utf8");if(!z.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var i=0|C(t,r);e=O(e,i);var n=e.write(t,r);n!==i&&(e=e.slice(0,n));return e}(e,t,r):function(e,t){if(B(t)){var r=0|L(t.length);return 0===(e=O(e,r)).length||t.copy(e,0,0,r),e}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return"number"!=typeof t.length||(i=t.length)!=i?O(e,0):I(e,t);if("Buffer"===t.type&&M(t.data))return I(e,t.data)}var i;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function j(e){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function P(e,t){if(j(t),e=O(e,t<0?0:0|L(t)),!z.TYPED_ARRAY_SUPPORT)for(var r=0;r<t;++r)e[r]=0;return e}function I(e,t){var r=t.length<0?0:0|L(t.length);e=O(e,r);for(var i=0;i<r;i+=1)e[i]=255&t[i];return e}function L(e){if(e>=T())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+T().toString(16)+" bytes");return 0|e}function B(e){return!(null==e||!e._isBuffer)}function C(e,t){if(B(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var i=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return le(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return fe(e).length;default:if(i)return le(e).length;t=(""+t).toLowerCase(),i=!0}}function D(e,t,r){var i=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return Q(this,t,r);case"utf8":case"utf-8":return Z(this,t,r);case"ascii":return $(this,t,r);case"latin1":case"binary":return X(this,t,r);case"base64":return G(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ee(this,t,r);default:if(i)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),i=!0}}function N(e,t,r){var i=e[t];e[t]=e[r],e[r]=i}function q(e,t,r,i,n){if(0===e.length)return-1;if("string"==typeof r?(i=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=n?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(n)return-1;r=e.length-1}else if(r<0){if(!n)return-1;r=0}if("string"==typeof t&&(t=z.from(t,i)),B(t))return 0===t.length?-1:U(e,t,r,i,n);if("number"==typeof t)return t&=255,z.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?n?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):U(e,[t],r,i,n);throw new TypeError("val must be string, number or Buffer")}function U(e,t,r,i,n){var o,a=1,s=e.length,u=t.length;if(void 0!==i&&("ucs2"===(i=String(i).toLowerCase())||"ucs-2"===i||"utf16le"===i||"utf-16le"===i)){if(e.length<2||t.length<2)return-1;a=2,s/=2,u/=2,r/=2}function c(e,t){return 1===a?e[t]:e.readUInt16BE(t*a)}if(n){var l=-1;for(o=r;o<s;o++)if(c(e,o)===c(t,-1===l?0:o-l)){if(-1===l&&(l=o),o-l+1===u)return l*a}else-1!==l&&(o-=o-l),l=-1}else for(r+u>s&&(r=s-u),o=r;o>=0;o--){for(var f=!0,d=0;d<u;d++)if(c(e,o+d)!==c(t,d)){f=!1;break}if(f)return o}return-1}function K(e,t,r,i){r=Number(r)||0;var n=e.length-r;i?(i=Number(i))>n&&(i=n):i=n;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");i>o/2&&(i=o/2);for(var a=0;a<i;++a){var s=parseInt(t.substr(2*a,2),16);if(isNaN(s))return a;e[r+a]=s}return a}function F(e,t,r,i){return de(le(t,e.length-r),e,r,i)}function V(e,t,r,i){return de(function(e){for(var t=[],r=0;r<e.length;++r)t.push(255&e.charCodeAt(r));return t}(t),e,r,i)}function H(e,t,r,i){return V(e,t,r,i)}function W(e,t,r,i){return de(fe(t),e,r,i)}function Y(e,t,r,i){return de(function(e,t){for(var r,i,n,o=[],a=0;a<e.length&&!((t-=2)<0);++a)i=(r=e.charCodeAt(a))>>8,n=r%256,o.push(n),o.push(i);return o}(t,e.length-r),e,r,i)}function G(e,t,r){return 0===t&&r===e.length?k(e):k(e.slice(t,r))}function Z(e,t,r){r=Math.min(e.length,r);for(var i=[],n=t;n<r;){var o,a,s,u,c=e[n],l=null,f=c>239?4:c>223?3:c>191?2:1;if(n+f<=r)switch(f){case 1:c<128&&(l=c);break;case 2:128==(192&(o=e[n+1]))&&(u=(31&c)<<6|63&o)>127&&(l=u);break;case 3:o=e[n+1],a=e[n+2],128==(192&o)&&128==(192&a)&&(u=(15&c)<<12|(63&o)<<6|63&a)>2047&&(u<55296||u>57343)&&(l=u);break;case 4:o=e[n+1],a=e[n+2],s=e[n+3],128==(192&o)&&128==(192&a)&&128==(192&s)&&(u=(15&c)<<18|(63&o)<<12|(63&a)<<6|63&s)>65535&&u<1114112&&(l=u)}null===l?(l=65533,f=1):l>65535&&(l-=65536,i.push(l>>>10&1023|55296),l=56320|1023&l),i.push(l),n+=f}return function(e){var t=e.length;if(t<=J)return String.fromCharCode.apply(String,e);var r="",i=0;for(;i<t;)r+=String.fromCharCode.apply(String,e.slice(i,i+=J));return r}(i)}z.poolSize=8192,z._augment=function(e){return e.__proto__=z.prototype,e},z.from=function(e,t,r){return R(null,e,t,r)},z.TYPED_ARRAY_SUPPORT&&(z.prototype.__proto__=Uint8Array.prototype,z.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&z[Symbol.species]),z.alloc=function(e,t,r){return function(e,t,r,i){return j(t),t<=0?O(e,t):void 0!==r?"string"==typeof i?O(e,t).fill(r,i):O(e,t).fill(r):O(e,t)}(null,e,t,r)},z.allocUnsafe=function(e){return P(null,e)},z.allocUnsafeSlow=function(e){return P(null,e)},z.isBuffer=he,z.compare=function(e,t){if(!B(e)||!B(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var r=e.length,i=t.length,n=0,o=Math.min(r,i);n<o;++n)if(e[n]!==t[n]){r=e[n],i=t[n];break}return r<i?-1:i<r?1:0},z.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}},z.concat=function(e,t){if(!M(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return z.alloc(0);var r;if(void 0===t)for(t=0,r=0;r<e.length;++r)t+=e[r].length;var i=z.allocUnsafe(t),n=0;for(r=0;r<e.length;++r){var o=e[r];if(!B(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(i,n),n+=o.length}return i},z.byteLength=C,z.prototype._isBuffer=!0,z.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)N(this,t,t+1);return this},z.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)N(this,t,t+3),N(this,t+1,t+2);return this},z.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)N(this,t,t+7),N(this,t+1,t+6),N(this,t+2,t+5),N(this,t+3,t+4);return this},z.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?Z(this,0,e):D.apply(this,arguments)},z.prototype.equals=function(e){if(!B(e))throw new TypeError("Argument must be a Buffer");return this===e||0===z.compare(this,e)},z.prototype.inspect=function(){var e="";return this.length>0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),"<Buffer "+e+">"},z.prototype.compare=function(e,t,r,i,n){if(!B(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===i&&(i=0),void 0===n&&(n=this.length),t<0||r>e.length||i<0||n>this.length)throw new RangeError("out of range index");if(i>=n&&t>=r)return 0;if(i>=n)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(n>>>=0)-(i>>>=0),a=(r>>>=0)-(t>>>=0),s=Math.min(o,a),u=this.slice(i,n),c=e.slice(t,r),l=0;l<s;++l)if(u[l]!==c[l]){o=u[l],a=c[l];break}return o<a?-1:a<o?1:0},z.prototype.includes=function(e,t,r){return-1!==this.indexOf(e,t,r)},z.prototype.indexOf=function(e,t,r){return q(this,e,t,r,!0)},z.prototype.lastIndexOf=function(e,t,r){return q(this,e,t,r,!1)},z.prototype.write=function(e,t,r,i){if(void 0===t)i="utf8",r=this.length,t=0;else if(void 0===r&&"string"==typeof t)i=t,r=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t|=0,isFinite(r)?(r|=0,void 0===i&&(i="utf8")):(i=r,r=void 0)}var n=this.length-t;if((void 0===r||r>n)&&(r=n),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");for(var o=!1;;)switch(i){case"hex":return K(this,e,t,r);case"utf8":case"utf-8":return F(this,e,t,r);case"ascii":return V(this,e,t,r);case"latin1":case"binary":return H(this,e,t,r);case"base64":return W(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Y(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),o=!0}},z.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var J=4096;function $(e,t,r){var i="";r=Math.min(e.length,r);for(var n=t;n<r;++n)i+=String.fromCharCode(127&e[n]);return i}function X(e,t,r){var i="";r=Math.min(e.length,r);for(var n=t;n<r;++n)i+=String.fromCharCode(e[n]);return i}function Q(e,t,r){var i=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>i)&&(r=i);for(var n="",o=t;o<r;++o)n+=ce(e[o]);return n}function ee(e,t,r){for(var i=e.slice(t,r),n="",o=0;o<i.length;o+=2)n+=String.fromCharCode(i[o]+256*i[o+1]);return n}function te(e,t,r){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}function re(e,t,r,i,n,o){if(!B(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>n||t<o)throw new RangeError('"value" argument is out of bounds');if(r+i>e.length)throw new RangeError("Index out of range")}function ie(e,t,r,i){t<0&&(t=65535+t+1);for(var n=0,o=Math.min(e.length-r,2);n<o;++n)e[r+n]=(t&255<<8*(i?n:1-n))>>>8*(i?n:1-n)}function ne(e,t,r,i){t<0&&(t=4294967295+t+1);for(var n=0,o=Math.min(e.length-r,4);n<o;++n)e[r+n]=t>>>8*(i?n:3-n)&255}function oe(e,t,r,i,n,o){if(r+i>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function ae(e,t,r,i,n){return n||oe(e,0,r,4),S(e,t,r,i,23,4),r+4}function se(e,t,r,i,n){return n||oe(e,0,r,8),S(e,t,r,i,52,8),r+8}z.prototype.slice=function(e,t){var r,i=this.length;if((e=~~e)<0?(e+=i)<0&&(e=0):e>i&&(e=i),(t=void 0===t?i:~~t)<0?(t+=i)<0&&(t=0):t>i&&(t=i),t<e&&(t=e),z.TYPED_ARRAY_SUPPORT)(r=this.subarray(e,t)).__proto__=z.prototype;else{var n=t-e;r=new z(n,void 0);for(var o=0;o<n;++o)r[o]=this[o+e]}return r},z.prototype.readUIntLE=function(e,t,r){e|=0,t|=0,r||te(e,t,this.length);for(var i=this[e],n=1,o=0;++o<t&&(n*=256);)i+=this[e+o]*n;return i},z.prototype.readUIntBE=function(e,t,r){e|=0,t|=0,r||te(e,t,this.length);for(var i=this[e+--t],n=1;t>0&&(n*=256);)i+=this[e+--t]*n;return i},z.prototype.readUInt8=function(e,t){return t||te(e,1,this.length),this[e]},z.prototype.readUInt16LE=function(e,t){return t||te(e,2,this.length),this[e]|this[e+1]<<8},z.prototype.readUInt16BE=function(e,t){return t||te(e,2,this.length),this[e]<<8|this[e+1]},z.prototype.readUInt32LE=function(e,t){return t||te(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},z.prototype.readUInt32BE=function(e,t){return t||te(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},z.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||te(e,t,this.length);for(var i=this[e],n=1,o=0;++o<t&&(n*=256);)i+=this[e+o]*n;return i>=(n*=128)&&(i-=Math.pow(2,8*t)),i},z.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||te(e,t,this.length);for(var i=t,n=1,o=this[e+--i];i>0&&(n*=256);)o+=this[e+--i]*n;return o>=(n*=128)&&(o-=Math.pow(2,8*t)),o},z.prototype.readInt8=function(e,t){return t||te(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},z.prototype.readInt16LE=function(e,t){t||te(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},z.prototype.readInt16BE=function(e,t){t||te(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},z.prototype.readInt32LE=function(e,t){return t||te(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},z.prototype.readInt32BE=function(e,t){return t||te(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},z.prototype.readFloatLE=function(e,t){return t||te(e,4,this.length),E(this,e,!0,23,4)},z.prototype.readFloatBE=function(e,t){return t||te(e,4,this.length),E(this,e,!1,23,4)},z.prototype.readDoubleLE=function(e,t){return t||te(e,8,this.length),E(this,e,!0,52,8)},z.prototype.readDoubleBE=function(e,t){return t||te(e,8,this.length),E(this,e,!1,52,8)},z.prototype.writeUIntLE=function(e,t,r,i){(e=+e,t|=0,r|=0,i)||re(this,e,t,r,Math.pow(2,8*r)-1,0);var n=1,o=0;for(this[t]=255&e;++o<r&&(n*=256);)this[t+o]=e/n&255;return t+r},z.prototype.writeUIntBE=function(e,t,r,i){(e=+e,t|=0,r|=0,i)||re(this,e,t,r,Math.pow(2,8*r)-1,0);var n=r-1,o=1;for(this[t+n]=255&e;--n>=0&&(o*=256);)this[t+n]=e/o&255;return t+r},z.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||re(this,e,t,1,255,0),z.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},z.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||re(this,e,t,2,65535,0),z.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ie(this,e,t,!0),t+2},z.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||re(this,e,t,2,65535,0),z.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ie(this,e,t,!1),t+2},z.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||re(this,e,t,4,4294967295,0),z.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):ne(this,e,t,!0),t+4},z.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||re(this,e,t,4,4294967295,0),z.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):ne(this,e,t,!1),t+4},z.prototype.writeIntLE=function(e,t,r,i){if(e=+e,t|=0,!i){var n=Math.pow(2,8*r-1);re(this,e,t,r,n-1,-n)}var o=0,a=1,s=0;for(this[t]=255&e;++o<r&&(a*=256);)e<0&&0===s&&0!==this[t+o-1]&&(s=1),this[t+o]=(e/a>>0)-s&255;return t+r},z.prototype.writeIntBE=function(e,t,r,i){if(e=+e,t|=0,!i){var n=Math.pow(2,8*r-1);re(this,e,t,r,n-1,-n)}var o=r-1,a=1,s=0;for(this[t+o]=255&e;--o>=0&&(a*=256);)e<0&&0===s&&0!==this[t+o+1]&&(s=1),this[t+o]=(e/a>>0)-s&255;return t+r},z.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||re(this,e,t,1,127,-128),z.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},z.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||re(this,e,t,2,32767,-32768),z.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ie(this,e,t,!0),t+2},z.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||re(this,e,t,2,32767,-32768),z.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ie(this,e,t,!1),t+2},z.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||re(this,e,t,4,2147483647,-2147483648),z.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):ne(this,e,t,!0),t+4},z.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||re(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),z.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):ne(this,e,t,!1),t+4},z.prototype.writeFloatLE=function(e,t,r){return ae(this,e,t,!0,r)},z.prototype.writeFloatBE=function(e,t,r){return ae(this,e,t,!1,r)},z.prototype.writeDoubleLE=function(e,t,r){return se(this,e,t,!0,r)},z.prototype.writeDoubleBE=function(e,t,r){return se(this,e,t,!1,r)},z.prototype.copy=function(e,t,r,i){if(r||(r=0),i||0===i||(i=this.length),t>=e.length&&(t=e.length),t||(t=0),i>0&&i<r&&(i=r),i===r)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("sourceStart out of bounds");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),e.length-t<i-r&&(i=e.length-t+r);var n,o=i-r;if(this===e&&r<t&&t<i)for(n=o-1;n>=0;--n)e[n+t]=this[n+r];else if(o<1e3||!z.TYPED_ARRAY_SUPPORT)for(n=0;n<o;++n)e[n+t]=this[n+r];else Uint8Array.prototype.set.call(e,this.subarray(r,r+o),t);return o},z.prototype.fill=function(e,t,r,i){if("string"==typeof e){if("string"==typeof t?(i=t,t=0,r=this.length):"string"==typeof r&&(i=r,r=this.length),1===e.length){var n=e.charCodeAt(0);n<256&&(e=n)}if(void 0!==i&&"string"!=typeof i)throw new TypeError("encoding must be a string");if("string"==typeof i&&!z.isEncoding(i))throw new TypeError("Unknown encoding: "+i)}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<r)throw new RangeError("Out of range index");if(r<=t)return this;var o;if(t>>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o<r;++o)this[o]=e;else{var a=B(e)?e:le(new z(e,i).toString()),s=a.length;for(o=0;o<r-t;++o)this[o+t]=a[o%s]}return this};var ue=/[^+\/0-9A-Za-z-_]/g;function ce(e){return e<16?"0"+e.toString(16):e.toString(16)}function le(e,t){var r;t=t||1/0;for(var i=e.length,n=null,o=[],a=0;a<i;++a){if((r=e.charCodeAt(a))>55295&&r<57344){if(!n){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(a+1===i){(t-=3)>-1&&o.push(239,191,189);continue}n=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),n=r;continue}r=65536+(n-55296<<10|r-56320)}else n&&(t-=3)>-1&&o.push(239,191,189);if(n=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=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((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function fe(e){return function(e){var t,r,i,n,o,a;y||w();var s=e.length;if(s%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[s-2]?2:"="===e[s-1]?1:0,a=new g(3*s/4-o),i=o>0?s-4:s;var u=0;for(t=0,r=0;t<i;t+=4,r+=3)n=v[e.charCodeAt(t)]<<18|v[e.charCodeAt(t+1)]<<12|v[e.charCodeAt(t+2)]<<6|v[e.charCodeAt(t+3)],a[u++]=n>>16&255,a[u++]=n>>8&255,a[u++]=255&n;return 2===o?(n=v[e.charCodeAt(t)]<<2|v[e.charCodeAt(t+1)]>>4,a[u++]=255&n):1===o&&(n=v[e.charCodeAt(t)]<<10|v[e.charCodeAt(t+1)]<<4|v[e.charCodeAt(t+2)]>>2,a[u++]=n>>8&255,a[u++]=255&n),a}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(ue,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function de(e,t,r,i){for(var n=0;n<i&&!(n+r>=t.length||n>=e.length);++n)t[n+r]=e[n];return n}function he(e){return null!=e&&(!!e._isBuffer||pe(e)||function(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&pe(e.slice(0,0))}(e))}function pe(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}var me="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function be(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function ve(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){if(this instanceof e){var r=[null];return r.push.apply(r,arguments),new(Function.bind.apply(t,r))}return t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var i=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,i.get?i:{enumerable:!0,get:function(){return e[t]}})})),r}function ge(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(!e)return;if("string"==typeof e)return ye(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return ye(e,t)}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var i=0,n=function(){};return{s:n,n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}function ye(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,i=new Array(t);r<t;r++)i[r]=e[r];return i}var we="Impossible case. Please create issue.",_e="The tweak was out of range or the resulted private key is invalid",ke="The tweak was out of range or equal to zero",Ee="Unknow error on context randomization",Se="Private Key is invalid",xe="Public Key could not be parsed",Me="Public Key serialization error",Ae="The sum of the public keys is not valid",Te="Signature could not be parsed",Oe="The nonce generation function failed, or the private key was invalid",ze="Public key could not be recover",Re="Scalar was invalid (zero or overflow)";function je(e,t){if(!e)throw new Error(t)}function Pe(e,t,r){if(je(t instanceof Uint8Array,"Expected ".concat(e," to be an Uint8Array")),void 0!==r)if(Array.isArray(r)){var i=r.join(", "),n="Expected ".concat(e," to be an Uint8Array with length [").concat(i,"]");je(r.includes(t.length),n)}else{var o="Expected ".concat(e," to be an Uint8Array with length ").concat(r);je(t.length===r,o)}}function Ie(e){je("Boolean"===Be(e),"Expected compressed to be a Boolean")}function Le(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:function(e){return new Uint8Array(e)},t=arguments.length>1?arguments[1]:void 0;return"function"==typeof e&&(e=e(t)),Pe("output",e,t),e}function Be(e){return Object.prototype.toString.call(e).slice(8,-1)}var Ce={},De="6.5.4",Ne={};function qe(e){return qe="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},qe(e)}var Ue={exports:{}},Ke=ve(Object.freeze({__proto__:null,Buffer:z,INSPECT_MAX_BYTES:50,SlowBuffer:function(e){return+e!=e&&(e=0),z.alloc(+e)},isBuffer:he,kMaxLength:A}));!function(e){!function(e,t){function r(e,t){if(!e)throw new Error(t||"Assertion failed")}function i(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}function n(e,t,r){if(n.isBN(e))return e;this.negative=0,this.words=null,this.length=0,this.red=null,null!==e&&("le"!==t&&"be"!==t||(r=t,t=10),this._init(e||0,t||10,r||"be"))}var o;"object"===qe(e)?e.exports=n:t.BN=n,n.BN=n,n.wordSize=26;try{o="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:Ke.Buffer}catch(e){}function a(e,t){var r=e.charCodeAt(t);return r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:r-48&15}function s(e,t,r){var i=a(e,r);return r-1>=t&&(i|=a(e,r-1)<<4),i}function u(e,t,r,i){for(var n=0,o=Math.min(e.length,r),a=t;a<o;a++){var s=e.charCodeAt(a)-48;n*=i,n+=s>=49?s-49+10:s>=17?s-17+10:s}return n}n.isBN=function(e){return e instanceof n||null!==e&&"object"===qe(e)&&e.constructor.wordSize===n.wordSize&&Array.isArray(e.words)},n.max=function(e,t){return e.cmp(t)>0?e:t},n.min=function(e,t){return e.cmp(t)<0?e:t},n.prototype._init=function(e,t,i){if("number"==typeof e)return this._initNumber(e,t,i);if("object"===qe(e))return this._initArray(e,t,i);"hex"===t&&(t=16),r(t===(0|t)&&t>=2&&t<=36);var n=0;"-"===(e=e.toString().replace(/\s+/g,""))[0]&&(n++,this.negative=1),n<e.length&&(16===t?this._parseHex(e,n,i):(this._parseBase(e,t,n),"le"===i&&this._initArray(this.toArray(),t,i)))},n.prototype._initNumber=function(e,t,i){e<0&&(this.negative=1,e=-e),e<67108864?(this.words=[67108863&e],this.length=1):e<4503599627370496?(this.words=[67108863&e,e/67108864&67108863],this.length=2):(r(e<9007199254740992),this.words=[67108863&e,e/67108864&67108863,1],this.length=3),"le"===i&&this._initArray(this.toArray(),t,i)},n.prototype._initArray=function(e,t,i){if(r("number"==typeof e.length),e.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(e.length/3),this.words=new Array(this.length);for(var n=0;n<this.length;n++)this.words[n]=0;var o,a,s=0;if("be"===i)for(n=e.length-1,o=0;n>=0;n-=3)a=e[n]|e[n-1]<<8|e[n-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"===i)for(n=0,o=0;n<e.length;n+=3)a=e[n]|e[n+1]<<8|e[n+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()},n.prototype._parseHex=function(e,t,r){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var i=0;i<this.length;i++)this.words[i]=0;var n,o=0,a=0;if("be"===r)for(i=e.length-1;i>=t;i-=2)n=s(e,t,i)<<o,this.words[a]|=67108863&n,o>=18?(o-=18,a+=1,this.words[a]|=n>>>26):o+=8;else for(i=(e.length-t)%2==0?t+1:t;i<e.length;i+=2)n=s(e,t,i)<<o,this.words[a]|=67108863&n,o>=18?(o-=18,a+=1,this.words[a]|=n>>>26):o+=8;this.strip()},n.prototype._parseBase=function(e,t,r){this.words=[0],this.length=1;for(var i=0,n=1;n<=67108863;n*=t)i++;i--,n=n/t|0;for(var o=e.length-r,a=o%i,s=Math.min(o,o-a)+r,c=0,l=r;l<s;l+=i)c=u(e,l,l+i,t),this.imuln(n),this.words[0]+c<67108864?this.words[0]+=c:this._iaddn(c);if(0!==a){var f=1;for(c=u(e,l,e.length,t),l=0;l<a;l++)f*=t;this.imuln(f),this.words[0]+c<67108864?this.words[0]+=c:this._iaddn(c)}this.strip()},n.prototype.copy=function(e){e.words=new Array(this.length);for(var t=0;t<this.length;t++)e.words[t]=this.words[t];e.length=this.length,e.negative=this.negative,e.red=this.red},n.prototype.clone=function(){var e=new n(null);return this.copy(e),e},n.prototype._expand=function(e){for(;this.length<e;)this.words[this.length++]=0;return this},n.prototype.strip=function(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign()},n.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},n.prototype.inspect=function(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"};var c=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],l=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],f=[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(e,t,r){r.negative=t.negative^e.negative;var i=e.length+t.length|0;r.length=i,i=i-1|0;var n=0|e.words[0],o=0|t.words[0],a=n*o,s=67108863&a,u=a/67108864|0;r.words[0]=s;for(var c=1;c<i;c++){for(var l=u>>>26,f=67108863&u,d=Math.min(c,t.length-1),h=Math.max(0,c-e.length+1);h<=d;h++){var p=c-h|0;l+=(a=(n=0|e.words[p])*(o=0|t.words[h])+f)/67108864|0,f=67108863&a}r.words[c]=0|f,u=0|l}return 0!==u?r.words[c]=0|u:r.length--,r.strip()}n.prototype.toString=function(e,t){var i;if(t=0|t||1,16===(e=e||10)||"hex"===e){i="";for(var n=0,o=0,a=0;a<this.length;a++){var s=this.words[a],u=(16777215&(s<<n|o)).toString(16);i=0!==(o=s>>>24-n&16777215)||a!==this.length-1?c[6-u.length]+u+i:u+i,(n+=2)>=26&&(n-=26,a--)}for(0!==o&&(i=o.toString(16)+i);i.length%t!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}if(e===(0|e)&&e>=2&&e<=36){var d=l[e],h=f[e];i="";var p=this.clone();for(p.negative=0;!p.isZero();){var m=p.modn(h).toString(e);i=(p=p.idivn(h)).isZero()?m+i:c[d-m.length]+m+i}for(this.isZero()&&(i="0"+i);i.length%t!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}r(!1,"Base should be between 2 and 36")},n.prototype.toNumber=function(){var e=this.words[0];return 2===this.length?e+=67108864*this.words[1]:3===this.length&&1===this.words[2]?e+=4503599627370496+67108864*this.words[1]:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-e:e},n.prototype.toJSON=function(){return this.toString(16)},n.prototype.toBuffer=function(e,t){return r(void 0!==o),this.toArrayLike(o,e,t)},n.prototype.toArray=function(e,t){return this.toArrayLike(Array,e,t)},n.prototype.toArrayLike=function(e,t,i){var n=this.byteLength(),o=i||Math.max(1,n);r(n<=o,"byte array longer than desired length"),r(o>0,"Requested array length <= 0"),this.strip();var a,s,u="le"===t,c=new e(o),l=this.clone();if(u){for(s=0;!l.isZero();s++)a=l.andln(255),l.iushrn(8),c[s]=a;for(;s<o;s++)c[s]=0}else{for(s=0;s<o-n;s++)c[s]=0;for(s=0;!l.isZero();s++)a=l.andln(255),l.iushrn(8),c[o-s-1]=a}return c},Math.clz32?n.prototype._countBits=function(e){return 32-Math.clz32(e)}:n.prototype._countBits=function(e){var t=e,r=0;return t>=4096&&(r+=13,t>>>=13),t>=64&&(r+=7,t>>>=7),t>=8&&(r+=4,t>>>=4),t>=2&&(r+=2,t>>>=2),r+t},n.prototype._zeroBits=function(e){if(0===e)return 26;var t=e,r=0;return 0==(8191&t)&&(r+=13,t>>>=13),0==(127&t)&&(r+=7,t>>>=7),0==(15&t)&&(r+=4,t>>>=4),0==(3&t)&&(r+=2,t>>>=2),0==(1&t)&&r++,r},n.prototype.bitLength=function(){var e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},n.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,t=0;t<this.length;t++){var r=this._zeroBits(this.words[t]);if(e+=r,26!==r)break}return e},n.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},n.prototype.toTwos=function(e){return 0!==this.negative?this.abs().inotn(e).iaddn(1):this.clone()},n.prototype.fromTwos=function(e){return this.testn(e-1)?this.notn(e).iaddn(1).ineg():this.clone()},n.prototype.isNeg=function(){return 0!==this.negative},n.prototype.neg=function(){return this.clone().ineg()},n.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},n.prototype.iuor=function(e){for(;this.length<e.length;)this.words[this.length++]=0;for(var t=0;t<e.length;t++)this.words[t]=this.words[t]|e.words[t];return this.strip()},n.prototype.ior=function(e){return r(0==(this.negative|e.negative)),this.iuor(e)},n.prototype.or=function(e){return this.length>e.length?this.clone().ior(e):e.clone().ior(this)},n.prototype.uor=function(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},n.prototype.iuand=function(e){var t;t=this.length>e.length?e:this;for(var r=0;r<t.length;r++)this.words[r]=this.words[r]&e.words[r];return this.length=t.length,this.strip()},n.prototype.iand=function(e){return r(0==(this.negative|e.negative)),this.iuand(e)},n.prototype.and=function(e){return this.length>e.length?this.clone().iand(e):e.clone().iand(this)},n.prototype.uand=function(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},n.prototype.iuxor=function(e){var t,r;this.length>e.length?(t=this,r=e):(t=e,r=this);for(var i=0;i<r.length;i++)this.words[i]=t.words[i]^r.words[i];if(this!==t)for(;i<t.length;i++)this.words[i]=t.words[i];return this.length=t.length,this.strip()},n.prototype.ixor=function(e){return r(0==(this.negative|e.negative)),this.iuxor(e)},n.prototype.xor=function(e){return this.length>e.length?this.clone().ixor(e):e.clone().ixor(this)},n.prototype.uxor=function(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},n.prototype.inotn=function(e){r("number"==typeof e&&e>=0);var t=0|Math.ceil(e/26),i=e%26;this._expand(t),i>0&&t--;for(var n=0;n<t;n++)this.words[n]=67108863&~this.words[n];return i>0&&(this.words[n]=~this.words[n]&67108863>>26-i),this.strip()},n.prototype.notn=function(e){return this.clone().inotn(e)},n.prototype.setn=function(e,t){r("number"==typeof e&&e>=0);var i=e/26|0,n=e%26;return this._expand(i+1),this.words[i]=t?this.words[i]|1<<n:this.words[i]&~(1<<n),this.strip()},n.prototype.iadd=function(e){var t,r,i;if(0!==this.negative&&0===e.negative)return this.negative=0,t=this.isub(e),this.negative^=1,this._normSign();if(0===this.negative&&0!==e.negative)return e.negative=0,t=this.isub(e),e.negative=1,t._normSign();this.length>e.length?(r=this,i=e):(r=e,i=this);for(var n=0,o=0;o<i.length;o++)t=(0|r.words[o])+(0|i.words[o])+n,this.words[o]=67108863&t,n=t>>>26;for(;0!==n&&o<r.length;o++)t=(0|r.words[o])+n,this.words[o]=67108863&t,n=t>>>26;if(this.length=r.length,0!==n)this.words[this.length]=n,this.length++;else if(r!==this)for(;o<r.length;o++)this.words[o]=r.words[o];return this},n.prototype.add=function(e){var t;return 0!==e.negative&&0===this.negative?(e.negative=0,t=this.sub(e),e.negative^=1,t):0===e.negative&&0!==this.negative?(this.negative=0,t=e.sub(this),this.negative=1,t):this.length>e.length?this.clone().iadd(e):e.clone().iadd(this)},n.prototype.isub=function(e){if(0!==e.negative){e.negative=0;var t=this.iadd(e);return e.negative=1,t._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var r,i,n=this.cmp(e);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(r=this,i=e):(r=e,i=this);for(var o=0,a=0;a<i.length;a++)o=(t=(0|r.words[a])-(0|i.words[a])+o)>>26,this.words[a]=67108863&t;for(;0!==o&&a<r.length;a++)o=(t=(0|r.words[a])+o)>>26,this.words[a]=67108863&t;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()},n.prototype.sub=function(e){return this.clone().isub(e)};var h=function(e,t,r){var i,n,o,a=e.words,s=t.words,u=r.words,c=0,l=0|a[0],f=8191&l,d=l>>>13,h=0|a[1],p=8191&h,m=h>>>13,b=0|a[2],v=8191&b,g=b>>>13,y=0|a[3],w=8191&y,_=y>>>13,k=0|a[4],E=8191&k,S=k>>>13,x=0|a[5],M=8191&x,A=x>>>13,T=0|a[6],O=8191&T,z=T>>>13,R=0|a[7],j=8191&R,P=R>>>13,I=0|a[8],L=8191&I,B=I>>>13,C=0|a[9],D=8191&C,N=C>>>13,q=0|s[0],U=8191&q,K=q>>>13,F=0|s[1],V=8191&F,H=F>>>13,W=0|s[2],Y=8191&W,G=W>>>13,Z=0|s[3],J=8191&Z,$=Z>>>13,X=0|s[4],Q=8191&X,ee=X>>>13,te=0|s[5],re=8191&te,ie=te>>>13,ne=0|s[6],oe=8191&ne,ae=ne>>>13,se=0|s[7],ue=8191&se,ce=se>>>13,le=0|s[8],fe=8191&le,de=le>>>13,he=0|s[9],pe=8191&he,me=he>>>13;r.negative=e.negative^t.negative,r.length=19;var be=(c+(i=Math.imul(f,U))|0)+((8191&(n=(n=Math.imul(f,K))+Math.imul(d,U)|0))<<13)|0;c=((o=Math.imul(d,K))+(n>>>13)|0)+(be>>>26)|0,be&=67108863,i=Math.imul(p,U),n=(n=Math.imul(p,K))+Math.imul(m,U)|0,o=Math.imul(m,K);var ve=(c+(i=i+Math.imul(f,V)|0)|0)+((8191&(n=(n=n+Math.imul(f,H)|0)+Math.imul(d,V)|0))<<13)|0;c=((o=o+Math.imul(d,H)|0)+(n>>>13)|0)+(ve>>>26)|0,ve&=67108863,i=Math.imul(v,U),n=(n=Math.imul(v,K))+Math.imul(g,U)|0,o=Math.imul(g,K),i=i+Math.imul(p,V)|0,n=(n=n+Math.imul(p,H)|0)+Math.imul(m,V)|0,o=o+Math.imul(m,H)|0;var ge=(c+(i=i+Math.imul(f,Y)|0)|0)+((8191&(n=(n=n+Math.imul(f,G)|0)+Math.imul(d,Y)|0))<<13)|0;c=((o=o+Math.imul(d,G)|0)+(n>>>13)|0)+(ge>>>26)|0,ge&=67108863,i=Math.imul(w,U),n=(n=Math.imul(w,K))+Math.imul(_,U)|0,o=Math.imul(_,K),i=i+Math.imul(v,V)|0,n=(n=n+Math.imul(v,H)|0)+Math.imul(g,V)|0,o=o+Math.imul(g,H)|0,i=i+Math.imul(p,Y)|0,n=(n=n+Math.imul(p,G)|0)+Math.imul(m,Y)|0,o=o+Math.imul(m,G)|0;var ye=(c+(i=i+Math.imul(f,J)|0)|0)+((8191&(n=(n=n+Math.imul(f,$)|0)+Math.imul(d,J)|0))<<13)|0;c=((o=o+Math.imul(d,$)|0)+(n>>>13)|0)+(ye>>>26)|0,ye&=67108863,i=Math.imul(E,U),n=(n=Math.imul(E,K))+Math.imul(S,U)|0,o=Math.imul(S,K),i=i+Math.imul(w,V)|0,n=(n=n+Math.imul(w,H)|0)+Math.imul(_,V)|0,o=o+Math.imul(_,H)|0,i=i+Math.imul(v,Y)|0,n=(n=n+Math.imul(v,G)|0)+Math.imul(g,Y)|0,o=o+Math.imul(g,G)|0,i=i+Math.imul(p,J)|0,n=(n=n+Math.imul(p,$)|0)+Math.imul(m,J)|0,o=o+Math.imul(m,$)|0;var we=(c+(i=i+Math.imul(f,Q)|0)|0)+((8191&(n=(n=n+Math.imul(f,ee)|0)+Math.imul(d,Q)|0))<<13)|0;c=((o=o+Math.imul(d,ee)|0)+(n>>>13)|0)+(we>>>26)|0,we&=67108863,i=Math.imul(M,U),n=(n=Math.imul(M,K))+Math.imul(A,U)|0,o=Math.imul(A,K),i=i+Math.imul(E,V)|0,n=(n=n+Math.imul(E,H)|0)+Math.imul(S,V)|0,o=o+Math.imul(S,H)|0,i=i+Math.imul(w,Y)|0,n=(n=n+Math.imul(w,G)|0)+Math.imul(_,Y)|0,o=o+Math.imul(_,G)|0,i=i+Math.imul(v,J)|0,n=(n=n+Math.imul(v,$)|0)+Math.imul(g,J)|0,o=o+Math.imul(g,$)|0,i=i+Math.imul(p,Q)|0,n=(n=n+Math.imul(p,ee)|0)+Math.imul(m,Q)|0,o=o+Math.imul(m,ee)|0;var _e=(c+(i=i+Math.imul(f,re)|0)|0)+((8191&(n=(n=n+Math.imul(f,ie)|0)+Math.imul(d,re)|0))<<13)|0;c=((o=o+Math.imul(d,ie)|0)+(n>>>13)|0)+(_e>>>26)|0,_e&=67108863,i=Math.imul(O,U),n=(n=Math.imul(O,K))+Math.imul(z,U)|0,o=Math.imul(z,K),i=i+Math.imul(M,V)|0,n=(n=n+Math.imul(M,H)|0)+Math.imul(A,V)|0,o=o+Math.imul(A,H)|0,i=i+Math.imul(E,Y)|0,n=(n=n+Math.imul(E,G)|0)+Math.imul(S,Y)|0,o=o+Math.imul(S,G)|0,i=i+Math.imul(w,J)|0,n=(n=n+Math.imul(w,$)|0)+Math.imul(_,J)|0,o=o+Math.imul(_,$)|0,i=i+Math.imul(v,Q)|0,n=(n=n+Math.imul(v,ee)|0)+Math.imul(g,Q)|0,o=o+Math.imul(g,ee)|0,i=i+Math.imul(p,re)|0,n=(n=n+Math.imul(p,ie)|0)+Math.imul(m,re)|0,o=o+Math.imul(m,ie)|0;var ke=(c+(i=i+Math.imul(f,oe)|0)|0)+((8191&(n=(n=n+Math.imul(f,ae)|0)+Math.imul(d,oe)|0))<<13)|0;c=((o=o+Math.imul(d,ae)|0)+(n>>>13)|0)+(ke>>>26)|0,ke&=67108863,i=Math.imul(j,U),n=(n=Math.imul(j,K))+Math.imul(P,U)|0,o=Math.imul(P,K),i=i+Math.imul(O,V)|0,n=(n=n+Math.imul(O,H)|0)+Math.imul(z,V)|0,o=o+Math.imul(z,H)|0,i=i+Math.imul(M,Y)|0,n=(n=n+Math.imul(M,G)|0)+Math.imul(A,Y)|0,o=o+Math.imul(A,G)|0,i=i+Math.imul(E,J)|0,n=(n=n+Math.imul(E,$)|0)+Math.imul(S,J)|0,o=o+Math.imul(S,$)|0,i=i+Math.imul(w,Q)|0,n=(n=n+Math.imul(w,ee)|0)+Math.imul(_,Q)|0,o=o+Math.imul(_,ee)|0,i=i+Math.imul(v,re)|0,n=(n=n+Math.imul(v,ie)|0)+Math.imul(g,re)|0,o=o+Math.imul(g,ie)|0,i=i+Math.imul(p,oe)|0,n=(n=n+Math.imul(p,ae)|0)+Math.imul(m,oe)|0,o=o+Math.imul(m,ae)|0;var Ee=(c+(i=i+Math.imul(f,ue)|0)|0)+((8191&(n=(n=n+Math.imul(f,ce)|0)+Math.imul(d,ue)|0))<<13)|0;c=((o=o+Math.imul(d,ce)|0)+(n>>>13)|0)+(Ee>>>26)|0,Ee&=67108863,i=Math.imul(L,U),n=(n=Math.imul(L,K))+Math.imul(B,U)|0,o=Math.imul(B,K),i=i+Math.imul(j,V)|0,n=(n=n+Math.imul(j,H)|0)+Math.imul(P,V)|0,o=o+Math.imul(P,H)|0,i=i+Math.imul(O,Y)|0,n=(n=n+Math.imul(O,G)|0)+Math.imul(z,Y)|0,o=o+Math.imul(z,G)|0,i=i+Math.imul(M,J)|0,n=(n=n+Math.imul(M,$)|0)+Math.imul(A,J)|0,o=o+Math.imul(A,$)|0,i=i+Math.imul(E,Q)|0,n=(n=n+Math.imul(E,ee)|0)+Math.imul(S,Q)|0,o=o+Math.imul(S,ee)|0,i=i+Math.imul(w,re)|0,n=(n=n+Math.imul(w,ie)|0)+Math.imul(_,re)|0,o=o+Math.imul(_,ie)|0,i=i+Math.imul(v,oe)|0,n=(n=n+Math.imul(v,ae)|0)+Math.imul(g,oe)|0,o=o+Math.imul(g,ae)|0,i=i+Math.imul(p,ue)|0,n=(n=n+Math.imul(p,ce)|0)+Math.imul(m,ue)|0,o=o+Math.imul(m,ce)|0;var Se=(c+(i=i+Math.imul(f,fe)|0)|0)+((8191&(n=(n=n+Math.imul(f,de)|0)+Math.imul(d,fe)|0))<<13)|0;c=((o=o+Math.imul(d,de)|0)+(n>>>13)|0)+(Se>>>26)|0,Se&=67108863,i=Math.imul(D,U),n=(n=Math.imul(D,K))+Math.imul(N,U)|0,o=Math.imul(N,K),i=i+Math.imul(L,V)|0,n=(n=n+Math.imul(L,H)|0)+Math.imul(B,V)|0,o=o+Math.imul(B,H)|0,i=i+Math.imul(j,Y)|0,n=(n=n+Math.imul(j,G)|0)+Math.imul(P,Y)|0,o=o+Math.imul(P,G)|0,i=i+Math.imul(O,J)|0,n=(n=n+Math.imul(O,$)|0)+Math.imul(z,J)|0,o=o+Math.imul(z,$)|0,i=i+Math.imul(M,Q)|0,n=(n=n+Math.imul(M,ee)|0)+Math.imul(A,Q)|0,o=o+Math.imul(A,ee)|0,i=i+Math.imul(E,re)|0,n=(n=n+Math.imul(E,ie)|0)+Math.imul(S,re)|0,o=o+Math.imul(S,ie)|0,i=i+Math.imul(w,oe)|0,n=(n=n+Math.imul(w,ae)|0)+Math.imul(_,oe)|0,o=o+Math.imul(_,ae)|0,i=i+Math.imul(v,ue)|0,n=(n=n+Math.imul(v,ce)|0)+Math.imul(g,ue)|0,o=o+Math.imul(g,ce)|0,i=i+Math.imul(p,fe)|0,n=(n=n+Math.imul(p,de)|0)+Math.imul(m,fe)|0,o=o+Math.imul(m,de)|0;var xe=(c+(i=i+Math.imul(f,pe)|0)|0)+((8191&(n=(n=n+Math.imul(f,me)|0)+Math.imul(d,pe)|0))<<13)|0;c=((o=o+Math.imul(d,me)|0)+(n>>>13)|0)+(xe>>>26)|0,xe&=67108863,i=Math.imul(D,V),n=(n=Math.imul(D,H))+Math.imul(N,V)|0,o=Math.imul(N,H),i=i+Math.imul(L,Y)|0,n=(n=n+Math.imul(L,G)|0)+Math.imul(B,Y)|0,o=o+Math.imul(B,G)|0,i=i+Math.imul(j,J)|0,n=(n=n+Math.imu