@burstjs/util
Advanced tools
Comparing version 0.5.0-beta.9 to 0.5.0-beta.10
@@ -17,2 +17,4 @@ # Change Log | ||
- `convertBase64StringToString` | ||
- Added Decimal to Hex conversion (Two's Complement support) | ||
- `convertDecStringToHexString` | ||
- New Symbols for BURST (Ƀ) and Planck (ƀ) | ||
@@ -19,0 +21,0 @@ - `BurstSymbol` |
@@ -1,2 +0,2 @@ | ||
var b$util=function(exports){"use strict";var GenesisBlockTime=Date.UTC(2014,7,11,2,0,0,0)/1e3,initialCodeword=[1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],gexp=[1,2,4,8,16,5,10,20,13,26,17,7,14,28,29,31,27,19,3,6,12,24,21,15,30,25,23,11,22,9,18,1],glog=[0,0,1,18,2,5,19,11,3,29,6,27,20,8,12,23,4,10,30,17,7,22,28,26,21,25,9,16,13,14,24,15],cwmap=[3,2,1,0,7,6,5,4,13,14,15,16,12,8,9,10,11],alphabet="23456789ABCDEFGHJKLMNPQRSTUVWXYZ".split(""),base32Length=13,gmult=function(e,r){if(0===e||0===r)return 0;var t=(glog[e]+glog[r])%31;return gexp[t]},isValid=function(e){0===e.indexOf("BURST-")&&(e=e.substr(6));for(var r=initialCodeword.slice(),t=0,n=0;n<e.length;n++){var o=alphabet.indexOf(e.charAt(n));if(!(o<=-1||o>alphabet.length)){if(t>16)return!1;r[cwmap[t]]=o,t++}}if(17!==t)return!1;for(var i=0,a=1;a<5;a++){for(var u=0,c=0;c<31;c++)if(!(c>12&&c<27)){var s=c;c>26&&(s-=14),u^=gmult(r[s],gexp[a*c%31])}i|=u}return 0===i},isBurstAddress=function(e){return/^BURST\-[A-Z0-9]{4}\-[A-Z0-9]{4}\-[A-Z0-9]{4}\-[A-Z0-9]{5}/i.test(e)&&isValid(e)},convertAddressToNumericId=function(e){if(null!=e&&0!==e.trim().length&&0===e.indexOf("BURST-")){e=e.substr(6);for(var r=initialCodeword.slice(),t=0,n=0;n<e.length;n++){var o=alphabet.indexOf(e.charAt(n));if(!(o<=-1||o>alphabet.length)){if(t>16)return;r[cwmap[t]]=o,t++}}if(isValid(e)){for(var i=base32Length,a=[],u=0;u<i;u++)a[u]=r[i-u-1];var c,s="",l=0;do{c=0,l=0;for(var f=0;f<i;f++)(l=32*l+a[f])>=10?(a[c]=Math.floor(l/10),l%=10,c+=1):c>0&&(a[c]=0,c+=1);i=c,s+=l}while(i>0);return s.split("").reverse().join("")}}},convertBurstTimeToEpochTime=function(e){return 1e3*(GenesisBlockTime+e)},convertBurstTimeToDate=function(e){return new Date(convertBurstTimeToEpochTime(e))},convertByteArrayToHexString=function(e){for(var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],t=[],n=0;n<e.length;n++)t.push((e[n]>>>4).toString(16)),t.push((15&e[n]).toString(16));return r?t.join("").toUpperCase():t.join("")},convertByteArrayToString=function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;if(0===t)return"";var n=e;if(0!==r){var o=null===t?e.length-r:t;checkBytesToIntInput(n,o,r),n=e.slice(r,r+o)}return decodeURIComponent(escape(String.fromCharCode.apply(null,Array.from(n))))};function checkBytesToIntInput(e,r){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;if(t<0)throw new Error("Start index should not be negative");if(e.length<t+r)throw new Error("Need at least "+r+" bytes to convert to an integer");return t}var convertDateToBurstTime=function(e){return Math.round(e.getTime()/1e3)-GenesisBlockTime},convertHexEndianess=function(e){for(var r="",t=e,n=t.length-1;n>=0;n-=2)r+=t[n-1]+t[n];return r},convertHexStringToByteArray=function(e){if(e.length%2)throw new Error("Invalid Hex String: ".concat(e));for(var r=new Uint8Array(e.length/2),t=0;t<e.length;t+=2){var n=parseInt(e.substr(t,2),16);if(Number.isNaN(n))throw new Error("Invalid Hex String: ".concat(e));r[t/2]=n}return r},convertHexStringToDecString=function(e){var r,t,n,o=[0];for(r=0;r<e.length;r+=1){for(n=parseInt(e.charAt(r),16),t=0;t<o.length;t+=1)o[t]=16*o[t]+n,n=o[t]/10|0,o[t]%=10;for(;n>0;)o.push(n%10),n=n/10|0}return o.reverse().join("")},convertHexStringToString=function(e){return convertByteArrayToString(convertHexStringToByteArray(e))},convertNQTStringToNumber=function(e){if(null==e||""===e)throw new Error("Invalid argument");return parseFloat(e)/1e8},convertNumberToNQTString=function(e){if(null==e)throw new Error("Invalid argument");return parseFloat(e.toString()).toFixed(8).replace(".","")},convertNumericIdToAddress=function(e){if(null!=e&&0!==e.trim().length){for(var r=[],t=initialCodeword.slice(),n=0,o=e.length,i=0;i<o;i++)r[i]=e.charCodeAt(i)-"0".charCodeAt(0);var a=0,u=0;do{a=0,u=0;for(var c=0;c<o;c++)(a=10*a+r[c])>=32?(r[u]=a>>5,a&=31,u++):u>0&&(r[u]=0,u++);o=u,t[n]=a,n++}while(o>0);for(var s=[0,0,0,0],l=base32Length-1;l>=0;l--){var f=t[l]^s[3];s[3]=s[2]^gmult(30,f),s[2]=s[1]^gmult(6,f),s[1]=s[0]^gmult(9,f),s[0]=gmult(17,f)}t[13]=s[0],t[14]=s[1],t[15]=s[2],t[16]=s[3];for(var h="BURST-",g=0;g<17;g++)h+=alphabet[t[cwmap[g]]],3==(3&g)&&g<13&&(h+="-");return h}},convertStringToByteArray=function(e){for(var r=unescape(encodeURIComponent(e)),t=new Uint8Array(r.length),n=0;n<r.length;++n)t[n]=r.charCodeAt(n);return t},convertStringToHexString=function(e){return convertByteArrayToHexString(convertStringToByteArray(e))},EncoderFormat;EncoderFormat=exports.EncoderFormat||(exports.EncoderFormat={}),EncoderFormat[EncoderFormat.Text=0]="Text",EncoderFormat[EncoderFormat.Hexadecimal=1]="Hexadecimal",EncoderFormat[EncoderFormat.Base64=2]="Base64";var commonjsGlobal="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function createCommonjsModule(e,r){return e(r={exports:{}},r.exports),r.exports}var base64=createCommonjsModule(function(module,exports){var global,factory;global="undefined"!=typeof self?self:"undefined"!=typeof window?window:commonjsGlobal,factory=function(global){global=global||{};var _Base64=global.Base64,version="2.5.1",buffer;if(module.exports)try{buffer=eval("require('buffer').Buffer")}catch(e){buffer=void 0}var b64chars="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",b64tab=function(e){for(var r={},t=0,n=e.length;t<n;t++)r[e.charAt(t)]=t;return r}(b64chars),fromCharCode=String.fromCharCode,cb_utob=function(e){if(e.length<2)return(r=e.charCodeAt(0))<128?e:r<2048?fromCharCode(192|r>>>6)+fromCharCode(128|63&r):fromCharCode(224|r>>>12&15)+fromCharCode(128|r>>>6&63)+fromCharCode(128|63&r);var r=65536+1024*(e.charCodeAt(0)-55296)+(e.charCodeAt(1)-56320);return fromCharCode(240|r>>>18&7)+fromCharCode(128|r>>>12&63)+fromCharCode(128|r>>>6&63)+fromCharCode(128|63&r)},re_utob=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,utob=function(e){return e.replace(re_utob,cb_utob)},cb_encode=function(e){var r=[0,2,1][e.length%3],t=e.charCodeAt(0)<<16|(e.length>1?e.charCodeAt(1):0)<<8|(e.length>2?e.charCodeAt(2):0);return[b64chars.charAt(t>>>18),b64chars.charAt(t>>>12&63),r>=2?"=":b64chars.charAt(t>>>6&63),r>=1?"=":b64chars.charAt(63&t)].join("")},btoa=global.btoa?function(e){return global.btoa(e)}:function(e){return e.replace(/[\s\S]{1,3}/g,cb_encode)},_encode=buffer?buffer.from&&Uint8Array&&buffer.from!==Uint8Array.from?function(e){return(e.constructor===buffer.constructor?e:buffer.from(e)).toString("base64")}:function(e){return(e.constructor===buffer.constructor?e:new buffer(e)).toString("base64")}:function(e){return btoa(utob(e))},encode=function(e,r){return r?_encode(String(e)).replace(/[+\/]/g,function(e){return"+"==e?"-":"_"}).replace(/=/g,""):_encode(String(e))},encodeURI=function(e){return encode(e,!0)},re_btou=new RegExp(["[À-ß][-¿]","[à-ï][-¿]{2}","[ð-÷][-¿]{3}"].join("|"),"g"),cb_btou=function(e){switch(e.length){case 4:var r=((7&e.charCodeAt(0))<<18|(63&e.charCodeAt(1))<<12|(63&e.charCodeAt(2))<<6|63&e.charCodeAt(3))-65536;return fromCharCode(55296+(r>>>10))+fromCharCode(56320+(1023&r));case 3:return fromCharCode((15&e.charCodeAt(0))<<12|(63&e.charCodeAt(1))<<6|63&e.charCodeAt(2));default:return fromCharCode((31&e.charCodeAt(0))<<6|63&e.charCodeAt(1))}},btou=function(e){return e.replace(re_btou,cb_btou)},cb_decode=function(e){var r=e.length,t=r%4,n=(r>0?b64tab[e.charAt(0)]<<18:0)|(r>1?b64tab[e.charAt(1)]<<12:0)|(r>2?b64tab[e.charAt(2)]<<6:0)|(r>3?b64tab[e.charAt(3)]:0),o=[fromCharCode(n>>>16),fromCharCode(n>>>8&255),fromCharCode(255&n)];return o.length-=[0,0,2,1][t],o.join("")},_atob=global.atob?function(e){return global.atob(e)}:function(e){return e.replace(/\S{1,4}/g,cb_decode)},atob=function(e){return _atob(String(e).replace(/[^A-Za-z0-9\+\/]/g,""))},_decode=buffer?buffer.from&&Uint8Array&&buffer.from!==Uint8Array.from?function(e){return(e.constructor===buffer.constructor?e:buffer.from(e,"base64")).toString()}:function(e){return(e.constructor===buffer.constructor?e:new buffer(e,"base64")).toString()}:function(e){return btou(_atob(e))},decode=function(e){return _decode(String(e).replace(/[-_]/g,function(e){return"-"==e?"+":"/"}).replace(/[^A-Za-z0-9\+\/]/g,""))},noConflict=function(){var e=global.Base64;return global.Base64=_Base64,e};if(global.Base64={VERSION:version,atob:atob,btoa:btoa,fromBase64:decode,toBase64:encode,utob:utob,encode:encode,encodeURI:encodeURI,btou:btou,decode:decode,noConflict:noConflict,__buffer__:buffer},"function"==typeof Object.defineProperty){var noEnum=function(e){return{value:e,enumerable:!1,writable:!0,configurable:!0}};global.Base64.extendString=function(){Object.defineProperty(String.prototype,"fromBase64",noEnum(function(){return decode(this)})),Object.defineProperty(String.prototype,"toBase64",noEnum(function(e){return encode(this,e)})),Object.defineProperty(String.prototype,"toBase64URI",noEnum(function(){return encode(this,!0)}))}}return global.Meteor&&(Base64=global.Base64),module.exports&&(module.exports.Base64=global.Base64),{Base64:global.Base64}},module.exports=factory(global)}),base64_1=base64.Base64,convertStringToBase64String=function(e){return!(arguments.length>1&&void 0!==arguments[1])||arguments[1]?base64_1.encodeURI(e):base64_1.encode(e)};function encodePayload(e,r){var t=e;switch("string"!=typeof e&&(t=JSON.stringify(e)),r){case exports.EncoderFormat.Hexadecimal:return convertStringToHexString(t);case exports.EncoderFormat.Base64:return convertStringToBase64String(t);case exports.EncoderFormat.Text:default:return t}}var createDeeplink=function(e){var r=e.encoderFormat,t=void 0===r?exports.EncoderFormat.Base64:r,n=e.domain,o=e.action,i=e.payload,a="burst.".concat(n,"://v1");return o&&(a+="?action=".concat(o)),i&&(a+="&payload=".concat(encodePayload(i,t))),a},MandatoryPattern=/^burst.(.+):\/\/(v.+?)\??/i,parseDeeplink=function(e){var r=function(){throw new Error("Invalid deeplink: "+e)},t=function(e,t){return e.startsWith(t+"=")||r(),e.split("=")[1]},n=e.match(MandatoryPattern);n&&3===n.length||r();var o={domain:n[1],version:n[2],action:void 0,payload:void 0,decodedPayload:void 0};try{var i=e.indexOf("?");if(-1!==i){var a=e.substring(i+1).split("&");a.length>=1&&(a.length>2&&r(),o.action=t(a[0],"action"),2===a.length&&(o.payload=t(a[1],"payload")))}}catch(e){r()}return o};function sumNQTStringToNumber(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++)r[t]=arguments[t];return r.reduce(function(e,r){return e+convertNQTStringToNumber(r)},0)}var BurstSymbol="Ƀ",BurstPlanckSymbol="ƀ",FeeQuantPlanck=735e3,OneBurstPlanck=1e8;function _classCallCheck(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function _createClass(e,r,t){return r&&_defineProperties(e.prototype,r),t&&_defineProperties(e,t),e}var BurstTime=function(){function e(r){_classCallCheck(this,e),this._burstTimestamp=r}return _createClass(e,[{key:"getBurstTimestamp",value:function(){return this._burstTimestamp}},{key:"setBurstTimestamp",value:function(e){this._burstTimestamp=e}},{key:"getEpoch",value:function(){return 1e3*(GenesisBlockTime+this._burstTimestamp)}},{key:"getDate",value:function(){return new Date(this.getEpoch())}},{key:"setDate",value:function(e){this._burstTimestamp=Math.round(e.getTime()/1e3)-GenesisBlockTime}},{key:"equals",value:function(e){return this._burstTimestamp===e._burstTimestamp}},{key:"before",value:function(e){return this._burstTimestamp<e._burstTimestamp}},{key:"after",value:function(e){return this._burstTimestamp>e._burstTimestamp}}],[{key:"fromBurstTimestamp",value:function(r){return new e(r)}},{key:"fromDate",value:function(r){var t=new e(0);return t.setDate(r),t}}]),e}(),isNumeric=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,mathceil=Math.ceil,mathfloor=Math.floor,bignumberError="[BigNumber Error] ",tooManyDigits=bignumberError+"Number primitive has more than 15 significant digits: ",BASE=1e14,LOG_BASE=14,MAX_SAFE_INTEGER=9007199254740991,POWS_TEN=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],SQRT_BASE=1e7,MAX=1e9;function clone(e){var r,t,n,o,i,a,u,c,s,l=y.prototype={constructor:y,toString:null,valueOf:null},f=new y(1),h=20,g=4,d=-7,p=21,m=-1e7,b=1e7,v=!1,S=1,A=0,B={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},E="0123456789abcdefghijklmnopqrstuvwxyz";function y(e,r){var o,i,a,u,c,s,l,f,d=this;if(!(d instanceof y))return new y(e,r);if(null==r){if(e&&!0===e._isBigNumber)return d.s=e.s,void(!e.c||e.e>b?d.c=d.e=null:e.e<m?d.c=[d.e=0]:(d.e=e.e,d.c=e.c.slice()));if((s="number"==typeof e)&&0*e==0){if(d.s=1/e<0?(e=-e,-1):1,e===~~e){for(u=0,c=e;c>=10;c/=10,u++);return void(u>b?d.c=d.e=null:(d.e=u,d.c=[e]))}f=String(e)}else{if(!isNumeric.test(f=String(e)))return n(d,f,s);d.s=45==f.charCodeAt(0)?(f=f.slice(1),-1):1}(u=f.indexOf("."))>-1&&(f=f.replace(".","")),(c=f.search(/e/i))>0?(u<0&&(u=c),u+=+f.slice(c+1),f=f.substring(0,c)):u<0&&(u=f.length)}else{if(intCheck(r,2,E.length,"Base"),10==r)return C(d=new y(e),h+d.e+1,g);if(f=String(e),s="number"==typeof e){if(0*e!=0)return n(d,f,s,r);if(d.s=1/e<0?(f=f.slice(1),-1):1,y.DEBUG&&f.replace(/^0\.0*|\./,"").length>15)throw Error(tooManyDigits+e)}else d.s=45===f.charCodeAt(0)?(f=f.slice(1),-1):1;for(o=E.slice(0,r),u=c=0,l=f.length;c<l;c++)if(o.indexOf(i=f.charAt(c))<0){if("."==i){if(c>u){u=l;continue}}else if(!a&&(f==f.toUpperCase()&&(f=f.toLowerCase())||f==f.toLowerCase()&&(f=f.toUpperCase()))){a=!0,c=-1,u=0;continue}return n(d,String(e),s,r)}s=!1,(u=(f=t(f,r,10,d.s)).indexOf("."))>-1?f=f.replace(".",""):u=f.length}for(c=0;48===f.charCodeAt(c);c++);for(l=f.length;48===f.charCodeAt(--l););if(f=f.slice(c,++l)){if(l-=c,s&&y.DEBUG&&l>15&&(e>MAX_SAFE_INTEGER||e!==mathfloor(e)))throw Error(tooManyDigits+d.s*e);if((u=u-c-1)>b)d.c=d.e=null;else if(u<m)d.c=[d.e=0];else{if(d.e=u,d.c=[],c=(u+1)%LOG_BASE,u<0&&(c+=LOG_BASE),c<l){for(c&&d.c.push(+f.slice(0,c)),l-=LOG_BASE;c<l;)d.c.push(+f.slice(c,c+=LOG_BASE));c=LOG_BASE-(f=f.slice(c)).length}else c-=l;for(;c--;f+="0");d.c.push(+f)}}else d.c=[d.e=0]}function T(e,r,t,n){var o,i,a,u,c;if(null==t?t=g:intCheck(t,0,8),!e.c)return e.toString();if(o=e.c[0],a=e.e,null==r)c=coeffToString(e.c),c=1==n||2==n&&(a<=d||a>=p)?toExponential(c,a):toFixedPoint(c,a,"0");else if(i=(e=C(new y(e),r,t)).e,u=(c=coeffToString(e.c)).length,1==n||2==n&&(r<=i||i<=d)){for(;u<r;c+="0",u++);c=toExponential(c,i)}else if(r-=a,c=toFixedPoint(c,i,"0"),i+1>u){if(--r>0)for(c+=".";r--;c+="0");}else if((r+=i-u)>0)for(i+1==u&&(c+=".");r--;c+="0");return e.s<0&&o?"-"+c:c}function _(e,r){for(var t,n=1,o=new y(e[0]);n<e.length;n++){if(!(t=new y(e[n])).s){o=t;break}r.call(o,t)&&(o=t)}return o}function w(e,r,t){for(var n=1,o=r.length;!r[--o];r.pop());for(o=r[0];o>=10;o/=10,n++);return(t=n+t*LOG_BASE-1)>b?e.c=e.e=null:t<m?e.c=[e.e=0]:(e.e=t,e.c=r),e}function C(e,r,t,n){var o,i,a,u,c,s,l,f=e.c,h=POWS_TEN;if(f){e:{for(o=1,u=f[0];u>=10;u/=10,o++);if((i=r-o)<0)i+=LOG_BASE,a=r,l=(c=f[s=0])/h[o-a-1]%10|0;else if((s=mathceil((i+1)/LOG_BASE))>=f.length){if(!n)break e;for(;f.length<=s;f.push(0));c=l=0,o=1,a=(i%=LOG_BASE)-LOG_BASE+1}else{for(c=u=f[s],o=1;u>=10;u/=10,o++);l=(a=(i%=LOG_BASE)-LOG_BASE+o)<0?0:c/h[o-a-1]%10|0}if(n=n||r<0||null!=f[s+1]||(a<0?c:c%h[o-a-1]),n=t<4?(l||n)&&(0==t||t==(e.s<0?3:2)):l>5||5==l&&(4==t||n||6==t&&(i>0?a>0?c/h[o-a]:0:f[s-1])%10&1||t==(e.s<0?8:7)),r<1||!f[0])return f.length=0,n?(r-=e.e+1,f[0]=h[(LOG_BASE-r%LOG_BASE)%LOG_BASE],e.e=-r||0):f[0]=e.e=0,e;if(0==i?(f.length=s,u=1,s--):(f.length=s+1,u=h[LOG_BASE-i],f[s]=a>0?mathfloor(c/h[o-a]%h[a])*u:0),n)for(;;){if(0==s){for(i=1,a=f[0];a>=10;a/=10,i++);for(a=f[0]+=u,u=1;a>=10;a/=10,u++);i!=u&&(e.e++,f[0]==BASE&&(f[0]=1));break}if(f[s]+=u,f[s]!=BASE)break;f[s--]=0,u=1}for(i=f.length;0===f[--i];f.pop());}e.e>b?e.c=e.e=null:e.e<m&&(e.c=[e.e=0])}return e}function O(e){var r,t=e.e;return null===t?e.toString():(r=coeffToString(e.c),r=t<=d||t>=p?toExponential(r,t):toFixedPoint(r,t,"0"),e.s<0?"-"+r:r)}return y.clone=clone,y.ROUND_UP=0,y.ROUND_DOWN=1,y.ROUND_CEIL=2,y.ROUND_FLOOR=3,y.ROUND_HALF_UP=4,y.ROUND_HALF_DOWN=5,y.ROUND_HALF_EVEN=6,y.ROUND_HALF_CEIL=7,y.ROUND_HALF_FLOOR=8,y.EUCLID=9,y.config=y.set=function(e){var r,t;if(null!=e){if("object"!=typeof e)throw Error(bignumberError+"Object expected: "+e);if(e.hasOwnProperty(r="DECIMAL_PLACES")&&(intCheck(t=e[r],0,MAX,r),h=t),e.hasOwnProperty(r="ROUNDING_MODE")&&(intCheck(t=e[r],0,8,r),g=t),e.hasOwnProperty(r="EXPONENTIAL_AT")&&((t=e[r])&&t.pop?(intCheck(t[0],-MAX,0,r),intCheck(t[1],0,MAX,r),d=t[0],p=t[1]):(intCheck(t,-MAX,MAX,r),d=-(p=t<0?-t:t))),e.hasOwnProperty(r="RANGE"))if((t=e[r])&&t.pop)intCheck(t[0],-MAX,-1,r),intCheck(t[1],1,MAX,r),m=t[0],b=t[1];else{if(intCheck(t,-MAX,MAX,r),!t)throw Error(bignumberError+r+" cannot be zero: "+t);m=-(b=t<0?-t:t)}if(e.hasOwnProperty(r="CRYPTO")){if((t=e[r])!==!!t)throw Error(bignumberError+r+" not true or false: "+t);if(t){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw v=!t,Error(bignumberError+"crypto unavailable");v=t}else v=t}if(e.hasOwnProperty(r="MODULO_MODE")&&(intCheck(t=e[r],0,9,r),S=t),e.hasOwnProperty(r="POW_PRECISION")&&(intCheck(t=e[r],0,MAX,r),A=t),e.hasOwnProperty(r="FORMAT")){if("object"!=typeof(t=e[r]))throw Error(bignumberError+r+" not an object: "+t);B=t}if(e.hasOwnProperty(r="ALPHABET")){if("string"!=typeof(t=e[r])||/^.$|[+-.\s]|(.).*\1/.test(t))throw Error(bignumberError+r+" invalid: "+t);E=t}}return{DECIMAL_PLACES:h,ROUNDING_MODE:g,EXPONENTIAL_AT:[d,p],RANGE:[m,b],CRYPTO:v,MODULO_MODE:S,POW_PRECISION:A,FORMAT:B,ALPHABET:E}},y.isBigNumber=function(e){if(!e||!0!==e._isBigNumber)return!1;if(!y.DEBUG)return!0;var r,t,n=e.c,o=e.e,i=e.s;e:if("[object Array]"=={}.toString.call(n)){if((1===i||-1===i)&&o>=-MAX&&o<=MAX&&o===mathfloor(o)){if(0===n[0]){if(0===o&&1===n.length)return!0;break e}if((r=(o+1)%LOG_BASE)<1&&(r+=LOG_BASE),String(n[0]).length==r){for(r=0;r<n.length;r++)if((t=n[r])<0||t>=BASE||t!==mathfloor(t))break e;if(0!==t)return!0}}}else if(null===n&&null===o&&(null===i||1===i||-1===i))return!0;throw Error(bignumberError+"Invalid BigNumber: "+e)},y.maximum=y.max=function(){return _(arguments,l.lt)},y.minimum=y.min=function(){return _(arguments,l.gt)},y.random=(o=9007199254740992*Math.random()&2097151?function(){return mathfloor(9007199254740992*Math.random())}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)},function(e){var r,t,n,i,a,u=0,c=[],s=new y(f);if(null==e?e=h:intCheck(e,0,MAX),i=mathceil(e/LOG_BASE),v)if(crypto.getRandomValues){for(r=crypto.getRandomValues(new Uint32Array(i*=2));u<i;)(a=131072*r[u]+(r[u+1]>>>11))>=9e15?(t=crypto.getRandomValues(new Uint32Array(2)),r[u]=t[0],r[u+1]=t[1]):(c.push(a%1e14),u+=2);u=i/2}else{if(!crypto.randomBytes)throw v=!1,Error(bignumberError+"crypto unavailable");for(r=crypto.randomBytes(i*=7);u<i;)(a=281474976710656*(31&r[u])+1099511627776*r[u+1]+4294967296*r[u+2]+16777216*r[u+3]+(r[u+4]<<16)+(r[u+5]<<8)+r[u+6])>=9e15?crypto.randomBytes(7).copy(r,u):(c.push(a%1e14),u+=7);u=i/7}if(!v)for(;u<i;)(a=o())<9e15&&(c[u++]=a%1e14);for(i=c[--u],e%=LOG_BASE,i&&e&&(a=POWS_TEN[LOG_BASE-e],c[u]=mathfloor(i/a)*a);0===c[u];c.pop(),u--);if(u<0)c=[n=0];else{for(n=-1;0===c[0];c.splice(0,1),n-=LOG_BASE);for(u=1,a=c[0];a>=10;a/=10,u++);u<LOG_BASE&&(n-=LOG_BASE-u)}return s.e=n,s.c=c,s}),y.sum=function(){for(var e=1,r=arguments,t=new y(r[0]);e<r.length;)t=t.plus(r[e++]);return t},t=function(){function e(e,r,t,n){for(var o,i,a=[0],u=0,c=e.length;u<c;){for(i=a.length;i--;a[i]*=r);for(a[0]+=n.indexOf(e.charAt(u++)),o=0;o<a.length;o++)a[o]>t-1&&(null==a[o+1]&&(a[o+1]=0),a[o+1]+=a[o]/t|0,a[o]%=t)}return a.reverse()}return function(t,n,o,i,a){var u,c,s,l,f,d,p,m,b=t.indexOf("."),v=h,S=g;for(b>=0&&(l=A,A=0,t=t.replace(".",""),d=(m=new y(n)).pow(t.length-b),A=l,m.c=e(toFixedPoint(coeffToString(d.c),d.e,"0"),10,o,"0123456789"),m.e=m.c.length),s=l=(p=e(t,n,o,a?(u=E,"0123456789"):(u="0123456789",E))).length;0==p[--l];p.pop());if(!p[0])return u.charAt(0);if(b<0?--s:(d.c=p,d.e=s,d.s=i,p=(d=r(d,m,v,S,o)).c,f=d.r,s=d.e),b=p[c=s+v+1],l=o/2,f=f||c<0||null!=p[c+1],f=S<4?(null!=b||f)&&(0==S||S==(d.s<0?3:2)):b>l||b==l&&(4==S||f||6==S&&1&p[c-1]||S==(d.s<0?8:7)),c<1||!p[0])t=f?toFixedPoint(u.charAt(1),-v,u.charAt(0)):u.charAt(0);else{if(p.length=c,f)for(--o;++p[--c]>o;)p[c]=0,c||(++s,p=[1].concat(p));for(l=p.length;!p[--l];);for(b=0,t="";b<=l;t+=u.charAt(p[b++]));t=toFixedPoint(t,s,u.charAt(0))}return t}}(),r=function(){function e(e,r,t){var n,o,i,a,u=0,c=e.length,s=r%SQRT_BASE,l=r/SQRT_BASE|0;for(e=e.slice();c--;)u=((o=s*(i=e[c]%SQRT_BASE)+(n=l*i+(a=e[c]/SQRT_BASE|0)*s)%SQRT_BASE*SQRT_BASE+u)/t|0)+(n/SQRT_BASE|0)+l*a,e[c]=o%t;return u&&(e=[u].concat(e)),e}function r(e,r,t,n){var o,i;if(t!=n)i=t>n?1:-1;else for(o=i=0;o<t;o++)if(e[o]!=r[o]){i=e[o]>r[o]?1:-1;break}return i}function t(e,r,t,n){for(var o=0;t--;)e[t]-=o,o=e[t]<r[t]?1:0,e[t]=o*n+e[t]-r[t];for(;!e[0]&&e.length>1;e.splice(0,1));}return function(n,o,i,a,u){var c,s,l,f,h,g,d,p,m,b,v,S,A,B,E,T,_,w=n.s==o.s?1:-1,O=n.c,x=o.c;if(!(O&&O[0]&&x&&x[0]))return new y(n.s&&o.s&&(O?!x||O[0]!=x[0]:x)?O&&0==O[0]||!x?0*w:w/0:NaN);for(m=(p=new y(w)).c=[],w=i+(s=n.e-o.e)+1,u||(u=BASE,s=bitFloor(n.e/LOG_BASE)-bitFloor(o.e/LOG_BASE),w=w/LOG_BASE|0),l=0;x[l]==(O[l]||0);l++);if(x[l]>(O[l]||0)&&s--,w<0)m.push(1),f=!0;else{for(B=O.length,T=x.length,l=0,w+=2,(h=mathfloor(u/(x[0]+1)))>1&&(x=e(x,h,u),O=e(O,h,u),T=x.length,B=O.length),A=T,v=(b=O.slice(0,T)).length;v<T;b[v++]=0);_=x.slice(),_=[0].concat(_),E=x[0],x[1]>=u/2&&E++;do{if(h=0,(c=r(x,b,T,v))<0){if(S=b[0],T!=v&&(S=S*u+(b[1]||0)),(h=mathfloor(S/E))>1)for(h>=u&&(h=u-1),d=(g=e(x,h,u)).length,v=b.length;1==r(g,b,d,v);)h--,t(g,T<d?_:x,d,u),d=g.length,c=1;else 0==h&&(c=h=1),d=(g=x.slice()).length;if(d<v&&(g=[0].concat(g)),t(b,g,v,u),v=b.length,-1==c)for(;r(x,b,T,v)<1;)h++,t(b,T<v?_:x,v,u),v=b.length}else 0===c&&(h++,b=[0]);m[l++]=h,b[0]?b[v++]=O[A]||0:(b=[O[A]],v=1)}while((A++<B||null!=b[0])&&w--);f=null!=b[0],m[0]||m.splice(0,1)}if(u==BASE){for(l=1,w=m[0];w>=10;w/=10,l++);C(p,i+(p.e=l+s*LOG_BASE-1)+1,a,f)}else p.e=s,p.r=+f;return p}}(),i=/^(-?)0([xbo])(?=\w[\w.]*$)/i,a=/^([^.]+)\.$/,u=/^\.([^.]+)$/,c=/^-?(Infinity|NaN)$/,s=/^\s*\+(?=[\w.])|^\s+|\s+$/g,n=function(e,r,t,n){var o,l=t?r:r.replace(s,"");if(c.test(l))e.s=isNaN(l)?null:l<0?-1:1;else{if(!t&&(l=l.replace(i,function(e,r,t){return o="x"==(t=t.toLowerCase())?16:"b"==t?2:8,n&&n!=o?e:r}),n&&(o=n,l=l.replace(a,"$1").replace(u,"0.$1")),r!=l))return new y(l,o);if(y.DEBUG)throw Error(bignumberError+"Not a"+(n?" base "+n:"")+" number: "+r);e.s=null}e.c=e.e=null},l.absoluteValue=l.abs=function(){var e=new y(this);return e.s<0&&(e.s=1),e},l.comparedTo=function(e,r){return compare(this,new y(e,r))},l.decimalPlaces=l.dp=function(e,r){var t,n,o,i=this;if(null!=e)return intCheck(e,0,MAX),null==r?r=g:intCheck(r,0,8),C(new y(i),e+i.e+1,r);if(!(t=i.c))return null;if(n=((o=t.length-1)-bitFloor(this.e/LOG_BASE))*LOG_BASE,o=t[o])for(;o%10==0;o/=10,n--);return n<0&&(n=0),n},l.dividedBy=l.div=function(e,t){return r(this,new y(e,t),h,g)},l.dividedToIntegerBy=l.idiv=function(e,t){return r(this,new y(e,t),0,1)},l.exponentiatedBy=l.pow=function(e,r){var t,n,o,i,a,u,c,s,l=this;if((e=new y(e)).c&&!e.isInteger())throw Error(bignumberError+"Exponent not an integer: "+O(e));if(null!=r&&(r=new y(r)),a=e.e>14,!l.c||!l.c[0]||1==l.c[0]&&!l.e&&1==l.c.length||!e.c||!e.c[0])return s=new y(Math.pow(+O(l),a?2-isOdd(e):+O(e))),r?s.mod(r):s;if(u=e.s<0,r){if(r.c?!r.c[0]:!r.s)return new y(NaN);(n=!u&&l.isInteger()&&r.isInteger())&&(l=l.mod(r))}else{if(e.e>9&&(l.e>0||l.e<-1||(0==l.e?l.c[0]>1||a&&l.c[1]>=24e7:l.c[0]<8e13||a&&l.c[0]<=9999975e7)))return i=l.s<0&&isOdd(e)?-0:0,l.e>-1&&(i=1/i),new y(u?1/i:i);A&&(i=mathceil(A/LOG_BASE+2))}for(a?(t=new y(.5),u&&(e.s=1),c=isOdd(e)):c=(o=Math.abs(+O(e)))%2,s=new y(f);;){if(c){if(!(s=s.times(l)).c)break;i?s.c.length>i&&(s.c.length=i):n&&(s=s.mod(r))}if(o){if(0===(o=mathfloor(o/2)))break;c=o%2}else if(C(e=e.times(t),e.e+1,1),e.e>14)c=isOdd(e);else{if(0===(o=+O(e)))break;c=o%2}l=l.times(l),i?l.c&&l.c.length>i&&(l.c.length=i):n&&(l=l.mod(r))}return n?s:(u&&(s=f.div(s)),r?s.mod(r):i?C(s,A,g,void 0):s)},l.integerValue=function(e){var r=new y(this);return null==e?e=g:intCheck(e,0,8),C(r,r.e+1,e)},l.isEqualTo=l.eq=function(e,r){return 0===compare(this,new y(e,r))},l.isFinite=function(){return!!this.c},l.isGreaterThan=l.gt=function(e,r){return compare(this,new y(e,r))>0},l.isGreaterThanOrEqualTo=l.gte=function(e,r){return 1===(r=compare(this,new y(e,r)))||0===r},l.isInteger=function(){return!!this.c&&bitFloor(this.e/LOG_BASE)>this.c.length-2},l.isLessThan=l.lt=function(e,r){return compare(this,new y(e,r))<0},l.isLessThanOrEqualTo=l.lte=function(e,r){return-1===(r=compare(this,new y(e,r)))||0===r},l.isNaN=function(){return!this.s},l.isNegative=function(){return this.s<0},l.isPositive=function(){return this.s>0},l.isZero=function(){return!!this.c&&0==this.c[0]},l.minus=function(e,r){var t,n,o,i,a=this,u=a.s;if(r=(e=new y(e,r)).s,!u||!r)return new y(NaN);if(u!=r)return e.s=-r,a.plus(e);var c=a.e/LOG_BASE,s=e.e/LOG_BASE,l=a.c,f=e.c;if(!c||!s){if(!l||!f)return l?(e.s=-r,e):new y(f?a:NaN);if(!l[0]||!f[0])return f[0]?(e.s=-r,e):new y(l[0]?a:3==g?-0:0)}if(c=bitFloor(c),s=bitFloor(s),l=l.slice(),u=c-s){for((i=u<0)?(u=-u,o=l):(s=c,o=f),o.reverse(),r=u;r--;o.push(0));o.reverse()}else for(n=(i=(u=l.length)<(r=f.length))?u:r,u=r=0;r<n;r++)if(l[r]!=f[r]){i=l[r]<f[r];break}if(i&&(o=l,l=f,f=o,e.s=-e.s),(r=(n=f.length)-(t=l.length))>0)for(;r--;l[t++]=0);for(r=BASE-1;n>u;){if(l[--n]<f[n]){for(t=n;t&&!l[--t];l[t]=r);--l[t],l[n]+=BASE}l[n]-=f[n]}for(;0==l[0];l.splice(0,1),--s);return l[0]?w(e,l,s):(e.s=3==g?-1:1,e.c=[e.e=0],e)},l.modulo=l.mod=function(e,t){var n,o,i=this;return e=new y(e,t),!i.c||!e.s||e.c&&!e.c[0]?new y(NaN):!e.c||i.c&&!i.c[0]?new y(i):(9==S?(o=e.s,e.s=1,n=r(i,e,0,3),e.s=o,n.s*=o):n=r(i,e,0,S),(e=i.minus(n.times(e))).c[0]||1!=S||(e.s=i.s),e)},l.multipliedBy=l.times=function(e,r){var t,n,o,i,a,u,c,s,l,f,h,g,d,p,m,b=this,v=b.c,S=(e=new y(e,r)).c;if(!(v&&S&&v[0]&&S[0]))return!b.s||!e.s||v&&!v[0]&&!S||S&&!S[0]&&!v?e.c=e.e=e.s=null:(e.s*=b.s,v&&S?(e.c=[0],e.e=0):e.c=e.e=null),e;for(n=bitFloor(b.e/LOG_BASE)+bitFloor(e.e/LOG_BASE),e.s*=b.s,(c=v.length)<(f=S.length)&&(d=v,v=S,S=d,o=c,c=f,f=o),o=c+f,d=[];o--;d.push(0));for(p=BASE,m=SQRT_BASE,o=f;--o>=0;){for(t=0,h=S[o]%m,g=S[o]/m|0,i=o+(a=c);i>o;)t=((s=h*(s=v[--a]%m)+(u=g*s+(l=v[a]/m|0)*h)%m*m+d[i]+t)/p|0)+(u/m|0)+g*l,d[i--]=s%p;d[i]=t}return t?++n:d.splice(0,1),w(e,d,n)},l.negated=function(){var e=new y(this);return e.s=-e.s||null,e},l.plus=function(e,r){var t,n=this,o=n.s;if(r=(e=new y(e,r)).s,!o||!r)return new y(NaN);if(o!=r)return e.s=-r,n.minus(e);var i=n.e/LOG_BASE,a=e.e/LOG_BASE,u=n.c,c=e.c;if(!i||!a){if(!u||!c)return new y(o/0);if(!u[0]||!c[0])return c[0]?e:new y(u[0]?n:0*o)}if(i=bitFloor(i),a=bitFloor(a),u=u.slice(),o=i-a){for(o>0?(a=i,t=c):(o=-o,t=u),t.reverse();o--;t.push(0));t.reverse()}for((o=u.length)-(r=c.length)<0&&(t=c,c=u,u=t,r=o),o=0;r;)o=(u[--r]=u[r]+c[r]+o)/BASE|0,u[r]=BASE===u[r]?0:u[r]%BASE;return o&&(u=[o].concat(u),++a),w(e,u,a)},l.precision=l.sd=function(e,r){var t,n,o,i=this;if(null!=e&&e!==!!e)return intCheck(e,1,MAX),null==r?r=g:intCheck(r,0,8),C(new y(i),e,r);if(!(t=i.c))return null;if(n=(o=t.length-1)*LOG_BASE+1,o=t[o]){for(;o%10==0;o/=10,n--);for(o=t[0];o>=10;o/=10,n++);}return e&&i.e+1>n&&(n=i.e+1),n},l.shiftedBy=function(e){return intCheck(e,-MAX_SAFE_INTEGER,MAX_SAFE_INTEGER),this.times("1e"+e)},l.squareRoot=l.sqrt=function(){var e,t,n,o,i,a=this,u=a.c,c=a.s,s=a.e,l=h+4,f=new y("0.5");if(1!==c||!u||!u[0])return new y(!c||c<0&&(!u||u[0])?NaN:u?a:1/0);if(0==(c=Math.sqrt(+O(a)))||c==1/0?(((t=coeffToString(u)).length+s)%2==0&&(t+="0"),c=Math.sqrt(+t),s=bitFloor((s+1)/2)-(s<0||s%2),n=new y(t=c==1/0?"1e"+s:(t=c.toExponential()).slice(0,t.indexOf("e")+1)+s)):n=new y(c+""),n.c[0])for((c=(s=n.e)+l)<3&&(c=0);;)if(i=n,n=f.times(i.plus(r(a,i,l,1))),coeffToString(i.c).slice(0,c)===(t=coeffToString(n.c)).slice(0,c)){if(n.e<s&&--c,"9999"!=(t=t.slice(c-3,c+1))&&(o||"4999"!=t)){+t&&(+t.slice(1)||"5"!=t.charAt(0))||(C(n,n.e+h+2,1),e=!n.times(n).eq(a));break}if(!o&&(C(i,i.e+h+2,0),i.times(i).eq(a))){n=i;break}l+=4,c+=4,o=1}return C(n,n.e+h+1,g,e)},l.toExponential=function(e,r){return null!=e&&(intCheck(e,0,MAX),e++),T(this,e,r,1)},l.toFixed=function(e,r){return null!=e&&(intCheck(e,0,MAX),e=e+this.e+1),T(this,e,r)},l.toFormat=function(e,r,t){var n,o=this;if(null==t)null!=e&&r&&"object"==typeof r?(t=r,r=null):e&&"object"==typeof e?(t=e,e=r=null):t=B;else if("object"!=typeof t)throw Error(bignumberError+"Argument not an object: "+t);if(n=o.toFixed(e,r),o.c){var i,a=n.split("."),u=+t.groupSize,c=+t.secondaryGroupSize,s=t.groupSeparator||"",l=a[0],f=a[1],h=o.s<0,g=h?l.slice(1):l,d=g.length;if(c&&(i=u,u=c,c=i,d-=i),u>0&&d>0){for(i=d%u||u,l=g.substr(0,i);i<d;i+=u)l+=s+g.substr(i,u);c>0&&(l+=s+g.slice(i)),h&&(l="-"+l)}n=f?l+(t.decimalSeparator||"")+((c=+t.fractionGroupSize)?f.replace(new RegExp("\\d{"+c+"}\\B","g"),"$&"+(t.fractionGroupSeparator||"")):f):l}return(t.prefix||"")+n+(t.suffix||"")},l.toFraction=function(e){var t,n,o,i,a,u,c,s,l,h,d,p,m=this,v=m.c;if(null!=e&&(!(c=new y(e)).isInteger()&&(c.c||1!==c.s)||c.lt(f)))throw Error(bignumberError+"Argument "+(c.isInteger()?"out of range: ":"not an integer: ")+O(c));if(!v)return new y(m);for(t=new y(f),l=n=new y(f),o=s=new y(f),p=coeffToString(v),a=t.e=p.length-m.e-1,t.c[0]=POWS_TEN[(u=a%LOG_BASE)<0?LOG_BASE+u:u],e=!e||c.comparedTo(t)>0?a>0?t:l:c,u=b,b=1/0,c=new y(p),s.c[0]=0;h=r(c,t,0,1),1!=(i=n.plus(h.times(o))).comparedTo(e);)n=o,o=i,l=s.plus(h.times(i=l)),s=i,t=c.minus(h.times(i=t)),c=i;return i=r(e.minus(n),o,0,1),s=s.plus(i.times(l)),n=n.plus(i.times(o)),s.s=l.s=m.s,d=r(l,o,a*=2,g).minus(m).abs().comparedTo(r(s,n,a,g).minus(m).abs())<1?[l,o]:[s,n],b=u,d},l.toNumber=function(){return+O(this)},l.toPrecision=function(e,r){return null!=e&&intCheck(e,1,MAX),T(this,e,r,2)},l.toString=function(e){var r,n=this,o=n.s,i=n.e;return null===i?o?(r="Infinity",o<0&&(r="-"+r)):r="NaN":(null==e?r=i<=d||i>=p?toExponential(coeffToString(n.c),i):toFixedPoint(coeffToString(n.c),i,"0"):10===e?r=toFixedPoint(coeffToString((n=C(new y(n),h+i+1,g)).c),n.e,"0"):(intCheck(e,2,E.length,"Base"),r=t(toFixedPoint(coeffToString(n.c),i,"0"),10,e,o,!0)),o<0&&n.c[0]&&(r="-"+r)),r},l.valueOf=l.toJSON=function(){return O(this)},l._isBigNumber=!0,l[Symbol.toStringTag]="BigNumber",l[Symbol.for("nodejs.util.inspect.custom")]=l.valueOf,null!=e&&y.set(e),y}function bitFloor(e){var r=0|e;return e>0||e===r?r:r-1}function coeffToString(e){for(var r,t,n=1,o=e.length,i=e[0]+"";n<o;){for(r=e[n++]+"",t=LOG_BASE-r.length;t--;r="0"+r);i+=r}for(o=i.length;48===i.charCodeAt(--o););return i.slice(0,o+1||1)}function compare(e,r){var t,n,o=e.c,i=r.c,a=e.s,u=r.s,c=e.e,s=r.e;if(!a||!u)return null;if(t=o&&!o[0],n=i&&!i[0],t||n)return t?n?0:-u:a;if(a!=u)return a;if(t=a<0,n=c==s,!o||!i)return n?0:!o^t?1:-1;if(!n)return c>s^t?1:-1;for(u=(c=o.length)<(s=i.length)?c:s,a=0;a<u;a++)if(o[a]!=i[a])return o[a]>i[a]^t?1:-1;return c==s?0:c>s^t?1:-1}function intCheck(e,r,t,n){if(e<r||e>t||e!==mathfloor(e))throw Error(bignumberError+(n||"Argument")+("number"==typeof e?e<r||e>t?" out of range: ":" not an integer: ":" not a primitive number: ")+String(e))}function isOdd(e){var r=e.c.length-1;return bitFloor(e.e/LOG_BASE)==r&&e.c[r]%2!=0}function toExponential(e,r){return(e.length>1?e.charAt(0)+"."+e.slice(1):e)+(r<0?"e":"e+")+r}function toFixedPoint(e,r,t){var n,o;if(r<0){for(o=t+".";++r;o+=t);e=o+e}else if(++r>(n=e.length)){for(o=t,r-=n;--r;o+=t);e+=o}else r<n&&(e=e.slice(0,r)+"."+e.slice(r));return e}var BigNumber=clone(),BurstValueFormat;function assureValidValue(e){if(!e||!/^-?\d*(\.\d+)?$/.test(e))throw new Error("Invalid value: ".concat(e))}BigNumber.config({EXPONENTIAL_AT:[-9,20]}),BurstValueFormat=exports.BurstValueFormat||(exports.BurstValueFormat={}),BurstValueFormat[BurstValueFormat.PLANCK=0]="PLANCK",BurstValueFormat[BurstValueFormat.BURST=1]="BURST";var BurstValue=function(){function e(r){_classCallCheck(this,e),assureValidValue(r),this._planck=new BigNumber(r)}return _createClass(e,[{key:"getRaw",value:function(){return this._planck}},{key:"getPlanck",value:function(){return this._planck.toString()}},{key:"setPlanck",value:function(e){assureValidValue(e),this._planck=new BigNumber(e)}},{key:"getBurst",value:function(){return this._planck.dividedBy(1e8).toString()}},{key:"setBurst",value:function(e){assureValidValue(e),this._planck=new BigNumber(e).multipliedBy(1e8)}},{key:"equals",value:function(e){return this._planck.eq(e._planck)}},{key:"lessOrEqual",value:function(e){return this._planck.lte(e._planck)}},{key:"less",value:function(e){return this._planck.lt(e._planck)}},{key:"greaterOrEqual",value:function(e){return this._planck.gte(e._planck)}},{key:"greater",value:function(e){return this._planck.gt(e._planck)}},{key:"add",value:function(e){return this._planck=this._planck.plus(e._planck),this}},{key:"subtract",value:function(e){return this._planck=this._planck.minus(e._planck),this}},{key:"multiply",value:function(e){return this._planck=this._planck.multipliedBy(e),this}},{key:"divide",value:function(e){if(0===e)throw new Error("Division by zero");return this._planck=this._planck.div(e),this}},{key:"toString",value:function(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:exports.BurstValueFormat.BURST)===exports.BurstValueFormat.BURST?"".concat(BurstSymbol," ").concat(this.getBurst()):"".concat(BurstPlanckSymbol," ").concat(this._planck)}}],[{key:"fromPlanck",value:function(r){return new e(r)}},{key:"fromBurst",value:function(r){var t=new e("0");return t.setBurst("number"==typeof r?r.toString(10):r),t}}]),e}();return exports.BurstPlanckSymbol=BurstPlanckSymbol,exports.BurstSymbol=BurstSymbol,exports.BurstTime=BurstTime,exports.BurstValue=BurstValue,exports.FeeQuantPlanck=FeeQuantPlanck,exports.OneBurstPlanck=OneBurstPlanck,exports.convertAddressToNumericId=convertAddressToNumericId,exports.convertBurstTimeToDate=convertBurstTimeToDate,exports.convertBurstTimeToEpochTime=convertBurstTimeToEpochTime,exports.convertByteArrayToHexString=convertByteArrayToHexString,exports.convertByteArrayToString=convertByteArrayToString,exports.convertDateToBurstTime=convertDateToBurstTime,exports.convertHexEndianess=convertHexEndianess,exports.convertHexStringToByteArray=convertHexStringToByteArray,exports.convertHexStringToDecString=convertHexStringToDecString,exports.convertHexStringToString=convertHexStringToString,exports.convertNQTStringToNumber=convertNQTStringToNumber,exports.convertNumberToNQTString=convertNumberToNQTString,exports.convertNumericIdToAddress=convertNumericIdToAddress,exports.convertStringToByteArray=convertStringToByteArray,exports.convertStringToHexString=convertStringToHexString,exports.createDeeplink=createDeeplink,exports.isBurstAddress=isBurstAddress,exports.isValid=isValid,exports.parseDeeplink=parseDeeplink,exports.sumNQTStringToNumber=sumNQTStringToNumber,exports}({}); | ||
var b$util=function(exports){"use strict";var GenesisBlockTime=Date.UTC(2014,7,11,2,0,0,0)/1e3,initialCodeword=[1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],gexp=[1,2,4,8,16,5,10,20,13,26,17,7,14,28,29,31,27,19,3,6,12,24,21,15,30,25,23,11,22,9,18,1],glog=[0,0,1,18,2,5,19,11,3,29,6,27,20,8,12,23,4,10,30,17,7,22,28,26,21,25,9,16,13,14,24,15],cwmap=[3,2,1,0,7,6,5,4,13,14,15,16,12,8,9,10,11],alphabet="23456789ABCDEFGHJKLMNPQRSTUVWXYZ".split(""),base32Length=13,gmult=function(e,r){if(0===e||0===r)return 0;var t=(glog[e]+glog[r])%31;return gexp[t]},isValid=function(e){0===e.indexOf("BURST-")&&(e=e.substr(6));for(var r=initialCodeword.slice(),t=0,n=0;n<e.length;n++){var o=alphabet.indexOf(e.charAt(n));if(!(o<=-1||o>alphabet.length)){if(t>16)return!1;r[cwmap[t]]=o,t++}}if(17!==t)return!1;for(var i=0,a=1;a<5;a++){for(var u=0,c=0;c<31;c++)if(!(c>12&&c<27)){var s=c;c>26&&(s-=14),u^=gmult(r[s],gexp[a*c%31])}i|=u}return 0===i},isBurstAddress=function(e){return/^BURST\-[A-Z0-9]{4}\-[A-Z0-9]{4}\-[A-Z0-9]{4}\-[A-Z0-9]{5}/i.test(e)&&isValid(e)},convertAddressToNumericId=function(e){if(null!=e&&0!==e.trim().length&&0===e.indexOf("BURST-")){e=e.substr(6);for(var r=initialCodeword.slice(),t=0,n=0;n<e.length;n++){var o=alphabet.indexOf(e.charAt(n));if(!(o<=-1||o>alphabet.length)){if(t>16)return;r[cwmap[t]]=o,t++}}if(isValid(e)){for(var i=base32Length,a=[],u=0;u<i;u++)a[u]=r[i-u-1];var c,s="",l=0;do{c=0,l=0;for(var f=0;f<i;f++)(l=32*l+a[f])>=10?(a[c]=Math.floor(l/10),l%=10,c+=1):c>0&&(a[c]=0,c+=1);i=c,s+=l}while(i>0);return s.split("").reverse().join("")}}},convertBurstTimeToEpochTime=function(e){return 1e3*(GenesisBlockTime+e)},convertBurstTimeToDate=function(e){return new Date(convertBurstTimeToEpochTime(e))},convertByteArrayToHexString=function(e){for(var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],t=[],n=0;n<e.length;n++)t.push((e[n]>>>4).toString(16)),t.push((15&e[n]).toString(16));return r?t.join("").toUpperCase():t.join("")},convertByteArrayToString=function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;if(0===t)return"";var n=e;if(0!==r){var o=null===t?e.length-r:t;checkBytesToIntInput(n,o,r),n=e.slice(r,r+o)}return decodeURIComponent(escape(String.fromCharCode.apply(null,Array.from(n))))};function checkBytesToIntInput(e,r){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;if(t<0)throw new Error("Start index should not be negative");if(e.length<t+r)throw new Error("Need at least "+r+" bytes to convert to an integer");return t}var convertDateToBurstTime=function(e){return Math.round(e.getTime()/1e3)-GenesisBlockTime},convertHexEndianess=function(e){for(var r="",t=e,n=t.length-1;n>=0;n-=2)r+=t[n-1]+t[n];return r},convertHexStringToByteArray=function(e){if(e.length%2)throw new Error("Invalid Hex String: ".concat(e));for(var r=new Uint8Array(e.length/2),t=0;t<e.length;t+=2){var n=parseInt(e.substr(t,2),16);if(Number.isNaN(n))throw new Error("Invalid Hex String: ".concat(e));r[t/2]=n}return r},convertHexStringToDecString=function(e){var r,t,n,o=[0];for(r=0;r<e.length;r+=1){for(n=parseInt(e.charAt(r),16),t=0;t<o.length;t+=1)o[t]=16*o[t]+n,n=o[t]/10|0,o[t]%=10;for(;n>0;)o.push(n%10),n=n/10|0}return o.reverse().join("")},isNumeric=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,mathceil=Math.ceil,mathfloor=Math.floor,bignumberError="[BigNumber Error] ",tooManyDigits=bignumberError+"Number primitive has more than 15 significant digits: ",BASE=1e14,LOG_BASE=14,MAX_SAFE_INTEGER=9007199254740991,POWS_TEN=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],SQRT_BASE=1e7,MAX=1e9;function clone(e){var r,t,n,o,i,a,u,c,s,l=y.prototype={constructor:y,toString:null,valueOf:null},f=new y(1),h=20,g=4,d=-7,p=21,m=-1e7,b=1e7,v=!1,S=1,B=0,A={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},E="0123456789abcdefghijklmnopqrstuvwxyz";function y(e,r){var o,i,a,u,c,s,l,f,d=this;if(!(d instanceof y))return new y(e,r);if(null==r){if(e&&!0===e._isBigNumber)return d.s=e.s,void(!e.c||e.e>b?d.c=d.e=null:e.e<m?d.c=[d.e=0]:(d.e=e.e,d.c=e.c.slice()));if((s="number"==typeof e)&&0*e==0){if(d.s=1/e<0?(e=-e,-1):1,e===~~e){for(u=0,c=e;c>=10;c/=10,u++);return void(u>b?d.c=d.e=null:(d.e=u,d.c=[e]))}f=String(e)}else{if(!isNumeric.test(f=String(e)))return n(d,f,s);d.s=45==f.charCodeAt(0)?(f=f.slice(1),-1):1}(u=f.indexOf("."))>-1&&(f=f.replace(".","")),(c=f.search(/e/i))>0?(u<0&&(u=c),u+=+f.slice(c+1),f=f.substring(0,c)):u<0&&(u=f.length)}else{if(intCheck(r,2,E.length,"Base"),10==r)return x(d=new y(e),h+d.e+1,g);if(f=String(e),s="number"==typeof e){if(0*e!=0)return n(d,f,s,r);if(d.s=1/e<0?(f=f.slice(1),-1):1,y.DEBUG&&f.replace(/^0\.0*|\./,"").length>15)throw Error(tooManyDigits+e)}else d.s=45===f.charCodeAt(0)?(f=f.slice(1),-1):1;for(o=E.slice(0,r),u=c=0,l=f.length;c<l;c++)if(o.indexOf(i=f.charAt(c))<0){if("."==i){if(c>u){u=l;continue}}else if(!a&&(f==f.toUpperCase()&&(f=f.toLowerCase())||f==f.toLowerCase()&&(f=f.toUpperCase()))){a=!0,c=-1,u=0;continue}return n(d,String(e),s,r)}s=!1,(u=(f=t(f,r,10,d.s)).indexOf("."))>-1?f=f.replace(".",""):u=f.length}for(c=0;48===f.charCodeAt(c);c++);for(l=f.length;48===f.charCodeAt(--l););if(f=f.slice(c,++l)){if(l-=c,s&&y.DEBUG&&l>15&&(e>MAX_SAFE_INTEGER||e!==mathfloor(e)))throw Error(tooManyDigits+d.s*e);if((u=u-c-1)>b)d.c=d.e=null;else if(u<m)d.c=[d.e=0];else{if(d.e=u,d.c=[],c=(u+1)%LOG_BASE,u<0&&(c+=LOG_BASE),c<l){for(c&&d.c.push(+f.slice(0,c)),l-=LOG_BASE;c<l;)d.c.push(+f.slice(c,c+=LOG_BASE));c=LOG_BASE-(f=f.slice(c)).length}else c-=l;for(;c--;f+="0");d.c.push(+f)}}else d.c=[d.e=0]}function T(e,r,t,n){var o,i,a,u,c;if(null==t?t=g:intCheck(t,0,8),!e.c)return e.toString();if(o=e.c[0],a=e.e,null==r)c=coeffToString(e.c),c=1==n||2==n&&(a<=d||a>=p)?toExponential(c,a):toFixedPoint(c,a,"0");else if(i=(e=x(new y(e),r,t)).e,u=(c=coeffToString(e.c)).length,1==n||2==n&&(r<=i||i<=d)){for(;u<r;c+="0",u++);c=toExponential(c,i)}else if(r-=a,c=toFixedPoint(c,i,"0"),i+1>u){if(--r>0)for(c+=".";r--;c+="0");}else if((r+=i-u)>0)for(i+1==u&&(c+=".");r--;c+="0");return e.s<0&&o?"-"+c:c}function _(e,r){for(var t,n=1,o=new y(e[0]);n<e.length;n++){if(!(t=new y(e[n])).s){o=t;break}r.call(o,t)&&(o=t)}return o}function w(e,r,t){for(var n=1,o=r.length;!r[--o];r.pop());for(o=r[0];o>=10;o/=10,n++);return(t=n+t*LOG_BASE-1)>b?e.c=e.e=null:t<m?e.c=[e.e=0]:(e.e=t,e.c=r),e}function x(e,r,t,n){var o,i,a,u,c,s,l,f=e.c,h=POWS_TEN;if(f){e:{for(o=1,u=f[0];u>=10;u/=10,o++);if((i=r-o)<0)i+=LOG_BASE,a=r,l=(c=f[s=0])/h[o-a-1]%10|0;else if((s=mathceil((i+1)/LOG_BASE))>=f.length){if(!n)break e;for(;f.length<=s;f.push(0));c=l=0,o=1,a=(i%=LOG_BASE)-LOG_BASE+1}else{for(c=u=f[s],o=1;u>=10;u/=10,o++);l=(a=(i%=LOG_BASE)-LOG_BASE+o)<0?0:c/h[o-a-1]%10|0}if(n=n||r<0||null!=f[s+1]||(a<0?c:c%h[o-a-1]),n=t<4?(l||n)&&(0==t||t==(e.s<0?3:2)):l>5||5==l&&(4==t||n||6==t&&(i>0?a>0?c/h[o-a]:0:f[s-1])%10&1||t==(e.s<0?8:7)),r<1||!f[0])return f.length=0,n?(r-=e.e+1,f[0]=h[(LOG_BASE-r%LOG_BASE)%LOG_BASE],e.e=-r||0):f[0]=e.e=0,e;if(0==i?(f.length=s,u=1,s--):(f.length=s+1,u=h[LOG_BASE-i],f[s]=a>0?mathfloor(c/h[o-a]%h[a])*u:0),n)for(;;){if(0==s){for(i=1,a=f[0];a>=10;a/=10,i++);for(a=f[0]+=u,u=1;a>=10;a/=10,u++);i!=u&&(e.e++,f[0]==BASE&&(f[0]=1));break}if(f[s]+=u,f[s]!=BASE)break;f[s--]=0,u=1}for(i=f.length;0===f[--i];f.pop());}e.e>b?e.c=e.e=null:e.e<m&&(e.c=[e.e=0])}return e}function C(e){var r,t=e.e;return null===t?e.toString():(r=coeffToString(e.c),r=t<=d||t>=p?toExponential(r,t):toFixedPoint(r,t,"0"),e.s<0?"-"+r:r)}return y.clone=clone,y.ROUND_UP=0,y.ROUND_DOWN=1,y.ROUND_CEIL=2,y.ROUND_FLOOR=3,y.ROUND_HALF_UP=4,y.ROUND_HALF_DOWN=5,y.ROUND_HALF_EVEN=6,y.ROUND_HALF_CEIL=7,y.ROUND_HALF_FLOOR=8,y.EUCLID=9,y.config=y.set=function(e){var r,t;if(null!=e){if("object"!=typeof e)throw Error(bignumberError+"Object expected: "+e);if(e.hasOwnProperty(r="DECIMAL_PLACES")&&(intCheck(t=e[r],0,MAX,r),h=t),e.hasOwnProperty(r="ROUNDING_MODE")&&(intCheck(t=e[r],0,8,r),g=t),e.hasOwnProperty(r="EXPONENTIAL_AT")&&((t=e[r])&&t.pop?(intCheck(t[0],-MAX,0,r),intCheck(t[1],0,MAX,r),d=t[0],p=t[1]):(intCheck(t,-MAX,MAX,r),d=-(p=t<0?-t:t))),e.hasOwnProperty(r="RANGE"))if((t=e[r])&&t.pop)intCheck(t[0],-MAX,-1,r),intCheck(t[1],1,MAX,r),m=t[0],b=t[1];else{if(intCheck(t,-MAX,MAX,r),!t)throw Error(bignumberError+r+" cannot be zero: "+t);m=-(b=t<0?-t:t)}if(e.hasOwnProperty(r="CRYPTO")){if((t=e[r])!==!!t)throw Error(bignumberError+r+" not true or false: "+t);if(t){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw v=!t,Error(bignumberError+"crypto unavailable");v=t}else v=t}if(e.hasOwnProperty(r="MODULO_MODE")&&(intCheck(t=e[r],0,9,r),S=t),e.hasOwnProperty(r="POW_PRECISION")&&(intCheck(t=e[r],0,MAX,r),B=t),e.hasOwnProperty(r="FORMAT")){if("object"!=typeof(t=e[r]))throw Error(bignumberError+r+" not an object: "+t);A=t}if(e.hasOwnProperty(r="ALPHABET")){if("string"!=typeof(t=e[r])||/^.$|[+-.\s]|(.).*\1/.test(t))throw Error(bignumberError+r+" invalid: "+t);E=t}}return{DECIMAL_PLACES:h,ROUNDING_MODE:g,EXPONENTIAL_AT:[d,p],RANGE:[m,b],CRYPTO:v,MODULO_MODE:S,POW_PRECISION:B,FORMAT:A,ALPHABET:E}},y.isBigNumber=function(e){if(!e||!0!==e._isBigNumber)return!1;if(!y.DEBUG)return!0;var r,t,n=e.c,o=e.e,i=e.s;e:if("[object Array]"=={}.toString.call(n)){if((1===i||-1===i)&&o>=-MAX&&o<=MAX&&o===mathfloor(o)){if(0===n[0]){if(0===o&&1===n.length)return!0;break e}if((r=(o+1)%LOG_BASE)<1&&(r+=LOG_BASE),String(n[0]).length==r){for(r=0;r<n.length;r++)if((t=n[r])<0||t>=BASE||t!==mathfloor(t))break e;if(0!==t)return!0}}}else if(null===n&&null===o&&(null===i||1===i||-1===i))return!0;throw Error(bignumberError+"Invalid BigNumber: "+e)},y.maximum=y.max=function(){return _(arguments,l.lt)},y.minimum=y.min=function(){return _(arguments,l.gt)},y.random=(o=9007199254740992*Math.random()&2097151?function(){return mathfloor(9007199254740992*Math.random())}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)},function(e){var r,t,n,i,a,u=0,c=[],s=new y(f);if(null==e?e=h:intCheck(e,0,MAX),i=mathceil(e/LOG_BASE),v)if(crypto.getRandomValues){for(r=crypto.getRandomValues(new Uint32Array(i*=2));u<i;)(a=131072*r[u]+(r[u+1]>>>11))>=9e15?(t=crypto.getRandomValues(new Uint32Array(2)),r[u]=t[0],r[u+1]=t[1]):(c.push(a%1e14),u+=2);u=i/2}else{if(!crypto.randomBytes)throw v=!1,Error(bignumberError+"crypto unavailable");for(r=crypto.randomBytes(i*=7);u<i;)(a=281474976710656*(31&r[u])+1099511627776*r[u+1]+4294967296*r[u+2]+16777216*r[u+3]+(r[u+4]<<16)+(r[u+5]<<8)+r[u+6])>=9e15?crypto.randomBytes(7).copy(r,u):(c.push(a%1e14),u+=7);u=i/7}if(!v)for(;u<i;)(a=o())<9e15&&(c[u++]=a%1e14);for(i=c[--u],e%=LOG_BASE,i&&e&&(a=POWS_TEN[LOG_BASE-e],c[u]=mathfloor(i/a)*a);0===c[u];c.pop(),u--);if(u<0)c=[n=0];else{for(n=-1;0===c[0];c.splice(0,1),n-=LOG_BASE);for(u=1,a=c[0];a>=10;a/=10,u++);u<LOG_BASE&&(n-=LOG_BASE-u)}return s.e=n,s.c=c,s}),y.sum=function(){for(var e=1,r=arguments,t=new y(r[0]);e<r.length;)t=t.plus(r[e++]);return t},t=function(){function e(e,r,t,n){for(var o,i,a=[0],u=0,c=e.length;u<c;){for(i=a.length;i--;a[i]*=r);for(a[0]+=n.indexOf(e.charAt(u++)),o=0;o<a.length;o++)a[o]>t-1&&(null==a[o+1]&&(a[o+1]=0),a[o+1]+=a[o]/t|0,a[o]%=t)}return a.reverse()}return function(t,n,o,i,a){var u,c,s,l,f,d,p,m,b=t.indexOf("."),v=h,S=g;for(b>=0&&(l=B,B=0,t=t.replace(".",""),d=(m=new y(n)).pow(t.length-b),B=l,m.c=e(toFixedPoint(coeffToString(d.c),d.e,"0"),10,o,"0123456789"),m.e=m.c.length),s=l=(p=e(t,n,o,a?(u=E,"0123456789"):(u="0123456789",E))).length;0==p[--l];p.pop());if(!p[0])return u.charAt(0);if(b<0?--s:(d.c=p,d.e=s,d.s=i,p=(d=r(d,m,v,S,o)).c,f=d.r,s=d.e),b=p[c=s+v+1],l=o/2,f=f||c<0||null!=p[c+1],f=S<4?(null!=b||f)&&(0==S||S==(d.s<0?3:2)):b>l||b==l&&(4==S||f||6==S&&1&p[c-1]||S==(d.s<0?8:7)),c<1||!p[0])t=f?toFixedPoint(u.charAt(1),-v,u.charAt(0)):u.charAt(0);else{if(p.length=c,f)for(--o;++p[--c]>o;)p[c]=0,c||(++s,p=[1].concat(p));for(l=p.length;!p[--l];);for(b=0,t="";b<=l;t+=u.charAt(p[b++]));t=toFixedPoint(t,s,u.charAt(0))}return t}}(),r=function(){function e(e,r,t){var n,o,i,a,u=0,c=e.length,s=r%SQRT_BASE,l=r/SQRT_BASE|0;for(e=e.slice();c--;)u=((o=s*(i=e[c]%SQRT_BASE)+(n=l*i+(a=e[c]/SQRT_BASE|0)*s)%SQRT_BASE*SQRT_BASE+u)/t|0)+(n/SQRT_BASE|0)+l*a,e[c]=o%t;return u&&(e=[u].concat(e)),e}function r(e,r,t,n){var o,i;if(t!=n)i=t>n?1:-1;else for(o=i=0;o<t;o++)if(e[o]!=r[o]){i=e[o]>r[o]?1:-1;break}return i}function t(e,r,t,n){for(var o=0;t--;)e[t]-=o,o=e[t]<r[t]?1:0,e[t]=o*n+e[t]-r[t];for(;!e[0]&&e.length>1;e.splice(0,1));}return function(n,o,i,a,u){var c,s,l,f,h,g,d,p,m,b,v,S,B,A,E,T,_,w=n.s==o.s?1:-1,C=n.c,O=o.c;if(!(C&&C[0]&&O&&O[0]))return new y(n.s&&o.s&&(C?!O||C[0]!=O[0]:O)?C&&0==C[0]||!O?0*w:w/0:NaN);for(m=(p=new y(w)).c=[],w=i+(s=n.e-o.e)+1,u||(u=BASE,s=bitFloor(n.e/LOG_BASE)-bitFloor(o.e/LOG_BASE),w=w/LOG_BASE|0),l=0;O[l]==(C[l]||0);l++);if(O[l]>(C[l]||0)&&s--,w<0)m.push(1),f=!0;else{for(A=C.length,T=O.length,l=0,w+=2,(h=mathfloor(u/(O[0]+1)))>1&&(O=e(O,h,u),C=e(C,h,u),T=O.length,A=C.length),B=T,v=(b=C.slice(0,T)).length;v<T;b[v++]=0);_=O.slice(),_=[0].concat(_),E=O[0],O[1]>=u/2&&E++;do{if(h=0,(c=r(O,b,T,v))<0){if(S=b[0],T!=v&&(S=S*u+(b[1]||0)),(h=mathfloor(S/E))>1)for(h>=u&&(h=u-1),d=(g=e(O,h,u)).length,v=b.length;1==r(g,b,d,v);)h--,t(g,T<d?_:O,d,u),d=g.length,c=1;else 0==h&&(c=h=1),d=(g=O.slice()).length;if(d<v&&(g=[0].concat(g)),t(b,g,v,u),v=b.length,-1==c)for(;r(O,b,T,v)<1;)h++,t(b,T<v?_:O,v,u),v=b.length}else 0===c&&(h++,b=[0]);m[l++]=h,b[0]?b[v++]=C[B]||0:(b=[C[B]],v=1)}while((B++<A||null!=b[0])&&w--);f=null!=b[0],m[0]||m.splice(0,1)}if(u==BASE){for(l=1,w=m[0];w>=10;w/=10,l++);x(p,i+(p.e=l+s*LOG_BASE-1)+1,a,f)}else p.e=s,p.r=+f;return p}}(),i=/^(-?)0([xbo])(?=\w[\w.]*$)/i,a=/^([^.]+)\.$/,u=/^\.([^.]+)$/,c=/^-?(Infinity|NaN)$/,s=/^\s*\+(?=[\w.])|^\s+|\s+$/g,n=function(e,r,t,n){var o,l=t?r:r.replace(s,"");if(c.test(l))e.s=isNaN(l)?null:l<0?-1:1;else{if(!t&&(l=l.replace(i,function(e,r,t){return o="x"==(t=t.toLowerCase())?16:"b"==t?2:8,n&&n!=o?e:r}),n&&(o=n,l=l.replace(a,"$1").replace(u,"0.$1")),r!=l))return new y(l,o);if(y.DEBUG)throw Error(bignumberError+"Not a"+(n?" base "+n:"")+" number: "+r);e.s=null}e.c=e.e=null},l.absoluteValue=l.abs=function(){var e=new y(this);return e.s<0&&(e.s=1),e},l.comparedTo=function(e,r){return compare(this,new y(e,r))},l.decimalPlaces=l.dp=function(e,r){var t,n,o,i=this;if(null!=e)return intCheck(e,0,MAX),null==r?r=g:intCheck(r,0,8),x(new y(i),e+i.e+1,r);if(!(t=i.c))return null;if(n=((o=t.length-1)-bitFloor(this.e/LOG_BASE))*LOG_BASE,o=t[o])for(;o%10==0;o/=10,n--);return n<0&&(n=0),n},l.dividedBy=l.div=function(e,t){return r(this,new y(e,t),h,g)},l.dividedToIntegerBy=l.idiv=function(e,t){return r(this,new y(e,t),0,1)},l.exponentiatedBy=l.pow=function(e,r){var t,n,o,i,a,u,c,s,l=this;if((e=new y(e)).c&&!e.isInteger())throw Error(bignumberError+"Exponent not an integer: "+C(e));if(null!=r&&(r=new y(r)),a=e.e>14,!l.c||!l.c[0]||1==l.c[0]&&!l.e&&1==l.c.length||!e.c||!e.c[0])return s=new y(Math.pow(+C(l),a?2-isOdd(e):+C(e))),r?s.mod(r):s;if(u=e.s<0,r){if(r.c?!r.c[0]:!r.s)return new y(NaN);(n=!u&&l.isInteger()&&r.isInteger())&&(l=l.mod(r))}else{if(e.e>9&&(l.e>0||l.e<-1||(0==l.e?l.c[0]>1||a&&l.c[1]>=24e7:l.c[0]<8e13||a&&l.c[0]<=9999975e7)))return i=l.s<0&&isOdd(e)?-0:0,l.e>-1&&(i=1/i),new y(u?1/i:i);B&&(i=mathceil(B/LOG_BASE+2))}for(a?(t=new y(.5),u&&(e.s=1),c=isOdd(e)):c=(o=Math.abs(+C(e)))%2,s=new y(f);;){if(c){if(!(s=s.times(l)).c)break;i?s.c.length>i&&(s.c.length=i):n&&(s=s.mod(r))}if(o){if(0===(o=mathfloor(o/2)))break;c=o%2}else if(x(e=e.times(t),e.e+1,1),e.e>14)c=isOdd(e);else{if(0===(o=+C(e)))break;c=o%2}l=l.times(l),i?l.c&&l.c.length>i&&(l.c.length=i):n&&(l=l.mod(r))}return n?s:(u&&(s=f.div(s)),r?s.mod(r):i?x(s,B,g,void 0):s)},l.integerValue=function(e){var r=new y(this);return null==e?e=g:intCheck(e,0,8),x(r,r.e+1,e)},l.isEqualTo=l.eq=function(e,r){return 0===compare(this,new y(e,r))},l.isFinite=function(){return!!this.c},l.isGreaterThan=l.gt=function(e,r){return compare(this,new y(e,r))>0},l.isGreaterThanOrEqualTo=l.gte=function(e,r){return 1===(r=compare(this,new y(e,r)))||0===r},l.isInteger=function(){return!!this.c&&bitFloor(this.e/LOG_BASE)>this.c.length-2},l.isLessThan=l.lt=function(e,r){return compare(this,new y(e,r))<0},l.isLessThanOrEqualTo=l.lte=function(e,r){return-1===(r=compare(this,new y(e,r)))||0===r},l.isNaN=function(){return!this.s},l.isNegative=function(){return this.s<0},l.isPositive=function(){return this.s>0},l.isZero=function(){return!!this.c&&0==this.c[0]},l.minus=function(e,r){var t,n,o,i,a=this,u=a.s;if(r=(e=new y(e,r)).s,!u||!r)return new y(NaN);if(u!=r)return e.s=-r,a.plus(e);var c=a.e/LOG_BASE,s=e.e/LOG_BASE,l=a.c,f=e.c;if(!c||!s){if(!l||!f)return l?(e.s=-r,e):new y(f?a:NaN);if(!l[0]||!f[0])return f[0]?(e.s=-r,e):new y(l[0]?a:3==g?-0:0)}if(c=bitFloor(c),s=bitFloor(s),l=l.slice(),u=c-s){for((i=u<0)?(u=-u,o=l):(s=c,o=f),o.reverse(),r=u;r--;o.push(0));o.reverse()}else for(n=(i=(u=l.length)<(r=f.length))?u:r,u=r=0;r<n;r++)if(l[r]!=f[r]){i=l[r]<f[r];break}if(i&&(o=l,l=f,f=o,e.s=-e.s),(r=(n=f.length)-(t=l.length))>0)for(;r--;l[t++]=0);for(r=BASE-1;n>u;){if(l[--n]<f[n]){for(t=n;t&&!l[--t];l[t]=r);--l[t],l[n]+=BASE}l[n]-=f[n]}for(;0==l[0];l.splice(0,1),--s);return l[0]?w(e,l,s):(e.s=3==g?-1:1,e.c=[e.e=0],e)},l.modulo=l.mod=function(e,t){var n,o,i=this;return e=new y(e,t),!i.c||!e.s||e.c&&!e.c[0]?new y(NaN):!e.c||i.c&&!i.c[0]?new y(i):(9==S?(o=e.s,e.s=1,n=r(i,e,0,3),e.s=o,n.s*=o):n=r(i,e,0,S),(e=i.minus(n.times(e))).c[0]||1!=S||(e.s=i.s),e)},l.multipliedBy=l.times=function(e,r){var t,n,o,i,a,u,c,s,l,f,h,g,d,p,m,b=this,v=b.c,S=(e=new y(e,r)).c;if(!(v&&S&&v[0]&&S[0]))return!b.s||!e.s||v&&!v[0]&&!S||S&&!S[0]&&!v?e.c=e.e=e.s=null:(e.s*=b.s,v&&S?(e.c=[0],e.e=0):e.c=e.e=null),e;for(n=bitFloor(b.e/LOG_BASE)+bitFloor(e.e/LOG_BASE),e.s*=b.s,(c=v.length)<(f=S.length)&&(d=v,v=S,S=d,o=c,c=f,f=o),o=c+f,d=[];o--;d.push(0));for(p=BASE,m=SQRT_BASE,o=f;--o>=0;){for(t=0,h=S[o]%m,g=S[o]/m|0,i=o+(a=c);i>o;)t=((s=h*(s=v[--a]%m)+(u=g*s+(l=v[a]/m|0)*h)%m*m+d[i]+t)/p|0)+(u/m|0)+g*l,d[i--]=s%p;d[i]=t}return t?++n:d.splice(0,1),w(e,d,n)},l.negated=function(){var e=new y(this);return e.s=-e.s||null,e},l.plus=function(e,r){var t,n=this,o=n.s;if(r=(e=new y(e,r)).s,!o||!r)return new y(NaN);if(o!=r)return e.s=-r,n.minus(e);var i=n.e/LOG_BASE,a=e.e/LOG_BASE,u=n.c,c=e.c;if(!i||!a){if(!u||!c)return new y(o/0);if(!u[0]||!c[0])return c[0]?e:new y(u[0]?n:0*o)}if(i=bitFloor(i),a=bitFloor(a),u=u.slice(),o=i-a){for(o>0?(a=i,t=c):(o=-o,t=u),t.reverse();o--;t.push(0));t.reverse()}for((o=u.length)-(r=c.length)<0&&(t=c,c=u,u=t,r=o),o=0;r;)o=(u[--r]=u[r]+c[r]+o)/BASE|0,u[r]=BASE===u[r]?0:u[r]%BASE;return o&&(u=[o].concat(u),++a),w(e,u,a)},l.precision=l.sd=function(e,r){var t,n,o,i=this;if(null!=e&&e!==!!e)return intCheck(e,1,MAX),null==r?r=g:intCheck(r,0,8),x(new y(i),e,r);if(!(t=i.c))return null;if(n=(o=t.length-1)*LOG_BASE+1,o=t[o]){for(;o%10==0;o/=10,n--);for(o=t[0];o>=10;o/=10,n++);}return e&&i.e+1>n&&(n=i.e+1),n},l.shiftedBy=function(e){return intCheck(e,-MAX_SAFE_INTEGER,MAX_SAFE_INTEGER),this.times("1e"+e)},l.squareRoot=l.sqrt=function(){var e,t,n,o,i,a=this,u=a.c,c=a.s,s=a.e,l=h+4,f=new y("0.5");if(1!==c||!u||!u[0])return new y(!c||c<0&&(!u||u[0])?NaN:u?a:1/0);if(0==(c=Math.sqrt(+C(a)))||c==1/0?(((t=coeffToString(u)).length+s)%2==0&&(t+="0"),c=Math.sqrt(+t),s=bitFloor((s+1)/2)-(s<0||s%2),n=new y(t=c==1/0?"1e"+s:(t=c.toExponential()).slice(0,t.indexOf("e")+1)+s)):n=new y(c+""),n.c[0])for((c=(s=n.e)+l)<3&&(c=0);;)if(i=n,n=f.times(i.plus(r(a,i,l,1))),coeffToString(i.c).slice(0,c)===(t=coeffToString(n.c)).slice(0,c)){if(n.e<s&&--c,"9999"!=(t=t.slice(c-3,c+1))&&(o||"4999"!=t)){+t&&(+t.slice(1)||"5"!=t.charAt(0))||(x(n,n.e+h+2,1),e=!n.times(n).eq(a));break}if(!o&&(x(i,i.e+h+2,0),i.times(i).eq(a))){n=i;break}l+=4,c+=4,o=1}return x(n,n.e+h+1,g,e)},l.toExponential=function(e,r){return null!=e&&(intCheck(e,0,MAX),e++),T(this,e,r,1)},l.toFixed=function(e,r){return null!=e&&(intCheck(e,0,MAX),e=e+this.e+1),T(this,e,r)},l.toFormat=function(e,r,t){var n,o=this;if(null==t)null!=e&&r&&"object"==typeof r?(t=r,r=null):e&&"object"==typeof e?(t=e,e=r=null):t=A;else if("object"!=typeof t)throw Error(bignumberError+"Argument not an object: "+t);if(n=o.toFixed(e,r),o.c){var i,a=n.split("."),u=+t.groupSize,c=+t.secondaryGroupSize,s=t.groupSeparator||"",l=a[0],f=a[1],h=o.s<0,g=h?l.slice(1):l,d=g.length;if(c&&(i=u,u=c,c=i,d-=i),u>0&&d>0){for(i=d%u||u,l=g.substr(0,i);i<d;i+=u)l+=s+g.substr(i,u);c>0&&(l+=s+g.slice(i)),h&&(l="-"+l)}n=f?l+(t.decimalSeparator||"")+((c=+t.fractionGroupSize)?f.replace(new RegExp("\\d{"+c+"}\\B","g"),"$&"+(t.fractionGroupSeparator||"")):f):l}return(t.prefix||"")+n+(t.suffix||"")},l.toFraction=function(e){var t,n,o,i,a,u,c,s,l,h,d,p,m=this,v=m.c;if(null!=e&&(!(c=new y(e)).isInteger()&&(c.c||1!==c.s)||c.lt(f)))throw Error(bignumberError+"Argument "+(c.isInteger()?"out of range: ":"not an integer: ")+C(c));if(!v)return new y(m);for(t=new y(f),l=n=new y(f),o=s=new y(f),p=coeffToString(v),a=t.e=p.length-m.e-1,t.c[0]=POWS_TEN[(u=a%LOG_BASE)<0?LOG_BASE+u:u],e=!e||c.comparedTo(t)>0?a>0?t:l:c,u=b,b=1/0,c=new y(p),s.c[0]=0;h=r(c,t,0,1),1!=(i=n.plus(h.times(o))).comparedTo(e);)n=o,o=i,l=s.plus(h.times(i=l)),s=i,t=c.minus(h.times(i=t)),c=i;return i=r(e.minus(n),o,0,1),s=s.plus(i.times(l)),n=n.plus(i.times(o)),s.s=l.s=m.s,d=r(l,o,a*=2,g).minus(m).abs().comparedTo(r(s,n,a,g).minus(m).abs())<1?[l,o]:[s,n],b=u,d},l.toNumber=function(){return+C(this)},l.toPrecision=function(e,r){return null!=e&&intCheck(e,1,MAX),T(this,e,r,2)},l.toString=function(e){var r,n=this,o=n.s,i=n.e;return null===i?o?(r="Infinity",o<0&&(r="-"+r)):r="NaN":(null==e?r=i<=d||i>=p?toExponential(coeffToString(n.c),i):toFixedPoint(coeffToString(n.c),i,"0"):10===e?r=toFixedPoint(coeffToString((n=x(new y(n),h+i+1,g)).c),n.e,"0"):(intCheck(e,2,E.length,"Base"),r=t(toFixedPoint(coeffToString(n.c),i,"0"),10,e,o,!0)),o<0&&n.c[0]&&(r="-"+r)),r},l.valueOf=l.toJSON=function(){return C(this)},l._isBigNumber=!0,l[Symbol.toStringTag]="BigNumber",l[Symbol.for("nodejs.util.inspect.custom")]=l.valueOf,null!=e&&y.set(e),y}function bitFloor(e){var r=0|e;return e>0||e===r?r:r-1}function coeffToString(e){for(var r,t,n=1,o=e.length,i=e[0]+"";n<o;){for(r=e[n++]+"",t=LOG_BASE-r.length;t--;r="0"+r);i+=r}for(o=i.length;48===i.charCodeAt(--o););return i.slice(0,o+1||1)}function compare(e,r){var t,n,o=e.c,i=r.c,a=e.s,u=r.s,c=e.e,s=r.e;if(!a||!u)return null;if(t=o&&!o[0],n=i&&!i[0],t||n)return t?n?0:-u:a;if(a!=u)return a;if(t=a<0,n=c==s,!o||!i)return n?0:!o^t?1:-1;if(!n)return c>s^t?1:-1;for(u=(c=o.length)<(s=i.length)?c:s,a=0;a<u;a++)if(o[a]!=i[a])return o[a]>i[a]^t?1:-1;return c==s?0:c>s^t?1:-1}function intCheck(e,r,t,n){if(e<r||e>t||e!==mathfloor(e))throw Error(bignumberError+(n||"Argument")+("number"==typeof e?e<r||e>t?" out of range: ":" not an integer: ":" not a primitive number: ")+String(e))}function isOdd(e){var r=e.c.length-1;return bitFloor(e.e/LOG_BASE)==r&&e.c[r]%2!=0}function toExponential(e,r){return(e.length>1?e.charAt(0)+"."+e.slice(1):e)+(r<0?"e":"e+")+r}function toFixedPoint(e,r,t){var n,o;if(r<0){for(o=t+".";++r;o+=t);e=o+e}else if(++r>(n=e.length)){for(o=t,r-=n;--r;o+=t);e+=o}else r<n&&(e=e.slice(0,r)+"."+e.slice(r));return e}var BigNumber=clone(),twosComplementBinary=function(e){for(var r=e.multipliedBy(-1).toString(2);r.length%8;)r="0"+r;var t="1"===r[0]&&-1!==r.slice(1).indexOf("1")?"11111111":"";return r=r.split("").map(function(e){return"0"===e?"1":"0"}).join(""),new BigNumber(t+r,2).plus(1)},convertDecStringToHexString=function(e){var r="string"==typeof e?new BigNumber(e):e;if(r.isNaN())throw new Error("Invalid argument: [".concat(e,"] - Expected a valid decimal value"));r.lt(0)&&(r=twosComplementBinary(r));var t=r.toString(16);return t.length%2?"0"+t:t},convertHexStringToString=function(e){return convertByteArrayToString(convertHexStringToByteArray(e))},convertNQTStringToNumber=function(e){if(null==e||""===e)throw new Error("Invalid argument");return parseFloat(e)/1e8},convertNumberToNQTString=function(e){if(null==e)throw new Error("Invalid argument");return parseFloat(e.toString()).toFixed(8).replace(".","")},convertNumericIdToAddress=function(e){if(null!=e&&0!==e.trim().length){for(var r=[],t=initialCodeword.slice(),n=0,o=e.length,i=0;i<o;i++)r[i]=e.charCodeAt(i)-"0".charCodeAt(0);var a=0,u=0;do{a=0,u=0;for(var c=0;c<o;c++)(a=10*a+r[c])>=32?(r[u]=a>>5,a&=31,u++):u>0&&(r[u]=0,u++);o=u,t[n]=a,n++}while(o>0);for(var s=[0,0,0,0],l=base32Length-1;l>=0;l--){var f=t[l]^s[3];s[3]=s[2]^gmult(30,f),s[2]=s[1]^gmult(6,f),s[1]=s[0]^gmult(9,f),s[0]=gmult(17,f)}t[13]=s[0],t[14]=s[1],t[15]=s[2],t[16]=s[3];for(var h="BURST-",g=0;g<17;g++)h+=alphabet[t[cwmap[g]]],3==(3&g)&&g<13&&(h+="-");return h}},convertStringToByteArray=function(e){for(var r=unescape(encodeURIComponent(e)),t=new Uint8Array(r.length),n=0;n<r.length;++n)t[n]=r.charCodeAt(n);return t},convertStringToHexString=function(e){return convertByteArrayToHexString(convertStringToByteArray(e))},EncoderFormat;EncoderFormat=exports.EncoderFormat||(exports.EncoderFormat={}),EncoderFormat[EncoderFormat.Text=0]="Text",EncoderFormat[EncoderFormat.Hexadecimal=1]="Hexadecimal",EncoderFormat[EncoderFormat.Base64=2]="Base64";var commonjsGlobal="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function createCommonjsModule(e,r){return e(r={exports:{}},r.exports),r.exports}var base64=createCommonjsModule(function(module,exports){var global,factory;global="undefined"!=typeof self?self:"undefined"!=typeof window?window:commonjsGlobal,factory=function(global){global=global||{};var _Base64=global.Base64,version="2.5.1",buffer;if(module.exports)try{buffer=eval("require('buffer').Buffer")}catch(e){buffer=void 0}var b64chars="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",b64tab=function(e){for(var r={},t=0,n=e.length;t<n;t++)r[e.charAt(t)]=t;return r}(b64chars),fromCharCode=String.fromCharCode,cb_utob=function(e){if(e.length<2)return(r=e.charCodeAt(0))<128?e:r<2048?fromCharCode(192|r>>>6)+fromCharCode(128|63&r):fromCharCode(224|r>>>12&15)+fromCharCode(128|r>>>6&63)+fromCharCode(128|63&r);var r=65536+1024*(e.charCodeAt(0)-55296)+(e.charCodeAt(1)-56320);return fromCharCode(240|r>>>18&7)+fromCharCode(128|r>>>12&63)+fromCharCode(128|r>>>6&63)+fromCharCode(128|63&r)},re_utob=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,utob=function(e){return e.replace(re_utob,cb_utob)},cb_encode=function(e){var r=[0,2,1][e.length%3],t=e.charCodeAt(0)<<16|(e.length>1?e.charCodeAt(1):0)<<8|(e.length>2?e.charCodeAt(2):0);return[b64chars.charAt(t>>>18),b64chars.charAt(t>>>12&63),r>=2?"=":b64chars.charAt(t>>>6&63),r>=1?"=":b64chars.charAt(63&t)].join("")},btoa=global.btoa?function(e){return global.btoa(e)}:function(e){return e.replace(/[\s\S]{1,3}/g,cb_encode)},_encode=buffer?buffer.from&&Uint8Array&&buffer.from!==Uint8Array.from?function(e){return(e.constructor===buffer.constructor?e:buffer.from(e)).toString("base64")}:function(e){return(e.constructor===buffer.constructor?e:new buffer(e)).toString("base64")}:function(e){return btoa(utob(e))},encode=function(e,r){return r?_encode(String(e)).replace(/[+\/]/g,function(e){return"+"==e?"-":"_"}).replace(/=/g,""):_encode(String(e))},encodeURI=function(e){return encode(e,!0)},re_btou=new RegExp(["[À-ß][-¿]","[à-ï][-¿]{2}","[ð-÷][-¿]{3}"].join("|"),"g"),cb_btou=function(e){switch(e.length){case 4:var r=((7&e.charCodeAt(0))<<18|(63&e.charCodeAt(1))<<12|(63&e.charCodeAt(2))<<6|63&e.charCodeAt(3))-65536;return fromCharCode(55296+(r>>>10))+fromCharCode(56320+(1023&r));case 3:return fromCharCode((15&e.charCodeAt(0))<<12|(63&e.charCodeAt(1))<<6|63&e.charCodeAt(2));default:return fromCharCode((31&e.charCodeAt(0))<<6|63&e.charCodeAt(1))}},btou=function(e){return e.replace(re_btou,cb_btou)},cb_decode=function(e){var r=e.length,t=r%4,n=(r>0?b64tab[e.charAt(0)]<<18:0)|(r>1?b64tab[e.charAt(1)]<<12:0)|(r>2?b64tab[e.charAt(2)]<<6:0)|(r>3?b64tab[e.charAt(3)]:0),o=[fromCharCode(n>>>16),fromCharCode(n>>>8&255),fromCharCode(255&n)];return o.length-=[0,0,2,1][t],o.join("")},_atob=global.atob?function(e){return global.atob(e)}:function(e){return e.replace(/\S{1,4}/g,cb_decode)},atob=function(e){return _atob(String(e).replace(/[^A-Za-z0-9\+\/]/g,""))},_decode=buffer?buffer.from&&Uint8Array&&buffer.from!==Uint8Array.from?function(e){return(e.constructor===buffer.constructor?e:buffer.from(e,"base64")).toString()}:function(e){return(e.constructor===buffer.constructor?e:new buffer(e,"base64")).toString()}:function(e){return btou(_atob(e))},decode=function(e){return _decode(String(e).replace(/[-_]/g,function(e){return"-"==e?"+":"/"}).replace(/[^A-Za-z0-9\+\/]/g,""))},noConflict=function(){var e=global.Base64;return global.Base64=_Base64,e};if(global.Base64={VERSION:version,atob:atob,btoa:btoa,fromBase64:decode,toBase64:encode,utob:utob,encode:encode,encodeURI:encodeURI,btou:btou,decode:decode,noConflict:noConflict,__buffer__:buffer},"function"==typeof Object.defineProperty){var noEnum=function(e){return{value:e,enumerable:!1,writable:!0,configurable:!0}};global.Base64.extendString=function(){Object.defineProperty(String.prototype,"fromBase64",noEnum(function(){return decode(this)})),Object.defineProperty(String.prototype,"toBase64",noEnum(function(e){return encode(this,e)})),Object.defineProperty(String.prototype,"toBase64URI",noEnum(function(){return encode(this,!0)}))}}return global.Meteor&&(Base64=global.Base64),module.exports&&(module.exports.Base64=global.Base64),{Base64:global.Base64}},module.exports=factory(global)}),base64_1=base64.Base64,convertStringToBase64String=function(e){return!(arguments.length>1&&void 0!==arguments[1])||arguments[1]?base64_1.encodeURI(e):base64_1.encode(e)};function encodePayload(e,r){var t=e;switch("string"!=typeof e&&(t=JSON.stringify(e)),r){case exports.EncoderFormat.Hexadecimal:return convertStringToHexString(t);case exports.EncoderFormat.Base64:return convertStringToBase64String(t);case exports.EncoderFormat.Text:default:return t}}var createDeeplink=function(e){var r=e.encoderFormat,t=void 0===r?exports.EncoderFormat.Base64:r,n=e.domain,o=e.action,i=e.payload,a="burst.".concat(n,"://v1");return o&&(a+="?action=".concat(o)),i&&(a+="&payload=".concat(encodePayload(i,t))),a},MandatoryPattern=/^burst.(.+):\/\/(v.+?)\??/i,parseDeeplink=function(e){var r=function(){throw new Error("Invalid deeplink: "+e)},t=function(e,t){return e.startsWith(t+"=")||r(),e.split("=")[1]},n=e.match(MandatoryPattern);n&&3===n.length||r();var o={domain:n[1],version:n[2],action:void 0,payload:void 0,decodedPayload:void 0};try{var i=e.indexOf("?");if(-1!==i){var a=e.substring(i+1).split("&");a.length>=1&&(a.length>2&&r(),o.action=t(a[0],"action"),2===a.length&&(o.payload=t(a[1],"payload")))}}catch(e){r()}return o};function sumNQTStringToNumber(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++)r[t]=arguments[t];return r.reduce(function(e,r){return e+convertNQTStringToNumber(r)},0)}var BurstSymbol="Ƀ",BurstPlanckSymbol="ƀ",FeeQuantPlanck=735e3,OneBurstPlanck=1e8;function _classCallCheck(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function _createClass(e,r,t){return r&&_defineProperties(e.prototype,r),t&&_defineProperties(e,t),e}var BurstTime=function(){function e(r){_classCallCheck(this,e),this._burstTimestamp=r}return _createClass(e,[{key:"getBurstTimestamp",value:function(){return this._burstTimestamp}},{key:"setBurstTimestamp",value:function(e){this._burstTimestamp=e}},{key:"getEpoch",value:function(){return 1e3*(GenesisBlockTime+this._burstTimestamp)}},{key:"getDate",value:function(){return new Date(this.getEpoch())}},{key:"setDate",value:function(e){this._burstTimestamp=Math.round(e.getTime()/1e3)-GenesisBlockTime}},{key:"equals",value:function(e){return this._burstTimestamp===e._burstTimestamp}},{key:"before",value:function(e){return this._burstTimestamp<e._burstTimestamp}},{key:"after",value:function(e){return this._burstTimestamp>e._burstTimestamp}}],[{key:"fromBurstTimestamp",value:function(r){return new e(r)}},{key:"fromDate",value:function(r){var t=new e(0);return t.setDate(r),t}}]),e}(),BurstValueFormat;function assureValidValue(e){if(!e||!/^-?\d*(\.\d+)?$/.test(e))throw new Error("Invalid value: ".concat(e))}BigNumber.config({EXPONENTIAL_AT:[-9,20]}),BurstValueFormat=exports.BurstValueFormat||(exports.BurstValueFormat={}),BurstValueFormat[BurstValueFormat.PLANCK=0]="PLANCK",BurstValueFormat[BurstValueFormat.BURST=1]="BURST";var BurstValue=function(){function e(r){_classCallCheck(this,e),assureValidValue(r),this._planck=new BigNumber(r)}return _createClass(e,[{key:"getRaw",value:function(){return this._planck}},{key:"getPlanck",value:function(){return this._planck.toString()}},{key:"setPlanck",value:function(e){assureValidValue(e),this._planck=new BigNumber(e)}},{key:"getBurst",value:function(){return this._planck.dividedBy(1e8).toString()}},{key:"setBurst",value:function(e){assureValidValue(e),this._planck=new BigNumber(e).multipliedBy(1e8)}},{key:"equals",value:function(e){return this._planck.eq(e._planck)}},{key:"lessOrEqual",value:function(e){return this._planck.lte(e._planck)}},{key:"less",value:function(e){return this._planck.lt(e._planck)}},{key:"greaterOrEqual",value:function(e){return this._planck.gte(e._planck)}},{key:"greater",value:function(e){return this._planck.gt(e._planck)}},{key:"add",value:function(e){return this._planck=this._planck.plus(e._planck),this}},{key:"subtract",value:function(e){return this._planck=this._planck.minus(e._planck),this}},{key:"multiply",value:function(e){return this._planck=this._planck.multipliedBy(e),this}},{key:"divide",value:function(e){if(0===e)throw new Error("Division by zero");return this._planck=this._planck.div(e),this}},{key:"toString",value:function(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:exports.BurstValueFormat.BURST)===exports.BurstValueFormat.BURST?"".concat(BurstSymbol," ").concat(this.getBurst()):"".concat(BurstPlanckSymbol," ").concat(this._planck)}}],[{key:"fromPlanck",value:function(r){return new e(r)}},{key:"fromBurst",value:function(r){var t=new e("0");return t.setBurst("number"==typeof r?r.toString(10):r),t}}]),e}();return exports.BurstPlanckSymbol=BurstPlanckSymbol,exports.BurstSymbol=BurstSymbol,exports.BurstTime=BurstTime,exports.BurstValue=BurstValue,exports.FeeQuantPlanck=FeeQuantPlanck,exports.OneBurstPlanck=OneBurstPlanck,exports.convertAddressToNumericId=convertAddressToNumericId,exports.convertBurstTimeToDate=convertBurstTimeToDate,exports.convertBurstTimeToEpochTime=convertBurstTimeToEpochTime,exports.convertByteArrayToHexString=convertByteArrayToHexString,exports.convertByteArrayToString=convertByteArrayToString,exports.convertDateToBurstTime=convertDateToBurstTime,exports.convertDecStringToHexString=convertDecStringToHexString,exports.convertHexEndianess=convertHexEndianess,exports.convertHexStringToByteArray=convertHexStringToByteArray,exports.convertHexStringToDecString=convertHexStringToDecString,exports.convertHexStringToString=convertHexStringToString,exports.convertNQTStringToNumber=convertNQTStringToNumber,exports.convertNumberToNQTString=convertNumberToNQTString,exports.convertNumericIdToAddress=convertNumericIdToAddress,exports.convertStringToByteArray=convertStringToByteArray,exports.convertStringToHexString=convertStringToHexString,exports.createDeeplink=createDeeplink,exports.isBurstAddress=isBurstAddress,exports.isValid=isValid,exports.parseDeeplink=parseDeeplink,exports.sumNQTStringToNumber=sumNQTStringToNumber,exports}({}); | ||
//# sourceMappingURL=burstjs.util.min.js.map |
@@ -10,2 +10,3 @@ export * from './convertAddressToNumericId'; | ||
export * from './convertHexStringToDecString'; | ||
export * from './convertDecStringToHexString'; | ||
export * from './convertHexStringToString'; | ||
@@ -12,0 +13,0 @@ export * from './convertNQTStringToNumber'; |
@@ -10,2 +10,3 @@ export * from './convertAddressToNumericId'; | ||
export * from './convertHexStringToDecString'; | ||
export * from './convertDecStringToHexString'; | ||
export * from './convertHexStringToString'; | ||
@@ -12,0 +13,0 @@ export * from './convertNQTStringToNumber'; |
@@ -15,2 +15,3 @@ "use strict"; | ||
__export(require("./convertHexStringToDecString")); | ||
__export(require("./convertDecStringToHexString")); | ||
__export(require("./convertHexStringToString")); | ||
@@ -17,0 +18,0 @@ __export(require("./convertNQTStringToNumber")); |
{ | ||
"name": "@burstjs/util", | ||
"version": "0.5.0-beta.9", | ||
"version": "0.5.0-beta.10", | ||
"description": "Useful utilities and tools for building Burstcoin applications", | ||
@@ -59,3 +59,3 @@ "keywords": [ | ||
}, | ||
"gitHead": "4218e0389d22c60d3a7e166c1cb167b95a3c89de", | ||
"gitHead": "3e56514d5c74b29d3fd90991ec6238d48bb5f425", | ||
"dependencies": { | ||
@@ -62,0 +62,0 @@ "bignumber.js": "^9.0.0", |
@@ -6,2 +6,4 @@ import {convertHexStringToByteArray} from '../convertHexStringToByteArray'; | ||
import {convertHexEndianess} from '../convertHexEndianess'; | ||
import {convertDecStringToHexString} from '../convertDecStringToHexString'; | ||
import BigNumber from 'bignumber.js'; | ||
@@ -84,2 +86,23 @@ describe('Hex String Conversions', () => { | ||
describe('convertDecStringToHexString', () => { | ||
it('should convert positive number as expected', () => { | ||
expect(convertDecStringToHexString('12345678901234567890')).toEqual('ab54a98ceb1f0ad2'); | ||
}); | ||
it('should convert zero number as expected', () => { | ||
expect(convertDecStringToHexString(new BigNumber('0'))).toEqual('00'); | ||
}); | ||
it('should convert negative number as two\'s complement', () => { | ||
expect(convertDecStringToHexString(new BigNumber('-1234567890'))).toEqual('b669fd2e'); | ||
}); | ||
it('should throw an error on invalid number', () => { | ||
expect(() => { | ||
convertDecStringToHexString('abc'); | ||
}).toThrow('Invalid argument: [abc] - Expected a valid decimal value'); | ||
}); | ||
}); | ||
}); |
@@ -15,2 +15,3 @@ /** | ||
export * from './convertHexStringToDecString'; | ||
export * from './convertDecStringToHexString'; | ||
export * from './convertHexStringToString'; | ||
@@ -17,0 +18,0 @@ export * from './convertNQTStringToNumber'; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
665573
169
5954