a-calc 0.0.72 → 0.0.80

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # a-calc
2
- 来源于实际业务的字符串四则运算的库, 可以解决js数字计算精度 科学记数法和格式化的问题, 支持千分位小数点格式化输出和带单位数字的计算等操作
2
+ 来源于实际业务的字符串四则运算的库, 可解决以下问题:
3
+
4
+ * js数字计算精度问题
5
+ * 数字计算可能输出科学计数法
6
+ * 数字格式化, 数字千分位输出
7
+ * 带单位的数字计算或格式化, 例如: `0.1% + 2% `
8
+ * 科学计数法写法的计算, 例如:`-2e3 + 6`
9
+ * 支持四种舍入规则:去尾、进一、四舍五入、四舍六入(一种更精准的方法)
3
10
 
4
11
  > 支持的运算符 : + - * / %
5
12
 
@@ -36,15 +43,26 @@ const {calc, fmt} = a_calc
36
43
  </script>
37
44
  ```
38
45
 
39
- ## 四则运算
46
+ ## 四则运算(支持科学计数法写法)
40
47
 
41
48
  ```js
42
49
  calc("0.1 + 0.2") // 0.3
43
50
 
44
51
  // 复杂一点的计算
45
52
  calc("0.1 + 0.2 * 0.3 / 0.4 * (0.5 + 0.6)") // 0.265
53
+
54
+ // 科学计数法的计算
55
+ calc("-2e2 + 3e+2") // 100
46
56
  ```
47
57
 
58
+ ## 关于空格
59
+
60
+ 空格在无歧义的情况下是非必须的,甚至可以正确解析下面人眼都难以解析的写法`calc("-2e+2+3e+2")`,但是没有人应该这样编写计算式来考验`a-calc`解析能力,<span style="color: red;">请记住始终在你的计算式包含空格,就像我写的示例那样!!!</span>
61
+
62
+ 顺便举个有歧义的计算式 `calc("50%%2", {_unit: true})`这种歧义显然是在带单位计算的时候出现,由于解析器不知道你的单位是`%` 还是 `%%` 所以你要用用空格给出明确的意思,正确的写法应该是 `calc("50% % 2", {_unit: true})`
63
+
64
+ 总之始终加空格!
65
+
48
66
  ## 填充变量并计算(重要)
49
67
 
50
68
  **计算后的值为精准值且不会出现科学计数法**
@@ -104,6 +122,23 @@ calc("10000000 + 100000000 | ,") // 110,000,000
104
122
  calc("10000000 + 100000000 | +,=10") // +110,000,000.0000000000
105
123
  ```
106
124
 
125
+ ## 四种舍入规则
126
+
127
+ 舍入规则通过在格式化字符串的部分加入,他们的符号分别为:
128
+
129
+ - `~-` 去尾,默认的舍入规则
130
+ - `~+` 进一
131
+ - `~5` 四舍五入
132
+ - `~6` 四舍六入,该舍入规则相较四舍五入更为精准,规则在舍入的后一位为5的时候有所不同,他会查看5后面的位置,如果后面的数字不为0那么会进一,如果后面的数字为0 ,那么会看5前面的数字是否为偶数,如果是则不进,不是则进
133
+
134
+ ```js
135
+ calc("0.11 + 0.22 | =1 ~+") // 0.4 保留一位并进一
136
+ calc("0.55 | =1 ~5") // 0.6
137
+ calc("0.65 | =1 ~6") // 0.6
138
+ ```
139
+
140
+ 这个新加入的舍入规则似乎会让格式化的部分更加的长,但是实际情况不是这样,一般一个项目的舍入规则是固定的,所以舍入规则部分的格式化应该被封装在默认的格式化参数中,在实际使用的时候完全不需要书写这部分内容,参考下面的`默认格式化` 说明
141
+
107
142
  ## 只格式化
108
143
 
109
144
  ```js
@@ -148,58 +183,80 @@ calc("111111 + 11111 | ,",{_fmt: "=2"}) // 122,222.00 很显然 , 和 =2 被组
148
183
  > 在项目中编写庞大的第二个参数是不好的, 所以第二个参数你应该想办法固定他, 下面只是一个在VUE项目中的演示
149
184
 
150
185
  ```js
151
- import { calc, fmt } from 'a-calc'
152
-
153
- Vue.mixin({
154
- methods: {
155
- calc (expr, obj) {
156
- let dataArr = [this]
157
- let _fmt = undefined
158
- let _error = undefined
159
- if (obj !== undefined) {
160
- dataArr.unshift(obj)
161
- if (obj._fmt !== undefined) {
162
- _fmt = obj._fmt
163
- }
164
- if (obj._error !== undefined) {
165
- _error = obj._error
166
- }
167
- }
168
-
169
- return calc(expr, {
170
- _fillData: dataArr,
171
- _error: _error === undefined ? '-' : _error,
172
- _fmt, // 格式化参数在没有字符串格式化的时候才有用
173
- })
174
- },
175
- fmt (expr, obj) {
176
- // 专门格式化的
177
- let dataArr = [this]
178
- let _fmt = undefined
179
- let _error = undefined
180
- if (obj !== undefined) {
181
- dataArr.unshift(obj)
182
- if (obj._fmt !== undefined) {
183
- _fmt = obj._fmt
184
- }
185
- if (obj._error !== undefined) {
186
- _error = obj._error
187
- }
188
- }
189
- return fmt(expr,
190
- {
191
- _fillData: dataArr,
192
- _error: _error === undefined ? '-' : _error,
193
- _fmt,
194
- _unit: true
195
- })
196
- },
197
- },
198
- })
186
+ import { calc, fmt } from "a-calc";
187
+
188
+ Vue.mixin( {
189
+ methods: {
190
+ calc ( expr, obj )
191
+ {
192
+ let dataArr = [this];
193
+ let _fmt = undefined;
194
+ let _error = undefined;
195
+
196
+ if ( obj !== undefined )
197
+ {
198
+ dataArr.unshift( obj );
199
+ if ( obj._fmt !== undefined )
200
+ {
201
+ _fmt = obj._fmt;
202
+ }
203
+ if ( obj._error !== undefined )
204
+ {
205
+ _error = obj._error;
206
+ }
207
+ }
208
+
209
+ return calc( expr, {
210
+ _fillData: dataArr,
211
+ _error: _error === undefined ? "-" : _error,
212
+ _fmt, // 格式化参数在没有字符串格式化的时候才有用
213
+ } );
214
+ },
215
+
216
+ fmt ( expr, obj )
217
+ {
218
+ // 专门格式化的
219
+ let dataArr = [this];
220
+ let _fmt = undefined;
221
+ let _error = undefined;
222
+
223
+ if ( obj !== undefined )
224
+ {
225
+ dataArr.unshift( obj );
226
+ if ( obj._fmt !== undefined )
227
+ {
228
+ _fmt = obj._fmt;
229
+ }
230
+ if ( obj._error !== undefined )
231
+ {
232
+ _error = obj._error;
233
+ }
234
+ }
235
+
236
+ return fmt( expr,
237
+ {
238
+ _fillData: dataArr,
239
+ _error: _error === undefined ? "-" : _error,
240
+ _fmt,
241
+ _unit: true
242
+ } );
243
+ },
244
+ },
245
+ } );
199
246
  ```
200
247
 
201
248
  ## 版本变更
202
249
 
250
+ * 0.0.80
251
+ * 带来4种舍入规则,分别为:去尾、进一、四舍五入、四舍六入
252
+ * 更多边界情况的检测
253
+ * fmt允许不在传入格式化字符串,这个特性允许你使用 fmt 来清除小数点后多余的0
254
+ * 0.0.79
255
+ * 更新文档
256
+ * 0.0.78
257
+ * 支持科学计数法的计算
258
+ * 完整的单元测试
259
+ * 更多边界情况的检测
203
260
  * 0.0.72
204
261
  * 支持单个数值的带单位写法, 例如 `calc("1元", {_unit: true})` 或者 `fmt("1元 | =2",{_unit: true})`
205
262
  * 补充文档
package/browser/index.js CHANGED
@@ -1 +1 @@
1
- var a_calc=function(e){"use strict";function F(e){return(F="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function O(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function A(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function E(e,t,r){return t&&A(e.prototype,t),r&&A(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function N(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&i(e,t)}function o(e){return(o=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function i(e,t){return(i=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function S(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}function j(e,t,r){return(j=S()?Reflect.construct:function(e,t,r){var n=[null];n.push.apply(n,t);t=new(Function.bind.apply(e,n));return r&&i(t,r.prototype),t}).apply(null,arguments)}function t(e){var r="function"==typeof Map?new Map:void 0;return(t=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==r){if(r.has(e))return r.get(e);r.set(e,t)}function t(){return j(e,arguments,o(this).constructor)}return t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),i(t,e)})(e)}function x(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");t=e;if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function P(r){var n=S();return function(){var e,t=o(r);return x(this,n?(e=o(this).constructor,Reflect.construct(t,arguments,e)):t.apply(this,arguments))}}function v(e){return function(e){if(Array.isArray(e))return k(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return k(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Map"===(r="Object"===r&&e.constructor?e.constructor.name:r)||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?k(e,t):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function k(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function R(e){return-1<"+-*/%()".indexOf(e)}function T(e){switch(e){case"+":case"-":return 1;case"*":case"/":case"%":return 2;default:return 0}}function g(e){return void 0!==e}function D(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return t.some(function(e){return void 0!==e})}function d(e){return null!==e}function h(e){return"string"==typeof e&&!!/^[+-]?\d+\.?\d*$/.test(e)}function B(e){var t=null,r=null,e=e.match(/^([+-]?[\d.]+)(\D*)$/);return e&&(r=e[1],""!==(e=e[2]).trim()&&(t=e)),{num:r,unit:t}}var y=function(){N(n,t(Error));var r=P(n);function n(e){var t;return O(this,n),(t=r.call(this,e)).name="CalculatorError",t.message=e,t}return E(n)}(),w=function(){N(n,t(Error));var r=P(n);function n(e){var t;return O(this,n),(t=r.call(this,e)).name="TokensFillError",t.message=e,t}return E(n)}(),$=function(){N(n,t(Error));var r=P(n);function n(e){var t;return O(this,n),(t=r.call(this,e)).name="ArgError",t.message=e,t}return E(n)}();function C(e){for(var t,r=0,n=e.length,o=[];r<n;)if(t=e[r],/\s/.test(t))r++;else if("+"===t)o.push({type:"plus",value:t}),r++;else if(","===t)o.push({type:"comma",value:t}),r++;else if("<>=".includes(t)){var i,u=t;n<=++r?o.push({type:"symbol",value:u}):(i=e[r],"<>=".includes(i)?(u+=i,o.push({type:"symbol",value:u}),r++):o.push({type:"symbol",value:t}))}else if(/[a-zA-Z_]/.test(t)){for(var l="";/[\w_.\[\]"']/.test(t)&&(l+=t,!(n<=++r));)t=e[r];o.push({type:"var",value:l})}else if(/\d/.test(t)){for(var a="";/[\d.]/.test(t)&&(a+=t,!(n<=++r));)t=e[r];o.push({type:"number",value:a})}return o}function J(e){var t={expr:"",fmt:null,data:null},r="",n=e[0];if(1===e.length)if("string"==typeof n)r=n;else{if("number"!=typeof n)throw new $("错误的参数类型: ".concat(n," 类型为:").concat(F(n)));r=n.toString()}else{if(2!=e.length)throw new $("过多的参数, 该函数最多接受两个参数!");n=e[1];if(i=n,("[object Object]"!==Object.prototype.toString.call(i)||Array.isArray(i))&&!Array.isArray(n))throw new Error("参数错误, 暂不支持的参数");if("string"==typeof(r=e[0])){if(""===r.trim())throw new w("参数不可为空字符串")}else if("number"==typeof r)r=r.toString();else if(void 0===r||Number.isNaN(r))throw new w("非法参数:".concat(r));t.data=n}var o,i=r.split("|");return 1===i.length?t.expr=i[0]:(t.expr=i[0],""!==(e=i[1]).trim()&&(n=C(e),t.fmt=n)),null!==t.data&&t.data._fmt&&(r=C(t.data._fmt),null===t.fmt?t.fmt=r:(o=t.fmt.map(function(e){return e.type}),r.forEach(function(e){o.includes(e.type)||t.fmt.push(e)}))),t}var K=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,Q=Math.ceil,I=Math.floor,U="[BigNumber Error] ",ee=U+"Number primitive has more than 15 significant digits: ",z=1e14,L=14,te=9007199254740991,re=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],M=1e7,G=1e9;function q(e){var t=0|e;return 0<e||e===t?t:t-1}function H(e){for(var t,r,n=1,o=e.length,i=e[0]+"";n<o;){for(t=e[n++]+"",r=L-t.length;r--;t="0"+t);i+=t}for(o=i.length;48===i.charCodeAt(--o););return i.slice(0,o+1||1)}function V(e,t){var r,n,o=e.c,i=t.c,u=e.s,l=t.s,e=e.e,t=t.e;if(!u||!l)return null;if(r=o&&!o[0],n=i&&!i[0],r||n)return r?n?0:-l:u;if(u!=l)return u;if(r=u<0,n=e==t,!o||!i)return n?0:!o^r?1:-1;if(!n)return t<e^r?1:-1;for(l=(e=o.length)<(t=i.length)?e:t,u=0;u<l;u++)if(o[u]!=i[u])return o[u]>i[u]^r?1:-1;return e==t?0:t<e^r?1:-1}function W(e,t,r,n){if(e<t||r<e||e!==I(e))throw Error(U+(n||"Argument")+("number"==typeof e?e<t||r<e?" out of range: ":" not an integer: ":" not a primitive number: ")+String(e))}function Z(e){var t=e.c.length-1;return q(e.e/L)==t&&e.c[t]%2!=0}function X(e,t){return(1<e.length?e.charAt(0)+"."+e.slice(1):e)+(t<0?"e":"e+")+t}function Y(e,t,r){var n,o;if(t<0){for(o=r+".";++t;o+=r);e=o+e}else if(++t>(n=e.length)){for(o=r,t-=n;--t;o+=r);e+=o}else t<n&&(e=e.slice(0,t)+"."+e.slice(t));return e}var s=function C(e){var d,c,h,t,f,y,u,l,a,s,p,r=x.prototype={constructor:x,toString:null,valueOf:null},v=new x(1),w=20,m=4,g=-7,b=21,_=-1e7,O=1e7,A=!1,o=1,E=0,N={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},S="0123456789abcdefghijklmnopqrstuvwxyz",j=!0;function x(e,t){var r,n,o,i,u,l,a,f,s=this;if(!(s instanceof x))return new x(e,t);if(null==t){if(e&&!0===e._isBigNumber)return s.s=e.s,void(!e.c||e.e>O?s.c=s.e=null:e.e<_?s.c=[s.e=0]:(s.e=e.e,s.c=e.c.slice()));if((l="number"==typeof e)&&0*e==0){if(s.s=1/e<0?(e=-e,-1):1,e===~~e){for(i=0,u=e;10<=u;u/=10,i++);return void(O<i?s.c=s.e=null:(s.e=i,s.c=[e]))}f=String(e)}else{if(!K.test(f=String(e)))return h(s,f,l);s.s=45==f.charCodeAt(0)?(f=f.slice(1),-1):1}0<(u=(f=-1<(i=f.indexOf("."))?f.replace(".",""):f).search(/e/i))?(i<0&&(i=u),i+=+f.slice(u+1),f=f.substring(0,u)):i<0&&(i=f.length)}else{if(W(t,2,S.length,"Base"),10==t&&j)return B(s=new x(e),w+s.e+1,m);if(f=String(e),l="number"==typeof e){if(0*e!=0)return h(s,f,l,t);if(s.s=1/e<0?(f=f.slice(1),-1):1,x.DEBUG&&15<f.replace(/^0\.0*|\./,"").length)throw Error(ee+e)}else s.s=45===f.charCodeAt(0)?(f=f.slice(1),-1):1;for(r=S.slice(0,t),i=u=0,a=f.length;u<a;u++)if(r.indexOf(n=f.charAt(u))<0){if("."==n){if(i<u){i=a;continue}}else if(!o&&(f==f.toUpperCase()&&(f=f.toLowerCase())||f==f.toLowerCase()&&(f=f.toUpperCase()))){o=!0,u=-1,i=0;continue}return h(s,String(e),l,t)}l=!1,-1<(i=(f=c(f,t,10,s.s)).indexOf("."))?f=f.replace(".",""):i=f.length}for(u=0;48===f.charCodeAt(u);u++);for(a=f.length;48===f.charCodeAt(--a););if(f=f.slice(u,++a)){if(a-=u,l&&x.DEBUG&&15<a&&(te<e||e!==I(e)))throw Error(ee+s.s*e);if((i=i-u-1)>O)s.c=s.e=null;else if(i<_)s.c=[s.e=0];else{if(s.e=i,s.c=[],u=(i+1)%L,i<0&&(u+=L),u<a){for(u&&s.c.push(+f.slice(0,u)),a-=L;u<a;)s.c.push(+f.slice(u,u+=L));u=L-(f=f.slice(u)).length}else u-=a;for(;u--;f+="0");s.c.push(+f)}}else s.c=[s.e=0]}function P(e,t,r,n){for(var o,i,u=[0],l=0,a=e.length;l<a;){for(i=u.length;i--;u[i]*=t);for(u[0]+=n.indexOf(e.charAt(l++)),o=0;o<u.length;o++)u[o]>r-1&&(null==u[o+1]&&(u[o+1]=0),u[o+1]+=u[o]/r|0,u[o]%=r)}return u.reverse()}function k(e,t,r){var n,o,i,u=0,l=e.length,a=t%M,f=t/M|0;for(e=e.slice();l--;)u=((o=a*(i=e[l]%M)+(n=f*i+(i=e[l]/M|0)*a)%M*M+u)/r|0)+(n/M|0)+f*i,e[l]=o%r;return e=u?[u].concat(e):e}function R(e,t,r,n){var o,i;if(r!=n)i=n<r?1:-1;else for(o=i=0;o<r;o++)if(e[o]!=t[o]){i=e[o]>t[o]?1:-1;break}return i}function T(e,t,r,n){for(var o=0;r--;)e[r]-=o,o=e[r]<t[r]?1:0,e[r]=o*n+e[r]-t[r];for(;!e[0]&&1<e.length;e.splice(0,1));}function n(e,t,r,n){var o,i,u,l;if(null==r?r=m:W(r,0,8),!e.c)return e.toString();if(o=e.c[0],i=e.e,null==t)l=H(e.c),l=1==n||2==n&&(i<=g||b<=i)?X(l,i):Y(l,i,"0");else if(r=(e=B(new x(e),t,r)).e,u=(l=H(e.c)).length,1==n||2==n&&(t<=r||r<=g)){for(;u<t;l+="0",u++);l=X(l,r)}else if(t-=i,l=Y(l,r,"0"),u<r+1){if(0<--t)for(l+=".";t--;l+="0");}else if(0<(t+=r-u))for(r+1==u&&(l+=".");t--;l+="0");return e.s<0&&o?"-"+l:l}function i(e,t){for(var r,n=1,o=new x(e[0]);n<e.length;n++){if(!(r=new x(e[n])).s){o=r;break}t.call(o,r)&&(o=r)}return o}function D(e,t,r){for(var n=1,o=t.length;!t[--o];t.pop());for(o=t[0];10<=o;o/=10,n++);return(r=n+r*L-1)>O?e.c=e.e=null:r<_?e.c=[e.e=0]:(e.e=r,e.c=t),e}function B(e,t,r,n){var o,i,u,l,a,f,s,c=e.c,h=re;if(c){e:{for(o=1,l=c[0];10<=l;l/=10,o++);if((i=t-o)<0)i+=L,u=t,s=(a=c[f=0])/h[o-u-1]%10|0;else if((f=Q((i+1)/L))>=c.length){if(!n)break e;for(;c.length<=f;c.push(0));a=s=0,u=(i%=L)-L+(o=1)}else{for(a=l=c[f],o=1;10<=l;l/=10,o++);s=(u=(i%=L)-L+o)<0?0:a/h[o-u-1]%10|0}if(n=n||t<0||null!=c[f+1]||(u<0?a:a%h[o-u-1]),n=r<4?(s||n)&&(0==r||r==(e.s<0?3:2)):5<s||5==s&&(4==r||n||6==r&&(0<i?0<u?a/h[o-u]:0:c[f-1])%10&1||r==(e.s<0?8:7)),t<1||!c[0])return c.length=0,n?(t-=e.e+1,c[0]=h[(L-t%L)%L],e.e=-t||0):c[0]=e.e=0,e;if(0==i?(c.length=f,l=1,f--):(c.length=f+1,l=h[L-i],c[f]=0<u?I(a/h[o-u]%h[u])*l:0),n)for(;;){if(0==f){for(i=1,u=c[0];10<=u;u/=10,i++);for(u=c[0]+=l,l=1;10<=u;u/=10,l++);i!=l&&(e.e++,c[0]==z&&(c[0]=1));break}if(c[f]+=l,c[f]!=z)break;c[f--]=0,l=1}for(i=c.length;0===c[--i];c.pop());}e.e>O?e.c=e.e=null:e.e<_&&(e.c=[e.e=0])}return e}function $(e){var t,r=e.e;return null===r?e.toString():(t=H(e.c),t=r<=g||b<=r?X(t,r):Y(t,r,"0"),e.s<0?"-"+t:t)}return x.clone=C,x.ROUND_UP=0,x.ROUND_DOWN=1,x.ROUND_CEIL=2,x.ROUND_FLOOR=3,x.ROUND_HALF_UP=4,x.ROUND_HALF_DOWN=5,x.ROUND_HALF_EVEN=6,x.ROUND_HALF_CEIL=7,x.ROUND_HALF_FLOOR=8,x.EUCLID=9,x.config=x.set=function(e){var t,r;if(null!=e){if("object"!=F(e))throw Error(U+"Object expected: "+e);if(e.hasOwnProperty(t="DECIMAL_PLACES")&&(W(r=e[t],0,G,t),w=r),e.hasOwnProperty(t="ROUNDING_MODE")&&(W(r=e[t],0,8,t),m=r),e.hasOwnProperty(t="EXPONENTIAL_AT")&&((r=e[t])&&r.pop?(W(r[0],-G,0,t),W(r[1],0,G,t),g=r[0],b=r[1]):(W(r,-G,G,t),g=-(b=r<0?-r:r))),e.hasOwnProperty(t="RANGE"))if((r=e[t])&&r.pop)W(r[0],-G,-1,t),W(r[1],1,G,t),_=r[0],O=r[1];else{if(W(r,-G,G,t),!r)throw Error(U+t+" cannot be zero: "+r);_=-(O=r<0?-r:r)}if(e.hasOwnProperty(t="CRYPTO")){if((r=e[t])!==!!r)throw Error(U+t+" not true or false: "+r);if(r){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw A=!r,Error(U+"crypto unavailable");A=r}else A=r}if(e.hasOwnProperty(t="MODULO_MODE")&&(W(r=e[t],0,9,t),o=r),e.hasOwnProperty(t="POW_PRECISION")&&(W(r=e[t],0,G,t),E=r),e.hasOwnProperty(t="FORMAT")){if("object"!=F(r=e[t]))throw Error(U+t+" not an object: "+r);N=r}if(e.hasOwnProperty(t="ALPHABET")){if("string"!=typeof(r=e[t])||/^.?$|[+\-.\s]|(.).*\1/.test(r))throw Error(U+t+" invalid: "+r);j="0123456789"==r.slice(0,10),S=r}}return{DECIMAL_PLACES:w,ROUNDING_MODE:m,EXPONENTIAL_AT:[g,b],RANGE:[_,O],CRYPTO:A,MODULO_MODE:o,POW_PRECISION:E,FORMAT:N,ALPHABET:S}},x.isBigNumber=function(e){if(!e||!0!==e._isBigNumber)return!1;if(!x.DEBUG)return!0;var t,r,n=e.c,o=e.e,i=e.s;e:if("[object Array]"=={}.toString.call(n)){if((1===i||-1===i)&&-G<=o&&o<=G&&o===I(o))if(0===n[0]){if(0===o&&1===n.length)return!0}else if((t=(o+1)%L)<1&&(t+=L),String(n[0]).length==t){for(t=0;t<n.length;t++)if((r=n[t])<0||z<=r||r!==I(r))break e;if(0!==r)return!0}}else if(null===n&&null===o&&(null===i||1===i||-1===i))return!0;throw Error(U+"Invalid BigNumber: "+e)},x.maximum=x.max=function(){return i(arguments,r.lt)},x.minimum=x.min=function(){return i(arguments,r.gt)},x.random=(t=9007199254740992,f=Math.random()*t&2097151?function(){return I(Math.random()*t)}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)},function(e){var t,r,n,o,i,u=0,l=[],a=new x(v);if(null==e?e=w:W(e,0,G),o=Q(e/L),A)if(crypto.getRandomValues){for(t=crypto.getRandomValues(new Uint32Array(o*=2));u<o;)9e15<=(i=131072*t[u]+(t[u+1]>>>11))?(r=crypto.getRandomValues(new Uint32Array(2)),t[u]=r[0],t[u+1]=r[1]):(l.push(i%1e14),u+=2);u=o/2}else{if(!crypto.randomBytes)throw A=!1,Error(U+"crypto unavailable");for(t=crypto.randomBytes(o*=7);u<o;)9e15<=(i=281474976710656*(31&t[u])+1099511627776*t[u+1]+4294967296*t[u+2]+16777216*t[u+3]+(t[u+4]<<16)+(t[u+5]<<8)+t[u+6])?crypto.randomBytes(7).copy(t,u):(l.push(i%1e14),u+=7);u=o/7}if(!A)for(;u<o;)(i=f())<9e15&&(l[u++]=i%1e14);for(o=l[--u],e%=L,o&&e&&(l[u]=I(o/(i=re[L-e]))*i);0===l[u];l.pop(),u--);if(u<0)l=[n=0];else{for(n=-1;0===l[0];l.splice(0,1),n-=L);for(u=1,i=l[0];10<=i;i/=10,u++);u<L&&(n-=L-u)}return a.e=n,a.c=l,a}),x.sum=function(){for(var e=1,t=arguments,r=new x(t[0]);e<t.length;)r=r.plus(t[e++]);return r},y="0123456789",c=function(e,t,r,n,o){var i,u,l,a,f,s,c,h,p=e.indexOf("."),v=w,g=m;for(0<=p&&(a=E,E=0,e=e.replace(".",""),s=(h=new x(t)).pow(e.length-p),E=a,h.c=P(Y(H(s.c),s.e,"0"),10,r,y),h.e=h.c.length),l=a=(c=P(e,t,r,o?(i=S,y):(i=y,S))).length;0==c[--a];c.pop());if(!c[0])return i.charAt(0);if(p<0?--l:(s.c=c,s.e=l,s.s=n,c=(s=d(s,h,v,g,r)).c,f=s.r,l=s.e),p=c[u=l+v+1],a=r/2,f=f||u<0||null!=c[u+1],f=g<4?(null!=p||f)&&(0==g||g==(s.s<0?3:2)):a<p||p==a&&(4==g||f||6==g&&1&c[u-1]||g==(s.s<0?8:7)),u<1||!c[0])e=f?Y(i.charAt(1),-v,i.charAt(0)):i.charAt(0);else{if(c.length=u,f)for(--r;++c[--u]>r;)c[u]=0,u||(++l,c=[1].concat(c));for(a=c.length;!c[--a];);for(p=0,e="";p<=a;e+=i.charAt(c[p++]));e=Y(e,l,i.charAt(0))}return e},d=function(e,t,r,n,o){var i,u,l,a,f,s,c,h,p,v,g,d,y,w,m,b,_,O=e.s==t.s?1:-1,A=e.c,E=t.c;if(!(A&&A[0]&&E&&E[0]))return new x(e.s&&t.s&&(A?!E||A[0]!=E[0]:E)?A&&0==A[0]||!E?0*O:O/0:NaN);for(p=(h=new x(O)).c=[],O=r+(u=e.e-t.e)+1,o||(o=z,u=q(e.e/L)-q(t.e/L),O=O/L|0),l=0;E[l]==(A[l]||0);l++);if(E[l]>(A[l]||0)&&u--,O<0)p.push(1),a=!0;else{for(w=A.length,b=E.length,O+=2,1<(f=I(o/(E[l=0]+1)))&&(E=k(E,f,o),A=k(A,f,o),b=E.length,w=A.length),y=b,g=(v=A.slice(0,b)).length;g<b;v[g++]=0);_=E.slice(),_=[0].concat(_),m=E[0],E[1]>=o/2&&m++;do{if(f=0,(i=R(E,v,b,g))<0){if(d=v[0],b!=g&&(d=d*o+(v[1]||0)),1<(f=I(d/m)))for(c=(s=k(E,f=o<=f?o-1:f,o)).length,g=v.length;1==R(s,v,c,g);)f--,T(s,b<c?_:E,c,o),c=s.length,i=1;else 0==f&&(i=f=1),c=(s=E.slice()).length;if(T(v,s=c<g?[0].concat(s):s,g,o),g=v.length,-1==i)for(;R(E,v,b,g)<1;)f++,T(v,b<g?_:E,g,o),g=v.length}else 0===i&&(f++,v=[0])}while(p[l++]=f,v[0]?v[g++]=A[y]||0:(v=[A[y]],g=1),(y++<w||null!=v[0])&&O--);a=null!=v[0],p[0]||p.splice(0,1)}if(o==z){for(l=1,O=p[0];10<=O;O/=10,l++);B(h,r+(h.e=l+u*L-1)+1,n,a)}else h.e=u,h.r=+a;return h},u=/^(-?)0([xbo])(?=\w[\w.]*$)/i,l=/^([^.]+)\.$/,a=/^\.([^.]+)$/,s=/^-?(Infinity|NaN)$/,p=/^\s*\+(?=[\w.])|^\s+|\s+$/g,h=function(e,t,r,n){var o,i=r?t:t.replace(p,"");if(s.test(i))e.s=isNaN(i)?null:i<0?-1:1;else{if(!r&&(i=i.replace(u,function(e,t,r){return o="x"==(r=r.toLowerCase())?16:"b"==r?2:8,n&&n!=o?e:t}),n&&(o=n,i=i.replace(l,"$1").replace(a,"0.$1")),t!=i))return new x(i,o);if(x.DEBUG)throw Error(U+"Not a"+(n?" base "+n:"")+" number: "+t);e.s=null}e.c=e.e=null},r.absoluteValue=r.abs=function(){var e=new x(this);return e.s<0&&(e.s=1),e},r.comparedTo=function(e,t){return V(this,new x(e,t))},r.decimalPlaces=r.dp=function(e,t){var r,n;if(null!=e)return W(e,0,G),null==t?t=m:W(t,0,8),B(new x(this),e+this.e+1,t);if(!(e=this.c))return null;if(r=((n=e.length-1)-q(this.e/L))*L,n=e[n])for(;n%10==0;n/=10,r--);return r=r<0?0:r},r.dividedBy=r.div=function(e,t){return d(this,new x(e,t),w,m)},r.dividedToIntegerBy=r.idiv=function(e,t){return d(this,new x(e,t),0,1)},r.exponentiatedBy=r.pow=function(e,t){var r,n,o,i,u,l,a,f,s=this;if((e=new x(e)).c&&!e.isInteger())throw Error(U+"Exponent not an integer: "+$(e));if(null!=t&&(t=new x(t)),u=14<e.e,!s.c||!s.c[0]||1==s.c[0]&&!s.e&&1==s.c.length||!e.c||!e.c[0])return f=new x(Math.pow(+$(s),u?2-Z(e):+$(e))),t?f.mod(t):f;if(l=e.s<0,t){if(t.c?!t.c[0]:!t.s)return new x(NaN);(n=!l&&s.isInteger()&&t.isInteger())&&(s=s.mod(t))}else{if(9<e.e&&(0<s.e||s.e<-1||(0==s.e?1<s.c[0]||u&&24e7<=s.c[1]:s.c[0]<8e13||u&&s.c[0]<=9999975e7)))return i=s.s<0&&Z(e)?-0:0,-1<s.e&&(i=1/i),new x(l?1/i:i);E&&(i=Q(E/L+2))}for(a=u?(r=new x(.5),l&&(e.s=1),Z(e)):(o=Math.abs(+$(e)))%2,f=new x(v);;){if(a){if(!(f=f.times(s)).c)break;i?f.c.length>i&&(f.c.length=i):n&&(f=f.mod(t))}if(o){if(0===(o=I(o/2)))break;a=o%2}else if(B(e=e.times(r),e.e+1,1),14<e.e)a=Z(e);else{if(0==(o=+$(e)))break;a=o%2}s=s.times(s),i?s.c&&s.c.length>i&&(s.c.length=i):n&&(s=s.mod(t))}return n?f:(l&&(f=v.div(f)),t?f.mod(t):i?B(f,E,m,void 0):f)},r.integerValue=function(e){var t=new x(this);return null==e?e=m:W(e,0,8),B(t,t.e+1,e)},r.isEqualTo=r.eq=function(e,t){return 0===V(this,new x(e,t))},r.isFinite=function(){return!!this.c},r.isGreaterThan=r.gt=function(e,t){return 0<V(this,new x(e,t))},r.isGreaterThanOrEqualTo=r.gte=function(e,t){return 1===(t=V(this,new x(e,t)))||0===t},r.isInteger=function(){return!!this.c&&q(this.e/L)>this.c.length-2},r.isLessThan=r.lt=function(e,t){return V(this,new x(e,t))<0},r.isLessThanOrEqualTo=r.lte=function(e,t){return-1===(t=V(this,new x(e,t)))||0===t},r.isNaN=function(){return!this.s},r.isNegative=function(){return this.s<0},r.isPositive=function(){return 0<this.s},r.isZero=function(){return!!this.c&&0==this.c[0]},r.minus=function(e,t){var r,n,o,i,u=this,l=u.s;if(t=(e=new x(e,t)).s,!l||!t)return new x(NaN);if(l!=t)return e.s=-t,u.plus(e);var a=u.e/L,f=e.e/L,s=u.c,c=e.c;if(!a||!f){if(!s||!c)return s?(e.s=-t,e):new x(c?u:NaN);if(!s[0]||!c[0])return c[0]?(e.s=-t,e):new x(s[0]?u:3==m?-0:0)}if(a=q(a),f=q(f),s=s.slice(),l=a-f){for((o=(i=l<0)?(l=-l,s):(f=a,c)).reverse(),t=l;t--;o.push(0));o.reverse()}else for(n=(i=(l=s.length)<(t=c.length))?l:t,l=t=0;t<n;t++)if(s[t]!=c[t]){i=s[t]<c[t];break}if(i&&(o=s,s=c,c=o,e.s=-e.s),0<(t=(n=c.length)-(r=s.length)))for(;t--;s[r++]=0);for(t=z-1;l<n;){if(s[--n]<c[n]){for(r=n;r&&!s[--r];s[r]=t);--s[r],s[n]+=z}s[n]-=c[n]}for(;0==s[0];s.splice(0,1),--f);return s[0]?D(e,s,f):(e.s=3==m?-1:1,e.c=[e.e=0],e)},r.modulo=r.mod=function(e,t){var r,n=this;return e=new x(e,t),!n.c||!e.s||e.c&&!e.c[0]?new x(NaN):!e.c||n.c&&!n.c[0]?new x(n):(9==o?(t=e.s,e.s=1,r=d(n,e,0,3),e.s=t,r.s*=t):r=d(n,e,0,o),(e=n.minus(r.times(e))).c[0]||1!=o||(e.s=n.s),e)},r.multipliedBy=r.times=function(e,t){var r,n,o,i,u,l,a,f,s,c,h,p=this,v=p.c,g=(e=new x(e,t)).c;if(!(v&&g&&v[0]&&g[0]))return!p.s||!e.s||v&&!v[0]&&!g||g&&!g[0]&&!v?e.c=e.e=e.s=null:(e.s*=p.s,v&&g?(e.c=[0],e.e=0):e.c=e.e=null),e;for(t=q(p.e/L)+q(e.e/L),e.s*=p.s,(l=v.length)<(p=g.length)&&(h=v,v=g,g=h,n=l,l=p,p=n),n=l+p,h=[];n--;h.push(0));for(n=p;0<=--n;){for(s=g[n]%1e7,c=g[n]/1e7|(r=0),o=n+(i=l);n<o;)r=((a=s*(a=v[--i]%1e7)+(u=c*a+(f=v[i]/1e7|0)*s)%1e7*1e7+h[o]+r)/1e14|0)+(u/1e7|0)+c*f,h[o--]=a%1e14;h[o]=r}return r?++t:h.splice(0,1),D(e,h,t)},r.negated=function(){var e=new x(this);return e.s=-e.s||null,e},r.plus=function(e,t){var r,n=this,o=n.s;if(t=(e=new x(e,t)).s,!o||!t)return new x(NaN);if(o!=t)return e.s=-t,n.minus(e);var i=n.e/L,u=e.e/L,l=n.c,a=e.c;if(!i||!u){if(!l||!a)return new x(o/0);if(!l[0]||!a[0])return a[0]?e:new x(l[0]?n:0*o)}if(i=q(i),u=q(u),l=l.slice(),o=i-u){for((r=0<o?(u=i,a):(o=-o,l)).reverse();o--;r.push(0));r.reverse()}for((o=l.length)-(t=a.length)<0&&(r=a,a=l,l=r,t=o),o=0;t;)o=(l[--t]=l[t]+a[t]+o)/z|0,l[t]=z===l[t]?0:l[t]%z;return o&&(l=[o].concat(l),++u),D(e,l,u)},r.precision=r.sd=function(e,t){var r,n;if(null!=e&&e!==!!e)return W(e,1,G),null==t?t=m:W(t,0,8),B(new x(this),e,t);if(!(t=this.c))return null;if(r=(n=t.length-1)*L+1,n=t[n]){for(;n%10==0;n/=10,r--);for(n=t[0];10<=n;n/=10,r++);}return r=e&&this.e+1>r?this.e+1:r},r.shiftedBy=function(e){return W(e,-te,te),this.times("1e"+e)},r.squareRoot=r.sqrt=function(){var e,t,r,n,o,i=this,u=i.c,l=i.s,a=i.e,f=w+4,s=new x("0.5");if(1!==l||!u||!u[0])return new x(!l||l<0&&(!u||u[0])?NaN:u?i:1/0);if((r=0==(l=Math.sqrt(+$(i)))||l==1/0?(((t=H(u)).length+a)%2==0&&(t+="0"),l=Math.sqrt(+t),a=q((a+1)/2)-(a<0||a%2),new x(t=l==1/0?"5e"+a:(t=l.toExponential()).slice(0,t.indexOf("e")+1)+a)):new x(l+"")).c[0])for((l=(a=r.e)+f)<3&&(l=0);;)if(o=r,r=s.times(o.plus(d(i,o,f,1))),H(o.c).slice(0,l)===(t=H(r.c)).slice(0,l)){if(r.e<a&&--l,"9999"!=(t=t.slice(l-3,l+1))&&(n||"4999"!=t)){+t&&(+t.slice(1)||"5"!=t.charAt(0))||(B(r,r.e+w+2,1),e=!r.times(r).eq(i));break}if(!n&&(B(o,o.e+w+2,0),o.times(o).eq(i))){r=o;break}f+=4,l+=4,n=1}return B(r,r.e+w+1,m,e)},r.toExponential=function(e,t){return null!=e&&(W(e,0,G),e++),n(this,e,t,1)},r.toFixed=function(e,t){return null!=e&&(W(e,0,G),e=e+this.e+1),n(this,e,t)},r.toFormat=function(e,t,r){if(null==r)null!=e&&t&&"object"==F(t)?(r=t,t=null):e&&"object"==F(e)?(r=e,e=t=null):r=N;else if("object"!=F(r))throw Error(U+"Argument not an object: "+r);if(e=this.toFixed(e,t),this.c){var n,t=e.split("."),o=+r.groupSize,i=+r.secondaryGroupSize,u=r.groupSeparator||"",l=t[0],t=t[1],a=this.s<0,f=a?l.slice(1):l,s=f.length;if(i&&(n=o,o=i,s-=i=n),0<o&&0<s){for(l=f.substr(0,n=s%o||o);n<s;n+=o)l+=u+f.substr(n,o);0<i&&(l+=u+f.slice(n)),a&&(l="-"+l)}e=t?l+(r.decimalSeparator||"")+((i=+r.fractionGroupSize)?t.replace(new RegExp("\\d{"+i+"}\\B","g"),"$&"+(r.fractionGroupSeparator||"")):t):l}return(r.prefix||"")+e+(r.suffix||"")},r.toFraction=function(e){var t,r,n,o,i,u,l,a,f,s,c=this,h=c.c;if(null!=e&&(!(l=new x(e)).isInteger()&&(l.c||1!==l.s)||l.lt(v)))throw Error(U+"Argument "+(l.isInteger()?"out of range: ":"not an integer: ")+$(l));if(!h)return new x(c);for(t=new x(v),f=r=new x(v),n=a=new x(v),h=H(h),i=t.e=h.length-c.e-1,t.c[0]=re[(u=i%L)<0?L+u:u],e=!e||0<l.comparedTo(t)?0<i?t:f:l,u=O,O=1/0,l=new x(h),a.c[0]=0;s=d(l,t,0,1),1!=(o=r.plus(s.times(n))).comparedTo(e);)r=n,n=o,f=a.plus(s.times(o=f)),a=o,t=l.minus(s.times(o=t)),l=o;return o=d(e.minus(r),n,0,1),a=a.plus(o.times(f)),r=r.plus(o.times(n)),a.s=f.s=c.s,h=d(f,n,i*=2,m).minus(c).abs().comparedTo(d(a,r,i,m).minus(c).abs())<1?[f,n]:[a,r],O=u,h},r.toNumber=function(){return+$(this)},r.toPrecision=function(e,t){return null!=e&&W(e,1,G),n(this,e,t,2)},r.toString=function(e){var t,r=this,n=r.s,o=r.e;return null===o?n?(t="Infinity",n<0&&(t="-"+t)):t="NaN":(t=null==e?o<=g||b<=o?X(H(r.c),o):Y(H(r.c),o,"0"):10===e&&j?Y(H((r=B(new x(r),w+o+1,m)).c),r.e,"0"):(W(e,2,S.length,"Base"),c(Y(H(r.c),o,"0"),10,e,n,!0)),n<0&&r.c[0]&&(t="-"+t)),t},r.valueOf=r.toJSON=function(){return $(this)},r._isBigNumber=!0,r[Symbol.toStringTag]="BigNumber",r[Symbol.for("nodejs.util.inspect.custom")]=r.valueOf,null!=e&&x.set(e),x}();function ne(e,t,r){var n="";if(s.isBigNumber(e))n=e.toFixed();else if("string"!=typeof e)n=e.toString();else if(!0===r){r=B(e);if(null===r.num)return null;n=s(r.num).toFixed()}else n=s(e).toFixed();if("undefined"===n||"NaN"===n)return null;var o=null,i=null,u=null,l=null;if(t.forEach(function(e){var t=e.type;if("symbol"===t){if(![">=","<=","="].includes(e.value))throw new Error("错误的格式化参数:",e.value);i=e.value}else if("comma"===t)u=!0;else if("number"===t)o=e.value;else{if("plus"!==t)throw new Error("错误的fmt Token");l=!0}}),null!==o){var r=n.split("."),e=r[0],a=1===r.length?"":r[1],f=a.length;switch(i){case"<=":a=f<=o?a:a.slice(0,o);break;case"=":f<o?a+="0".repeat(o-f):o<f&&(a=a.slice(0,o));break;case">=":a=o<=f?a:a+"0".repeat(o-f)}n=""===a?e:"".concat(e,".").concat(a)}return null!==u&&(n=1<(t=n.split(".")).length?((r=t[0]).includes("-")?t[0]=r[0]+r.slice(1).replace(/(?=(?!^)(?:\d{3})+$)/g,","):t[0]=r.replace(/(?=(?!^)(?:\d{3})+$)/g,","),t.join(".")):(e=t[0]).includes("-")?e[0]+e.slice(1).replace(/(?=(?!^)(?:\d{3})+$)/g,","):e.replace(/(?=(?!^)(?:\d{3})+$)/g,",")),n=null===l||n.startsWith("-")?n:"+"+n}function oe(e){for(var t=[],r=0,n=null,o=e.length;r<o;)if(n=e[r],/\s/.test(n))r++;else if("+-".includes(n)){var i=t[t.length-1];if(0===t.length||"+-".includes(i)||"("===i){var u=n;if(++r>=o){t.push(u);break}for(n=e[r];/[a-zA-Z\d._]/.test(n)&&(u+=n,!(++r>=o));)n=e[r];t.push(u)}else t.push(n),r++}else if("*/%()".includes(n))t.push(n),r++;else if(/[a-zA-Z_$]/.test(n)){for(var l="";/[\w_.\[\]"']/.test(n)&&(l+=n,!(++r>=o));)n=e[r];t.push(l)}else if(/\d/.test(n)){for(var a="";/[^+*/()\s-]/.test(n)&&(a+=n,!(++r>=o));)n=e[r];t.push(a)}return t}var r="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},ie=Array.isArray,r="object"==F(r)&&r&&r.Object===Object&&r,n="object"==("undefined"==typeof self?"undefined":F(self))&&self&&self.Object===Object&&self,r=r||n||Function("return this")(),n=r.Symbol,u=Object.prototype,ue=u.hasOwnProperty,le=u.toString,l=n?n.toStringTag:void 0;var ae=Object.prototype.toString;var fe=function(e){var t=ue.call(e,l),r=e[l];try{var n=!(e[l]=void 0)}catch(e){}var o=le.call(e);return n&&(t?e[l]=r:delete e[l]),o},se=function(e){return ae.call(e)},ce=n?n.toStringTag:void 0;function he(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":(ce&&ce in Object(e)?fe:se)(e)}var pe=he,ve=function(e){return null!=e&&"object"==F(e)};function ge(e){return"symbol"==F(e)||ve(e)&&"[object Symbol]"==pe(e)}var de=ie,ye=ge,we=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,me=/^\w*$/;function be(e,t){if(de(e))return!1;var r=F(e);return!("number"!=r&&"symbol"!=r&&"boolean"!=r&&null!=e&&!ye(e))||(me.test(e)||!we.test(e)||null!=t&&e in Object(t))}function _e(e){var t=F(e);return null!=e&&("object"==t||"function"==t)}var Oe=he,Ae=_e;function Ee(e){return!!Ae(e)&&("[object Function]"==(e=Oe(e))||"[object GeneratorFunction]"==e||"[object AsyncFunction]"==e||"[object Proxy]"==e)}var u=r["__core-js_shared__"],Ne=(u=/[^.]+$/.exec(u&&u.keys&&u.keys.IE_PROTO||""))?"Symbol(src)_1."+u:"";var Se=Function.prototype.toString;var je=Ee,xe=function(e){return!!Ne&&Ne in e},Pe=_e,ke=function(e){if(null!=e){try{return Se.call(e)}catch(e){}try{return e+""}catch(e){}}return""},Re=/^\[object .+?Constructor\]$/,u=Function.prototype,a=Object.prototype,u=u.toString,a=a.hasOwnProperty,Te=RegExp("^"+u.call(a).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");var De=function(e){return!(!Pe(e)||xe(e))&&(je(e)?Te:Re).test(ke(e))},Be=function(e,t){return null==e?void 0:e[t]};function $e(e,t){return e=Be(e,t),De(e)?e:void 0}var u=$e(Object,"create"),Ce=u;var Fe=u,Ie=Object.prototype.hasOwnProperty;var Ue=u,ze=Object.prototype.hasOwnProperty;var Le=u;function Me(e){return e=this.has(e)&&delete this.__data__[e],this.size-=e?1:0,e}function Ge(e){var t,r=this.__data__;return Fe?"__lodash_hash_undefined__"===(t=r[e])?void 0:t:Ie.call(r,e)?r[e]:void 0}function qe(e){var t=this.__data__;return Ue?void 0!==t[e]:ze.call(t,e)}function He(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=Le&&void 0===t?"__lodash_hash_undefined__":t,this}function f(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}f.prototype.clear=function(){this.__data__=Ce?Ce(null):{},this.size=0},f.prototype.delete=Me,f.prototype.get=Ge,f.prototype.has=qe,f.prototype.set=He;a=f;var Ve=function(e,t){return e===t||e!=e&&t!=t};function c(e,t){for(var r=e.length;r--;)if(Ve(e[r][0],t))return r;return-1}var We=c,Ze=Array.prototype.splice;var Xe=c;var Ye=c;var Je=c;function Ke(e){var t=this.__data__;return!((e=We(t,e))<0)&&(e==t.length-1?t.pop():Ze.call(t,e,1),--this.size,!0)}function Qe(e){var t=this.__data__;return(e=Xe(t,e))<0?void 0:t[e][1]}function et(e){return-1<Ye(this.__data__,e)}function tt(e,t){var r=this.__data__,n=Je(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this}function p(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}p.prototype.clear=function(){this.__data__=[],this.size=0},p.prototype.delete=Ke,p.prototype.get=Qe,p.prototype.has=et,p.prototype.set=tt;var u=p,r=$e(r,"Map"),rt=a,nt=u,ot=r;var it=function(e){var t=F(e);return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e};function m(e,t){return e=e.__data__,it(t)?e["string"==typeof t?"string":"hash"]:e.map}var ut=m;var lt=m;var at=m;var ft=m;function st(e){return e=ut(this,e).delete(e),this.size-=e?1:0,e}function ct(e){return lt(this,e).get(e)}function ht(e){return at(this,e).has(e)}function pt(e,t){var r=ft(this,e),n=r.size;return r.set(e,t),this.size+=r.size==n?0:1,this}function b(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}b.prototype.clear=function(){this.size=0,this.__data__={hash:new rt,map:new(ot||nt),string:new rt}},b.prototype.delete=st,b.prototype.get=ct,b.prototype.has=ht,b.prototype.set=pt;var vt=b;function gt(n,o){if("function"!=typeof n||null!=o&&"function"!=typeof o)throw new TypeError("Expected a function");function i(){var e=arguments,t=o?o.apply(this,e):e[0],r=i.cache;return r.has(t)?r.get(t):(e=n.apply(this,e),i.cache=r.set(t,e)||r,e)}return i.cache=new(gt.Cache||vt),i}gt.Cache=vt;var dt=gt;var yt=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,wt=/\\(\\)?/g,a=function(e){var t=(e=dt(e,function(e){return 500===t.size&&t.clear(),e})).cache;return e}(function(e){var o=[];return 46===e.charCodeAt(0)&&o.push(""),e.replace(yt,function(e,t,r,n){o.push(r?n.replace(wt,"$1"):t||e)}),o});var mt=function(e,t){for(var r=-1,n=null==e?0:e.length,o=Array(n);++r<n;)o[r]=t(e[r],r,e);return o},bt=ie,_t=ge,u=n?n.prototype:void 0,Ot=u?u.toString:void 0;var At=function e(t){if("string"==typeof t)return t;if(bt(t))return mt(t,e)+"";if(_t(t))return Ot?Ot.call(t):"";var r=t+"";return"0"==r&&1/t==-1/0?"-0":r};var Et=ie,Nt=be,St=a,jt=function(e){return null==e?"":At(e)};var xt=ge;var Pt=function(e,t){return Et(e)?e:Nt(e,t)?[e]:St(jt(e))},kt=function(e){if("string"==typeof e||xt(e))return e;var t=e+"";return"0"==t&&1/e==-1/0?"-0":t};var Rt=function(e,t){for(var r=0,n=(t=Pt(t,e)).length;null!=e&&r<n;)e=e[kt(t[r++])];return r&&r==n?e:void 0};var _=function(e,t,r){return void 0===(e=null==e?void 0:Rt(e,t))?r:e};function Tt(e,t,r){var n=[];if(!d(t))throw new w("错误的填充数据:",t);Array.isArray(t)?n=t:n.push(t);for(var o=[],i=0;i<e.length;i++){var u=e[i];if(/^[a-zA-z_][\w\[\]"'_.]*$/.test(u)){if("undefined"===u||"NaN"===u)throw new w("key不应该为:".concat(u));for(var l=null,a=0;a<n.length;a++){var f=n[a],f=_(f,u);if(void 0!==f){l=f;break}}if(null===l)throw new w("token填充失败,请确认".concat(u,"存在"));if("string"==typeof l){if(""===l.trim())throw new w("token填充失败,".concat(u,"值不可为空字符"));if(!0===r){if(!/^[+-]?[\d.]+\D*$/.test(l))throw new w("token填充失败,".concat(u,"值:").concat(l,"为非法单位数字"))}else if(!h(l))throw new w("token填充失败,".concat(u,"值:").concat(l,"为非法数字"))}l="string"!=typeof l?l.toString():l,o.push(l)}else o.push(u)}return o}function Dt(e,o){return e.map(function(e){if("var"!==e.type)return e;for(var t,r,n=0;n<o.length&&!g(t=_(o[n],e.value));n++);if("number"==typeof(r=t)||h(r))return{type:"number",value:t};throw new w("错误的填充值")})}function Bt(e){var r=null;return e.length,{tokens:e.map(function(e){var t=B(e);return null!==t.unit?(null==r&&(r=t.unit),t.num):e}),unit:r}}function $t(e){for(var t,r=[],n=[],o=e;0<o.length;){var i=o.shift();if(R(i))if("("===i)r.push(i);else if(")"===i){for(var u=r.pop();"("!==u&&0<r.length;)n.push(u),u=r.pop();if("("!==u)throw"error: unmatched ()"}else{for(;t=r[r.length-1],T(i)<=T(t)&&0<r.length;)n.push(r.pop());r.push(i)}else n.push(i)}if(0<r.length){if(")"===r[r.length-1]||"("===r[r.length-1])throw"error: unmatched ()";for(;0<r.length;)n.push(r.pop())}return n}function Ct(e){for(var t,r=[];0<e.length;){var n=e.shift();if(R(n)){if(r.length<2)throw new y("错误的栈长度, 可能是无法计算的表达式");var o=r.pop(),i=r.pop();if("string"==typeof o&&!s.isBigNumber(o)){if(!h(o))throw new y("".concat(o,"不是一个合法的数字"));o=new s(o)}if("string"==typeof i&&!s.isBigNumber(i)){if(!h(i))throw new y("".concat(i,"不是一个合法的数字"));i=new s(i)}switch(n){case"+":r.push(i.plus(o));break;case"-":r.push(i.minus(o));break;case"*":r.push(i.times(o));break;case"/":r.push(i.div(o));break;case"%":r.push(i.mod(o))}}else r.push(n)}if(1!==r.length)throw"unvalid expression";return t=r[0],s.isBigNumber(t)?t:s(t)}return e.calc=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];var n,o=J(t),i=oe(o.expr),u=null,l=null;if(!0===_(o,"data._debug")&&(console.warn("======a-calc调试模式======"),console.warn(o),console.warn(i)),d(o.data)){var a=o.data,f=[],s=a._error,c=a._fillError,h=a._warn,p=_(a,"_unit",null);if(Array.isArray(a)?f=a:(f.push(u=a),g(a=_(u,"_fillData"))&&(Array.isArray(a)?f=[].concat(v(f),v(a)):f.push(a))),D(c,s))try{i=Tt(i,f,p),d(o.fmt)&&(o.fmt=Dt(o.fmt,f))}catch(e){if(e instanceof w)return g(h)&&!0===h&&console.warn(e),g(c)?c:s;throw e}else i=Tt(i,f,p),d(o.fmt)&&(o.fmt=Dt(o.fmt,f));!0===p&&(l=(a=Bt(i)).unit,i=a.tokens)}if(c=$t(i),f=null,d(u)&&D(n,s))try{f=Ct(c)}catch(e){if(e instanceof y)return void 0!==h&&!0===h&&console.warn(e),s;throw e}else f=Ct(c);return null!==(f=d(o.fmt)?ne(f,o.fmt):null!==f?f.toFixed():null)&&null!==l&&(f+=l),f},e.fmt=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];var n=J(t),o=oe(n.expr),i=null,u=null;if(!0===_(n,"data._debug")&&(console.warn("======a-calc调试模式======"),console.warn(n),console.warn(o)),""===n.expr.trim()&&d(n.data)&&g(n.data._error))return n.data._error;if(2<o.length)throw new Error("fmt并非用于计算, 不能传入多个标识:".concat(n.expr));if(1!==o.length)throw new Error("fmt接收了一个无法被解析的标识");if(d(n.data)){var l,a=n.data,f=[],s=a._fillError,c=_(a,"_unit",null);if(Array.isArray(a)?f=a:(f.push(i=a),g(l=_(i,"_fillData"))&&(Array.isArray(l)?f=[].concat(v(f),v(l)):f.push(l))),D(s,a._error))try{o=Tt(o,f,c),d(n.fmt)&&(n.fmt=Dt(n.fmt,f))}catch(e){if(e instanceof w)return void 0!==i._warn&&!0===i._warn&&console.warn(e),i._fillError||i._error;throw e}else o=Tt(o,f,c),d(n.fmt)&&(n.fmt=Dt(n.fmt,f));!0===c&&(u=(l=Bt(o)).unit,o=l.tokens)}if(null===n.fmt)throw"表达式没有格式化部分";if(s=o[0],!0===c){if(!/^[+-]?[\d.]+\D*$/.test(s))throw new w("token填充失败,".concat(key,"值:").concat(value,"为非法单位数字"))}else if(!h(s))throw new w("待格式化对象: ".concat(s," 不是数字"));return null!==(a=ne(s,n.fmt,c))&&null!==u&&(a+=u),a},e.version="0.0.71",Object.defineProperty(e,"__esModule",{value:!0}),e}({});
1
+ var a_calc=function(e){"use strict";function C(e){return(C="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function A(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function t(e,t,r){return t&&A(e.prototype,t),r&&A(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&l(e,t)}function u(e){return(u=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function l(e,t){return(l=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function N(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}function S(e,t,r){return(S=N()?Reflect.construct:function(e,t,r){var n=[null];n.push.apply(n,t);t=new(Function.bind.apply(e,n));return r&&l(t,r.prototype),t}).apply(null,arguments)}function a(e){var r="function"==typeof Map?new Map:void 0;return(a=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==r){if(r.has(e))return r.get(e);r.set(e,t)}function t(){return S(e,arguments,u(this).constructor)}return t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),l(t,e)})(e)}function j(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");t=e;if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function c(r){var n=N();return function(){var e,t=u(r);return j(this,n?(e=u(this).constructor,Reflect.construct(t,arguments,e)):t.apply(this,arguments))}}function v(e){return function(e){if(Array.isArray(e))return P(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return P(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Map"===(r="Object"===r&&e.constructor?e.constructor.name:r)||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?P(e,t):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function P(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var x=/^[+-]?\d[\d.]*(?:e\+|E\+|e-|E-|e|E)?\d*$/,R=/^[+-]?\d[\d.]*(?:e\+|E\+|e-|E-|e|E)?\d*\D*$/,T=/^[a-zA-z_][\w\[\]"'_.]*$/;function k(e){return-1<"+-*/%()".indexOf(e)}function D(e){switch(e){case"+":case"-":return 1;case"*":case"/":case"%":return 2;default:return 0}}function g(e){return void 0!==e}function B(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return t.some(function(e){return void 0!==e})}function d(e){return null!==e}function h(e){return"string"==typeof e&&!!x.test(e)}function $(e){for(var t,r,n=null,i=null,o=[/^([+-]?[\d.]+(?:e|E)(?:\+|-)?\d+)(\D*)$/,/^([+-]?[\d.]+)(\D*)$/],u=0;u<o.length;u++){var l=e.match(o[u]);if(l){t=l;break}}return t&&(i=t[1],""!==(r=t[2]).trim()&&(n=r)),{num:i,unit:n}}var y=function(){o(n,a(Error));var r=c(n);function n(e){var t;return i(this,n),(t=r.call(this,e)).name="CalculatorError",t.message=e,t}return t(n)}(),w=function(){o(n,a(Error));var r=c(n);function n(e){var t;return i(this,n),(t=r.call(this,e)).name="TokensFillError",t.message=e,t}return t(n)}(),F=function(){o(n,a(Error));var r=c(n);function n(e){var t;return i(this,n),(t=r.call(this,e)).name="ArgError",t.message=e,t}return t(n)}(),X=function(){o(n,a(Error));var r=c(n);function n(e){var t;return i(this,n),(t=r.call(this,e)).name="FmtError",t.message=e,t}return t(n)}();function Y(e){for(var t,r=0,n=e.length,i=[];r<n;)if(t=e[r],/\s/.test(t))r++;else if("+"===t)i.push({type:"plus",value:t}),r++;else if(","===t)i.push({type:"comma",value:t}),r++;else if("<>=".includes(t)){var o=t;++r>=n?i.push({type:"symbol",value:o}):(u=e[r],"<>=".includes(u)?(o+=u,i.push({type:"symbol",value:o}),r++):i.push({type:"symbol",value:t}))}else if("~"===t){var u=t;if(++r>=n)throw new X("fmt格式化传参错误!错误解析字符:".concat(t));if(t=e[r],!"+-56".includes(t))throw new X("fmt格式化传参错误!错误解析字符:".concat(t));u+=t,i.push({type:"round",value:u}),r++}else if(/[a-zA-Z_]/.test(t)){for(var l="";/[\w_.\[\]"']/.test(t)&&(l+=t,!(n<=++r));)t=e[r];i.push({type:"var",value:l})}else if(/\d/.test(t)){for(var a="";/[\d.]/.test(t)&&(a+=t,!(n<=++r));)t=e[r];i.push({type:"number",value:a})}return i}function J(e){var t={expr:"",fmt:null,data:null},r="",n=e[0];if(1===e.length)if("string"==typeof n)r=n;else{if("number"!=typeof n)throw new F("错误的参数类型: ".concat(n," 类型为:").concat(C(n)));r=n.toString()}else{if(2!==e.length)throw new F("过多的参数, 该函数最多接受两个参数!");n=e[1];if(o=n,("[object Object]"!==Object.prototype.toString.call(o)||Array.isArray(o))&&!Array.isArray(n))throw new Error("参数错误, 不支持的参数");if("string"==typeof(r=e[0])){if(""===r.trim())throw new w("参数不可为空字符串");if("NaN"===r)throw new w("非法参数:".concat(r))}else if("number"==typeof r)r=r.toString();else if(void 0===r||Number.isNaN(r))throw new w("非法参数:".concat(r));t.data=n}var i,o=r.split("|");return 1===o.length?t.expr=o[0]:(t.expr=o[0],""!==(e=o[1]).trim()&&(t.fmt=Y(e))),null!==t.data&&t.data._fmt&&(n=Y(t.data._fmt),null===t.fmt?t.fmt=n:(i=t.fmt.map(function(e){return e.type}),n.forEach(function(e){i.includes(e.type)||t.fmt.push(e)}))),t}var K=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,Q=Math.ceil,I=Math.floor,U="[BigNumber Error] ",ee=U+"Number primitive has more than 15 significant digits: ",L=1e14,M=14,te=9007199254740991,re=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],z=1e7,G=1e9;function q(e){var t=0|e;return 0<e||e===t?t:t-1}function H(e){for(var t,r,n=1,i=e.length,o=e[0]+"";n<i;){for(t=e[n++]+"",r=M-t.length;r--;t="0"+t);o+=t}for(i=o.length;48===o.charCodeAt(--i););return o.slice(0,i+1||1)}function V(e,t){var r,n,i=e.c,o=t.c,u=e.s,l=t.s,e=e.e,t=t.e;if(!u||!l)return null;if(r=i&&!i[0],n=o&&!o[0],r||n)return r?n?0:-l:u;if(u!=l)return u;if(r=u<0,n=e==t,!i||!o)return n?0:!i^r?1:-1;if(!n)return t<e^r?1:-1;for(l=(e=i.length)<(t=o.length)?e:t,u=0;u<l;u++)if(i[u]!=o[u])return i[u]>o[u]^r?1:-1;return e==t?0:t<e^r?1:-1}function W(e,t,r,n){if(e<t||r<e||e!==I(e))throw Error(U+(n||"Argument")+("number"==typeof e?e<t||r<e?" out of range: ":" not an integer: ":" not a primitive number: ")+String(e))}function ne(e){var t=e.c.length-1;return q(e.e/M)==t&&e.c[t]%2!=0}function ie(e,t){return(1<e.length?e.charAt(0)+"."+e.slice(1):e)+(t<0?"e":"e+")+t}function Z(e,t,r){var n,i;if(t<0){for(i=r+".";++t;i+=r);e=i+e}else if(++t>(n=e.length)){for(i=r,t-=n;--t;i+=r);e+=i}else t<n&&(e=e.slice(0,t)+"."+e.slice(t));return e}var m=function F(e){var d,f,h,t,c,y,u,l,a,s,p,r=P.prototype={constructor:P,toString:null,valueOf:null},v=new P(1),w=20,m=4,g=-7,b=21,_=-1e7,O=1e7,E=!1,i=1,A=0,N={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},S="0123456789abcdefghijklmnopqrstuvwxyz",j=!0;function P(e,t){var r,n,i,o,u,l,a,c,s=this;if(!(s instanceof P))return new P(e,t);if(null==t){if(e&&!0===e._isBigNumber)return s.s=e.s,void(!e.c||e.e>O?s.c=s.e=null:e.e<_?s.c=[s.e=0]:(s.e=e.e,s.c=e.c.slice()));if((l="number"==typeof e)&&0*e==0){if(s.s=1/e<0?(e=-e,-1):1,e===~~e){for(o=0,u=e;10<=u;u/=10,o++);return void(O<o?s.c=s.e=null:(s.e=o,s.c=[e]))}c=String(e)}else{if(!K.test(c=String(e)))return h(s,c,l);s.s=45==c.charCodeAt(0)?(c=c.slice(1),-1):1}0<(u=(c=-1<(o=c.indexOf("."))?c.replace(".",""):c).search(/e/i))?(o<0&&(o=u),o+=+c.slice(u+1),c=c.substring(0,u)):o<0&&(o=c.length)}else{if(W(t,2,S.length,"Base"),10==t&&j)return B(s=new P(e),w+s.e+1,m);if(c=String(e),l="number"==typeof e){if(0*e!=0)return h(s,c,l,t);if(s.s=1/e<0?(c=c.slice(1),-1):1,P.DEBUG&&15<c.replace(/^0\.0*|\./,"").length)throw Error(ee+e)}else s.s=45===c.charCodeAt(0)?(c=c.slice(1),-1):1;for(r=S.slice(0,t),o=u=0,a=c.length;u<a;u++)if(r.indexOf(n=c.charAt(u))<0){if("."==n){if(o<u){o=a;continue}}else if(!i&&(c==c.toUpperCase()&&(c=c.toLowerCase())||c==c.toLowerCase()&&(c=c.toUpperCase()))){i=!0,u=-1,o=0;continue}return h(s,String(e),l,t)}l=!1,-1<(o=(c=f(c,t,10,s.s)).indexOf("."))?c=c.replace(".",""):o=c.length}for(u=0;48===c.charCodeAt(u);u++);for(a=c.length;48===c.charCodeAt(--a););if(c=c.slice(u,++a)){if(a-=u,l&&P.DEBUG&&15<a&&(te<e||e!==I(e)))throw Error(ee+s.s*e);if((o=o-u-1)>O)s.c=s.e=null;else if(o<_)s.c=[s.e=0];else{if(s.e=o,s.c=[],u=(o+1)%M,o<0&&(u+=M),u<a){for(u&&s.c.push(+c.slice(0,u)),a-=M;u<a;)s.c.push(+c.slice(u,u+=M));u=M-(c=c.slice(u)).length}else u-=a;for(;u--;c+="0");s.c.push(+c)}}else s.c=[s.e=0]}function x(e,t,r,n){for(var i,o,u=[0],l=0,a=e.length;l<a;){for(o=u.length;o--;u[o]*=t);for(u[0]+=n.indexOf(e.charAt(l++)),i=0;i<u.length;i++)u[i]>r-1&&(null==u[i+1]&&(u[i+1]=0),u[i+1]+=u[i]/r|0,u[i]%=r)}return u.reverse()}function R(e,t,r){var n,i,o,u=0,l=e.length,a=t%z,c=t/z|0;for(e=e.slice();l--;)u=((i=a*(o=e[l]%z)+(n=c*o+(o=e[l]/z|0)*a)%z*z+u)/r|0)+(n/z|0)+c*o,e[l]=i%r;return e=u?[u].concat(e):e}function T(e,t,r,n){var i,o;if(r!=n)o=n<r?1:-1;else for(i=o=0;i<r;i++)if(e[i]!=t[i]){o=e[i]>t[i]?1:-1;break}return o}function k(e,t,r,n){for(var i=0;r--;)e[r]-=i,i=e[r]<t[r]?1:0,e[r]=i*n+e[r]-t[r];for(;!e[0]&&1<e.length;e.splice(0,1));}function n(e,t,r,n){var i,o,u,l;if(null==r?r=m:W(r,0,8),!e.c)return e.toString();if(i=e.c[0],o=e.e,null==t)l=H(e.c),l=1==n||2==n&&(o<=g||b<=o)?ie(l,o):Z(l,o,"0");else if(r=(e=B(new P(e),t,r)).e,u=(l=H(e.c)).length,1==n||2==n&&(t<=r||r<=g)){for(;u<t;l+="0",u++);l=ie(l,r)}else if(t-=o,l=Z(l,r,"0"),u<r+1){if(0<--t)for(l+=".";t--;l+="0");}else if(0<(t+=r-u))for(r+1==u&&(l+=".");t--;l+="0");return e.s<0&&i?"-"+l:l}function o(e,t){for(var r,n=1,i=new P(e[0]);n<e.length;n++){if(!(r=new P(e[n])).s){i=r;break}t.call(i,r)&&(i=r)}return i}function D(e,t,r){for(var n=1,i=t.length;!t[--i];t.pop());for(i=t[0];10<=i;i/=10,n++);return(r=n+r*M-1)>O?e.c=e.e=null:r<_?e.c=[e.e=0]:(e.e=r,e.c=t),e}function B(e,t,r,n){var i,o,u,l,a,c,s,f=e.c,h=re;if(f){e:{for(i=1,l=f[0];10<=l;l/=10,i++);if((o=t-i)<0)o+=M,u=t,s=(a=f[c=0])/h[i-u-1]%10|0;else if((c=Q((o+1)/M))>=f.length){if(!n)break e;for(;f.length<=c;f.push(0));a=s=0,u=(o%=M)-M+(i=1)}else{for(a=l=f[c],i=1;10<=l;l/=10,i++);s=(u=(o%=M)-M+i)<0?0:a/h[i-u-1]%10|0}if(n=n||t<0||null!=f[c+1]||(u<0?a:a%h[i-u-1]),n=r<4?(s||n)&&(0==r||r==(e.s<0?3:2)):5<s||5==s&&(4==r||n||6==r&&(0<o?0<u?a/h[i-u]:0:f[c-1])%10&1||r==(e.s<0?8:7)),t<1||!f[0])return f.length=0,n?(t-=e.e+1,f[0]=h[(M-t%M)%M],e.e=-t||0):f[0]=e.e=0,e;if(0==o?(f.length=c,l=1,c--):(f.length=c+1,l=h[M-o],f[c]=0<u?I(a/h[i-u]%h[u])*l:0),n)for(;;){if(0==c){for(o=1,u=f[0];10<=u;u/=10,o++);for(u=f[0]+=l,l=1;10<=u;u/=10,l++);o!=l&&(e.e++,f[0]==L&&(f[0]=1));break}if(f[c]+=l,f[c]!=L)break;f[c--]=0,l=1}for(o=f.length;0===f[--o];f.pop());}e.e>O?e.c=e.e=null:e.e<_&&(e.c=[e.e=0])}return e}function $(e){var t,r=e.e;return null===r?e.toString():(t=H(e.c),t=r<=g||b<=r?ie(t,r):Z(t,r,"0"),e.s<0?"-"+t:t)}return P.clone=F,P.ROUND_UP=0,P.ROUND_DOWN=1,P.ROUND_CEIL=2,P.ROUND_FLOOR=3,P.ROUND_HALF_UP=4,P.ROUND_HALF_DOWN=5,P.ROUND_HALF_EVEN=6,P.ROUND_HALF_CEIL=7,P.ROUND_HALF_FLOOR=8,P.EUCLID=9,P.config=P.set=function(e){var t,r;if(null!=e){if("object"!=C(e))throw Error(U+"Object expected: "+e);if(e.hasOwnProperty(t="DECIMAL_PLACES")&&(W(r=e[t],0,G,t),w=r),e.hasOwnProperty(t="ROUNDING_MODE")&&(W(r=e[t],0,8,t),m=r),e.hasOwnProperty(t="EXPONENTIAL_AT")&&((r=e[t])&&r.pop?(W(r[0],-G,0,t),W(r[1],0,G,t),g=r[0],b=r[1]):(W(r,-G,G,t),g=-(b=r<0?-r:r))),e.hasOwnProperty(t="RANGE"))if((r=e[t])&&r.pop)W(r[0],-G,-1,t),W(r[1],1,G,t),_=r[0],O=r[1];else{if(W(r,-G,G,t),!r)throw Error(U+t+" cannot be zero: "+r);_=-(O=r<0?-r:r)}if(e.hasOwnProperty(t="CRYPTO")){if((r=e[t])!==!!r)throw Error(U+t+" not true or false: "+r);if(r){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw E=!r,Error(U+"crypto unavailable");E=r}else E=r}if(e.hasOwnProperty(t="MODULO_MODE")&&(W(r=e[t],0,9,t),i=r),e.hasOwnProperty(t="POW_PRECISION")&&(W(r=e[t],0,G,t),A=r),e.hasOwnProperty(t="FORMAT")){if("object"!=C(r=e[t]))throw Error(U+t+" not an object: "+r);N=r}if(e.hasOwnProperty(t="ALPHABET")){if("string"!=typeof(r=e[t])||/^.?$|[+\-.\s]|(.).*\1/.test(r))throw Error(U+t+" invalid: "+r);j="0123456789"==r.slice(0,10),S=r}}return{DECIMAL_PLACES:w,ROUNDING_MODE:m,EXPONENTIAL_AT:[g,b],RANGE:[_,O],CRYPTO:E,MODULO_MODE:i,POW_PRECISION:A,FORMAT:N,ALPHABET:S}},P.isBigNumber=function(e){if(!e||!0!==e._isBigNumber)return!1;if(!P.DEBUG)return!0;var t,r,n=e.c,i=e.e,o=e.s;e:if("[object Array]"=={}.toString.call(n)){if((1===o||-1===o)&&-G<=i&&i<=G&&i===I(i))if(0===n[0]){if(0===i&&1===n.length)return!0}else if((t=(i+1)%M)<1&&(t+=M),String(n[0]).length==t){for(t=0;t<n.length;t++)if((r=n[t])<0||L<=r||r!==I(r))break e;if(0!==r)return!0}}else if(null===n&&null===i&&(null===o||1===o||-1===o))return!0;throw Error(U+"Invalid BigNumber: "+e)},P.maximum=P.max=function(){return o(arguments,r.lt)},P.minimum=P.min=function(){return o(arguments,r.gt)},P.random=(t=9007199254740992,c=Math.random()*t&2097151?function(){return I(Math.random()*t)}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)},function(e){var t,r,n,i,o,u=0,l=[],a=new P(v);if(null==e?e=w:W(e,0,G),i=Q(e/M),E)if(crypto.getRandomValues){for(t=crypto.getRandomValues(new Uint32Array(i*=2));u<i;)9e15<=(o=131072*t[u]+(t[u+1]>>>11))?(r=crypto.getRandomValues(new Uint32Array(2)),t[u]=r[0],t[u+1]=r[1]):(l.push(o%1e14),u+=2);u=i/2}else{if(!crypto.randomBytes)throw E=!1,Error(U+"crypto unavailable");for(t=crypto.randomBytes(i*=7);u<i;)9e15<=(o=281474976710656*(31&t[u])+1099511627776*t[u+1]+4294967296*t[u+2]+16777216*t[u+3]+(t[u+4]<<16)+(t[u+5]<<8)+t[u+6])?crypto.randomBytes(7).copy(t,u):(l.push(o%1e14),u+=7);u=i/7}if(!E)for(;u<i;)(o=c())<9e15&&(l[u++]=o%1e14);for(i=l[--u],e%=M,i&&e&&(l[u]=I(i/(o=re[M-e]))*o);0===l[u];l.pop(),u--);if(u<0)l=[n=0];else{for(n=-1;0===l[0];l.splice(0,1),n-=M);for(u=1,o=l[0];10<=o;o/=10,u++);u<M&&(n-=M-u)}return a.e=n,a.c=l,a}),P.sum=function(){for(var e=1,t=arguments,r=new P(t[0]);e<t.length;)r=r.plus(t[e++]);return r},y="0123456789",f=function(e,t,r,n,i){var o,u,l,a,c,s,f,h,p=e.indexOf("."),v=w,g=m;for(0<=p&&(a=A,A=0,e=e.replace(".",""),s=(h=new P(t)).pow(e.length-p),A=a,h.c=x(Z(H(s.c),s.e,"0"),10,r,y),h.e=h.c.length),l=a=(f=x(e,t,r,i?(o=S,y):(o=y,S))).length;0==f[--a];f.pop());if(!f[0])return o.charAt(0);if(p<0?--l:(s.c=f,s.e=l,s.s=n,f=(s=d(s,h,v,g,r)).c,c=s.r,l=s.e),p=f[u=l+v+1],a=r/2,c=c||u<0||null!=f[u+1],c=g<4?(null!=p||c)&&(0==g||g==(s.s<0?3:2)):a<p||p==a&&(4==g||c||6==g&&1&f[u-1]||g==(s.s<0?8:7)),u<1||!f[0])e=c?Z(o.charAt(1),-v,o.charAt(0)):o.charAt(0);else{if(f.length=u,c)for(--r;++f[--u]>r;)f[u]=0,u||(++l,f=[1].concat(f));for(a=f.length;!f[--a];);for(p=0,e="";p<=a;e+=o.charAt(f[p++]));e=Z(e,l,o.charAt(0))}return e},d=function(e,t,r,n,i){var o,u,l,a,c,s,f,h,p,v,g,d,y,w,m,b,_,O=e.s==t.s?1:-1,E=e.c,A=t.c;if(!(E&&E[0]&&A&&A[0]))return new P(e.s&&t.s&&(E?!A||E[0]!=A[0]:A)?E&&0==E[0]||!A?0*O:O/0:NaN);for(p=(h=new P(O)).c=[],O=r+(u=e.e-t.e)+1,i||(i=L,u=q(e.e/M)-q(t.e/M),O=O/M|0),l=0;A[l]==(E[l]||0);l++);if(A[l]>(E[l]||0)&&u--,O<0)p.push(1),a=!0;else{for(w=E.length,b=A.length,O+=2,1<(c=I(i/(A[l=0]+1)))&&(A=R(A,c,i),E=R(E,c,i),b=A.length,w=E.length),y=b,g=(v=E.slice(0,b)).length;g<b;v[g++]=0);_=A.slice(),_=[0].concat(_),m=A[0],A[1]>=i/2&&m++;do{if(c=0,(o=T(A,v,b,g))<0){if(d=v[0],b!=g&&(d=d*i+(v[1]||0)),1<(c=I(d/m)))for(f=(s=R(A,c=i<=c?i-1:c,i)).length,g=v.length;1==T(s,v,f,g);)c--,k(s,b<f?_:A,f,i),f=s.length,o=1;else 0==c&&(o=c=1),f=(s=A.slice()).length;if(k(v,s=f<g?[0].concat(s):s,g,i),g=v.length,-1==o)for(;T(A,v,b,g)<1;)c++,k(v,b<g?_:A,g,i),g=v.length}else 0===o&&(c++,v=[0])}while(p[l++]=c,v[0]?v[g++]=E[y]||0:(v=[E[y]],g=1),(y++<w||null!=v[0])&&O--);a=null!=v[0],p[0]||p.splice(0,1)}if(i==L){for(l=1,O=p[0];10<=O;O/=10,l++);B(h,r+(h.e=l+u*M-1)+1,n,a)}else h.e=u,h.r=+a;return h},u=/^(-?)0([xbo])(?=\w[\w.]*$)/i,l=/^([^.]+)\.$/,a=/^\.([^.]+)$/,s=/^-?(Infinity|NaN)$/,p=/^\s*\+(?=[\w.])|^\s+|\s+$/g,h=function(e,t,r,n){var i,o=r?t:t.replace(p,"");if(s.test(o))e.s=isNaN(o)?null:o<0?-1:1;else{if(!r&&(o=o.replace(u,function(e,t,r){return i="x"==(r=r.toLowerCase())?16:"b"==r?2:8,n&&n!=i?e:t}),n&&(i=n,o=o.replace(l,"$1").replace(a,"0.$1")),t!=o))return new P(o,i);if(P.DEBUG)throw Error(U+"Not a"+(n?" base "+n:"")+" number: "+t);e.s=null}e.c=e.e=null},r.absoluteValue=r.abs=function(){var e=new P(this);return e.s<0&&(e.s=1),e},r.comparedTo=function(e,t){return V(this,new P(e,t))},r.decimalPlaces=r.dp=function(e,t){var r,n;if(null!=e)return W(e,0,G),null==t?t=m:W(t,0,8),B(new P(this),e+this.e+1,t);if(!(e=this.c))return null;if(r=((n=e.length-1)-q(this.e/M))*M,n=e[n])for(;n%10==0;n/=10,r--);return r=r<0?0:r},r.dividedBy=r.div=function(e,t){return d(this,new P(e,t),w,m)},r.dividedToIntegerBy=r.idiv=function(e,t){return d(this,new P(e,t),0,1)},r.exponentiatedBy=r.pow=function(e,t){var r,n,i,o,u,l,a,c,s=this;if((e=new P(e)).c&&!e.isInteger())throw Error(U+"Exponent not an integer: "+$(e));if(null!=t&&(t=new P(t)),u=14<e.e,!s.c||!s.c[0]||1==s.c[0]&&!s.e&&1==s.c.length||!e.c||!e.c[0])return c=new P(Math.pow(+$(s),u?2-ne(e):+$(e))),t?c.mod(t):c;if(l=e.s<0,t){if(t.c?!t.c[0]:!t.s)return new P(NaN);(n=!l&&s.isInteger()&&t.isInteger())&&(s=s.mod(t))}else{if(9<e.e&&(0<s.e||s.e<-1||(0==s.e?1<s.c[0]||u&&24e7<=s.c[1]:s.c[0]<8e13||u&&s.c[0]<=9999975e7)))return o=s.s<0&&ne(e)?-0:0,-1<s.e&&(o=1/o),new P(l?1/o:o);A&&(o=Q(A/M+2))}for(a=u?(r=new P(.5),l&&(e.s=1),ne(e)):(i=Math.abs(+$(e)))%2,c=new P(v);;){if(a){if(!(c=c.times(s)).c)break;o?c.c.length>o&&(c.c.length=o):n&&(c=c.mod(t))}if(i){if(0===(i=I(i/2)))break;a=i%2}else if(B(e=e.times(r),e.e+1,1),14<e.e)a=ne(e);else{if(0==(i=+$(e)))break;a=i%2}s=s.times(s),o?s.c&&s.c.length>o&&(s.c.length=o):n&&(s=s.mod(t))}return n?c:(l&&(c=v.div(c)),t?c.mod(t):o?B(c,A,m,void 0):c)},r.integerValue=function(e){var t=new P(this);return null==e?e=m:W(e,0,8),B(t,t.e+1,e)},r.isEqualTo=r.eq=function(e,t){return 0===V(this,new P(e,t))},r.isFinite=function(){return!!this.c},r.isGreaterThan=r.gt=function(e,t){return 0<V(this,new P(e,t))},r.isGreaterThanOrEqualTo=r.gte=function(e,t){return 1===(t=V(this,new P(e,t)))||0===t},r.isInteger=function(){return!!this.c&&q(this.e/M)>this.c.length-2},r.isLessThan=r.lt=function(e,t){return V(this,new P(e,t))<0},r.isLessThanOrEqualTo=r.lte=function(e,t){return-1===(t=V(this,new P(e,t)))||0===t},r.isNaN=function(){return!this.s},r.isNegative=function(){return this.s<0},r.isPositive=function(){return 0<this.s},r.isZero=function(){return!!this.c&&0==this.c[0]},r.minus=function(e,t){var r,n,i,o,u=this,l=u.s;if(t=(e=new P(e,t)).s,!l||!t)return new P(NaN);if(l!=t)return e.s=-t,u.plus(e);var a=u.e/M,c=e.e/M,s=u.c,f=e.c;if(!a||!c){if(!s||!f)return s?(e.s=-t,e):new P(f?u:NaN);if(!s[0]||!f[0])return f[0]?(e.s=-t,e):new P(s[0]?u:3==m?-0:0)}if(a=q(a),c=q(c),s=s.slice(),l=a-c){for((i=(o=l<0)?(l=-l,s):(c=a,f)).reverse(),t=l;t--;i.push(0));i.reverse()}else for(n=(o=(l=s.length)<(t=f.length))?l:t,l=t=0;t<n;t++)if(s[t]!=f[t]){o=s[t]<f[t];break}if(o&&(i=s,s=f,f=i,e.s=-e.s),0<(t=(n=f.length)-(r=s.length)))for(;t--;s[r++]=0);for(t=L-1;l<n;){if(s[--n]<f[n]){for(r=n;r&&!s[--r];s[r]=t);--s[r],s[n]+=L}s[n]-=f[n]}for(;0==s[0];s.splice(0,1),--c);return s[0]?D(e,s,c):(e.s=3==m?-1:1,e.c=[e.e=0],e)},r.modulo=r.mod=function(e,t){var r,n=this;return e=new P(e,t),!n.c||!e.s||e.c&&!e.c[0]?new P(NaN):!e.c||n.c&&!n.c[0]?new P(n):(9==i?(t=e.s,e.s=1,r=d(n,e,0,3),e.s=t,r.s*=t):r=d(n,e,0,i),(e=n.minus(r.times(e))).c[0]||1!=i||(e.s=n.s),e)},r.multipliedBy=r.times=function(e,t){var r,n,i,o,u,l,a,c,s,f,h,p=this,v=p.c,g=(e=new P(e,t)).c;if(!(v&&g&&v[0]&&g[0]))return!p.s||!e.s||v&&!v[0]&&!g||g&&!g[0]&&!v?e.c=e.e=e.s=null:(e.s*=p.s,v&&g?(e.c=[0],e.e=0):e.c=e.e=null),e;for(t=q(p.e/M)+q(e.e/M),e.s*=p.s,(l=v.length)<(p=g.length)&&(h=v,v=g,g=h,n=l,l=p,p=n),n=l+p,h=[];n--;h.push(0));for(n=p;0<=--n;){for(s=g[n]%1e7,f=g[n]/1e7|(r=0),i=n+(o=l);n<i;)r=((a=s*(a=v[--o]%1e7)+(u=f*a+(c=v[o]/1e7|0)*s)%1e7*1e7+h[i]+r)/1e14|0)+(u/1e7|0)+f*c,h[i--]=a%1e14;h[i]=r}return r?++t:h.splice(0,1),D(e,h,t)},r.negated=function(){var e=new P(this);return e.s=-e.s||null,e},r.plus=function(e,t){var r,n=this,i=n.s;if(t=(e=new P(e,t)).s,!i||!t)return new P(NaN);if(i!=t)return e.s=-t,n.minus(e);var o=n.e/M,u=e.e/M,l=n.c,a=e.c;if(!o||!u){if(!l||!a)return new P(i/0);if(!l[0]||!a[0])return a[0]?e:new P(l[0]?n:0*i)}if(o=q(o),u=q(u),l=l.slice(),i=o-u){for((r=0<i?(u=o,a):(i=-i,l)).reverse();i--;r.push(0));r.reverse()}for((i=l.length)-(t=a.length)<0&&(r=a,a=l,l=r,t=i),i=0;t;)i=(l[--t]=l[t]+a[t]+i)/L|0,l[t]=L===l[t]?0:l[t]%L;return i&&(l=[i].concat(l),++u),D(e,l,u)},r.precision=r.sd=function(e,t){var r,n;if(null!=e&&e!==!!e)return W(e,1,G),null==t?t=m:W(t,0,8),B(new P(this),e,t);if(!(t=this.c))return null;if(r=(n=t.length-1)*M+1,n=t[n]){for(;n%10==0;n/=10,r--);for(n=t[0];10<=n;n/=10,r++);}return r=e&&this.e+1>r?this.e+1:r},r.shiftedBy=function(e){return W(e,-te,te),this.times("1e"+e)},r.squareRoot=r.sqrt=function(){var e,t,r,n,i,o=this,u=o.c,l=o.s,a=o.e,c=w+4,s=new P("0.5");if(1!==l||!u||!u[0])return new P(!l||l<0&&(!u||u[0])?NaN:u?o:1/0);if((r=0==(l=Math.sqrt(+$(o)))||l==1/0?(((t=H(u)).length+a)%2==0&&(t+="0"),l=Math.sqrt(+t),a=q((a+1)/2)-(a<0||a%2),new P(t=l==1/0?"5e"+a:(t=l.toExponential()).slice(0,t.indexOf("e")+1)+a)):new P(l+"")).c[0])for((l=(a=r.e)+c)<3&&(l=0);;)if(i=r,r=s.times(i.plus(d(o,i,c,1))),H(i.c).slice(0,l)===(t=H(r.c)).slice(0,l)){if(r.e<a&&--l,"9999"!=(t=t.slice(l-3,l+1))&&(n||"4999"!=t)){+t&&(+t.slice(1)||"5"!=t.charAt(0))||(B(r,r.e+w+2,1),e=!r.times(r).eq(o));break}if(!n&&(B(i,i.e+w+2,0),i.times(i).eq(o))){r=i;break}c+=4,l+=4,n=1}return B(r,r.e+w+1,m,e)},r.toExponential=function(e,t){return null!=e&&(W(e,0,G),e++),n(this,e,t,1)},r.toFixed=function(e,t){return null!=e&&(W(e,0,G),e=e+this.e+1),n(this,e,t)},r.toFormat=function(e,t,r){if(null==r)null!=e&&t&&"object"==C(t)?(r=t,t=null):e&&"object"==C(e)?(r=e,e=t=null):r=N;else if("object"!=C(r))throw Error(U+"Argument not an object: "+r);if(e=this.toFixed(e,t),this.c){var n,t=e.split("."),i=+r.groupSize,o=+r.secondaryGroupSize,u=r.groupSeparator||"",l=t[0],t=t[1],a=this.s<0,c=a?l.slice(1):l,s=c.length;if(o&&(n=i,i=o,s-=o=n),0<i&&0<s){for(l=c.substr(0,n=s%i||i);n<s;n+=i)l+=u+c.substr(n,i);0<o&&(l+=u+c.slice(n)),a&&(l="-"+l)}e=t?l+(r.decimalSeparator||"")+((o=+r.fractionGroupSize)?t.replace(new RegExp("\\d{"+o+"}\\B","g"),"$&"+(r.fractionGroupSeparator||"")):t):l}return(r.prefix||"")+e+(r.suffix||"")},r.toFraction=function(e){var t,r,n,i,o,u,l,a,c,s,f=this,h=f.c;if(null!=e&&(!(l=new P(e)).isInteger()&&(l.c||1!==l.s)||l.lt(v)))throw Error(U+"Argument "+(l.isInteger()?"out of range: ":"not an integer: ")+$(l));if(!h)return new P(f);for(t=new P(v),c=r=new P(v),n=a=new P(v),h=H(h),o=t.e=h.length-f.e-1,t.c[0]=re[(u=o%M)<0?M+u:u],e=!e||0<l.comparedTo(t)?0<o?t:c:l,u=O,O=1/0,l=new P(h),a.c[0]=0;s=d(l,t,0,1),1!=(i=r.plus(s.times(n))).comparedTo(e);)r=n,n=i,c=a.plus(s.times(i=c)),a=i,t=l.minus(s.times(i=t)),l=i;return i=d(e.minus(r),n,0,1),a=a.plus(i.times(c)),r=r.plus(i.times(n)),a.s=c.s=f.s,h=d(c,n,o*=2,m).minus(f).abs().comparedTo(d(a,r,o,m).minus(f).abs())<1?[c,n]:[a,r],O=u,h},r.toNumber=function(){return+$(this)},r.toPrecision=function(e,t){return null!=e&&W(e,1,G),n(this,e,t,2)},r.toString=function(e){var t,r=this,n=r.s,i=r.e;return null===i?n?(t="Infinity",n<0&&(t="-"+t)):t="NaN":(t=null==e?i<=g||b<=i?ie(H(r.c),i):Z(H(r.c),i,"0"):10===e&&j?Z(H((r=B(new P(r),w+i+1,m)).c),r.e,"0"):(W(e,2,S.length,"Base"),f(Z(H(r.c),i,"0"),10,e,n,!0)),n<0&&r.c[0]&&(t="-"+t)),t},r.valueOf=r.toJSON=function(){return $(this)},r._isBigNumber=!0,r[Symbol.toStringTag]="BigNumber",r[Symbol.for("nodejs.util.inspect.custom")]=r.valueOf,null!=e&&P.set(e),P}();function oe(e,t,r){var n="";if(m.isBigNumber(e))n=e.toFixed();else if("string"!=typeof e)n=e.toString();else if(!0===r){r=$(e);if(null===r.num)return null;n=m(r.num).toFixed()}else n=m(e).toFixed();if("undefined"===n||"NaN"===n)return null;var i,o,u,l,a,c,s,f,h=null,p=null,v=null,g=null,d="~-";return t.forEach(function(e){var t=e.type;if("symbol"===t){if(![">=","<=","="].includes(e.value))throw new Error("错误的格式化参数:",e.value);p=e.value}else if("comma"===t)v=!0;else if("number"===t)h=e.value;else if("plus"===t)g=!0;else{if("round"!==t)throw new Error("错误的fmt Token");d=e.value}}),null!==h&&(r=n.split("."),e=r[0],t=1===r.length?"":r[1],r=p,u=h,s=d,l=i=e,f=(a=o=t).length,c={"~-":function(){a=o.slice(0,u)},"~+":function(){""===(a=o.slice(0,u))?l=i.slice(0,i.length-1)+(+i[i.length-1]+1):a=a.slice(0,u-1)+(+a[u-1]+1)},"~5":function(){a=o.slice(0,u);var e=+o[u];""===a?5<=e&&(l=i.slice(0,i.length-1)+(+i[i.length-1]+1)):5<=e&&(a=a.slice(0,u-1)+(+a[u-1]+1))},"~6":function(){a=o.slice(0,u);var e=""===(e=o.slice(+u+1,o.length))?0:parseInt(e),t=+o[u],r=+i[i.length-1];""===a?(6<=t||5==t&&0<e||5==t&&r%2!=0)&&(l=i.slice(0,i.length-1)+(+i[i.length-1]+1)):(r=+o[u-1],(6<=t||5==t&&0<e||5==t&&r%2!=0)&&(a=a.slice(0,u-1)+(+a[u-1]+1)))}},"<="===r?f<=u?a=o:c[s]&&c[s]():"="===r?f<u?a=o+"0".repeat(u-f):u<f&&c[s]&&c[s]():">="===r&&f<u&&(a=o+"0".repeat(u-f)),e=(c={intPart:l,decPart:a}).intPart,n=""===(t=c.decPart)?e:"".concat(e,".").concat(t)),null!==v&&(n=1<(s=n.split(".")).length?((r=s[0]).includes("-")?s[0]=r[0]+r.slice(1).replace(/(?=(?!^)(?:\d{3})+$)/g,","):s[0]=r.replace(/(?=(?!^)(?:\d{3})+$)/g,","),s.join(".")):(f=s[0]).includes("-")?f[0]+f.slice(1).replace(/(?=(?!^)(?:\d{3})+$)/g,","):f.replace(/(?=(?!^)(?:\d{3})+$)/g,",")),n=null===g||n.startsWith("-")?n:"+"+n}function ue(e,t){for(var r=1<arguments.length&&void 0!==t&&t,n=[],i=0,o=null,u=e.length;i<u;)if(o=e[i],/\s/.test(o))i++;else if("+-".includes(o)){var l=n[n.length-1];if(0===n.length||"+-".includes(l)||"("===l){var a=o;if(++i>=u){n.push(a);break}for(var o=e[i],c=0;/[^*/()\s]/.test(o)&&(["+","-"].includes(o)&&c++,!(2<c||!/[eE]/.test(a[a.length-1])&&"+-".includes(o)))&&(a+=o,!(++i>=u));)o=e[i];n.push(a)}else n.push(o),i++}else if("*/%()".includes(o))n.push(o),i++;else if(/[a-zA-Z_$]/.test(o)){for(var s="";/[\w_.\[\]"']/.test(o)&&(s+=o,!(++i>=u));)o=e[i];n.push(s)}else if(/\d/.test(o)){for(var f="",h=0,p=void 0,p=r?/[^*/()\s]/:/[\d.eE\+-]/;p.test(o)&&(["+","-"].includes(o)&&h++,!(1<h||!/[eE]/.test(f[f.length-1])&&"+-".includes(o)))&&(f+=o,!(++i>=u));)o=e[i];n.push(f)}return n}var r="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},le=Array.isArray,r="object"==C(r)&&r&&r.Object===Object&&r,n="object"==("undefined"==typeof self?"undefined":C(self))&&self&&self.Object===Object&&self,r=r||n||Function("return this")(),n=r.Symbol,s=Object.prototype,ae=s.hasOwnProperty,ce=s.toString,f=n?n.toStringTag:void 0;var se=Object.prototype.toString;var fe=function(e){var t=ae.call(e,f),r=e[f];try{var n=!(e[f]=void 0)}catch(e){}var i=ce.call(e);return n&&(t?e[f]=r:delete e[f]),i},he=function(e){return se.call(e)},pe=n?n.toStringTag:void 0;function ve(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":(pe&&pe in Object(e)?fe:he)(e)}var ge=ve,de=function(e){return null!=e&&"object"==C(e)};function ye(e){return"symbol"==C(e)||de(e)&&"[object Symbol]"==ge(e)}var we=le,me=ye,be=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,_e=/^\w*$/;function Oe(e,t){if(we(e))return!1;var r=C(e);return!("number"!=r&&"symbol"!=r&&"boolean"!=r&&null!=e&&!me(e))||(_e.test(e)||!be.test(e)||null!=t&&e in Object(t))}function Ee(e){var t=C(e);return null!=e&&("object"==t||"function"==t)}var Ae=ve,Ne=Ee;function Se(e){return!!Ne(e)&&("[object Function]"==(e=Ae(e))||"[object GeneratorFunction]"==e||"[object AsyncFunction]"==e||"[object Proxy]"==e)}var s=r["__core-js_shared__"],je=(s=/[^.]+$/.exec(s&&s.keys&&s.keys.IE_PROTO||""))?"Symbol(src)_1."+s:"";var Pe=Function.prototype.toString;var xe=Se,Re=function(e){return!!je&&je in e},Te=Ee,ke=function(e){if(null!=e){try{return Pe.call(e)}catch(e){}try{return e+""}catch(e){}}return""},De=/^\[object .+?Constructor\]$/,s=Function.prototype,p=Object.prototype,s=s.toString,p=p.hasOwnProperty,Be=RegExp("^"+s.call(p).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");var $e=function(e){return!(!Te(e)||Re(e))&&(xe(e)?Be:De).test(ke(e))},Fe=function(e,t){return null==e?void 0:e[t]};function Ce(e,t){return e=Fe(e,t),$e(e)?e:void 0}var s=Ce(Object,"create"),Ie=s;var Ue=s,Le=Object.prototype.hasOwnProperty;var Me=s,ze=Object.prototype.hasOwnProperty;var Ge=s;function qe(e){return e=this.has(e)&&delete this.__data__[e],this.size-=e?1:0,e}function He(e){var t,r=this.__data__;return Ue?"__lodash_hash_undefined__"===(t=r[e])?void 0:t:Le.call(r,e)?r[e]:void 0}function Ve(e){var t=this.__data__;return Me?void 0!==t[e]:ze.call(t,e)}function We(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=Ge&&void 0===t?"__lodash_hash_undefined__":t,this}function b(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}b.prototype.clear=function(){this.__data__=Ie?Ie(null):{},this.size=0},b.prototype.delete=qe,b.prototype.get=He,b.prototype.has=Ve,b.prototype.set=We;p=b;var Ze=function(e,t){return e===t||e!=e&&t!=t};function Xe(e,t){for(var r=e.length;r--;)if(Ze(e[r][0],t))return r;return-1}var Ye=Xe,Je=Array.prototype.splice;var Ke=Xe;var Qe=Xe;var et=Xe;function tt(e){var t=this.__data__;return!((e=Ye(t,e))<0)&&(e==t.length-1?t.pop():Je.call(t,e,1),--this.size,!0)}function rt(e){var t=this.__data__;return(e=Ke(t,e))<0?void 0:t[e][1]}function nt(e){return-1<Qe(this.__data__,e)}function it(e,t){var r=this.__data__,n=et(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this}function _(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}_.prototype.clear=function(){this.__data__=[],this.size=0},_.prototype.delete=tt,_.prototype.get=rt,_.prototype.has=nt,_.prototype.set=it;var s=_,r=Ce(r,"Map"),ot=p,ut=s,lt=r;var at=function(e){var t=C(e);return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e};function ct(e,t){return e=e.__data__,at(t)?e["string"==typeof t?"string":"hash"]:e.map}var st=ct;var ft=ct;var ht=ct;var pt=ct;function vt(e){return e=st(this,e).delete(e),this.size-=e?1:0,e}function gt(e){return ft(this,e).get(e)}function dt(e){return ht(this,e).has(e)}function yt(e,t){var r=pt(this,e),n=r.size;return r.set(e,t),this.size+=r.size==n?0:1,this}function O(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}O.prototype.clear=function(){this.size=0,this.__data__={hash:new ot,map:new(lt||ut),string:new ot}},O.prototype.delete=vt,O.prototype.get=gt,O.prototype.has=dt,O.prototype.set=yt;var wt=O;function mt(n,i){if("function"!=typeof n||null!=i&&"function"!=typeof i)throw new TypeError("Expected a function");function o(){var e=arguments,t=i?i.apply(this,e):e[0],r=o.cache;return r.has(t)?r.get(t):(e=n.apply(this,e),o.cache=r.set(t,e)||r,e)}return o.cache=new(mt.Cache||wt),o}mt.Cache=wt;var bt=mt;var _t=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Ot=/\\(\\)?/g,p=function(e){var t=(e=bt(e,function(e){return 500===t.size&&t.clear(),e})).cache;return e}(function(e){var i=[];return 46===e.charCodeAt(0)&&i.push(""),e.replace(_t,function(e,t,r,n){i.push(r?n.replace(Ot,"$1"):t||e)}),i});var Et=function(e,t){for(var r=-1,n=null==e?0:e.length,i=Array(n);++r<n;)i[r]=t(e[r],r,e);return i},At=le,Nt=ye,s=n?n.prototype:void 0,St=s?s.toString:void 0;var jt=function e(t){if("string"==typeof t)return t;if(At(t))return Et(t,e)+"";if(Nt(t))return St?St.call(t):"";var r=t+"";return"0"==r&&1/t==-1/0?"-0":r};var Pt=le,xt=Oe,Rt=p,Tt=function(e){return null==e?"":jt(e)};var kt=ye;var Dt=function(e,t){return Pt(e)?e:xt(e,t)?[e]:Rt(Tt(e))},Bt=function(e){if("string"==typeof e||kt(e))return e;var t=e+"";return"0"==t&&1/e==-1/0?"-0":t};var $t=function(e,t){for(var r=0,n=(t=Dt(t,e)).length;null!=e&&r<n;)e=e[Bt(t[r++])];return r&&r==n?e:void 0};var E=function(e,t,r){return void 0===(e=null==e?void 0:$t(e,t))?r:e};function Ft(e,t,r){var n=[];if(!d(t))throw new w("错误的填充数据:",t);Array.isArray(t)?n=t:n.push(t);for(var i=[],o=0;o<e.length;o++){var u=e[o];if(T.test(u)){if("undefined"===u||"NaN"===u)throw new w("key不应该为:".concat(u));for(var l=null,a=0;a<n.length;a++){var c=n[a],c=E(c,u);if(void 0!==c){l=c;break}}if(null===l)throw new w("token填充失败,请确认".concat(u,"存在"));if("string"==typeof l){if(""===l.trim())throw new w("token填充失败,".concat(u,"值不可为空字符"));if(!0===r){if(!R.test(l))throw new w("token填充失败,".concat(u,"值:").concat(l,"为非法单位数字"))}else if(!h(l))throw new w("token填充失败,".concat(u,"值:").concat(l,"为非法数字"))}l="string"!=typeof l?l.toString():l,i.push(l)}else i.push(u)}return i}function Ct(e,i){return e.map(function(e){if("var"!==e.type)return e;for(var t,r,n=0;n<i.length&&!g(t=E(i[n],e.value));n++);if("number"==typeof(r=t)||h(r))return{type:"number",value:t};throw new w("错误的填充值")})}function It(e){var r=null;return e.length,{tokens:e.map(function(e){var t=$(e);return null!==t.unit?(null==r&&(r=t.unit),t.num):e}),unit:r}}function Ut(e){for(var t,r=[],n=[],i=e;0<i.length;){var o=i.shift();if(k(o))if("("===o)r.push(o);else if(")"===o){for(var u=r.pop();"("!==u&&0<r.length;)n.push(u),u=r.pop();if("("!==u)throw"error: unmatched ()"}else{for(;t=r[r.length-1],D(o)<=D(t)&&0<r.length;)n.push(r.pop());r.push(o)}else n.push(o)}if(0<r.length){if(")"===r[r.length-1]||"("===r[r.length-1])throw"error: unmatched ()";for(;0<r.length;)n.push(r.pop())}return n}function Lt(e){for(var t=[];0<e.length;){var r=e.shift();if(k(r)){if(t.length<2)throw new y("错误的栈长度, 可能是无法计算的表达式");var n=t.pop(),i=t.pop();if("string"==typeof n&&!m.isBigNumber(n)){if(!h(n))throw new y("".concat(n,"不是一个合法的数字"));n=new m(n)}if("string"==typeof i&&!m.isBigNumber(i)){if(!h(i))throw new y("".concat(i,"不是一个合法的数字"));i=new m(i)}switch(r){case"+":t.push(i.plus(n));break;case"-":t.push(i.minus(n));break;case"*":t.push(i.times(n));break;case"/":t.push(i.div(n));break;case"%":t.push(i.mod(n))}}else t.push(r)}if(1!==t.length)throw"unvalid expression";var o=t[0];if((o=m.isBigNumber(o)?o:m(o)).isNaN())throw new y("计算结果为NaN");return o}return e.calc=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];var n,i=J(t),o=ue(i.expr,E(i,"data._unit",!1)),u=null,l=null;if(!0===E(i,"data._debug")&&(console.warn("======a-calc调试模式======"),console.warn(i),console.warn(o),i.fmt&&console.warn(i.fmt)),d(i.data)){var a=i.data,c=[],s=a._error,f=a._fillError,h=a._warn,p=E(a,"_unit",null);if(Array.isArray(a)?c=a:(c.push(u=a),g(a=E(u,"_fillData"))&&(Array.isArray(a)?c=[].concat(v(c),v(a)):c.push(a))),B(f,s))try{o=Ft(o,c,p),d(i.fmt)&&(i.fmt=Ct(i.fmt,c))}catch(e){if(e instanceof w)return g(h)&&!0===h&&console.warn(e),g(f)?f:s;throw e}else o=Ft(o,c,p),d(i.fmt)&&(i.fmt=Ct(i.fmt,c));!0===p&&(l=(a=It(o)).unit,o=a.tokens)}if(!0===E(i,"data._debug")&&(console.warn(o),console.warn("单位:".concat(l))),f=Ut(o),c=null,d(u)&&B(n,s))try{c=Lt(f)}catch(e){if(e instanceof y)return void 0!==h&&!0===h&&console.warn(e),s;throw e}else c=Lt(f);return null!==(c=d(i.fmt)?oe(c,i.fmt):null!==c?c.toFixed():null)&&null!==l&&(c+=l),c},e.fmt=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];var n=J(t),i=ue(n.expr,E(n,"data._unit",!1)),o=null,u=null;if(!0===E(n,"data._debug")&&(console.warn("======a-calc调试模式======"),console.warn(n),console.warn(i)),""===n.expr.trim()&&d(n.data)&&g(n.data._error))return n.data._error;if(2<i.length)throw new Error("fmt并非用于计算, 不能传入多个标识:".concat(n.expr));if(1!==i.length)throw new Error("fmt接收了一个无法被解析的标识");if(d(n.data)){var l,a=n.data,c=[],s=a._fillError,f=E(a,"_unit",null);if(Array.isArray(a)?c=a:(c.push(o=a),g(l=E(o,"_fillData"))&&(Array.isArray(l)?c=[].concat(v(c),v(l)):c.push(l))),B(s,a._error))try{i=Ft(i,c,f),d(n.fmt)&&(n.fmt=Ct(n.fmt,c))}catch(e){if(e instanceof w)return void 0!==o._warn&&!0===o._warn&&console.warn(e),o._fillError||o._error;throw e}else i=Ft(i,c,f),d(n.fmt)&&(n.fmt=Ct(n.fmt,c));!0===f&&(u=(l=It(i)).unit,i=l.tokens)}if(s=i[0],!0===f){if(!R.test(s))throw new w("token填充失败,".concat(key,"值:").concat(value,"为非法单位数字"))}else if(!h(s))throw new w("待格式化对象: ".concat(s," 不是数字"));return null!==(a=null!==n.fmt?oe(s,n.fmt,f):m(s).toFixed())&&null!==u&&(a+=u),a},e.version="0.0.80",Object.defineProperty(e,"__esModule",{value:!0}),e}({});
package/cjs/index.cjs ADDED
@@ -0,0 +1 @@
1
+ "use strict";function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function _createClass(e,t,r){return t&&_defineProperties(e.prototype,t),r&&_defineProperties(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&_setPrototypeOf(e,t)}function _getPrototypeOf(e){return(_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function _setPrototypeOf(e,t){return(_setPrototypeOf=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}function _construct(e,t,r){return(_construct=_isNativeReflectConstruct()?Reflect.construct:function(e,t,r){var n=[null];n.push.apply(n,t);t=new(Function.bind.apply(e,n));return r&&_setPrototypeOf(t,r.prototype),t}).apply(null,arguments)}function _isNativeFunction(e){return-1!==Function.toString.call(e).indexOf("[native code]")}function _wrapNativeSuper(e){var r="function"==typeof Map?new Map:void 0;return(_wrapNativeSuper=function(e){if(null===e||!_isNativeFunction(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==r){if(r.has(e))return r.get(e);r.set(e,t)}function t(){return _construct(e,arguments,_getPrototypeOf(this).constructor)}return t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),_setPrototypeOf(t,e)})(e)}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _possibleConstructorReturn(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(e)}function _createSuper(r){var n=_isNativeReflectConstruct();return function(){var e,t=_getPrototypeOf(r);return _possibleConstructorReturn(this,n?(e=_getPrototypeOf(this).constructor,Reflect.construct(t,arguments,e)):t.apply(this,arguments))}}function _toConsumableArray(e){return _arrayWithoutHoles(e)||_iterableToArray(e)||_unsupportedIterableToArray(e)||_nonIterableSpread()}function _arrayWithoutHoles(e){if(Array.isArray(e))return _arrayLikeToArray(e)}function _iterableToArray(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Map"===(r="Object"===r&&e.constructor?e.constructor.name:r)||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(e,t):void 0}}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];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.")}Object.defineProperty(exports,"__esModule",{value:!0});var RNumber=/^[+-]?\d[\d.]*(?:e\+|E\+|e-|E-|e|E)?\d*$/,RUnitNumber=/^[+-]?\d[\d.]*(?:e\+|E\+|e-|E-|e|E)?\d*\D*$/,RVar=/^[a-zA-z_][\w\[\]"'_.]*$/;function isOperator(e){return-1<"+-*/%()".indexOf(e)}function getPrioraty(e){switch(e){case"+":case"-":return 1;case"*":case"/":case"%":return 2;default:return 0}}function prioraty(e,t){return getPrioraty(e)<=getPrioraty(t)}function isObj(e){return"[object Object]"===Object.prototype.toString.call(e)&&!Array.isArray(e)}function notUndefined(e){return void 0!==e}function anyNotUndefined(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return t.some(function(e){return void 0!==e})}function notNull(e){return null!==e}function isNumber(e){return"number"==typeof e||isStrNumber(e)}function isStrNumber(e){return"string"==typeof e&&!!RNumber.test(e)}function splitUnitNum(e){for(var t,r,n=null,o=null,i=[/^([+-]?[\d.]+(?:e|E)(?:\+|-)?\d+)(\D*)$/,/^([+-]?[\d.]+)(\D*)$/],a=0;a<i.length;a++){var s=e.match(i[a]);if(s){t=s;break}}return t&&(o=t[1],""!==(r=t[2]).trim()&&(n=r)),{num:o,unit:n}}var CalculatorError=function(){_inherits(n,_wrapNativeSuper(Error));var r=_createSuper(n);function n(e){var t;return _classCallCheck(this,n),(t=r.call(this,e)).name="CalculatorError",t.message=e,t}return _createClass(n)}(),TokensFillError=function(){_inherits(n,_wrapNativeSuper(Error));var r=_createSuper(n);function n(e){var t;return _classCallCheck(this,n),(t=r.call(this,e)).name="TokensFillError",t.message=e,t}return _createClass(n)}(),ArgError=function(){_inherits(n,_wrapNativeSuper(Error));var r=_createSuper(n);function n(e){var t;return _classCallCheck(this,n),(t=r.call(this,e)).name="ArgError",t.message=e,t}return _createClass(n)}(),FmtError=function(){_inherits(n,_wrapNativeSuper(Error));var r=_createSuper(n);function n(e){var t;return _classCallCheck(this,n),(t=r.call(this,e)).name="FmtError",t.message=e,t}return _createClass(n)}();function fmtTokenizer(e){for(var t,r=0,n=e.length,o=[];r<n;)if(t=e[r],/\s/.test(t))r++;else if("+"===t)o.push({type:"plus",value:t}),r++;else if(","===t)o.push({type:"comma",value:t}),r++;else if("<>=".includes(t)){var i=t;++r>=n?o.push({type:"symbol",value:i}):(a=e[r],"<>=".includes(a)?(i+=a,o.push({type:"symbol",value:i}),r++):o.push({type:"symbol",value:t}))}else if("~"===t){var a=t;if(++r>=n)throw new FmtError("fmt格式化传参错误!错误解析字符:".concat(t));if(t=e[r],!"+-56".includes(t))throw new FmtError("fmt格式化传参错误!错误解析字符:".concat(t));a+=t,o.push({type:"round",value:a}),r++}else if(/[a-zA-Z_]/.test(t)){for(var s="";/[\w_.\[\]"']/.test(t)&&(s+=t,!(n<=++r));)t=e[r];o.push({type:"var",value:s})}else if(/\d/.test(t)){for(var l="";/[\d.]/.test(t)&&(l+=t,!(n<=++r));)t=e[r];o.push({type:"number",value:l})}return o}function parseArgs(e){var t={expr:"",fmt:null,data:null},r="",n=e[0];if(1===e.length)if("string"==typeof n)r=n;else{if("number"!=typeof n)throw new ArgError("错误的参数类型: ".concat(n," 类型为:").concat(_typeof(n)));r=n.toString()}else{if(2!==e.length)throw new ArgError("过多的参数, 该函数最多接受两个参数!");n=e[1];if(!isObj(n)&&!Array.isArray(n))throw new Error("参数错误, 不支持的参数");if("string"==typeof(r=e[0])){if(""===r.trim())throw new TokensFillError("参数不可为空字符串");if("NaN"===r)throw new TokensFillError("非法参数:".concat(r))}else if("number"==typeof r)r=r.toString();else if(void 0===r||Number.isNaN(r))throw new TokensFillError("非法参数:".concat(r));t.data=n}var o,e=r.split("|");return 1===e.length?t.expr=e[0]:(t.expr=e[0],""!==(n=e[1]).trim()&&(t.fmt=fmtTokenizer(n))),null!==t.data&&t.data._fmt&&(r=fmtTokenizer(t.data._fmt),null===t.fmt?t.fmt=r:(o=t.fmt.map(function(e){return e.type}),r.forEach(function(e){o.includes(e.type)||t.fmt.push(e)}))),t}var isNumeric=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,mathceil=Math.ceil,mathfloor=Math.floor,bignumberError="[BigNumber Error] ",tooManyDigits=bignumberError+"Number primitive has more than 15 significant digits: ",BASE=1e14,LOG_BASE=14,MAX_SAFE_INTEGER=9007199254740991,POWS_TEN=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],SQRT_BASE=1e7,MAX=1e9;function clone(e){var m,f,h,t,c,y,a,s,l,u,p,r=T.prototype={constructor:T,toString:null,valueOf:null},g=new T(1),b=20,d=4,_=-7,v=21,S=-1e7,$=1e7,E=!1,o=1,w=0,C={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},O="0123456789abcdefghijklmnopqrstuvwxyz",A=!0;function T(e,t){var r,n,o,i,a,s,l,c,u=this;if(!(u instanceof T))return new T(e,t);if(null==t){if(e&&!0===e._isBigNumber)return u.s=e.s,void(!e.c||e.e>$?u.c=u.e=null:e.e<S?u.c=[u.e=0]:(u.e=e.e,u.c=e.c.slice()));if((s="number"==typeof e)&&0*e==0){if(u.s=1/e<0?(e=-e,-1):1,e===~~e){for(i=0,a=e;10<=a;a/=10,i++);return void($<i?u.c=u.e=null:(u.e=i,u.c=[e]))}c=String(e)}else{if(!isNumeric.test(c=String(e)))return h(u,c,s);u.s=45==c.charCodeAt(0)?(c=c.slice(1),-1):1}0<(a=(c=-1<(i=c.indexOf("."))?c.replace(".",""):c).search(/e/i))?(i<0&&(i=a),i+=+c.slice(a+1),c=c.substring(0,a)):i<0&&(i=c.length)}else{if(intCheck(t,2,O.length,"Base"),10==t&&A)return M(u=new T(e),b+u.e+1,d);if(c=String(e),s="number"==typeof e){if(0*e!=0)return h(u,c,s,t);if(u.s=1/e<0?(c=c.slice(1),-1):1,T.DEBUG&&15<c.replace(/^0\.0*|\./,"").length)throw Error(tooManyDigits+e)}else u.s=45===c.charCodeAt(0)?(c=c.slice(1),-1):1;for(r=O.slice(0,t),i=a=0,l=c.length;a<l;a++)if(r.indexOf(n=c.charAt(a))<0){if("."==n){if(i<a){i=l;continue}}else if(!o&&(c==c.toUpperCase()&&(c=c.toLowerCase())||c==c.toLowerCase()&&(c=c.toUpperCase()))){o=!0,a=-1,i=0;continue}return h(u,String(e),s,t)}s=!1,-1<(i=(c=f(c,t,10,u.s)).indexOf("."))?c=c.replace(".",""):i=c.length}for(a=0;48===c.charCodeAt(a);a++);for(l=c.length;48===c.charCodeAt(--l););if(c=c.slice(a,++l)){if(l-=a,s&&T.DEBUG&&15<l&&(MAX_SAFE_INTEGER<e||e!==mathfloor(e)))throw Error(tooManyDigits+u.s*e);if((i=i-a-1)>$)u.c=u.e=null;else if(i<S)u.c=[u.e=0];else{if(u.e=i,u.c=[],a=(i+1)%LOG_BASE,i<0&&(a+=LOG_BASE),a<l){for(a&&u.c.push(+c.slice(0,a)),l-=LOG_BASE;a<l;)u.c.push(+c.slice(a,a+=LOG_BASE));a=LOG_BASE-(c=c.slice(a)).length}else a-=l;for(;a--;c+="0");u.c.push(+c)}}else u.c=[u.e=0]}function N(e,t,r,n){for(var o,i,a=[0],s=0,l=e.length;s<l;){for(i=a.length;i--;a[i]*=t);for(a[0]+=n.indexOf(e.charAt(s++)),o=0;o<a.length;o++)a[o]>r-1&&(null==a[o+1]&&(a[o+1]=0),a[o+1]+=a[o]/r|0,a[o]%=r)}return a.reverse()}function P(e,t,r){var n,o,i,a=0,s=e.length,l=t%SQRT_BASE,c=t/SQRT_BASE|0;for(e=e.slice();s--;)a=((o=l*(i=e[s]%SQRT_BASE)+(n=c*i+(i=e[s]/SQRT_BASE|0)*l)%SQRT_BASE*SQRT_BASE+a)/r|0)+(n/SQRT_BASE|0)+c*i,e[s]=o%r;return e=a?[a].concat(e):e}function k(e,t,r,n){var o,i;if(r!=n)i=n<r?1:-1;else for(o=i=0;o<r;o++)if(e[o]!=t[o]){i=e[o]>t[o]?1:-1;break}return i}function G(e,t,r,n){for(var o=0;r--;)e[r]-=o,o=e[r]<t[r]?1:0,e[r]=o*n+e[r]-t[r];for(;!e[0]&&1<e.length;e.splice(0,1));}function n(e,t,r,n){var o,i,a,s;if(null==r?r=d:intCheck(r,0,8),!e.c)return e.toString();if(o=e.c[0],i=e.e,null==t)s=coeffToString(e.c),s=1==n||2==n&&(i<=_||v<=i)?toExponential(s,i):toFixedPoint(s,i,"0");else if(r=(e=M(new T(e),t,r)).e,a=(s=coeffToString(e.c)).length,1==n||2==n&&(t<=r||r<=_)){for(;a<t;s+="0",a++);s=toExponential(s,r)}else if(t-=i,s=toFixedPoint(s,r,"0"),a<r+1){if(0<--t)for(s+=".";t--;s+="0");}else if(0<(t+=r-a))for(r+1==a&&(s+=".");t--;s+="0");return e.s<0&&o?"-"+s:s}function i(e,t){for(var r,n=1,o=new T(e[0]);n<e.length;n++){if(!(r=new T(e[n])).s){o=r;break}t.call(o,r)&&(o=r)}return o}function B(e,t,r){for(var n=1,o=t.length;!t[--o];t.pop());for(o=t[0];10<=o;o/=10,n++);return(r=n+r*LOG_BASE-1)>$?e.c=e.e=null:r<S?e.c=[e.e=0]:(e.e=r,e.c=t),e}function M(e,t,r,n){var o,i,a,s,l,c,u,f=e.c,h=POWS_TEN;if(f){e:{for(o=1,s=f[0];10<=s;s/=10,o++);if((i=t-o)<0)i+=LOG_BASE,a=t,u=(l=f[c=0])/h[o-a-1]%10|0;else if((c=mathceil((i+1)/LOG_BASE))>=f.length){if(!n)break e;for(;f.length<=c;f.push(0));l=u=0,a=(i%=LOG_BASE)-LOG_BASE+(o=1)}else{for(l=s=f[c],o=1;10<=s;s/=10,o++);u=(a=(i%=LOG_BASE)-LOG_BASE+o)<0?0:l/h[o-a-1]%10|0}if(n=n||t<0||null!=f[c+1]||(a<0?l:l%h[o-a-1]),n=r<4?(u||n)&&(0==r||r==(e.s<0?3:2)):5<u||5==u&&(4==r||n||6==r&&(0<i?0<a?l/h[o-a]:0:f[c-1])%10&1||r==(e.s<0?8:7)),t<1||!f[0])return f.length=0,n?(t-=e.e+1,f[0]=h[(LOG_BASE-t%LOG_BASE)%LOG_BASE],e.e=-t||0):f[0]=e.e=0,e;if(0==i?(f.length=c,s=1,c--):(f.length=c+1,s=h[LOG_BASE-i],f[c]=0<a?mathfloor(l/h[o-a]%h[a])*s:0),n)for(;;){if(0==c){for(i=1,a=f[0];10<=a;a/=10,i++);for(a=f[0]+=s,s=1;10<=a;a/=10,s++);i!=s&&(e.e++,f[0]==BASE&&(f[0]=1));break}if(f[c]+=s,f[c]!=BASE)break;f[c--]=0,s=1}for(i=f.length;0===f[--i];f.pop());}e.e>$?e.c=e.e=null:e.e<S&&(e.c=[e.e=0])}return e}function j(e){var t,r=e.e;return null===r?e.toString():(t=coeffToString(e.c),t=r<=_||v<=r?toExponential(t,r):toFixedPoint(t,r,"0"),e.s<0?"-"+t:t)}return T.clone=clone,T.ROUND_UP=0,T.ROUND_DOWN=1,T.ROUND_CEIL=2,T.ROUND_FLOOR=3,T.ROUND_HALF_UP=4,T.ROUND_HALF_DOWN=5,T.ROUND_HALF_EVEN=6,T.ROUND_HALF_CEIL=7,T.ROUND_HALF_FLOOR=8,T.EUCLID=9,T.config=T.set=function(e){var t,r;if(null!=e){if("object"!=_typeof(e))throw Error(bignumberError+"Object expected: "+e);if(e.hasOwnProperty(t="DECIMAL_PLACES")&&(intCheck(r=e[t],0,MAX,t),b=r),e.hasOwnProperty(t="ROUNDING_MODE")&&(intCheck(r=e[t],0,8,t),d=r),e.hasOwnProperty(t="EXPONENTIAL_AT")&&((r=e[t])&&r.pop?(intCheck(r[0],-MAX,0,t),intCheck(r[1],0,MAX,t),_=r[0],v=r[1]):(intCheck(r,-MAX,MAX,t),_=-(v=r<0?-r:r))),e.hasOwnProperty(t="RANGE"))if((r=e[t])&&r.pop)intCheck(r[0],-MAX,-1,t),intCheck(r[1],1,MAX,t),S=r[0],$=r[1];else{if(intCheck(r,-MAX,MAX,t),!r)throw Error(bignumberError+t+" cannot be zero: "+r);S=-($=r<0?-r:r)}if(e.hasOwnProperty(t="CRYPTO")){if((r=e[t])!==!!r)throw Error(bignumberError+t+" not true or false: "+r);if(r){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw E=!r,Error(bignumberError+"crypto unavailable");E=r}else E=r}if(e.hasOwnProperty(t="MODULO_MODE")&&(intCheck(r=e[t],0,9,t),o=r),e.hasOwnProperty(t="POW_PRECISION")&&(intCheck(r=e[t],0,MAX,t),w=r),e.hasOwnProperty(t="FORMAT")){if("object"!=_typeof(r=e[t]))throw Error(bignumberError+t+" not an object: "+r);C=r}if(e.hasOwnProperty(t="ALPHABET")){if("string"!=typeof(r=e[t])||/^.?$|[+\-.\s]|(.).*\1/.test(r))throw Error(bignumberError+t+" invalid: "+r);A="0123456789"==r.slice(0,10),O=r}}return{DECIMAL_PLACES:b,ROUNDING_MODE:d,EXPONENTIAL_AT:[_,v],RANGE:[S,$],CRYPTO:E,MODULO_MODE:o,POW_PRECISION:w,FORMAT:C,ALPHABET:O}},T.isBigNumber=function(e){if(!e||!0!==e._isBigNumber)return!1;if(!T.DEBUG)return!0;var t,r,n=e.c,o=e.e,i=e.s;e:if("[object Array]"=={}.toString.call(n)){if((1===i||-1===i)&&-MAX<=o&&o<=MAX&&o===mathfloor(o))if(0===n[0]){if(0===o&&1===n.length)return!0}else if((t=(o+1)%LOG_BASE)<1&&(t+=LOG_BASE),String(n[0]).length==t){for(t=0;t<n.length;t++)if((r=n[t])<0||BASE<=r||r!==mathfloor(r))break e;if(0!==r)return!0}}else if(null===n&&null===o&&(null===i||1===i||-1===i))return!0;throw Error(bignumberError+"Invalid BigNumber: "+e)},T.maximum=T.max=function(){return i(arguments,r.lt)},T.minimum=T.min=function(){return i(arguments,r.gt)},T.random=(t=9007199254740992,c=Math.random()*t&2097151?function(){return mathfloor(Math.random()*t)}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)},function(e){var t,r,n,o,i,a=0,s=[],l=new T(g);if(null==e?e=b:intCheck(e,0,MAX),o=mathceil(e/LOG_BASE),E)if(crypto.getRandomValues){for(t=crypto.getRandomValues(new Uint32Array(o*=2));a<o;)9e15<=(i=131072*t[a]+(t[a+1]>>>11))?(r=crypto.getRandomValues(new Uint32Array(2)),t[a]=r[0],t[a+1]=r[1]):(s.push(i%1e14),a+=2);a=o/2}else{if(!crypto.randomBytes)throw E=!1,Error(bignumberError+"crypto unavailable");for(t=crypto.randomBytes(o*=7);a<o;)9e15<=(i=281474976710656*(31&t[a])+1099511627776*t[a+1]+4294967296*t[a+2]+16777216*t[a+3]+(t[a+4]<<16)+(t[a+5]<<8)+t[a+6])?crypto.randomBytes(7).copy(t,a):(s.push(i%1e14),a+=7);a=o/7}if(!E)for(;a<o;)(i=c())<9e15&&(s[a++]=i%1e14);for(o=s[--a],e%=LOG_BASE,o&&e&&(i=POWS_TEN[LOG_BASE-e],s[a]=mathfloor(o/i)*i);0===s[a];s.pop(),a--);if(a<0)s=[n=0];else{for(n=-1;0===s[0];s.splice(0,1),n-=LOG_BASE);for(a=1,i=s[0];10<=i;i/=10,a++);a<LOG_BASE&&(n-=LOG_BASE-a)}return l.e=n,l.c=s,l}),T.sum=function(){for(var e=1,t=arguments,r=new T(t[0]);e<t.length;)r=r.plus(t[e++]);return r},y="0123456789",f=function(e,t,r,n,o){var i,a,s,l,c,u,f,h,p=e.indexOf("."),g=b,_=d;for(0<=p&&(l=w,w=0,e=e.replace(".",""),u=(h=new T(t)).pow(e.length-p),w=l,h.c=N(toFixedPoint(coeffToString(u.c),u.e,"0"),10,r,y),h.e=h.c.length),s=l=(f=N(e,t,r,o?(i=O,y):(i=y,O))).length;0==f[--l];f.pop());if(!f[0])return i.charAt(0);if(p<0?--s:(u.c=f,u.e=s,u.s=n,f=(u=m(u,h,g,_,r)).c,c=u.r,s=u.e),p=f[a=s+g+1],l=r/2,c=c||a<0||null!=f[a+1],c=_<4?(null!=p||c)&&(0==_||_==(u.s<0?3:2)):l<p||p==l&&(4==_||c||6==_&&1&f[a-1]||_==(u.s<0?8:7)),a<1||!f[0])e=c?toFixedPoint(i.charAt(1),-g,i.charAt(0)):i.charAt(0);else{if(f.length=a,c)for(--r;++f[--a]>r;)f[a]=0,a||(++s,f=[1].concat(f));for(l=f.length;!f[--l];);for(p=0,e="";p<=l;e+=i.charAt(f[p++]));e=toFixedPoint(e,s,i.charAt(0))}return e},m=function(e,t,r,n,o){var i,a,s,l,c,u,f,h,p,g,_,m,y,b,d,v,S,$=e.s==t.s?1:-1,E=e.c,w=t.c;if(!(E&&E[0]&&w&&w[0]))return new T(e.s&&t.s&&(E?!w||E[0]!=w[0]:w)?E&&0==E[0]||!w?0*$:$/0:NaN);for(p=(h=new T($)).c=[],$=r+(a=e.e-t.e)+1,o||(o=BASE,a=bitFloor(e.e/LOG_BASE)-bitFloor(t.e/LOG_BASE),$=$/LOG_BASE|0),s=0;w[s]==(E[s]||0);s++);if(w[s]>(E[s]||0)&&a--,$<0)p.push(1),l=!0;else{for(b=E.length,v=w.length,$+=2,1<(c=mathfloor(o/(w[s=0]+1)))&&(w=P(w,c,o),E=P(E,c,o),v=w.length,b=E.length),y=v,_=(g=E.slice(0,v)).length;_<v;g[_++]=0);S=w.slice(),S=[0].concat(S),d=w[0],w[1]>=o/2&&d++;do{if(c=0,(i=k(w,g,v,_))<0){if(m=g[0],v!=_&&(m=m*o+(g[1]||0)),1<(c=mathfloor(m/d)))for(f=(u=P(w,c=o<=c?o-1:c,o)).length,_=g.length;1==k(u,g,f,_);)c--,G(u,v<f?S:w,f,o),f=u.length,i=1;else 0==c&&(i=c=1),f=(u=w.slice()).length;if(G(g,u=f<_?[0].concat(u):u,_,o),_=g.length,-1==i)for(;k(w,g,v,_)<1;)c++,G(g,v<_?S:w,_,o),_=g.length}else 0===i&&(c++,g=[0])}while(p[s++]=c,g[0]?g[_++]=E[y]||0:(g=[E[y]],_=1),(y++<b||null!=g[0])&&$--);l=null!=g[0],p[0]||p.splice(0,1)}if(o==BASE){for(s=1,$=p[0];10<=$;$/=10,s++);M(h,r+(h.e=s+a*LOG_BASE-1)+1,n,l)}else h.e=a,h.r=+l;return h},a=/^(-?)0([xbo])(?=\w[\w.]*$)/i,s=/^([^.]+)\.$/,l=/^\.([^.]+)$/,u=/^-?(Infinity|NaN)$/,p=/^\s*\+(?=[\w.])|^\s+|\s+$/g,h=function(e,t,r,n){var o,i=r?t:t.replace(p,"");if(u.test(i))e.s=isNaN(i)?null:i<0?-1:1;else{if(!r&&(i=i.replace(a,function(e,t,r){return o="x"==(r=r.toLowerCase())?16:"b"==r?2:8,n&&n!=o?e:t}),n&&(o=n,i=i.replace(s,"$1").replace(l,"0.$1")),t!=i))return new T(i,o);if(T.DEBUG)throw Error(bignumberError+"Not a"+(n?" base "+n:"")+" number: "+t);e.s=null}e.c=e.e=null},r.absoluteValue=r.abs=function(){var e=new T(this);return e.s<0&&(e.s=1),e},r.comparedTo=function(e,t){return compare(this,new T(e,t))},r.decimalPlaces=r.dp=function(e,t){var r,n;if(null!=e)return intCheck(e,0,MAX),null==t?t=d:intCheck(t,0,8),M(new T(this),e+this.e+1,t);if(!(e=this.c))return null;if(r=((n=e.length-1)-bitFloor(this.e/LOG_BASE))*LOG_BASE,n=e[n])for(;n%10==0;n/=10,r--);return r=r<0?0:r},r.dividedBy=r.div=function(e,t){return m(this,new T(e,t),b,d)},r.dividedToIntegerBy=r.idiv=function(e,t){return m(this,new T(e,t),0,1)},r.exponentiatedBy=r.pow=function(e,t){var r,n,o,i,a,s,l,c,u=this;if((e=new T(e)).c&&!e.isInteger())throw Error(bignumberError+"Exponent not an integer: "+j(e));if(null!=t&&(t=new T(t)),a=14<e.e,!u.c||!u.c[0]||1==u.c[0]&&!u.e&&1==u.c.length||!e.c||!e.c[0])return c=new T(Math.pow(+j(u),a?2-isOdd(e):+j(e))),t?c.mod(t):c;if(s=e.s<0,t){if(t.c?!t.c[0]:!t.s)return new T(NaN);(n=!s&&u.isInteger()&&t.isInteger())&&(u=u.mod(t))}else{if(9<e.e&&(0<u.e||u.e<-1||(0==u.e?1<u.c[0]||a&&24e7<=u.c[1]:u.c[0]<8e13||a&&u.c[0]<=9999975e7)))return i=u.s<0&&isOdd(e)?-0:0,-1<u.e&&(i=1/i),new T(s?1/i:i);w&&(i=mathceil(w/LOG_BASE+2))}for(l=a?(r=new T(.5),s&&(e.s=1),isOdd(e)):(o=Math.abs(+j(e)))%2,c=new T(g);;){if(l){if(!(c=c.times(u)).c)break;i?c.c.length>i&&(c.c.length=i):n&&(c=c.mod(t))}if(o){if(0===(o=mathfloor(o/2)))break;l=o%2}else if(M(e=e.times(r),e.e+1,1),14<e.e)l=isOdd(e);else{if(0===(o=+j(e)))break;l=o%2}u=u.times(u),i?u.c&&u.c.length>i&&(u.c.length=i):n&&(u=u.mod(t))}return n?c:(s&&(c=g.div(c)),t?c.mod(t):i?M(c,w,d,void 0):c)},r.integerValue=function(e){var t=new T(this);return null==e?e=d:intCheck(e,0,8),M(t,t.e+1,e)},r.isEqualTo=r.eq=function(e,t){return 0===compare(this,new T(e,t))},r.isFinite=function(){return!!this.c},r.isGreaterThan=r.gt=function(e,t){return 0<compare(this,new T(e,t))},r.isGreaterThanOrEqualTo=r.gte=function(e,t){return 1===(t=compare(this,new T(e,t)))||0===t},r.isInteger=function(){return!!this.c&&bitFloor(this.e/LOG_BASE)>this.c.length-2},r.isLessThan=r.lt=function(e,t){return compare(this,new T(e,t))<0},r.isLessThanOrEqualTo=r.lte=function(e,t){return-1===(t=compare(this,new T(e,t)))||0===t},r.isNaN=function(){return!this.s},r.isNegative=function(){return this.s<0},r.isPositive=function(){return 0<this.s},r.isZero=function(){return!!this.c&&0==this.c[0]},r.minus=function(e,t){var r,n,o,i,a=this,s=a.s;if(t=(e=new T(e,t)).s,!s||!t)return new T(NaN);if(s!=t)return e.s=-t,a.plus(e);var l=a.e/LOG_BASE,c=e.e/LOG_BASE,u=a.c,f=e.c;if(!l||!c){if(!u||!f)return u?(e.s=-t,e):new T(f?a:NaN);if(!u[0]||!f[0])return f[0]?(e.s=-t,e):new T(u[0]?a:3==d?-0:0)}if(l=bitFloor(l),c=bitFloor(c),u=u.slice(),s=l-c){for((o=(i=s<0)?(s=-s,u):(c=l,f)).reverse(),t=s;t--;o.push(0));o.reverse()}else for(n=(i=(s=u.length)<(t=f.length))?s:t,s=t=0;t<n;t++)if(u[t]!=f[t]){i=u[t]<f[t];break}if(i&&(o=u,u=f,f=o,e.s=-e.s),0<(t=(n=f.length)-(r=u.length)))for(;t--;u[r++]=0);for(t=BASE-1;s<n;){if(u[--n]<f[n]){for(r=n;r&&!u[--r];u[r]=t);--u[r],u[n]+=BASE}u[n]-=f[n]}for(;0==u[0];u.splice(0,1),--c);return u[0]?B(e,u,c):(e.s=3==d?-1:1,e.c=[e.e=0],e)},r.modulo=r.mod=function(e,t){var r,n=this;return e=new T(e,t),!n.c||!e.s||e.c&&!e.c[0]?new T(NaN):!e.c||n.c&&!n.c[0]?new T(n):(9==o?(t=e.s,e.s=1,r=m(n,e,0,3),e.s=t,r.s*=t):r=m(n,e,0,o),(e=n.minus(r.times(e))).c[0]||1!=o||(e.s=n.s),e)},r.multipliedBy=r.times=function(e,t){var r,n,o,i,a,s,l,c,u,f,h,p,g,_=this,m=_.c,y=(e=new T(e,t)).c;if(!(m&&y&&m[0]&&y[0]))return!_.s||!e.s||m&&!m[0]&&!y||y&&!y[0]&&!m?e.c=e.e=e.s=null:(e.s*=_.s,m&&y?(e.c=[0],e.e=0):e.c=e.e=null),e;for(t=bitFloor(_.e/LOG_BASE)+bitFloor(e.e/LOG_BASE),e.s*=_.s,(s=m.length)<(_=y.length)&&(h=m,m=y,y=h,n=s,s=_,_=n),n=s+_,h=[];n--;h.push(0));for(p=BASE,g=SQRT_BASE,n=_;0<=--n;){for(u=y[n]%g,f=y[n]/g|(r=0),o=n+(i=s);n<o;)r=((l=u*(l=m[--i]%g)+(a=f*l+(c=m[i]/g|0)*u)%g*g+h[o]+r)/p|0)+(a/g|0)+f*c,h[o--]=l%p;h[o]=r}return r?++t:h.splice(0,1),B(e,h,t)},r.negated=function(){var e=new T(this);return e.s=-e.s||null,e},r.plus=function(e,t){var r,n=this,o=n.s;if(t=(e=new T(e,t)).s,!o||!t)return new T(NaN);if(o!=t)return e.s=-t,n.minus(e);var i=n.e/LOG_BASE,a=e.e/LOG_BASE,s=n.c,l=e.c;if(!i||!a){if(!s||!l)return new T(o/0);if(!s[0]||!l[0])return l[0]?e:new T(s[0]?n:0*o)}if(i=bitFloor(i),a=bitFloor(a),s=s.slice(),o=i-a){for((r=0<o?(a=i,l):(o=-o,s)).reverse();o--;r.push(0));r.reverse()}for((o=s.length)-(t=l.length)<0&&(r=l,l=s,s=r,t=o),o=0;t;)o=(s[--t]=s[t]+l[t]+o)/BASE|0,s[t]=BASE===s[t]?0:s[t]%BASE;return o&&(s=[o].concat(s),++a),B(e,s,a)},r.precision=r.sd=function(e,t){var r,n;if(null!=e&&e!==!!e)return intCheck(e,1,MAX),null==t?t=d:intCheck(t,0,8),M(new T(this),e,t);if(!(t=this.c))return null;if(r=(n=t.length-1)*LOG_BASE+1,n=t[n]){for(;n%10==0;n/=10,r--);for(n=t[0];10<=n;n/=10,r++);}return r=e&&this.e+1>r?this.e+1:r},r.shiftedBy=function(e){return intCheck(e,-MAX_SAFE_INTEGER,MAX_SAFE_INTEGER),this.times("1e"+e)},r.squareRoot=r.sqrt=function(){var e,t,r,n,o,i=this,a=i.c,s=i.s,l=i.e,c=b+4,u=new T("0.5");if(1!==s||!a||!a[0])return new T(!s||s<0&&(!a||a[0])?NaN:a?i:1/0);if((r=0==(s=Math.sqrt(+j(i)))||s==1/0?(((t=coeffToString(a)).length+l)%2==0&&(t+="0"),s=Math.sqrt(+t),l=bitFloor((l+1)/2)-(l<0||l%2),new T(t=s==1/0?"5e"+l:(t=s.toExponential()).slice(0,t.indexOf("e")+1)+l)):new T(s+"")).c[0])for((s=(l=r.e)+c)<3&&(s=0);;)if(o=r,r=u.times(o.plus(m(i,o,c,1))),coeffToString(o.c).slice(0,s)===(t=coeffToString(r.c)).slice(0,s)){if(r.e<l&&--s,"9999"!=(t=t.slice(s-3,s+1))&&(n||"4999"!=t)){+t&&(+t.slice(1)||"5"!=t.charAt(0))||(M(r,r.e+b+2,1),e=!r.times(r).eq(i));break}if(!n&&(M(o,o.e+b+2,0),o.times(o).eq(i))){r=o;break}c+=4,s+=4,n=1}return M(r,r.e+b+1,d,e)},r.toExponential=function(e,t){return null!=e&&(intCheck(e,0,MAX),e++),n(this,e,t,1)},r.toFixed=function(e,t){return null!=e&&(intCheck(e,0,MAX),e=e+this.e+1),n(this,e,t)},r.toFormat=function(e,t,r){if(null==r)null!=e&&t&&"object"==_typeof(t)?(r=t,t=null):e&&"object"==_typeof(e)?(r=e,e=t=null):r=C;else if("object"!=_typeof(r))throw Error(bignumberError+"Argument not an object: "+r);if(e=this.toFixed(e,t),this.c){var n,t=e.split("."),o=+r.groupSize,i=+r.secondaryGroupSize,a=r.groupSeparator||"",s=t[0],t=t[1],l=this.s<0,c=l?s.slice(1):s,u=c.length;if(i&&(n=o,o=i,u-=i=n),0<o&&0<u){for(s=c.substr(0,n=u%o||o);n<u;n+=o)s+=a+c.substr(n,o);0<i&&(s+=a+c.slice(n)),l&&(s="-"+s)}e=t?s+(r.decimalSeparator||"")+((i=+r.fractionGroupSize)?t.replace(new RegExp("\\d{"+i+"}\\B","g"),"$&"+(r.fractionGroupSeparator||"")):t):s}return(r.prefix||"")+e+(r.suffix||"")},r.toFraction=function(e){var t,r,n,o,i,a,s,l,c,u,f=this,h=f.c;if(null!=e&&(!(s=new T(e)).isInteger()&&(s.c||1!==s.s)||s.lt(g)))throw Error(bignumberError+"Argument "+(s.isInteger()?"out of range: ":"not an integer: ")+j(s));if(!h)return new T(f);for(t=new T(g),c=r=new T(g),n=l=new T(g),h=coeffToString(h),i=t.e=h.length-f.e-1,t.c[0]=POWS_TEN[(a=i%LOG_BASE)<0?LOG_BASE+a:a],e=!e||0<s.comparedTo(t)?0<i?t:c:s,a=$,$=1/0,s=new T(h),l.c[0]=0;u=m(s,t,0,1),1!=(o=r.plus(u.times(n))).comparedTo(e);)r=n,n=o,c=l.plus(u.times(o=c)),l=o,t=s.minus(u.times(o=t)),s=o;return o=m(e.minus(r),n,0,1),l=l.plus(o.times(c)),r=r.plus(o.times(n)),l.s=c.s=f.s,h=m(c,n,i*=2,d).minus(f).abs().comparedTo(m(l,r,i,d).minus(f).abs())<1?[c,n]:[l,r],$=a,h},r.toNumber=function(){return+j(this)},r.toPrecision=function(e,t){return null!=e&&intCheck(e,1,MAX),n(this,e,t,2)},r.toString=function(e){var t,r=this,n=r.s,o=r.e;return null===o?n?(t="Infinity",n<0&&(t="-"+t)):t="NaN":(t=null==e?o<=_||v<=o?toExponential(coeffToString(r.c),o):toFixedPoint(coeffToString(r.c),o,"0"):10===e&&A?toFixedPoint(coeffToString((r=M(new T(r),b+o+1,d)).c),r.e,"0"):(intCheck(e,2,O.length,"Base"),f(toFixedPoint(coeffToString(r.c),o,"0"),10,e,n,!0)),n<0&&r.c[0]&&(t="-"+t)),t},r.valueOf=r.toJSON=function(){return j(this)},r._isBigNumber=!0,r[Symbol.toStringTag]="BigNumber",r[Symbol.for("nodejs.util.inspect.custom")]=r.valueOf,null!=e&&T.set(e),T}function bitFloor(e){var t=0|e;return 0<e||e===t?t:t-1}function coeffToString(e){for(var t,r,n=1,o=e.length,i=e[0]+"";n<o;){for(t=e[n++]+"",r=LOG_BASE-t.length;r--;t="0"+t);i+=t}for(o=i.length;48===i.charCodeAt(--o););return i.slice(0,o+1||1)}function compare(e,t){var r,n,o=e.c,i=t.c,a=e.s,s=t.s,e=e.e,t=t.e;if(!a||!s)return null;if(r=o&&!o[0],n=i&&!i[0],r||n)return r?n?0:-s:a;if(a!=s)return a;if(r=a<0,n=e==t,!o||!i)return n?0:!o^r?1:-1;if(!n)return t<e^r?1:-1;for(s=(e=o.length)<(t=i.length)?e:t,a=0;a<s;a++)if(o[a]!=i[a])return o[a]>i[a]^r?1:-1;return e==t?0:t<e^r?1:-1}function intCheck(e,t,r,n){if(e<t||r<e||e!==mathfloor(e))throw Error(bignumberError+(n||"Argument")+("number"==typeof e?e<t||r<e?" out of range: ":" not an integer: ":" not a primitive number: ")+String(e))}function isOdd(e){var t=e.c.length-1;return bitFloor(e.e/LOG_BASE)==t&&e.c[t]%2!=0}function toExponential(e,t){return(1<e.length?e.charAt(0)+"."+e.slice(1):e)+(t<0?"e":"e+")+t}function toFixedPoint(e,t,r){var n,o;if(t<0){for(o=r+".";++t;o+=r);e=o+e}else if(++t>(n=e.length)){for(o=r,t-=n;--t;o+=r);e+=o}else t<n&&(e=e.slice(0,t)+"."+e.slice(t));return e}var BigNumber=clone();function decimalRound(n,o,e,i,t){var a=n,s=o,r=o.length,l={"~-":function(){s=o.slice(0,i)},"~+":function(){""===(s=o.slice(0,i))?a=n.slice(0,n.length-1)+(+n[n.length-1]+1):s=s.slice(0,i-1)+(+s[i-1]+1)},"~5":function(){s=o.slice(0,i);var e=+o[i];""===s?5<=e&&(a=n.slice(0,n.length-1)+(+n[n.length-1]+1)):5<=e&&(s=s.slice(0,i-1)+(+s[i-1]+1))},"~6":function(){s=o.slice(0,i);var e=""===(e=o.slice(+i+1,o.length))?0:parseInt(e),t=+o[i],r=+n[n.length-1];""===s?(6<=t||5==t&&0<e||5==t&&r%2!=0)&&(a=n.slice(0,n.length-1)+(+n[n.length-1]+1)):(r=+o[i-1],(6<=t||5==t&&0<e||5==t&&r%2!=0)&&(s=s.slice(0,i-1)+(+s[i-1]+1)))}};return"<="===e?r<=i?s=o:l[t]&&l[t]():"="===e?r<i?s=o+"0".repeat(i-r):i<r&&l[t]&&l[t]():">="===e&&r<i&&(s=o+"0".repeat(i-r)),{intPart:a,decPart:s}}function format(e,t,r){var n="";if(BigNumber.isBigNumber(e))n=e.toFixed();else if("string"!=typeof e)n=e.toString();else if(!0===r){r=splitUnitNum(e);if(null===r.num)return null;n=BigNumber(r.num).toFixed()}else n=BigNumber(e).toFixed();if("undefined"===n||"NaN"===n)return null;var o=null,i=null,a=null,s=null,l="~-";return t.forEach(function(e){var t=e.type;if("symbol"===t){if(![">=","<=","="].includes(e.value))throw new Error("错误的格式化参数:",e.value);i=e.value}else if("comma"===t)a=!0;else if("number"===t)o=e.value;else if("plus"===t)s=!0;else{if("round"!==t)throw new Error("错误的fmt Token");l=e.value}}),null!==o&&(e=(t=decimalRound(e=(r=n.split("."))[0],1===r.length?"":r[1],i,o,l)).intPart,n=""===(r=t.decPart)?e:"".concat(e,".").concat(r)),null!==a&&(n=1<(t=n.split(".")).length?((e=t[0]).includes("-")?t[0]=e[0]+e.slice(1).replace(/(?=(?!^)(?:\d{3})+$)/g,","):t[0]=e.replace(/(?=(?!^)(?:\d{3})+$)/g,","),t.join(".")):(r=t[0]).includes("-")?r[0]+r.slice(1).replace(/(?=(?!^)(?:\d{3})+$)/g,","):r.replace(/(?=(?!^)(?:\d{3})+$)/g,",")),n=null===s||n.startsWith("-")?n:"+"+n}function tokenizer(e){for(var t=1<arguments.length&&void 0!==arguments[1]&&arguments[1],r=[],n=0,o=null,i=e.length;n<i;)if(o=e[n],/\s/.test(o))n++;else if("+-".includes(o)){var a=r[r.length-1];if(0===r.length||"+-".includes(a)||"("===a){var s=o;if(++n>=i){r.push(s);break}for(var o=e[n],l=0;/[^*/()\s]/.test(o)&&(["+","-"].includes(o)&&l++,!(2<l||!/[eE]/.test(s[s.length-1])&&"+-".includes(o)))&&(s+=o,!(++n>=i));)o=e[n];r.push(s)}else r.push(o),n++}else if("*/%()".includes(o))r.push(o),n++;else if(/[a-zA-Z_$]/.test(o)){for(var c="";/[\w_.\[\]"']/.test(o)&&(c+=o,!(++n>=i));)o=e[n];r.push(c)}else if(/\d/.test(o)){for(var u="",f=0,h=void 0,h=t?/[^*/()\s]/:/[\d.eE\+-]/;h.test(o)&&(["+","-"].includes(o)&&f++,!(1<f||!/[eE]/.test(u[u.length-1])&&"+-".includes(o)))&&(u+=o,!(++n>=i));)o=e[n];r.push(u)}return r}var commonjsGlobal="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},isArray$3=Array.isArray,isArray_1=isArray$3,freeGlobal$1="object"==_typeof(commonjsGlobal)&&commonjsGlobal&&commonjsGlobal.Object===Object&&commonjsGlobal,_freeGlobal=freeGlobal$1,freeGlobal=freeGlobal$1,freeSelf="object"==("undefined"==typeof self?"undefined":_typeof(self))&&self&&self.Object===Object&&self,root$3=freeGlobal||freeSelf||Function("return this")(),_root=root$3,root$2=_root,_Symbol2=_root.Symbol,_Symbol$3=_Symbol2,_Symbol$2=_Symbol$3,objectProto$4=Object.prototype,hasOwnProperty$3=objectProto$4.hasOwnProperty,nativeObjectToString$1=objectProto$4.toString,symToStringTag$1=_Symbol$2?_Symbol$2.toStringTag:void 0;function getRawTag$1(e){var t=hasOwnProperty$3.call(e,symToStringTag$1),r=e[symToStringTag$1];try{var n=!(e[symToStringTag$1]=void 0)}catch(e){}var o=nativeObjectToString$1.call(e);return n&&(t?e[symToStringTag$1]=r:delete e[symToStringTag$1]),o}var _getRawTag=getRawTag$1,objectProto$3=Object.prototype,nativeObjectToString=objectProto$3.toString;function objectToString$1(e){return nativeObjectToString.call(e)}var _objectToString=objectToString$1,_Symbol$1=_Symbol$3,getRawTag=_getRawTag,objectToString=objectToString$1,nullTag="[object Null]",undefinedTag="[object Undefined]",symToStringTag=_Symbol$3?_Symbol$3.toStringTag:void 0;function baseGetTag$2(e){return null==e?void 0===e?undefinedTag:nullTag:(symToStringTag&&symToStringTag in Object(e)?getRawTag:objectToString)(e)}var _baseGetTag=baseGetTag$2;function isObjectLike$1(e){return null!=e&&"object"==_typeof(e)}var isObjectLike_1=isObjectLike$1,baseGetTag$1=baseGetTag$2,isObjectLike=isObjectLike$1,symbolTag="[object Symbol]";function isSymbol$3(e){return"symbol"==_typeof(e)||isObjectLike(e)&&baseGetTag$1(e)==symbolTag}var isSymbol_1=isSymbol$3,isArray$2=isArray_1,isSymbol$2=isSymbol_1,reIsDeepProp=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,reIsPlainProp=/^\w*$/;function isKey$1(e,t){if(isArray$2(e))return!1;var r=_typeof(e);return!("number"!=r&&"symbol"!=r&&"boolean"!=r&&null!=e&&!isSymbol$2(e))||(reIsPlainProp.test(e)||!reIsDeepProp.test(e)||null!=t&&e in Object(t))}var _isKey=isKey$1;function isObject$2(e){var t=_typeof(e);return null!=e&&("object"==t||"function"==t)}var isObject_1=isObject$2,baseGetTag=baseGetTag$2,isObject$1=isObject_1,asyncTag="[object AsyncFunction]",funcTag="[object Function]",genTag="[object GeneratorFunction]",proxyTag="[object Proxy]";function isFunction$1(e){if(!isObject$1(e))return!1;e=baseGetTag(e);return e==funcTag||e==genTag||e==asyncTag||e==proxyTag}var isFunction_1=isFunction$1,root$1=_root,coreJsData$1=_root["__core-js_shared__"],_coreJsData=coreJsData$1,coreJsData=coreJsData$1,maskSrcKey=function(){var e=/[^.]+$/.exec(coreJsData&&coreJsData.keys&&coreJsData.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function isMasked$1(e){return!!maskSrcKey&&maskSrcKey in e}var _isMasked=isMasked$1,funcProto$1=Function.prototype,funcToString$1=funcProto$1.toString;function toSource$1(e){if(null!=e){try{return funcToString$1.call(e)}catch(e){}try{return e+""}catch(e){}}return""}var _toSource=toSource$1,isFunction=isFunction_1,isMasked=_isMasked,isObject=isObject_1,toSource=toSource$1,reRegExpChar=/[\\^$.*+?()[\]{}|]/g,reIsHostCtor=/^\[object .+?Constructor\]$/,funcProto=Function.prototype,objectProto$2=Object.prototype,funcToString=funcProto.toString,hasOwnProperty$2=objectProto$2.hasOwnProperty,reIsNative=RegExp("^"+funcToString.call(hasOwnProperty$2).replace(reRegExpChar,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function baseIsNative$1(e){return!(!isObject(e)||isMasked(e))&&(isFunction(e)?reIsNative:reIsHostCtor).test(toSource(e))}var _baseIsNative=baseIsNative$1;function getValue$1(e,t){return null==e?void 0:e[t]}var _getValue=getValue$1,baseIsNative=baseIsNative$1,getValue=getValue$1;function getNative$2(e,t){e=getValue(e,t);return baseIsNative(e)?e:void 0}var _getNative=getNative$2,getNative$1=_getNative,nativeCreate$4=_getNative(Object,"create"),_nativeCreate=nativeCreate$4,nativeCreate$3=_nativeCreate;function hashClear$1(){this.__data__=nativeCreate$3?nativeCreate$3(null):{},this.size=0}var _hashClear=hashClear$1;function hashDelete$1(e){e=this.has(e)&&delete this.__data__[e];return this.size-=e?1:0,e}var _hashDelete=hashDelete$1,nativeCreate$2=_nativeCreate,HASH_UNDEFINED$1="__lodash_hash_undefined__",objectProto$1=Object.prototype,hasOwnProperty$1=objectProto$1.hasOwnProperty;function hashGet$1(e){var t,r=this.__data__;return nativeCreate$2?(t=r[e])===HASH_UNDEFINED$1?void 0:t:hasOwnProperty$1.call(r,e)?r[e]:void 0}var _hashGet=hashGet$1,nativeCreate$1=_nativeCreate,objectProto=Object.prototype,hasOwnProperty=objectProto.hasOwnProperty;function hashHas$1(e){var t=this.__data__;return nativeCreate$1?void 0!==t[e]:hasOwnProperty.call(t,e)}var _hashHas=hashHas$1,nativeCreate=_nativeCreate,HASH_UNDEFINED="__lodash_hash_undefined__";function hashSet$1(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=nativeCreate&&void 0===t?HASH_UNDEFINED:t,this}var _hashSet=hashSet$1,hashClear=_hashClear,hashDelete=_hashDelete,hashGet=_hashGet,hashHas=hashHas$1,hashSet=hashSet$1;function Hash$1(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}Hash$1.prototype.clear=hashClear,Hash$1.prototype.delete=hashDelete,Hash$1.prototype.get=hashGet,Hash$1.prototype.has=hashHas,Hash$1.prototype.set=hashSet;var _Hash=Hash$1;function listCacheClear$1(){this.__data__=[],this.size=0}var _listCacheClear=listCacheClear$1;function eq$1(e,t){return e===t||e!=e&&t!=t}var eq_1=eq$1,eq=eq$1;function assocIndexOf$4(e,t){for(var r=e.length;r--;)if(eq(e[r][0],t))return r;return-1}var _assocIndexOf=assocIndexOf$4,assocIndexOf$3=_assocIndexOf,arrayProto=Array.prototype,splice=arrayProto.splice;function listCacheDelete$1(e){var t=this.__data__,e=assocIndexOf$3(t,e);return!(e<0)&&(e==t.length-1?t.pop():splice.call(t,e,1),--this.size,!0)}var _listCacheDelete=listCacheDelete$1,assocIndexOf$2=_assocIndexOf;function listCacheGet$1(e){var t=this.__data__,e=assocIndexOf$2(t,e);return e<0?void 0:t[e][1]}var _listCacheGet=listCacheGet$1,assocIndexOf$1=_assocIndexOf;function listCacheHas$1(e){return-1<assocIndexOf$1(this.__data__,e)}var _listCacheHas=listCacheHas$1,assocIndexOf=_assocIndexOf;function listCacheSet$1(e,t){var r=this.__data__,n=assocIndexOf(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this}var _listCacheSet=listCacheSet$1,listCacheClear=_listCacheClear,listCacheDelete=listCacheDelete$1,listCacheGet=listCacheGet$1,listCacheHas=listCacheHas$1,listCacheSet=listCacheSet$1;function ListCache$1(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}ListCache$1.prototype.clear=listCacheClear,ListCache$1.prototype.delete=listCacheDelete,ListCache$1.prototype.get=listCacheGet,ListCache$1.prototype.has=listCacheHas,ListCache$1.prototype.set=listCacheSet;var _ListCache=ListCache$1,getNative=_getNative,root=_root,Map$2=_getNative(_root,"Map"),_Map=Map$2,Hash=_Hash,ListCache=_ListCache,Map$1=Map$2;function mapCacheClear$1(){this.size=0,this.__data__={hash:new Hash,map:new(Map$1||ListCache),string:new Hash}}var _mapCacheClear=mapCacheClear$1;function isKeyable$1(e){var t=_typeof(e);return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e}var _isKeyable=isKeyable$1,isKeyable=isKeyable$1;function getMapData$4(e,t){e=e.__data__;return isKeyable(t)?e["string"==typeof t?"string":"hash"]:e.map}var _getMapData=getMapData$4,getMapData$3=getMapData$4;function mapCacheDelete$1(e){e=getMapData$3(this,e).delete(e);return this.size-=e?1:0,e}var _mapCacheDelete=mapCacheDelete$1,getMapData$2=getMapData$4;function mapCacheGet$1(e){return getMapData$2(this,e).get(e)}var _mapCacheGet=mapCacheGet$1,getMapData$1=getMapData$4;function mapCacheHas$1(e){return getMapData$1(this,e).has(e)}var _mapCacheHas=mapCacheHas$1,getMapData=getMapData$4;function mapCacheSet$1(e,t){var r=getMapData(this,e),n=r.size;return r.set(e,t),this.size+=r.size==n?0:1,this}var _mapCacheSet=mapCacheSet$1,mapCacheClear=mapCacheClear$1,mapCacheDelete=mapCacheDelete$1,mapCacheGet=mapCacheGet$1,mapCacheHas=mapCacheHas$1,mapCacheSet=mapCacheSet$1;function MapCache$1(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}MapCache$1.prototype.clear=mapCacheClear,MapCache$1.prototype.delete=mapCacheDelete,MapCache$1.prototype.get=mapCacheGet,MapCache$1.prototype.has=mapCacheHas,MapCache$1.prototype.set=mapCacheSet;var _MapCache=MapCache$1,MapCache=MapCache$1,FUNC_ERROR_TEXT="Expected a function";function memoize$1(n,o){if("function"!=typeof n||null!=o&&"function"!=typeof o)throw new TypeError(FUNC_ERROR_TEXT);function i(){var e=arguments,t=o?o.apply(this,e):e[0],r=i.cache;return r.has(t)?r.get(t):(e=n.apply(this,e),i.cache=r.set(t,e)||r,e)}return i.cache=new(memoize$1.Cache||MapCache),i}memoize$1.Cache=MapCache;var memoize_1=memoize$1,memoize=memoize$1,MAX_MEMOIZE_SIZE=500;function memoizeCapped$1(e){var e=memoize(e,function(e){return t.size===MAX_MEMOIZE_SIZE&&t.clear(),e}),t=e.cache;return e}var _memoizeCapped=memoizeCapped$1,memoizeCapped=memoizeCapped$1,rePropName=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,reEscapeChar=/\\(\\)?/g,stringToPath$1=memoizeCapped$1(function(e){var o=[];return 46===e.charCodeAt(0)&&o.push(""),e.replace(rePropName,function(e,t,r,n){o.push(r?n.replace(reEscapeChar,"$1"):t||e)}),o}),_stringToPath=stringToPath$1;function arrayMap$1(e,t){for(var r=-1,n=null==e?0:e.length,o=Array(n);++r<n;)o[r]=t(e[r],r,e);return o}var _arrayMap=arrayMap$1,_Symbol=_Symbol$3,arrayMap=arrayMap$1,isArray$1=isArray_1,isSymbol$1=isSymbol_1,INFINITY$1=1/0,symbolProto=_Symbol$3?_Symbol$3.prototype:void 0,symbolToString=symbolProto?symbolProto.toString:void 0;function baseToString$1(e){if("string"==typeof e)return e;if(isArray$1(e))return arrayMap(e,baseToString$1)+"";if(isSymbol$1(e))return symbolToString?symbolToString.call(e):"";var t=e+"";return"0"==t&&1/e==-INFINITY$1?"-0":t}var _baseToString=baseToString$1,baseToString=baseToString$1;function toString$1(e){return null==e?"":baseToString(e)}var toString_1=toString$1,isArray=isArray_1,isKey=_isKey,stringToPath=_stringToPath,toString=toString$1;function castPath$1(e,t){return isArray(e)?e:isKey(e,t)?[e]:stringToPath(toString(e))}var _castPath=castPath$1,isSymbol=isSymbol_1,INFINITY=1/0;function toKey$1(e){if("string"==typeof e||isSymbol(e))return e;var t=e+"";return"0"==t&&1/e==-INFINITY?"-0":t}var _toKey=toKey$1,castPath=castPath$1,toKey=toKey$1;function baseGet$1(e,t){for(var r=0,n=(t=castPath(t,e)).length;null!=e&&r<n;)e=e[toKey(t[r++])];return r&&r==n?e:void 0}var _baseGet=baseGet$1,baseGet=baseGet$1;function get(e,t,r){e=null==e?void 0:baseGet(e,t);return void 0===e?r:e}var get_1=get;function fillTokens(e,t,r){var n=[];if(!notNull(t))throw new TokensFillError("错误的填充数据:",t);Array.isArray(t)?n=t:n.push(t);for(var o=[],i=0;i<e.length;i++){var a=e[i];if(RVar.test(a)){if("undefined"===a||"NaN"===a)throw new TokensFillError("key不应该为:".concat(a));for(var s=null,l=0;l<n.length;l++){var c=n[l],c=get_1(c,a);if(void 0!==c){s=c;break}}if(null===s)throw new TokensFillError("token填充失败,请确认".concat(a,"存在"));if("string"==typeof s){if(""===s.trim())throw new TokensFillError("token填充失败,".concat(a,"值不可为空字符"));if(!0===r){if(!RUnitNumber.test(s))throw new TokensFillError("token填充失败,".concat(a,"值:").concat(s,"为非法单位数字"))}else if(!isStrNumber(s))throw new TokensFillError("token填充失败,".concat(a,"值:").concat(s,"为非法数字"))}s="string"!=typeof s?s.toString():s,o.push(s)}else o.push(a)}return o}function fillFmtTokens(e,n){return e.map(function(e){if("var"!==e.type)return e;for(var t,r=0;r<n.length&&!notUndefined(t=get_1(n[r],e.value));r++);if(isNumber(t))return{type:"number",value:t};throw new TokensFillError("错误的填充值")})}function getTokenAndUnit(e){var r=null;return e.length,{tokens:e.map(function(e){var t=splitUnitNum(e);return null!==t.unit?(null==r&&(r=t.unit),t.num):e}),unit:r}}function fmt(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];var n=parseArgs(t),o=tokenizer(n.expr,get_1(n,"data._unit",!1)),i=null,a=null;if(!0===get_1(n,"data._debug")&&(console.warn("======a-calc调试模式======"),console.warn(n),console.warn(o)),""===n.expr.trim()&&notNull(n.data)&&notUndefined(n.data._error))return n.data._error;if(2<o.length)throw new Error("fmt并非用于计算, 不能传入多个标识:".concat(n.expr));if(1!==o.length)throw new Error("fmt接收了一个无法被解析的标识");if(notNull(n.data)){var s,l=n.data,c=[],u=l._fillError,f=get_1(l,"_unit",null);if(Array.isArray(l)?c=l:(c.push(i=l),notUndefined(s=get_1(i,"_fillData"))&&(Array.isArray(s)?c=[].concat(_toConsumableArray(c),_toConsumableArray(s)):c.push(s))),anyNotUndefined(u,l._error))try{o=fillTokens(o,c,f),notNull(n.fmt)&&(n.fmt=fillFmtTokens(n.fmt,c))}catch(e){if(e instanceof TokensFillError)return void 0!==i._warn&&!0===i._warn&&console.warn(e),i._fillError||i._error;throw e}else o=fillTokens(o,c,f),notNull(n.fmt)&&(n.fmt=fillFmtTokens(n.fmt,c));!0===f&&(a=(s=getTokenAndUnit(o)).unit,o=s.tokens)}u=o[0];if(!0===f){if(!RUnitNumber.test(u))throw new TokensFillError("token填充失败,".concat(key,"值:").concat(value,"为非法单位数字"))}else if(!isStrNumber(u))throw new TokensFillError("待格式化对象: ".concat(u," 不是数字"));return null!==(l=null!==n.fmt?format(u,n.fmt,f):BigNumber(u).toFixed())&&null!==a&&(l+=a),l}var version="0.0.80";function token2postfix(e){for(var t=[],r=[],n=e;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;)r.push(i),i=t.pop();if("("!==i)throw"error: unmatched ()"}else{for(;prioraty(o,t[t.length-1])&&0<t.length;)r.push(t.pop());t.push(o)}else r.push(o)}if(0<t.length){if(")"===t[t.length-1]||"("===t[t.length-1])throw"error: unmatched ()";for(;0<t.length;)r.push(t.pop())}return r}function evalPostfix(e){for(var t=[];0<e.length;){var r=e.shift();if(isOperator(r)){if(t.length<2)throw new CalculatorError("错误的栈长度, 可能是无法计算的表达式");var n=t.pop(),o=t.pop();if("string"==typeof n&&!BigNumber.isBigNumber(n)){if(!isStrNumber(n))throw new CalculatorError("".concat(n,"不是一个合法的数字"));n=new BigNumber(n)}if("string"==typeof o&&!BigNumber.isBigNumber(o)){if(!isStrNumber(o))throw new CalculatorError("".concat(o,"不是一个合法的数字"));o=new BigNumber(o)}switch(r){case"+":t.push(o.plus(n));break;case"-":t.push(o.minus(n));break;case"*":t.push(o.times(n));break;case"/":t.push(o.div(n));break;case"%":t.push(o.mod(n))}}else t.push(r)}if(1!==t.length)throw"unvalid expression";var i=t[0];if((i=BigNumber.isBigNumber(i)?i:BigNumber(i)).isNaN())throw new CalculatorError("计算结果为NaN");return i}function calc(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];var n,o=parseArgs(t),i=tokenizer(o.expr,get_1(o,"data._unit",!1)),a=null,s=null;if(!0===get_1(o,"data._debug")&&(console.warn("======a-calc调试模式======"),console.warn(o),console.warn(i),o.fmt&&console.warn(o.fmt)),notNull(o.data)){var l=o.data,c=[],u=l._error,f=l._fillError,h=l._warn,p=get_1(l,"_unit",null);if(Array.isArray(l)?c=l:(c.push(a=l),notUndefined(l=get_1(a,"_fillData"))&&(Array.isArray(l)?c=[].concat(_toConsumableArray(c),_toConsumableArray(l)):c.push(l))),anyNotUndefined(f,u))try{i=fillTokens(i,c,p),notNull(o.fmt)&&(o.fmt=fillFmtTokens(o.fmt,c))}catch(e){if(e instanceof TokensFillError)return notUndefined(h)&&!0===h&&console.warn(e),notUndefined(f)?f:u;throw e}else i=fillTokens(i,c,p),notNull(o.fmt)&&(o.fmt=fillFmtTokens(o.fmt,c));!0===p&&(s=(l=getTokenAndUnit(i)).unit,i=l.tokens)}!0===get_1(o,"data._debug")&&(console.warn(i),console.warn("单位:".concat(s)));f=token2postfix(i),c=null;if(notNull(a)&&anyNotUndefined(n,u))try{c=evalPostfix(f)}catch(e){if(e instanceof CalculatorError)return void 0!==h&&!0===h&&console.warn(e),notUndefined(n)?n:u;throw e}else c=evalPostfix(f);return null!==(c=notNull(o.fmt)?format(c,o.fmt):null!==c?c.toFixed():null)&&null!==s&&(c+=s),c}exports.calc=calc,exports.fmt=fmt,exports.version=version;
package/es/index.mjs ADDED
@@ -0,0 +1 @@
1
+ function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function _createClass(e,t,r){return t&&_defineProperties(e.prototype,t),r&&_defineProperties(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&_setPrototypeOf(e,t)}function _getPrototypeOf(e){return(_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function _setPrototypeOf(e,t){return(_setPrototypeOf=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}function _construct(e,t,r){return(_construct=_isNativeReflectConstruct()?Reflect.construct:function(e,t,r){var n=[null];n.push.apply(n,t);t=new(Function.bind.apply(e,n));return r&&_setPrototypeOf(t,r.prototype),t}).apply(null,arguments)}function _isNativeFunction(e){return-1!==Function.toString.call(e).indexOf("[native code]")}function _wrapNativeSuper(e){var r="function"==typeof Map?new Map:void 0;return(_wrapNativeSuper=function(e){if(null===e||!_isNativeFunction(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==r){if(r.has(e))return r.get(e);r.set(e,t)}function t(){return _construct(e,arguments,_getPrototypeOf(this).constructor)}return t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),_setPrototypeOf(t,e)})(e)}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _possibleConstructorReturn(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(e)}function _createSuper(r){var n=_isNativeReflectConstruct();return function(){var e,t=_getPrototypeOf(r);return _possibleConstructorReturn(this,n?(e=_getPrototypeOf(this).constructor,Reflect.construct(t,arguments,e)):t.apply(this,arguments))}}function _toConsumableArray(e){return _arrayWithoutHoles(e)||_iterableToArray(e)||_unsupportedIterableToArray(e)||_nonIterableSpread()}function _arrayWithoutHoles(e){if(Array.isArray(e))return _arrayLikeToArray(e)}function _iterableToArray(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Map"===(r="Object"===r&&e.constructor?e.constructor.name:r)||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(e,t):void 0}}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];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.")}var RNumber=/^[+-]?\d[\d.]*(?:e\+|E\+|e-|E-|e|E)?\d*$/,RUnitNumber=/^[+-]?\d[\d.]*(?:e\+|E\+|e-|E-|e|E)?\d*\D*$/,RVar=/^[a-zA-z_][\w\[\]"'_.]*$/;function isOperator(e){return-1<"+-*/%()".indexOf(e)}function getPrioraty(e){switch(e){case"+":case"-":return 1;case"*":case"/":case"%":return 2;default:return 0}}function prioraty(e,t){return getPrioraty(e)<=getPrioraty(t)}function isObj(e){return"[object Object]"===Object.prototype.toString.call(e)&&!Array.isArray(e)}function notUndefined(e){return void 0!==e}function anyNotUndefined(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return t.some(function(e){return void 0!==e})}function notNull(e){return null!==e}function isNumber(e){return"number"==typeof e||isStrNumber(e)}function isStrNumber(e){return"string"==typeof e&&!!RNumber.test(e)}function splitUnitNum(e){for(var t,r,n=null,o=null,i=[/^([+-]?[\d.]+(?:e|E)(?:\+|-)?\d+)(\D*)$/,/^([+-]?[\d.]+)(\D*)$/],a=0;a<i.length;a++){var s=e.match(i[a]);if(s){t=s;break}}return t&&(o=t[1],""!==(r=t[2]).trim()&&(n=r)),{num:o,unit:n}}var CalculatorError=function(){_inherits(n,_wrapNativeSuper(Error));var r=_createSuper(n);function n(e){var t;return _classCallCheck(this,n),(t=r.call(this,e)).name="CalculatorError",t.message=e,t}return _createClass(n)}(),TokensFillError=function(){_inherits(n,_wrapNativeSuper(Error));var r=_createSuper(n);function n(e){var t;return _classCallCheck(this,n),(t=r.call(this,e)).name="TokensFillError",t.message=e,t}return _createClass(n)}(),ArgError=function(){_inherits(n,_wrapNativeSuper(Error));var r=_createSuper(n);function n(e){var t;return _classCallCheck(this,n),(t=r.call(this,e)).name="ArgError",t.message=e,t}return _createClass(n)}(),FmtError=function(){_inherits(n,_wrapNativeSuper(Error));var r=_createSuper(n);function n(e){var t;return _classCallCheck(this,n),(t=r.call(this,e)).name="FmtError",t.message=e,t}return _createClass(n)}();function fmtTokenizer(e){for(var t,r=0,n=e.length,o=[];r<n;)if(t=e[r],/\s/.test(t))r++;else if("+"===t)o.push({type:"plus",value:t}),r++;else if(","===t)o.push({type:"comma",value:t}),r++;else if("<>=".includes(t)){var i=t;++r>=n?o.push({type:"symbol",value:i}):(a=e[r],"<>=".includes(a)?(i+=a,o.push({type:"symbol",value:i}),r++):o.push({type:"symbol",value:t}))}else if("~"===t){var a=t;if(++r>=n)throw new FmtError("fmt格式化传参错误!错误解析字符:".concat(t));if(t=e[r],!"+-56".includes(t))throw new FmtError("fmt格式化传参错误!错误解析字符:".concat(t));a+=t,o.push({type:"round",value:a}),r++}else if(/[a-zA-Z_]/.test(t)){for(var s="";/[\w_.\[\]"']/.test(t)&&(s+=t,!(n<=++r));)t=e[r];o.push({type:"var",value:s})}else if(/\d/.test(t)){for(var l="";/[\d.]/.test(t)&&(l+=t,!(n<=++r));)t=e[r];o.push({type:"number",value:l})}return o}function parseArgs(e){var t={expr:"",fmt:null,data:null},r="",n=e[0];if(1===e.length)if("string"==typeof n)r=n;else{if("number"!=typeof n)throw new ArgError("错误的参数类型: ".concat(n," 类型为:").concat(_typeof(n)));r=n.toString()}else{if(2!==e.length)throw new ArgError("过多的参数, 该函数最多接受两个参数!");n=e[1];if(!isObj(n)&&!Array.isArray(n))throw new Error("参数错误, 不支持的参数");if("string"==typeof(r=e[0])){if(""===r.trim())throw new TokensFillError("参数不可为空字符串");if("NaN"===r)throw new TokensFillError("非法参数:".concat(r))}else if("number"==typeof r)r=r.toString();else if(void 0===r||Number.isNaN(r))throw new TokensFillError("非法参数:".concat(r));t.data=n}var o,e=r.split("|");return 1===e.length?t.expr=e[0]:(t.expr=e[0],""!==(n=e[1]).trim()&&(t.fmt=fmtTokenizer(n))),null!==t.data&&t.data._fmt&&(r=fmtTokenizer(t.data._fmt),null===t.fmt?t.fmt=r:(o=t.fmt.map(function(e){return e.type}),r.forEach(function(e){o.includes(e.type)||t.fmt.push(e)}))),t}var isNumeric=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,mathceil=Math.ceil,mathfloor=Math.floor,bignumberError="[BigNumber Error] ",tooManyDigits=bignumberError+"Number primitive has more than 15 significant digits: ",BASE=1e14,LOG_BASE=14,MAX_SAFE_INTEGER=9007199254740991,POWS_TEN=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],SQRT_BASE=1e7,MAX=1e9;function clone(e){var m,f,h,t,c,y,a,s,l,u,p,r=T.prototype={constructor:T,toString:null,valueOf:null},g=new T(1),b=20,d=4,_=-7,v=21,S=-1e7,$=1e7,E=!1,o=1,w=0,C={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},O="0123456789abcdefghijklmnopqrstuvwxyz",A=!0;function T(e,t){var r,n,o,i,a,s,l,c,u=this;if(!(u instanceof T))return new T(e,t);if(null==t){if(e&&!0===e._isBigNumber)return u.s=e.s,void(!e.c||e.e>$?u.c=u.e=null:e.e<S?u.c=[u.e=0]:(u.e=e.e,u.c=e.c.slice()));if((s="number"==typeof e)&&0*e==0){if(u.s=1/e<0?(e=-e,-1):1,e===~~e){for(i=0,a=e;10<=a;a/=10,i++);return void($<i?u.c=u.e=null:(u.e=i,u.c=[e]))}c=String(e)}else{if(!isNumeric.test(c=String(e)))return h(u,c,s);u.s=45==c.charCodeAt(0)?(c=c.slice(1),-1):1}0<(a=(c=-1<(i=c.indexOf("."))?c.replace(".",""):c).search(/e/i))?(i<0&&(i=a),i+=+c.slice(a+1),c=c.substring(0,a)):i<0&&(i=c.length)}else{if(intCheck(t,2,O.length,"Base"),10==t&&A)return M(u=new T(e),b+u.e+1,d);if(c=String(e),s="number"==typeof e){if(0*e!=0)return h(u,c,s,t);if(u.s=1/e<0?(c=c.slice(1),-1):1,T.DEBUG&&15<c.replace(/^0\.0*|\./,"").length)throw Error(tooManyDigits+e)}else u.s=45===c.charCodeAt(0)?(c=c.slice(1),-1):1;for(r=O.slice(0,t),i=a=0,l=c.length;a<l;a++)if(r.indexOf(n=c.charAt(a))<0){if("."==n){if(i<a){i=l;continue}}else if(!o&&(c==c.toUpperCase()&&(c=c.toLowerCase())||c==c.toLowerCase()&&(c=c.toUpperCase()))){o=!0,a=-1,i=0;continue}return h(u,String(e),s,t)}s=!1,-1<(i=(c=f(c,t,10,u.s)).indexOf("."))?c=c.replace(".",""):i=c.length}for(a=0;48===c.charCodeAt(a);a++);for(l=c.length;48===c.charCodeAt(--l););if(c=c.slice(a,++l)){if(l-=a,s&&T.DEBUG&&15<l&&(MAX_SAFE_INTEGER<e||e!==mathfloor(e)))throw Error(tooManyDigits+u.s*e);if((i=i-a-1)>$)u.c=u.e=null;else if(i<S)u.c=[u.e=0];else{if(u.e=i,u.c=[],a=(i+1)%LOG_BASE,i<0&&(a+=LOG_BASE),a<l){for(a&&u.c.push(+c.slice(0,a)),l-=LOG_BASE;a<l;)u.c.push(+c.slice(a,a+=LOG_BASE));a=LOG_BASE-(c=c.slice(a)).length}else a-=l;for(;a--;c+="0");u.c.push(+c)}}else u.c=[u.e=0]}function N(e,t,r,n){for(var o,i,a=[0],s=0,l=e.length;s<l;){for(i=a.length;i--;a[i]*=t);for(a[0]+=n.indexOf(e.charAt(s++)),o=0;o<a.length;o++)a[o]>r-1&&(null==a[o+1]&&(a[o+1]=0),a[o+1]+=a[o]/r|0,a[o]%=r)}return a.reverse()}function P(e,t,r){var n,o,i,a=0,s=e.length,l=t%SQRT_BASE,c=t/SQRT_BASE|0;for(e=e.slice();s--;)a=((o=l*(i=e[s]%SQRT_BASE)+(n=c*i+(i=e[s]/SQRT_BASE|0)*l)%SQRT_BASE*SQRT_BASE+a)/r|0)+(n/SQRT_BASE|0)+c*i,e[s]=o%r;return e=a?[a].concat(e):e}function k(e,t,r,n){var o,i;if(r!=n)i=n<r?1:-1;else for(o=i=0;o<r;o++)if(e[o]!=t[o]){i=e[o]>t[o]?1:-1;break}return i}function G(e,t,r,n){for(var o=0;r--;)e[r]-=o,o=e[r]<t[r]?1:0,e[r]=o*n+e[r]-t[r];for(;!e[0]&&1<e.length;e.splice(0,1));}function n(e,t,r,n){var o,i,a,s;if(null==r?r=d:intCheck(r,0,8),!e.c)return e.toString();if(o=e.c[0],i=e.e,null==t)s=coeffToString(e.c),s=1==n||2==n&&(i<=_||v<=i)?toExponential(s,i):toFixedPoint(s,i,"0");else if(r=(e=M(new T(e),t,r)).e,a=(s=coeffToString(e.c)).length,1==n||2==n&&(t<=r||r<=_)){for(;a<t;s+="0",a++);s=toExponential(s,r)}else if(t-=i,s=toFixedPoint(s,r,"0"),a<r+1){if(0<--t)for(s+=".";t--;s+="0");}else if(0<(t+=r-a))for(r+1==a&&(s+=".");t--;s+="0");return e.s<0&&o?"-"+s:s}function i(e,t){for(var r,n=1,o=new T(e[0]);n<e.length;n++){if(!(r=new T(e[n])).s){o=r;break}t.call(o,r)&&(o=r)}return o}function B(e,t,r){for(var n=1,o=t.length;!t[--o];t.pop());for(o=t[0];10<=o;o/=10,n++);return(r=n+r*LOG_BASE-1)>$?e.c=e.e=null:r<S?e.c=[e.e=0]:(e.e=r,e.c=t),e}function M(e,t,r,n){var o,i,a,s,l,c,u,f=e.c,h=POWS_TEN;if(f){e:{for(o=1,s=f[0];10<=s;s/=10,o++);if((i=t-o)<0)i+=LOG_BASE,a=t,u=(l=f[c=0])/h[o-a-1]%10|0;else if((c=mathceil((i+1)/LOG_BASE))>=f.length){if(!n)break e;for(;f.length<=c;f.push(0));l=u=0,a=(i%=LOG_BASE)-LOG_BASE+(o=1)}else{for(l=s=f[c],o=1;10<=s;s/=10,o++);u=(a=(i%=LOG_BASE)-LOG_BASE+o)<0?0:l/h[o-a-1]%10|0}if(n=n||t<0||null!=f[c+1]||(a<0?l:l%h[o-a-1]),n=r<4?(u||n)&&(0==r||r==(e.s<0?3:2)):5<u||5==u&&(4==r||n||6==r&&(0<i?0<a?l/h[o-a]:0:f[c-1])%10&1||r==(e.s<0?8:7)),t<1||!f[0])return f.length=0,n?(t-=e.e+1,f[0]=h[(LOG_BASE-t%LOG_BASE)%LOG_BASE],e.e=-t||0):f[0]=e.e=0,e;if(0==i?(f.length=c,s=1,c--):(f.length=c+1,s=h[LOG_BASE-i],f[c]=0<a?mathfloor(l/h[o-a]%h[a])*s:0),n)for(;;){if(0==c){for(i=1,a=f[0];10<=a;a/=10,i++);for(a=f[0]+=s,s=1;10<=a;a/=10,s++);i!=s&&(e.e++,f[0]==BASE&&(f[0]=1));break}if(f[c]+=s,f[c]!=BASE)break;f[c--]=0,s=1}for(i=f.length;0===f[--i];f.pop());}e.e>$?e.c=e.e=null:e.e<S&&(e.c=[e.e=0])}return e}function j(e){var t,r=e.e;return null===r?e.toString():(t=coeffToString(e.c),t=r<=_||v<=r?toExponential(t,r):toFixedPoint(t,r,"0"),e.s<0?"-"+t:t)}return T.clone=clone,T.ROUND_UP=0,T.ROUND_DOWN=1,T.ROUND_CEIL=2,T.ROUND_FLOOR=3,T.ROUND_HALF_UP=4,T.ROUND_HALF_DOWN=5,T.ROUND_HALF_EVEN=6,T.ROUND_HALF_CEIL=7,T.ROUND_HALF_FLOOR=8,T.EUCLID=9,T.config=T.set=function(e){var t,r;if(null!=e){if("object"!=_typeof(e))throw Error(bignumberError+"Object expected: "+e);if(e.hasOwnProperty(t="DECIMAL_PLACES")&&(intCheck(r=e[t],0,MAX,t),b=r),e.hasOwnProperty(t="ROUNDING_MODE")&&(intCheck(r=e[t],0,8,t),d=r),e.hasOwnProperty(t="EXPONENTIAL_AT")&&((r=e[t])&&r.pop?(intCheck(r[0],-MAX,0,t),intCheck(r[1],0,MAX,t),_=r[0],v=r[1]):(intCheck(r,-MAX,MAX,t),_=-(v=r<0?-r:r))),e.hasOwnProperty(t="RANGE"))if((r=e[t])&&r.pop)intCheck(r[0],-MAX,-1,t),intCheck(r[1],1,MAX,t),S=r[0],$=r[1];else{if(intCheck(r,-MAX,MAX,t),!r)throw Error(bignumberError+t+" cannot be zero: "+r);S=-($=r<0?-r:r)}if(e.hasOwnProperty(t="CRYPTO")){if((r=e[t])!==!!r)throw Error(bignumberError+t+" not true or false: "+r);if(r){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw E=!r,Error(bignumberError+"crypto unavailable");E=r}else E=r}if(e.hasOwnProperty(t="MODULO_MODE")&&(intCheck(r=e[t],0,9,t),o=r),e.hasOwnProperty(t="POW_PRECISION")&&(intCheck(r=e[t],0,MAX,t),w=r),e.hasOwnProperty(t="FORMAT")){if("object"!=_typeof(r=e[t]))throw Error(bignumberError+t+" not an object: "+r);C=r}if(e.hasOwnProperty(t="ALPHABET")){if("string"!=typeof(r=e[t])||/^.?$|[+\-.\s]|(.).*\1/.test(r))throw Error(bignumberError+t+" invalid: "+r);A="0123456789"==r.slice(0,10),O=r}}return{DECIMAL_PLACES:b,ROUNDING_MODE:d,EXPONENTIAL_AT:[_,v],RANGE:[S,$],CRYPTO:E,MODULO_MODE:o,POW_PRECISION:w,FORMAT:C,ALPHABET:O}},T.isBigNumber=function(e){if(!e||!0!==e._isBigNumber)return!1;if(!T.DEBUG)return!0;var t,r,n=e.c,o=e.e,i=e.s;e:if("[object Array]"=={}.toString.call(n)){if((1===i||-1===i)&&-MAX<=o&&o<=MAX&&o===mathfloor(o))if(0===n[0]){if(0===o&&1===n.length)return!0}else if((t=(o+1)%LOG_BASE)<1&&(t+=LOG_BASE),String(n[0]).length==t){for(t=0;t<n.length;t++)if((r=n[t])<0||BASE<=r||r!==mathfloor(r))break e;if(0!==r)return!0}}else if(null===n&&null===o&&(null===i||1===i||-1===i))return!0;throw Error(bignumberError+"Invalid BigNumber: "+e)},T.maximum=T.max=function(){return i(arguments,r.lt)},T.minimum=T.min=function(){return i(arguments,r.gt)},T.random=(t=9007199254740992,c=Math.random()*t&2097151?function(){return mathfloor(Math.random()*t)}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)},function(e){var t,r,n,o,i,a=0,s=[],l=new T(g);if(null==e?e=b:intCheck(e,0,MAX),o=mathceil(e/LOG_BASE),E)if(crypto.getRandomValues){for(t=crypto.getRandomValues(new Uint32Array(o*=2));a<o;)9e15<=(i=131072*t[a]+(t[a+1]>>>11))?(r=crypto.getRandomValues(new Uint32Array(2)),t[a]=r[0],t[a+1]=r[1]):(s.push(i%1e14),a+=2);a=o/2}else{if(!crypto.randomBytes)throw E=!1,Error(bignumberError+"crypto unavailable");for(t=crypto.randomBytes(o*=7);a<o;)9e15<=(i=281474976710656*(31&t[a])+1099511627776*t[a+1]+4294967296*t[a+2]+16777216*t[a+3]+(t[a+4]<<16)+(t[a+5]<<8)+t[a+6])?crypto.randomBytes(7).copy(t,a):(s.push(i%1e14),a+=7);a=o/7}if(!E)for(;a<o;)(i=c())<9e15&&(s[a++]=i%1e14);for(o=s[--a],e%=LOG_BASE,o&&e&&(i=POWS_TEN[LOG_BASE-e],s[a]=mathfloor(o/i)*i);0===s[a];s.pop(),a--);if(a<0)s=[n=0];else{for(n=-1;0===s[0];s.splice(0,1),n-=LOG_BASE);for(a=1,i=s[0];10<=i;i/=10,a++);a<LOG_BASE&&(n-=LOG_BASE-a)}return l.e=n,l.c=s,l}),T.sum=function(){for(var e=1,t=arguments,r=new T(t[0]);e<t.length;)r=r.plus(t[e++]);return r},y="0123456789",f=function(e,t,r,n,o){var i,a,s,l,c,u,f,h,p=e.indexOf("."),g=b,_=d;for(0<=p&&(l=w,w=0,e=e.replace(".",""),u=(h=new T(t)).pow(e.length-p),w=l,h.c=N(toFixedPoint(coeffToString(u.c),u.e,"0"),10,r,y),h.e=h.c.length),s=l=(f=N(e,t,r,o?(i=O,y):(i=y,O))).length;0==f[--l];f.pop());if(!f[0])return i.charAt(0);if(p<0?--s:(u.c=f,u.e=s,u.s=n,f=(u=m(u,h,g,_,r)).c,c=u.r,s=u.e),p=f[a=s+g+1],l=r/2,c=c||a<0||null!=f[a+1],c=_<4?(null!=p||c)&&(0==_||_==(u.s<0?3:2)):l<p||p==l&&(4==_||c||6==_&&1&f[a-1]||_==(u.s<0?8:7)),a<1||!f[0])e=c?toFixedPoint(i.charAt(1),-g,i.charAt(0)):i.charAt(0);else{if(f.length=a,c)for(--r;++f[--a]>r;)f[a]=0,a||(++s,f=[1].concat(f));for(l=f.length;!f[--l];);for(p=0,e="";p<=l;e+=i.charAt(f[p++]));e=toFixedPoint(e,s,i.charAt(0))}return e},m=function(e,t,r,n,o){var i,a,s,l,c,u,f,h,p,g,_,m,y,b,d,v,S,$=e.s==t.s?1:-1,E=e.c,w=t.c;if(!(E&&E[0]&&w&&w[0]))return new T(e.s&&t.s&&(E?!w||E[0]!=w[0]:w)?E&&0==E[0]||!w?0*$:$/0:NaN);for(p=(h=new T($)).c=[],$=r+(a=e.e-t.e)+1,o||(o=BASE,a=bitFloor(e.e/LOG_BASE)-bitFloor(t.e/LOG_BASE),$=$/LOG_BASE|0),s=0;w[s]==(E[s]||0);s++);if(w[s]>(E[s]||0)&&a--,$<0)p.push(1),l=!0;else{for(b=E.length,v=w.length,$+=2,1<(c=mathfloor(o/(w[s=0]+1)))&&(w=P(w,c,o),E=P(E,c,o),v=w.length,b=E.length),y=v,_=(g=E.slice(0,v)).length;_<v;g[_++]=0);S=w.slice(),S=[0].concat(S),d=w[0],w[1]>=o/2&&d++;do{if(c=0,(i=k(w,g,v,_))<0){if(m=g[0],v!=_&&(m=m*o+(g[1]||0)),1<(c=mathfloor(m/d)))for(f=(u=P(w,c=o<=c?o-1:c,o)).length,_=g.length;1==k(u,g,f,_);)c--,G(u,v<f?S:w,f,o),f=u.length,i=1;else 0==c&&(i=c=1),f=(u=w.slice()).length;if(G(g,u=f<_?[0].concat(u):u,_,o),_=g.length,-1==i)for(;k(w,g,v,_)<1;)c++,G(g,v<_?S:w,_,o),_=g.length}else 0===i&&(c++,g=[0])}while(p[s++]=c,g[0]?g[_++]=E[y]||0:(g=[E[y]],_=1),(y++<b||null!=g[0])&&$--);l=null!=g[0],p[0]||p.splice(0,1)}if(o==BASE){for(s=1,$=p[0];10<=$;$/=10,s++);M(h,r+(h.e=s+a*LOG_BASE-1)+1,n,l)}else h.e=a,h.r=+l;return h},a=/^(-?)0([xbo])(?=\w[\w.]*$)/i,s=/^([^.]+)\.$/,l=/^\.([^.]+)$/,u=/^-?(Infinity|NaN)$/,p=/^\s*\+(?=[\w.])|^\s+|\s+$/g,h=function(e,t,r,n){var o,i=r?t:t.replace(p,"");if(u.test(i))e.s=isNaN(i)?null:i<0?-1:1;else{if(!r&&(i=i.replace(a,function(e,t,r){return o="x"==(r=r.toLowerCase())?16:"b"==r?2:8,n&&n!=o?e:t}),n&&(o=n,i=i.replace(s,"$1").replace(l,"0.$1")),t!=i))return new T(i,o);if(T.DEBUG)throw Error(bignumberError+"Not a"+(n?" base "+n:"")+" number: "+t);e.s=null}e.c=e.e=null},r.absoluteValue=r.abs=function(){var e=new T(this);return e.s<0&&(e.s=1),e},r.comparedTo=function(e,t){return compare(this,new T(e,t))},r.decimalPlaces=r.dp=function(e,t){var r,n;if(null!=e)return intCheck(e,0,MAX),null==t?t=d:intCheck(t,0,8),M(new T(this),e+this.e+1,t);if(!(e=this.c))return null;if(r=((n=e.length-1)-bitFloor(this.e/LOG_BASE))*LOG_BASE,n=e[n])for(;n%10==0;n/=10,r--);return r=r<0?0:r},r.dividedBy=r.div=function(e,t){return m(this,new T(e,t),b,d)},r.dividedToIntegerBy=r.idiv=function(e,t){return m(this,new T(e,t),0,1)},r.exponentiatedBy=r.pow=function(e,t){var r,n,o,i,a,s,l,c,u=this;if((e=new T(e)).c&&!e.isInteger())throw Error(bignumberError+"Exponent not an integer: "+j(e));if(null!=t&&(t=new T(t)),a=14<e.e,!u.c||!u.c[0]||1==u.c[0]&&!u.e&&1==u.c.length||!e.c||!e.c[0])return c=new T(Math.pow(+j(u),a?2-isOdd(e):+j(e))),t?c.mod(t):c;if(s=e.s<0,t){if(t.c?!t.c[0]:!t.s)return new T(NaN);(n=!s&&u.isInteger()&&t.isInteger())&&(u=u.mod(t))}else{if(9<e.e&&(0<u.e||u.e<-1||(0==u.e?1<u.c[0]||a&&24e7<=u.c[1]:u.c[0]<8e13||a&&u.c[0]<=9999975e7)))return i=u.s<0&&isOdd(e)?-0:0,-1<u.e&&(i=1/i),new T(s?1/i:i);w&&(i=mathceil(w/LOG_BASE+2))}for(l=a?(r=new T(.5),s&&(e.s=1),isOdd(e)):(o=Math.abs(+j(e)))%2,c=new T(g);;){if(l){if(!(c=c.times(u)).c)break;i?c.c.length>i&&(c.c.length=i):n&&(c=c.mod(t))}if(o){if(0===(o=mathfloor(o/2)))break;l=o%2}else if(M(e=e.times(r),e.e+1,1),14<e.e)l=isOdd(e);else{if(0===(o=+j(e)))break;l=o%2}u=u.times(u),i?u.c&&u.c.length>i&&(u.c.length=i):n&&(u=u.mod(t))}return n?c:(s&&(c=g.div(c)),t?c.mod(t):i?M(c,w,d,void 0):c)},r.integerValue=function(e){var t=new T(this);return null==e?e=d:intCheck(e,0,8),M(t,t.e+1,e)},r.isEqualTo=r.eq=function(e,t){return 0===compare(this,new T(e,t))},r.isFinite=function(){return!!this.c},r.isGreaterThan=r.gt=function(e,t){return 0<compare(this,new T(e,t))},r.isGreaterThanOrEqualTo=r.gte=function(e,t){return 1===(t=compare(this,new T(e,t)))||0===t},r.isInteger=function(){return!!this.c&&bitFloor(this.e/LOG_BASE)>this.c.length-2},r.isLessThan=r.lt=function(e,t){return compare(this,new T(e,t))<0},r.isLessThanOrEqualTo=r.lte=function(e,t){return-1===(t=compare(this,new T(e,t)))||0===t},r.isNaN=function(){return!this.s},r.isNegative=function(){return this.s<0},r.isPositive=function(){return 0<this.s},r.isZero=function(){return!!this.c&&0==this.c[0]},r.minus=function(e,t){var r,n,o,i,a=this,s=a.s;if(t=(e=new T(e,t)).s,!s||!t)return new T(NaN);if(s!=t)return e.s=-t,a.plus(e);var l=a.e/LOG_BASE,c=e.e/LOG_BASE,u=a.c,f=e.c;if(!l||!c){if(!u||!f)return u?(e.s=-t,e):new T(f?a:NaN);if(!u[0]||!f[0])return f[0]?(e.s=-t,e):new T(u[0]?a:3==d?-0:0)}if(l=bitFloor(l),c=bitFloor(c),u=u.slice(),s=l-c){for((o=(i=s<0)?(s=-s,u):(c=l,f)).reverse(),t=s;t--;o.push(0));o.reverse()}else for(n=(i=(s=u.length)<(t=f.length))?s:t,s=t=0;t<n;t++)if(u[t]!=f[t]){i=u[t]<f[t];break}if(i&&(o=u,u=f,f=o,e.s=-e.s),0<(t=(n=f.length)-(r=u.length)))for(;t--;u[r++]=0);for(t=BASE-1;s<n;){if(u[--n]<f[n]){for(r=n;r&&!u[--r];u[r]=t);--u[r],u[n]+=BASE}u[n]-=f[n]}for(;0==u[0];u.splice(0,1),--c);return u[0]?B(e,u,c):(e.s=3==d?-1:1,e.c=[e.e=0],e)},r.modulo=r.mod=function(e,t){var r,n=this;return e=new T(e,t),!n.c||!e.s||e.c&&!e.c[0]?new T(NaN):!e.c||n.c&&!n.c[0]?new T(n):(9==o?(t=e.s,e.s=1,r=m(n,e,0,3),e.s=t,r.s*=t):r=m(n,e,0,o),(e=n.minus(r.times(e))).c[0]||1!=o||(e.s=n.s),e)},r.multipliedBy=r.times=function(e,t){var r,n,o,i,a,s,l,c,u,f,h,p,g,_=this,m=_.c,y=(e=new T(e,t)).c;if(!(m&&y&&m[0]&&y[0]))return!_.s||!e.s||m&&!m[0]&&!y||y&&!y[0]&&!m?e.c=e.e=e.s=null:(e.s*=_.s,m&&y?(e.c=[0],e.e=0):e.c=e.e=null),e;for(t=bitFloor(_.e/LOG_BASE)+bitFloor(e.e/LOG_BASE),e.s*=_.s,(s=m.length)<(_=y.length)&&(h=m,m=y,y=h,n=s,s=_,_=n),n=s+_,h=[];n--;h.push(0));for(p=BASE,g=SQRT_BASE,n=_;0<=--n;){for(u=y[n]%g,f=y[n]/g|(r=0),o=n+(i=s);n<o;)r=((l=u*(l=m[--i]%g)+(a=f*l+(c=m[i]/g|0)*u)%g*g+h[o]+r)/p|0)+(a/g|0)+f*c,h[o--]=l%p;h[o]=r}return r?++t:h.splice(0,1),B(e,h,t)},r.negated=function(){var e=new T(this);return e.s=-e.s||null,e},r.plus=function(e,t){var r,n=this,o=n.s;if(t=(e=new T(e,t)).s,!o||!t)return new T(NaN);if(o!=t)return e.s=-t,n.minus(e);var i=n.e/LOG_BASE,a=e.e/LOG_BASE,s=n.c,l=e.c;if(!i||!a){if(!s||!l)return new T(o/0);if(!s[0]||!l[0])return l[0]?e:new T(s[0]?n:0*o)}if(i=bitFloor(i),a=bitFloor(a),s=s.slice(),o=i-a){for((r=0<o?(a=i,l):(o=-o,s)).reverse();o--;r.push(0));r.reverse()}for((o=s.length)-(t=l.length)<0&&(r=l,l=s,s=r,t=o),o=0;t;)o=(s[--t]=s[t]+l[t]+o)/BASE|0,s[t]=BASE===s[t]?0:s[t]%BASE;return o&&(s=[o].concat(s),++a),B(e,s,a)},r.precision=r.sd=function(e,t){var r,n;if(null!=e&&e!==!!e)return intCheck(e,1,MAX),null==t?t=d:intCheck(t,0,8),M(new T(this),e,t);if(!(t=this.c))return null;if(r=(n=t.length-1)*LOG_BASE+1,n=t[n]){for(;n%10==0;n/=10,r--);for(n=t[0];10<=n;n/=10,r++);}return r=e&&this.e+1>r?this.e+1:r},r.shiftedBy=function(e){return intCheck(e,-MAX_SAFE_INTEGER,MAX_SAFE_INTEGER),this.times("1e"+e)},r.squareRoot=r.sqrt=function(){var e,t,r,n,o,i=this,a=i.c,s=i.s,l=i.e,c=b+4,u=new T("0.5");if(1!==s||!a||!a[0])return new T(!s||s<0&&(!a||a[0])?NaN:a?i:1/0);if((r=0==(s=Math.sqrt(+j(i)))||s==1/0?(((t=coeffToString(a)).length+l)%2==0&&(t+="0"),s=Math.sqrt(+t),l=bitFloor((l+1)/2)-(l<0||l%2),new T(t=s==1/0?"5e"+l:(t=s.toExponential()).slice(0,t.indexOf("e")+1)+l)):new T(s+"")).c[0])for((s=(l=r.e)+c)<3&&(s=0);;)if(o=r,r=u.times(o.plus(m(i,o,c,1))),coeffToString(o.c).slice(0,s)===(t=coeffToString(r.c)).slice(0,s)){if(r.e<l&&--s,"9999"!=(t=t.slice(s-3,s+1))&&(n||"4999"!=t)){+t&&(+t.slice(1)||"5"!=t.charAt(0))||(M(r,r.e+b+2,1),e=!r.times(r).eq(i));break}if(!n&&(M(o,o.e+b+2,0),o.times(o).eq(i))){r=o;break}c+=4,s+=4,n=1}return M(r,r.e+b+1,d,e)},r.toExponential=function(e,t){return null!=e&&(intCheck(e,0,MAX),e++),n(this,e,t,1)},r.toFixed=function(e,t){return null!=e&&(intCheck(e,0,MAX),e=e+this.e+1),n(this,e,t)},r.toFormat=function(e,t,r){if(null==r)null!=e&&t&&"object"==_typeof(t)?(r=t,t=null):e&&"object"==_typeof(e)?(r=e,e=t=null):r=C;else if("object"!=_typeof(r))throw Error(bignumberError+"Argument not an object: "+r);if(e=this.toFixed(e,t),this.c){var n,t=e.split("."),o=+r.groupSize,i=+r.secondaryGroupSize,a=r.groupSeparator||"",s=t[0],t=t[1],l=this.s<0,c=l?s.slice(1):s,u=c.length;if(i&&(n=o,o=i,u-=i=n),0<o&&0<u){for(s=c.substr(0,n=u%o||o);n<u;n+=o)s+=a+c.substr(n,o);0<i&&(s+=a+c.slice(n)),l&&(s="-"+s)}e=t?s+(r.decimalSeparator||"")+((i=+r.fractionGroupSize)?t.replace(new RegExp("\\d{"+i+"}\\B","g"),"$&"+(r.fractionGroupSeparator||"")):t):s}return(r.prefix||"")+e+(r.suffix||"")},r.toFraction=function(e){var t,r,n,o,i,a,s,l,c,u,f=this,h=f.c;if(null!=e&&(!(s=new T(e)).isInteger()&&(s.c||1!==s.s)||s.lt(g)))throw Error(bignumberError+"Argument "+(s.isInteger()?"out of range: ":"not an integer: ")+j(s));if(!h)return new T(f);for(t=new T(g),c=r=new T(g),n=l=new T(g),h=coeffToString(h),i=t.e=h.length-f.e-1,t.c[0]=POWS_TEN[(a=i%LOG_BASE)<0?LOG_BASE+a:a],e=!e||0<s.comparedTo(t)?0<i?t:c:s,a=$,$=1/0,s=new T(h),l.c[0]=0;u=m(s,t,0,1),1!=(o=r.plus(u.times(n))).comparedTo(e);)r=n,n=o,c=l.plus(u.times(o=c)),l=o,t=s.minus(u.times(o=t)),s=o;return o=m(e.minus(r),n,0,1),l=l.plus(o.times(c)),r=r.plus(o.times(n)),l.s=c.s=f.s,h=m(c,n,i*=2,d).minus(f).abs().comparedTo(m(l,r,i,d).minus(f).abs())<1?[c,n]:[l,r],$=a,h},r.toNumber=function(){return+j(this)},r.toPrecision=function(e,t){return null!=e&&intCheck(e,1,MAX),n(this,e,t,2)},r.toString=function(e){var t,r=this,n=r.s,o=r.e;return null===o?n?(t="Infinity",n<0&&(t="-"+t)):t="NaN":(t=null==e?o<=_||v<=o?toExponential(coeffToString(r.c),o):toFixedPoint(coeffToString(r.c),o,"0"):10===e&&A?toFixedPoint(coeffToString((r=M(new T(r),b+o+1,d)).c),r.e,"0"):(intCheck(e,2,O.length,"Base"),f(toFixedPoint(coeffToString(r.c),o,"0"),10,e,n,!0)),n<0&&r.c[0]&&(t="-"+t)),t},r.valueOf=r.toJSON=function(){return j(this)},r._isBigNumber=!0,r[Symbol.toStringTag]="BigNumber",r[Symbol.for("nodejs.util.inspect.custom")]=r.valueOf,null!=e&&T.set(e),T}function bitFloor(e){var t=0|e;return 0<e||e===t?t:t-1}function coeffToString(e){for(var t,r,n=1,o=e.length,i=e[0]+"";n<o;){for(t=e[n++]+"",r=LOG_BASE-t.length;r--;t="0"+t);i+=t}for(o=i.length;48===i.charCodeAt(--o););return i.slice(0,o+1||1)}function compare(e,t){var r,n,o=e.c,i=t.c,a=e.s,s=t.s,e=e.e,t=t.e;if(!a||!s)return null;if(r=o&&!o[0],n=i&&!i[0],r||n)return r?n?0:-s:a;if(a!=s)return a;if(r=a<0,n=e==t,!o||!i)return n?0:!o^r?1:-1;if(!n)return t<e^r?1:-1;for(s=(e=o.length)<(t=i.length)?e:t,a=0;a<s;a++)if(o[a]!=i[a])return o[a]>i[a]^r?1:-1;return e==t?0:t<e^r?1:-1}function intCheck(e,t,r,n){if(e<t||r<e||e!==mathfloor(e))throw Error(bignumberError+(n||"Argument")+("number"==typeof e?e<t||r<e?" out of range: ":" not an integer: ":" not a primitive number: ")+String(e))}function isOdd(e){var t=e.c.length-1;return bitFloor(e.e/LOG_BASE)==t&&e.c[t]%2!=0}function toExponential(e,t){return(1<e.length?e.charAt(0)+"."+e.slice(1):e)+(t<0?"e":"e+")+t}function toFixedPoint(e,t,r){var n,o;if(t<0){for(o=r+".";++t;o+=r);e=o+e}else if(++t>(n=e.length)){for(o=r,t-=n;--t;o+=r);e+=o}else t<n&&(e=e.slice(0,t)+"."+e.slice(t));return e}var BigNumber=clone();function decimalRound(n,o,e,i,t){var a=n,s=o,r=o.length,l={"~-":function(){s=o.slice(0,i)},"~+":function(){""===(s=o.slice(0,i))?a=n.slice(0,n.length-1)+(+n[n.length-1]+1):s=s.slice(0,i-1)+(+s[i-1]+1)},"~5":function(){s=o.slice(0,i);var e=+o[i];""===s?5<=e&&(a=n.slice(0,n.length-1)+(+n[n.length-1]+1)):5<=e&&(s=s.slice(0,i-1)+(+s[i-1]+1))},"~6":function(){s=o.slice(0,i);var e=""===(e=o.slice(+i+1,o.length))?0:parseInt(e),t=+o[i],r=+n[n.length-1];""===s?(6<=t||5==t&&0<e||5==t&&r%2!=0)&&(a=n.slice(0,n.length-1)+(+n[n.length-1]+1)):(r=+o[i-1],(6<=t||5==t&&0<e||5==t&&r%2!=0)&&(s=s.slice(0,i-1)+(+s[i-1]+1)))}};return"<="===e?r<=i?s=o:l[t]&&l[t]():"="===e?r<i?s=o+"0".repeat(i-r):i<r&&l[t]&&l[t]():">="===e&&r<i&&(s=o+"0".repeat(i-r)),{intPart:a,decPart:s}}function format(e,t,r){var n="";if(BigNumber.isBigNumber(e))n=e.toFixed();else if("string"!=typeof e)n=e.toString();else if(!0===r){r=splitUnitNum(e);if(null===r.num)return null;n=BigNumber(r.num).toFixed()}else n=BigNumber(e).toFixed();if("undefined"===n||"NaN"===n)return null;var o=null,i=null,a=null,s=null,l="~-";return t.forEach(function(e){var t=e.type;if("symbol"===t){if(![">=","<=","="].includes(e.value))throw new Error("错误的格式化参数:",e.value);i=e.value}else if("comma"===t)a=!0;else if("number"===t)o=e.value;else if("plus"===t)s=!0;else{if("round"!==t)throw new Error("错误的fmt Token");l=e.value}}),null!==o&&(e=(t=decimalRound(e=(r=n.split("."))[0],1===r.length?"":r[1],i,o,l)).intPart,n=""===(r=t.decPart)?e:"".concat(e,".").concat(r)),null!==a&&(n=1<(t=n.split(".")).length?((e=t[0]).includes("-")?t[0]=e[0]+e.slice(1).replace(/(?=(?!^)(?:\d{3})+$)/g,","):t[0]=e.replace(/(?=(?!^)(?:\d{3})+$)/g,","),t.join(".")):(r=t[0]).includes("-")?r[0]+r.slice(1).replace(/(?=(?!^)(?:\d{3})+$)/g,","):r.replace(/(?=(?!^)(?:\d{3})+$)/g,",")),n=null===s||n.startsWith("-")?n:"+"+n}function tokenizer(e){for(var t=1<arguments.length&&void 0!==arguments[1]&&arguments[1],r=[],n=0,o=null,i=e.length;n<i;)if(o=e[n],/\s/.test(o))n++;else if("+-".includes(o)){var a=r[r.length-1];if(0===r.length||"+-".includes(a)||"("===a){var s=o;if(++n>=i){r.push(s);break}for(var o=e[n],l=0;/[^*/()\s]/.test(o)&&(["+","-"].includes(o)&&l++,!(2<l||!/[eE]/.test(s[s.length-1])&&"+-".includes(o)))&&(s+=o,!(++n>=i));)o=e[n];r.push(s)}else r.push(o),n++}else if("*/%()".includes(o))r.push(o),n++;else if(/[a-zA-Z_$]/.test(o)){for(var c="";/[\w_.\[\]"']/.test(o)&&(c+=o,!(++n>=i));)o=e[n];r.push(c)}else if(/\d/.test(o)){for(var u="",f=0,h=void 0,h=t?/[^*/()\s]/:/[\d.eE\+-]/;h.test(o)&&(["+","-"].includes(o)&&f++,!(1<f||!/[eE]/.test(u[u.length-1])&&"+-".includes(o)))&&(u+=o,!(++n>=i));)o=e[n];r.push(u)}return r}var commonjsGlobal="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},isArray$3=Array.isArray,isArray_1=isArray$3,freeGlobal$1="object"==_typeof(commonjsGlobal)&&commonjsGlobal&&commonjsGlobal.Object===Object&&commonjsGlobal,_freeGlobal=freeGlobal$1,freeGlobal=freeGlobal$1,freeSelf="object"==("undefined"==typeof self?"undefined":_typeof(self))&&self&&self.Object===Object&&self,root$3=freeGlobal||freeSelf||Function("return this")(),_root=root$3,root$2=_root,_Symbol2=_root.Symbol,_Symbol$3=_Symbol2,_Symbol$2=_Symbol$3,objectProto$4=Object.prototype,hasOwnProperty$3=objectProto$4.hasOwnProperty,nativeObjectToString$1=objectProto$4.toString,symToStringTag$1=_Symbol$2?_Symbol$2.toStringTag:void 0;function getRawTag$1(e){var t=hasOwnProperty$3.call(e,symToStringTag$1),r=e[symToStringTag$1];try{var n=!(e[symToStringTag$1]=void 0)}catch(e){}var o=nativeObjectToString$1.call(e);return n&&(t?e[symToStringTag$1]=r:delete e[symToStringTag$1]),o}var _getRawTag=getRawTag$1,objectProto$3=Object.prototype,nativeObjectToString=objectProto$3.toString;function objectToString$1(e){return nativeObjectToString.call(e)}var _objectToString=objectToString$1,_Symbol$1=_Symbol$3,getRawTag=_getRawTag,objectToString=objectToString$1,nullTag="[object Null]",undefinedTag="[object Undefined]",symToStringTag=_Symbol$3?_Symbol$3.toStringTag:void 0;function baseGetTag$2(e){return null==e?void 0===e?undefinedTag:nullTag:(symToStringTag&&symToStringTag in Object(e)?getRawTag:objectToString)(e)}var _baseGetTag=baseGetTag$2;function isObjectLike$1(e){return null!=e&&"object"==_typeof(e)}var isObjectLike_1=isObjectLike$1,baseGetTag$1=baseGetTag$2,isObjectLike=isObjectLike$1,symbolTag="[object Symbol]";function isSymbol$3(e){return"symbol"==_typeof(e)||isObjectLike(e)&&baseGetTag$1(e)==symbolTag}var isSymbol_1=isSymbol$3,isArray$2=isArray_1,isSymbol$2=isSymbol_1,reIsDeepProp=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,reIsPlainProp=/^\w*$/;function isKey$1(e,t){if(isArray$2(e))return!1;var r=_typeof(e);return!("number"!=r&&"symbol"!=r&&"boolean"!=r&&null!=e&&!isSymbol$2(e))||(reIsPlainProp.test(e)||!reIsDeepProp.test(e)||null!=t&&e in Object(t))}var _isKey=isKey$1;function isObject$2(e){var t=_typeof(e);return null!=e&&("object"==t||"function"==t)}var isObject_1=isObject$2,baseGetTag=baseGetTag$2,isObject$1=isObject_1,asyncTag="[object AsyncFunction]",funcTag="[object Function]",genTag="[object GeneratorFunction]",proxyTag="[object Proxy]";function isFunction$1(e){if(!isObject$1(e))return!1;e=baseGetTag(e);return e==funcTag||e==genTag||e==asyncTag||e==proxyTag}var isFunction_1=isFunction$1,root$1=_root,coreJsData$1=_root["__core-js_shared__"],_coreJsData=coreJsData$1,coreJsData=coreJsData$1,maskSrcKey=function(){var e=/[^.]+$/.exec(coreJsData&&coreJsData.keys&&coreJsData.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function isMasked$1(e){return!!maskSrcKey&&maskSrcKey in e}var _isMasked=isMasked$1,funcProto$1=Function.prototype,funcToString$1=funcProto$1.toString;function toSource$1(e){if(null!=e){try{return funcToString$1.call(e)}catch(e){}try{return e+""}catch(e){}}return""}var _toSource=toSource$1,isFunction=isFunction_1,isMasked=_isMasked,isObject=isObject_1,toSource=toSource$1,reRegExpChar=/[\\^$.*+?()[\]{}|]/g,reIsHostCtor=/^\[object .+?Constructor\]$/,funcProto=Function.prototype,objectProto$2=Object.prototype,funcToString=funcProto.toString,hasOwnProperty$2=objectProto$2.hasOwnProperty,reIsNative=RegExp("^"+funcToString.call(hasOwnProperty$2).replace(reRegExpChar,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function baseIsNative$1(e){return!(!isObject(e)||isMasked(e))&&(isFunction(e)?reIsNative:reIsHostCtor).test(toSource(e))}var _baseIsNative=baseIsNative$1;function getValue$1(e,t){return null==e?void 0:e[t]}var _getValue=getValue$1,baseIsNative=baseIsNative$1,getValue=getValue$1;function getNative$2(e,t){e=getValue(e,t);return baseIsNative(e)?e:void 0}var _getNative=getNative$2,getNative$1=_getNative,nativeCreate$4=_getNative(Object,"create"),_nativeCreate=nativeCreate$4,nativeCreate$3=_nativeCreate;function hashClear$1(){this.__data__=nativeCreate$3?nativeCreate$3(null):{},this.size=0}var _hashClear=hashClear$1;function hashDelete$1(e){e=this.has(e)&&delete this.__data__[e];return this.size-=e?1:0,e}var _hashDelete=hashDelete$1,nativeCreate$2=_nativeCreate,HASH_UNDEFINED$1="__lodash_hash_undefined__",objectProto$1=Object.prototype,hasOwnProperty$1=objectProto$1.hasOwnProperty;function hashGet$1(e){var t,r=this.__data__;return nativeCreate$2?(t=r[e])===HASH_UNDEFINED$1?void 0:t:hasOwnProperty$1.call(r,e)?r[e]:void 0}var _hashGet=hashGet$1,nativeCreate$1=_nativeCreate,objectProto=Object.prototype,hasOwnProperty=objectProto.hasOwnProperty;function hashHas$1(e){var t=this.__data__;return nativeCreate$1?void 0!==t[e]:hasOwnProperty.call(t,e)}var _hashHas=hashHas$1,nativeCreate=_nativeCreate,HASH_UNDEFINED="__lodash_hash_undefined__";function hashSet$1(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=nativeCreate&&void 0===t?HASH_UNDEFINED:t,this}var _hashSet=hashSet$1,hashClear=_hashClear,hashDelete=_hashDelete,hashGet=_hashGet,hashHas=hashHas$1,hashSet=hashSet$1;function Hash$1(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}Hash$1.prototype.clear=hashClear,Hash$1.prototype.delete=hashDelete,Hash$1.prototype.get=hashGet,Hash$1.prototype.has=hashHas,Hash$1.prototype.set=hashSet;var _Hash=Hash$1;function listCacheClear$1(){this.__data__=[],this.size=0}var _listCacheClear=listCacheClear$1;function eq$1(e,t){return e===t||e!=e&&t!=t}var eq_1=eq$1,eq=eq$1;function assocIndexOf$4(e,t){for(var r=e.length;r--;)if(eq(e[r][0],t))return r;return-1}var _assocIndexOf=assocIndexOf$4,assocIndexOf$3=_assocIndexOf,arrayProto=Array.prototype,splice=arrayProto.splice;function listCacheDelete$1(e){var t=this.__data__,e=assocIndexOf$3(t,e);return!(e<0)&&(e==t.length-1?t.pop():splice.call(t,e,1),--this.size,!0)}var _listCacheDelete=listCacheDelete$1,assocIndexOf$2=_assocIndexOf;function listCacheGet$1(e){var t=this.__data__,e=assocIndexOf$2(t,e);return e<0?void 0:t[e][1]}var _listCacheGet=listCacheGet$1,assocIndexOf$1=_assocIndexOf;function listCacheHas$1(e){return-1<assocIndexOf$1(this.__data__,e)}var _listCacheHas=listCacheHas$1,assocIndexOf=_assocIndexOf;function listCacheSet$1(e,t){var r=this.__data__,n=assocIndexOf(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this}var _listCacheSet=listCacheSet$1,listCacheClear=_listCacheClear,listCacheDelete=listCacheDelete$1,listCacheGet=listCacheGet$1,listCacheHas=listCacheHas$1,listCacheSet=listCacheSet$1;function ListCache$1(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}ListCache$1.prototype.clear=listCacheClear,ListCache$1.prototype.delete=listCacheDelete,ListCache$1.prototype.get=listCacheGet,ListCache$1.prototype.has=listCacheHas,ListCache$1.prototype.set=listCacheSet;var _ListCache=ListCache$1,getNative=_getNative,root=_root,Map$2=_getNative(_root,"Map"),_Map=Map$2,Hash=_Hash,ListCache=_ListCache,Map$1=Map$2;function mapCacheClear$1(){this.size=0,this.__data__={hash:new Hash,map:new(Map$1||ListCache),string:new Hash}}var _mapCacheClear=mapCacheClear$1;function isKeyable$1(e){var t=_typeof(e);return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e}var _isKeyable=isKeyable$1,isKeyable=isKeyable$1;function getMapData$4(e,t){e=e.__data__;return isKeyable(t)?e["string"==typeof t?"string":"hash"]:e.map}var _getMapData=getMapData$4,getMapData$3=getMapData$4;function mapCacheDelete$1(e){e=getMapData$3(this,e).delete(e);return this.size-=e?1:0,e}var _mapCacheDelete=mapCacheDelete$1,getMapData$2=getMapData$4;function mapCacheGet$1(e){return getMapData$2(this,e).get(e)}var _mapCacheGet=mapCacheGet$1,getMapData$1=getMapData$4;function mapCacheHas$1(e){return getMapData$1(this,e).has(e)}var _mapCacheHas=mapCacheHas$1,getMapData=getMapData$4;function mapCacheSet$1(e,t){var r=getMapData(this,e),n=r.size;return r.set(e,t),this.size+=r.size==n?0:1,this}var _mapCacheSet=mapCacheSet$1,mapCacheClear=mapCacheClear$1,mapCacheDelete=mapCacheDelete$1,mapCacheGet=mapCacheGet$1,mapCacheHas=mapCacheHas$1,mapCacheSet=mapCacheSet$1;function MapCache$1(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}MapCache$1.prototype.clear=mapCacheClear,MapCache$1.prototype.delete=mapCacheDelete,MapCache$1.prototype.get=mapCacheGet,MapCache$1.prototype.has=mapCacheHas,MapCache$1.prototype.set=mapCacheSet;var _MapCache=MapCache$1,MapCache=MapCache$1,FUNC_ERROR_TEXT="Expected a function";function memoize$1(n,o){if("function"!=typeof n||null!=o&&"function"!=typeof o)throw new TypeError(FUNC_ERROR_TEXT);function i(){var e=arguments,t=o?o.apply(this,e):e[0],r=i.cache;return r.has(t)?r.get(t):(e=n.apply(this,e),i.cache=r.set(t,e)||r,e)}return i.cache=new(memoize$1.Cache||MapCache),i}memoize$1.Cache=MapCache;var memoize_1=memoize$1,memoize=memoize$1,MAX_MEMOIZE_SIZE=500;function memoizeCapped$1(e){var e=memoize(e,function(e){return t.size===MAX_MEMOIZE_SIZE&&t.clear(),e}),t=e.cache;return e}var _memoizeCapped=memoizeCapped$1,memoizeCapped=memoizeCapped$1,rePropName=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,reEscapeChar=/\\(\\)?/g,stringToPath$1=memoizeCapped$1(function(e){var o=[];return 46===e.charCodeAt(0)&&o.push(""),e.replace(rePropName,function(e,t,r,n){o.push(r?n.replace(reEscapeChar,"$1"):t||e)}),o}),_stringToPath=stringToPath$1;function arrayMap$1(e,t){for(var r=-1,n=null==e?0:e.length,o=Array(n);++r<n;)o[r]=t(e[r],r,e);return o}var _arrayMap=arrayMap$1,_Symbol=_Symbol$3,arrayMap=arrayMap$1,isArray$1=isArray_1,isSymbol$1=isSymbol_1,INFINITY$1=1/0,symbolProto=_Symbol$3?_Symbol$3.prototype:void 0,symbolToString=symbolProto?symbolProto.toString:void 0;function baseToString$1(e){if("string"==typeof e)return e;if(isArray$1(e))return arrayMap(e,baseToString$1)+"";if(isSymbol$1(e))return symbolToString?symbolToString.call(e):"";var t=e+"";return"0"==t&&1/e==-INFINITY$1?"-0":t}var _baseToString=baseToString$1,baseToString=baseToString$1;function toString$1(e){return null==e?"":baseToString(e)}var toString_1=toString$1,isArray=isArray_1,isKey=_isKey,stringToPath=_stringToPath,toString=toString$1;function castPath$1(e,t){return isArray(e)?e:isKey(e,t)?[e]:stringToPath(toString(e))}var _castPath=castPath$1,isSymbol=isSymbol_1,INFINITY=1/0;function toKey$1(e){if("string"==typeof e||isSymbol(e))return e;var t=e+"";return"0"==t&&1/e==-INFINITY?"-0":t}var _toKey=toKey$1,castPath=castPath$1,toKey=toKey$1;function baseGet$1(e,t){for(var r=0,n=(t=castPath(t,e)).length;null!=e&&r<n;)e=e[toKey(t[r++])];return r&&r==n?e:void 0}var _baseGet=baseGet$1,baseGet=baseGet$1;function get(e,t,r){e=null==e?void 0:baseGet(e,t);return void 0===e?r:e}var get_1=get;function fillTokens(e,t,r){var n=[];if(!notNull(t))throw new TokensFillError("错误的填充数据:",t);Array.isArray(t)?n=t:n.push(t);for(var o=[],i=0;i<e.length;i++){var a=e[i];if(RVar.test(a)){if("undefined"===a||"NaN"===a)throw new TokensFillError("key不应该为:".concat(a));for(var s=null,l=0;l<n.length;l++){var c=n[l],c=get_1(c,a);if(void 0!==c){s=c;break}}if(null===s)throw new TokensFillError("token填充失败,请确认".concat(a,"存在"));if("string"==typeof s){if(""===s.trim())throw new TokensFillError("token填充失败,".concat(a,"值不可为空字符"));if(!0===r){if(!RUnitNumber.test(s))throw new TokensFillError("token填充失败,".concat(a,"值:").concat(s,"为非法单位数字"))}else if(!isStrNumber(s))throw new TokensFillError("token填充失败,".concat(a,"值:").concat(s,"为非法数字"))}s="string"!=typeof s?s.toString():s,o.push(s)}else o.push(a)}return o}function fillFmtTokens(e,n){return e.map(function(e){if("var"!==e.type)return e;for(var t,r=0;r<n.length&&!notUndefined(t=get_1(n[r],e.value));r++);if(isNumber(t))return{type:"number",value:t};throw new TokensFillError("错误的填充值")})}function getTokenAndUnit(e){var r=null;return e.length,{tokens:e.map(function(e){var t=splitUnitNum(e);return null!==t.unit?(null==r&&(r=t.unit),t.num):e}),unit:r}}function fmt(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];var n=parseArgs(t),o=tokenizer(n.expr,get_1(n,"data._unit",!1)),i=null,a=null;if(!0===get_1(n,"data._debug")&&(console.warn("======a-calc调试模式======"),console.warn(n),console.warn(o)),""===n.expr.trim()&&notNull(n.data)&&notUndefined(n.data._error))return n.data._error;if(2<o.length)throw new Error("fmt并非用于计算, 不能传入多个标识:".concat(n.expr));if(1!==o.length)throw new Error("fmt接收了一个无法被解析的标识");if(notNull(n.data)){var s,l=n.data,c=[],u=l._fillError,f=get_1(l,"_unit",null);if(Array.isArray(l)?c=l:(c.push(i=l),notUndefined(s=get_1(i,"_fillData"))&&(Array.isArray(s)?c=[].concat(_toConsumableArray(c),_toConsumableArray(s)):c.push(s))),anyNotUndefined(u,l._error))try{o=fillTokens(o,c,f),notNull(n.fmt)&&(n.fmt=fillFmtTokens(n.fmt,c))}catch(e){if(e instanceof TokensFillError)return void 0!==i._warn&&!0===i._warn&&console.warn(e),i._fillError||i._error;throw e}else o=fillTokens(o,c,f),notNull(n.fmt)&&(n.fmt=fillFmtTokens(n.fmt,c));!0===f&&(a=(s=getTokenAndUnit(o)).unit,o=s.tokens)}u=o[0];if(!0===f){if(!RUnitNumber.test(u))throw new TokensFillError("token填充失败,".concat(key,"值:").concat(value,"为非法单位数字"))}else if(!isStrNumber(u))throw new TokensFillError("待格式化对象: ".concat(u," 不是数字"));return null!==(l=null!==n.fmt?format(u,n.fmt,f):BigNumber(u).toFixed())&&null!==a&&(l+=a),l}var version="0.0.80";function token2postfix(e){for(var t=[],r=[],n=e;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;)r.push(i),i=t.pop();if("("!==i)throw"error: unmatched ()"}else{for(;prioraty(o,t[t.length-1])&&0<t.length;)r.push(t.pop());t.push(o)}else r.push(o)}if(0<t.length){if(")"===t[t.length-1]||"("===t[t.length-1])throw"error: unmatched ()";for(;0<t.length;)r.push(t.pop())}return r}function evalPostfix(e){for(var t=[];0<e.length;){var r=e.shift();if(isOperator(r)){if(t.length<2)throw new CalculatorError("错误的栈长度, 可能是无法计算的表达式");var n=t.pop(),o=t.pop();if("string"==typeof n&&!BigNumber.isBigNumber(n)){if(!isStrNumber(n))throw new CalculatorError("".concat(n,"不是一个合法的数字"));n=new BigNumber(n)}if("string"==typeof o&&!BigNumber.isBigNumber(o)){if(!isStrNumber(o))throw new CalculatorError("".concat(o,"不是一个合法的数字"));o=new BigNumber(o)}switch(r){case"+":t.push(o.plus(n));break;case"-":t.push(o.minus(n));break;case"*":t.push(o.times(n));break;case"/":t.push(o.div(n));break;case"%":t.push(o.mod(n))}}else t.push(r)}if(1!==t.length)throw"unvalid expression";var i=t[0];if((i=BigNumber.isBigNumber(i)?i:BigNumber(i)).isNaN())throw new CalculatorError("计算结果为NaN");return i}function calc(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];var n,o=parseArgs(t),i=tokenizer(o.expr,get_1(o,"data._unit",!1)),a=null,s=null;if(!0===get_1(o,"data._debug")&&(console.warn("======a-calc调试模式======"),console.warn(o),console.warn(i),o.fmt&&console.warn(o.fmt)),notNull(o.data)){var l=o.data,c=[],u=l._error,f=l._fillError,h=l._warn,p=get_1(l,"_unit",null);if(Array.isArray(l)?c=l:(c.push(a=l),notUndefined(l=get_1(a,"_fillData"))&&(Array.isArray(l)?c=[].concat(_toConsumableArray(c),_toConsumableArray(l)):c.push(l))),anyNotUndefined(f,u))try{i=fillTokens(i,c,p),notNull(o.fmt)&&(o.fmt=fillFmtTokens(o.fmt,c))}catch(e){if(e instanceof TokensFillError)return notUndefined(h)&&!0===h&&console.warn(e),notUndefined(f)?f:u;throw e}else i=fillTokens(i,c,p),notNull(o.fmt)&&(o.fmt=fillFmtTokens(o.fmt,c));!0===p&&(s=(l=getTokenAndUnit(i)).unit,i=l.tokens)}!0===get_1(o,"data._debug")&&(console.warn(i),console.warn("单位:".concat(s)));f=token2postfix(i),c=null;if(notNull(a)&&anyNotUndefined(n,u))try{c=evalPostfix(f)}catch(e){if(e instanceof CalculatorError)return void 0!==h&&!0===h&&console.warn(e),notUndefined(n)?n:u;throw e}else c=evalPostfix(f);return null!==(c=notNull(o.fmt)?format(c,o.fmt):null!==c?c.toFixed():null)&&null!==s&&(c+=s),c}export{calc,fmt,version};
package/package.json CHANGED
@@ -1,34 +1,33 @@
1
1
  {
2
2
  "name": "a-calc",
3
- "version": "0.0.72",
4
- "description": "JavaScript的字符串四则运算库, 支持格式化操作例如: 千分位格式化, 灵活指定小数点位数",
5
- "main": "./cjs/index.js",
3
+ "version": "0.0.80",
4
+ "description": "JavaScript的精准四则运算库,支持复杂运算与格式化操作例如: 带单位计算,千分位, 灵活指定小数点位数,指定舍入规则",
5
+ "main": "./cjs/index.cjs",
6
6
  "exports": {
7
7
  ".": {
8
- "import": "./es/index.js",
9
- "require": "./cjs/index.js"
8
+ "import": "./es/index.mjs",
9
+ "require": "./cjs/index.cjs"
10
10
  },
11
11
  "./es": {
12
- "import": "./es/index.js",
13
- "default": "./es/index.js"
12
+ "import": "./es/index.mjs",
13
+ "default": "./es/index.mjs"
14
14
  },
15
15
  "./cjs": {
16
- "require": "./cjs/index.js",
17
- "default": "./cjs/index.js"
16
+ "require": "./cjs/index.cjs",
17
+ "default": "./cjs/index.cjs"
18
18
  }
19
19
  },
20
20
  "browser": "./browser/index.js",
21
- "module": "./es/index.js",
21
+ "module": "./es/index.mjs",
22
22
  "typings": "./calc.d.ts",
23
23
  "scripts": {
24
24
  "dev": "rollup -c --environment build:dev",
25
25
  "dev:w": "rollup -c -w --environment build:dev",
26
- "build": "rollup -c --environment build:build",
26
+ "build": "rollup -c --environment build:build & yarn test",
27
27
  "build:w": "rollup -c -w --environment build:build",
28
- "test": "cross-env ava"
28
+ "test": "cross-env ava --verbose --tap test/*.mjs"
29
29
  },
30
30
  "files": [
31
- "example",
32
31
  "es",
33
32
  "cjs",
34
33
  "browser",
@@ -1,67 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <meta charset="UTF-8">
5
- <title>Title</title>
6
- </head>
7
- <body>
8
- <script src="./index.js"></script>
9
- <script>
10
- const { calc, fmt } = a_calc;
11
-
12
-
13
- console.log(fmt("07987987789.23442231元 | , +=2",{_unit: true}))
14
- // console.log(
15
- // fmt("1 + 1",{_fmt:",>=4", _error:"-"})
16
- // );
17
-
18
- // console.log(
19
- // calc("a + b - c * 12131312 | =2,(-)", [
20
- // { a: 1 },
21
- // { b: 2, c: 3 }
22
- // ])
23
- // );
24
-
25
- // console.log(calc("1 + 2.2 + 3.3| , esdfds.",{_error: "-",_fmt: "=", esdfds: {
26
- // dew: 10,
27
- // }}))
28
-
29
- // console.log(calc("a + 234% | +,=8",{a: "1.010", _unit:true}))
30
- // console.log(fmt("10.00% | <=3", {_unit: true}))
31
- //
32
- // console.log(calc("2123ddf - +2 | =n",{n: 5,_unit: true}))
33
-
34
- // console.log(fmt("a | =n",{a: "-1.10%",n:3, _unit: true}))
35
-
36
-
37
- // console.log(fmt("a | +,>=n",{a: "+10000.100%",n:5, _unit: true}))
38
-
39
- // console.log(calc("0.0012 + +2 * 2 - 100% | +,=4",{_unit: true, _debug: true}))
40
-
41
- // console.log(calc("12321.21321 * (a * 232%) - 10000000% | +, <=4", {_unit: true, a: 3.33}))
42
-
43
- // console.log(calc("+23.232400 | <=8",{a: 1232423.23432}))
44
-
45
-
46
- // console.log(calc("1 + o.a / arr[0].d",{
47
- // o: { a: 2 },
48
- // arr: [{ d: 8 }]
49
- // }))
50
-
51
-
52
- // console.log(calc("1 + 1 | +"))
53
-
54
- // console.log(calc("10000000 + 100000000 | +,=10"))
55
-
56
- // console.log(calc("1.123$$$ + 2.88% | + =6", {_unit: true}))
57
-
58
- // console.log(calc("1 + 2sd + d", {
59
- // d: 8,
60
- // _error: "-"
61
- // }))
62
- //
63
- // console.log(calc("111111 + 11111 | ,",{_fmt: "=2"}))
64
-
65
- </script>
66
- </body>
67
- </html>
package/cjs/index.js DELETED
@@ -1 +0,0 @@
1
- "use strict";function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function _createClass(e,t,r){return t&&_defineProperties(e.prototype,t),r&&_defineProperties(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&_setPrototypeOf(e,t)}function _getPrototypeOf(e){return(_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function _setPrototypeOf(e,t){return(_setPrototypeOf=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}function _construct(e,t,r){return(_construct=_isNativeReflectConstruct()?Reflect.construct:function(e,t,r){var n=[null];n.push.apply(n,t);t=new(Function.bind.apply(e,n));return r&&_setPrototypeOf(t,r.prototype),t}).apply(null,arguments)}function _isNativeFunction(e){return-1!==Function.toString.call(e).indexOf("[native code]")}function _wrapNativeSuper(e){var r="function"==typeof Map?new Map:void 0;return(_wrapNativeSuper=function(e){if(null===e||!_isNativeFunction(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==r){if(r.has(e))return r.get(e);r.set(e,t)}function t(){return _construct(e,arguments,_getPrototypeOf(this).constructor)}return t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),_setPrototypeOf(t,e)})(e)}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _possibleConstructorReturn(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(e)}function _createSuper(r){var n=_isNativeReflectConstruct();return function(){var e,t=_getPrototypeOf(r);return _possibleConstructorReturn(this,n?(e=_getPrototypeOf(this).constructor,Reflect.construct(t,arguments,e)):t.apply(this,arguments))}}function _toConsumableArray(e){return _arrayWithoutHoles(e)||_iterableToArray(e)||_unsupportedIterableToArray(e)||_nonIterableSpread()}function _arrayWithoutHoles(e){if(Array.isArray(e))return _arrayLikeToArray(e)}function _iterableToArray(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Map"===(r="Object"===r&&e.constructor?e.constructor.name:r)||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(e,t):void 0}}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];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(e){return-1<"+-*/%()".indexOf(e)}function getPrioraty(e){switch(e){case"+":case"-":return 1;case"*":case"/":case"%":return 2;default:return 0}}function prioraty(e,t){return getPrioraty(e)<=getPrioraty(t)}function isObj(e){return"[object Object]"===Object.prototype.toString.call(e)&&!Array.isArray(e)}function notUndefined(e){return void 0!==e}function anyNotUndefined(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return t.some(function(e){return void 0!==e})}function notNull(e){return null!==e}function isNumber(e){return"number"==typeof e||isStrNumber(e)}function isStrNumber(e){return"string"==typeof e&&!!/^[+-]?\d+\.?\d*$/.test(e)}function splitUnitNum(e){var t=null,r=null,e=e.match(/^([+-]?[\d.]+)(\D*)$/);return e&&(r=e[1],""!==(e=e[2]).trim()&&(t=e)),{num:r,unit:t}}Object.defineProperty(exports,"__esModule",{value:!0});var CalculatorError=function(){_inherits(n,_wrapNativeSuper(Error));var r=_createSuper(n);function n(e){var t;return _classCallCheck(this,n),(t=r.call(this,e)).name="CalculatorError",t.message=e,t}return _createClass(n)}(),TokensFillError=function(){_inherits(n,_wrapNativeSuper(Error));var r=_createSuper(n);function n(e){var t;return _classCallCheck(this,n),(t=r.call(this,e)).name="TokensFillError",t.message=e,t}return _createClass(n)}(),ArgError=function(){_inherits(n,_wrapNativeSuper(Error));var r=_createSuper(n);function n(e){var t;return _classCallCheck(this,n),(t=r.call(this,e)).name="ArgError",t.message=e,t}return _createClass(n)}();function fmtTokenizer(e){for(var t,r=0,n=e.length,o=[];r<n;)if(t=e[r],/\s/.test(t))r++;else if("+"===t)o.push({type:"plus",value:t}),r++;else if(","===t)o.push({type:"comma",value:t}),r++;else if("<>=".includes(t)){var i,a=t;n<=++r?o.push({type:"symbol",value:a}):(i=e[r],"<>=".includes(i)?(a+=i,o.push({type:"symbol",value:a}),r++):o.push({type:"symbol",value:t}))}else if(/[a-zA-Z_]/.test(t)){for(var s="";/[\w_.\[\]"']/.test(t)&&(s+=t,!(n<=++r));)t=e[r];o.push({type:"var",value:s})}else if(/\d/.test(t)){for(var l="";/[\d.]/.test(t)&&(l+=t,!(n<=++r));)t=e[r];o.push({type:"number",value:l})}return o}function parseArgs(e){var t={expr:"",fmt:null,data:null},r="",n=e[0];if(1===e.length)if("string"==typeof n)r=n;else{if("number"!=typeof n)throw new ArgError("错误的参数类型: ".concat(n," 类型为:").concat(_typeof(n)));r=n.toString()}else{if(2!=e.length)throw new ArgError("过多的参数, 该函数最多接受两个参数!");n=e[1];if(!isObj(n)&&!Array.isArray(n))throw new Error("参数错误, 暂不支持的参数");if("string"==typeof(r=e[0])){if(""===r.trim())throw new TokensFillError("参数不可为空字符串")}else if("number"==typeof r)r=r.toString();else if(void 0===r||Number.isNaN(r))throw new TokensFillError("非法参数:".concat(r));t.data=n}var o,e=r.split("|");return 1===e.length?t.expr=e[0]:(t.expr=e[0],""!==(n=e[1]).trim()&&(r=fmtTokenizer(n),t.fmt=r)),null!==t.data&&t.data._fmt&&(e=fmtTokenizer(t.data._fmt),null===t.fmt?t.fmt=e:(o=t.fmt.map(function(e){return e.type}),e.forEach(function(e){o.includes(e.type)||t.fmt.push(e)}))),t}var isNumeric=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,mathceil=Math.ceil,mathfloor=Math.floor,bignumberError="[BigNumber Error] ",tooManyDigits=bignumberError+"Number primitive has more than 15 significant digits: ",BASE=1e14,LOG_BASE=14,MAX_SAFE_INTEGER=9007199254740991,POWS_TEN=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],SQRT_BASE=1e7,MAX=1e9;function clone(e){var m,f,h,t,c,y,a,s,l,u,p,r=T.prototype={constructor:T,toString:null,valueOf:null},g=new T(1),b=20,d=4,_=-7,v=21,S=-1e7,$=1e7,E=!1,o=1,w=0,O={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},C="0123456789abcdefghijklmnopqrstuvwxyz",A=!0;function T(e,t){var r,n,o,i,a,s,l,c,u=this;if(!(u instanceof T))return new T(e,t);if(null==t){if(e&&!0===e._isBigNumber)return u.s=e.s,void(!e.c||e.e>$?u.c=u.e=null:e.e<S?u.c=[u.e=0]:(u.e=e.e,u.c=e.c.slice()));if((s="number"==typeof e)&&0*e==0){if(u.s=1/e<0?(e=-e,-1):1,e===~~e){for(i=0,a=e;10<=a;a/=10,i++);return void($<i?u.c=u.e=null:(u.e=i,u.c=[e]))}c=String(e)}else{if(!isNumeric.test(c=String(e)))return h(u,c,s);u.s=45==c.charCodeAt(0)?(c=c.slice(1),-1):1}0<(a=(c=-1<(i=c.indexOf("."))?c.replace(".",""):c).search(/e/i))?(i<0&&(i=a),i+=+c.slice(a+1),c=c.substring(0,a)):i<0&&(i=c.length)}else{if(intCheck(t,2,C.length,"Base"),10==t&&A)return M(u=new T(e),b+u.e+1,d);if(c=String(e),s="number"==typeof e){if(0*e!=0)return h(u,c,s,t);if(u.s=1/e<0?(c=c.slice(1),-1):1,T.DEBUG&&15<c.replace(/^0\.0*|\./,"").length)throw Error(tooManyDigits+e)}else u.s=45===c.charCodeAt(0)?(c=c.slice(1),-1):1;for(r=C.slice(0,t),i=a=0,l=c.length;a<l;a++)if(r.indexOf(n=c.charAt(a))<0){if("."==n){if(i<a){i=l;continue}}else if(!o&&(c==c.toUpperCase()&&(c=c.toLowerCase())||c==c.toLowerCase()&&(c=c.toUpperCase()))){o=!0,a=-1,i=0;continue}return h(u,String(e),s,t)}s=!1,-1<(i=(c=f(c,t,10,u.s)).indexOf("."))?c=c.replace(".",""):i=c.length}for(a=0;48===c.charCodeAt(a);a++);for(l=c.length;48===c.charCodeAt(--l););if(c=c.slice(a,++l)){if(l-=a,s&&T.DEBUG&&15<l&&(MAX_SAFE_INTEGER<e||e!==mathfloor(e)))throw Error(tooManyDigits+u.s*e);if((i=i-a-1)>$)u.c=u.e=null;else if(i<S)u.c=[u.e=0];else{if(u.e=i,u.c=[],a=(i+1)%LOG_BASE,i<0&&(a+=LOG_BASE),a<l){for(a&&u.c.push(+c.slice(0,a)),l-=LOG_BASE;a<l;)u.c.push(+c.slice(a,a+=LOG_BASE));a=LOG_BASE-(c=c.slice(a)).length}else a-=l;for(;a--;c+="0");u.c.push(+c)}}else u.c=[u.e=0]}function N(e,t,r,n){for(var o,i,a=[0],s=0,l=e.length;s<l;){for(i=a.length;i--;a[i]*=t);for(a[0]+=n.indexOf(e.charAt(s++)),o=0;o<a.length;o++)a[o]>r-1&&(null==a[o+1]&&(a[o+1]=0),a[o+1]+=a[o]/r|0,a[o]%=r)}return a.reverse()}function P(e,t,r){var n,o,i,a=0,s=e.length,l=t%SQRT_BASE,c=t/SQRT_BASE|0;for(e=e.slice();s--;)a=((o=l*(i=e[s]%SQRT_BASE)+(n=c*i+(i=e[s]/SQRT_BASE|0)*l)%SQRT_BASE*SQRT_BASE+a)/r|0)+(n/SQRT_BASE|0)+c*i,e[s]=o%r;return e=a?[a].concat(e):e}function k(e,t,r,n){var o,i;if(r!=n)i=n<r?1:-1;else for(o=i=0;o<r;o++)if(e[o]!=t[o]){i=e[o]>t[o]?1:-1;break}return i}function G(e,t,r,n){for(var o=0;r--;)e[r]-=o,o=e[r]<t[r]?1:0,e[r]=o*n+e[r]-t[r];for(;!e[0]&&1<e.length;e.splice(0,1));}function n(e,t,r,n){var o,i,a,s;if(null==r?r=d:intCheck(r,0,8),!e.c)return e.toString();if(o=e.c[0],i=e.e,null==t)s=coeffToString(e.c),s=1==n||2==n&&(i<=_||v<=i)?toExponential(s,i):toFixedPoint(s,i,"0");else if(r=(e=M(new T(e),t,r)).e,a=(s=coeffToString(e.c)).length,1==n||2==n&&(t<=r||r<=_)){for(;a<t;s+="0",a++);s=toExponential(s,r)}else if(t-=i,s=toFixedPoint(s,r,"0"),a<r+1){if(0<--t)for(s+=".";t--;s+="0");}else if(0<(t+=r-a))for(r+1==a&&(s+=".");t--;s+="0");return e.s<0&&o?"-"+s:s}function i(e,t){for(var r,n=1,o=new T(e[0]);n<e.length;n++){if(!(r=new T(e[n])).s){o=r;break}t.call(o,r)&&(o=r)}return o}function B(e,t,r){for(var n=1,o=t.length;!t[--o];t.pop());for(o=t[0];10<=o;o/=10,n++);return(r=n+r*LOG_BASE-1)>$?e.c=e.e=null:r<S?e.c=[e.e=0]:(e.e=r,e.c=t),e}function M(e,t,r,n){var o,i,a,s,l,c,u,f=e.c,h=POWS_TEN;if(f){e:{for(o=1,s=f[0];10<=s;s/=10,o++);if((i=t-o)<0)i+=LOG_BASE,a=t,u=(l=f[c=0])/h[o-a-1]%10|0;else if((c=mathceil((i+1)/LOG_BASE))>=f.length){if(!n)break e;for(;f.length<=c;f.push(0));l=u=0,a=(i%=LOG_BASE)-LOG_BASE+(o=1)}else{for(l=s=f[c],o=1;10<=s;s/=10,o++);u=(a=(i%=LOG_BASE)-LOG_BASE+o)<0?0:l/h[o-a-1]%10|0}if(n=n||t<0||null!=f[c+1]||(a<0?l:l%h[o-a-1]),n=r<4?(u||n)&&(0==r||r==(e.s<0?3:2)):5<u||5==u&&(4==r||n||6==r&&(0<i?0<a?l/h[o-a]:0:f[c-1])%10&1||r==(e.s<0?8:7)),t<1||!f[0])return f.length=0,n?(t-=e.e+1,f[0]=h[(LOG_BASE-t%LOG_BASE)%LOG_BASE],e.e=-t||0):f[0]=e.e=0,e;if(0==i?(f.length=c,s=1,c--):(f.length=c+1,s=h[LOG_BASE-i],f[c]=0<a?mathfloor(l/h[o-a]%h[a])*s:0),n)for(;;){if(0==c){for(i=1,a=f[0];10<=a;a/=10,i++);for(a=f[0]+=s,s=1;10<=a;a/=10,s++);i!=s&&(e.e++,f[0]==BASE&&(f[0]=1));break}if(f[c]+=s,f[c]!=BASE)break;f[c--]=0,s=1}for(i=f.length;0===f[--i];f.pop());}e.e>$?e.c=e.e=null:e.e<S&&(e.c=[e.e=0])}return e}function j(e){var t,r=e.e;return null===r?e.toString():(t=coeffToString(e.c),t=r<=_||v<=r?toExponential(t,r):toFixedPoint(t,r,"0"),e.s<0?"-"+t:t)}return T.clone=clone,T.ROUND_UP=0,T.ROUND_DOWN=1,T.ROUND_CEIL=2,T.ROUND_FLOOR=3,T.ROUND_HALF_UP=4,T.ROUND_HALF_DOWN=5,T.ROUND_HALF_EVEN=6,T.ROUND_HALF_CEIL=7,T.ROUND_HALF_FLOOR=8,T.EUCLID=9,T.config=T.set=function(e){var t,r;if(null!=e){if("object"!=_typeof(e))throw Error(bignumberError+"Object expected: "+e);if(e.hasOwnProperty(t="DECIMAL_PLACES")&&(intCheck(r=e[t],0,MAX,t),b=r),e.hasOwnProperty(t="ROUNDING_MODE")&&(intCheck(r=e[t],0,8,t),d=r),e.hasOwnProperty(t="EXPONENTIAL_AT")&&((r=e[t])&&r.pop?(intCheck(r[0],-MAX,0,t),intCheck(r[1],0,MAX,t),_=r[0],v=r[1]):(intCheck(r,-MAX,MAX,t),_=-(v=r<0?-r:r))),e.hasOwnProperty(t="RANGE"))if((r=e[t])&&r.pop)intCheck(r[0],-MAX,-1,t),intCheck(r[1],1,MAX,t),S=r[0],$=r[1];else{if(intCheck(r,-MAX,MAX,t),!r)throw Error(bignumberError+t+" cannot be zero: "+r);S=-($=r<0?-r:r)}if(e.hasOwnProperty(t="CRYPTO")){if((r=e[t])!==!!r)throw Error(bignumberError+t+" not true or false: "+r);if(r){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw E=!r,Error(bignumberError+"crypto unavailable");E=r}else E=r}if(e.hasOwnProperty(t="MODULO_MODE")&&(intCheck(r=e[t],0,9,t),o=r),e.hasOwnProperty(t="POW_PRECISION")&&(intCheck(r=e[t],0,MAX,t),w=r),e.hasOwnProperty(t="FORMAT")){if("object"!=_typeof(r=e[t]))throw Error(bignumberError+t+" not an object: "+r);O=r}if(e.hasOwnProperty(t="ALPHABET")){if("string"!=typeof(r=e[t])||/^.?$|[+\-.\s]|(.).*\1/.test(r))throw Error(bignumberError+t+" invalid: "+r);A="0123456789"==r.slice(0,10),C=r}}return{DECIMAL_PLACES:b,ROUNDING_MODE:d,EXPONENTIAL_AT:[_,v],RANGE:[S,$],CRYPTO:E,MODULO_MODE:o,POW_PRECISION:w,FORMAT:O,ALPHABET:C}},T.isBigNumber=function(e){if(!e||!0!==e._isBigNumber)return!1;if(!T.DEBUG)return!0;var t,r,n=e.c,o=e.e,i=e.s;e:if("[object Array]"=={}.toString.call(n)){if((1===i||-1===i)&&-MAX<=o&&o<=MAX&&o===mathfloor(o))if(0===n[0]){if(0===o&&1===n.length)return!0}else if((t=(o+1)%LOG_BASE)<1&&(t+=LOG_BASE),String(n[0]).length==t){for(t=0;t<n.length;t++)if((r=n[t])<0||BASE<=r||r!==mathfloor(r))break e;if(0!==r)return!0}}else if(null===n&&null===o&&(null===i||1===i||-1===i))return!0;throw Error(bignumberError+"Invalid BigNumber: "+e)},T.maximum=T.max=function(){return i(arguments,r.lt)},T.minimum=T.min=function(){return i(arguments,r.gt)},T.random=(t=9007199254740992,c=Math.random()*t&2097151?function(){return mathfloor(Math.random()*t)}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)},function(e){var t,r,n,o,i,a=0,s=[],l=new T(g);if(null==e?e=b:intCheck(e,0,MAX),o=mathceil(e/LOG_BASE),E)if(crypto.getRandomValues){for(t=crypto.getRandomValues(new Uint32Array(o*=2));a<o;)9e15<=(i=131072*t[a]+(t[a+1]>>>11))?(r=crypto.getRandomValues(new Uint32Array(2)),t[a]=r[0],t[a+1]=r[1]):(s.push(i%1e14),a+=2);a=o/2}else{if(!crypto.randomBytes)throw E=!1,Error(bignumberError+"crypto unavailable");for(t=crypto.randomBytes(o*=7);a<o;)9e15<=(i=281474976710656*(31&t[a])+1099511627776*t[a+1]+4294967296*t[a+2]+16777216*t[a+3]+(t[a+4]<<16)+(t[a+5]<<8)+t[a+6])?crypto.randomBytes(7).copy(t,a):(s.push(i%1e14),a+=7);a=o/7}if(!E)for(;a<o;)(i=c())<9e15&&(s[a++]=i%1e14);for(o=s[--a],e%=LOG_BASE,o&&e&&(i=POWS_TEN[LOG_BASE-e],s[a]=mathfloor(o/i)*i);0===s[a];s.pop(),a--);if(a<0)s=[n=0];else{for(n=-1;0===s[0];s.splice(0,1),n-=LOG_BASE);for(a=1,i=s[0];10<=i;i/=10,a++);a<LOG_BASE&&(n-=LOG_BASE-a)}return l.e=n,l.c=s,l}),T.sum=function(){for(var e=1,t=arguments,r=new T(t[0]);e<t.length;)r=r.plus(t[e++]);return r},y="0123456789",f=function(e,t,r,n,o){var i,a,s,l,c,u,f,h,p=e.indexOf("."),g=b,_=d;for(0<=p&&(l=w,w=0,e=e.replace(".",""),u=(h=new T(t)).pow(e.length-p),w=l,h.c=N(toFixedPoint(coeffToString(u.c),u.e,"0"),10,r,y),h.e=h.c.length),s=l=(f=N(e,t,r,o?(i=C,y):(i=y,C))).length;0==f[--l];f.pop());if(!f[0])return i.charAt(0);if(p<0?--s:(u.c=f,u.e=s,u.s=n,f=(u=m(u,h,g,_,r)).c,c=u.r,s=u.e),p=f[a=s+g+1],l=r/2,c=c||a<0||null!=f[a+1],c=_<4?(null!=p||c)&&(0==_||_==(u.s<0?3:2)):l<p||p==l&&(4==_||c||6==_&&1&f[a-1]||_==(u.s<0?8:7)),a<1||!f[0])e=c?toFixedPoint(i.charAt(1),-g,i.charAt(0)):i.charAt(0);else{if(f.length=a,c)for(--r;++f[--a]>r;)f[a]=0,a||(++s,f=[1].concat(f));for(l=f.length;!f[--l];);for(p=0,e="";p<=l;e+=i.charAt(f[p++]));e=toFixedPoint(e,s,i.charAt(0))}return e},m=function(e,t,r,n,o){var i,a,s,l,c,u,f,h,p,g,_,m,y,b,d,v,S,$=e.s==t.s?1:-1,E=e.c,w=t.c;if(!(E&&E[0]&&w&&w[0]))return new T(e.s&&t.s&&(E?!w||E[0]!=w[0]:w)?E&&0==E[0]||!w?0*$:$/0:NaN);for(p=(h=new T($)).c=[],$=r+(a=e.e-t.e)+1,o||(o=BASE,a=bitFloor(e.e/LOG_BASE)-bitFloor(t.e/LOG_BASE),$=$/LOG_BASE|0),s=0;w[s]==(E[s]||0);s++);if(w[s]>(E[s]||0)&&a--,$<0)p.push(1),l=!0;else{for(b=E.length,v=w.length,$+=2,1<(c=mathfloor(o/(w[s=0]+1)))&&(w=P(w,c,o),E=P(E,c,o),v=w.length,b=E.length),y=v,_=(g=E.slice(0,v)).length;_<v;g[_++]=0);S=w.slice(),S=[0].concat(S),d=w[0],w[1]>=o/2&&d++;do{if(c=0,(i=k(w,g,v,_))<0){if(m=g[0],v!=_&&(m=m*o+(g[1]||0)),1<(c=mathfloor(m/d)))for(f=(u=P(w,c=o<=c?o-1:c,o)).length,_=g.length;1==k(u,g,f,_);)c--,G(u,v<f?S:w,f,o),f=u.length,i=1;else 0==c&&(i=c=1),f=(u=w.slice()).length;if(G(g,u=f<_?[0].concat(u):u,_,o),_=g.length,-1==i)for(;k(w,g,v,_)<1;)c++,G(g,v<_?S:w,_,o),_=g.length}else 0===i&&(c++,g=[0])}while(p[s++]=c,g[0]?g[_++]=E[y]||0:(g=[E[y]],_=1),(y++<b||null!=g[0])&&$--);l=null!=g[0],p[0]||p.splice(0,1)}if(o==BASE){for(s=1,$=p[0];10<=$;$/=10,s++);M(h,r+(h.e=s+a*LOG_BASE-1)+1,n,l)}else h.e=a,h.r=+l;return h},a=/^(-?)0([xbo])(?=\w[\w.]*$)/i,s=/^([^.]+)\.$/,l=/^\.([^.]+)$/,u=/^-?(Infinity|NaN)$/,p=/^\s*\+(?=[\w.])|^\s+|\s+$/g,h=function(e,t,r,n){var o,i=r?t:t.replace(p,"");if(u.test(i))e.s=isNaN(i)?null:i<0?-1:1;else{if(!r&&(i=i.replace(a,function(e,t,r){return o="x"==(r=r.toLowerCase())?16:"b"==r?2:8,n&&n!=o?e:t}),n&&(o=n,i=i.replace(s,"$1").replace(l,"0.$1")),t!=i))return new T(i,o);if(T.DEBUG)throw Error(bignumberError+"Not a"+(n?" base "+n:"")+" number: "+t);e.s=null}e.c=e.e=null},r.absoluteValue=r.abs=function(){var e=new T(this);return e.s<0&&(e.s=1),e},r.comparedTo=function(e,t){return compare(this,new T(e,t))},r.decimalPlaces=r.dp=function(e,t){var r,n;if(null!=e)return intCheck(e,0,MAX),null==t?t=d:intCheck(t,0,8),M(new T(this),e+this.e+1,t);if(!(e=this.c))return null;if(r=((n=e.length-1)-bitFloor(this.e/LOG_BASE))*LOG_BASE,n=e[n])for(;n%10==0;n/=10,r--);return r=r<0?0:r},r.dividedBy=r.div=function(e,t){return m(this,new T(e,t),b,d)},r.dividedToIntegerBy=r.idiv=function(e,t){return m(this,new T(e,t),0,1)},r.exponentiatedBy=r.pow=function(e,t){var r,n,o,i,a,s,l,c,u=this;if((e=new T(e)).c&&!e.isInteger())throw Error(bignumberError+"Exponent not an integer: "+j(e));if(null!=t&&(t=new T(t)),a=14<e.e,!u.c||!u.c[0]||1==u.c[0]&&!u.e&&1==u.c.length||!e.c||!e.c[0])return c=new T(Math.pow(+j(u),a?2-isOdd(e):+j(e))),t?c.mod(t):c;if(s=e.s<0,t){if(t.c?!t.c[0]:!t.s)return new T(NaN);(n=!s&&u.isInteger()&&t.isInteger())&&(u=u.mod(t))}else{if(9<e.e&&(0<u.e||u.e<-1||(0==u.e?1<u.c[0]||a&&24e7<=u.c[1]:u.c[0]<8e13||a&&u.c[0]<=9999975e7)))return i=u.s<0&&isOdd(e)?-0:0,-1<u.e&&(i=1/i),new T(s?1/i:i);w&&(i=mathceil(w/LOG_BASE+2))}for(l=a?(r=new T(.5),s&&(e.s=1),isOdd(e)):(o=Math.abs(+j(e)))%2,c=new T(g);;){if(l){if(!(c=c.times(u)).c)break;i?c.c.length>i&&(c.c.length=i):n&&(c=c.mod(t))}if(o){if(0===(o=mathfloor(o/2)))break;l=o%2}else if(M(e=e.times(r),e.e+1,1),14<e.e)l=isOdd(e);else{if(0===(o=+j(e)))break;l=o%2}u=u.times(u),i?u.c&&u.c.length>i&&(u.c.length=i):n&&(u=u.mod(t))}return n?c:(s&&(c=g.div(c)),t?c.mod(t):i?M(c,w,d,void 0):c)},r.integerValue=function(e){var t=new T(this);return null==e?e=d:intCheck(e,0,8),M(t,t.e+1,e)},r.isEqualTo=r.eq=function(e,t){return 0===compare(this,new T(e,t))},r.isFinite=function(){return!!this.c},r.isGreaterThan=r.gt=function(e,t){return 0<compare(this,new T(e,t))},r.isGreaterThanOrEqualTo=r.gte=function(e,t){return 1===(t=compare(this,new T(e,t)))||0===t},r.isInteger=function(){return!!this.c&&bitFloor(this.e/LOG_BASE)>this.c.length-2},r.isLessThan=r.lt=function(e,t){return compare(this,new T(e,t))<0},r.isLessThanOrEqualTo=r.lte=function(e,t){return-1===(t=compare(this,new T(e,t)))||0===t},r.isNaN=function(){return!this.s},r.isNegative=function(){return this.s<0},r.isPositive=function(){return 0<this.s},r.isZero=function(){return!!this.c&&0==this.c[0]},r.minus=function(e,t){var r,n,o,i,a=this,s=a.s;if(t=(e=new T(e,t)).s,!s||!t)return new T(NaN);if(s!=t)return e.s=-t,a.plus(e);var l=a.e/LOG_BASE,c=e.e/LOG_BASE,u=a.c,f=e.c;if(!l||!c){if(!u||!f)return u?(e.s=-t,e):new T(f?a:NaN);if(!u[0]||!f[0])return f[0]?(e.s=-t,e):new T(u[0]?a:3==d?-0:0)}if(l=bitFloor(l),c=bitFloor(c),u=u.slice(),s=l-c){for((o=(i=s<0)?(s=-s,u):(c=l,f)).reverse(),t=s;t--;o.push(0));o.reverse()}else for(n=(i=(s=u.length)<(t=f.length))?s:t,s=t=0;t<n;t++)if(u[t]!=f[t]){i=u[t]<f[t];break}if(i&&(o=u,u=f,f=o,e.s=-e.s),0<(t=(n=f.length)-(r=u.length)))for(;t--;u[r++]=0);for(t=BASE-1;s<n;){if(u[--n]<f[n]){for(r=n;r&&!u[--r];u[r]=t);--u[r],u[n]+=BASE}u[n]-=f[n]}for(;0==u[0];u.splice(0,1),--c);return u[0]?B(e,u,c):(e.s=3==d?-1:1,e.c=[e.e=0],e)},r.modulo=r.mod=function(e,t){var r,n=this;return e=new T(e,t),!n.c||!e.s||e.c&&!e.c[0]?new T(NaN):!e.c||n.c&&!n.c[0]?new T(n):(9==o?(t=e.s,e.s=1,r=m(n,e,0,3),e.s=t,r.s*=t):r=m(n,e,0,o),(e=n.minus(r.times(e))).c[0]||1!=o||(e.s=n.s),e)},r.multipliedBy=r.times=function(e,t){var r,n,o,i,a,s,l,c,u,f,h,p,g,_=this,m=_.c,y=(e=new T(e,t)).c;if(!(m&&y&&m[0]&&y[0]))return!_.s||!e.s||m&&!m[0]&&!y||y&&!y[0]&&!m?e.c=e.e=e.s=null:(e.s*=_.s,m&&y?(e.c=[0],e.e=0):e.c=e.e=null),e;for(t=bitFloor(_.e/LOG_BASE)+bitFloor(e.e/LOG_BASE),e.s*=_.s,(s=m.length)<(_=y.length)&&(h=m,m=y,y=h,n=s,s=_,_=n),n=s+_,h=[];n--;h.push(0));for(p=BASE,g=SQRT_BASE,n=_;0<=--n;){for(u=y[n]%g,f=y[n]/g|(r=0),o=n+(i=s);n<o;)r=((l=u*(l=m[--i]%g)+(a=f*l+(c=m[i]/g|0)*u)%g*g+h[o]+r)/p|0)+(a/g|0)+f*c,h[o--]=l%p;h[o]=r}return r?++t:h.splice(0,1),B(e,h,t)},r.negated=function(){var e=new T(this);return e.s=-e.s||null,e},r.plus=function(e,t){var r,n=this,o=n.s;if(t=(e=new T(e,t)).s,!o||!t)return new T(NaN);if(o!=t)return e.s=-t,n.minus(e);var i=n.e/LOG_BASE,a=e.e/LOG_BASE,s=n.c,l=e.c;if(!i||!a){if(!s||!l)return new T(o/0);if(!s[0]||!l[0])return l[0]?e:new T(s[0]?n:0*o)}if(i=bitFloor(i),a=bitFloor(a),s=s.slice(),o=i-a){for((r=0<o?(a=i,l):(o=-o,s)).reverse();o--;r.push(0));r.reverse()}for((o=s.length)-(t=l.length)<0&&(r=l,l=s,s=r,t=o),o=0;t;)o=(s[--t]=s[t]+l[t]+o)/BASE|0,s[t]=BASE===s[t]?0:s[t]%BASE;return o&&(s=[o].concat(s),++a),B(e,s,a)},r.precision=r.sd=function(e,t){var r,n;if(null!=e&&e!==!!e)return intCheck(e,1,MAX),null==t?t=d:intCheck(t,0,8),M(new T(this),e,t);if(!(t=this.c))return null;if(r=(n=t.length-1)*LOG_BASE+1,n=t[n]){for(;n%10==0;n/=10,r--);for(n=t[0];10<=n;n/=10,r++);}return r=e&&this.e+1>r?this.e+1:r},r.shiftedBy=function(e){return intCheck(e,-MAX_SAFE_INTEGER,MAX_SAFE_INTEGER),this.times("1e"+e)},r.squareRoot=r.sqrt=function(){var e,t,r,n,o,i=this,a=i.c,s=i.s,l=i.e,c=b+4,u=new T("0.5");if(1!==s||!a||!a[0])return new T(!s||s<0&&(!a||a[0])?NaN:a?i:1/0);if((r=0==(s=Math.sqrt(+j(i)))||s==1/0?(((t=coeffToString(a)).length+l)%2==0&&(t+="0"),s=Math.sqrt(+t),l=bitFloor((l+1)/2)-(l<0||l%2),new T(t=s==1/0?"5e"+l:(t=s.toExponential()).slice(0,t.indexOf("e")+1)+l)):new T(s+"")).c[0])for((s=(l=r.e)+c)<3&&(s=0);;)if(o=r,r=u.times(o.plus(m(i,o,c,1))),coeffToString(o.c).slice(0,s)===(t=coeffToString(r.c)).slice(0,s)){if(r.e<l&&--s,"9999"!=(t=t.slice(s-3,s+1))&&(n||"4999"!=t)){+t&&(+t.slice(1)||"5"!=t.charAt(0))||(M(r,r.e+b+2,1),e=!r.times(r).eq(i));break}if(!n&&(M(o,o.e+b+2,0),o.times(o).eq(i))){r=o;break}c+=4,s+=4,n=1}return M(r,r.e+b+1,d,e)},r.toExponential=function(e,t){return null!=e&&(intCheck(e,0,MAX),e++),n(this,e,t,1)},r.toFixed=function(e,t){return null!=e&&(intCheck(e,0,MAX),e=e+this.e+1),n(this,e,t)},r.toFormat=function(e,t,r){if(null==r)null!=e&&t&&"object"==_typeof(t)?(r=t,t=null):e&&"object"==_typeof(e)?(r=e,e=t=null):r=O;else if("object"!=_typeof(r))throw Error(bignumberError+"Argument not an object: "+r);if(e=this.toFixed(e,t),this.c){var n,t=e.split("."),o=+r.groupSize,i=+r.secondaryGroupSize,a=r.groupSeparator||"",s=t[0],t=t[1],l=this.s<0,c=l?s.slice(1):s,u=c.length;if(i&&(n=o,o=i,u-=i=n),0<o&&0<u){for(s=c.substr(0,n=u%o||o);n<u;n+=o)s+=a+c.substr(n,o);0<i&&(s+=a+c.slice(n)),l&&(s="-"+s)}e=t?s+(r.decimalSeparator||"")+((i=+r.fractionGroupSize)?t.replace(new RegExp("\\d{"+i+"}\\B","g"),"$&"+(r.fractionGroupSeparator||"")):t):s}return(r.prefix||"")+e+(r.suffix||"")},r.toFraction=function(e){var t,r,n,o,i,a,s,l,c,u,f=this,h=f.c;if(null!=e&&(!(s=new T(e)).isInteger()&&(s.c||1!==s.s)||s.lt(g)))throw Error(bignumberError+"Argument "+(s.isInteger()?"out of range: ":"not an integer: ")+j(s));if(!h)return new T(f);for(t=new T(g),c=r=new T(g),n=l=new T(g),h=coeffToString(h),i=t.e=h.length-f.e-1,t.c[0]=POWS_TEN[(a=i%LOG_BASE)<0?LOG_BASE+a:a],e=!e||0<s.comparedTo(t)?0<i?t:c:s,a=$,$=1/0,s=new T(h),l.c[0]=0;u=m(s,t,0,1),1!=(o=r.plus(u.times(n))).comparedTo(e);)r=n,n=o,c=l.plus(u.times(o=c)),l=o,t=s.minus(u.times(o=t)),s=o;return o=m(e.minus(r),n,0,1),l=l.plus(o.times(c)),r=r.plus(o.times(n)),l.s=c.s=f.s,h=m(c,n,i*=2,d).minus(f).abs().comparedTo(m(l,r,i,d).minus(f).abs())<1?[c,n]:[l,r],$=a,h},r.toNumber=function(){return+j(this)},r.toPrecision=function(e,t){return null!=e&&intCheck(e,1,MAX),n(this,e,t,2)},r.toString=function(e){var t,r=this,n=r.s,o=r.e;return null===o?n?(t="Infinity",n<0&&(t="-"+t)):t="NaN":(t=null==e?o<=_||v<=o?toExponential(coeffToString(r.c),o):toFixedPoint(coeffToString(r.c),o,"0"):10===e&&A?toFixedPoint(coeffToString((r=M(new T(r),b+o+1,d)).c),r.e,"0"):(intCheck(e,2,C.length,"Base"),f(toFixedPoint(coeffToString(r.c),o,"0"),10,e,n,!0)),n<0&&r.c[0]&&(t="-"+t)),t},r.valueOf=r.toJSON=function(){return j(this)},r._isBigNumber=!0,r[Symbol.toStringTag]="BigNumber",r[Symbol.for("nodejs.util.inspect.custom")]=r.valueOf,null!=e&&T.set(e),T}function bitFloor(e){var t=0|e;return 0<e||e===t?t:t-1}function coeffToString(e){for(var t,r,n=1,o=e.length,i=e[0]+"";n<o;){for(t=e[n++]+"",r=LOG_BASE-t.length;r--;t="0"+t);i+=t}for(o=i.length;48===i.charCodeAt(--o););return i.slice(0,o+1||1)}function compare(e,t){var r,n,o=e.c,i=t.c,a=e.s,s=t.s,e=e.e,t=t.e;if(!a||!s)return null;if(r=o&&!o[0],n=i&&!i[0],r||n)return r?n?0:-s:a;if(a!=s)return a;if(r=a<0,n=e==t,!o||!i)return n?0:!o^r?1:-1;if(!n)return t<e^r?1:-1;for(s=(e=o.length)<(t=i.length)?e:t,a=0;a<s;a++)if(o[a]!=i[a])return o[a]>i[a]^r?1:-1;return e==t?0:t<e^r?1:-1}function intCheck(e,t,r,n){if(e<t||r<e||e!==mathfloor(e))throw Error(bignumberError+(n||"Argument")+("number"==typeof e?e<t||r<e?" out of range: ":" not an integer: ":" not a primitive number: ")+String(e))}function isOdd(e){var t=e.c.length-1;return bitFloor(e.e/LOG_BASE)==t&&e.c[t]%2!=0}function toExponential(e,t){return(1<e.length?e.charAt(0)+"."+e.slice(1):e)+(t<0?"e":"e+")+t}function toFixedPoint(e,t,r){var n,o;if(t<0){for(o=r+".";++t;o+=r);e=o+e}else if(++t>(n=e.length)){for(o=r,t-=n;--t;o+=r);e+=o}else t<n&&(e=e.slice(0,t)+"."+e.slice(t));return e}var BigNumber=clone();function format(e,t,r){var n="";if(BigNumber.isBigNumber(e))n=e.toFixed();else if("string"!=typeof e)n=e.toString();else if(!0===r){r=splitUnitNum(e);if(null===r.num)return null;n=BigNumber(r.num).toFixed()}else n=BigNumber(e).toFixed();if("undefined"===n||"NaN"===n)return null;var o=null,i=null,a=null,s=null;if(t.forEach(function(e){var t=e.type;if("symbol"===t){if(![">=","<=","="].includes(e.value))throw new Error("错误的格式化参数:",e.value);i=e.value}else if("comma"===t)a=!0;else if("number"===t)o=e.value;else{if("plus"!==t)throw new Error("错误的fmt Token");s=!0}}),null!==o){var r=n.split("."),e=r[0],l=1===r.length?"":r[1],c=l.length;switch(i){case"<=":l=c<=o?l:l.slice(0,o);break;case"=":c<o?l+="0".repeat(o-c):o<c&&(l=l.slice(0,o));break;case">=":l=o<=c?l:l+"0".repeat(o-c)}n=""===l?e:"".concat(e,".").concat(l)}return null!==a&&(n=1<(t=n.split(".")).length?((r=t[0]).includes("-")?t[0]=r[0]+r.slice(1).replace(/(?=(?!^)(?:\d{3})+$)/g,","):t[0]=r.replace(/(?=(?!^)(?:\d{3})+$)/g,","),t.join(".")):(e=t[0]).includes("-")?e[0]+e.slice(1).replace(/(?=(?!^)(?:\d{3})+$)/g,","):e.replace(/(?=(?!^)(?:\d{3})+$)/g,",")),n=null===s||n.startsWith("-")?n:"+"+n}function tokenizer(e){for(var t=[],r=0,n=null,o=e.length;r<o;)if(n=e[r],/\s/.test(n))r++;else if("+-".includes(n)){var i=t[t.length-1];if(0===t.length||"+-".includes(i)||"("===i){var a=n;if(++r>=o){t.push(a);break}for(n=e[r];/[a-zA-Z\d._]/.test(n)&&(a+=n,!(++r>=o));)n=e[r];t.push(a)}else t.push(n),r++}else if("*/%()".includes(n))t.push(n),r++;else if(/[a-zA-Z_$]/.test(n)){for(var s="";/[\w_.\[\]"']/.test(n)&&(s+=n,!(++r>=o));)n=e[r];t.push(s)}else if(/\d/.test(n)){for(var l="";/[^+*/()\s-]/.test(n)&&(l+=n,!(++r>=o));)n=e[r];t.push(l)}return t}var commonjsGlobal="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},isArray$3=Array.isArray,isArray_1=isArray$3,freeGlobal$1="object"==_typeof(commonjsGlobal)&&commonjsGlobal&&commonjsGlobal.Object===Object&&commonjsGlobal,_freeGlobal=freeGlobal$1,freeGlobal=freeGlobal$1,freeSelf="object"==("undefined"==typeof self?"undefined":_typeof(self))&&self&&self.Object===Object&&self,root$3=freeGlobal||freeSelf||Function("return this")(),_root=root$3,root$2=_root,_Symbol2=_root.Symbol,_Symbol$3=_Symbol2,_Symbol$2=_Symbol$3,objectProto$4=Object.prototype,hasOwnProperty$3=objectProto$4.hasOwnProperty,nativeObjectToString$1=objectProto$4.toString,symToStringTag$1=_Symbol$2?_Symbol$2.toStringTag:void 0;function getRawTag$1(e){var t=hasOwnProperty$3.call(e,symToStringTag$1),r=e[symToStringTag$1];try{var n=!(e[symToStringTag$1]=void 0)}catch(e){}var o=nativeObjectToString$1.call(e);return n&&(t?e[symToStringTag$1]=r:delete e[symToStringTag$1]),o}var _getRawTag=getRawTag$1,objectProto$3=Object.prototype,nativeObjectToString=objectProto$3.toString;function objectToString$1(e){return nativeObjectToString.call(e)}var _objectToString=objectToString$1,_Symbol$1=_Symbol$3,getRawTag=_getRawTag,objectToString=objectToString$1,nullTag="[object Null]",undefinedTag="[object Undefined]",symToStringTag=_Symbol$3?_Symbol$3.toStringTag:void 0;function baseGetTag$2(e){return null==e?void 0===e?undefinedTag:nullTag:(symToStringTag&&symToStringTag in Object(e)?getRawTag:objectToString)(e)}var _baseGetTag=baseGetTag$2;function isObjectLike$1(e){return null!=e&&"object"==_typeof(e)}var isObjectLike_1=isObjectLike$1,baseGetTag$1=baseGetTag$2,isObjectLike=isObjectLike$1,symbolTag="[object Symbol]";function isSymbol$3(e){return"symbol"==_typeof(e)||isObjectLike(e)&&baseGetTag$1(e)==symbolTag}var isSymbol_1=isSymbol$3,isArray$2=isArray_1,isSymbol$2=isSymbol_1,reIsDeepProp=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,reIsPlainProp=/^\w*$/;function isKey$1(e,t){if(isArray$2(e))return!1;var r=_typeof(e);return!("number"!=r&&"symbol"!=r&&"boolean"!=r&&null!=e&&!isSymbol$2(e))||(reIsPlainProp.test(e)||!reIsDeepProp.test(e)||null!=t&&e in Object(t))}var _isKey=isKey$1;function isObject$2(e){var t=_typeof(e);return null!=e&&("object"==t||"function"==t)}var isObject_1=isObject$2,baseGetTag=baseGetTag$2,isObject$1=isObject_1,asyncTag="[object AsyncFunction]",funcTag="[object Function]",genTag="[object GeneratorFunction]",proxyTag="[object Proxy]";function isFunction$1(e){if(!isObject$1(e))return!1;e=baseGetTag(e);return e==funcTag||e==genTag||e==asyncTag||e==proxyTag}var isFunction_1=isFunction$1,root$1=_root,coreJsData$1=_root["__core-js_shared__"],_coreJsData=coreJsData$1,coreJsData=coreJsData$1,maskSrcKey=function(){var e=/[^.]+$/.exec(coreJsData&&coreJsData.keys&&coreJsData.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function isMasked$1(e){return!!maskSrcKey&&maskSrcKey in e}var _isMasked=isMasked$1,funcProto$1=Function.prototype,funcToString$1=funcProto$1.toString;function toSource$1(e){if(null!=e){try{return funcToString$1.call(e)}catch(e){}try{return e+""}catch(e){}}return""}var _toSource=toSource$1,isFunction=isFunction_1,isMasked=_isMasked,isObject=isObject_1,toSource=toSource$1,reRegExpChar=/[\\^$.*+?()[\]{}|]/g,reIsHostCtor=/^\[object .+?Constructor\]$/,funcProto=Function.prototype,objectProto$2=Object.prototype,funcToString=funcProto.toString,hasOwnProperty$2=objectProto$2.hasOwnProperty,reIsNative=RegExp("^"+funcToString.call(hasOwnProperty$2).replace(reRegExpChar,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function baseIsNative$1(e){return!(!isObject(e)||isMasked(e))&&(isFunction(e)?reIsNative:reIsHostCtor).test(toSource(e))}var _baseIsNative=baseIsNative$1;function getValue$1(e,t){return null==e?void 0:e[t]}var _getValue=getValue$1,baseIsNative=baseIsNative$1,getValue=getValue$1;function getNative$2(e,t){e=getValue(e,t);return baseIsNative(e)?e:void 0}var _getNative=getNative$2,getNative$1=_getNative,nativeCreate$4=_getNative(Object,"create"),_nativeCreate=nativeCreate$4,nativeCreate$3=_nativeCreate;function hashClear$1(){this.__data__=nativeCreate$3?nativeCreate$3(null):{},this.size=0}var _hashClear=hashClear$1;function hashDelete$1(e){e=this.has(e)&&delete this.__data__[e];return this.size-=e?1:0,e}var _hashDelete=hashDelete$1,nativeCreate$2=_nativeCreate,HASH_UNDEFINED$1="__lodash_hash_undefined__",objectProto$1=Object.prototype,hasOwnProperty$1=objectProto$1.hasOwnProperty;function hashGet$1(e){var t,r=this.__data__;return nativeCreate$2?(t=r[e])===HASH_UNDEFINED$1?void 0:t:hasOwnProperty$1.call(r,e)?r[e]:void 0}var _hashGet=hashGet$1,nativeCreate$1=_nativeCreate,objectProto=Object.prototype,hasOwnProperty=objectProto.hasOwnProperty;function hashHas$1(e){var t=this.__data__;return nativeCreate$1?void 0!==t[e]:hasOwnProperty.call(t,e)}var _hashHas=hashHas$1,nativeCreate=_nativeCreate,HASH_UNDEFINED="__lodash_hash_undefined__";function hashSet$1(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=nativeCreate&&void 0===t?HASH_UNDEFINED:t,this}var _hashSet=hashSet$1,hashClear=_hashClear,hashDelete=_hashDelete,hashGet=_hashGet,hashHas=hashHas$1,hashSet=hashSet$1;function Hash$1(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}Hash$1.prototype.clear=hashClear,Hash$1.prototype.delete=hashDelete,Hash$1.prototype.get=hashGet,Hash$1.prototype.has=hashHas,Hash$1.prototype.set=hashSet;var _Hash=Hash$1;function listCacheClear$1(){this.__data__=[],this.size=0}var _listCacheClear=listCacheClear$1;function eq$1(e,t){return e===t||e!=e&&t!=t}var eq_1=eq$1,eq=eq$1;function assocIndexOf$4(e,t){for(var r=e.length;r--;)if(eq(e[r][0],t))return r;return-1}var _assocIndexOf=assocIndexOf$4,assocIndexOf$3=_assocIndexOf,arrayProto=Array.prototype,splice=arrayProto.splice;function listCacheDelete$1(e){var t=this.__data__,e=assocIndexOf$3(t,e);return!(e<0)&&(e==t.length-1?t.pop():splice.call(t,e,1),--this.size,!0)}var _listCacheDelete=listCacheDelete$1,assocIndexOf$2=_assocIndexOf;function listCacheGet$1(e){var t=this.__data__,e=assocIndexOf$2(t,e);return e<0?void 0:t[e][1]}var _listCacheGet=listCacheGet$1,assocIndexOf$1=_assocIndexOf;function listCacheHas$1(e){return-1<assocIndexOf$1(this.__data__,e)}var _listCacheHas=listCacheHas$1,assocIndexOf=_assocIndexOf;function listCacheSet$1(e,t){var r=this.__data__,n=assocIndexOf(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this}var _listCacheSet=listCacheSet$1,listCacheClear=_listCacheClear,listCacheDelete=listCacheDelete$1,listCacheGet=listCacheGet$1,listCacheHas=listCacheHas$1,listCacheSet=listCacheSet$1;function ListCache$1(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}ListCache$1.prototype.clear=listCacheClear,ListCache$1.prototype.delete=listCacheDelete,ListCache$1.prototype.get=listCacheGet,ListCache$1.prototype.has=listCacheHas,ListCache$1.prototype.set=listCacheSet;var _ListCache=ListCache$1,getNative=_getNative,root=_root,Map$2=_getNative(_root,"Map"),_Map=Map$2,Hash=_Hash,ListCache=_ListCache,Map$1=Map$2;function mapCacheClear$1(){this.size=0,this.__data__={hash:new Hash,map:new(Map$1||ListCache),string:new Hash}}var _mapCacheClear=mapCacheClear$1;function isKeyable$1(e){var t=_typeof(e);return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e}var _isKeyable=isKeyable$1,isKeyable=isKeyable$1;function getMapData$4(e,t){e=e.__data__;return isKeyable(t)?e["string"==typeof t?"string":"hash"]:e.map}var _getMapData=getMapData$4,getMapData$3=getMapData$4;function mapCacheDelete$1(e){e=getMapData$3(this,e).delete(e);return this.size-=e?1:0,e}var _mapCacheDelete=mapCacheDelete$1,getMapData$2=getMapData$4;function mapCacheGet$1(e){return getMapData$2(this,e).get(e)}var _mapCacheGet=mapCacheGet$1,getMapData$1=getMapData$4;function mapCacheHas$1(e){return getMapData$1(this,e).has(e)}var _mapCacheHas=mapCacheHas$1,getMapData=getMapData$4;function mapCacheSet$1(e,t){var r=getMapData(this,e),n=r.size;return r.set(e,t),this.size+=r.size==n?0:1,this}var _mapCacheSet=mapCacheSet$1,mapCacheClear=mapCacheClear$1,mapCacheDelete=mapCacheDelete$1,mapCacheGet=mapCacheGet$1,mapCacheHas=mapCacheHas$1,mapCacheSet=mapCacheSet$1;function MapCache$1(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}MapCache$1.prototype.clear=mapCacheClear,MapCache$1.prototype.delete=mapCacheDelete,MapCache$1.prototype.get=mapCacheGet,MapCache$1.prototype.has=mapCacheHas,MapCache$1.prototype.set=mapCacheSet;var _MapCache=MapCache$1,MapCache=MapCache$1,FUNC_ERROR_TEXT="Expected a function";function memoize$1(n,o){if("function"!=typeof n||null!=o&&"function"!=typeof o)throw new TypeError(FUNC_ERROR_TEXT);function i(){var e=arguments,t=o?o.apply(this,e):e[0],r=i.cache;return r.has(t)?r.get(t):(e=n.apply(this,e),i.cache=r.set(t,e)||r,e)}return i.cache=new(memoize$1.Cache||MapCache),i}memoize$1.Cache=MapCache;var memoize_1=memoize$1,memoize=memoize$1,MAX_MEMOIZE_SIZE=500;function memoizeCapped$1(e){var e=memoize(e,function(e){return t.size===MAX_MEMOIZE_SIZE&&t.clear(),e}),t=e.cache;return e}var _memoizeCapped=memoizeCapped$1,memoizeCapped=memoizeCapped$1,rePropName=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,reEscapeChar=/\\(\\)?/g,stringToPath$1=memoizeCapped$1(function(e){var o=[];return 46===e.charCodeAt(0)&&o.push(""),e.replace(rePropName,function(e,t,r,n){o.push(r?n.replace(reEscapeChar,"$1"):t||e)}),o}),_stringToPath=stringToPath$1;function arrayMap$1(e,t){for(var r=-1,n=null==e?0:e.length,o=Array(n);++r<n;)o[r]=t(e[r],r,e);return o}var _arrayMap=arrayMap$1,_Symbol=_Symbol$3,arrayMap=arrayMap$1,isArray$1=isArray_1,isSymbol$1=isSymbol_1,INFINITY$1=1/0,symbolProto=_Symbol$3?_Symbol$3.prototype:void 0,symbolToString=symbolProto?symbolProto.toString:void 0;function baseToString$1(e){if("string"==typeof e)return e;if(isArray$1(e))return arrayMap(e,baseToString$1)+"";if(isSymbol$1(e))return symbolToString?symbolToString.call(e):"";var t=e+"";return"0"==t&&1/e==-INFINITY$1?"-0":t}var _baseToString=baseToString$1,baseToString=baseToString$1;function toString$1(e){return null==e?"":baseToString(e)}var toString_1=toString$1,isArray=isArray_1,isKey=_isKey,stringToPath=_stringToPath,toString=toString$1;function castPath$1(e,t){return isArray(e)?e:isKey(e,t)?[e]:stringToPath(toString(e))}var _castPath=castPath$1,isSymbol=isSymbol_1,INFINITY=1/0;function toKey$1(e){if("string"==typeof e||isSymbol(e))return e;var t=e+"";return"0"==t&&1/e==-INFINITY?"-0":t}var _toKey=toKey$1,castPath=castPath$1,toKey=toKey$1;function baseGet$1(e,t){for(var r=0,n=(t=castPath(t,e)).length;null!=e&&r<n;)e=e[toKey(t[r++])];return r&&r==n?e:void 0}var _baseGet=baseGet$1,baseGet=baseGet$1;function get(e,t,r){e=null==e?void 0:baseGet(e,t);return void 0===e?r:e}var get_1=get;function fillTokens(e,t,r){var n=[];if(!notNull(t))throw new TokensFillError("错误的填充数据:",t);Array.isArray(t)?n=t:n.push(t);for(var o=[],i=0;i<e.length;i++){var a=e[i];if(/^[a-zA-z_][\w\[\]"'_.]*$/.test(a)){if("undefined"===a||"NaN"===a)throw new TokensFillError("key不应该为:".concat(a));for(var s=null,l=0;l<n.length;l++){var c=n[l],c=get_1(c,a);if(void 0!==c){s=c;break}}if(null===s)throw new TokensFillError("token填充失败,请确认".concat(a,"存在"));if("string"==typeof s){if(""===s.trim())throw new TokensFillError("token填充失败,".concat(a,"值不可为空字符"));if(!0===r){if(!/^[+-]?[\d.]+\D*$/.test(s))throw new TokensFillError("token填充失败,".concat(a,"值:").concat(s,"为非法单位数字"))}else if(!isStrNumber(s))throw new TokensFillError("token填充失败,".concat(a,"值:").concat(s,"为非法数字"))}s="string"!=typeof s?s.toString():s,o.push(s)}else o.push(a)}return o}function fillFmtTokens(e,n){return e.map(function(e){if("var"!==e.type)return e;for(var t,r=0;r<n.length&&!notUndefined(t=get_1(n[r],e.value));r++);if(isNumber(t))return{type:"number",value:t};throw new TokensFillError("错误的填充值")})}function getTokenAndUnit(e){var r=null;return e.length,{tokens:e.map(function(e){var t=splitUnitNum(e);return null!==t.unit?(null==r&&(r=t.unit),t.num):e}),unit:r}}function fmt(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];var n=parseArgs(t),o=tokenizer(n.expr),i=null,a=null;if(!0===get_1(n,"data._debug")&&(console.warn("======a-calc调试模式======"),console.warn(n),console.warn(o)),""===n.expr.trim()&&notNull(n.data)&&notUndefined(n.data._error))return n.data._error;if(2<o.length)throw new Error("fmt并非用于计算, 不能传入多个标识:".concat(n.expr));if(1!==o.length)throw new Error("fmt接收了一个无法被解析的标识");if(notNull(n.data)){var s,l=n.data,c=[],u=l._fillError,f=get_1(l,"_unit",null);if(Array.isArray(l)?c=l:(c.push(i=l),notUndefined(s=get_1(i,"_fillData"))&&(Array.isArray(s)?c=[].concat(_toConsumableArray(c),_toConsumableArray(s)):c.push(s))),anyNotUndefined(u,l._error))try{o=fillTokens(o,c,f),notNull(n.fmt)&&(n.fmt=fillFmtTokens(n.fmt,c))}catch(e){if(e instanceof TokensFillError)return void 0!==i._warn&&!0===i._warn&&console.warn(e),i._fillError||i._error;throw e}else o=fillTokens(o,c,f),notNull(n.fmt)&&(n.fmt=fillFmtTokens(n.fmt,c));!0===f&&(a=(s=getTokenAndUnit(o)).unit,o=s.tokens)}if(null===n.fmt)throw"表达式没有格式化部分";u=o[0];if(!0===f){if(!/^[+-]?[\d.]+\D*$/.test(u))throw new TokensFillError("token填充失败,".concat(key,"值:").concat(value,"为非法单位数字"))}else if(!isStrNumber(u))throw new TokensFillError("待格式化对象: ".concat(u," 不是数字"));l=format(u,n.fmt,f);return null!==l&&null!==a&&(l+=a),l}var version="0.0.71";function token2postfix(e){for(var t=[],r=[],n=e;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;)r.push(i),i=t.pop();if("("!==i)throw"error: unmatched ()"}else{for(;prioraty(o,t[t.length-1])&&0<t.length;)r.push(t.pop());t.push(o)}else r.push(o)}if(0<t.length){if(")"===t[t.length-1]||"("===t[t.length-1])throw"error: unmatched ()";for(;0<t.length;)r.push(t.pop())}return r}function evalPostfix(e){for(var t,r=[];0<e.length;){var n=e.shift();if(isOperator(n)){if(r.length<2)throw new CalculatorError("错误的栈长度, 可能是无法计算的表达式");var o=r.pop(),i=r.pop();if("string"==typeof o&&!BigNumber.isBigNumber(o)){if(!isStrNumber(o))throw new CalculatorError("".concat(o,"不是一个合法的数字"));o=new BigNumber(o)}if("string"==typeof i&&!BigNumber.isBigNumber(i)){if(!isStrNumber(i))throw new CalculatorError("".concat(i,"不是一个合法的数字"));i=new BigNumber(i)}switch(n){case"+":r.push(i.plus(o));break;case"-":r.push(i.minus(o));break;case"*":r.push(i.times(o));break;case"/":r.push(i.div(o));break;case"%":r.push(i.mod(o))}}else r.push(n)}if(1!==r.length)throw"unvalid expression";return t=r[0],BigNumber.isBigNumber(t)?t:BigNumber(t)}function calc(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];var n,o=parseArgs(t),i=tokenizer(o.expr),a=null,s=null;if(!0===get_1(o,"data._debug")&&(console.warn("======a-calc调试模式======"),console.warn(o),console.warn(i)),notNull(o.data)){var l=o.data,c=[],u=l._error,f=l._fillError,h=l._warn,p=get_1(l,"_unit",null);if(Array.isArray(l)?c=l:(c.push(a=l),notUndefined(l=get_1(a,"_fillData"))&&(Array.isArray(l)?c=[].concat(_toConsumableArray(c),_toConsumableArray(l)):c.push(l))),anyNotUndefined(f,u))try{i=fillTokens(i,c,p),notNull(o.fmt)&&(o.fmt=fillFmtTokens(o.fmt,c))}catch(e){if(e instanceof TokensFillError)return notUndefined(h)&&!0===h&&console.warn(e),notUndefined(f)?f:u;throw e}else i=fillTokens(i,c,p),notNull(o.fmt)&&(o.fmt=fillFmtTokens(o.fmt,c));!0===p&&(s=(l=getTokenAndUnit(i)).unit,i=l.tokens)}f=token2postfix(i),c=null;if(notNull(a)&&anyNotUndefined(n,u))try{c=evalPostfix(f)}catch(e){if(e instanceof CalculatorError)return void 0!==h&&!0===h&&console.warn(e),notUndefined(n)?n:u;throw e}else c=evalPostfix(f);return null!==(c=notNull(o.fmt)?format(c,o.fmt):null!==c?c.toFixed():null)&&null!==s&&(c+=s),c}exports.calc=calc,exports.fmt=fmt,exports.version=version;
package/cjs/package.json DELETED
@@ -1,3 +0,0 @@
1
- {
2
- "type": "commonjs"
3
- }
package/es/index.js DELETED
@@ -1 +0,0 @@
1
- function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function _createClass(e,t,r){return t&&_defineProperties(e.prototype,t),r&&_defineProperties(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&_setPrototypeOf(e,t)}function _getPrototypeOf(e){return(_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function _setPrototypeOf(e,t){return(_setPrototypeOf=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}function _construct(e,t,r){return(_construct=_isNativeReflectConstruct()?Reflect.construct:function(e,t,r){var n=[null];n.push.apply(n,t);t=new(Function.bind.apply(e,n));return r&&_setPrototypeOf(t,r.prototype),t}).apply(null,arguments)}function _isNativeFunction(e){return-1!==Function.toString.call(e).indexOf("[native code]")}function _wrapNativeSuper(e){var r="function"==typeof Map?new Map:void 0;return(_wrapNativeSuper=function(e){if(null===e||!_isNativeFunction(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==r){if(r.has(e))return r.get(e);r.set(e,t)}function t(){return _construct(e,arguments,_getPrototypeOf(this).constructor)}return t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),_setPrototypeOf(t,e)})(e)}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _possibleConstructorReturn(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(e)}function _createSuper(r){var n=_isNativeReflectConstruct();return function(){var e,t=_getPrototypeOf(r);return _possibleConstructorReturn(this,n?(e=_getPrototypeOf(this).constructor,Reflect.construct(t,arguments,e)):t.apply(this,arguments))}}function _toConsumableArray(e){return _arrayWithoutHoles(e)||_iterableToArray(e)||_unsupportedIterableToArray(e)||_nonIterableSpread()}function _arrayWithoutHoles(e){if(Array.isArray(e))return _arrayLikeToArray(e)}function _iterableToArray(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Map"===(r="Object"===r&&e.constructor?e.constructor.name:r)||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(e,t):void 0}}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];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(e){return-1<"+-*/%()".indexOf(e)}function getPrioraty(e){switch(e){case"+":case"-":return 1;case"*":case"/":case"%":return 2;default:return 0}}function prioraty(e,t){return getPrioraty(e)<=getPrioraty(t)}function isObj(e){return"[object Object]"===Object.prototype.toString.call(e)&&!Array.isArray(e)}function notUndefined(e){return void 0!==e}function anyNotUndefined(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return t.some(function(e){return void 0!==e})}function notNull(e){return null!==e}function isNumber(e){return"number"==typeof e||isStrNumber(e)}function isStrNumber(e){return"string"==typeof e&&!!/^[+-]?\d+\.?\d*$/.test(e)}function splitUnitNum(e){var t=null,r=null,e=e.match(/^([+-]?[\d.]+)(\D*)$/);return e&&(r=e[1],""!==(e=e[2]).trim()&&(t=e)),{num:r,unit:t}}var CalculatorError=function(){_inherits(n,_wrapNativeSuper(Error));var r=_createSuper(n);function n(e){var t;return _classCallCheck(this,n),(t=r.call(this,e)).name="CalculatorError",t.message=e,t}return _createClass(n)}(),TokensFillError=function(){_inherits(n,_wrapNativeSuper(Error));var r=_createSuper(n);function n(e){var t;return _classCallCheck(this,n),(t=r.call(this,e)).name="TokensFillError",t.message=e,t}return _createClass(n)}(),ArgError=function(){_inherits(n,_wrapNativeSuper(Error));var r=_createSuper(n);function n(e){var t;return _classCallCheck(this,n),(t=r.call(this,e)).name="ArgError",t.message=e,t}return _createClass(n)}();function fmtTokenizer(e){for(var t,r=0,n=e.length,o=[];r<n;)if(t=e[r],/\s/.test(t))r++;else if("+"===t)o.push({type:"plus",value:t}),r++;else if(","===t)o.push({type:"comma",value:t}),r++;else if("<>=".includes(t)){var i,a=t;n<=++r?o.push({type:"symbol",value:a}):(i=e[r],"<>=".includes(i)?(a+=i,o.push({type:"symbol",value:a}),r++):o.push({type:"symbol",value:t}))}else if(/[a-zA-Z_]/.test(t)){for(var s="";/[\w_.\[\]"']/.test(t)&&(s+=t,!(n<=++r));)t=e[r];o.push({type:"var",value:s})}else if(/\d/.test(t)){for(var l="";/[\d.]/.test(t)&&(l+=t,!(n<=++r));)t=e[r];o.push({type:"number",value:l})}return o}function parseArgs(e){var t={expr:"",fmt:null,data:null},r="",n=e[0];if(1===e.length)if("string"==typeof n)r=n;else{if("number"!=typeof n)throw new ArgError("错误的参数类型: ".concat(n," 类型为:").concat(_typeof(n)));r=n.toString()}else{if(2!=e.length)throw new ArgError("过多的参数, 该函数最多接受两个参数!");n=e[1];if(!isObj(n)&&!Array.isArray(n))throw new Error("参数错误, 暂不支持的参数");if("string"==typeof(r=e[0])){if(""===r.trim())throw new TokensFillError("参数不可为空字符串")}else if("number"==typeof r)r=r.toString();else if(void 0===r||Number.isNaN(r))throw new TokensFillError("非法参数:".concat(r));t.data=n}var o,e=r.split("|");return 1===e.length?t.expr=e[0]:(t.expr=e[0],""!==(n=e[1]).trim()&&(r=fmtTokenizer(n),t.fmt=r)),null!==t.data&&t.data._fmt&&(e=fmtTokenizer(t.data._fmt),null===t.fmt?t.fmt=e:(o=t.fmt.map(function(e){return e.type}),e.forEach(function(e){o.includes(e.type)||t.fmt.push(e)}))),t}var isNumeric=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,mathceil=Math.ceil,mathfloor=Math.floor,bignumberError="[BigNumber Error] ",tooManyDigits=bignumberError+"Number primitive has more than 15 significant digits: ",BASE=1e14,LOG_BASE=14,MAX_SAFE_INTEGER=9007199254740991,POWS_TEN=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],SQRT_BASE=1e7,MAX=1e9;function clone(e){var m,f,h,t,c,y,a,s,l,u,p,r=T.prototype={constructor:T,toString:null,valueOf:null},g=new T(1),b=20,d=4,_=-7,v=21,S=-1e7,$=1e7,E=!1,o=1,w=0,C={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},O="0123456789abcdefghijklmnopqrstuvwxyz",A=!0;function T(e,t){var r,n,o,i,a,s,l,c,u=this;if(!(u instanceof T))return new T(e,t);if(null==t){if(e&&!0===e._isBigNumber)return u.s=e.s,void(!e.c||e.e>$?u.c=u.e=null:e.e<S?u.c=[u.e=0]:(u.e=e.e,u.c=e.c.slice()));if((s="number"==typeof e)&&0*e==0){if(u.s=1/e<0?(e=-e,-1):1,e===~~e){for(i=0,a=e;10<=a;a/=10,i++);return void($<i?u.c=u.e=null:(u.e=i,u.c=[e]))}c=String(e)}else{if(!isNumeric.test(c=String(e)))return h(u,c,s);u.s=45==c.charCodeAt(0)?(c=c.slice(1),-1):1}0<(a=(c=-1<(i=c.indexOf("."))?c.replace(".",""):c).search(/e/i))?(i<0&&(i=a),i+=+c.slice(a+1),c=c.substring(0,a)):i<0&&(i=c.length)}else{if(intCheck(t,2,O.length,"Base"),10==t&&A)return M(u=new T(e),b+u.e+1,d);if(c=String(e),s="number"==typeof e){if(0*e!=0)return h(u,c,s,t);if(u.s=1/e<0?(c=c.slice(1),-1):1,T.DEBUG&&15<c.replace(/^0\.0*|\./,"").length)throw Error(tooManyDigits+e)}else u.s=45===c.charCodeAt(0)?(c=c.slice(1),-1):1;for(r=O.slice(0,t),i=a=0,l=c.length;a<l;a++)if(r.indexOf(n=c.charAt(a))<0){if("."==n){if(i<a){i=l;continue}}else if(!o&&(c==c.toUpperCase()&&(c=c.toLowerCase())||c==c.toLowerCase()&&(c=c.toUpperCase()))){o=!0,a=-1,i=0;continue}return h(u,String(e),s,t)}s=!1,-1<(i=(c=f(c,t,10,u.s)).indexOf("."))?c=c.replace(".",""):i=c.length}for(a=0;48===c.charCodeAt(a);a++);for(l=c.length;48===c.charCodeAt(--l););if(c=c.slice(a,++l)){if(l-=a,s&&T.DEBUG&&15<l&&(MAX_SAFE_INTEGER<e||e!==mathfloor(e)))throw Error(tooManyDigits+u.s*e);if((i=i-a-1)>$)u.c=u.e=null;else if(i<S)u.c=[u.e=0];else{if(u.e=i,u.c=[],a=(i+1)%LOG_BASE,i<0&&(a+=LOG_BASE),a<l){for(a&&u.c.push(+c.slice(0,a)),l-=LOG_BASE;a<l;)u.c.push(+c.slice(a,a+=LOG_BASE));a=LOG_BASE-(c=c.slice(a)).length}else a-=l;for(;a--;c+="0");u.c.push(+c)}}else u.c=[u.e=0]}function N(e,t,r,n){for(var o,i,a=[0],s=0,l=e.length;s<l;){for(i=a.length;i--;a[i]*=t);for(a[0]+=n.indexOf(e.charAt(s++)),o=0;o<a.length;o++)a[o]>r-1&&(null==a[o+1]&&(a[o+1]=0),a[o+1]+=a[o]/r|0,a[o]%=r)}return a.reverse()}function P(e,t,r){var n,o,i,a=0,s=e.length,l=t%SQRT_BASE,c=t/SQRT_BASE|0;for(e=e.slice();s--;)a=((o=l*(i=e[s]%SQRT_BASE)+(n=c*i+(i=e[s]/SQRT_BASE|0)*l)%SQRT_BASE*SQRT_BASE+a)/r|0)+(n/SQRT_BASE|0)+c*i,e[s]=o%r;return e=a?[a].concat(e):e}function k(e,t,r,n){var o,i;if(r!=n)i=n<r?1:-1;else for(o=i=0;o<r;o++)if(e[o]!=t[o]){i=e[o]>t[o]?1:-1;break}return i}function G(e,t,r,n){for(var o=0;r--;)e[r]-=o,o=e[r]<t[r]?1:0,e[r]=o*n+e[r]-t[r];for(;!e[0]&&1<e.length;e.splice(0,1));}function n(e,t,r,n){var o,i,a,s;if(null==r?r=d:intCheck(r,0,8),!e.c)return e.toString();if(o=e.c[0],i=e.e,null==t)s=coeffToString(e.c),s=1==n||2==n&&(i<=_||v<=i)?toExponential(s,i):toFixedPoint(s,i,"0");else if(r=(e=M(new T(e),t,r)).e,a=(s=coeffToString(e.c)).length,1==n||2==n&&(t<=r||r<=_)){for(;a<t;s+="0",a++);s=toExponential(s,r)}else if(t-=i,s=toFixedPoint(s,r,"0"),a<r+1){if(0<--t)for(s+=".";t--;s+="0");}else if(0<(t+=r-a))for(r+1==a&&(s+=".");t--;s+="0");return e.s<0&&o?"-"+s:s}function i(e,t){for(var r,n=1,o=new T(e[0]);n<e.length;n++){if(!(r=new T(e[n])).s){o=r;break}t.call(o,r)&&(o=r)}return o}function B(e,t,r){for(var n=1,o=t.length;!t[--o];t.pop());for(o=t[0];10<=o;o/=10,n++);return(r=n+r*LOG_BASE-1)>$?e.c=e.e=null:r<S?e.c=[e.e=0]:(e.e=r,e.c=t),e}function M(e,t,r,n){var o,i,a,s,l,c,u,f=e.c,h=POWS_TEN;if(f){e:{for(o=1,s=f[0];10<=s;s/=10,o++);if((i=t-o)<0)i+=LOG_BASE,a=t,u=(l=f[c=0])/h[o-a-1]%10|0;else if((c=mathceil((i+1)/LOG_BASE))>=f.length){if(!n)break e;for(;f.length<=c;f.push(0));l=u=0,a=(i%=LOG_BASE)-LOG_BASE+(o=1)}else{for(l=s=f[c],o=1;10<=s;s/=10,o++);u=(a=(i%=LOG_BASE)-LOG_BASE+o)<0?0:l/h[o-a-1]%10|0}if(n=n||t<0||null!=f[c+1]||(a<0?l:l%h[o-a-1]),n=r<4?(u||n)&&(0==r||r==(e.s<0?3:2)):5<u||5==u&&(4==r||n||6==r&&(0<i?0<a?l/h[o-a]:0:f[c-1])%10&1||r==(e.s<0?8:7)),t<1||!f[0])return f.length=0,n?(t-=e.e+1,f[0]=h[(LOG_BASE-t%LOG_BASE)%LOG_BASE],e.e=-t||0):f[0]=e.e=0,e;if(0==i?(f.length=c,s=1,c--):(f.length=c+1,s=h[LOG_BASE-i],f[c]=0<a?mathfloor(l/h[o-a]%h[a])*s:0),n)for(;;){if(0==c){for(i=1,a=f[0];10<=a;a/=10,i++);for(a=f[0]+=s,s=1;10<=a;a/=10,s++);i!=s&&(e.e++,f[0]==BASE&&(f[0]=1));break}if(f[c]+=s,f[c]!=BASE)break;f[c--]=0,s=1}for(i=f.length;0===f[--i];f.pop());}e.e>$?e.c=e.e=null:e.e<S&&(e.c=[e.e=0])}return e}function j(e){var t,r=e.e;return null===r?e.toString():(t=coeffToString(e.c),t=r<=_||v<=r?toExponential(t,r):toFixedPoint(t,r,"0"),e.s<0?"-"+t:t)}return T.clone=clone,T.ROUND_UP=0,T.ROUND_DOWN=1,T.ROUND_CEIL=2,T.ROUND_FLOOR=3,T.ROUND_HALF_UP=4,T.ROUND_HALF_DOWN=5,T.ROUND_HALF_EVEN=6,T.ROUND_HALF_CEIL=7,T.ROUND_HALF_FLOOR=8,T.EUCLID=9,T.config=T.set=function(e){var t,r;if(null!=e){if("object"!=_typeof(e))throw Error(bignumberError+"Object expected: "+e);if(e.hasOwnProperty(t="DECIMAL_PLACES")&&(intCheck(r=e[t],0,MAX,t),b=r),e.hasOwnProperty(t="ROUNDING_MODE")&&(intCheck(r=e[t],0,8,t),d=r),e.hasOwnProperty(t="EXPONENTIAL_AT")&&((r=e[t])&&r.pop?(intCheck(r[0],-MAX,0,t),intCheck(r[1],0,MAX,t),_=r[0],v=r[1]):(intCheck(r,-MAX,MAX,t),_=-(v=r<0?-r:r))),e.hasOwnProperty(t="RANGE"))if((r=e[t])&&r.pop)intCheck(r[0],-MAX,-1,t),intCheck(r[1],1,MAX,t),S=r[0],$=r[1];else{if(intCheck(r,-MAX,MAX,t),!r)throw Error(bignumberError+t+" cannot be zero: "+r);S=-($=r<0?-r:r)}if(e.hasOwnProperty(t="CRYPTO")){if((r=e[t])!==!!r)throw Error(bignumberError+t+" not true or false: "+r);if(r){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw E=!r,Error(bignumberError+"crypto unavailable");E=r}else E=r}if(e.hasOwnProperty(t="MODULO_MODE")&&(intCheck(r=e[t],0,9,t),o=r),e.hasOwnProperty(t="POW_PRECISION")&&(intCheck(r=e[t],0,MAX,t),w=r),e.hasOwnProperty(t="FORMAT")){if("object"!=_typeof(r=e[t]))throw Error(bignumberError+t+" not an object: "+r);C=r}if(e.hasOwnProperty(t="ALPHABET")){if("string"!=typeof(r=e[t])||/^.?$|[+\-.\s]|(.).*\1/.test(r))throw Error(bignumberError+t+" invalid: "+r);A="0123456789"==r.slice(0,10),O=r}}return{DECIMAL_PLACES:b,ROUNDING_MODE:d,EXPONENTIAL_AT:[_,v],RANGE:[S,$],CRYPTO:E,MODULO_MODE:o,POW_PRECISION:w,FORMAT:C,ALPHABET:O}},T.isBigNumber=function(e){if(!e||!0!==e._isBigNumber)return!1;if(!T.DEBUG)return!0;var t,r,n=e.c,o=e.e,i=e.s;e:if("[object Array]"=={}.toString.call(n)){if((1===i||-1===i)&&-MAX<=o&&o<=MAX&&o===mathfloor(o))if(0===n[0]){if(0===o&&1===n.length)return!0}else if((t=(o+1)%LOG_BASE)<1&&(t+=LOG_BASE),String(n[0]).length==t){for(t=0;t<n.length;t++)if((r=n[t])<0||BASE<=r||r!==mathfloor(r))break e;if(0!==r)return!0}}else if(null===n&&null===o&&(null===i||1===i||-1===i))return!0;throw Error(bignumberError+"Invalid BigNumber: "+e)},T.maximum=T.max=function(){return i(arguments,r.lt)},T.minimum=T.min=function(){return i(arguments,r.gt)},T.random=(t=9007199254740992,c=Math.random()*t&2097151?function(){return mathfloor(Math.random()*t)}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)},function(e){var t,r,n,o,i,a=0,s=[],l=new T(g);if(null==e?e=b:intCheck(e,0,MAX),o=mathceil(e/LOG_BASE),E)if(crypto.getRandomValues){for(t=crypto.getRandomValues(new Uint32Array(o*=2));a<o;)9e15<=(i=131072*t[a]+(t[a+1]>>>11))?(r=crypto.getRandomValues(new Uint32Array(2)),t[a]=r[0],t[a+1]=r[1]):(s.push(i%1e14),a+=2);a=o/2}else{if(!crypto.randomBytes)throw E=!1,Error(bignumberError+"crypto unavailable");for(t=crypto.randomBytes(o*=7);a<o;)9e15<=(i=281474976710656*(31&t[a])+1099511627776*t[a+1]+4294967296*t[a+2]+16777216*t[a+3]+(t[a+4]<<16)+(t[a+5]<<8)+t[a+6])?crypto.randomBytes(7).copy(t,a):(s.push(i%1e14),a+=7);a=o/7}if(!E)for(;a<o;)(i=c())<9e15&&(s[a++]=i%1e14);for(o=s[--a],e%=LOG_BASE,o&&e&&(i=POWS_TEN[LOG_BASE-e],s[a]=mathfloor(o/i)*i);0===s[a];s.pop(),a--);if(a<0)s=[n=0];else{for(n=-1;0===s[0];s.splice(0,1),n-=LOG_BASE);for(a=1,i=s[0];10<=i;i/=10,a++);a<LOG_BASE&&(n-=LOG_BASE-a)}return l.e=n,l.c=s,l}),T.sum=function(){for(var e=1,t=arguments,r=new T(t[0]);e<t.length;)r=r.plus(t[e++]);return r},y="0123456789",f=function(e,t,r,n,o){var i,a,s,l,c,u,f,h,p=e.indexOf("."),g=b,_=d;for(0<=p&&(l=w,w=0,e=e.replace(".",""),u=(h=new T(t)).pow(e.length-p),w=l,h.c=N(toFixedPoint(coeffToString(u.c),u.e,"0"),10,r,y),h.e=h.c.length),s=l=(f=N(e,t,r,o?(i=O,y):(i=y,O))).length;0==f[--l];f.pop());if(!f[0])return i.charAt(0);if(p<0?--s:(u.c=f,u.e=s,u.s=n,f=(u=m(u,h,g,_,r)).c,c=u.r,s=u.e),p=f[a=s+g+1],l=r/2,c=c||a<0||null!=f[a+1],c=_<4?(null!=p||c)&&(0==_||_==(u.s<0?3:2)):l<p||p==l&&(4==_||c||6==_&&1&f[a-1]||_==(u.s<0?8:7)),a<1||!f[0])e=c?toFixedPoint(i.charAt(1),-g,i.charAt(0)):i.charAt(0);else{if(f.length=a,c)for(--r;++f[--a]>r;)f[a]=0,a||(++s,f=[1].concat(f));for(l=f.length;!f[--l];);for(p=0,e="";p<=l;e+=i.charAt(f[p++]));e=toFixedPoint(e,s,i.charAt(0))}return e},m=function(e,t,r,n,o){var i,a,s,l,c,u,f,h,p,g,_,m,y,b,d,v,S,$=e.s==t.s?1:-1,E=e.c,w=t.c;if(!(E&&E[0]&&w&&w[0]))return new T(e.s&&t.s&&(E?!w||E[0]!=w[0]:w)?E&&0==E[0]||!w?0*$:$/0:NaN);for(p=(h=new T($)).c=[],$=r+(a=e.e-t.e)+1,o||(o=BASE,a=bitFloor(e.e/LOG_BASE)-bitFloor(t.e/LOG_BASE),$=$/LOG_BASE|0),s=0;w[s]==(E[s]||0);s++);if(w[s]>(E[s]||0)&&a--,$<0)p.push(1),l=!0;else{for(b=E.length,v=w.length,$+=2,1<(c=mathfloor(o/(w[s=0]+1)))&&(w=P(w,c,o),E=P(E,c,o),v=w.length,b=E.length),y=v,_=(g=E.slice(0,v)).length;_<v;g[_++]=0);S=w.slice(),S=[0].concat(S),d=w[0],w[1]>=o/2&&d++;do{if(c=0,(i=k(w,g,v,_))<0){if(m=g[0],v!=_&&(m=m*o+(g[1]||0)),1<(c=mathfloor(m/d)))for(f=(u=P(w,c=o<=c?o-1:c,o)).length,_=g.length;1==k(u,g,f,_);)c--,G(u,v<f?S:w,f,o),f=u.length,i=1;else 0==c&&(i=c=1),f=(u=w.slice()).length;if(G(g,u=f<_?[0].concat(u):u,_,o),_=g.length,-1==i)for(;k(w,g,v,_)<1;)c++,G(g,v<_?S:w,_,o),_=g.length}else 0===i&&(c++,g=[0])}while(p[s++]=c,g[0]?g[_++]=E[y]||0:(g=[E[y]],_=1),(y++<b||null!=g[0])&&$--);l=null!=g[0],p[0]||p.splice(0,1)}if(o==BASE){for(s=1,$=p[0];10<=$;$/=10,s++);M(h,r+(h.e=s+a*LOG_BASE-1)+1,n,l)}else h.e=a,h.r=+l;return h},a=/^(-?)0([xbo])(?=\w[\w.]*$)/i,s=/^([^.]+)\.$/,l=/^\.([^.]+)$/,u=/^-?(Infinity|NaN)$/,p=/^\s*\+(?=[\w.])|^\s+|\s+$/g,h=function(e,t,r,n){var o,i=r?t:t.replace(p,"");if(u.test(i))e.s=isNaN(i)?null:i<0?-1:1;else{if(!r&&(i=i.replace(a,function(e,t,r){return o="x"==(r=r.toLowerCase())?16:"b"==r?2:8,n&&n!=o?e:t}),n&&(o=n,i=i.replace(s,"$1").replace(l,"0.$1")),t!=i))return new T(i,o);if(T.DEBUG)throw Error(bignumberError+"Not a"+(n?" base "+n:"")+" number: "+t);e.s=null}e.c=e.e=null},r.absoluteValue=r.abs=function(){var e=new T(this);return e.s<0&&(e.s=1),e},r.comparedTo=function(e,t){return compare(this,new T(e,t))},r.decimalPlaces=r.dp=function(e,t){var r,n;if(null!=e)return intCheck(e,0,MAX),null==t?t=d:intCheck(t,0,8),M(new T(this),e+this.e+1,t);if(!(e=this.c))return null;if(r=((n=e.length-1)-bitFloor(this.e/LOG_BASE))*LOG_BASE,n=e[n])for(;n%10==0;n/=10,r--);return r=r<0?0:r},r.dividedBy=r.div=function(e,t){return m(this,new T(e,t),b,d)},r.dividedToIntegerBy=r.idiv=function(e,t){return m(this,new T(e,t),0,1)},r.exponentiatedBy=r.pow=function(e,t){var r,n,o,i,a,s,l,c,u=this;if((e=new T(e)).c&&!e.isInteger())throw Error(bignumberError+"Exponent not an integer: "+j(e));if(null!=t&&(t=new T(t)),a=14<e.e,!u.c||!u.c[0]||1==u.c[0]&&!u.e&&1==u.c.length||!e.c||!e.c[0])return c=new T(Math.pow(+j(u),a?2-isOdd(e):+j(e))),t?c.mod(t):c;if(s=e.s<0,t){if(t.c?!t.c[0]:!t.s)return new T(NaN);(n=!s&&u.isInteger()&&t.isInteger())&&(u=u.mod(t))}else{if(9<e.e&&(0<u.e||u.e<-1||(0==u.e?1<u.c[0]||a&&24e7<=u.c[1]:u.c[0]<8e13||a&&u.c[0]<=9999975e7)))return i=u.s<0&&isOdd(e)?-0:0,-1<u.e&&(i=1/i),new T(s?1/i:i);w&&(i=mathceil(w/LOG_BASE+2))}for(l=a?(r=new T(.5),s&&(e.s=1),isOdd(e)):(o=Math.abs(+j(e)))%2,c=new T(g);;){if(l){if(!(c=c.times(u)).c)break;i?c.c.length>i&&(c.c.length=i):n&&(c=c.mod(t))}if(o){if(0===(o=mathfloor(o/2)))break;l=o%2}else if(M(e=e.times(r),e.e+1,1),14<e.e)l=isOdd(e);else{if(0===(o=+j(e)))break;l=o%2}u=u.times(u),i?u.c&&u.c.length>i&&(u.c.length=i):n&&(u=u.mod(t))}return n?c:(s&&(c=g.div(c)),t?c.mod(t):i?M(c,w,d,void 0):c)},r.integerValue=function(e){var t=new T(this);return null==e?e=d:intCheck(e,0,8),M(t,t.e+1,e)},r.isEqualTo=r.eq=function(e,t){return 0===compare(this,new T(e,t))},r.isFinite=function(){return!!this.c},r.isGreaterThan=r.gt=function(e,t){return 0<compare(this,new T(e,t))},r.isGreaterThanOrEqualTo=r.gte=function(e,t){return 1===(t=compare(this,new T(e,t)))||0===t},r.isInteger=function(){return!!this.c&&bitFloor(this.e/LOG_BASE)>this.c.length-2},r.isLessThan=r.lt=function(e,t){return compare(this,new T(e,t))<0},r.isLessThanOrEqualTo=r.lte=function(e,t){return-1===(t=compare(this,new T(e,t)))||0===t},r.isNaN=function(){return!this.s},r.isNegative=function(){return this.s<0},r.isPositive=function(){return 0<this.s},r.isZero=function(){return!!this.c&&0==this.c[0]},r.minus=function(e,t){var r,n,o,i,a=this,s=a.s;if(t=(e=new T(e,t)).s,!s||!t)return new T(NaN);if(s!=t)return e.s=-t,a.plus(e);var l=a.e/LOG_BASE,c=e.e/LOG_BASE,u=a.c,f=e.c;if(!l||!c){if(!u||!f)return u?(e.s=-t,e):new T(f?a:NaN);if(!u[0]||!f[0])return f[0]?(e.s=-t,e):new T(u[0]?a:3==d?-0:0)}if(l=bitFloor(l),c=bitFloor(c),u=u.slice(),s=l-c){for((o=(i=s<0)?(s=-s,u):(c=l,f)).reverse(),t=s;t--;o.push(0));o.reverse()}else for(n=(i=(s=u.length)<(t=f.length))?s:t,s=t=0;t<n;t++)if(u[t]!=f[t]){i=u[t]<f[t];break}if(i&&(o=u,u=f,f=o,e.s=-e.s),0<(t=(n=f.length)-(r=u.length)))for(;t--;u[r++]=0);for(t=BASE-1;s<n;){if(u[--n]<f[n]){for(r=n;r&&!u[--r];u[r]=t);--u[r],u[n]+=BASE}u[n]-=f[n]}for(;0==u[0];u.splice(0,1),--c);return u[0]?B(e,u,c):(e.s=3==d?-1:1,e.c=[e.e=0],e)},r.modulo=r.mod=function(e,t){var r,n=this;return e=new T(e,t),!n.c||!e.s||e.c&&!e.c[0]?new T(NaN):!e.c||n.c&&!n.c[0]?new T(n):(9==o?(t=e.s,e.s=1,r=m(n,e,0,3),e.s=t,r.s*=t):r=m(n,e,0,o),(e=n.minus(r.times(e))).c[0]||1!=o||(e.s=n.s),e)},r.multipliedBy=r.times=function(e,t){var r,n,o,i,a,s,l,c,u,f,h,p,g,_=this,m=_.c,y=(e=new T(e,t)).c;if(!(m&&y&&m[0]&&y[0]))return!_.s||!e.s||m&&!m[0]&&!y||y&&!y[0]&&!m?e.c=e.e=e.s=null:(e.s*=_.s,m&&y?(e.c=[0],e.e=0):e.c=e.e=null),e;for(t=bitFloor(_.e/LOG_BASE)+bitFloor(e.e/LOG_BASE),e.s*=_.s,(s=m.length)<(_=y.length)&&(h=m,m=y,y=h,n=s,s=_,_=n),n=s+_,h=[];n--;h.push(0));for(p=BASE,g=SQRT_BASE,n=_;0<=--n;){for(u=y[n]%g,f=y[n]/g|(r=0),o=n+(i=s);n<o;)r=((l=u*(l=m[--i]%g)+(a=f*l+(c=m[i]/g|0)*u)%g*g+h[o]+r)/p|0)+(a/g|0)+f*c,h[o--]=l%p;h[o]=r}return r?++t:h.splice(0,1),B(e,h,t)},r.negated=function(){var e=new T(this);return e.s=-e.s||null,e},r.plus=function(e,t){var r,n=this,o=n.s;if(t=(e=new T(e,t)).s,!o||!t)return new T(NaN);if(o!=t)return e.s=-t,n.minus(e);var i=n.e/LOG_BASE,a=e.e/LOG_BASE,s=n.c,l=e.c;if(!i||!a){if(!s||!l)return new T(o/0);if(!s[0]||!l[0])return l[0]?e:new T(s[0]?n:0*o)}if(i=bitFloor(i),a=bitFloor(a),s=s.slice(),o=i-a){for((r=0<o?(a=i,l):(o=-o,s)).reverse();o--;r.push(0));r.reverse()}for((o=s.length)-(t=l.length)<0&&(r=l,l=s,s=r,t=o),o=0;t;)o=(s[--t]=s[t]+l[t]+o)/BASE|0,s[t]=BASE===s[t]?0:s[t]%BASE;return o&&(s=[o].concat(s),++a),B(e,s,a)},r.precision=r.sd=function(e,t){var r,n;if(null!=e&&e!==!!e)return intCheck(e,1,MAX),null==t?t=d:intCheck(t,0,8),M(new T(this),e,t);if(!(t=this.c))return null;if(r=(n=t.length-1)*LOG_BASE+1,n=t[n]){for(;n%10==0;n/=10,r--);for(n=t[0];10<=n;n/=10,r++);}return r=e&&this.e+1>r?this.e+1:r},r.shiftedBy=function(e){return intCheck(e,-MAX_SAFE_INTEGER,MAX_SAFE_INTEGER),this.times("1e"+e)},r.squareRoot=r.sqrt=function(){var e,t,r,n,o,i=this,a=i.c,s=i.s,l=i.e,c=b+4,u=new T("0.5");if(1!==s||!a||!a[0])return new T(!s||s<0&&(!a||a[0])?NaN:a?i:1/0);if((r=0==(s=Math.sqrt(+j(i)))||s==1/0?(((t=coeffToString(a)).length+l)%2==0&&(t+="0"),s=Math.sqrt(+t),l=bitFloor((l+1)/2)-(l<0||l%2),new T(t=s==1/0?"5e"+l:(t=s.toExponential()).slice(0,t.indexOf("e")+1)+l)):new T(s+"")).c[0])for((s=(l=r.e)+c)<3&&(s=0);;)if(o=r,r=u.times(o.plus(m(i,o,c,1))),coeffToString(o.c).slice(0,s)===(t=coeffToString(r.c)).slice(0,s)){if(r.e<l&&--s,"9999"!=(t=t.slice(s-3,s+1))&&(n||"4999"!=t)){+t&&(+t.slice(1)||"5"!=t.charAt(0))||(M(r,r.e+b+2,1),e=!r.times(r).eq(i));break}if(!n&&(M(o,o.e+b+2,0),o.times(o).eq(i))){r=o;break}c+=4,s+=4,n=1}return M(r,r.e+b+1,d,e)},r.toExponential=function(e,t){return null!=e&&(intCheck(e,0,MAX),e++),n(this,e,t,1)},r.toFixed=function(e,t){return null!=e&&(intCheck(e,0,MAX),e=e+this.e+1),n(this,e,t)},r.toFormat=function(e,t,r){if(null==r)null!=e&&t&&"object"==_typeof(t)?(r=t,t=null):e&&"object"==_typeof(e)?(r=e,e=t=null):r=C;else if("object"!=_typeof(r))throw Error(bignumberError+"Argument not an object: "+r);if(e=this.toFixed(e,t),this.c){var n,t=e.split("."),o=+r.groupSize,i=+r.secondaryGroupSize,a=r.groupSeparator||"",s=t[0],t=t[1],l=this.s<0,c=l?s.slice(1):s,u=c.length;if(i&&(n=o,o=i,u-=i=n),0<o&&0<u){for(s=c.substr(0,n=u%o||o);n<u;n+=o)s+=a+c.substr(n,o);0<i&&(s+=a+c.slice(n)),l&&(s="-"+s)}e=t?s+(r.decimalSeparator||"")+((i=+r.fractionGroupSize)?t.replace(new RegExp("\\d{"+i+"}\\B","g"),"$&"+(r.fractionGroupSeparator||"")):t):s}return(r.prefix||"")+e+(r.suffix||"")},r.toFraction=function(e){var t,r,n,o,i,a,s,l,c,u,f=this,h=f.c;if(null!=e&&(!(s=new T(e)).isInteger()&&(s.c||1!==s.s)||s.lt(g)))throw Error(bignumberError+"Argument "+(s.isInteger()?"out of range: ":"not an integer: ")+j(s));if(!h)return new T(f);for(t=new T(g),c=r=new T(g),n=l=new T(g),h=coeffToString(h),i=t.e=h.length-f.e-1,t.c[0]=POWS_TEN[(a=i%LOG_BASE)<0?LOG_BASE+a:a],e=!e||0<s.comparedTo(t)?0<i?t:c:s,a=$,$=1/0,s=new T(h),l.c[0]=0;u=m(s,t,0,1),1!=(o=r.plus(u.times(n))).comparedTo(e);)r=n,n=o,c=l.plus(u.times(o=c)),l=o,t=s.minus(u.times(o=t)),s=o;return o=m(e.minus(r),n,0,1),l=l.plus(o.times(c)),r=r.plus(o.times(n)),l.s=c.s=f.s,h=m(c,n,i*=2,d).minus(f).abs().comparedTo(m(l,r,i,d).minus(f).abs())<1?[c,n]:[l,r],$=a,h},r.toNumber=function(){return+j(this)},r.toPrecision=function(e,t){return null!=e&&intCheck(e,1,MAX),n(this,e,t,2)},r.toString=function(e){var t,r=this,n=r.s,o=r.e;return null===o?n?(t="Infinity",n<0&&(t="-"+t)):t="NaN":(t=null==e?o<=_||v<=o?toExponential(coeffToString(r.c),o):toFixedPoint(coeffToString(r.c),o,"0"):10===e&&A?toFixedPoint(coeffToString((r=M(new T(r),b+o+1,d)).c),r.e,"0"):(intCheck(e,2,O.length,"Base"),f(toFixedPoint(coeffToString(r.c),o,"0"),10,e,n,!0)),n<0&&r.c[0]&&(t="-"+t)),t},r.valueOf=r.toJSON=function(){return j(this)},r._isBigNumber=!0,r[Symbol.toStringTag]="BigNumber",r[Symbol.for("nodejs.util.inspect.custom")]=r.valueOf,null!=e&&T.set(e),T}function bitFloor(e){var t=0|e;return 0<e||e===t?t:t-1}function coeffToString(e){for(var t,r,n=1,o=e.length,i=e[0]+"";n<o;){for(t=e[n++]+"",r=LOG_BASE-t.length;r--;t="0"+t);i+=t}for(o=i.length;48===i.charCodeAt(--o););return i.slice(0,o+1||1)}function compare(e,t){var r,n,o=e.c,i=t.c,a=e.s,s=t.s,e=e.e,t=t.e;if(!a||!s)return null;if(r=o&&!o[0],n=i&&!i[0],r||n)return r?n?0:-s:a;if(a!=s)return a;if(r=a<0,n=e==t,!o||!i)return n?0:!o^r?1:-1;if(!n)return t<e^r?1:-1;for(s=(e=o.length)<(t=i.length)?e:t,a=0;a<s;a++)if(o[a]!=i[a])return o[a]>i[a]^r?1:-1;return e==t?0:t<e^r?1:-1}function intCheck(e,t,r,n){if(e<t||r<e||e!==mathfloor(e))throw Error(bignumberError+(n||"Argument")+("number"==typeof e?e<t||r<e?" out of range: ":" not an integer: ":" not a primitive number: ")+String(e))}function isOdd(e){var t=e.c.length-1;return bitFloor(e.e/LOG_BASE)==t&&e.c[t]%2!=0}function toExponential(e,t){return(1<e.length?e.charAt(0)+"."+e.slice(1):e)+(t<0?"e":"e+")+t}function toFixedPoint(e,t,r){var n,o;if(t<0){for(o=r+".";++t;o+=r);e=o+e}else if(++t>(n=e.length)){for(o=r,t-=n;--t;o+=r);e+=o}else t<n&&(e=e.slice(0,t)+"."+e.slice(t));return e}var BigNumber=clone();function format(e,t,r){var n="";if(BigNumber.isBigNumber(e))n=e.toFixed();else if("string"!=typeof e)n=e.toString();else if(!0===r){r=splitUnitNum(e);if(null===r.num)return null;n=BigNumber(r.num).toFixed()}else n=BigNumber(e).toFixed();if("undefined"===n||"NaN"===n)return null;var o=null,i=null,a=null,s=null;if(t.forEach(function(e){var t=e.type;if("symbol"===t){if(![">=","<=","="].includes(e.value))throw new Error("错误的格式化参数:",e.value);i=e.value}else if("comma"===t)a=!0;else if("number"===t)o=e.value;else{if("plus"!==t)throw new Error("错误的fmt Token");s=!0}}),null!==o){var r=n.split("."),e=r[0],l=1===r.length?"":r[1],c=l.length;switch(i){case"<=":l=c<=o?l:l.slice(0,o);break;case"=":c<o?l+="0".repeat(o-c):o<c&&(l=l.slice(0,o));break;case">=":l=o<=c?l:l+"0".repeat(o-c)}n=""===l?e:"".concat(e,".").concat(l)}return null!==a&&(n=1<(t=n.split(".")).length?((r=t[0]).includes("-")?t[0]=r[0]+r.slice(1).replace(/(?=(?!^)(?:\d{3})+$)/g,","):t[0]=r.replace(/(?=(?!^)(?:\d{3})+$)/g,","),t.join(".")):(e=t[0]).includes("-")?e[0]+e.slice(1).replace(/(?=(?!^)(?:\d{3})+$)/g,","):e.replace(/(?=(?!^)(?:\d{3})+$)/g,",")),n=null===s||n.startsWith("-")?n:"+"+n}function tokenizer(e){for(var t=[],r=0,n=null,o=e.length;r<o;)if(n=e[r],/\s/.test(n))r++;else if("+-".includes(n)){var i=t[t.length-1];if(0===t.length||"+-".includes(i)||"("===i){var a=n;if(++r>=o){t.push(a);break}for(n=e[r];/[a-zA-Z\d._]/.test(n)&&(a+=n,!(++r>=o));)n=e[r];t.push(a)}else t.push(n),r++}else if("*/%()".includes(n))t.push(n),r++;else if(/[a-zA-Z_$]/.test(n)){for(var s="";/[\w_.\[\]"']/.test(n)&&(s+=n,!(++r>=o));)n=e[r];t.push(s)}else if(/\d/.test(n)){for(var l="";/[^+*/()\s-]/.test(n)&&(l+=n,!(++r>=o));)n=e[r];t.push(l)}return t}var commonjsGlobal="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},isArray$3=Array.isArray,isArray_1=isArray$3,freeGlobal$1="object"==_typeof(commonjsGlobal)&&commonjsGlobal&&commonjsGlobal.Object===Object&&commonjsGlobal,_freeGlobal=freeGlobal$1,freeGlobal=freeGlobal$1,freeSelf="object"==("undefined"==typeof self?"undefined":_typeof(self))&&self&&self.Object===Object&&self,root$3=freeGlobal||freeSelf||Function("return this")(),_root=root$3,root$2=_root,_Symbol2=_root.Symbol,_Symbol$3=_Symbol2,_Symbol$2=_Symbol$3,objectProto$4=Object.prototype,hasOwnProperty$3=objectProto$4.hasOwnProperty,nativeObjectToString$1=objectProto$4.toString,symToStringTag$1=_Symbol$2?_Symbol$2.toStringTag:void 0;function getRawTag$1(e){var t=hasOwnProperty$3.call(e,symToStringTag$1),r=e[symToStringTag$1];try{var n=!(e[symToStringTag$1]=void 0)}catch(e){}var o=nativeObjectToString$1.call(e);return n&&(t?e[symToStringTag$1]=r:delete e[symToStringTag$1]),o}var _getRawTag=getRawTag$1,objectProto$3=Object.prototype,nativeObjectToString=objectProto$3.toString;function objectToString$1(e){return nativeObjectToString.call(e)}var _objectToString=objectToString$1,_Symbol$1=_Symbol$3,getRawTag=_getRawTag,objectToString=objectToString$1,nullTag="[object Null]",undefinedTag="[object Undefined]",symToStringTag=_Symbol$3?_Symbol$3.toStringTag:void 0;function baseGetTag$2(e){return null==e?void 0===e?undefinedTag:nullTag:(symToStringTag&&symToStringTag in Object(e)?getRawTag:objectToString)(e)}var _baseGetTag=baseGetTag$2;function isObjectLike$1(e){return null!=e&&"object"==_typeof(e)}var isObjectLike_1=isObjectLike$1,baseGetTag$1=baseGetTag$2,isObjectLike=isObjectLike$1,symbolTag="[object Symbol]";function isSymbol$3(e){return"symbol"==_typeof(e)||isObjectLike(e)&&baseGetTag$1(e)==symbolTag}var isSymbol_1=isSymbol$3,isArray$2=isArray_1,isSymbol$2=isSymbol_1,reIsDeepProp=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,reIsPlainProp=/^\w*$/;function isKey$1(e,t){if(isArray$2(e))return!1;var r=_typeof(e);return!("number"!=r&&"symbol"!=r&&"boolean"!=r&&null!=e&&!isSymbol$2(e))||(reIsPlainProp.test(e)||!reIsDeepProp.test(e)||null!=t&&e in Object(t))}var _isKey=isKey$1;function isObject$2(e){var t=_typeof(e);return null!=e&&("object"==t||"function"==t)}var isObject_1=isObject$2,baseGetTag=baseGetTag$2,isObject$1=isObject_1,asyncTag="[object AsyncFunction]",funcTag="[object Function]",genTag="[object GeneratorFunction]",proxyTag="[object Proxy]";function isFunction$1(e){if(!isObject$1(e))return!1;e=baseGetTag(e);return e==funcTag||e==genTag||e==asyncTag||e==proxyTag}var isFunction_1=isFunction$1,root$1=_root,coreJsData$1=_root["__core-js_shared__"],_coreJsData=coreJsData$1,coreJsData=coreJsData$1,maskSrcKey=function(){var e=/[^.]+$/.exec(coreJsData&&coreJsData.keys&&coreJsData.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function isMasked$1(e){return!!maskSrcKey&&maskSrcKey in e}var _isMasked=isMasked$1,funcProto$1=Function.prototype,funcToString$1=funcProto$1.toString;function toSource$1(e){if(null!=e){try{return funcToString$1.call(e)}catch(e){}try{return e+""}catch(e){}}return""}var _toSource=toSource$1,isFunction=isFunction_1,isMasked=_isMasked,isObject=isObject_1,toSource=toSource$1,reRegExpChar=/[\\^$.*+?()[\]{}|]/g,reIsHostCtor=/^\[object .+?Constructor\]$/,funcProto=Function.prototype,objectProto$2=Object.prototype,funcToString=funcProto.toString,hasOwnProperty$2=objectProto$2.hasOwnProperty,reIsNative=RegExp("^"+funcToString.call(hasOwnProperty$2).replace(reRegExpChar,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function baseIsNative$1(e){return!(!isObject(e)||isMasked(e))&&(isFunction(e)?reIsNative:reIsHostCtor).test(toSource(e))}var _baseIsNative=baseIsNative$1;function getValue$1(e,t){return null==e?void 0:e[t]}var _getValue=getValue$1,baseIsNative=baseIsNative$1,getValue=getValue$1;function getNative$2(e,t){e=getValue(e,t);return baseIsNative(e)?e:void 0}var _getNative=getNative$2,getNative$1=_getNative,nativeCreate$4=_getNative(Object,"create"),_nativeCreate=nativeCreate$4,nativeCreate$3=_nativeCreate;function hashClear$1(){this.__data__=nativeCreate$3?nativeCreate$3(null):{},this.size=0}var _hashClear=hashClear$1;function hashDelete$1(e){e=this.has(e)&&delete this.__data__[e];return this.size-=e?1:0,e}var _hashDelete=hashDelete$1,nativeCreate$2=_nativeCreate,HASH_UNDEFINED$1="__lodash_hash_undefined__",objectProto$1=Object.prototype,hasOwnProperty$1=objectProto$1.hasOwnProperty;function hashGet$1(e){var t,r=this.__data__;return nativeCreate$2?(t=r[e])===HASH_UNDEFINED$1?void 0:t:hasOwnProperty$1.call(r,e)?r[e]:void 0}var _hashGet=hashGet$1,nativeCreate$1=_nativeCreate,objectProto=Object.prototype,hasOwnProperty=objectProto.hasOwnProperty;function hashHas$1(e){var t=this.__data__;return nativeCreate$1?void 0!==t[e]:hasOwnProperty.call(t,e)}var _hashHas=hashHas$1,nativeCreate=_nativeCreate,HASH_UNDEFINED="__lodash_hash_undefined__";function hashSet$1(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=nativeCreate&&void 0===t?HASH_UNDEFINED:t,this}var _hashSet=hashSet$1,hashClear=_hashClear,hashDelete=_hashDelete,hashGet=_hashGet,hashHas=hashHas$1,hashSet=hashSet$1;function Hash$1(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}Hash$1.prototype.clear=hashClear,Hash$1.prototype.delete=hashDelete,Hash$1.prototype.get=hashGet,Hash$1.prototype.has=hashHas,Hash$1.prototype.set=hashSet;var _Hash=Hash$1;function listCacheClear$1(){this.__data__=[],this.size=0}var _listCacheClear=listCacheClear$1;function eq$1(e,t){return e===t||e!=e&&t!=t}var eq_1=eq$1,eq=eq$1;function assocIndexOf$4(e,t){for(var r=e.length;r--;)if(eq(e[r][0],t))return r;return-1}var _assocIndexOf=assocIndexOf$4,assocIndexOf$3=_assocIndexOf,arrayProto=Array.prototype,splice=arrayProto.splice;function listCacheDelete$1(e){var t=this.__data__,e=assocIndexOf$3(t,e);return!(e<0)&&(e==t.length-1?t.pop():splice.call(t,e,1),--this.size,!0)}var _listCacheDelete=listCacheDelete$1,assocIndexOf$2=_assocIndexOf;function listCacheGet$1(e){var t=this.__data__,e=assocIndexOf$2(t,e);return e<0?void 0:t[e][1]}var _listCacheGet=listCacheGet$1,assocIndexOf$1=_assocIndexOf;function listCacheHas$1(e){return-1<assocIndexOf$1(this.__data__,e)}var _listCacheHas=listCacheHas$1,assocIndexOf=_assocIndexOf;function listCacheSet$1(e,t){var r=this.__data__,n=assocIndexOf(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this}var _listCacheSet=listCacheSet$1,listCacheClear=_listCacheClear,listCacheDelete=listCacheDelete$1,listCacheGet=listCacheGet$1,listCacheHas=listCacheHas$1,listCacheSet=listCacheSet$1;function ListCache$1(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}ListCache$1.prototype.clear=listCacheClear,ListCache$1.prototype.delete=listCacheDelete,ListCache$1.prototype.get=listCacheGet,ListCache$1.prototype.has=listCacheHas,ListCache$1.prototype.set=listCacheSet;var _ListCache=ListCache$1,getNative=_getNative,root=_root,Map$2=_getNative(_root,"Map"),_Map=Map$2,Hash=_Hash,ListCache=_ListCache,Map$1=Map$2;function mapCacheClear$1(){this.size=0,this.__data__={hash:new Hash,map:new(Map$1||ListCache),string:new Hash}}var _mapCacheClear=mapCacheClear$1;function isKeyable$1(e){var t=_typeof(e);return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e}var _isKeyable=isKeyable$1,isKeyable=isKeyable$1;function getMapData$4(e,t){e=e.__data__;return isKeyable(t)?e["string"==typeof t?"string":"hash"]:e.map}var _getMapData=getMapData$4,getMapData$3=getMapData$4;function mapCacheDelete$1(e){e=getMapData$3(this,e).delete(e);return this.size-=e?1:0,e}var _mapCacheDelete=mapCacheDelete$1,getMapData$2=getMapData$4;function mapCacheGet$1(e){return getMapData$2(this,e).get(e)}var _mapCacheGet=mapCacheGet$1,getMapData$1=getMapData$4;function mapCacheHas$1(e){return getMapData$1(this,e).has(e)}var _mapCacheHas=mapCacheHas$1,getMapData=getMapData$4;function mapCacheSet$1(e,t){var r=getMapData(this,e),n=r.size;return r.set(e,t),this.size+=r.size==n?0:1,this}var _mapCacheSet=mapCacheSet$1,mapCacheClear=mapCacheClear$1,mapCacheDelete=mapCacheDelete$1,mapCacheGet=mapCacheGet$1,mapCacheHas=mapCacheHas$1,mapCacheSet=mapCacheSet$1;function MapCache$1(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}MapCache$1.prototype.clear=mapCacheClear,MapCache$1.prototype.delete=mapCacheDelete,MapCache$1.prototype.get=mapCacheGet,MapCache$1.prototype.has=mapCacheHas,MapCache$1.prototype.set=mapCacheSet;var _MapCache=MapCache$1,MapCache=MapCache$1,FUNC_ERROR_TEXT="Expected a function";function memoize$1(n,o){if("function"!=typeof n||null!=o&&"function"!=typeof o)throw new TypeError(FUNC_ERROR_TEXT);function i(){var e=arguments,t=o?o.apply(this,e):e[0],r=i.cache;return r.has(t)?r.get(t):(e=n.apply(this,e),i.cache=r.set(t,e)||r,e)}return i.cache=new(memoize$1.Cache||MapCache),i}memoize$1.Cache=MapCache;var memoize_1=memoize$1,memoize=memoize$1,MAX_MEMOIZE_SIZE=500;function memoizeCapped$1(e){var e=memoize(e,function(e){return t.size===MAX_MEMOIZE_SIZE&&t.clear(),e}),t=e.cache;return e}var _memoizeCapped=memoizeCapped$1,memoizeCapped=memoizeCapped$1,rePropName=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,reEscapeChar=/\\(\\)?/g,stringToPath$1=memoizeCapped$1(function(e){var o=[];return 46===e.charCodeAt(0)&&o.push(""),e.replace(rePropName,function(e,t,r,n){o.push(r?n.replace(reEscapeChar,"$1"):t||e)}),o}),_stringToPath=stringToPath$1;function arrayMap$1(e,t){for(var r=-1,n=null==e?0:e.length,o=Array(n);++r<n;)o[r]=t(e[r],r,e);return o}var _arrayMap=arrayMap$1,_Symbol=_Symbol$3,arrayMap=arrayMap$1,isArray$1=isArray_1,isSymbol$1=isSymbol_1,INFINITY$1=1/0,symbolProto=_Symbol$3?_Symbol$3.prototype:void 0,symbolToString=symbolProto?symbolProto.toString:void 0;function baseToString$1(e){if("string"==typeof e)return e;if(isArray$1(e))return arrayMap(e,baseToString$1)+"";if(isSymbol$1(e))return symbolToString?symbolToString.call(e):"";var t=e+"";return"0"==t&&1/e==-INFINITY$1?"-0":t}var _baseToString=baseToString$1,baseToString=baseToString$1;function toString$1(e){return null==e?"":baseToString(e)}var toString_1=toString$1,isArray=isArray_1,isKey=_isKey,stringToPath=_stringToPath,toString=toString$1;function castPath$1(e,t){return isArray(e)?e:isKey(e,t)?[e]:stringToPath(toString(e))}var _castPath=castPath$1,isSymbol=isSymbol_1,INFINITY=1/0;function toKey$1(e){if("string"==typeof e||isSymbol(e))return e;var t=e+"";return"0"==t&&1/e==-INFINITY?"-0":t}var _toKey=toKey$1,castPath=castPath$1,toKey=toKey$1;function baseGet$1(e,t){for(var r=0,n=(t=castPath(t,e)).length;null!=e&&r<n;)e=e[toKey(t[r++])];return r&&r==n?e:void 0}var _baseGet=baseGet$1,baseGet=baseGet$1;function get(e,t,r){e=null==e?void 0:baseGet(e,t);return void 0===e?r:e}var get_1=get;function fillTokens(e,t,r){var n=[];if(!notNull(t))throw new TokensFillError("错误的填充数据:",t);Array.isArray(t)?n=t:n.push(t);for(var o=[],i=0;i<e.length;i++){var a=e[i];if(/^[a-zA-z_][\w\[\]"'_.]*$/.test(a)){if("undefined"===a||"NaN"===a)throw new TokensFillError("key不应该为:".concat(a));for(var s=null,l=0;l<n.length;l++){var c=n[l],c=get_1(c,a);if(void 0!==c){s=c;break}}if(null===s)throw new TokensFillError("token填充失败,请确认".concat(a,"存在"));if("string"==typeof s){if(""===s.trim())throw new TokensFillError("token填充失败,".concat(a,"值不可为空字符"));if(!0===r){if(!/^[+-]?[\d.]+\D*$/.test(s))throw new TokensFillError("token填充失败,".concat(a,"值:").concat(s,"为非法单位数字"))}else if(!isStrNumber(s))throw new TokensFillError("token填充失败,".concat(a,"值:").concat(s,"为非法数字"))}s="string"!=typeof s?s.toString():s,o.push(s)}else o.push(a)}return o}function fillFmtTokens(e,n){return e.map(function(e){if("var"!==e.type)return e;for(var t,r=0;r<n.length&&!notUndefined(t=get_1(n[r],e.value));r++);if(isNumber(t))return{type:"number",value:t};throw new TokensFillError("错误的填充值")})}function getTokenAndUnit(e){var r=null;return e.length,{tokens:e.map(function(e){var t=splitUnitNum(e);return null!==t.unit?(null==r&&(r=t.unit),t.num):e}),unit:r}}function fmt(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];var n=parseArgs(t),o=tokenizer(n.expr),i=null,a=null;if(!0===get_1(n,"data._debug")&&(console.warn("======a-calc调试模式======"),console.warn(n),console.warn(o)),""===n.expr.trim()&&notNull(n.data)&&notUndefined(n.data._error))return n.data._error;if(2<o.length)throw new Error("fmt并非用于计算, 不能传入多个标识:".concat(n.expr));if(1!==o.length)throw new Error("fmt接收了一个无法被解析的标识");if(notNull(n.data)){var s,l=n.data,c=[],u=l._fillError,f=get_1(l,"_unit",null);if(Array.isArray(l)?c=l:(c.push(i=l),notUndefined(s=get_1(i,"_fillData"))&&(Array.isArray(s)?c=[].concat(_toConsumableArray(c),_toConsumableArray(s)):c.push(s))),anyNotUndefined(u,l._error))try{o=fillTokens(o,c,f),notNull(n.fmt)&&(n.fmt=fillFmtTokens(n.fmt,c))}catch(e){if(e instanceof TokensFillError)return void 0!==i._warn&&!0===i._warn&&console.warn(e),i._fillError||i._error;throw e}else o=fillTokens(o,c,f),notNull(n.fmt)&&(n.fmt=fillFmtTokens(n.fmt,c));!0===f&&(a=(s=getTokenAndUnit(o)).unit,o=s.tokens)}if(null===n.fmt)throw"表达式没有格式化部分";u=o[0];if(!0===f){if(!/^[+-]?[\d.]+\D*$/.test(u))throw new TokensFillError("token填充失败,".concat(key,"值:").concat(value,"为非法单位数字"))}else if(!isStrNumber(u))throw new TokensFillError("待格式化对象: ".concat(u," 不是数字"));l=format(u,n.fmt,f);return null!==l&&null!==a&&(l+=a),l}var version="0.0.71";function token2postfix(e){for(var t=[],r=[],n=e;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;)r.push(i),i=t.pop();if("("!==i)throw"error: unmatched ()"}else{for(;prioraty(o,t[t.length-1])&&0<t.length;)r.push(t.pop());t.push(o)}else r.push(o)}if(0<t.length){if(")"===t[t.length-1]||"("===t[t.length-1])throw"error: unmatched ()";for(;0<t.length;)r.push(t.pop())}return r}function evalPostfix(e){for(var t,r=[];0<e.length;){var n=e.shift();if(isOperator(n)){if(r.length<2)throw new CalculatorError("错误的栈长度, 可能是无法计算的表达式");var o=r.pop(),i=r.pop();if("string"==typeof o&&!BigNumber.isBigNumber(o)){if(!isStrNumber(o))throw new CalculatorError("".concat(o,"不是一个合法的数字"));o=new BigNumber(o)}if("string"==typeof i&&!BigNumber.isBigNumber(i)){if(!isStrNumber(i))throw new CalculatorError("".concat(i,"不是一个合法的数字"));i=new BigNumber(i)}switch(n){case"+":r.push(i.plus(o));break;case"-":r.push(i.minus(o));break;case"*":r.push(i.times(o));break;case"/":r.push(i.div(o));break;case"%":r.push(i.mod(o))}}else r.push(n)}if(1!==r.length)throw"unvalid expression";return t=r[0],BigNumber.isBigNumber(t)?t:BigNumber(t)}function calc(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];var n,o=parseArgs(t),i=tokenizer(o.expr),a=null,s=null;if(!0===get_1(o,"data._debug")&&(console.warn("======a-calc调试模式======"),console.warn(o),console.warn(i)),notNull(o.data)){var l=o.data,c=[],u=l._error,f=l._fillError,h=l._warn,p=get_1(l,"_unit",null);if(Array.isArray(l)?c=l:(c.push(a=l),notUndefined(l=get_1(a,"_fillData"))&&(Array.isArray(l)?c=[].concat(_toConsumableArray(c),_toConsumableArray(l)):c.push(l))),anyNotUndefined(f,u))try{i=fillTokens(i,c,p),notNull(o.fmt)&&(o.fmt=fillFmtTokens(o.fmt,c))}catch(e){if(e instanceof TokensFillError)return notUndefined(h)&&!0===h&&console.warn(e),notUndefined(f)?f:u;throw e}else i=fillTokens(i,c,p),notNull(o.fmt)&&(o.fmt=fillFmtTokens(o.fmt,c));!0===p&&(s=(l=getTokenAndUnit(i)).unit,i=l.tokens)}f=token2postfix(i),c=null;if(notNull(a)&&anyNotUndefined(n,u))try{c=evalPostfix(f)}catch(e){if(e instanceof CalculatorError)return void 0!==h&&!0===h&&console.warn(e),notUndefined(n)?n:u;throw e}else c=evalPostfix(f);return null!==(c=notNull(o.fmt)?format(c,o.fmt):null!==c?c.toFixed():null)&&null!==s&&(c+=s),c}export{calc,fmt,version};
package/es/package.json DELETED
@@ -1,3 +0,0 @@
1
- {
2
- "type": "module"
3
- }
@@ -1,23 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8">
5
- <title>Title</title>
6
- <style>
7
- * {
8
- margin: 0;
9
- padding: 0;
10
- }
11
- </style>
12
- </head>
13
- <body>
14
-
15
- <!--<script src="./decimal.js.js"></script>-->
16
- <script src="../browser/index.js"></script>
17
-
18
- <script>
19
-
20
-
21
- </script>
22
- </body>
23
- </html>
package/example/index.js DELETED
@@ -1,8 +0,0 @@
1
- import { tokenizer } from "../src/tokenizer.js";
2
- import { token2postfix } from "../src/postfixExpr.js";
3
-
4
- let t1 = tokenizer("-1 - (-22321 * 3)");
5
- let t2 = tokenizer("1123 - (0.322 + -33.3) % 66");
6
- let t3 = tokenizer("+0.888-22*(66--3.33)");
7
-
8
- console.log(token2postfix(t2))