Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

a-calc

Package Overview
Dependencies
Maintainers
1
Versions
161
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

a-calc - npm Package Compare versions

Comparing version 1.1.1 to 1.2.0

2

browser/index.js

@@ -1,1 +0,1 @@

var a_calc=function(e){"use strict";function R(e){return(R="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})(e)}function N(e){return function(e){if(Array.isArray(e))return x(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){var r;if(e)return"string"==typeof e?x(e,t):"Map"===(r="Object"===(r=Object.prototype.toString.call(e).slice(8,-1))&&e.constructor?e.constructor.name:r)||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?x(e,t):void 0}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function x(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var A="1.1.1",S=/^[+-]?\d[\d.]*(?:e\+|E\+|e-|E-|e|E)?\d*$/,j=/^[+-]?\d[\d.]*(?:e\+|E\+|e-|E-|e|E)?\d*\D*$/;function k(e){return-1<"+-*/%()**".indexOf(e)}function P(e){switch(e){case"+":case"-":return 1;case"*":case"/":case"%":return 2;case"**":return 3;default:return 0}}function f(e){return void 0!==e}function p(e){return null!==e}function T(e){return"string"==typeof e&&!!S.test(e)}var o={initial:"initial",number:"number",variable:"var",symbol:"symbol",percent:"percent",round:"round",plus:"plus",comma:"comma",fraction:"fraction",scientific:"scientific"},B="<>=";function $(e){for(var t=o.initial,r=[],n=[];e;){var i=e[0];if(t===o.initial)if(B.includes(i))t=o.symbol,r.push(i),e=e.slice(1);else if("~"===i)t=o.round,r.push(i),e=e.slice(1);else if("-"===i){if(t=o.initial,/[Ee]/.test(e[1]))n.push({type:"scientific",value:e[1]});else{if(!/[Nn]/.test(e[1]))throw new Error("不识别的fmt字符:".concat(e.slice(2)));n.push({type:"to-number",value:e[1]})}e=e.slice(2)}else{if("/"===i)t=o.initial,n.push({type:"fraction",value:i});else if(/[a-zA-Z_]/.test(i))t=o.variable,r.push(i);else if(/\d/.test(i))t=o.number,r.push(i);else if("+"===i)t=o.initial,n.push({type:"plus",value:i});else if(","===i)t=o.initial,n.push({type:"comma",value:i});else if("%"===i)t=o.initial,n.push({type:"percent",value:i});else if(!/\s/.test(i))throw new Error("不识别的fmt字符:".concat(i));e=e.slice(1)}else if(t===o.number)/\d/.test(i)?(r.push(i),e=e.slice(1)):(n.push({type:"number",value:r.join("")}),r.length=0,t=o.initial);else if(t===o.variable)/[\$\w_\-.\[\]"']/.test(i)?(r.push(i),e=e.slice(1)):(n.push({type:"var",value:r.join("")}),r.length=0,t=o.initial);else if(t===o.symbol)/\s/.test(i)?e=e.slice(1):B.includes(i)?(r.push(i),e=e.slice(1)):(n.push({type:"symbol",value:r.join("")}),r.length=0,t=o.initial);else{if(t!==o.round)throw new Error("错误的自动机状态");if(/\s/.test(i))e=e.slice(1);else{if(!("56+-".includes(i)&&r.length<2))throw new Error("舍入格式化语法错误:".concat(i));r.push(i),e=e.slice(1),n.push({type:"round",value:r.join("")}),r.length=0,t=o.initial}}}if(0<r.length&&(n.push({type:t,value:r.join("")}),r.length=0,t=o.initial),1<n.filter(function(e){return"number"===e.type}).length)throw new Error("格式化字符串错误,发现多余的数字");return n}var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},r=Array.isArray,t="object"==R(t)&&t&&t.Object===Object&&t,n=t,i="object"==("undefined"==typeof self?"undefined":R(self))&&self&&self.Object===Object&&self,n=n||i||Function("return this")(),i=n.Symbol,s=Object.prototype,F=s.hasOwnProperty,D=s.toString,u=i?i.toStringTag:void 0;var I=Object.prototype.toString;var X=function(e){var t=F.call(e,u),r=e[u];try{var n=!(e[u]=void 0)}catch(e){}var i=D.call(e);return n&&(t?e[u]=r:delete e[u]),i},Y=function(e){return I.call(e)},J=i?i.toStringTag:void 0;function K(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":(J&&J in Object(e)?X:Y)(e)}function Q(e){return null!=e&&"object"==R(e)}var ee=K,te=Q;function re(e){return"symbol"==R(e)||te(e)&&"[object Symbol]"==ee(e)}var ne=r,ie=re,oe=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,se=/^\w*$/;function ue(e,t){var r;return!ne(e)&&(!("number"!=(r=R(e))&&"symbol"!=r&&"boolean"!=r&&null!=e&&!ie(e))||se.test(e)||!oe.test(e)||null!=t&&e in Object(t))}function le(e){var t=R(e);return null!=e&&("object"==t||"function"==t)}var ce=K,ae=le;function fe(e){return!!ae(e)&&("[object Function]"==(e=ce(e))||"[object GeneratorFunction]"==e||"[object AsyncFunction]"==e||"[object Proxy]"==e)}var s=n["__core-js_shared__"],pe=(s=/[^.]+$/.exec(s&&s.keys&&s.keys.IE_PROTO||""))?"Symbol(src)_1."+s:"";var he=Function.prototype.toString;function ge(e){if(null!=e){try{return he.call(e)}catch(e){}try{return e+""}catch(e){}}return""}var ve=fe,de=function(e){return!!pe&&pe in e},ye=le,me=ge,we=/^\[object .+?Constructor\]$/,s=Function.prototype,l=Object.prototype,s=s.toString,l=l.hasOwnProperty,be=RegExp("^"+s.call(l).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");var _e=function(e){return!(!ye(e)||de(e))&&(ve(e)?be:we).test(me(e))},Ee=function(e,t){return null==e?void 0:e[t]};function c(e,t){return e=Ee(e,t),_e(e)?e:void 0}var s=c(Object,"create"),Oe=s;var Ne=s,xe=Object.prototype.hasOwnProperty;var Ae=s,Se=Object.prototype.hasOwnProperty;var je=s;function ke(e){return e=this.has(e)&&delete this.__data__[e],this.size-=e?1:0,e}function Pe(e){var t,r=this.__data__;return Ne?"__lodash_hash_undefined__"===(t=r[e])?void 0:t:xe.call(r,e)?r[e]:void 0}function Te(e){var t=this.__data__;return Ae?void 0!==t[e]:Se.call(t,e)}function Be(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=je&&void 0===t?"__lodash_hash_undefined__":t,this}function a(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}a.prototype.clear=function(){this.__data__=Oe?Oe(null):{},this.size=0},a.prototype.delete=ke,a.prototype.get=Pe,a.prototype.has=Te,a.prototype.set=Be;l=a;var $e=function(e,t){return e===t||e!=e&&t!=t};function Fe(e,t){for(var r=e.length;r--;)if($e(e[r][0],t))return r;return-1}var De=Fe,Ie=Array.prototype.splice;var Re=Fe;var Ce=Fe;var Ue=Fe;function ze(e){var t=this.__data__;return!((e=De(t,e))<0||(e==t.length-1?t.pop():Ie.call(t,e,1),--this.size,0))}function Me(e){var t=this.__data__;return(e=Re(t,e))<0?void 0:t[e][1]}function Le(e){return-1<Ce(this.__data__,e)}function Ge(e,t){var r=this.__data__,n=Ue(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this}function h(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}h.prototype.clear=function(){this.__data__=[],this.size=0},h.prototype.delete=ze,h.prototype.get=Me,h.prototype.has=Le,h.prototype.set=Ge;var s=h,g=c(n,"Map"),qe=l,Ve=s,We=g;var He=function(e){var t=R(e);return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e};function Ze(e,t){return e=e.__data__,He(t)?e["string"==typeof t?"string":"hash"]:e.map}var Xe=Ze;var Ye=Ze;var Je=Ze;var Ke=Ze;function Qe(e){return e=Xe(this,e).delete(e),this.size-=e?1:0,e}function et(e){return Ye(this,e).get(e)}function tt(e){return Je(this,e).has(e)}function rt(e,t){var r=Ke(this,e),n=r.size;return r.set(e,t),this.size+=r.size==n?0:1,this}function v(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}v.prototype.clear=function(){this.size=0,this.__data__={hash:new qe,map:new(We||Ve),string:new qe}},v.prototype.delete=Qe,v.prototype.get=et,v.prototype.has=tt,v.prototype.set=rt;var nt=v;function it(n,i){if("function"!=typeof n||null!=i&&"function"!=typeof i)throw new TypeError("Expected a function");function o(){var e=arguments,t=i?i.apply(this,e):e[0],r=o.cache;return r.has(t)?r.get(t):(e=n.apply(this,e),o.cache=r.set(t,e)||r,e)}return o.cache=new(it.Cache||nt),o}it.Cache=nt;var ot=it;var st=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ut=/\\(\\)?/g,l=function(e){var t=(e=ot(e,function(e){return 500===t.size&&t.clear(),e})).cache;return e}(function(e){var i=[];return 46===e.charCodeAt(0)&&i.push(""),e.replace(st,function(e,t,r,n){i.push(r?n.replace(ut,"$1"):t||e)}),i});var lt=function(e,t){for(var r=-1,n=null==e?0:e.length,i=Array(n);++r<n;)i[r]=t(e[r],r,e);return i},ct=r,at=re,s=i?i.prototype:void 0,ft=s?s.toString:void 0;var pt=function e(t){var r;return"string"==typeof t?t:ct(t)?lt(t,e)+"":at(t)?ft?ft.call(t):"":"0"==(r=t+"")&&1/t==-1/0?"-0":r};var ht=r,gt=ue,vt=l,dt=function(e){return null==e?"":pt(e)};var yt=re;var mt=function(e,t){return ht(e)?e:gt(e,t)?[e]:vt(dt(e))},wt=function(e){var t;return"string"==typeof e||yt(e)?e:"0"==(t=e+"")&&1/e==-1/0?"-0":t};var bt=function(e,t){for(var r=0,n=(t=mt(t,e)).length;null!=e&&r<n;)e=e[wt(t[r++])];return r&&r==n?e:void 0};var d=function(e,t,r){return void 0===(e=null==e?void 0:bt(e,t))?r:e};var y={initial:"initial",number:"number",scientific:"scientific",operator:"operator",bracket:"bracket",var:"var"},_t="+-",Et="*/%",Ot="()";function Nt(e,t){for(var r,n,i,o=1<arguments.length&&void 0!==t&&t,s=y.initial,u=[],l=[],c=function(){u.push(r),e=e.slice(1)},a=function(e){l.push({type:e,value:u.join("")}),u.length=0},f=function(){e=e.slice(1)};e;)switch(r=e[0],s){case y.initial:if(_t.includes(r)){var p=l.at(-1),s=0===l.length||"operator"===p.type||"("===p?y.number:y.operator;c()}else if(Et.includes(r))s=y.operator,c();else if(/\d/.test(r))s=y.number,c();else if(Ot.includes(r))s=y.bracket;else if(/[a-zA-Z_$]/.test(r))s=y.var,c();else{if(!/\s/.test(r))throw new Error("不识别的字符".concat(r));f()}break;case y.bracket:l.push({type:y.bracket,value:r}),f(),s=y.initial;break;case y.operator:p=u.at(-1);"*"===r&&"*"===p&&c(),a(y.operator),s=y.initial;break;case y.number:if(/\d/.test(r))c();else if("."===r){if(0===u.length||u.includes("."))throw new Error("非法的小数部分".concat(u.join("")));c()}else"Ee".includes(r)?(s=y.scientific,c()):["auto","on",!0].includes(o)&&/[^*/+\-()\s]/.test(r)||"space"===o&&/\S/.test(r)?c():(a(y.number),s=y.initial);break;case y.scientific:/\d/.test(r)?c():_t.includes(r)?(n=u.slice(1),i=u.at(-1),n.includes(r)||!/[Ee]/.test(i)?(a(y.scientific),s=y.initial):c()):["auto","on",!0].includes(o)&&/[^*/+\-()\s]/.test(r)||"space"===o&&/\S/.test(r)?c():(a(y.scientific),s=y.initial);break;case y.var:/[\w_.\[\]"']/.test(r)?c():(a(y.var),s=y.initial);break;default:throw new Error("状态错误")}return 0!==u.length&&(l.push({type:s,value:u.join("")}),u.length=0,s=y.initial),l}function xt(e,t,r){if(null===t)throw new Error("错误的填充数据:",t);for(var n=[],i=0;i<e.length;i++){var o=e[i];if("var"!==o.type)n.push(o);else{if("undefined"===o.value||"NaN"===o.value)throw new Error("key不应该为:".concat(o.value));for(var s=null,u=0;u<t.length;u++){var l=t[u],l=d(l,o.value);if(void 0!==l){s=l;break}}if(null===s)throw new Error("token填充失败,请确认".concat(o,"存在"));if("string"==typeof s){if(""===s.trim())throw new Error("token填充失败,".concat(o.value,"值不可为空字符"));if([!0,"on","auto","space"].includes(r)){if(!j.test(s))throw new Error("token填充失败,".concat(o.value,"值:").concat(s,"为非法单位数字"))}else if(!T(s))throw new Error("token填充失败,".concat(o,"值:").concat(s,"为非法数字"))}s="string"!=typeof s?s.toString():s,n.push({type:"number",value:s})}}return n}function At(e){for(var t,r=[],n=[],i=e.map(function(e){return e.value});0<i.length;){var o=i.shift();if(k(o))if("("===o)r.push(o);else if(")"===o){for(var s=r.pop();"("!==s&&0<r.length;)n.push(s),s=r.pop();if("("!==s)throw"error: unmatched ()"}else{for(;t=r[r.length-1],P(o)<=P(t)&&0<r.length;)n.push(r.pop());r.push(o)}else n.push(o)}if(0<r.length){if(")"===r[r.length-1]||"("===r[r.length-1])throw"error: unmatched ()";for(;0<r.length;)n.push(r.pop())}return n}var St=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,jt=Math.ceil,C=Math.floor,U="[BigNumber Error] ",kt=U+"Number primitive has more than 15 significant digits: ",z=1e14,M=14,Pt=9007199254740991,Tt=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],L=1e7,G=1e9;function q(e){var t=0|e;return 0<e||e===t?t:t-1}function V(e){for(var t,r,n=1,i=e.length,o=e[0]+"";n<i;){for(t=e[n++]+"",r=M-t.length;r--;t="0"+t);o+=t}for(i=o.length;48===o.charCodeAt(--i););return o.slice(0,i+1||1)}function W(e,t){var r,n,i=e.c,o=t.c,s=e.s,u=t.s,e=e.e,t=t.e;if(!s||!u)return null;if(r=i&&!i[0],n=o&&!o[0],r||n)return r?n?0:-u:s;if(s!=u)return s;if(r=s<0,n=e==t,!i||!o)return n?0:!i^r?1:-1;if(!n)return t<e^r?1:-1;for(u=(e=i.length)<(t=o.length)?e:t,s=0;s<u;s++)if(i[s]!=o[s])return i[s]>o[s]^r?1:-1;return e==t?0:t<e^r?1:-1}function H(e,t,r,n){if(e<t||r<e||e!==C(e))throw Error(U+(n||"Argument")+("number"==typeof e?e<t||r<e?" out of range: ":" not an integer: ":" not a primitive number: ")+String(e))}function Bt(e){var t=e.c.length-1;return q(e.e/M)==t&&e.c[t]%2!=0}function $t(e,t){return(1<e.length?e.charAt(0)+"."+e.slice(1):e)+(t<0?"e":"e+")+t}function Z(e,t,r){var n,i;if(t<0){for(i=r+".";++t;i+=r);e=i+e}else if(++t>(n=e.length)){for(i=r,t-=n;--t;i+=r);e+=i}else t<n&&(e=e.slice(0,t)+"."+e.slice(t));return e}var E=function I(e){var d,f,p,t,c,y,s,u,l,a,h,r=j.prototype={constructor:j,toString:null,valueOf:null},g=new j(1),m=20,w=4,v=-7,b=21,_=-1e7,E=1e7,O=!1,i=1,N=0,x={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},A="0123456789abcdefghijklmnopqrstuvwxyz",S=!0;function j(e,t){var r,n,i,o,s,u,l,c,a=this;if(!(a instanceof j))return new j(e,t);if(null==t){if(e&&!0===e._isBigNumber)return a.s=e.s,void(!e.c||e.e>E?a.c=a.e=null:e.e<_?a.c=[a.e=0]:(a.e=e.e,a.c=e.c.slice()));if((u="number"==typeof e)&&0*e==0){if(a.s=1/e<0?(e=-e,-1):1,e===~~e){for(o=0,s=e;10<=s;s/=10,o++);return void(E<o?a.c=a.e=null:(a.e=o,a.c=[e]))}c=String(e)}else{if(!St.test(c=String(e)))return p(a,c,u);a.s=45==c.charCodeAt(0)?(c=c.slice(1),-1):1}0<(s=(c=-1<(o=c.indexOf("."))?c.replace(".",""):c).search(/e/i))?(o<0&&(o=s),o+=+c.slice(s+1),c=c.substring(0,s)):o<0&&(o=c.length)}else{if(H(t,2,A.length,"Base"),10==t&&S)return F(a=new j(e),m+a.e+1,w);if(c=String(e),u="number"==typeof e){if(0*e!=0)return p(a,c,u,t);if(a.s=1/e<0?(c=c.slice(1),-1):1,j.DEBUG&&15<c.replace(/^0\.0*|\./,"").length)throw Error(kt+e)}else a.s=45===c.charCodeAt(0)?(c=c.slice(1),-1):1;for(r=A.slice(0,t),o=s=0,l=c.length;s<l;s++)if(r.indexOf(n=c.charAt(s))<0){if("."==n){if(o<s){o=l;continue}}else if(!i&&(c==c.toUpperCase()&&(c=c.toLowerCase())||c==c.toLowerCase()&&(c=c.toUpperCase()))){i=!0,s=-1,o=0;continue}return p(a,String(e),u,t)}u=!1,-1<(o=(c=f(c,t,10,a.s)).indexOf("."))?c=c.replace(".",""):o=c.length}for(s=0;48===c.charCodeAt(s);s++);for(l=c.length;48===c.charCodeAt(--l););if(c=c.slice(s,++l)){if(l-=s,u&&j.DEBUG&&15<l&&(Pt<e||e!==C(e)))throw Error(kt+a.s*e);if((o=o-s-1)>E)a.c=a.e=null;else if(o<_)a.c=[a.e=0];else{if(a.e=o,a.c=[],s=(o+1)%M,o<0&&(s+=M),s<l){for(s&&a.c.push(+c.slice(0,s)),l-=M;s<l;)a.c.push(+c.slice(s,s+=M));s=M-(c=c.slice(s)).length}else s-=l;for(;s--;c+="0");a.c.push(+c)}}else a.c=[a.e=0]}function k(e,t,r,n){for(var i,o,s=[0],u=0,l=e.length;u<l;){for(o=s.length;o--;s[o]*=t);for(s[0]+=n.indexOf(e.charAt(u++)),i=0;i<s.length;i++)r-1<s[i]&&(null==s[i+1]&&(s[i+1]=0),s[i+1]+=s[i]/r|0,s[i]%=r)}return s.reverse()}function P(e,t,r){var n,i,o,s=0,u=e.length,l=t%L,c=t/L|0;for(e=e.slice();u--;)s=((i=l*(o=e[u]%L)+(n=c*o+(o=e[u]/L|0)*l)%L*L+s)/r|0)+(n/L|0)+c*o,e[u]=i%r;return e=s?[s].concat(e):e}function T(e,t,r,n){var i,o;if(r!=n)o=n<r?1:-1;else for(i=o=0;i<r;i++)if(e[i]!=t[i]){o=e[i]>t[i]?1:-1;break}return o}function B(e,t,r,n){for(var i=0;r--;)e[r]-=i,i=e[r]<t[r]?1:0,e[r]=i*n+e[r]-t[r];for(;!e[0]&&1<e.length;e.splice(0,1));}function n(e,t,r,n){var i,o,s,u;if(null==r?r=w:H(r,0,8),!e.c)return e.toString();if(i=e.c[0],o=e.e,null==t)u=V(e.c),u=1==n||2==n&&(o<=v||b<=o)?$t(u,o):Z(u,o,"0");else if(r=(e=F(new j(e),t,r)).e,s=(u=V(e.c)).length,1==n||2==n&&(t<=r||r<=v)){for(;s<t;u+="0",s++);u=$t(u,r)}else if(t-=o,u=Z(u,r,"0"),s<r+1){if(0<--t)for(u+=".";t--;u+="0");}else if(0<(t+=r-s))for(r+1==s&&(u+=".");t--;u+="0");return e.s<0&&i?"-"+u:u}function o(e,t){for(var r,n=1,i=new j(e[0]);n<e.length;n++){if(!(r=new j(e[n])).s){i=r;break}t.call(i,r)&&(i=r)}return i}function $(e,t,r){for(var n=1,i=t.length;!t[--i];t.pop());for(i=t[0];10<=i;i/=10,n++);return(r=n+r*M-1)>E?e.c=e.e=null:r<_?e.c=[e.e=0]:(e.e=r,e.c=t),e}function F(e,t,r,n){var i,o,s,u,l,c,a,f=e.c,p=Tt;if(f){e:{for(i=1,u=f[0];10<=u;u/=10,i++);if((o=t-i)<0)o+=M,s=t,a=(l=f[c=0])/p[i-s-1]%10|0;else if((c=jt((o+1)/M))>=f.length){if(!n)break e;for(;f.length<=c;f.push(0));l=a=0,s=(o%=M)-M+(i=1)}else{for(l=u=f[c],i=1;10<=u;u/=10,i++);a=(s=(o%=M)-M+i)<0?0:l/p[i-s-1]%10|0}if(n=n||t<0||null!=f[c+1]||(s<0?l:l%p[i-s-1]),n=r<4?(a||n)&&(0==r||r==(e.s<0?3:2)):5<a||5==a&&(4==r||n||6==r&&(0<o?0<s?l/p[i-s]:0:f[c-1])%10&1||r==(e.s<0?8:7)),t<1||!f[0])return f.length=0,n?(t-=e.e+1,f[0]=p[(M-t%M)%M],e.e=-t||0):f[0]=e.e=0,e;if(0==o?(f.length=c,u=1,c--):(f.length=c+1,u=p[M-o],f[c]=0<s?C(l/p[i-s]%p[s])*u:0),n)for(;;){if(0==c){for(o=1,s=f[0];10<=s;s/=10,o++);for(s=f[0]+=u,u=1;10<=s;s/=10,u++);o!=u&&(e.e++,f[0]==z)&&(f[0]=1);break}if(f[c]+=u,f[c]!=z)break;f[c--]=0,u=1}for(o=f.length;0===f[--o];f.pop());}e.e>E?e.c=e.e=null:e.e<_&&(e.c=[e.e=0])}return e}function D(e){var t,r=e.e;return null===r?e.toString():(t=V(e.c),t=r<=v||b<=r?$t(t,r):Z(t,r,"0"),e.s<0?"-"+t:t)}return j.clone=I,j.ROUND_UP=0,j.ROUND_DOWN=1,j.ROUND_CEIL=2,j.ROUND_FLOOR=3,j.ROUND_HALF_UP=4,j.ROUND_HALF_DOWN=5,j.ROUND_HALF_EVEN=6,j.ROUND_HALF_CEIL=7,j.ROUND_HALF_FLOOR=8,j.EUCLID=9,j.config=j.set=function(e){var t,r;if(null!=e){if("object"!=R(e))throw Error(U+"Object expected: "+e);if(e.hasOwnProperty(t="DECIMAL_PLACES")&&(H(r=e[t],0,G,t),m=r),e.hasOwnProperty(t="ROUNDING_MODE")&&(H(r=e[t],0,8,t),w=r),e.hasOwnProperty(t="EXPONENTIAL_AT")&&((r=e[t])&&r.pop?(H(r[0],-G,0,t),H(r[1],0,G,t),v=r[0],b=r[1]):(H(r,-G,G,t),v=-(b=r<0?-r:r))),e.hasOwnProperty(t="RANGE"))if((r=e[t])&&r.pop)H(r[0],-G,-1,t),H(r[1],1,G,t),_=r[0],E=r[1];else{if(H(r,-G,G,t),!r)throw Error(U+t+" cannot be zero: "+r);_=-(E=r<0?-r:r)}if(e.hasOwnProperty(t="CRYPTO")){if((r=e[t])!==!!r)throw Error(U+t+" not true or false: "+r);if(r&&("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes))throw O=!r,Error(U+"crypto unavailable");O=r}if(e.hasOwnProperty(t="MODULO_MODE")&&(H(r=e[t],0,9,t),i=r),e.hasOwnProperty(t="POW_PRECISION")&&(H(r=e[t],0,G,t),N=r),e.hasOwnProperty(t="FORMAT")){if("object"!=R(r=e[t]))throw Error(U+t+" not an object: "+r);x=r}if(e.hasOwnProperty(t="ALPHABET")){if("string"!=typeof(r=e[t])||/^.?$|[+\-.\s]|(.).*\1/.test(r))throw Error(U+t+" invalid: "+r);S="0123456789"==r.slice(0,10),A=r}}return{DECIMAL_PLACES:m,ROUNDING_MODE:w,EXPONENTIAL_AT:[v,b],RANGE:[_,E],CRYPTO:O,MODULO_MODE:i,POW_PRECISION:N,FORMAT:x,ALPHABET:A}},j.isBigNumber=function(e){if(!e||!0!==e._isBigNumber)return!1;if(!j.DEBUG)return!0;var t,r,n=e.c,i=e.e,o=e.s;e:if("[object Array]"=={}.toString.call(n)){if((1===o||-1===o)&&-G<=i&&i<=G&&i===C(i))if(0===n[0]){if(0===i&&1===n.length)return!0}else if((t=(i+1)%M)<1&&(t+=M),String(n[0]).length==t){for(t=0;t<n.length;t++)if((r=n[t])<0||z<=r||r!==C(r))break e;if(0!==r)return!0}}else if(null===n&&null===i&&(null===o||1===o||-1===o))return!0;throw Error(U+"Invalid BigNumber: "+e)},j.maximum=j.max=function(){return o(arguments,r.lt)},j.minimum=j.min=function(){return o(arguments,r.gt)},j.random=(t=9007199254740992,c=Math.random()*t&2097151?function(){return C(Math.random()*t)}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)},function(e){var t,r,n,i,o,s=0,u=[],l=new j(g);if(null==e?e=m:H(e,0,G),i=jt(e/M),O)if(crypto.getRandomValues){for(t=crypto.getRandomValues(new Uint32Array(i*=2));s<i;)9e15<=(o=131072*t[s]+(t[s+1]>>>11))?(r=crypto.getRandomValues(new Uint32Array(2)),t[s]=r[0],t[s+1]=r[1]):(u.push(o%1e14),s+=2);s=i/2}else{if(!crypto.randomBytes)throw O=!1,Error(U+"crypto unavailable");for(t=crypto.randomBytes(i*=7);s<i;)9e15<=(o=281474976710656*(31&t[s])+1099511627776*t[s+1]+4294967296*t[s+2]+16777216*t[s+3]+(t[s+4]<<16)+(t[s+5]<<8)+t[s+6])?crypto.randomBytes(7).copy(t,s):(u.push(o%1e14),s+=7);s=i/7}if(!O)for(;s<i;)(o=c())<9e15&&(u[s++]=o%1e14);for(i=u[--s],e%=M,i&&e&&(u[s]=C(i/(o=Tt[M-e]))*o);0===u[s];u.pop(),s--);if(s<0)u=[n=0];else{for(n=-1;0===u[0];u.splice(0,1),n-=M);for(s=1,o=u[0];10<=o;o/=10,s++);s<M&&(n-=M-s)}return l.e=n,l.c=u,l}),j.sum=function(){for(var e=1,t=arguments,r=new j(t[0]);e<t.length;)r=r.plus(t[e++]);return r},y="0123456789",f=function(e,t,r,n,i){var o,s,u,l,c,a,f,p,h=e.indexOf("."),g=m,v=w;for(0<=h&&(l=N,N=0,e=e.replace(".",""),a=(p=new j(t)).pow(e.length-h),N=l,p.c=k(Z(V(a.c),a.e,"0"),10,r,y),p.e=p.c.length),u=l=(f=k(e,t,r,i?(o=A,y):(o=y,A))).length;0==f[--l];f.pop());if(!f[0])return o.charAt(0);if(h<0?--u:(a.c=f,a.e=u,a.s=n,f=(a=d(a,p,g,v,r)).c,c=a.r,u=a.e),h=f[s=u+g+1],l=r/2,c=c||s<0||null!=f[s+1],c=v<4?(null!=h||c)&&(0==v||v==(a.s<0?3:2)):l<h||h==l&&(4==v||c||6==v&&1&f[s-1]||v==(a.s<0?8:7)),s<1||!f[0])e=c?Z(o.charAt(1),-g,o.charAt(0)):o.charAt(0);else{if(f.length=s,c)for(--r;++f[--s]>r;)f[s]=0,s||(++u,f=[1].concat(f));for(l=f.length;!f[--l];);for(h=0,e="";h<=l;e+=o.charAt(f[h++]));e=Z(e,u,o.charAt(0))}return e},d=function(e,t,r,n,i){var o,s,u,l,c,a,f,p,h,g,v,d,y,m,w,b,_,E=e.s==t.s?1:-1,O=e.c,N=t.c;if(!(O&&O[0]&&N&&N[0]))return new j(e.s&&t.s&&(O?!N||O[0]!=N[0]:N)?O&&0==O[0]||!N?0*E:E/0:NaN);for(h=(p=new j(E)).c=[],E=r+(s=e.e-t.e)+1,i||(i=z,s=q(e.e/M)-q(t.e/M),E=E/M|0),u=0;N[u]==(O[u]||0);u++);if(N[u]>(O[u]||0)&&s--,E<0)h.push(1),l=!0;else{for(m=O.length,b=N.length,E+=2,1<(c=C(i/(N[u=0]+1)))&&(N=P(N,c,i),O=P(O,c,i),b=N.length,m=O.length),y=b,v=(g=O.slice(0,b)).length;v<b;g[v++]=0);_=N.slice(),_=[0].concat(_),w=N[0],N[1]>=i/2&&w++;do{if(c=0,(o=T(N,g,b,v))<0){if(d=g[0],b!=v&&(d=d*i+(g[1]||0)),1<(c=C(d/w)))for(f=(a=P(N,c=i<=c?i-1:c,i)).length,v=g.length;1==T(a,g,f,v);)c--,B(a,b<f?_:N,f,i),f=a.length,o=1;else 0==c&&(o=c=1),f=(a=N.slice()).length;if(B(g,a=f<v?[0].concat(a):a,v,i),v=g.length,-1==o)for(;T(N,g,b,v)<1;)c++,B(g,b<v?_:N,v,i),v=g.length}else 0===o&&(c++,g=[0])}while(h[u++]=c,g[0]?g[v++]=O[y]||0:(g=[O[y]],v=1),(y++<m||null!=g[0])&&E--);l=null!=g[0],h[0]||h.splice(0,1)}if(i==z){for(u=1,E=h[0];10<=E;E/=10,u++);F(p,r+(p.e=u+s*M-1)+1,n,l)}else p.e=s,p.r=+l;return p},s=/^(-?)0([xbo])(?=\w[\w.]*$)/i,u=/^([^.]+)\.$/,l=/^\.([^.]+)$/,a=/^-?(Infinity|NaN)$/,h=/^\s*\+(?=[\w.])|^\s+|\s+$/g,p=function(e,t,r,n){var i,o=r?t:t.replace(h,"");if(a.test(o))e.s=isNaN(o)?null:o<0?-1:1;else{if(!r&&(o=o.replace(s,function(e,t,r){return i="x"==(r=r.toLowerCase())?16:"b"==r?2:8,n&&n!=i?e:t}),n&&(i=n,o=o.replace(u,"$1").replace(l,"0.$1")),t!=o))return new j(o,i);if(j.DEBUG)throw Error(U+"Not a"+(n?" base "+n:"")+" number: "+t);e.s=null}e.c=e.e=null},r.absoluteValue=r.abs=function(){var e=new j(this);return e.s<0&&(e.s=1),e},r.comparedTo=function(e,t){return W(this,new j(e,t))},r.decimalPlaces=r.dp=function(e,t){var r,n;if(null!=e)return H(e,0,G),null==t?t=w:H(t,0,8),F(new j(this),e+this.e+1,t);if(!(e=this.c))return null;if(r=((n=e.length-1)-q(this.e/M))*M,n=e[n])for(;n%10==0;n/=10,r--);return r=r<0?0:r},r.dividedBy=r.div=function(e,t){return d(this,new j(e,t),m,w)},r.dividedToIntegerBy=r.idiv=function(e,t){return d(this,new j(e,t),0,1)},r.exponentiatedBy=r.pow=function(e,t){var r,n,i,o,s,u,l,c,a=this;if((e=new j(e)).c&&!e.isInteger())throw Error(U+"Exponent not an integer: "+D(e));if(null!=t&&(t=new j(t)),s=14<e.e,!a.c||!a.c[0]||1==a.c[0]&&!a.e&&1==a.c.length||!e.c||!e.c[0])return c=new j(Math.pow(+D(a),s?e.s*(2-Bt(e)):+D(e))),t?c.mod(t):c;if(u=e.s<0,t){if(t.c?!t.c[0]:!t.s)return new j(NaN);(n=!u&&a.isInteger()&&t.isInteger())&&(a=a.mod(t))}else{if(9<e.e&&(0<a.e||a.e<-1||(0==a.e?1<a.c[0]||s&&24e7<=a.c[1]:a.c[0]<8e13||s&&a.c[0]<=9999975e7)))return o=a.s<0&&Bt(e)?-0:0,-1<a.e&&(o=1/o),new j(u?1/o:o);N&&(o=jt(N/M+2))}for(l=s?(r=new j(.5),u&&(e.s=1),Bt(e)):(i=Math.abs(+D(e)))%2,c=new j(g);;){if(l){if(!(c=c.times(a)).c)break;o?c.c.length>o&&(c.c.length=o):n&&(c=c.mod(t))}if(i){if(0===(i=C(i/2)))break;l=i%2}else if(F(e=e.times(r),e.e+1,1),14<e.e)l=Bt(e);else{if(0==(i=+D(e)))break;l=i%2}a=a.times(a),o?a.c&&a.c.length>o&&(a.c.length=o):n&&(a=a.mod(t))}return n?c:(u&&(c=g.div(c)),t?c.mod(t):o?F(c,N,w,void 0):c)},r.integerValue=function(e){var t=new j(this);return null==e?e=w:H(e,0,8),F(t,t.e+1,e)},r.isEqualTo=r.eq=function(e,t){return 0===W(this,new j(e,t))},r.isFinite=function(){return!!this.c},r.isGreaterThan=r.gt=function(e,t){return 0<W(this,new j(e,t))},r.isGreaterThanOrEqualTo=r.gte=function(e,t){return 1===(t=W(this,new j(e,t)))||0===t},r.isInteger=function(){return!!this.c&&q(this.e/M)>this.c.length-2},r.isLessThan=r.lt=function(e,t){return W(this,new j(e,t))<0},r.isLessThanOrEqualTo=r.lte=function(e,t){return-1===(t=W(this,new j(e,t)))||0===t},r.isNaN=function(){return!this.s},r.isNegative=function(){return this.s<0},r.isPositive=function(){return 0<this.s},r.isZero=function(){return!!this.c&&0==this.c[0]},r.minus=function(e,t){var r,n,i,o,s=this,u=s.s;if(t=(e=new j(e,t)).s,!u||!t)return new j(NaN);if(u!=t)return e.s=-t,s.plus(e);var l=s.e/M,c=e.e/M,a=s.c,f=e.c;if(!l||!c){if(!a||!f)return a?(e.s=-t,e):new j(f?s:NaN);if(!a[0]||!f[0])return f[0]?(e.s=-t,e):new j(a[0]?s:3==w?-0:0)}if(l=q(l),c=q(c),a=a.slice(),u=l-c){for((i=(o=u<0)?(u=-u,a):(c=l,f)).reverse(),t=u;t--;i.push(0));i.reverse()}else for(n=(o=(u=a.length)<(t=f.length))?u:t,u=t=0;t<n;t++)if(a[t]!=f[t]){o=a[t]<f[t];break}if(o&&(i=a,a=f,f=i,e.s=-e.s),0<(t=(n=f.length)-(r=a.length)))for(;t--;a[r++]=0);for(t=z-1;u<n;){if(a[--n]<f[n]){for(r=n;r&&!a[--r];a[r]=t);--a[r],a[n]+=z}a[n]-=f[n]}for(;0==a[0];a.splice(0,1),--c);return a[0]?$(e,a,c):(e.s=3==w?-1:1,e.c=[e.e=0],e)},r.modulo=r.mod=function(e,t){var r,n=this;return e=new j(e,t),!n.c||!e.s||e.c&&!e.c[0]?new j(NaN):!e.c||n.c&&!n.c[0]?new j(n):(9==i?(t=e.s,e.s=1,r=d(n,e,0,3),e.s=t,r.s*=t):r=d(n,e,0,i),(e=n.minus(r.times(e))).c[0]||1!=i||(e.s=n.s),e)},r.multipliedBy=r.times=function(e,t){var r,n,i,o,s,u,l,c,a,f,p,h=this,g=h.c,v=(e=new j(e,t)).c;if(!(g&&v&&g[0]&&v[0]))return!h.s||!e.s||g&&!g[0]&&!v||v&&!v[0]&&!g?e.c=e.e=e.s=null:(e.s*=h.s,g&&v?(e.c=[0],e.e=0):e.c=e.e=null),e;for(t=q(h.e/M)+q(e.e/M),e.s*=h.s,(u=g.length)<(h=v.length)&&(p=g,g=v,v=p,n=u,u=h,h=n),n=u+h,p=[];n--;p.push(0));for(n=h;0<=--n;){for(a=v[n]%1e7,f=v[n]/1e7|(r=0),i=n+(o=u);n<i;)r=((l=a*(l=g[--o]%1e7)+(s=f*l+(c=g[o]/1e7|0)*a)%1e7*1e7+p[i]+r)/1e14|0)+(s/1e7|0)+f*c,p[i--]=l%1e14;p[i]=r}return r?++t:p.splice(0,1),$(e,p,t)},r.negated=function(){var e=new j(this);return e.s=-e.s||null,e},r.plus=function(e,t){var r,n=this,i=n.s;if(t=(e=new j(e,t)).s,!i||!t)return new j(NaN);if(i!=t)return e.s=-t,n.minus(e);var o=n.e/M,s=e.e/M,u=n.c,l=e.c;if(!o||!s){if(!u||!l)return new j(i/0);if(!u[0]||!l[0])return l[0]?e:new j(u[0]?n:0*i)}if(o=q(o),s=q(s),u=u.slice(),i=o-s){for((r=0<i?(s=o,l):(i=-i,u)).reverse();i--;r.push(0));r.reverse()}for((i=u.length)-(t=l.length)<0&&(r=l,l=u,u=r,t=i),i=0;t;)i=(u[--t]=u[t]+l[t]+i)/z|0,u[t]=z===u[t]?0:u[t]%z;return i&&(u=[i].concat(u),++s),$(e,u,s)},r.precision=r.sd=function(e,t){var r,n;if(null!=e&&e!==!!e)return H(e,1,G),null==t?t=w:H(t,0,8),F(new j(this),e,t);if(!(t=this.c))return null;if(r=(n=t.length-1)*M+1,n=t[n]){for(;n%10==0;n/=10,r--);for(n=t[0];10<=n;n/=10,r++);}return r=e&&this.e+1>r?this.e+1:r},r.shiftedBy=function(e){return H(e,-Pt,Pt),this.times("1e"+e)},r.squareRoot=r.sqrt=function(){var e,t,r,n,i,o=this,s=o.c,u=o.s,l=o.e,c=m+4,a=new j("0.5");if(1!==u||!s||!s[0])return new j(!u||u<0&&(!s||s[0])?NaN:s?o:1/0);if((r=0==(u=Math.sqrt(+D(o)))||u==1/0?(((t=V(s)).length+l)%2==0&&(t+="0"),u=Math.sqrt(+t),l=q((l+1)/2)-(l<0||l%2),new j(t=u==1/0?"5e"+l:(t=u.toExponential()).slice(0,t.indexOf("e")+1)+l)):new j(u+"")).c[0])for((u=(l=r.e)+c)<3&&(u=0);;)if(i=r,r=a.times(i.plus(d(o,i,c,1))),V(i.c).slice(0,u)===(t=V(r.c)).slice(0,u)){if(r.e<l&&--u,"9999"!=(t=t.slice(u-3,u+1))&&(n||"4999"!=t)){+t&&(+t.slice(1)||"5"!=t.charAt(0))||(F(r,r.e+m+2,1),e=!r.times(r).eq(o));break}if(!n&&(F(i,i.e+m+2,0),i.times(i).eq(o))){r=i;break}c+=4,u+=4,n=1}return F(r,r.e+m+1,w,e)},r.toExponential=function(e,t){return null!=e&&(H(e,0,G),e++),n(this,e,t,1)},r.toFixed=function(e,t){return null!=e&&(H(e,0,G),e=e+this.e+1),n(this,e,t)},r.toFormat=function(e,t,r){if(null==r)null!=e&&t&&"object"==R(t)?(r=t,t=null):e&&"object"==R(e)?(r=e,e=t=null):r=x;else if("object"!=R(r))throw Error(U+"Argument not an object: "+r);if(e=this.toFixed(e,t),this.c){var n,t=e.split("."),i=+r.groupSize,o=+r.secondaryGroupSize,s=r.groupSeparator||"",u=t[0],t=t[1],l=this.s<0,c=l?u.slice(1):u,a=c.length;if(o&&(n=i,i=o,a-=o=n),0<i&&0<a){for(u=c.substr(0,n=a%i||i);n<a;n+=i)u+=s+c.substr(n,i);0<o&&(u+=s+c.slice(n)),l&&(u="-"+u)}e=t?u+(r.decimalSeparator||"")+((o=+r.fractionGroupSize)?t.replace(new RegExp("\\d{"+o+"}\\B","g"),"$&"+(r.fractionGroupSeparator||"")):t):u}return(r.prefix||"")+e+(r.suffix||"")},r.toFraction=function(e){var t,r,n,i,o,s,u,l,c,a,f=this,p=f.c;if(null!=e&&(!(u=new j(e)).isInteger()&&(u.c||1!==u.s)||u.lt(g)))throw Error(U+"Argument "+(u.isInteger()?"out of range: ":"not an integer: ")+D(u));if(!p)return new j(f);for(t=new j(g),c=r=new j(g),n=l=new j(g),p=V(p),o=t.e=p.length-f.e-1,t.c[0]=Tt[(s=o%M)<0?M+s:s],e=!e||0<u.comparedTo(t)?0<o?t:c:u,s=E,E=1/0,u=new j(p),l.c[0]=0;a=d(u,t,0,1),1!=(i=r.plus(a.times(n))).comparedTo(e);)r=n,n=i,c=l.plus(a.times(i=c)),l=i,t=u.minus(a.times(i=t)),u=i;return i=d(e.minus(r),n,0,1),l=l.plus(i.times(c)),r=r.plus(i.times(n)),l.s=c.s=f.s,p=d(c,n,o*=2,w).minus(f).abs().comparedTo(d(l,r,o,w).minus(f).abs())<1?[c,n]:[l,r],E=s,p},r.toNumber=function(){return+D(this)},r.toPrecision=function(e,t){return null!=e&&H(e,1,G),n(this,e,t,2)},r.toString=function(e){var t,r=this,n=r.s,i=r.e;return null===i?n?(t="Infinity",n<0&&(t="-"+t)):t="NaN":(t=null==e?i<=v||b<=i?$t(V(r.c),i):Z(V(r.c),i,"0"):10===e&&S?Z(V((r=F(new j(r),m+i+1,w)).c),r.e,"0"):(H(e,2,A.length,"Base"),f(Z(V(r.c),i,"0"),10,e,n,!0)),n<0&&r.c[0]&&(t="-"+t)),t},r.valueOf=r.toJSON=function(){return D(this)},r._isBigNumber=!0,r[Symbol.toStringTag]="BigNumber",r[Symbol.for("nodejs.util.inspect.custom")]=r.valueOf,null!=e&&j.set(e),j}();function Ft(e){for(var t=[];0<e.length;){var r=e.shift();if(k(r)){if(t.length<2)throw new Error("错误的栈长度, 可能是无法计算的表达式");var n=t.pop(),i=t.pop();if("string"==typeof n&&!E.isBigNumber(n)){if(!T(n))throw new Error("".concat(n,"不是一个合法的数字"));n=new E(n)}if("string"==typeof i&&!E.isBigNumber(i)){if(!T(i))throw new Error("".concat(i,"不是一个合法的数字"));i=new E(i)}switch(r){case"+":t.push(i.plus(n));break;case"-":t.push(i.minus(n));break;case"*":t.push(i.times(n));break;case"/":t.push(i.div(n));break;case"%":t.push(i.mod(n));break;case"**":t.push(i.pow(n))}}else t.push(r)}if(1!==t.length)throw"unvalid expression";var o=t[0];if((o=E.isBigNumber(o)?o:E(o)).isNaN())throw new Error("计算结果为NaN");return o}function Dt(e,t,r){var n,i,o,s,u,l,c,a,f,p,h,g,v,d,y,m,w,b,_="";return E.isBigNumber(e)?_=e.toFixed():"string"!=typeof e&&(_=e.toString()),"undefined"===_||"NaN"===_?null:(i=n=null,s=o=!1,m=a=c=l=!(u="~-"),t.forEach(function(e){var t=e.type;if("symbol"===t){if(![">=","<=","=","<",">"].includes(e.value))throw new Error("错误的格式化参数:",e.value);i=e.value}else if("to-number"===t)m=!0;else if("comma"===t)o=!0;else if("number"===t)n=e.value;else if("plus"===t)s=!0;else if("round"===t)u=e.value;else if("fraction"===t)c=!0;else if("scientific"===t)l=!0;else{if("percent"!==t)throw new Error("错误的fmt Token");a=!0}}),l?(e=E(_).toExponential(),s&&!e.startsWith("-")?"+"+e:e):c?(t=E(_).toFraction().map(function(e){return e.toFixed()}).join("/"),s&&!t.startsWith("-")?"+"+t:t):(a&&(_=E(_).times(100).toFixed()),n&&(e=_.split("."),t=e[0],e=1===e.length?"":e[1],h=i,g=+n,w=u,v=f=t,y=(d=p=e).length,b={"~-":function(){d=p.slice(0,"<"===h?g-1:g)},"~+":function(){var e,t="<"===h?g-1:g;y<=t||0===y||(e=p.slice(0,t),0!=+p.slice(t,y)&&(e=(+e+1).toString()).length>t?(d=e.slice(1,e.length),v=(+v+1).toString()):d=e)},"~5":function(){var e,t;0===y||(d=p.slice(0,e="<"===h?g-1:g),t=+p[e],Number.isNaN(t))||5<=t&&(d=(+d+1).toString()).length>e&&(d=d.slice(1,d.length),v=(+v+1).toString())},"~6":function(){var e,t,r,n;0!==y&&(t=+p[e="<"===h?g-1:g],r=""===(r=p.slice(+e+1,p.length))?0:parseInt(r),n=0===e?+f[f.length-1]:+p[e-1],d=p.slice(0,e),6<=t||5==t&&0<r||5==t&&n%2!=0)&&(d=(+d+1).toString()).length>e&&(d=d.slice(1,d.length),v=(+v+1).toString())}},"<="===h?d=y<=g?p:(b[w]&&b[w](),d.replace(/0+$/,"")):"<"===h?d=y<g?p:(b[w]&&b[w](),d.replace(/0+$/,"")):"="===h?y<g?d=p+"0".repeat(g-y):g<y&&b[w]&&b[w]():">="===h?y<g&&(d=p+"0".repeat(g-y)):">"===h&&y<=g&&(d=p+"0".repeat(g-y+1)),t=(b={int_part:v,dec_part:d}).int_part,_=""===(e=b.dec_part)?t:"".concat(t,".").concat(e)),o&&(m=!1,_=1<(w=_.split(".")).length?((b=w[0]).includes("-")?w[0]=b[0]+b.slice(1).replace(/(?=(?!^)(?:\d{3})+$)/g,","):w[0]=b.replace(/(?=(?!^)(?:\d{3})+$)/g,","),w.join(".")):(t=w[0]).includes("-")?t[0]+t.slice(1).replace(/(?=(?!^)(?:\d{3})+$)/g,","):t.replace(/(?=(?!^)(?:\d{3})+$)/g,",")),s&&(m=!1,_.startsWith("-")||(_="+"+_)),a&&(m=!1,_+="%"),m&&!r?+_:_))}function It(e,i){return e.map(function(e){if("var"!==e.type)return e;for(var t,r,n=0;n<i.length&&!f(t=d(i[n],e.value));n++);if("number"==typeof(r=t)||T(r))return{type:"number",value:t};throw new Error("错误的填充值")})}function Rt(e){var r=null;return e.length,{tokens:e.map(function(e){var t=function(e){for(var t,r,n=null,i=null,o=[/^([+-]?[\d.]+(?:e|E)(?:\+|-)?\d+)(.*)$/,/^([+-]?[\d.]+)(.*)$/],s=0;s<o.length;s++){var u=e.match(o[s]);if(u){t=u;break}}return t&&(i=t[1],""!==(r=t[2]).trim())&&(n=r),{num:i,unit:n}}(e.value);return null!==t.unit?(null==r&&(r=t.unit),{type:"number",value:t.num}):e}),unit:r}}s=c;try{var m=s(Object,"defineProperty");m({},"",{})}catch(e){}var Ct=K,Ut=Q;r=function(e){return Ut(e)&&"[object Arguments]"==Ct(e)},l=Object.prototype,l.hasOwnProperty,l.propertyIsEnumerable,r(function(){return arguments}()),s={exports:{}};l=(l=(m=s).exports)&&!l.nodeType&&l,r=(r=l&&m&&!m.nodeType&&m)&&r.exports===l?n.Buffer:void 0,l=r?r.isBuffer:void 0,m.exports=l||function(){return!1};var w,zt,Mt,s={exports:{}},t=(l=(l=(r=s).exports)&&!l.nodeType&&l,w=l&&r&&!r.nodeType&&r,zt=w&&w.exports===l&&t.process,l=function(){try{var e=w&&w.require&&w.require("util").types;return e?e:zt&&zt.binding&&zt.binding("util")}catch(e){}}(),r.exports=l,s.exports),r=(t&&t.isTypedArray,{exports:{}});t=(t=(l=r).exports)&&!t.nodeType&&t,r=(r=t&&l&&!l.nodeType&&l)&&r.exports===t?n.Buffer:void 0,Mt=r?r.allocUnsafe:void 0,l.exports=function(e,t){return t?e.slice():(t=e.length,t=Mt?Mt(t):new e.constructor(t),e.copy(t),t)};var t=c(n,"DataView"),r=g,l=c(n,"Promise"),g=c(n,"Set"),b=c(n,"WeakMap"),Lt=K,_=ge,Gt="[object Map]",qt="[object Promise]",Vt="[object Set]",Wt="[object WeakMap]",Ht="[object DataView]",Zt=_(t),Xt=_(r),Yt=_(l),Jt=_(g),Kt=_(b),O=Lt;(t&&O(new t(new ArrayBuffer(1)))!=Ht||r&&O(new r)!=Gt||l&&O(l.resolve())!=qt||g&&O(new g)!=Vt||b&&O(new b)!=Wt)&&(O=function(e){var t=Lt(e),e="[object Object]"==t?e.constructor:void 0,e=e?_(e):"";if(e)switch(e){case Zt:return Ht;case Xt:return Gt;case Yt:return qt;case Jt:return Vt;case Kt:return Wt}return t}),n.Uint8Array;t=i?i.prototype:void 0,t&&t.valueOf,r=s.exports,r&&r.isMap,l=s.exports,l&&l.isSet,g=s.exports,g&&g.isArrayBuffer,b=s.exports;b&&b.isDate,Function.prototype.toString.call(Object);O=i?i.prototype:void 0;O&&O.valueOf;n.isFinite;t=s.exports;function Qt(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];var n=function(e){var t={expr:"",fmt:null,options:null,fmt_err:!1,expr_err:!1},r="",n=e[0],i=(f(i=e[1])&&(t.options=i),d(i,"_error",!1));if(0===e.length)throw new Error("至少传入一个参数");if("string"==typeof n){if(""===(r=n).trim()||n.includes("NaN"))return t.expr_err=!0,t}else{if("number"!=typeof n){if(!0===i)return t.expr_err=!0,t;throw new Error("错误的第一个参数类型: ".concat(n," 类型为:").concat(R(n)))}r=n.toString()}if(e=r.split("|"),t.expr=e[0],1<e.length){i=e[1];if(""!==i.trim())try{t.fmt=$(i)}catch(e){return t.fmt_err=!0,t}}if(null!==t.options&&t.options._fmt){var o,n=[];try{n=$(t.options._fmt)}catch(e){return t.fmt_err=!0,t}null===t.fmt?t.fmt=n:(o=t.fmt.map(function(e){return e.type}),n.forEach(function(e){o.includes(e.type)||t.fmt.push(e)}))}return t}(t),i=d(n,"options._error",void 0),o=d(n,"options._debug",!1),s=d(n,"options._unit",!1),u=n.options,l=null;if(n.fmt_err||n.expr_err){if(f(i))return i;throw new Error("表达式或格式化字符串错误,表达式为:".concat(n.expr))}if(f(i))try{c=Nt(n.expr,s)}catch(e){return i}else c=Nt(n.expr,s);if(o&&(console.warn("======a-calc调试模式======"),console.warn("arg:"),console.warn(n),console.warn("tokens:"),console.warn(c)),p(u)){var c,a=[];if(Array.isArray(u)?a=u:(a.push(u),f(u=d(u,"_fill_data",{}))&&(Array.isArray(u)?a=[].concat(N(a),N(u)):a.push(u))),f(i))try{c=xt(c,a,s),p(n.fmt)&&(n.fmt=It(n.fmt,a))}catch(e){return i}else c=xt(c,a,s),p(n.fmt)&&(n.fmt=It(n.fmt,a));[!0,"on","auto","space"].includes(s)&&(l=(u=Rt(c)).unit,c=u.tokens)}a=At(c),o&&(console.warn("分离单位之后的tokens:"),console.warn(c),console.warn("转换后的tokens"),console.log(a),console.warn("单位:".concat(l))),u=null;if(f(i))try{u=Ft(a)}catch(e){return i}else u=Ft(a);if("Infinity"!==(u=p(n.fmt)?Dt(u,n.fmt,s):null!==u?u.toFixed():null)&&null!==u)return null!==l&&(u+=l),u;if(f(i))return i;throw new Error("计算错误可能是非法的计算式")}t&&t.isRegExp,i&&i.iterator,console.log("%ca-calc:%c ".concat(A," %c=> %curl:%c https://www.npmjs.com/package/a-calc"),"color: #fff;background: #67C23A;padding: 2px 5px;border-radius:4px;font-size: 14px;","color: #409EFF;font-size:14px;","color: #409EFF;font-size:14px;","background: #67C23A;font-size:14px; padding: 2px 5px; border-radius: 4px; color: #fff;","font-size:14px;");r=Qt;return e.calc=Qt,e.fmt=r,e.version=A,Object.defineProperty(e,"__esModule",{value:!0}),e}({});
var a_calc=function(e){"use strict";function C(e){return(C="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})(e)}function _(e){return function(e){if(Array.isArray(e))return n(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){var r;if(e)return"string"==typeof e?n(e,t):"Map"===(r="Object"===(r=Object.prototype.toString.call(e).slice(8,-1))&&e.constructor?e.constructor.name:r)||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?n(e,t):void 0}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function n(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var O="1.2.0",N=/^[+-]?\d[\d.]*(?:e\+|E\+|e-|E-|e|E)?\d*$/,A=/^[+-]?\d[\d.]*(?:e\+|E\+|e-|E-|e|E)?\d*\D*$/;function S(e){return-1<"+-*/%()**".indexOf(e)}function x(e){switch(e){case"+":case"-":return 1;case"*":case"/":case"%":return 2;case"**":return 3;default:return 0}}function f(e){return void 0!==e}function h(e){return null!==e}function c(e){return"string"==typeof e&&!!N.test(e)}var o={initial:"initial",number:"number",variable:"var",symbol:"symbol",percent:"percent",round:"round",plus:"plus",comma:"comma",fraction:"fraction",to_number:"to-number",scientific:"scientific"},j="<>=";function k(e){for(var t=o.initial,r=[],n=[];e;){var i=e[0];if(t===o.initial)if(/\s/.test(i))e=e.slice(1);else if(j.includes(i))t=o.symbol,r.push(i),e=e.slice(1);else if(","===i)t=o.initial,n.push({type:"comma",value:i}),e=e.slice(1);else if(/[a-zA-Z_]/.test(i))t=o.variable,r.push(i),e=e.slice(1);else if(/\d/.test(i))t=o.number,r.push(i),e=e.slice(1);else if("+"===i)t=o.initial,n.push({type:"plus",value:i}),e=e.slice(1);else if("~"===i)t=o.round,r.push(i),e=e.slice(1);else if("%"===i)t=o.initial,n.push({type:"percent",value:i}),e=e.slice(1);else if("/"===i)t=o.initial,n.push({type:"fraction",value:i}),e=e.slice(1);else{if("!"!==i)throw new Error("不识别的fmt字符:".concat(i));if(t=o.initial,/[Ee]/.test(e[1]))n.push({type:"scientific",value:e[1]});else{if(!/[Nn]/.test(e[1]))throw new Error("不识别的fmt字符:".concat(e.slice(2)));n.push({type:"to-number",value:e[1]})}e=e.slice(2)}else if(t===o.number)/\d/.test(i)?(r.push(i),e=e.slice(1)):(n.push({type:"number",value:r.join("")}),r.length=0,t=o.initial);else if(t===o.variable)/[\$\w_\-.\[\]"']/.test(i)?(r.push(i),e=e.slice(1)):(n.push({type:"var",value:r.join("")}),r.length=0,t=o.initial);else if(t===o.symbol)/\s/.test(i)?e=e.slice(1):j.includes(i)?(r.push(i),e=e.slice(1)):(n.push({type:"symbol",value:r.join("")}),r.length=0,t=o.initial);else{if(t!==o.round)throw new Error("错误的自动机状态");if(/\s/.test(i))e=e.slice(1);else{if(!("56+-".includes(i)&&r.length<2))throw new Error("舍入格式化语法错误:".concat(i));r.push(i),e=e.slice(1),n.push({type:"round",value:r.join("")}),r.length=0,t=o.initial}}}if(0<r.length&&(n.push({type:t,value:r.join("")}),r.length=0,t=o.initial),1<n.filter(function(e){return"number"===e.type}).length)throw new Error("格式化字符串错误,发现多余的数字");return n}var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},r=Array.isArray,t="object"==C(t)&&t&&t.Object===Object&&t,i="object"==("undefined"==typeof self?"undefined":C(self))&&self&&self.Object===Object&&self,t=t||i||Function("return this")(),i=t.Symbol,s=Object.prototype,P=s.hasOwnProperty,$=s.toString,l=i?i.toStringTag:void 0;var T=Object.prototype.toString;var B=function(e){var t=P.call(e,l),r=e[l];try{var n=!(e[l]=void 0)}catch(e){}var i=$.call(e);return n&&(t?e[l]=r:delete e[l]),i},F=function(e){return T.call(e)},I=i?i.toStringTag:void 0;function R(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":(I&&I in Object(e)?B:F)(e)}var J=R,K=function(e){return null!=e&&"object"==C(e)};function u(e){return"symbol"==C(e)||K(e)&&"[object Symbol]"==J(e)}var Q=r,ee=u,te=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,re=/^\w*$/;function ne(e,t){var r;return!Q(e)&&(!("number"!=(r=C(e))&&"symbol"!=r&&"boolean"!=r&&null!=e&&!ee(e))||re.test(e)||!te.test(e)||null!=t&&e in Object(t))}function ie(e){var t=C(e);return null!=e&&("object"==t||"function"==t)}var oe=R,se=ie;function le(e){return!!se(e)&&("[object Function]"==(e=oe(e))||"[object GeneratorFunction]"==e||"[object AsyncFunction]"==e||"[object Proxy]"==e)}var s=t["__core-js_shared__"],ue=(s=/[^.]+$/.exec(s&&s.keys&&s.keys.IE_PROTO||""))?"Symbol(src)_1."+s:"";var ce=Function.prototype.toString;var ae=le,fe=function(e){return!!ue&&ue in e},he=ie,pe=function(e){if(null!=e){try{return ce.call(e)}catch(e){}try{return e+""}catch(e){}}return""},ge=/^\[object .+?Constructor\]$/,s=Function.prototype,a=Object.prototype,s=s.toString,a=a.hasOwnProperty,ve=RegExp("^"+s.call(a).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");var de=function(e){return!(!he(e)||fe(e))&&(ae(e)?ve:ge).test(pe(e))},me=function(e,t){return null==e?void 0:e[t]};function we(e,t){return e=me(e,t),de(e)?e:void 0}var s=we(Object,"create"),ye=s;var be=s,_e=Object.prototype.hasOwnProperty;var Ee=s,Oe=Object.prototype.hasOwnProperty;var Ne=s;function Ae(e){return e=this.has(e)&&delete this.__data__[e],this.size-=e?1:0,e}function Se(e){var t,r=this.__data__;return be?"__lodash_hash_undefined__"===(t=r[e])?void 0:t:_e.call(r,e)?r[e]:void 0}function xe(e){var t=this.__data__;return Ee?void 0!==t[e]:Oe.call(t,e)}function je(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=Ne&&void 0===t?"__lodash_hash_undefined__":t,this}function p(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}p.prototype.clear=function(){this.__data__=ye?ye(null):{},this.size=0},p.prototype.delete=Ae,p.prototype.get=Se,p.prototype.has=xe,p.prototype.set=je;a=p;var ke=function(e,t){return e===t||e!=e&&t!=t};function g(e,t){for(var r=e.length;r--;)if(ke(e[r][0],t))return r;return-1}var Pe=g,$e=Array.prototype.splice;var Te=g;var Be=g;var Fe=g;function Ie(e){var t=this.__data__;return!((e=Pe(t,e))<0||(e==t.length-1?t.pop():$e.call(t,e,1),--this.size,0))}function Re(e){var t=this.__data__;return(e=Te(t,e))<0?void 0:t[e][1]}function Ce(e){return-1<Be(this.__data__,e)}function ze(e,t){var r=this.__data__,n=Fe(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this}function v(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}v.prototype.clear=function(){this.__data__=[],this.size=0},v.prototype.delete=Ie,v.prototype.get=Re,v.prototype.has=Ce,v.prototype.set=ze;var s=v,t=we(t,"Map"),De=a,Ue=s,Le=t;var Me=function(e){var t=C(e);return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e};function d(e,t){return e=e.__data__,Me(t)?e["string"==typeof t?"string":"hash"]:e.map}var Ge=d;var qe=d;var He=d;var Ve=d;function We(e){return e=Ge(this,e).delete(e),this.size-=e?1:0,e}function Ze(e){return qe(this,e).get(e)}function Xe(e){return He(this,e).has(e)}function Ye(e,t){var r=Ve(this,e),n=r.size;return r.set(e,t),this.size+=r.size==n?0:1,this}function m(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}m.prototype.clear=function(){this.size=0,this.__data__={hash:new De,map:new(Le||Ue),string:new De}},m.prototype.delete=We,m.prototype.get=Ze,m.prototype.has=Xe,m.prototype.set=Ye;var Je=m;function w(n,i){if("function"!=typeof n||null!=i&&"function"!=typeof i)throw new TypeError("Expected a function");function o(){var e=arguments,t=i?i.apply(this,e):e[0],r=o.cache;return r.has(t)?r.get(t):(e=n.apply(this,e),o.cache=r.set(t,e)||r,e)}return o.cache=new(w.Cache||Je),o}w.Cache=Je;var Ke=w;var Qe=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,et=/\\(\\)?/g,a=function(e){var t=(e=Ke(e,function(e){return 500===t.size&&t.clear(),e})).cache;return e}(function(e){var i=[];return 46===e.charCodeAt(0)&&i.push(""),e.replace(Qe,function(e,t,r,n){i.push(r?n.replace(et,"$1"):t||e)}),i});var tt=function(e,t){for(var r=-1,n=null==e?0:e.length,i=Array(n);++r<n;)i[r]=t(e[r],r,e);return i},rt=r,nt=u,s=i?i.prototype:void 0,it=s?s.toString:void 0;var ot=function e(t){var r;return"string"==typeof t?t:rt(t)?tt(t,e)+"":nt(t)?it?it.call(t):"":"0"==(r=t+"")&&1/t==-1/0?"-0":r};var st=r,lt=ne,ut=a,ct=function(e){return null==e?"":ot(e)};var at=u;var ft=function(e,t){return st(e)?e:lt(e,t)?[e]:ut(ct(e))},ht=function(e){var t;return"string"==typeof e||at(e)?e:"0"==(t=e+"")&&1/e==-1/0?"-0":t};var pt=function(e,t){for(var r=0,n=(t=ft(t,e)).length;null!=e&&r<n;)e=e[ht(t[r++])];return r&&r==n?e:void 0};var y=function(e,t,r){return void 0===(e=null==e?void 0:pt(e,t))?r:e};var b={initial:"initial",number:"number",scientific:"scientific",operator:"operator",bracket:"bracket",var:"var"},gt="+-",vt="*/%",dt="()";function mt(e,t){for(var r,n,i,o=1<arguments.length&&void 0!==t&&t,s=b.initial,l=[],u=[],c=function(){l.push(r),e=e.slice(1)},a=function(e){u.push({type:e,value:l.join("")}),l.length=0},f=function(){e=e.slice(1)};e;)switch(r=e[0],s){case b.initial:if(gt.includes(r)){var h=u.at(-1),s=0===u.length||"operator"===h.type||"("===h?b.number:b.operator;c()}else if(vt.includes(r))s=b.operator,c();else if(/\d/.test(r))s=b.number,c();else if(dt.includes(r))s=b.bracket;else if(/[a-zA-Z_$]/.test(r))s=b.var,c();else{if(!/\s/.test(r))throw new Error("不识别的字符".concat(r));f()}break;case b.bracket:u.push({type:b.bracket,value:r}),f(),s=b.initial;break;case b.operator:h=l.at(-1);"*"===r&&"*"===h&&c(),a(b.operator),s=b.initial;break;case b.number:if(/\d/.test(r))c();else if("."===r){if(0===l.length||l.includes("."))throw new Error("非法的小数部分".concat(l.join("")));c()}else"Ee".includes(r)?(s=b.scientific,c()):["auto","on",!0].includes(o)&&/[^*/+\-()\s]/.test(r)||"space"===o&&/\S/.test(r)?c():(a(b.number),s=b.initial);break;case b.scientific:/\d/.test(r)?c():gt.includes(r)?(n=l.slice(1),i=l.at(-1),n.includes(r)||!/[Ee]/.test(i)?(a(b.scientific),s=b.initial):c()):["auto","on",!0].includes(o)&&/[^*/+\-()\s]/.test(r)||"space"===o&&/\S/.test(r)?c():(a(b.scientific),s=b.initial);break;case b.var:/[\w_.\[\]"']/.test(r)?c():(a(b.var),s=b.initial);break;default:throw new Error("状态错误")}return 0!==l.length&&(u.push({type:s,value:l.join("")}),l.length=0,s=b.initial),u}function wt(e,t,r){if(null===t)throw new Error("错误的填充数据:",t);for(var n=[],i=0;i<e.length;i++){var o=e[i];if("var"!==o.type)n.push(o);else{if("undefined"===o.value||"NaN"===o.value)throw new Error("key不应该为:".concat(o.value));for(var s=null,l=0;l<t.length;l++){var u=t[l],u=y(u,o.value);if(void 0!==u){s=u;break}}if(null===s)throw new Error("token填充失败,请确认".concat(o,"存在"));if("string"==typeof s){if(""===s.trim())throw new Error("token填充失败,".concat(o.value,"值不可为空字符"));if([!0,"on","auto","space"].includes(r)){if(!A.test(s))throw new Error("token填充失败,".concat(o.value,"值:").concat(s,"为非法单位数字"))}else if(!c(s))throw new Error("token填充失败,".concat(o,"值:").concat(s,"为非法数字"))}s="string"!=typeof s?s.toString():s,n.push({type:"number",value:s})}}return n}function yt(e){for(var t,r=[],n=[],i=e.map(function(e){return e.value});0<i.length;){var o=i.shift();if(S(o))if("("===o)r.push(o);else if(")"===o){for(var s=r.pop();"("!==s&&0<r.length;)n.push(s),s=r.pop();if("("!==s)throw"error: unmatched ()"}else{for(;t=r[r.length-1],x(o)<=x(t)&&0<r.length;)n.push(r.pop());r.push(o)}else n.push(o)}if(0<r.length){if(")"===r[r.length-1]||"("===r[r.length-1])throw"error: unmatched ()";for(;0<r.length;)n.push(r.pop())}return n}var bt=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,_t=Math.ceil,z=Math.floor,D="[BigNumber Error] ",Et=D+"Number primitive has more than 15 significant digits: ",U=1e14,L=14,Ot=9007199254740991,Nt=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],M=1e7,G=1e9;function q(e){var t=0|e;return 0<e||e===t?t:t-1}function H(e){for(var t,r,n=1,i=e.length,o=e[0]+"";n<i;){for(t=e[n++]+"",r=L-t.length;r--;t="0"+t);o+=t}for(i=o.length;48===o.charCodeAt(--i););return o.slice(0,i+1||1)}function V(e,t){var r,n,i=e.c,o=t.c,s=e.s,l=t.s,e=e.e,t=t.e;if(!s||!l)return null;if(r=i&&!i[0],n=o&&!o[0],r||n)return r?n?0:-l:s;if(s!=l)return s;if(r=s<0,n=e==t,!i||!o)return n?0:!i^r?1:-1;if(!n)return t<e^r?1:-1;for(l=(e=i.length)<(t=o.length)?e:t,s=0;s<l;s++)if(i[s]!=o[s])return i[s]>o[s]^r?1:-1;return e==t?0:t<e^r?1:-1}function W(e,t,r,n){if(e<t||r<e||e!==z(e))throw Error(D+(n||"Argument")+("number"==typeof e?e<t||r<e?" out of range: ":" not an integer: ":" not a primitive number: ")+String(e))}function Z(e){var t=e.c.length-1;return q(e.e/L)==t&&e.c[t]%2!=0}function X(e,t){return(1<e.length?e.charAt(0)+"."+e.slice(1):e)+(t<0?"e":"e+")+t}function Y(e,t,r){var n,i;if(t<0){for(i=r+".";++t;i+=r);e=i+e}else if(++t>(n=e.length)){for(i=r,t-=n;--t;i+=r);e+=i}else t<n&&(e=e.slice(0,t)+"."+e.slice(t));return e}var E=function R(e){var d,f,h,t,c,m,s,l,u,a,p,r=j.prototype={constructor:j,toString:null,valueOf:null},g=new j(1),w=20,y=4,v=-7,b=21,_=-1e7,E=1e7,O=!1,i=1,N=0,A={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},S="0123456789abcdefghijklmnopqrstuvwxyz",x=!0;function j(e,t){var r,n,i,o,s,l,u,c,a=this;if(!(a instanceof j))return new j(e,t);if(null==t){if(e&&!0===e._isBigNumber)return a.s=e.s,void(!e.c||e.e>E?a.c=a.e=null:e.e<_?a.c=[a.e=0]:(a.e=e.e,a.c=e.c.slice()));if((l="number"==typeof e)&&0*e==0){if(a.s=1/e<0?(e=-e,-1):1,e===~~e){for(o=0,s=e;10<=s;s/=10,o++);return void(E<o?a.c=a.e=null:(a.e=o,a.c=[e]))}c=String(e)}else{if(!bt.test(c=String(e)))return h(a,c,l);a.s=45==c.charCodeAt(0)?(c=c.slice(1),-1):1}0<(s=(c=-1<(o=c.indexOf("."))?c.replace(".",""):c).search(/e/i))?(o<0&&(o=s),o+=+c.slice(s+1),c=c.substring(0,s)):o<0&&(o=c.length)}else{if(W(t,2,S.length,"Base"),10==t&&x)return F(a=new j(e),w+a.e+1,y);if(c=String(e),l="number"==typeof e){if(0*e!=0)return h(a,c,l,t);if(a.s=1/e<0?(c=c.slice(1),-1):1,j.DEBUG&&15<c.replace(/^0\.0*|\./,"").length)throw Error(Et+e)}else a.s=45===c.charCodeAt(0)?(c=c.slice(1),-1):1;for(r=S.slice(0,t),o=s=0,u=c.length;s<u;s++)if(r.indexOf(n=c.charAt(s))<0){if("."==n){if(o<s){o=u;continue}}else if(!i&&(c==c.toUpperCase()&&(c=c.toLowerCase())||c==c.toLowerCase()&&(c=c.toUpperCase()))){i=!0,s=-1,o=0;continue}return h(a,String(e),l,t)}l=!1,-1<(o=(c=f(c,t,10,a.s)).indexOf("."))?c=c.replace(".",""):o=c.length}for(s=0;48===c.charCodeAt(s);s++);for(u=c.length;48===c.charCodeAt(--u););if(c=c.slice(s,++u)){if(u-=s,l&&j.DEBUG&&15<u&&(Ot<e||e!==z(e)))throw Error(Et+a.s*e);if((o=o-s-1)>E)a.c=a.e=null;else if(o<_)a.c=[a.e=0];else{if(a.e=o,a.c=[],s=(o+1)%L,o<0&&(s+=L),s<u){for(s&&a.c.push(+c.slice(0,s)),u-=L;s<u;)a.c.push(+c.slice(s,s+=L));s=L-(c=c.slice(s)).length}else s-=u;for(;s--;c+="0");a.c.push(+c)}}else a.c=[a.e=0]}function k(e,t,r,n){for(var i,o,s=[0],l=0,u=e.length;l<u;){for(o=s.length;o--;s[o]*=t);for(s[0]+=n.indexOf(e.charAt(l++)),i=0;i<s.length;i++)r-1<s[i]&&(null==s[i+1]&&(s[i+1]=0),s[i+1]+=s[i]/r|0,s[i]%=r)}return s.reverse()}function P(e,t,r){var n,i,o,s=0,l=e.length,u=t%M,c=t/M|0;for(e=e.slice();l--;)s=((i=u*(o=e[l]%M)+(n=c*o+(o=e[l]/M|0)*u)%M*M+s)/r|0)+(n/M|0)+c*o,e[l]=i%r;return e=s?[s].concat(e):e}function $(e,t,r,n){var i,o;if(r!=n)o=n<r?1:-1;else for(i=o=0;i<r;i++)if(e[i]!=t[i]){o=e[i]>t[i]?1:-1;break}return o}function T(e,t,r,n){for(var i=0;r--;)e[r]-=i,i=e[r]<t[r]?1:0,e[r]=i*n+e[r]-t[r];for(;!e[0]&&1<e.length;e.splice(0,1));}function n(e,t,r,n){var i,o,s,l;if(null==r?r=y:W(r,0,8),!e.c)return e.toString();if(i=e.c[0],o=e.e,null==t)l=H(e.c),l=1==n||2==n&&(o<=v||b<=o)?X(l,o):Y(l,o,"0");else if(r=(e=F(new j(e),t,r)).e,s=(l=H(e.c)).length,1==n||2==n&&(t<=r||r<=v)){for(;s<t;l+="0",s++);l=X(l,r)}else if(t-=o,l=Y(l,r,"0"),s<r+1){if(0<--t)for(l+=".";t--;l+="0");}else if(0<(t+=r-s))for(r+1==s&&(l+=".");t--;l+="0");return e.s<0&&i?"-"+l:l}function o(e,t){for(var r,n=1,i=new j(e[0]);n<e.length;n++){if(!(r=new j(e[n])).s){i=r;break}t.call(i,r)&&(i=r)}return i}function B(e,t,r){for(var n=1,i=t.length;!t[--i];t.pop());for(i=t[0];10<=i;i/=10,n++);return(r=n+r*L-1)>E?e.c=e.e=null:r<_?e.c=[e.e=0]:(e.e=r,e.c=t),e}function F(e,t,r,n){var i,o,s,l,u,c,a,f=e.c,h=Nt;if(f){e:{for(i=1,l=f[0];10<=l;l/=10,i++);if((o=t-i)<0)o+=L,s=t,a=(u=f[c=0])/h[i-s-1]%10|0;else if((c=_t((o+1)/L))>=f.length){if(!n)break e;for(;f.length<=c;f.push(0));u=a=0,s=(o%=L)-L+(i=1)}else{for(u=l=f[c],i=1;10<=l;l/=10,i++);a=(s=(o%=L)-L+i)<0?0:u/h[i-s-1]%10|0}if(n=n||t<0||null!=f[c+1]||(s<0?u:u%h[i-s-1]),n=r<4?(a||n)&&(0==r||r==(e.s<0?3:2)):5<a||5==a&&(4==r||n||6==r&&(0<o?0<s?u/h[i-s]:0:f[c-1])%10&1||r==(e.s<0?8:7)),t<1||!f[0])return f.length=0,n?(t-=e.e+1,f[0]=h[(L-t%L)%L],e.e=-t||0):f[0]=e.e=0,e;if(0==o?(f.length=c,l=1,c--):(f.length=c+1,l=h[L-o],f[c]=0<s?z(u/h[i-s]%h[s])*l:0),n)for(;;){if(0==c){for(o=1,s=f[0];10<=s;s/=10,o++);for(s=f[0]+=l,l=1;10<=s;s/=10,l++);o!=l&&(e.e++,f[0]==U)&&(f[0]=1);break}if(f[c]+=l,f[c]!=U)break;f[c--]=0,l=1}for(o=f.length;0===f[--o];f.pop());}e.e>E?e.c=e.e=null:e.e<_&&(e.c=[e.e=0])}return e}function I(e){var t,r=e.e;return null===r?e.toString():(t=H(e.c),t=r<=v||b<=r?X(t,r):Y(t,r,"0"),e.s<0?"-"+t:t)}return j.clone=R,j.ROUND_UP=0,j.ROUND_DOWN=1,j.ROUND_CEIL=2,j.ROUND_FLOOR=3,j.ROUND_HALF_UP=4,j.ROUND_HALF_DOWN=5,j.ROUND_HALF_EVEN=6,j.ROUND_HALF_CEIL=7,j.ROUND_HALF_FLOOR=8,j.EUCLID=9,j.config=j.set=function(e){var t,r;if(null!=e){if("object"!=C(e))throw Error(D+"Object expected: "+e);if(e.hasOwnProperty(t="DECIMAL_PLACES")&&(W(r=e[t],0,G,t),w=r),e.hasOwnProperty(t="ROUNDING_MODE")&&(W(r=e[t],0,8,t),y=r),e.hasOwnProperty(t="EXPONENTIAL_AT")&&((r=e[t])&&r.pop?(W(r[0],-G,0,t),W(r[1],0,G,t),v=r[0],b=r[1]):(W(r,-G,G,t),v=-(b=r<0?-r:r))),e.hasOwnProperty(t="RANGE"))if((r=e[t])&&r.pop)W(r[0],-G,-1,t),W(r[1],1,G,t),_=r[0],E=r[1];else{if(W(r,-G,G,t),!r)throw Error(D+t+" cannot be zero: "+r);_=-(E=r<0?-r:r)}if(e.hasOwnProperty(t="CRYPTO")){if((r=e[t])!==!!r)throw Error(D+t+" not true or false: "+r);if(r&&("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes))throw O=!r,Error(D+"crypto unavailable");O=r}if(e.hasOwnProperty(t="MODULO_MODE")&&(W(r=e[t],0,9,t),i=r),e.hasOwnProperty(t="POW_PRECISION")&&(W(r=e[t],0,G,t),N=r),e.hasOwnProperty(t="FORMAT")){if("object"!=C(r=e[t]))throw Error(D+t+" not an object: "+r);A=r}if(e.hasOwnProperty(t="ALPHABET")){if("string"!=typeof(r=e[t])||/^.?$|[+\-.\s]|(.).*\1/.test(r))throw Error(D+t+" invalid: "+r);x="0123456789"==r.slice(0,10),S=r}}return{DECIMAL_PLACES:w,ROUNDING_MODE:y,EXPONENTIAL_AT:[v,b],RANGE:[_,E],CRYPTO:O,MODULO_MODE:i,POW_PRECISION:N,FORMAT:A,ALPHABET:S}},j.isBigNumber=function(e){if(!e||!0!==e._isBigNumber)return!1;if(!j.DEBUG)return!0;var t,r,n=e.c,i=e.e,o=e.s;e:if("[object Array]"=={}.toString.call(n)){if((1===o||-1===o)&&-G<=i&&i<=G&&i===z(i))if(0===n[0]){if(0===i&&1===n.length)return!0}else if((t=(i+1)%L)<1&&(t+=L),String(n[0]).length==t){for(t=0;t<n.length;t++)if((r=n[t])<0||U<=r||r!==z(r))break e;if(0!==r)return!0}}else if(null===n&&null===i&&(null===o||1===o||-1===o))return!0;throw Error(D+"Invalid BigNumber: "+e)},j.maximum=j.max=function(){return o(arguments,r.lt)},j.minimum=j.min=function(){return o(arguments,r.gt)},j.random=(t=9007199254740992,c=Math.random()*t&2097151?function(){return z(Math.random()*t)}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)},function(e){var t,r,n,i,o,s=0,l=[],u=new j(g);if(null==e?e=w:W(e,0,G),i=_t(e/L),O)if(crypto.getRandomValues){for(t=crypto.getRandomValues(new Uint32Array(i*=2));s<i;)9e15<=(o=131072*t[s]+(t[s+1]>>>11))?(r=crypto.getRandomValues(new Uint32Array(2)),t[s]=r[0],t[s+1]=r[1]):(l.push(o%1e14),s+=2);s=i/2}else{if(!crypto.randomBytes)throw O=!1,Error(D+"crypto unavailable");for(t=crypto.randomBytes(i*=7);s<i;)9e15<=(o=281474976710656*(31&t[s])+1099511627776*t[s+1]+4294967296*t[s+2]+16777216*t[s+3]+(t[s+4]<<16)+(t[s+5]<<8)+t[s+6])?crypto.randomBytes(7).copy(t,s):(l.push(o%1e14),s+=7);s=i/7}if(!O)for(;s<i;)(o=c())<9e15&&(l[s++]=o%1e14);for(i=l[--s],e%=L,i&&e&&(l[s]=z(i/(o=Nt[L-e]))*o);0===l[s];l.pop(),s--);if(s<0)l=[n=0];else{for(n=-1;0===l[0];l.splice(0,1),n-=L);for(s=1,o=l[0];10<=o;o/=10,s++);s<L&&(n-=L-s)}return u.e=n,u.c=l,u}),j.sum=function(){for(var e=1,t=arguments,r=new j(t[0]);e<t.length;)r=r.plus(t[e++]);return r},m="0123456789",f=function(e,t,r,n,i){var o,s,l,u,c,a,f,h,p=e.indexOf("."),g=w,v=y;for(0<=p&&(u=N,N=0,e=e.replace(".",""),a=(h=new j(t)).pow(e.length-p),N=u,h.c=k(Y(H(a.c),a.e,"0"),10,r,m),h.e=h.c.length),l=u=(f=k(e,t,r,i?(o=S,m):(o=m,S))).length;0==f[--u];f.pop());if(!f[0])return o.charAt(0);if(p<0?--l:(a.c=f,a.e=l,a.s=n,f=(a=d(a,h,g,v,r)).c,c=a.r,l=a.e),p=f[s=l+g+1],u=r/2,c=c||s<0||null!=f[s+1],c=v<4?(null!=p||c)&&(0==v||v==(a.s<0?3:2)):u<p||p==u&&(4==v||c||6==v&&1&f[s-1]||v==(a.s<0?8:7)),s<1||!f[0])e=c?Y(o.charAt(1),-g,o.charAt(0)):o.charAt(0);else{if(f.length=s,c)for(--r;++f[--s]>r;)f[s]=0,s||(++l,f=[1].concat(f));for(u=f.length;!f[--u];);for(p=0,e="";p<=u;e+=o.charAt(f[p++]));e=Y(e,l,o.charAt(0))}return e},d=function(e,t,r,n,i){var o,s,l,u,c,a,f,h,p,g,v,d,m,w,y,b,_,E=e.s==t.s?1:-1,O=e.c,N=t.c;if(!(O&&O[0]&&N&&N[0]))return new j(e.s&&t.s&&(O?!N||O[0]!=N[0]:N)?O&&0==O[0]||!N?0*E:E/0:NaN);for(p=(h=new j(E)).c=[],E=r+(s=e.e-t.e)+1,i||(i=U,s=q(e.e/L)-q(t.e/L),E=E/L|0),l=0;N[l]==(O[l]||0);l++);if(N[l]>(O[l]||0)&&s--,E<0)p.push(1),u=!0;else{for(w=O.length,b=N.length,E+=2,1<(c=z(i/(N[l=0]+1)))&&(N=P(N,c,i),O=P(O,c,i),b=N.length,w=O.length),m=b,v=(g=O.slice(0,b)).length;v<b;g[v++]=0);_=N.slice(),_=[0].concat(_),y=N[0],N[1]>=i/2&&y++;do{if(c=0,(o=$(N,g,b,v))<0){if(d=g[0],b!=v&&(d=d*i+(g[1]||0)),1<(c=z(d/y)))for(f=(a=P(N,c=i<=c?i-1:c,i)).length,v=g.length;1==$(a,g,f,v);)c--,T(a,b<f?_:N,f,i),f=a.length,o=1;else 0==c&&(o=c=1),f=(a=N.slice()).length;if(T(g,a=f<v?[0].concat(a):a,v,i),v=g.length,-1==o)for(;$(N,g,b,v)<1;)c++,T(g,b<v?_:N,v,i),v=g.length}else 0===o&&(c++,g=[0])}while(p[l++]=c,g[0]?g[v++]=O[m]||0:(g=[O[m]],v=1),(m++<w||null!=g[0])&&E--);u=null!=g[0],p[0]||p.splice(0,1)}if(i==U){for(l=1,E=p[0];10<=E;E/=10,l++);F(h,r+(h.e=l+s*L-1)+1,n,u)}else h.e=s,h.r=+u;return h},s=/^(-?)0([xbo])(?=\w[\w.]*$)/i,l=/^([^.]+)\.$/,u=/^\.([^.]+)$/,a=/^-?(Infinity|NaN)$/,p=/^\s*\+(?=[\w.])|^\s+|\s+$/g,h=function(e,t,r,n){var i,o=r?t:t.replace(p,"");if(a.test(o))e.s=isNaN(o)?null:o<0?-1:1;else{if(!r&&(o=o.replace(s,function(e,t,r){return i="x"==(r=r.toLowerCase())?16:"b"==r?2:8,n&&n!=i?e:t}),n&&(i=n,o=o.replace(l,"$1").replace(u,"0.$1")),t!=o))return new j(o,i);if(j.DEBUG)throw Error(D+"Not a"+(n?" base "+n:"")+" number: "+t);e.s=null}e.c=e.e=null},r.absoluteValue=r.abs=function(){var e=new j(this);return e.s<0&&(e.s=1),e},r.comparedTo=function(e,t){return V(this,new j(e,t))},r.decimalPlaces=r.dp=function(e,t){var r,n;if(null!=e)return W(e,0,G),null==t?t=y:W(t,0,8),F(new j(this),e+this.e+1,t);if(!(e=this.c))return null;if(r=((n=e.length-1)-q(this.e/L))*L,n=e[n])for(;n%10==0;n/=10,r--);return r=r<0?0:r},r.dividedBy=r.div=function(e,t){return d(this,new j(e,t),w,y)},r.dividedToIntegerBy=r.idiv=function(e,t){return d(this,new j(e,t),0,1)},r.exponentiatedBy=r.pow=function(e,t){var r,n,i,o,s,l,u,c,a=this;if((e=new j(e)).c&&!e.isInteger())throw Error(D+"Exponent not an integer: "+I(e));if(null!=t&&(t=new j(t)),s=14<e.e,!a.c||!a.c[0]||1==a.c[0]&&!a.e&&1==a.c.length||!e.c||!e.c[0])return c=new j(Math.pow(+I(a),s?e.s*(2-Z(e)):+I(e))),t?c.mod(t):c;if(l=e.s<0,t){if(t.c?!t.c[0]:!t.s)return new j(NaN);(n=!l&&a.isInteger()&&t.isInteger())&&(a=a.mod(t))}else{if(9<e.e&&(0<a.e||a.e<-1||(0==a.e?1<a.c[0]||s&&24e7<=a.c[1]:a.c[0]<8e13||s&&a.c[0]<=9999975e7)))return o=a.s<0&&Z(e)?-0:0,-1<a.e&&(o=1/o),new j(l?1/o:o);N&&(o=_t(N/L+2))}for(u=s?(r=new j(.5),l&&(e.s=1),Z(e)):(i=Math.abs(+I(e)))%2,c=new j(g);;){if(u){if(!(c=c.times(a)).c)break;o?c.c.length>o&&(c.c.length=o):n&&(c=c.mod(t))}if(i){if(0===(i=z(i/2)))break;u=i%2}else if(F(e=e.times(r),e.e+1,1),14<e.e)u=Z(e);else{if(0==(i=+I(e)))break;u=i%2}a=a.times(a),o?a.c&&a.c.length>o&&(a.c.length=o):n&&(a=a.mod(t))}return n?c:(l&&(c=g.div(c)),t?c.mod(t):o?F(c,N,y,void 0):c)},r.integerValue=function(e){var t=new j(this);return null==e?e=y:W(e,0,8),F(t,t.e+1,e)},r.isEqualTo=r.eq=function(e,t){return 0===V(this,new j(e,t))},r.isFinite=function(){return!!this.c},r.isGreaterThan=r.gt=function(e,t){return 0<V(this,new j(e,t))},r.isGreaterThanOrEqualTo=r.gte=function(e,t){return 1===(t=V(this,new j(e,t)))||0===t},r.isInteger=function(){return!!this.c&&q(this.e/L)>this.c.length-2},r.isLessThan=r.lt=function(e,t){return V(this,new j(e,t))<0},r.isLessThanOrEqualTo=r.lte=function(e,t){return-1===(t=V(this,new j(e,t)))||0===t},r.isNaN=function(){return!this.s},r.isNegative=function(){return this.s<0},r.isPositive=function(){return 0<this.s},r.isZero=function(){return!!this.c&&0==this.c[0]},r.minus=function(e,t){var r,n,i,o,s=this,l=s.s;if(t=(e=new j(e,t)).s,!l||!t)return new j(NaN);if(l!=t)return e.s=-t,s.plus(e);var u=s.e/L,c=e.e/L,a=s.c,f=e.c;if(!u||!c){if(!a||!f)return a?(e.s=-t,e):new j(f?s:NaN);if(!a[0]||!f[0])return f[0]?(e.s=-t,e):new j(a[0]?s:3==y?-0:0)}if(u=q(u),c=q(c),a=a.slice(),l=u-c){for((i=(o=l<0)?(l=-l,a):(c=u,f)).reverse(),t=l;t--;i.push(0));i.reverse()}else for(n=(o=(l=a.length)<(t=f.length))?l:t,l=t=0;t<n;t++)if(a[t]!=f[t]){o=a[t]<f[t];break}if(o&&(i=a,a=f,f=i,e.s=-e.s),0<(t=(n=f.length)-(r=a.length)))for(;t--;a[r++]=0);for(t=U-1;l<n;){if(a[--n]<f[n]){for(r=n;r&&!a[--r];a[r]=t);--a[r],a[n]+=U}a[n]-=f[n]}for(;0==a[0];a.splice(0,1),--c);return a[0]?B(e,a,c):(e.s=3==y?-1:1,e.c=[e.e=0],e)},r.modulo=r.mod=function(e,t){var r,n=this;return e=new j(e,t),!n.c||!e.s||e.c&&!e.c[0]?new j(NaN):!e.c||n.c&&!n.c[0]?new j(n):(9==i?(t=e.s,e.s=1,r=d(n,e,0,3),e.s=t,r.s*=t):r=d(n,e,0,i),(e=n.minus(r.times(e))).c[0]||1!=i||(e.s=n.s),e)},r.multipliedBy=r.times=function(e,t){var r,n,i,o,s,l,u,c,a,f,h,p=this,g=p.c,v=(e=new j(e,t)).c;if(!(g&&v&&g[0]&&v[0]))return!p.s||!e.s||g&&!g[0]&&!v||v&&!v[0]&&!g?e.c=e.e=e.s=null:(e.s*=p.s,g&&v?(e.c=[0],e.e=0):e.c=e.e=null),e;for(t=q(p.e/L)+q(e.e/L),e.s*=p.s,(l=g.length)<(p=v.length)&&(h=g,g=v,v=h,n=l,l=p,p=n),n=l+p,h=[];n--;h.push(0));for(n=p;0<=--n;){for(a=v[n]%1e7,f=v[n]/1e7|(r=0),i=n+(o=l);n<i;)r=((u=a*(u=g[--o]%1e7)+(s=f*u+(c=g[o]/1e7|0)*a)%1e7*1e7+h[i]+r)/1e14|0)+(s/1e7|0)+f*c,h[i--]=u%1e14;h[i]=r}return r?++t:h.splice(0,1),B(e,h,t)},r.negated=function(){var e=new j(this);return e.s=-e.s||null,e},r.plus=function(e,t){var r,n=this,i=n.s;if(t=(e=new j(e,t)).s,!i||!t)return new j(NaN);if(i!=t)return e.s=-t,n.minus(e);var o=n.e/L,s=e.e/L,l=n.c,u=e.c;if(!o||!s){if(!l||!u)return new j(i/0);if(!l[0]||!u[0])return u[0]?e:new j(l[0]?n:0*i)}if(o=q(o),s=q(s),l=l.slice(),i=o-s){for((r=0<i?(s=o,u):(i=-i,l)).reverse();i--;r.push(0));r.reverse()}for((i=l.length)-(t=u.length)<0&&(r=u,u=l,l=r,t=i),i=0;t;)i=(l[--t]=l[t]+u[t]+i)/U|0,l[t]=U===l[t]?0:l[t]%U;return i&&(l=[i].concat(l),++s),B(e,l,s)},r.precision=r.sd=function(e,t){var r,n;if(null!=e&&e!==!!e)return W(e,1,G),null==t?t=y:W(t,0,8),F(new j(this),e,t);if(!(t=this.c))return null;if(r=(n=t.length-1)*L+1,n=t[n]){for(;n%10==0;n/=10,r--);for(n=t[0];10<=n;n/=10,r++);}return r=e&&this.e+1>r?this.e+1:r},r.shiftedBy=function(e){return W(e,-Ot,Ot),this.times("1e"+e)},r.squareRoot=r.sqrt=function(){var e,t,r,n,i,o=this,s=o.c,l=o.s,u=o.e,c=w+4,a=new j("0.5");if(1!==l||!s||!s[0])return new j(!l||l<0&&(!s||s[0])?NaN:s?o:1/0);if((r=0==(l=Math.sqrt(+I(o)))||l==1/0?(((t=H(s)).length+u)%2==0&&(t+="0"),l=Math.sqrt(+t),u=q((u+1)/2)-(u<0||u%2),new j(t=l==1/0?"5e"+u:(t=l.toExponential()).slice(0,t.indexOf("e")+1)+u)):new j(l+"")).c[0])for((l=(u=r.e)+c)<3&&(l=0);;)if(i=r,r=a.times(i.plus(d(o,i,c,1))),H(i.c).slice(0,l)===(t=H(r.c)).slice(0,l)){if(r.e<u&&--l,"9999"!=(t=t.slice(l-3,l+1))&&(n||"4999"!=t)){+t&&(+t.slice(1)||"5"!=t.charAt(0))||(F(r,r.e+w+2,1),e=!r.times(r).eq(o));break}if(!n&&(F(i,i.e+w+2,0),i.times(i).eq(o))){r=i;break}c+=4,l+=4,n=1}return F(r,r.e+w+1,y,e)},r.toExponential=function(e,t){return null!=e&&(W(e,0,G),e++),n(this,e,t,1)},r.toFixed=function(e,t){return null!=e&&(W(e,0,G),e=e+this.e+1),n(this,e,t)},r.toFormat=function(e,t,r){if(null==r)null!=e&&t&&"object"==C(t)?(r=t,t=null):e&&"object"==C(e)?(r=e,e=t=null):r=A;else if("object"!=C(r))throw Error(D+"Argument not an object: "+r);if(e=this.toFixed(e,t),this.c){var n,t=e.split("."),i=+r.groupSize,o=+r.secondaryGroupSize,s=r.groupSeparator||"",l=t[0],t=t[1],u=this.s<0,c=u?l.slice(1):l,a=c.length;if(o&&(n=i,i=o,a-=o=n),0<i&&0<a){for(l=c.substr(0,n=a%i||i);n<a;n+=i)l+=s+c.substr(n,i);0<o&&(l+=s+c.slice(n)),u&&(l="-"+l)}e=t?l+(r.decimalSeparator||"")+((o=+r.fractionGroupSize)?t.replace(new RegExp("\\d{"+o+"}\\B","g"),"$&"+(r.fractionGroupSeparator||"")):t):l}return(r.prefix||"")+e+(r.suffix||"")},r.toFraction=function(e){var t,r,n,i,o,s,l,u,c,a,f=this,h=f.c;if(null!=e&&(!(l=new j(e)).isInteger()&&(l.c||1!==l.s)||l.lt(g)))throw Error(D+"Argument "+(l.isInteger()?"out of range: ":"not an integer: ")+I(l));if(!h)return new j(f);for(t=new j(g),c=r=new j(g),n=u=new j(g),h=H(h),o=t.e=h.length-f.e-1,t.c[0]=Nt[(s=o%L)<0?L+s:s],e=!e||0<l.comparedTo(t)?0<o?t:c:l,s=E,E=1/0,l=new j(h),u.c[0]=0;a=d(l,t,0,1),1!=(i=r.plus(a.times(n))).comparedTo(e);)r=n,n=i,c=u.plus(a.times(i=c)),u=i,t=l.minus(a.times(i=t)),l=i;return i=d(e.minus(r),n,0,1),u=u.plus(i.times(c)),r=r.plus(i.times(n)),u.s=c.s=f.s,h=d(c,n,o*=2,y).minus(f).abs().comparedTo(d(u,r,o,y).minus(f).abs())<1?[c,n]:[u,r],E=s,h},r.toNumber=function(){return+I(this)},r.toPrecision=function(e,t){return null!=e&&W(e,1,G),n(this,e,t,2)},r.toString=function(e){var t,r=this,n=r.s,i=r.e;return null===i?n?(t="Infinity",n<0&&(t="-"+t)):t="NaN":(t=null==e?i<=v||b<=i?X(H(r.c),i):Y(H(r.c),i,"0"):10===e&&x?Y(H((r=F(new j(r),w+i+1,y)).c),r.e,"0"):(W(e,2,S.length,"Base"),f(Y(H(r.c),i,"0"),10,e,n,!0)),n<0&&r.c[0]&&(t="-"+t)),t},r.valueOf=r.toJSON=function(){return I(this)},r._isBigNumber=!0,r[Symbol.toStringTag]="BigNumber",r[Symbol.for("nodejs.util.inspect.custom")]=r.valueOf,null!=e&&j.set(e),j}();function At(e){for(var t=[];0<e.length;){var r=e.shift();if(S(r)){if(t.length<2)throw new Error("错误的栈长度, 可能是无法计算的表达式");var n=t.pop(),i=t.pop();if("string"==typeof n&&!E.isBigNumber(n)){if(!c(n))throw new Error("".concat(n,"不是一个合法的数字"));n=new E(n)}if("string"==typeof i&&!E.isBigNumber(i)){if(!c(i))throw new Error("".concat(i,"不是一个合法的数字"));i=new E(i)}switch(r){case"+":t.push(i.plus(n));break;case"-":t.push(i.minus(n));break;case"*":t.push(i.times(n));break;case"/":t.push(i.div(n));break;case"%":t.push(i.mod(n));break;case"**":t.push(i.pow(n))}}else t.push(r)}if(1!==t.length)throw"unvalid expression";var o=t[0];if((o=E.isBigNumber(o)?o:E(o)).isNaN())throw new Error("计算结果为NaN");return o}function St(e,t,r){var n,i,o,s,l,u,c,a,f,h,p,g,v,d,m,w,y,b,_="";return E.isBigNumber(e)?_=e.toFixed():"string"!=typeof e&&(_=e.toString()),"undefined"===_||"NaN"===_?null:(i=n=null,s=o=!1,w=a=c=u=!(l="~-"),t.forEach(function(e){var t=e.type;if("symbol"===t){if(![">=","<=","=","<",">"].includes(e.value))throw new Error("错误的格式化参数:",e.value);i=e.value}else if("to-number"===t)w=!0;else if("comma"===t)o=!0;else if("number"===t)n=e.value;else if("plus"===t)s=!0;else if("round"===t)l=e.value;else if("fraction"===t)c=!0;else if("scientific"===t)u=!0;else{if("percent"!==t)throw new Error("错误的fmt Token");a=!0}}),u?(e=E(_).toExponential(),s&&!e.startsWith("-")?"+"+e:e):c?(t=E(_).toFraction().map(function(e){return e.toFixed()}).join("/"),s&&!t.startsWith("-")?"+"+t:t):(a&&(_=E(_).times(100).toFixed()),n&&(e=_.split("."),t=e[0],e=1===e.length?"":e[1],p=i,g=+n,y=l,v=f=t,m=(d=h=e).length,b={"~-":function(){d=h.slice(0,"<"===p?g-1:g)},"~+":function(){var e,t="<"===p?g-1:g;m<=t||0===m||(e=h.slice(0,t),0!=+h.slice(t,m)&&(e=(+e+1).toString()).length>t?(d=e.slice(1,e.length),v=(+v+1).toString()):d=e)},"~5":function(){var e,t;0===m||(d=h.slice(0,e="<"===p?g-1:g),t=+h[e],Number.isNaN(t))||5<=t&&(d=(+d+1).toString()).length>e&&(d=d.slice(1,d.length),v=(+v+1).toString())},"~6":function(){var e,t,r,n;0!==m&&(t=+h[e="<"===p?g-1:g],r=""===(r=h.slice(+e+1,h.length))?0:parseInt(r),n=0===e?+f[f.length-1]:+h[e-1],d=h.slice(0,e),6<=t||5==t&&0<r||5==t&&n%2!=0)&&(d=(+d+1).toString()).length>e&&(d=d.slice(1,d.length),v=(+v+1).toString())}},"<="===p?d=m<=g?h:(b[y]&&b[y](),d.replace(/0+$/,"")):"<"===p?d=m<g?h:(b[y]&&b[y](),d.replace(/0+$/,"")):"="===p?m<g?d=h+"0".repeat(g-m):g<m&&b[y]&&b[y]():">="===p?m<g&&(d=h+"0".repeat(g-m)):">"===p&&m<=g&&(d=h+"0".repeat(g-m+1)),t=(b={int_part:v,dec_part:d}).int_part,_=""===(e=b.dec_part)?t:"".concat(t,".").concat(e)),o&&(w=!1,_=1<(y=_.split(".")).length?((b=y[0]).includes("-")?y[0]=b[0]+b.slice(1).replace(/(?=(?!^)(?:\d{3})+$)/g,","):y[0]=b.replace(/(?=(?!^)(?:\d{3})+$)/g,","),y.join(".")):(t=y[0]).includes("-")?t[0]+t.slice(1).replace(/(?=(?!^)(?:\d{3})+$)/g,","):t.replace(/(?=(?!^)(?:\d{3})+$)/g,",")),s&&(w=!1,_.startsWith("-")||(_="+"+_)),a&&(w=!1,_+="%"),w&&!r?+_:_))}function xt(e,i){return e.map(function(e){if("var"!==e.type)return e;for(var t,r,n=0;n<i.length&&!f(t=y(i[n],e.value));n++);if("number"==typeof(r=t)||c(r))return{type:"number",value:t};throw new Error("错误的填充值")})}function jt(e){var r=null;return e.length,{tokens:e.map(function(e){var t=function(e){for(var t,r,n=null,i=null,o=[/^([+-]?[\d.]+(?:e|E)(?:\+|-)?\d+)(.*)$/,/^([+-]?[\d.]+)(.*)$/],s=0;s<o.length;s++){var l=e.match(o[s]);if(l){t=l;break}}return t&&(i=t[1],""!==(r=t[2]).trim())&&(n=r),{num:i,unit:n}}(e.value);return null!==t.unit?(null==r&&(r=t.unit),{type:"number",value:t.num}):e}),unit:r}}function kt(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];var n=function(e){var t={expr:"",fmt:null,options:null,fmt_err:!1,expr_err:!1},r="",n=e[0],i=(f(i=e[1])&&(t.options=i),y(i,"_error",!1));if(0===e.length)throw new Error("至少传入一个参数");if("string"==typeof n){if(""===(r=n).trim()||n.includes("NaN"))return t.expr_err=!0,t}else{if("number"!=typeof n){if(!0===i)return t.expr_err=!0,t;throw new Error("错误的第一个参数类型: ".concat(n," 类型为:").concat(C(n)))}r=n.toString()}if(e=r.split("|"),t.expr=e[0],1<e.length){i=e[1];if(""!==i.trim())try{t.fmt=k(i)}catch(e){return t.fmt_err=!0,t}}if(null!==t.options&&t.options._fmt){var o,n=[];try{n=k(t.options._fmt)}catch(e){return t.fmt_err=!0,t}null===t.fmt?t.fmt=n:(o=t.fmt.map(function(e){return e.type}),n.forEach(function(e){o.includes(e.type)||t.fmt.push(e)}))}return t}(t),i=y(n,"options._error",void 0),o=y(n,"options._debug",!1),s=y(n,"options._unit",!1),l=n.options,u=null;if(n.fmt_err||n.expr_err){if(f(i))return i;throw new Error("表达式或格式化字符串错误,表达式为:".concat(n.expr))}if(f(i))try{c=mt(n.expr,s)}catch(e){return i}else c=mt(n.expr,s);if(o&&(console.warn("======a-calc调试模式======"),console.warn("arg:"),console.warn(n),console.warn("tokens:"),console.warn(c)),h(l)){var c,a=[];if(Array.isArray(l)?a=l:(a.push(l),f(l=y(l,"_fill_data",{}))&&(Array.isArray(l)?a=[].concat(_(a),_(l)):a.push(l))),f(i))try{c=wt(c,a,s),h(n.fmt)&&(n.fmt=xt(n.fmt,a))}catch(e){return i}else c=wt(c,a,s),h(n.fmt)&&(n.fmt=xt(n.fmt,a));[!0,"on","auto","space"].includes(s)&&(u=(l=jt(c)).unit,c=l.tokens)}a=yt(c),o&&(console.warn("分离单位之后的tokens:"),console.warn(c),console.warn("转换后的tokens"),console.log(a),console.warn("单位:".concat(u))),l=null;if(f(i))try{l=At(a)}catch(e){return i}else l=At(a);if("Infinity"!==(l=h(n.fmt)?St(l,n.fmt,s):null!==l?l.toFixed():null)&&null!==l)return null!==u&&(l+=u),l;if(f(i))return i;throw new Error("计算错误可能是非法的计算式")}console.log("%ca-calc:%c ".concat(O," %c=> %curl:%c https://www.npmjs.com/package/a-calc"),"color: #fff;background: #67C23A;padding: 2px 5px;border-radius:4px;font-size: 14px;","color: #409EFF;font-size:14px;","color: #409EFF;font-size:14px;","background: #67C23A;font-size:14px; padding: 2px 5px; border-radius: 4px; color: #fff;","font-size:14px;");t=kt;return e.calc=kt,e.fmt=t,e.version=O,Object.defineProperty(e,"__esModule",{value:!0}),e}({});
{
"name": "a-calc",
"version": "1.1.1",
"version": "1.2.0",
"description": "Very powerful arbitrary precision calculation library and number formatting library",

@@ -60,3 +60,4 @@ "main": "./cjs/index.cjs",

"浮点数",
"精度"
"精度",
"金融计算"
],

@@ -63,0 +64,0 @@ "author": "Autumn",

# a-calc
来源于实际业务的数字字符串四则运算的库, 可解决以下问题:
A convenient library for accurate calculation and formatting of numbers, which can solve the following problems:
* 体积:未压缩体积35-43KB 。gzip压缩体积13-15KB
* js数字计算精度问题
* 其他第三方库编码体验差且格式化不够方便
* 数字计算可能输出科学计数法
* 数字格式化, 数字千分位输出, 数字直接格式化成百分比, 保留数字的正负号, 直接输出分数等
* 带单位的数字计算或格式化, 例如: `0.1% + 2% `
* 科学计数法写法的计算, 例如:`-2e3 + 6`
* 支持四种舍入规则:去尾、进一、四舍五入、四舍六入(一种更精准的方法)
* Size: uncompressed size 35-43KB. Gzip compression size 13-15KB
* Make the number calculation of javascript accurate
* Other third-party libraries have poor coding experience and inconvenient formatting
* Scientific notation of possible output of numerical calculation
* Format digits, output digits in thousandths, format digits directly into percentages, keep signs of digits, output fractions directly, etc.
* Calculation or formatting of numbers with units, e.g.: `0.1% + 2%`
* Calculation in scientific notation, for example: `-2e3 + 6`
* Support four rounding rules: rounding to the end, rounding to one, rounding to five, rounding to six (a more accurate method)
> 支持的运算符 : + - * / % **
> Supported operators : + - * / % **
## 安装
**Language:** 英文 | [简体中文](https://github.com/Autumn-one/a-calc-old/blob/main/README_ZH.md)
## Installation
```

@@ -21,3 +23,3 @@ npm install a-calc

## 引入
## Import

@@ -28,4 +30,4 @@ **commonjs**

const {calc, fmt} = require("a-calc")
// 或者
const {calc, fmt} = require("a-calc/cjs") // 注意这个写法是明确指定使用cjs版本这是有意义的, 有些打包工具会对语法做转换, 直接写 a-calc 不好使(nuxt.js就是), 那就换成 a-calc/cjs 试试
// or
const {calc, fmt} = require("a-calc/cjs") // Note that this is written to explicitly specify the use of the cjs version which makes sense, some packaging tools will do a conversion of the syntax, directly write a-calc does not work (nuxt.js is), then replace it with a-calc/cjs try
```

@@ -37,3 +39,3 @@

import {calc, fmt} from "a-calc"
// 或者
// or
const {calc, fmt} from "a-calc/es"

@@ -51,3 +53,3 @@ ```

## 四则运算(支持科学计数法写法)
## Usage

@@ -57,20 +59,20 @@ ```js

// 复杂一点的计算
// A little more complicated calculation
calc("0.1 + 0.2 * 0.3 / 0.4 * (0.5 + 0.6)") // 0.265
// 科学计数法的计算
// Calculation of scientific notation
calc("-2e2 + 3e+2") // 100
```
## 关于空格
## About Spaces
空格在无歧义的情况下是非必须的,甚至可以正确解析下面人眼都难以解析的写法`calc("-2e+2+3e+2")`,但是这样清晰度太低了,请尽其所能写更清晰的代码而不是shit!<span style="color: red;">始终在你的计算式包含空格,这样更漂亮和清晰,就像我写的示例那样!!!</span>
Spaces are non-essential in the absence of ambiguity, and can even correctly parse the following writing `calc("-2e+2+3e+2")` which is difficult for the human eye to parse, but this is too low clarity, please do your best to write clearer code instead of shit! <span style="color: red;">Always include spaces in your formula, which is more beautiful and clear, just like the example I wrote!!!</span>
顺便举个有歧义的计算式 `calc("50%%2", {_unit: true})`这种歧义显然是在带单位计算的时候出现,由于解析器不知道你的单位是`%` 还是 `%%` 所以你要用空格给出明确的意思,正确的写法应该是 `calc("50% % 2", {_unit: true})`
By the way, an ambiguous equation `calc("50%%2", {_unit: true})` This ambiguity obviously occurs when calculating with units, since the parser doesn't know whether your units are `%` or `%%` so you have to use spaces to give a clear meaning, the correct way to write it would be `calc("50% % 2", {_unit: true}) `
总之始终加空格!
In short, always add space!
## 填充变量并计算(重要)
## Fill variables and calculate (important)
**计算后的值为精准值且不会出现科学计数法**
**The calculated value is accurate and there is no scientific counting method**

@@ -87,3 +89,3 @@ ```js

// 复杂一点的
// A little more complicated
calc("1 + o.a / arr[0].d",{

@@ -100,8 +102,8 @@ o: { a: 2 },

## 带单位的计算
## Calculation with unit
> 实际情况不总是那么理想, 也许我们不得不计算两个百分比数字, 幸好现在a-calc支持这些操作, 但是请注意,单位会从第一个携带单位的数字上取, 后面的单位会被忽略
> The reality is not always ideal, maybe we have to calculate two percentage numbers, fortunately a-calc supports these operations now, but please note that the units will be taken from the first number carrying the unit, and the subsequent units will be ignored
```js
// 要特别注意 _unit是必须的, 且不是默认开启的, 这是因为带单位的计算会额外做一些操作, 相比之下单纯的数字计算更快
// It is important to note that this is required and not enabled by default, because calculations with units do some extra work, which is faster than calculations with numbers alone
calc("1 + 2%", {_unit: true}) // 3%

@@ -112,20 +114,20 @@

在 `1.0.6` 之后带单位的计算可以有更多的参数,`_unit` 的取值可以为`boolean | "on" | "off" | "auto" | "space"` 参数看起来很多其实和之前的用法差不多, `true "on" "auto"` 这三个值的效果是一样的,表示自动识别数字后的单位,`false "off"` 表示关闭单位计算,最大的不同是 `"space"` 这个值表示只将空格作为单位分隔符,例如你的单位恰好是 `+-` 这种情况在普通模式下会被识别成运算符,就可以使用 `"space"` 模式,但是此时的空格就是必须的了,你要这样写:`calc("2+- * 3")` 最终结果为:`6+-`
After `1.0.6`, calculations with units can have more parameters, `_unit` can take values like `boolean | "on" | "off" | "auto" | "space"` The parameters look like a lot, but they are similar to the previous usage, `true "on" "auto"` has the same effect, it means that it automatically recognizes the number after the The biggest difference is that the `"space"` value means that only spaces are used as unit separators. For example, if your units happen to be `+-`, which would be recognized as an operator in normal mode, you can use the `"space"` mode, but then spaces are required, and you would write it like this: `calc ("2+- * 3")` The final result is: `6+-`
## 计算并格式化
## Calculate and format
格式化支持如下功能:限制小数位数,保留正负号,百分比输出,科学计数法输出,千分位输出,并且他们是可以组合的,不过有个别的情况组合是不生效的,这个自己去试一下,组合情况太多,不在一一列举。
Formatting supports the following features: limit decimal places, Keep Plus and minus signs, percentage output, scientific notation output, and kilobyte output, and they can be combined, but there are individual combinations that are not valid, try This yourself. There are too many combinations to list one by one.
**格式化列表:**
**Formatted list:**
- `>|>=|<|<=|=数字` 表示限制小数位数,例: `<=2` 小数位数小于等于2 `>3` 小数位数必须大于3,这个等价于`>=4`
- `,` 输出为千分位数字字符串
- `/` 输出为分数
- `+` 输出的正数带`+` 号
- `%` 输出百分比数字,可以和限制小数组合使用
- `-e` 输出为科学计数法,e可以大写
- `-n` 输出为数字而不是数字字符串,n可以大写,但是如果你设置了千分位、分数或百分比格式化等这个选项不生效
- `>|>=|<|<=|=Numeric` means restrict the number of decimal places, for example: `<=2` the number of decimal places is less than or equal to 2 `>3` the number of decimal places must be greater than 3, this is equivalent to `>=4`
- `,` The output is a string of digits in the thousandths
- `/` Output as fraction
- `+` Output positive numbers with `+` sign
- `%` Output a percentage number that can be used in combination with restricted decimals
- `!e` The output is scientific notation and e can be capitalized
- `!n` The output is a number, not a numeric string, and N can be uppercase, but if you set percentiles, fractions, or percentages, disk formatting and so on, this option does not take effect
```js
// 操作小数位数
// Operational decimal places
calc("0.1 + 0.2 | =2") // 0.30

@@ -137,32 +139,32 @@ calc("0.11111 + 0.11111 | <=4") // 0.2222

// 保留正负号
// Keep the sign
calc("1 + 1 | +") // +2
// 千分位
// thousands
calc("10000000 + 100000000 | ,") // 110,000,000
// 分数
// Fraction
calc("0.025 + 0.2 | /") // 9/40
// 百分比
// Percentage
calc("1 + 1 | %") // 200%
// 科学计数法, 注意这个 e也可以大写
calc("1 + 1 | -e") // 2e+0
// Scientific notation, notice that this e can also be capitalized
calc("1 + 1 | !e") // 2e+0
// 同时指定小数位和千分位且保留正负号
// Specifies both the decimal and the thousandth digits and leaves the sign plus or minus
calc("10000000 + 100000000 | +,=10") // +110,000,000.0000000000
```
## 四种舍入规则
## Four rounding rules
舍入规则通过在格式化字符串的部分加入,他们的符号分别为:
The rounding rule is added to the part of the format string, whose symbols are respectively:
- `~-` 去尾,默认的舍入规则
- `~+` 进一
- `~5` 四舍五入
- `~6` 四舍六入,该舍入规则相较四舍五入更为精准,规则在舍入的后一位为5的时候有所不同,他会查看5后面的位置,如果后面的数字不为0那么会进一,如果后面的数字为0 ,那么会看5前面的数字是否为偶数,如果是则不进,不是则进
- `~-` Tail off, default rounding rule
- `~+` Enter One
- `~5` Rounding
- `~6` This rounding rule is more accurate than rounding. The rule is different when the last digit of the rounding rule is 5. It looks at the position after 5, and if the last digit is not 0, it goes to 1, if the following number is 0, then you will see if the number before 5 is even, if it is not enter, not enter
```js
calc("0.11 + 0.22 | =1 ~+") // 0.4 保留一位并进一
calc("0.11 + 0.22 | =1 ~+") // 0.4 Keep one digit and enter one
calc("0.55 | =1 ~5") // 0.6

@@ -172,5 +174,5 @@ calc("0.65 | =1 ~6") // 0.6

这个新加入的舍入规则似乎会让格式化的部分更加的长,但是实际情况不是这样,一般一个项目的舍入规则是固定的,所以舍入规则部分的格式化应该被封装在默认的格式化参数中,在实际使用的时候完全不需要书写这部分内容,参考下面的`默认格式化` 说明
This newly added rounding rule seems to make the formatted part longer, but this is not the case. Generally, the rounding rule of an item is fixed, so the formatting of the rounding rule part should be encapsulated in the default formatting parameters. In actual use, there is no need to write this part at all. Refer to the "Default Format" description below
## 只格式化
## Format only

@@ -180,3 +182,3 @@ ```js

fmt("0.1 | =2") // 0.10
// calc 具备 fmt 的功能, 但是fmt具备更好的语义
// Calc has the functionality of fmt, but fmt has better semantics

@@ -188,36 +190,36 @@ fmt("1000000 | ,") // 1,000,000

## 高级技巧
## Advanced skills
**错误处理**
**Error Handling**
> 通常直接使用calc做计算要求输入的计算式是完全正确的, 默认 a-calc 不会帮你处理计算式的错误, 这个可以自己做过滤, 但在项目里我们可能不想做这件事情那么就需要额外的高级API, 在输入的计算式有误的时候静默捕获并给出一个合适的返回值
> Usually using calc directly requires the input formula to be completely correct. By default a-calc will not help you deal with the error of the formula. This can be filtered by yourself, but we may not want to do this in the project, so we need an extra advanced API to silently capture and give an appropriate return value when the input formula is wrong
```js
calc("1 + 2sd + d",{
_fill_data: {d: 3}, // 从这里数据源对象要赋给 _fill_data, 该对象也可以是一个对象数组,此时取数据的时候是依次从数组的项里查找,找到第一个立刻停止
_error: "-", // 计算式出错的时候返回 - 作为替代值
_fill_data: {d: 3}, // From here, the data source object is assigned to _fill_data, which can also be an array of objects. When fetching data, it is successively searched from the array items, and the first one is immediately stopped
_error: "-", // Returns - as an alternative value if the equation is wrong
})
// 上面的写法可以简化一下
// The above writing can be simplified
calc("1 + 2sd + d", {
d: 8,
_error: "-"
}) // 这种简化单纯是为了方便
}) // This simplification is simply for convenience
```
**默认格式化**
**Default formatting**
> 在实际项目中可以利用默认格式化优化开发体验
> Default formatting can be used to optimize the development experience in real projects
```js
calc("111111 + 11111 | ,",{_fmt: "=2"}) // 122,222.00 很显然 , 和 =2 被组合起来了,且表达式中的格式化字符串优先级更高
calc("111111 + 11111 | ,",{_fmt: "=2"}) // 122,222.00 Obviously , and =2 are combined, and the formatted string in the expression has higher priority
```
## 在项目中的使用姿势(vue3为例)
## Use gestures in projects(vue3)
> 在项目中编写庞大的第二个参数是不好的, 所以第二个参数你应该想办法固定他, 下面只是一个在VUE项目中的演示
> It is not good to write a huge second parameter in the project, so you should find a way to fix it. The following is just a demonstration in the VUE project
### 集成到vue3模板
### Integration into vue3 templates
下面是包装函数,模板和 script setup 中都可以使用这个函数,可以使用 `unplugin-auto-import` 自动集成到模板中,具体看对应插件的文档,如果你想手动集成就使用 vue 的`app.config.globalProperties`绑定就好了
You can use `unplugin-auto-import` to automatically integrate it into the template, see the documentation of the corresponding plugin, or use the `app.config.globalProperties` binding of vue if you want to integrate it manually

@@ -256,11 +258,11 @@ ```typescript

### 集成到script setup中
### Integrated into script setup
还是使用上面的函数,依然可以使用 `unplugin-auto-import` 插件来自动导入,实际开发的体验就像是`calc` 是一个全局函数一样,不用import。
Still using the above functions, you can still use the `unplugin-auto-import` plugin to automatically import them, and the actual development experience is like `calc` is a global function without import.
当然如果你不用这个插件自动导入那么就需要每次写的时候都import一下。
Of course if you don't use this plugin to import automatically then you need to import it every time you write.
### 模板中的使用方式
### Usage in templates
模板中的calc可以访问到所有的setup中定义的状态,所以可以直接写,有些时候状态状态来自于作用域插槽,那就在额外传入第二个参数。
calc in the template has access to all the states defined in setup, so it can be written directly. Sometimes the state state comes from the scope slot, which is passed in as an additional second parameter.

@@ -290,5 +292,5 @@ ```vue

### script setup中的使用方式
### Usage in script setup
这个需要注意了,在setup顶级作用域中直接使用 `calc` 是访问不到setup内部状态的,但是在生命周期中是可以直接访问到的。
This should be noted that using `calc` directly in the setup top-level scope does not access the setup internal state, but it can be accessed directly during the life cycle.

@@ -316,9 +318,9 @@ ```vue

### 不推荐的写法
### Disrecommended writing
`a-calc` 可以使用模板字符串写法, 但是我在实践中发现这种写法的可读性很糟糕,除非你真的有足够合理的理由,不然不建议使用模板字符串的写法。
`a-calc` can be written using template strings, but I've found in practice that the readability of this writing is terrible, and it's not recommended unless you really have a valid enough reason to use template strings.
```typescript
calc(`${a} + ${b}`) // 这种写法不推荐
calc("a + b", {a,b}) // 推荐写法,因为更清晰
calc(`${a} + ${b}`) // This writing style is not recommended
calc("a + b", {a,b}) // Recommended writing style because it is clearer
```

@@ -328,67 +330,66 @@

## 版本变更
## Version change
* 1.2.0
- Very minor breaking update, the former `-e` and `-n` become `!e` and `!n` respectively
- Document update
* 1.1.0
- 很小的破环性更新,以前的 `\e` 科学计数法输出,现在是 `-e`,其他没变
- 增加了 `-n` 输出数字类型
- 对于小数位的限制支持了 `<` 和 `>` 符号
- 修复了若干舍入格式化问题
- 单元测试增加到107个
- Very minor loop-breaking update, the previous `\e` scientific notation output is now `-e`, the rest is unchanged
- Added `-n` output number type
- Support `<` and `>` symbols for decimal place restrictions
- Fixed several rounding formatting issues
- Increased the number of unit tests to 107
* 1.0.25
- 文档更新,简化 a-calc 集成到vue3的写法
- Documentation update to simplify writing a-calc integration to vue3
* 1.0.23
- 文档更新,重新编写将a-calc集成到vue3的推荐写法
- Updated documentation to rewrite the recommended way to integrate a-calc into vue3
* 1.0.22
- 优化小数位舍入逻辑
- Optimize fractional rounding logic
* 1.0.21
- 完善导出的类型定义
- Improve export type definition
* 1.0.19
- 修复 _error 为空字符串的时候可能无法捕获错误的问题
- Fix the problem that _error may not catch errors when it is an empty string.
* 1.0.14
- 修复 ** 运算符优先级错误的问题。
- 对于 `<=` 格式化时可能会有多余的0未去除的问题进行修复。
- Fix ** operator priority error.
- Fix for `<=` formatting that may have extra zeros not removed.
* 1.0.12
- 文档添加库体积说明
- 修复表达式为空的时候加上 _error 参数依然异常的问题, 并添加相应的单元测试
- Document add library volume description
- Fix the problem that the _error parameter is still abnormal when the expression is null, and add the corresponding unit test.
* 1.0.10
- 更新文档
- Update documentation
* 1.0.6
* 破坏性变更:所有暴露出的小驼峰命名全部改成了蛇形命名法例如原来的`_fillData` 现在变成了 `_fill_data`,原因是蛇形命名法更清晰。
* 内部代码极大的简化,解析器几乎完全重写,带来更稳定的体验
* 原先的设计就是calc函数具备所有fmt的功能,可是1.0.6之前的版本虽然符合这个设计,但calc和fmt是分别实现的,现在fmt只是calc的别名。
* 支持新的运算符 **
* 支持新的格式化字符 % 可以将数字输出成百分比
* 支持新的格式化字符 `\e`,可以将数字格式化成科学计数法
* 修复格式化字符串非法的时候可能造成死循环的问题
* 解决1/0是 Infinity 的问题
* 增加若干单元测试
* 更详细的类型提示
* 更新文档,添加vue3集成的示例代码
* Destructive change: all exposed small humps are now snake naming, e.g. `_fillData` is now `_fill_data`, because the snake naming is clearer.
* The internal code has been greatly simplified and the parser has been almost completely rewritten to bring a more stable experience
* The original design was that the calc function had all the functionality of fmt, but while versions prior to 1.0.6 conformed to this design, calc and fmt were implemented separately, and now fmt is just an alias for calc.
* Support for the new operator **
* Support for new formatting characters % Can output numbers as percentages
* Support for the new formatting character `\e`, which can format numbers into scientific notation
* Fix a problem that may cause a dead loop when formatting an illegal string
* Fix the problem that 1/0 is Infinity.
* Add several unit tests
* More detailed type hints
* Update documentation to add sample code for vue3 integration
* 0.0.80
* 带来4种舍入规则,分别为:去尾、进一、四舍五入、四舍六入
* 更多边界情况的检测
* fmt允许不传入格式化字符串,这个特性允许你使用 fmt 来清除小数点后多余的0
* 0.0.79
* 更新文档
* Bring 4 types of rounding rules, which are: rounding to the end, rounding to one, rounding to five, rounding to six
* More boundary case detection
* fmt allows not passing in formatted strings, a feature that allows you to use fmt to remove extra zeros after the decimal point
* 0.0.79
* Update documentation
* 0.0.78
* 支持科学计数法的计算
* 完整的单元测试
* 更多边界情况的检测
* Support for scientific notation calculations
* Full unit tests
* More boundary case detection
* 0.0.72
* 支持单个数值的带单位写法, 例如 `calc("1元", {_unit: true})` 或者 `fmt("1元 | =2",{_unit: true})`
* 补充文档
* Support for writing single values with units, e.g. `calc("$1", {_unit: true})` or `fmt("$1 | =2",{_unit: true})`
* Additional documentation
## 注意
## Attention
- 不要对单个数字包裹括号
- Do not wrap parentheses around a single number
## 视频教程
## Question submission
待定
(If you encounter any problems, please be the first to send me feedback email, 718879459@qq.com for bugs I will be the first to fix him)
## 问题提交
(如果遇到了什么问题, 请第一时间向我发送反馈邮件, 718879459@qq.com 对于bug我会第一时间修复他)

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc