Comparing version 0.0.39 to 0.0.43
@@ -1,1 +0,1 @@ | ||
var a_calc=function(r){"use strict";function t(r){return r&&"object"==typeof r&&"default"in r?r:{default:r}}var u=t(BigNumber);function o(r,t){if(!(r instanceof t))throw new TypeError("Cannot call a class as a function")}function n(r,t){for(var e=0;e<t.length;e++){var n=t[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(r,n.key,n)}}function i(r,t,e){return t&&n(r.prototype,t),e&&n(r,e),Object.defineProperty(r,"prototype",{writable:!1}),r}function a(r,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");r.prototype=Object.create(t&&t.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),Object.defineProperty(r,"prototype",{writable:!1}),t&&f(r,t)}function l(r){return(l=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)})(r)}function f(r,t){return(f=Object.setPrototypeOf||function(r,t){return r.__proto__=t,r})(r,t)}function c(){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(r){return!1}}function s(r,t,e){return(s=c()?Reflect.construct:function(r,t,e){var n=[null];n.push.apply(n,t);t=new(Function.bind.apply(r,n));return e&&f(t,e.prototype),t}).apply(null,arguments)}function p(r){var e="function"==typeof Map?new Map:void 0;return(p=function(r){if(null===r||-1===Function.toString.call(r).indexOf("[native code]"))return r;if("function"!=typeof r)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(r))return e.get(r);e.set(r,t)}function t(){return s(r,arguments,l(this).constructor)}return t.prototype=Object.create(r.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),f(t,r)})(r)}function h(r,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");t=r;if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function d(e){var n=c();return function(){var r,t=l(e);return h(this,n?(r=l(this).constructor,Reflect.construct(t,arguments,r)):t.apply(this,arguments))}}function v(r){return function(r){if(Array.isArray(r))return y(r)}(r)||function(r){if("undefined"!=typeof Symbol&&null!=r[Symbol.iterator]||null!=r["@@iterator"])return Array.from(r)}(r)||function(r,t){if(r){if("string"==typeof r)return y(r,t);var e=Object.prototype.toString.call(r).slice(8,-1);return"Map"===(e="Object"===e&&r.constructor?r.constructor.name:e)||"Set"===e?Array.from(r):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?y(r,t):void 0}}(r)||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 y(r,t){(null==t||t>r.length)&&(t=r.length);for(var e=0,n=new Array(t);e<t;e++)n[e]=r[e];return n}function g(r){return-1<"+-*/%()".indexOf(r)}function b(r){switch(r){case"+":case"-":return 1;case"*":case"/":case"%":return 2;default:return 0}}function w(r){var t={expr:"",fmt:null,data:null},e="",n=r[0];if(1===r.length)"string"==typeof n?e=n:"number"==typeof n?e=n.toString():Array.isArray(n)&&(e=n[0]);else if(1<r.length){n=r[r.length-1];if(l=n,"[object Object]"!==Object.prototype.toString.call(l)||Array.isArray(l))for(var o=v(r.shift());o.length||r.length;)var i=0===o.length?"":o.shift(),a=0===r.length?"":r.shift(),e=e+i+(a="number"==typeof a?a.toString():a);else e=r[0],t.data=n}var l=e.split("|");return 1===l.length?t.expr=l[0]:(t.expr=l[0],""!==(n=l[1]).trim()&&(t.fmt=n)),t}function m(r,t){var e="",n=(e=u.default.isBigNumber(r)?r.toFixed():"string"!=typeof r?r.toString():r,null),r=null,o=null,i=t.match(/(<=|>=|=)\s*(\d+)/);if(i&&(r=i[1],n=Number(i[2])),t.includes(",")&&(o=!0),null!==n){var i=e.split("."),t=i[0],a=1===i.length?"":i[1],l=a.length;switch(r){case"<=":a=l<=n?a:a.slice(0,n);break;case"=":l<n?a+="0".repeat(n-l):n<l&&(a=a.slice(0,n));break;case">=":a=n<=l?a:a+"0".repeat(n-l)}e=""===a?t:"".concat(t,".").concat(a)}return e=null!==o?1<(i=e.split(".")).length?((r=i[0]).includes("-")?i[0]=r[0]+r.slice(1).replace(/(?=(?!^)(?:\d{3})+$)/g,","):i[0]=r.replace(/(?=(?!^)(?:\d{3})+$)/g,","),i.join(".")):(t=i[0]).includes("-")?t[0]+t.slice(1).replace(/(?=(?!^)(?:\d{3})+$)/g,","):t.replace(/(?=(?!^)(?:\d{3})+$)/g,","):e}function O(r){for(var t=[],e=0,n=null,o=r.length;e<o;)if(n=r[e],/\s/.test(n))e++;else if("+-".includes(n)){var i=t[t.length-1];if(0===t.length||"+-".includes(i)||"("===i){for(var a=n,n=r[++e];/[a-zA-Z\d._]/.test(n);)a+=n,n=r[++e];t.push(a)}else t.push(n),e++}else if("*/%()".includes(n))t.push(n),e++;else if(/[a-zA-Z_]/.test(n)){for(var l="";/[a-zA-Z0-9_]/.test(n)&&(l+=n,!(++e>=o));)n=r[e];t.push(l)}else if(/\d/.test(n)){for(var u="";/[\d.]/.test(n)&&(u+=n,!(++e>=o));)n=r[e];t.push(u)}return t}var j=function(){a(n,p(Error));var e=d(n);function n(r){var t;return o(this,n),(t=e.call(this,r)).name="CalculatorError",t.message=r,t}return i(n)}(),E=function(){a(n,p(Error));var e=d(n);function n(r){var t;return o(this,n),(t=e.call(this,r)).name="TokensFillError",t.message=r,t}return i(n)}();function _(r,t){var e=t._fillData;return void 0===t._fillData&&(e=t),r.map(function(r){if(/^[a-zA-z_][\w_]*$/.test(r)){var t=e[r];if(void 0!==t)return"number"==typeof t?t.toString():t;throw new E("错误的参数:".concat(r," 请确认他存在"))}return r})}function A(r){for(var t,e=[],n=[],o=r;0<o.length;){var i=o.shift();if(g(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(;t=e[e.length-1],b(i)<=b(t)&&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 x(r){for(var t=[];0<r.length;){var e=r.shift();if(g(e)){if(t.length<2)throw new j("错误的栈长度, 可能是无法计算的表达式");var n=t.pop(),o=t.pop();if("string"==typeof n&&!u.default.isBigNumber(n)){if(!/^[+-]*[\d.]+$/.test(n))throw new j("".concat(n,"不是一个合法的数字"));n=new u.default(n)}if("string"==typeof o&&!u.default.isBigNumber(o)){if(!/^[+-]*[\d.]+$/.test(o))throw new j("".concat(o,"不是一个合法的数字"));o=new u.default(o)}switch(e){case"+":t.push(o.plus(n));break;case"-":t.push(o.minus(n));break;case"*":t.push(o.times(n));break;case"/":t.push(o.div(n));break;case"%":t.push(o.mod(n))}}else t.push(e)}if(1!==t.length)throw"unvalid expression";return t[0]}return r.calc=function(){for(var r=arguments.length,t=new Array(r),e=0;e<r;e++)t[e]=arguments[e];var n=w(t),o=O(n.expr),i=null;if(null!==n.data)if(null===(i=void 0!==n.data._fillData?n.data:i)||void 0===i.fillError&&void 0===i.error)o=_(o,n.data);else try{o=_(o,n.data)}catch(r){if(r instanceof E)return void 0!==i.warn&&!0===i.warn&&console.warn(r),i.fillError||i.error;throw r}var o=A(o),a=null;if(null!==i){if(void 0!==i.calcError||void 0!==i.error)try{a=x(o)}catch(r){if(r instanceof j)return void 0!==i.warn&&!0===i.warn&&console.warn(r),void 0!==i.calcError?i.calcError:i.error;throw r}}else a=x(o);return a=null!==n.fmt?m(a,n.fmt):null!==a?a.toFixed():null},r.fmt=function(){for(var r=arguments.length,t=new Array(r),e=0;e<r;e++)t[e]=arguments[e];var n=w(t),o=O(n.expr),i=null;if(2<o.length)throw new Error("fmt并非用于计算, 不能传入多个标识:".concat(n.expr));if(1!==o.length)throw new Error("fmt接收了一个无法被解析的标识");if(null!==n.data)if(null===(i=void 0!==n.data._fillData?n.data:i)||void 0===i.fillError&&void 0===i.error)o=_(o,n.data);else try{o=_(o,n.data)}catch(r){if(r instanceof TokensFillError)return i.fillError||i.error;throw r}if(null===n.fmt)throw"表达式没有格式化部分";return m(o[0],n.fmt)},r.version="0.0.38",Object.defineProperty(r,"__esModule",{value:!0}),r}({}); | ||
var a_calc=function(r){"use strict";function t(r){return r&&"object"==typeof r&&"default"in r?r:{default:r}}var u=t(BigNumber);function o(r,t){if(!(r instanceof t))throw new TypeError("Cannot call a class as a function")}function n(r,t){for(var e=0;e<t.length;e++){var n=t[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(r,n.key,n)}}function i(r,t,e){return t&&n(r.prototype,t),e&&n(r,e),Object.defineProperty(r,"prototype",{writable:!1}),r}function a(r,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");r.prototype=Object.create(t&&t.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),Object.defineProperty(r,"prototype",{writable:!1}),t&&f(r,t)}function l(r){return(l=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)})(r)}function f(r,t){return(f=Object.setPrototypeOf||function(r,t){return r.__proto__=t,r})(r,t)}function c(){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(r){return!1}}function s(r,t,e){return(s=c()?Reflect.construct:function(r,t,e){var n=[null];n.push.apply(n,t);t=new(Function.bind.apply(r,n));return e&&f(t,e.prototype),t}).apply(null,arguments)}function p(r){var e="function"==typeof Map?new Map:void 0;return(p=function(r){if(null===r||-1===Function.toString.call(r).indexOf("[native code]"))return r;if("function"!=typeof r)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(r))return e.get(r);e.set(r,t)}function t(){return s(r,arguments,l(this).constructor)}return t.prototype=Object.create(r.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),f(t,r)})(r)}function h(r,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");t=r;if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function d(e){var n=c();return function(){var r,t=l(e);return h(this,n?(r=l(this).constructor,Reflect.construct(t,arguments,r)):t.apply(this,arguments))}}function v(r){return function(r){if(Array.isArray(r))return y(r)}(r)||function(r){if("undefined"!=typeof Symbol&&null!=r[Symbol.iterator]||null!=r["@@iterator"])return Array.from(r)}(r)||function(r,t){if(r){if("string"==typeof r)return y(r,t);var e=Object.prototype.toString.call(r).slice(8,-1);return"Map"===(e="Object"===e&&r.constructor?r.constructor.name:e)||"Set"===e?Array.from(r):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?y(r,t):void 0}}(r)||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 y(r,t){(null==t||t>r.length)&&(t=r.length);for(var e=0,n=new Array(t);e<t;e++)n[e]=r[e];return n}function g(r){return-1<"+-*/%()".indexOf(r)}function w(r){switch(r){case"+":case"-":return 1;case"*":case"/":case"%":return 2;default:return 0}}function b(){for(var r=arguments.length,t=new Array(r),e=0;e<r;e++)t[e]=arguments[e];return t.some(function(r){return void 0!==r})}function _(r){var t={expr:"",fmt:null,data:null},e="",n=r[0];if(1===r.length)"string"==typeof n?e=n:"number"==typeof n?e=n.toString():Array.isArray(n)&&(e=n[0]);else if(1<r.length){n=r[r.length-1];if(l=n,"[object Object]"!==Object.prototype.toString.call(l)||Array.isArray(l))for(var o=v(r.shift());o.length||r.length;)var i=0===o.length?"":o.shift(),a=0===r.length?"":r.shift(),e=e+i+(a="number"==typeof a?a.toString():a);else e=r[0],t.data=n}var l=e.split("|");return 1===l.length?t.expr=l[0]:(t.expr=l[0],""!==(n=l[1]).trim()&&(t.fmt=n)),t}function m(r,t){var e="",n=(e=u.default.isBigNumber(r)?r.toFixed():"string"!=typeof r?r.toString():r,null),r=null,o=null,i=t.match(/(<=|>=|=)\s*(\d+)/);if(i&&(r=i[1],n=Number(i[2])),t.includes(",")&&(o=!0),null!==n){var i=e.split("."),t=i[0],a=1===i.length?"":i[1],l=a.length;switch(r){case"<=":a=l<=n?a:a.slice(0,n);break;case"=":l<n?a+="0".repeat(n-l):n<l&&(a=a.slice(0,n));break;case">=":a=n<=l?a:a+"0".repeat(n-l)}e=""===a?t:"".concat(t,".").concat(a)}return e=null!==o?1<(i=e.split(".")).length?((r=i[0]).includes("-")?i[0]=r[0]+r.slice(1).replace(/(?=(?!^)(?:\d{3})+$)/g,","):i[0]=r.replace(/(?=(?!^)(?:\d{3})+$)/g,","),i.join(".")):(t=i[0]).includes("-")?t[0]+t.slice(1).replace(/(?=(?!^)(?:\d{3})+$)/g,","):t.replace(/(?=(?!^)(?:\d{3})+$)/g,","):e}function E(r){for(var t=[],e=0,n=null,o=r.length;e<o;)if(n=r[e],/\s/.test(n))e++;else if("+-".includes(n)){var i=t[t.length-1];if(0===t.length||"+-".includes(i)||"("===i){for(var a=n,n=r[++e];/[a-zA-Z\d._]/.test(n);)a+=n,n=r[++e];t.push(a)}else t.push(n),e++}else if("*/%()".includes(n))t.push(n),e++;else if(/[a-zA-Z_]/.test(n)){for(var l="";/[a-zA-Z0-9_]/.test(n)&&(l+=n,!(++e>=o));)n=r[e];t.push(l)}else if(/\d/.test(n)){for(var u="";/[\d.]/.test(n)&&(u+=n,!(++e>=o));)n=r[e];t.push(u)}return t}var O=function(){a(n,p(Error));var e=d(n);function n(r){var t;return o(this,n),(t=e.call(this,r)).name="CalculatorError",t.message=r,t}return i(n)}(),j=function(){a(n,p(Error));var e=d(n);function n(r){var t;return o(this,n),(t=e.call(this,r)).name="TokensFillError",t.message=r,t}return i(n)}();function A(r,t){var e=t._fillData;return void 0===t._fillData&&(e=t),r.map(function(r){if(/^[a-zA-z_][\w_]*$/.test(r)){var t=e[r];if(void 0!==t)return"number"==typeof t?t.toString():t;throw new j("错误的参数:".concat(r," 请确认他存在"))}return r})}function x(r){for(var t,e=[],n=[],o=r;0<o.length;){var i=o.shift();if(g(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(;t=e[e.length-1],w(i)<=w(t)&&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 S(r){for(var t=[];0<r.length;){var e=r.shift();if(g(e)){if(t.length<2)throw new O("错误的栈长度, 可能是无法计算的表达式");var n=t.pop(),o=t.pop();if("string"==typeof n&&!u.default.isBigNumber(n)){if(!/^[+-]*[\d.]+$/.test(n))throw new O("".concat(n,"不是一个合法的数字"));n=new u.default(n)}if("string"==typeof o&&!u.default.isBigNumber(o)){if(!/^[+-]*[\d.]+$/.test(o))throw new O("".concat(o,"不是一个合法的数字"));o=new u.default(o)}switch(e){case"+":t.push(o.plus(n));break;case"-":t.push(o.minus(n));break;case"*":t.push(o.times(n));break;case"/":t.push(o.div(n));break;case"%":t.push(o.mod(n))}}else t.push(e)}if(1!==t.length)throw"unvalid expression";return t[0]}return r.calc=function(){for(var r=arguments.length,t=new Array(r),e=0;e<r;e++)t[e]=arguments[e];var n=_(t),o=E(n.expr),i=null;if(null!==n.data){var a=n.data;if(null!==(i=b(a._fillData,a._error,a._fillError,a._calcError)?a:i)&&void 0!==a._fillData&&b(i._fillError,i._error))try{o=A(o,a._fillData)}catch(r){if(r instanceof j)return void 0!==i._warn&&!0===i._warn&&console.warn(r),i._fillError||i._error;throw r}else o=A(o,a)}if(a=x(o),(o=null)!==i){if(void 0!==i._calcError||void 0!==i._error)try{o=S(a)}catch(r){if(r instanceof O)return void 0!==i._warn&&!0===i._warn&&console.warn(r),void 0!==i._calcError?i._calcError:i._error;throw r}}else o=S(a);return o=null!==n.fmt?m(o,n.fmt):null!==o?o.toFixed():null},r.fmt=function(){for(var r=arguments.length,t=new Array(r),e=0;e<r;e++)t[e]=arguments[e];var n=_(t),o=E(n.expr),i=null;if(""===n.expr.trim()&&void 0!==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=b(a._fillData,a._error,a._fillError)?a:i)&&void 0!==a._fillData&&b(i._fillError,i._error))try{o=A(o,a._fillData)}catch(r){if(r instanceof j)return void 0!==i._warn&&!0===i._warn&&console.warn(r),i._fillError||i._error;throw r}else o=A(o,a)}if(null===n.fmt)throw"表达式没有格式化部分";return m(o[0],n.fmt)},r.version="0.0.42",Object.defineProperty(r,"__esModule",{value:!0}),r}({}); |
@@ -1,1 +0,1 @@ | ||
var a_calc=function(e){"use strict";function C(e){return(C="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function i(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}function n(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 r(e,r,t){return r&&n(e.prototype,r),t&&n(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function o(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&&l(e,r)}function u(e){return(u=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function l(e,r){return(l=Object.setPrototypeOf||function(e,r){return e.__proto__=r,e})(e,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(e){return!1}}function s(e,r,t){return(s=f()?Reflect.construct:function(e,r,t){var n=[null];n.push.apply(n,r);r=new(Function.bind.apply(e,n));return t&&l(r,t.prototype),r}).apply(null,arguments)}function c(e){var t="function"==typeof Map?new Map:void 0;return(c=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 s(e,arguments,u(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),l(r,e)})(e)}function y(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 a(t){var n=f();return function(){var e,r=u(t);return y(this,n?(e=u(this).constructor,Reflect.construct(r,arguments,e)):r.apply(this,arguments))}}function b(e){return function(e){if(Array.isArray(e))return h(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 h(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)?h(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 h(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 p(e){return-1<"+-*/%()".indexOf(e)}function g(e){switch(e){case"+":case"-":return 1;case"*":case"/":case"%":return 2;default:return 0}}function d(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(l=n,"[object Object]"!==Object.prototype.toString.call(l)||Array.isArray(l))for(var i=b(e.shift());i.length||e.length;)var o=0===i.length?"":i.shift(),u=0===e.length?"":e.shift(),t=t+o+(u="number"==typeof u?u.toString():u);else t=e[0],r.data=n}var l=t.split("|");return 1===l.length?r.expr=l[0]:(r.expr=l[0],""!==(n=l[1]).trim()&&(r.fmt=n)),r}var re=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,M=Math.ceil,k=Math.floor,F="[BigNumber Error] ",$=F+"Number primitive has more than 15 significant digits: ",G=1e14,z=14,q=9007199254740991,H=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],V=1e7,W=1e9;function Z(e){var r=0|e;return 0<e||e===r?r:r-1}function X(e){for(var r,t,n=1,i=e.length,o=e[0]+"";n<i;){for(r=e[n++]+"",t=z-r.length;t--;r="0"+r);o+=r}for(i=o.length;48===o.charCodeAt(--i););return o.slice(0,i+1||1)}function Y(e,r){var t,n,i=e.c,o=r.c,u=e.s,l=r.s,e=e.e,r=r.e;if(!u||!l)return null;if(t=i&&!i[0],n=o&&!o[0],t||n)return t?n?0:-l:u;if(u!=l)return u;if(t=u<0,n=e==r,!i||!o)return n?0:!i^t?1:-1;if(!n)return r<e^t?1:-1;for(l=(e=i.length)<(r=o.length)?e:r,u=0;u<l;u++)if(i[u]!=o[u])return i[u]>o[u]^t?1:-1;return e==r?0:r<e^t?1:-1}function J(e,r,t,n){if(e<r||t<e||e!==k(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 K(e){var r=e.c.length-1;return Z(e.e/z)==r&&e.c[r]%2!=0}function Q(e,r){return(1<e.length?e.charAt(0)+"."+e.slice(1):e)+(r<0?"e":"e+")+r}function ee(e,r,t){var n,i;if(r<0){for(i=t+".";++r;i+=t);e=i+e}else if(++r>(n=e.length)){for(i=t,r-=n;--r;i+=t);e+=i}else r<n&&(e=e.slice(0,r)+"."+e.slice(r));return e}var w=function U(e){var w,a,h,r,s,m,u,l,f,c,p,t=P.prototype={constructor:P,toString:null,valueOf:null},g=new P(1),v=20,y=4,d=-7,b=21,O=-1e7,E=1e7,N=!1,i=1,A=0,S={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},_="0123456789abcdefghijklmnopqrstuvwxyz",x=!0;function P(e,r){var t,n,i,o,u,l,f,s,c=this;if(!(c instanceof P))return new P(e,r);if(null==r){if(e&&!0===e._isBigNumber)return c.s=e.s,void(!e.c||e.e>E?c.c=c.e=null:e.e<O?c.c=[c.e=0]:(c.e=e.e,c.c=e.c.slice()));if((l="number"==typeof e)&&0*e==0){if(c.s=1/e<0?(e=-e,-1):1,e===~~e){for(o=0,u=e;10<=u;u/=10,o++);return void(E<o?c.c=c.e=null:(c.e=o,c.c=[e]))}s=String(e)}else{if(!re.test(s=String(e)))return h(c,s,l);c.s=45==s.charCodeAt(0)?(s=s.slice(1),-1):1}0<(u=(s=-1<(o=s.indexOf("."))?s.replace(".",""):s).search(/e/i))?(o<0&&(o=u),o+=+s.slice(u+1),s=s.substring(0,u)):o<0&&(o=s.length)}else{if(J(r,2,_.length,"Base"),10==r&&x)return I(c=new P(e),v+c.e+1,y);if(s=String(e),l="number"==typeof e){if(0*e!=0)return h(c,s,l,r);if(c.s=1/e<0?(s=s.slice(1),-1):1,P.DEBUG&&15<s.replace(/^0\.0*|\./,"").length)throw Error($+e)}else c.s=45===s.charCodeAt(0)?(s=s.slice(1),-1):1;for(t=_.slice(0,r),o=u=0,f=s.length;u<f;u++)if(t.indexOf(n=s.charAt(u))<0){if("."==n){if(o<u){o=f;continue}}else if(!i&&(s==s.toUpperCase()&&(s=s.toLowerCase())||s==s.toLowerCase()&&(s=s.toUpperCase()))){i=!0,u=-1,o=0;continue}return h(c,String(e),l,r)}l=!1,-1<(o=(s=a(s,r,10,c.s)).indexOf("."))?s=s.replace(".",""):o=s.length}for(u=0;48===s.charCodeAt(u);u++);for(f=s.length;48===s.charCodeAt(--f););if(s=s.slice(u,++f)){if(f-=u,l&&P.DEBUG&&15<f&&(q<e||e!==k(e)))throw Error($+c.s*e);if((o=o-u-1)>E)c.c=c.e=null;else if(o<O)c.c=[c.e=0];else{if(c.e=o,c.c=[],u=(o+1)%z,o<0&&(u+=z),u<f){for(u&&c.c.push(+s.slice(0,u)),f-=z;u<f;)c.c.push(+s.slice(u,u+=z));u=z-(s=s.slice(u)).length}else u-=f;for(;u--;s+="0");c.c.push(+s)}}else c.c=[c.e=0]}function R(e,r,t,n){for(var i,o,u=[0],l=0,f=e.length;l<f;){for(o=u.length;o--;u[o]*=r);for(u[0]+=n.indexOf(e.charAt(l++)),i=0;i<u.length;i++)u[i]>t-1&&(null==u[i+1]&&(u[i+1]=0),u[i+1]+=u[i]/t|0,u[i]%=t)}return u.reverse()}function D(e,r,t){var n,i,o,u=0,l=e.length,f=r%V,s=r/V|0;for(e=e.slice();l--;)u=((i=f*(o=e[l]%V)+(n=s*o+(o=e[l]/V|0)*f)%V*V+u)/t|0)+(n/V|0)+s*o,e[l]=i%t;return e=u?[u].concat(e):e}function j(e,r,t,n){var i,o;if(t!=n)o=n<t?1:-1;else for(i=o=0;i<t;i++)if(e[i]!=r[i]){o=e[i]>r[i]?1:-1;break}return o}function B(e,r,t,n){for(var i=0;t--;)e[t]-=i,i=e[t]<r[t]?1:0,e[t]=i*n+e[t]-r[t];for(;!e[0]&&1<e.length;e.splice(0,1));}function n(e,r,t,n){var i,o,u,l;if(null==t?t=y:J(t,0,8),!e.c)return e.toString();if(i=e.c[0],o=e.e,null==r)l=X(e.c),l=1==n||2==n&&(o<=d||b<=o)?Q(l,o):ee(l,o,"0");else if(t=(e=I(new P(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=Q(l,t)}else if(r-=o,l=ee(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&&i?"-"+l:l}function o(e,r){for(var t,n=1,i=new P(e[0]);n<e.length;n++){if(!(t=new P(e[n])).s){i=t;break}r.call(i,t)&&(i=t)}return i}function T(e,r,t){for(var n=1,i=r.length;!r[--i];r.pop());for(i=r[0];10<=i;i/=10,n++);return(t=n+t*z-1)>E?e.c=e.e=null:t<O?e.c=[e.e=0]:(e.e=t,e.c=r),e}function I(e,r,t,n){var i,o,u,l,f,s,c,a=e.c,h=H;if(a){e:{for(i=1,l=a[0];10<=l;l/=10,i++);if((o=r-i)<0)o+=z,u=r,c=(f=a[s=0])/h[i-u-1]%10|0;else if((s=M((o+1)/z))>=a.length){if(!n)break e;for(;a.length<=s;a.push(0));f=c=0,u=(o%=z)-z+(i=1)}else{for(f=l=a[s],i=1;10<=l;l/=10,i++);c=(u=(o%=z)-z+i)<0?0:f/h[i-u-1]%10|0}if(n=n||r<0||null!=a[s+1]||(u<0?f:f%h[i-u-1]),n=t<4?(c||n)&&(0==t||t==(e.s<0?3:2)):5<c||5==c&&(4==t||n||6==t&&(0<o?0<u?f/h[i-u]:0:a[s-1])%10&1||t==(e.s<0?8:7)),r<1||!a[0])return a.length=0,n?(r-=e.e+1,a[0]=h[(z-r%z)%z],e.e=-r||0):a[0]=e.e=0,e;if(0==o?(a.length=s,l=1,s--):(a.length=s+1,l=h[z-o],a[s]=0<u?k(f/h[i-u]%h[u])*l:0),n)for(;;){if(0==s){for(o=1,u=a[0];10<=u;u/=10,o++);for(u=a[0]+=l,l=1;10<=u;u/=10,l++);o!=l&&(e.e++,a[0]==G&&(a[0]=1));break}if(a[s]+=l,a[s]!=G)break;a[s--]=0,l=1}for(o=a.length;0===a[--o];a.pop());}e.e>E?e.c=e.e=null:e.e<O&&(e.c=[e.e=0])}return e}function L(e){var r,t=e.e;return null===t?e.toString():(r=X(e.c),r=t<=d||b<=t?Q(r,t):ee(r,t,"0"),e.s<0?"-"+r:r)}return P.clone=U,P.ROUND_UP=0,P.ROUND_DOWN=1,P.ROUND_CEIL=2,P.ROUND_FLOOR=3,P.ROUND_HALF_UP=4,P.ROUND_HALF_DOWN=5,P.ROUND_HALF_EVEN=6,P.ROUND_HALF_CEIL=7,P.ROUND_HALF_FLOOR=8,P.EUCLID=9,P.config=P.set=function(e){var r,t;if(null!=e){if("object"!=C(e))throw Error(F+"Object expected: "+e);if(e.hasOwnProperty(r="DECIMAL_PLACES")&&(J(t=e[r],0,W,r),v=t),e.hasOwnProperty(r="ROUNDING_MODE")&&(J(t=e[r],0,8,r),y=t),e.hasOwnProperty(r="EXPONENTIAL_AT")&&((t=e[r])&&t.pop?(J(t[0],-W,0,r),J(t[1],0,W,r),d=t[0],b=t[1]):(J(t,-W,W,r),d=-(b=t<0?-t:t))),e.hasOwnProperty(r="RANGE"))if((t=e[r])&&t.pop)J(t[0],-W,-1,r),J(t[1],1,W,r),O=t[0],E=t[1];else{if(J(t,-W,W,r),!t)throw Error(F+r+" cannot be zero: "+t);O=-(E=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 N=!t,Error(F+"crypto unavailable");N=t}else N=t}if(e.hasOwnProperty(r="MODULO_MODE")&&(J(t=e[r],0,9,r),i=t),e.hasOwnProperty(r="POW_PRECISION")&&(J(t=e[r],0,W,r),A=t),e.hasOwnProperty(r="FORMAT")){if("object"!=C(t=e[r]))throw Error(F+r+" not an object: "+t);S=t}if(e.hasOwnProperty(r="ALPHABET")){if("string"!=typeof(t=e[r])||/^.?$|[+\-.\s]|(.).*\1/.test(t))throw Error(F+r+" invalid: "+t);x="0123456789"==t.slice(0,10),_=t}}return{DECIMAL_PLACES:v,ROUNDING_MODE:y,EXPONENTIAL_AT:[d,b],RANGE:[O,E],CRYPTO:N,MODULO_MODE:i,POW_PRECISION:A,FORMAT:S,ALPHABET:_}},P.isBigNumber=function(e){if(!e||!0!==e._isBigNumber)return!1;if(!P.DEBUG)return!0;var r,t,n=e.c,i=e.e,o=e.s;e:if("[object Array]"=={}.toString.call(n)){if((1===o||-1===o)&&-W<=i&&i<=W&&i===k(i))if(0===n[0]){if(0===i&&1===n.length)return!0}else if((r=(i+1)%z)<1&&(r+=z),String(n[0]).length==r){for(r=0;r<n.length;r++)if((t=n[r])<0||G<=t||t!==k(t))break e;if(0!==t)return!0}}else if(null===n&&null===i&&(null===o||1===o||-1===o))return!0;throw Error(F+"Invalid BigNumber: "+e)},P.maximum=P.max=function(){return o(arguments,t.lt)},P.minimum=P.min=function(){return o(arguments,t.gt)},P.random=(r=9007199254740992,s=Math.random()*r&2097151?function(){return k(Math.random()*r)}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)},function(e){var r,t,n,i,o,u=0,l=[],f=new P(g);if(null==e?e=v:J(e,0,W),i=M(e/z),N)if(crypto.getRandomValues){for(r=crypto.getRandomValues(new Uint32Array(i*=2));u<i;)9e15<=(o=131072*r[u]+(r[u+1]>>>11))?(t=crypto.getRandomValues(new Uint32Array(2)),r[u]=t[0],r[u+1]=t[1]):(l.push(o%1e14),u+=2);u=i/2}else{if(!crypto.randomBytes)throw N=!1,Error(F+"crypto unavailable");for(r=crypto.randomBytes(i*=7);u<i;)9e15<=(o=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(o%1e14),u+=7);u=i/7}if(!N)for(;u<i;)(o=s())<9e15&&(l[u++]=o%1e14);for(i=l[--u],e%=z,i&&e&&(l[u]=k(i/(o=H[z-e]))*o);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,o=l[0];10<=o;o/=10,u++);u<z&&(n-=z-u)}return f.e=n,f.c=l,f}),P.sum=function(){for(var e=1,r=arguments,t=new P(r[0]);e<r.length;)t=t.plus(r[e++]);return t},m="0123456789",a=function(e,r,t,n,i){var o,u,l,f,s,c,a,h,p=e.indexOf("."),g=v,d=y;for(0<=p&&(f=A,A=0,e=e.replace(".",""),c=(h=new P(r)).pow(e.length-p),A=f,h.c=R(ee(X(c.c),c.e,"0"),10,t,m),h.e=h.c.length),l=f=(a=R(e,r,t,i?(o=_,m):(o=m,_))).length;0==a[--f];a.pop());if(!a[0])return o.charAt(0);if(p<0?--l:(c.c=a,c.e=l,c.s=n,a=(c=w(c,h,g,d,t)).c,s=c.r,l=c.e),p=a[u=l+g+1],f=t/2,s=s||u<0||null!=a[u+1],s=d<4?(null!=p||s)&&(0==d||d==(c.s<0?3:2)):f<p||p==f&&(4==d||s||6==d&&1&a[u-1]||d==(c.s<0?8:7)),u<1||!a[0])e=s?ee(o.charAt(1),-g,o.charAt(0)):o.charAt(0);else{if(a.length=u,s)for(--t;++a[--u]>t;)a[u]=0,u||(++l,a=[1].concat(a));for(f=a.length;!a[--f];);for(p=0,e="";p<=f;e+=o.charAt(a[p++]));e=ee(e,l,o.charAt(0))}return e},w=function(e,r,t,n,i){var o,u,l,f,s,c,a,h,p,g,d,w,m,v,y,b,O,E=e.s==r.s?1:-1,N=e.c,A=r.c;if(!(N&&N[0]&&A&&A[0]))return new P(e.s&&r.s&&(N?!A||N[0]!=A[0]:A)?N&&0==N[0]||!A?0*E:E/0:NaN);for(p=(h=new P(E)).c=[],E=t+(u=e.e-r.e)+1,i||(i=G,u=Z(e.e/z)-Z(r.e/z),E=E/z|0),l=0;A[l]==(N[l]||0);l++);if(A[l]>(N[l]||0)&&u--,E<0)p.push(1),f=!0;else{for(v=N.length,b=A.length,E+=2,1<(s=k(i/(A[l=0]+1)))&&(A=D(A,s,i),N=D(N,s,i),b=A.length,v=N.length),m=b,d=(g=N.slice(0,b)).length;d<b;g[d++]=0);O=A.slice(),O=[0].concat(O),y=A[0],A[1]>=i/2&&y++;do{if(s=0,(o=j(A,g,b,d))<0){if(w=g[0],b!=d&&(w=w*i+(g[1]||0)),1<(s=k(w/y)))for(a=(c=D(A,s=i<=s?i-1:s,i)).length,d=g.length;1==j(c,g,a,d);)s--,B(c,b<a?O:A,a,i),a=c.length,o=1;else 0==s&&(o=s=1),a=(c=A.slice()).length;if(B(g,c=a<d?[0].concat(c):c,d,i),d=g.length,-1==o)for(;j(A,g,b,d)<1;)s++,B(g,b<d?O:A,d,i),d=g.length}else 0===o&&(s++,g=[0])}while(p[l++]=s,g[0]?g[d++]=N[m]||0:(g=[N[m]],d=1),(m++<v||null!=g[0])&&E--);f=null!=g[0],p[0]||p.splice(0,1)}if(i==G){for(l=1,E=p[0];10<=E;E/=10,l++);I(h,t+(h.e=l+u*z-1)+1,n,f)}else h.e=u,h.r=+f;return h},u=/^(-?)0([xbo])(?=\w[\w.]*$)/i,l=/^([^.]+)\.$/,f=/^\.([^.]+)$/,c=/^-?(Infinity|NaN)$/,p=/^\s*\+(?=[\w.])|^\s+|\s+$/g,h=function(e,r,t,n){var i,o=t?r:r.replace(p,"");if(c.test(o))e.s=isNaN(o)?null:o<0?-1:1;else{if(!t&&(o=o.replace(u,function(e,r,t){return i="x"==(t=t.toLowerCase())?16:"b"==t?2:8,n&&n!=i?e:r}),n&&(i=n,o=o.replace(l,"$1").replace(f,"0.$1")),r!=o))return new P(o,i);if(P.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 P(this);return e.s<0&&(e.s=1),e},t.comparedTo=function(e,r){return Y(this,new P(e,r))},t.decimalPlaces=t.dp=function(e,r){var t,n;if(null!=e)return J(e,0,W),null==r?r=y:J(r,0,8),I(new P(this),e+this.e+1,r);if(!(e=this.c))return null;if(t=((n=e.length-1)-Z(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 w(this,new P(e,r),v,y)},t.dividedToIntegerBy=t.idiv=function(e,r){return w(this,new P(e,r),0,1)},t.exponentiatedBy=t.pow=function(e,r){var t,n,i,o,u,l,f,s,c=this;if((e=new P(e)).c&&!e.isInteger())throw Error(F+"Exponent not an integer: "+L(e));if(null!=r&&(r=new P(r)),u=14<e.e,!c.c||!c.c[0]||1==c.c[0]&&!c.e&&1==c.c.length||!e.c||!e.c[0])return s=new P(Math.pow(+L(c),u?2-K(e):+L(e))),r?s.mod(r):s;if(l=e.s<0,r){if(r.c?!r.c[0]:!r.s)return new P(NaN);(n=!l&&c.isInteger()&&r.isInteger())&&(c=c.mod(r))}else{if(9<e.e&&(0<c.e||c.e<-1||(0==c.e?1<c.c[0]||u&&24e7<=c.c[1]:c.c[0]<8e13||u&&c.c[0]<=9999975e7)))return o=c.s<0&&K(e)?-0:0,-1<c.e&&(o=1/o),new P(l?1/o:o);A&&(o=M(A/z+2))}for(f=u?(t=new P(.5),l&&(e.s=1),K(e)):(i=Math.abs(+L(e)))%2,s=new P(g);;){if(f){if(!(s=s.times(c)).c)break;o?s.c.length>o&&(s.c.length=o):n&&(s=s.mod(r))}if(i){if(0===(i=k(i/2)))break;f=i%2}else if(I(e=e.times(t),e.e+1,1),14<e.e)f=K(e);else{if(0==(i=+L(e)))break;f=i%2}c=c.times(c),o?c.c&&c.c.length>o&&(c.c.length=o):n&&(c=c.mod(r))}return n?s:(l&&(s=g.div(s)),r?s.mod(r):o?I(s,A,y,void 0):s)},t.integerValue=function(e){var r=new P(this);return null==e?e=y:J(e,0,8),I(r,r.e+1,e)},t.isEqualTo=t.eq=function(e,r){return 0===Y(this,new P(e,r))},t.isFinite=function(){return!!this.c},t.isGreaterThan=t.gt=function(e,r){return 0<Y(this,new P(e,r))},t.isGreaterThanOrEqualTo=t.gte=function(e,r){return 1===(r=Y(this,new P(e,r)))||0===r},t.isInteger=function(){return!!this.c&&Z(this.e/z)>this.c.length-2},t.isLessThan=t.lt=function(e,r){return Y(this,new P(e,r))<0},t.isLessThanOrEqualTo=t.lte=function(e,r){return-1===(r=Y(this,new P(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,i,o,u=this,l=u.s;if(r=(e=new P(e,r)).s,!l||!r)return new P(NaN);if(l!=r)return e.s=-r,u.plus(e);var f=u.e/z,s=e.e/z,c=u.c,a=e.c;if(!f||!s){if(!c||!a)return c?(e.s=-r,e):new P(a?u:NaN);if(!c[0]||!a[0])return a[0]?(e.s=-r,e):new P(c[0]?u:3==y?-0:0)}if(f=Z(f),s=Z(s),c=c.slice(),l=f-s){for((i=(o=l<0)?(l=-l,c):(s=f,a)).reverse(),r=l;r--;i.push(0));i.reverse()}else for(n=(o=(l=c.length)<(r=a.length))?l:r,l=r=0;r<n;r++)if(c[r]!=a[r]){o=c[r]<a[r];break}if(o&&(i=c,c=a,a=i,e.s=-e.s),0<(r=(n=a.length)-(t=c.length)))for(;r--;c[t++]=0);for(r=G-1;l<n;){if(c[--n]<a[n]){for(t=n;t&&!c[--t];c[t]=r);--c[t],c[n]+=G}c[n]-=a[n]}for(;0==c[0];c.splice(0,1),--s);return c[0]?T(e,c,s):(e.s=3==y?-1:1,e.c=[e.e=0],e)},t.modulo=t.mod=function(e,r){var t,n=this;return e=new P(e,r),!n.c||!e.s||e.c&&!e.c[0]?new P(NaN):!e.c||n.c&&!n.c[0]?new P(n):(9==i?(r=e.s,e.s=1,t=w(n,e,0,3),e.s=r,t.s*=r):t=w(n,e,0,i),(e=n.minus(t.times(e))).c[0]||1!=i||(e.s=n.s),e)},t.multipliedBy=t.times=function(e,r){var t,n,i,o,u,l,f,s,c,a,h,p=this,g=p.c,d=(e=new P(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=Z(p.e/z)+Z(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(c=d[n]%1e7,a=d[n]/1e7|(t=0),i=n+(o=l);n<i;)t=((f=c*(f=g[--o]%1e7)+(u=a*f+(s=g[o]/1e7|0)*c)%1e7*1e7+h[i]+t)/1e14|0)+(u/1e7|0)+a*s,h[i--]=f%1e14;h[i]=t}return t?++r:h.splice(0,1),T(e,h,r)},t.negated=function(){var e=new P(this);return e.s=-e.s||null,e},t.plus=function(e,r){var t,n=this,i=n.s;if(r=(e=new P(e,r)).s,!i||!r)return new P(NaN);if(i!=r)return e.s=-r,n.minus(e);var o=n.e/z,u=e.e/z,l=n.c,f=e.c;if(!o||!u){if(!l||!f)return new P(i/0);if(!l[0]||!f[0])return f[0]?e:new P(l[0]?n:0*i)}if(o=Z(o),u=Z(u),l=l.slice(),i=o-u){for((t=0<i?(u=o,f):(i=-i,l)).reverse();i--;t.push(0));t.reverse()}for((i=l.length)-(r=f.length)<0&&(t=f,f=l,l=t,r=i),i=0;r;)i=(l[--r]=l[r]+f[r]+i)/G|0,l[r]=G===l[r]?0:l[r]%G;return i&&(l=[i].concat(l),++u),T(e,l,u)},t.precision=t.sd=function(e,r){var t,n;if(null!=e&&e!==!!e)return J(e,1,W),null==r?r=y:J(r,0,8),I(new P(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 J(e,-q,q),this.times("1e"+e)},t.squareRoot=t.sqrt=function(){var e,r,t,n,i,o=this,u=o.c,l=o.s,f=o.e,s=v+4,c=new P("0.5");if(1!==l||!u||!u[0])return new P(!l||l<0&&(!u||u[0])?NaN:u?o:1/0);if((t=0==(l=Math.sqrt(+L(o)))||l==1/0?(((r=X(u)).length+f)%2==0&&(r+="0"),l=Math.sqrt(+r),f=Z((f+1)/2)-(f<0||f%2),new P(r=l==1/0?"5e"+f:(r=l.toExponential()).slice(0,r.indexOf("e")+1)+f)):new P(l+"")).c[0])for((l=(f=t.e)+s)<3&&(l=0);;)if(i=t,t=c.times(i.plus(w(o,i,s,1))),X(i.c).slice(0,l)===(r=X(t.c)).slice(0,l)){if(t.e<f&&--l,"9999"!=(r=r.slice(l-3,l+1))&&(n||"4999"!=r)){+r&&(+r.slice(1)||"5"!=r.charAt(0))||(I(t,t.e+v+2,1),e=!t.times(t).eq(o));break}if(!n&&(I(i,i.e+v+2,0),i.times(i).eq(o))){t=i;break}s+=4,l+=4,n=1}return I(t,t.e+v+1,y,e)},t.toExponential=function(e,r){return null!=e&&(J(e,0,W),e++),n(this,e,r,1)},t.toFixed=function(e,r){return null!=e&&(J(e,0,W),e=e+this.e+1),n(this,e,r)},t.toFormat=function(e,r,t){if(null==t)null!=e&&r&&"object"==C(r)?(t=r,r=null):e&&"object"==C(e)?(t=e,e=r=null):t=S;else if("object"!=C(t))throw Error(F+"Argument not an object: "+t);if(e=this.toFixed(e,r),this.c){var n,r=e.split("."),i=+t.groupSize,o=+t.secondaryGroupSize,u=t.groupSeparator||"",l=r[0],r=r[1],f=this.s<0,s=f?l.slice(1):l,c=s.length;if(o&&(n=i,i=o,c-=o=n),0<i&&0<c){for(l=s.substr(0,n=c%i||i);n<c;n+=i)l+=u+s.substr(n,i);0<o&&(l+=u+s.slice(n)),f&&(l="-"+l)}e=r?l+(t.decimalSeparator||"")+((o=+t.fractionGroupSize)?r.replace(new RegExp("\\d{"+o+"}\\B","g"),"$&"+(t.fractionGroupSeparator||"")):r):l}return(t.prefix||"")+e+(t.suffix||"")},t.toFraction=function(e){var r,t,n,i,o,u,l,f,s,c,a=this,h=a.c;if(null!=e&&(!(l=new P(e)).isInteger()&&(l.c||1!==l.s)||l.lt(g)))throw Error(F+"Argument "+(l.isInteger()?"out of range: ":"not an integer: ")+L(l));if(!h)return new P(a);for(r=new P(g),s=t=new P(g),n=f=new P(g),h=X(h),o=r.e=h.length-a.e-1,r.c[0]=H[(u=o%z)<0?z+u:u],e=!e||0<l.comparedTo(r)?0<o?r:s:l,u=E,E=1/0,l=new P(h),f.c[0]=0;c=w(l,r,0,1),1!=(i=t.plus(c.times(n))).comparedTo(e);)t=n,n=i,s=f.plus(c.times(i=s)),f=i,r=l.minus(c.times(i=r)),l=i;return i=w(e.minus(t),n,0,1),f=f.plus(i.times(s)),t=t.plus(i.times(n)),f.s=s.s=a.s,h=w(s,n,o*=2,y).minus(a).abs().comparedTo(w(f,t,o,y).minus(a).abs())<1?[s,n]:[f,t],E=u,h},t.toNumber=function(){return+L(this)},t.toPrecision=function(e,r){return null!=e&&J(e,1,W),n(this,e,r,2)},t.toString=function(e){var r,t=this,n=t.s,i=t.e;return null===i?n?(r="Infinity",n<0&&(r="-"+r)):r="NaN":(r=null==e?i<=d||b<=i?Q(X(t.c),i):ee(X(t.c),i,"0"):10===e&&x?ee(X((t=I(new P(t),v+i+1,y)).c),t.e,"0"):(J(e,2,_.length,"Base"),a(ee(X(t.c),i,"0"),10,e,n,!0)),n<0&&t.c[0]&&(r="-"+r)),r},t.valueOf=t.toJSON=function(){return L(this)},t._isBigNumber=!0,t[Symbol.toStringTag]="BigNumber",t[Symbol.for("nodejs.util.inspect.custom")]=t.valueOf,null!=e&&P.set(e),P}();function O(e,r){var t="",n=(t=w.isBigNumber(e)?e.toFixed():"string"!=typeof e?e.toString():e,null),e=null,i=null,o=r.match(/(<=|>=|=)\s*(\d+)/);if(o&&(e=o[1],n=Number(o[2])),r.includes(",")&&(i=!0),null!==n){var o=t.split("."),r=o[0],u=1===o.length?"":o[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!==i?1<(o=t.split(".")).length?((e=o[0]).includes("-")?o[0]=e[0]+e.slice(1).replace(/(?=(?!^)(?:\d{3})+$)/g,","):o[0]=e.replace(/(?=(?!^)(?:\d{3})+$)/g,","),o.join(".")):(r=o[0]).includes("-")?r[0]+r.slice(1).replace(/(?=(?!^)(?:\d{3})+$)/g,","):r.replace(/(?=(?!^)(?:\d{3})+$)/g,","):t}function E(e){for(var r=[],t=0,n=null,i=e.length;t<i;)if(n=e[t],/\s/.test(n))t++;else if("+-".includes(n)){var o=r[r.length-1];if(0===r.length||"+-".includes(o)||"("===o){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(/[a-zA-Z_]/.test(n)){for(var l="";/[a-zA-Z0-9_]/.test(n)&&(l+=n,!(++t>=i));)n=e[t];r.push(l)}else if(/\d/.test(n)){for(var f="";/[\d.]/.test(n)&&(f+=n,!(++t>=i));)n=e[t];r.push(f)}return r}var m=function(){o(n,c(Error));var t=a(n);function n(e){var r;return i(this,n),(r=t.call(this,e)).name="CalculatorError",r.message=e,r}return r(n)}(),N=function(){o(n,c(Error));var t=a(n);function n(e){var r;return i(this,n),(r=t.call(this,e)).name="TokensFillError",r.message=e,r}return r(n)}();function v(e,r){var t=r._fillData;return void 0===r._fillData&&(t=r),e.map(function(e){if(/^[a-zA-z_][\w_]*$/.test(e)){var r=t[e];if(void 0!==r)return"number"==typeof r?r.toString():r;throw new N("错误的参数:".concat(e," 请确认他存在"))}return e})}function A(e){for(var r,t=[],n=[],i=e;0<i.length;){var o=i.shift();if(p(o))if("("===o)t.push(o);else if(")"===o){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],g(o)<=g(r)&&0<t.length;)n.push(t.pop());t.push(o)}else n.push(o)}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 S(e){for(var r=[];0<e.length;){var t=e.shift();if(p(t)){if(r.length<2)throw new m("错误的栈长度, 可能是无法计算的表达式");var n=r.pop(),i=r.pop();if("string"==typeof n&&!w.isBigNumber(n)){if(!/^[+-]*[\d.]+$/.test(n))throw new m("".concat(n,"不是一个合法的数字"));n=new w(n)}if("string"==typeof i&&!w.isBigNumber(i)){if(!/^[+-]*[\d.]+$/.test(i))throw new m("".concat(i,"不是一个合法的数字"));i=new w(i)}switch(t){case"+":r.push(i.plus(n));break;case"-":r.push(i.minus(n));break;case"*":r.push(i.times(n));break;case"/":r.push(i.div(n));break;case"%":r.push(i.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=d(r),i=E(n.expr),o=null;if(null!==n.data)if(null===(o=void 0!==n.data._fillData?n.data:o)||void 0===o.fillError&&void 0===o.error)i=v(i,n.data);else try{i=v(i,n.data)}catch(e){if(e instanceof N)return void 0!==o.warn&&!0===o.warn&&console.warn(e),o.fillError||o.error;throw e}var i=A(i),u=null;if(null!==o){if(void 0!==o.calcError||void 0!==o.error)try{u=S(i)}catch(e){if(e instanceof m)return void 0!==o.warn&&!0===o.warn&&console.warn(e),void 0!==o.calcError?o.calcError:o.error;throw e}}else u=S(i);return u=null!==n.fmt?O(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=d(r),i=E(n.expr),o=null;if(2<i.length)throw new Error("fmt并非用于计算, 不能传入多个标识:".concat(n.expr));if(1!==i.length)throw new Error("fmt接收了一个无法被解析的标识");if(null!==n.data)if(null===(o=void 0!==n.data._fillData?n.data:o)||void 0===o.fillError&&void 0===o.error)i=v(i,n.data);else try{i=v(i,n.data)}catch(e){if(e instanceof TokensFillError)return o.fillError||o.error;throw e}if(null===n.fmt)throw"表达式没有格式化部分";return O(i[0],n.fmt)},e.version="0.0.38",Object.defineProperty(e,"__esModule",{value:!0}),e}({}); | ||
var a_calc=function(e){"use strict";function C(e){return(C="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function i(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}function n(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 r(e,r,t){return r&&n(e.prototype,r),t&&n(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function o(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&&u(e,r)}function l(e){return(l=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function u(e,r){return(u=Object.setPrototypeOf||function(e,r){return e.__proto__=r,e})(e,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(e){return!1}}function c(e,r,t){return(c=f()?Reflect.construct:function(e,r,t){var n=[null];n.push.apply(n,r);r=new(Function.bind.apply(e,n));return t&&u(r,t.prototype),r}).apply(null,arguments)}function s(e){var t="function"==typeof Map?new Map:void 0;return(s=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 c(e,arguments,l(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),u(r,e)})(e)}function b(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 a(t){var n=f();return function(){var e,r=l(t);return b(this,n?(e=l(this).constructor,Reflect.construct(r,arguments,e)):r.apply(this,arguments))}}function O(e){return function(e){if(Array.isArray(e))return h(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 h(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)?h(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 h(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 p(e){return-1<"+-*/%()".indexOf(e)}function g(e){switch(e){case"+":case"-":return 1;case"*":case"/":case"%":return 2;default:return 0}}function w(){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 _(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(u=n,"[object Object]"!==Object.prototype.toString.call(u)||Array.isArray(u))for(var i=O(e.shift());i.length||e.length;)var o=0===i.length?"":i.shift(),l=0===e.length?"":e.shift(),t=t+o+(l="number"==typeof l?l.toString():l);else t=e[0],r.data=n}var u=t.split("|");return 1===u.length?r.expr=u[0]:(r.expr=u[0],""!==(n=u[1]).trim()&&(r.fmt=n)),r}var ee=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,M=Math.ceil,k=Math.floor,F="[BigNumber Error] ",re=F+"Number primitive has more than 15 significant digits: ",$=1e14,G=14,z=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 Z(e){for(var r,t,n=1,i=e.length,o=e[0]+"";n<i;){for(r=e[n++]+"",t=G-r.length;t--;r="0"+r);o+=r}for(i=o.length;48===o.charCodeAt(--i););return o.slice(0,i+1||1)}function X(e,r){var t,n,i=e.c,o=r.c,l=e.s,u=r.s,e=e.e,r=r.e;if(!l||!u)return null;if(t=i&&!i[0],n=o&&!o[0],t||n)return t?n?0:-u:l;if(l!=u)return l;if(t=l<0,n=e==r,!i||!o)return n?0:!i^t?1:-1;if(!n)return r<e^t?1:-1;for(u=(e=i.length)<(r=o.length)?e:r,l=0;l<u;l++)if(i[l]!=o[l])return i[l]>o[l]^t?1:-1;return e==r?0:r<e^t?1:-1}function Y(e,r,t,n){if(e<r||t<e||e!==k(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 J(e){var r=e.c.length-1;return W(e.e/G)==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,i;if(r<0){for(i=t+".";++r;i+=t);e=i+e}else if(++r>(n=e.length)){for(i=t,r-=n;--r;i+=t);e+=i}else r<n&&(e=e.slice(0,r)+"."+e.slice(r));return e}var d=function U(e){var d,a,h,r,c,m,l,u,f,s,p,t=D.prototype={constructor:D,toString:null,valueOf:null},g=new D(1),v=20,y=4,w=-7,b=21,O=-1e7,_=1e7,E=!1,i=1,N=0,A={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},S="0123456789abcdefghijklmnopqrstuvwxyz",x=!0;function D(e,r){var t,n,i,o,l,u,f,c,s=this;if(!(s instanceof D))return new D(e,r);if(null==r){if(e&&!0===e._isBigNumber)return s.s=e.s,void(!e.c||e.e>_?s.c=s.e=null:e.e<O?s.c=[s.e=0]:(s.e=e.e,s.c=e.c.slice()));if((u="number"==typeof e)&&0*e==0){if(s.s=1/e<0?(e=-e,-1):1,e===~~e){for(o=0,l=e;10<=l;l/=10,o++);return void(_<o?s.c=s.e=null:(s.e=o,s.c=[e]))}c=String(e)}else{if(!ee.test(c=String(e)))return h(s,c,u);s.s=45==c.charCodeAt(0)?(c=c.slice(1),-1):1}0<(l=(c=-1<(o=c.indexOf("."))?c.replace(".",""):c).search(/e/i))?(o<0&&(o=l),o+=+c.slice(l+1),c=c.substring(0,l)):o<0&&(o=c.length)}else{if(Y(r,2,S.length,"Base"),10==r&&x)return I(s=new D(e),v+s.e+1,y);if(c=String(e),u="number"==typeof e){if(0*e!=0)return h(s,c,u,r);if(s.s=1/e<0?(c=c.slice(1),-1):1,D.DEBUG&&15<c.replace(/^0\.0*|\./,"").length)throw Error(re+e)}else s.s=45===c.charCodeAt(0)?(c=c.slice(1),-1):1;for(t=S.slice(0,r),o=l=0,f=c.length;l<f;l++)if(t.indexOf(n=c.charAt(l))<0){if("."==n){if(o<l){o=f;continue}}else if(!i&&(c==c.toUpperCase()&&(c=c.toLowerCase())||c==c.toLowerCase()&&(c=c.toUpperCase()))){i=!0,l=-1,o=0;continue}return h(s,String(e),u,r)}u=!1,-1<(o=(c=a(c,r,10,s.s)).indexOf("."))?c=c.replace(".",""):o=c.length}for(l=0;48===c.charCodeAt(l);l++);for(f=c.length;48===c.charCodeAt(--f););if(c=c.slice(l,++f)){if(f-=l,u&&D.DEBUG&&15<f&&(z<e||e!==k(e)))throw Error(re+s.s*e);if((o=o-l-1)>_)s.c=s.e=null;else if(o<O)s.c=[s.e=0];else{if(s.e=o,s.c=[],l=(o+1)%G,o<0&&(l+=G),l<f){for(l&&s.c.push(+c.slice(0,l)),f-=G;l<f;)s.c.push(+c.slice(l,l+=G));l=G-(c=c.slice(l)).length}else l-=f;for(;l--;c+="0");s.c.push(+c)}}else s.c=[s.e=0]}function P(e,r,t,n){for(var i,o,l=[0],u=0,f=e.length;u<f;){for(o=l.length;o--;l[o]*=r);for(l[0]+=n.indexOf(e.charAt(u++)),i=0;i<l.length;i++)l[i]>t-1&&(null==l[i+1]&&(l[i+1]=0),l[i+1]+=l[i]/t|0,l[i]%=t)}return l.reverse()}function R(e,r,t){var n,i,o,l=0,u=e.length,f=r%H,c=r/H|0;for(e=e.slice();u--;)l=((i=f*(o=e[u]%H)+(n=c*o+(o=e[u]/H|0)*f)%H*H+l)/t|0)+(n/H|0)+c*o,e[u]=i%t;return e=l?[l].concat(e):e}function j(e,r,t,n){var i,o;if(t!=n)o=n<t?1:-1;else for(i=o=0;i<t;i++)if(e[i]!=r[i]){o=e[i]>r[i]?1:-1;break}return o}function B(e,r,t,n){for(var i=0;t--;)e[t]-=i,i=e[t]<r[t]?1:0,e[t]=i*n+e[t]-r[t];for(;!e[0]&&1<e.length;e.splice(0,1));}function n(e,r,t,n){var i,o,l,u;if(null==t?t=y:Y(t,0,8),!e.c)return e.toString();if(i=e.c[0],o=e.e,null==r)u=Z(e.c),u=1==n||2==n&&(o<=w||b<=o)?K(u,o):Q(u,o,"0");else if(t=(e=I(new D(e),r,t)).e,l=(u=Z(e.c)).length,1==n||2==n&&(r<=t||t<=w)){for(;l<r;u+="0",l++);u=K(u,t)}else if(r-=o,u=Q(u,t,"0"),l<t+1){if(0<--r)for(u+=".";r--;u+="0");}else if(0<(r+=t-l))for(t+1==l&&(u+=".");r--;u+="0");return e.s<0&&i?"-"+u:u}function o(e,r){for(var t,n=1,i=new D(e[0]);n<e.length;n++){if(!(t=new D(e[n])).s){i=t;break}r.call(i,t)&&(i=t)}return i}function T(e,r,t){for(var n=1,i=r.length;!r[--i];r.pop());for(i=r[0];10<=i;i/=10,n++);return(t=n+t*G-1)>_?e.c=e.e=null:t<O?e.c=[e.e=0]:(e.e=t,e.c=r),e}function I(e,r,t,n){var i,o,l,u,f,c,s,a=e.c,h=q;if(a){e:{for(i=1,u=a[0];10<=u;u/=10,i++);if((o=r-i)<0)o+=G,l=r,s=(f=a[c=0])/h[i-l-1]%10|0;else if((c=M((o+1)/G))>=a.length){if(!n)break e;for(;a.length<=c;a.push(0));f=s=0,l=(o%=G)-G+(i=1)}else{for(f=u=a[c],i=1;10<=u;u/=10,i++);s=(l=(o%=G)-G+i)<0?0:f/h[i-l-1]%10|0}if(n=n||r<0||null!=a[c+1]||(l<0?f:f%h[i-l-1]),n=t<4?(s||n)&&(0==t||t==(e.s<0?3:2)):5<s||5==s&&(4==t||n||6==t&&(0<o?0<l?f/h[i-l]:0:a[c-1])%10&1||t==(e.s<0?8:7)),r<1||!a[0])return a.length=0,n?(r-=e.e+1,a[0]=h[(G-r%G)%G],e.e=-r||0):a[0]=e.e=0,e;if(0==o?(a.length=c,u=1,c--):(a.length=c+1,u=h[G-o],a[c]=0<l?k(f/h[i-l]%h[l])*u:0),n)for(;;){if(0==c){for(o=1,l=a[0];10<=l;l/=10,o++);for(l=a[0]+=u,u=1;10<=l;l/=10,u++);o!=u&&(e.e++,a[0]==$&&(a[0]=1));break}if(a[c]+=u,a[c]!=$)break;a[c--]=0,u=1}for(o=a.length;0===a[--o];a.pop());}e.e>_?e.c=e.e=null:e.e<O&&(e.c=[e.e=0])}return e}function L(e){var r,t=e.e;return null===t?e.toString():(r=Z(e.c),r=t<=w||b<=t?K(r,t):Q(r,t,"0"),e.s<0?"-"+r:r)}return D.clone=U,D.ROUND_UP=0,D.ROUND_DOWN=1,D.ROUND_CEIL=2,D.ROUND_FLOOR=3,D.ROUND_HALF_UP=4,D.ROUND_HALF_DOWN=5,D.ROUND_HALF_EVEN=6,D.ROUND_HALF_CEIL=7,D.ROUND_HALF_FLOOR=8,D.EUCLID=9,D.config=D.set=function(e){var r,t;if(null!=e){if("object"!=C(e))throw Error(F+"Object expected: "+e);if(e.hasOwnProperty(r="DECIMAL_PLACES")&&(Y(t=e[r],0,V,r),v=t),e.hasOwnProperty(r="ROUNDING_MODE")&&(Y(t=e[r],0,8,r),y=t),e.hasOwnProperty(r="EXPONENTIAL_AT")&&((t=e[r])&&t.pop?(Y(t[0],-V,0,r),Y(t[1],0,V,r),w=t[0],b=t[1]):(Y(t,-V,V,r),w=-(b=t<0?-t:t))),e.hasOwnProperty(r="RANGE"))if((t=e[r])&&t.pop)Y(t[0],-V,-1,r),Y(t[1],1,V,r),O=t[0],_=t[1];else{if(Y(t,-V,V,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 E=!t,Error(F+"crypto unavailable");E=t}else E=t}if(e.hasOwnProperty(r="MODULO_MODE")&&(Y(t=e[r],0,9,r),i=t),e.hasOwnProperty(r="POW_PRECISION")&&(Y(t=e[r],0,V,r),N=t),e.hasOwnProperty(r="FORMAT")){if("object"!=C(t=e[r]))throw Error(F+r+" not an object: "+t);A=t}if(e.hasOwnProperty(r="ALPHABET")){if("string"!=typeof(t=e[r])||/^.?$|[+\-.\s]|(.).*\1/.test(t))throw Error(F+r+" invalid: "+t);x="0123456789"==t.slice(0,10),S=t}}return{DECIMAL_PLACES:v,ROUNDING_MODE:y,EXPONENTIAL_AT:[w,b],RANGE:[O,_],CRYPTO:E,MODULO_MODE:i,POW_PRECISION:N,FORMAT:A,ALPHABET:S}},D.isBigNumber=function(e){if(!e||!0!==e._isBigNumber)return!1;if(!D.DEBUG)return!0;var r,t,n=e.c,i=e.e,o=e.s;e:if("[object Array]"=={}.toString.call(n)){if((1===o||-1===o)&&-V<=i&&i<=V&&i===k(i))if(0===n[0]){if(0===i&&1===n.length)return!0}else if((r=(i+1)%G)<1&&(r+=G),String(n[0]).length==r){for(r=0;r<n.length;r++)if((t=n[r])<0||$<=t||t!==k(t))break e;if(0!==t)return!0}}else if(null===n&&null===i&&(null===o||1===o||-1===o))return!0;throw Error(F+"Invalid BigNumber: "+e)},D.maximum=D.max=function(){return o(arguments,t.lt)},D.minimum=D.min=function(){return o(arguments,t.gt)},D.random=(r=9007199254740992,c=Math.random()*r&2097151?function(){return k(Math.random()*r)}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)},function(e){var r,t,n,i,o,l=0,u=[],f=new D(g);if(null==e?e=v:Y(e,0,V),i=M(e/G),E)if(crypto.getRandomValues){for(r=crypto.getRandomValues(new Uint32Array(i*=2));l<i;)9e15<=(o=131072*r[l]+(r[l+1]>>>11))?(t=crypto.getRandomValues(new Uint32Array(2)),r[l]=t[0],r[l+1]=t[1]):(u.push(o%1e14),l+=2);l=i/2}else{if(!crypto.randomBytes)throw E=!1,Error(F+"crypto unavailable");for(r=crypto.randomBytes(i*=7);l<i;)9e15<=(o=281474976710656*(31&r[l])+1099511627776*r[l+1]+4294967296*r[l+2]+16777216*r[l+3]+(r[l+4]<<16)+(r[l+5]<<8)+r[l+6])?crypto.randomBytes(7).copy(r,l):(u.push(o%1e14),l+=7);l=i/7}if(!E)for(;l<i;)(o=c())<9e15&&(u[l++]=o%1e14);for(i=u[--l],e%=G,i&&e&&(u[l]=k(i/(o=q[G-e]))*o);0===u[l];u.pop(),l--);if(l<0)u=[n=0];else{for(n=-1;0===u[0];u.splice(0,1),n-=G);for(l=1,o=u[0];10<=o;o/=10,l++);l<G&&(n-=G-l)}return f.e=n,f.c=u,f}),D.sum=function(){for(var e=1,r=arguments,t=new D(r[0]);e<r.length;)t=t.plus(r[e++]);return t},m="0123456789",a=function(e,r,t,n,i){var o,l,u,f,c,s,a,h,p=e.indexOf("."),g=v,w=y;for(0<=p&&(f=N,N=0,e=e.replace(".",""),s=(h=new D(r)).pow(e.length-p),N=f,h.c=P(Q(Z(s.c),s.e,"0"),10,t,m),h.e=h.c.length),u=f=(a=P(e,r,t,i?(o=S,m):(o=m,S))).length;0==a[--f];a.pop());if(!a[0])return o.charAt(0);if(p<0?--u:(s.c=a,s.e=u,s.s=n,a=(s=d(s,h,g,w,t)).c,c=s.r,u=s.e),p=a[l=u+g+1],f=t/2,c=c||l<0||null!=a[l+1],c=w<4?(null!=p||c)&&(0==w||w==(s.s<0?3:2)):f<p||p==f&&(4==w||c||6==w&&1&a[l-1]||w==(s.s<0?8:7)),l<1||!a[0])e=c?Q(o.charAt(1),-g,o.charAt(0)):o.charAt(0);else{if(a.length=l,c)for(--t;++a[--l]>t;)a[l]=0,l||(++u,a=[1].concat(a));for(f=a.length;!a[--f];);for(p=0,e="";p<=f;e+=o.charAt(a[p++]));e=Q(e,u,o.charAt(0))}return e},d=function(e,r,t,n,i){var o,l,u,f,c,s,a,h,p,g,w,d,m,v,y,b,O,_=e.s==r.s?1:-1,E=e.c,N=r.c;if(!(E&&E[0]&&N&&N[0]))return new D(e.s&&r.s&&(E?!N||E[0]!=N[0]:N)?E&&0==E[0]||!N?0*_:_/0:NaN);for(p=(h=new D(_)).c=[],_=t+(l=e.e-r.e)+1,i||(i=$,l=W(e.e/G)-W(r.e/G),_=_/G|0),u=0;N[u]==(E[u]||0);u++);if(N[u]>(E[u]||0)&&l--,_<0)p.push(1),f=!0;else{for(v=E.length,b=N.length,_+=2,1<(c=k(i/(N[u=0]+1)))&&(N=R(N,c,i),E=R(E,c,i),b=N.length,v=E.length),m=b,w=(g=E.slice(0,b)).length;w<b;g[w++]=0);O=N.slice(),O=[0].concat(O),y=N[0],N[1]>=i/2&&y++;do{if(c=0,(o=j(N,g,b,w))<0){if(d=g[0],b!=w&&(d=d*i+(g[1]||0)),1<(c=k(d/y)))for(a=(s=R(N,c=i<=c?i-1:c,i)).length,w=g.length;1==j(s,g,a,w);)c--,B(s,b<a?O:N,a,i),a=s.length,o=1;else 0==c&&(o=c=1),a=(s=N.slice()).length;if(B(g,s=a<w?[0].concat(s):s,w,i),w=g.length,-1==o)for(;j(N,g,b,w)<1;)c++,B(g,b<w?O:N,w,i),w=g.length}else 0===o&&(c++,g=[0])}while(p[u++]=c,g[0]?g[w++]=E[m]||0:(g=[E[m]],w=1),(m++<v||null!=g[0])&&_--);f=null!=g[0],p[0]||p.splice(0,1)}if(i==$){for(u=1,_=p[0];10<=_;_/=10,u++);I(h,t+(h.e=u+l*G-1)+1,n,f)}else h.e=l,h.r=+f;return h},l=/^(-?)0([xbo])(?=\w[\w.]*$)/i,u=/^([^.]+)\.$/,f=/^\.([^.]+)$/,s=/^-?(Infinity|NaN)$/,p=/^\s*\+(?=[\w.])|^\s+|\s+$/g,h=function(e,r,t,n){var i,o=t?r:r.replace(p,"");if(s.test(o))e.s=isNaN(o)?null:o<0?-1:1;else{if(!t&&(o=o.replace(l,function(e,r,t){return i="x"==(t=t.toLowerCase())?16:"b"==t?2:8,n&&n!=i?e:r}),n&&(i=n,o=o.replace(u,"$1").replace(f,"0.$1")),r!=o))return new D(o,i);if(D.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 D(this);return e.s<0&&(e.s=1),e},t.comparedTo=function(e,r){return X(this,new D(e,r))},t.decimalPlaces=t.dp=function(e,r){var t,n;if(null!=e)return Y(e,0,V),null==r?r=y:Y(r,0,8),I(new D(this),e+this.e+1,r);if(!(e=this.c))return null;if(t=((n=e.length-1)-W(this.e/G))*G,n=e[n])for(;n%10==0;n/=10,t--);return t=t<0?0:t},t.dividedBy=t.div=function(e,r){return d(this,new D(e,r),v,y)},t.dividedToIntegerBy=t.idiv=function(e,r){return d(this,new D(e,r),0,1)},t.exponentiatedBy=t.pow=function(e,r){var t,n,i,o,l,u,f,c,s=this;if((e=new D(e)).c&&!e.isInteger())throw Error(F+"Exponent not an integer: "+L(e));if(null!=r&&(r=new D(r)),l=14<e.e,!s.c||!s.c[0]||1==s.c[0]&&!s.e&&1==s.c.length||!e.c||!e.c[0])return c=new D(Math.pow(+L(s),l?2-J(e):+L(e))),r?c.mod(r):c;if(u=e.s<0,r){if(r.c?!r.c[0]:!r.s)return new D(NaN);(n=!u&&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]||l&&24e7<=s.c[1]:s.c[0]<8e13||l&&s.c[0]<=9999975e7)))return o=s.s<0&&J(e)?-0:0,-1<s.e&&(o=1/o),new D(u?1/o:o);N&&(o=M(N/G+2))}for(f=l?(t=new D(.5),u&&(e.s=1),J(e)):(i=Math.abs(+L(e)))%2,c=new D(g);;){if(f){if(!(c=c.times(s)).c)break;o?c.c.length>o&&(c.c.length=o):n&&(c=c.mod(r))}if(i){if(0===(i=k(i/2)))break;f=i%2}else if(I(e=e.times(t),e.e+1,1),14<e.e)f=J(e);else{if(0==(i=+L(e)))break;f=i%2}s=s.times(s),o?s.c&&s.c.length>o&&(s.c.length=o):n&&(s=s.mod(r))}return n?c:(u&&(c=g.div(c)),r?c.mod(r):o?I(c,N,y,void 0):c)},t.integerValue=function(e){var r=new D(this);return null==e?e=y:Y(e,0,8),I(r,r.e+1,e)},t.isEqualTo=t.eq=function(e,r){return 0===X(this,new D(e,r))},t.isFinite=function(){return!!this.c},t.isGreaterThan=t.gt=function(e,r){return 0<X(this,new D(e,r))},t.isGreaterThanOrEqualTo=t.gte=function(e,r){return 1===(r=X(this,new D(e,r)))||0===r},t.isInteger=function(){return!!this.c&&W(this.e/G)>this.c.length-2},t.isLessThan=t.lt=function(e,r){return X(this,new D(e,r))<0},t.isLessThanOrEqualTo=t.lte=function(e,r){return-1===(r=X(this,new D(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,i,o,l=this,u=l.s;if(r=(e=new D(e,r)).s,!u||!r)return new D(NaN);if(u!=r)return e.s=-r,l.plus(e);var f=l.e/G,c=e.e/G,s=l.c,a=e.c;if(!f||!c){if(!s||!a)return s?(e.s=-r,e):new D(a?l:NaN);if(!s[0]||!a[0])return a[0]?(e.s=-r,e):new D(s[0]?l:3==y?-0:0)}if(f=W(f),c=W(c),s=s.slice(),u=f-c){for((i=(o=u<0)?(u=-u,s):(c=f,a)).reverse(),r=u;r--;i.push(0));i.reverse()}else for(n=(o=(u=s.length)<(r=a.length))?u:r,u=r=0;r<n;r++)if(s[r]!=a[r]){o=s[r]<a[r];break}if(o&&(i=s,s=a,a=i,e.s=-e.s),0<(r=(n=a.length)-(t=s.length)))for(;r--;s[t++]=0);for(r=$-1;u<n;){if(s[--n]<a[n]){for(t=n;t&&!s[--t];s[t]=r);--s[t],s[n]+=$}s[n]-=a[n]}for(;0==s[0];s.splice(0,1),--c);return s[0]?T(e,s,c):(e.s=3==y?-1:1,e.c=[e.e=0],e)},t.modulo=t.mod=function(e,r){var t,n=this;return e=new D(e,r),!n.c||!e.s||e.c&&!e.c[0]?new D(NaN):!e.c||n.c&&!n.c[0]?new D(n):(9==i?(r=e.s,e.s=1,t=d(n,e,0,3),e.s=r,t.s*=r):t=d(n,e,0,i),(e=n.minus(t.times(e))).c[0]||1!=i||(e.s=n.s),e)},t.multipliedBy=t.times=function(e,r){var t,n,i,o,l,u,f,c,s,a,h,p=this,g=p.c,w=(e=new D(e,r)).c;if(!(g&&w&&g[0]&&w[0]))return!p.s||!e.s||g&&!g[0]&&!w||w&&!w[0]&&!g?e.c=e.e=e.s=null:(e.s*=p.s,g&&w?(e.c=[0],e.e=0):e.c=e.e=null),e;for(r=W(p.e/G)+W(e.e/G),e.s*=p.s,(u=g.length)<(p=w.length)&&(h=g,g=w,w=h,n=u,u=p,p=n),n=u+p,h=[];n--;h.push(0));for(n=p;0<=--n;){for(s=w[n]%1e7,a=w[n]/1e7|(t=0),i=n+(o=u);n<i;)t=((f=s*(f=g[--o]%1e7)+(l=a*f+(c=g[o]/1e7|0)*s)%1e7*1e7+h[i]+t)/1e14|0)+(l/1e7|0)+a*c,h[i--]=f%1e14;h[i]=t}return t?++r:h.splice(0,1),T(e,h,r)},t.negated=function(){var e=new D(this);return e.s=-e.s||null,e},t.plus=function(e,r){var t,n=this,i=n.s;if(r=(e=new D(e,r)).s,!i||!r)return new D(NaN);if(i!=r)return e.s=-r,n.minus(e);var o=n.e/G,l=e.e/G,u=n.c,f=e.c;if(!o||!l){if(!u||!f)return new D(i/0);if(!u[0]||!f[0])return f[0]?e:new D(u[0]?n:0*i)}if(o=W(o),l=W(l),u=u.slice(),i=o-l){for((t=0<i?(l=o,f):(i=-i,u)).reverse();i--;t.push(0));t.reverse()}for((i=u.length)-(r=f.length)<0&&(t=f,f=u,u=t,r=i),i=0;r;)i=(u[--r]=u[r]+f[r]+i)/$|0,u[r]=$===u[r]?0:u[r]%$;return i&&(u=[i].concat(u),++l),T(e,u,l)},t.precision=t.sd=function(e,r){var t,n;if(null!=e&&e!==!!e)return Y(e,1,V),null==r?r=y:Y(r,0,8),I(new D(this),e,r);if(!(r=this.c))return null;if(t=(n=r.length-1)*G+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 Y(e,-z,z),this.times("1e"+e)},t.squareRoot=t.sqrt=function(){var e,r,t,n,i,o=this,l=o.c,u=o.s,f=o.e,c=v+4,s=new D("0.5");if(1!==u||!l||!l[0])return new D(!u||u<0&&(!l||l[0])?NaN:l?o:1/0);if((t=0==(u=Math.sqrt(+L(o)))||u==1/0?(((r=Z(l)).length+f)%2==0&&(r+="0"),u=Math.sqrt(+r),f=W((f+1)/2)-(f<0||f%2),new D(r=u==1/0?"5e"+f:(r=u.toExponential()).slice(0,r.indexOf("e")+1)+f)):new D(u+"")).c[0])for((u=(f=t.e)+c)<3&&(u=0);;)if(i=t,t=s.times(i.plus(d(o,i,c,1))),Z(i.c).slice(0,u)===(r=Z(t.c)).slice(0,u)){if(t.e<f&&--u,"9999"!=(r=r.slice(u-3,u+1))&&(n||"4999"!=r)){+r&&(+r.slice(1)||"5"!=r.charAt(0))||(I(t,t.e+v+2,1),e=!t.times(t).eq(o));break}if(!n&&(I(i,i.e+v+2,0),i.times(i).eq(o))){t=i;break}c+=4,u+=4,n=1}return I(t,t.e+v+1,y,e)},t.toExponential=function(e,r){return null!=e&&(Y(e,0,V),e++),n(this,e,r,1)},t.toFixed=function(e,r){return null!=e&&(Y(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"==C(r)?(t=r,r=null):e&&"object"==C(e)?(t=e,e=r=null):t=A;else if("object"!=C(t))throw Error(F+"Argument not an object: "+t);if(e=this.toFixed(e,r),this.c){var n,r=e.split("."),i=+t.groupSize,o=+t.secondaryGroupSize,l=t.groupSeparator||"",u=r[0],r=r[1],f=this.s<0,c=f?u.slice(1):u,s=c.length;if(o&&(n=i,i=o,s-=o=n),0<i&&0<s){for(u=c.substr(0,n=s%i||i);n<s;n+=i)u+=l+c.substr(n,i);0<o&&(u+=l+c.slice(n)),f&&(u="-"+u)}e=r?u+(t.decimalSeparator||"")+((o=+t.fractionGroupSize)?r.replace(new RegExp("\\d{"+o+"}\\B","g"),"$&"+(t.fractionGroupSeparator||"")):r):u}return(t.prefix||"")+e+(t.suffix||"")},t.toFraction=function(e){var r,t,n,i,o,l,u,f,c,s,a=this,h=a.c;if(null!=e&&(!(u=new D(e)).isInteger()&&(u.c||1!==u.s)||u.lt(g)))throw Error(F+"Argument "+(u.isInteger()?"out of range: ":"not an integer: ")+L(u));if(!h)return new D(a);for(r=new D(g),c=t=new D(g),n=f=new D(g),h=Z(h),o=r.e=h.length-a.e-1,r.c[0]=q[(l=o%G)<0?G+l:l],e=!e||0<u.comparedTo(r)?0<o?r:c:u,l=_,_=1/0,u=new D(h),f.c[0]=0;s=d(u,r,0,1),1!=(i=t.plus(s.times(n))).comparedTo(e);)t=n,n=i,c=f.plus(s.times(i=c)),f=i,r=u.minus(s.times(i=r)),u=i;return i=d(e.minus(t),n,0,1),f=f.plus(i.times(c)),t=t.plus(i.times(n)),f.s=c.s=a.s,h=d(c,n,o*=2,y).minus(a).abs().comparedTo(d(f,t,o,y).minus(a).abs())<1?[c,n]:[f,t],_=l,h},t.toNumber=function(){return+L(this)},t.toPrecision=function(e,r){return null!=e&&Y(e,1,V),n(this,e,r,2)},t.toString=function(e){var r,t=this,n=t.s,i=t.e;return null===i?n?(r="Infinity",n<0&&(r="-"+r)):r="NaN":(r=null==e?i<=w||b<=i?K(Z(t.c),i):Q(Z(t.c),i,"0"):10===e&&x?Q(Z((t=I(new D(t),v+i+1,y)).c),t.e,"0"):(Y(e,2,S.length,"Base"),a(Q(Z(t.c),i,"0"),10,e,n,!0)),n<0&&t.c[0]&&(r="-"+r)),r},t.valueOf=t.toJSON=function(){return L(this)},t._isBigNumber=!0,t[Symbol.toStringTag]="BigNumber",t[Symbol.for("nodejs.util.inspect.custom")]=t.valueOf,null!=e&&D.set(e),D}();function E(e,r){var t="",n=(t=d.isBigNumber(e)?e.toFixed():"string"!=typeof e?e.toString():e,null),e=null,i=null,o=r.match(/(<=|>=|=)\s*(\d+)/);if(o&&(e=o[1],n=Number(o[2])),r.includes(",")&&(i=!0),null!==n){var o=t.split("."),r=o[0],l=1===o.length?"":o[1],u=l.length;switch(e){case"<=":l=u<=n?l:l.slice(0,n);break;case"=":u<n?l+="0".repeat(n-u):n<u&&(l=l.slice(0,n));break;case">=":l=n<=u?l:l+"0".repeat(n-u)}t=""===l?r:"".concat(r,".").concat(l)}return t=null!==i?1<(o=t.split(".")).length?((e=o[0]).includes("-")?o[0]=e[0]+e.slice(1).replace(/(?=(?!^)(?:\d{3})+$)/g,","):o[0]=e.replace(/(?=(?!^)(?:\d{3})+$)/g,","),o.join(".")):(r=o[0]).includes("-")?r[0]+r.slice(1).replace(/(?=(?!^)(?:\d{3})+$)/g,","):r.replace(/(?=(?!^)(?:\d{3})+$)/g,","):t}function N(e){for(var r=[],t=0,n=null,i=e.length;t<i;)if(n=e[t],/\s/.test(n))t++;else if("+-".includes(n)){var o=r[r.length-1];if(0===r.length||"+-".includes(o)||"("===o){for(var l=n,n=e[++t];/[a-zA-Z\d._]/.test(n);)l+=n,n=e[++t];r.push(l)}else r.push(n),t++}else if("*/%()".includes(n))r.push(n),t++;else if(/[a-zA-Z_]/.test(n)){for(var u="";/[a-zA-Z0-9_]/.test(n)&&(u+=n,!(++t>=i));)n=e[t];r.push(u)}else if(/\d/.test(n)){for(var f="";/[\d.]/.test(n)&&(f+=n,!(++t>=i));)n=e[t];r.push(f)}return r}var m=function(){o(n,s(Error));var t=a(n);function n(e){var r;return i(this,n),(r=t.call(this,e)).name="CalculatorError",r.message=e,r}return r(n)}(),v=function(){o(n,s(Error));var t=a(n);function n(e){var r;return i(this,n),(r=t.call(this,e)).name="TokensFillError",r.message=e,r}return r(n)}();function y(e,r){var t=r._fillData;return void 0===r._fillData&&(t=r),e.map(function(e){if(/^[a-zA-z_][\w_]*$/.test(e)){var r=t[e];if(void 0!==r)return"number"==typeof r?r.toString():r;throw new v("错误的参数:".concat(e," 请确认他存在"))}return e})}function A(e){for(var r,t=[],n=[],i=e;0<i.length;){var o=i.shift();if(p(o))if("("===o)t.push(o);else if(")"===o){for(var l=t.pop();"("!==l&&0<t.length;)n.push(l),l=t.pop();if("("!==l)throw"error: unmatched ()"}else{for(;r=t[t.length-1],g(o)<=g(r)&&0<t.length;)n.push(t.pop());t.push(o)}else n.push(o)}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 S(e){for(var r=[];0<e.length;){var t=e.shift();if(p(t)){if(r.length<2)throw new m("错误的栈长度, 可能是无法计算的表达式");var n=r.pop(),i=r.pop();if("string"==typeof n&&!d.isBigNumber(n)){if(!/^[+-]*[\d.]+$/.test(n))throw new m("".concat(n,"不是一个合法的数字"));n=new d(n)}if("string"==typeof i&&!d.isBigNumber(i)){if(!/^[+-]*[\d.]+$/.test(i))throw new m("".concat(i,"不是一个合法的数字"));i=new d(i)}switch(t){case"+":r.push(i.plus(n));break;case"-":r.push(i.minus(n));break;case"*":r.push(i.times(n));break;case"/":r.push(i.div(n));break;case"%":r.push(i.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),i=N(n.expr),o=null;if(null!==n.data){var l=n.data;if(null!==(o=w(l._fillData,l._error,l._fillError,l._calcError)?l:o)&&void 0!==l._fillData&&w(o._fillError,o._error))try{i=y(i,l._fillData)}catch(e){if(e instanceof v)return void 0!==o._warn&&!0===o._warn&&console.warn(e),o._fillError||o._error;throw e}else i=y(i,l)}if(l=A(i),(i=null)!==o){if(void 0!==o._calcError||void 0!==o._error)try{i=S(l)}catch(e){if(e instanceof m)return void 0!==o._warn&&!0===o._warn&&console.warn(e),void 0!==o._calcError?o._calcError:o._error;throw e}}else i=S(l);return i=null!==n.fmt?E(i,n.fmt):null!==i?i.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),i=N(n.expr),o=null;if(""===n.expr.trim()&&void 0!==n.data&&void 0!==n.data._error)return n.data._error;if(2<i.length)throw new Error("fmt并非用于计算, 不能传入多个标识:".concat(n.expr));if(1!==i.length)throw new Error("fmt接收了一个无法被解析的标识");if(null!==n.data){var l=n.data;if(null!==(o=w(l._fillData,l._error,l._fillError)?l:o)&&void 0!==l._fillData&&w(o._fillError,o._error))try{i=y(i,l._fillData)}catch(e){if(e instanceof v)return void 0!==o._warn&&!0===o._warn&&console.warn(e),o._fillError||o._error;throw e}else i=y(i,l)}if(null===n.fmt)throw"表达式没有格式化部分";return E(i[0],n.fmt)},e.version="0.0.42",Object.defineProperty(e,"__esModule",{value:!0}),e}({}); |
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var BigNumber=require("bignumber.js");function _interopDefaultLegacy(r){return r&&"object"==typeof r&&"default"in r?r:{default:r}}var BigNumber__default=_interopDefaultLegacy(BigNumber);function _classCallCheck(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}function _defineProperties(r,e){for(var t=0;t<e.length;t++){var n=e[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(r,n.key,n)}}function _createClass(r,e,t){return e&&_defineProperties(r.prototype,e),t&&_defineProperties(r,t),Object.defineProperty(r,"prototype",{writable:!1}),r}function _inherits(r,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),Object.defineProperty(r,"prototype",{writable:!1}),e&&_setPrototypeOf(r,e)}function _getPrototypeOf(r){return(_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)})(r)}function _setPrototypeOf(r,e){return(_setPrototypeOf=Object.setPrototypeOf||function(r,e){return r.__proto__=e,r})(r,e)}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(r){return!1}}function _construct(r,e,t){return(_construct=_isNativeReflectConstruct()?Reflect.construct:function(r,e,t){var n=[null];n.push.apply(n,e);e=new(Function.bind.apply(r,n));return t&&_setPrototypeOf(e,t.prototype),e}).apply(null,arguments)}function _isNativeFunction(r){return-1!==Function.toString.call(r).indexOf("[native code]")}function _wrapNativeSuper(r){var t="function"==typeof Map?new Map:void 0;return(_wrapNativeSuper=function(r){if(null===r||!_isNativeFunction(r))return r;if("function"!=typeof r)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(r))return t.get(r);t.set(r,e)}function e(){return _construct(r,arguments,_getPrototypeOf(this).constructor)}return e.prototype=Object.create(r.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),_setPrototypeOf(e,r)})(r)}function _assertThisInitialized(r){if(void 0===r)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return r}function _possibleConstructorReturn(r,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(r)}function _createSuper(t){var n=_isNativeReflectConstruct();return function(){var r,e=_getPrototypeOf(t);return _possibleConstructorReturn(this,n?(r=_getPrototypeOf(this).constructor,Reflect.construct(e,arguments,r)):e.apply(this,arguments))}}function _toConsumableArray(r){return _arrayWithoutHoles(r)||_iterableToArray(r)||_unsupportedIterableToArray(r)||_nonIterableSpread()}function _arrayWithoutHoles(r){if(Array.isArray(r))return _arrayLikeToArray(r)}function _iterableToArray(r){if("undefined"!=typeof Symbol&&null!=r[Symbol.iterator]||null!=r["@@iterator"])return Array.from(r)}function _unsupportedIterableToArray(r,e){if(r){if("string"==typeof r)return _arrayLikeToArray(r,e);var t=Object.prototype.toString.call(r).slice(8,-1);return"Map"===(t="Object"===t&&r.constructor?r.constructor.name:t)||"Set"===t?Array.from(r):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?_arrayLikeToArray(r,e):void 0}}function _arrayLikeToArray(r,e){(null==e||e>r.length)&&(e=r.length);for(var t=0,n=new Array(e);t<e;t++)n[t]=r[t];return n}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(r){return-1<"+-*/%()".indexOf(r)}function getPrioraty(r){switch(r){case"+":case"-":return 1;case"*":case"/":case"%":return 2;default:return 0}}function prioraty(r,e){return getPrioraty(r)<=getPrioraty(e)}function isObj(r){return"[object Object]"===Object.prototype.toString.call(r)&&!Array.isArray(r)}function parseArgs(r){var e={expr:"",fmt:null,data:null},t="",n=r[0];if(1===r.length)"string"==typeof n?t=n:"number"==typeof n?t=n.toString():Array.isArray(n)&&(t=n[0]);else if(1<r.length){n=r[r.length-1];if(isObj(n))t=r[0],e.data=n;else for(var o=_toConsumableArray(r.shift());o.length||r.length;)var i=0===o.length?"":o.shift(),a=0===r.length?"":r.shift(),t=t+i+(a="number"==typeof a?a.toString():a)}var n=t.split("|");return 1===n.length?e.expr=n[0]:(e.expr=n[0],""!==(n=n[1]).trim()&&(e.fmt=n)),e}function format(r,e){var t="",n=(t=BigNumber__default.default.isBigNumber(r)?r.toFixed():"string"!=typeof r?r.toString():r,null),r=null,o=null,i=e.match(/(<=|>=|=)\s*(\d+)/);if(i&&(r=i[1],n=Number(i[2])),e.includes(",")&&(o=!0),null!==n){var i=t.split("."),e=i[0],a=1===i.length?"":i[1],l=a.length;switch(r){case"<=":a=l<=n?a:a.slice(0,n);break;case"=":l<n?a+="0".repeat(n-l):n<l&&(a=a.slice(0,n));break;case">=":a=n<=l?a:a+"0".repeat(n-l)}t=""===a?e:"".concat(e,".").concat(a)}return t=null!==o?1<(i=t.split(".")).length?((r=i[0]).includes("-")?i[0]=r[0]+r.slice(1).replace(/(?=(?!^)(?:\d{3})+$)/g,","):i[0]=r.replace(/(?=(?!^)(?:\d{3})+$)/g,","),i.join(".")):(e=i[0]).includes("-")?e[0]+e.slice(1).replace(/(?=(?!^)(?:\d{3})+$)/g,","):e.replace(/(?=(?!^)(?:\d{3})+$)/g,","):t}function tokenizer(r){for(var e=[],t=0,n=null,o=r.length;t<o;)if(n=r[t],/\s/.test(n))t++;else if("+-".includes(n)){var i=e[e.length-1];if(0===e.length||"+-".includes(i)||"("===i){for(var a=n,n=r[++t];/[a-zA-Z\d._]/.test(n);)a+=n,n=r[++t];e.push(a)}else e.push(n),t++}else if("*/%()".includes(n))e.push(n),t++;else if(/[a-zA-Z_]/.test(n)){for(var l="";/[a-zA-Z0-9_]/.test(n)&&(l+=n,!(++t>=o));)n=r[t];e.push(l)}else if(/\d/.test(n)){for(var u="";/[\d.]/.test(n)&&(u+=n,!(++t>=o));)n=r[t];e.push(u)}return e}var CalculatorError=function(){_inherits(n,_wrapNativeSuper(Error));var t=_createSuper(n);function n(r){var e;return _classCallCheck(this,n),(e=t.call(this,r)).name="CalculatorError",e.message=r,e}return _createClass(n)}(),TokensFillError$1=function(){_inherits(n,_wrapNativeSuper(Error));var t=_createSuper(n);function n(r){var e;return _classCallCheck(this,n),(e=t.call(this,r)).name="TokensFillError",e.message=r,e}return _createClass(n)}();function fillTokens(r,e){var t=e._fillData;return void 0===e._fillData&&(t=e),r.map(function(r){if(/^[a-zA-z_][\w_]*$/.test(r)){var e=t[r];if(void 0!==e)return"number"==typeof e?e.toString():e;throw new TokensFillError$1("错误的参数:".concat(r," 请确认他存在"))}return r})}function fmt(){for(var r=arguments.length,e=new Array(r),t=0;t<r;t++)e[t]=arguments[t];var n=parseArgs(e),o=tokenizer(n.expr),i=null;if(2<o.length)throw new Error("fmt并非用于计算, 不能传入多个标识:".concat(n.expr));if(1!==o.length)throw new Error("fmt接收了一个无法被解析的标识");if(null!==n.data)if(null===(i=void 0!==n.data._fillData?n.data:i)||void 0===i.fillError&&void 0===i.error)o=fillTokens(o,n.data);else try{o=fillTokens(o,n.data)}catch(r){if(r instanceof TokensFillError)return i.fillError||i.error;throw r}if(null===n.fmt)throw"表达式没有格式化部分";return format(o[0],n.fmt)}var version="0.0.38";function token2postfix(r){for(var e=[],t=[],n=r;0<n.length;){var o=n.shift();if(isOperator(o))if("("===o)e.push(o);else if(")"===o){for(var i=e.pop();"("!==i&&0<e.length;)t.push(i),i=e.pop();if("("!==i)throw"error: unmatched ()"}else{for(;prioraty(o,e[e.length-1])&&0<e.length;)t.push(e.pop());e.push(o)}else t.push(o)}if(0<e.length){if(")"===e[e.length-1]||"("===e[e.length-1])throw"error: unmatched ()";for(;0<e.length;)t.push(e.pop())}return t}function evalPostfix(r){for(var e=[];0<r.length;){var t=r.shift();if(isOperator(t)){if(e.length<2)throw new CalculatorError("错误的栈长度, 可能是无法计算的表达式");var n=e.pop(),o=e.pop();if("string"==typeof n&&!BigNumber__default.default.isBigNumber(n)){if(!/^[+-]*[\d.]+$/.test(n))throw new CalculatorError("".concat(n,"不是一个合法的数字"));n=new BigNumber__default.default(n)}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(t){case"+":e.push(o.plus(n));break;case"-":e.push(o.minus(n));break;case"*":e.push(o.times(n));break;case"/":e.push(o.div(n));break;case"%":e.push(o.mod(n))}}else e.push(t)}if(1!==e.length)throw"unvalid expression";return e[0]}function calc(){for(var r=arguments.length,e=new Array(r),t=0;t<r;t++)e[t]=arguments[t];var n=parseArgs(e),o=tokenizer(n.expr),i=null;if(null!==n.data)if(null===(i=void 0!==n.data._fillData?n.data:i)||void 0===i.fillError&&void 0===i.error)o=fillTokens(o,n.data);else try{o=fillTokens(o,n.data)}catch(r){if(r instanceof TokensFillError$1)return void 0!==i.warn&&!0===i.warn&&console.warn(r),i.fillError||i.error;throw r}var o=token2postfix(o),a=null;if(null!==i){if(void 0!==i.calcError||void 0!==i.error)try{a=evalPostfix(o)}catch(r){if(r instanceof CalculatorError)return void 0!==i.warn&&!0===i.warn&&console.warn(r),void 0!==i.calcError?i.calcError:i.error;throw r}}else a=evalPostfix(o);return a=null!==n.fmt?format(a,n.fmt):null!==a?a.toFixed():null}exports.calc=calc,exports.fmt=fmt,exports.version=version; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var BigNumber=require("bignumber.js");function _interopDefaultLegacy(r){return r&&"object"==typeof r&&"default"in r?r:{default:r}}var BigNumber__default=_interopDefaultLegacy(BigNumber);function _classCallCheck(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}function _defineProperties(r,e){for(var t=0;t<e.length;t++){var n=e[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(r,n.key,n)}}function _createClass(r,e,t){return e&&_defineProperties(r.prototype,e),t&&_defineProperties(r,t),Object.defineProperty(r,"prototype",{writable:!1}),r}function _inherits(r,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),Object.defineProperty(r,"prototype",{writable:!1}),e&&_setPrototypeOf(r,e)}function _getPrototypeOf(r){return(_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)})(r)}function _setPrototypeOf(r,e){return(_setPrototypeOf=Object.setPrototypeOf||function(r,e){return r.__proto__=e,r})(r,e)}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(r){return!1}}function _construct(r,e,t){return(_construct=_isNativeReflectConstruct()?Reflect.construct:function(r,e,t){var n=[null];n.push.apply(n,e);e=new(Function.bind.apply(r,n));return t&&_setPrototypeOf(e,t.prototype),e}).apply(null,arguments)}function _isNativeFunction(r){return-1!==Function.toString.call(r).indexOf("[native code]")}function _wrapNativeSuper(r){var t="function"==typeof Map?new Map:void 0;return(_wrapNativeSuper=function(r){if(null===r||!_isNativeFunction(r))return r;if("function"!=typeof r)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(r))return t.get(r);t.set(r,e)}function e(){return _construct(r,arguments,_getPrototypeOf(this).constructor)}return e.prototype=Object.create(r.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),_setPrototypeOf(e,r)})(r)}function _assertThisInitialized(r){if(void 0===r)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return r}function _possibleConstructorReturn(r,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(r)}function _createSuper(t){var n=_isNativeReflectConstruct();return function(){var r,e=_getPrototypeOf(t);return _possibleConstructorReturn(this,n?(r=_getPrototypeOf(this).constructor,Reflect.construct(e,arguments,r)):e.apply(this,arguments))}}function _toConsumableArray(r){return _arrayWithoutHoles(r)||_iterableToArray(r)||_unsupportedIterableToArray(r)||_nonIterableSpread()}function _arrayWithoutHoles(r){if(Array.isArray(r))return _arrayLikeToArray(r)}function _iterableToArray(r){if("undefined"!=typeof Symbol&&null!=r[Symbol.iterator]||null!=r["@@iterator"])return Array.from(r)}function _unsupportedIterableToArray(r,e){if(r){if("string"==typeof r)return _arrayLikeToArray(r,e);var t=Object.prototype.toString.call(r).slice(8,-1);return"Map"===(t="Object"===t&&r.constructor?r.constructor.name:t)||"Set"===t?Array.from(r):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?_arrayLikeToArray(r,e):void 0}}function _arrayLikeToArray(r,e){(null==e||e>r.length)&&(e=r.length);for(var t=0,n=new Array(e);t<e;t++)n[t]=r[t];return n}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(r){return-1<"+-*/%()".indexOf(r)}function getPrioraty(r){switch(r){case"+":case"-":return 1;case"*":case"/":case"%":return 2;default:return 0}}function prioraty(r,e){return getPrioraty(r)<=getPrioraty(e)}function isObj(r){return"[object Object]"===Object.prototype.toString.call(r)&&!Array.isArray(r)}function anyNoUndefined(){for(var r=arguments.length,e=new Array(r),t=0;t<r;t++)e[t]=arguments[t];return e.some(function(r){return void 0!==r})}function parseArgs(r){var e={expr:"",fmt:null,data:null},t="",n=r[0];if(1===r.length)"string"==typeof n?t=n:"number"==typeof n?t=n.toString():Array.isArray(n)&&(t=n[0]);else if(1<r.length){n=r[r.length-1];if(isObj(n))t=r[0],e.data=n;else for(var o=_toConsumableArray(r.shift());o.length||r.length;)var i=0===o.length?"":o.shift(),a=0===r.length?"":r.shift(),t=t+i+(a="number"==typeof a?a.toString():a)}var n=t.split("|");return 1===n.length?e.expr=n[0]:(e.expr=n[0],""!==(n=n[1]).trim()&&(e.fmt=n)),e}function format(r,e){var t="",n=(t=BigNumber__default.default.isBigNumber(r)?r.toFixed():"string"!=typeof r?r.toString():r,null),r=null,o=null,i=e.match(/(<=|>=|=)\s*(\d+)/);if(i&&(r=i[1],n=Number(i[2])),e.includes(",")&&(o=!0),null!==n){var i=t.split("."),e=i[0],a=1===i.length?"":i[1],l=a.length;switch(r){case"<=":a=l<=n?a:a.slice(0,n);break;case"=":l<n?a+="0".repeat(n-l):n<l&&(a=a.slice(0,n));break;case">=":a=n<=l?a:a+"0".repeat(n-l)}t=""===a?e:"".concat(e,".").concat(a)}return t=null!==o?1<(i=t.split(".")).length?((r=i[0]).includes("-")?i[0]=r[0]+r.slice(1).replace(/(?=(?!^)(?:\d{3})+$)/g,","):i[0]=r.replace(/(?=(?!^)(?:\d{3})+$)/g,","),i.join(".")):(e=i[0]).includes("-")?e[0]+e.slice(1).replace(/(?=(?!^)(?:\d{3})+$)/g,","):e.replace(/(?=(?!^)(?:\d{3})+$)/g,","):t}function tokenizer(r){for(var e=[],t=0,n=null,o=r.length;t<o;)if(n=r[t],/\s/.test(n))t++;else if("+-".includes(n)){var i=e[e.length-1];if(0===e.length||"+-".includes(i)||"("===i){for(var a=n,n=r[++t];/[a-zA-Z\d._]/.test(n);)a+=n,n=r[++t];e.push(a)}else e.push(n),t++}else if("*/%()".includes(n))e.push(n),t++;else if(/[a-zA-Z_]/.test(n)){for(var l="";/[a-zA-Z0-9_]/.test(n)&&(l+=n,!(++t>=o));)n=r[t];e.push(l)}else if(/\d/.test(n)){for(var u="";/[\d.]/.test(n)&&(u+=n,!(++t>=o));)n=r[t];e.push(u)}return e}var CalculatorError=function(){_inherits(n,_wrapNativeSuper(Error));var t=_createSuper(n);function n(r){var e;return _classCallCheck(this,n),(e=t.call(this,r)).name="CalculatorError",e.message=r,e}return _createClass(n)}(),TokensFillError=function(){_inherits(n,_wrapNativeSuper(Error));var t=_createSuper(n);function n(r){var e;return _classCallCheck(this,n),(e=t.call(this,r)).name="TokensFillError",e.message=r,e}return _createClass(n)}();function fillTokens(r,e){var t=e._fillData;return void 0===e._fillData&&(t=e),r.map(function(r){if(/^[a-zA-z_][\w_]*$/.test(r)){var e=t[r];if(void 0!==e)return"number"==typeof e?e.toString():e;throw new TokensFillError("错误的参数:".concat(r," 请确认他存在"))}return r})}function fmt(){for(var r=arguments.length,e=new Array(r),t=0;t<r;t++)e[t]=arguments[t];var n=parseArgs(e),o=tokenizer(n.expr),i=null;if(""===n.expr.trim()&&void 0!==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=anyNoUndefined(a._fillData,a._error,a._fillError)?a:i)&&void 0!==a._fillData&&anyNoUndefined(i._fillError,i._error))try{o=fillTokens(o,a._fillData)}catch(r){if(r instanceof TokensFillError)return void 0!==i._warn&&!0===i._warn&&console.warn(r),i._fillError||i._error;throw r}else o=fillTokens(o,a)}if(null===n.fmt)throw"表达式没有格式化部分";return format(o[0],n.fmt)}var version="0.0.42";function token2postfix(r){for(var e=[],t=[],n=r;0<n.length;){var o=n.shift();if(isOperator(o))if("("===o)e.push(o);else if(")"===o){for(var i=e.pop();"("!==i&&0<e.length;)t.push(i),i=e.pop();if("("!==i)throw"error: unmatched ()"}else{for(;prioraty(o,e[e.length-1])&&0<e.length;)t.push(e.pop());e.push(o)}else t.push(o)}if(0<e.length){if(")"===e[e.length-1]||"("===e[e.length-1])throw"error: unmatched ()";for(;0<e.length;)t.push(e.pop())}return t}function evalPostfix(r){for(var e=[];0<r.length;){var t=r.shift();if(isOperator(t)){if(e.length<2)throw new CalculatorError("错误的栈长度, 可能是无法计算的表达式");var n=e.pop(),o=e.pop();if("string"==typeof n&&!BigNumber__default.default.isBigNumber(n)){if(!/^[+-]*[\d.]+$/.test(n))throw new CalculatorError("".concat(n,"不是一个合法的数字"));n=new BigNumber__default.default(n)}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(t){case"+":e.push(o.plus(n));break;case"-":e.push(o.minus(n));break;case"*":e.push(o.times(n));break;case"/":e.push(o.div(n));break;case"%":e.push(o.mod(n))}}else e.push(t)}if(1!==e.length)throw"unvalid expression";return e[0]}function calc(){for(var r=arguments.length,e=new Array(r),t=0;t<r;t++)e[t]=arguments[t];var n=parseArgs(e),o=tokenizer(n.expr),i=null;if(null!==n.data){var a=n.data;if(null!==(i=anyNoUndefined(a._fillData,a._error,a._fillError,a._calcError)?a:i)&&void 0!==a._fillData&&anyNoUndefined(i._fillError,i._error))try{o=fillTokens(o,a._fillData)}catch(r){if(r instanceof TokensFillError)return void 0!==i._warn&&!0===i._warn&&console.warn(r),i._fillError||i._error;throw r}else o=fillTokens(o,a)}a=token2postfix(o),o=null;if(null!==i){if(void 0!==i._calcError||void 0!==i._error)try{o=evalPostfix(a)}catch(r){if(r instanceof CalculatorError)return void 0!==i._warn&&!0===i._warn&&console.warn(r),void 0!==i._calcError?i._calcError:i._error;throw r}}else o=evalPostfix(a);return o=null!==n.fmt?format(o,n.fmt):null!==o?o.toFixed():null}exports.calc=calc,exports.fmt=fmt,exports.version=version; |
@@ -1,1 +0,1 @@ | ||
import BigNumber from"bignumber.js";function _classCallCheck(r,t){if(!(r instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(r,t){for(var e=0;e<t.length;e++){var n=t[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(r,n.key,n)}}function _createClass(r,t,e){return t&&_defineProperties(r.prototype,t),e&&_defineProperties(r,e),Object.defineProperty(r,"prototype",{writable:!1}),r}function _inherits(r,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");r.prototype=Object.create(t&&t.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),Object.defineProperty(r,"prototype",{writable:!1}),t&&_setPrototypeOf(r,t)}function _getPrototypeOf(r){return(_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)})(r)}function _setPrototypeOf(r,t){return(_setPrototypeOf=Object.setPrototypeOf||function(r,t){return r.__proto__=t,r})(r,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(r){return!1}}function _construct(r,t,e){return(_construct=_isNativeReflectConstruct()?Reflect.construct:function(r,t,e){var n=[null];n.push.apply(n,t);t=new(Function.bind.apply(r,n));return e&&_setPrototypeOf(t,e.prototype),t}).apply(null,arguments)}function _isNativeFunction(r){return-1!==Function.toString.call(r).indexOf("[native code]")}function _wrapNativeSuper(r){var e="function"==typeof Map?new Map:void 0;return(_wrapNativeSuper=function(r){if(null===r||!_isNativeFunction(r))return r;if("function"!=typeof r)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(r))return e.get(r);e.set(r,t)}function t(){return _construct(r,arguments,_getPrototypeOf(this).constructor)}return t.prototype=Object.create(r.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),_setPrototypeOf(t,r)})(r)}function _assertThisInitialized(r){if(void 0===r)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return r}function _possibleConstructorReturn(r,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(r)}function _createSuper(e){var n=_isNativeReflectConstruct();return function(){var r,t=_getPrototypeOf(e);return _possibleConstructorReturn(this,n?(r=_getPrototypeOf(this).constructor,Reflect.construct(t,arguments,r)):t.apply(this,arguments))}}function _toConsumableArray(r){return _arrayWithoutHoles(r)||_iterableToArray(r)||_unsupportedIterableToArray(r)||_nonIterableSpread()}function _arrayWithoutHoles(r){if(Array.isArray(r))return _arrayLikeToArray(r)}function _iterableToArray(r){if("undefined"!=typeof Symbol&&null!=r[Symbol.iterator]||null!=r["@@iterator"])return Array.from(r)}function _unsupportedIterableToArray(r,t){if(r){if("string"==typeof r)return _arrayLikeToArray(r,t);var e=Object.prototype.toString.call(r).slice(8,-1);return"Map"===(e="Object"===e&&r.constructor?r.constructor.name:e)||"Set"===e?Array.from(r):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?_arrayLikeToArray(r,t):void 0}}function _arrayLikeToArray(r,t){(null==t||t>r.length)&&(t=r.length);for(var e=0,n=new Array(t);e<t;e++)n[e]=r[e];return n}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(r){return-1<"+-*/%()".indexOf(r)}function getPrioraty(r){switch(r){case"+":case"-":return 1;case"*":case"/":case"%":return 2;default:return 0}}function prioraty(r,t){return getPrioraty(r)<=getPrioraty(t)}function isObj(r){return"[object Object]"===Object.prototype.toString.call(r)&&!Array.isArray(r)}function parseArgs(r){var t={expr:"",fmt:null,data:null},e="",n=r[0];if(1===r.length)"string"==typeof n?e=n:"number"==typeof n?e=n.toString():Array.isArray(n)&&(e=n[0]);else if(1<r.length){n=r[r.length-1];if(isObj(n))e=r[0],t.data=n;else for(var o=_toConsumableArray(r.shift());o.length||r.length;)var i=0===o.length?"":o.shift(),a=0===r.length?"":r.shift(),e=e+i+(a="number"==typeof a?a.toString():a)}var n=e.split("|");return 1===n.length?t.expr=n[0]:(t.expr=n[0],""!==(n=n[1]).trim()&&(t.fmt=n)),t}function format(r,t){var e="",n=(e=BigNumber.isBigNumber(r)?r.toFixed():"string"!=typeof r?r.toString():r,null),r=null,o=null,i=t.match(/(<=|>=|=)\s*(\d+)/);if(i&&(r=i[1],n=Number(i[2])),t.includes(",")&&(o=!0),null!==n){var i=e.split("."),t=i[0],a=1===i.length?"":i[1],l=a.length;switch(r){case"<=":a=l<=n?a:a.slice(0,n);break;case"=":l<n?a+="0".repeat(n-l):n<l&&(a=a.slice(0,n));break;case">=":a=n<=l?a:a+"0".repeat(n-l)}e=""===a?t:"".concat(t,".").concat(a)}return e=null!==o?1<(i=e.split(".")).length?((r=i[0]).includes("-")?i[0]=r[0]+r.slice(1).replace(/(?=(?!^)(?:\d{3})+$)/g,","):i[0]=r.replace(/(?=(?!^)(?:\d{3})+$)/g,","),i.join(".")):(t=i[0]).includes("-")?t[0]+t.slice(1).replace(/(?=(?!^)(?:\d{3})+$)/g,","):t.replace(/(?=(?!^)(?:\d{3})+$)/g,","):e}function tokenizer(r){for(var t=[],e=0,n=null,o=r.length;e<o;)if(n=r[e],/\s/.test(n))e++;else if("+-".includes(n)){var i=t[t.length-1];if(0===t.length||"+-".includes(i)||"("===i){for(var a=n,n=r[++e];/[a-zA-Z\d._]/.test(n);)a+=n,n=r[++e];t.push(a)}else t.push(n),e++}else if("*/%()".includes(n))t.push(n),e++;else if(/[a-zA-Z_]/.test(n)){for(var l="";/[a-zA-Z0-9_]/.test(n)&&(l+=n,!(++e>=o));)n=r[e];t.push(l)}else if(/\d/.test(n)){for(var u="";/[\d.]/.test(n)&&(u+=n,!(++e>=o));)n=r[e];t.push(u)}return t}var CalculatorError=function(){_inherits(n,_wrapNativeSuper(Error));var e=_createSuper(n);function n(r){var t;return _classCallCheck(this,n),(t=e.call(this,r)).name="CalculatorError",t.message=r,t}return _createClass(n)}(),TokensFillError$1=function(){_inherits(n,_wrapNativeSuper(Error));var e=_createSuper(n);function n(r){var t;return _classCallCheck(this,n),(t=e.call(this,r)).name="TokensFillError",t.message=r,t}return _createClass(n)}();function fillTokens(r,t){var e=t._fillData;return void 0===t._fillData&&(e=t),r.map(function(r){if(/^[a-zA-z_][\w_]*$/.test(r)){var t=e[r];if(void 0!==t)return"number"==typeof t?t.toString():t;throw new TokensFillError$1("错误的参数:".concat(r," 请确认他存在"))}return r})}function fmt(){for(var r=arguments.length,t=new Array(r),e=0;e<r;e++)t[e]=arguments[e];var n=parseArgs(t),o=tokenizer(n.expr),i=null;if(2<o.length)throw new Error("fmt并非用于计算, 不能传入多个标识:".concat(n.expr));if(1!==o.length)throw new Error("fmt接收了一个无法被解析的标识");if(null!==n.data)if(null===(i=void 0!==n.data._fillData?n.data:i)||void 0===i.fillError&&void 0===i.error)o=fillTokens(o,n.data);else try{o=fillTokens(o,n.data)}catch(r){if(r instanceof TokensFillError)return i.fillError||i.error;throw r}if(null===n.fmt)throw"表达式没有格式化部分";return format(o[0],n.fmt)}var version="0.0.38";function token2postfix(r){for(var t=[],e=[],n=r;0<n.length;){var o=n.shift();if(isOperator(o))if("("===o)t.push(o);else if(")"===o){for(var i=t.pop();"("!==i&&0<t.length;)e.push(i),i=t.pop();if("("!==i)throw"error: unmatched ()"}else{for(;prioraty(o,t[t.length-1])&&0<t.length;)e.push(t.pop());t.push(o)}else e.push(o)}if(0<t.length){if(")"===t[t.length-1]||"("===t[t.length-1])throw"error: unmatched ()";for(;0<t.length;)e.push(t.pop())}return e}function evalPostfix(r){for(var t=[];0<r.length;){var e=r.shift();if(isOperator(e)){if(t.length<2)throw new CalculatorError("错误的栈长度, 可能是无法计算的表达式");var n=t.pop(),o=t.pop();if("string"==typeof n&&!BigNumber.isBigNumber(n)){if(!/^[+-]*[\d.]+$/.test(n))throw new CalculatorError("".concat(n,"不是一个合法的数字"));n=new BigNumber(n)}if("string"==typeof o&&!BigNumber.isBigNumber(o)){if(!/^[+-]*[\d.]+$/.test(o))throw new CalculatorError("".concat(o,"不是一个合法的数字"));o=new BigNumber(o)}switch(e){case"+":t.push(o.plus(n));break;case"-":t.push(o.minus(n));break;case"*":t.push(o.times(n));break;case"/":t.push(o.div(n));break;case"%":t.push(o.mod(n))}}else t.push(e)}if(1!==t.length)throw"unvalid expression";return t[0]}function calc(){for(var r=arguments.length,t=new Array(r),e=0;e<r;e++)t[e]=arguments[e];var n=parseArgs(t),o=tokenizer(n.expr),i=null;if(null!==n.data)if(null===(i=void 0!==n.data._fillData?n.data:i)||void 0===i.fillError&&void 0===i.error)o=fillTokens(o,n.data);else try{o=fillTokens(o,n.data)}catch(r){if(r instanceof TokensFillError$1)return void 0!==i.warn&&!0===i.warn&&console.warn(r),i.fillError||i.error;throw r}var o=token2postfix(o),a=null;if(null!==i){if(void 0!==i.calcError||void 0!==i.error)try{a=evalPostfix(o)}catch(r){if(r instanceof CalculatorError)return void 0!==i.warn&&!0===i.warn&&console.warn(r),void 0!==i.calcError?i.calcError:i.error;throw r}}else a=evalPostfix(o);return a=null!==n.fmt?format(a,n.fmt):null!==a?a.toFixed():null}export{calc,fmt,version}; | ||
import BigNumber from"bignumber.js";function _classCallCheck(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}function _defineProperties(r,e){for(var t=0;t<e.length;t++){var n=e[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(r,n.key,n)}}function _createClass(r,e,t){return e&&_defineProperties(r.prototype,e),t&&_defineProperties(r,t),Object.defineProperty(r,"prototype",{writable:!1}),r}function _inherits(r,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),Object.defineProperty(r,"prototype",{writable:!1}),e&&_setPrototypeOf(r,e)}function _getPrototypeOf(r){return(_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)})(r)}function _setPrototypeOf(r,e){return(_setPrototypeOf=Object.setPrototypeOf||function(r,e){return r.__proto__=e,r})(r,e)}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(r){return!1}}function _construct(r,e,t){return(_construct=_isNativeReflectConstruct()?Reflect.construct:function(r,e,t){var n=[null];n.push.apply(n,e);e=new(Function.bind.apply(r,n));return t&&_setPrototypeOf(e,t.prototype),e}).apply(null,arguments)}function _isNativeFunction(r){return-1!==Function.toString.call(r).indexOf("[native code]")}function _wrapNativeSuper(r){var t="function"==typeof Map?new Map:void 0;return(_wrapNativeSuper=function(r){if(null===r||!_isNativeFunction(r))return r;if("function"!=typeof r)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(r))return t.get(r);t.set(r,e)}function e(){return _construct(r,arguments,_getPrototypeOf(this).constructor)}return e.prototype=Object.create(r.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),_setPrototypeOf(e,r)})(r)}function _assertThisInitialized(r){if(void 0===r)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return r}function _possibleConstructorReturn(r,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(r)}function _createSuper(t){var n=_isNativeReflectConstruct();return function(){var r,e=_getPrototypeOf(t);return _possibleConstructorReturn(this,n?(r=_getPrototypeOf(this).constructor,Reflect.construct(e,arguments,r)):e.apply(this,arguments))}}function _toConsumableArray(r){return _arrayWithoutHoles(r)||_iterableToArray(r)||_unsupportedIterableToArray(r)||_nonIterableSpread()}function _arrayWithoutHoles(r){if(Array.isArray(r))return _arrayLikeToArray(r)}function _iterableToArray(r){if("undefined"!=typeof Symbol&&null!=r[Symbol.iterator]||null!=r["@@iterator"])return Array.from(r)}function _unsupportedIterableToArray(r,e){if(r){if("string"==typeof r)return _arrayLikeToArray(r,e);var t=Object.prototype.toString.call(r).slice(8,-1);return"Map"===(t="Object"===t&&r.constructor?r.constructor.name:t)||"Set"===t?Array.from(r):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?_arrayLikeToArray(r,e):void 0}}function _arrayLikeToArray(r,e){(null==e||e>r.length)&&(e=r.length);for(var t=0,n=new Array(e);t<e;t++)n[t]=r[t];return n}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(r){return-1<"+-*/%()".indexOf(r)}function getPrioraty(r){switch(r){case"+":case"-":return 1;case"*":case"/":case"%":return 2;default:return 0}}function prioraty(r,e){return getPrioraty(r)<=getPrioraty(e)}function isObj(r){return"[object Object]"===Object.prototype.toString.call(r)&&!Array.isArray(r)}function anyNoUndefined(){for(var r=arguments.length,e=new Array(r),t=0;t<r;t++)e[t]=arguments[t];return e.some(function(r){return void 0!==r})}function parseArgs(r){var e={expr:"",fmt:null,data:null},t="",n=r[0];if(1===r.length)"string"==typeof n?t=n:"number"==typeof n?t=n.toString():Array.isArray(n)&&(t=n[0]);else if(1<r.length){n=r[r.length-1];if(isObj(n))t=r[0],e.data=n;else for(var o=_toConsumableArray(r.shift());o.length||r.length;)var i=0===o.length?"":o.shift(),a=0===r.length?"":r.shift(),t=t+i+(a="number"==typeof a?a.toString():a)}var n=t.split("|");return 1===n.length?e.expr=n[0]:(e.expr=n[0],""!==(n=n[1]).trim()&&(e.fmt=n)),e}function format(r,e){var t="",n=(t=BigNumber.isBigNumber(r)?r.toFixed():"string"!=typeof r?r.toString():r,null),r=null,o=null,i=e.match(/(<=|>=|=)\s*(\d+)/);if(i&&(r=i[1],n=Number(i[2])),e.includes(",")&&(o=!0),null!==n){var i=t.split("."),e=i[0],a=1===i.length?"":i[1],l=a.length;switch(r){case"<=":a=l<=n?a:a.slice(0,n);break;case"=":l<n?a+="0".repeat(n-l):n<l&&(a=a.slice(0,n));break;case">=":a=n<=l?a:a+"0".repeat(n-l)}t=""===a?e:"".concat(e,".").concat(a)}return t=null!==o?1<(i=t.split(".")).length?((r=i[0]).includes("-")?i[0]=r[0]+r.slice(1).replace(/(?=(?!^)(?:\d{3})+$)/g,","):i[0]=r.replace(/(?=(?!^)(?:\d{3})+$)/g,","),i.join(".")):(e=i[0]).includes("-")?e[0]+e.slice(1).replace(/(?=(?!^)(?:\d{3})+$)/g,","):e.replace(/(?=(?!^)(?:\d{3})+$)/g,","):t}function tokenizer(r){for(var e=[],t=0,n=null,o=r.length;t<o;)if(n=r[t],/\s/.test(n))t++;else if("+-".includes(n)){var i=e[e.length-1];if(0===e.length||"+-".includes(i)||"("===i){for(var a=n,n=r[++t];/[a-zA-Z\d._]/.test(n);)a+=n,n=r[++t];e.push(a)}else e.push(n),t++}else if("*/%()".includes(n))e.push(n),t++;else if(/[a-zA-Z_]/.test(n)){for(var l="";/[a-zA-Z0-9_]/.test(n)&&(l+=n,!(++t>=o));)n=r[t];e.push(l)}else if(/\d/.test(n)){for(var u="";/[\d.]/.test(n)&&(u+=n,!(++t>=o));)n=r[t];e.push(u)}return e}var CalculatorError=function(){_inherits(n,_wrapNativeSuper(Error));var t=_createSuper(n);function n(r){var e;return _classCallCheck(this,n),(e=t.call(this,r)).name="CalculatorError",e.message=r,e}return _createClass(n)}(),TokensFillError=function(){_inherits(n,_wrapNativeSuper(Error));var t=_createSuper(n);function n(r){var e;return _classCallCheck(this,n),(e=t.call(this,r)).name="TokensFillError",e.message=r,e}return _createClass(n)}();function fillTokens(r,e){var t=e._fillData;return void 0===e._fillData&&(t=e),r.map(function(r){if(/^[a-zA-z_][\w_]*$/.test(r)){var e=t[r];if(void 0!==e)return"number"==typeof e?e.toString():e;throw new TokensFillError("错误的参数:".concat(r," 请确认他存在"))}return r})}function fmt(){for(var r=arguments.length,e=new Array(r),t=0;t<r;t++)e[t]=arguments[t];var n=parseArgs(e),o=tokenizer(n.expr),i=null;if(""===n.expr.trim()&&void 0!==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=anyNoUndefined(a._fillData,a._error,a._fillError)?a:i)&&void 0!==a._fillData&&anyNoUndefined(i._fillError,i._error))try{o=fillTokens(o,a._fillData)}catch(r){if(r instanceof TokensFillError)return void 0!==i._warn&&!0===i._warn&&console.warn(r),i._fillError||i._error;throw r}else o=fillTokens(o,a)}if(null===n.fmt)throw"表达式没有格式化部分";return format(o[0],n.fmt)}var version="0.0.42";function token2postfix(r){for(var e=[],t=[],n=r;0<n.length;){var o=n.shift();if(isOperator(o))if("("===o)e.push(o);else if(")"===o){for(var i=e.pop();"("!==i&&0<e.length;)t.push(i),i=e.pop();if("("!==i)throw"error: unmatched ()"}else{for(;prioraty(o,e[e.length-1])&&0<e.length;)t.push(e.pop());e.push(o)}else t.push(o)}if(0<e.length){if(")"===e[e.length-1]||"("===e[e.length-1])throw"error: unmatched ()";for(;0<e.length;)t.push(e.pop())}return t}function evalPostfix(r){for(var e=[];0<r.length;){var t=r.shift();if(isOperator(t)){if(e.length<2)throw new CalculatorError("错误的栈长度, 可能是无法计算的表达式");var n=e.pop(),o=e.pop();if("string"==typeof n&&!BigNumber.isBigNumber(n)){if(!/^[+-]*[\d.]+$/.test(n))throw new CalculatorError("".concat(n,"不是一个合法的数字"));n=new BigNumber(n)}if("string"==typeof o&&!BigNumber.isBigNumber(o)){if(!/^[+-]*[\d.]+$/.test(o))throw new CalculatorError("".concat(o,"不是一个合法的数字"));o=new BigNumber(o)}switch(t){case"+":e.push(o.plus(n));break;case"-":e.push(o.minus(n));break;case"*":e.push(o.times(n));break;case"/":e.push(o.div(n));break;case"%":e.push(o.mod(n))}}else e.push(t)}if(1!==e.length)throw"unvalid expression";return e[0]}function calc(){for(var r=arguments.length,e=new Array(r),t=0;t<r;t++)e[t]=arguments[t];var n=parseArgs(e),o=tokenizer(n.expr),i=null;if(null!==n.data){var a=n.data;if(null!==(i=anyNoUndefined(a._fillData,a._error,a._fillError,a._calcError)?a:i)&&void 0!==a._fillData&&anyNoUndefined(i._fillError,i._error))try{o=fillTokens(o,a._fillData)}catch(r){if(r instanceof TokensFillError)return void 0!==i._warn&&!0===i._warn&&console.warn(r),i._fillError||i._error;throw r}else o=fillTokens(o,a)}a=token2postfix(o),o=null;if(null!==i){if(void 0!==i._calcError||void 0!==i._error)try{o=evalPostfix(a)}catch(r){if(r instanceof CalculatorError)return void 0!==i._warn&&!0===i._warn&&console.warn(r),void 0!==i._calcError?i._calcError:i._error;throw r}}else o=evalPostfix(a);return o=null!==n.fmt?format(o,n.fmt):null!==o?o.toFixed():null}export{calc,fmt,version}; |
{ | ||
"name": "a-calc", | ||
"version": "0.0.39", | ||
"version": "0.0.43", | ||
"description": "JavaScript的字符串四则运算库, 支持格式化操作例如: 千分位格式化, 灵活指定小数点位数", | ||
"main": "./es/index.js", | ||
"main": "./cjs/index.js", | ||
"exports": { | ||
".": { | ||
"types": "./calc.d.ts", | ||
"node": { | ||
"import": "./es/index.js", | ||
"require": "./cjs/index.js" | ||
}, | ||
"default": "./cjs/index.js" | ||
"import": "./es/index.js", | ||
"require": "./cjs/index.js" | ||
}, | ||
"./es": { | ||
"import": "./es/index.js", | ||
"default": "./es/index.js" | ||
}, | ||
"./cjs": { | ||
"require": "./cjs/index.js", | ||
"default": "./cjs/index.js" | ||
@@ -25,3 +23,2 @@ } | ||
"typings": "./calc.d.ts", | ||
"types": "./calc.d.ts", | ||
"scripts": { | ||
@@ -28,0 +25,0 @@ "dev": "rollup -c -w --environment build:dev", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
61022
219