1 // [AIV_SHORT] Build version: 2.2.0 - Thursday, June 4th, 2020, 2:31:20 PM
5 /***/ (function(module, exports, __webpack_require__) {
10 exports.__esModule = true;
12 var _assign = __webpack_require__(69);
14 var _assign2 = _interopRequireDefault(_assign);
16 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
18 exports.default = _assign2.default || function (target) {
19 for (var i = 1; i < arguments.length; i++) {
20 var source = arguments[i];
22 for (var key in source) {
23 if (Object.prototype.hasOwnProperty.call(source, key)) {
24 target[key] = source[key];
35 /***/ (function(module, __webpack_exports__, __webpack_require__) {
38 Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
39 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_vue_loader_lib_selector_type_script_index_0_voteConfirm_vue__ = __webpack_require__(602);
40 /* empty harmony namespace reexport */
41 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__node_modules_vue_loader_lib_template_compiler_index_id_data_v_59f3fab1_hasScoped_true_buble_transforms_node_modules_vue_loader_lib_selector_type_template_index_0_voteConfirm_vue__ = __webpack_require__(652);
42 function injectStyle (ssrContext) {
43 __webpack_require__(650)
45 var normalizeComponent = __webpack_require__(266)
51 /* template functional */
52 var __vue_template_functional__ = false
54 var __vue_styles__ = injectStyle
56 var __vue_scopeId__ = "data-v-59f3fab1"
57 /* moduleIdentifier (server only) */
58 var __vue_module_identifier__ = null
59 var Component = normalizeComponent(
60 __WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_vue_loader_lib_selector_type_script_index_0_voteConfirm_vue__["a" /* default */],
61 __WEBPACK_IMPORTED_MODULE_1__node_modules_vue_loader_lib_template_compiler_index_id_data_v_59f3fab1_hasScoped_true_buble_transforms_node_modules_vue_loader_lib_selector_type_template_index_0_voteConfirm_vue__["a" /* default */],
62 __vue_template_functional__,
65 __vue_module_identifier__
68 /* harmony default export */ __webpack_exports__["default"] = (Component.exports);
74 /***/ (function(module, exports, __webpack_require__) {
76 var __WEBPACK_AMD_DEFINE_RESULT__;;(function (globalObject) {
\r
80 * bignumber.js v9.0.0
\r
81 * A JavaScript library for arbitrary-precision arithmetic.
\r
82 * https://github.com/MikeMcl/bignumber.js
\r
83 * Copyright (c) 2019 Michael Mclaughlin <M8ch88l@gmail.com>
\r
86 * BigNumber.prototype methods | BigNumber methods
\r
88 * absoluteValue abs | clone
\r
89 * comparedTo | config set
\r
90 * decimalPlaces dp | DECIMAL_PLACES
\r
91 * dividedBy div | ROUNDING_MODE
\r
92 * dividedToIntegerBy idiv | EXPONENTIAL_AT
\r
93 * exponentiatedBy pow | RANGE
\r
94 * integerValue | CRYPTO
\r
95 * isEqualTo eq | MODULO_MODE
\r
96 * isFinite | POW_PRECISION
\r
97 * isGreaterThan gt | FORMAT
\r
98 * isGreaterThanOrEqualTo gte | ALPHABET
\r
99 * isInteger | isBigNumber
\r
100 * isLessThan lt | maximum max
\r
101 * isLessThanOrEqualTo lte | minimum min
\r
108 * multipliedBy times |
\r
113 * squareRoot sqrt |
\r
128 isNumeric = /^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,
\r
129 mathceil = Math.ceil,
\r
130 mathfloor = Math.floor,
\r
132 bignumberError = '[BigNumber Error] ',
\r
133 tooManyDigits = bignumberError + 'Number primitive has more than 15 significant digits: ',
\r
137 MAX_SAFE_INTEGER = 0x1fffffffffffff, // 2^53 - 1
\r
138 // MAX_INT32 = 0x7fffffff, // 2^31 - 1
\r
139 POWS_TEN = [1, 10, 100, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13],
\r
143 // The limit on the value of DECIMAL_PLACES, TO_EXP_NEG, TO_EXP_POS, MIN_EXP, MAX_EXP, and
\r
144 // the arguments to toExponential, toFixed, toFormat, and toPrecision.
\r
145 MAX = 1E9; // 0 to MAX_INT32
\r
149 * Create and return a BigNumber constructor.
\r
151 function clone(configObject) {
\r
152 var div, convertBase, parseNumeric,
\r
153 P = BigNumber.prototype = { constructor: BigNumber, toString: null, valueOf: null },
\r
154 ONE = new BigNumber(1),
\r
157 //----------------------------- EDITABLE CONFIG DEFAULTS -------------------------------
\r
160 // The default values below must be integers within the inclusive ranges stated.
\r
161 // The values can also be changed at run-time using BigNumber.set.
\r
163 // The maximum number of decimal places for operations involving division.
\r
164 DECIMAL_PLACES = 20, // 0 to MAX
\r
166 // The rounding mode used when rounding to the above decimal places, and when using
\r
167 // toExponential, toFixed, toFormat and toPrecision, and round (default value).
\r
168 // UP 0 Away from zero.
\r
169 // DOWN 1 Towards zero.
\r
170 // CEIL 2 Towards +Infinity.
\r
171 // FLOOR 3 Towards -Infinity.
\r
172 // HALF_UP 4 Towards nearest neighbour. If equidistant, up.
\r
173 // HALF_DOWN 5 Towards nearest neighbour. If equidistant, down.
\r
174 // HALF_EVEN 6 Towards nearest neighbour. If equidistant, towards even neighbour.
\r
175 // HALF_CEIL 7 Towards nearest neighbour. If equidistant, towards +Infinity.
\r
176 // HALF_FLOOR 8 Towards nearest neighbour. If equidistant, towards -Infinity.
\r
177 ROUNDING_MODE = 4, // 0 to 8
\r
179 // EXPONENTIAL_AT : [TO_EXP_NEG , TO_EXP_POS]
\r
181 // The exponent value at and beneath which toString returns exponential notation.
\r
183 TO_EXP_NEG = -7, // 0 to -MAX
\r
185 // The exponent value at and above which toString returns exponential notation.
\r
187 TO_EXP_POS = 21, // 0 to MAX
\r
189 // RANGE : [MIN_EXP, MAX_EXP]
\r
191 // The minimum exponent value, beneath which underflow to zero occurs.
\r
192 // Number type: -324 (5e-324)
\r
193 MIN_EXP = -1e7, // -1 to -MAX
\r
195 // The maximum exponent value, above which overflow to Infinity occurs.
\r
196 // Number type: 308 (1.7976931348623157e+308)
\r
197 // For MAX_EXP > 1e7, e.g. new BigNumber('1e100000000').plus(1) may be slow.
\r
198 MAX_EXP = 1e7, // 1 to MAX
\r
200 // Whether to use cryptographically-secure random number generation, if available.
\r
201 CRYPTO = false, // true or false
\r
203 // The modulo mode used when calculating the modulus: a mod n.
\r
204 // The quotient (q = a / n) is calculated according to the corresponding rounding mode.
\r
205 // The remainder (r) is calculated as: r = a - n * q.
\r
207 // UP 0 The remainder is positive if the dividend is negative, else is negative.
\r
208 // DOWN 1 The remainder has the same sign as the dividend.
\r
209 // This modulo mode is commonly known as 'truncated division' and is
\r
210 // equivalent to (a % n) in JavaScript.
\r
211 // FLOOR 3 The remainder has the same sign as the divisor (Python %).
\r
212 // HALF_EVEN 6 This modulo mode implements the IEEE 754 remainder function.
\r
213 // EUCLID 9 Euclidian division. q = sign(n) * floor(a / abs(n)).
\r
214 // The remainder is always positive.
\r
216 // The truncated division, floored division, Euclidian division and IEEE 754 remainder
\r
217 // modes are commonly used for the modulus operation.
\r
218 // Although the other rounding modes can also be used, they may not give useful results.
\r
219 MODULO_MODE = 1, // 0 to 9
\r
221 // The maximum number of significant digits of the result of the exponentiatedBy operation.
\r
222 // If POW_PRECISION is 0, there will be unlimited significant digits.
\r
223 POW_PRECISION = 0, // 0 to MAX
\r
225 // The format specification used by the BigNumber.prototype.toFormat method.
\r
229 secondaryGroupSize: 0,
\r
230 groupSeparator: ',',
\r
231 decimalSeparator: '.',
\r
232 fractionGroupSize: 0,
\r
233 fractionGroupSeparator: '\xA0', // non-breaking space
\r
237 // The alphabet used for base conversion. It must be at least 2 characters long, with no '+',
\r
238 // '-', '.', whitespace, or repeated character.
\r
239 // '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_'
\r
240 ALPHABET = '0123456789abcdefghijklmnopqrstuvwxyz';
\r
243 //------------------------------------------------------------------------------------------
\r
250 * The BigNumber constructor and exported function.
\r
251 * Create and return a new instance of a BigNumber object.
\r
253 * v {number|string|BigNumber} A numeric value.
\r
254 * [b] {number} The base of v. Integer, 2 to ALPHABET.length inclusive.
\r
256 function BigNumber(v, b) {
\r
257 var alphabet, c, caseChanged, e, i, isNum, len, str,
\r
260 // Enable constructor call without `new`.
\r
261 if (!(x instanceof BigNumber)) return new BigNumber(v, b);
\r
265 if (v && v._isBigNumber === true) {
\r
268 if (!v.c || v.e > MAX_EXP) {
\r
270 } else if (v.e < MIN_EXP) {
\r
280 if ((isNum = typeof v == 'number') && v * 0 == 0) {
\r
282 // Use `1 / n` to handle minus zero also.
\r
283 x.s = 1 / v < 0 ? (v = -v, -1) : 1;
\r
285 // Fast path for integers, where n < 2147483648 (2**31).
\r
287 for (e = 0, i = v; i >= 10; i /= 10, e++);
\r
302 if (!isNumeric.test(str = String(v))) return parseNumeric(x, str, isNum);
\r
304 x.s = str.charCodeAt(0) == 45 ? (str = str.slice(1), -1) : 1;
\r
308 if ((e = str.indexOf('.')) > -1) str = str.replace('.', '');
\r
310 // Exponential form?
\r
311 if ((i = str.search(/e/i)) > 0) {
\r
313 // Determine exponent.
\r
315 e += +str.slice(i + 1);
\r
316 str = str.substring(0, i);
\r
317 } else if (e < 0) {
\r
325 // '[BigNumber Error] Base {not a primitive number|not an integer|out of range}: {b}'
\r
326 intCheck(b, 2, ALPHABET.length, 'Base');
\r
328 // Allow exponential notation to be used with base 10 argument, while
\r
329 // also rounding to DECIMAL_PLACES as with other bases.
\r
331 x = new BigNumber(v);
\r
332 return round(x, DECIMAL_PLACES + x.e + 1, ROUNDING_MODE);
\r
337 if (isNum = typeof v == 'number') {
\r
339 // Avoid potential interpretation of Infinity and NaN as base 44+ values.
\r
340 if (v * 0 != 0) return parseNumeric(x, str, isNum, b);
\r
342 x.s = 1 / v < 0 ? (str = str.slice(1), -1) : 1;
\r
344 // '[BigNumber Error] Number primitive has more than 15 significant digits: {n}'
\r
345 if (BigNumber.DEBUG && str.replace(/^0\.0*|\./, '').length > 15) {
\r
347 (tooManyDigits + v);
\r
350 x.s = str.charCodeAt(0) === 45 ? (str = str.slice(1), -1) : 1;
\r
353 alphabet = ALPHABET.slice(0, b);
\r
356 // Check that str is a valid base b number.
\r
357 // Don't use RegExp, so alphabet can contain special characters.
\r
358 for (len = str.length; i < len; i++) {
\r
359 if (alphabet.indexOf(c = str.charAt(i)) < 0) {
\r
362 // If '.' is not the first character and it has not be found before.
\r
367 } else if (!caseChanged) {
\r
369 // Allow e.g. hexadecimal 'FF' as well as 'ff'.
\r
370 if (str == str.toUpperCase() && (str = str.toLowerCase()) ||
\r
371 str == str.toLowerCase() && (str = str.toUpperCase())) {
\r
372 caseChanged = true;
\r
379 return parseNumeric(x, String(v), isNum, b);
\r
383 // Prevent later check for length on converted number.
\r
385 str = convertBase(str, b, 10, x.s);
\r
388 if ((e = str.indexOf('.')) > -1) str = str.replace('.', '');
\r
389 else e = str.length;
\r
392 // Determine leading zeros.
\r
393 for (i = 0; str.charCodeAt(i) === 48; i++);
\r
395 // Determine trailing zeros.
\r
396 for (len = str.length; str.charCodeAt(--len) === 48;);
\r
398 if (str = str.slice(i, ++len)) {
\r
401 // '[BigNumber Error] Number primitive has more than 15 significant digits: {n}'
\r
402 if (isNum && BigNumber.DEBUG &&
\r
403 len > 15 && (v > MAX_SAFE_INTEGER || v !== mathfloor(v))) {
\r
405 (tooManyDigits + (x.s * v));
\r
409 if ((e = e - i - 1) > MAX_EXP) {
\r
415 } else if (e < MIN_EXP) {
\r
425 // e is the base 10 exponent.
\r
426 // i is where to slice str to get the first element of the coefficient array.
\r
427 i = (e + 1) % LOG_BASE;
\r
428 if (e < 0) i += LOG_BASE; // i < 1
\r
431 if (i) x.c.push(+str.slice(0, i));
\r
433 for (len -= LOG_BASE; i < len;) {
\r
434 x.c.push(+str.slice(i, i += LOG_BASE));
\r
437 i = LOG_BASE - (str = str.slice(i)).length;
\r
442 for (; i--; str += '0');
\r
453 // CONSTRUCTOR PROPERTIES
\r
456 BigNumber.clone = clone;
\r
458 BigNumber.ROUND_UP = 0;
\r
459 BigNumber.ROUND_DOWN = 1;
\r
460 BigNumber.ROUND_CEIL = 2;
\r
461 BigNumber.ROUND_FLOOR = 3;
\r
462 BigNumber.ROUND_HALF_UP = 4;
\r
463 BigNumber.ROUND_HALF_DOWN = 5;
\r
464 BigNumber.ROUND_HALF_EVEN = 6;
\r
465 BigNumber.ROUND_HALF_CEIL = 7;
\r
466 BigNumber.ROUND_HALF_FLOOR = 8;
\r
467 BigNumber.EUCLID = 9;
\r
471 * Configure infrequently-changing library-wide settings.
\r
473 * Accept an object with the following optional properties (if the value of a property is
\r
474 * a number, it must be an integer within the inclusive range stated):
\r
476 * DECIMAL_PLACES {number} 0 to MAX
\r
477 * ROUNDING_MODE {number} 0 to 8
\r
478 * EXPONENTIAL_AT {number|number[]} -MAX to MAX or [-MAX to 0, 0 to MAX]
\r
479 * RANGE {number|number[]} -MAX to MAX (not zero) or [-MAX to -1, 1 to MAX]
\r
480 * CRYPTO {boolean} true or false
\r
481 * MODULO_MODE {number} 0 to 9
\r
482 * POW_PRECISION {number} 0 to MAX
\r
483 * ALPHABET {string} A string of two or more unique characters which does
\r
485 * FORMAT {object} An object with some of the following properties:
\r
487 * groupSize {number}
\r
488 * secondaryGroupSize {number}
\r
489 * groupSeparator {string}
\r
490 * decimalSeparator {string}
\r
491 * fractionGroupSize {number}
\r
492 * fractionGroupSeparator {string}
\r
495 * (The values assigned to the above FORMAT object properties are not checked for validity.)
\r
498 * BigNumber.config({ DECIMAL_PLACES : 20, ROUNDING_MODE : 4 })
\r
500 * Ignore properties/parameters set to null or undefined, except for ALPHABET.
\r
502 * Return an object with the properties current values.
\r
504 BigNumber.config = BigNumber.set = function (obj) {
\r
509 if (typeof obj == 'object') {
\r
511 // DECIMAL_PLACES {number} Integer, 0 to MAX inclusive.
\r
512 // '[BigNumber Error] DECIMAL_PLACES {not a primitive number|not an integer|out of range}: {v}'
\r
513 if (obj.hasOwnProperty(p = 'DECIMAL_PLACES')) {
\r
515 intCheck(v, 0, MAX, p);
\r
516 DECIMAL_PLACES = v;
\r
519 // ROUNDING_MODE {number} Integer, 0 to 8 inclusive.
\r
520 // '[BigNumber Error] ROUNDING_MODE {not a primitive number|not an integer|out of range}: {v}'
\r
521 if (obj.hasOwnProperty(p = 'ROUNDING_MODE')) {
\r
523 intCheck(v, 0, 8, p);
\r
527 // EXPONENTIAL_AT {number|number[]}
\r
528 // Integer, -MAX to MAX inclusive or
\r
529 // [integer -MAX to 0 inclusive, 0 to MAX inclusive].
\r
530 // '[BigNumber Error] EXPONENTIAL_AT {not a primitive number|not an integer|out of range}: {v}'
\r
531 if (obj.hasOwnProperty(p = 'EXPONENTIAL_AT')) {
\r
534 intCheck(v[0], -MAX, 0, p);
\r
535 intCheck(v[1], 0, MAX, p);
\r
539 intCheck(v, -MAX, MAX, p);
\r
540 TO_EXP_NEG = -(TO_EXP_POS = v < 0 ? -v : v);
\r
544 // RANGE {number|number[]} Non-zero integer, -MAX to MAX inclusive or
\r
545 // [integer -MAX to -1 inclusive, integer 1 to MAX inclusive].
\r
546 // '[BigNumber Error] RANGE {not a primitive number|not an integer|out of range|cannot be zero}: {v}'
\r
547 if (obj.hasOwnProperty(p = 'RANGE')) {
\r
550 intCheck(v[0], -MAX, -1, p);
\r
551 intCheck(v[1], 1, MAX, p);
\r
555 intCheck(v, -MAX, MAX, p);
\r
557 MIN_EXP = -(MAX_EXP = v < 0 ? -v : v);
\r
560 (bignumberError + p + ' cannot be zero: ' + v);
\r
565 // CRYPTO {boolean} true or false.
\r
566 // '[BigNumber Error] CRYPTO not true or false: {v}'
\r
567 // '[BigNumber Error] crypto unavailable'
\r
568 if (obj.hasOwnProperty(p = 'CRYPTO')) {
\r
572 if (typeof crypto != 'undefined' && crypto &&
\r
573 (crypto.getRandomValues || crypto.randomBytes)) {
\r
578 (bignumberError + 'crypto unavailable');
\r
585 (bignumberError + p + ' not true or false: ' + v);
\r
589 // MODULO_MODE {number} Integer, 0 to 9 inclusive.
\r
590 // '[BigNumber Error] MODULO_MODE {not a primitive number|not an integer|out of range}: {v}'
\r
591 if (obj.hasOwnProperty(p = 'MODULO_MODE')) {
\r
593 intCheck(v, 0, 9, p);
\r
597 // POW_PRECISION {number} Integer, 0 to MAX inclusive.
\r
598 // '[BigNumber Error] POW_PRECISION {not a primitive number|not an integer|out of range}: {v}'
\r
599 if (obj.hasOwnProperty(p = 'POW_PRECISION')) {
\r
601 intCheck(v, 0, MAX, p);
\r
606 // '[BigNumber Error] FORMAT not an object: {v}'
\r
607 if (obj.hasOwnProperty(p = 'FORMAT')) {
\r
609 if (typeof v == 'object') FORMAT = v;
\r
611 (bignumberError + p + ' not an object: ' + v);
\r
614 // ALPHABET {string}
\r
615 // '[BigNumber Error] ALPHABET invalid: {v}'
\r
616 if (obj.hasOwnProperty(p = 'ALPHABET')) {
\r
619 // Disallow if only one character,
\r
620 // or if it contains '+', '-', '.', whitespace, or a repeated character.
\r
621 if (typeof v == 'string' && !/^.$|[+-.\s]|(.).*\1/.test(v)) {
\r
625 (bignumberError + p + ' invalid: ' + v);
\r
631 // '[BigNumber Error] Object expected: {v}'
\r
633 (bignumberError + 'Object expected: ' + obj);
\r
638 DECIMAL_PLACES: DECIMAL_PLACES,
\r
639 ROUNDING_MODE: ROUNDING_MODE,
\r
640 EXPONENTIAL_AT: [TO_EXP_NEG, TO_EXP_POS],
\r
641 RANGE: [MIN_EXP, MAX_EXP],
\r
643 MODULO_MODE: MODULO_MODE,
\r
644 POW_PRECISION: POW_PRECISION,
\r
652 * Return true if v is a BigNumber instance, otherwise return false.
\r
654 * If BigNumber.DEBUG is true, throw if a BigNumber instance is not well-formed.
\r
658 * '[BigNumber Error] Invalid BigNumber: {v}'
\r
660 BigNumber.isBigNumber = function (v) {
\r
661 if (!v || v._isBigNumber !== true) return false;
\r
662 if (!BigNumber.DEBUG) return true;
\r
669 out: if ({}.toString.call(c) == '[object Array]') {
\r
671 if ((s === 1 || s === -1) && e >= -MAX && e <= MAX && e === mathfloor(e)) {
\r
673 // If the first element is zero, the BigNumber value must be zero.
\r
675 if (e === 0 && c.length === 1) return true;
\r
679 // Calculate number of digits that c[0] should have, based on the exponent.
\r
680 i = (e + 1) % LOG_BASE;
\r
681 if (i < 1) i += LOG_BASE;
\r
683 // Calculate number of digits of c[0].
\r
684 //if (Math.ceil(Math.log(c[0] + 1) / Math.LN10) == i) {
\r
685 if (String(c[0]).length == i) {
\r
687 for (i = 0; i < c.length; i++) {
\r
689 if (n < 0 || n >= BASE || n !== mathfloor(n)) break out;
\r
692 // Last element cannot be zero, unless it is the only element.
\r
693 if (n !== 0) return true;
\r
698 } else if (c === null && e === null && (s === null || s === 1 || s === -1)) {
\r
703 (bignumberError + 'Invalid BigNumber: ' + v);
\r
708 * Return a new BigNumber whose value is the maximum of the arguments.
\r
710 * arguments {number|string|BigNumber}
\r
712 BigNumber.maximum = BigNumber.max = function () {
\r
713 return maxOrMin(arguments, P.lt);
\r
718 * Return a new BigNumber whose value is the minimum of the arguments.
\r
720 * arguments {number|string|BigNumber}
\r
722 BigNumber.minimum = BigNumber.min = function () {
\r
723 return maxOrMin(arguments, P.gt);
\r
728 * Return a new BigNumber with a random value equal to or greater than 0 and less than 1,
\r
729 * and with dp, or DECIMAL_PLACES if dp is omitted, decimal places (or less if trailing
\r
730 * zeros are produced).
\r
732 * [dp] {number} Decimal places. Integer, 0 to MAX inclusive.
\r
734 * '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {dp}'
\r
735 * '[BigNumber Error] crypto unavailable'
\r
737 BigNumber.random = (function () {
\r
738 var pow2_53 = 0x20000000000000;
\r
740 // Return a 53 bit integer n, where 0 <= n < 9007199254740992.
\r
741 // Check if Math.random() produces more than 32 bits of randomness.
\r
742 // If it does, assume at least 53 bits are produced, otherwise assume at least 30 bits.
\r
743 // 0x40000000 is 2^30, 0x800000 is 2^23, 0x1fffff is 2^21 - 1.
\r
744 var random53bitInt = (Math.random() * pow2_53) & 0x1fffff
\r
745 ? function () { return mathfloor(Math.random() * pow2_53); }
\r
746 : function () { return ((Math.random() * 0x40000000 | 0) * 0x800000) +
\r
747 (Math.random() * 0x800000 | 0); };
\r
749 return function (dp) {
\r
753 rand = new BigNumber(ONE);
\r
755 if (dp == null) dp = DECIMAL_PLACES;
\r
756 else intCheck(dp, 0, MAX);
\r
758 k = mathceil(dp / LOG_BASE);
\r
762 // Browsers supporting crypto.getRandomValues.
\r
763 if (crypto.getRandomValues) {
\r
765 a = crypto.getRandomValues(new Uint32Array(k *= 2));
\r
770 // ((Math.pow(2, 32) - 1) * Math.pow(2, 21)).toString(2)
\r
771 // 11111 11111111 11111111 11111111 11100000 00000000 00000000
\r
772 // ((Math.pow(2, 32) - 1) >>> 11).toString(2)
\r
773 // 11111 11111111 11111111
\r
774 // 0x20000 is 2^21.
\r
775 v = a[i] * 0x20000 + (a[i + 1] >>> 11);
\r
777 // Rejection sampling:
\r
778 // 0 <= v < 9007199254740992
\r
779 // Probability that v >= 9e15, is
\r
780 // 7199254740992 / 9007199254740992 ~= 0.0008, i.e. 1 in 1251
\r
782 b = crypto.getRandomValues(new Uint32Array(2));
\r
787 // 0 <= v <= 8999999999999999
\r
788 // 0 <= (v % 1e14) <= 99999999999999
\r
795 // Node.js supporting crypto.randomBytes.
\r
796 } else if (crypto.randomBytes) {
\r
799 a = crypto.randomBytes(k *= 7);
\r
803 // 0x1000000000000 is 2^48, 0x10000000000 is 2^40
\r
804 // 0x100000000 is 2^32, 0x1000000 is 2^24
\r
805 // 11111 11111111 11111111 11111111 11111111 11111111 11111111
\r
806 // 0 <= v < 9007199254740992
\r
807 v = ((a[i] & 31) * 0x1000000000000) + (a[i + 1] * 0x10000000000) +
\r
808 (a[i + 2] * 0x100000000) + (a[i + 3] * 0x1000000) +
\r
809 (a[i + 4] << 16) + (a[i + 5] << 8) + a[i + 6];
\r
812 crypto.randomBytes(7).copy(a, i);
\r
815 // 0 <= (v % 1e14) <= 99999999999999
\r
824 (bignumberError + 'crypto unavailable');
\r
828 // Use Math.random.
\r
832 v = random53bitInt();
\r
833 if (v < 9e15) c[i++] = v % 1e14;
\r
840 // Convert trailing digits to zeros according to dp.
\r
842 v = POWS_TEN[LOG_BASE - dp];
\r
843 c[i] = mathfloor(k / v) * v;
\r
846 // Remove trailing elements which are zero.
\r
847 for (; c[i] === 0; c.pop(), i--);
\r
854 // Remove leading elements which are zero and adjust exponent accordingly.
\r
855 for (e = -1 ; c[0] === 0; c.splice(0, 1), e -= LOG_BASE);
\r
857 // Count the digits of the first element of c to determine leading zeros, and...
\r
858 for (i = 1, v = c[0]; v >= 10; v /= 10, i++);
\r
860 // adjust the exponent accordingly.
\r
861 if (i < LOG_BASE) e -= LOG_BASE - i;
\r
872 * Return a BigNumber whose value is the sum of the arguments.
\r
874 * arguments {number|string|BigNumber}
\r
876 BigNumber.sum = function () {
\r
879 sum = new BigNumber(args[0]);
\r
880 for (; i < args.length;) sum = sum.plus(args[i++]);
\r
885 // PRIVATE FUNCTIONS
\r
888 // Called by BigNumber and BigNumber.prototype.toString.
\r
889 convertBase = (function () {
\r
890 var decimal = '0123456789';
\r
893 * Convert string of baseIn to an array of numbers of baseOut.
\r
894 * Eg. toBaseOut('255', 10, 16) returns [15, 15].
\r
895 * Eg. toBaseOut('ff', 16, 10) returns [2, 5, 5].
\r
897 function toBaseOut(str, baseIn, baseOut, alphabet) {
\r
905 for (arrL = arr.length; arrL--; arr[arrL] *= baseIn);
\r
907 arr[0] += alphabet.indexOf(str.charAt(i++));
\r
909 for (j = 0; j < arr.length; j++) {
\r
911 if (arr[j] > baseOut - 1) {
\r
912 if (arr[j + 1] == null) arr[j + 1] = 0;
\r
913 arr[j + 1] += arr[j] / baseOut | 0;
\r
919 return arr.reverse();
\r
922 // Convert a numeric string of baseIn to a numeric string of baseOut.
\r
923 // If the caller is toString, we are converting from base 10 to baseOut.
\r
924 // If the caller is BigNumber, we are converting from baseIn to base 10.
\r
925 return function (str, baseIn, baseOut, sign, callerIsToString) {
\r
926 var alphabet, d, e, k, r, x, xc, y,
\r
927 i = str.indexOf('.'),
\r
928 dp = DECIMAL_PLACES,
\r
929 rm = ROUNDING_MODE;
\r
935 // Unlimited precision.
\r
937 str = str.replace('.', '');
\r
938 y = new BigNumber(baseIn);
\r
939 x = y.pow(str.length - i);
\r
942 // Convert str as if an integer, then restore the fraction part by dividing the
\r
943 // result by its base raised to a power.
\r
945 y.c = toBaseOut(toFixedPoint(coeffToString(x.c), x.e, '0'),
\r
946 10, baseOut, decimal);
\r
950 // Convert the number as integer.
\r
952 xc = toBaseOut(str, baseIn, baseOut, callerIsToString
\r
953 ? (alphabet = ALPHABET, decimal)
\r
954 : (alphabet = decimal, ALPHABET));
\r
956 // xc now represents str as an integer and converted to baseOut. e is the exponent.
\r
959 // Remove trailing zeros.
\r
960 for (; xc[--k] == 0; xc.pop());
\r
963 if (!xc[0]) return alphabet.charAt(0);
\r
965 // Does str represent an integer? If so, no need for the division.
\r
972 // The sign is needed for correct rounding.
\r
974 x = div(x, y, dp, rm, baseOut);
\r
980 // xc now represents str converted to baseOut.
\r
982 // THe index of the rounding digit.
\r
985 // The rounding digit: the digit to the right of the digit that may be rounded up.
\r
988 // Look at the rounding digits and mode to determine whether to round up.
\r
991 r = r || d < 0 || xc[d + 1] != null;
\r
993 r = rm < 4 ? (i != null || r) && (rm == 0 || rm == (x.s < 0 ? 3 : 2))
\r
994 : i > k || i == k &&(rm == 4 || r || rm == 6 && xc[d - 1] & 1 ||
\r
995 rm == (x.s < 0 ? 8 : 7));
\r
997 // If the index of the rounding digit is not greater than zero, or xc represents
\r
998 // zero, then the result of the base conversion is zero or, if rounding up, a value
\r
999 // such as 0.00001.
\r
1000 if (d < 1 || !xc[0]) {
\r
1003 str = r ? toFixedPoint(alphabet.charAt(1), -dp, alphabet.charAt(0)) : alphabet.charAt(0);
\r
1006 // Truncate xc to the required number of decimal places.
\r
1012 // Rounding up may mean the previous digit has to be rounded up and so on.
\r
1013 for (--baseOut; ++xc[--d] > baseOut;) {
\r
1018 xc = [1].concat(xc);
\r
1023 // Determine trailing zeros.
\r
1024 for (k = xc.length; !xc[--k];);
\r
1026 // E.g. [4, 11, 15] becomes 4bf.
\r
1027 for (i = 0, str = ''; i <= k; str += alphabet.charAt(xc[i++]));
\r
1029 // Add leading zeros, decimal point and trailing zeros as required.
\r
1030 str = toFixedPoint(str, e, alphabet.charAt(0));
\r
1033 // The caller will add the sign.
\r
1039 // Perform division in the specified base. Called by div and convertBase.
\r
1040 div = (function () {
\r
1042 // Assume non-zero x and k.
\r
1043 function multiply(x, k, base) {
\r
1044 var m, temp, xlo, xhi,
\r
1047 klo = k % SQRT_BASE,
\r
1048 khi = k / SQRT_BASE | 0;
\r
1050 for (x = x.slice(); i--;) {
\r
1051 xlo = x[i] % SQRT_BASE;
\r
1052 xhi = x[i] / SQRT_BASE | 0;
\r
1053 m = khi * xlo + xhi * klo;
\r
1054 temp = klo * xlo + ((m % SQRT_BASE) * SQRT_BASE) + carry;
\r
1055 carry = (temp / base | 0) + (m / SQRT_BASE | 0) + khi * xhi;
\r
1056 x[i] = temp % base;
\r
1059 if (carry) x = [carry].concat(x);
\r
1064 function compare(a, b, aL, bL) {
\r
1068 cmp = aL > bL ? 1 : -1;
\r
1071 for (i = cmp = 0; i < aL; i++) {
\r
1073 if (a[i] != b[i]) {
\r
1074 cmp = a[i] > b[i] ? 1 : -1;
\r
1083 function subtract(a, b, aL, base) {
\r
1086 // Subtract b from a.
\r
1089 i = a[aL] < b[aL] ? 1 : 0;
\r
1090 a[aL] = i * base + a[aL] - b[aL];
\r
1093 // Remove leading zeros.
\r
1094 for (; !a[0] && a.length > 1; a.splice(0, 1));
\r
1097 // x: dividend, y: divisor.
\r
1098 return function (x, y, dp, rm, base) {
\r
1099 var cmp, e, i, more, n, prod, prodL, q, qc, rem, remL, rem0, xi, xL, yc0,
\r
1101 s = x.s == y.s ? 1 : -1,
\r
1105 // Either NaN, Infinity or 0?
\r
1106 if (!xc || !xc[0] || !yc || !yc[0]) {
\r
1108 return new BigNumber(
\r
1110 // Return NaN if either NaN, or both Infinity or 0.
\r
1111 !x.s || !y.s || (xc ? yc && xc[0] == yc[0] : !yc) ? NaN :
\r
1113 // Return ±0 if x is ±0 or y is ±Infinity, or return ±Infinity as y is ±0.
\r
1114 xc && xc[0] == 0 || !yc ? s * 0 : s / 0
\r
1118 q = new BigNumber(s);
\r
1125 e = bitFloor(x.e / LOG_BASE) - bitFloor(y.e / LOG_BASE);
\r
1126 s = s / LOG_BASE | 0;
\r
1129 // Result exponent may be one less then the current value of e.
\r
1130 // The coefficients of the BigNumbers from convertBase may have trailing zeros.
\r
1131 for (i = 0; yc[i] == (xc[i] || 0); i++);
\r
1133 if (yc[i] > (xc[i] || 0)) e--;
\r
1144 // Normalise xc and yc so highest order digit of yc is >= base / 2.
\r
1146 n = mathfloor(base / (yc[0] + 1));
\r
1148 // Not necessary, but to handle odd bases where yc[0] == (base / 2) - 1.
\r
1149 // if (n > 1 || n++ == 1 && yc[0] < base / 2) {
\r
1151 yc = multiply(yc, n, base);
\r
1152 xc = multiply(xc, n, base);
\r
1158 rem = xc.slice(0, yL);
\r
1159 remL = rem.length;
\r
1161 // Add zeros to make remainder as long as divisor.
\r
1162 for (; remL < yL; rem[remL++] = 0);
\r
1164 yz = [0].concat(yz);
\r
1166 if (yc[1] >= base / 2) yc0++;
\r
1167 // Not necessary, but to prevent trial digit n > base, when using base 3.
\r
1168 // else if (base == 3 && yc0 == 1) yc0 = 1 + 1e-15;
\r
1173 // Compare divisor and remainder.
\r
1174 cmp = compare(yc, rem, yL, remL);
\r
1176 // If divisor < remainder.
\r
1179 // Calculate trial digit, n.
\r
1182 if (yL != remL) rem0 = rem0 * base + (rem[1] || 0);
\r
1184 // n is how many times the divisor goes into the current remainder.
\r
1185 n = mathfloor(rem0 / yc0);
\r
1188 // product = divisor multiplied by trial digit (n).
\r
1189 // Compare product and remainder.
\r
1190 // If product is greater than remainder:
\r
1191 // Subtract divisor from product, decrement trial digit.
\r
1192 // Subtract product from remainder.
\r
1193 // If product was less than remainder at the last compare:
\r
1194 // Compare new remainder and divisor.
\r
1195 // If remainder is greater than divisor:
\r
1196 // Subtract divisor from remainder, increment trial digit.
\r
1200 // n may be > base only when base is 3.
\r
1201 if (n >= base) n = base - 1;
\r
1203 // product = divisor * trial digit.
\r
1204 prod = multiply(yc, n, base);
\r
1205 prodL = prod.length;
\r
1206 remL = rem.length;
\r
1208 // Compare product and remainder.
\r
1209 // If product > remainder then trial digit n too high.
\r
1210 // n is 1 too high about 5% of the time, and is not known to have
\r
1211 // ever been more than 1 too high.
\r
1212 while (compare(prod, rem, prodL, remL) == 1) {
\r
1215 // Subtract divisor from product.
\r
1216 subtract(prod, yL < prodL ? yz : yc, prodL, base);
\r
1217 prodL = prod.length;
\r
1222 // n is 0 or 1, cmp is -1.
\r
1223 // If n is 0, there is no need to compare yc and rem again below,
\r
1224 // so change cmp to 1 to avoid it.
\r
1225 // If n is 1, leave cmp as -1, so yc and rem are compared again.
\r
1228 // divisor < remainder, so n must be at least 1.
\r
1232 // product = divisor
\r
1233 prod = yc.slice();
\r
1234 prodL = prod.length;
\r
1237 if (prodL < remL) prod = [0].concat(prod);
\r
1239 // Subtract product from remainder.
\r
1240 subtract(rem, prod, remL, base);
\r
1241 remL = rem.length;
\r
1243 // If product was < remainder.
\r
1246 // Compare divisor and new remainder.
\r
1247 // If divisor < new remainder, subtract divisor from remainder.
\r
1248 // Trial digit n too low.
\r
1249 // n is 1 too low about 5% of the time, and very rarely 2 too low.
\r
1250 while (compare(yc, rem, yL, remL) < 1) {
\r
1253 // Subtract divisor from remainder.
\r
1254 subtract(rem, yL < remL ? yz : yc, remL, base);
\r
1255 remL = rem.length;
\r
1258 } else if (cmp === 0) {
\r
1261 } // else cmp === 1 and n will be 0
\r
1263 // Add the next digit, n, to the result array.
\r
1266 // Update the remainder.
\r
1268 rem[remL++] = xc[xi] || 0;
\r
1273 } while ((xi++ < xL || rem[0] != null) && s--);
\r
1275 more = rem[0] != null;
\r
1278 if (!qc[0]) qc.splice(0, 1);
\r
1281 if (base == BASE) {
\r
1283 // To calculate q.e, first get the number of digits of qc[0].
\r
1284 for (i = 1, s = qc[0]; s >= 10; s /= 10, i++);
\r
1286 round(q, dp + (q.e = i + e * LOG_BASE - 1) + 1, rm, more);
\r
1288 // Caller is convertBase.
\r
1300 * Return a string representing the value of BigNumber n in fixed-point or exponential
\r
1301 * notation rounded to the specified decimal places or significant digits.
\r
1304 * i: the index of the last digit required (i.e. the digit that may be rounded up).
\r
1305 * rm: the rounding mode.
\r
1306 * id: 1 (toExponential) or 2 (toPrecision).
\r
1308 function format(n, i, rm, id) {
\r
1309 var c0, e, ne, len, str;
\r
1311 if (rm == null) rm = ROUNDING_MODE;
\r
1312 else intCheck(rm, 0, 8);
\r
1314 if (!n.c) return n.toString();
\r
1320 str = coeffToString(n.c);
\r
1321 str = id == 1 || id == 2 && (ne <= TO_EXP_NEG || ne >= TO_EXP_POS)
\r
1322 ? toExponential(str, ne)
\r
1323 : toFixedPoint(str, ne, '0');
\r
1325 n = round(new BigNumber(n), i, rm);
\r
1327 // n.e may have changed if the value was rounded up.
\r
1330 str = coeffToString(n.c);
\r
1333 // toPrecision returns exponential notation if the number of significant digits
\r
1334 // specified is less than the number of digits necessary to represent the integer
\r
1335 // part of the value in fixed-point notation.
\r
1337 // Exponential notation.
\r
1338 if (id == 1 || id == 2 && (i <= e || e <= TO_EXP_NEG)) {
\r
1341 for (; len < i; str += '0', len++);
\r
1342 str = toExponential(str, e);
\r
1344 // Fixed-point notation.
\r
1347 str = toFixedPoint(str, e, '0');
\r
1350 if (e + 1 > len) {
\r
1351 if (--i > 0) for (str += '.'; i--; str += '0');
\r
1355 if (e + 1 == len) str += '.';
\r
1356 for (; i--; str += '0');
\r
1362 return n.s < 0 && c0 ? '-' + str : str;
\r
1366 // Handle BigNumber.max and BigNumber.min.
\r
1367 function maxOrMin(args, method) {
\r
1370 m = new BigNumber(args[0]);
\r
1372 for (; i < args.length; i++) {
\r
1373 n = new BigNumber(args[i]);
\r
1375 // If any number is NaN, return NaN.
\r
1379 } else if (method.call(m, n)) {
\r
1389 * Strip trailing zeros, calculate base 10 exponent and check against MIN_EXP and MAX_EXP.
\r
1390 * Called by minus, plus and times.
\r
1392 function normalise(n, c, e) {
\r
1396 // Remove trailing zeros.
\r
1397 for (; !c[--j]; c.pop());
\r
1399 // Calculate the base 10 exponent. First get the number of digits of c[0].
\r
1400 for (j = c[0]; j >= 10; j /= 10, i++);
\r
1403 if ((e = i + e * LOG_BASE - 1) > MAX_EXP) {
\r
1409 } else if (e < MIN_EXP) {
\r
1422 // Handle values that fail the validity test in BigNumber.
\r
1423 parseNumeric = (function () {
\r
1424 var basePrefix = /^(-?)0([xbo])(?=\w[\w.]*$)/i,
\r
1425 dotAfter = /^([^.]+)\.$/,
\r
1426 dotBefore = /^\.([^.]+)$/,
\r
1427 isInfinityOrNaN = /^-?(Infinity|NaN)$/,
\r
1428 whitespaceOrPlus = /^\s*\+(?=[\w.])|^\s+|\s+$/g;
\r
1430 return function (x, str, isNum, b) {
\r
1432 s = isNum ? str : str.replace(whitespaceOrPlus, '');
\r
1434 // No exception on ±Infinity or NaN.
\r
1435 if (isInfinityOrNaN.test(s)) {
\r
1436 x.s = isNaN(s) ? null : s < 0 ? -1 : 1;
\r
1440 // basePrefix = /^(-?)0([xbo])(?=\w[\w.]*$)/i
\r
1441 s = s.replace(basePrefix, function (m, p1, p2) {
\r
1442 base = (p2 = p2.toLowerCase()) == 'x' ? 16 : p2 == 'b' ? 2 : 8;
\r
1443 return !b || b == base ? p1 : m;
\r
1449 // E.g. '1.' to '1', '.1' to '0.1'
\r
1450 s = s.replace(dotAfter, '$1').replace(dotBefore, '0.$1');
\r
1453 if (str != s) return new BigNumber(s, base);
\r
1456 // '[BigNumber Error] Not a number: {n}'
\r
1457 // '[BigNumber Error] Not a base {b} number: {n}'
\r
1458 if (BigNumber.DEBUG) {
\r
1460 (bignumberError + 'Not a' + (b ? ' base ' + b : '') + ' number: ' + str);
\r
1473 * Round x to sd significant digits using rounding mode rm. Check for over/under-flow.
\r
1474 * If r is truthy, it is known that there are more digits after the rounding digit.
\r
1476 function round(x, sd, rm, r) {
\r
1477 var d, i, j, k, n, ni, rd,
\r
1479 pows10 = POWS_TEN;
\r
1481 // if x is not Infinity or NaN...
\r
1484 // rd is the rounding digit, i.e. the digit after the digit that may be rounded up.
\r
1485 // n is a base 1e14 number, the value of the element of array x.c containing rd.
\r
1486 // ni is the index of n within x.c.
\r
1487 // d is the number of digits of n.
\r
1488 // i is the index of rd within n including leading zeros.
\r
1489 // j is the actual index of rd within n (if < 0, rd is a leading zero).
\r
1492 // Get the number of digits of the first element of xc.
\r
1493 for (d = 1, k = xc[0]; k >= 10; k /= 10, d++);
\r
1496 // If the rounding digit is in the first element of xc...
\r
1502 // Get the rounding digit at index j of n.
\r
1503 rd = n / pows10[d - j - 1] % 10 | 0;
\r
1505 ni = mathceil((i + 1) / LOG_BASE);
\r
1507 if (ni >= xc.length) {
\r
1511 // Needed by sqrt.
\r
1512 for (; xc.length <= ni; xc.push(0));
\r
1516 j = i - LOG_BASE + 1;
\r
1523 // Get the number of digits of n.
\r
1524 for (d = 1; k >= 10; k /= 10, d++);
\r
1526 // Get the index of rd within n.
\r
1529 // Get the index of rd within n, adjusted for leading zeros.
\r
1530 // The number of leading zeros of n is given by LOG_BASE - d.
\r
1531 j = i - LOG_BASE + d;
\r
1533 // Get the rounding digit at index j of n.
\r
1534 rd = j < 0 ? 0 : n / pows10[d - j - 1] % 10 | 0;
\r
1538 r = r || sd < 0 ||
\r
1540 // Are there any non-zero digits after the rounding digit?
\r
1541 // The expression n % pows10[d - j - 1] returns all digits of n to the right
\r
1542 // of the digit at j, e.g. if n is 908714 and j is 2, the expression gives 714.
\r
1543 xc[ni + 1] != null || (j < 0 ? n : n % pows10[d - j - 1]);
\r
1546 ? (rd || r) && (rm == 0 || rm == (x.s < 0 ? 3 : 2))
\r
1547 : rd > 5 || rd == 5 && (rm == 4 || r || rm == 6 &&
\r
1549 // Check whether the digit to the left of the rounding digit is odd.
\r
1550 ((i > 0 ? j > 0 ? n / pows10[d - j] : 0 : xc[ni - 1]) % 10) & 1 ||
\r
1551 rm == (x.s < 0 ? 8 : 7));
\r
1553 if (sd < 1 || !xc[0]) {
\r
1558 // Convert sd to decimal places.
\r
1561 // 1, 0.1, 0.01, 0.001, 0.0001 etc.
\r
1562 xc[0] = pows10[(LOG_BASE - sd % LOG_BASE) % LOG_BASE];
\r
1573 // Remove excess digits.
\r
1579 xc.length = ni + 1;
\r
1580 k = pows10[LOG_BASE - i];
\r
1582 // E.g. 56700 becomes 56000 if 7 is the rounding digit.
\r
1583 // j > 0 means i > number of leading zeros of n.
\r
1584 xc[ni] = j > 0 ? mathfloor(n / pows10[d - j] % pows10[j]) * k : 0;
\r
1592 // If the digit to be rounded up is in the first element of xc...
\r
1595 // i will be the length of xc[0] before k is added.
\r
1596 for (i = 1, j = xc[0]; j >= 10; j /= 10, i++);
\r
1598 for (k = 1; j >= 10; j /= 10, k++);
\r
1600 // if i != k the length has increased.
\r
1603 if (xc[0] == BASE) xc[0] = 1;
\r
1609 if (xc[ni] != BASE) break;
\r
1616 // Remove trailing zeros.
\r
1617 for (i = xc.length; xc[--i] === 0; xc.pop());
\r
1620 // Overflow? Infinity.
\r
1621 if (x.e > MAX_EXP) {
\r
1624 // Underflow? Zero.
\r
1625 } else if (x.e < MIN_EXP) {
\r
1634 function valueOf(n) {
\r
1638 if (e === null) return n.toString();
\r
1640 str = coeffToString(n.c);
\r
1642 str = e <= TO_EXP_NEG || e >= TO_EXP_POS
\r
1643 ? toExponential(str, e)
\r
1644 : toFixedPoint(str, e, '0');
\r
1646 return n.s < 0 ? '-' + str : str;
\r
1650 // PROTOTYPE/INSTANCE METHODS
\r
1654 * Return a new BigNumber whose value is the absolute value of this BigNumber.
\r
1656 P.absoluteValue = P.abs = function () {
\r
1657 var x = new BigNumber(this);
\r
1658 if (x.s < 0) x.s = 1;
\r
1665 * 1 if the value of this BigNumber is greater than the value of BigNumber(y, b),
\r
1666 * -1 if the value of this BigNumber is less than the value of BigNumber(y, b),
\r
1667 * 0 if they have the same value,
\r
1668 * or null if the value of either is NaN.
\r
1670 P.comparedTo = function (y, b) {
\r
1671 return compare(this, new BigNumber(y, b));
\r
1676 * If dp is undefined or null or true or false, return the number of decimal places of the
\r
1677 * value of this BigNumber, or null if the value of this BigNumber is ±Infinity or NaN.
\r
1679 * Otherwise, if dp is a number, return a new BigNumber whose value is the value of this
\r
1680 * BigNumber rounded to a maximum of dp decimal places using rounding mode rm, or
\r
1681 * ROUNDING_MODE if rm is omitted.
\r
1683 * [dp] {number} Decimal places: integer, 0 to MAX inclusive.
\r
1684 * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
\r
1686 * '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {dp|rm}'
\r
1688 P.decimalPlaces = P.dp = function (dp, rm) {
\r
1693 intCheck(dp, 0, MAX);
\r
1694 if (rm == null) rm = ROUNDING_MODE;
\r
1695 else intCheck(rm, 0, 8);
\r
1697 return round(new BigNumber(x), dp + x.e + 1, rm);
\r
1700 if (!(c = x.c)) return null;
\r
1701 n = ((v = c.length - 1) - bitFloor(this.e / LOG_BASE)) * LOG_BASE;
\r
1703 // Subtract the number of trailing zeros of the last number.
\r
1704 if (v = c[v]) for (; v % 10 == 0; v /= 10, n--);
\r
1728 * Return a new BigNumber whose value is the value of this BigNumber divided by the value of
\r
1729 * BigNumber(y, b), rounded according to DECIMAL_PLACES and ROUNDING_MODE.
\r
1731 P.dividedBy = P.div = function (y, b) {
\r
1732 return div(this, new BigNumber(y, b), DECIMAL_PLACES, ROUNDING_MODE);
\r
1737 * Return a new BigNumber whose value is the integer part of dividing the value of this
\r
1738 * BigNumber by the value of BigNumber(y, b).
\r
1740 P.dividedToIntegerBy = P.idiv = function (y, b) {
\r
1741 return div(this, new BigNumber(y, b), 0, 1);
\r
1746 * Return a BigNumber whose value is the value of this BigNumber exponentiated by n.
\r
1748 * If m is present, return the result modulo m.
\r
1749 * If n is negative round according to DECIMAL_PLACES and ROUNDING_MODE.
\r
1750 * If POW_PRECISION is non-zero and m is not present, round to POW_PRECISION using ROUNDING_MODE.
\r
1752 * The modular power operation works efficiently when x, n, and m are integers, otherwise it
\r
1753 * is equivalent to calculating x.exponentiatedBy(n).modulo(m) with a POW_PRECISION of 0.
\r
1755 * n {number|string|BigNumber} The exponent. An integer.
\r
1756 * [m] {number|string|BigNumber} The modulus.
\r
1758 * '[BigNumber Error] Exponent not an integer: {n}'
\r
1760 P.exponentiatedBy = P.pow = function (n, m) {
\r
1761 var half, isModExp, i, k, more, nIsBig, nIsNeg, nIsOdd, y,
\r
1764 n = new BigNumber(n);
\r
1766 // Allow NaN and ±Infinity, but not other non-integers.
\r
1767 if (n.c && !n.isInteger()) {
\r
1769 (bignumberError + 'Exponent not an integer: ' + valueOf(n));
\r
1772 if (m != null) m = new BigNumber(m);
\r
1774 // Exponent of MAX_SAFE_INTEGER is 15.
\r
1775 nIsBig = n.e > 14;
\r
1777 // If x is NaN, ±Infinity, ±0 or ±1, or n is ±Infinity, NaN or ±0.
\r
1778 if (!x.c || !x.c[0] || x.c[0] == 1 && !x.e && x.c.length == 1 || !n.c || !n.c[0]) {
\r
1780 // The sign of the result of pow when x is negative depends on the evenness of n.
\r
1781 // If +n overflows to ±Infinity, the evenness of n would be not be known.
\r
1782 y = new BigNumber(Math.pow(+valueOf(x), nIsBig ? 2 - isOdd(n) : +valueOf(n)));
\r
1783 return m ? y.mod(m) : y;
\r
1790 // x % m returns NaN if abs(m) is zero, or m is NaN.
\r
1791 if (m.c ? !m.c[0] : !m.s) return new BigNumber(NaN);
\r
1793 isModExp = !nIsNeg && x.isInteger() && m.isInteger();
\r
1795 if (isModExp) x = x.mod(m);
\r
1797 // Overflow to ±Infinity: >=2**1e10 or >=1.0000024**1e15.
\r
1798 // Underflow to ±0: <=0.79**1e10 or <=0.9999975**1e15.
\r
1799 } else if (n.e > 9 && (x.e > 0 || x.e < -1 || (x.e == 0
\r
1801 ? x.c[0] > 1 || nIsBig && x.c[1] >= 24e7
\r
1802 // [80000000000000] [99999750000000]
\r
1803 : x.c[0] < 8e13 || nIsBig && x.c[0] <= 9999975e7))) {
\r
1805 // If x is negative and n is odd, k = -0, else k = 0.
\r
1806 k = x.s < 0 && isOdd(n) ? -0 : 0;
\r
1808 // If x >= 1, k = ±Infinity.
\r
1809 if (x.e > -1) k = 1 / k;
\r
1811 // If n is negative return ±0, else return ±Infinity.
\r
1812 return new BigNumber(nIsNeg ? 1 / k : k);
\r
1814 } else if (POW_PRECISION) {
\r
1816 // Truncating each coefficient array to a length of k after each multiplication
\r
1817 // equates to truncating significant digits to POW_PRECISION + [28, 41],
\r
1818 // i.e. there will be a minimum of 28 guard digits retained.
\r
1819 k = mathceil(POW_PRECISION / LOG_BASE + 2);
\r
1823 half = new BigNumber(0.5);
\r
1824 if (nIsNeg) n.s = 1;
\r
1825 nIsOdd = isOdd(n);
\r
1827 i = Math.abs(+valueOf(n));
\r
1831 y = new BigNumber(ONE);
\r
1833 // Performs 54 loop iterations for n of 9007199254740991.
\r
1841 if (y.c.length > k) y.c.length = k;
\r
1842 } else if (isModExp) {
\r
1843 y = y.mod(m); //y = y.minus(div(y, m, 0, MODULO_MODE).times(m));
\r
1848 i = mathfloor(i / 2);
\r
1849 if (i === 0) break;
\r
1852 n = n.times(half);
\r
1853 round(n, n.e + 1, 1);
\r
1856 nIsOdd = isOdd(n);
\r
1859 if (i === 0) break;
\r
1867 if (x.c && x.c.length > k) x.c.length = k;
\r
1868 } else if (isModExp) {
\r
1869 x = x.mod(m); //x = x.minus(div(x, m, 0, MODULO_MODE).times(m));
\r
1873 if (isModExp) return y;
\r
1874 if (nIsNeg) y = ONE.div(y);
\r
1876 return m ? y.mod(m) : k ? round(y, POW_PRECISION, ROUNDING_MODE, more) : y;
\r
1881 * Return a new BigNumber whose value is the value of this BigNumber rounded to an integer
\r
1882 * using rounding mode rm, or ROUNDING_MODE if rm is omitted.
\r
1884 * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
\r
1886 * '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {rm}'
\r
1888 P.integerValue = function (rm) {
\r
1889 var n = new BigNumber(this);
\r
1890 if (rm == null) rm = ROUNDING_MODE;
\r
1891 else intCheck(rm, 0, 8);
\r
1892 return round(n, n.e + 1, rm);
\r
1897 * Return true if the value of this BigNumber is equal to the value of BigNumber(y, b),
\r
1898 * otherwise return false.
\r
1900 P.isEqualTo = P.eq = function (y, b) {
\r
1901 return compare(this, new BigNumber(y, b)) === 0;
\r
1906 * Return true if the value of this BigNumber is a finite number, otherwise return false.
\r
1908 P.isFinite = function () {
\r
1914 * Return true if the value of this BigNumber is greater than the value of BigNumber(y, b),
\r
1915 * otherwise return false.
\r
1917 P.isGreaterThan = P.gt = function (y, b) {
\r
1918 return compare(this, new BigNumber(y, b)) > 0;
\r
1923 * Return true if the value of this BigNumber is greater than or equal to the value of
\r
1924 * BigNumber(y, b), otherwise return false.
\r
1926 P.isGreaterThanOrEqualTo = P.gte = function (y, b) {
\r
1927 return (b = compare(this, new BigNumber(y, b))) === 1 || b === 0;
\r
1933 * Return true if the value of this BigNumber is an integer, otherwise return false.
\r
1935 P.isInteger = function () {
\r
1936 return !!this.c && bitFloor(this.e / LOG_BASE) > this.c.length - 2;
\r
1941 * Return true if the value of this BigNumber is less than the value of BigNumber(y, b),
\r
1942 * otherwise return false.
\r
1944 P.isLessThan = P.lt = function (y, b) {
\r
1945 return compare(this, new BigNumber(y, b)) < 0;
\r
1950 * Return true if the value of this BigNumber is less than or equal to the value of
\r
1951 * BigNumber(y, b), otherwise return false.
\r
1953 P.isLessThanOrEqualTo = P.lte = function (y, b) {
\r
1954 return (b = compare(this, new BigNumber(y, b))) === -1 || b === 0;
\r
1959 * Return true if the value of this BigNumber is NaN, otherwise return false.
\r
1961 P.isNaN = function () {
\r
1967 * Return true if the value of this BigNumber is negative, otherwise return false.
\r
1969 P.isNegative = function () {
\r
1970 return this.s < 0;
\r
1975 * Return true if the value of this BigNumber is positive, otherwise return false.
\r
1977 P.isPositive = function () {
\r
1978 return this.s > 0;
\r
1983 * Return true if the value of this BigNumber is 0 or -0, otherwise return false.
\r
1985 P.isZero = function () {
\r
1986 return !!this.c && this.c[0] == 0;
\r
2007 * Return a new BigNumber whose value is the value of this BigNumber minus the value of
\r
2008 * BigNumber(y, b).
\r
2010 P.minus = function (y, b) {
\r
2011 var i, j, t, xLTy,
\r
2015 y = new BigNumber(y, b);
\r
2019 if (!a || !b) return new BigNumber(NaN);
\r
2027 var xe = x.e / LOG_BASE,
\r
2028 ye = y.e / LOG_BASE,
\r
2034 // Either Infinity?
\r
2035 if (!xc || !yc) return xc ? (y.s = -b, y) : new BigNumber(yc ? x : NaN);
\r
2038 if (!xc[0] || !yc[0]) {
\r
2040 // Return y if y is non-zero, x if x is non-zero, or zero if both are zero.
\r
2041 return yc[0] ? (y.s = -b, y) : new BigNumber(xc[0] ? x :
\r
2043 // IEEE 754 (2008) 6.3: n - n = -0 when rounding to -Infinity
\r
2044 ROUNDING_MODE == 3 ? -0 : 0);
\r
2048 xe = bitFloor(xe);
\r
2049 ye = bitFloor(ye);
\r
2052 // Determine which is the bigger number.
\r
2053 if (a = xe - ye) {
\r
2055 if (xLTy = a < 0) {
\r
2065 // Prepend zeros to equalise exponents.
\r
2066 for (b = a; b--; t.push(0));
\r
2070 // Exponents equal. Check digit by digit.
\r
2071 j = (xLTy = (a = xc.length) < (b = yc.length)) ? a : b;
\r
2073 for (a = b = 0; b < j; b++) {
\r
2075 if (xc[b] != yc[b]) {
\r
2076 xLTy = xc[b] < yc[b];
\r
2082 // x < y? Point xc to the array of the bigger number.
\r
2083 if (xLTy) t = xc, xc = yc, yc = t, y.s = -y.s;
\r
2085 b = (j = yc.length) - (i = xc.length);
\r
2087 // Append zeros to xc if shorter.
\r
2088 // No need to add zeros to yc if shorter as subtract only needs to start at yc.length.
\r
2089 if (b > 0) for (; b--; xc[i++] = 0);
\r
2092 // Subtract yc from xc.
\r
2095 if (xc[--j] < yc[j]) {
\r
2096 for (i = j; i && !xc[--i]; xc[i] = b);
\r
2104 // Remove leading zeros and adjust exponent accordingly.
\r
2105 for (; xc[0] == 0; xc.splice(0, 1), --ye);
\r
2110 // Following IEEE 754 (2008) 6.3,
\r
2111 // n - n = +0 but n - n = -0 when rounding towards -Infinity.
\r
2112 y.s = ROUNDING_MODE == 3 ? -1 : 1;
\r
2117 // No need to check for Infinity as +x - +y != Infinity && -x - -y != Infinity
\r
2118 // for finite x and y.
\r
2119 return normalise(y, xc, ye);
\r
2141 * Return a new BigNumber whose value is the value of this BigNumber modulo the value of
\r
2142 * BigNumber(y, b). The result depends on the value of MODULO_MODE.
\r
2144 P.modulo = P.mod = function (y, b) {
\r
2148 y = new BigNumber(y, b);
\r
2150 // Return NaN if x is Infinity or NaN, or y is NaN or zero.
\r
2151 if (!x.c || !y.s || y.c && !y.c[0]) {
\r
2152 return new BigNumber(NaN);
\r
2154 // Return x if y is Infinity or x is zero.
\r
2155 } else if (!y.c || x.c && !x.c[0]) {
\r
2156 return new BigNumber(x);
\r
2159 if (MODULO_MODE == 9) {
\r
2161 // Euclidian division: q = sign(y) * floor(x / abs(y))
\r
2162 // r = x - qy where 0 <= r < abs(y)
\r
2165 q = div(x, y, 0, 3);
\r
2169 q = div(x, y, 0, MODULO_MODE);
\r
2172 y = x.minus(q.times(y));
\r
2174 // To match JavaScript %, ensure sign of zero is sign of dividend.
\r
2175 if (!y.c[0] && MODULO_MODE == 1) y.s = x.s;
\r
2198 * Return a new BigNumber whose value is the value of this BigNumber multiplied by the value
\r
2199 * of BigNumber(y, b).
\r
2201 P.multipliedBy = P.times = function (y, b) {
\r
2202 var c, e, i, j, k, m, xcL, xlo, xhi, ycL, ylo, yhi, zc,
\r
2206 yc = (y = new BigNumber(y, b)).c;
\r
2208 // Either NaN, ±Infinity or ±0?
\r
2209 if (!xc || !yc || !xc[0] || !yc[0]) {
\r
2211 // Return NaN if either is NaN, or one is 0 and the other is Infinity.
\r
2212 if (!x.s || !y.s || xc && !xc[0] && !yc || yc && !yc[0] && !xc) {
\r
2213 y.c = y.e = y.s = null;
\r
2217 // Return ±Infinity if either is ±Infinity.
\r
2221 // Return ±0 if either is ±0.
\r
2231 e = bitFloor(x.e / LOG_BASE) + bitFloor(y.e / LOG_BASE);
\r
2236 // Ensure xc points to longer array and xcL to its length.
\r
2237 if (xcL < ycL) zc = xc, xc = yc, yc = zc, i = xcL, xcL = ycL, ycL = i;
\r
2239 // Initialise the result array with zeros.
\r
2240 for (i = xcL + ycL, zc = []; i--; zc.push(0));
\r
2243 sqrtBase = SQRT_BASE;
\r
2245 for (i = ycL; --i >= 0;) {
\r
2247 ylo = yc[i] % sqrtBase;
\r
2248 yhi = yc[i] / sqrtBase | 0;
\r
2250 for (k = xcL, j = i + k; j > i;) {
\r
2251 xlo = xc[--k] % sqrtBase;
\r
2252 xhi = xc[k] / sqrtBase | 0;
\r
2253 m = yhi * xlo + xhi * ylo;
\r
2254 xlo = ylo * xlo + ((m % sqrtBase) * sqrtBase) + zc[j] + c;
\r
2255 c = (xlo / base | 0) + (m / sqrtBase | 0) + yhi * xhi;
\r
2256 zc[j--] = xlo % base;
\r
2268 return normalise(y, zc, e);
\r
2273 * Return a new BigNumber whose value is the value of this BigNumber negated,
\r
2274 * i.e. multiplied by -1.
\r
2276 P.negated = function () {
\r
2277 var x = new BigNumber(this);
\r
2278 x.s = -x.s || null;
\r
2300 * Return a new BigNumber whose value is the value of this BigNumber plus the value of
\r
2301 * BigNumber(y, b).
\r
2303 P.plus = function (y, b) {
\r
2308 y = new BigNumber(y, b);
\r
2312 if (!a || !b) return new BigNumber(NaN);
\r
2317 return x.minus(y);
\r
2320 var xe = x.e / LOG_BASE,
\r
2321 ye = y.e / LOG_BASE,
\r
2327 // Return ±Infinity if either ±Infinity.
\r
2328 if (!xc || !yc) return new BigNumber(a / 0);
\r
2331 // Return y if y is non-zero, x if x is non-zero, or zero if both are zero.
\r
2332 if (!xc[0] || !yc[0]) return yc[0] ? y : new BigNumber(xc[0] ? x : a * 0);
\r
2335 xe = bitFloor(xe);
\r
2336 ye = bitFloor(ye);
\r
2339 // Prepend zeros to equalise exponents. Faster to use reverse then do unshifts.
\r
2340 if (a = xe - ye) {
\r
2350 for (; a--; t.push(0));
\r
2357 // Point xc to the longer array, and b to the shorter length.
\r
2358 if (a - b < 0) t = yc, yc = xc, xc = t, b = a;
\r
2360 // Only start adding at yc.length - 1 as the further digits of xc can be ignored.
\r
2362 a = (xc[--b] = xc[b] + yc[b] + a) / BASE | 0;
\r
2363 xc[b] = BASE === xc[b] ? 0 : xc[b] % BASE;
\r
2367 xc = [a].concat(xc);
\r
2371 // No need to check for zero, as +x + +y != 0 && -x + -y != 0
\r
2372 // ye = MAX_EXP + 1 possible
\r
2373 return normalise(y, xc, ye);
\r
2378 * If sd is undefined or null or true or false, return the number of significant digits of
\r
2379 * the value of this BigNumber, or null if the value of this BigNumber is ±Infinity or NaN.
\r
2380 * If sd is true include integer-part trailing zeros in the count.
\r
2382 * Otherwise, if sd is a number, return a new BigNumber whose value is the value of this
\r
2383 * BigNumber rounded to a maximum of sd significant digits using rounding mode rm, or
\r
2384 * ROUNDING_MODE if rm is omitted.
\r
2386 * sd {number|boolean} number: significant digits: integer, 1 to MAX inclusive.
\r
2387 * boolean: whether to count integer-part trailing zeros: true or false.
\r
2388 * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
\r
2390 * '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {sd|rm}'
\r
2392 P.precision = P.sd = function (sd, rm) {
\r
2396 if (sd != null && sd !== !!sd) {
\r
2397 intCheck(sd, 1, MAX);
\r
2398 if (rm == null) rm = ROUNDING_MODE;
\r
2399 else intCheck(rm, 0, 8);
\r
2401 return round(new BigNumber(x), sd, rm);
\r
2404 if (!(c = x.c)) return null;
\r
2406 n = v * LOG_BASE + 1;
\r
2410 // Subtract the number of trailing zeros of the last element.
\r
2411 for (; v % 10 == 0; v /= 10, n--);
\r
2413 // Add the number of digits of the first element.
\r
2414 for (v = c[0]; v >= 10; v /= 10, n++);
\r
2417 if (sd && x.e + 1 > n) n = x.e + 1;
\r
2424 * Return a new BigNumber whose value is the value of this BigNumber shifted by k places
\r
2425 * (powers of 10). Shift to the right if n > 0, and to the left if n < 0.
\r
2427 * k {number} Integer, -MAX_SAFE_INTEGER to MAX_SAFE_INTEGER inclusive.
\r
2429 * '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {k}'
\r
2431 P.shiftedBy = function (k) {
\r
2432 intCheck(k, -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER);
\r
2433 return this.times('1e' + k);
\r
2445 * Return a new BigNumber whose value is the square root of the value of this BigNumber,
\r
2446 * rounded according to DECIMAL_PLACES and ROUNDING_MODE.
\r
2448 P.squareRoot = P.sqrt = function () {
\r
2449 var m, n, r, rep, t,
\r
2454 dp = DECIMAL_PLACES + 4,
\r
2455 half = new BigNumber('0.5');
\r
2457 // Negative/NaN/Infinity/zero?
\r
2458 if (s !== 1 || !c || !c[0]) {
\r
2459 return new BigNumber(!s || s < 0 && (!c || c[0]) ? NaN : c ? x : 1 / 0);
\r
2462 // Initial estimate.
\r
2463 s = Math.sqrt(+valueOf(x));
\r
2465 // Math.sqrt underflow/overflow?
\r
2466 // Pass x to Math.sqrt as integer, then adjust the exponent of the result.
\r
2467 if (s == 0 || s == 1 / 0) {
\r
2468 n = coeffToString(c);
\r
2469 if ((n.length + e) % 2 == 0) n += '0';
\r
2470 s = Math.sqrt(+n);
\r
2471 e = bitFloor((e + 1) / 2) - (e < 0 || e % 2);
\r
2476 n = s.toExponential();
\r
2477 n = n.slice(0, n.indexOf('e') + 1) + e;
\r
2480 r = new BigNumber(n);
\r
2482 r = new BigNumber(s + '');
\r
2485 // Check for zero.
\r
2486 // r could be zero if MIN_EXP is changed after the this value was created.
\r
2487 // This would cause a division by zero (x/t) and hence Infinity below, which would cause
\r
2488 // coeffToString to throw.
\r
2494 // Newton-Raphson iteration.
\r
2497 r = half.times(t.plus(div(x, t, dp, 1)));
\r
2499 if (coeffToString(t.c).slice(0, s) === (n = coeffToString(r.c)).slice(0, s)) {
\r
2501 // The exponent of r may here be one less than the final result exponent,
\r
2502 // e.g 0.0009999 (e-4) --> 0.001 (e-3), so adjust s so the rounding digits
\r
2503 // are indexed correctly.
\r
2505 n = n.slice(s - 3, s + 1);
\r
2507 // The 4th rounding digit may be in error by -1 so if the 4 rounding digits
\r
2508 // are 9999 or 4999 (i.e. approaching a rounding boundary) continue the
\r
2510 if (n == '9999' || !rep && n == '4999') {
\r
2512 // On the first iteration only, check to see if rounding up gives the
\r
2513 // exact result as the nines may infinitely repeat.
\r
2515 round(t, t.e + DECIMAL_PLACES + 2, 0);
\r
2517 if (t.times(t).eq(x)) {
\r
2528 // If rounding digits are null, 0{0,4} or 50{0,3}, check for exact
\r
2529 // result. If not, then there are further digits and m will be truthy.
\r
2530 if (!+n || !+n.slice(1) && n.charAt(0) == '5') {
\r
2532 // Truncate to the first rounding digit.
\r
2533 round(r, r.e + DECIMAL_PLACES + 2, 1);
\r
2534 m = !r.times(r).eq(x);
\r
2543 return round(r, r.e + DECIMAL_PLACES + 1, ROUNDING_MODE, m);
\r
2548 * Return a string representing the value of this BigNumber in exponential notation and
\r
2549 * rounded using ROUNDING_MODE to dp fixed decimal places.
\r
2551 * [dp] {number} Decimal places. Integer, 0 to MAX inclusive.
\r
2552 * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
\r
2554 * '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {dp|rm}'
\r
2556 P.toExponential = function (dp, rm) {
\r
2558 intCheck(dp, 0, MAX);
\r
2561 return format(this, dp, rm, 1);
\r
2566 * Return a string representing the value of this BigNumber in fixed-point notation rounding
\r
2567 * to dp fixed decimal places using rounding mode rm, or ROUNDING_MODE if rm is omitted.
\r
2569 * Note: as with JavaScript's number type, (-0).toFixed(0) is '0',
\r
2570 * but e.g. (-0.00001).toFixed(0) is '-0'.
\r
2572 * [dp] {number} Decimal places. Integer, 0 to MAX inclusive.
\r
2573 * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
\r
2575 * '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {dp|rm}'
\r
2577 P.toFixed = function (dp, rm) {
\r
2579 intCheck(dp, 0, MAX);
\r
2580 dp = dp + this.e + 1;
\r
2582 return format(this, dp, rm);
\r
2587 * Return a string representing the value of this BigNumber in fixed-point notation rounded
\r
2588 * using rm or ROUNDING_MODE to dp decimal places, and formatted according to the properties
\r
2589 * of the format or FORMAT object (see BigNumber.set).
\r
2591 * The formatting object may contain some or all of the properties shown below.
\r
2596 * secondaryGroupSize: 0,
\r
2597 * groupSeparator: ',',
\r
2598 * decimalSeparator: '.',
\r
2599 * fractionGroupSize: 0,
\r
2600 * fractionGroupSeparator: '\xA0', // non-breaking space
\r
2604 * [dp] {number} Decimal places. Integer, 0 to MAX inclusive.
\r
2605 * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
\r
2606 * [format] {object} Formatting options. See FORMAT pbject above.
\r
2608 * '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {dp|rm}'
\r
2609 * '[BigNumber Error] Argument not an object: {format}'
\r
2611 P.toFormat = function (dp, rm, format) {
\r
2615 if (format == null) {
\r
2616 if (dp != null && rm && typeof rm == 'object') {
\r
2619 } else if (dp && typeof dp == 'object') {
\r
2625 } else if (typeof format != 'object') {
\r
2627 (bignumberError + 'Argument not an object: ' + format);
\r
2630 str = x.toFixed(dp, rm);
\r
2634 arr = str.split('.'),
\r
2635 g1 = +format.groupSize,
\r
2636 g2 = +format.secondaryGroupSize,
\r
2637 groupSeparator = format.groupSeparator || '',
\r
2639 fractionPart = arr[1],
\r
2641 intDigits = isNeg ? intPart.slice(1) : intPart,
\r
2642 len = intDigits.length;
\r
2644 if (g2) i = g1, g1 = g2, g2 = i, len -= i;
\r
2646 if (g1 > 0 && len > 0) {
\r
2647 i = len % g1 || g1;
\r
2648 intPart = intDigits.substr(0, i);
\r
2649 for (; i < len; i += g1) intPart += groupSeparator + intDigits.substr(i, g1);
\r
2650 if (g2 > 0) intPart += groupSeparator + intDigits.slice(i);
\r
2651 if (isNeg) intPart = '-' + intPart;
\r
2654 str = fractionPart
\r
2655 ? intPart + (format.decimalSeparator || '') + ((g2 = +format.fractionGroupSize)
\r
2656 ? fractionPart.replace(new RegExp('\\d{' + g2 + '}\\B', 'g'),
\r
2657 '$&' + (format.fractionGroupSeparator || ''))
\r
2662 return (format.prefix || '') + str + (format.suffix || '');
\r
2667 * Return an array of two BigNumbers representing the value of this BigNumber as a simple
\r
2668 * fraction with an integer numerator and an integer denominator.
\r
2669 * The denominator will be a positive non-zero value less than or equal to the specified
\r
2670 * maximum denominator. If a maximum denominator is not specified, the denominator will be
\r
2671 * the lowest value necessary to represent the number exactly.
\r
2673 * [md] {number|string|BigNumber} Integer >= 1, or Infinity. The maximum denominator.
\r
2675 * '[BigNumber Error] Argument {not an integer|out of range} : {md}'
\r
2677 P.toFraction = function (md) {
\r
2678 var d, d0, d1, d2, e, exp, n, n0, n1, q, r, s,
\r
2683 n = new BigNumber(md);
\r
2685 // Throw if md is less than one or is not an integer, unless it is Infinity.
\r
2686 if (!n.isInteger() && (n.c || n.s !== 1) || n.lt(ONE)) {
\r
2688 (bignumberError + 'Argument ' +
\r
2689 (n.isInteger() ? 'out of range: ' : 'not an integer: ') + valueOf(n));
\r
2693 if (!xc) return new BigNumber(x);
\r
2695 d = new BigNumber(ONE);
\r
2696 n1 = d0 = new BigNumber(ONE);
\r
2697 d1 = n0 = new BigNumber(ONE);
\r
2698 s = coeffToString(xc);
\r
2700 // Determine initial denominator.
\r
2701 // d is a power of 10 and the minimum max denominator that specifies the value exactly.
\r
2702 e = d.e = s.length - x.e - 1;
\r
2703 d.c[0] = POWS_TEN[(exp = e % LOG_BASE) < 0 ? LOG_BASE + exp : exp];
\r
2704 md = !md || n.comparedTo(d) > 0 ? (e > 0 ? d : n1) : n;
\r
2708 n = new BigNumber(s);
\r
2714 q = div(n, d, 0, 1);
\r
2715 d2 = d0.plus(q.times(d1));
\r
2716 if (d2.comparedTo(md) == 1) break;
\r
2719 n1 = n0.plus(q.times(d2 = n1));
\r
2721 d = n.minus(q.times(d2 = d));
\r
2725 d2 = div(md.minus(d0), d1, 0, 1);
\r
2726 n0 = n0.plus(d2.times(n1));
\r
2727 d0 = d0.plus(d2.times(d1));
\r
2728 n0.s = n1.s = x.s;
\r
2731 // Determine which fraction is closer to x, n0/d0 or n1/d1
\r
2732 r = div(n1, d1, e, ROUNDING_MODE).minus(x).abs().comparedTo(
\r
2733 div(n0, d0, e, ROUNDING_MODE).minus(x).abs()) < 1 ? [n1, d1] : [n0, d0];
\r
2742 * Return the value of this BigNumber converted to a number primitive.
\r
2744 P.toNumber = function () {
\r
2745 return +valueOf(this);
\r
2750 * Return a string representing the value of this BigNumber rounded to sd significant digits
\r
2751 * using rounding mode rm or ROUNDING_MODE. If sd is less than the number of digits
\r
2752 * necessary to represent the integer part of the value in fixed-point notation, then use
\r
2753 * exponential notation.
\r
2755 * [sd] {number} Significant digits. Integer, 1 to MAX inclusive.
\r
2756 * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
\r
2758 * '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {sd|rm}'
\r
2760 P.toPrecision = function (sd, rm) {
\r
2761 if (sd != null) intCheck(sd, 1, MAX);
\r
2762 return format(this, sd, rm, 2);
\r
2767 * Return a string representing the value of this BigNumber in base b, or base 10 if b is
\r
2768 * omitted. If a base is specified, including base 10, round according to DECIMAL_PLACES and
\r
2769 * ROUNDING_MODE. If a base is not specified, and this BigNumber has a positive exponent
\r
2770 * that is equal to or greater than TO_EXP_POS, or a negative exponent equal to or less than
\r
2771 * TO_EXP_NEG, return exponential notation.
\r
2773 * [b] {number} Integer, 2 to ALPHABET.length inclusive.
\r
2775 * '[BigNumber Error] Base {not a primitive number|not an integer|out of range}: {b}'
\r
2777 P.toString = function (b) {
\r
2783 // Infinity or NaN?
\r
2787 if (s < 0) str = '-' + str;
\r
2793 str = e <= TO_EXP_NEG || e >= TO_EXP_POS
\r
2794 ? toExponential(coeffToString(n.c), e)
\r
2795 : toFixedPoint(coeffToString(n.c), e, '0');
\r
2796 } else if (b === 10) {
\r
2797 n = round(new BigNumber(n), DECIMAL_PLACES + e + 1, ROUNDING_MODE);
\r
2798 str = toFixedPoint(coeffToString(n.c), n.e, '0');
\r
2800 intCheck(b, 2, ALPHABET.length, 'Base');
\r
2801 str = convertBase(toFixedPoint(coeffToString(n.c), e, '0'), 10, b, s, true);
\r
2804 if (s < 0 && n.c[0]) str = '-' + str;
\r
2812 * Return as toString, but do not accept a base argument, and include the minus sign for
\r
2815 P.valueOf = P.toJSON = function () {
\r
2816 return valueOf(this);
\r
2820 P._isBigNumber = true;
\r
2822 if (configObject != null) BigNumber.set(configObject);
\r
2828 // PRIVATE HELPER FUNCTIONS
\r
2830 // These functions don't need access to variables,
\r
2831 // e.g. DECIMAL_PLACES, in the scope of the `clone` function above.
\r
2834 function bitFloor(n) {
\r
2836 return n > 0 || n === i ? i : i - 1;
\r
2840 // Return a coefficient array as a string of base 10 digits.
\r
2841 function coeffToString(a) {
\r
2849 z = LOG_BASE - s.length;
\r
2850 for (; z--; s = '0' + s);
\r
2854 // Determine trailing zeros.
\r
2855 for (j = r.length; r.charCodeAt(--j) === 48;);
\r
2857 return r.slice(0, j + 1 || 1);
\r
2861 // Compare the value of BigNumbers x and y.
\r
2862 function compare(x, y) {
\r
2872 if (!i || !j) return null;
\r
2878 if (a || b) return a ? b ? 0 : -j : i;
\r
2881 if (i != j) return i;
\r
2886 // Either Infinity?
\r
2887 if (!xc || !yc) return b ? 0 : !xc ^ a ? 1 : -1;
\r
2889 // Compare exponents.
\r
2890 if (!b) return k > l ^ a ? 1 : -1;
\r
2892 j = (k = xc.length) < (l = yc.length) ? k : l;
\r
2894 // Compare digit by digit.
\r
2895 for (i = 0; i < j; i++) if (xc[i] != yc[i]) return xc[i] > yc[i] ^ a ? 1 : -1;
\r
2897 // Compare lengths.
\r
2898 return k == l ? 0 : k > l ^ a ? 1 : -1;
\r
2903 * Check that n is a primitive number, an integer, and in range, otherwise throw.
\r
2905 function intCheck(n, min, max, name) {
\r
2906 if (n < min || n > max || n !== mathfloor(n)) {
\r
2908 (bignumberError + (name || 'Argument') + (typeof n == 'number'
\r
2909 ? n < min || n > max ? ' out of range: ' : ' not an integer: '
\r
2910 : ' not a primitive number: ') + String(n));
\r
2915 // Assumes finite n.
\r
2916 function isOdd(n) {
\r
2917 var k = n.c.length - 1;
\r
2918 return bitFloor(n.e / LOG_BASE) == k && n.c[k] % 2 != 0;
\r
2922 function toExponential(str, e) {
\r
2923 return (str.length > 1 ? str.charAt(0) + '.' + str.slice(1) : str) +
\r
2924 (e < 0 ? 'e' : 'e+') + e;
\r
2928 function toFixedPoint(str, e, z) {
\r
2931 // Negative exponent?
\r
2935 for (zs = z + '.'; ++e; zs += z);
\r
2938 // Positive exponent
\r
2944 for (zs = z, e -= len; --e; zs += z);
\r
2946 } else if (e < len) {
\r
2947 str = str.slice(0, e) + '.' + str.slice(e);
\r
2958 BigNumber = clone();
\r
2959 BigNumber['default'] = BigNumber.BigNumber = BigNumber;
\r
2963 !(__WEBPACK_AMD_DEFINE_RESULT__ = (function () { return BigNumber; }).call(exports, __webpack_require__, exports, module),
2964 __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
\r
2966 // Node.js and other environments that support module.exports.
\r
2967 } else if (typeof module != 'undefined' && module.exports) {
\r
2968 module.exports = BigNumber;
\r
2972 if (!globalObject) {
\r
2973 globalObject = typeof self != 'undefined' && self ? self : window;
\r
2976 globalObject.BigNumber = BigNumber;
\r
2984 /***/ (function(module, __webpack_exports__, __webpack_require__) {
2987 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_core_js_json_stringify__ = __webpack_require__(144);
2988 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_core_js_json_stringify___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_babel_runtime_core_js_json_stringify__);
2989 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_babel_runtime_core_js_promise__ = __webpack_require__(76);
2990 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_babel_runtime_core_js_promise___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_babel_runtime_core_js_promise__);
2991 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__bytom__ = __webpack_require__(436);
2992 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__utils_utils__ = __webpack_require__(578);
2998 var transaction = {};
3000 transaction.list = function (guid, asset_id, start, limit, tx_types) {
3001 var filter = { asset_id: asset_id };
3003 filter.tx_types = tx_types;
3005 return __WEBPACK_IMPORTED_MODULE_2__bytom__["a" /* default */].transaction.list(guid, filter, null, start, limit);
3008 transaction.convertArgument = function (argArray) {
3009 var fn = function asyncConvert(object) {
3010 var type = object.type;
3011 var value = object.value;
3012 return __WEBPACK_IMPORTED_MODULE_2__bytom__["a" /* default */].transaction.convertArgument(type, value).then(function (resp) {
3017 var actionFunction = argArray.map(fn);
3018 return __WEBPACK_IMPORTED_MODULE_1_babel_runtime_core_js_promise___default.a.all(actionFunction);
3021 transaction.chainStatus = function () {
3022 return __WEBPACK_IMPORTED_MODULE_2__bytom__["a" /* default */].query.getblockcount();
3025 transaction.asset = function (asset_id) {
3026 return __WEBPACK_IMPORTED_MODULE_2__bytom__["a" /* default */].query.asset(asset_id);
3029 transaction.build = function (address, to, asset, amount, fee, confirmations) {
3030 var retPromise = new __WEBPACK_IMPORTED_MODULE_1_babel_runtime_core_js_promise___default.a(function (resolve, reject) {
3031 __WEBPACK_IMPORTED_MODULE_2__bytom__["a" /* default */].transaction.buildPayment(address, to, asset, amount.toString(), fee, confirmations).then(function (res) {
3033 }).catch(function (error) {
3040 transaction.buildCrossChain = function (address, to, asset, amount, confirmations) {
3041 var retPromise = new __WEBPACK_IMPORTED_MODULE_1_babel_runtime_core_js_promise___default.a(function (resolve, reject) {
3042 __WEBPACK_IMPORTED_MODULE_2__bytom__["a" /* default */].transaction.buildCrossChain(address, to, asset, amount.toString(), confirmations).then(function (res) {
3044 }).catch(function (error) {
3051 transaction.buildVote = function (address, vote, amount, confirmations, memo) {
3052 var retPromise = new __WEBPACK_IMPORTED_MODULE_1_babel_runtime_core_js_promise___default.a(function (resolve, reject) {
3053 __WEBPACK_IMPORTED_MODULE_2__bytom__["a" /* default */].transaction.buildVote(address, vote, amount.toString(), confirmations, memo).then(function (res) {
3055 }).catch(function (error) {
3062 transaction.buildVeto = function (address, vote, amount, confirmations, memo) {
3063 var retPromise = new __WEBPACK_IMPORTED_MODULE_1_babel_runtime_core_js_promise___default.a(function (resolve, reject) {
3064 __WEBPACK_IMPORTED_MODULE_2__bytom__["a" /* default */].transaction.buildVeto(address, vote, amount.toString(), confirmations, memo).then(function (res) {
3066 }).catch(function (error) {
3073 transaction.buildTransaction = function (address, inputs, outputs, gas, confirmations) {
3074 var retPromise = new __WEBPACK_IMPORTED_MODULE_1_babel_runtime_core_js_promise___default.a(function (resolve, reject) {
3075 __WEBPACK_IMPORTED_MODULE_2__bytom__["a" /* default */].transaction.buildTransaction(address, inputs, outputs, gas, confirmations).then(function (res) {
3077 }).catch(function (error) {
3084 transaction.signTransaction = function (guid, transaction, password) {
3085 var retPromise = new __WEBPACK_IMPORTED_MODULE_1_babel_runtime_core_js_promise___default.a(function (resolve, reject) {
3086 __WEBPACK_IMPORTED_MODULE_2__bytom__["a" /* default */].transaction.signTransaction(guid, __WEBPACK_IMPORTED_MODULE_0_babel_runtime_core_js_json_stringify___default()(Object(__WEBPACK_IMPORTED_MODULE_3__utils_utils__["b" /* snakeize */])(transaction)), password).then(function (res) {
3088 }).catch(function (error) {
3095 transaction.transfer = function (guid, transaction, password, address) {
3096 var retPromise = new __WEBPACK_IMPORTED_MODULE_1_babel_runtime_core_js_promise___default.a(function (resolve, reject) {
3097 __WEBPACK_IMPORTED_MODULE_2__bytom__["a" /* default */].transaction.signTransaction(guid, __WEBPACK_IMPORTED_MODULE_0_babel_runtime_core_js_json_stringify___default()(Object(__WEBPACK_IMPORTED_MODULE_3__utils_utils__["b" /* snakeize */])(transaction)), password).then(function (ret) {
3098 __WEBPACK_IMPORTED_MODULE_2__bytom__["a" /* default */].transaction.submitPayment(address, ret.raw_transaction, ret.signatures).then(function (res3) {
3100 transactionHash: res3.txHash
3103 }).catch(function (error) {
3106 }).catch(function (error) {
3114 transaction.signMessage = function (message, password, address) {
3115 return __WEBPACK_IMPORTED_MODULE_2__bytom__["a" /* default */].keys.signMessage(message, password, address);
3118 transaction.advancedTransfer = function (guid, transaction, password, arrayData, address) {
3119 var retPromise = new __WEBPACK_IMPORTED_MODULE_1_babel_runtime_core_js_promise___default.a(function (resolve, reject) {
3120 __WEBPACK_IMPORTED_MODULE_2__bytom__["a" /* default */].transaction.signTransaction(guid, __WEBPACK_IMPORTED_MODULE_0_babel_runtime_core_js_json_stringify___default()(Object(__WEBPACK_IMPORTED_MODULE_3__utils_utils__["b" /* snakeize */])(transaction)), password).then(function (ret) {
3121 var signatures = ret.signatures;
3123 signatures[0] = arrayData;
3125 __WEBPACK_IMPORTED_MODULE_2__bytom__["a" /* default */].transaction.submitPayment(address, ret.raw_transaction, signatures).then(function (res3) {
3127 transactionHash: res3.txHash
3130 }).catch(function (error) {
3133 }).catch(function (error) {
3141 /* harmony default export */ __webpack_exports__["a"] = (transaction);
3146 /***/ (function(module, __webpack_exports__, __webpack_require__) {
3149 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return camelize; });
3150 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return snakeize; });
3151 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_typeof__ = __webpack_require__(145);
3152 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_typeof___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_typeof__);
3154 var camelize = function camelize(object) {
3155 if ((typeof object === 'undefined' ? 'undefined' : __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_typeof___default()(object)) == 'object') {
3156 for (var key in object) {
3157 var value = object[key];
3160 if (/_/.test(key)) {
3161 newKey = key.replace(/([_][a-z])/g, function (v) {
3162 return v[1].toUpperCase();
3167 if ((typeof value === 'undefined' ? 'undefined' : __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_typeof___default()(value)) == 'object') {
3168 value = camelize(value);
3171 object[newKey] = value;
3176 return object.replace(/([_][a-z])/g, function (v) {
3177 return v[1].toUpperCase();
3182 var snakeize = function snakeize(object) {
3183 for (var key in object) {
3184 var value = object[key];
3187 // Skip all-caps keys
3188 if (/^[A-Z]+$/.test(key)) {
3192 if (/[A-Z]/.test(key)) {
3193 newKey = key.replace(/([A-Z])/g, function (v) {
3194 return '_' + v.toLowerCase();
3199 if ((typeof value === 'undefined' ? 'undefined' : __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_typeof___default()(value)) == 'object') {
3200 value = snakeize(value);
3203 object[newKey] = value;
3212 /***/ (function(module, __webpack_exports__, __webpack_require__) {
3215 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__cn__ = __webpack_require__(581);
3219 cn: __WEBPACK_IMPORTED_MODULE_0__cn__["a" /* default */]
3222 function getLang(str, lang) {
3223 if (sdkLang[lang] && sdkLang[lang][str]) {
3224 return sdkLang[lang][str];
3229 /* harmony default export */ __webpack_exports__["a"] = (getLang);
3234 /***/ (function(module, __webpack_exports__, __webpack_require__) {
3238 "key alias already exists": "秘钥别名已经存在",
3239 "db insert error": "数据库写入异常",
3240 "db get error": "数据库查询异常",
3241 "not found by XPub": "未找到私钥数据",
3242 "db update error": "数据库更新失败",
3243 "db update error: not found by rootXPub": "数据库更新失败:未找到相应的私钥数据",
3244 "duplicate account alias": "账户别名已存在",
3245 "The wallet already has account data. Can't restore.": "当前钱包存在数据,无法从备份覆盖恢复",
3246 "could not decrypt key with given passphrase": "无法解密私钥,请检查密码是否正确",
3247 "unknown address type": "未知的地址类型"
3250 /* harmony default export */ __webpack_exports__["a"] = (cn);
3255 /***/ (function(module, __webpack_exports__, __webpack_require__) {
3258 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_extends__ = __webpack_require__(532);
3259 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_extends___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_extends__);
3260 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__assets_language__ = __webpack_require__(438);
3261 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_vuex__ = __webpack_require__(433);
3318 var CLASS_CN = "form-item-content form-item-content-cn";
3319 var CLASS_EN = "form-item-content form-item-content-en";
3320 /* harmony default export */ __webpack_exports__["a"] = ({
3321 data: function data() {
3334 computed: __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_extends___default()({
3335 passwdStyle: function passwdStyle() {
3336 if (this.i18n == "cn") {
3338 } else if (this.i18n == "en") {
3343 }, Object(__WEBPACK_IMPORTED_MODULE_2_vuex__["c" /* mapGetters */])(['language'])),
3345 open: function open() {
3346 this.i18n = Object(__WEBPACK_IMPORTED_MODULE_1__assets_language__["b" /* getLanguage */])(this.language);
3350 close: function close() {
3353 confirm: function confirm() {
3354 if (this.passwd == "") {
3356 body: this.$t("transfer.emptyPassword")
3362 this.$emit("confirm", this.passwd);
3370 /***/ (function(module, __webpack_exports__, __webpack_require__) {
3373 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_vue_loader_lib_selector_type_script_index_0_modal_passwd_vue__ = __webpack_require__(582);
3374 /* unused harmony namespace reexport */
3375 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__node_modules_vue_loader_lib_template_compiler_index_id_data_v_2a9f9bf0_hasScoped_true_buble_transforms_node_modules_vue_loader_lib_selector_type_template_index_0_modal_passwd_vue__ = __webpack_require__(587);
3376 function injectStyle (ssrContext) {
3377 __webpack_require__(585)
3379 var normalizeComponent = __webpack_require__(266)
3385 /* template functional */
3386 var __vue_template_functional__ = false
3388 var __vue_styles__ = injectStyle
3390 var __vue_scopeId__ = "data-v-2a9f9bf0"
3391 /* moduleIdentifier (server only) */
3392 var __vue_module_identifier__ = null
3393 var Component = normalizeComponent(
3394 __WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_vue_loader_lib_selector_type_script_index_0_modal_passwd_vue__["a" /* default */],
3395 __WEBPACK_IMPORTED_MODULE_1__node_modules_vue_loader_lib_template_compiler_index_id_data_v_2a9f9bf0_hasScoped_true_buble_transforms_node_modules_vue_loader_lib_selector_type_template_index_0_modal_passwd_vue__["a" /* default */],
3396 __vue_template_functional__,
3399 __vue_module_identifier__
3402 /* harmony default export */ __webpack_exports__["a"] = (Component.exports);
3408 /***/ (function(module, exports, __webpack_require__) {
3410 // style-loader: Adds some css to the DOM by adding a <style> tag
3413 var content = __webpack_require__(586);
3414 if(typeof content === 'string') content = [[module.i, content, '']];
3415 if(content.locals) module.exports = content.locals;
3416 // add the styles to the DOM
3417 var update = __webpack_require__(84)("c3761858", content, true, {});
3422 /***/ (function(module, exports, __webpack_require__) {
3424 exports = module.exports = __webpack_require__(83)(false);
3429 exports.push([module.i, ".mask[data-v-2a9f9bf0]{z-index:3!important;top:60px!important}.confirm[data-v-2a9f9bf0]{padding:10px 20px;position:fixed;width:310px;left:0;bottom:0;right:0;z-index:4}.btn-inline[data-v-2a9f9bf0]{display:flex;padding:0}.btn-inline .btn[data-v-2a9f9bf0]{margin:10px 15px}.form-item-content-en[data-v-2a9f9bf0]{margin-left:145px}.form-item-content-cn[data-v-2a9f9bf0]{margin-left:85px}", ""]);
3437 /***/ (function(module, __webpack_exports__, __webpack_require__) {
3440 var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',[_c('section',{directives:[{name:"show",rawName:"v-show",value:(_vm.show),expression:"show"}],staticClass:"mask"}),_vm._v(" "),_c('div',{directives:[{name:"show",rawName:"v-show",value:(_vm.show),expression:"show"}],staticClass:"confirm form bg-gray"},[_c('div',{staticClass:"form-item"},[_c('label',{staticClass:"form-item-label"},[_vm._v(_vm._s(_vm.$t('transfer.confirmPassword')))]),_vm._v(" "),_c('div',{class:_vm.passwdStyle},[_c('input',{directives:[{name:"model",rawName:"v-model",value:(_vm.passwd),expression:"passwd"}],attrs:{"type":"password","autofocus":""},domProps:{"value":(_vm.passwd)},on:{"input":function($event){if($event.target.composing){ return; }_vm.passwd=$event.target.value}}})])]),_vm._v(" "),_c('div',{staticClass:"btn-group btn-inline"},[_c('div',{staticClass:"btn bg-green",on:{"click":_vm.confirm}},[_vm._v(_vm._s(_vm.$t('welcome.confirm')))]),_vm._v(" "),_c('div',{staticClass:"btn bg-red",on:{"click":_vm.close}},[_vm._v(_vm._s(_vm.$t('welcome.cancel')))])])])])}
3441 var staticRenderFns = []
3442 var esExports = { render: render, staticRenderFns: staticRenderFns }
3443 /* harmony default export */ __webpack_exports__["a"] = (esExports);
3448 /***/ (function(module, __webpack_exports__, __webpack_require__) {
3451 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_core_js_promise__ = __webpack_require__(76);
3452 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_core_js_promise___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_babel_runtime_core_js_promise__);
3453 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_extends__ = __webpack_require__(532);
3454 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_extends___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_extends__);
3455 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__utils_address__ = __webpack_require__(437);
3456 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__models_transaction__ = __webpack_require__(577);
3457 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_bignumber_js__ = __webpack_require__(576);
3458 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_bignumber_js___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_4_bignumber_js__);
3459 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__models_account__ = __webpack_require__(435);
3460 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__components_modal_passwd__ = __webpack_require__(584);
3461 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__assets_language_sdk__ = __webpack_require__(579);
3462 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_8_extension_streams__ = __webpack_require__(137);
3463 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_8_extension_streams___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_8_extension_streams__);
3464 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_9_vuex__ = __webpack_require__(433);
3642 /* harmony default export */ __webpack_exports__["a"] = ({
3644 modalPasswd: __WEBPACK_IMPORTED_MODULE_6__components_modal_passwd__["a" /* default */]
3646 data: function data() {
3650 accountLabel: this.$t('listVote.voteAccount'),
3663 beforeRouteEnter: function beforeRouteEnter(to, from, next) {
3664 next(function (vm) {
3665 if (from.name === 'veto') {
3666 vm.title = vm.$t('vote.vetoDetials');
3667 vm.accountLabel = vm.$t('listVote.vetoAccount');
3674 computed: __WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_extends___default()({
3675 totalAmount: function totalAmount() {
3676 if (this.assetAlias && this.assetAlias.toUpperCase() === 'BTM') {
3677 var n = new __WEBPACK_IMPORTED_MODULE_4_bignumber_js___default.a(this.transaction.amount);
3678 return n.plus(this.transaction.fee).toNumber();
3680 return Number(this.transaction.amount);
3683 }, Object(__WEBPACK_IMPORTED_MODULE_9_vuex__["d" /* mapState */])(['selectVote']), Object(__WEBPACK_IMPORTED_MODULE_9_vuex__["c" /* mapGetters */])(['language', 'net'])),
3685 shortAddress: function shortAddress(add) {
3686 return __WEBPACK_IMPORTED_MODULE_2__utils_address__["a" /* default */].short(add);
3688 transfer: function transfer() {
3691 if (this.password == "") {
3693 body: this.$t("transfer.emptyPassword")
3697 var loader = this.$loading.show({
3698 // Optional parameters
3701 onCancel: this.onCancel
3704 __WEBPACK_IMPORTED_MODULE_0_babel_runtime_core_js_promise___default.a.all(this.rawData.map(function (rawdata) {
3705 return __WEBPACK_IMPORTED_MODULE_3__models_transaction__["a" /* default */].transfer(_this.account.guid, rawdata, _this.password, _this.account.vpAddress);
3706 })).then(function (ret) {
3708 if (_this.$route.params.type == 'popup') {
3709 __WEBPACK_IMPORTED_MODULE_8_extension_streams__["LocalStream"].send({ method: 'transfer', action: 'success', message: ret[ret.length - 1] });
3712 _this.$dialog.show({
3714 body: _this.$t("transfer.success")
3716 _this.$router.push('/');
3717 if (_this.transaction.type === 'toVapor') {
3718 __WEBPACK_IMPORTED_MODULE_5__models_account__["a" /* default */].setupNet(_this.net + "vapor");
3720 }).catch(function (error) {
3722 _this.$dialog.show({
3723 body: Object(__WEBPACK_IMPORTED_MODULE_7__assets_language_sdk__["a" /* default */])(error.message, _this.language)
3727 }, mounted: function mounted() {
3728 var params = this.$route.params;
3730 this.account = params.account;
3731 this.transaction = params.transaction;
3732 this.transaction.toShort = params.transaction.to;
3733 this.rawData = params.rawData;
3735 this.assetAlias = params.assetAlias;
3742 /***/ (function(module, exports, __webpack_require__) {
3744 // style-loader: Adds some css to the DOM by adding a <style> tag
3747 var content = __webpack_require__(651);
3748 if(typeof content === 'string') content = [[module.i, content, '']];
3749 if(content.locals) module.exports = content.locals;
3750 // add the styles to the DOM
3751 var update = __webpack_require__(84)("62272a1a", content, true, {});
3756 /***/ (function(module, exports, __webpack_require__) {
3758 exports = module.exports = __webpack_require__(83)(false);
3763 exports.push([module.i, ".warp[data-v-59f3fab1]{position:absolute;top:0;left:0;right:0;height:600px;z-index:2}.header[data-v-59f3fab1]{display:flex}.header p[data-v-59f3fab1]{text-align:center;width:270px;padding-top:17px}.content[data-v-59f3fab1]{margin:20px;padding:20px;overflow:hidden;border-radius:4px;width:280px}.ft[data-v-59f3fab1]{border-radius:5px;padding:0 20px!important;line-height:45px;margin-bottom:20px}.ft .from[data-v-59f3fab1]{overflow-x:hidden;width:90px}.ft .to[data-v-59f3fab1]{overflow-x:hidden;padding-left:20px;float:right}.right-arrow[data-v-59f3fab1]{width:32px;height:32px;border-top:12px solid #3c454b;border-right:12px solid #3c454b;transform:rotate(45deg);position:absolute;left:105px}.divider[data-v-59f3fab1]{margin:15px 0}.value .uint[data-v-59f3fab1]{font-size:12px;margin-left:3px;text-transform:uppercase}.fee-intro[data-v-59f3fab1]{font-size:10px}.btn-inline[data-v-59f3fab1]{display:flex;padding:0}.btn-inline .btn[data-v-59f3fab1]{margin:10px 15px}.row[data-v-59f3fab1]{word-break:break-all}.col[data-v-59f3fab1]{font-size:14px;width:35%}.label[data-v-59f3fab1]{color:#7b7b7b}.value[data-v-59f3fab1]{color:#282828;width:60%}.asset[data-v-59f3fab1]{text-transform:uppercase}table[data-v-59f3fab1]{width:100%}.form-item[data-v-59f3fab1]{padding:0;margin:0;margin-bottom:10px}.scorll-panel[data-v-59f3fab1]{overflow:scroll;height:545px}.view-link[data-v-59f3fab1]{font-size:14px;color:#035bd4}", ""]);
3771 /***/ (function(module, __webpack_exports__, __webpack_require__) {
3774 var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"warp bg-gray"},[_c('section',{staticClass:"header bg-header"},[_c('i',{staticClass:"iconfont icon-back",on:{"click":function($event){_vm.$router.go(-1)}}}),_vm._v(" "),_c('p',[_vm._v(_vm._s(_vm.title || _vm.$t('vote.voteDetials')))])]),_vm._v(" "),_c('div',{staticClass:"scorll-panel"},[_c('section',{staticClass:"content bg-white"},[_c('table',[_c('tbody',[_c('tr',{staticClass:"row"},[_c('td',{staticClass:"col label"},[_vm._v(_vm._s(_vm.accountLabel))]),_vm._v(" "),_c('td',{staticClass:"col value"},[_vm._v(_vm._s(_vm.account.alias))])]),_vm._v(" "),(_vm.selectVote.name)?_c('tr',{staticClass:"row"},[_c('td',{staticClass:"col label"},[_vm._v(_vm._s(_vm.$t('listVote.bpName')))]),_vm._v(" "),_c('td',{staticClass:"col value"},[_vm._v(_vm._s(_vm.selectVote.name))])]):_c('tr',{staticClass:"row"},[_c('td',{staticClass:"col label"},[_vm._v(_vm._s(_vm.$t('listVote.bpPubkey')))]),_vm._v(" "),_c('td',{staticClass:"col value"},[_vm._v(_vm._s(_vm.transaction.toShort))])]),_vm._v(" "),_c('div',{staticClass:"divider"}),_vm._v(" "),_c('tr',{staticClass:"row"},[_c('td',{staticClass:"col label"},[_vm._v(_vm._s(_vm.$t('listVote.votes')))]),_vm._v(" "),_c('td',{staticClass:"col value"},[_vm._v(_vm._s(_vm.transaction.amount)),(_vm.assetAlias)?_c('span',{staticClass:"uint"},[_vm._v(_vm._s(_vm.assetAlias))]):_vm._e()])]),_vm._v(" "),_c('tr',{staticClass:"row"},[_c('td',{staticClass:"col label"},[_vm._v(_vm._s(_vm.$t('transfer.fee')))]),_vm._v(" "),_c('td',{staticClass:"col value"},[_vm._v(_vm._s(_vm.transaction.fee)),_c('span',{staticClass:"uint"},[_vm._v("BTM")])])])])])]),_vm._v(" "),_c('section',{staticClass:"content bg-white"},[_c('div',{staticClass:"form"},[_c('div',{staticClass:"form-item"},[_c('label',{staticClass:"form-item-label"},[_vm._v(_vm._s(_vm.$t('transfer.confirmPassword')))]),_vm._v(" "),_c('div',{staticClass:"form-item-content"},[_c('input',{directives:[{name:"model",rawName:"v-model",value:(_vm.password),expression:"password"}],attrs:{"type":"password","autofocus":""},domProps:{"value":(_vm.password)},on:{"input":function($event){if($event.target.composing){ return; }_vm.password=$event.target.value}}})])])])]),_vm._v(" "),_c('div',{staticClass:"row",staticStyle:{"margin":"20px"}},[_c('div',{staticClass:"btn bg-green",on:{"click":_vm.transfer}},[_vm._v(_vm._s(_vm.$t('transfer.confirm')))])])])])}
3775 var staticRenderFns = []
3776 var esExports = { render: render, staticRenderFns: staticRenderFns }
3777 /* harmony default export */ __webpack_exports__["a"] = (esExports);
3782 //# sourceMappingURL=6.js.map