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

a-calc

Package Overview
Dependencies
Maintainers
1
Versions
161
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

a-calc - npm Package Compare versions

Comparing version 0.0.29 to 0.0.32

2

browser/index.core.js

@@ -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(Decimal);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 y(r){return function(r){if(Array.isArray(r))return v(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 v(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)?v(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 v(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 m(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=y(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 w(r,t){var e="",n=(e=u.default.isDecimal(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();switch("string"==typeof n&&(n=new u.default(n)),"string"==typeof o&&(o=new u.default(o)),e){case"+":t.push(o.add(n));break;case"-":t.push(o.sub(n));break;case"*":t.push(o.mul(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=m(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 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.calcError?i.calcError:i.error;throw r}}else a=x(o);return a=null!==n.fmt?w(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=m(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 w(o[0],n.fmt)},r.version="0.0.28",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(Decimal);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 y(r){return function(r){if(Array.isArray(r))return v(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 v(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)?v(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 v(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 m(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=y(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 w(r,t){var e="",n=(e=u.default.isDecimal(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();switch("string"==typeof n&&(n=new u.default(n)),"string"==typeof o&&(o=new u.default(o)),e){case"+":t.push(o.add(n));break;case"-":t.push(o.sub(n));break;case"*":t.push(o.mul(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=m(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 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.calcError?i.calcError:i.error;throw r}}else a=x(o);return a=null!==n.fmt?w(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=m(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 w(o[0],n.fmt)},r.version="0.0.30",Object.defineProperty(r,"__esModule",{value:!0}),r}({});

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

var a_calc=function(n){"use strict";function s(n){return(s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(n){return typeof n}:function(n){return n&&"function"==typeof Symbol&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n})(n)}function k(n,e){if(!(n instanceof e))throw new TypeError("Cannot call a class as a function")}function U(n,e){for(var t=0;t<e.length;t++){var r=e[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(n,r.key,r)}}function I(n,e,t){return e&&U(n.prototype,e),t&&U(n,t),Object.defineProperty(n,"prototype",{writable:!1}),n}function L(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),Object.defineProperty(n,"prototype",{writable:!1}),e&&o(n,e)}function i(n){return(i=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)})(n)}function o(n,e){return(o=Object.setPrototypeOf||function(n,e){return n.__proto__=e,n})(n,e)}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(n){return!1}}function $(n,e,t){return($=C()?Reflect.construct:function(n,e,t){var r=[null];r.push.apply(r,e);e=new(Function.bind.apply(n,r));return t&&o(e,t.prototype),e}).apply(null,arguments)}function e(n){var t="function"==typeof Map?new Map:void 0;return(e=function(n){if(null===n||-1===Function.toString.call(n).indexOf("[native code]"))return n;if("function"!=typeof n)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(n))return t.get(n);t.set(n,e)}function e(){return $(n,arguments,i(this).constructor)}return e.prototype=Object.create(n.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),o(e,n)})(n)}function H(n,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");e=n;if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function B(t){var r=C();return function(){var n,e=i(t);return H(this,r?(n=i(this).constructor,Reflect.construct(e,arguments,n)):e.apply(this,arguments))}}function V(n){return function(n){if(Array.isArray(n))return r(n)}(n)||function(n){if("undefined"!=typeof Symbol&&null!=n[Symbol.iterator]||null!=n["@@iterator"])return Array.from(n)}(n)||function(n,e){if(n){if("string"==typeof n)return r(n,e);var t=Object.prototype.toString.call(n).slice(8,-1);return"Map"===(t="Object"===t&&n.constructor?n.constructor.name:t)||"Set"===t?Array.from(n):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?r(n,e):void 0}}(n)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function r(n,e){(null==e||e>n.length)&&(e=n.length);for(var t=0,r=new Array(e);t<e;t++)r[t]=n[t];return r}function z(n){return-1<"+-*/%()".indexOf(n)}function W(n){switch(n){case"+":case"-":return 1;case"*":case"/":case"%":return 2;default:return 0}}function J(n){var e={expr:"",fmt:null,data:null},t="",r=n[0];if(1===n.length)"string"==typeof r?t=r:"number"==typeof r?t=r.toString():Array.isArray(r)&&(t=r[0]);else if(1<n.length){r=n[n.length-1];if(u=r,"[object Object]"!==Object.prototype.toString.call(u)||Array.isArray(u))for(var i=V(n.shift());i.length||n.length;)var o=0===i.length?"":i.shift(),s=0===n.length?"":n.shift(),t=t+o+(s="number"==typeof s?s.toString():s);else t=n[0],e.data=r}var u=t.split("|");return 1===u.length?e.expr=u[0]:(e.expr=u[0],""!==(r=u[1]).trim()&&(e.fmt=r)),e}var G,u,c=9e15,p=1e9,g="0123456789abcdef",f="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",a="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",K={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-c,maxE:c,crypto:!1},y=!0,l="[DecimalError] ",m=l+"Invalid argument: ",Q=l+"Precision limit exceeded",X=l+"crypto unavailable",t="[object Decimal]",q=Math.floor,w=Math.pow,Y=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,nn=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,en=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,tn=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,F=1e7,D=7,rn=f.length-1,on=a.length-1,h={toStringTag:t};function b(n){var e,t,r,i=n.length-1,o="",s=n[0];if(0<i){for(o+=s,e=1;e<i;e++)r=n[e]+"",(t=D-r.length)&&(o+=S(t)),o+=r;s=n[e],(t=D-(r=s+"").length)&&(o+=S(t))}else if(0===s)return"0";for(;s%10==0;)s/=10;return o+s}function v(n,e,t){if(n!==~~n||n<e||t<n)throw Error(m+n)}function N(n,e,t,r){for(var i,o,s=n[0];10<=s;s/=10)--e;return--e<0?(e+=D,i=0):(i=Math.ceil((e+1)/D),e%=D),s=w(10,D-e),o=n[i]%s|0,null==r?e<3?(0==e?o=o/100|0:1==e&&(o=o/10|0),t<4&&99999==o||3<t&&49999==o||5e4==o||0==o):(t<4&&o+1==s||3<t&&o+1==s/2)&&(n[i+1]/s/100|0)==w(10,e-2)-1||(o==s/2||0==o)&&0==(n[i+1]/s/100|0):e<4?(0==e?o=o/1e3|0:1==e?o=o/100|0:2==e&&(o=o/10|0),(r||t<4)&&9999==o||!r&&3<t&&4999==o):((r||t<4)&&o+1==s||!r&&3<t&&o+1==s/2)&&(n[i+1]/s/1e3|0)==w(10,e-3)-1}function E(n,e,t){for(var r,i,o=[0],s=0,u=n.length;s<u;){for(i=o.length;i--;)o[i]*=e;for(o[0]+=g.indexOf(n.charAt(s++)),r=0;r<o.length;r++)o[r]>t-1&&(void 0===o[r+1]&&(o[r+1]=0),o[r+1]+=o[r]/t|0,o[r]%=t)}return o.reverse()}h.absoluteValue=h.abs=function(){var n=new this.constructor(this);return n.s<0&&(n.s=1),P(n)},h.ceil=function(){return P(new this.constructor(this),this.e+1,2)},h.clampedTo=h.clamp=function(n,e){var t=this.constructor;if(n=new t(n),e=new t(e),!n.s||!e.s)return new t(NaN);if(n.gt(e))throw Error(m+e);return this.cmp(n)<0?n:0<this.cmp(e)?e:new t(this)},h.comparedTo=h.cmp=function(n){var e,t,r=this,i=r.d,o=(n=new r.constructor(n)).d,s=r.s,u=n.s;if(!i||!o)return s&&u?s!==u?s:i===o?0:!i^s<0?1:-1:NaN;if(!i[0]||!o[0])return i[0]?s:o[0]?-u:0;if(s!==u)return s;if(r.e!==n.e)return r.e>n.e^s<0?1:-1;for(e=0,t=(u=i.length)<(r=o.length)?u:r;e<t;++e)if(i[e]!==o[e])return i[e]>o[e]^s<0?1:-1;return u===r?0:r<u^s<0?1:-1},h.cosine=h.cos=function(){var n,e,t=this,r=t.constructor;return t.d?t.d[0]?(n=r.precision,e=r.rounding,r.precision=n+Math.max(t.e,t.sd())+D,r.rounding=1,t=function(n,e){var t,r;if(e.isZero())return e;r=(r=e.d.length)<32?(t=Math.ceil(r/3),(1/T(4,t)).toString()):(t=16,"2.3283064365386962890625e-10");n.precision+=t,e=R(n,1,e.times(r),new n(1));for(var i=t;i--;){var o=e.times(e);e=o.times(o).minus(o).times(8).plus(1)}return n.precision-=t,e}(r,mn(r,t)),r.precision=n,r.rounding=e,P(2==u||3==u?t.neg():t,n,e,!0)):new r(1):new r(NaN)},h.cubeRoot=h.cbrt=function(){var n,e,t,r,i,o,s,u,c,f,a=this,l=a.constructor;if(!a.isFinite()||a.isZero())return new l(a);for(y=!1,(o=a.s*w(a.s*a,1/3))&&Math.abs(o)!=1/0?r=new l(o.toString()):(t=b(a.d),(o=((n=a.e)-t.length+1)%3)&&(t+=1==o||-2==o?"0":"00"),o=w(t,1/3),n=q((n+1)/3)-(n%3==(n<0?-1:2)),(r=new l(t=o==1/0?"5e"+n:(t=o.toExponential()).slice(0,t.indexOf("e")+1)+n)).s=a.s),s=(n=l.precision)+3;;)if(f=(c=(u=r).times(u).times(u)).plus(a),r=x(f.plus(a).times(u),f.plus(c),s+2,1),b(u.d).slice(0,s)===(t=b(r.d)).slice(0,s)){if("9999"!=(t=t.slice(s-3,s+1))&&(i||"4999"!=t)){+t&&(+t.slice(1)||"5"!=t.charAt(0))||(P(r,n+1,1),e=!r.times(r).times(r).eq(a));break}if(!i&&(P(u,n+1,0),u.times(u).times(u).eq(a))){r=u;break}s+=4,i=1}return y=!0,P(r,n,l.rounding,e)},h.decimalPlaces=h.dp=function(){var n,e=this.d,t=NaN;if(e){if(t=((n=e.length-1)-q(this.e/D))*D,n=e[n])for(;n%10==0;n/=10)t--;t<0&&(t=0)}return t},h.dividedBy=h.div=function(n){return x(this,new this.constructor(n))},h.dividedToIntegerBy=h.divToInt=function(n){var e=this.constructor;return P(x(this,new e(n),0,1,1),e.precision,e.rounding)},h.equals=h.eq=function(n){return 0===this.cmp(n)},h.floor=function(){return P(new this.constructor(this),this.e+1,3)},h.greaterThan=h.gt=function(n){return 0<this.cmp(n)},h.greaterThanOrEqualTo=h.gte=function(n){n=this.cmp(n);return 1==n||0===n},h.hyperbolicCosine=h.cosh=function(){var n,e,t,r=(u=this).constructor,i=new r(1);if(!u.isFinite())return new r(u.s?1/0:NaN);if(u.isZero())return i;e=r.precision,t=r.rounding,r.precision=e+Math.max(u.e,u.sd())+4,r.rounding=1;for(var o,s=(s=u.d.length)<32?(1/T(4,n=Math.ceil(s/3))).toString():(n=16,"2.3283064365386962890625e-10"),u=R(r,1,u.times(s),new r(1),!0),c=n,f=new r(8);c--;)o=u.times(u),u=i.minus(o.times(f.minus(o.times(f))));return P(u,r.precision=e,r.rounding=t,!0)},h.hyperbolicSine=h.sinh=function(){var n,e,t,r=(s=this).constructor;if(!s.isFinite()||s.isZero())return new r(s);if(n=r.precision,e=r.rounding,r.precision=n+Math.max(s.e,s.sd())+4,r.rounding=1,(t=s.d.length)<3)s=R(r,2,s,s,!0);else for(var i,o=1.4*Math.sqrt(t),s=R(r,2,s=s.times(1/T(5,o=16<o?16:0|o)),s,!0),u=new r(5),c=new r(16),f=new r(20);o--;)i=s.times(s),s=s.times(u.plus(i.times(c.times(i).plus(f))));return P(s,r.precision=n,r.rounding=e,!0)},h.hyperbolicTangent=h.tanh=function(){var n,e,t=this,r=t.constructor;return t.isFinite()?t.isZero()?new r(t):(n=r.precision,e=r.rounding,r.precision=n+7,r.rounding=1,x(t.sinh(),t.cosh(),r.precision=n,r.rounding=e)):new r(t.s)},h.inverseCosine=h.acos=function(){var n=this,e=n.constructor,t=n.abs().cmp(1),r=e.precision,i=e.rounding;return-1!==t?0===t?n.isNeg()?d(e,r,i):new e(0):new e(NaN):n.isZero()?d(e,r+4,i).times(.5):(e.precision=r+6,e.rounding=1,n=n.asin(),t=d(e,r+4,i).times(.5),e.precision=r,e.rounding=i,t.minus(n))},h.inverseHyperbolicCosine=h.acosh=function(){var n,e,t=this,r=t.constructor;return t.lte(1)?new r(t.eq(1)?0:NaN):t.isFinite()?(n=r.precision,e=r.rounding,r.precision=n+Math.max(Math.abs(t.e),t.sd())+4,r.rounding=1,y=!1,t=t.times(t).minus(1).sqrt().plus(t),y=!0,r.precision=n,r.rounding=e,t.ln()):new r(t)},h.inverseHyperbolicSine=h.asinh=function(){var n,e,t=this,r=t.constructor;return!t.isFinite()||t.isZero()?new r(t):(n=r.precision,e=r.rounding,r.precision=n+2*Math.max(Math.abs(t.e),t.sd())+6,r.rounding=1,y=!1,t=t.times(t).plus(1).sqrt().plus(t),y=!0,r.precision=n,r.rounding=e,t.ln())},h.inverseHyperbolicTangent=h.atanh=function(){var n,e,t,r=this,i=r.constructor;return r.isFinite()?0<=r.e?new i(r.abs().eq(1)?r.s/0:r.isZero()?r:NaN):(n=i.precision,e=i.rounding,t=r.sd(),Math.max(t,n)<2*-r.e-1?P(new i(r),n,e,!0):(i.precision=t=t-r.e,r=x(r.plus(1),new i(1).minus(r),t+n,1),i.precision=n+4,i.rounding=1,r=r.ln(),i.precision=n,i.rounding=e,r.times(.5))):new i(NaN)},h.inverseSine=h.asin=function(){var n,e,t,r=this,i=r.constructor;return r.isZero()?new i(r):(n=r.abs().cmp(1),e=i.precision,t=i.rounding,-1!==n?0===n?((n=d(i,e+4,t).times(.5)).s=r.s,n):new i(NaN):(i.precision=e+6,i.rounding=1,r=r.div(new i(1).minus(r.times(r)).sqrt().plus(1)).atan(),i.precision=e,i.rounding=t,r.times(2)))},h.inverseTangent=h.atan=function(){var n,e,t,r,i,o,s,u,c,f=this,a=f.constructor,l=a.precision,h=a.rounding;if(f.isFinite()){if(f.isZero())return new a(f);if(f.abs().eq(1)&&l+4<=on)return(s=d(a,l+4,h).times(.25)).s=f.s,s}else{if(!f.s)return new a(NaN);if(l+4<=on)return(s=d(a,l+4,h).times(.5)).s=f.s,s}for(a.precision=u=l+10,a.rounding=1,n=t=Math.min(28,u/D+2|0);n;--n)f=f.div(f.times(f).plus(1).sqrt().plus(1));for(y=!1,e=Math.ceil(u/D),r=1,c=f.times(f),s=new a(f),i=f;-1!==n;)if(i=i.times(c),o=s.minus(i.div(r+=2)),i=i.times(c),void 0!==(s=o.plus(i.div(r+=2))).d[e])for(n=e;s.d[n]===o.d[n]&&n--;);return t&&(s=s.times(2<<t-1)),y=!0,P(s,a.precision=l,a.rounding=h,!0)},h.isFinite=function(){return!!this.d},h.isInteger=h.isInt=function(){return!!this.d&&q(this.e/D)>this.d.length-2},h.isNaN=function(){return!this.s},h.isNegative=h.isNeg=function(){return this.s<0},h.isPositive=h.isPos=function(){return 0<this.s},h.isZero=function(){return!!this.d&&0===this.d[0]},h.lessThan=h.lt=function(n){return this.cmp(n)<0},h.lessThanOrEqualTo=h.lte=function(n){return this.cmp(n)<1},h.logarithm=h.log=function(n){var e,t,r,i,o,s,u,c,f=this,a=f.constructor,l=a.precision,h=a.rounding;if(null==n)n=new a(10),e=!0;else{if(t=(n=new a(n)).d,n.s<0||!t||!t[0]||n.eq(1))return new a(NaN);e=n.eq(10)}if(t=f.d,f.s<0||!t||!t[0]||f.eq(1))return new a(t&&!t[0]?-1/0:1!=f.s?NaN:t?0:1/0);if(e)if(1<t.length)o=!0;else{for(i=t[0];i%10==0;)i/=10;o=1!==i}if(y=!1,s=_(f,u=l+5),r=e?A(a,u+10):_(n,u),N((c=x(s,r,u,1)).d,i=l,h))do{if(s=_(f,u+=10),r=e?A(a,u+10):_(n,u),c=x(s,r,u,1),!o){+b(c.d).slice(i+1,i+15)+1==1e14&&(c=P(c,l+1,0));break}}while(N(c.d,i+=10,h));return y=!0,P(c,l,h)},h.minus=h.sub=function(n){var e,t,r,i,o,s,u,c,f,a,l,h=this,d=h.constructor;if(n=new d(n),!h.d||!n.d)return h.s&&n.s?h.d?n.s=-n.s:n=new d(n.d||h.s!==n.s?h:NaN):n=new d(NaN),n;if(h.s!=n.s)return n.s=-n.s,h.plus(n);if(f=h.d,l=n.d,u=d.precision,c=d.rounding,!f[0]||!l[0]){if(l[0])n.s=-n.s;else{if(!f[0])return new d(3===c?-0:0);n=new d(h)}return y?P(n,u,c):n}if(t=q(n.e/D),h=q(h.e/D),f=f.slice(),o=h-t){for(s=(a=o<0)?(e=f,o=-o,l.length):(e=l,t=h,f.length),(r=Math.max(Math.ceil(u/D),s)+2)<o&&(o=r,e.length=1),e.reverse(),r=o;r--;)e.push(0);e.reverse()}else{for((a=(r=f.length)<(s=l.length))&&(s=r),r=0;r<s;r++)if(f[r]!=l[r]){a=f[r]<l[r];break}o=0}for(a&&(e=f,f=l,l=e,n.s=-n.s),s=f.length,r=l.length-s;0<r;--r)f[s++]=0;for(r=l.length;o<r;){if(f[--r]<l[r]){for(i=r;i&&0===f[--i];)f[i]=F-1;--f[i],f[r]+=F}f[r]-=l[r]}for(;0===f[--s];)f.pop();for(;0===f[0];f.shift())--t;return f[0]?(n.d=f,n.e=M(f,t),y?P(n,u,c):n):new d(3===c?-0:0)},h.modulo=h.mod=function(n){var e,t=this,r=t.constructor;return n=new r(n),!t.d||!n.s||n.d&&!n.d[0]?new r(NaN):!n.d||t.d&&!t.d[0]?P(new r(t),r.precision,r.rounding):(y=!1,9==r.modulo?(e=x(t,n.abs(),0,3,1)).s*=n.s:e=x(t,n,0,r.modulo,1),e=e.times(n),y=!0,t.minus(e))},h.naturalExponential=h.exp=function(){return dn(this)},h.naturalLogarithm=h.ln=function(){return _(this)},h.negated=h.neg=function(){var n=new this.constructor(this);return n.s=-n.s,P(n)},h.plus=h.add=function(n){var e,t,r,i,o,s,u,c,f=this,a=f.constructor;if(n=new a(n),!f.d||!n.d)return f.s&&n.s?f.d||(n=new a(n.d||f.s===n.s?f:NaN)):n=new a(NaN),n;if(f.s!=n.s)return n.s=-n.s,f.minus(n);if(u=f.d,c=n.d,o=a.precision,s=a.rounding,!u[0]||!c[0])return c[0]||(n=new a(f)),y?P(n,o,s):n;if(a=q(f.e/D),f=q(n.e/D),u=u.slice(),r=a-f){for((i=(i=r<0?(t=u,r=-r,c.length):(t=c,f=a,u.length))<(a=Math.ceil(o/D))?a+1:i+1)<r&&(r=i,t.length=1),t.reverse();r--;)t.push(0);t.reverse()}for((i=u.length)-(r=c.length)<0&&(r=i,t=c,c=u,u=t),e=0;r;)e=(u[--r]=u[r]+c[r]+e)/F|0,u[r]%=F;for(e&&(u.unshift(e),++f),i=u.length;0==u[--i];)u.pop();return n.d=u,n.e=M(u,f),y?P(n,o,s):n},h.precision=h.sd=function(n){var e;if(void 0!==n&&n!==!!n&&1!==n&&0!==n)throw Error(m+n);return this.d?(e=fn(this.d),n&&this.e+1>e&&(e=this.e+1)):e=NaN,e},h.round=function(){var n=this.constructor;return P(new n(this),this.e+1,n.rounding)},h.sine=h.sin=function(){var n,e,t=this,r=t.constructor;return t.isFinite()?t.isZero()?new r(t):(n=r.precision,e=r.rounding,r.precision=n+Math.max(t.e,t.sd())+D,r.rounding=1,t=function(n,e){var t,r=e.d.length;if(r<3)return e.isZero()?e:R(n,2,e,e);t=16<(t=1.4*Math.sqrt(r))?16:0|t,e=e.times(1/T(5,t)),e=R(n,2,e,e);for(var i,o=new n(5),s=new n(16),u=new n(20);t--;)i=e.times(e),e=e.times(o.plus(i.times(s.times(i).minus(u))));return e}(r,mn(r,t)),r.precision=n,r.rounding=e,P(2<u?t.neg():t,n,e,!0)):new r(NaN)},h.squareRoot=h.sqrt=function(){var n,e,t,r,i,o,s=this,u=s.d,c=s.e,f=s.s,a=s.constructor;if(1!==f||!u||!u[0])return new a(!f||f<0&&(!u||u[0])?NaN:u?s:1/0);for(y=!1,r=0==(f=Math.sqrt(+s))||f==1/0?(((e=b(u)).length+c)%2==0&&(e+="0"),f=Math.sqrt(e),c=q((c+1)/2)-(c<0||c%2),new a(e=f==1/0?"5e"+c:(e=f.toExponential()).slice(0,e.indexOf("e")+1)+c)):new a(f.toString()),t=(c=a.precision)+3;;)if(r=(o=r).plus(x(s,o,t+2,1)).times(.5),b(o.d).slice(0,t)===(e=b(r.d)).slice(0,t)){if("9999"!=(e=e.slice(t-3,t+1))&&(i||"4999"!=e)){+e&&(+e.slice(1)||"5"!=e.charAt(0))||(P(r,c+1,1),n=!r.times(r).eq(s));break}if(!i&&(P(o,c+1,0),o.times(o).eq(s))){r=o;break}t+=4,i=1}return y=!0,P(r,c,a.rounding,n)},h.tangent=h.tan=function(){var n,e,t=this,r=t.constructor;return t.isFinite()?t.isZero()?new r(t):(n=r.precision,e=r.rounding,r.precision=n+10,r.rounding=1,(t=t.sin()).s=1,t=x(t,new r(1).minus(t.times(t)).sqrt(),n+10,0),r.precision=n,r.rounding=e,P(2==u||4==u?t.neg():t,n,e,!0)):new r(NaN)},h.times=h.mul=function(n){var e,t,r,i,o,s,u,c,f,a=this.constructor,l=this.d,h=(n=new a(n)).d;if(n.s*=this.s,!(l&&l[0]&&h&&h[0]))return new a(!n.s||l&&!l[0]&&!h||h&&!h[0]&&!l?NaN:l&&h?0*n.s:n.s/0);for(t=q(this.e/D)+q(n.e/D),(c=l.length)<(f=h.length)&&(o=l,l=h,h=o,s=c,c=f,f=s),o=[],r=s=c+f;r--;)o.push(0);for(r=f;0<=--r;){for(e=0,i=c+r;r<i;)u=o[i]+h[r]*l[i-r-1]+e,o[i--]=u%F|0,e=u/F|0;o[i]=(o[i]+e)%F|0}for(;!o[--s];)o.pop();return e?++t:o.shift(),n.d=o,n.e=M(o,t),y?P(n,a.precision,a.rounding):n},h.toBinary=function(n,e){return wn(this,2,n,e)},h.toDecimalPlaces=h.toDP=function(n,e){var t=this.constructor,r=new t(this);return void 0===n?r:(v(n,0,p),void 0===e?e=t.rounding:v(e,0,8),P(r,n+r.e+1,e))},h.toExponential=function(n,e){var t=this,r=t.constructor,r=void 0===n?O(t,!0):(v(n,0,p),void 0===e?e=r.rounding:v(e,0,8),O(t=P(new r(t),n+1,e),!0,n+1));return t.isNeg()&&!t.isZero()?"-"+r:r},h.toFixed=function(n,e){var t=this,r=t.constructor,e=void 0===n?O(t):(v(n,0,p),void 0===e?e=r.rounding:v(e,0,8),O(r=P(new r(t),n+t.e+1,e),!1,n+r.e+1));return t.isNeg()&&!t.isZero()?"-"+e:e},h.toFraction=function(n){var e,t,r,i,o,s,u,c,f,a,l=this,h=l.d,d=l.constructor;if(!h)return new d(l);if(c=t=new d(1),r=u=new d(0),o=(e=new d(r)).e=fn(h)-l.e-1,e.d[0]=w(10,(f=o%D)<0?D+f:f),null==n)n=0<o?e:c;else{if(!(s=new d(n)).isInt()||s.lt(c))throw Error(m+s);n=s.gt(e)?0<o?e:c:s}for(y=!1,s=new d(b(h)),f=d.precision,d.precision=o=h.length*D*2;a=x(s,e,0,1,1),1!=(i=t.plus(a.times(r))).cmp(n);)t=r,r=i,i=c,c=u.plus(a.times(i)),u=i,i=e,e=s.minus(a.times(i)),s=i;return i=x(n.minus(t),r,0,1,1),u=u.plus(i.times(c)),t=t.plus(i.times(r)),u.s=c.s=l.s,h=x(c,r,o,1).minus(l).abs().cmp(x(u,t,o,1).minus(l).abs())<1?[c,r]:[u,t],d.precision=f,y=!0,h},h.toHexadecimal=h.toHex=function(n,e){return wn(this,16,n,e)},h.toNearest=function(n,e){var t=(r=this).constructor,r=new t(r);if(null==n){if(!r.d)return r;n=new t(1),e=t.rounding}else{if(n=new t(n),void 0===e?e=t.rounding:v(e,0,8),!r.d)return n.s?r:n;if(!n.d)return n.s&&(n.s=r.s),n}return n.d[0]?(y=!1,r=x(r,n,0,e,1).times(n),y=!0,P(r)):(n.s=r.s,r=n),r},h.toNumber=function(){return+this},h.toOctal=function(n,e){return wn(this,8,n,e)},h.toPower=h.pow=function(n){var e,t,r,i,o,s,u=this,c=u.constructor,f=+(n=new c(n));if(!(u.d&&n.d&&u.d[0]&&n.d[0]))return new c(w(+u,f));if((u=new c(u)).eq(1))return u;if(r=c.precision,o=c.rounding,n.eq(1))return P(u,r,o);if((e=q(n.e/D))>=n.d.length-1&&(t=f<0?-f:f)<=9007199254740991)return i=an(c,u,t,r),n.s<0?new c(1).div(i):P(i,r,o);if((s=u.s)<0){if(e<n.d.length-1)return new c(NaN);if(0==(1&n.d[e])&&(s=1),0==u.e&&1==u.d[0]&&1==u.d.length)return u.s=s,u}return(e=0!=(t=w(+u,f))&&isFinite(t)?new c(t+"").e:q(f*(Math.log("0."+b(u.d))/Math.LN10+u.e+1)))>c.maxE+1||e<c.minE-1?new c(0<e?s/0:0):(y=!1,c.rounding=u.s=1,t=Math.min(12,(e+"").length),(i=(i=dn(n.times(_(u,r+t)),r)).d&&N((i=P(i,r+5,1)).d,r,o)&&+b((i=P(dn(n.times(_(u,(e=r+10)+t)),e),e+5,1)).d).slice(r+1,r+15)+1==1e14?P(i,r+1,0):i).s=s,y=!0,P(i,r,c.rounding=o))},h.toPrecision=function(n,e){var t=this,r=t.constructor,e=void 0===n?O(t,t.e<=r.toExpNeg||t.e>=r.toExpPos):(v(n,1,p),void 0===e?e=r.rounding:v(e,0,8),O(t=P(new r(t),n,e),n<=t.e||t.e<=r.toExpNeg,n));return t.isNeg()&&!t.isZero()?"-"+e:e},h.toSignificantDigits=h.toSD=function(n,e){var t=this.constructor;return void 0===n?(n=t.precision,e=t.rounding):(v(n,1,p),void 0===e?e=t.rounding:v(e,0,8)),P(new t(this),n,e)},h.toString=function(){var n=this,e=n.constructor,e=O(n,n.e<=e.toExpNeg||n.e>=e.toExpPos);return n.isNeg()&&!n.isZero()?"-"+e:e},h.truncated=h.trunc=function(){return P(new this.constructor(this),this.e+1,1)},h.valueOf=h.toJSON=function(){var n=this,e=n.constructor,e=O(n,n.e<=e.toExpNeg||n.e>=e.toExpPos);return n.isNeg()?"-"+e:e};var x=function(n,e,t,r,i,o){var s,u,c,f,a,l,h,d,p,g,m,w,v,y,b,N,E,x,O,M=n.constructor,A=n.s==e.s?1:-1,S=n.d,_=e.d;if(!(S&&S[0]&&_&&_[0]))return new M(n.s&&e.s&&(S?!_||S[0]!=_[0]:_)?S&&0==S[0]||!_?0*A:A/0:NaN);for(u=o?(a=1,n.e-e.e):(o=F,q(n.e/(a=D))-q(e.e/a)),x=_.length,N=S.length,p=(A=new M(A)).d=[],c=0;_[c]==(S[c]||0);c++);if(_[c]>(S[c]||0)&&u--,null==t?(v=t=M.precision,r=M.rounding):v=i?t+(n.e-e.e)+1:t,v<0)p.push(1),l=!0;else{if(v=v/a+2|0,c=0,1==x){for(_=_[f=0],v++;(c<N||f)&&v--;c++)y=f*o+(S[c]||0),p[c]=y/_|0,f=y%_|0;l=f||c<N}else{for(1<(f=o/(_[0]+1)|0)&&(_=sn(_,f,o),S=sn(S,f,o),x=_.length,N=S.length),b=x,m=(g=S.slice(0,x)).length;m<x;)g[m++]=0;for((O=_.slice()).unshift(0),E=_[0],_[1]>=o/2&&++E;f=0,(s=un(_,g,x,m))<0?(w=g[0],1<(f=(w=x!=m?w*o+(g[1]||0):w)/E|0)?1==(s=un(h=sn(_,f=o<=f?o-1:f,o),g,d=h.length,m=g.length))&&(f--,cn(h,x<d?O:_,d,o)):(0==f&&(s=f=1),h=_.slice()),(d=h.length)<m&&h.unshift(0),cn(g,h,m,o),-1==s&&(s=un(_,g,x,m=g.length))<1&&(f++,cn(g,x<m?O:_,m,o)),m=g.length):0===s&&(f++,g=[0]),p[c++]=f,s&&g[0]?g[m++]=S[b]||0:(g=[S[b]],m=1),(b++<N||void 0!==g[0])&&v--;);l=void 0!==g[0]}p[0]||p.shift()}if(1==a)A.e=u,G=l;else{for(c=1,f=p[0];10<=f;f/=10)c++;A.e=c+u*a-1,P(A,i?t+A.e+1:t,r,l)}return A};function sn(n,e,t){var r,i=0,o=n.length;for(n=n.slice();o--;)r=n[o]*e+i,n[o]=r%t|0,i=r/t|0;return i&&n.unshift(i),n}function un(n,e,t,r){var i,o;if(t!=r)o=r<t?1:-1;else for(i=o=0;i<t;i++)if(n[i]!=e[i]){o=n[i]>e[i]?1:-1;break}return o}function cn(n,e,t,r){for(var i=0;t--;)n[t]-=i,i=n[t]<e[t]?1:0,n[t]=i*r+n[t]-e[t];for(;!n[0]&&1<n.length;)n.shift()}function P(n,e,t,r){var i,o,s,u,c,f,a,l,h=n.constructor;n:if(null!=e){if(!(a=n.d))return n;for(i=1,u=a[0];10<=u;u/=10)i++;if((o=e-i)<0)o+=D,s=e,c=(f=a[l=0])/w(10,i-s-1)%10|0;else if(l=Math.ceil((o+1)/D),(u=a.length)<=l){if(!r)break n;for(;u++<=l;)a.push(0);f=c=0,s=(o%=D)-D+(i=1)}else{for(f=u=a[l],i=1;10<=u;u/=10)i++;c=(s=(o%=D)-D+i)<0?0:f/w(10,i-s-1)%10|0}if(r=r||e<0||void 0!==a[l+1]||(s<0?f:f%w(10,i-s-1)),c=t<4?(c||r)&&(0==t||t==(n.s<0?3:2)):5<c||5==c&&(4==t||r||6==t&&(0<o?0<s?f/w(10,i-s):0:a[l-1])%10&1||t==(n.s<0?8:7)),e<1||!a[0])return a.length=0,c?(e-=n.e+1,a[0]=w(10,(D-e%D)%D),n.e=-e||0):a[0]=n.e=0,n;if(0==o?(a.length=l,u=1,l--):(a.length=l+1,u=w(10,D-o),a[l]=0<s?(f/w(10,i-s)%w(10,s)|0)*u:0),c)for(;;){if(0==l){for(o=1,s=a[0];10<=s;s/=10)o++;for(s=a[0]+=u,u=1;10<=s;s/=10)u++;o!=u&&(n.e++,a[0]==F&&(a[0]=1));break}if(a[l]+=u,a[l]!=F)break;a[l--]=0,u=1}for(o=a.length;0===a[--o];)a.pop()}return y&&(n.e>h.maxE?(n.d=null,n.e=NaN):n.e<h.minE&&(n.e=0,n.d=[0])),n}function O(n,e,t){if(!n.isFinite())return pn(n);var r,i=n.e,o=b(n.d),s=o.length;return e?(t&&0<(r=t-s)?o=o.charAt(0)+"."+o.slice(1)+S(r):1<s&&(o=o.charAt(0)+"."+o.slice(1)),o=o+(n.e<0?"e":"e+")+n.e):i<0?(o="0."+S(-i-1)+o,t&&0<(r=t-s)&&(o+=S(r))):s<=i?(o+=S(i+1-s),t&&0<(r=t-i-1)&&(o=o+"."+S(r))):((r=i+1)<s&&(o=o.slice(0,r)+"."+o.slice(r)),t&&0<(r=t-s)&&(i+1===s&&(o+="."),o+=S(r))),o}function M(n,e){var t=n[0];for(e*=D;10<=t;t/=10)e++;return e}function A(n,e,t){if(rn<e)throw y=!0,t&&(n.precision=t),Error(Q);return P(new n(f),e,1,!0)}function d(n,e,t){if(on<e)throw Error(Q);return P(new n(a),e,t,!0)}function fn(n){var e=n.length-1,t=e*D+1;if(e=n[e]){for(;e%10==0;e/=10)t--;for(e=n[0];10<=e;e/=10)t++}return t}function S(n){for(var e="";n--;)e+="0";return e}function an(n,e,t,r){var i,o=new n(1),s=Math.ceil(r/D+4);for(y=!1;;){if(t%2&&vn((o=o.times(e)).d,s)&&(i=!0),0===(t=q(t/2))){t=o.d.length-1,i&&0===o.d[t]&&++o.d[t];break}vn((e=e.times(e)).d,s)}return y=!0,o}function ln(n){return 1&n.d[n.d.length-1]}function hn(n,e,t){for(var r,i=new n(e[0]),o=0;++o<e.length;){if(!(r=new n(e[o])).s){i=r;break}i[t](r)&&(i=r)}return i}function dn(n,e){var t,r,i,o,s,u,c,f=0,a=0,l=0,h=n.constructor,d=h.rounding,p=h.precision;if(!n.d||!n.d[0]||17<n.e)return new h(n.d?n.d[0]?n.s<0?0:1/0:1:n.s?n.s<0?0:n:NaN);for(c=null==e?(y=!1,p):e,u=new h(.03125);-2<n.e;)n=n.times(u),l+=5;for(c+=r=Math.log(w(2,l))/Math.LN10*2+5|0,t=o=s=new h(1),h.precision=c;;){if(o=P(o.times(n),c,1),t=t.times(++a),b((u=s.plus(x(o,t,c,1))).d).slice(0,c)===b(s.d).slice(0,c)){for(i=l;i--;)s=P(s.times(s),c,1);if(null!=e)return h.precision=p,s;if(!(f<3&&N(s.d,c-r,d,f)))return P(s,h.precision=p,d,y=!0);h.precision=c+=10,t=o=u=new h(1),a=0,f++}s=u}}function _(n,e){var t,r,i,o,s,u,c,f,a,l,h,d=1,p=n,g=p.d,m=p.constructor,w=m.rounding,v=m.precision;if(p.s<0||!g||!g[0]||!p.e&&1==g[0]&&1==g.length)return new m(g&&!g[0]?-1/0:1!=p.s?NaN:g?0:p);if(a=null==e?(y=!1,v):e,m.precision=a+=10,r=(t=b(g)).charAt(0),!(Math.abs(o=p.e)<15e14))return f=A(m,a+2,v).times(o+""),p=_(new m(r+"."+t.slice(1)),a-10).plus(f),m.precision=v,null==e?P(p,v,w,y=!0):p;for(;r<7&&1!=r||1==r&&3<t.charAt(1);)r=(t=b((p=p.times(n)).d)).charAt(0),d++;for(o=p.e,1<r?(p=new m("0."+t),o++):p=new m(r+"."+t.slice(1)),c=s=p=x((l=p).minus(1),p.plus(1),a,1),h=P(p.times(p),a,1),i=3;;){if(s=P(s.times(h),a,1),b((f=c.plus(x(s,new m(i),a,1))).d).slice(0,a)===b(c.d).slice(0,a)){if(c=c.times(2),0!==o&&(c=c.plus(A(m,a+2,v).times(o+""))),c=x(c,new m(d),a,1),null!=e)return m.precision=v,c;if(!N(c.d,a-10,w,u))return P(c,m.precision=v,w,y=!0);m.precision=a+=10,f=s=p=x(l.minus(1),l.plus(1),a,1),h=P(p.times(p),a,1),i=u=1}c=f,i+=2}}function pn(n){return String(n.s*n.s/0)}function gn(n,e){var t,r,i;for(0<(r=(e=-1<(t=e.indexOf("."))?e.replace(".",""):e).search(/e/i))?(t<0&&(t=r),t+=+e.slice(r+1),e=e.substring(0,r)):t<0&&(t=e.length),r=0;48===e.charCodeAt(r);r++);for(i=e.length;48===e.charCodeAt(i-1);--i);if(e=e.slice(r,i)){if(i-=r,n.e=t=t-r-1,n.d=[],r=(t+1)%D,t<0&&(r+=D),r<i){for(r&&n.d.push(+e.slice(0,r)),i-=D;r<i;)n.d.push(+e.slice(r,r+=D));e=e.slice(r),r=D-e.length}else r-=i;for(;r--;)e+="0";n.d.push(+e),y&&(n.e>n.constructor.maxE?(n.d=null,n.e=NaN):n.e<n.constructor.minE&&(n.e=0,n.d=[0]))}else n.e=0,n.d=[0];return n}function R(n,e,t,r,i){var o,s,u,c,f=n.precision,a=Math.ceil(f/D);for(y=!1,c=t.times(t),u=new n(r);;){if(s=x(u.times(c),new n(e++*e++),f,1),u=i?r.plus(s):r.minus(s),r=x(s.times(c),new n(e++*e++),f,1),void 0!==(s=u.plus(r)).d[a]){for(o=a;s.d[o]===u.d[o]&&o--;);if(-1==o)break}o=u,u=r,r=s,s=o}return y=!0,s.d.length=a+1,s}function T(n,e){for(var t=n;--e;)t*=n;return t}function mn(n,e){var t,r=e.s<0,n=d(n,n.precision,1),i=n.times(.5);if((e=e.abs()).lte(i))return u=r?4:1,e;if((t=e.divToInt(n)).isZero())u=r?3:2;else{if((e=e.minus(t.times(n))).lte(i))return u=ln(t)?r?2:3:r?4:1,e;u=ln(t)?r?1:4:r?3:2}return e.minus(n).abs()}function wn(n,e,t,r){var i,o,s,u,c,f,a,l,h=n.constructor,d=void 0!==t;if(d?(v(t,1,p),void 0===r?r=h.rounding:v(r,0,8)):(t=h.precision,r=h.rounding),n.isFinite()){for(d?(i=2,16==e?t=4*t-3:8==e&&(t=3*t-2)):i=e,0<=(s=(f=O(n)).indexOf("."))&&(f=f.replace(".",""),(l=new h(1)).e=f.length-s,l.d=E(O(l),10,i),l.e=l.d.length),o=u=(a=E(f,10,i)).length;0==a[--u];)a.pop();if(a[0]){if(s<0?o--:((n=new h(n)).d=a,n.e=o,a=(n=x(n,l,t,r,0,i)).d,o=n.e,c=G),s=a[t],h=i/2,c=c||void 0!==a[t+1],c=r<4?(void 0!==s||c)&&(0===r||r===(n.s<0?3:2)):h<s||s===h&&(4===r||c||6===r&&1&a[t-1]||r===(n.s<0?8:7)),a.length=t,c)for(;++a[--t]>i-1;)a[t]=0,t||(++o,a.unshift(1));for(u=a.length;!a[u-1];--u);for(s=0,f="";s<u;s++)f+=g.charAt(a[s]);if(d){if(1<u)if(16==e||8==e){for(s=16==e?4:3,--u;u%s;u++)f+="0";for(u=(a=E(f,i,e)).length;!a[u-1];--u);for(s=1,f="1.";s<u;s++)f+=g.charAt(a[s])}else f=f.charAt(0)+"."+f.slice(1);f=f+(o<0?"p":"p+")+o}else if(o<0){for(;++o;)f="0"+f;f="0."+f}else if(++o>u)for(o-=u;o--;)f+="0";else o<u&&(f=f.slice(0,o)+"."+f.slice(o))}else f=d?"0p+0":"0";f=(16==e?"0x":2==e?"0b":8==e?"0o":"")+f}else f=pn(n);return n.s<0?"-"+f:f}function vn(n,e){return n.length>e&&(n.length=e,1)}function yn(n){return new this(n).abs()}function bn(n){return new this(n).acos()}function Nn(n){return new this(n).acosh()}function En(n,e){return new this(n).plus(e)}function xn(n){return new this(n).asin()}function On(n){return new this(n).asinh()}function Mn(n){return new this(n).atan()}function An(n){return new this(n).atanh()}function Sn(n,e){n=new this(n),e=new this(e);var t,r=this.precision,i=this.rounding,o=r+4;return n.s&&e.s?n.d||e.d?!e.d||n.isZero()?(t=e.s<0?d(this,r,i):new this(0)).s=n.s:!n.d||e.isZero()?(t=d(this,o,1).times(.5)).s=n.s:t=e.s<0?(this.precision=o,this.rounding=1,t=this.atan(x(n,e,o,1)),e=d(this,o,1),this.precision=r,this.rounding=i,n.s<0?t.minus(e):t.plus(e)):this.atan(x(n,e,o,1)):(t=d(this,o,1).times(0<e.s?.25:.75)).s=n.s:t=new this(NaN),t}function _n(n){return new this(n).cbrt()}function qn(n){return P(n=new this(n),n.e+1,2)}function Fn(n,e,t){return new this(n).clamp(e,t)}function Dn(n){if(!n||"object"!==s(n))throw Error(l+"Object expected");for(var e,t,r=!0===n.defaults,i=["precision",1,p,"rounding",0,8,"toExpNeg",-c,0,"toExpPos",0,c,"maxE",0,c,"minE",-c,0,"modulo",0,9],o=0;o<i.length;o+=3)if(e=i[o],r&&(this[e]=K[e]),void 0!==(t=n[e])){if(!(q(t)===t&&i[o+1]<=t&&t<=i[o+2]))throw Error(m+e+": "+t);this[e]=t}if(e="crypto",r&&(this[e]=K[e]),void 0!==(t=n[e])){if(!0!==t&&!1!==t&&0!==t&&1!==t)throw Error(m+e+": "+t);if(t){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw Error(X);this[e]=!0}else this[e]=!1}return this}function Pn(n){return new this(n).cos()}function Rn(n){return new this(n).cosh()}function Tn(n,e){return new this(n).div(e)}function Zn(n){return new this(n).exp()}function jn(n){return P(n=new this(n),n.e+1,3)}function kn(){var n,e,t=new this(0);for(y=!1,n=0;n<arguments.length;)if((e=new this(arguments[n++])).d)t.d&&(t=t.plus(e.times(e)));else{if(e.s)return y=!0,new this(1/0);t=e}return y=!0,t.sqrt()}function Un(n){return n instanceof Z||n&&n.toStringTag===t||!1}function In(n){return new this(n).ln()}function Ln(n,e){return new this(n).log(e)}function Cn(n){return new this(n).log(2)}function $n(n){return new this(n).log(10)}function Hn(){return hn(this,arguments,"lt")}function Bn(){return hn(this,arguments,"gt")}function Vn(n,e){return new this(n).mod(e)}function zn(n,e){return new this(n).mul(e)}function Wn(n,e){return new this(n).pow(e)}function Jn(n){var e,t,r,i,o=0,s=new this(1),u=[];if(void 0===n?n=this.precision:v(n,1,p),r=Math.ceil(n/D),this.crypto)if(crypto.getRandomValues)for(e=crypto.getRandomValues(new Uint32Array(r));o<r;)429e7<=(i=e[o])?e[o]=crypto.getRandomValues(new Uint32Array(1))[0]:u[o++]=i%1e7;else{if(!crypto.randomBytes)throw Error(X);for(e=crypto.randomBytes(r*=4);o<r;)214e7<=(i=e[o]+(e[o+1]<<8)+(e[o+2]<<16)+((127&e[o+3])<<24))?crypto.randomBytes(4).copy(e,o):(u.push(i%1e7),o+=4);o=r/4}else for(;o<r;)u[o++]=1e7*Math.random()|0;for(r=u[--o],n%=D,r&&n&&(i=w(10,D-n),u[o]=(r/i|0)*i);0===u[o];o--)u.pop();if(o<0)u=[t=0];else{for(t=-1;0===u[0];t-=D)u.shift();for(r=1,i=u[0];10<=i;i/=10)r++;r<D&&(t-=D-r)}return s.e=t,s.d=u,s}function Gn(n){return P(n=new this(n),n.e+1,this.rounding)}function Kn(n){return(n=new this(n)).d?n.d[0]?n.s:0*n.s:n.s||NaN}function Qn(n){return new this(n).sin()}function Xn(n){return new this(n).sinh()}function Yn(n){return new this(n).sqrt()}function ne(n,e){return new this(n).sub(e)}function ee(){var n=0,e=arguments,t=new this(e[n]);for(y=!1;t.s&&++n<e.length;)t=t.plus(e[n]);return y=!0,P(t,this.precision,this.rounding)}function te(n){return new this(n).tan()}function re(n){return new this(n).tanh()}function ie(n){return P(n=new this(n),n.e+1,1)}h[Symbol.for("nodejs.util.inspect.custom")]=h.toString,h[Symbol.toStringTag]="Decimal";var Z=h.constructor=function n(e){var t,r,i;function o(n){var e,t,r,i=this;if(!(i instanceof o))return new o(n);if(i.constructor=o,Un(n))return i.s=n.s,void(y?!n.d||n.e>o.maxE?(i.e=NaN,i.d=null):n.e<o.minE?(i.e=0,i.d=[0]):(i.e=n.e,i.d=n.d.slice()):(i.e=n.e,i.d=n.d&&n.d.slice()));if("number"===(r=s(n))){if(0===n)return i.s=1/n<0?-1:1,i.e=0,void(i.d=[0]);if(n<0?(n=-n,i.s=-1):i.s=1,n===~~n&&n<1e7){for(e=0,t=n;10<=t;t/=10)e++;return void(y?o.maxE<e?(i.e=NaN,i.d=null):e<o.minE?(i.e=0,i.d=[0]):(i.e=e,i.d=[n]):(i.e=e,i.d=[n]))}return 0*n!=0?(n||(i.s=NaN),i.e=NaN,void(i.d=null)):gn(i,n.toString())}if("string"!==r)throw Error(m+n);return 45===(t=n.charCodeAt(0))?(n=n.slice(1),i.s=-1):(43===t&&(n=n.slice(1)),i.s=1),(tn.test(n)?gn:function(n,e){var t,r,i,o,s,u,c,f;if(-1<e.indexOf("_")){if(e=e.replace(/(\d)_(?=\d)/g,"$1"),tn.test(e))return gn(n,e)}else if("Infinity"===e||"NaN"===e)return+e||(n.s=NaN),n.e=NaN,n.d=null,n;if(nn.test(e))t=16,e=e.toLowerCase();else if(Y.test(e))t=2;else{if(!en.test(e))throw Error(m+e);t=8}for(o=(e=0<(o=e.search(/p/i))?(c=+e.slice(o+1),e.substring(2,o)):e.slice(2)).indexOf("."),r=n.constructor,(s=0<=o)&&(o=(u=(e=e.replace(".","")).length)-o,i=an(r,new r(t),o,2*o)),o=e=(f=E(e,t,F)).length-1;0===f[o];--o)f.pop();return o<0?new r(0*n.s):(n.e=M(f,e),n.d=f,y=!1,s&&(n=x(n,i,4*u)),c&&(n=n.times(Math.abs(c)<54?w(2,c):Z.pow(2,c))),y=!0,n)})(i,n)}if(o.prototype=h,o.ROUND_UP=0,o.ROUND_DOWN=1,o.ROUND_CEIL=2,o.ROUND_FLOOR=3,o.ROUND_HALF_UP=4,o.ROUND_HALF_DOWN=5,o.ROUND_HALF_EVEN=6,o.ROUND_HALF_CEIL=7,o.ROUND_HALF_FLOOR=8,o.EUCLID=9,o.config=o.set=Dn,o.clone=n,o.isDecimal=Un,o.abs=yn,o.acos=bn,o.acosh=Nn,o.add=En,o.asin=xn,o.asinh=On,o.atan=Mn,o.atanh=An,o.atan2=Sn,o.cbrt=_n,o.ceil=qn,o.clamp=Fn,o.cos=Pn,o.cosh=Rn,o.div=Tn,o.exp=Zn,o.floor=jn,o.hypot=kn,o.ln=In,o.log=Ln,o.log10=$n,o.log2=Cn,o.max=Hn,o.min=Bn,o.mod=Vn,o.mul=zn,o.pow=Wn,o.random=Jn,o.round=Gn,o.sign=Kn,o.sin=Qn,o.sinh=Xn,o.sqrt=Yn,o.sub=ne,o.sum=ee,o.tan=te,o.tanh=re,o.trunc=ie,(e=void 0===e?{}:e)&&!0!==e.defaults)for(i=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],t=0;t<i.length;)e.hasOwnProperty(r=i[t++])||(e[r]=this[r]);return o.config(e),o}(K);function oe(n,e){var t="",r=(t=Z.isDecimal(n)?n.toFixed():"string"!=typeof n?n.toString():n,null),n=null,i=null,o=e.match(/(<=|>=|=)\s*(\d+)/);if(o&&(n=o[1],r=Number(o[2])),e.includes(",")&&(i=!0),null!==r){var o=t.split("."),e=o[0],s=1===o.length?"":o[1],u=s.length;switch(n){case"<=":s=u<=r?s:s.slice(0,r);break;case"=":u<r?s+="0".repeat(r-u):r<u&&(s=s.slice(0,r));break;case">=":s=r<=u?s:s+"0".repeat(r-u)}t=""===s?e:"".concat(e,".").concat(s)}return t=null!==i?1<(o=t.split(".")).length?((n=o[0]).includes("-")?o[0]=n[0]+n.slice(1).replace(/(?=(?!^)(?:\d{3})+$)/g,","):o[0]=n.replace(/(?=(?!^)(?:\d{3})+$)/g,","),o.join(".")):(e=o[0]).includes("-")?e[0]+e.slice(1).replace(/(?=(?!^)(?:\d{3})+$)/g,","):e.replace(/(?=(?!^)(?:\d{3})+$)/g,","):t}function se(n){for(var e=[],t=0,r=null,i=n.length;t<i;)if(r=n[t],/\s/.test(r))t++;else if("+-".includes(r)){var o=e[e.length-1];if(0===e.length||"+-".includes(o)||"("===o){for(var s=r,r=n[++t];/[a-zA-Z\d._]/.test(r);)s+=r,r=n[++t];e.push(s)}else e.push(r),t++}else if("*/%()".includes(r))e.push(r),t++;else if(/[a-zA-Z_]/.test(r)){for(var u="";/[a-zA-Z0-9_]/.test(r)&&(u+=r,!(++t>=i));)r=n[t];e.push(u)}else if(/\d/.test(r)){for(var c="";/[\d.]/.test(r)&&(c+=r,!(++t>=i));)r=n[t];e.push(c)}return e}var f=new Z(f),a=new Z(a),ue=function(){L(r,e(Error));var t=B(r);function r(n){var e;return k(this,r),(e=t.call(this,n)).name="CalculatorError",e.message=n,e}return I(r)}(),ce=function(){L(r,e(Error));var t=B(r);function r(n){var e;return k(this,r),(e=t.call(this,n)).name="TokensFillError",e.message=n,e}return I(r)}();function j(n,e){var t=e._fillData;return void 0===e._fillData&&(t=e),n.map(function(n){if(/^[a-zA-z_][\w_]*$/.test(n)){var e=t[n];if(void 0!==e)return"number"==typeof e?e.toString():e;throw new ce("错误的参数:".concat(n," 请确认他存在"))}return n})}function fe(n){for(var e,t=[],r=[],i=n;0<i.length;){var o=i.shift();if(z(o))if("("===o)t.push(o);else if(")"===o){for(var s=t.pop();"("!==s&&0<t.length;)r.push(s),s=t.pop();if("("!==s)throw"error: unmatched ()"}else{for(;e=t[t.length-1],W(o)<=W(e)&&0<t.length;)r.push(t.pop());t.push(o)}else r.push(o)}if(0<t.length){if(")"===t[t.length-1]||"("===t[t.length-1])throw"error: unmatched ()";for(;0<t.length;)r.push(t.pop())}return r}function ae(n){for(var e=[];0<n.length;){var t=n.shift();if(z(t)){if(e.length<2)throw new ue("错误的栈长度, 可能是无法计算的表达式");var r=e.pop(),i=e.pop();switch("string"==typeof r&&(r=new Z(r)),"string"==typeof i&&(i=new Z(i)),t){case"+":e.push(i.add(r));break;case"-":e.push(i.sub(r));break;case"*":e.push(i.mul(r));break;case"/":e.push(i.div(r));break;case"%":e.push(i.mod(r))}}else e.push(t)}if(1!==e.length)throw"unvalid expression";return e[0]}return n.calc=function(){for(var n=arguments.length,e=new Array(n),t=0;t<n;t++)e[t]=arguments[t];var r=J(e),i=se(r.expr),o=null;if(null!==r.data)if(null===(o=void 0!==r.data._fillData?r.data:o)||void 0===o.fillError&&void 0===o.error)i=j(i,r.data);else try{i=j(i,r.data)}catch(n){if(n instanceof ce)return o.fillError||o.error;throw n}var i=fe(i),s=null;if(null!==o){if(void 0!==o.calcError||void 0!==o.error)try{s=ae(i)}catch(n){if(n instanceof ue)return void 0!==o.calcError?o.calcError:o.error;throw n}}else s=ae(i);return s=null!==r.fmt?oe(s,r.fmt):null!==s?s.toFixed():null},n.fmt=function(){for(var n=arguments.length,e=new Array(n),t=0;t<n;t++)e[t]=arguments[t];var r=J(e),i=se(r.expr),o=null;if(2<i.length)throw new Error("fmt并非用于计算, 不能传入多个标识:".concat(r.expr));if(1!==i.length)throw new Error("fmt接收了一个无法被解析的标识");if(null!==r.data)if(null===(o=void 0!==r.data._fillData?r.data:o)||void 0===o.fillError&&void 0===o.error)i=j(i,r.data);else try{i=j(i,r.data)}catch(n){if(n instanceof TokensFillError)return o.fillError||o.error;throw n}if(null===r.fmt)throw"表达式没有格式化部分";return oe(i[0],r.fmt)},n.version="0.0.28",Object.defineProperty(n,"__esModule",{value:!0}),n}({});
var a_calc=function(n){"use strict";function s(n){return(s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(n){return typeof n}:function(n){return n&&"function"==typeof Symbol&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n})(n)}function k(n,e){if(!(n instanceof e))throw new TypeError("Cannot call a class as a function")}function U(n,e){for(var t=0;t<e.length;t++){var r=e[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(n,r.key,r)}}function I(n,e,t){return e&&U(n.prototype,e),t&&U(n,t),Object.defineProperty(n,"prototype",{writable:!1}),n}function L(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),Object.defineProperty(n,"prototype",{writable:!1}),e&&o(n,e)}function i(n){return(i=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)})(n)}function o(n,e){return(o=Object.setPrototypeOf||function(n,e){return n.__proto__=e,n})(n,e)}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(n){return!1}}function $(n,e,t){return($=C()?Reflect.construct:function(n,e,t){var r=[null];r.push.apply(r,e);e=new(Function.bind.apply(n,r));return t&&o(e,t.prototype),e}).apply(null,arguments)}function e(n){var t="function"==typeof Map?new Map:void 0;return(e=function(n){if(null===n||-1===Function.toString.call(n).indexOf("[native code]"))return n;if("function"!=typeof n)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(n))return t.get(n);t.set(n,e)}function e(){return $(n,arguments,i(this).constructor)}return e.prototype=Object.create(n.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),o(e,n)})(n)}function H(n,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");e=n;if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function B(t){var r=C();return function(){var n,e=i(t);return H(this,r?(n=i(this).constructor,Reflect.construct(e,arguments,n)):e.apply(this,arguments))}}function V(n){return function(n){if(Array.isArray(n))return r(n)}(n)||function(n){if("undefined"!=typeof Symbol&&null!=n[Symbol.iterator]||null!=n["@@iterator"])return Array.from(n)}(n)||function(n,e){if(n){if("string"==typeof n)return r(n,e);var t=Object.prototype.toString.call(n).slice(8,-1);return"Map"===(t="Object"===t&&n.constructor?n.constructor.name:t)||"Set"===t?Array.from(n):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?r(n,e):void 0}}(n)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function r(n,e){(null==e||e>n.length)&&(e=n.length);for(var t=0,r=new Array(e);t<e;t++)r[t]=n[t];return r}function z(n){return-1<"+-*/%()".indexOf(n)}function W(n){switch(n){case"+":case"-":return 1;case"*":case"/":case"%":return 2;default:return 0}}function J(n){var e={expr:"",fmt:null,data:null},t="",r=n[0];if(1===n.length)"string"==typeof r?t=r:"number"==typeof r?t=r.toString():Array.isArray(r)&&(t=r[0]);else if(1<n.length){r=n[n.length-1];if(u=r,"[object Object]"!==Object.prototype.toString.call(u)||Array.isArray(u))for(var i=V(n.shift());i.length||n.length;)var o=0===i.length?"":i.shift(),s=0===n.length?"":n.shift(),t=t+o+(s="number"==typeof s?s.toString():s);else t=n[0],e.data=r}var u=t.split("|");return 1===u.length?e.expr=u[0]:(e.expr=u[0],""!==(r=u[1]).trim()&&(e.fmt=r)),e}var G,u,c=9e15,p=1e9,g="0123456789abcdef",f="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",a="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",K={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-c,maxE:c,crypto:!1},y=!0,l="[DecimalError] ",m=l+"Invalid argument: ",Q=l+"Precision limit exceeded",X=l+"crypto unavailable",t="[object Decimal]",q=Math.floor,w=Math.pow,Y=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,nn=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,en=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,tn=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,F=1e7,D=7,rn=f.length-1,on=a.length-1,h={toStringTag:t};function b(n){var e,t,r,i=n.length-1,o="",s=n[0];if(0<i){for(o+=s,e=1;e<i;e++)r=n[e]+"",(t=D-r.length)&&(o+=S(t)),o+=r;s=n[e],(t=D-(r=s+"").length)&&(o+=S(t))}else if(0===s)return"0";for(;s%10==0;)s/=10;return o+s}function v(n,e,t){if(n!==~~n||n<e||t<n)throw Error(m+n)}function N(n,e,t,r){for(var i,o,s=n[0];10<=s;s/=10)--e;return--e<0?(e+=D,i=0):(i=Math.ceil((e+1)/D),e%=D),s=w(10,D-e),o=n[i]%s|0,null==r?e<3?(0==e?o=o/100|0:1==e&&(o=o/10|0),t<4&&99999==o||3<t&&49999==o||5e4==o||0==o):(t<4&&o+1==s||3<t&&o+1==s/2)&&(n[i+1]/s/100|0)==w(10,e-2)-1||(o==s/2||0==o)&&0==(n[i+1]/s/100|0):e<4?(0==e?o=o/1e3|0:1==e?o=o/100|0:2==e&&(o=o/10|0),(r||t<4)&&9999==o||!r&&3<t&&4999==o):((r||t<4)&&o+1==s||!r&&3<t&&o+1==s/2)&&(n[i+1]/s/1e3|0)==w(10,e-3)-1}function E(n,e,t){for(var r,i,o=[0],s=0,u=n.length;s<u;){for(i=o.length;i--;)o[i]*=e;for(o[0]+=g.indexOf(n.charAt(s++)),r=0;r<o.length;r++)o[r]>t-1&&(void 0===o[r+1]&&(o[r+1]=0),o[r+1]+=o[r]/t|0,o[r]%=t)}return o.reverse()}h.absoluteValue=h.abs=function(){var n=new this.constructor(this);return n.s<0&&(n.s=1),P(n)},h.ceil=function(){return P(new this.constructor(this),this.e+1,2)},h.clampedTo=h.clamp=function(n,e){var t=this.constructor;if(n=new t(n),e=new t(e),!n.s||!e.s)return new t(NaN);if(n.gt(e))throw Error(m+e);return this.cmp(n)<0?n:0<this.cmp(e)?e:new t(this)},h.comparedTo=h.cmp=function(n){var e,t,r=this,i=r.d,o=(n=new r.constructor(n)).d,s=r.s,u=n.s;if(!i||!o)return s&&u?s!==u?s:i===o?0:!i^s<0?1:-1:NaN;if(!i[0]||!o[0])return i[0]?s:o[0]?-u:0;if(s!==u)return s;if(r.e!==n.e)return r.e>n.e^s<0?1:-1;for(e=0,t=(u=i.length)<(r=o.length)?u:r;e<t;++e)if(i[e]!==o[e])return i[e]>o[e]^s<0?1:-1;return u===r?0:r<u^s<0?1:-1},h.cosine=h.cos=function(){var n,e,t=this,r=t.constructor;return t.d?t.d[0]?(n=r.precision,e=r.rounding,r.precision=n+Math.max(t.e,t.sd())+D,r.rounding=1,t=function(n,e){var t,r;if(e.isZero())return e;r=(r=e.d.length)<32?(t=Math.ceil(r/3),(1/T(4,t)).toString()):(t=16,"2.3283064365386962890625e-10");n.precision+=t,e=R(n,1,e.times(r),new n(1));for(var i=t;i--;){var o=e.times(e);e=o.times(o).minus(o).times(8).plus(1)}return n.precision-=t,e}(r,mn(r,t)),r.precision=n,r.rounding=e,P(2==u||3==u?t.neg():t,n,e,!0)):new r(1):new r(NaN)},h.cubeRoot=h.cbrt=function(){var n,e,t,r,i,o,s,u,c,f,a=this,l=a.constructor;if(!a.isFinite()||a.isZero())return new l(a);for(y=!1,(o=a.s*w(a.s*a,1/3))&&Math.abs(o)!=1/0?r=new l(o.toString()):(t=b(a.d),(o=((n=a.e)-t.length+1)%3)&&(t+=1==o||-2==o?"0":"00"),o=w(t,1/3),n=q((n+1)/3)-(n%3==(n<0?-1:2)),(r=new l(t=o==1/0?"5e"+n:(t=o.toExponential()).slice(0,t.indexOf("e")+1)+n)).s=a.s),s=(n=l.precision)+3;;)if(f=(c=(u=r).times(u).times(u)).plus(a),r=x(f.plus(a).times(u),f.plus(c),s+2,1),b(u.d).slice(0,s)===(t=b(r.d)).slice(0,s)){if("9999"!=(t=t.slice(s-3,s+1))&&(i||"4999"!=t)){+t&&(+t.slice(1)||"5"!=t.charAt(0))||(P(r,n+1,1),e=!r.times(r).times(r).eq(a));break}if(!i&&(P(u,n+1,0),u.times(u).times(u).eq(a))){r=u;break}s+=4,i=1}return y=!0,P(r,n,l.rounding,e)},h.decimalPlaces=h.dp=function(){var n,e=this.d,t=NaN;if(e){if(t=((n=e.length-1)-q(this.e/D))*D,n=e[n])for(;n%10==0;n/=10)t--;t<0&&(t=0)}return t},h.dividedBy=h.div=function(n){return x(this,new this.constructor(n))},h.dividedToIntegerBy=h.divToInt=function(n){var e=this.constructor;return P(x(this,new e(n),0,1,1),e.precision,e.rounding)},h.equals=h.eq=function(n){return 0===this.cmp(n)},h.floor=function(){return P(new this.constructor(this),this.e+1,3)},h.greaterThan=h.gt=function(n){return 0<this.cmp(n)},h.greaterThanOrEqualTo=h.gte=function(n){n=this.cmp(n);return 1==n||0===n},h.hyperbolicCosine=h.cosh=function(){var n,e,t,r=(u=this).constructor,i=new r(1);if(!u.isFinite())return new r(u.s?1/0:NaN);if(u.isZero())return i;e=r.precision,t=r.rounding,r.precision=e+Math.max(u.e,u.sd())+4,r.rounding=1;for(var o,s=(s=u.d.length)<32?(1/T(4,n=Math.ceil(s/3))).toString():(n=16,"2.3283064365386962890625e-10"),u=R(r,1,u.times(s),new r(1),!0),c=n,f=new r(8);c--;)o=u.times(u),u=i.minus(o.times(f.minus(o.times(f))));return P(u,r.precision=e,r.rounding=t,!0)},h.hyperbolicSine=h.sinh=function(){var n,e,t,r=(s=this).constructor;if(!s.isFinite()||s.isZero())return new r(s);if(n=r.precision,e=r.rounding,r.precision=n+Math.max(s.e,s.sd())+4,r.rounding=1,(t=s.d.length)<3)s=R(r,2,s,s,!0);else for(var i,o=1.4*Math.sqrt(t),s=R(r,2,s=s.times(1/T(5,o=16<o?16:0|o)),s,!0),u=new r(5),c=new r(16),f=new r(20);o--;)i=s.times(s),s=s.times(u.plus(i.times(c.times(i).plus(f))));return P(s,r.precision=n,r.rounding=e,!0)},h.hyperbolicTangent=h.tanh=function(){var n,e,t=this,r=t.constructor;return t.isFinite()?t.isZero()?new r(t):(n=r.precision,e=r.rounding,r.precision=n+7,r.rounding=1,x(t.sinh(),t.cosh(),r.precision=n,r.rounding=e)):new r(t.s)},h.inverseCosine=h.acos=function(){var n=this,e=n.constructor,t=n.abs().cmp(1),r=e.precision,i=e.rounding;return-1!==t?0===t?n.isNeg()?d(e,r,i):new e(0):new e(NaN):n.isZero()?d(e,r+4,i).times(.5):(e.precision=r+6,e.rounding=1,n=n.asin(),t=d(e,r+4,i).times(.5),e.precision=r,e.rounding=i,t.minus(n))},h.inverseHyperbolicCosine=h.acosh=function(){var n,e,t=this,r=t.constructor;return t.lte(1)?new r(t.eq(1)?0:NaN):t.isFinite()?(n=r.precision,e=r.rounding,r.precision=n+Math.max(Math.abs(t.e),t.sd())+4,r.rounding=1,y=!1,t=t.times(t).minus(1).sqrt().plus(t),y=!0,r.precision=n,r.rounding=e,t.ln()):new r(t)},h.inverseHyperbolicSine=h.asinh=function(){var n,e,t=this,r=t.constructor;return!t.isFinite()||t.isZero()?new r(t):(n=r.precision,e=r.rounding,r.precision=n+2*Math.max(Math.abs(t.e),t.sd())+6,r.rounding=1,y=!1,t=t.times(t).plus(1).sqrt().plus(t),y=!0,r.precision=n,r.rounding=e,t.ln())},h.inverseHyperbolicTangent=h.atanh=function(){var n,e,t,r=this,i=r.constructor;return r.isFinite()?0<=r.e?new i(r.abs().eq(1)?r.s/0:r.isZero()?r:NaN):(n=i.precision,e=i.rounding,t=r.sd(),Math.max(t,n)<2*-r.e-1?P(new i(r),n,e,!0):(i.precision=t=t-r.e,r=x(r.plus(1),new i(1).minus(r),t+n,1),i.precision=n+4,i.rounding=1,r=r.ln(),i.precision=n,i.rounding=e,r.times(.5))):new i(NaN)},h.inverseSine=h.asin=function(){var n,e,t,r=this,i=r.constructor;return r.isZero()?new i(r):(n=r.abs().cmp(1),e=i.precision,t=i.rounding,-1!==n?0===n?((n=d(i,e+4,t).times(.5)).s=r.s,n):new i(NaN):(i.precision=e+6,i.rounding=1,r=r.div(new i(1).minus(r.times(r)).sqrt().plus(1)).atan(),i.precision=e,i.rounding=t,r.times(2)))},h.inverseTangent=h.atan=function(){var n,e,t,r,i,o,s,u,c,f=this,a=f.constructor,l=a.precision,h=a.rounding;if(f.isFinite()){if(f.isZero())return new a(f);if(f.abs().eq(1)&&l+4<=on)return(s=d(a,l+4,h).times(.25)).s=f.s,s}else{if(!f.s)return new a(NaN);if(l+4<=on)return(s=d(a,l+4,h).times(.5)).s=f.s,s}for(a.precision=u=l+10,a.rounding=1,n=t=Math.min(28,u/D+2|0);n;--n)f=f.div(f.times(f).plus(1).sqrt().plus(1));for(y=!1,e=Math.ceil(u/D),r=1,c=f.times(f),s=new a(f),i=f;-1!==n;)if(i=i.times(c),o=s.minus(i.div(r+=2)),i=i.times(c),void 0!==(s=o.plus(i.div(r+=2))).d[e])for(n=e;s.d[n]===o.d[n]&&n--;);return t&&(s=s.times(2<<t-1)),y=!0,P(s,a.precision=l,a.rounding=h,!0)},h.isFinite=function(){return!!this.d},h.isInteger=h.isInt=function(){return!!this.d&&q(this.e/D)>this.d.length-2},h.isNaN=function(){return!this.s},h.isNegative=h.isNeg=function(){return this.s<0},h.isPositive=h.isPos=function(){return 0<this.s},h.isZero=function(){return!!this.d&&0===this.d[0]},h.lessThan=h.lt=function(n){return this.cmp(n)<0},h.lessThanOrEqualTo=h.lte=function(n){return this.cmp(n)<1},h.logarithm=h.log=function(n){var e,t,r,i,o,s,u,c,f=this,a=f.constructor,l=a.precision,h=a.rounding;if(null==n)n=new a(10),e=!0;else{if(t=(n=new a(n)).d,n.s<0||!t||!t[0]||n.eq(1))return new a(NaN);e=n.eq(10)}if(t=f.d,f.s<0||!t||!t[0]||f.eq(1))return new a(t&&!t[0]?-1/0:1!=f.s?NaN:t?0:1/0);if(e)if(1<t.length)o=!0;else{for(i=t[0];i%10==0;)i/=10;o=1!==i}if(y=!1,s=_(f,u=l+5),r=e?A(a,u+10):_(n,u),N((c=x(s,r,u,1)).d,i=l,h))do{if(s=_(f,u+=10),r=e?A(a,u+10):_(n,u),c=x(s,r,u,1),!o){+b(c.d).slice(i+1,i+15)+1==1e14&&(c=P(c,l+1,0));break}}while(N(c.d,i+=10,h));return y=!0,P(c,l,h)},h.minus=h.sub=function(n){var e,t,r,i,o,s,u,c,f,a,l,h=this,d=h.constructor;if(n=new d(n),!h.d||!n.d)return h.s&&n.s?h.d?n.s=-n.s:n=new d(n.d||h.s!==n.s?h:NaN):n=new d(NaN),n;if(h.s!=n.s)return n.s=-n.s,h.plus(n);if(f=h.d,l=n.d,u=d.precision,c=d.rounding,!f[0]||!l[0]){if(l[0])n.s=-n.s;else{if(!f[0])return new d(3===c?-0:0);n=new d(h)}return y?P(n,u,c):n}if(t=q(n.e/D),h=q(h.e/D),f=f.slice(),o=h-t){for(s=(a=o<0)?(e=f,o=-o,l.length):(e=l,t=h,f.length),(r=Math.max(Math.ceil(u/D),s)+2)<o&&(o=r,e.length=1),e.reverse(),r=o;r--;)e.push(0);e.reverse()}else{for((a=(r=f.length)<(s=l.length))&&(s=r),r=0;r<s;r++)if(f[r]!=l[r]){a=f[r]<l[r];break}o=0}for(a&&(e=f,f=l,l=e,n.s=-n.s),s=f.length,r=l.length-s;0<r;--r)f[s++]=0;for(r=l.length;o<r;){if(f[--r]<l[r]){for(i=r;i&&0===f[--i];)f[i]=F-1;--f[i],f[r]+=F}f[r]-=l[r]}for(;0===f[--s];)f.pop();for(;0===f[0];f.shift())--t;return f[0]?(n.d=f,n.e=M(f,t),y?P(n,u,c):n):new d(3===c?-0:0)},h.modulo=h.mod=function(n){var e,t=this,r=t.constructor;return n=new r(n),!t.d||!n.s||n.d&&!n.d[0]?new r(NaN):!n.d||t.d&&!t.d[0]?P(new r(t),r.precision,r.rounding):(y=!1,9==r.modulo?(e=x(t,n.abs(),0,3,1)).s*=n.s:e=x(t,n,0,r.modulo,1),e=e.times(n),y=!0,t.minus(e))},h.naturalExponential=h.exp=function(){return dn(this)},h.naturalLogarithm=h.ln=function(){return _(this)},h.negated=h.neg=function(){var n=new this.constructor(this);return n.s=-n.s,P(n)},h.plus=h.add=function(n){var e,t,r,i,o,s,u,c,f=this,a=f.constructor;if(n=new a(n),!f.d||!n.d)return f.s&&n.s?f.d||(n=new a(n.d||f.s===n.s?f:NaN)):n=new a(NaN),n;if(f.s!=n.s)return n.s=-n.s,f.minus(n);if(u=f.d,c=n.d,o=a.precision,s=a.rounding,!u[0]||!c[0])return c[0]||(n=new a(f)),y?P(n,o,s):n;if(a=q(f.e/D),f=q(n.e/D),u=u.slice(),r=a-f){for((i=(i=r<0?(t=u,r=-r,c.length):(t=c,f=a,u.length))<(a=Math.ceil(o/D))?a+1:i+1)<r&&(r=i,t.length=1),t.reverse();r--;)t.push(0);t.reverse()}for((i=u.length)-(r=c.length)<0&&(r=i,t=c,c=u,u=t),e=0;r;)e=(u[--r]=u[r]+c[r]+e)/F|0,u[r]%=F;for(e&&(u.unshift(e),++f),i=u.length;0==u[--i];)u.pop();return n.d=u,n.e=M(u,f),y?P(n,o,s):n},h.precision=h.sd=function(n){var e;if(void 0!==n&&n!==!!n&&1!==n&&0!==n)throw Error(m+n);return this.d?(e=fn(this.d),n&&this.e+1>e&&(e=this.e+1)):e=NaN,e},h.round=function(){var n=this.constructor;return P(new n(this),this.e+1,n.rounding)},h.sine=h.sin=function(){var n,e,t=this,r=t.constructor;return t.isFinite()?t.isZero()?new r(t):(n=r.precision,e=r.rounding,r.precision=n+Math.max(t.e,t.sd())+D,r.rounding=1,t=function(n,e){var t,r=e.d.length;if(r<3)return e.isZero()?e:R(n,2,e,e);t=16<(t=1.4*Math.sqrt(r))?16:0|t,e=e.times(1/T(5,t)),e=R(n,2,e,e);for(var i,o=new n(5),s=new n(16),u=new n(20);t--;)i=e.times(e),e=e.times(o.plus(i.times(s.times(i).minus(u))));return e}(r,mn(r,t)),r.precision=n,r.rounding=e,P(2<u?t.neg():t,n,e,!0)):new r(NaN)},h.squareRoot=h.sqrt=function(){var n,e,t,r,i,o,s=this,u=s.d,c=s.e,f=s.s,a=s.constructor;if(1!==f||!u||!u[0])return new a(!f||f<0&&(!u||u[0])?NaN:u?s:1/0);for(y=!1,r=0==(f=Math.sqrt(+s))||f==1/0?(((e=b(u)).length+c)%2==0&&(e+="0"),f=Math.sqrt(e),c=q((c+1)/2)-(c<0||c%2),new a(e=f==1/0?"5e"+c:(e=f.toExponential()).slice(0,e.indexOf("e")+1)+c)):new a(f.toString()),t=(c=a.precision)+3;;)if(r=(o=r).plus(x(s,o,t+2,1)).times(.5),b(o.d).slice(0,t)===(e=b(r.d)).slice(0,t)){if("9999"!=(e=e.slice(t-3,t+1))&&(i||"4999"!=e)){+e&&(+e.slice(1)||"5"!=e.charAt(0))||(P(r,c+1,1),n=!r.times(r).eq(s));break}if(!i&&(P(o,c+1,0),o.times(o).eq(s))){r=o;break}t+=4,i=1}return y=!0,P(r,c,a.rounding,n)},h.tangent=h.tan=function(){var n,e,t=this,r=t.constructor;return t.isFinite()?t.isZero()?new r(t):(n=r.precision,e=r.rounding,r.precision=n+10,r.rounding=1,(t=t.sin()).s=1,t=x(t,new r(1).minus(t.times(t)).sqrt(),n+10,0),r.precision=n,r.rounding=e,P(2==u||4==u?t.neg():t,n,e,!0)):new r(NaN)},h.times=h.mul=function(n){var e,t,r,i,o,s,u,c,f,a=this.constructor,l=this.d,h=(n=new a(n)).d;if(n.s*=this.s,!(l&&l[0]&&h&&h[0]))return new a(!n.s||l&&!l[0]&&!h||h&&!h[0]&&!l?NaN:l&&h?0*n.s:n.s/0);for(t=q(this.e/D)+q(n.e/D),(c=l.length)<(f=h.length)&&(o=l,l=h,h=o,s=c,c=f,f=s),o=[],r=s=c+f;r--;)o.push(0);for(r=f;0<=--r;){for(e=0,i=c+r;r<i;)u=o[i]+h[r]*l[i-r-1]+e,o[i--]=u%F|0,e=u/F|0;o[i]=(o[i]+e)%F|0}for(;!o[--s];)o.pop();return e?++t:o.shift(),n.d=o,n.e=M(o,t),y?P(n,a.precision,a.rounding):n},h.toBinary=function(n,e){return wn(this,2,n,e)},h.toDecimalPlaces=h.toDP=function(n,e){var t=this.constructor,r=new t(this);return void 0===n?r:(v(n,0,p),void 0===e?e=t.rounding:v(e,0,8),P(r,n+r.e+1,e))},h.toExponential=function(n,e){var t=this,r=t.constructor,r=void 0===n?O(t,!0):(v(n,0,p),void 0===e?e=r.rounding:v(e,0,8),O(t=P(new r(t),n+1,e),!0,n+1));return t.isNeg()&&!t.isZero()?"-"+r:r},h.toFixed=function(n,e){var t=this,r=t.constructor,e=void 0===n?O(t):(v(n,0,p),void 0===e?e=r.rounding:v(e,0,8),O(r=P(new r(t),n+t.e+1,e),!1,n+r.e+1));return t.isNeg()&&!t.isZero()?"-"+e:e},h.toFraction=function(n){var e,t,r,i,o,s,u,c,f,a,l=this,h=l.d,d=l.constructor;if(!h)return new d(l);if(c=t=new d(1),r=u=new d(0),o=(e=new d(r)).e=fn(h)-l.e-1,e.d[0]=w(10,(f=o%D)<0?D+f:f),null==n)n=0<o?e:c;else{if(!(s=new d(n)).isInt()||s.lt(c))throw Error(m+s);n=s.gt(e)?0<o?e:c:s}for(y=!1,s=new d(b(h)),f=d.precision,d.precision=o=h.length*D*2;a=x(s,e,0,1,1),1!=(i=t.plus(a.times(r))).cmp(n);)t=r,r=i,i=c,c=u.plus(a.times(i)),u=i,i=e,e=s.minus(a.times(i)),s=i;return i=x(n.minus(t),r,0,1,1),u=u.plus(i.times(c)),t=t.plus(i.times(r)),u.s=c.s=l.s,h=x(c,r,o,1).minus(l).abs().cmp(x(u,t,o,1).minus(l).abs())<1?[c,r]:[u,t],d.precision=f,y=!0,h},h.toHexadecimal=h.toHex=function(n,e){return wn(this,16,n,e)},h.toNearest=function(n,e){var t=(r=this).constructor,r=new t(r);if(null==n){if(!r.d)return r;n=new t(1),e=t.rounding}else{if(n=new t(n),void 0===e?e=t.rounding:v(e,0,8),!r.d)return n.s?r:n;if(!n.d)return n.s&&(n.s=r.s),n}return n.d[0]?(y=!1,r=x(r,n,0,e,1).times(n),y=!0,P(r)):(n.s=r.s,r=n),r},h.toNumber=function(){return+this},h.toOctal=function(n,e){return wn(this,8,n,e)},h.toPower=h.pow=function(n){var e,t,r,i,o,s,u=this,c=u.constructor,f=+(n=new c(n));if(!(u.d&&n.d&&u.d[0]&&n.d[0]))return new c(w(+u,f));if((u=new c(u)).eq(1))return u;if(r=c.precision,o=c.rounding,n.eq(1))return P(u,r,o);if((e=q(n.e/D))>=n.d.length-1&&(t=f<0?-f:f)<=9007199254740991)return i=an(c,u,t,r),n.s<0?new c(1).div(i):P(i,r,o);if((s=u.s)<0){if(e<n.d.length-1)return new c(NaN);if(0==(1&n.d[e])&&(s=1),0==u.e&&1==u.d[0]&&1==u.d.length)return u.s=s,u}return(e=0!=(t=w(+u,f))&&isFinite(t)?new c(t+"").e:q(f*(Math.log("0."+b(u.d))/Math.LN10+u.e+1)))>c.maxE+1||e<c.minE-1?new c(0<e?s/0:0):(y=!1,c.rounding=u.s=1,t=Math.min(12,(e+"").length),(i=(i=dn(n.times(_(u,r+t)),r)).d&&N((i=P(i,r+5,1)).d,r,o)&&+b((i=P(dn(n.times(_(u,(e=r+10)+t)),e),e+5,1)).d).slice(r+1,r+15)+1==1e14?P(i,r+1,0):i).s=s,y=!0,P(i,r,c.rounding=o))},h.toPrecision=function(n,e){var t=this,r=t.constructor,e=void 0===n?O(t,t.e<=r.toExpNeg||t.e>=r.toExpPos):(v(n,1,p),void 0===e?e=r.rounding:v(e,0,8),O(t=P(new r(t),n,e),n<=t.e||t.e<=r.toExpNeg,n));return t.isNeg()&&!t.isZero()?"-"+e:e},h.toSignificantDigits=h.toSD=function(n,e){var t=this.constructor;return void 0===n?(n=t.precision,e=t.rounding):(v(n,1,p),void 0===e?e=t.rounding:v(e,0,8)),P(new t(this),n,e)},h.toString=function(){var n=this,e=n.constructor,e=O(n,n.e<=e.toExpNeg||n.e>=e.toExpPos);return n.isNeg()&&!n.isZero()?"-"+e:e},h.truncated=h.trunc=function(){return P(new this.constructor(this),this.e+1,1)},h.valueOf=h.toJSON=function(){var n=this,e=n.constructor,e=O(n,n.e<=e.toExpNeg||n.e>=e.toExpPos);return n.isNeg()?"-"+e:e};var x=function(n,e,t,r,i,o){var s,u,c,f,a,l,h,d,p,g,m,w,v,y,b,N,E,x,O,M=n.constructor,A=n.s==e.s?1:-1,S=n.d,_=e.d;if(!(S&&S[0]&&_&&_[0]))return new M(n.s&&e.s&&(S?!_||S[0]!=_[0]:_)?S&&0==S[0]||!_?0*A:A/0:NaN);for(u=o?(a=1,n.e-e.e):(o=F,q(n.e/(a=D))-q(e.e/a)),x=_.length,N=S.length,p=(A=new M(A)).d=[],c=0;_[c]==(S[c]||0);c++);if(_[c]>(S[c]||0)&&u--,null==t?(v=t=M.precision,r=M.rounding):v=i?t+(n.e-e.e)+1:t,v<0)p.push(1),l=!0;else{if(v=v/a+2|0,c=0,1==x){for(_=_[f=0],v++;(c<N||f)&&v--;c++)y=f*o+(S[c]||0),p[c]=y/_|0,f=y%_|0;l=f||c<N}else{for(1<(f=o/(_[0]+1)|0)&&(_=sn(_,f,o),S=sn(S,f,o),x=_.length,N=S.length),b=x,m=(g=S.slice(0,x)).length;m<x;)g[m++]=0;for((O=_.slice()).unshift(0),E=_[0],_[1]>=o/2&&++E;f=0,(s=un(_,g,x,m))<0?(w=g[0],1<(f=(w=x!=m?w*o+(g[1]||0):w)/E|0)?1==(s=un(h=sn(_,f=o<=f?o-1:f,o),g,d=h.length,m=g.length))&&(f--,cn(h,x<d?O:_,d,o)):(0==f&&(s=f=1),h=_.slice()),(d=h.length)<m&&h.unshift(0),cn(g,h,m,o),-1==s&&(s=un(_,g,x,m=g.length))<1&&(f++,cn(g,x<m?O:_,m,o)),m=g.length):0===s&&(f++,g=[0]),p[c++]=f,s&&g[0]?g[m++]=S[b]||0:(g=[S[b]],m=1),(b++<N||void 0!==g[0])&&v--;);l=void 0!==g[0]}p[0]||p.shift()}if(1==a)A.e=u,G=l;else{for(c=1,f=p[0];10<=f;f/=10)c++;A.e=c+u*a-1,P(A,i?t+A.e+1:t,r,l)}return A};function sn(n,e,t){var r,i=0,o=n.length;for(n=n.slice();o--;)r=n[o]*e+i,n[o]=r%t|0,i=r/t|0;return i&&n.unshift(i),n}function un(n,e,t,r){var i,o;if(t!=r)o=r<t?1:-1;else for(i=o=0;i<t;i++)if(n[i]!=e[i]){o=n[i]>e[i]?1:-1;break}return o}function cn(n,e,t,r){for(var i=0;t--;)n[t]-=i,i=n[t]<e[t]?1:0,n[t]=i*r+n[t]-e[t];for(;!n[0]&&1<n.length;)n.shift()}function P(n,e,t,r){var i,o,s,u,c,f,a,l,h=n.constructor;n:if(null!=e){if(!(a=n.d))return n;for(i=1,u=a[0];10<=u;u/=10)i++;if((o=e-i)<0)o+=D,s=e,c=(f=a[l=0])/w(10,i-s-1)%10|0;else if(l=Math.ceil((o+1)/D),(u=a.length)<=l){if(!r)break n;for(;u++<=l;)a.push(0);f=c=0,s=(o%=D)-D+(i=1)}else{for(f=u=a[l],i=1;10<=u;u/=10)i++;c=(s=(o%=D)-D+i)<0?0:f/w(10,i-s-1)%10|0}if(r=r||e<0||void 0!==a[l+1]||(s<0?f:f%w(10,i-s-1)),c=t<4?(c||r)&&(0==t||t==(n.s<0?3:2)):5<c||5==c&&(4==t||r||6==t&&(0<o?0<s?f/w(10,i-s):0:a[l-1])%10&1||t==(n.s<0?8:7)),e<1||!a[0])return a.length=0,c?(e-=n.e+1,a[0]=w(10,(D-e%D)%D),n.e=-e||0):a[0]=n.e=0,n;if(0==o?(a.length=l,u=1,l--):(a.length=l+1,u=w(10,D-o),a[l]=0<s?(f/w(10,i-s)%w(10,s)|0)*u:0),c)for(;;){if(0==l){for(o=1,s=a[0];10<=s;s/=10)o++;for(s=a[0]+=u,u=1;10<=s;s/=10)u++;o!=u&&(n.e++,a[0]==F&&(a[0]=1));break}if(a[l]+=u,a[l]!=F)break;a[l--]=0,u=1}for(o=a.length;0===a[--o];)a.pop()}return y&&(n.e>h.maxE?(n.d=null,n.e=NaN):n.e<h.minE&&(n.e=0,n.d=[0])),n}function O(n,e,t){if(!n.isFinite())return pn(n);var r,i=n.e,o=b(n.d),s=o.length;return e?(t&&0<(r=t-s)?o=o.charAt(0)+"."+o.slice(1)+S(r):1<s&&(o=o.charAt(0)+"."+o.slice(1)),o=o+(n.e<0?"e":"e+")+n.e):i<0?(o="0."+S(-i-1)+o,t&&0<(r=t-s)&&(o+=S(r))):s<=i?(o+=S(i+1-s),t&&0<(r=t-i-1)&&(o=o+"."+S(r))):((r=i+1)<s&&(o=o.slice(0,r)+"."+o.slice(r)),t&&0<(r=t-s)&&(i+1===s&&(o+="."),o+=S(r))),o}function M(n,e){var t=n[0];for(e*=D;10<=t;t/=10)e++;return e}function A(n,e,t){if(rn<e)throw y=!0,t&&(n.precision=t),Error(Q);return P(new n(f),e,1,!0)}function d(n,e,t){if(on<e)throw Error(Q);return P(new n(a),e,t,!0)}function fn(n){var e=n.length-1,t=e*D+1;if(e=n[e]){for(;e%10==0;e/=10)t--;for(e=n[0];10<=e;e/=10)t++}return t}function S(n){for(var e="";n--;)e+="0";return e}function an(n,e,t,r){var i,o=new n(1),s=Math.ceil(r/D+4);for(y=!1;;){if(t%2&&vn((o=o.times(e)).d,s)&&(i=!0),0===(t=q(t/2))){t=o.d.length-1,i&&0===o.d[t]&&++o.d[t];break}vn((e=e.times(e)).d,s)}return y=!0,o}function ln(n){return 1&n.d[n.d.length-1]}function hn(n,e,t){for(var r,i=new n(e[0]),o=0;++o<e.length;){if(!(r=new n(e[o])).s){i=r;break}i[t](r)&&(i=r)}return i}function dn(n,e){var t,r,i,o,s,u,c,f=0,a=0,l=0,h=n.constructor,d=h.rounding,p=h.precision;if(!n.d||!n.d[0]||17<n.e)return new h(n.d?n.d[0]?n.s<0?0:1/0:1:n.s?n.s<0?0:n:NaN);for(c=null==e?(y=!1,p):e,u=new h(.03125);-2<n.e;)n=n.times(u),l+=5;for(c+=r=Math.log(w(2,l))/Math.LN10*2+5|0,t=o=s=new h(1),h.precision=c;;){if(o=P(o.times(n),c,1),t=t.times(++a),b((u=s.plus(x(o,t,c,1))).d).slice(0,c)===b(s.d).slice(0,c)){for(i=l;i--;)s=P(s.times(s),c,1);if(null!=e)return h.precision=p,s;if(!(f<3&&N(s.d,c-r,d,f)))return P(s,h.precision=p,d,y=!0);h.precision=c+=10,t=o=u=new h(1),a=0,f++}s=u}}function _(n,e){var t,r,i,o,s,u,c,f,a,l,h,d=1,p=n,g=p.d,m=p.constructor,w=m.rounding,v=m.precision;if(p.s<0||!g||!g[0]||!p.e&&1==g[0]&&1==g.length)return new m(g&&!g[0]?-1/0:1!=p.s?NaN:g?0:p);if(a=null==e?(y=!1,v):e,m.precision=a+=10,r=(t=b(g)).charAt(0),!(Math.abs(o=p.e)<15e14))return f=A(m,a+2,v).times(o+""),p=_(new m(r+"."+t.slice(1)),a-10).plus(f),m.precision=v,null==e?P(p,v,w,y=!0):p;for(;r<7&&1!=r||1==r&&3<t.charAt(1);)r=(t=b((p=p.times(n)).d)).charAt(0),d++;for(o=p.e,1<r?(p=new m("0."+t),o++):p=new m(r+"."+t.slice(1)),c=s=p=x((l=p).minus(1),p.plus(1),a,1),h=P(p.times(p),a,1),i=3;;){if(s=P(s.times(h),a,1),b((f=c.plus(x(s,new m(i),a,1))).d).slice(0,a)===b(c.d).slice(0,a)){if(c=c.times(2),0!==o&&(c=c.plus(A(m,a+2,v).times(o+""))),c=x(c,new m(d),a,1),null!=e)return m.precision=v,c;if(!N(c.d,a-10,w,u))return P(c,m.precision=v,w,y=!0);m.precision=a+=10,f=s=p=x(l.minus(1),l.plus(1),a,1),h=P(p.times(p),a,1),i=u=1}c=f,i+=2}}function pn(n){return String(n.s*n.s/0)}function gn(n,e){var t,r,i;for(0<(r=(e=-1<(t=e.indexOf("."))?e.replace(".",""):e).search(/e/i))?(t<0&&(t=r),t+=+e.slice(r+1),e=e.substring(0,r)):t<0&&(t=e.length),r=0;48===e.charCodeAt(r);r++);for(i=e.length;48===e.charCodeAt(i-1);--i);if(e=e.slice(r,i)){if(i-=r,n.e=t=t-r-1,n.d=[],r=(t+1)%D,t<0&&(r+=D),r<i){for(r&&n.d.push(+e.slice(0,r)),i-=D;r<i;)n.d.push(+e.slice(r,r+=D));e=e.slice(r),r=D-e.length}else r-=i;for(;r--;)e+="0";n.d.push(+e),y&&(n.e>n.constructor.maxE?(n.d=null,n.e=NaN):n.e<n.constructor.minE&&(n.e=0,n.d=[0]))}else n.e=0,n.d=[0];return n}function R(n,e,t,r,i){var o,s,u,c,f=n.precision,a=Math.ceil(f/D);for(y=!1,c=t.times(t),u=new n(r);;){if(s=x(u.times(c),new n(e++*e++),f,1),u=i?r.plus(s):r.minus(s),r=x(s.times(c),new n(e++*e++),f,1),void 0!==(s=u.plus(r)).d[a]){for(o=a;s.d[o]===u.d[o]&&o--;);if(-1==o)break}o=u,u=r,r=s,s=o}return y=!0,s.d.length=a+1,s}function T(n,e){for(var t=n;--e;)t*=n;return t}function mn(n,e){var t,r=e.s<0,n=d(n,n.precision,1),i=n.times(.5);if((e=e.abs()).lte(i))return u=r?4:1,e;if((t=e.divToInt(n)).isZero())u=r?3:2;else{if((e=e.minus(t.times(n))).lte(i))return u=ln(t)?r?2:3:r?4:1,e;u=ln(t)?r?1:4:r?3:2}return e.minus(n).abs()}function wn(n,e,t,r){var i,o,s,u,c,f,a,l,h=n.constructor,d=void 0!==t;if(d?(v(t,1,p),void 0===r?r=h.rounding:v(r,0,8)):(t=h.precision,r=h.rounding),n.isFinite()){for(d?(i=2,16==e?t=4*t-3:8==e&&(t=3*t-2)):i=e,0<=(s=(f=O(n)).indexOf("."))&&(f=f.replace(".",""),(l=new h(1)).e=f.length-s,l.d=E(O(l),10,i),l.e=l.d.length),o=u=(a=E(f,10,i)).length;0==a[--u];)a.pop();if(a[0]){if(s<0?o--:((n=new h(n)).d=a,n.e=o,a=(n=x(n,l,t,r,0,i)).d,o=n.e,c=G),s=a[t],h=i/2,c=c||void 0!==a[t+1],c=r<4?(void 0!==s||c)&&(0===r||r===(n.s<0?3:2)):h<s||s===h&&(4===r||c||6===r&&1&a[t-1]||r===(n.s<0?8:7)),a.length=t,c)for(;++a[--t]>i-1;)a[t]=0,t||(++o,a.unshift(1));for(u=a.length;!a[u-1];--u);for(s=0,f="";s<u;s++)f+=g.charAt(a[s]);if(d){if(1<u)if(16==e||8==e){for(s=16==e?4:3,--u;u%s;u++)f+="0";for(u=(a=E(f,i,e)).length;!a[u-1];--u);for(s=1,f="1.";s<u;s++)f+=g.charAt(a[s])}else f=f.charAt(0)+"."+f.slice(1);f=f+(o<0?"p":"p+")+o}else if(o<0){for(;++o;)f="0"+f;f="0."+f}else if(++o>u)for(o-=u;o--;)f+="0";else o<u&&(f=f.slice(0,o)+"."+f.slice(o))}else f=d?"0p+0":"0";f=(16==e?"0x":2==e?"0b":8==e?"0o":"")+f}else f=pn(n);return n.s<0?"-"+f:f}function vn(n,e){return n.length>e&&(n.length=e,1)}function yn(n){return new this(n).abs()}function bn(n){return new this(n).acos()}function Nn(n){return new this(n).acosh()}function En(n,e){return new this(n).plus(e)}function xn(n){return new this(n).asin()}function On(n){return new this(n).asinh()}function Mn(n){return new this(n).atan()}function An(n){return new this(n).atanh()}function Sn(n,e){n=new this(n),e=new this(e);var t,r=this.precision,i=this.rounding,o=r+4;return n.s&&e.s?n.d||e.d?!e.d||n.isZero()?(t=e.s<0?d(this,r,i):new this(0)).s=n.s:!n.d||e.isZero()?(t=d(this,o,1).times(.5)).s=n.s:t=e.s<0?(this.precision=o,this.rounding=1,t=this.atan(x(n,e,o,1)),e=d(this,o,1),this.precision=r,this.rounding=i,n.s<0?t.minus(e):t.plus(e)):this.atan(x(n,e,o,1)):(t=d(this,o,1).times(0<e.s?.25:.75)).s=n.s:t=new this(NaN),t}function _n(n){return new this(n).cbrt()}function qn(n){return P(n=new this(n),n.e+1,2)}function Fn(n,e,t){return new this(n).clamp(e,t)}function Dn(n){if(!n||"object"!==s(n))throw Error(l+"Object expected");for(var e,t,r=!0===n.defaults,i=["precision",1,p,"rounding",0,8,"toExpNeg",-c,0,"toExpPos",0,c,"maxE",0,c,"minE",-c,0,"modulo",0,9],o=0;o<i.length;o+=3)if(e=i[o],r&&(this[e]=K[e]),void 0!==(t=n[e])){if(!(q(t)===t&&i[o+1]<=t&&t<=i[o+2]))throw Error(m+e+": "+t);this[e]=t}if(e="crypto",r&&(this[e]=K[e]),void 0!==(t=n[e])){if(!0!==t&&!1!==t&&0!==t&&1!==t)throw Error(m+e+": "+t);if(t){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw Error(X);this[e]=!0}else this[e]=!1}return this}function Pn(n){return new this(n).cos()}function Rn(n){return new this(n).cosh()}function Tn(n,e){return new this(n).div(e)}function Zn(n){return new this(n).exp()}function jn(n){return P(n=new this(n),n.e+1,3)}function kn(){var n,e,t=new this(0);for(y=!1,n=0;n<arguments.length;)if((e=new this(arguments[n++])).d)t.d&&(t=t.plus(e.times(e)));else{if(e.s)return y=!0,new this(1/0);t=e}return y=!0,t.sqrt()}function Un(n){return n instanceof Z||n&&n.toStringTag===t||!1}function In(n){return new this(n).ln()}function Ln(n,e){return new this(n).log(e)}function Cn(n){return new this(n).log(2)}function $n(n){return new this(n).log(10)}function Hn(){return hn(this,arguments,"lt")}function Bn(){return hn(this,arguments,"gt")}function Vn(n,e){return new this(n).mod(e)}function zn(n,e){return new this(n).mul(e)}function Wn(n,e){return new this(n).pow(e)}function Jn(n){var e,t,r,i,o=0,s=new this(1),u=[];if(void 0===n?n=this.precision:v(n,1,p),r=Math.ceil(n/D),this.crypto)if(crypto.getRandomValues)for(e=crypto.getRandomValues(new Uint32Array(r));o<r;)429e7<=(i=e[o])?e[o]=crypto.getRandomValues(new Uint32Array(1))[0]:u[o++]=i%1e7;else{if(!crypto.randomBytes)throw Error(X);for(e=crypto.randomBytes(r*=4);o<r;)214e7<=(i=e[o]+(e[o+1]<<8)+(e[o+2]<<16)+((127&e[o+3])<<24))?crypto.randomBytes(4).copy(e,o):(u.push(i%1e7),o+=4);o=r/4}else for(;o<r;)u[o++]=1e7*Math.random()|0;for(r=u[--o],n%=D,r&&n&&(i=w(10,D-n),u[o]=(r/i|0)*i);0===u[o];o--)u.pop();if(o<0)u=[t=0];else{for(t=-1;0===u[0];t-=D)u.shift();for(r=1,i=u[0];10<=i;i/=10)r++;r<D&&(t-=D-r)}return s.e=t,s.d=u,s}function Gn(n){return P(n=new this(n),n.e+1,this.rounding)}function Kn(n){return(n=new this(n)).d?n.d[0]?n.s:0*n.s:n.s||NaN}function Qn(n){return new this(n).sin()}function Xn(n){return new this(n).sinh()}function Yn(n){return new this(n).sqrt()}function ne(n,e){return new this(n).sub(e)}function ee(){var n=0,e=arguments,t=new this(e[n]);for(y=!1;t.s&&++n<e.length;)t=t.plus(e[n]);return y=!0,P(t,this.precision,this.rounding)}function te(n){return new this(n).tan()}function re(n){return new this(n).tanh()}function ie(n){return P(n=new this(n),n.e+1,1)}h[Symbol.for("nodejs.util.inspect.custom")]=h.toString,h[Symbol.toStringTag]="Decimal";var Z=h.constructor=function n(e){var t,r,i;function o(n){var e,t,r,i=this;if(!(i instanceof o))return new o(n);if(i.constructor=o,Un(n))return i.s=n.s,void(y?!n.d||n.e>o.maxE?(i.e=NaN,i.d=null):n.e<o.minE?(i.e=0,i.d=[0]):(i.e=n.e,i.d=n.d.slice()):(i.e=n.e,i.d=n.d&&n.d.slice()));if("number"===(r=s(n))){if(0===n)return i.s=1/n<0?-1:1,i.e=0,void(i.d=[0]);if(n<0?(n=-n,i.s=-1):i.s=1,n===~~n&&n<1e7){for(e=0,t=n;10<=t;t/=10)e++;return void(y?o.maxE<e?(i.e=NaN,i.d=null):e<o.minE?(i.e=0,i.d=[0]):(i.e=e,i.d=[n]):(i.e=e,i.d=[n]))}return 0*n!=0?(n||(i.s=NaN),i.e=NaN,void(i.d=null)):gn(i,n.toString())}if("string"!==r)throw Error(m+n);return 45===(t=n.charCodeAt(0))?(n=n.slice(1),i.s=-1):(43===t&&(n=n.slice(1)),i.s=1),(tn.test(n)?gn:function(n,e){var t,r,i,o,s,u,c,f;if(-1<e.indexOf("_")){if(e=e.replace(/(\d)_(?=\d)/g,"$1"),tn.test(e))return gn(n,e)}else if("Infinity"===e||"NaN"===e)return+e||(n.s=NaN),n.e=NaN,n.d=null,n;if(nn.test(e))t=16,e=e.toLowerCase();else if(Y.test(e))t=2;else{if(!en.test(e))throw Error(m+e);t=8}for(o=(e=0<(o=e.search(/p/i))?(c=+e.slice(o+1),e.substring(2,o)):e.slice(2)).indexOf("."),r=n.constructor,(s=0<=o)&&(o=(u=(e=e.replace(".","")).length)-o,i=an(r,new r(t),o,2*o)),o=e=(f=E(e,t,F)).length-1;0===f[o];--o)f.pop();return o<0?new r(0*n.s):(n.e=M(f,e),n.d=f,y=!1,s&&(n=x(n,i,4*u)),c&&(n=n.times(Math.abs(c)<54?w(2,c):Z.pow(2,c))),y=!0,n)})(i,n)}if(o.prototype=h,o.ROUND_UP=0,o.ROUND_DOWN=1,o.ROUND_CEIL=2,o.ROUND_FLOOR=3,o.ROUND_HALF_UP=4,o.ROUND_HALF_DOWN=5,o.ROUND_HALF_EVEN=6,o.ROUND_HALF_CEIL=7,o.ROUND_HALF_FLOOR=8,o.EUCLID=9,o.config=o.set=Dn,o.clone=n,o.isDecimal=Un,o.abs=yn,o.acos=bn,o.acosh=Nn,o.add=En,o.asin=xn,o.asinh=On,o.atan=Mn,o.atanh=An,o.atan2=Sn,o.cbrt=_n,o.ceil=qn,o.clamp=Fn,o.cos=Pn,o.cosh=Rn,o.div=Tn,o.exp=Zn,o.floor=jn,o.hypot=kn,o.ln=In,o.log=Ln,o.log10=$n,o.log2=Cn,o.max=Hn,o.min=Bn,o.mod=Vn,o.mul=zn,o.pow=Wn,o.random=Jn,o.round=Gn,o.sign=Kn,o.sin=Qn,o.sinh=Xn,o.sqrt=Yn,o.sub=ne,o.sum=ee,o.tan=te,o.tanh=re,o.trunc=ie,(e=void 0===e?{}:e)&&!0!==e.defaults)for(i=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],t=0;t<i.length;)e.hasOwnProperty(r=i[t++])||(e[r]=this[r]);return o.config(e),o}(K);function oe(n,e){var t="",r=(t=Z.isDecimal(n)?n.toFixed():"string"!=typeof n?n.toString():n,null),n=null,i=null,o=e.match(/(<=|>=|=)\s*(\d+)/);if(o&&(n=o[1],r=Number(o[2])),e.includes(",")&&(i=!0),null!==r){var o=t.split("."),e=o[0],s=1===o.length?"":o[1],u=s.length;switch(n){case"<=":s=u<=r?s:s.slice(0,r);break;case"=":u<r?s+="0".repeat(r-u):r<u&&(s=s.slice(0,r));break;case">=":s=r<=u?s:s+"0".repeat(r-u)}t=""===s?e:"".concat(e,".").concat(s)}return t=null!==i?1<(o=t.split(".")).length?((n=o[0]).includes("-")?o[0]=n[0]+n.slice(1).replace(/(?=(?!^)(?:\d{3})+$)/g,","):o[0]=n.replace(/(?=(?!^)(?:\d{3})+$)/g,","),o.join(".")):(e=o[0]).includes("-")?e[0]+e.slice(1).replace(/(?=(?!^)(?:\d{3})+$)/g,","):e.replace(/(?=(?!^)(?:\d{3})+$)/g,","):t}function se(n){for(var e=[],t=0,r=null,i=n.length;t<i;)if(r=n[t],/\s/.test(r))t++;else if("+-".includes(r)){var o=e[e.length-1];if(0===e.length||"+-".includes(o)||"("===o){for(var s=r,r=n[++t];/[a-zA-Z\d._]/.test(r);)s+=r,r=n[++t];e.push(s)}else e.push(r),t++}else if("*/%()".includes(r))e.push(r),t++;else if(/[a-zA-Z_]/.test(r)){for(var u="";/[a-zA-Z0-9_]/.test(r)&&(u+=r,!(++t>=i));)r=n[t];e.push(u)}else if(/\d/.test(r)){for(var c="";/[\d.]/.test(r)&&(c+=r,!(++t>=i));)r=n[t];e.push(c)}return e}var f=new Z(f),a=new Z(a),ue=function(){L(r,e(Error));var t=B(r);function r(n){var e;return k(this,r),(e=t.call(this,n)).name="CalculatorError",e.message=n,e}return I(r)}(),ce=function(){L(r,e(Error));var t=B(r);function r(n){var e;return k(this,r),(e=t.call(this,n)).name="TokensFillError",e.message=n,e}return I(r)}();function j(n,e){var t=e._fillData;return void 0===e._fillData&&(t=e),n.map(function(n){if(/^[a-zA-z_][\w_]*$/.test(n)){var e=t[n];if(void 0!==e)return"number"==typeof e?e.toString():e;throw new ce("错误的参数:".concat(n," 请确认他存在"))}return n})}function fe(n){for(var e,t=[],r=[],i=n;0<i.length;){var o=i.shift();if(z(o))if("("===o)t.push(o);else if(")"===o){for(var s=t.pop();"("!==s&&0<t.length;)r.push(s),s=t.pop();if("("!==s)throw"error: unmatched ()"}else{for(;e=t[t.length-1],W(o)<=W(e)&&0<t.length;)r.push(t.pop());t.push(o)}else r.push(o)}if(0<t.length){if(")"===t[t.length-1]||"("===t[t.length-1])throw"error: unmatched ()";for(;0<t.length;)r.push(t.pop())}return r}function ae(n){for(var e=[];0<n.length;){var t=n.shift();if(z(t)){if(e.length<2)throw new ue("错误的栈长度, 可能是无法计算的表达式");var r=e.pop(),i=e.pop();switch("string"==typeof r&&(r=new Z(r)),"string"==typeof i&&(i=new Z(i)),t){case"+":e.push(i.add(r));break;case"-":e.push(i.sub(r));break;case"*":e.push(i.mul(r));break;case"/":e.push(i.div(r));break;case"%":e.push(i.mod(r))}}else e.push(t)}if(1!==e.length)throw"unvalid expression";return e[0]}return n.calc=function(){for(var n=arguments.length,e=new Array(n),t=0;t<n;t++)e[t]=arguments[t];var r=J(e),i=se(r.expr),o=null;if(null!==r.data)if(null===(o=void 0!==r.data._fillData?r.data:o)||void 0===o.fillError&&void 0===o.error)i=j(i,r.data);else try{i=j(i,r.data)}catch(n){if(n instanceof ce)return o.fillError||o.error;throw n}var i=fe(i),s=null;if(null!==o){if(void 0!==o.calcError||void 0!==o.error)try{s=ae(i)}catch(n){if(n instanceof ue)return void 0!==o.calcError?o.calcError:o.error;throw n}}else s=ae(i);return s=null!==r.fmt?oe(s,r.fmt):null!==s?s.toFixed():null},n.fmt=function(){for(var n=arguments.length,e=new Array(n),t=0;t<n;t++)e[t]=arguments[t];var r=J(e),i=se(r.expr),o=null;if(2<i.length)throw new Error("fmt并非用于计算, 不能传入多个标识:".concat(r.expr));if(1!==i.length)throw new Error("fmt接收了一个无法被解析的标识");if(null!==r.data)if(null===(o=void 0!==r.data._fillData?r.data:o)||void 0===o.fillError&&void 0===o.error)i=j(i,r.data);else try{i=j(i,r.data)}catch(n){if(n instanceof TokensFillError)return o.fillError||o.error;throw n}if(null===r.fmt)throw"表达式没有格式化部分";return oe(i[0],r.fmt)},n.version="0.0.30",Object.defineProperty(n,"__esModule",{value:!0}),n}({});

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

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var Decimal=require("decimal.js");function _interopDefaultLegacy(r){return r&&"object"==typeof r&&"default"in r?r:{default:r}}var Decimal__default=_interopDefaultLegacy(Decimal);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 a=0===o.length?"":o.shift(),i=0===r.length?"":r.shift(),t=t+a+(i="number"==typeof i?i.toString():i)}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=Decimal__default.default.isDecimal(r)?r.toFixed():"string"!=typeof r?r.toString():r,null),r=null,o=null,a=e.match(/(<=|>=|=)\s*(\d+)/);if(a&&(r=a[1],n=Number(a[2])),e.includes(",")&&(o=!0),null!==n){var a=t.split("."),e=a[0],i=1===a.length?"":a[1],l=i.length;switch(r){case"<=":i=l<=n?i:i.slice(0,n);break;case"=":l<n?i+="0".repeat(n-l):n<l&&(i=i.slice(0,n));break;case">=":i=n<=l?i:i+"0".repeat(n-l)}t=""===i?e:"".concat(e,".").concat(i)}return t=null!==o?1<(a=t.split(".")).length?((r=a[0]).includes("-")?a[0]=r[0]+r.slice(1).replace(/(?=(?!^)(?:\d{3})+$)/g,","):a[0]=r.replace(/(?=(?!^)(?:\d{3})+$)/g,","),a.join(".")):(e=a[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 a=e[e.length-1];if(0===e.length||"+-".includes(a)||"("===a){for(var i=n,n=r[++t];/[a-zA-Z\d._]/.test(n);)i+=n,n=r[++t];e.push(i)}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),a=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===(a=void 0!==n.data._fillData?n.data:a)||void 0===a.fillError&&void 0===a.error)o=fillTokens(o,n.data);else try{o=fillTokens(o,n.data)}catch(r){if(r instanceof TokensFillError)return a.fillError||a.error;throw r}if(null===n.fmt)throw"表达式没有格式化部分";return format(o[0],n.fmt)}var version="0.0.28";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 a=e.pop();"("!==a&&0<e.length;)t.push(a),a=e.pop();if("("!==a)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();switch("string"==typeof n&&(n=new Decimal__default.default(n)),"string"==typeof o&&(o=new Decimal__default.default(o)),t){case"+":e.push(o.add(n));break;case"-":e.push(o.sub(n));break;case"*":e.push(o.mul(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),a=null;if(null!==n.data)if(null===(a=void 0!==n.data._fillData?n.data:a)||void 0===a.fillError&&void 0===a.error)o=fillTokens(o,n.data);else try{o=fillTokens(o,n.data)}catch(r){if(r instanceof TokensFillError$1)return a.fillError||a.error;throw r}var o=token2postfix(o),i=null;if(null!==a){if(void 0!==a.calcError||void 0!==a.error)try{i=evalPostfix(o)}catch(r){if(r instanceof CalculatorError)return void 0!==a.calcError?a.calcError:a.error;throw r}}else i=evalPostfix(o);return i=null!==n.fmt?format(i,n.fmt):null!==i?i.toFixed():null}exports.calc=calc,exports.fmt=fmt,exports.version=version;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var Decimal=require("decimal.js");function _interopDefaultLegacy(r){return r&&"object"==typeof r&&"default"in r?r:{default:r}}var Decimal__default=_interopDefaultLegacy(Decimal);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 a=0===o.length?"":o.shift(),i=0===r.length?"":r.shift(),t=t+a+(i="number"==typeof i?i.toString():i)}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=Decimal__default.default.isDecimal(r)?r.toFixed():"string"!=typeof r?r.toString():r,null),r=null,o=null,a=e.match(/(<=|>=|=)\s*(\d+)/);if(a&&(r=a[1],n=Number(a[2])),e.includes(",")&&(o=!0),null!==n){var a=t.split("."),e=a[0],i=1===a.length?"":a[1],l=i.length;switch(r){case"<=":i=l<=n?i:i.slice(0,n);break;case"=":l<n?i+="0".repeat(n-l):n<l&&(i=i.slice(0,n));break;case">=":i=n<=l?i:i+"0".repeat(n-l)}t=""===i?e:"".concat(e,".").concat(i)}return t=null!==o?1<(a=t.split(".")).length?((r=a[0]).includes("-")?a[0]=r[0]+r.slice(1).replace(/(?=(?!^)(?:\d{3})+$)/g,","):a[0]=r.replace(/(?=(?!^)(?:\d{3})+$)/g,","),a.join(".")):(e=a[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 a=e[e.length-1];if(0===e.length||"+-".includes(a)||"("===a){for(var i=n,n=r[++t];/[a-zA-Z\d._]/.test(n);)i+=n,n=r[++t];e.push(i)}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),a=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===(a=void 0!==n.data._fillData?n.data:a)||void 0===a.fillError&&void 0===a.error)o=fillTokens(o,n.data);else try{o=fillTokens(o,n.data)}catch(r){if(r instanceof TokensFillError)return a.fillError||a.error;throw r}if(null===n.fmt)throw"表达式没有格式化部分";return format(o[0],n.fmt)}var version="0.0.30";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 a=e.pop();"("!==a&&0<e.length;)t.push(a),a=e.pop();if("("!==a)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();switch("string"==typeof n&&(n=new Decimal__default.default(n)),"string"==typeof o&&(o=new Decimal__default.default(o)),t){case"+":e.push(o.add(n));break;case"-":e.push(o.sub(n));break;case"*":e.push(o.mul(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),a=null;if(null!==n.data)if(null===(a=void 0!==n.data._fillData?n.data:a)||void 0===a.fillError&&void 0===a.error)o=fillTokens(o,n.data);else try{o=fillTokens(o,n.data)}catch(r){if(r instanceof TokensFillError$1)return a.fillError||a.error;throw r}var o=token2postfix(o),i=null;if(null!==a){if(void 0!==a.calcError||void 0!==a.error)try{i=evalPostfix(o)}catch(r){if(r instanceof CalculatorError)return void 0!==a.calcError?a.calcError:a.error;throw r}}else i=evalPostfix(o);return i=null!==n.fmt?format(i,n.fmt):null!==i?i.toFixed():null}exports.calc=calc,exports.fmt=fmt,exports.version=version;

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

import Decimal from"decimal.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=Decimal.isDecimal(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.28";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();switch("string"==typeof n&&(n=new Decimal(n)),"string"==typeof o&&(o=new Decimal(o)),e){case"+":t.push(o.add(n));break;case"-":t.push(o.sub(n));break;case"*":t.push(o.mul(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 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.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 Decimal from"decimal.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=Decimal.isDecimal(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.30";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();switch("string"==typeof n&&(n=new Decimal(n)),"string"==typeof o&&(o=new Decimal(o)),e){case"+":t.push(o.add(n));break;case"-":t.push(o.sub(n));break;case"*":t.push(o.mul(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 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.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};
{
"name": "a-calc",
"version": "0.0.29",
"version": "0.0.32",
"description": "JavaScript的字符串四则运算库, 支持格式化操作例如: 千分位格式化, 灵活指定小数点位数",

@@ -38,3 +38,3 @@ "main": "./es/index.js",

"type": "git",
"url": "git+https://github.com/Autumn-one/a-calc.git"
"url": "git+https://github.com/Autumn-one/a-calc-old.git"
},

@@ -51,6 +51,7 @@ "keywords": [

"bugs": {
"url": "https://github.com/Autumn-one/a-calc/issues"
"url": "https://github.com/Autumn-one/a-calc-old/issues"
},
"homepage": "https://github.com/Autumn-one/a-calc#readme",
"homepage": "https://github.com/Autumn-one/a-calc-old#readme",
"devDependencies": {
"@babel/core": "^7.17.10",
"@babel/preset-env": "^7.17.10",

@@ -72,5 +73,4 @@ "@rollup/plugin-babel": "^5.3.1",

"dependencies": {
"@babel/core": "^7.17.10",
"decimal.js": "^10.3.1"
}
}
SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc