a-calc 0.0.60 → 0.0.61

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -112,11 +112,16 @@ Usually you do the calculation directly with CALC and it requires that the input
112
112
  (通常直接使用calc做计算要求输入的计算式是完全正确的, 默认 a-calc 不会帮你处理计算式的错误, 这个可以自己做过滤, 但在项目里我们可能不想做这件事情那么就需要额外的高级API, 在输入的计算式有误的时候静默捕获并给出一个合适的出错时返回的值)
113
113
 
114
114
  ```js
115
- calc("1 + 2... + d",{
116
- _fillData: {d: 3},
115
+ calc("1 + 2sd + d",{
116
+ _fillData: {d: 3}, // 从这里数据源对象要赋给 _fillData, 该对象也可以是一个对象数组,此时取数据的时候是依次从数组的项里查找,找到第一个立刻停止
117
117
  _error: "-", // 计算式出错的时候返回 - 作为替代值
118
118
  })
119
- // 注意这种写法填充数字的对象要给 _fillData
119
+
120
+ // 上面的写法可以简化一下
121
+ calc("1 + 2sd + d", {
122
+ d: 8,
123
+ _error: "-"
124
+ }) // 这种简化单纯是为了方便
120
125
  ```
121
126
 
122
127
 
@@ -1 +1 @@
1
- var a_calc=function(t){"use strict";function R(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var l=R(BigNumber);function u(t){return-1<"+-*/%()".indexOf(t)}function c(t){switch(t){case"+":case"-":return 1;case"*":case"/":case"%":return 2;default:return 0}}function f(){for(var t=arguments.length,r=new Array(t),e=0;e<t;e++)r[e]=arguments[e];return r.some(function(t){return void 0!==t})}function s(t){return"string"==typeof t&&!!/^[+-]?\d+\.?\d*$/.test(t)}function n(t){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function o(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}function i(t,r){for(var e=0;e<r.length;e++){var n=r[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function r(t,r,e){return r&&i(t.prototype,r),e&&i(t,e),Object.defineProperty(t,"prototype",{writable:!1}),t}function a(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),r&&h(t,r)}function p(t){return(p=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function h(t,r){return(h=Object.setPrototypeOf||function(t,r){return t.__proto__=r,t})(t,r)}function d(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(t){return!1}}function v(t,r,e){return(v=d()?Reflect.construct:function(t,r,e){var n=[null];n.push.apply(n,r);r=new(Function.bind.apply(t,n));return e&&h(r,e.prototype),r}).apply(null,arguments)}function y(t){var e="function"==typeof Map?new Map:void 0;return(y=function(t){if(null===t||-1===Function.toString.call(t).indexOf("[native code]"))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,r)}function r(){return v(t,arguments,p(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),h(r,t)})(t)}function B(t,r){if(r&&("object"==typeof r||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");r=t;if(void 0===r)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return r}function _(e){var n=d();return function(){var t,r=p(e);return B(this,n?(t=p(this).constructor,Reflect.construct(r,arguments,t)):r.apply(this,arguments))}}var g=function(){a(n,y(Error));var e=_(n);function n(t){var r;return o(this,n),(r=e.call(this,t)).name="CalculatorError",r.message=t,r}return r(n)}(),b=function(){a(n,y(Error));var e=_(n);function n(t){var r;return o(this,n),(r=e.call(this,t)).name="TokensFillError",r.message=t,r}return r(n)}();function w(t){var r={expr:"",fmt:null,data:null},e="",n=t[0];if(1===t.length)"string"==typeof n?e=n:"number"==typeof n?e=n.toString():Array.isArray(n)&&(e=n[0]);else if(1<t.length){n=t[t.length-1];if(o=n,("[object Object]"!==Object.prototype.toString.call(o)||Array.isArray(o))&&!Array.isArray(n))throw new Error("参数错误, 暂不支持的参数");if("string"==typeof(e=t[0])){if(""===e.trim())throw new b("参数不可为空字符串")}else if("number"==typeof e)e=e.toString();else if(void 0===e||Number.isNaN(e))throw new b("非法参数:".concat(e));r.data=n}var o=e.split("|");return 1===o.length?r.expr=o[0]:(r.expr=o[0],""!==(t=o[1]).trim()&&(r.fmt=t)),null!==r.data&&null===r.fmt&&r.data._fmt&&(r.fmt=r.data._fmt),r}function m(t,r){var e="",n=(e=l.default.isBigNumber(t)?t.toFixed():"string"!=typeof t?t.toString():t,null),t=null,o=null,i=r.match(/(<=|>=|=)\s*(\d+)/);if(i&&(t=i[1],n=Number(i[2])),r.includes(",")&&(o=!0),null!==n){var i=e.split("."),r=i[0],a=1===i.length?"":i[1],u=a.length;switch(t){case"<=":a=u<=n?a:a.slice(0,n);break;case"=":u<n?a+="0".repeat(n-u):n<u&&(a=a.slice(0,n));break;case">=":a=n<=u?a:a+"0".repeat(n-u)}e=""===a?r:"".concat(r,".").concat(a)}return e=null!==o?1<(i=e.split(".")).length?((t=i[0]).includes("-")?i[0]=t[0]+t.slice(1).replace(/(?=(?!^)(?:\d{3})+$)/g,","):i[0]=t.replace(/(?=(?!^)(?:\d{3})+$)/g,","),i.join(".")):(r=i[0]).includes("-")?r[0]+r.slice(1).replace(/(?=(?!^)(?:\d{3})+$)/g,","):r.replace(/(?=(?!^)(?:\d{3})+$)/g,","):e}function C(t){for(var r=[],e=0,n=null,o=t.length;e<o;)if(n=t[e],/\s/.test(n))e++;else if("+-".includes(n)){var i=r[r.length-1];if(0===r.length||"+-".includes(i)||"("===i){for(var a=n,n=t[++e];/[a-zA-Z\d._]/.test(n);)a+=n,n=t[++e];r.push(a)}else r.push(n),e++}else if("*/%()".includes(n))r.push(n),e++;else if(/[\w_.\[\]"']/.test(n)){for(var u="";/[\w_.\[\]"']/.test(n)&&(u+=n,!(++e>=o));)n=t[e];r.push(u)}else if(/\d/.test(n)){for(var l="";/[\d.]/.test(n)&&(l+=n,!(++e>=o));)n=t[e];r.push(l)}return r}var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},j=Array.isArray,e="object"==n(e)&&e&&e.Object===Object&&e,O="object"==("undefined"==typeof self?"undefined":n(self))&&self&&self.Object===Object&&self,e=e||O||Function("return this")(),O=e.Symbol,E=Object.prototype,M=E.hasOwnProperty,G=E.toString,A=O?O.toStringTag:void 0;var I=Object.prototype.toString;var U=function(t){var r=M.call(t,A),e=t[A];try{var n=!(t[A]=void 0)}catch(t){}var o=G.call(t);return n&&(r?t[A]=e:delete t[A]),o},Z=function(t){return I.call(t)},q=O?O.toStringTag:void 0;function H(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":(q&&q in Object(t)?U:Z)(t)}var J=H,K=function(t){return null!=t&&"object"==n(t)};function S(t){return"symbol"==n(t)||K(t)&&"[object Symbol]"==J(t)}var L=j,Q=S,V=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,W=/^\w*$/;function X(t,r){if(L(t))return!1;var e=n(t);return!("number"!=e&&"symbol"!=e&&"boolean"!=e&&null!=t&&!Q(t))||(W.test(t)||!V.test(t)||null!=r&&t in Object(r))}function Y(t){var r=n(t);return null!=t&&("object"==r||"function"==r)}var tt=H,rt=Y;function et(t){return!!rt(t)&&("[object Function]"==(t=tt(t))||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t)}var E=e["__core-js_shared__"],nt=(E=/[^.]+$/.exec(E&&E.keys&&E.keys.IE_PROTO||""))?"Symbol(src)_1."+E:"";var ot=Function.prototype.toString;var it=et,at=function(t){return!!nt&&nt in t},ut=Y,lt=function(t){if(null!=t){try{return ot.call(t)}catch(t){}try{return t+""}catch(t){}}return""},ct=/^\[object .+?Constructor\]$/,E=Function.prototype,x=Object.prototype,E=E.toString,x=x.hasOwnProperty,ft=RegExp("^"+E.call(x).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");var st=function(t){return!(!ut(t)||at(t))&&(it(t)?ft:ct).test(lt(t))},pt=function(t,r){return null==t?void 0:t[r]};function ht(t,r){return t=pt(t,r),st(t)?t:void 0}var E=ht(Object,"create"),dt=E;var vt=E,yt=Object.prototype.hasOwnProperty;var _t=E,gt=Object.prototype.hasOwnProperty;var bt=E;function wt(t){return t=this.has(t)&&delete this.__data__[t],this.size-=t?1:0,t}function mt(t){var r,e=this.__data__;return vt?"__lodash_hash_undefined__"===(r=e[t])?void 0:r:yt.call(e,t)?e[t]:void 0}function jt(t){var r=this.__data__;return _t?void 0!==r[t]:gt.call(r,t)}function Ot(t,r){var e=this.__data__;return this.size+=this.has(t)?0:1,e[t]=bt&&void 0===r?"__lodash_hash_undefined__":r,this}function $(t){var r=-1,e=null==t?0:t.length;for(this.clear();++r<e;){var n=t[r];this.set(n[0],n[1])}}$.prototype.clear=function(){this.__data__=dt?dt(null):{},this.size=0},$.prototype.delete=wt,$.prototype.get=mt,$.prototype.has=jt,$.prototype.set=Ot;x=$;var Et=function(t,r){return t===r||t!=t&&r!=r};function P(t,r){for(var e=t.length;e--;)if(Et(t[e][0],r))return e;return-1}var At=P,St=Array.prototype.splice;var xt=P;var $t=P;var Pt=P;function kt(t){var r=this.__data__;return!((t=At(r,t))<0)&&(t==r.length-1?r.pop():St.call(r,t,1),--this.size,!0)}function zt(t){var r=this.__data__;return(t=xt(r,t))<0?void 0:r[t][1]}function Ft(t){return-1<$t(this.__data__,t)}function Nt(t,r){var e=this.__data__,n=Pt(e,t);return n<0?(++this.size,e.push([t,r])):e[n][1]=r,this}function k(t){var r=-1,e=null==t?0:t.length;for(this.clear();++r<e;){var n=t[r];this.set(n[0],n[1])}}k.prototype.clear=function(){this.__data__=[],this.size=0},k.prototype.delete=kt,k.prototype.get=zt,k.prototype.has=Ft,k.prototype.set=Nt;var E=k,e=ht(e,"Map"),Tt=x,Dt=E,Rt=e;var Bt=function(t){var r=n(t);return"string"==r||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==t:null===t};function z(t,r){return t=t.__data__,Bt(r)?t["string"==typeof r?"string":"hash"]:t.map}var Ct=z;var Mt=z;var Gt=z;var It=z;function Ut(t){return t=Ct(this,t).delete(t),this.size-=t?1:0,t}function Zt(t){return Mt(this,t).get(t)}function qt(t){return Gt(this,t).has(t)}function Ht(t,r){var e=It(this,t),n=e.size;return e.set(t,r),this.size+=e.size==n?0:1,this}function F(t){var r=-1,e=null==t?0:t.length;for(this.clear();++r<e;){var n=t[r];this.set(n[0],n[1])}}F.prototype.clear=function(){this.size=0,this.__data__={hash:new Tt,map:new(Rt||Dt),string:new Tt}},F.prototype.delete=Ut,F.prototype.get=Zt,F.prototype.has=qt,F.prototype.set=Ht;var Jt=F;function N(n,o){if("function"!=typeof n||null!=o&&"function"!=typeof o)throw new TypeError("Expected a function");function i(){var t=arguments,r=o?o.apply(this,t):t[0],e=i.cache;return e.has(r)?e.get(r):(t=n.apply(this,t),i.cache=e.set(r,t)||e,t)}return i.cache=new(N.Cache||Jt),i}N.Cache=Jt;var Kt=N;var Lt=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Qt=/\\(\\)?/g,x=function(t){var r=(t=Kt(t,function(t){return 500===r.size&&r.clear(),t})).cache;return t}(function(t){var o=[];return 46===t.charCodeAt(0)&&o.push(""),t.replace(Lt,function(t,r,e,n){o.push(e?n.replace(Qt,"$1"):r||t)}),o});var Vt=function(t,r){for(var e=-1,n=null==t?0:t.length,o=Array(n);++e<n;)o[e]=r(t[e],e,t);return o},Wt=j,Xt=S,E=O?O.prototype:void 0,Yt=E?E.toString:void 0;var tr=function t(r){if("string"==typeof r)return r;if(Wt(r))return Vt(r,t)+"";if(Xt(r))return Yt?Yt.call(r):"";var e=r+"";return"0"==e&&1/r==-1/0?"-0":e};var rr=j,er=X,nr=x,or=function(t){return null==t?"":tr(t)};var ir=S;var ar=function(t,r){return rr(t)?t:er(t,r)?[t]:nr(or(t))},ur=function(t){if("string"==typeof t||ir(t))return t;var r=t+"";return"0"==r&&1/t==-1/0?"-0":r};var lr=function(t,r){for(var e=0,n=(r=ar(r,t)).length;null!=t&&e<n;)t=t[ur(r[e++])];return e&&e==n?t:void 0};var T=function(t,r,e){return void 0===(t=null==t?void 0:lr(t,r))?e:t};function D(t,r){for(var e=r._fillData,n=(void 0===r._fillData&&(e=r),Array.isArray(e)||(e=[e]),[]),o=0;o<t.length;o++){var i=t[o];if(/^[a-zA-z_][\w\[\]"'_.]*$/.test(i)){if("undefined"===i||"NaN"===i)throw new b("key不应该为:".concat(i));for(var a=null,u=0;u<e.length;u++){var l=e[u],l=T(l,i);if(void 0!==l){a=l;break}}if(null===a)throw new b("token填充失败,请确认".concat(i,"存在"));if("string"==typeof a){if(""===a.trim())throw new b("token填充失败,".concat(i,"值不可为空字符"));if(!s(a))throw new b("token填充失败,".concat(i,"值:").concat(a,"为非法数字"))}a="string"!=typeof a?a.toString():a,n.push(a)}else n.push(i)}return n}function cr(t){for(var r,e=[],n=[],o=t;0<o.length;){var i=o.shift();if(u(i))if("("===i)e.push(i);else if(")"===i){for(var a=e.pop();"("!==a&&0<e.length;)n.push(a),a=e.pop();if("("!==a)throw"error: unmatched ()"}else{for(;r=e[e.length-1],c(i)<=c(r)&&0<e.length;)n.push(e.pop());e.push(i)}else n.push(i)}if(0<e.length){if(")"===e[e.length-1]||"("===e[e.length-1])throw"error: unmatched ()";for(;0<e.length;)n.push(e.pop())}return n}function fr(t){for(var r=[];0<t.length;){var e=t.shift();if(u(e)){if(r.length<2)throw new g("错误的栈长度, 可能是无法计算的表达式");var n=r.pop(),o=r.pop();if("string"==typeof n&&!l.default.isBigNumber(n)){if(!/^[+-]*[\d.]+$/.test(n))throw new g("".concat(n,"不是一个合法的数字"));n=new l.default(n)}if("string"==typeof o&&!l.default.isBigNumber(o)){if(!/^[+-]*[\d.]+$/.test(o))throw new g("".concat(o,"不是一个合法的数字"));o=new l.default(o)}switch(e){case"+":r.push(o.plus(n));break;case"-":r.push(o.minus(n));break;case"*":r.push(o.times(n));break;case"/":r.push(o.div(n));break;case"%":r.push(o.mod(n))}}else r.push(e)}if(1!==r.length)throw"unvalid expression";return r[0]}return t.calc=function(){for(var t=arguments.length,r=new Array(t),e=0;e<t;e++)r[e]=arguments[e];var n=w(r),o=C(n.expr),i=null;if(!0===T(n,"data._debug")&&(console.warn("======a-calc调试模式======"),console.warn(n),console.warn(o)),null!==n.data){var a=n.data;if(null!==(i=!Array.isArray(a)&&f(a._fillData,a._error,a._fillError,a._calcError)?a:i)&&void 0!==a._fillData&&f(i._fillError,i._error))try{o=D(o,a._fillData)}catch(t){if(t instanceof b)return void 0!==i._warn&&!0===i._warn&&console.warn(t),i._fillError||i._error;throw t}else o=D(o,a)}if(a=cr(o),(o=null)===i||void 0===i._calcError&&void 0===i._error)o=fr(a);else try{o=fr(a)}catch(t){if(t instanceof g)return void 0!==i._warn&&!0===i._warn&&console.warn(t),void 0!==i._calcError?i._calcError:i._error;throw t}return o=null!==n.fmt?m(o,n.fmt):null!==o?o.toFixed():null},t.fmt=function(){for(var t=arguments.length,r=new Array(t),e=0;e<t;e++)r[e]=arguments[e];var n=w(r),o=C(n.expr),i=null;if(!0===T(n,"data._debug")&&(console.warn("======a-calc调试模式======"),console.warn(n),console.warn(o)),""===n.expr.trim()&&null!==n.data&&void 0!==n.data._error)return n.data._error;if(2<o.length)throw new Error("fmt并非用于计算, 不能传入多个标识:".concat(n.expr));if(1!==o.length)throw new Error("fmt接收了一个无法被解析的标识");if(null!==n.data){var a=n.data;if(null!==(i=!Array.isArray(a)&&f(a._fillData,a._error,a._fillError)?a:i)&&void 0!==a._fillData&&f(i._fillError,i._error))try{o=D(o,a._fillData)}catch(t){if(t instanceof b)return void 0!==i._warn&&!0===i._warn&&console.warn(t),i._fillError||i._error;throw t}else o=D(o,a)}if(null===n.fmt)throw"表达式没有格式化部分";if(s(i=o[0]))return m(o[0],n.fmt);throw new b("待格式化对象: ".concat(i," 不是数字"))},t.version="0.0.58",Object.defineProperty(t,"__esModule",{value:!0}),t}({});
1
+ var a_calc=function(t){"use strict";function C(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var c=C(BigNumber);function n(t){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function o(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}function i(t,r){for(var e=0;e<r.length;e++){var n=r[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function r(t,r,e){return r&&i(t.prototype,r),e&&i(t,e),Object.defineProperty(t,"prototype",{writable:!1}),t}function a(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),r&&l(t,r)}function u(t){return(u=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function l(t,r){return(l=Object.setPrototypeOf||function(t,r){return t.__proto__=r,t})(t,r)}function f(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(t){return!1}}function s(t,r,e){return(s=f()?Reflect.construct:function(t,r,e){var n=[null];n.push.apply(n,r);r=new(Function.bind.apply(t,n));return e&&l(r,e.prototype),r}).apply(null,arguments)}function p(t){var e="function"==typeof Map?new Map:void 0;return(p=function(t){if(null===t||-1===Function.toString.call(t).indexOf("[native code]"))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,r)}function r(){return s(t,arguments,u(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),l(r,t)})(t)}function B(t,r){if(r&&("object"==typeof r||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");r=t;if(void 0===r)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return r}function h(e){var n=f();return function(){var t,r=u(e);return B(this,n?(t=u(this).constructor,Reflect.construct(r,arguments,t)):r.apply(this,arguments))}}function y(t){return function(t){if(Array.isArray(t))return v(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,r){if(t){if("string"==typeof t)return v(t,r);var e=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(e="Object"===e&&t.constructor?t.constructor.name:e)||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?v(t,r):void 0}}(t)||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 v(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=new Array(r);e<r;e++)n[e]=t[e];return n}function M(t){return-1<"+-*/%()".indexOf(t)}function I(t){switch(t){case"+":case"-":return 1;case"*":case"/":case"%":return 2;default:return 0}}function d(t){return void 0!==t}function _(){for(var t=arguments.length,r=new Array(t),e=0;e<t;e++)r[e]=arguments[e];return r.some(function(t){return void 0!==t})}function b(t){return null!==t}function g(t){return"string"==typeof t&&!!/^[+-]?\d+\.?\d*$/.test(t)}var w=function(){a(n,p(Error));var e=h(n);function n(t){var r;return o(this,n),(r=e.call(this,t)).name="CalculatorError",r.message=t,r}return r(n)}(),m=function(){a(n,p(Error));var e=h(n);function n(t){var r;return o(this,n),(r=e.call(this,t)).name="TokensFillError",r.message=t,r}return r(n)}();function D(t){var r={expr:"",fmt:null,data:null},e="",n=t[0];if(1===t.length)"string"==typeof n?e=n:"number"==typeof n?e=n.toString():Array.isArray(n)&&(e=n[0]);else if(1<t.length){n=t[t.length-1];if(o=n,("[object Object]"!==Object.prototype.toString.call(o)||Array.isArray(o))&&!Array.isArray(n))throw new Error("参数错误, 暂不支持的参数");if("string"==typeof(e=t[0])){if(""===e.trim())throw new m("参数不可为空字符串")}else if("number"==typeof e)e=e.toString();else if(void 0===e||Number.isNaN(e))throw new m("非法参数:".concat(e));r.data=n}var o=e.split("|");return 1===o.length?r.expr=o[0]:(r.expr=o[0],""!==(t=o[1]).trim()&&(r.fmt=t)),null!==r.data&&null===r.fmt&&r.data._fmt&&(r.fmt=r.data._fmt),r}function U(t,r){var e="",n=(e=c.default.isBigNumber(t)?t.toFixed():"string"!=typeof t?t.toString():t,null),t=null,o=null,i=r.match(/(<=|>=|=)\s*(\d+)/);if(i&&(t=i[1],n=Number(i[2])),r.includes(",")&&(o=!0),null!==n){var i=e.split("."),r=i[0],a=1===i.length?"":i[1],u=a.length;switch(t){case"<=":a=u<=n?a:a.slice(0,n);break;case"=":u<n?a+="0".repeat(n-u):n<u&&(a=a.slice(0,n));break;case">=":a=n<=u?a:a+"0".repeat(n-u)}e=""===a?r:"".concat(r,".").concat(a)}return e=null!==o?1<(i=e.split(".")).length?((t=i[0]).includes("-")?i[0]=t[0]+t.slice(1).replace(/(?=(?!^)(?:\d{3})+$)/g,","):i[0]=t.replace(/(?=(?!^)(?:\d{3})+$)/g,","),i.join(".")):(r=i[0]).includes("-")?r[0]+r.slice(1).replace(/(?=(?!^)(?:\d{3})+$)/g,","):r.replace(/(?=(?!^)(?:\d{3})+$)/g,","):e}function G(t){for(var r=[],e=0,n=null,o=t.length;e<o;)if(n=t[e],/\s/.test(n))e++;else if("+-".includes(n)){var i=r[r.length-1];if(0===r.length||"+-".includes(i)||"("===i){for(var a=n,n=t[++e];/[a-zA-Z\d._]/.test(n);)a+=n,n=t[++e];r.push(a)}else r.push(n),e++}else if("*/%()".includes(n))r.push(n),e++;else if(/[\w_.\[\]"']/.test(n)){for(var u="";/[\w_.\[\]"']/.test(n)&&(u+=n,!(++e>=o));)n=t[e];r.push(u)}else if(/\d/.test(n)){for(var c="";/[\d.]/.test(n)&&(c+=n,!(++e>=o));)n=t[e];r.push(c)}return r}var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},j=Array.isArray,e="object"==n(e)&&e&&e.Object===Object&&e,O="object"==("undefined"==typeof self?"undefined":n(self))&&self&&self.Object===Object&&self,e=e||O||Function("return this")(),O=e.Symbol,A=Object.prototype,Z=A.hasOwnProperty,q=A.toString,S=O?O.toStringTag:void 0;var H=Object.prototype.toString;var J=function(t){var r=Z.call(t,S),e=t[S];try{var n=!(t[S]=void 0)}catch(t){}var o=q.call(t);return n&&(r?t[S]=e:delete t[S]),o},K=function(t){return H.call(t)},L=O?O.toStringTag:void 0;function Q(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":(L&&L in Object(t)?J:K)(t)}var V=Q,W=function(t){return null!=t&&"object"==n(t)};function E(t){return"symbol"==n(t)||W(t)&&"[object Symbol]"==V(t)}var X=j,Y=E,tt=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,rt=/^\w*$/;function et(t,r){if(X(t))return!1;var e=n(t);return!("number"!=e&&"symbol"!=e&&"boolean"!=e&&null!=t&&!Y(t))||(rt.test(t)||!tt.test(t)||null!=r&&t in Object(r))}function nt(t){var r=n(t);return null!=t&&("object"==r||"function"==r)}var ot=Q,it=nt;function at(t){return!!it(t)&&("[object Function]"==(t=ot(t))||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t)}var A=e["__core-js_shared__"],ut=(A=/[^.]+$/.exec(A&&A.keys&&A.keys.IE_PROTO||""))?"Symbol(src)_1."+A:"";var ct=Function.prototype.toString;var lt=at,ft=function(t){return!!ut&&ut in t},st=nt,pt=function(t){if(null!=t){try{return ct.call(t)}catch(t){}try{return t+""}catch(t){}}return""},ht=/^\[object .+?Constructor\]$/,A=Function.prototype,x=Object.prototype,A=A.toString,x=x.hasOwnProperty,yt=RegExp("^"+A.call(x).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");var vt=function(t){return!(!st(t)||ft(t))&&(lt(t)?yt:ht).test(pt(t))},dt=function(t,r){return null==t?void 0:t[r]};function _t(t,r){return t=dt(t,r),vt(t)?t:void 0}var A=_t(Object,"create"),bt=A;var gt=A,wt=Object.prototype.hasOwnProperty;var mt=A,jt=Object.prototype.hasOwnProperty;var Ot=A;function At(t){return t=this.has(t)&&delete this.__data__[t],this.size-=t?1:0,t}function St(t){var r,e=this.__data__;return gt?"__lodash_hash_undefined__"===(r=e[t])?void 0:r:wt.call(e,t)?e[t]:void 0}function Et(t){var r=this.__data__;return mt?void 0!==r[t]:jt.call(r,t)}function xt(t,r){var e=this.__data__;return this.size+=this.has(t)?0:1,e[t]=Ot&&void 0===r?"__lodash_hash_undefined__":r,this}function P(t){var r=-1,e=null==t?0:t.length;for(this.clear();++r<e;){var n=t[r];this.set(n[0],n[1])}}P.prototype.clear=function(){this.__data__=bt?bt(null):{},this.size=0},P.prototype.delete=At,P.prototype.get=St,P.prototype.has=Et,P.prototype.set=xt;x=P;var Pt=function(t,r){return t===r||t!=t&&r!=r};function $(t,r){for(var e=t.length;e--;)if(Pt(t[e][0],r))return e;return-1}var $t=$,kt=Array.prototype.splice;var zt=$;var Tt=$;var Ft=$;function Nt(t){var r=this.__data__;return!((t=$t(r,t))<0)&&(t==r.length-1?r.pop():kt.call(r,t,1),--this.size,!0)}function Rt(t){var r=this.__data__;return(t=zt(r,t))<0?void 0:r[t][1]}function Ct(t){return-1<Tt(this.__data__,t)}function Bt(t,r){var e=this.__data__,n=Ft(e,t);return n<0?(++this.size,e.push([t,r])):e[n][1]=r,this}function k(t){var r=-1,e=null==t?0:t.length;for(this.clear();++r<e;){var n=t[r];this.set(n[0],n[1])}}k.prototype.clear=function(){this.__data__=[],this.size=0},k.prototype.delete=Nt,k.prototype.get=Rt,k.prototype.has=Ct,k.prototype.set=Bt;var A=k,e=_t(e,"Map"),Mt=x,It=A,Dt=e;var Ut=function(t){var r=n(t);return"string"==r||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==t:null===t};function z(t,r){return t=t.__data__,Ut(r)?t["string"==typeof r?"string":"hash"]:t.map}var Gt=z;var Zt=z;var qt=z;var Ht=z;function Jt(t){return t=Gt(this,t).delete(t),this.size-=t?1:0,t}function Kt(t){return Zt(this,t).get(t)}function Lt(t){return qt(this,t).has(t)}function Qt(t,r){var e=Ht(this,t),n=e.size;return e.set(t,r),this.size+=e.size==n?0:1,this}function T(t){var r=-1,e=null==t?0:t.length;for(this.clear();++r<e;){var n=t[r];this.set(n[0],n[1])}}T.prototype.clear=function(){this.size=0,this.__data__={hash:new Mt,map:new(Dt||It),string:new Mt}},T.prototype.delete=Jt,T.prototype.get=Kt,T.prototype.has=Lt,T.prototype.set=Qt;var Vt=T;function F(n,o){if("function"!=typeof n||null!=o&&"function"!=typeof o)throw new TypeError("Expected a function");function i(){var t=arguments,r=o?o.apply(this,t):t[0],e=i.cache;return e.has(r)?e.get(r):(t=n.apply(this,t),i.cache=e.set(r,t)||e,t)}return i.cache=new(F.Cache||Vt),i}F.Cache=Vt;var Wt=F;var Xt=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Yt=/\\(\\)?/g,x=function(t){var r=(t=Wt(t,function(t){return 500===r.size&&r.clear(),t})).cache;return t}(function(t){var o=[];return 46===t.charCodeAt(0)&&o.push(""),t.replace(Xt,function(t,r,e,n){o.push(e?n.replace(Yt,"$1"):r||t)}),o});var tr=function(t,r){for(var e=-1,n=null==t?0:t.length,o=Array(n);++e<n;)o[e]=r(t[e],e,t);return o},rr=j,er=E,A=O?O.prototype:void 0,nr=A?A.toString:void 0;var or=function t(r){if("string"==typeof r)return r;if(rr(r))return tr(r,t)+"";if(er(r))return nr?nr.call(r):"";var e=r+"";return"0"==e&&1/r==-1/0?"-0":e};var ir=j,ar=et,ur=x,cr=function(t){return null==t?"":or(t)};var lr=E;var fr=function(t,r){return ir(t)?t:ar(t,r)?[t]:ur(cr(t))},sr=function(t){if("string"==typeof t||lr(t))return t;var r=t+"";return"0"==r&&1/t==-1/0?"-0":r};var pr=function(t,r){for(var e=0,n=(r=fr(r,t)).length;null!=t&&e<n;)t=t[sr(r[e++])];return e&&e==n?t:void 0};var N=function(t,r,e){return void 0===(t=null==t?void 0:pr(t,r))?e:t};function R(t,r){var e=[];if(!b(r))throw new m("错误的填充数据:",r);Array.isArray(r)?e=r:e.push(r);for(var n=[],o=0;o<t.length;o++){var i=t[o];if(/^[a-zA-z_][\w\[\]"'_.]*$/.test(i)){if("undefined"===i||"NaN"===i)throw new m("key不应该为:".concat(i));for(var a=null,u=0;u<e.length;u++){var c=e[u],c=N(c,i);if(void 0!==c){a=c;break}}if(null===a)throw new m("token填充失败,请确认".concat(i,"存在"));if("string"==typeof a){if(""===a.trim())throw new m("token填充失败,".concat(i,"值不可为空字符"));if(!g(a))throw new m("token填充失败,".concat(i,"值:").concat(a,"为非法数字"))}a="string"!=typeof a?a.toString():a,n.push(a)}else n.push(i)}return n}function hr(t){for(var r,e=[],n=[],o=t;0<o.length;){var i=o.shift();if(M(i))if("("===i)e.push(i);else if(")"===i){for(var a=e.pop();"("!==a&&0<e.length;)n.push(a),a=e.pop();if("("!==a)throw"error: unmatched ()"}else{for(;r=e[e.length-1],I(i)<=I(r)&&0<e.length;)n.push(e.pop());e.push(i)}else n.push(i)}if(0<e.length){if(")"===e[e.length-1]||"("===e[e.length-1])throw"error: unmatched ()";for(;0<e.length;)n.push(e.pop())}return n}function yr(t){for(var r=[];0<t.length;){var e=t.shift();if(M(e)){if(r.length<2)throw new w("错误的栈长度, 可能是无法计算的表达式");var n=r.pop(),o=r.pop();if("string"==typeof n&&!c.default.isBigNumber(n)){if(!g(n))throw new w("".concat(n,"不是一个合法的数字"));n=new c.default(n)}if("string"==typeof o&&!c.default.isBigNumber(o)){if(!g(o))throw new w("".concat(o,"不是一个合法的数字"));o=new c.default(o)}switch(e){case"+":r.push(o.plus(n));break;case"-":r.push(o.minus(n));break;case"*":r.push(o.times(n));break;case"/":r.push(o.div(n));break;case"%":r.push(o.mod(n))}}else r.push(e)}if(1!==r.length)throw"unvalid expression";return r[0]}return t.calc=function(){for(var t=arguments.length,r=new Array(t),e=0;e<t;e++)r[e]=arguments[e];var n=D(r),o=G(n.expr),i=null;if(!0===N(n,"data._debug")&&(console.warn("======a-calc调试模式======"),console.warn(n),console.warn(o)),null!==n.data){var a=n.data,u=[];if(Array.isArray(a)?u=a:(u.push(i=a),d(c=N(i,"_fillData"))&&(Array.isArray(c)?u=[].concat(y(u),y(c)):u.push(c))),_(a._fillError,a._error))try{o=R(o,u)}catch(t){if(t instanceof m)return void 0!==i._warn&&!0===i._warn&&console.warn(t),i._fillError||i._error;throw t}else o=R(o,u)}var c=hr(o),a=null;if(b(i)&&_(i._calcError,i._error))try{a=yr(c)}catch(t){if(t instanceof w)return void 0!==i._warn&&!0===i._warn&&console.warn(t),void 0!==i._calcError?i._calcError:i._error;throw t}else a=yr(c);return a=b(n.fmt)?U(a,n.fmt):null!==a?a.toFixed():null},t.fmt=function(){for(var t=arguments.length,r=new Array(t),e=0;e<t;e++)r[e]=arguments[e];var n=D(r),o=G(n.expr),i=null;if(!0===N(n,"data._debug")&&(console.warn("======a-calc调试模式======"),console.warn(n),console.warn(o)),""===n.expr.trim()&&b(n.data)&&d(n.data._error))return n.data._error;if(2<o.length)throw new Error("fmt并非用于计算, 不能传入多个标识:".concat(n.expr));if(1!==o.length)throw new Error("fmt接收了一个无法被解析的标识");if(null!==n.data){var a=arg.data,u=[];if(Array.isArray(a)?u=a:(u.push(i=a),d(c=N(i,"_fillData"))&&(Array.isArray(c)?u=[].concat(y(u),y(c)):u.push(c))),_(a._fillError,a._error))try{o=R(o,u)}catch(t){if(t instanceof m)return void 0!==i._warn&&!0===i._warn&&console.warn(t),i._fillError||i._error;throw t}else o=R(o,u)}if(null===n.fmt)throw"表达式没有格式化部分";var c=o[0];if(g(c))return U(o[0],n.fmt);throw new m("待格式化对象: ".concat(c," 不是数字"))},t.version="0.0.60",Object.defineProperty(t,"__esModule",{value:!0}),t}({});
@@ -14,12 +14,16 @@
14
14
  // fmt("1 + 1",{_fmt:",>=4", _error:"-"})
15
15
  // );
16
16
 
17
- console.log(
18
- calc("a + b - c", [
19
- { a: 1 },
20
- { b: 2, c: 3 }
21
- ])
22
- );
17
+ // console.log(
18
+ // calc("a + b - c * 12131312 | =2,(-)", [
19
+ // { a: 1 },
20
+ // { b: 2, c: 3 }
21
+ // ])
22
+ // );
23
+
24
+ console.log(calc("1 + 2.2 + 3.3 - ..| ,=2",{_error: "-"}))
25
+
26
+
23
27
 
24
28
  </script>
25
29
  </body>
package/browser/index.js CHANGED
@@ -1 +1 @@
1
- var a_calc=function(e){"use strict";function _(e){return-1<"+-*/%()".indexOf(e)}function b(e){switch(e){case"+":case"-":return 1;case"*":case"/":case"%":return 2;default:return 0}}function l(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++)r[t]=arguments[t];return r.some(function(e){return void 0!==e})}function m(e){return"string"==typeof e&&!!/^[+-]?\d+\.?\d*$/.test(e)}function F(e){return(F="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 O(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}function E(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 N(e,r,t){return r&&E(e.prototype,r),t&&E(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function A(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(r&&r.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),r&&i(e,r)}function o(e){return(o=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function i(e,r){return(i=Object.setPrototypeOf||function(e,r){return e.__proto__=r,e})(e,r)}function S(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}function j(e,r,t){return(j=S()?Reflect.construct:function(e,r,t){var n=[null];n.push.apply(n,r);r=new(Function.bind.apply(e,n));return t&&i(r,t.prototype),r}).apply(null,arguments)}function r(e){var t="function"==typeof Map?new Map:void 0;return(r=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return j(e,arguments,o(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),i(r,e)})(e)}function x(e,r){if(r&&("object"==typeof r||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");r=e;if(void 0===r)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return r}function P(t){var n=S();return function(){var e,r=o(t);return x(this,n?(e=o(this).constructor,Reflect.construct(r,arguments,e)):r.apply(this,arguments))}}var c=function(){A(n,r(Error));var t=P(n);function n(e){var r;return O(this,n),(r=t.call(this,e)).name="CalculatorError",r.message=e,r}return N(n)}(),a=function(){A(n,r(Error));var t=P(n);function n(e){var r;return O(this,n),(r=t.call(this,e)).name="TokensFillError",r.message=e,r}return N(n)}();function R(e){var r={expr:"",fmt:null,data:null},t="",n=e[0];if(1===e.length)"string"==typeof n?t=n:"number"==typeof n?t=n.toString():Array.isArray(n)&&(t=n[0]);else if(1<e.length){n=e[e.length-1];if(o=n,("[object Object]"!==Object.prototype.toString.call(o)||Array.isArray(o))&&!Array.isArray(n))throw new Error("参数错误, 暂不支持的参数");if("string"==typeof(t=e[0])){if(""===t.trim())throw new a("参数不可为空字符串")}else if("number"==typeof t)t=t.toString();else if(void 0===t||Number.isNaN(t))throw new a("非法参数:".concat(t));r.data=n}var o=t.split("|");return 1===o.length?r.expr=o[0]:(r.expr=o[0],""!==(e=o[1]).trim()&&(r.fmt=e)),null!==r.data&&null===r.fmt&&r.data._fmt&&(r.fmt=r.data._fmt),r}var ee=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,L=Math.ceil,U=Math.floor,I="[BigNumber Error] ",re=I+"Number primitive has more than 15 significant digits: ",M=1e14,z=14,G=9007199254740991,q=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],H=1e7,V=1e9;function W(e){var r=0|e;return 0<e||e===r?r:r-1}function X(e){for(var r,t,n=1,o=e.length,i=e[0]+"";n<o;){for(r=e[n++]+"",t=z-r.length;t--;r="0"+r);i+=r}for(o=i.length;48===i.charCodeAt(--o););return i.slice(0,o+1||1)}function Y(e,r){var t,n,o=e.c,i=r.c,u=e.s,l=r.s,e=e.e,r=r.e;if(!u||!l)return null;if(t=o&&!o[0],n=i&&!i[0],t||n)return t?n?0:-l:u;if(u!=l)return u;if(t=u<0,n=e==r,!o||!i)return n?0:!o^t?1:-1;if(!n)return r<e^t?1:-1;for(l=(e=o.length)<(r=i.length)?e:r,u=0;u<l;u++)if(o[u]!=i[u])return o[u]>i[u]^t?1:-1;return e==r?0:r<e^t?1:-1}function Z(e,r,t,n){if(e<r||t<e||e!==U(e))throw Error(I+(n||"Argument")+("number"==typeof e?e<r||t<e?" out of range: ":" not an integer: ":" not a primitive number: ")+String(e))}function J(e){var r=e.c.length-1;return W(e.e/z)==r&&e.c[r]%2!=0}function K(e,r){return(1<e.length?e.charAt(0)+"."+e.slice(1):e)+(r<0?"e":"e+")+r}function Q(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 s=function $(e){var v,f,h,r,a,y,u,l,c,s,p,t=x.prototype={constructor:x,toString:null,valueOf:null},g=new x(1),w=20,_=4,d=-7,b=21,m=-1e7,O=1e7,E=!1,o=1,N=0,A={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},S="0123456789abcdefghijklmnopqrstuvwxyz",j=!0;function x(e,r){var t,n,o,i,u,l,c,a,s=this;if(!(s instanceof x))return new x(e,r);if(null==r){if(e&&!0===e._isBigNumber)return s.s=e.s,void(!e.c||e.e>O?s.c=s.e=null:e.e<m?s.c=[s.e=0]:(s.e=e.e,s.c=e.c.slice()));if((l="number"==typeof e)&&0*e==0){if(s.s=1/e<0?(e=-e,-1):1,e===~~e){for(i=0,u=e;10<=u;u/=10,i++);return void(O<i?s.c=s.e=null:(s.e=i,s.c=[e]))}a=String(e)}else{if(!ee.test(a=String(e)))return h(s,a,l);s.s=45==a.charCodeAt(0)?(a=a.slice(1),-1):1}0<(u=(a=-1<(i=a.indexOf("."))?a.replace(".",""):a).search(/e/i))?(i<0&&(i=u),i+=+a.slice(u+1),a=a.substring(0,u)):i<0&&(i=a.length)}else{if(Z(r,2,S.length,"Base"),10==r&&j)return k(s=new x(e),w+s.e+1,_);if(a=String(e),l="number"==typeof e){if(0*e!=0)return h(s,a,l,r);if(s.s=1/e<0?(a=a.slice(1),-1):1,x.DEBUG&&15<a.replace(/^0\.0*|\./,"").length)throw Error(re+e)}else s.s=45===a.charCodeAt(0)?(a=a.slice(1),-1):1;for(t=S.slice(0,r),i=u=0,c=a.length;u<c;u++)if(t.indexOf(n=a.charAt(u))<0){if("."==n){if(i<u){i=c;continue}}else if(!o&&(a==a.toUpperCase()&&(a=a.toLowerCase())||a==a.toLowerCase()&&(a=a.toUpperCase()))){o=!0,u=-1,i=0;continue}return h(s,String(e),l,r)}l=!1,-1<(i=(a=f(a,r,10,s.s)).indexOf("."))?a=a.replace(".",""):i=a.length}for(u=0;48===a.charCodeAt(u);u++);for(c=a.length;48===a.charCodeAt(--c););if(a=a.slice(u,++c)){if(c-=u,l&&x.DEBUG&&15<c&&(G<e||e!==U(e)))throw Error(re+s.s*e);if((i=i-u-1)>O)s.c=s.e=null;else if(i<m)s.c=[s.e=0];else{if(s.e=i,s.c=[],u=(i+1)%z,i<0&&(u+=z),u<c){for(u&&s.c.push(+a.slice(0,u)),c-=z;u<c;)s.c.push(+a.slice(u,u+=z));u=z-(a=a.slice(u)).length}else u-=c;for(;u--;a+="0");s.c.push(+a)}}else s.c=[s.e=0]}function P(e,r,t,n){for(var o,i,u=[0],l=0,c=e.length;l<c;){for(i=u.length;i--;u[i]*=r);for(u[0]+=n.indexOf(e.charAt(l++)),o=0;o<u.length;o++)u[o]>t-1&&(null==u[o+1]&&(u[o+1]=0),u[o+1]+=u[o]/t|0,u[o]%=t)}return u.reverse()}function R(e,r,t){var n,o,i,u=0,l=e.length,c=r%H,a=r/H|0;for(e=e.slice();l--;)u=((o=c*(i=e[l]%H)+(n=a*i+(i=e[l]/H|0)*c)%H*H+u)/t|0)+(n/H|0)+a*i,e[l]=o%t;return e=u?[u].concat(e):e}function D(e,r,t,n){var o,i;if(t!=n)i=n<t?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]&&1<e.length;e.splice(0,1));}function n(e,r,t,n){var o,i,u,l;if(null==t?t=_:Z(t,0,8),!e.c)return e.toString();if(o=e.c[0],i=e.e,null==r)l=X(e.c),l=1==n||2==n&&(i<=d||b<=i)?K(l,i):Q(l,i,"0");else if(t=(e=k(new x(e),r,t)).e,u=(l=X(e.c)).length,1==n||2==n&&(r<=t||t<=d)){for(;u<r;l+="0",u++);l=K(l,t)}else if(r-=i,l=Q(l,t,"0"),u<t+1){if(0<--r)for(l+=".";r--;l+="0");}else if(0<(r+=t-u))for(t+1==u&&(l+=".");r--;l+="0");return e.s<0&&o?"-"+l:l}function i(e,r){for(var t,n=1,o=new x(e[0]);n<e.length;n++){if(!(t=new x(e[n])).s){o=t;break}r.call(o,t)&&(o=t)}return o}function B(e,r,t){for(var n=1,o=r.length;!r[--o];r.pop());for(o=r[0];10<=o;o/=10,n++);return(t=n+t*z-1)>O?e.c=e.e=null:t<m?e.c=[e.e=0]:(e.e=t,e.c=r),e}function k(e,r,t,n){var o,i,u,l,c,a,s,f=e.c,h=q;if(f){e:{for(o=1,l=f[0];10<=l;l/=10,o++);if((i=r-o)<0)i+=z,u=r,s=(c=f[a=0])/h[o-u-1]%10|0;else if((a=L((i+1)/z))>=f.length){if(!n)break e;for(;f.length<=a;f.push(0));c=s=0,u=(i%=z)-z+(o=1)}else{for(c=l=f[a],o=1;10<=l;l/=10,o++);s=(u=(i%=z)-z+o)<0?0:c/h[o-u-1]%10|0}if(n=n||r<0||null!=f[a+1]||(u<0?c:c%h[o-u-1]),n=t<4?(s||n)&&(0==t||t==(e.s<0?3:2)):5<s||5==s&&(4==t||n||6==t&&(0<i?0<u?c/h[o-u]:0:f[a-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[(z-r%z)%z],e.e=-r||0):f[0]=e.e=0,e;if(0==i?(f.length=a,l=1,a--):(f.length=a+1,l=h[z-i],f[a]=0<u?U(c/h[o-u]%h[u])*l:0),n)for(;;){if(0==a){for(i=1,u=f[0];10<=u;u/=10,i++);for(u=f[0]+=l,l=1;10<=u;u/=10,l++);i!=l&&(e.e++,f[0]==M&&(f[0]=1));break}if(f[a]+=l,f[a]!=M)break;f[a--]=0,l=1}for(i=f.length;0===f[--i];f.pop());}e.e>O?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=X(e.c),r=t<=d||b<=t?K(r,t):Q(r,t,"0"),e.s<0?"-"+r:r)}return x.clone=$,x.ROUND_UP=0,x.ROUND_DOWN=1,x.ROUND_CEIL=2,x.ROUND_FLOOR=3,x.ROUND_HALF_UP=4,x.ROUND_HALF_DOWN=5,x.ROUND_HALF_EVEN=6,x.ROUND_HALF_CEIL=7,x.ROUND_HALF_FLOOR=8,x.EUCLID=9,x.config=x.set=function(e){var r,t;if(null!=e){if("object"!=F(e))throw Error(I+"Object expected: "+e);if(e.hasOwnProperty(r="DECIMAL_PLACES")&&(Z(t=e[r],0,V,r),w=t),e.hasOwnProperty(r="ROUNDING_MODE")&&(Z(t=e[r],0,8,r),_=t),e.hasOwnProperty(r="EXPONENTIAL_AT")&&((t=e[r])&&t.pop?(Z(t[0],-V,0,r),Z(t[1],0,V,r),d=t[0],b=t[1]):(Z(t,-V,V,r),d=-(b=t<0?-t:t))),e.hasOwnProperty(r="RANGE"))if((t=e[r])&&t.pop)Z(t[0],-V,-1,r),Z(t[1],1,V,r),m=t[0],O=t[1];else{if(Z(t,-V,V,r),!t)throw Error(I+r+" cannot be zero: "+t);m=-(O=t<0?-t:t)}if(e.hasOwnProperty(r="CRYPTO")){if((t=e[r])!==!!t)throw Error(I+r+" not true or false: "+t);if(t){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw E=!t,Error(I+"crypto unavailable");E=t}else E=t}if(e.hasOwnProperty(r="MODULO_MODE")&&(Z(t=e[r],0,9,r),o=t),e.hasOwnProperty(r="POW_PRECISION")&&(Z(t=e[r],0,V,r),N=t),e.hasOwnProperty(r="FORMAT")){if("object"!=F(t=e[r]))throw Error(I+r+" not an object: "+t);A=t}if(e.hasOwnProperty(r="ALPHABET")){if("string"!=typeof(t=e[r])||/^.?$|[+\-.\s]|(.).*\1/.test(t))throw Error(I+r+" invalid: "+t);j="0123456789"==t.slice(0,10),S=t}}return{DECIMAL_PLACES:w,ROUNDING_MODE:_,EXPONENTIAL_AT:[d,b],RANGE:[m,O],CRYPTO:E,MODULO_MODE:o,POW_PRECISION:N,FORMAT:A,ALPHABET:S}},x.isBigNumber=function(e){if(!e||!0!==e._isBigNumber)return!1;if(!x.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)&&-V<=o&&o<=V&&o===U(o))if(0===n[0]){if(0===o&&1===n.length)return!0}else if((r=(o+1)%z)<1&&(r+=z),String(n[0]).length==r){for(r=0;r<n.length;r++)if((t=n[r])<0||M<=t||t!==U(t))break e;if(0!==t)return!0}}else if(null===n&&null===o&&(null===i||1===i||-1===i))return!0;throw Error(I+"Invalid BigNumber: "+e)},x.maximum=x.max=function(){return i(arguments,t.lt)},x.minimum=x.min=function(){return i(arguments,t.gt)},x.random=(r=9007199254740992,a=Math.random()*r&2097151?function(){return U(Math.random()*r)}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)},function(e){var r,t,n,o,i,u=0,l=[],c=new x(g);if(null==e?e=w:Z(e,0,V),o=L(e/z),E)if(crypto.getRandomValues){for(r=crypto.getRandomValues(new Uint32Array(o*=2));u<o;)9e15<=(i=131072*r[u]+(r[u+1]>>>11))?(t=crypto.getRandomValues(new Uint32Array(2)),r[u]=t[0],r[u+1]=t[1]):(l.push(i%1e14),u+=2);u=o/2}else{if(!crypto.randomBytes)throw E=!1,Error(I+"crypto unavailable");for(r=crypto.randomBytes(o*=7);u<o;)9e15<=(i=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])?crypto.randomBytes(7).copy(r,u):(l.push(i%1e14),u+=7);u=o/7}if(!E)for(;u<o;)(i=a())<9e15&&(l[u++]=i%1e14);for(o=l[--u],e%=z,o&&e&&(l[u]=U(o/(i=q[z-e]))*i);0===l[u];l.pop(),u--);if(u<0)l=[n=0];else{for(n=-1;0===l[0];l.splice(0,1),n-=z);for(u=1,i=l[0];10<=i;i/=10,u++);u<z&&(n-=z-u)}return c.e=n,c.c=l,c}),x.sum=function(){for(var e=1,r=arguments,t=new x(r[0]);e<r.length;)t=t.plus(r[e++]);return t},y="0123456789",f=function(e,r,t,n,o){var i,u,l,c,a,s,f,h,p=e.indexOf("."),g=w,d=_;for(0<=p&&(c=N,N=0,e=e.replace(".",""),s=(h=new x(r)).pow(e.length-p),N=c,h.c=P(Q(X(s.c),s.e,"0"),10,t,y),h.e=h.c.length),l=c=(f=P(e,r,t,o?(i=S,y):(i=y,S))).length;0==f[--c];f.pop());if(!f[0])return i.charAt(0);if(p<0?--l:(s.c=f,s.e=l,s.s=n,f=(s=v(s,h,g,d,t)).c,a=s.r,l=s.e),p=f[u=l+g+1],c=t/2,a=a||u<0||null!=f[u+1],a=d<4?(null!=p||a)&&(0==d||d==(s.s<0?3:2)):c<p||p==c&&(4==d||a||6==d&&1&f[u-1]||d==(s.s<0?8:7)),u<1||!f[0])e=a?Q(i.charAt(1),-g,i.charAt(0)):i.charAt(0);else{if(f.length=u,a)for(--t;++f[--u]>t;)f[u]=0,u||(++l,f=[1].concat(f));for(c=f.length;!f[--c];);for(p=0,e="";p<=c;e+=i.charAt(f[p++]));e=Q(e,l,i.charAt(0))}return e},v=function(e,r,t,n,o){var i,u,l,c,a,s,f,h,p,g,d,v,y,w,_,b,m,O=e.s==r.s?1:-1,E=e.c,N=r.c;if(!(E&&E[0]&&N&&N[0]))return new x(e.s&&r.s&&(E?!N||E[0]!=N[0]:N)?E&&0==E[0]||!N?0*O:O/0:NaN);for(p=(h=new x(O)).c=[],O=t+(u=e.e-r.e)+1,o||(o=M,u=W(e.e/z)-W(r.e/z),O=O/z|0),l=0;N[l]==(E[l]||0);l++);if(N[l]>(E[l]||0)&&u--,O<0)p.push(1),c=!0;else{for(w=E.length,b=N.length,O+=2,1<(a=U(o/(N[l=0]+1)))&&(N=R(N,a,o),E=R(E,a,o),b=N.length,w=E.length),y=b,d=(g=E.slice(0,b)).length;d<b;g[d++]=0);m=N.slice(),m=[0].concat(m),_=N[0],N[1]>=o/2&&_++;do{if(a=0,(i=D(N,g,b,d))<0){if(v=g[0],b!=d&&(v=v*o+(g[1]||0)),1<(a=U(v/_)))for(f=(s=R(N,a=o<=a?o-1:a,o)).length,d=g.length;1==D(s,g,f,d);)a--,T(s,b<f?m:N,f,o),f=s.length,i=1;else 0==a&&(i=a=1),f=(s=N.slice()).length;if(T(g,s=f<d?[0].concat(s):s,d,o),d=g.length,-1==i)for(;D(N,g,b,d)<1;)a++,T(g,b<d?m:N,d,o),d=g.length}else 0===i&&(a++,g=[0])}while(p[l++]=a,g[0]?g[d++]=E[y]||0:(g=[E[y]],d=1),(y++<w||null!=g[0])&&O--);c=null!=g[0],p[0]||p.splice(0,1)}if(o==M){for(l=1,O=p[0];10<=O;O/=10,l++);k(h,t+(h.e=l+u*z-1)+1,n,c)}else h.e=u,h.r=+c;return h},u=/^(-?)0([xbo])(?=\w[\w.]*$)/i,l=/^([^.]+)\.$/,c=/^\.([^.]+)$/,s=/^-?(Infinity|NaN)$/,p=/^\s*\+(?=[\w.])|^\s+|\s+$/g,h=function(e,r,t,n){var o,i=t?r:r.replace(p,"");if(s.test(i))e.s=isNaN(i)?null:i<0?-1:1;else{if(!t&&(i=i.replace(u,function(e,r,t){return o="x"==(t=t.toLowerCase())?16:"b"==t?2:8,n&&n!=o?e:r}),n&&(o=n,i=i.replace(l,"$1").replace(c,"0.$1")),r!=i))return new x(i,o);if(x.DEBUG)throw Error(I+"Not a"+(n?" base "+n:"")+" number: "+r);e.s=null}e.c=e.e=null},t.absoluteValue=t.abs=function(){var e=new x(this);return e.s<0&&(e.s=1),e},t.comparedTo=function(e,r){return Y(this,new x(e,r))},t.decimalPlaces=t.dp=function(e,r){var t,n;if(null!=e)return Z(e,0,V),null==r?r=_:Z(r,0,8),k(new x(this),e+this.e+1,r);if(!(e=this.c))return null;if(t=((n=e.length-1)-W(this.e/z))*z,n=e[n])for(;n%10==0;n/=10,t--);return t=t<0?0:t},t.dividedBy=t.div=function(e,r){return v(this,new x(e,r),w,_)},t.dividedToIntegerBy=t.idiv=function(e,r){return v(this,new x(e,r),0,1)},t.exponentiatedBy=t.pow=function(e,r){var t,n,o,i,u,l,c,a,s=this;if((e=new x(e)).c&&!e.isInteger())throw Error(I+"Exponent not an integer: "+C(e));if(null!=r&&(r=new x(r)),u=14<e.e,!s.c||!s.c[0]||1==s.c[0]&&!s.e&&1==s.c.length||!e.c||!e.c[0])return a=new x(Math.pow(+C(s),u?2-J(e):+C(e))),r?a.mod(r):a;if(l=e.s<0,r){if(r.c?!r.c[0]:!r.s)return new x(NaN);(n=!l&&s.isInteger()&&r.isInteger())&&(s=s.mod(r))}else{if(9<e.e&&(0<s.e||s.e<-1||(0==s.e?1<s.c[0]||u&&24e7<=s.c[1]:s.c[0]<8e13||u&&s.c[0]<=9999975e7)))return i=s.s<0&&J(e)?-0:0,-1<s.e&&(i=1/i),new x(l?1/i:i);N&&(i=L(N/z+2))}for(c=u?(t=new x(.5),l&&(e.s=1),J(e)):(o=Math.abs(+C(e)))%2,a=new x(g);;){if(c){if(!(a=a.times(s)).c)break;i?a.c.length>i&&(a.c.length=i):n&&(a=a.mod(r))}if(o){if(0===(o=U(o/2)))break;c=o%2}else if(k(e=e.times(t),e.e+1,1),14<e.e)c=J(e);else{if(0==(o=+C(e)))break;c=o%2}s=s.times(s),i?s.c&&s.c.length>i&&(s.c.length=i):n&&(s=s.mod(r))}return n?a:(l&&(a=g.div(a)),r?a.mod(r):i?k(a,N,_,void 0):a)},t.integerValue=function(e){var r=new x(this);return null==e?e=_:Z(e,0,8),k(r,r.e+1,e)},t.isEqualTo=t.eq=function(e,r){return 0===Y(this,new x(e,r))},t.isFinite=function(){return!!this.c},t.isGreaterThan=t.gt=function(e,r){return 0<Y(this,new x(e,r))},t.isGreaterThanOrEqualTo=t.gte=function(e,r){return 1===(r=Y(this,new x(e,r)))||0===r},t.isInteger=function(){return!!this.c&&W(this.e/z)>this.c.length-2},t.isLessThan=t.lt=function(e,r){return Y(this,new x(e,r))<0},t.isLessThanOrEqualTo=t.lte=function(e,r){return-1===(r=Y(this,new x(e,r)))||0===r},t.isNaN=function(){return!this.s},t.isNegative=function(){return this.s<0},t.isPositive=function(){return 0<this.s},t.isZero=function(){return!!this.c&&0==this.c[0]},t.minus=function(e,r){var t,n,o,i,u=this,l=u.s;if(r=(e=new x(e,r)).s,!l||!r)return new x(NaN);if(l!=r)return e.s=-r,u.plus(e);var c=u.e/z,a=e.e/z,s=u.c,f=e.c;if(!c||!a){if(!s||!f)return s?(e.s=-r,e):new x(f?u:NaN);if(!s[0]||!f[0])return f[0]?(e.s=-r,e):new x(s[0]?u:3==_?-0:0)}if(c=W(c),a=W(a),s=s.slice(),l=c-a){for((o=(i=l<0)?(l=-l,s):(a=c,f)).reverse(),r=l;r--;o.push(0));o.reverse()}else for(n=(i=(l=s.length)<(r=f.length))?l:r,l=r=0;r<n;r++)if(s[r]!=f[r]){i=s[r]<f[r];break}if(i&&(o=s,s=f,f=o,e.s=-e.s),0<(r=(n=f.length)-(t=s.length)))for(;r--;s[t++]=0);for(r=M-1;l<n;){if(s[--n]<f[n]){for(t=n;t&&!s[--t];s[t]=r);--s[t],s[n]+=M}s[n]-=f[n]}for(;0==s[0];s.splice(0,1),--a);return s[0]?B(e,s,a):(e.s=3==_?-1:1,e.c=[e.e=0],e)},t.modulo=t.mod=function(e,r){var t,n=this;return e=new x(e,r),!n.c||!e.s||e.c&&!e.c[0]?new x(NaN):!e.c||n.c&&!n.c[0]?new x(n):(9==o?(r=e.s,e.s=1,t=v(n,e,0,3),e.s=r,t.s*=r):t=v(n,e,0,o),(e=n.minus(t.times(e))).c[0]||1!=o||(e.s=n.s),e)},t.multipliedBy=t.times=function(e,r){var t,n,o,i,u,l,c,a,s,f,h,p=this,g=p.c,d=(e=new x(e,r)).c;if(!(g&&d&&g[0]&&d[0]))return!p.s||!e.s||g&&!g[0]&&!d||d&&!d[0]&&!g?e.c=e.e=e.s=null:(e.s*=p.s,g&&d?(e.c=[0],e.e=0):e.c=e.e=null),e;for(r=W(p.e/z)+W(e.e/z),e.s*=p.s,(l=g.length)<(p=d.length)&&(h=g,g=d,d=h,n=l,l=p,p=n),n=l+p,h=[];n--;h.push(0));for(n=p;0<=--n;){for(s=d[n]%1e7,f=d[n]/1e7|(t=0),o=n+(i=l);n<o;)t=((c=s*(c=g[--i]%1e7)+(u=f*c+(a=g[i]/1e7|0)*s)%1e7*1e7+h[o]+t)/1e14|0)+(u/1e7|0)+f*a,h[o--]=c%1e14;h[o]=t}return t?++r:h.splice(0,1),B(e,h,r)},t.negated=function(){var e=new x(this);return e.s=-e.s||null,e},t.plus=function(e,r){var t,n=this,o=n.s;if(r=(e=new x(e,r)).s,!o||!r)return new x(NaN);if(o!=r)return e.s=-r,n.minus(e);var i=n.e/z,u=e.e/z,l=n.c,c=e.c;if(!i||!u){if(!l||!c)return new x(o/0);if(!l[0]||!c[0])return c[0]?e:new x(l[0]?n:0*o)}if(i=W(i),u=W(u),l=l.slice(),o=i-u){for((t=0<o?(u=i,c):(o=-o,l)).reverse();o--;t.push(0));t.reverse()}for((o=l.length)-(r=c.length)<0&&(t=c,c=l,l=t,r=o),o=0;r;)o=(l[--r]=l[r]+c[r]+o)/M|0,l[r]=M===l[r]?0:l[r]%M;return o&&(l=[o].concat(l),++u),B(e,l,u)},t.precision=t.sd=function(e,r){var t,n;if(null!=e&&e!==!!e)return Z(e,1,V),null==r?r=_:Z(r,0,8),k(new x(this),e,r);if(!(r=this.c))return null;if(t=(n=r.length-1)*z+1,n=r[n]){for(;n%10==0;n/=10,t--);for(n=r[0];10<=n;n/=10,t++);}return t=e&&this.e+1>t?this.e+1:t},t.shiftedBy=function(e){return Z(e,-G,G),this.times("1e"+e)},t.squareRoot=t.sqrt=function(){var e,r,t,n,o,i=this,u=i.c,l=i.s,c=i.e,a=w+4,s=new x("0.5");if(1!==l||!u||!u[0])return new x(!l||l<0&&(!u||u[0])?NaN:u?i:1/0);if((t=0==(l=Math.sqrt(+C(i)))||l==1/0?(((r=X(u)).length+c)%2==0&&(r+="0"),l=Math.sqrt(+r),c=W((c+1)/2)-(c<0||c%2),new x(r=l==1/0?"5e"+c:(r=l.toExponential()).slice(0,r.indexOf("e")+1)+c)):new x(l+"")).c[0])for((l=(c=t.e)+a)<3&&(l=0);;)if(o=t,t=s.times(o.plus(v(i,o,a,1))),X(o.c).slice(0,l)===(r=X(t.c)).slice(0,l)){if(t.e<c&&--l,"9999"!=(r=r.slice(l-3,l+1))&&(n||"4999"!=r)){+r&&(+r.slice(1)||"5"!=r.charAt(0))||(k(t,t.e+w+2,1),e=!t.times(t).eq(i));break}if(!n&&(k(o,o.e+w+2,0),o.times(o).eq(i))){t=o;break}a+=4,l+=4,n=1}return k(t,t.e+w+1,_,e)},t.toExponential=function(e,r){return null!=e&&(Z(e,0,V),e++),n(this,e,r,1)},t.toFixed=function(e,r){return null!=e&&(Z(e,0,V),e=e+this.e+1),n(this,e,r)},t.toFormat=function(e,r,t){if(null==t)null!=e&&r&&"object"==F(r)?(t=r,r=null):e&&"object"==F(e)?(t=e,e=r=null):t=A;else if("object"!=F(t))throw Error(I+"Argument not an object: "+t);if(e=this.toFixed(e,r),this.c){var n,r=e.split("."),o=+t.groupSize,i=+t.secondaryGroupSize,u=t.groupSeparator||"",l=r[0],r=r[1],c=this.s<0,a=c?l.slice(1):l,s=a.length;if(i&&(n=o,o=i,s-=i=n),0<o&&0<s){for(l=a.substr(0,n=s%o||o);n<s;n+=o)l+=u+a.substr(n,o);0<i&&(l+=u+a.slice(n)),c&&(l="-"+l)}e=r?l+(t.decimalSeparator||"")+((i=+t.fractionGroupSize)?r.replace(new RegExp("\\d{"+i+"}\\B","g"),"$&"+(t.fractionGroupSeparator||"")):r):l}return(t.prefix||"")+e+(t.suffix||"")},t.toFraction=function(e){var r,t,n,o,i,u,l,c,a,s,f=this,h=f.c;if(null!=e&&(!(l=new x(e)).isInteger()&&(l.c||1!==l.s)||l.lt(g)))throw Error(I+"Argument "+(l.isInteger()?"out of range: ":"not an integer: ")+C(l));if(!h)return new x(f);for(r=new x(g),a=t=new x(g),n=c=new x(g),h=X(h),i=r.e=h.length-f.e-1,r.c[0]=q[(u=i%z)<0?z+u:u],e=!e||0<l.comparedTo(r)?0<i?r:a:l,u=O,O=1/0,l=new x(h),c.c[0]=0;s=v(l,r,0,1),1!=(o=t.plus(s.times(n))).comparedTo(e);)t=n,n=o,a=c.plus(s.times(o=a)),c=o,r=l.minus(s.times(o=r)),l=o;return o=v(e.minus(t),n,0,1),c=c.plus(o.times(a)),t=t.plus(o.times(n)),c.s=a.s=f.s,h=v(a,n,i*=2,_).minus(f).abs().comparedTo(v(c,t,i,_).minus(f).abs())<1?[a,n]:[c,t],O=u,h},t.toNumber=function(){return+C(this)},t.toPrecision=function(e,r){return null!=e&&Z(e,1,V),n(this,e,r,2)},t.toString=function(e){var r,t=this,n=t.s,o=t.e;return null===o?n?(r="Infinity",n<0&&(r="-"+r)):r="NaN":(r=null==e?o<=d||b<=o?K(X(t.c),o):Q(X(t.c),o,"0"):10===e&&j?Q(X((t=k(new x(t),w+o+1,_)).c),t.e,"0"):(Z(e,2,S.length,"Base"),f(Q(X(t.c),o,"0"),10,e,n,!0)),n<0&&t.c[0]&&(r="-"+r)),r},t.valueOf=t.toJSON=function(){return C(this)},t._isBigNumber=!0,t[Symbol.toStringTag]="BigNumber",t[Symbol.for("nodejs.util.inspect.custom")]=t.valueOf,null!=e&&x.set(e),x}();function D(e,r){var t="",n=(t=s.isBigNumber(e)?e.toFixed():"string"!=typeof e?e.toString():e,null),e=null,o=null,i=r.match(/(<=|>=|=)\s*(\d+)/);if(i&&(e=i[1],n=Number(i[2])),r.includes(",")&&(o=!0),null!==n){var i=t.split("."),r=i[0],u=1===i.length?"":i[1],l=u.length;switch(e){case"<=":u=l<=n?u:u.slice(0,n);break;case"=":l<n?u+="0".repeat(n-l):n<l&&(u=u.slice(0,n));break;case">=":u=n<=l?u:u+"0".repeat(n-l)}t=""===u?r:"".concat(r,".").concat(u)}return t=null!==o?1<(i=t.split(".")).length?((e=i[0]).includes("-")?i[0]=e[0]+e.slice(1).replace(/(?=(?!^)(?:\d{3})+$)/g,","):i[0]=e.replace(/(?=(?!^)(?:\d{3})+$)/g,","),i.join(".")):(r=i[0]).includes("-")?r[0]+r.slice(1).replace(/(?=(?!^)(?:\d{3})+$)/g,","):r.replace(/(?=(?!^)(?:\d{3})+$)/g,","):t}function T(e){for(var r=[],t=0,n=null,o=e.length;t<o;)if(n=e[t],/\s/.test(n))t++;else if("+-".includes(n)){var i=r[r.length-1];if(0===r.length||"+-".includes(i)||"("===i){for(var u=n,n=e[++t];/[a-zA-Z\d._]/.test(n);)u+=n,n=e[++t];r.push(u)}else r.push(n),t++}else if("*/%()".includes(n))r.push(n),t++;else if(/[\w_.\[\]"']/.test(n)){for(var l="";/[\w_.\[\]"']/.test(n)&&(l+=n,!(++t>=o));)n=e[t];r.push(l)}else if(/\d/.test(n)){for(var c="";/[\d.]/.test(n)&&(c+=n,!(++t>=o));)n=e[t];r.push(c)}return r}var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},B=Array.isArray,t="object"==F(t)&&t&&t.Object===Object&&t,n="object"==("undefined"==typeof self?"undefined":F(self))&&self&&self.Object===Object&&self,t=t||n||Function("return this")(),n=t.Symbol,u=Object.prototype,k=u.hasOwnProperty,C=u.toString,f=n?n.toStringTag:void 0;var $=Object.prototype.toString;var te=function(e){var r=k.call(e,f),t=e[f];try{var n=!(e[f]=void 0)}catch(e){}var o=C.call(e);return n&&(r?e[f]=t:delete e[f]),o},ne=function(e){return $.call(e)},oe=n?n.toStringTag:void 0;function ie(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":(oe&&oe in Object(e)?te:ne)(e)}var ue=ie,le=function(e){return null!=e&&"object"==F(e)};function ce(e){return"symbol"==F(e)||le(e)&&"[object Symbol]"==ue(e)}var ae=B,se=ce,fe=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,he=/^\w*$/;function pe(e,r){if(ae(e))return!1;var t=F(e);return!("number"!=t&&"symbol"!=t&&"boolean"!=t&&null!=e&&!se(e))||(he.test(e)||!fe.test(e)||null!=r&&e in Object(r))}function ge(e){var r=F(e);return null!=e&&("object"==r||"function"==r)}var de=ie,ve=ge;function ye(e){return!!ve(e)&&("[object Function]"==(e=de(e))||"[object GeneratorFunction]"==e||"[object AsyncFunction]"==e||"[object Proxy]"==e)}var u=t["__core-js_shared__"],we=(u=/[^.]+$/.exec(u&&u.keys&&u.keys.IE_PROTO||""))?"Symbol(src)_1."+u:"";var _e=Function.prototype.toString;var be=ye,me=function(e){return!!we&&we in e},Oe=ge,Ee=function(e){if(null!=e){try{return _e.call(e)}catch(e){}try{return e+""}catch(e){}}return""},Ne=/^\[object .+?Constructor\]$/,u=Function.prototype,h=Object.prototype,u=u.toString,h=h.hasOwnProperty,Ae=RegExp("^"+u.call(h).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");var Se=function(e){return!(!Oe(e)||me(e))&&(be(e)?Ae:Ne).test(Ee(e))},je=function(e,r){return null==e?void 0:e[r]};function xe(e,r){return e=je(e,r),Se(e)?e:void 0}var u=xe(Object,"create"),Pe=u;var Re=u,De=Object.prototype.hasOwnProperty;var Te=u,Be=Object.prototype.hasOwnProperty;var ke=u;function Ce(e){return e=this.has(e)&&delete this.__data__[e],this.size-=e?1:0,e}function $e(e){var r,t=this.__data__;return Re?"__lodash_hash_undefined__"===(r=t[e])?void 0:r:De.call(t,e)?t[e]:void 0}function Fe(e){var r=this.__data__;return Te?void 0!==r[e]:Be.call(r,e)}function Le(e,r){var t=this.__data__;return this.size+=this.has(e)?0:1,t[e]=ke&&void 0===r?"__lodash_hash_undefined__":r,this}function p(e){var r=-1,t=null==e?0:e.length;for(this.clear();++r<t;){var n=e[r];this.set(n[0],n[1])}}p.prototype.clear=function(){this.__data__=Pe?Pe(null):{},this.size=0},p.prototype.delete=Ce,p.prototype.get=$e,p.prototype.has=Fe,p.prototype.set=Le;h=p;var Ue=function(e,r){return e===r||e!=e&&r!=r};function g(e,r){for(var t=e.length;t--;)if(Ue(e[t][0],r))return t;return-1}var Ie=g,Me=Array.prototype.splice;var ze=g;var Ge=g;var qe=g;function He(e){var r=this.__data__;return!((e=Ie(r,e))<0)&&(e==r.length-1?r.pop():Me.call(r,e,1),--this.size,!0)}function Ve(e){var r=this.__data__;return(e=ze(r,e))<0?void 0:r[e][1]}function We(e){return-1<Ge(this.__data__,e)}function Xe(e,r){var t=this.__data__,n=qe(t,e);return n<0?(++this.size,t.push([e,r])):t[n][1]=r,this}function d(e){var r=-1,t=null==e?0:e.length;for(this.clear();++r<t;){var n=e[r];this.set(n[0],n[1])}}d.prototype.clear=function(){this.__data__=[],this.size=0},d.prototype.delete=He,d.prototype.get=Ve,d.prototype.has=We,d.prototype.set=Xe;var u=d,t=xe(t,"Map"),Ye=h,Ze=u,Je=t;var Ke=function(e){var r=F(e);return"string"==r||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==e:null===e};function v(e,r){return e=e.__data__,Ke(r)?e["string"==typeof r?"string":"hash"]:e.map}var Qe=v;var er=v;var rr=v;var tr=v;function nr(e){return e=Qe(this,e).delete(e),this.size-=e?1:0,e}function or(e){return er(this,e).get(e)}function ir(e){return rr(this,e).has(e)}function ur(e,r){var t=tr(this,e),n=t.size;return t.set(e,r),this.size+=t.size==n?0:1,this}function y(e){var r=-1,t=null==e?0:e.length;for(this.clear();++r<t;){var n=e[r];this.set(n[0],n[1])}}y.prototype.clear=function(){this.size=0,this.__data__={hash:new Ye,map:new(Je||Ze),string:new Ye}},y.prototype.delete=nr,y.prototype.get=or,y.prototype.has=ir,y.prototype.set=ur;var lr=y;function cr(n,o){if("function"!=typeof n||null!=o&&"function"!=typeof o)throw new TypeError("Expected a function");function i(){var e=arguments,r=o?o.apply(this,e):e[0],t=i.cache;return t.has(r)?t.get(r):(e=n.apply(this,e),i.cache=t.set(r,e)||t,e)}return i.cache=new(cr.Cache||lr),i}cr.Cache=lr;var ar=cr;var sr=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,fr=/\\(\\)?/g,h=function(e){var r=(e=ar(e,function(e){return 500===r.size&&r.clear(),e})).cache;return e}(function(e){var o=[];return 46===e.charCodeAt(0)&&o.push(""),e.replace(sr,function(e,r,t,n){o.push(t?n.replace(fr,"$1"):r||e)}),o});var hr=function(e,r){for(var t=-1,n=null==e?0:e.length,o=Array(n);++t<n;)o[t]=r(e[t],t,e);return o},pr=B,gr=ce,u=n?n.prototype:void 0,dr=u?u.toString:void 0;var vr=function e(r){if("string"==typeof r)return r;if(pr(r))return hr(r,e)+"";if(gr(r))return dr?dr.call(r):"";var t=r+"";return"0"==t&&1/r==-1/0?"-0":t};var yr=B,wr=pe,_r=h,br=function(e){return null==e?"":vr(e)};var mr=ce;var Or=function(e,r){return yr(e)?e:wr(e,r)?[e]:_r(br(e))},Er=function(e){if("string"==typeof e||mr(e))return e;var r=e+"";return"0"==r&&1/e==-1/0?"-0":r};var Nr=function(e,r){for(var t=0,n=(r=Or(r,e)).length;null!=e&&t<n;)e=e[Er(r[t++])];return t&&t==n?e:void 0};var Ar=function(e,r,t){return void 0===(e=null==e?void 0:Nr(e,r))?t:e};function w(e,r){for(var t=r._fillData,n=(void 0===r._fillData&&(t=r),Array.isArray(t)||(t=[t]),[]),o=0;o<e.length;o++){var i=e[o];if(/^[a-zA-z_][\w\[\]"'_.]*$/.test(i)){if("undefined"===i||"NaN"===i)throw new a("key不应该为:".concat(i));for(var u=null,l=0;l<t.length;l++){var c=t[l],c=Ar(c,i);if(void 0!==c){u=c;break}}if(null===u)throw new a("token填充失败,请确认".concat(i,"存在"));if("string"==typeof u){if(""===u.trim())throw new a("token填充失败,".concat(i,"值不可为空字符"));if(!m(u))throw new a("token填充失败,".concat(i,"值:").concat(u,"为非法数字"))}u="string"!=typeof u?u.toString():u,n.push(u)}else n.push(i)}return n}function Sr(e){for(var r,t=[],n=[],o=e;0<o.length;){var i=o.shift();if(_(i))if("("===i)t.push(i);else if(")"===i){for(var u=t.pop();"("!==u&&0<t.length;)n.push(u),u=t.pop();if("("!==u)throw"error: unmatched ()"}else{for(;r=t[t.length-1],b(i)<=b(r)&&0<t.length;)n.push(t.pop());t.push(i)}else n.push(i)}if(0<t.length){if(")"===t[t.length-1]||"("===t[t.length-1])throw"error: unmatched ()";for(;0<t.length;)n.push(t.pop())}return n}function jr(e){for(var r=[];0<e.length;){var t=e.shift();if(_(t)){if(r.length<2)throw new c("错误的栈长度, 可能是无法计算的表达式");var n=r.pop(),o=r.pop();if("string"==typeof n&&!s.isBigNumber(n)){if(!/^[+-]*[\d.]+$/.test(n))throw new c("".concat(n,"不是一个合法的数字"));n=new s(n)}if("string"==typeof o&&!s.isBigNumber(o)){if(!/^[+-]*[\d.]+$/.test(o))throw new c("".concat(o,"不是一个合法的数字"));o=new s(o)}switch(t){case"+":r.push(o.plus(n));break;case"-":r.push(o.minus(n));break;case"*":r.push(o.times(n));break;case"/":r.push(o.div(n));break;case"%":r.push(o.mod(n))}}else r.push(t)}if(1!==r.length)throw"unvalid expression";return r[0]}return e.calc=function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++)r[t]=arguments[t];var n=R(r),o=T(n.expr),i=null;if(!0===Ar(n,"data._debug")&&(console.warn("======a-calc调试模式======"),console.warn(n),console.warn(o)),null!==n.data){var u=n.data;if(null!==(i=!Array.isArray(u)&&l(u._fillData,u._error,u._fillError,u._calcError)?u:i)&&void 0!==u._fillData&&l(i._fillError,i._error))try{o=w(o,u._fillData)}catch(e){if(e instanceof a)return void 0!==i._warn&&!0===i._warn&&console.warn(e),i._fillError||i._error;throw e}else o=w(o,u)}if(u=Sr(o),(o=null)===i||void 0===i._calcError&&void 0===i._error)o=jr(u);else try{o=jr(u)}catch(e){if(e instanceof c)return void 0!==i._warn&&!0===i._warn&&console.warn(e),void 0!==i._calcError?i._calcError:i._error;throw e}return o=null!==n.fmt?D(o,n.fmt):null!==o?o.toFixed():null},e.fmt=function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++)r[t]=arguments[t];var n=R(r),o=T(n.expr),i=null;if(!0===Ar(n,"data._debug")&&(console.warn("======a-calc调试模式======"),console.warn(n),console.warn(o)),""===n.expr.trim()&&null!==n.data&&void 0!==n.data._error)return n.data._error;if(2<o.length)throw new Error("fmt并非用于计算, 不能传入多个标识:".concat(n.expr));if(1!==o.length)throw new Error("fmt接收了一个无法被解析的标识");if(null!==n.data){var u=n.data;if(null!==(i=!Array.isArray(u)&&l(u._fillData,u._error,u._fillError)?u:i)&&void 0!==u._fillData&&l(i._fillError,i._error))try{o=w(o,u._fillData)}catch(e){if(e instanceof a)return void 0!==i._warn&&!0===i._warn&&console.warn(e),i._fillError||i._error;throw e}else o=w(o,u)}if(null===n.fmt)throw"表达式没有格式化部分";if(m(i=o[0]))return D(o[0],n.fmt);throw new a("待格式化对象: ".concat(i," 不是数字"))},e.version="0.0.58",Object.defineProperty(e,"__esModule",{value:!0}),e}({});
1
+ var a_calc=function(e){"use strict";function U(e){return(U="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 O(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}function A(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 E(e,r,t){return r&&A(e.prototype,r),t&&A(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function N(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(r&&r.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),r&&i(e,r)}function o(e){return(o=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function i(e,r){return(i=Object.setPrototypeOf||function(e,r){return e.__proto__=r,e})(e,r)}function S(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}function j(e,r,t){return(j=S()?Reflect.construct:function(e,r,t){var n=[null];n.push.apply(n,r);r=new(Function.bind.apply(e,n));return t&&i(r,t.prototype),r}).apply(null,arguments)}function r(e){var t="function"==typeof Map?new Map:void 0;return(r=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return j(e,arguments,o(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),i(r,e)})(e)}function x(e,r){if(r&&("object"==typeof r||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");r=e;if(void 0===r)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return r}function P(t){var n=S();return function(){var e,r=o(t);return x(this,n?(e=o(this).constructor,Reflect.construct(r,arguments,e)):r.apply(this,arguments))}}function l(e){return function(e){if(Array.isArray(e))return R(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,r){if(e){if("string"==typeof e)return R(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);return"Map"===(t="Object"===t&&e.constructor?e.constructor.name:t)||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?R(e,r):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 R(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}function T(e){return-1<"+-*/%()".indexOf(e)}function B(e){switch(e){case"+":case"-":return 1;case"*":case"/":case"%":return 2;default:return 0}}function D(e){return void 0!==e}function k(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++)r[t]=arguments[t];return r.some(function(e){return void 0!==e})}function s(e){return null!==e}function f(e){return"string"==typeof e&&!!/^[+-]?\d+\.?\d*$/.test(e)}var h=function(){N(n,r(Error));var t=P(n);function n(e){var r;return O(this,n),(r=t.call(this,e)).name="CalculatorError",r.message=e,r}return E(n)}(),p=function(){N(n,r(Error));var t=P(n);function n(e){var r;return O(this,n),(r=t.call(this,e)).name="TokensFillError",r.message=e,r}return E(n)}();function C(e){var r={expr:"",fmt:null,data:null},t="",n=e[0];if(1===e.length)"string"==typeof n?t=n:"number"==typeof n?t=n.toString():Array.isArray(n)&&(t=n[0]);else if(1<e.length){n=e[e.length-1];if(o=n,("[object Object]"!==Object.prototype.toString.call(o)||Array.isArray(o))&&!Array.isArray(n))throw new Error("参数错误, 暂不支持的参数");if("string"==typeof(t=e[0])){if(""===t.trim())throw new p("参数不可为空字符串")}else if("number"==typeof t)t=t.toString();else if(void 0===t||Number.isNaN(t))throw new p("非法参数:".concat(t));r.data=n}var o=t.split("|");return 1===o.length?r.expr=o[0]:(r.expr=o[0],""!==(e=o[1]).trim()&&(r.fmt=e)),null!==r.data&&null===r.fmt&&r.data._fmt&&(r.fmt=r.data._fmt),r}var J=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,K=Math.ceil,$=Math.floor,F="[BigNumber Error] ",Q=F+"Number primitive has more than 15 significant digits: ",L=1e14,M=14,ee=9007199254740991,re=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],z=1e7,G=1e9;function q(e){var r=0|e;return 0<e||e===r?r:r-1}function H(e){for(var r,t,n=1,o=e.length,i=e[0]+"";n<o;){for(r=e[n++]+"",t=M-r.length;t--;r="0"+r);i+=r}for(o=i.length;48===i.charCodeAt(--o););return i.slice(0,o+1||1)}function V(e,r){var t,n,o=e.c,i=r.c,u=e.s,c=r.s,e=e.e,r=r.e;if(!u||!c)return null;if(t=o&&!o[0],n=i&&!i[0],t||n)return t?n?0:-c:u;if(u!=c)return u;if(t=u<0,n=e==r,!o||!i)return n?0:!o^t?1:-1;if(!n)return r<e^t?1:-1;for(c=(e=o.length)<(r=i.length)?e:r,u=0;u<c;u++)if(o[u]!=i[u])return o[u]>i[u]^t?1:-1;return e==r?0:r<e^t?1:-1}function W(e,r,t,n){if(e<r||t<e||e!==$(e))throw Error(F+(n||"Argument")+("number"==typeof e?e<r||t<e?" out of range: ":" not an integer: ":" not a primitive number: ")+String(e))}function X(e){var r=e.c.length-1;return q(e.e/M)==r&&e.c[r]%2!=0}function Y(e,r){return(1<e.length?e.charAt(0)+"."+e.slice(1):e)+(r<0?"e":"e+")+r}function Z(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 a=function I(e){var v,f,h,r,l,y,u,c,a,s,p,t=x.prototype={constructor:x,toString:null,valueOf:null},g=new x(1),w=20,b=4,d=-7,m=21,_=-1e7,O=1e7,A=!1,o=1,E=0,N={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},S="0123456789abcdefghijklmnopqrstuvwxyz",j=!0;function x(e,r){var t,n,o,i,u,c,a,l,s=this;if(!(s instanceof x))return new x(e,r);if(null==r){if(e&&!0===e._isBigNumber)return s.s=e.s,void(!e.c||e.e>O?s.c=s.e=null:e.e<_?s.c=[s.e=0]:(s.e=e.e,s.c=e.c.slice()));if((c="number"==typeof e)&&0*e==0){if(s.s=1/e<0?(e=-e,-1):1,e===~~e){for(i=0,u=e;10<=u;u/=10,i++);return void(O<i?s.c=s.e=null:(s.e=i,s.c=[e]))}l=String(e)}else{if(!J.test(l=String(e)))return h(s,l,c);s.s=45==l.charCodeAt(0)?(l=l.slice(1),-1):1}0<(u=(l=-1<(i=l.indexOf("."))?l.replace(".",""):l).search(/e/i))?(i<0&&(i=u),i+=+l.slice(u+1),l=l.substring(0,u)):i<0&&(i=l.length)}else{if(W(r,2,S.length,"Base"),10==r&&j)return k(s=new x(e),w+s.e+1,b);if(l=String(e),c="number"==typeof e){if(0*e!=0)return h(s,l,c,r);if(s.s=1/e<0?(l=l.slice(1),-1):1,x.DEBUG&&15<l.replace(/^0\.0*|\./,"").length)throw Error(Q+e)}else s.s=45===l.charCodeAt(0)?(l=l.slice(1),-1):1;for(t=S.slice(0,r),i=u=0,a=l.length;u<a;u++)if(t.indexOf(n=l.charAt(u))<0){if("."==n){if(i<u){i=a;continue}}else if(!o&&(l==l.toUpperCase()&&(l=l.toLowerCase())||l==l.toLowerCase()&&(l=l.toUpperCase()))){o=!0,u=-1,i=0;continue}return h(s,String(e),c,r)}c=!1,-1<(i=(l=f(l,r,10,s.s)).indexOf("."))?l=l.replace(".",""):i=l.length}for(u=0;48===l.charCodeAt(u);u++);for(a=l.length;48===l.charCodeAt(--a););if(l=l.slice(u,++a)){if(a-=u,c&&x.DEBUG&&15<a&&(ee<e||e!==$(e)))throw Error(Q+s.s*e);if((i=i-u-1)>O)s.c=s.e=null;else if(i<_)s.c=[s.e=0];else{if(s.e=i,s.c=[],u=(i+1)%M,i<0&&(u+=M),u<a){for(u&&s.c.push(+l.slice(0,u)),a-=M;u<a;)s.c.push(+l.slice(u,u+=M));u=M-(l=l.slice(u)).length}else u-=a;for(;u--;l+="0");s.c.push(+l)}}else s.c=[s.e=0]}function P(e,r,t,n){for(var o,i,u=[0],c=0,a=e.length;c<a;){for(i=u.length;i--;u[i]*=r);for(u[0]+=n.indexOf(e.charAt(c++)),o=0;o<u.length;o++)u[o]>t-1&&(null==u[o+1]&&(u[o+1]=0),u[o+1]+=u[o]/t|0,u[o]%=t)}return u.reverse()}function R(e,r,t){var n,o,i,u=0,c=e.length,a=r%z,l=r/z|0;for(e=e.slice();c--;)u=((o=a*(i=e[c]%z)+(n=l*i+(i=e[c]/z|0)*a)%z*z+u)/t|0)+(n/z|0)+l*i,e[c]=o%t;return e=u?[u].concat(e):e}function T(e,r,t,n){var o,i;if(t!=n)i=n<t?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 B(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]&&1<e.length;e.splice(0,1));}function n(e,r,t,n){var o,i,u,c;if(null==t?t=b:W(t,0,8),!e.c)return e.toString();if(o=e.c[0],i=e.e,null==r)c=H(e.c),c=1==n||2==n&&(i<=d||m<=i)?Y(c,i):Z(c,i,"0");else if(t=(e=k(new x(e),r,t)).e,u=(c=H(e.c)).length,1==n||2==n&&(r<=t||t<=d)){for(;u<r;c+="0",u++);c=Y(c,t)}else if(r-=i,c=Z(c,t,"0"),u<t+1){if(0<--r)for(c+=".";r--;c+="0");}else if(0<(r+=t-u))for(t+1==u&&(c+=".");r--;c+="0");return e.s<0&&o?"-"+c:c}function i(e,r){for(var t,n=1,o=new x(e[0]);n<e.length;n++){if(!(t=new x(e[n])).s){o=t;break}r.call(o,t)&&(o=t)}return o}function D(e,r,t){for(var n=1,o=r.length;!r[--o];r.pop());for(o=r[0];10<=o;o/=10,n++);return(t=n+t*M-1)>O?e.c=e.e=null:t<_?e.c=[e.e=0]:(e.e=t,e.c=r),e}function k(e,r,t,n){var o,i,u,c,a,l,s,f=e.c,h=re;if(f){e:{for(o=1,c=f[0];10<=c;c/=10,o++);if((i=r-o)<0)i+=M,u=r,s=(a=f[l=0])/h[o-u-1]%10|0;else if((l=K((i+1)/M))>=f.length){if(!n)break e;for(;f.length<=l;f.push(0));a=s=0,u=(i%=M)-M+(o=1)}else{for(a=c=f[l],o=1;10<=c;c/=10,o++);s=(u=(i%=M)-M+o)<0?0:a/h[o-u-1]%10|0}if(n=n||r<0||null!=f[l+1]||(u<0?a:a%h[o-u-1]),n=t<4?(s||n)&&(0==t||t==(e.s<0?3:2)):5<s||5==s&&(4==t||n||6==t&&(0<i?0<u?a/h[o-u]:0:f[l-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[(M-r%M)%M],e.e=-r||0):f[0]=e.e=0,e;if(0==i?(f.length=l,c=1,l--):(f.length=l+1,c=h[M-i],f[l]=0<u?$(a/h[o-u]%h[u])*c:0),n)for(;;){if(0==l){for(i=1,u=f[0];10<=u;u/=10,i++);for(u=f[0]+=c,c=1;10<=u;u/=10,c++);i!=c&&(e.e++,f[0]==L&&(f[0]=1));break}if(f[l]+=c,f[l]!=L)break;f[l--]=0,c=1}for(i=f.length;0===f[--i];f.pop());}e.e>O?e.c=e.e=null:e.e<_&&(e.c=[e.e=0])}return e}function C(e){var r,t=e.e;return null===t?e.toString():(r=H(e.c),r=t<=d||m<=t?Y(r,t):Z(r,t,"0"),e.s<0?"-"+r:r)}return x.clone=I,x.ROUND_UP=0,x.ROUND_DOWN=1,x.ROUND_CEIL=2,x.ROUND_FLOOR=3,x.ROUND_HALF_UP=4,x.ROUND_HALF_DOWN=5,x.ROUND_HALF_EVEN=6,x.ROUND_HALF_CEIL=7,x.ROUND_HALF_FLOOR=8,x.EUCLID=9,x.config=x.set=function(e){var r,t;if(null!=e){if("object"!=U(e))throw Error(F+"Object expected: "+e);if(e.hasOwnProperty(r="DECIMAL_PLACES")&&(W(t=e[r],0,G,r),w=t),e.hasOwnProperty(r="ROUNDING_MODE")&&(W(t=e[r],0,8,r),b=t),e.hasOwnProperty(r="EXPONENTIAL_AT")&&((t=e[r])&&t.pop?(W(t[0],-G,0,r),W(t[1],0,G,r),d=t[0],m=t[1]):(W(t,-G,G,r),d=-(m=t<0?-t:t))),e.hasOwnProperty(r="RANGE"))if((t=e[r])&&t.pop)W(t[0],-G,-1,r),W(t[1],1,G,r),_=t[0],O=t[1];else{if(W(t,-G,G,r),!t)throw Error(F+r+" cannot be zero: "+t);_=-(O=t<0?-t:t)}if(e.hasOwnProperty(r="CRYPTO")){if((t=e[r])!==!!t)throw Error(F+r+" not true or false: "+t);if(t){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw A=!t,Error(F+"crypto unavailable");A=t}else A=t}if(e.hasOwnProperty(r="MODULO_MODE")&&(W(t=e[r],0,9,r),o=t),e.hasOwnProperty(r="POW_PRECISION")&&(W(t=e[r],0,G,r),E=t),e.hasOwnProperty(r="FORMAT")){if("object"!=U(t=e[r]))throw Error(F+r+" not an object: "+t);N=t}if(e.hasOwnProperty(r="ALPHABET")){if("string"!=typeof(t=e[r])||/^.?$|[+\-.\s]|(.).*\1/.test(t))throw Error(F+r+" invalid: "+t);j="0123456789"==t.slice(0,10),S=t}}return{DECIMAL_PLACES:w,ROUNDING_MODE:b,EXPONENTIAL_AT:[d,m],RANGE:[_,O],CRYPTO:A,MODULO_MODE:o,POW_PRECISION:E,FORMAT:N,ALPHABET:S}},x.isBigNumber=function(e){if(!e||!0!==e._isBigNumber)return!1;if(!x.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)&&-G<=o&&o<=G&&o===$(o))if(0===n[0]){if(0===o&&1===n.length)return!0}else if((r=(o+1)%M)<1&&(r+=M),String(n[0]).length==r){for(r=0;r<n.length;r++)if((t=n[r])<0||L<=t||t!==$(t))break e;if(0!==t)return!0}}else if(null===n&&null===o&&(null===i||1===i||-1===i))return!0;throw Error(F+"Invalid BigNumber: "+e)},x.maximum=x.max=function(){return i(arguments,t.lt)},x.minimum=x.min=function(){return i(arguments,t.gt)},x.random=(r=9007199254740992,l=Math.random()*r&2097151?function(){return $(Math.random()*r)}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)},function(e){var r,t,n,o,i,u=0,c=[],a=new x(g);if(null==e?e=w:W(e,0,G),o=K(e/M),A)if(crypto.getRandomValues){for(r=crypto.getRandomValues(new Uint32Array(o*=2));u<o;)9e15<=(i=131072*r[u]+(r[u+1]>>>11))?(t=crypto.getRandomValues(new Uint32Array(2)),r[u]=t[0],r[u+1]=t[1]):(c.push(i%1e14),u+=2);u=o/2}else{if(!crypto.randomBytes)throw A=!1,Error(F+"crypto unavailable");for(r=crypto.randomBytes(o*=7);u<o;)9e15<=(i=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])?crypto.randomBytes(7).copy(r,u):(c.push(i%1e14),u+=7);u=o/7}if(!A)for(;u<o;)(i=l())<9e15&&(c[u++]=i%1e14);for(o=c[--u],e%=M,o&&e&&(c[u]=$(o/(i=re[M-e]))*i);0===c[u];c.pop(),u--);if(u<0)c=[n=0];else{for(n=-1;0===c[0];c.splice(0,1),n-=M);for(u=1,i=c[0];10<=i;i/=10,u++);u<M&&(n-=M-u)}return a.e=n,a.c=c,a}),x.sum=function(){for(var e=1,r=arguments,t=new x(r[0]);e<r.length;)t=t.plus(r[e++]);return t},y="0123456789",f=function(e,r,t,n,o){var i,u,c,a,l,s,f,h,p=e.indexOf("."),g=w,d=b;for(0<=p&&(a=E,E=0,e=e.replace(".",""),s=(h=new x(r)).pow(e.length-p),E=a,h.c=P(Z(H(s.c),s.e,"0"),10,t,y),h.e=h.c.length),c=a=(f=P(e,r,t,o?(i=S,y):(i=y,S))).length;0==f[--a];f.pop());if(!f[0])return i.charAt(0);if(p<0?--c:(s.c=f,s.e=c,s.s=n,f=(s=v(s,h,g,d,t)).c,l=s.r,c=s.e),p=f[u=c+g+1],a=t/2,l=l||u<0||null!=f[u+1],l=d<4?(null!=p||l)&&(0==d||d==(s.s<0?3:2)):a<p||p==a&&(4==d||l||6==d&&1&f[u-1]||d==(s.s<0?8:7)),u<1||!f[0])e=l?Z(i.charAt(1),-g,i.charAt(0)):i.charAt(0);else{if(f.length=u,l)for(--t;++f[--u]>t;)f[u]=0,u||(++c,f=[1].concat(f));for(a=f.length;!f[--a];);for(p=0,e="";p<=a;e+=i.charAt(f[p++]));e=Z(e,c,i.charAt(0))}return e},v=function(e,r,t,n,o){var i,u,c,a,l,s,f,h,p,g,d,v,y,w,b,m,_,O=e.s==r.s?1:-1,A=e.c,E=r.c;if(!(A&&A[0]&&E&&E[0]))return new x(e.s&&r.s&&(A?!E||A[0]!=E[0]:E)?A&&0==A[0]||!E?0*O:O/0:NaN);for(p=(h=new x(O)).c=[],O=t+(u=e.e-r.e)+1,o||(o=L,u=q(e.e/M)-q(r.e/M),O=O/M|0),c=0;E[c]==(A[c]||0);c++);if(E[c]>(A[c]||0)&&u--,O<0)p.push(1),a=!0;else{for(w=A.length,m=E.length,O+=2,1<(l=$(o/(E[c=0]+1)))&&(E=R(E,l,o),A=R(A,l,o),m=E.length,w=A.length),y=m,d=(g=A.slice(0,m)).length;d<m;g[d++]=0);_=E.slice(),_=[0].concat(_),b=E[0],E[1]>=o/2&&b++;do{if(l=0,(i=T(E,g,m,d))<0){if(v=g[0],m!=d&&(v=v*o+(g[1]||0)),1<(l=$(v/b)))for(f=(s=R(E,l=o<=l?o-1:l,o)).length,d=g.length;1==T(s,g,f,d);)l--,B(s,m<f?_:E,f,o),f=s.length,i=1;else 0==l&&(i=l=1),f=(s=E.slice()).length;if(B(g,s=f<d?[0].concat(s):s,d,o),d=g.length,-1==i)for(;T(E,g,m,d)<1;)l++,B(g,m<d?_:E,d,o),d=g.length}else 0===i&&(l++,g=[0])}while(p[c++]=l,g[0]?g[d++]=A[y]||0:(g=[A[y]],d=1),(y++<w||null!=g[0])&&O--);a=null!=g[0],p[0]||p.splice(0,1)}if(o==L){for(c=1,O=p[0];10<=O;O/=10,c++);k(h,t+(h.e=c+u*M-1)+1,n,a)}else h.e=u,h.r=+a;return h},u=/^(-?)0([xbo])(?=\w[\w.]*$)/i,c=/^([^.]+)\.$/,a=/^\.([^.]+)$/,s=/^-?(Infinity|NaN)$/,p=/^\s*\+(?=[\w.])|^\s+|\s+$/g,h=function(e,r,t,n){var o,i=t?r:r.replace(p,"");if(s.test(i))e.s=isNaN(i)?null:i<0?-1:1;else{if(!t&&(i=i.replace(u,function(e,r,t){return o="x"==(t=t.toLowerCase())?16:"b"==t?2:8,n&&n!=o?e:r}),n&&(o=n,i=i.replace(c,"$1").replace(a,"0.$1")),r!=i))return new x(i,o);if(x.DEBUG)throw Error(F+"Not a"+(n?" base "+n:"")+" number: "+r);e.s=null}e.c=e.e=null},t.absoluteValue=t.abs=function(){var e=new x(this);return e.s<0&&(e.s=1),e},t.comparedTo=function(e,r){return V(this,new x(e,r))},t.decimalPlaces=t.dp=function(e,r){var t,n;if(null!=e)return W(e,0,G),null==r?r=b:W(r,0,8),k(new x(this),e+this.e+1,r);if(!(e=this.c))return null;if(t=((n=e.length-1)-q(this.e/M))*M,n=e[n])for(;n%10==0;n/=10,t--);return t=t<0?0:t},t.dividedBy=t.div=function(e,r){return v(this,new x(e,r),w,b)},t.dividedToIntegerBy=t.idiv=function(e,r){return v(this,new x(e,r),0,1)},t.exponentiatedBy=t.pow=function(e,r){var t,n,o,i,u,c,a,l,s=this;if((e=new x(e)).c&&!e.isInteger())throw Error(F+"Exponent not an integer: "+C(e));if(null!=r&&(r=new x(r)),u=14<e.e,!s.c||!s.c[0]||1==s.c[0]&&!s.e&&1==s.c.length||!e.c||!e.c[0])return l=new x(Math.pow(+C(s),u?2-X(e):+C(e))),r?l.mod(r):l;if(c=e.s<0,r){if(r.c?!r.c[0]:!r.s)return new x(NaN);(n=!c&&s.isInteger()&&r.isInteger())&&(s=s.mod(r))}else{if(9<e.e&&(0<s.e||s.e<-1||(0==s.e?1<s.c[0]||u&&24e7<=s.c[1]:s.c[0]<8e13||u&&s.c[0]<=9999975e7)))return i=s.s<0&&X(e)?-0:0,-1<s.e&&(i=1/i),new x(c?1/i:i);E&&(i=K(E/M+2))}for(a=u?(t=new x(.5),c&&(e.s=1),X(e)):(o=Math.abs(+C(e)))%2,l=new x(g);;){if(a){if(!(l=l.times(s)).c)break;i?l.c.length>i&&(l.c.length=i):n&&(l=l.mod(r))}if(o){if(0===(o=$(o/2)))break;a=o%2}else if(k(e=e.times(t),e.e+1,1),14<e.e)a=X(e);else{if(0==(o=+C(e)))break;a=o%2}s=s.times(s),i?s.c&&s.c.length>i&&(s.c.length=i):n&&(s=s.mod(r))}return n?l:(c&&(l=g.div(l)),r?l.mod(r):i?k(l,E,b,void 0):l)},t.integerValue=function(e){var r=new x(this);return null==e?e=b:W(e,0,8),k(r,r.e+1,e)},t.isEqualTo=t.eq=function(e,r){return 0===V(this,new x(e,r))},t.isFinite=function(){return!!this.c},t.isGreaterThan=t.gt=function(e,r){return 0<V(this,new x(e,r))},t.isGreaterThanOrEqualTo=t.gte=function(e,r){return 1===(r=V(this,new x(e,r)))||0===r},t.isInteger=function(){return!!this.c&&q(this.e/M)>this.c.length-2},t.isLessThan=t.lt=function(e,r){return V(this,new x(e,r))<0},t.isLessThanOrEqualTo=t.lte=function(e,r){return-1===(r=V(this,new x(e,r)))||0===r},t.isNaN=function(){return!this.s},t.isNegative=function(){return this.s<0},t.isPositive=function(){return 0<this.s},t.isZero=function(){return!!this.c&&0==this.c[0]},t.minus=function(e,r){var t,n,o,i,u=this,c=u.s;if(r=(e=new x(e,r)).s,!c||!r)return new x(NaN);if(c!=r)return e.s=-r,u.plus(e);var a=u.e/M,l=e.e/M,s=u.c,f=e.c;if(!a||!l){if(!s||!f)return s?(e.s=-r,e):new x(f?u:NaN);if(!s[0]||!f[0])return f[0]?(e.s=-r,e):new x(s[0]?u:3==b?-0:0)}if(a=q(a),l=q(l),s=s.slice(),c=a-l){for((o=(i=c<0)?(c=-c,s):(l=a,f)).reverse(),r=c;r--;o.push(0));o.reverse()}else for(n=(i=(c=s.length)<(r=f.length))?c:r,c=r=0;r<n;r++)if(s[r]!=f[r]){i=s[r]<f[r];break}if(i&&(o=s,s=f,f=o,e.s=-e.s),0<(r=(n=f.length)-(t=s.length)))for(;r--;s[t++]=0);for(r=L-1;c<n;){if(s[--n]<f[n]){for(t=n;t&&!s[--t];s[t]=r);--s[t],s[n]+=L}s[n]-=f[n]}for(;0==s[0];s.splice(0,1),--l);return s[0]?D(e,s,l):(e.s=3==b?-1:1,e.c=[e.e=0],e)},t.modulo=t.mod=function(e,r){var t,n=this;return e=new x(e,r),!n.c||!e.s||e.c&&!e.c[0]?new x(NaN):!e.c||n.c&&!n.c[0]?new x(n):(9==o?(r=e.s,e.s=1,t=v(n,e,0,3),e.s=r,t.s*=r):t=v(n,e,0,o),(e=n.minus(t.times(e))).c[0]||1!=o||(e.s=n.s),e)},t.multipliedBy=t.times=function(e,r){var t,n,o,i,u,c,a,l,s,f,h,p=this,g=p.c,d=(e=new x(e,r)).c;if(!(g&&d&&g[0]&&d[0]))return!p.s||!e.s||g&&!g[0]&&!d||d&&!d[0]&&!g?e.c=e.e=e.s=null:(e.s*=p.s,g&&d?(e.c=[0],e.e=0):e.c=e.e=null),e;for(r=q(p.e/M)+q(e.e/M),e.s*=p.s,(c=g.length)<(p=d.length)&&(h=g,g=d,d=h,n=c,c=p,p=n),n=c+p,h=[];n--;h.push(0));for(n=p;0<=--n;){for(s=d[n]%1e7,f=d[n]/1e7|(t=0),o=n+(i=c);n<o;)t=((a=s*(a=g[--i]%1e7)+(u=f*a+(l=g[i]/1e7|0)*s)%1e7*1e7+h[o]+t)/1e14|0)+(u/1e7|0)+f*l,h[o--]=a%1e14;h[o]=t}return t?++r:h.splice(0,1),D(e,h,r)},t.negated=function(){var e=new x(this);return e.s=-e.s||null,e},t.plus=function(e,r){var t,n=this,o=n.s;if(r=(e=new x(e,r)).s,!o||!r)return new x(NaN);if(o!=r)return e.s=-r,n.minus(e);var i=n.e/M,u=e.e/M,c=n.c,a=e.c;if(!i||!u){if(!c||!a)return new x(o/0);if(!c[0]||!a[0])return a[0]?e:new x(c[0]?n:0*o)}if(i=q(i),u=q(u),c=c.slice(),o=i-u){for((t=0<o?(u=i,a):(o=-o,c)).reverse();o--;t.push(0));t.reverse()}for((o=c.length)-(r=a.length)<0&&(t=a,a=c,c=t,r=o),o=0;r;)o=(c[--r]=c[r]+a[r]+o)/L|0,c[r]=L===c[r]?0:c[r]%L;return o&&(c=[o].concat(c),++u),D(e,c,u)},t.precision=t.sd=function(e,r){var t,n;if(null!=e&&e!==!!e)return W(e,1,G),null==r?r=b:W(r,0,8),k(new x(this),e,r);if(!(r=this.c))return null;if(t=(n=r.length-1)*M+1,n=r[n]){for(;n%10==0;n/=10,t--);for(n=r[0];10<=n;n/=10,t++);}return t=e&&this.e+1>t?this.e+1:t},t.shiftedBy=function(e){return W(e,-ee,ee),this.times("1e"+e)},t.squareRoot=t.sqrt=function(){var e,r,t,n,o,i=this,u=i.c,c=i.s,a=i.e,l=w+4,s=new x("0.5");if(1!==c||!u||!u[0])return new x(!c||c<0&&(!u||u[0])?NaN:u?i:1/0);if((t=0==(c=Math.sqrt(+C(i)))||c==1/0?(((r=H(u)).length+a)%2==0&&(r+="0"),c=Math.sqrt(+r),a=q((a+1)/2)-(a<0||a%2),new x(r=c==1/0?"5e"+a:(r=c.toExponential()).slice(0,r.indexOf("e")+1)+a)):new x(c+"")).c[0])for((c=(a=t.e)+l)<3&&(c=0);;)if(o=t,t=s.times(o.plus(v(i,o,l,1))),H(o.c).slice(0,c)===(r=H(t.c)).slice(0,c)){if(t.e<a&&--c,"9999"!=(r=r.slice(c-3,c+1))&&(n||"4999"!=r)){+r&&(+r.slice(1)||"5"!=r.charAt(0))||(k(t,t.e+w+2,1),e=!t.times(t).eq(i));break}if(!n&&(k(o,o.e+w+2,0),o.times(o).eq(i))){t=o;break}l+=4,c+=4,n=1}return k(t,t.e+w+1,b,e)},t.toExponential=function(e,r){return null!=e&&(W(e,0,G),e++),n(this,e,r,1)},t.toFixed=function(e,r){return null!=e&&(W(e,0,G),e=e+this.e+1),n(this,e,r)},t.toFormat=function(e,r,t){if(null==t)null!=e&&r&&"object"==U(r)?(t=r,r=null):e&&"object"==U(e)?(t=e,e=r=null):t=N;else if("object"!=U(t))throw Error(F+"Argument not an object: "+t);if(e=this.toFixed(e,r),this.c){var n,r=e.split("."),o=+t.groupSize,i=+t.secondaryGroupSize,u=t.groupSeparator||"",c=r[0],r=r[1],a=this.s<0,l=a?c.slice(1):c,s=l.length;if(i&&(n=o,o=i,s-=i=n),0<o&&0<s){for(c=l.substr(0,n=s%o||o);n<s;n+=o)c+=u+l.substr(n,o);0<i&&(c+=u+l.slice(n)),a&&(c="-"+c)}e=r?c+(t.decimalSeparator||"")+((i=+t.fractionGroupSize)?r.replace(new RegExp("\\d{"+i+"}\\B","g"),"$&"+(t.fractionGroupSeparator||"")):r):c}return(t.prefix||"")+e+(t.suffix||"")},t.toFraction=function(e){var r,t,n,o,i,u,c,a,l,s,f=this,h=f.c;if(null!=e&&(!(c=new x(e)).isInteger()&&(c.c||1!==c.s)||c.lt(g)))throw Error(F+"Argument "+(c.isInteger()?"out of range: ":"not an integer: ")+C(c));if(!h)return new x(f);for(r=new x(g),l=t=new x(g),n=a=new x(g),h=H(h),i=r.e=h.length-f.e-1,r.c[0]=re[(u=i%M)<0?M+u:u],e=!e||0<c.comparedTo(r)?0<i?r:l:c,u=O,O=1/0,c=new x(h),a.c[0]=0;s=v(c,r,0,1),1!=(o=t.plus(s.times(n))).comparedTo(e);)t=n,n=o,l=a.plus(s.times(o=l)),a=o,r=c.minus(s.times(o=r)),c=o;return o=v(e.minus(t),n,0,1),a=a.plus(o.times(l)),t=t.plus(o.times(n)),a.s=l.s=f.s,h=v(l,n,i*=2,b).minus(f).abs().comparedTo(v(a,t,i,b).minus(f).abs())<1?[l,n]:[a,t],O=u,h},t.toNumber=function(){return+C(this)},t.toPrecision=function(e,r){return null!=e&&W(e,1,G),n(this,e,r,2)},t.toString=function(e){var r,t=this,n=t.s,o=t.e;return null===o?n?(r="Infinity",n<0&&(r="-"+r)):r="NaN":(r=null==e?o<=d||m<=o?Y(H(t.c),o):Z(H(t.c),o,"0"):10===e&&j?Z(H((t=k(new x(t),w+o+1,b)).c),t.e,"0"):(W(e,2,S.length,"Base"),f(Z(H(t.c),o,"0"),10,e,n,!0)),n<0&&t.c[0]&&(r="-"+r)),r},t.valueOf=t.toJSON=function(){return C(this)},t._isBigNumber=!0,t[Symbol.toStringTag]="BigNumber",t[Symbol.for("nodejs.util.inspect.custom")]=t.valueOf,null!=e&&x.set(e),x}();function I(e,r){var t="",n=(t=a.isBigNumber(e)?e.toFixed():"string"!=typeof e?e.toString():e,null),e=null,o=null,i=r.match(/(<=|>=|=)\s*(\d+)/);if(i&&(e=i[1],n=Number(i[2])),r.includes(",")&&(o=!0),null!==n){var i=t.split("."),r=i[0],u=1===i.length?"":i[1],c=u.length;switch(e){case"<=":u=c<=n?u:u.slice(0,n);break;case"=":c<n?u+="0".repeat(n-c):n<c&&(u=u.slice(0,n));break;case">=":u=n<=c?u:u+"0".repeat(n-c)}t=""===u?r:"".concat(r,".").concat(u)}return t=null!==o?1<(i=t.split(".")).length?((e=i[0]).includes("-")?i[0]=e[0]+e.slice(1).replace(/(?=(?!^)(?:\d{3})+$)/g,","):i[0]=e.replace(/(?=(?!^)(?:\d{3})+$)/g,","),i.join(".")):(r=i[0]).includes("-")?r[0]+r.slice(1).replace(/(?=(?!^)(?:\d{3})+$)/g,","):r.replace(/(?=(?!^)(?:\d{3})+$)/g,","):t}function te(e){for(var r=[],t=0,n=null,o=e.length;t<o;)if(n=e[t],/\s/.test(n))t++;else if("+-".includes(n)){var i=r[r.length-1];if(0===r.length||"+-".includes(i)||"("===i){for(var u=n,n=e[++t];/[a-zA-Z\d._]/.test(n);)u+=n,n=e[++t];r.push(u)}else r.push(n),t++}else if("*/%()".includes(n))r.push(n),t++;else if(/[\w_.\[\]"']/.test(n)){for(var c="";/[\w_.\[\]"']/.test(n)&&(c+=n,!(++t>=o));)n=e[t];r.push(c)}else if(/\d/.test(n)){for(var a="";/[\d.]/.test(n)&&(a+=n,!(++t>=o));)n=e[t];r.push(a)}return r}var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},ne=Array.isArray,t="object"==U(t)&&t&&t.Object===Object&&t,n="object"==("undefined"==typeof self?"undefined":U(self))&&self&&self.Object===Object&&self,t=t||n||Function("return this")(),n=t.Symbol,u=Object.prototype,oe=u.hasOwnProperty,ie=u.toString,c=n?n.toStringTag:void 0;var ue=Object.prototype.toString;var ce=function(e){var r=oe.call(e,c),t=e[c];try{var n=!(e[c]=void 0)}catch(e){}var o=ie.call(e);return n&&(r?e[c]=t:delete e[c]),o},ae=function(e){return ue.call(e)},le=n?n.toStringTag:void 0;function se(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":(le&&le in Object(e)?ce:ae)(e)}var fe=se,he=function(e){return null!=e&&"object"==U(e)};function pe(e){return"symbol"==U(e)||he(e)&&"[object Symbol]"==fe(e)}var ge=ne,de=pe,ve=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,ye=/^\w*$/;function we(e,r){if(ge(e))return!1;var t=U(e);return!("number"!=t&&"symbol"!=t&&"boolean"!=t&&null!=e&&!de(e))||(ye.test(e)||!ve.test(e)||null!=r&&e in Object(r))}function be(e){var r=U(e);return null!=e&&("object"==r||"function"==r)}var me=se,_e=be;function Oe(e){return!!_e(e)&&("[object Function]"==(e=me(e))||"[object GeneratorFunction]"==e||"[object AsyncFunction]"==e||"[object Proxy]"==e)}var u=t["__core-js_shared__"],Ae=(u=/[^.]+$/.exec(u&&u.keys&&u.keys.IE_PROTO||""))?"Symbol(src)_1."+u:"";var Ee=Function.prototype.toString;var Ne=Oe,Se=function(e){return!!Ae&&Ae in e},je=be,xe=function(e){if(null!=e){try{return Ee.call(e)}catch(e){}try{return e+""}catch(e){}}return""},Pe=/^\[object .+?Constructor\]$/,u=Function.prototype,g=Object.prototype,u=u.toString,g=g.hasOwnProperty,Re=RegExp("^"+u.call(g).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");var Te=function(e){return!(!je(e)||Se(e))&&(Ne(e)?Re:Pe).test(xe(e))},Be=function(e,r){return null==e?void 0:e[r]};function De(e,r){return e=Be(e,r),Te(e)?e:void 0}var u=De(Object,"create"),ke=u;var Ce=u,Ie=Object.prototype.hasOwnProperty;var Ue=u,$e=Object.prototype.hasOwnProperty;var Fe=u;function Le(e){return e=this.has(e)&&delete this.__data__[e],this.size-=e?1:0,e}function Me(e){var r,t=this.__data__;return Ce?"__lodash_hash_undefined__"===(r=t[e])?void 0:r:Ie.call(t,e)?t[e]:void 0}function ze(e){var r=this.__data__;return Ue?void 0!==r[e]:$e.call(r,e)}function Ge(e,r){var t=this.__data__;return this.size+=this.has(e)?0:1,t[e]=Fe&&void 0===r?"__lodash_hash_undefined__":r,this}function d(e){var r=-1,t=null==e?0:e.length;for(this.clear();++r<t;){var n=e[r];this.set(n[0],n[1])}}d.prototype.clear=function(){this.__data__=ke?ke(null):{},this.size=0},d.prototype.delete=Le,d.prototype.get=Me,d.prototype.has=ze,d.prototype.set=Ge;g=d;var qe=function(e,r){return e===r||e!=e&&r!=r};function v(e,r){for(var t=e.length;t--;)if(qe(e[t][0],r))return t;return-1}var He=v,Ve=Array.prototype.splice;var We=v;var Xe=v;var Ye=v;function Ze(e){var r=this.__data__;return!((e=He(r,e))<0)&&(e==r.length-1?r.pop():Ve.call(r,e,1),--this.size,!0)}function Je(e){var r=this.__data__;return(e=We(r,e))<0?void 0:r[e][1]}function Ke(e){return-1<Xe(this.__data__,e)}function Qe(e,r){var t=this.__data__,n=Ye(t,e);return n<0?(++this.size,t.push([e,r])):t[n][1]=r,this}function y(e){var r=-1,t=null==e?0:e.length;for(this.clear();++r<t;){var n=e[r];this.set(n[0],n[1])}}y.prototype.clear=function(){this.__data__=[],this.size=0},y.prototype.delete=Ze,y.prototype.get=Je,y.prototype.has=Ke,y.prototype.set=Qe;var u=y,t=De(t,"Map"),er=g,rr=u,tr=t;var nr=function(e){var r=U(e);return"string"==r||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==e:null===e};function w(e,r){return e=e.__data__,nr(r)?e["string"==typeof r?"string":"hash"]:e.map}var or=w;var ir=w;var ur=w;var cr=w;function ar(e){return e=or(this,e).delete(e),this.size-=e?1:0,e}function lr(e){return ir(this,e).get(e)}function sr(e){return ur(this,e).has(e)}function fr(e,r){var t=cr(this,e),n=t.size;return t.set(e,r),this.size+=t.size==n?0:1,this}function b(e){var r=-1,t=null==e?0:e.length;for(this.clear();++r<t;){var n=e[r];this.set(n[0],n[1])}}b.prototype.clear=function(){this.size=0,this.__data__={hash:new er,map:new(tr||rr),string:new er}},b.prototype.delete=ar,b.prototype.get=lr,b.prototype.has=sr,b.prototype.set=fr;var hr=b;function pr(n,o){if("function"!=typeof n||null!=o&&"function"!=typeof o)throw new TypeError("Expected a function");function i(){var e=arguments,r=o?o.apply(this,e):e[0],t=i.cache;return t.has(r)?t.get(r):(e=n.apply(this,e),i.cache=t.set(r,e)||t,e)}return i.cache=new(pr.Cache||hr),i}pr.Cache=hr;var gr=pr;var dr=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,vr=/\\(\\)?/g,g=function(e){var r=(e=gr(e,function(e){return 500===r.size&&r.clear(),e})).cache;return e}(function(e){var o=[];return 46===e.charCodeAt(0)&&o.push(""),e.replace(dr,function(e,r,t,n){o.push(t?n.replace(vr,"$1"):r||e)}),o});var yr=function(e,r){for(var t=-1,n=null==e?0:e.length,o=Array(n);++t<n;)o[t]=r(e[t],t,e);return o},wr=ne,br=pe,u=n?n.prototype:void 0,mr=u?u.toString:void 0;var _r=function e(r){if("string"==typeof r)return r;if(wr(r))return yr(r,e)+"";if(br(r))return mr?mr.call(r):"";var t=r+"";return"0"==t&&1/r==-1/0?"-0":t};var Or=ne,Ar=we,Er=g,Nr=function(e){return null==e?"":_r(e)};var Sr=pe;var jr=function(e,r){return Or(e)?e:Ar(e,r)?[e]:Er(Nr(e))},xr=function(e){if("string"==typeof e||Sr(e))return e;var r=e+"";return"0"==r&&1/e==-1/0?"-0":r};var Pr=function(e,r){for(var t=0,n=(r=jr(r,e)).length;null!=e&&t<n;)e=e[xr(r[t++])];return t&&t==n?e:void 0};var m=function(e,r,t){return void 0===(e=null==e?void 0:Pr(e,r))?t:e};function _(e,r){var t=[];if(!s(r))throw new p("错误的填充数据:",r);Array.isArray(r)?t=r:t.push(r);for(var n=[],o=0;o<e.length;o++){var i=e[o];if(/^[a-zA-z_][\w\[\]"'_.]*$/.test(i)){if("undefined"===i||"NaN"===i)throw new p("key不应该为:".concat(i));for(var u=null,c=0;c<t.length;c++){var a=t[c],a=m(a,i);if(void 0!==a){u=a;break}}if(null===u)throw new p("token填充失败,请确认".concat(i,"存在"));if("string"==typeof u){if(""===u.trim())throw new p("token填充失败,".concat(i,"值不可为空字符"));if(!f(u))throw new p("token填充失败,".concat(i,"值:").concat(u,"为非法数字"))}u="string"!=typeof u?u.toString():u,n.push(u)}else n.push(i)}return n}function Rr(e){for(var r,t=[],n=[],o=e;0<o.length;){var i=o.shift();if(T(i))if("("===i)t.push(i);else if(")"===i){for(var u=t.pop();"("!==u&&0<t.length;)n.push(u),u=t.pop();if("("!==u)throw"error: unmatched ()"}else{for(;r=t[t.length-1],B(i)<=B(r)&&0<t.length;)n.push(t.pop());t.push(i)}else n.push(i)}if(0<t.length){if(")"===t[t.length-1]||"("===t[t.length-1])throw"error: unmatched ()";for(;0<t.length;)n.push(t.pop())}return n}function Tr(e){for(var r=[];0<e.length;){var t=e.shift();if(T(t)){if(r.length<2)throw new h("错误的栈长度, 可能是无法计算的表达式");var n=r.pop(),o=r.pop();if("string"==typeof n&&!a.isBigNumber(n)){if(!f(n))throw new h("".concat(n,"不是一个合法的数字"));n=new a(n)}if("string"==typeof o&&!a.isBigNumber(o)){if(!f(o))throw new h("".concat(o,"不是一个合法的数字"));o=new a(o)}switch(t){case"+":r.push(o.plus(n));break;case"-":r.push(o.minus(n));break;case"*":r.push(o.times(n));break;case"/":r.push(o.div(n));break;case"%":r.push(o.mod(n))}}else r.push(t)}if(1!==r.length)throw"unvalid expression";return r[0]}return e.calc=function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++)r[t]=arguments[t];var n=C(r),o=te(n.expr),i=null;if(!0===m(n,"data._debug")&&(console.warn("======a-calc调试模式======"),console.warn(n),console.warn(o)),null!==n.data){var u=n.data,c=[];if(Array.isArray(u)?c=u:(c.push(i=u),D(a=m(i,"_fillData"))&&(Array.isArray(a)?c=[].concat(l(c),l(a)):c.push(a))),k(u._fillError,u._error))try{o=_(o,c)}catch(e){if(e instanceof p)return void 0!==i._warn&&!0===i._warn&&console.warn(e),i._fillError||i._error;throw e}else o=_(o,c)}var a=Rr(o),u=null;if(s(i)&&k(i._calcError,i._error))try{u=Tr(a)}catch(e){if(e instanceof h)return void 0!==i._warn&&!0===i._warn&&console.warn(e),void 0!==i._calcError?i._calcError:i._error;throw e}else u=Tr(a);return u=s(n.fmt)?I(u,n.fmt):null!==u?u.toFixed():null},e.fmt=function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++)r[t]=arguments[t];var n=C(r),o=te(n.expr),i=null;if(!0===m(n,"data._debug")&&(console.warn("======a-calc调试模式======"),console.warn(n),console.warn(o)),""===n.expr.trim()&&s(n.data)&&D(n.data._error))return n.data._error;if(2<o.length)throw new Error("fmt并非用于计算, 不能传入多个标识:".concat(n.expr));if(1!==o.length)throw new Error("fmt接收了一个无法被解析的标识");if(null!==n.data){var u=arg.data,c=[];if(Array.isArray(u)?c=u:(c.push(i=u),D(a=m(i,"_fillData"))&&(Array.isArray(a)?c=[].concat(l(c),l(a)):c.push(a))),k(u._fillError,u._error))try{o=_(o,c)}catch(e){if(e instanceof p)return void 0!==i._warn&&!0===i._warn&&console.warn(e),i._fillError||i._error;throw e}else o=_(o,c)}if(null===n.fmt)throw"表达式没有格式化部分";var a=o[0];if(f(a))return I(o[0],n.fmt);throw new p("待格式化对象: ".concat(a," 不是数字"))},e.version="0.0.60",Object.defineProperty(e,"__esModule",{value:!0}),e}({});
package/cjs/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var BigNumber=require("bignumber.js");function _interopDefaultLegacy(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var BigNumber__default=_interopDefaultLegacy(BigNumber);function isOperator(e){return-1<"+-*/%()".indexOf(e)}function getPrioraty(e){switch(e){case"+":case"-":return 1;case"*":case"/":case"%":return 2;default:return 0}}function prioraty(e,t){return getPrioraty(e)<=getPrioraty(t)}function isObj(e){return"[object Object]"===Object.prototype.toString.call(e)&&!Array.isArray(e)}function anyNoUndefined(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return t.some(function(e){return void 0!==e})}function isStrNumber(e){return"string"==typeof e&&!!/^[+-]?\d+\.?\d*$/.test(e)}function _typeof(e){return(_typeof="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 _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function _createClass(e,t,r){return t&&_defineProperties(e.prototype,t),r&&_defineProperties(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&_setPrototypeOf(e,t)}function _getPrototypeOf(e){return(_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function _setPrototypeOf(e,t){return(_setPrototypeOf=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}function _construct(e,t,r){return(_construct=_isNativeReflectConstruct()?Reflect.construct:function(e,t,r){var a=[null];a.push.apply(a,t);t=new(Function.bind.apply(e,a));return r&&_setPrototypeOf(t,r.prototype),t}).apply(null,arguments)}function _isNativeFunction(e){return-1!==Function.toString.call(e).indexOf("[native code]")}function _wrapNativeSuper(e){var r="function"==typeof Map?new Map:void 0;return(_wrapNativeSuper=function(e){if(null===e||!_isNativeFunction(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==r){if(r.has(e))return r.get(e);r.set(e,t)}function t(){return _construct(e,arguments,_getPrototypeOf(this).constructor)}return t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),_setPrototypeOf(t,e)})(e)}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _possibleConstructorReturn(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(e)}function _createSuper(r){var a=_isNativeReflectConstruct();return function(){var e,t=_getPrototypeOf(r);return _possibleConstructorReturn(this,a?(e=_getPrototypeOf(this).constructor,Reflect.construct(t,arguments,e)):t.apply(this,arguments))}}var CalculatorError=function(){_inherits(a,_wrapNativeSuper(Error));var r=_createSuper(a);function a(e){var t;return _classCallCheck(this,a),(t=r.call(this,e)).name="CalculatorError",t.message=e,t}return _createClass(a)}(),TokensFillError=function(){_inherits(a,_wrapNativeSuper(Error));var r=_createSuper(a);function a(e){var t;return _classCallCheck(this,a),(t=r.call(this,e)).name="TokensFillError",t.message=e,t}return _createClass(a)}();function parseArgs(e){var t={expr:"",fmt:null,data:null},r="",a=e[0];if(1===e.length)"string"==typeof a?r=a:"number"==typeof a?r=a.toString():Array.isArray(a)&&(r=a[0]);else if(1<e.length){a=e[e.length-1];if(!isObj(a)&&!Array.isArray(a))throw new Error("参数错误, 暂不支持的参数");if("string"==typeof(r=e[0])){if(""===r.trim())throw new TokensFillError("参数不可为空字符串")}else if("number"==typeof r)r=r.toString();else if(void 0===r||Number.isNaN(r))throw new TokensFillError("非法参数:".concat(r));t.data=a}e=r.split("|");return 1===e.length?t.expr=e[0]:(t.expr=e[0],""!==(a=e[1]).trim()&&(t.fmt=a)),null!==t.data&&null===t.fmt&&t.data._fmt&&(t.fmt=t.data._fmt),t}function format(e,t){var r="",a=(r=BigNumber__default.default.isBigNumber(e)?e.toFixed():"string"!=typeof e?e.toString():e,null),e=null,o=null,n=t.match(/(<=|>=|=)\s*(\d+)/);if(n&&(e=n[1],a=Number(n[2])),t.includes(",")&&(o=!0),null!==a){var n=r.split("."),t=n[0],i=1===n.length?"":n[1],s=i.length;switch(e){case"<=":i=s<=a?i:i.slice(0,a);break;case"=":s<a?i+="0".repeat(a-s):a<s&&(i=i.slice(0,a));break;case">=":i=a<=s?i:i+"0".repeat(a-s)}r=""===i?t:"".concat(t,".").concat(i)}return r=null!==o?1<(n=r.split(".")).length?((e=n[0]).includes("-")?n[0]=e[0]+e.slice(1).replace(/(?=(?!^)(?:\d{3})+$)/g,","):n[0]=e.replace(/(?=(?!^)(?:\d{3})+$)/g,","),n.join(".")):(t=n[0]).includes("-")?t[0]+t.slice(1).replace(/(?=(?!^)(?:\d{3})+$)/g,","):t.replace(/(?=(?!^)(?:\d{3})+$)/g,","):r}function tokenizer(e){for(var t=[],r=0,a=null,o=e.length;r<o;)if(a=e[r],/\s/.test(a))r++;else if("+-".includes(a)){var n=t[t.length-1];if(0===t.length||"+-".includes(n)||"("===n){for(var i=a,a=e[++r];/[a-zA-Z\d._]/.test(a);)i+=a,a=e[++r];t.push(i)}else t.push(a),r++}else if("*/%()".includes(a))t.push(a),r++;else if(/[\w_.\[\]"']/.test(a)){for(var s="";/[\w_.\[\]"']/.test(a)&&(s+=a,!(++r>=o));)a=e[r];t.push(s)}else if(/\d/.test(a)){for(var c="";/[\d.]/.test(a)&&(c+=a,!(++r>=o));)a=e[r];t.push(c)}return t}var commonjsGlobal="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},isArray$3=Array.isArray,isArray_1=isArray$3,freeGlobal$1="object"==_typeof(commonjsGlobal)&&commonjsGlobal&&commonjsGlobal.Object===Object&&commonjsGlobal,_freeGlobal=freeGlobal$1,freeGlobal=freeGlobal$1,freeSelf="object"==("undefined"==typeof self?"undefined":_typeof(self))&&self&&self.Object===Object&&self,root$3=freeGlobal||freeSelf||Function("return this")(),_root=root$3,root$2=_root,_Symbol2=_root.Symbol,_Symbol$3=_Symbol2,_Symbol$2=_Symbol$3,objectProto$4=Object.prototype,hasOwnProperty$3=objectProto$4.hasOwnProperty,nativeObjectToString$1=objectProto$4.toString,symToStringTag$1=_Symbol$2?_Symbol$2.toStringTag:void 0;function getRawTag$1(e){var t=hasOwnProperty$3.call(e,symToStringTag$1),r=e[symToStringTag$1];try{var a=!(e[symToStringTag$1]=void 0)}catch(e){}var o=nativeObjectToString$1.call(e);return a&&(t?e[symToStringTag$1]=r:delete e[symToStringTag$1]),o}var _getRawTag=getRawTag$1,objectProto$3=Object.prototype,nativeObjectToString=objectProto$3.toString;function objectToString$1(e){return nativeObjectToString.call(e)}var _objectToString=objectToString$1,_Symbol$1=_Symbol$3,getRawTag=_getRawTag,objectToString=objectToString$1,nullTag="[object Null]",undefinedTag="[object Undefined]",symToStringTag=_Symbol$3?_Symbol$3.toStringTag:void 0;function baseGetTag$2(e){return null==e?void 0===e?undefinedTag:nullTag:(symToStringTag&&symToStringTag in Object(e)?getRawTag:objectToString)(e)}var _baseGetTag=baseGetTag$2;function isObjectLike$1(e){return null!=e&&"object"==_typeof(e)}var isObjectLike_1=isObjectLike$1,baseGetTag$1=baseGetTag$2,isObjectLike=isObjectLike$1,symbolTag="[object Symbol]";function isSymbol$3(e){return"symbol"==_typeof(e)||isObjectLike(e)&&baseGetTag$1(e)==symbolTag}var isSymbol_1=isSymbol$3,isArray$2=isArray_1,isSymbol$2=isSymbol_1,reIsDeepProp=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,reIsPlainProp=/^\w*$/;function isKey$1(e,t){if(isArray$2(e))return!1;var r=_typeof(e);return!("number"!=r&&"symbol"!=r&&"boolean"!=r&&null!=e&&!isSymbol$2(e))||(reIsPlainProp.test(e)||!reIsDeepProp.test(e)||null!=t&&e in Object(t))}var _isKey=isKey$1;function isObject$2(e){var t=_typeof(e);return null!=e&&("object"==t||"function"==t)}var isObject_1=isObject$2,baseGetTag=baseGetTag$2,isObject$1=isObject_1,asyncTag="[object AsyncFunction]",funcTag="[object Function]",genTag="[object GeneratorFunction]",proxyTag="[object Proxy]";function isFunction$1(e){if(!isObject$1(e))return!1;e=baseGetTag(e);return e==funcTag||e==genTag||e==asyncTag||e==proxyTag}var isFunction_1=isFunction$1,root$1=_root,coreJsData$1=_root["__core-js_shared__"],_coreJsData=coreJsData$1,coreJsData=coreJsData$1,maskSrcKey=function(){var e=/[^.]+$/.exec(coreJsData&&coreJsData.keys&&coreJsData.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function isMasked$1(e){return!!maskSrcKey&&maskSrcKey in e}var _isMasked=isMasked$1,funcProto$1=Function.prototype,funcToString$1=funcProto$1.toString;function toSource$1(e){if(null!=e){try{return funcToString$1.call(e)}catch(e){}try{return e+""}catch(e){}}return""}var _toSource=toSource$1,isFunction=isFunction_1,isMasked=_isMasked,isObject=isObject_1,toSource=toSource$1,reRegExpChar=/[\\^$.*+?()[\]{}|]/g,reIsHostCtor=/^\[object .+?Constructor\]$/,funcProto=Function.prototype,objectProto$2=Object.prototype,funcToString=funcProto.toString,hasOwnProperty$2=objectProto$2.hasOwnProperty,reIsNative=RegExp("^"+funcToString.call(hasOwnProperty$2).replace(reRegExpChar,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function baseIsNative$1(e){return!(!isObject(e)||isMasked(e))&&(isFunction(e)?reIsNative:reIsHostCtor).test(toSource(e))}var _baseIsNative=baseIsNative$1;function getValue$1(e,t){return null==e?void 0:e[t]}var _getValue=getValue$1,baseIsNative=baseIsNative$1,getValue=getValue$1;function getNative$2(e,t){e=getValue(e,t);return baseIsNative(e)?e:void 0}var _getNative=getNative$2,getNative$1=_getNative,nativeCreate$4=_getNative(Object,"create"),_nativeCreate=nativeCreate$4,nativeCreate$3=_nativeCreate;function hashClear$1(){this.__data__=nativeCreate$3?nativeCreate$3(null):{},this.size=0}var _hashClear=hashClear$1;function hashDelete$1(e){e=this.has(e)&&delete this.__data__[e];return this.size-=e?1:0,e}var _hashDelete=hashDelete$1,nativeCreate$2=_nativeCreate,HASH_UNDEFINED$1="__lodash_hash_undefined__",objectProto$1=Object.prototype,hasOwnProperty$1=objectProto$1.hasOwnProperty;function hashGet$1(e){var t,r=this.__data__;return nativeCreate$2?(t=r[e])===HASH_UNDEFINED$1?void 0:t:hasOwnProperty$1.call(r,e)?r[e]:void 0}var _hashGet=hashGet$1,nativeCreate$1=_nativeCreate,objectProto=Object.prototype,hasOwnProperty=objectProto.hasOwnProperty;function hashHas$1(e){var t=this.__data__;return nativeCreate$1?void 0!==t[e]:hasOwnProperty.call(t,e)}var _hashHas=hashHas$1,nativeCreate=_nativeCreate,HASH_UNDEFINED="__lodash_hash_undefined__";function hashSet$1(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=nativeCreate&&void 0===t?HASH_UNDEFINED:t,this}var _hashSet=hashSet$1,hashClear=_hashClear,hashDelete=_hashDelete,hashGet=_hashGet,hashHas=hashHas$1,hashSet=hashSet$1;function Hash$1(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var a=e[t];this.set(a[0],a[1])}}Hash$1.prototype.clear=hashClear,Hash$1.prototype.delete=hashDelete,Hash$1.prototype.get=hashGet,Hash$1.prototype.has=hashHas,Hash$1.prototype.set=hashSet;var _Hash=Hash$1;function listCacheClear$1(){this.__data__=[],this.size=0}var _listCacheClear=listCacheClear$1;function eq$1(e,t){return e===t||e!=e&&t!=t}var eq_1=eq$1,eq=eq$1;function assocIndexOf$4(e,t){for(var r=e.length;r--;)if(eq(e[r][0],t))return r;return-1}var _assocIndexOf=assocIndexOf$4,assocIndexOf$3=_assocIndexOf,arrayProto=Array.prototype,splice=arrayProto.splice;function listCacheDelete$1(e){var t=this.__data__,e=assocIndexOf$3(t,e);return!(e<0)&&(e==t.length-1?t.pop():splice.call(t,e,1),--this.size,!0)}var _listCacheDelete=listCacheDelete$1,assocIndexOf$2=_assocIndexOf;function listCacheGet$1(e){var t=this.__data__,e=assocIndexOf$2(t,e);return e<0?void 0:t[e][1]}var _listCacheGet=listCacheGet$1,assocIndexOf$1=_assocIndexOf;function listCacheHas$1(e){return-1<assocIndexOf$1(this.__data__,e)}var _listCacheHas=listCacheHas$1,assocIndexOf=_assocIndexOf;function listCacheSet$1(e,t){var r=this.__data__,a=assocIndexOf(r,e);return a<0?(++this.size,r.push([e,t])):r[a][1]=t,this}var _listCacheSet=listCacheSet$1,listCacheClear=_listCacheClear,listCacheDelete=listCacheDelete$1,listCacheGet=listCacheGet$1,listCacheHas=listCacheHas$1,listCacheSet=listCacheSet$1;function ListCache$1(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var a=e[t];this.set(a[0],a[1])}}ListCache$1.prototype.clear=listCacheClear,ListCache$1.prototype.delete=listCacheDelete,ListCache$1.prototype.get=listCacheGet,ListCache$1.prototype.has=listCacheHas,ListCache$1.prototype.set=listCacheSet;var _ListCache=ListCache$1,getNative=_getNative,root=_root,Map$2=_getNative(_root,"Map"),_Map=Map$2,Hash=_Hash,ListCache=_ListCache,Map$1=Map$2;function mapCacheClear$1(){this.size=0,this.__data__={hash:new Hash,map:new(Map$1||ListCache),string:new Hash}}var _mapCacheClear=mapCacheClear$1;function isKeyable$1(e){var t=_typeof(e);return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e}var _isKeyable=isKeyable$1,isKeyable=isKeyable$1;function getMapData$4(e,t){e=e.__data__;return isKeyable(t)?e["string"==typeof t?"string":"hash"]:e.map}var _getMapData=getMapData$4,getMapData$3=getMapData$4;function mapCacheDelete$1(e){e=getMapData$3(this,e).delete(e);return this.size-=e?1:0,e}var _mapCacheDelete=mapCacheDelete$1,getMapData$2=getMapData$4;function mapCacheGet$1(e){return getMapData$2(this,e).get(e)}var _mapCacheGet=mapCacheGet$1,getMapData$1=getMapData$4;function mapCacheHas$1(e){return getMapData$1(this,e).has(e)}var _mapCacheHas=mapCacheHas$1,getMapData=getMapData$4;function mapCacheSet$1(e,t){var r=getMapData(this,e),a=r.size;return r.set(e,t),this.size+=r.size==a?0:1,this}var _mapCacheSet=mapCacheSet$1,mapCacheClear=mapCacheClear$1,mapCacheDelete=mapCacheDelete$1,mapCacheGet=mapCacheGet$1,mapCacheHas=mapCacheHas$1,mapCacheSet=mapCacheSet$1;function MapCache$1(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var a=e[t];this.set(a[0],a[1])}}MapCache$1.prototype.clear=mapCacheClear,MapCache$1.prototype.delete=mapCacheDelete,MapCache$1.prototype.get=mapCacheGet,MapCache$1.prototype.has=mapCacheHas,MapCache$1.prototype.set=mapCacheSet;var _MapCache=MapCache$1,MapCache=MapCache$1,FUNC_ERROR_TEXT="Expected a function";function memoize$1(a,o){if("function"!=typeof a||null!=o&&"function"!=typeof o)throw new TypeError(FUNC_ERROR_TEXT);function n(){var e=arguments,t=o?o.apply(this,e):e[0],r=n.cache;return r.has(t)?r.get(t):(e=a.apply(this,e),n.cache=r.set(t,e)||r,e)}return n.cache=new(memoize$1.Cache||MapCache),n}memoize$1.Cache=MapCache;var memoize_1=memoize$1,memoize=memoize$1,MAX_MEMOIZE_SIZE=500;function memoizeCapped$1(e){var e=memoize(e,function(e){return t.size===MAX_MEMOIZE_SIZE&&t.clear(),e}),t=e.cache;return e}var _memoizeCapped=memoizeCapped$1,memoizeCapped=memoizeCapped$1,rePropName=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,reEscapeChar=/\\(\\)?/g,stringToPath$1=memoizeCapped$1(function(e){var o=[];return 46===e.charCodeAt(0)&&o.push(""),e.replace(rePropName,function(e,t,r,a){o.push(r?a.replace(reEscapeChar,"$1"):t||e)}),o}),_stringToPath=stringToPath$1;function arrayMap$1(e,t){for(var r=-1,a=null==e?0:e.length,o=Array(a);++r<a;)o[r]=t(e[r],r,e);return o}var _arrayMap=arrayMap$1,_Symbol=_Symbol$3,arrayMap=arrayMap$1,isArray$1=isArray_1,isSymbol$1=isSymbol_1,INFINITY$1=1/0,symbolProto=_Symbol$3?_Symbol$3.prototype:void 0,symbolToString=symbolProto?symbolProto.toString:void 0;function baseToString$1(e){if("string"==typeof e)return e;if(isArray$1(e))return arrayMap(e,baseToString$1)+"";if(isSymbol$1(e))return symbolToString?symbolToString.call(e):"";var t=e+"";return"0"==t&&1/e==-INFINITY$1?"-0":t}var _baseToString=baseToString$1,baseToString=baseToString$1;function toString$1(e){return null==e?"":baseToString(e)}var toString_1=toString$1,isArray=isArray_1,isKey=_isKey,stringToPath=_stringToPath,toString=toString$1;function castPath$1(e,t){return isArray(e)?e:isKey(e,t)?[e]:stringToPath(toString(e))}var _castPath=castPath$1,isSymbol=isSymbol_1,INFINITY=1/0;function toKey$1(e){if("string"==typeof e||isSymbol(e))return e;var t=e+"";return"0"==t&&1/e==-INFINITY?"-0":t}var _toKey=toKey$1,castPath=castPath$1,toKey=toKey$1;function baseGet$1(e,t){for(var r=0,a=(t=castPath(t,e)).length;null!=e&&r<a;)e=e[toKey(t[r++])];return r&&r==a?e:void 0}var _baseGet=baseGet$1,baseGet=baseGet$1;function get(e,t,r){e=null==e?void 0:baseGet(e,t);return void 0===e?r:e}var get_1=get;function fillTokens(e,t){for(var r=t._fillData,a=(void 0===t._fillData&&(r=t),Array.isArray(r)||(r=[r]),[]),o=0;o<e.length;o++){var n=e[o];if(/^[a-zA-z_][\w\[\]"'_.]*$/.test(n)){if("undefined"===n||"NaN"===n)throw new TokensFillError("key不应该为:".concat(n));for(var i=null,s=0;s<r.length;s++){var c=r[s],c=get_1(c,n);if(void 0!==c){i=c;break}}if(null===i)throw new TokensFillError("token填充失败,请确认".concat(n,"存在"));if("string"==typeof i){if(""===i.trim())throw new TokensFillError("token填充失败,".concat(n,"值不可为空字符"));if(!isStrNumber(i))throw new TokensFillError("token填充失败,".concat(n,"值:").concat(i,"为非法数字"))}i="string"!=typeof i?i.toString():i,a.push(i)}else a.push(n)}return a}function fmt(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];var a=parseArgs(t),o=tokenizer(a.expr),n=null;if(!0===get_1(a,"data._debug")&&(console.warn("======a-calc调试模式======"),console.warn(a),console.warn(o)),""===a.expr.trim()&&null!==a.data&&void 0!==a.data._error)return a.data._error;if(2<o.length)throw new Error("fmt并非用于计算, 不能传入多个标识:".concat(a.expr));if(1!==o.length)throw new Error("fmt接收了一个无法被解析的标识");if(null!==a.data){var i=a.data;if(null!==(n=!Array.isArray(i)&&anyNoUndefined(i._fillData,i._error,i._fillError)?i:n)&&void 0!==i._fillData&&anyNoUndefined(n._fillError,n._error))try{o=fillTokens(o,i._fillData)}catch(e){if(e instanceof TokensFillError)return void 0!==n._warn&&!0===n._warn&&console.warn(e),n._fillError||n._error;throw e}else o=fillTokens(o,i)}if(null===a.fmt)throw"表达式没有格式化部分";n=o[0];if(isStrNumber(n))return format(o[0],a.fmt);throw new TokensFillError("待格式化对象: ".concat(n," 不是数字"))}var version="0.0.58";function token2postfix(e){for(var t=[],r=[],a=e;0<a.length;){var o=a.shift();if(isOperator(o))if("("===o)t.push(o);else if(")"===o){for(var n=t.pop();"("!==n&&0<t.length;)r.push(n),n=t.pop();if("("!==n)throw"error: unmatched ()"}else{for(;prioraty(o,t[t.length-1])&&0<t.length;)r.push(t.pop());t.push(o)}else r.push(o)}if(0<t.length){if(")"===t[t.length-1]||"("===t[t.length-1])throw"error: unmatched ()";for(;0<t.length;)r.push(t.pop())}return r}function evalPostfix(e){for(var t=[];0<e.length;){var r=e.shift();if(isOperator(r)){if(t.length<2)throw new CalculatorError("错误的栈长度, 可能是无法计算的表达式");var a=t.pop(),o=t.pop();if("string"==typeof a&&!BigNumber__default.default.isBigNumber(a)){if(!/^[+-]*[\d.]+$/.test(a))throw new CalculatorError("".concat(a,"不是一个合法的数字"));a=new BigNumber__default.default(a)}if("string"==typeof o&&!BigNumber__default.default.isBigNumber(o)){if(!/^[+-]*[\d.]+$/.test(o))throw new CalculatorError("".concat(o,"不是一个合法的数字"));o=new BigNumber__default.default(o)}switch(r){case"+":t.push(o.plus(a));break;case"-":t.push(o.minus(a));break;case"*":t.push(o.times(a));break;case"/":t.push(o.div(a));break;case"%":t.push(o.mod(a))}}else t.push(r)}if(1!==t.length)throw"unvalid expression";return t[0]}function calc(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];var a=parseArgs(t),o=tokenizer(a.expr),n=null;if(!0===get_1(a,"data._debug")&&(console.warn("======a-calc调试模式======"),console.warn(a),console.warn(o)),null!==a.data){var i=a.data;if(null!==(n=!Array.isArray(i)&&anyNoUndefined(i._fillData,i._error,i._fillError,i._calcError)?i:n)&&void 0!==i._fillData&&anyNoUndefined(n._fillError,n._error))try{o=fillTokens(o,i._fillData)}catch(e){if(e instanceof TokensFillError)return void 0!==n._warn&&!0===n._warn&&console.warn(e),n._fillError||n._error;throw e}else o=fillTokens(o,i)}i=token2postfix(o),o=null;if(null===n||void 0===n._calcError&&void 0===n._error)o=evalPostfix(i);else try{o=evalPostfix(i)}catch(e){if(e instanceof CalculatorError)return void 0!==n._warn&&!0===n._warn&&console.warn(e),void 0!==n._calcError?n._calcError:n._error;throw e}return o=null!==a.fmt?format(o,a.fmt):null!==o?o.toFixed():null}exports.calc=calc,exports.fmt=fmt,exports.version=version;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var BigNumber=require("bignumber.js");function _interopDefaultLegacy(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var BigNumber__default=_interopDefaultLegacy(BigNumber);function _typeof(e){return(_typeof="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 _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function _createClass(e,t,r){return t&&_defineProperties(e.prototype,t),r&&_defineProperties(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&_setPrototypeOf(e,t)}function _getPrototypeOf(e){return(_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function _setPrototypeOf(e,t){return(_setPrototypeOf=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}function _construct(e,t,r){return(_construct=_isNativeReflectConstruct()?Reflect.construct:function(e,t,r){var a=[null];a.push.apply(a,t);t=new(Function.bind.apply(e,a));return r&&_setPrototypeOf(t,r.prototype),t}).apply(null,arguments)}function _isNativeFunction(e){return-1!==Function.toString.call(e).indexOf("[native code]")}function _wrapNativeSuper(e){var r="function"==typeof Map?new Map:void 0;return(_wrapNativeSuper=function(e){if(null===e||!_isNativeFunction(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==r){if(r.has(e))return r.get(e);r.set(e,t)}function t(){return _construct(e,arguments,_getPrototypeOf(this).constructor)}return t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),_setPrototypeOf(t,e)})(e)}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _possibleConstructorReturn(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(e)}function _createSuper(r){var a=_isNativeReflectConstruct();return function(){var e,t=_getPrototypeOf(r);return _possibleConstructorReturn(this,a?(e=_getPrototypeOf(this).constructor,Reflect.construct(t,arguments,e)):t.apply(this,arguments))}}function _toConsumableArray(e){return _arrayWithoutHoles(e)||_iterableToArray(e)||_unsupportedIterableToArray(e)||_nonIterableSpread()}function _arrayWithoutHoles(e){if(Array.isArray(e))return _arrayLikeToArray(e)}function _iterableToArray(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Map"===(r="Object"===r&&e.constructor?e.constructor.name:r)||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(e,t):void 0}}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,a=new Array(t);r<t;r++)a[r]=e[r];return a}function _nonIterableSpread(){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 isOperator(e){return-1<"+-*/%()".indexOf(e)}function getPrioraty(e){switch(e){case"+":case"-":return 1;case"*":case"/":case"%":return 2;default:return 0}}function prioraty(e,t){return getPrioraty(e)<=getPrioraty(t)}function isObj(e){return"[object Object]"===Object.prototype.toString.call(e)&&!Array.isArray(e)}function notUndefined(e){return void 0!==e}function anyNotUndefined(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return t.some(function(e){return void 0!==e})}function notNull(e){return null!==e}function isStrNumber(e){return"string"==typeof e&&!!/^[+-]?\d+\.?\d*$/.test(e)}var CalculatorError=function(){_inherits(a,_wrapNativeSuper(Error));var r=_createSuper(a);function a(e){var t;return _classCallCheck(this,a),(t=r.call(this,e)).name="CalculatorError",t.message=e,t}return _createClass(a)}(),TokensFillError=function(){_inherits(a,_wrapNativeSuper(Error));var r=_createSuper(a);function a(e){var t;return _classCallCheck(this,a),(t=r.call(this,e)).name="TokensFillError",t.message=e,t}return _createClass(a)}();function parseArgs(e){var t={expr:"",fmt:null,data:null},r="",a=e[0];if(1===e.length)"string"==typeof a?r=a:"number"==typeof a?r=a.toString():Array.isArray(a)&&(r=a[0]);else if(1<e.length){a=e[e.length-1];if(!isObj(a)&&!Array.isArray(a))throw new Error("参数错误, 暂不支持的参数");if("string"==typeof(r=e[0])){if(""===r.trim())throw new TokensFillError("参数不可为空字符串")}else if("number"==typeof r)r=r.toString();else if(void 0===r||Number.isNaN(r))throw new TokensFillError("非法参数:".concat(r));t.data=a}e=r.split("|");return 1===e.length?t.expr=e[0]:(t.expr=e[0],""!==(a=e[1]).trim()&&(t.fmt=a)),null!==t.data&&null===t.fmt&&t.data._fmt&&(t.fmt=t.data._fmt),t}function format(e,t){var r="",a=(r=BigNumber__default.default.isBigNumber(e)?e.toFixed():"string"!=typeof e?e.toString():e,null),e=null,o=null,n=t.match(/(<=|>=|=)\s*(\d+)/);if(n&&(e=n[1],a=Number(n[2])),t.includes(",")&&(o=!0),null!==a){var n=r.split("."),t=n[0],i=1===n.length?"":n[1],s=i.length;switch(e){case"<=":i=s<=a?i:i.slice(0,a);break;case"=":s<a?i+="0".repeat(a-s):a<s&&(i=i.slice(0,a));break;case">=":i=a<=s?i:i+"0".repeat(a-s)}r=""===i?t:"".concat(t,".").concat(i)}return r=null!==o?1<(n=r.split(".")).length?((e=n[0]).includes("-")?n[0]=e[0]+e.slice(1).replace(/(?=(?!^)(?:\d{3})+$)/g,","):n[0]=e.replace(/(?=(?!^)(?:\d{3})+$)/g,","),n.join(".")):(t=n[0]).includes("-")?t[0]+t.slice(1).replace(/(?=(?!^)(?:\d{3})+$)/g,","):t.replace(/(?=(?!^)(?:\d{3})+$)/g,","):r}function tokenizer(e){for(var t=[],r=0,a=null,o=e.length;r<o;)if(a=e[r],/\s/.test(a))r++;else if("+-".includes(a)){var n=t[t.length-1];if(0===t.length||"+-".includes(n)||"("===n){for(var i=a,a=e[++r];/[a-zA-Z\d._]/.test(a);)i+=a,a=e[++r];t.push(i)}else t.push(a),r++}else if("*/%()".includes(a))t.push(a),r++;else if(/[\w_.\[\]"']/.test(a)){for(var s="";/[\w_.\[\]"']/.test(a)&&(s+=a,!(++r>=o));)a=e[r];t.push(s)}else if(/\d/.test(a)){for(var c="";/[\d.]/.test(a)&&(c+=a,!(++r>=o));)a=e[r];t.push(c)}return t}var commonjsGlobal="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},isArray$3=Array.isArray,isArray_1=isArray$3,freeGlobal$1="object"==_typeof(commonjsGlobal)&&commonjsGlobal&&commonjsGlobal.Object===Object&&commonjsGlobal,_freeGlobal=freeGlobal$1,freeGlobal=freeGlobal$1,freeSelf="object"==("undefined"==typeof self?"undefined":_typeof(self))&&self&&self.Object===Object&&self,root$3=freeGlobal||freeSelf||Function("return this")(),_root=root$3,root$2=_root,_Symbol2=_root.Symbol,_Symbol$3=_Symbol2,_Symbol$2=_Symbol$3,objectProto$4=Object.prototype,hasOwnProperty$3=objectProto$4.hasOwnProperty,nativeObjectToString$1=objectProto$4.toString,symToStringTag$1=_Symbol$2?_Symbol$2.toStringTag:void 0;function getRawTag$1(e){var t=hasOwnProperty$3.call(e,symToStringTag$1),r=e[symToStringTag$1];try{var a=!(e[symToStringTag$1]=void 0)}catch(e){}var o=nativeObjectToString$1.call(e);return a&&(t?e[symToStringTag$1]=r:delete e[symToStringTag$1]),o}var _getRawTag=getRawTag$1,objectProto$3=Object.prototype,nativeObjectToString=objectProto$3.toString;function objectToString$1(e){return nativeObjectToString.call(e)}var _objectToString=objectToString$1,_Symbol$1=_Symbol$3,getRawTag=_getRawTag,objectToString=objectToString$1,nullTag="[object Null]",undefinedTag="[object Undefined]",symToStringTag=_Symbol$3?_Symbol$3.toStringTag:void 0;function baseGetTag$2(e){return null==e?void 0===e?undefinedTag:nullTag:(symToStringTag&&symToStringTag in Object(e)?getRawTag:objectToString)(e)}var _baseGetTag=baseGetTag$2;function isObjectLike$1(e){return null!=e&&"object"==_typeof(e)}var isObjectLike_1=isObjectLike$1,baseGetTag$1=baseGetTag$2,isObjectLike=isObjectLike$1,symbolTag="[object Symbol]";function isSymbol$3(e){return"symbol"==_typeof(e)||isObjectLike(e)&&baseGetTag$1(e)==symbolTag}var isSymbol_1=isSymbol$3,isArray$2=isArray_1,isSymbol$2=isSymbol_1,reIsDeepProp=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,reIsPlainProp=/^\w*$/;function isKey$1(e,t){if(isArray$2(e))return!1;var r=_typeof(e);return!("number"!=r&&"symbol"!=r&&"boolean"!=r&&null!=e&&!isSymbol$2(e))||(reIsPlainProp.test(e)||!reIsDeepProp.test(e)||null!=t&&e in Object(t))}var _isKey=isKey$1;function isObject$2(e){var t=_typeof(e);return null!=e&&("object"==t||"function"==t)}var isObject_1=isObject$2,baseGetTag=baseGetTag$2,isObject$1=isObject_1,asyncTag="[object AsyncFunction]",funcTag="[object Function]",genTag="[object GeneratorFunction]",proxyTag="[object Proxy]";function isFunction$1(e){if(!isObject$1(e))return!1;e=baseGetTag(e);return e==funcTag||e==genTag||e==asyncTag||e==proxyTag}var isFunction_1=isFunction$1,root$1=_root,coreJsData$1=_root["__core-js_shared__"],_coreJsData=coreJsData$1,coreJsData=coreJsData$1,maskSrcKey=function(){var e=/[^.]+$/.exec(coreJsData&&coreJsData.keys&&coreJsData.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function isMasked$1(e){return!!maskSrcKey&&maskSrcKey in e}var _isMasked=isMasked$1,funcProto$1=Function.prototype,funcToString$1=funcProto$1.toString;function toSource$1(e){if(null!=e){try{return funcToString$1.call(e)}catch(e){}try{return e+""}catch(e){}}return""}var _toSource=toSource$1,isFunction=isFunction_1,isMasked=_isMasked,isObject=isObject_1,toSource=toSource$1,reRegExpChar=/[\\^$.*+?()[\]{}|]/g,reIsHostCtor=/^\[object .+?Constructor\]$/,funcProto=Function.prototype,objectProto$2=Object.prototype,funcToString=funcProto.toString,hasOwnProperty$2=objectProto$2.hasOwnProperty,reIsNative=RegExp("^"+funcToString.call(hasOwnProperty$2).replace(reRegExpChar,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function baseIsNative$1(e){return!(!isObject(e)||isMasked(e))&&(isFunction(e)?reIsNative:reIsHostCtor).test(toSource(e))}var _baseIsNative=baseIsNative$1;function getValue$1(e,t){return null==e?void 0:e[t]}var _getValue=getValue$1,baseIsNative=baseIsNative$1,getValue=getValue$1;function getNative$2(e,t){e=getValue(e,t);return baseIsNative(e)?e:void 0}var _getNative=getNative$2,getNative$1=_getNative,nativeCreate$4=_getNative(Object,"create"),_nativeCreate=nativeCreate$4,nativeCreate$3=_nativeCreate;function hashClear$1(){this.__data__=nativeCreate$3?nativeCreate$3(null):{},this.size=0}var _hashClear=hashClear$1;function hashDelete$1(e){e=this.has(e)&&delete this.__data__[e];return this.size-=e?1:0,e}var _hashDelete=hashDelete$1,nativeCreate$2=_nativeCreate,HASH_UNDEFINED$1="__lodash_hash_undefined__",objectProto$1=Object.prototype,hasOwnProperty$1=objectProto$1.hasOwnProperty;function hashGet$1(e){var t,r=this.__data__;return nativeCreate$2?(t=r[e])===HASH_UNDEFINED$1?void 0:t:hasOwnProperty$1.call(r,e)?r[e]:void 0}var _hashGet=hashGet$1,nativeCreate$1=_nativeCreate,objectProto=Object.prototype,hasOwnProperty=objectProto.hasOwnProperty;function hashHas$1(e){var t=this.__data__;return nativeCreate$1?void 0!==t[e]:hasOwnProperty.call(t,e)}var _hashHas=hashHas$1,nativeCreate=_nativeCreate,HASH_UNDEFINED="__lodash_hash_undefined__";function hashSet$1(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=nativeCreate&&void 0===t?HASH_UNDEFINED:t,this}var _hashSet=hashSet$1,hashClear=_hashClear,hashDelete=_hashDelete,hashGet=_hashGet,hashHas=hashHas$1,hashSet=hashSet$1;function Hash$1(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var a=e[t];this.set(a[0],a[1])}}Hash$1.prototype.clear=hashClear,Hash$1.prototype.delete=hashDelete,Hash$1.prototype.get=hashGet,Hash$1.prototype.has=hashHas,Hash$1.prototype.set=hashSet;var _Hash=Hash$1;function listCacheClear$1(){this.__data__=[],this.size=0}var _listCacheClear=listCacheClear$1;function eq$1(e,t){return e===t||e!=e&&t!=t}var eq_1=eq$1,eq=eq$1;function assocIndexOf$4(e,t){for(var r=e.length;r--;)if(eq(e[r][0],t))return r;return-1}var _assocIndexOf=assocIndexOf$4,assocIndexOf$3=_assocIndexOf,arrayProto=Array.prototype,splice=arrayProto.splice;function listCacheDelete$1(e){var t=this.__data__,e=assocIndexOf$3(t,e);return!(e<0)&&(e==t.length-1?t.pop():splice.call(t,e,1),--this.size,!0)}var _listCacheDelete=listCacheDelete$1,assocIndexOf$2=_assocIndexOf;function listCacheGet$1(e){var t=this.__data__,e=assocIndexOf$2(t,e);return e<0?void 0:t[e][1]}var _listCacheGet=listCacheGet$1,assocIndexOf$1=_assocIndexOf;function listCacheHas$1(e){return-1<assocIndexOf$1(this.__data__,e)}var _listCacheHas=listCacheHas$1,assocIndexOf=_assocIndexOf;function listCacheSet$1(e,t){var r=this.__data__,a=assocIndexOf(r,e);return a<0?(++this.size,r.push([e,t])):r[a][1]=t,this}var _listCacheSet=listCacheSet$1,listCacheClear=_listCacheClear,listCacheDelete=listCacheDelete$1,listCacheGet=listCacheGet$1,listCacheHas=listCacheHas$1,listCacheSet=listCacheSet$1;function ListCache$1(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var a=e[t];this.set(a[0],a[1])}}ListCache$1.prototype.clear=listCacheClear,ListCache$1.prototype.delete=listCacheDelete,ListCache$1.prototype.get=listCacheGet,ListCache$1.prototype.has=listCacheHas,ListCache$1.prototype.set=listCacheSet;var _ListCache=ListCache$1,getNative=_getNative,root=_root,Map$2=_getNative(_root,"Map"),_Map=Map$2,Hash=_Hash,ListCache=_ListCache,Map$1=Map$2;function mapCacheClear$1(){this.size=0,this.__data__={hash:new Hash,map:new(Map$1||ListCache),string:new Hash}}var _mapCacheClear=mapCacheClear$1;function isKeyable$1(e){var t=_typeof(e);return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e}var _isKeyable=isKeyable$1,isKeyable=isKeyable$1;function getMapData$4(e,t){e=e.__data__;return isKeyable(t)?e["string"==typeof t?"string":"hash"]:e.map}var _getMapData=getMapData$4,getMapData$3=getMapData$4;function mapCacheDelete$1(e){e=getMapData$3(this,e).delete(e);return this.size-=e?1:0,e}var _mapCacheDelete=mapCacheDelete$1,getMapData$2=getMapData$4;function mapCacheGet$1(e){return getMapData$2(this,e).get(e)}var _mapCacheGet=mapCacheGet$1,getMapData$1=getMapData$4;function mapCacheHas$1(e){return getMapData$1(this,e).has(e)}var _mapCacheHas=mapCacheHas$1,getMapData=getMapData$4;function mapCacheSet$1(e,t){var r=getMapData(this,e),a=r.size;return r.set(e,t),this.size+=r.size==a?0:1,this}var _mapCacheSet=mapCacheSet$1,mapCacheClear=mapCacheClear$1,mapCacheDelete=mapCacheDelete$1,mapCacheGet=mapCacheGet$1,mapCacheHas=mapCacheHas$1,mapCacheSet=mapCacheSet$1;function MapCache$1(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var a=e[t];this.set(a[0],a[1])}}MapCache$1.prototype.clear=mapCacheClear,MapCache$1.prototype.delete=mapCacheDelete,MapCache$1.prototype.get=mapCacheGet,MapCache$1.prototype.has=mapCacheHas,MapCache$1.prototype.set=mapCacheSet;var _MapCache=MapCache$1,MapCache=MapCache$1,FUNC_ERROR_TEXT="Expected a function";function memoize$1(a,o){if("function"!=typeof a||null!=o&&"function"!=typeof o)throw new TypeError(FUNC_ERROR_TEXT);function n(){var e=arguments,t=o?o.apply(this,e):e[0],r=n.cache;return r.has(t)?r.get(t):(e=a.apply(this,e),n.cache=r.set(t,e)||r,e)}return n.cache=new(memoize$1.Cache||MapCache),n}memoize$1.Cache=MapCache;var memoize_1=memoize$1,memoize=memoize$1,MAX_MEMOIZE_SIZE=500;function memoizeCapped$1(e){var e=memoize(e,function(e){return t.size===MAX_MEMOIZE_SIZE&&t.clear(),e}),t=e.cache;return e}var _memoizeCapped=memoizeCapped$1,memoizeCapped=memoizeCapped$1,rePropName=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,reEscapeChar=/\\(\\)?/g,stringToPath$1=memoizeCapped$1(function(e){var o=[];return 46===e.charCodeAt(0)&&o.push(""),e.replace(rePropName,function(e,t,r,a){o.push(r?a.replace(reEscapeChar,"$1"):t||e)}),o}),_stringToPath=stringToPath$1;function arrayMap$1(e,t){for(var r=-1,a=null==e?0:e.length,o=Array(a);++r<a;)o[r]=t(e[r],r,e);return o}var _arrayMap=arrayMap$1,_Symbol=_Symbol$3,arrayMap=arrayMap$1,isArray$1=isArray_1,isSymbol$1=isSymbol_1,INFINITY$1=1/0,symbolProto=_Symbol$3?_Symbol$3.prototype:void 0,symbolToString=symbolProto?symbolProto.toString:void 0;function baseToString$1(e){if("string"==typeof e)return e;if(isArray$1(e))return arrayMap(e,baseToString$1)+"";if(isSymbol$1(e))return symbolToString?symbolToString.call(e):"";var t=e+"";return"0"==t&&1/e==-INFINITY$1?"-0":t}var _baseToString=baseToString$1,baseToString=baseToString$1;function toString$1(e){return null==e?"":baseToString(e)}var toString_1=toString$1,isArray=isArray_1,isKey=_isKey,stringToPath=_stringToPath,toString=toString$1;function castPath$1(e,t){return isArray(e)?e:isKey(e,t)?[e]:stringToPath(toString(e))}var _castPath=castPath$1,isSymbol=isSymbol_1,INFINITY=1/0;function toKey$1(e){if("string"==typeof e||isSymbol(e))return e;var t=e+"";return"0"==t&&1/e==-INFINITY?"-0":t}var _toKey=toKey$1,castPath=castPath$1,toKey=toKey$1;function baseGet$1(e,t){for(var r=0,a=(t=castPath(t,e)).length;null!=e&&r<a;)e=e[toKey(t[r++])];return r&&r==a?e:void 0}var _baseGet=baseGet$1,baseGet=baseGet$1;function get(e,t,r){e=null==e?void 0:baseGet(e,t);return void 0===e?r:e}var get_1=get;function fillTokens(e,t){var r=[];if(!notNull(t))throw new TokensFillError("错误的填充数据:",t);Array.isArray(t)?r=t:r.push(t);for(var a=[],o=0;o<e.length;o++){var n=e[o];if(/^[a-zA-z_][\w\[\]"'_.]*$/.test(n)){if("undefined"===n||"NaN"===n)throw new TokensFillError("key不应该为:".concat(n));for(var i=null,s=0;s<r.length;s++){var c=r[s],c=get_1(c,n);if(void 0!==c){i=c;break}}if(null===i)throw new TokensFillError("token填充失败,请确认".concat(n,"存在"));if("string"==typeof i){if(""===i.trim())throw new TokensFillError("token填充失败,".concat(n,"值不可为空字符"));if(!isStrNumber(i))throw new TokensFillError("token填充失败,".concat(n,"值:").concat(i,"为非法数字"))}i="string"!=typeof i?i.toString():i,a.push(i)}else a.push(n)}return a}function fmt(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];var a=parseArgs(t),o=tokenizer(a.expr),n=null;if(!0===get_1(a,"data._debug")&&(console.warn("======a-calc调试模式======"),console.warn(a),console.warn(o)),""===a.expr.trim()&&notNull(a.data)&&notUndefined(a.data._error))return a.data._error;if(2<o.length)throw new Error("fmt并非用于计算, 不能传入多个标识:".concat(a.expr));if(1!==o.length)throw new Error("fmt接收了一个无法被解析的标识");if(null!==a.data){var i=arg.data,s=[];if(Array.isArray(i)?s=i:(s.push(n=i),notUndefined(c=get_1(n,"_fillData"))&&(Array.isArray(c)?s=[].concat(_toConsumableArray(s),_toConsumableArray(c)):s.push(c))),anyNotUndefined(i._fillError,i._error))try{o=fillTokens(o,s)}catch(e){if(e instanceof TokensFillError)return void 0!==n._warn&&!0===n._warn&&console.warn(e),n._fillError||n._error;throw e}else o=fillTokens(o,s)}if(null===a.fmt)throw"表达式没有格式化部分";var c=o[0];if(isStrNumber(c))return format(o[0],a.fmt);throw new TokensFillError("待格式化对象: ".concat(c," 不是数字"))}var version="0.0.60";function token2postfix(e){for(var t=[],r=[],a=e;0<a.length;){var o=a.shift();if(isOperator(o))if("("===o)t.push(o);else if(")"===o){for(var n=t.pop();"("!==n&&0<t.length;)r.push(n),n=t.pop();if("("!==n)throw"error: unmatched ()"}else{for(;prioraty(o,t[t.length-1])&&0<t.length;)r.push(t.pop());t.push(o)}else r.push(o)}if(0<t.length){if(")"===t[t.length-1]||"("===t[t.length-1])throw"error: unmatched ()";for(;0<t.length;)r.push(t.pop())}return r}function evalPostfix(e){for(var t=[];0<e.length;){var r=e.shift();if(isOperator(r)){if(t.length<2)throw new CalculatorError("错误的栈长度, 可能是无法计算的表达式");var a=t.pop(),o=t.pop();if("string"==typeof a&&!BigNumber__default.default.isBigNumber(a)){if(!isStrNumber(a))throw new CalculatorError("".concat(a,"不是一个合法的数字"));a=new BigNumber__default.default(a)}if("string"==typeof o&&!BigNumber__default.default.isBigNumber(o)){if(!isStrNumber(o))throw new CalculatorError("".concat(o,"不是一个合法的数字"));o=new BigNumber__default.default(o)}switch(r){case"+":t.push(o.plus(a));break;case"-":t.push(o.minus(a));break;case"*":t.push(o.times(a));break;case"/":t.push(o.div(a));break;case"%":t.push(o.mod(a))}}else t.push(r)}if(1!==t.length)throw"unvalid expression";return t[0]}function calc(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];var a=parseArgs(t),o=tokenizer(a.expr),n=null;if(!0===get_1(a,"data._debug")&&(console.warn("======a-calc调试模式======"),console.warn(a),console.warn(o)),null!==a.data){var i=a.data,s=[];if(Array.isArray(i)?s=i:(s.push(n=i),notUndefined(c=get_1(n,"_fillData"))&&(Array.isArray(c)?s=[].concat(_toConsumableArray(s),_toConsumableArray(c)):s.push(c))),anyNotUndefined(i._fillError,i._error))try{o=fillTokens(o,s)}catch(e){if(e instanceof TokensFillError)return void 0!==n._warn&&!0===n._warn&&console.warn(e),n._fillError||n._error;throw e}else o=fillTokens(o,s)}var c=token2postfix(o),i=null;if(notNull(n)&&anyNotUndefined(n._calcError,n._error))try{i=evalPostfix(c)}catch(e){if(e instanceof CalculatorError)return void 0!==n._warn&&!0===n._warn&&console.warn(e),void 0!==n._calcError?n._calcError:n._error;throw e}else i=evalPostfix(c);return i=notNull(a.fmt)?format(i,a.fmt):null!==i?i.toFixed():null}exports.calc=calc,exports.fmt=fmt,exports.version=version;
package/es/index.js CHANGED
@@ -1 +1 @@
1
- import BigNumber from"bignumber.js";function isOperator(e){return-1<"+-*/%()".indexOf(e)}function getPrioraty(e){switch(e){case"+":case"-":return 1;case"*":case"/":case"%":return 2;default:return 0}}function prioraty(e,t){return getPrioraty(e)<=getPrioraty(t)}function isObj(e){return"[object Object]"===Object.prototype.toString.call(e)&&!Array.isArray(e)}function anyNoUndefined(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return t.some(function(e){return void 0!==e})}function isStrNumber(e){return"string"==typeof e&&!!/^[+-]?\d+\.?\d*$/.test(e)}function _typeof(e){return(_typeof="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 _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function _createClass(e,t,r){return t&&_defineProperties(e.prototype,t),r&&_defineProperties(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&_setPrototypeOf(e,t)}function _getPrototypeOf(e){return(_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function _setPrototypeOf(e,t){return(_setPrototypeOf=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}function _construct(e,t,r){return(_construct=_isNativeReflectConstruct()?Reflect.construct:function(e,t,r){var a=[null];a.push.apply(a,t);t=new(Function.bind.apply(e,a));return r&&_setPrototypeOf(t,r.prototype),t}).apply(null,arguments)}function _isNativeFunction(e){return-1!==Function.toString.call(e).indexOf("[native code]")}function _wrapNativeSuper(e){var r="function"==typeof Map?new Map:void 0;return(_wrapNativeSuper=function(e){if(null===e||!_isNativeFunction(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==r){if(r.has(e))return r.get(e);r.set(e,t)}function t(){return _construct(e,arguments,_getPrototypeOf(this).constructor)}return t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),_setPrototypeOf(t,e)})(e)}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _possibleConstructorReturn(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(e)}function _createSuper(r){var a=_isNativeReflectConstruct();return function(){var e,t=_getPrototypeOf(r);return _possibleConstructorReturn(this,a?(e=_getPrototypeOf(this).constructor,Reflect.construct(t,arguments,e)):t.apply(this,arguments))}}var CalculatorError=function(){_inherits(a,_wrapNativeSuper(Error));var r=_createSuper(a);function a(e){var t;return _classCallCheck(this,a),(t=r.call(this,e)).name="CalculatorError",t.message=e,t}return _createClass(a)}(),TokensFillError=function(){_inherits(a,_wrapNativeSuper(Error));var r=_createSuper(a);function a(e){var t;return _classCallCheck(this,a),(t=r.call(this,e)).name="TokensFillError",t.message=e,t}return _createClass(a)}();function parseArgs(e){var t={expr:"",fmt:null,data:null},r="",a=e[0];if(1===e.length)"string"==typeof a?r=a:"number"==typeof a?r=a.toString():Array.isArray(a)&&(r=a[0]);else if(1<e.length){a=e[e.length-1];if(!isObj(a)&&!Array.isArray(a))throw new Error("参数错误, 暂不支持的参数");if("string"==typeof(r=e[0])){if(""===r.trim())throw new TokensFillError("参数不可为空字符串")}else if("number"==typeof r)r=r.toString();else if(void 0===r||Number.isNaN(r))throw new TokensFillError("非法参数:".concat(r));t.data=a}e=r.split("|");return 1===e.length?t.expr=e[0]:(t.expr=e[0],""!==(a=e[1]).trim()&&(t.fmt=a)),null!==t.data&&null===t.fmt&&t.data._fmt&&(t.fmt=t.data._fmt),t}function format(e,t){var r="",a=(r=BigNumber.isBigNumber(e)?e.toFixed():"string"!=typeof e?e.toString():e,null),e=null,o=null,n=t.match(/(<=|>=|=)\s*(\d+)/);if(n&&(e=n[1],a=Number(n[2])),t.includes(",")&&(o=!0),null!==a){var n=r.split("."),t=n[0],i=1===n.length?"":n[1],s=i.length;switch(e){case"<=":i=s<=a?i:i.slice(0,a);break;case"=":s<a?i+="0".repeat(a-s):a<s&&(i=i.slice(0,a));break;case">=":i=a<=s?i:i+"0".repeat(a-s)}r=""===i?t:"".concat(t,".").concat(i)}return r=null!==o?1<(n=r.split(".")).length?((e=n[0]).includes("-")?n[0]=e[0]+e.slice(1).replace(/(?=(?!^)(?:\d{3})+$)/g,","):n[0]=e.replace(/(?=(?!^)(?:\d{3})+$)/g,","),n.join(".")):(t=n[0]).includes("-")?t[0]+t.slice(1).replace(/(?=(?!^)(?:\d{3})+$)/g,","):t.replace(/(?=(?!^)(?:\d{3})+$)/g,","):r}function tokenizer(e){for(var t=[],r=0,a=null,o=e.length;r<o;)if(a=e[r],/\s/.test(a))r++;else if("+-".includes(a)){var n=t[t.length-1];if(0===t.length||"+-".includes(n)||"("===n){for(var i=a,a=e[++r];/[a-zA-Z\d._]/.test(a);)i+=a,a=e[++r];t.push(i)}else t.push(a),r++}else if("*/%()".includes(a))t.push(a),r++;else if(/[\w_.\[\]"']/.test(a)){for(var s="";/[\w_.\[\]"']/.test(a)&&(s+=a,!(++r>=o));)a=e[r];t.push(s)}else if(/\d/.test(a)){for(var c="";/[\d.]/.test(a)&&(c+=a,!(++r>=o));)a=e[r];t.push(c)}return t}var commonjsGlobal="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},isArray$3=Array.isArray,isArray_1=isArray$3,freeGlobal$1="object"==_typeof(commonjsGlobal)&&commonjsGlobal&&commonjsGlobal.Object===Object&&commonjsGlobal,_freeGlobal=freeGlobal$1,freeGlobal=freeGlobal$1,freeSelf="object"==("undefined"==typeof self?"undefined":_typeof(self))&&self&&self.Object===Object&&self,root$3=freeGlobal||freeSelf||Function("return this")(),_root=root$3,root$2=_root,_Symbol2=_root.Symbol,_Symbol$3=_Symbol2,_Symbol$2=_Symbol$3,objectProto$4=Object.prototype,hasOwnProperty$3=objectProto$4.hasOwnProperty,nativeObjectToString$1=objectProto$4.toString,symToStringTag$1=_Symbol$2?_Symbol$2.toStringTag:void 0;function getRawTag$1(e){var t=hasOwnProperty$3.call(e,symToStringTag$1),r=e[symToStringTag$1];try{var a=!(e[symToStringTag$1]=void 0)}catch(e){}var o=nativeObjectToString$1.call(e);return a&&(t?e[symToStringTag$1]=r:delete e[symToStringTag$1]),o}var _getRawTag=getRawTag$1,objectProto$3=Object.prototype,nativeObjectToString=objectProto$3.toString;function objectToString$1(e){return nativeObjectToString.call(e)}var _objectToString=objectToString$1,_Symbol$1=_Symbol$3,getRawTag=_getRawTag,objectToString=objectToString$1,nullTag="[object Null]",undefinedTag="[object Undefined]",symToStringTag=_Symbol$3?_Symbol$3.toStringTag:void 0;function baseGetTag$2(e){return null==e?void 0===e?undefinedTag:nullTag:(symToStringTag&&symToStringTag in Object(e)?getRawTag:objectToString)(e)}var _baseGetTag=baseGetTag$2;function isObjectLike$1(e){return null!=e&&"object"==_typeof(e)}var isObjectLike_1=isObjectLike$1,baseGetTag$1=baseGetTag$2,isObjectLike=isObjectLike$1,symbolTag="[object Symbol]";function isSymbol$3(e){return"symbol"==_typeof(e)||isObjectLike(e)&&baseGetTag$1(e)==symbolTag}var isSymbol_1=isSymbol$3,isArray$2=isArray_1,isSymbol$2=isSymbol_1,reIsDeepProp=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,reIsPlainProp=/^\w*$/;function isKey$1(e,t){if(isArray$2(e))return!1;var r=_typeof(e);return!("number"!=r&&"symbol"!=r&&"boolean"!=r&&null!=e&&!isSymbol$2(e))||(reIsPlainProp.test(e)||!reIsDeepProp.test(e)||null!=t&&e in Object(t))}var _isKey=isKey$1;function isObject$2(e){var t=_typeof(e);return null!=e&&("object"==t||"function"==t)}var isObject_1=isObject$2,baseGetTag=baseGetTag$2,isObject$1=isObject_1,asyncTag="[object AsyncFunction]",funcTag="[object Function]",genTag="[object GeneratorFunction]",proxyTag="[object Proxy]";function isFunction$1(e){if(!isObject$1(e))return!1;e=baseGetTag(e);return e==funcTag||e==genTag||e==asyncTag||e==proxyTag}var isFunction_1=isFunction$1,root$1=_root,coreJsData$1=_root["__core-js_shared__"],_coreJsData=coreJsData$1,coreJsData=coreJsData$1,maskSrcKey=function(){var e=/[^.]+$/.exec(coreJsData&&coreJsData.keys&&coreJsData.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function isMasked$1(e){return!!maskSrcKey&&maskSrcKey in e}var _isMasked=isMasked$1,funcProto$1=Function.prototype,funcToString$1=funcProto$1.toString;function toSource$1(e){if(null!=e){try{return funcToString$1.call(e)}catch(e){}try{return e+""}catch(e){}}return""}var _toSource=toSource$1,isFunction=isFunction_1,isMasked=_isMasked,isObject=isObject_1,toSource=toSource$1,reRegExpChar=/[\\^$.*+?()[\]{}|]/g,reIsHostCtor=/^\[object .+?Constructor\]$/,funcProto=Function.prototype,objectProto$2=Object.prototype,funcToString=funcProto.toString,hasOwnProperty$2=objectProto$2.hasOwnProperty,reIsNative=RegExp("^"+funcToString.call(hasOwnProperty$2).replace(reRegExpChar,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function baseIsNative$1(e){return!(!isObject(e)||isMasked(e))&&(isFunction(e)?reIsNative:reIsHostCtor).test(toSource(e))}var _baseIsNative=baseIsNative$1;function getValue$1(e,t){return null==e?void 0:e[t]}var _getValue=getValue$1,baseIsNative=baseIsNative$1,getValue=getValue$1;function getNative$2(e,t){e=getValue(e,t);return baseIsNative(e)?e:void 0}var _getNative=getNative$2,getNative$1=_getNative,nativeCreate$4=_getNative(Object,"create"),_nativeCreate=nativeCreate$4,nativeCreate$3=_nativeCreate;function hashClear$1(){this.__data__=nativeCreate$3?nativeCreate$3(null):{},this.size=0}var _hashClear=hashClear$1;function hashDelete$1(e){e=this.has(e)&&delete this.__data__[e];return this.size-=e?1:0,e}var _hashDelete=hashDelete$1,nativeCreate$2=_nativeCreate,HASH_UNDEFINED$1="__lodash_hash_undefined__",objectProto$1=Object.prototype,hasOwnProperty$1=objectProto$1.hasOwnProperty;function hashGet$1(e){var t,r=this.__data__;return nativeCreate$2?(t=r[e])===HASH_UNDEFINED$1?void 0:t:hasOwnProperty$1.call(r,e)?r[e]:void 0}var _hashGet=hashGet$1,nativeCreate$1=_nativeCreate,objectProto=Object.prototype,hasOwnProperty=objectProto.hasOwnProperty;function hashHas$1(e){var t=this.__data__;return nativeCreate$1?void 0!==t[e]:hasOwnProperty.call(t,e)}var _hashHas=hashHas$1,nativeCreate=_nativeCreate,HASH_UNDEFINED="__lodash_hash_undefined__";function hashSet$1(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=nativeCreate&&void 0===t?HASH_UNDEFINED:t,this}var _hashSet=hashSet$1,hashClear=_hashClear,hashDelete=_hashDelete,hashGet=_hashGet,hashHas=hashHas$1,hashSet=hashSet$1;function Hash$1(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var a=e[t];this.set(a[0],a[1])}}Hash$1.prototype.clear=hashClear,Hash$1.prototype.delete=hashDelete,Hash$1.prototype.get=hashGet,Hash$1.prototype.has=hashHas,Hash$1.prototype.set=hashSet;var _Hash=Hash$1;function listCacheClear$1(){this.__data__=[],this.size=0}var _listCacheClear=listCacheClear$1;function eq$1(e,t){return e===t||e!=e&&t!=t}var eq_1=eq$1,eq=eq$1;function assocIndexOf$4(e,t){for(var r=e.length;r--;)if(eq(e[r][0],t))return r;return-1}var _assocIndexOf=assocIndexOf$4,assocIndexOf$3=_assocIndexOf,arrayProto=Array.prototype,splice=arrayProto.splice;function listCacheDelete$1(e){var t=this.__data__,e=assocIndexOf$3(t,e);return!(e<0)&&(e==t.length-1?t.pop():splice.call(t,e,1),--this.size,!0)}var _listCacheDelete=listCacheDelete$1,assocIndexOf$2=_assocIndexOf;function listCacheGet$1(e){var t=this.__data__,e=assocIndexOf$2(t,e);return e<0?void 0:t[e][1]}var _listCacheGet=listCacheGet$1,assocIndexOf$1=_assocIndexOf;function listCacheHas$1(e){return-1<assocIndexOf$1(this.__data__,e)}var _listCacheHas=listCacheHas$1,assocIndexOf=_assocIndexOf;function listCacheSet$1(e,t){var r=this.__data__,a=assocIndexOf(r,e);return a<0?(++this.size,r.push([e,t])):r[a][1]=t,this}var _listCacheSet=listCacheSet$1,listCacheClear=_listCacheClear,listCacheDelete=listCacheDelete$1,listCacheGet=listCacheGet$1,listCacheHas=listCacheHas$1,listCacheSet=listCacheSet$1;function ListCache$1(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var a=e[t];this.set(a[0],a[1])}}ListCache$1.prototype.clear=listCacheClear,ListCache$1.prototype.delete=listCacheDelete,ListCache$1.prototype.get=listCacheGet,ListCache$1.prototype.has=listCacheHas,ListCache$1.prototype.set=listCacheSet;var _ListCache=ListCache$1,getNative=_getNative,root=_root,Map$2=_getNative(_root,"Map"),_Map=Map$2,Hash=_Hash,ListCache=_ListCache,Map$1=Map$2;function mapCacheClear$1(){this.size=0,this.__data__={hash:new Hash,map:new(Map$1||ListCache),string:new Hash}}var _mapCacheClear=mapCacheClear$1;function isKeyable$1(e){var t=_typeof(e);return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e}var _isKeyable=isKeyable$1,isKeyable=isKeyable$1;function getMapData$4(e,t){e=e.__data__;return isKeyable(t)?e["string"==typeof t?"string":"hash"]:e.map}var _getMapData=getMapData$4,getMapData$3=getMapData$4;function mapCacheDelete$1(e){e=getMapData$3(this,e).delete(e);return this.size-=e?1:0,e}var _mapCacheDelete=mapCacheDelete$1,getMapData$2=getMapData$4;function mapCacheGet$1(e){return getMapData$2(this,e).get(e)}var _mapCacheGet=mapCacheGet$1,getMapData$1=getMapData$4;function mapCacheHas$1(e){return getMapData$1(this,e).has(e)}var _mapCacheHas=mapCacheHas$1,getMapData=getMapData$4;function mapCacheSet$1(e,t){var r=getMapData(this,e),a=r.size;return r.set(e,t),this.size+=r.size==a?0:1,this}var _mapCacheSet=mapCacheSet$1,mapCacheClear=mapCacheClear$1,mapCacheDelete=mapCacheDelete$1,mapCacheGet=mapCacheGet$1,mapCacheHas=mapCacheHas$1,mapCacheSet=mapCacheSet$1;function MapCache$1(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var a=e[t];this.set(a[0],a[1])}}MapCache$1.prototype.clear=mapCacheClear,MapCache$1.prototype.delete=mapCacheDelete,MapCache$1.prototype.get=mapCacheGet,MapCache$1.prototype.has=mapCacheHas,MapCache$1.prototype.set=mapCacheSet;var _MapCache=MapCache$1,MapCache=MapCache$1,FUNC_ERROR_TEXT="Expected a function";function memoize$1(a,o){if("function"!=typeof a||null!=o&&"function"!=typeof o)throw new TypeError(FUNC_ERROR_TEXT);function n(){var e=arguments,t=o?o.apply(this,e):e[0],r=n.cache;return r.has(t)?r.get(t):(e=a.apply(this,e),n.cache=r.set(t,e)||r,e)}return n.cache=new(memoize$1.Cache||MapCache),n}memoize$1.Cache=MapCache;var memoize_1=memoize$1,memoize=memoize$1,MAX_MEMOIZE_SIZE=500;function memoizeCapped$1(e){var e=memoize(e,function(e){return t.size===MAX_MEMOIZE_SIZE&&t.clear(),e}),t=e.cache;return e}var _memoizeCapped=memoizeCapped$1,memoizeCapped=memoizeCapped$1,rePropName=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,reEscapeChar=/\\(\\)?/g,stringToPath$1=memoizeCapped$1(function(e){var o=[];return 46===e.charCodeAt(0)&&o.push(""),e.replace(rePropName,function(e,t,r,a){o.push(r?a.replace(reEscapeChar,"$1"):t||e)}),o}),_stringToPath=stringToPath$1;function arrayMap$1(e,t){for(var r=-1,a=null==e?0:e.length,o=Array(a);++r<a;)o[r]=t(e[r],r,e);return o}var _arrayMap=arrayMap$1,_Symbol=_Symbol$3,arrayMap=arrayMap$1,isArray$1=isArray_1,isSymbol$1=isSymbol_1,INFINITY$1=1/0,symbolProto=_Symbol$3?_Symbol$3.prototype:void 0,symbolToString=symbolProto?symbolProto.toString:void 0;function baseToString$1(e){if("string"==typeof e)return e;if(isArray$1(e))return arrayMap(e,baseToString$1)+"";if(isSymbol$1(e))return symbolToString?symbolToString.call(e):"";var t=e+"";return"0"==t&&1/e==-INFINITY$1?"-0":t}var _baseToString=baseToString$1,baseToString=baseToString$1;function toString$1(e){return null==e?"":baseToString(e)}var toString_1=toString$1,isArray=isArray_1,isKey=_isKey,stringToPath=_stringToPath,toString=toString$1;function castPath$1(e,t){return isArray(e)?e:isKey(e,t)?[e]:stringToPath(toString(e))}var _castPath=castPath$1,isSymbol=isSymbol_1,INFINITY=1/0;function toKey$1(e){if("string"==typeof e||isSymbol(e))return e;var t=e+"";return"0"==t&&1/e==-INFINITY?"-0":t}var _toKey=toKey$1,castPath=castPath$1,toKey=toKey$1;function baseGet$1(e,t){for(var r=0,a=(t=castPath(t,e)).length;null!=e&&r<a;)e=e[toKey(t[r++])];return r&&r==a?e:void 0}var _baseGet=baseGet$1,baseGet=baseGet$1;function get(e,t,r){e=null==e?void 0:baseGet(e,t);return void 0===e?r:e}var get_1=get;function fillTokens(e,t){for(var r=t._fillData,a=(void 0===t._fillData&&(r=t),Array.isArray(r)||(r=[r]),[]),o=0;o<e.length;o++){var n=e[o];if(/^[a-zA-z_][\w\[\]"'_.]*$/.test(n)){if("undefined"===n||"NaN"===n)throw new TokensFillError("key不应该为:".concat(n));for(var i=null,s=0;s<r.length;s++){var c=r[s],c=get_1(c,n);if(void 0!==c){i=c;break}}if(null===i)throw new TokensFillError("token填充失败,请确认".concat(n,"存在"));if("string"==typeof i){if(""===i.trim())throw new TokensFillError("token填充失败,".concat(n,"值不可为空字符"));if(!isStrNumber(i))throw new TokensFillError("token填充失败,".concat(n,"值:").concat(i,"为非法数字"))}i="string"!=typeof i?i.toString():i,a.push(i)}else a.push(n)}return a}function fmt(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];var a=parseArgs(t),o=tokenizer(a.expr),n=null;if(!0===get_1(a,"data._debug")&&(console.warn("======a-calc调试模式======"),console.warn(a),console.warn(o)),""===a.expr.trim()&&null!==a.data&&void 0!==a.data._error)return a.data._error;if(2<o.length)throw new Error("fmt并非用于计算, 不能传入多个标识:".concat(a.expr));if(1!==o.length)throw new Error("fmt接收了一个无法被解析的标识");if(null!==a.data){var i=a.data;if(null!==(n=!Array.isArray(i)&&anyNoUndefined(i._fillData,i._error,i._fillError)?i:n)&&void 0!==i._fillData&&anyNoUndefined(n._fillError,n._error))try{o=fillTokens(o,i._fillData)}catch(e){if(e instanceof TokensFillError)return void 0!==n._warn&&!0===n._warn&&console.warn(e),n._fillError||n._error;throw e}else o=fillTokens(o,i)}if(null===a.fmt)throw"表达式没有格式化部分";n=o[0];if(isStrNumber(n))return format(o[0],a.fmt);throw new TokensFillError("待格式化对象: ".concat(n," 不是数字"))}var version="0.0.58";function token2postfix(e){for(var t=[],r=[],a=e;0<a.length;){var o=a.shift();if(isOperator(o))if("("===o)t.push(o);else if(")"===o){for(var n=t.pop();"("!==n&&0<t.length;)r.push(n),n=t.pop();if("("!==n)throw"error: unmatched ()"}else{for(;prioraty(o,t[t.length-1])&&0<t.length;)r.push(t.pop());t.push(o)}else r.push(o)}if(0<t.length){if(")"===t[t.length-1]||"("===t[t.length-1])throw"error: unmatched ()";for(;0<t.length;)r.push(t.pop())}return r}function evalPostfix(e){for(var t=[];0<e.length;){var r=e.shift();if(isOperator(r)){if(t.length<2)throw new CalculatorError("错误的栈长度, 可能是无法计算的表达式");var a=t.pop(),o=t.pop();if("string"==typeof a&&!BigNumber.isBigNumber(a)){if(!/^[+-]*[\d.]+$/.test(a))throw new CalculatorError("".concat(a,"不是一个合法的数字"));a=new BigNumber(a)}if("string"==typeof o&&!BigNumber.isBigNumber(o)){if(!/^[+-]*[\d.]+$/.test(o))throw new CalculatorError("".concat(o,"不是一个合法的数字"));o=new BigNumber(o)}switch(r){case"+":t.push(o.plus(a));break;case"-":t.push(o.minus(a));break;case"*":t.push(o.times(a));break;case"/":t.push(o.div(a));break;case"%":t.push(o.mod(a))}}else t.push(r)}if(1!==t.length)throw"unvalid expression";return t[0]}function calc(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];var a=parseArgs(t),o=tokenizer(a.expr),n=null;if(!0===get_1(a,"data._debug")&&(console.warn("======a-calc调试模式======"),console.warn(a),console.warn(o)),null!==a.data){var i=a.data;if(null!==(n=!Array.isArray(i)&&anyNoUndefined(i._fillData,i._error,i._fillError,i._calcError)?i:n)&&void 0!==i._fillData&&anyNoUndefined(n._fillError,n._error))try{o=fillTokens(o,i._fillData)}catch(e){if(e instanceof TokensFillError)return void 0!==n._warn&&!0===n._warn&&console.warn(e),n._fillError||n._error;throw e}else o=fillTokens(o,i)}i=token2postfix(o),o=null;if(null===n||void 0===n._calcError&&void 0===n._error)o=evalPostfix(i);else try{o=evalPostfix(i)}catch(e){if(e instanceof CalculatorError)return void 0!==n._warn&&!0===n._warn&&console.warn(e),void 0!==n._calcError?n._calcError:n._error;throw e}return o=null!==a.fmt?format(o,a.fmt):null!==o?o.toFixed():null}export{calc,fmt,version};
1
+ import BigNumber from"bignumber.js";function _typeof(e){return(_typeof="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 _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function _createClass(e,t,r){return t&&_defineProperties(e.prototype,t),r&&_defineProperties(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&_setPrototypeOf(e,t)}function _getPrototypeOf(e){return(_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function _setPrototypeOf(e,t){return(_setPrototypeOf=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}function _construct(e,t,r){return(_construct=_isNativeReflectConstruct()?Reflect.construct:function(e,t,r){var a=[null];a.push.apply(a,t);t=new(Function.bind.apply(e,a));return r&&_setPrototypeOf(t,r.prototype),t}).apply(null,arguments)}function _isNativeFunction(e){return-1!==Function.toString.call(e).indexOf("[native code]")}function _wrapNativeSuper(e){var r="function"==typeof Map?new Map:void 0;return(_wrapNativeSuper=function(e){if(null===e||!_isNativeFunction(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==r){if(r.has(e))return r.get(e);r.set(e,t)}function t(){return _construct(e,arguments,_getPrototypeOf(this).constructor)}return t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),_setPrototypeOf(t,e)})(e)}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _possibleConstructorReturn(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(e)}function _createSuper(r){var a=_isNativeReflectConstruct();return function(){var e,t=_getPrototypeOf(r);return _possibleConstructorReturn(this,a?(e=_getPrototypeOf(this).constructor,Reflect.construct(t,arguments,e)):t.apply(this,arguments))}}function _toConsumableArray(e){return _arrayWithoutHoles(e)||_iterableToArray(e)||_unsupportedIterableToArray(e)||_nonIterableSpread()}function _arrayWithoutHoles(e){if(Array.isArray(e))return _arrayLikeToArray(e)}function _iterableToArray(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Map"===(r="Object"===r&&e.constructor?e.constructor.name:r)||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(e,t):void 0}}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,a=new Array(t);r<t;r++)a[r]=e[r];return a}function _nonIterableSpread(){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 isOperator(e){return-1<"+-*/%()".indexOf(e)}function getPrioraty(e){switch(e){case"+":case"-":return 1;case"*":case"/":case"%":return 2;default:return 0}}function prioraty(e,t){return getPrioraty(e)<=getPrioraty(t)}function isObj(e){return"[object Object]"===Object.prototype.toString.call(e)&&!Array.isArray(e)}function notUndefined(e){return void 0!==e}function anyNotUndefined(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return t.some(function(e){return void 0!==e})}function notNull(e){return null!==e}function isStrNumber(e){return"string"==typeof e&&!!/^[+-]?\d+\.?\d*$/.test(e)}var CalculatorError=function(){_inherits(a,_wrapNativeSuper(Error));var r=_createSuper(a);function a(e){var t;return _classCallCheck(this,a),(t=r.call(this,e)).name="CalculatorError",t.message=e,t}return _createClass(a)}(),TokensFillError=function(){_inherits(a,_wrapNativeSuper(Error));var r=_createSuper(a);function a(e){var t;return _classCallCheck(this,a),(t=r.call(this,e)).name="TokensFillError",t.message=e,t}return _createClass(a)}();function parseArgs(e){var t={expr:"",fmt:null,data:null},r="",a=e[0];if(1===e.length)"string"==typeof a?r=a:"number"==typeof a?r=a.toString():Array.isArray(a)&&(r=a[0]);else if(1<e.length){a=e[e.length-1];if(!isObj(a)&&!Array.isArray(a))throw new Error("参数错误, 暂不支持的参数");if("string"==typeof(r=e[0])){if(""===r.trim())throw new TokensFillError("参数不可为空字符串")}else if("number"==typeof r)r=r.toString();else if(void 0===r||Number.isNaN(r))throw new TokensFillError("非法参数:".concat(r));t.data=a}e=r.split("|");return 1===e.length?t.expr=e[0]:(t.expr=e[0],""!==(a=e[1]).trim()&&(t.fmt=a)),null!==t.data&&null===t.fmt&&t.data._fmt&&(t.fmt=t.data._fmt),t}function format(e,t){var r="",a=(r=BigNumber.isBigNumber(e)?e.toFixed():"string"!=typeof e?e.toString():e,null),e=null,o=null,n=t.match(/(<=|>=|=)\s*(\d+)/);if(n&&(e=n[1],a=Number(n[2])),t.includes(",")&&(o=!0),null!==a){var n=r.split("."),t=n[0],i=1===n.length?"":n[1],s=i.length;switch(e){case"<=":i=s<=a?i:i.slice(0,a);break;case"=":s<a?i+="0".repeat(a-s):a<s&&(i=i.slice(0,a));break;case">=":i=a<=s?i:i+"0".repeat(a-s)}r=""===i?t:"".concat(t,".").concat(i)}return r=null!==o?1<(n=r.split(".")).length?((e=n[0]).includes("-")?n[0]=e[0]+e.slice(1).replace(/(?=(?!^)(?:\d{3})+$)/g,","):n[0]=e.replace(/(?=(?!^)(?:\d{3})+$)/g,","),n.join(".")):(t=n[0]).includes("-")?t[0]+t.slice(1).replace(/(?=(?!^)(?:\d{3})+$)/g,","):t.replace(/(?=(?!^)(?:\d{3})+$)/g,","):r}function tokenizer(e){for(var t=[],r=0,a=null,o=e.length;r<o;)if(a=e[r],/\s/.test(a))r++;else if("+-".includes(a)){var n=t[t.length-1];if(0===t.length||"+-".includes(n)||"("===n){for(var i=a,a=e[++r];/[a-zA-Z\d._]/.test(a);)i+=a,a=e[++r];t.push(i)}else t.push(a),r++}else if("*/%()".includes(a))t.push(a),r++;else if(/[\w_.\[\]"']/.test(a)){for(var s="";/[\w_.\[\]"']/.test(a)&&(s+=a,!(++r>=o));)a=e[r];t.push(s)}else if(/\d/.test(a)){for(var c="";/[\d.]/.test(a)&&(c+=a,!(++r>=o));)a=e[r];t.push(c)}return t}var commonjsGlobal="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},isArray$3=Array.isArray,isArray_1=isArray$3,freeGlobal$1="object"==_typeof(commonjsGlobal)&&commonjsGlobal&&commonjsGlobal.Object===Object&&commonjsGlobal,_freeGlobal=freeGlobal$1,freeGlobal=freeGlobal$1,freeSelf="object"==("undefined"==typeof self?"undefined":_typeof(self))&&self&&self.Object===Object&&self,root$3=freeGlobal||freeSelf||Function("return this")(),_root=root$3,root$2=_root,_Symbol2=_root.Symbol,_Symbol$3=_Symbol2,_Symbol$2=_Symbol$3,objectProto$4=Object.prototype,hasOwnProperty$3=objectProto$4.hasOwnProperty,nativeObjectToString$1=objectProto$4.toString,symToStringTag$1=_Symbol$2?_Symbol$2.toStringTag:void 0;function getRawTag$1(e){var t=hasOwnProperty$3.call(e,symToStringTag$1),r=e[symToStringTag$1];try{var a=!(e[symToStringTag$1]=void 0)}catch(e){}var o=nativeObjectToString$1.call(e);return a&&(t?e[symToStringTag$1]=r:delete e[symToStringTag$1]),o}var _getRawTag=getRawTag$1,objectProto$3=Object.prototype,nativeObjectToString=objectProto$3.toString;function objectToString$1(e){return nativeObjectToString.call(e)}var _objectToString=objectToString$1,_Symbol$1=_Symbol$3,getRawTag=_getRawTag,objectToString=objectToString$1,nullTag="[object Null]",undefinedTag="[object Undefined]",symToStringTag=_Symbol$3?_Symbol$3.toStringTag:void 0;function baseGetTag$2(e){return null==e?void 0===e?undefinedTag:nullTag:(symToStringTag&&symToStringTag in Object(e)?getRawTag:objectToString)(e)}var _baseGetTag=baseGetTag$2;function isObjectLike$1(e){return null!=e&&"object"==_typeof(e)}var isObjectLike_1=isObjectLike$1,baseGetTag$1=baseGetTag$2,isObjectLike=isObjectLike$1,symbolTag="[object Symbol]";function isSymbol$3(e){return"symbol"==_typeof(e)||isObjectLike(e)&&baseGetTag$1(e)==symbolTag}var isSymbol_1=isSymbol$3,isArray$2=isArray_1,isSymbol$2=isSymbol_1,reIsDeepProp=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,reIsPlainProp=/^\w*$/;function isKey$1(e,t){if(isArray$2(e))return!1;var r=_typeof(e);return!("number"!=r&&"symbol"!=r&&"boolean"!=r&&null!=e&&!isSymbol$2(e))||(reIsPlainProp.test(e)||!reIsDeepProp.test(e)||null!=t&&e in Object(t))}var _isKey=isKey$1;function isObject$2(e){var t=_typeof(e);return null!=e&&("object"==t||"function"==t)}var isObject_1=isObject$2,baseGetTag=baseGetTag$2,isObject$1=isObject_1,asyncTag="[object AsyncFunction]",funcTag="[object Function]",genTag="[object GeneratorFunction]",proxyTag="[object Proxy]";function isFunction$1(e){if(!isObject$1(e))return!1;e=baseGetTag(e);return e==funcTag||e==genTag||e==asyncTag||e==proxyTag}var isFunction_1=isFunction$1,root$1=_root,coreJsData$1=_root["__core-js_shared__"],_coreJsData=coreJsData$1,coreJsData=coreJsData$1,maskSrcKey=function(){var e=/[^.]+$/.exec(coreJsData&&coreJsData.keys&&coreJsData.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function isMasked$1(e){return!!maskSrcKey&&maskSrcKey in e}var _isMasked=isMasked$1,funcProto$1=Function.prototype,funcToString$1=funcProto$1.toString;function toSource$1(e){if(null!=e){try{return funcToString$1.call(e)}catch(e){}try{return e+""}catch(e){}}return""}var _toSource=toSource$1,isFunction=isFunction_1,isMasked=_isMasked,isObject=isObject_1,toSource=toSource$1,reRegExpChar=/[\\^$.*+?()[\]{}|]/g,reIsHostCtor=/^\[object .+?Constructor\]$/,funcProto=Function.prototype,objectProto$2=Object.prototype,funcToString=funcProto.toString,hasOwnProperty$2=objectProto$2.hasOwnProperty,reIsNative=RegExp("^"+funcToString.call(hasOwnProperty$2).replace(reRegExpChar,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function baseIsNative$1(e){return!(!isObject(e)||isMasked(e))&&(isFunction(e)?reIsNative:reIsHostCtor).test(toSource(e))}var _baseIsNative=baseIsNative$1;function getValue$1(e,t){return null==e?void 0:e[t]}var _getValue=getValue$1,baseIsNative=baseIsNative$1,getValue=getValue$1;function getNative$2(e,t){e=getValue(e,t);return baseIsNative(e)?e:void 0}var _getNative=getNative$2,getNative$1=_getNative,nativeCreate$4=_getNative(Object,"create"),_nativeCreate=nativeCreate$4,nativeCreate$3=_nativeCreate;function hashClear$1(){this.__data__=nativeCreate$3?nativeCreate$3(null):{},this.size=0}var _hashClear=hashClear$1;function hashDelete$1(e){e=this.has(e)&&delete this.__data__[e];return this.size-=e?1:0,e}var _hashDelete=hashDelete$1,nativeCreate$2=_nativeCreate,HASH_UNDEFINED$1="__lodash_hash_undefined__",objectProto$1=Object.prototype,hasOwnProperty$1=objectProto$1.hasOwnProperty;function hashGet$1(e){var t,r=this.__data__;return nativeCreate$2?(t=r[e])===HASH_UNDEFINED$1?void 0:t:hasOwnProperty$1.call(r,e)?r[e]:void 0}var _hashGet=hashGet$1,nativeCreate$1=_nativeCreate,objectProto=Object.prototype,hasOwnProperty=objectProto.hasOwnProperty;function hashHas$1(e){var t=this.__data__;return nativeCreate$1?void 0!==t[e]:hasOwnProperty.call(t,e)}var _hashHas=hashHas$1,nativeCreate=_nativeCreate,HASH_UNDEFINED="__lodash_hash_undefined__";function hashSet$1(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=nativeCreate&&void 0===t?HASH_UNDEFINED:t,this}var _hashSet=hashSet$1,hashClear=_hashClear,hashDelete=_hashDelete,hashGet=_hashGet,hashHas=hashHas$1,hashSet=hashSet$1;function Hash$1(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var a=e[t];this.set(a[0],a[1])}}Hash$1.prototype.clear=hashClear,Hash$1.prototype.delete=hashDelete,Hash$1.prototype.get=hashGet,Hash$1.prototype.has=hashHas,Hash$1.prototype.set=hashSet;var _Hash=Hash$1;function listCacheClear$1(){this.__data__=[],this.size=0}var _listCacheClear=listCacheClear$1;function eq$1(e,t){return e===t||e!=e&&t!=t}var eq_1=eq$1,eq=eq$1;function assocIndexOf$4(e,t){for(var r=e.length;r--;)if(eq(e[r][0],t))return r;return-1}var _assocIndexOf=assocIndexOf$4,assocIndexOf$3=_assocIndexOf,arrayProto=Array.prototype,splice=arrayProto.splice;function listCacheDelete$1(e){var t=this.__data__,e=assocIndexOf$3(t,e);return!(e<0)&&(e==t.length-1?t.pop():splice.call(t,e,1),--this.size,!0)}var _listCacheDelete=listCacheDelete$1,assocIndexOf$2=_assocIndexOf;function listCacheGet$1(e){var t=this.__data__,e=assocIndexOf$2(t,e);return e<0?void 0:t[e][1]}var _listCacheGet=listCacheGet$1,assocIndexOf$1=_assocIndexOf;function listCacheHas$1(e){return-1<assocIndexOf$1(this.__data__,e)}var _listCacheHas=listCacheHas$1,assocIndexOf=_assocIndexOf;function listCacheSet$1(e,t){var r=this.__data__,a=assocIndexOf(r,e);return a<0?(++this.size,r.push([e,t])):r[a][1]=t,this}var _listCacheSet=listCacheSet$1,listCacheClear=_listCacheClear,listCacheDelete=listCacheDelete$1,listCacheGet=listCacheGet$1,listCacheHas=listCacheHas$1,listCacheSet=listCacheSet$1;function ListCache$1(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var a=e[t];this.set(a[0],a[1])}}ListCache$1.prototype.clear=listCacheClear,ListCache$1.prototype.delete=listCacheDelete,ListCache$1.prototype.get=listCacheGet,ListCache$1.prototype.has=listCacheHas,ListCache$1.prototype.set=listCacheSet;var _ListCache=ListCache$1,getNative=_getNative,root=_root,Map$2=_getNative(_root,"Map"),_Map=Map$2,Hash=_Hash,ListCache=_ListCache,Map$1=Map$2;function mapCacheClear$1(){this.size=0,this.__data__={hash:new Hash,map:new(Map$1||ListCache),string:new Hash}}var _mapCacheClear=mapCacheClear$1;function isKeyable$1(e){var t=_typeof(e);return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e}var _isKeyable=isKeyable$1,isKeyable=isKeyable$1;function getMapData$4(e,t){e=e.__data__;return isKeyable(t)?e["string"==typeof t?"string":"hash"]:e.map}var _getMapData=getMapData$4,getMapData$3=getMapData$4;function mapCacheDelete$1(e){e=getMapData$3(this,e).delete(e);return this.size-=e?1:0,e}var _mapCacheDelete=mapCacheDelete$1,getMapData$2=getMapData$4;function mapCacheGet$1(e){return getMapData$2(this,e).get(e)}var _mapCacheGet=mapCacheGet$1,getMapData$1=getMapData$4;function mapCacheHas$1(e){return getMapData$1(this,e).has(e)}var _mapCacheHas=mapCacheHas$1,getMapData=getMapData$4;function mapCacheSet$1(e,t){var r=getMapData(this,e),a=r.size;return r.set(e,t),this.size+=r.size==a?0:1,this}var _mapCacheSet=mapCacheSet$1,mapCacheClear=mapCacheClear$1,mapCacheDelete=mapCacheDelete$1,mapCacheGet=mapCacheGet$1,mapCacheHas=mapCacheHas$1,mapCacheSet=mapCacheSet$1;function MapCache$1(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var a=e[t];this.set(a[0],a[1])}}MapCache$1.prototype.clear=mapCacheClear,MapCache$1.prototype.delete=mapCacheDelete,MapCache$1.prototype.get=mapCacheGet,MapCache$1.prototype.has=mapCacheHas,MapCache$1.prototype.set=mapCacheSet;var _MapCache=MapCache$1,MapCache=MapCache$1,FUNC_ERROR_TEXT="Expected a function";function memoize$1(a,o){if("function"!=typeof a||null!=o&&"function"!=typeof o)throw new TypeError(FUNC_ERROR_TEXT);function n(){var e=arguments,t=o?o.apply(this,e):e[0],r=n.cache;return r.has(t)?r.get(t):(e=a.apply(this,e),n.cache=r.set(t,e)||r,e)}return n.cache=new(memoize$1.Cache||MapCache),n}memoize$1.Cache=MapCache;var memoize_1=memoize$1,memoize=memoize$1,MAX_MEMOIZE_SIZE=500;function memoizeCapped$1(e){var e=memoize(e,function(e){return t.size===MAX_MEMOIZE_SIZE&&t.clear(),e}),t=e.cache;return e}var _memoizeCapped=memoizeCapped$1,memoizeCapped=memoizeCapped$1,rePropName=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,reEscapeChar=/\\(\\)?/g,stringToPath$1=memoizeCapped$1(function(e){var o=[];return 46===e.charCodeAt(0)&&o.push(""),e.replace(rePropName,function(e,t,r,a){o.push(r?a.replace(reEscapeChar,"$1"):t||e)}),o}),_stringToPath=stringToPath$1;function arrayMap$1(e,t){for(var r=-1,a=null==e?0:e.length,o=Array(a);++r<a;)o[r]=t(e[r],r,e);return o}var _arrayMap=arrayMap$1,_Symbol=_Symbol$3,arrayMap=arrayMap$1,isArray$1=isArray_1,isSymbol$1=isSymbol_1,INFINITY$1=1/0,symbolProto=_Symbol$3?_Symbol$3.prototype:void 0,symbolToString=symbolProto?symbolProto.toString:void 0;function baseToString$1(e){if("string"==typeof e)return e;if(isArray$1(e))return arrayMap(e,baseToString$1)+"";if(isSymbol$1(e))return symbolToString?symbolToString.call(e):"";var t=e+"";return"0"==t&&1/e==-INFINITY$1?"-0":t}var _baseToString=baseToString$1,baseToString=baseToString$1;function toString$1(e){return null==e?"":baseToString(e)}var toString_1=toString$1,isArray=isArray_1,isKey=_isKey,stringToPath=_stringToPath,toString=toString$1;function castPath$1(e,t){return isArray(e)?e:isKey(e,t)?[e]:stringToPath(toString(e))}var _castPath=castPath$1,isSymbol=isSymbol_1,INFINITY=1/0;function toKey$1(e){if("string"==typeof e||isSymbol(e))return e;var t=e+"";return"0"==t&&1/e==-INFINITY?"-0":t}var _toKey=toKey$1,castPath=castPath$1,toKey=toKey$1;function baseGet$1(e,t){for(var r=0,a=(t=castPath(t,e)).length;null!=e&&r<a;)e=e[toKey(t[r++])];return r&&r==a?e:void 0}var _baseGet=baseGet$1,baseGet=baseGet$1;function get(e,t,r){e=null==e?void 0:baseGet(e,t);return void 0===e?r:e}var get_1=get;function fillTokens(e,t){var r=[];if(!notNull(t))throw new TokensFillError("错误的填充数据:",t);Array.isArray(t)?r=t:r.push(t);for(var a=[],o=0;o<e.length;o++){var n=e[o];if(/^[a-zA-z_][\w\[\]"'_.]*$/.test(n)){if("undefined"===n||"NaN"===n)throw new TokensFillError("key不应该为:".concat(n));for(var i=null,s=0;s<r.length;s++){var c=r[s],c=get_1(c,n);if(void 0!==c){i=c;break}}if(null===i)throw new TokensFillError("token填充失败,请确认".concat(n,"存在"));if("string"==typeof i){if(""===i.trim())throw new TokensFillError("token填充失败,".concat(n,"值不可为空字符"));if(!isStrNumber(i))throw new TokensFillError("token填充失败,".concat(n,"值:").concat(i,"为非法数字"))}i="string"!=typeof i?i.toString():i,a.push(i)}else a.push(n)}return a}function fmt(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];var a=parseArgs(t),o=tokenizer(a.expr),n=null;if(!0===get_1(a,"data._debug")&&(console.warn("======a-calc调试模式======"),console.warn(a),console.warn(o)),""===a.expr.trim()&&notNull(a.data)&&notUndefined(a.data._error))return a.data._error;if(2<o.length)throw new Error("fmt并非用于计算, 不能传入多个标识:".concat(a.expr));if(1!==o.length)throw new Error("fmt接收了一个无法被解析的标识");if(null!==a.data){var i=arg.data,s=[];if(Array.isArray(i)?s=i:(s.push(n=i),notUndefined(c=get_1(n,"_fillData"))&&(Array.isArray(c)?s=[].concat(_toConsumableArray(s),_toConsumableArray(c)):s.push(c))),anyNotUndefined(i._fillError,i._error))try{o=fillTokens(o,s)}catch(e){if(e instanceof TokensFillError)return void 0!==n._warn&&!0===n._warn&&console.warn(e),n._fillError||n._error;throw e}else o=fillTokens(o,s)}if(null===a.fmt)throw"表达式没有格式化部分";var c=o[0];if(isStrNumber(c))return format(o[0],a.fmt);throw new TokensFillError("待格式化对象: ".concat(c," 不是数字"))}var version="0.0.60";function token2postfix(e){for(var t=[],r=[],a=e;0<a.length;){var o=a.shift();if(isOperator(o))if("("===o)t.push(o);else if(")"===o){for(var n=t.pop();"("!==n&&0<t.length;)r.push(n),n=t.pop();if("("!==n)throw"error: unmatched ()"}else{for(;prioraty(o,t[t.length-1])&&0<t.length;)r.push(t.pop());t.push(o)}else r.push(o)}if(0<t.length){if(")"===t[t.length-1]||"("===t[t.length-1])throw"error: unmatched ()";for(;0<t.length;)r.push(t.pop())}return r}function evalPostfix(e){for(var t=[];0<e.length;){var r=e.shift();if(isOperator(r)){if(t.length<2)throw new CalculatorError("错误的栈长度, 可能是无法计算的表达式");var a=t.pop(),o=t.pop();if("string"==typeof a&&!BigNumber.isBigNumber(a)){if(!isStrNumber(a))throw new CalculatorError("".concat(a,"不是一个合法的数字"));a=new BigNumber(a)}if("string"==typeof o&&!BigNumber.isBigNumber(o)){if(!isStrNumber(o))throw new CalculatorError("".concat(o,"不是一个合法的数字"));o=new BigNumber(o)}switch(r){case"+":t.push(o.plus(a));break;case"-":t.push(o.minus(a));break;case"*":t.push(o.times(a));break;case"/":t.push(o.div(a));break;case"%":t.push(o.mod(a))}}else t.push(r)}if(1!==t.length)throw"unvalid expression";return t[0]}function calc(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];var a=parseArgs(t),o=tokenizer(a.expr),n=null;if(!0===get_1(a,"data._debug")&&(console.warn("======a-calc调试模式======"),console.warn(a),console.warn(o)),null!==a.data){var i=a.data,s=[];if(Array.isArray(i)?s=i:(s.push(n=i),notUndefined(c=get_1(n,"_fillData"))&&(Array.isArray(c)?s=[].concat(_toConsumableArray(s),_toConsumableArray(c)):s.push(c))),anyNotUndefined(i._fillError,i._error))try{o=fillTokens(o,s)}catch(e){if(e instanceof TokensFillError)return void 0!==n._warn&&!0===n._warn&&console.warn(e),n._fillError||n._error;throw e}else o=fillTokens(o,s)}var c=token2postfix(o),i=null;if(notNull(n)&&anyNotUndefined(n._calcError,n._error))try{i=evalPostfix(c)}catch(e){if(e instanceof CalculatorError)return void 0!==n._warn&&!0===n._warn&&console.warn(e),void 0!==n._calcError?n._calcError:n._error;throw e}else i=evalPostfix(c);return i=notNull(a.fmt)?format(i,a.fmt):null!==i?i.toFixed():null}export{calc,fmt,version};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "a-calc",
3
- "version": "0.0.60",
3
+ "version": "0.0.61",
4
4
  "description": "JavaScript的字符串四则运算库, 支持格式化操作例如: 千分位格式化, 灵活指定小数点位数",
5
5
  "main": "./cjs/index.js",
6
6
  "exports": {