@wzyjs/utils 0.3.28 → 0.3.30
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/dist/{web/antd.d.ts → common/antd/index.d.ts} +1 -0
- package/dist/common/base/array.d.ts +0 -2
- package/dist/common/base/index.d.ts +0 -1
- package/dist/common/base/object.d.ts +1 -7
- package/dist/common/base/other.d.ts +1 -3
- package/dist/common/base/promise.d.ts +1 -1
- package/dist/common/base/string.d.ts +10 -10
- package/dist/common/dayjs/index.d.ts +0 -2
- package/dist/common/index.d.ts +2 -2
- package/dist/node.cjs.js +4511 -32993
- package/dist/node.d.ts +1 -0
- package/dist/node.esm.js +4426 -32864
- package/dist/web/download.d.ts +1 -1
- package/dist/web/element.d.ts +1 -5
- package/dist/web.cjs.js +839 -2755
- package/dist/web.d.ts +2 -2
- package/dist/web.esm.js +839 -2755
- package/package.json +3 -2
- package/dist/common/base/number.d.ts +0 -5
- package/dist/common/image/index.d.ts +0 -1
- package/dist/web/location.d.ts +0 -8
- package/dist/web/style.d.ts +0 -10
package/dist/web.esm.js
CHANGED
|
@@ -8270,7 +8270,7 @@ var require_lodash = __commonJS((exports, module) => {
|
|
|
8270
8270
|
var tag = baseGetTag(value);
|
|
8271
8271
|
return tag == errorTag || tag == domExcTag || typeof value.message == "string" && typeof value.name == "string" && !isPlainObject2(value);
|
|
8272
8272
|
}
|
|
8273
|
-
function
|
|
8273
|
+
function isFinite(value) {
|
|
8274
8274
|
return typeof value == "number" && nativeIsFinite(value);
|
|
8275
8275
|
}
|
|
8276
8276
|
function isFunction3(value) {
|
|
@@ -9139,7 +9139,7 @@ __p += '`;
|
|
|
9139
9139
|
return augend + addend;
|
|
9140
9140
|
}, 0);
|
|
9141
9141
|
var ceil = createRound("ceil");
|
|
9142
|
-
var
|
|
9142
|
+
var divide2 = createMathOperation(function(dividend, divisor) {
|
|
9143
9143
|
return dividend / divisor;
|
|
9144
9144
|
}, 1);
|
|
9145
9145
|
var floor = createRound("floor");
|
|
@@ -9341,7 +9341,7 @@ __p += '`;
|
|
|
9341
9341
|
lodash.conformsTo = conformsTo;
|
|
9342
9342
|
lodash.deburr = deburr;
|
|
9343
9343
|
lodash.defaultTo = defaultTo;
|
|
9344
|
-
lodash.divide =
|
|
9344
|
+
lodash.divide = divide2;
|
|
9345
9345
|
lodash.endsWith = endsWith2;
|
|
9346
9346
|
lodash.eq = eq;
|
|
9347
9347
|
lodash.escape = escape2;
|
|
@@ -9384,7 +9384,7 @@ __p += '`;
|
|
|
9384
9384
|
lodash.isEqual = isEqual;
|
|
9385
9385
|
lodash.isEqualWith = isEqualWith;
|
|
9386
9386
|
lodash.isError = isError;
|
|
9387
|
-
lodash.isFinite =
|
|
9387
|
+
lodash.isFinite = isFinite;
|
|
9388
9388
|
lodash.isFunction = isFunction3;
|
|
9389
9389
|
lodash.isInteger = isInteger;
|
|
9390
9390
|
lodash.isLength = isLength;
|
|
@@ -10308,6 +10308,482 @@ var require_zh_cn = __commonJS((exports, module) => {
|
|
|
10308
10308
|
});
|
|
10309
10309
|
});
|
|
10310
10310
|
|
|
10311
|
+
// ../../node_modules/papaparse/papaparse.min.js
|
|
10312
|
+
var require_papaparse_min = __commonJS((exports, module) => {
|
|
10313
|
+
((e, t) => {
|
|
10314
|
+
typeof define == "function" && define.amd ? define([], t) : typeof module == "object" && typeof exports != "undefined" ? module.exports = t() : e.Papa = t();
|
|
10315
|
+
})(exports, function r() {
|
|
10316
|
+
var n = typeof self != "undefined" ? self : typeof window != "undefined" ? window : n !== undefined ? n : {};
|
|
10317
|
+
var d, s = !n.document && !!n.postMessage, a = n.IS_PAPA_WORKER || false, o = {}, h = 0, v = {};
|
|
10318
|
+
function u(e) {
|
|
10319
|
+
this._handle = null, this._finished = false, this._completed = false, this._halted = false, this._input = null, this._baseIndex = 0, this._partialLine = "", this._rowCount = 0, this._start = 0, this._nextChunk = null, this.isFirstChunk = true, this._completeResults = { data: [], errors: [], meta: {} }, function(e2) {
|
|
10320
|
+
var t = b(e2);
|
|
10321
|
+
t.chunkSize = parseInt(t.chunkSize), e2.step || e2.chunk || (t.chunkSize = null);
|
|
10322
|
+
this._handle = new i(t), (this._handle.streamer = this)._config = t;
|
|
10323
|
+
}.call(this, e), this.parseChunk = function(t, e2) {
|
|
10324
|
+
var i2 = parseInt(this._config.skipFirstNLines) || 0;
|
|
10325
|
+
if (this.isFirstChunk && 0 < i2) {
|
|
10326
|
+
let e3 = this._config.newline;
|
|
10327
|
+
e3 || (r2 = this._config.quoteChar || '"', e3 = this._handle.guessLineEndings(t, r2)), t = [...t.split(e3).slice(i2)].join(e3);
|
|
10328
|
+
}
|
|
10329
|
+
this.isFirstChunk && U(this._config.beforeFirstChunk) && (r2 = this._config.beforeFirstChunk(t)) !== undefined && (t = r2), this.isFirstChunk = false, this._halted = false;
|
|
10330
|
+
var i2 = this._partialLine + t, r2 = (this._partialLine = "", this._handle.parse(i2, this._baseIndex, !this._finished));
|
|
10331
|
+
if (!this._handle.paused() && !this._handle.aborted()) {
|
|
10332
|
+
t = r2.meta.cursor, i2 = (this._finished || (this._partialLine = i2.substring(t - this._baseIndex), this._baseIndex = t), r2 && r2.data && (this._rowCount += r2.data.length), this._finished || this._config.preview && this._rowCount >= this._config.preview);
|
|
10333
|
+
if (a)
|
|
10334
|
+
n.postMessage({ results: r2, workerId: v.WORKER_ID, finished: i2 });
|
|
10335
|
+
else if (U(this._config.chunk) && !e2) {
|
|
10336
|
+
if (this._config.chunk(r2, this._handle), this._handle.paused() || this._handle.aborted())
|
|
10337
|
+
return void (this._halted = true);
|
|
10338
|
+
this._completeResults = r2 = undefined;
|
|
10339
|
+
}
|
|
10340
|
+
return this._config.step || this._config.chunk || (this._completeResults.data = this._completeResults.data.concat(r2.data), this._completeResults.errors = this._completeResults.errors.concat(r2.errors), this._completeResults.meta = r2.meta), this._completed || !i2 || !U(this._config.complete) || r2 && r2.meta.aborted || (this._config.complete(this._completeResults, this._input), this._completed = true), i2 || r2 && r2.meta.paused || this._nextChunk(), r2;
|
|
10341
|
+
}
|
|
10342
|
+
this._halted = true;
|
|
10343
|
+
}, this._sendError = function(e2) {
|
|
10344
|
+
U(this._config.error) ? this._config.error(e2) : a && this._config.error && n.postMessage({ workerId: v.WORKER_ID, error: e2, finished: false });
|
|
10345
|
+
};
|
|
10346
|
+
}
|
|
10347
|
+
function f(e) {
|
|
10348
|
+
var r2;
|
|
10349
|
+
(e = e || {}).chunkSize || (e.chunkSize = v.RemoteChunkSize), u.call(this, e), this._nextChunk = s ? function() {
|
|
10350
|
+
this._readChunk(), this._chunkLoaded();
|
|
10351
|
+
} : function() {
|
|
10352
|
+
this._readChunk();
|
|
10353
|
+
}, this.stream = function(e2) {
|
|
10354
|
+
this._input = e2, this._nextChunk();
|
|
10355
|
+
}, this._readChunk = function() {
|
|
10356
|
+
if (this._finished)
|
|
10357
|
+
this._chunkLoaded();
|
|
10358
|
+
else {
|
|
10359
|
+
if (r2 = new XMLHttpRequest, this._config.withCredentials && (r2.withCredentials = this._config.withCredentials), s || (r2.onload = y(this._chunkLoaded, this), r2.onerror = y(this._chunkError, this)), r2.open(this._config.downloadRequestBody ? "POST" : "GET", this._input, !s), this._config.downloadRequestHeaders) {
|
|
10360
|
+
var e2, t = this._config.downloadRequestHeaders;
|
|
10361
|
+
for (e2 in t)
|
|
10362
|
+
r2.setRequestHeader(e2, t[e2]);
|
|
10363
|
+
}
|
|
10364
|
+
var i2;
|
|
10365
|
+
this._config.chunkSize && (i2 = this._start + this._config.chunkSize - 1, r2.setRequestHeader("Range", "bytes=" + this._start + "-" + i2));
|
|
10366
|
+
try {
|
|
10367
|
+
r2.send(this._config.downloadRequestBody);
|
|
10368
|
+
} catch (e3) {
|
|
10369
|
+
this._chunkError(e3.message);
|
|
10370
|
+
}
|
|
10371
|
+
s && r2.status === 0 && this._chunkError();
|
|
10372
|
+
}
|
|
10373
|
+
}, this._chunkLoaded = function() {
|
|
10374
|
+
r2.readyState === 4 && (r2.status < 200 || 400 <= r2.status ? this._chunkError() : (this._start += this._config.chunkSize || r2.responseText.length, this._finished = !this._config.chunkSize || this._start >= ((e2) => (e2 = e2.getResponseHeader("Content-Range")) !== null ? parseInt(e2.substring(e2.lastIndexOf("/") + 1)) : -1)(r2), this.parseChunk(r2.responseText)));
|
|
10375
|
+
}, this._chunkError = function(e2) {
|
|
10376
|
+
e2 = r2.statusText || e2;
|
|
10377
|
+
this._sendError(new Error(e2));
|
|
10378
|
+
};
|
|
10379
|
+
}
|
|
10380
|
+
function l(e) {
|
|
10381
|
+
(e = e || {}).chunkSize || (e.chunkSize = v.LocalChunkSize), u.call(this, e);
|
|
10382
|
+
var i2, r2, n2 = typeof FileReader != "undefined";
|
|
10383
|
+
this.stream = function(e2) {
|
|
10384
|
+
this._input = e2, r2 = e2.slice || e2.webkitSlice || e2.mozSlice, n2 ? ((i2 = new FileReader).onload = y(this._chunkLoaded, this), i2.onerror = y(this._chunkError, this)) : i2 = new FileReaderSync, this._nextChunk();
|
|
10385
|
+
}, this._nextChunk = function() {
|
|
10386
|
+
this._finished || this._config.preview && !(this._rowCount < this._config.preview) || this._readChunk();
|
|
10387
|
+
}, this._readChunk = function() {
|
|
10388
|
+
var e2 = this._input, t = (this._config.chunkSize && (t = Math.min(this._start + this._config.chunkSize, this._input.size), e2 = r2.call(e2, this._start, t)), i2.readAsText(e2, this._config.encoding));
|
|
10389
|
+
n2 || this._chunkLoaded({ target: { result: t } });
|
|
10390
|
+
}, this._chunkLoaded = function(e2) {
|
|
10391
|
+
this._start += this._config.chunkSize, this._finished = !this._config.chunkSize || this._start >= this._input.size, this.parseChunk(e2.target.result);
|
|
10392
|
+
}, this._chunkError = function() {
|
|
10393
|
+
this._sendError(i2.error);
|
|
10394
|
+
};
|
|
10395
|
+
}
|
|
10396
|
+
function c(e) {
|
|
10397
|
+
var i2;
|
|
10398
|
+
u.call(this, e = e || {}), this.stream = function(e2) {
|
|
10399
|
+
return i2 = e2, this._nextChunk();
|
|
10400
|
+
}, this._nextChunk = function() {
|
|
10401
|
+
var e2, t;
|
|
10402
|
+
if (!this._finished)
|
|
10403
|
+
return e2 = this._config.chunkSize, i2 = e2 ? (t = i2.substring(0, e2), i2.substring(e2)) : (t = i2, ""), this._finished = !i2, this.parseChunk(t);
|
|
10404
|
+
};
|
|
10405
|
+
}
|
|
10406
|
+
function p(e) {
|
|
10407
|
+
u.call(this, e = e || {});
|
|
10408
|
+
var t = [], i2 = true, r2 = false;
|
|
10409
|
+
this.pause = function() {
|
|
10410
|
+
u.prototype.pause.apply(this, arguments), this._input.pause();
|
|
10411
|
+
}, this.resume = function() {
|
|
10412
|
+
u.prototype.resume.apply(this, arguments), this._input.resume();
|
|
10413
|
+
}, this.stream = function(e2) {
|
|
10414
|
+
this._input = e2, this._input.on("data", this._streamData), this._input.on("end", this._streamEnd), this._input.on("error", this._streamError);
|
|
10415
|
+
}, this._checkIsFinished = function() {
|
|
10416
|
+
r2 && t.length === 1 && (this._finished = true);
|
|
10417
|
+
}, this._nextChunk = function() {
|
|
10418
|
+
this._checkIsFinished(), t.length ? this.parseChunk(t.shift()) : i2 = true;
|
|
10419
|
+
}, this._streamData = y(function(e2) {
|
|
10420
|
+
try {
|
|
10421
|
+
t.push(typeof e2 == "string" ? e2 : e2.toString(this._config.encoding)), i2 && (i2 = false, this._checkIsFinished(), this.parseChunk(t.shift()));
|
|
10422
|
+
} catch (e3) {
|
|
10423
|
+
this._streamError(e3);
|
|
10424
|
+
}
|
|
10425
|
+
}, this), this._streamError = y(function(e2) {
|
|
10426
|
+
this._streamCleanUp(), this._sendError(e2);
|
|
10427
|
+
}, this), this._streamEnd = y(function() {
|
|
10428
|
+
this._streamCleanUp(), r2 = true, this._streamData("");
|
|
10429
|
+
}, this), this._streamCleanUp = y(function() {
|
|
10430
|
+
this._input.removeListener("data", this._streamData), this._input.removeListener("end", this._streamEnd), this._input.removeListener("error", this._streamError);
|
|
10431
|
+
}, this);
|
|
10432
|
+
}
|
|
10433
|
+
function i(m2) {
|
|
10434
|
+
var n2, s2, a2, t, o2 = Math.pow(2, 53), h2 = -o2, u2 = /^\s*-?(\d+\.?|\.\d+|\d+\.\d+)([eE][-+]?\d+)?\s*$/, d2 = /^((\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z)))$/, i2 = this, r2 = 0, f2 = 0, l2 = false, e = false, c2 = [], p2 = { data: [], errors: [], meta: {} };
|
|
10435
|
+
function y2(e2) {
|
|
10436
|
+
return m2.skipEmptyLines === "greedy" ? e2.join("").trim() === "" : e2.length === 1 && e2[0].length === 0;
|
|
10437
|
+
}
|
|
10438
|
+
function g2() {
|
|
10439
|
+
if (p2 && a2 && (k("Delimiter", "UndetectableDelimiter", "Unable to auto-detect delimiting character; defaulted to '" + v.DefaultDelimiter + "'"), a2 = false), m2.skipEmptyLines && (p2.data = p2.data.filter(function(e3) {
|
|
10440
|
+
return !y2(e3);
|
|
10441
|
+
})), _2()) {
|
|
10442
|
+
let t3 = function(e3, t4) {
|
|
10443
|
+
U(m2.transformHeader) && (e3 = m2.transformHeader(e3, t4)), c2.push(e3);
|
|
10444
|
+
};
|
|
10445
|
+
var t2 = t3;
|
|
10446
|
+
if (p2)
|
|
10447
|
+
if (Array.isArray(p2.data[0])) {
|
|
10448
|
+
for (var e2 = 0;_2() && e2 < p2.data.length; e2++)
|
|
10449
|
+
p2.data[e2].forEach(t3);
|
|
10450
|
+
p2.data.splice(0, 1);
|
|
10451
|
+
} else
|
|
10452
|
+
p2.data.forEach(t3);
|
|
10453
|
+
}
|
|
10454
|
+
function i3(e3, t3) {
|
|
10455
|
+
for (var i4 = m2.header ? {} : [], r4 = 0;r4 < e3.length; r4++) {
|
|
10456
|
+
var n3 = r4, s3 = e3[r4], s3 = ((e4, t4) => ((e5) => (m2.dynamicTypingFunction && m2.dynamicTyping[e5] === undefined && (m2.dynamicTyping[e5] = m2.dynamicTypingFunction(e5)), (m2.dynamicTyping[e5] || m2.dynamicTyping) === true))(e4) ? t4 === "true" || t4 === "TRUE" || t4 !== "false" && t4 !== "FALSE" && (((e5) => {
|
|
10457
|
+
if (u2.test(e5)) {
|
|
10458
|
+
e5 = parseFloat(e5);
|
|
10459
|
+
if (h2 < e5 && e5 < o2)
|
|
10460
|
+
return 1;
|
|
10461
|
+
}
|
|
10462
|
+
})(t4) ? parseFloat(t4) : d2.test(t4) ? new Date(t4) : t4 === "" ? null : t4) : t4)(n3 = m2.header ? r4 >= c2.length ? "__parsed_extra" : c2[r4] : n3, s3 = m2.transform ? m2.transform(s3, n3) : s3);
|
|
10463
|
+
n3 === "__parsed_extra" ? (i4[n3] = i4[n3] || [], i4[n3].push(s3)) : i4[n3] = s3;
|
|
10464
|
+
}
|
|
10465
|
+
return m2.header && (r4 > c2.length ? k("FieldMismatch", "TooManyFields", "Too many fields: expected " + c2.length + " fields but parsed " + r4, f2 + t3) : r4 < c2.length && k("FieldMismatch", "TooFewFields", "Too few fields: expected " + c2.length + " fields but parsed " + r4, f2 + t3)), i4;
|
|
10466
|
+
}
|
|
10467
|
+
var r3;
|
|
10468
|
+
p2 && (m2.header || m2.dynamicTyping || m2.transform) && (r3 = 1, !p2.data.length || Array.isArray(p2.data[0]) ? (p2.data = p2.data.map(i3), r3 = p2.data.length) : p2.data = i3(p2.data, 0), m2.header && p2.meta && (p2.meta.fields = c2), f2 += r3);
|
|
10469
|
+
}
|
|
10470
|
+
function _2() {
|
|
10471
|
+
return m2.header && c2.length === 0;
|
|
10472
|
+
}
|
|
10473
|
+
function k(e2, t2, i3, r3) {
|
|
10474
|
+
e2 = { type: e2, code: t2, message: i3 };
|
|
10475
|
+
r3 !== undefined && (e2.row = r3), p2.errors.push(e2);
|
|
10476
|
+
}
|
|
10477
|
+
U(m2.step) && (t = m2.step, m2.step = function(e2) {
|
|
10478
|
+
p2 = e2, _2() ? g2() : (g2(), p2.data.length !== 0 && (r2 += e2.data.length, m2.preview && r2 > m2.preview ? s2.abort() : (p2.data = p2.data[0], t(p2, i2))));
|
|
10479
|
+
}), this.parse = function(e2, t2, i3) {
|
|
10480
|
+
var r3 = m2.quoteChar || '"', r3 = (m2.newline || (m2.newline = this.guessLineEndings(e2, r3)), a2 = false, m2.delimiter ? U(m2.delimiter) && (m2.delimiter = m2.delimiter(e2), p2.meta.delimiter = m2.delimiter) : ((r3 = ((e3, t3, i4, r4, n3) => {
|
|
10481
|
+
var s3, a3, o3, h3;
|
|
10482
|
+
n3 = n3 || [",", "\t", "|", ";", v.RECORD_SEP, v.UNIT_SEP];
|
|
10483
|
+
for (var u3 = 0;u3 < n3.length; u3++) {
|
|
10484
|
+
for (var d3, f3 = n3[u3], l3 = 0, c3 = 0, p3 = 0, g3 = (o3 = undefined, new E({ comments: r4, delimiter: f3, newline: t3, preview: 10 }).parse(e3)), _3 = 0;_3 < g3.data.length; _3++)
|
|
10485
|
+
i4 && y2(g3.data[_3]) ? p3++ : (d3 = g3.data[_3].length, c3 += d3, o3 === undefined ? o3 = d3 : 0 < d3 && (l3 += Math.abs(d3 - o3), o3 = d3));
|
|
10486
|
+
0 < g3.data.length && (c3 /= g3.data.length - p3), (a3 === undefined || l3 <= a3) && (h3 === undefined || h3 < c3) && 1.99 < c3 && (a3 = l3, s3 = f3, h3 = c3);
|
|
10487
|
+
}
|
|
10488
|
+
return { successful: !!(m2.delimiter = s3), bestDelimiter: s3 };
|
|
10489
|
+
})(e2, m2.newline, m2.skipEmptyLines, m2.comments, m2.delimitersToGuess)).successful ? m2.delimiter = r3.bestDelimiter : (a2 = true, m2.delimiter = v.DefaultDelimiter), p2.meta.delimiter = m2.delimiter), b(m2));
|
|
10490
|
+
return m2.preview && m2.header && r3.preview++, n2 = e2, s2 = new E(r3), p2 = s2.parse(n2, t2, i3), g2(), l2 ? { meta: { paused: true } } : p2 || { meta: { paused: false } };
|
|
10491
|
+
}, this.paused = function() {
|
|
10492
|
+
return l2;
|
|
10493
|
+
}, this.pause = function() {
|
|
10494
|
+
l2 = true, s2.abort(), n2 = U(m2.chunk) ? "" : n2.substring(s2.getCharIndex());
|
|
10495
|
+
}, this.resume = function() {
|
|
10496
|
+
i2.streamer._halted ? (l2 = false, i2.streamer.parseChunk(n2, true)) : setTimeout(i2.resume, 3);
|
|
10497
|
+
}, this.aborted = function() {
|
|
10498
|
+
return e;
|
|
10499
|
+
}, this.abort = function() {
|
|
10500
|
+
e = true, s2.abort(), p2.meta.aborted = true, U(m2.complete) && m2.complete(p2), n2 = "";
|
|
10501
|
+
}, this.guessLineEndings = function(e2, t2) {
|
|
10502
|
+
e2 = e2.substring(0, 1048576);
|
|
10503
|
+
var t2 = new RegExp(P(t2) + "([^]*?)" + P(t2), "gm"), i3 = (e2 = e2.replace(t2, "")).split("\r"), t2 = e2.split(`
|
|
10504
|
+
`), e2 = 1 < t2.length && t2[0].length < i3[0].length;
|
|
10505
|
+
if (i3.length === 1 || e2)
|
|
10506
|
+
return `
|
|
10507
|
+
`;
|
|
10508
|
+
for (var r3 = 0, n3 = 0;n3 < i3.length; n3++)
|
|
10509
|
+
i3[n3][0] === `
|
|
10510
|
+
` && r3++;
|
|
10511
|
+
return r3 >= i3.length / 2 ? `\r
|
|
10512
|
+
` : "\r";
|
|
10513
|
+
};
|
|
10514
|
+
}
|
|
10515
|
+
function P(e) {
|
|
10516
|
+
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
10517
|
+
}
|
|
10518
|
+
function E(C) {
|
|
10519
|
+
var S = (C = C || {}).delimiter, O = C.newline, x = C.comments, I = C.step, A = C.preview, T = C.fastMode, D = null, L = false, F = C.quoteChar == null ? '"' : C.quoteChar, j = F;
|
|
10520
|
+
if (C.escapeChar !== undefined && (j = C.escapeChar), (typeof S != "string" || -1 < v.BAD_DELIMITERS.indexOf(S)) && (S = ","), x === S)
|
|
10521
|
+
throw new Error("Comment character same as delimiter");
|
|
10522
|
+
x === true ? x = "#" : (typeof x != "string" || -1 < v.BAD_DELIMITERS.indexOf(x)) && (x = false), O !== `
|
|
10523
|
+
` && O !== "\r" && O !== `\r
|
|
10524
|
+
` && (O = `
|
|
10525
|
+
`);
|
|
10526
|
+
var z = 0, M = false;
|
|
10527
|
+
this.parse = function(i2, t, r2) {
|
|
10528
|
+
if (typeof i2 != "string")
|
|
10529
|
+
throw new Error("Input must be a string");
|
|
10530
|
+
var n2 = i2.length, e = S.length, s2 = O.length, a2 = x.length, o2 = U(I), h2 = [], u2 = [], d2 = [], f2 = z = 0;
|
|
10531
|
+
if (!i2)
|
|
10532
|
+
return w();
|
|
10533
|
+
if (T || T !== false && i2.indexOf(F) === -1) {
|
|
10534
|
+
for (var l2 = i2.split(O), c2 = 0;c2 < l2.length; c2++) {
|
|
10535
|
+
if (d2 = l2[c2], z += d2.length, c2 !== l2.length - 1)
|
|
10536
|
+
z += O.length;
|
|
10537
|
+
else if (r2)
|
|
10538
|
+
return w();
|
|
10539
|
+
if (!x || d2.substring(0, a2) !== x) {
|
|
10540
|
+
if (o2) {
|
|
10541
|
+
if (h2 = [], k(d2.split(S)), R(), M)
|
|
10542
|
+
return w();
|
|
10543
|
+
} else
|
|
10544
|
+
k(d2.split(S));
|
|
10545
|
+
if (A && A <= c2)
|
|
10546
|
+
return h2 = h2.slice(0, A), w(true);
|
|
10547
|
+
}
|
|
10548
|
+
}
|
|
10549
|
+
return w();
|
|
10550
|
+
}
|
|
10551
|
+
for (var p2 = i2.indexOf(S, z), g2 = i2.indexOf(O, z), _2 = new RegExp(P(j) + P(F), "g"), m2 = i2.indexOf(F, z);; )
|
|
10552
|
+
if (i2[z] === F)
|
|
10553
|
+
for (m2 = z, z++;; ) {
|
|
10554
|
+
if ((m2 = i2.indexOf(F, m2 + 1)) === -1)
|
|
10555
|
+
return r2 || u2.push({ type: "Quotes", code: "MissingQuotes", message: "Quoted field unterminated", row: h2.length, index: z }), E2();
|
|
10556
|
+
if (m2 === n2 - 1)
|
|
10557
|
+
return E2(i2.substring(z, m2).replace(_2, F));
|
|
10558
|
+
if (F === j && i2[m2 + 1] === j)
|
|
10559
|
+
m2++;
|
|
10560
|
+
else if (F === j || m2 === 0 || i2[m2 - 1] !== j) {
|
|
10561
|
+
p2 !== -1 && p2 < m2 + 1 && (p2 = i2.indexOf(S, m2 + 1));
|
|
10562
|
+
var y2 = v2((g2 = g2 !== -1 && g2 < m2 + 1 ? i2.indexOf(O, m2 + 1) : g2) === -1 ? p2 : Math.min(p2, g2));
|
|
10563
|
+
if (i2.substr(m2 + 1 + y2, e) === S) {
|
|
10564
|
+
d2.push(i2.substring(z, m2).replace(_2, F)), i2[z = m2 + 1 + y2 + e] !== F && (m2 = i2.indexOf(F, z)), p2 = i2.indexOf(S, z), g2 = i2.indexOf(O, z);
|
|
10565
|
+
break;
|
|
10566
|
+
}
|
|
10567
|
+
y2 = v2(g2);
|
|
10568
|
+
if (i2.substring(m2 + 1 + y2, m2 + 1 + y2 + s2) === O) {
|
|
10569
|
+
if (d2.push(i2.substring(z, m2).replace(_2, F)), b2(m2 + 1 + y2 + s2), p2 = i2.indexOf(S, z), m2 = i2.indexOf(F, z), o2 && (R(), M))
|
|
10570
|
+
return w();
|
|
10571
|
+
if (A && h2.length >= A)
|
|
10572
|
+
return w(true);
|
|
10573
|
+
break;
|
|
10574
|
+
}
|
|
10575
|
+
u2.push({ type: "Quotes", code: "InvalidQuotes", message: "Trailing quote on quoted field is malformed", row: h2.length, index: z }), m2++;
|
|
10576
|
+
}
|
|
10577
|
+
}
|
|
10578
|
+
else if (x && d2.length === 0 && i2.substring(z, z + a2) === x) {
|
|
10579
|
+
if (g2 === -1)
|
|
10580
|
+
return w();
|
|
10581
|
+
z = g2 + s2, g2 = i2.indexOf(O, z), p2 = i2.indexOf(S, z);
|
|
10582
|
+
} else if (p2 !== -1 && (p2 < g2 || g2 === -1))
|
|
10583
|
+
d2.push(i2.substring(z, p2)), z = p2 + e, p2 = i2.indexOf(S, z);
|
|
10584
|
+
else {
|
|
10585
|
+
if (g2 === -1)
|
|
10586
|
+
break;
|
|
10587
|
+
if (d2.push(i2.substring(z, g2)), b2(g2 + s2), o2 && (R(), M))
|
|
10588
|
+
return w();
|
|
10589
|
+
if (A && h2.length >= A)
|
|
10590
|
+
return w(true);
|
|
10591
|
+
}
|
|
10592
|
+
return E2();
|
|
10593
|
+
function k(e2) {
|
|
10594
|
+
h2.push(e2), f2 = z;
|
|
10595
|
+
}
|
|
10596
|
+
function v2(e2) {
|
|
10597
|
+
var t2 = 0;
|
|
10598
|
+
return t2 = e2 !== -1 && (e2 = i2.substring(m2 + 1, e2)) && e2.trim() === "" ? e2.length : t2;
|
|
10599
|
+
}
|
|
10600
|
+
function E2(e2) {
|
|
10601
|
+
return r2 || (e2 === undefined && (e2 = i2.substring(z)), d2.push(e2), z = n2, k(d2), o2 && R()), w();
|
|
10602
|
+
}
|
|
10603
|
+
function b2(e2) {
|
|
10604
|
+
z = e2, k(d2), d2 = [], g2 = i2.indexOf(O, z);
|
|
10605
|
+
}
|
|
10606
|
+
function w(e2) {
|
|
10607
|
+
if (C.header && !t && h2.length && !L) {
|
|
10608
|
+
var s3 = h2[0], a3 = Object.create(null), o3 = new Set(s3);
|
|
10609
|
+
let n3 = false;
|
|
10610
|
+
for (let r3 = 0;r3 < s3.length; r3++) {
|
|
10611
|
+
let i3 = s3[r3];
|
|
10612
|
+
if (a3[i3 = U(C.transformHeader) ? C.transformHeader(i3, r3) : i3]) {
|
|
10613
|
+
let e3, t2 = a3[i3];
|
|
10614
|
+
for (;e3 = i3 + "_" + t2, t2++, o3.has(e3); )
|
|
10615
|
+
;
|
|
10616
|
+
o3.add(e3), s3[r3] = e3, a3[i3]++, n3 = true, (D = D === null ? {} : D)[e3] = i3;
|
|
10617
|
+
} else
|
|
10618
|
+
a3[i3] = 1, s3[r3] = i3;
|
|
10619
|
+
o3.add(i3);
|
|
10620
|
+
}
|
|
10621
|
+
n3 && console.warn("Duplicate headers found and renamed."), L = true;
|
|
10622
|
+
}
|
|
10623
|
+
return { data: h2, errors: u2, meta: { delimiter: S, linebreak: O, aborted: M, truncated: !!e2, cursor: f2 + (t || 0), renamedHeaders: D } };
|
|
10624
|
+
}
|
|
10625
|
+
function R() {
|
|
10626
|
+
I(w()), h2 = [], u2 = [];
|
|
10627
|
+
}
|
|
10628
|
+
}, this.abort = function() {
|
|
10629
|
+
M = true;
|
|
10630
|
+
}, this.getCharIndex = function() {
|
|
10631
|
+
return z;
|
|
10632
|
+
};
|
|
10633
|
+
}
|
|
10634
|
+
function g(e) {
|
|
10635
|
+
var t = e.data, i2 = o[t.workerId], r2 = false;
|
|
10636
|
+
if (t.error)
|
|
10637
|
+
i2.userError(t.error, t.file);
|
|
10638
|
+
else if (t.results && t.results.data) {
|
|
10639
|
+
var n2 = { abort: function() {
|
|
10640
|
+
r2 = true, _(t.workerId, { data: [], errors: [], meta: { aborted: true } });
|
|
10641
|
+
}, pause: m, resume: m };
|
|
10642
|
+
if (U(i2.userStep)) {
|
|
10643
|
+
for (var s2 = 0;s2 < t.results.data.length && (i2.userStep({ data: t.results.data[s2], errors: t.results.errors, meta: t.results.meta }, n2), !r2); s2++)
|
|
10644
|
+
;
|
|
10645
|
+
delete t.results;
|
|
10646
|
+
} else
|
|
10647
|
+
U(i2.userChunk) && (i2.userChunk(t.results, n2, t.file), delete t.results);
|
|
10648
|
+
}
|
|
10649
|
+
t.finished && !r2 && _(t.workerId, t.results);
|
|
10650
|
+
}
|
|
10651
|
+
function _(e, t) {
|
|
10652
|
+
var i2 = o[e];
|
|
10653
|
+
U(i2.userComplete) && i2.userComplete(t), i2.terminate(), delete o[e];
|
|
10654
|
+
}
|
|
10655
|
+
function m() {
|
|
10656
|
+
throw new Error("Not implemented.");
|
|
10657
|
+
}
|
|
10658
|
+
function b(e) {
|
|
10659
|
+
if (typeof e != "object" || e === null)
|
|
10660
|
+
return e;
|
|
10661
|
+
var t, i2 = Array.isArray(e) ? [] : {};
|
|
10662
|
+
for (t in e)
|
|
10663
|
+
i2[t] = b(e[t]);
|
|
10664
|
+
return i2;
|
|
10665
|
+
}
|
|
10666
|
+
function y(e, t) {
|
|
10667
|
+
return function() {
|
|
10668
|
+
e.apply(t, arguments);
|
|
10669
|
+
};
|
|
10670
|
+
}
|
|
10671
|
+
function U(e) {
|
|
10672
|
+
return typeof e == "function";
|
|
10673
|
+
}
|
|
10674
|
+
return v.parse = function(e, t) {
|
|
10675
|
+
var i2 = (t = t || {}).dynamicTyping || false;
|
|
10676
|
+
U(i2) && (t.dynamicTypingFunction = i2, i2 = {});
|
|
10677
|
+
if (t.dynamicTyping = i2, t.transform = !!U(t.transform) && t.transform, !t.worker || !v.WORKERS_SUPPORTED)
|
|
10678
|
+
return i2 = null, v.NODE_STREAM_INPUT, typeof e == "string" ? (e = ((e2) => e2.charCodeAt(0) !== 65279 ? e2 : e2.slice(1))(e), i2 = new (t.download ? f : c)(t)) : e.readable === true && U(e.read) && U(e.on) ? i2 = new p(t) : (n.File && e instanceof File || e instanceof Object) && (i2 = new l(t)), i2.stream(e);
|
|
10679
|
+
(i2 = (() => {
|
|
10680
|
+
var e2;
|
|
10681
|
+
return !!v.WORKERS_SUPPORTED && (e2 = (() => {
|
|
10682
|
+
var e3 = n.URL || n.webkitURL || null, t2 = r.toString();
|
|
10683
|
+
return v.BLOB_URL || (v.BLOB_URL = e3.createObjectURL(new Blob(["var global = (function() { if (typeof self !== 'undefined') { return self; } if (typeof window !== 'undefined') { return window; } if (typeof global !== 'undefined') { return global; } return {}; })(); global.IS_PAPA_WORKER=true; ", "(", t2, ")();"], { type: "text/javascript" })));
|
|
10684
|
+
})(), (e2 = new n.Worker(e2)).onmessage = g, e2.id = h++, o[e2.id] = e2);
|
|
10685
|
+
})()).userStep = t.step, i2.userChunk = t.chunk, i2.userComplete = t.complete, i2.userError = t.error, t.step = U(t.step), t.chunk = U(t.chunk), t.complete = U(t.complete), t.error = U(t.error), delete t.worker, i2.postMessage({ input: e, config: t, workerId: i2.id });
|
|
10686
|
+
}, v.unparse = function(e, t) {
|
|
10687
|
+
var n2 = false, _2 = true, m2 = ",", y2 = `\r
|
|
10688
|
+
`, s2 = '"', a2 = s2 + s2, i2 = false, r2 = null, o2 = false, h2 = ((() => {
|
|
10689
|
+
if (typeof t == "object") {
|
|
10690
|
+
if (typeof t.delimiter != "string" || v.BAD_DELIMITERS.filter(function(e2) {
|
|
10691
|
+
return t.delimiter.indexOf(e2) !== -1;
|
|
10692
|
+
}).length || (m2 = t.delimiter), typeof t.quotes != "boolean" && typeof t.quotes != "function" && !Array.isArray(t.quotes) || (n2 = t.quotes), typeof t.skipEmptyLines != "boolean" && typeof t.skipEmptyLines != "string" || (i2 = t.skipEmptyLines), typeof t.newline == "string" && (y2 = t.newline), typeof t.quoteChar == "string" && (s2 = t.quoteChar), typeof t.header == "boolean" && (_2 = t.header), Array.isArray(t.columns)) {
|
|
10693
|
+
if (t.columns.length === 0)
|
|
10694
|
+
throw new Error("Option columns is empty");
|
|
10695
|
+
r2 = t.columns;
|
|
10696
|
+
}
|
|
10697
|
+
t.escapeChar !== undefined && (a2 = t.escapeChar + s2), t.escapeFormulae instanceof RegExp ? o2 = t.escapeFormulae : typeof t.escapeFormulae == "boolean" && t.escapeFormulae && (o2 = /^[=+\-@\t\r].*$/);
|
|
10698
|
+
}
|
|
10699
|
+
})(), new RegExp(P(s2), "g"));
|
|
10700
|
+
typeof e == "string" && (e = JSON.parse(e));
|
|
10701
|
+
if (Array.isArray(e)) {
|
|
10702
|
+
if (!e.length || Array.isArray(e[0]))
|
|
10703
|
+
return u2(null, e, i2);
|
|
10704
|
+
if (typeof e[0] == "object")
|
|
10705
|
+
return u2(r2 || Object.keys(e[0]), e, i2);
|
|
10706
|
+
} else if (typeof e == "object")
|
|
10707
|
+
return typeof e.data == "string" && (e.data = JSON.parse(e.data)), Array.isArray(e.data) && (e.fields || (e.fields = e.meta && e.meta.fields || r2), e.fields || (e.fields = Array.isArray(e.data[0]) ? e.fields : typeof e.data[0] == "object" ? Object.keys(e.data[0]) : []), Array.isArray(e.data[0]) || typeof e.data[0] == "object" || (e.data = [e.data])), u2(e.fields || [], e.data || [], i2);
|
|
10708
|
+
throw new Error("Unable to serialize unrecognized input");
|
|
10709
|
+
function u2(e2, t2, i3) {
|
|
10710
|
+
var r3 = "", n3 = (typeof e2 == "string" && (e2 = JSON.parse(e2)), typeof t2 == "string" && (t2 = JSON.parse(t2)), Array.isArray(e2) && 0 < e2.length), s3 = !Array.isArray(t2[0]);
|
|
10711
|
+
if (n3 && _2) {
|
|
10712
|
+
for (var a3 = 0;a3 < e2.length; a3++)
|
|
10713
|
+
0 < a3 && (r3 += m2), r3 += k(e2[a3], a3);
|
|
10714
|
+
0 < t2.length && (r3 += y2);
|
|
10715
|
+
}
|
|
10716
|
+
for (var o3 = 0;o3 < t2.length; o3++) {
|
|
10717
|
+
var h3 = (n3 ? e2 : t2[o3]).length, u3 = false, d2 = n3 ? Object.keys(t2[o3]).length === 0 : t2[o3].length === 0;
|
|
10718
|
+
if (i3 && !n3 && (u3 = i3 === "greedy" ? t2[o3].join("").trim() === "" : t2[o3].length === 1 && t2[o3][0].length === 0), i3 === "greedy" && n3) {
|
|
10719
|
+
for (var f2 = [], l2 = 0;l2 < h3; l2++) {
|
|
10720
|
+
var c2 = s3 ? e2[l2] : l2;
|
|
10721
|
+
f2.push(t2[o3][c2]);
|
|
10722
|
+
}
|
|
10723
|
+
u3 = f2.join("").trim() === "";
|
|
10724
|
+
}
|
|
10725
|
+
if (!u3) {
|
|
10726
|
+
for (var p2 = 0;p2 < h3; p2++) {
|
|
10727
|
+
0 < p2 && !d2 && (r3 += m2);
|
|
10728
|
+
var g2 = n3 && s3 ? e2[p2] : p2;
|
|
10729
|
+
r3 += k(t2[o3][g2], p2);
|
|
10730
|
+
}
|
|
10731
|
+
o3 < t2.length - 1 && (!i3 || 0 < h3 && !d2) && (r3 += y2);
|
|
10732
|
+
}
|
|
10733
|
+
}
|
|
10734
|
+
return r3;
|
|
10735
|
+
}
|
|
10736
|
+
function k(e2, t2) {
|
|
10737
|
+
var i3, r3;
|
|
10738
|
+
return e2 == null ? "" : e2.constructor === Date ? JSON.stringify(e2).slice(1, 25) : (r3 = false, o2 && typeof e2 == "string" && o2.test(e2) && (e2 = "'" + e2, r3 = true), i3 = e2.toString().replace(h2, a2), (r3 = r3 || n2 === true || typeof n2 == "function" && n2(e2, t2) || Array.isArray(n2) && n2[t2] || ((e3, t3) => {
|
|
10739
|
+
for (var i4 = 0;i4 < t3.length; i4++)
|
|
10740
|
+
if (-1 < e3.indexOf(t3[i4]))
|
|
10741
|
+
return true;
|
|
10742
|
+
return false;
|
|
10743
|
+
})(i3, v.BAD_DELIMITERS) || -1 < i3.indexOf(m2) || i3.charAt(0) === " " || i3.charAt(i3.length - 1) === " ") ? s2 + i3 + s2 : i3);
|
|
10744
|
+
}
|
|
10745
|
+
}, v.RECORD_SEP = String.fromCharCode(30), v.UNIT_SEP = String.fromCharCode(31), v.BYTE_ORDER_MARK = "\uFEFF", v.BAD_DELIMITERS = ["\r", `
|
|
10746
|
+
`, '"', v.BYTE_ORDER_MARK], v.WORKERS_SUPPORTED = !s && !!n.Worker, v.NODE_STREAM_INPUT = 1, v.LocalChunkSize = 10485760, v.RemoteChunkSize = 5242880, v.DefaultDelimiter = ",", v.Parser = E, v.ParserHandle = i, v.NetworkStreamer = f, v.FileStreamer = l, v.StringStreamer = c, v.ReadableStreamStreamer = p, n.jQuery && ((d = n.jQuery).fn.parse = function(o2) {
|
|
10747
|
+
var i2 = o2.config || {}, h2 = [];
|
|
10748
|
+
return this.each(function(e2) {
|
|
10749
|
+
if (!(d(this).prop("tagName").toUpperCase() === "INPUT" && d(this).attr("type").toLowerCase() === "file" && n.FileReader) || !this.files || this.files.length === 0)
|
|
10750
|
+
return true;
|
|
10751
|
+
for (var t = 0;t < this.files.length; t++)
|
|
10752
|
+
h2.push({ file: this.files[t], inputElem: this, instanceConfig: d.extend({}, i2) });
|
|
10753
|
+
}), e(), this;
|
|
10754
|
+
function e() {
|
|
10755
|
+
if (h2.length === 0)
|
|
10756
|
+
U(o2.complete) && o2.complete();
|
|
10757
|
+
else {
|
|
10758
|
+
var e2, t, i3, r2, n2 = h2[0];
|
|
10759
|
+
if (U(o2.before)) {
|
|
10760
|
+
var s2 = o2.before(n2.file, n2.inputElem);
|
|
10761
|
+
if (typeof s2 == "object") {
|
|
10762
|
+
if (s2.action === "abort")
|
|
10763
|
+
return e2 = "AbortError", t = n2.file, i3 = n2.inputElem, r2 = s2.reason, void (U(o2.error) && o2.error({ name: e2 }, t, i3, r2));
|
|
10764
|
+
if (s2.action === "skip")
|
|
10765
|
+
return void u2();
|
|
10766
|
+
typeof s2.config == "object" && (n2.instanceConfig = d.extend(n2.instanceConfig, s2.config));
|
|
10767
|
+
} else if (s2 === "skip")
|
|
10768
|
+
return void u2();
|
|
10769
|
+
}
|
|
10770
|
+
var a2 = n2.instanceConfig.complete;
|
|
10771
|
+
n2.instanceConfig.complete = function(e3) {
|
|
10772
|
+
U(a2) && a2(e3, n2.file, n2.inputElem), u2();
|
|
10773
|
+
}, v.parse(n2.file, n2.instanceConfig);
|
|
10774
|
+
}
|
|
10775
|
+
}
|
|
10776
|
+
function u2() {
|
|
10777
|
+
h2.splice(0, 1), e();
|
|
10778
|
+
}
|
|
10779
|
+
}), a && (n.onmessage = function(e) {
|
|
10780
|
+
e = e.data;
|
|
10781
|
+
v.WORKER_ID === undefined && e && (v.WORKER_ID = e.workerId);
|
|
10782
|
+
typeof e.input == "string" ? n.postMessage({ workerId: v.WORKER_ID, results: v.parse(e.input, e.config), finished: true }) : (n.File && e.input instanceof File || e.input instanceof Object) && (e = v.parse(e.input, e.config)) && n.postMessage({ workerId: v.WORKER_ID, results: e, finished: true });
|
|
10783
|
+
}), (f.prototype = Object.create(u.prototype)).constructor = f, (l.prototype = Object.create(u.prototype)).constructor = l, (c.prototype = Object.create(c.prototype)).constructor = c, (p.prototype = Object.create(u.prototype)).constructor = p, v;
|
|
10784
|
+
});
|
|
10785
|
+
});
|
|
10786
|
+
|
|
10311
10787
|
// ../../node_modules/zod/v3/external.js
|
|
10312
10788
|
var exports_external = {};
|
|
10313
10789
|
__export(exports_external, {
|
|
@@ -18108,7 +18584,149 @@ var import_consola = __toESM(require_consola_browser(), 1);
|
|
|
18108
18584
|
var import_classnames = __toESM(require_classnames(), 1);
|
|
18109
18585
|
var import_localforage = __toESM(require_localforage(), 1);
|
|
18110
18586
|
var import_copy_to_clipboard = __toESM(require_copy_to_clipboard(), 1);
|
|
18111
|
-
|
|
18587
|
+
|
|
18588
|
+
// ../../node_modules/pretty-bytes/index.js
|
|
18589
|
+
var BYTE_UNITS = [
|
|
18590
|
+
"B",
|
|
18591
|
+
"kB",
|
|
18592
|
+
"MB",
|
|
18593
|
+
"GB",
|
|
18594
|
+
"TB",
|
|
18595
|
+
"PB",
|
|
18596
|
+
"EB",
|
|
18597
|
+
"ZB",
|
|
18598
|
+
"YB"
|
|
18599
|
+
];
|
|
18600
|
+
var BIBYTE_UNITS = [
|
|
18601
|
+
"B",
|
|
18602
|
+
"KiB",
|
|
18603
|
+
"MiB",
|
|
18604
|
+
"GiB",
|
|
18605
|
+
"TiB",
|
|
18606
|
+
"PiB",
|
|
18607
|
+
"EiB",
|
|
18608
|
+
"ZiB",
|
|
18609
|
+
"YiB"
|
|
18610
|
+
];
|
|
18611
|
+
var BIT_UNITS = [
|
|
18612
|
+
"b",
|
|
18613
|
+
"kbit",
|
|
18614
|
+
"Mbit",
|
|
18615
|
+
"Gbit",
|
|
18616
|
+
"Tbit",
|
|
18617
|
+
"Pbit",
|
|
18618
|
+
"Ebit",
|
|
18619
|
+
"Zbit",
|
|
18620
|
+
"Ybit"
|
|
18621
|
+
];
|
|
18622
|
+
var BIBIT_UNITS = [
|
|
18623
|
+
"b",
|
|
18624
|
+
"kibit",
|
|
18625
|
+
"Mibit",
|
|
18626
|
+
"Gibit",
|
|
18627
|
+
"Tibit",
|
|
18628
|
+
"Pibit",
|
|
18629
|
+
"Eibit",
|
|
18630
|
+
"Zibit",
|
|
18631
|
+
"Yibit"
|
|
18632
|
+
];
|
|
18633
|
+
var toLocaleString = (number, locale, options) => {
|
|
18634
|
+
let result = number;
|
|
18635
|
+
if (typeof locale === "string" || Array.isArray(locale)) {
|
|
18636
|
+
result = number.toLocaleString(locale, options);
|
|
18637
|
+
} else if (locale === true || options !== undefined) {
|
|
18638
|
+
result = number.toLocaleString(undefined, options);
|
|
18639
|
+
}
|
|
18640
|
+
return result;
|
|
18641
|
+
};
|
|
18642
|
+
var log10 = (numberOrBigInt) => {
|
|
18643
|
+
if (typeof numberOrBigInt === "number") {
|
|
18644
|
+
return Math.log10(numberOrBigInt);
|
|
18645
|
+
}
|
|
18646
|
+
const string = numberOrBigInt.toString(10);
|
|
18647
|
+
return string.length + Math.log10(`0.${string.slice(0, 15)}`);
|
|
18648
|
+
};
|
|
18649
|
+
var log = (numberOrBigInt) => {
|
|
18650
|
+
if (typeof numberOrBigInt === "number") {
|
|
18651
|
+
return Math.log(numberOrBigInt);
|
|
18652
|
+
}
|
|
18653
|
+
return log10(numberOrBigInt) * Math.log(10);
|
|
18654
|
+
};
|
|
18655
|
+
var divide = (numberOrBigInt, divisor) => {
|
|
18656
|
+
if (typeof numberOrBigInt === "number") {
|
|
18657
|
+
return numberOrBigInt / divisor;
|
|
18658
|
+
}
|
|
18659
|
+
const integerPart = numberOrBigInt / BigInt(divisor);
|
|
18660
|
+
const remainder = numberOrBigInt % BigInt(divisor);
|
|
18661
|
+
return Number(integerPart) + Number(remainder) / divisor;
|
|
18662
|
+
};
|
|
18663
|
+
var applyFixedWidth = (result, fixedWidth) => {
|
|
18664
|
+
if (fixedWidth === undefined) {
|
|
18665
|
+
return result;
|
|
18666
|
+
}
|
|
18667
|
+
if (typeof fixedWidth !== "number" || !Number.isSafeInteger(fixedWidth) || fixedWidth < 0) {
|
|
18668
|
+
throw new TypeError(`Expected fixedWidth to be a non-negative integer, got ${typeof fixedWidth}: ${fixedWidth}`);
|
|
18669
|
+
}
|
|
18670
|
+
if (fixedWidth === 0) {
|
|
18671
|
+
return result;
|
|
18672
|
+
}
|
|
18673
|
+
return result.length < fixedWidth ? result.padStart(fixedWidth, " ") : result;
|
|
18674
|
+
};
|
|
18675
|
+
var buildLocaleOptions = (options) => {
|
|
18676
|
+
const { minimumFractionDigits, maximumFractionDigits } = options;
|
|
18677
|
+
if (minimumFractionDigits === undefined && maximumFractionDigits === undefined) {
|
|
18678
|
+
return;
|
|
18679
|
+
}
|
|
18680
|
+
return {
|
|
18681
|
+
...minimumFractionDigits !== undefined && { minimumFractionDigits },
|
|
18682
|
+
...maximumFractionDigits !== undefined && { maximumFractionDigits },
|
|
18683
|
+
roundingMode: "trunc"
|
|
18684
|
+
};
|
|
18685
|
+
};
|
|
18686
|
+
function prettyBytes(number, options) {
|
|
18687
|
+
if (typeof number !== "bigint" && !Number.isFinite(number)) {
|
|
18688
|
+
throw new TypeError(`Expected a finite number, got ${typeof number}: ${number}`);
|
|
18689
|
+
}
|
|
18690
|
+
options = {
|
|
18691
|
+
bits: false,
|
|
18692
|
+
binary: false,
|
|
18693
|
+
space: true,
|
|
18694
|
+
nonBreakingSpace: false,
|
|
18695
|
+
...options
|
|
18696
|
+
};
|
|
18697
|
+
const UNITS = options.bits ? options.binary ? BIBIT_UNITS : BIT_UNITS : options.binary ? BIBYTE_UNITS : BYTE_UNITS;
|
|
18698
|
+
const separator = options.space ? options.nonBreakingSpace ? " " : " " : "";
|
|
18699
|
+
const isZero = typeof number === "number" ? number === 0 : number === 0n;
|
|
18700
|
+
if (options.signed && isZero) {
|
|
18701
|
+
const result2 = ` 0${separator}${UNITS[0]}`;
|
|
18702
|
+
return applyFixedWidth(result2, options.fixedWidth);
|
|
18703
|
+
}
|
|
18704
|
+
const isNegative = number < 0;
|
|
18705
|
+
const prefix = isNegative ? "-" : options.signed ? "+" : "";
|
|
18706
|
+
if (isNegative) {
|
|
18707
|
+
number = -number;
|
|
18708
|
+
}
|
|
18709
|
+
const localeOptions = buildLocaleOptions(options);
|
|
18710
|
+
let result;
|
|
18711
|
+
if (number < 1) {
|
|
18712
|
+
const numberString = toLocaleString(number, options.locale, localeOptions);
|
|
18713
|
+
result = prefix + numberString + separator + UNITS[0];
|
|
18714
|
+
} else {
|
|
18715
|
+
const exponent = Math.min(Math.floor(options.binary ? log(number) / Math.log(1024) : log10(number) / 3), UNITS.length - 1);
|
|
18716
|
+
number = divide(number, (options.binary ? 1024 : 1000) ** exponent);
|
|
18717
|
+
if (!localeOptions) {
|
|
18718
|
+
const minPrecision = Math.max(3, Math.floor(number).toString().length);
|
|
18719
|
+
number = number.toPrecision(minPrecision);
|
|
18720
|
+
}
|
|
18721
|
+
const numberString = toLocaleString(Number(number), options.locale, localeOptions);
|
|
18722
|
+
const unit = UNITS[exponent];
|
|
18723
|
+
result = prefix + numberString + separator + unit;
|
|
18724
|
+
}
|
|
18725
|
+
return applyFixedWidth(result, options.fixedWidth);
|
|
18726
|
+
}
|
|
18727
|
+
|
|
18728
|
+
// src/web.ts
|
|
18729
|
+
var import_lodash = __toESM(require_lodash(), 1);
|
|
18112
18730
|
|
|
18113
18731
|
// src/common/ai/index.ts
|
|
18114
18732
|
var exports_ai = {};
|
|
@@ -19548,16 +20166,6 @@ var getStrLength = (value) => {
|
|
|
19548
20166
|
const chineseLength = getChineseByStr(value).length;
|
|
19549
20167
|
return value.length - chineseLength + chineseLength * 2;
|
|
19550
20168
|
};
|
|
19551
|
-
var replaceAll = (str, searchValue, replaceValue) => {
|
|
19552
|
-
if (!str || !searchValue || !replaceValue) {
|
|
19553
|
-
return str || "";
|
|
19554
|
-
}
|
|
19555
|
-
str = str.replace(searchValue, replaceValue);
|
|
19556
|
-
if (!str.includes(searchValue)) {
|
|
19557
|
-
return str;
|
|
19558
|
-
}
|
|
19559
|
-
return replaceAll(str, searchValue, replaceValue);
|
|
19560
|
-
};
|
|
19561
20169
|
var replaceByRules = (str, rules) => {
|
|
19562
20170
|
rules.forEach(([searchValue, replaceValue]) => {
|
|
19563
20171
|
str = str.replaceAll(searchValue, replaceValue);
|
|
@@ -19576,67 +20184,46 @@ var replaceByVariables = (prompt, variables) => {
|
|
|
19576
20184
|
var getType = (value) => {
|
|
19577
20185
|
return Object.prototype.toString.call(value).slice(8, -1);
|
|
19578
20186
|
};
|
|
19579
|
-
var
|
|
19580
|
-
|
|
19581
|
-
|
|
19582
|
-
};
|
|
19583
|
-
var jsonParse = (value) => {
|
|
19584
|
-
if (typeof value === "object") {
|
|
19585
|
-
return value;
|
|
20187
|
+
var safeJsonParse = (value, fallback) => {
|
|
20188
|
+
if (typeof value !== "string") {
|
|
20189
|
+
return value ?? fallback;
|
|
19586
20190
|
}
|
|
19587
20191
|
try {
|
|
19588
20192
|
return JSON.parse(value);
|
|
19589
|
-
} catch
|
|
19590
|
-
return
|
|
20193
|
+
} catch {
|
|
20194
|
+
return fallback;
|
|
19591
20195
|
}
|
|
19592
20196
|
};
|
|
19593
|
-
var
|
|
20197
|
+
var isJsonObject = (str) => {
|
|
19594
20198
|
try {
|
|
19595
|
-
|
|
19596
|
-
|
|
19597
|
-
|
|
19598
|
-
|
|
19599
|
-
|
|
19600
|
-
};
|
|
19601
|
-
var toString3 = (value) => {
|
|
19602
|
-
return Object.prototype.toString.call(value).slice(8, -1) === "object" ? JSON.stringify(value) : String(value);
|
|
20199
|
+
const val = JSON.parse(str);
|
|
20200
|
+
return typeof val === "object" && val !== null && !Array.isArray(val);
|
|
20201
|
+
} catch {
|
|
20202
|
+
return false;
|
|
20203
|
+
}
|
|
19603
20204
|
};
|
|
19604
20205
|
var getRandomColor = () => {
|
|
19605
|
-
const
|
|
19606
|
-
|
|
19607
|
-
return color;
|
|
19608
|
-
} else {
|
|
19609
|
-
return getRandomColor();
|
|
19610
|
-
}
|
|
20206
|
+
const rand = () => Math.floor(Math.random() * 156 + 50);
|
|
20207
|
+
return `rgb(${rand()},${rand()},${rand()})`;
|
|
19611
20208
|
};
|
|
19612
|
-
var
|
|
19613
|
-
|
|
20209
|
+
var hexToRgba2 = (hexColor, a = 1) => {
|
|
20210
|
+
let red = parseInt(hexColor.substr(1, 2), 16);
|
|
20211
|
+
let green = parseInt(hexColor.substr(3, 2), 16);
|
|
20212
|
+
let blue = parseInt(hexColor.substr(5, 2), 16);
|
|
20213
|
+
return {
|
|
20214
|
+
nums: { red, green, blue },
|
|
20215
|
+
text: `rgba(${red}, ${green}, ${blue}, ${a})`
|
|
20216
|
+
};
|
|
19614
20217
|
};
|
|
19615
|
-
var
|
|
19616
|
-
|
|
19617
|
-
return "";
|
|
19618
|
-
}
|
|
19619
|
-
const res = str.match(/[\u4e00-\u9fa5]/g);
|
|
19620
|
-
if (!res) {
|
|
19621
|
-
return "";
|
|
19622
|
-
}
|
|
19623
|
-
return res.join("");
|
|
20218
|
+
var getRandomString = (length = 4) => {
|
|
20219
|
+
return Math.random().toString(36).substring(2, 2 + length);
|
|
19624
20220
|
};
|
|
19625
20221
|
var getSliceStr = (str, before, after) => {
|
|
19626
|
-
|
|
19627
|
-
|
|
19628
|
-
|
|
19629
|
-
|
|
19630
|
-
return
|
|
19631
|
-
};
|
|
19632
|
-
var getLength = (value) => {
|
|
19633
|
-
const chineseLength = getChinese(value).length;
|
|
19634
|
-
return value.length - chineseLength + chineseLength * 2;
|
|
19635
|
-
};
|
|
19636
|
-
var getCookie = (name) => {
|
|
19637
|
-
const reg = new RegExp(`(^| )${name}=([^;]*)(;|$)`);
|
|
19638
|
-
const arr = document.cookie.match(reg);
|
|
19639
|
-
return arr ? unescape(arr[2]) : null;
|
|
20222
|
+
const start = str.indexOf(before);
|
|
20223
|
+
const end = str.indexOf(after, start + before.length);
|
|
20224
|
+
if (start === -1 || end === -1)
|
|
20225
|
+
return "";
|
|
20226
|
+
return str.slice(start + before.length, end);
|
|
19640
20227
|
};
|
|
19641
20228
|
var generateAlphabetArray = (n) => {
|
|
19642
20229
|
return Array.from({ length: n }, (_, i) => String.fromCharCode(97 + i));
|
|
@@ -19660,2553 +20247,126 @@ var levenshteinDistance = (a, b) => {
|
|
|
19660
20247
|
}
|
|
19661
20248
|
return matrix[b.length][a.length];
|
|
19662
20249
|
};
|
|
19663
|
-
|
|
19664
|
-
|
|
19665
|
-
|
|
19666
|
-
|
|
19667
|
-
|
|
19668
|
-
|
|
19669
|
-
|
|
20250
|
+
|
|
20251
|
+
// src/common/base/array.ts
|
|
20252
|
+
var removeSimilarDuplicates = (arr, threshold, isLog) => {
|
|
20253
|
+
const uniqueArray = [];
|
|
20254
|
+
const similarPairs = [];
|
|
20255
|
+
for (const str of arr) {
|
|
20256
|
+
const isSimilar = uniqueArray.some((uniqueStr) => {
|
|
20257
|
+
const distance = levenshteinDistance(str, uniqueStr);
|
|
20258
|
+
if (distance <= threshold) {
|
|
20259
|
+
similarPairs.push([str, uniqueStr]);
|
|
20260
|
+
return true;
|
|
20261
|
+
}
|
|
20262
|
+
return false;
|
|
20263
|
+
});
|
|
20264
|
+
if (!isSimilar) {
|
|
20265
|
+
uniqueArray.push(str);
|
|
20266
|
+
}
|
|
20267
|
+
}
|
|
20268
|
+
if (isLog) {
|
|
20269
|
+
if (similarPairs.length > 0) {
|
|
20270
|
+
similarPairs.forEach((pair) => {
|
|
20271
|
+
console.log(pair[0]);
|
|
20272
|
+
console.log(pair[1]);
|
|
20273
|
+
console.log();
|
|
20274
|
+
});
|
|
19670
20275
|
} else {
|
|
19671
|
-
|
|
20276
|
+
console.log("没有找到类似的字符串");
|
|
19672
20277
|
}
|
|
19673
20278
|
}
|
|
19674
|
-
|
|
20279
|
+
return uniqueArray;
|
|
19675
20280
|
};
|
|
19676
20281
|
|
|
19677
|
-
//
|
|
19678
|
-
|
|
19679
|
-
|
|
19680
|
-
|
|
19681
|
-
|
|
19682
|
-
|
|
19683
|
-
|
|
19684
|
-
*/
|
|
19685
|
-
var EXP_LIMIT = 9000000000000000;
|
|
19686
|
-
var MAX_DIGITS = 1e9;
|
|
19687
|
-
var NUMERALS = "0123456789abcdef";
|
|
19688
|
-
var LN10 = "2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058";
|
|
19689
|
-
var PI = "3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789";
|
|
19690
|
-
var DEFAULTS = {
|
|
19691
|
-
precision: 20,
|
|
19692
|
-
rounding: 4,
|
|
19693
|
-
modulo: 1,
|
|
19694
|
-
toExpNeg: -7,
|
|
19695
|
-
toExpPos: 21,
|
|
19696
|
-
minE: -EXP_LIMIT,
|
|
19697
|
-
maxE: EXP_LIMIT,
|
|
19698
|
-
crypto: false
|
|
19699
|
-
};
|
|
19700
|
-
var inexact;
|
|
19701
|
-
var quadrant;
|
|
19702
|
-
var external2 = true;
|
|
19703
|
-
var decimalError = "[DecimalError] ";
|
|
19704
|
-
var invalidArgument = decimalError + "Invalid argument: ";
|
|
19705
|
-
var precisionLimitExceeded = decimalError + "Precision limit exceeded";
|
|
19706
|
-
var cryptoUnavailable = decimalError + "crypto unavailable";
|
|
19707
|
-
var tag = "[object Decimal]";
|
|
19708
|
-
var mathfloor = Math.floor;
|
|
19709
|
-
var mathpow = Math.pow;
|
|
19710
|
-
var isBinary = /^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i;
|
|
19711
|
-
var isHex = /^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i;
|
|
19712
|
-
var isOctal = /^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i;
|
|
19713
|
-
var isDecimal = /^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;
|
|
19714
|
-
var BASE = 1e7;
|
|
19715
|
-
var LOG_BASE = 7;
|
|
19716
|
-
var MAX_SAFE_INTEGER = 9007199254740991;
|
|
19717
|
-
var LN10_PRECISION = LN10.length - 1;
|
|
19718
|
-
var PI_PRECISION = PI.length - 1;
|
|
19719
|
-
var P = { toStringTag: tag };
|
|
19720
|
-
P.absoluteValue = P.abs = function() {
|
|
19721
|
-
var x = new this.constructor(this);
|
|
19722
|
-
if (x.s < 0)
|
|
19723
|
-
x.s = 1;
|
|
19724
|
-
return finalise(x);
|
|
19725
|
-
};
|
|
19726
|
-
P.ceil = function() {
|
|
19727
|
-
return finalise(new this.constructor(this), this.e + 1, 2);
|
|
19728
|
-
};
|
|
19729
|
-
P.clampedTo = P.clamp = function(min, max) {
|
|
19730
|
-
var k, x = this, Ctor = x.constructor;
|
|
19731
|
-
min = new Ctor(min);
|
|
19732
|
-
max = new Ctor(max);
|
|
19733
|
-
if (!min.s || !max.s)
|
|
19734
|
-
return new Ctor(NaN);
|
|
19735
|
-
if (min.gt(max))
|
|
19736
|
-
throw Error(invalidArgument + max);
|
|
19737
|
-
k = x.cmp(min);
|
|
19738
|
-
return k < 0 ? min : x.cmp(max) > 0 ? max : new Ctor(x);
|
|
19739
|
-
};
|
|
19740
|
-
P.comparedTo = P.cmp = function(y) {
|
|
19741
|
-
var i, j, xdL, ydL, x = this, xd = x.d, yd = (y = new x.constructor(y)).d, xs = x.s, ys = y.s;
|
|
19742
|
-
if (!xd || !yd) {
|
|
19743
|
-
return !xs || !ys ? NaN : xs !== ys ? xs : xd === yd ? 0 : !xd ^ xs < 0 ? 1 : -1;
|
|
19744
|
-
}
|
|
19745
|
-
if (!xd[0] || !yd[0])
|
|
19746
|
-
return xd[0] ? xs : yd[0] ? -ys : 0;
|
|
19747
|
-
if (xs !== ys)
|
|
19748
|
-
return xs;
|
|
19749
|
-
if (x.e !== y.e)
|
|
19750
|
-
return x.e > y.e ^ xs < 0 ? 1 : -1;
|
|
19751
|
-
xdL = xd.length;
|
|
19752
|
-
ydL = yd.length;
|
|
19753
|
-
for (i = 0, j = xdL < ydL ? xdL : ydL;i < j; ++i) {
|
|
19754
|
-
if (xd[i] !== yd[i])
|
|
19755
|
-
return xd[i] > yd[i] ^ xs < 0 ? 1 : -1;
|
|
19756
|
-
}
|
|
19757
|
-
return xdL === ydL ? 0 : xdL > ydL ^ xs < 0 ? 1 : -1;
|
|
19758
|
-
};
|
|
19759
|
-
P.cosine = P.cos = function() {
|
|
19760
|
-
var pr, rm, x = this, Ctor = x.constructor;
|
|
19761
|
-
if (!x.d)
|
|
19762
|
-
return new Ctor(NaN);
|
|
19763
|
-
if (!x.d[0])
|
|
19764
|
-
return new Ctor(1);
|
|
19765
|
-
pr = Ctor.precision;
|
|
19766
|
-
rm = Ctor.rounding;
|
|
19767
|
-
Ctor.precision = pr + Math.max(x.e, x.sd()) + LOG_BASE;
|
|
19768
|
-
Ctor.rounding = 1;
|
|
19769
|
-
x = cosine(Ctor, toLessThanHalfPi(Ctor, x));
|
|
19770
|
-
Ctor.precision = pr;
|
|
19771
|
-
Ctor.rounding = rm;
|
|
19772
|
-
return finalise(quadrant == 2 || quadrant == 3 ? x.neg() : x, pr, rm, true);
|
|
19773
|
-
};
|
|
19774
|
-
P.cubeRoot = P.cbrt = function() {
|
|
19775
|
-
var e, m, n, r, rep, s, sd, t, t3, t3plusx, x = this, Ctor = x.constructor;
|
|
19776
|
-
if (!x.isFinite() || x.isZero())
|
|
19777
|
-
return new Ctor(x);
|
|
19778
|
-
external2 = false;
|
|
19779
|
-
s = x.s * mathpow(x.s * x, 1 / 3);
|
|
19780
|
-
if (!s || Math.abs(s) == 1 / 0) {
|
|
19781
|
-
n = digitsToString(x.d);
|
|
19782
|
-
e = x.e;
|
|
19783
|
-
if (s = (e - n.length + 1) % 3)
|
|
19784
|
-
n += s == 1 || s == -2 ? "0" : "00";
|
|
19785
|
-
s = mathpow(n, 1 / 3);
|
|
19786
|
-
e = mathfloor((e + 1) / 3) - (e % 3 == (e < 0 ? -1 : 2));
|
|
19787
|
-
if (s == 1 / 0) {
|
|
19788
|
-
n = "5e" + e;
|
|
19789
|
-
} else {
|
|
19790
|
-
n = s.toExponential();
|
|
19791
|
-
n = n.slice(0, n.indexOf("e") + 1) + e;
|
|
20282
|
+
// src/common/base/object.ts
|
|
20283
|
+
var findAttr = (data, target, path = "data") => {
|
|
20284
|
+
if (Array.isArray(data)) {
|
|
20285
|
+
for (let i = 0;i < data.length; i++) {
|
|
20286
|
+
const res = findAttr(data[i], target, `${path}[${i}]`);
|
|
20287
|
+
if (res)
|
|
20288
|
+
return res;
|
|
19792
20289
|
}
|
|
19793
|
-
|
|
19794
|
-
|
|
19795
|
-
|
|
19796
|
-
|
|
19797
|
-
|
|
19798
|
-
|
|
19799
|
-
|
|
19800
|
-
|
|
19801
|
-
t3 = t.times(t).times(t);
|
|
19802
|
-
t3plusx = t3.plus(x);
|
|
19803
|
-
r = divide(t3plusx.plus(x).times(t), t3plusx.plus(t3), sd + 2, 1);
|
|
19804
|
-
if (digitsToString(t.d).slice(0, sd) === (n = digitsToString(r.d)).slice(0, sd)) {
|
|
19805
|
-
n = n.slice(sd - 3, sd + 1);
|
|
19806
|
-
if (n == "9999" || !rep && n == "4999") {
|
|
19807
|
-
if (!rep) {
|
|
19808
|
-
finalise(t, e + 1, 0);
|
|
19809
|
-
if (t.times(t).times(t).eq(x)) {
|
|
19810
|
-
r = t;
|
|
19811
|
-
break;
|
|
19812
|
-
}
|
|
19813
|
-
}
|
|
19814
|
-
sd += 4;
|
|
19815
|
-
rep = 1;
|
|
19816
|
-
} else {
|
|
19817
|
-
if (!+n || !+n.slice(1) && n.charAt(0) == "5") {
|
|
19818
|
-
finalise(r, e + 1, 1);
|
|
19819
|
-
m = !r.times(r).times(r).eq(x);
|
|
19820
|
-
}
|
|
19821
|
-
break;
|
|
19822
|
-
}
|
|
20290
|
+
}
|
|
20291
|
+
if (data && typeof data === "object") {
|
|
20292
|
+
if (target in data)
|
|
20293
|
+
return `${path}.${target}`;
|
|
20294
|
+
for (const key2 in data) {
|
|
20295
|
+
const res = findAttr(data[key2], target, `${path}.${key2}`);
|
|
20296
|
+
if (res)
|
|
20297
|
+
return res;
|
|
19823
20298
|
}
|
|
19824
20299
|
}
|
|
19825
|
-
|
|
19826
|
-
return finalise(r, e, Ctor.rounding, m);
|
|
19827
|
-
};
|
|
19828
|
-
P.decimalPlaces = P.dp = function() {
|
|
19829
|
-
var w, d = this.d, n = NaN;
|
|
19830
|
-
if (d) {
|
|
19831
|
-
w = d.length - 1;
|
|
19832
|
-
n = (w - mathfloor(this.e / LOG_BASE)) * LOG_BASE;
|
|
19833
|
-
w = d[w];
|
|
19834
|
-
if (w)
|
|
19835
|
-
for (;w % 10 == 0; w /= 10)
|
|
19836
|
-
n--;
|
|
19837
|
-
if (n < 0)
|
|
19838
|
-
n = 0;
|
|
19839
|
-
}
|
|
19840
|
-
return n;
|
|
19841
|
-
};
|
|
19842
|
-
P.dividedBy = P.div = function(y) {
|
|
19843
|
-
return divide(this, new this.constructor(y));
|
|
19844
|
-
};
|
|
19845
|
-
P.dividedToIntegerBy = P.divToInt = function(y) {
|
|
19846
|
-
var x = this, Ctor = x.constructor;
|
|
19847
|
-
return finalise(divide(x, new Ctor(y), 0, 1, 1), Ctor.precision, Ctor.rounding);
|
|
19848
|
-
};
|
|
19849
|
-
P.equals = P.eq = function(y) {
|
|
19850
|
-
return this.cmp(y) === 0;
|
|
20300
|
+
return null;
|
|
19851
20301
|
};
|
|
19852
|
-
|
|
19853
|
-
|
|
20302
|
+
var filterParams = (params, deep = false) => {
|
|
20303
|
+
const clean = (value) => {
|
|
20304
|
+
if (value === undefined || value === null) {
|
|
20305
|
+
return;
|
|
20306
|
+
}
|
|
20307
|
+
if (!deep) {
|
|
20308
|
+
return value;
|
|
20309
|
+
}
|
|
20310
|
+
if (Array.isArray(value)) {
|
|
20311
|
+
return value.map((v) => clean(v)).filter((v) => v !== undefined);
|
|
20312
|
+
}
|
|
20313
|
+
if (typeof value === "object") {
|
|
20314
|
+
return Object.entries(value).reduce((acc, [k, v]) => {
|
|
20315
|
+
const cleaned = clean(v);
|
|
20316
|
+
if (cleaned !== undefined)
|
|
20317
|
+
acc[k] = cleaned;
|
|
20318
|
+
return acc;
|
|
20319
|
+
}, {});
|
|
20320
|
+
}
|
|
20321
|
+
return value;
|
|
20322
|
+
};
|
|
20323
|
+
return clean(params);
|
|
19854
20324
|
};
|
|
19855
|
-
|
|
19856
|
-
|
|
20325
|
+
|
|
20326
|
+
// src/common/base/other.ts
|
|
20327
|
+
var delay = (time = 1000) => {
|
|
20328
|
+
return new Promise((resolve2) => setTimeout(resolve2, time));
|
|
19857
20329
|
};
|
|
19858
|
-
|
|
19859
|
-
|
|
19860
|
-
|
|
20330
|
+
var calcJsText = (expr, context) => {
|
|
20331
|
+
const keys = Object.keys(context);
|
|
20332
|
+
const values = keys.map((key2) => context[key2]);
|
|
20333
|
+
return Function(...keys, `return (${expr})`)(...values);
|
|
19861
20334
|
};
|
|
19862
|
-
|
|
19863
|
-
|
|
19864
|
-
|
|
19865
|
-
|
|
19866
|
-
|
|
19867
|
-
|
|
19868
|
-
|
|
19869
|
-
|
|
19870
|
-
|
|
19871
|
-
Ctor.rounding = 1;
|
|
19872
|
-
len = x.d.length;
|
|
19873
|
-
if (len < 32) {
|
|
19874
|
-
k = Math.ceil(len / 3);
|
|
19875
|
-
n = (1 / tinyPow(4, k)).toString();
|
|
19876
|
-
} else {
|
|
19877
|
-
k = 16;
|
|
19878
|
-
n = "2.3283064365386962890625e-10";
|
|
20335
|
+
var logNetwork = (type, path, params, response) => {
|
|
20336
|
+
const styles = {
|
|
20337
|
+
header: "color: #fff; background: #35495e; padding: 2px 8px; border-radius: 3px 0 0 3px;",
|
|
20338
|
+
value: "color: #35495e; background: #f0f4f8; padding: 2px 6px; border-radius: 0 3px 3px 0;",
|
|
20339
|
+
separator: "color: #409EFF; margin: 0 4px;"
|
|
20340
|
+
};
|
|
20341
|
+
console.groupCollapsed(`666 %c${type}%c${path}`, styles.header, styles.value);
|
|
20342
|
+
if (params) {
|
|
20343
|
+
console.table(params);
|
|
19879
20344
|
}
|
|
19880
|
-
|
|
19881
|
-
|
|
19882
|
-
for (;i--; ) {
|
|
19883
|
-
cosh2_x = x.times(x);
|
|
19884
|
-
x = one.minus(cosh2_x.times(d8.minus(cosh2_x.times(d8))));
|
|
20345
|
+
if (response) {
|
|
20346
|
+
console.table(response);
|
|
19885
20347
|
}
|
|
19886
|
-
|
|
19887
|
-
};
|
|
19888
|
-
P.hyperbolicSine = P.sinh = function() {
|
|
19889
|
-
var k, pr, rm, len, x = this, Ctor = x.constructor;
|
|
19890
|
-
if (!x.isFinite() || x.isZero())
|
|
19891
|
-
return new Ctor(x);
|
|
19892
|
-
pr = Ctor.precision;
|
|
19893
|
-
rm = Ctor.rounding;
|
|
19894
|
-
Ctor.precision = pr + Math.max(x.e, x.sd()) + 4;
|
|
19895
|
-
Ctor.rounding = 1;
|
|
19896
|
-
len = x.d.length;
|
|
19897
|
-
if (len < 3) {
|
|
19898
|
-
x = taylorSeries(Ctor, 2, x, x, true);
|
|
19899
|
-
} else {
|
|
19900
|
-
k = 1.4 * Math.sqrt(len);
|
|
19901
|
-
k = k > 16 ? 16 : k | 0;
|
|
19902
|
-
x = x.times(1 / tinyPow(5, k));
|
|
19903
|
-
x = taylorSeries(Ctor, 2, x, x, true);
|
|
19904
|
-
var sinh2_x, d5 = new Ctor(5), d16 = new Ctor(16), d20 = new Ctor(20);
|
|
19905
|
-
for (;k--; ) {
|
|
19906
|
-
sinh2_x = x.times(x);
|
|
19907
|
-
x = x.times(d5.plus(sinh2_x.times(d16.times(sinh2_x).plus(d20))));
|
|
19908
|
-
}
|
|
19909
|
-
}
|
|
19910
|
-
Ctor.precision = pr;
|
|
19911
|
-
Ctor.rounding = rm;
|
|
19912
|
-
return finalise(x, pr, rm, true);
|
|
19913
|
-
};
|
|
19914
|
-
P.hyperbolicTangent = P.tanh = function() {
|
|
19915
|
-
var pr, rm, x = this, Ctor = x.constructor;
|
|
19916
|
-
if (!x.isFinite())
|
|
19917
|
-
return new Ctor(x.s);
|
|
19918
|
-
if (x.isZero())
|
|
19919
|
-
return new Ctor(x);
|
|
19920
|
-
pr = Ctor.precision;
|
|
19921
|
-
rm = Ctor.rounding;
|
|
19922
|
-
Ctor.precision = pr + 7;
|
|
19923
|
-
Ctor.rounding = 1;
|
|
19924
|
-
return divide(x.sinh(), x.cosh(), Ctor.precision = pr, Ctor.rounding = rm);
|
|
19925
|
-
};
|
|
19926
|
-
P.inverseCosine = P.acos = function() {
|
|
19927
|
-
var x = this, Ctor = x.constructor, k = x.abs().cmp(1), pr = Ctor.precision, rm = Ctor.rounding;
|
|
19928
|
-
if (k !== -1) {
|
|
19929
|
-
return k === 0 ? x.isNeg() ? getPi(Ctor, pr, rm) : new Ctor(0) : new Ctor(NaN);
|
|
19930
|
-
}
|
|
19931
|
-
if (x.isZero())
|
|
19932
|
-
return getPi(Ctor, pr + 4, rm).times(0.5);
|
|
19933
|
-
Ctor.precision = pr + 6;
|
|
19934
|
-
Ctor.rounding = 1;
|
|
19935
|
-
x = new Ctor(1).minus(x).div(x.plus(1)).sqrt().atan();
|
|
19936
|
-
Ctor.precision = pr;
|
|
19937
|
-
Ctor.rounding = rm;
|
|
19938
|
-
return x.times(2);
|
|
19939
|
-
};
|
|
19940
|
-
P.inverseHyperbolicCosine = P.acosh = function() {
|
|
19941
|
-
var pr, rm, x = this, Ctor = x.constructor;
|
|
19942
|
-
if (x.lte(1))
|
|
19943
|
-
return new Ctor(x.eq(1) ? 0 : NaN);
|
|
19944
|
-
if (!x.isFinite())
|
|
19945
|
-
return new Ctor(x);
|
|
19946
|
-
pr = Ctor.precision;
|
|
19947
|
-
rm = Ctor.rounding;
|
|
19948
|
-
Ctor.precision = pr + Math.max(Math.abs(x.e), x.sd()) + 4;
|
|
19949
|
-
Ctor.rounding = 1;
|
|
19950
|
-
external2 = false;
|
|
19951
|
-
x = x.times(x).minus(1).sqrt().plus(x);
|
|
19952
|
-
external2 = true;
|
|
19953
|
-
Ctor.precision = pr;
|
|
19954
|
-
Ctor.rounding = rm;
|
|
19955
|
-
return x.ln();
|
|
19956
|
-
};
|
|
19957
|
-
P.inverseHyperbolicSine = P.asinh = function() {
|
|
19958
|
-
var pr, rm, x = this, Ctor = x.constructor;
|
|
19959
|
-
if (!x.isFinite() || x.isZero())
|
|
19960
|
-
return new Ctor(x);
|
|
19961
|
-
pr = Ctor.precision;
|
|
19962
|
-
rm = Ctor.rounding;
|
|
19963
|
-
Ctor.precision = pr + 2 * Math.max(Math.abs(x.e), x.sd()) + 6;
|
|
19964
|
-
Ctor.rounding = 1;
|
|
19965
|
-
external2 = false;
|
|
19966
|
-
x = x.times(x).plus(1).sqrt().plus(x);
|
|
19967
|
-
external2 = true;
|
|
19968
|
-
Ctor.precision = pr;
|
|
19969
|
-
Ctor.rounding = rm;
|
|
19970
|
-
return x.ln();
|
|
19971
|
-
};
|
|
19972
|
-
P.inverseHyperbolicTangent = P.atanh = function() {
|
|
19973
|
-
var pr, rm, wpr, xsd, x = this, Ctor = x.constructor;
|
|
19974
|
-
if (!x.isFinite())
|
|
19975
|
-
return new Ctor(NaN);
|
|
19976
|
-
if (x.e >= 0)
|
|
19977
|
-
return new Ctor(x.abs().eq(1) ? x.s / 0 : x.isZero() ? x : NaN);
|
|
19978
|
-
pr = Ctor.precision;
|
|
19979
|
-
rm = Ctor.rounding;
|
|
19980
|
-
xsd = x.sd();
|
|
19981
|
-
if (Math.max(xsd, pr) < 2 * -x.e - 1)
|
|
19982
|
-
return finalise(new Ctor(x), pr, rm, true);
|
|
19983
|
-
Ctor.precision = wpr = xsd - x.e;
|
|
19984
|
-
x = divide(x.plus(1), new Ctor(1).minus(x), wpr + pr, 1);
|
|
19985
|
-
Ctor.precision = pr + 4;
|
|
19986
|
-
Ctor.rounding = 1;
|
|
19987
|
-
x = x.ln();
|
|
19988
|
-
Ctor.precision = pr;
|
|
19989
|
-
Ctor.rounding = rm;
|
|
19990
|
-
return x.times(0.5);
|
|
20348
|
+
console.groupEnd();
|
|
19991
20349
|
};
|
|
19992
|
-
|
|
19993
|
-
|
|
19994
|
-
|
|
19995
|
-
|
|
19996
|
-
|
|
19997
|
-
|
|
19998
|
-
|
|
19999
|
-
|
|
20000
|
-
|
|
20001
|
-
|
|
20002
|
-
halfPi.s = x.s;
|
|
20003
|
-
return halfPi;
|
|
20004
|
-
}
|
|
20005
|
-
return new Ctor(NaN);
|
|
20006
|
-
}
|
|
20007
|
-
Ctor.precision = pr + 6;
|
|
20008
|
-
Ctor.rounding = 1;
|
|
20009
|
-
x = x.div(new Ctor(1).minus(x.times(x)).sqrt().plus(1)).atan();
|
|
20010
|
-
Ctor.precision = pr;
|
|
20011
|
-
Ctor.rounding = rm;
|
|
20012
|
-
return x.times(2);
|
|
20350
|
+
|
|
20351
|
+
// src/common/base/promise.ts
|
|
20352
|
+
var executePromise = async (promise) => {
|
|
20353
|
+
const start = Date.now();
|
|
20354
|
+
const result = await promise;
|
|
20355
|
+
const time = Date.now() - start;
|
|
20356
|
+
return {
|
|
20357
|
+
result,
|
|
20358
|
+
time
|
|
20359
|
+
};
|
|
20013
20360
|
};
|
|
20014
|
-
|
|
20015
|
-
|
|
20016
|
-
|
|
20017
|
-
|
|
20018
|
-
|
|
20019
|
-
|
|
20020
|
-
|
|
20021
|
-
|
|
20022
|
-
|
|
20023
|
-
}
|
|
20024
|
-
} else if (x.isZero()) {
|
|
20025
|
-
return new Ctor(x);
|
|
20026
|
-
} else if (x.abs().eq(1) && pr + 4 <= PI_PRECISION) {
|
|
20027
|
-
r = getPi(Ctor, pr + 4, rm).times(0.25);
|
|
20028
|
-
r.s = x.s;
|
|
20029
|
-
return r;
|
|
20030
|
-
}
|
|
20031
|
-
Ctor.precision = wpr = pr + 10;
|
|
20032
|
-
Ctor.rounding = 1;
|
|
20033
|
-
k = Math.min(28, wpr / LOG_BASE + 2 | 0);
|
|
20034
|
-
for (i = k;i; --i)
|
|
20035
|
-
x = x.div(x.times(x).plus(1).sqrt().plus(1));
|
|
20036
|
-
external2 = false;
|
|
20037
|
-
j = Math.ceil(wpr / LOG_BASE);
|
|
20038
|
-
n = 1;
|
|
20039
|
-
x2 = x.times(x);
|
|
20040
|
-
r = new Ctor(x);
|
|
20041
|
-
px = x;
|
|
20042
|
-
for (;i !== -1; ) {
|
|
20043
|
-
px = px.times(x2);
|
|
20044
|
-
t = r.minus(px.div(n += 2));
|
|
20045
|
-
px = px.times(x2);
|
|
20046
|
-
r = t.plus(px.div(n += 2));
|
|
20047
|
-
if (r.d[j] !== undefined)
|
|
20048
|
-
for (i = j;r.d[i] === t.d[i] && i--; )
|
|
20049
|
-
;
|
|
20050
|
-
}
|
|
20051
|
-
if (k)
|
|
20052
|
-
r = r.times(2 << k - 1);
|
|
20053
|
-
external2 = true;
|
|
20054
|
-
return finalise(r, Ctor.precision = pr, Ctor.rounding = rm, true);
|
|
20055
|
-
};
|
|
20056
|
-
P.isFinite = function() {
|
|
20057
|
-
return !!this.d;
|
|
20058
|
-
};
|
|
20059
|
-
P.isInteger = P.isInt = function() {
|
|
20060
|
-
return !!this.d && mathfloor(this.e / LOG_BASE) > this.d.length - 2;
|
|
20061
|
-
};
|
|
20062
|
-
P.isNaN = function() {
|
|
20063
|
-
return !this.s;
|
|
20064
|
-
};
|
|
20065
|
-
P.isNegative = P.isNeg = function() {
|
|
20066
|
-
return this.s < 0;
|
|
20067
|
-
};
|
|
20068
|
-
P.isPositive = P.isPos = function() {
|
|
20069
|
-
return this.s > 0;
|
|
20070
|
-
};
|
|
20071
|
-
P.isZero = function() {
|
|
20072
|
-
return !!this.d && this.d[0] === 0;
|
|
20073
|
-
};
|
|
20074
|
-
P.lessThan = P.lt = function(y) {
|
|
20075
|
-
return this.cmp(y) < 0;
|
|
20076
|
-
};
|
|
20077
|
-
P.lessThanOrEqualTo = P.lte = function(y) {
|
|
20078
|
-
return this.cmp(y) < 1;
|
|
20079
|
-
};
|
|
20080
|
-
P.logarithm = P.log = function(base) {
|
|
20081
|
-
var isBase10, d, denominator, k, inf, num, sd, r, arg = this, Ctor = arg.constructor, pr = Ctor.precision, rm = Ctor.rounding, guard = 5;
|
|
20082
|
-
if (base == null) {
|
|
20083
|
-
base = new Ctor(10);
|
|
20084
|
-
isBase10 = true;
|
|
20085
|
-
} else {
|
|
20086
|
-
base = new Ctor(base);
|
|
20087
|
-
d = base.d;
|
|
20088
|
-
if (base.s < 0 || !d || !d[0] || base.eq(1))
|
|
20089
|
-
return new Ctor(NaN);
|
|
20090
|
-
isBase10 = base.eq(10);
|
|
20091
|
-
}
|
|
20092
|
-
d = arg.d;
|
|
20093
|
-
if (arg.s < 0 || !d || !d[0] || arg.eq(1)) {
|
|
20094
|
-
return new Ctor(d && !d[0] ? -1 / 0 : arg.s != 1 ? NaN : d ? 0 : 1 / 0);
|
|
20095
|
-
}
|
|
20096
|
-
if (isBase10) {
|
|
20097
|
-
if (d.length > 1) {
|
|
20098
|
-
inf = true;
|
|
20099
|
-
} else {
|
|
20100
|
-
for (k = d[0];k % 10 === 0; )
|
|
20101
|
-
k /= 10;
|
|
20102
|
-
inf = k !== 1;
|
|
20103
|
-
}
|
|
20104
|
-
}
|
|
20105
|
-
external2 = false;
|
|
20106
|
-
sd = pr + guard;
|
|
20107
|
-
num = naturalLogarithm(arg, sd);
|
|
20108
|
-
denominator = isBase10 ? getLn10(Ctor, sd + 10) : naturalLogarithm(base, sd);
|
|
20109
|
-
r = divide(num, denominator, sd, 1);
|
|
20110
|
-
if (checkRoundingDigits(r.d, k = pr, rm)) {
|
|
20111
|
-
do {
|
|
20112
|
-
sd += 10;
|
|
20113
|
-
num = naturalLogarithm(arg, sd);
|
|
20114
|
-
denominator = isBase10 ? getLn10(Ctor, sd + 10) : naturalLogarithm(base, sd);
|
|
20115
|
-
r = divide(num, denominator, sd, 1);
|
|
20116
|
-
if (!inf) {
|
|
20117
|
-
if (+digitsToString(r.d).slice(k + 1, k + 15) + 1 == 100000000000000) {
|
|
20118
|
-
r = finalise(r, pr + 1, 0);
|
|
20119
|
-
}
|
|
20120
|
-
break;
|
|
20121
|
-
}
|
|
20122
|
-
} while (checkRoundingDigits(r.d, k += 10, rm));
|
|
20123
|
-
}
|
|
20124
|
-
external2 = true;
|
|
20125
|
-
return finalise(r, pr, rm);
|
|
20126
|
-
};
|
|
20127
|
-
P.minus = P.sub = function(y) {
|
|
20128
|
-
var d, e, i, j, k, len, pr, rm, xd, xe, xLTy, yd, x = this, Ctor = x.constructor;
|
|
20129
|
-
y = new Ctor(y);
|
|
20130
|
-
if (!x.d || !y.d) {
|
|
20131
|
-
if (!x.s || !y.s)
|
|
20132
|
-
y = new Ctor(NaN);
|
|
20133
|
-
else if (x.d)
|
|
20134
|
-
y.s = -y.s;
|
|
20135
|
-
else
|
|
20136
|
-
y = new Ctor(y.d || x.s !== y.s ? x : NaN);
|
|
20137
|
-
return y;
|
|
20138
|
-
}
|
|
20139
|
-
if (x.s != y.s) {
|
|
20140
|
-
y.s = -y.s;
|
|
20141
|
-
return x.plus(y);
|
|
20142
|
-
}
|
|
20143
|
-
xd = x.d;
|
|
20144
|
-
yd = y.d;
|
|
20145
|
-
pr = Ctor.precision;
|
|
20146
|
-
rm = Ctor.rounding;
|
|
20147
|
-
if (!xd[0] || !yd[0]) {
|
|
20148
|
-
if (yd[0])
|
|
20149
|
-
y.s = -y.s;
|
|
20150
|
-
else if (xd[0])
|
|
20151
|
-
y = new Ctor(x);
|
|
20152
|
-
else
|
|
20153
|
-
return new Ctor(rm === 3 ? -0 : 0);
|
|
20154
|
-
return external2 ? finalise(y, pr, rm) : y;
|
|
20155
|
-
}
|
|
20156
|
-
e = mathfloor(y.e / LOG_BASE);
|
|
20157
|
-
xe = mathfloor(x.e / LOG_BASE);
|
|
20158
|
-
xd = xd.slice();
|
|
20159
|
-
k = xe - e;
|
|
20160
|
-
if (k) {
|
|
20161
|
-
xLTy = k < 0;
|
|
20162
|
-
if (xLTy) {
|
|
20163
|
-
d = xd;
|
|
20164
|
-
k = -k;
|
|
20165
|
-
len = yd.length;
|
|
20166
|
-
} else {
|
|
20167
|
-
d = yd;
|
|
20168
|
-
e = xe;
|
|
20169
|
-
len = xd.length;
|
|
20170
|
-
}
|
|
20171
|
-
i = Math.max(Math.ceil(pr / LOG_BASE), len) + 2;
|
|
20172
|
-
if (k > i) {
|
|
20173
|
-
k = i;
|
|
20174
|
-
d.length = 1;
|
|
20175
|
-
}
|
|
20176
|
-
d.reverse();
|
|
20177
|
-
for (i = k;i--; )
|
|
20178
|
-
d.push(0);
|
|
20179
|
-
d.reverse();
|
|
20180
|
-
} else {
|
|
20181
|
-
i = xd.length;
|
|
20182
|
-
len = yd.length;
|
|
20183
|
-
xLTy = i < len;
|
|
20184
|
-
if (xLTy)
|
|
20185
|
-
len = i;
|
|
20186
|
-
for (i = 0;i < len; i++) {
|
|
20187
|
-
if (xd[i] != yd[i]) {
|
|
20188
|
-
xLTy = xd[i] < yd[i];
|
|
20189
|
-
break;
|
|
20190
|
-
}
|
|
20191
|
-
}
|
|
20192
|
-
k = 0;
|
|
20193
|
-
}
|
|
20194
|
-
if (xLTy) {
|
|
20195
|
-
d = xd;
|
|
20196
|
-
xd = yd;
|
|
20197
|
-
yd = d;
|
|
20198
|
-
y.s = -y.s;
|
|
20199
|
-
}
|
|
20200
|
-
len = xd.length;
|
|
20201
|
-
for (i = yd.length - len;i > 0; --i)
|
|
20202
|
-
xd[len++] = 0;
|
|
20203
|
-
for (i = yd.length;i > k; ) {
|
|
20204
|
-
if (xd[--i] < yd[i]) {
|
|
20205
|
-
for (j = i;j && xd[--j] === 0; )
|
|
20206
|
-
xd[j] = BASE - 1;
|
|
20207
|
-
--xd[j];
|
|
20208
|
-
xd[i] += BASE;
|
|
20209
|
-
}
|
|
20210
|
-
xd[i] -= yd[i];
|
|
20211
|
-
}
|
|
20212
|
-
for (;xd[--len] === 0; )
|
|
20213
|
-
xd.pop();
|
|
20214
|
-
for (;xd[0] === 0; xd.shift())
|
|
20215
|
-
--e;
|
|
20216
|
-
if (!xd[0])
|
|
20217
|
-
return new Ctor(rm === 3 ? -0 : 0);
|
|
20218
|
-
y.d = xd;
|
|
20219
|
-
y.e = getBase10Exponent(xd, e);
|
|
20220
|
-
return external2 ? finalise(y, pr, rm) : y;
|
|
20221
|
-
};
|
|
20222
|
-
P.modulo = P.mod = function(y) {
|
|
20223
|
-
var q, x = this, Ctor = x.constructor;
|
|
20224
|
-
y = new Ctor(y);
|
|
20225
|
-
if (!x.d || !y.s || y.d && !y.d[0])
|
|
20226
|
-
return new Ctor(NaN);
|
|
20227
|
-
if (!y.d || x.d && !x.d[0]) {
|
|
20228
|
-
return finalise(new Ctor(x), Ctor.precision, Ctor.rounding);
|
|
20229
|
-
}
|
|
20230
|
-
external2 = false;
|
|
20231
|
-
if (Ctor.modulo == 9) {
|
|
20232
|
-
q = divide(x, y.abs(), 0, 3, 1);
|
|
20233
|
-
q.s *= y.s;
|
|
20234
|
-
} else {
|
|
20235
|
-
q = divide(x, y, 0, Ctor.modulo, 1);
|
|
20236
|
-
}
|
|
20237
|
-
q = q.times(y);
|
|
20238
|
-
external2 = true;
|
|
20239
|
-
return x.minus(q);
|
|
20240
|
-
};
|
|
20241
|
-
P.naturalExponential = P.exp = function() {
|
|
20242
|
-
return naturalExponential(this);
|
|
20243
|
-
};
|
|
20244
|
-
P.naturalLogarithm = P.ln = function() {
|
|
20245
|
-
return naturalLogarithm(this);
|
|
20246
|
-
};
|
|
20247
|
-
P.negated = P.neg = function() {
|
|
20248
|
-
var x = new this.constructor(this);
|
|
20249
|
-
x.s = -x.s;
|
|
20250
|
-
return finalise(x);
|
|
20251
|
-
};
|
|
20252
|
-
P.plus = P.add = function(y) {
|
|
20253
|
-
var carry, d, e, i, k, len, pr, rm, xd, yd, x = this, Ctor = x.constructor;
|
|
20254
|
-
y = new Ctor(y);
|
|
20255
|
-
if (!x.d || !y.d) {
|
|
20256
|
-
if (!x.s || !y.s)
|
|
20257
|
-
y = new Ctor(NaN);
|
|
20258
|
-
else if (!x.d)
|
|
20259
|
-
y = new Ctor(y.d || x.s === y.s ? x : NaN);
|
|
20260
|
-
return y;
|
|
20261
|
-
}
|
|
20262
|
-
if (x.s != y.s) {
|
|
20263
|
-
y.s = -y.s;
|
|
20264
|
-
return x.minus(y);
|
|
20265
|
-
}
|
|
20266
|
-
xd = x.d;
|
|
20267
|
-
yd = y.d;
|
|
20268
|
-
pr = Ctor.precision;
|
|
20269
|
-
rm = Ctor.rounding;
|
|
20270
|
-
if (!xd[0] || !yd[0]) {
|
|
20271
|
-
if (!yd[0])
|
|
20272
|
-
y = new Ctor(x);
|
|
20273
|
-
return external2 ? finalise(y, pr, rm) : y;
|
|
20274
|
-
}
|
|
20275
|
-
k = mathfloor(x.e / LOG_BASE);
|
|
20276
|
-
e = mathfloor(y.e / LOG_BASE);
|
|
20277
|
-
xd = xd.slice();
|
|
20278
|
-
i = k - e;
|
|
20279
|
-
if (i) {
|
|
20280
|
-
if (i < 0) {
|
|
20281
|
-
d = xd;
|
|
20282
|
-
i = -i;
|
|
20283
|
-
len = yd.length;
|
|
20284
|
-
} else {
|
|
20285
|
-
d = yd;
|
|
20286
|
-
e = k;
|
|
20287
|
-
len = xd.length;
|
|
20288
|
-
}
|
|
20289
|
-
k = Math.ceil(pr / LOG_BASE);
|
|
20290
|
-
len = k > len ? k + 1 : len + 1;
|
|
20291
|
-
if (i > len) {
|
|
20292
|
-
i = len;
|
|
20293
|
-
d.length = 1;
|
|
20294
|
-
}
|
|
20295
|
-
d.reverse();
|
|
20296
|
-
for (;i--; )
|
|
20297
|
-
d.push(0);
|
|
20298
|
-
d.reverse();
|
|
20299
|
-
}
|
|
20300
|
-
len = xd.length;
|
|
20301
|
-
i = yd.length;
|
|
20302
|
-
if (len - i < 0) {
|
|
20303
|
-
i = len;
|
|
20304
|
-
d = yd;
|
|
20305
|
-
yd = xd;
|
|
20306
|
-
xd = d;
|
|
20307
|
-
}
|
|
20308
|
-
for (carry = 0;i; ) {
|
|
20309
|
-
carry = (xd[--i] = xd[i] + yd[i] + carry) / BASE | 0;
|
|
20310
|
-
xd[i] %= BASE;
|
|
20311
|
-
}
|
|
20312
|
-
if (carry) {
|
|
20313
|
-
xd.unshift(carry);
|
|
20314
|
-
++e;
|
|
20315
|
-
}
|
|
20316
|
-
for (len = xd.length;xd[--len] == 0; )
|
|
20317
|
-
xd.pop();
|
|
20318
|
-
y.d = xd;
|
|
20319
|
-
y.e = getBase10Exponent(xd, e);
|
|
20320
|
-
return external2 ? finalise(y, pr, rm) : y;
|
|
20321
|
-
};
|
|
20322
|
-
P.precision = P.sd = function(z) {
|
|
20323
|
-
var k, x = this;
|
|
20324
|
-
if (z !== undefined && z !== !!z && z !== 1 && z !== 0)
|
|
20325
|
-
throw Error(invalidArgument + z);
|
|
20326
|
-
if (x.d) {
|
|
20327
|
-
k = getPrecision(x.d);
|
|
20328
|
-
if (z && x.e + 1 > k)
|
|
20329
|
-
k = x.e + 1;
|
|
20330
|
-
} else {
|
|
20331
|
-
k = NaN;
|
|
20332
|
-
}
|
|
20333
|
-
return k;
|
|
20334
|
-
};
|
|
20335
|
-
P.round = function() {
|
|
20336
|
-
var x = this, Ctor = x.constructor;
|
|
20337
|
-
return finalise(new Ctor(x), x.e + 1, Ctor.rounding);
|
|
20338
|
-
};
|
|
20339
|
-
P.sine = P.sin = function() {
|
|
20340
|
-
var pr, rm, x = this, Ctor = x.constructor;
|
|
20341
|
-
if (!x.isFinite())
|
|
20342
|
-
return new Ctor(NaN);
|
|
20343
|
-
if (x.isZero())
|
|
20344
|
-
return new Ctor(x);
|
|
20345
|
-
pr = Ctor.precision;
|
|
20346
|
-
rm = Ctor.rounding;
|
|
20347
|
-
Ctor.precision = pr + Math.max(x.e, x.sd()) + LOG_BASE;
|
|
20348
|
-
Ctor.rounding = 1;
|
|
20349
|
-
x = sine(Ctor, toLessThanHalfPi(Ctor, x));
|
|
20350
|
-
Ctor.precision = pr;
|
|
20351
|
-
Ctor.rounding = rm;
|
|
20352
|
-
return finalise(quadrant > 2 ? x.neg() : x, pr, rm, true);
|
|
20353
|
-
};
|
|
20354
|
-
P.squareRoot = P.sqrt = function() {
|
|
20355
|
-
var m, n, sd, r, rep, t, x = this, d = x.d, e = x.e, s = x.s, Ctor = x.constructor;
|
|
20356
|
-
if (s !== 1 || !d || !d[0]) {
|
|
20357
|
-
return new Ctor(!s || s < 0 && (!d || d[0]) ? NaN : d ? x : 1 / 0);
|
|
20358
|
-
}
|
|
20359
|
-
external2 = false;
|
|
20360
|
-
s = Math.sqrt(+x);
|
|
20361
|
-
if (s == 0 || s == 1 / 0) {
|
|
20362
|
-
n = digitsToString(d);
|
|
20363
|
-
if ((n.length + e) % 2 == 0)
|
|
20364
|
-
n += "0";
|
|
20365
|
-
s = Math.sqrt(n);
|
|
20366
|
-
e = mathfloor((e + 1) / 2) - (e < 0 || e % 2);
|
|
20367
|
-
if (s == 1 / 0) {
|
|
20368
|
-
n = "5e" + e;
|
|
20369
|
-
} else {
|
|
20370
|
-
n = s.toExponential();
|
|
20371
|
-
n = n.slice(0, n.indexOf("e") + 1) + e;
|
|
20372
|
-
}
|
|
20373
|
-
r = new Ctor(n);
|
|
20374
|
-
} else {
|
|
20375
|
-
r = new Ctor(s.toString());
|
|
20376
|
-
}
|
|
20377
|
-
sd = (e = Ctor.precision) + 3;
|
|
20378
|
-
for (;; ) {
|
|
20379
|
-
t = r;
|
|
20380
|
-
r = t.plus(divide(x, t, sd + 2, 1)).times(0.5);
|
|
20381
|
-
if (digitsToString(t.d).slice(0, sd) === (n = digitsToString(r.d)).slice(0, sd)) {
|
|
20382
|
-
n = n.slice(sd - 3, sd + 1);
|
|
20383
|
-
if (n == "9999" || !rep && n == "4999") {
|
|
20384
|
-
if (!rep) {
|
|
20385
|
-
finalise(t, e + 1, 0);
|
|
20386
|
-
if (t.times(t).eq(x)) {
|
|
20387
|
-
r = t;
|
|
20388
|
-
break;
|
|
20389
|
-
}
|
|
20390
|
-
}
|
|
20391
|
-
sd += 4;
|
|
20392
|
-
rep = 1;
|
|
20393
|
-
} else {
|
|
20394
|
-
if (!+n || !+n.slice(1) && n.charAt(0) == "5") {
|
|
20395
|
-
finalise(r, e + 1, 1);
|
|
20396
|
-
m = !r.times(r).eq(x);
|
|
20397
|
-
}
|
|
20398
|
-
break;
|
|
20399
|
-
}
|
|
20400
|
-
}
|
|
20401
|
-
}
|
|
20402
|
-
external2 = true;
|
|
20403
|
-
return finalise(r, e, Ctor.rounding, m);
|
|
20404
|
-
};
|
|
20405
|
-
P.tangent = P.tan = function() {
|
|
20406
|
-
var pr, rm, x = this, Ctor = x.constructor;
|
|
20407
|
-
if (!x.isFinite())
|
|
20408
|
-
return new Ctor(NaN);
|
|
20409
|
-
if (x.isZero())
|
|
20410
|
-
return new Ctor(x);
|
|
20411
|
-
pr = Ctor.precision;
|
|
20412
|
-
rm = Ctor.rounding;
|
|
20413
|
-
Ctor.precision = pr + 10;
|
|
20414
|
-
Ctor.rounding = 1;
|
|
20415
|
-
x = x.sin();
|
|
20416
|
-
x.s = 1;
|
|
20417
|
-
x = divide(x, new Ctor(1).minus(x.times(x)).sqrt(), pr + 10, 0);
|
|
20418
|
-
Ctor.precision = pr;
|
|
20419
|
-
Ctor.rounding = rm;
|
|
20420
|
-
return finalise(quadrant == 2 || quadrant == 4 ? x.neg() : x, pr, rm, true);
|
|
20421
|
-
};
|
|
20422
|
-
P.times = P.mul = function(y) {
|
|
20423
|
-
var carry, e, i, k, r, rL, t, xdL, ydL, x = this, Ctor = x.constructor, xd = x.d, yd = (y = new Ctor(y)).d;
|
|
20424
|
-
y.s *= x.s;
|
|
20425
|
-
if (!xd || !xd[0] || !yd || !yd[0]) {
|
|
20426
|
-
return new Ctor(!y.s || xd && !xd[0] && !yd || yd && !yd[0] && !xd ? NaN : !xd || !yd ? y.s / 0 : y.s * 0);
|
|
20427
|
-
}
|
|
20428
|
-
e = mathfloor(x.e / LOG_BASE) + mathfloor(y.e / LOG_BASE);
|
|
20429
|
-
xdL = xd.length;
|
|
20430
|
-
ydL = yd.length;
|
|
20431
|
-
if (xdL < ydL) {
|
|
20432
|
-
r = xd;
|
|
20433
|
-
xd = yd;
|
|
20434
|
-
yd = r;
|
|
20435
|
-
rL = xdL;
|
|
20436
|
-
xdL = ydL;
|
|
20437
|
-
ydL = rL;
|
|
20438
|
-
}
|
|
20439
|
-
r = [];
|
|
20440
|
-
rL = xdL + ydL;
|
|
20441
|
-
for (i = rL;i--; )
|
|
20442
|
-
r.push(0);
|
|
20443
|
-
for (i = ydL;--i >= 0; ) {
|
|
20444
|
-
carry = 0;
|
|
20445
|
-
for (k = xdL + i;k > i; ) {
|
|
20446
|
-
t = r[k] + yd[i] * xd[k - i - 1] + carry;
|
|
20447
|
-
r[k--] = t % BASE | 0;
|
|
20448
|
-
carry = t / BASE | 0;
|
|
20449
|
-
}
|
|
20450
|
-
r[k] = (r[k] + carry) % BASE | 0;
|
|
20451
|
-
}
|
|
20452
|
-
for (;!r[--rL]; )
|
|
20453
|
-
r.pop();
|
|
20454
|
-
if (carry)
|
|
20455
|
-
++e;
|
|
20456
|
-
else
|
|
20457
|
-
r.shift();
|
|
20458
|
-
y.d = r;
|
|
20459
|
-
y.e = getBase10Exponent(r, e);
|
|
20460
|
-
return external2 ? finalise(y, Ctor.precision, Ctor.rounding) : y;
|
|
20461
|
-
};
|
|
20462
|
-
P.toBinary = function(sd, rm) {
|
|
20463
|
-
return toStringBinary(this, 2, sd, rm);
|
|
20464
|
-
};
|
|
20465
|
-
P.toDecimalPlaces = P.toDP = function(dp, rm) {
|
|
20466
|
-
var x = this, Ctor = x.constructor;
|
|
20467
|
-
x = new Ctor(x);
|
|
20468
|
-
if (dp === undefined)
|
|
20469
|
-
return x;
|
|
20470
|
-
checkInt32(dp, 0, MAX_DIGITS);
|
|
20471
|
-
if (rm === undefined)
|
|
20472
|
-
rm = Ctor.rounding;
|
|
20473
|
-
else
|
|
20474
|
-
checkInt32(rm, 0, 8);
|
|
20475
|
-
return finalise(x, dp + x.e + 1, rm);
|
|
20476
|
-
};
|
|
20477
|
-
P.toExponential = function(dp, rm) {
|
|
20478
|
-
var str, x = this, Ctor = x.constructor;
|
|
20479
|
-
if (dp === undefined) {
|
|
20480
|
-
str = finiteToString(x, true);
|
|
20481
|
-
} else {
|
|
20482
|
-
checkInt32(dp, 0, MAX_DIGITS);
|
|
20483
|
-
if (rm === undefined)
|
|
20484
|
-
rm = Ctor.rounding;
|
|
20485
|
-
else
|
|
20486
|
-
checkInt32(rm, 0, 8);
|
|
20487
|
-
x = finalise(new Ctor(x), dp + 1, rm);
|
|
20488
|
-
str = finiteToString(x, true, dp + 1);
|
|
20489
|
-
}
|
|
20490
|
-
return x.isNeg() && !x.isZero() ? "-" + str : str;
|
|
20491
|
-
};
|
|
20492
|
-
P.toFixed = function(dp, rm) {
|
|
20493
|
-
var str, y, x = this, Ctor = x.constructor;
|
|
20494
|
-
if (dp === undefined) {
|
|
20495
|
-
str = finiteToString(x);
|
|
20496
|
-
} else {
|
|
20497
|
-
checkInt32(dp, 0, MAX_DIGITS);
|
|
20498
|
-
if (rm === undefined)
|
|
20499
|
-
rm = Ctor.rounding;
|
|
20500
|
-
else
|
|
20501
|
-
checkInt32(rm, 0, 8);
|
|
20502
|
-
y = finalise(new Ctor(x), dp + x.e + 1, rm);
|
|
20503
|
-
str = finiteToString(y, false, dp + y.e + 1);
|
|
20504
|
-
}
|
|
20505
|
-
return x.isNeg() && !x.isZero() ? "-" + str : str;
|
|
20506
|
-
};
|
|
20507
|
-
P.toFraction = function(maxD) {
|
|
20508
|
-
var d, d0, d1, d2, e, k, n, n0, n1, pr, q, r, x = this, xd = x.d, Ctor = x.constructor;
|
|
20509
|
-
if (!xd)
|
|
20510
|
-
return new Ctor(x);
|
|
20511
|
-
n1 = d0 = new Ctor(1);
|
|
20512
|
-
d1 = n0 = new Ctor(0);
|
|
20513
|
-
d = new Ctor(d1);
|
|
20514
|
-
e = d.e = getPrecision(xd) - x.e - 1;
|
|
20515
|
-
k = e % LOG_BASE;
|
|
20516
|
-
d.d[0] = mathpow(10, k < 0 ? LOG_BASE + k : k);
|
|
20517
|
-
if (maxD == null) {
|
|
20518
|
-
maxD = e > 0 ? d : n1;
|
|
20519
|
-
} else {
|
|
20520
|
-
n = new Ctor(maxD);
|
|
20521
|
-
if (!n.isInt() || n.lt(n1))
|
|
20522
|
-
throw Error(invalidArgument + n);
|
|
20523
|
-
maxD = n.gt(d) ? e > 0 ? d : n1 : n;
|
|
20524
|
-
}
|
|
20525
|
-
external2 = false;
|
|
20526
|
-
n = new Ctor(digitsToString(xd));
|
|
20527
|
-
pr = Ctor.precision;
|
|
20528
|
-
Ctor.precision = e = xd.length * LOG_BASE * 2;
|
|
20529
|
-
for (;; ) {
|
|
20530
|
-
q = divide(n, d, 0, 1, 1);
|
|
20531
|
-
d2 = d0.plus(q.times(d1));
|
|
20532
|
-
if (d2.cmp(maxD) == 1)
|
|
20533
|
-
break;
|
|
20534
|
-
d0 = d1;
|
|
20535
|
-
d1 = d2;
|
|
20536
|
-
d2 = n1;
|
|
20537
|
-
n1 = n0.plus(q.times(d2));
|
|
20538
|
-
n0 = d2;
|
|
20539
|
-
d2 = d;
|
|
20540
|
-
d = n.minus(q.times(d2));
|
|
20541
|
-
n = d2;
|
|
20542
|
-
}
|
|
20543
|
-
d2 = divide(maxD.minus(d0), d1, 0, 1, 1);
|
|
20544
|
-
n0 = n0.plus(d2.times(n1));
|
|
20545
|
-
d0 = d0.plus(d2.times(d1));
|
|
20546
|
-
n0.s = n1.s = x.s;
|
|
20547
|
-
r = divide(n1, d1, e, 1).minus(x).abs().cmp(divide(n0, d0, e, 1).minus(x).abs()) < 1 ? [n1, d1] : [n0, d0];
|
|
20548
|
-
Ctor.precision = pr;
|
|
20549
|
-
external2 = true;
|
|
20550
|
-
return r;
|
|
20551
|
-
};
|
|
20552
|
-
P.toHexadecimal = P.toHex = function(sd, rm) {
|
|
20553
|
-
return toStringBinary(this, 16, sd, rm);
|
|
20554
|
-
};
|
|
20555
|
-
P.toNearest = function(y, rm) {
|
|
20556
|
-
var x = this, Ctor = x.constructor;
|
|
20557
|
-
x = new Ctor(x);
|
|
20558
|
-
if (y == null) {
|
|
20559
|
-
if (!x.d)
|
|
20560
|
-
return x;
|
|
20561
|
-
y = new Ctor(1);
|
|
20562
|
-
rm = Ctor.rounding;
|
|
20563
|
-
} else {
|
|
20564
|
-
y = new Ctor(y);
|
|
20565
|
-
if (rm === undefined) {
|
|
20566
|
-
rm = Ctor.rounding;
|
|
20567
|
-
} else {
|
|
20568
|
-
checkInt32(rm, 0, 8);
|
|
20569
|
-
}
|
|
20570
|
-
if (!x.d)
|
|
20571
|
-
return y.s ? x : y;
|
|
20572
|
-
if (!y.d) {
|
|
20573
|
-
if (y.s)
|
|
20574
|
-
y.s = x.s;
|
|
20575
|
-
return y;
|
|
20576
|
-
}
|
|
20577
|
-
}
|
|
20578
|
-
if (y.d[0]) {
|
|
20579
|
-
external2 = false;
|
|
20580
|
-
x = divide(x, y, 0, rm, 1).times(y);
|
|
20581
|
-
external2 = true;
|
|
20582
|
-
finalise(x);
|
|
20583
|
-
} else {
|
|
20584
|
-
y.s = x.s;
|
|
20585
|
-
x = y;
|
|
20586
|
-
}
|
|
20587
|
-
return x;
|
|
20588
|
-
};
|
|
20589
|
-
P.toNumber = function() {
|
|
20590
|
-
return +this;
|
|
20591
|
-
};
|
|
20592
|
-
P.toOctal = function(sd, rm) {
|
|
20593
|
-
return toStringBinary(this, 8, sd, rm);
|
|
20594
|
-
};
|
|
20595
|
-
P.toPower = P.pow = function(y) {
|
|
20596
|
-
var e, k, pr, r, rm, s, x = this, Ctor = x.constructor, yn = +(y = new Ctor(y));
|
|
20597
|
-
if (!x.d || !y.d || !x.d[0] || !y.d[0])
|
|
20598
|
-
return new Ctor(mathpow(+x, yn));
|
|
20599
|
-
x = new Ctor(x);
|
|
20600
|
-
if (x.eq(1))
|
|
20601
|
-
return x;
|
|
20602
|
-
pr = Ctor.precision;
|
|
20603
|
-
rm = Ctor.rounding;
|
|
20604
|
-
if (y.eq(1))
|
|
20605
|
-
return finalise(x, pr, rm);
|
|
20606
|
-
e = mathfloor(y.e / LOG_BASE);
|
|
20607
|
-
if (e >= y.d.length - 1 && (k = yn < 0 ? -yn : yn) <= MAX_SAFE_INTEGER) {
|
|
20608
|
-
r = intPow(Ctor, x, k, pr);
|
|
20609
|
-
return y.s < 0 ? new Ctor(1).div(r) : finalise(r, pr, rm);
|
|
20610
|
-
}
|
|
20611
|
-
s = x.s;
|
|
20612
|
-
if (s < 0) {
|
|
20613
|
-
if (e < y.d.length - 1)
|
|
20614
|
-
return new Ctor(NaN);
|
|
20615
|
-
if ((y.d[e] & 1) == 0)
|
|
20616
|
-
s = 1;
|
|
20617
|
-
if (x.e == 0 && x.d[0] == 1 && x.d.length == 1) {
|
|
20618
|
-
x.s = s;
|
|
20619
|
-
return x;
|
|
20620
|
-
}
|
|
20621
|
-
}
|
|
20622
|
-
k = mathpow(+x, yn);
|
|
20623
|
-
e = k == 0 || !isFinite(k) ? mathfloor(yn * (Math.log("0." + digitsToString(x.d)) / Math.LN10 + x.e + 1)) : new Ctor(k + "").e;
|
|
20624
|
-
if (e > Ctor.maxE + 1 || e < Ctor.minE - 1)
|
|
20625
|
-
return new Ctor(e > 0 ? s / 0 : 0);
|
|
20626
|
-
external2 = false;
|
|
20627
|
-
Ctor.rounding = x.s = 1;
|
|
20628
|
-
k = Math.min(12, (e + "").length);
|
|
20629
|
-
r = naturalExponential(y.times(naturalLogarithm(x, pr + k)), pr);
|
|
20630
|
-
if (r.d) {
|
|
20631
|
-
r = finalise(r, pr + 5, 1);
|
|
20632
|
-
if (checkRoundingDigits(r.d, pr, rm)) {
|
|
20633
|
-
e = pr + 10;
|
|
20634
|
-
r = finalise(naturalExponential(y.times(naturalLogarithm(x, e + k)), e), e + 5, 1);
|
|
20635
|
-
if (+digitsToString(r.d).slice(pr + 1, pr + 15) + 1 == 100000000000000) {
|
|
20636
|
-
r = finalise(r, pr + 1, 0);
|
|
20637
|
-
}
|
|
20638
|
-
}
|
|
20639
|
-
}
|
|
20640
|
-
r.s = s;
|
|
20641
|
-
external2 = true;
|
|
20642
|
-
Ctor.rounding = rm;
|
|
20643
|
-
return finalise(r, pr, rm);
|
|
20644
|
-
};
|
|
20645
|
-
P.toPrecision = function(sd, rm) {
|
|
20646
|
-
var str, x = this, Ctor = x.constructor;
|
|
20647
|
-
if (sd === undefined) {
|
|
20648
|
-
str = finiteToString(x, x.e <= Ctor.toExpNeg || x.e >= Ctor.toExpPos);
|
|
20649
|
-
} else {
|
|
20650
|
-
checkInt32(sd, 1, MAX_DIGITS);
|
|
20651
|
-
if (rm === undefined)
|
|
20652
|
-
rm = Ctor.rounding;
|
|
20653
|
-
else
|
|
20654
|
-
checkInt32(rm, 0, 8);
|
|
20655
|
-
x = finalise(new Ctor(x), sd, rm);
|
|
20656
|
-
str = finiteToString(x, sd <= x.e || x.e <= Ctor.toExpNeg, sd);
|
|
20657
|
-
}
|
|
20658
|
-
return x.isNeg() && !x.isZero() ? "-" + str : str;
|
|
20659
|
-
};
|
|
20660
|
-
P.toSignificantDigits = P.toSD = function(sd, rm) {
|
|
20661
|
-
var x = this, Ctor = x.constructor;
|
|
20662
|
-
if (sd === undefined) {
|
|
20663
|
-
sd = Ctor.precision;
|
|
20664
|
-
rm = Ctor.rounding;
|
|
20665
|
-
} else {
|
|
20666
|
-
checkInt32(sd, 1, MAX_DIGITS);
|
|
20667
|
-
if (rm === undefined)
|
|
20668
|
-
rm = Ctor.rounding;
|
|
20669
|
-
else
|
|
20670
|
-
checkInt32(rm, 0, 8);
|
|
20671
|
-
}
|
|
20672
|
-
return finalise(new Ctor(x), sd, rm);
|
|
20673
|
-
};
|
|
20674
|
-
P.toString = function() {
|
|
20675
|
-
var x = this, Ctor = x.constructor, str = finiteToString(x, x.e <= Ctor.toExpNeg || x.e >= Ctor.toExpPos);
|
|
20676
|
-
return x.isNeg() && !x.isZero() ? "-" + str : str;
|
|
20677
|
-
};
|
|
20678
|
-
P.truncated = P.trunc = function() {
|
|
20679
|
-
return finalise(new this.constructor(this), this.e + 1, 1);
|
|
20680
|
-
};
|
|
20681
|
-
P.valueOf = P.toJSON = function() {
|
|
20682
|
-
var x = this, Ctor = x.constructor, str = finiteToString(x, x.e <= Ctor.toExpNeg || x.e >= Ctor.toExpPos);
|
|
20683
|
-
return x.isNeg() ? "-" + str : str;
|
|
20684
|
-
};
|
|
20685
|
-
function digitsToString(d) {
|
|
20686
|
-
var i, k, ws, indexOfLastWord = d.length - 1, str = "", w = d[0];
|
|
20687
|
-
if (indexOfLastWord > 0) {
|
|
20688
|
-
str += w;
|
|
20689
|
-
for (i = 1;i < indexOfLastWord; i++) {
|
|
20690
|
-
ws = d[i] + "";
|
|
20691
|
-
k = LOG_BASE - ws.length;
|
|
20692
|
-
if (k)
|
|
20693
|
-
str += getZeroString(k);
|
|
20694
|
-
str += ws;
|
|
20695
|
-
}
|
|
20696
|
-
w = d[i];
|
|
20697
|
-
ws = w + "";
|
|
20698
|
-
k = LOG_BASE - ws.length;
|
|
20699
|
-
if (k)
|
|
20700
|
-
str += getZeroString(k);
|
|
20701
|
-
} else if (w === 0) {
|
|
20702
|
-
return "0";
|
|
20703
|
-
}
|
|
20704
|
-
for (;w % 10 === 0; )
|
|
20705
|
-
w /= 10;
|
|
20706
|
-
return str + w;
|
|
20707
|
-
}
|
|
20708
|
-
function checkInt32(i, min, max) {
|
|
20709
|
-
if (i !== ~~i || i < min || i > max) {
|
|
20710
|
-
throw Error(invalidArgument + i);
|
|
20711
|
-
}
|
|
20712
|
-
}
|
|
20713
|
-
function checkRoundingDigits(d, i, rm, repeating) {
|
|
20714
|
-
var di, k, r, rd;
|
|
20715
|
-
for (k = d[0];k >= 10; k /= 10)
|
|
20716
|
-
--i;
|
|
20717
|
-
if (--i < 0) {
|
|
20718
|
-
i += LOG_BASE;
|
|
20719
|
-
di = 0;
|
|
20720
|
-
} else {
|
|
20721
|
-
di = Math.ceil((i + 1) / LOG_BASE);
|
|
20722
|
-
i %= LOG_BASE;
|
|
20723
|
-
}
|
|
20724
|
-
k = mathpow(10, LOG_BASE - i);
|
|
20725
|
-
rd = d[di] % k | 0;
|
|
20726
|
-
if (repeating == null) {
|
|
20727
|
-
if (i < 3) {
|
|
20728
|
-
if (i == 0)
|
|
20729
|
-
rd = rd / 100 | 0;
|
|
20730
|
-
else if (i == 1)
|
|
20731
|
-
rd = rd / 10 | 0;
|
|
20732
|
-
r = rm < 4 && rd == 99999 || rm > 3 && rd == 49999 || rd == 50000 || rd == 0;
|
|
20733
|
-
} else {
|
|
20734
|
-
r = (rm < 4 && rd + 1 == k || rm > 3 && rd + 1 == k / 2) && (d[di + 1] / k / 100 | 0) == mathpow(10, i - 2) - 1 || (rd == k / 2 || rd == 0) && (d[di + 1] / k / 100 | 0) == 0;
|
|
20735
|
-
}
|
|
20736
|
-
} else {
|
|
20737
|
-
if (i < 4) {
|
|
20738
|
-
if (i == 0)
|
|
20739
|
-
rd = rd / 1000 | 0;
|
|
20740
|
-
else if (i == 1)
|
|
20741
|
-
rd = rd / 100 | 0;
|
|
20742
|
-
else if (i == 2)
|
|
20743
|
-
rd = rd / 10 | 0;
|
|
20744
|
-
r = (repeating || rm < 4) && rd == 9999 || !repeating && rm > 3 && rd == 4999;
|
|
20745
|
-
} else {
|
|
20746
|
-
r = ((repeating || rm < 4) && rd + 1 == k || !repeating && rm > 3 && rd + 1 == k / 2) && (d[di + 1] / k / 1000 | 0) == mathpow(10, i - 3) - 1;
|
|
20747
|
-
}
|
|
20748
|
-
}
|
|
20749
|
-
return r;
|
|
20750
|
-
}
|
|
20751
|
-
function convertBase(str, baseIn, baseOut) {
|
|
20752
|
-
var j, arr = [0], arrL, i = 0, strL = str.length;
|
|
20753
|
-
for (;i < strL; ) {
|
|
20754
|
-
for (arrL = arr.length;arrL--; )
|
|
20755
|
-
arr[arrL] *= baseIn;
|
|
20756
|
-
arr[0] += NUMERALS.indexOf(str.charAt(i++));
|
|
20757
|
-
for (j = 0;j < arr.length; j++) {
|
|
20758
|
-
if (arr[j] > baseOut - 1) {
|
|
20759
|
-
if (arr[j + 1] === undefined)
|
|
20760
|
-
arr[j + 1] = 0;
|
|
20761
|
-
arr[j + 1] += arr[j] / baseOut | 0;
|
|
20762
|
-
arr[j] %= baseOut;
|
|
20763
|
-
}
|
|
20764
|
-
}
|
|
20765
|
-
}
|
|
20766
|
-
return arr.reverse();
|
|
20767
|
-
}
|
|
20768
|
-
function cosine(Ctor, x) {
|
|
20769
|
-
var k, len, y;
|
|
20770
|
-
if (x.isZero())
|
|
20771
|
-
return x;
|
|
20772
|
-
len = x.d.length;
|
|
20773
|
-
if (len < 32) {
|
|
20774
|
-
k = Math.ceil(len / 3);
|
|
20775
|
-
y = (1 / tinyPow(4, k)).toString();
|
|
20776
|
-
} else {
|
|
20777
|
-
k = 16;
|
|
20778
|
-
y = "2.3283064365386962890625e-10";
|
|
20779
|
-
}
|
|
20780
|
-
Ctor.precision += k;
|
|
20781
|
-
x = taylorSeries(Ctor, 1, x.times(y), new Ctor(1));
|
|
20782
|
-
for (var i = k;i--; ) {
|
|
20783
|
-
var cos2x = x.times(x);
|
|
20784
|
-
x = cos2x.times(cos2x).minus(cos2x).times(8).plus(1);
|
|
20785
|
-
}
|
|
20786
|
-
Ctor.precision -= k;
|
|
20787
|
-
return x;
|
|
20788
|
-
}
|
|
20789
|
-
var divide = function() {
|
|
20790
|
-
function multiplyInteger(x, k, base) {
|
|
20791
|
-
var temp, carry = 0, i = x.length;
|
|
20792
|
-
for (x = x.slice();i--; ) {
|
|
20793
|
-
temp = x[i] * k + carry;
|
|
20794
|
-
x[i] = temp % base | 0;
|
|
20795
|
-
carry = temp / base | 0;
|
|
20796
|
-
}
|
|
20797
|
-
if (carry)
|
|
20798
|
-
x.unshift(carry);
|
|
20799
|
-
return x;
|
|
20800
|
-
}
|
|
20801
|
-
function compare(a, b, aL, bL) {
|
|
20802
|
-
var i, r;
|
|
20803
|
-
if (aL != bL) {
|
|
20804
|
-
r = aL > bL ? 1 : -1;
|
|
20805
|
-
} else {
|
|
20806
|
-
for (i = r = 0;i < aL; i++) {
|
|
20807
|
-
if (a[i] != b[i]) {
|
|
20808
|
-
r = a[i] > b[i] ? 1 : -1;
|
|
20809
|
-
break;
|
|
20810
|
-
}
|
|
20811
|
-
}
|
|
20812
|
-
}
|
|
20813
|
-
return r;
|
|
20814
|
-
}
|
|
20815
|
-
function subtract(a, b, aL, base) {
|
|
20816
|
-
var i = 0;
|
|
20817
|
-
for (;aL--; ) {
|
|
20818
|
-
a[aL] -= i;
|
|
20819
|
-
i = a[aL] < b[aL] ? 1 : 0;
|
|
20820
|
-
a[aL] = i * base + a[aL] - b[aL];
|
|
20821
|
-
}
|
|
20822
|
-
for (;!a[0] && a.length > 1; )
|
|
20823
|
-
a.shift();
|
|
20824
|
-
}
|
|
20825
|
-
return function(x, y, pr, rm, dp, base) {
|
|
20826
|
-
var cmp, e, i, k, logBase, more, prod, prodL, q, qd, rem, remL, rem0, sd, t, xi, xL, yd0, yL, yz, Ctor = x.constructor, sign = x.s == y.s ? 1 : -1, xd = x.d, yd = y.d;
|
|
20827
|
-
if (!xd || !xd[0] || !yd || !yd[0]) {
|
|
20828
|
-
return new Ctor(!x.s || !y.s || (xd ? yd && xd[0] == yd[0] : !yd) ? NaN : xd && xd[0] == 0 || !yd ? sign * 0 : sign / 0);
|
|
20829
|
-
}
|
|
20830
|
-
if (base) {
|
|
20831
|
-
logBase = 1;
|
|
20832
|
-
e = x.e - y.e;
|
|
20833
|
-
} else {
|
|
20834
|
-
base = BASE;
|
|
20835
|
-
logBase = LOG_BASE;
|
|
20836
|
-
e = mathfloor(x.e / logBase) - mathfloor(y.e / logBase);
|
|
20837
|
-
}
|
|
20838
|
-
yL = yd.length;
|
|
20839
|
-
xL = xd.length;
|
|
20840
|
-
q = new Ctor(sign);
|
|
20841
|
-
qd = q.d = [];
|
|
20842
|
-
for (i = 0;yd[i] == (xd[i] || 0); i++)
|
|
20843
|
-
;
|
|
20844
|
-
if (yd[i] > (xd[i] || 0))
|
|
20845
|
-
e--;
|
|
20846
|
-
if (pr == null) {
|
|
20847
|
-
sd = pr = Ctor.precision;
|
|
20848
|
-
rm = Ctor.rounding;
|
|
20849
|
-
} else if (dp) {
|
|
20850
|
-
sd = pr + (x.e - y.e) + 1;
|
|
20851
|
-
} else {
|
|
20852
|
-
sd = pr;
|
|
20853
|
-
}
|
|
20854
|
-
if (sd < 0) {
|
|
20855
|
-
qd.push(1);
|
|
20856
|
-
more = true;
|
|
20857
|
-
} else {
|
|
20858
|
-
sd = sd / logBase + 2 | 0;
|
|
20859
|
-
i = 0;
|
|
20860
|
-
if (yL == 1) {
|
|
20861
|
-
k = 0;
|
|
20862
|
-
yd = yd[0];
|
|
20863
|
-
sd++;
|
|
20864
|
-
for (;(i < xL || k) && sd--; i++) {
|
|
20865
|
-
t = k * base + (xd[i] || 0);
|
|
20866
|
-
qd[i] = t / yd | 0;
|
|
20867
|
-
k = t % yd | 0;
|
|
20868
|
-
}
|
|
20869
|
-
more = k || i < xL;
|
|
20870
|
-
} else {
|
|
20871
|
-
k = base / (yd[0] + 1) | 0;
|
|
20872
|
-
if (k > 1) {
|
|
20873
|
-
yd = multiplyInteger(yd, k, base);
|
|
20874
|
-
xd = multiplyInteger(xd, k, base);
|
|
20875
|
-
yL = yd.length;
|
|
20876
|
-
xL = xd.length;
|
|
20877
|
-
}
|
|
20878
|
-
xi = yL;
|
|
20879
|
-
rem = xd.slice(0, yL);
|
|
20880
|
-
remL = rem.length;
|
|
20881
|
-
for (;remL < yL; )
|
|
20882
|
-
rem[remL++] = 0;
|
|
20883
|
-
yz = yd.slice();
|
|
20884
|
-
yz.unshift(0);
|
|
20885
|
-
yd0 = yd[0];
|
|
20886
|
-
if (yd[1] >= base / 2)
|
|
20887
|
-
++yd0;
|
|
20888
|
-
do {
|
|
20889
|
-
k = 0;
|
|
20890
|
-
cmp = compare(yd, rem, yL, remL);
|
|
20891
|
-
if (cmp < 0) {
|
|
20892
|
-
rem0 = rem[0];
|
|
20893
|
-
if (yL != remL)
|
|
20894
|
-
rem0 = rem0 * base + (rem[1] || 0);
|
|
20895
|
-
k = rem0 / yd0 | 0;
|
|
20896
|
-
if (k > 1) {
|
|
20897
|
-
if (k >= base)
|
|
20898
|
-
k = base - 1;
|
|
20899
|
-
prod = multiplyInteger(yd, k, base);
|
|
20900
|
-
prodL = prod.length;
|
|
20901
|
-
remL = rem.length;
|
|
20902
|
-
cmp = compare(prod, rem, prodL, remL);
|
|
20903
|
-
if (cmp == 1) {
|
|
20904
|
-
k--;
|
|
20905
|
-
subtract(prod, yL < prodL ? yz : yd, prodL, base);
|
|
20906
|
-
}
|
|
20907
|
-
} else {
|
|
20908
|
-
if (k == 0)
|
|
20909
|
-
cmp = k = 1;
|
|
20910
|
-
prod = yd.slice();
|
|
20911
|
-
}
|
|
20912
|
-
prodL = prod.length;
|
|
20913
|
-
if (prodL < remL)
|
|
20914
|
-
prod.unshift(0);
|
|
20915
|
-
subtract(rem, prod, remL, base);
|
|
20916
|
-
if (cmp == -1) {
|
|
20917
|
-
remL = rem.length;
|
|
20918
|
-
cmp = compare(yd, rem, yL, remL);
|
|
20919
|
-
if (cmp < 1) {
|
|
20920
|
-
k++;
|
|
20921
|
-
subtract(rem, yL < remL ? yz : yd, remL, base);
|
|
20922
|
-
}
|
|
20923
|
-
}
|
|
20924
|
-
remL = rem.length;
|
|
20925
|
-
} else if (cmp === 0) {
|
|
20926
|
-
k++;
|
|
20927
|
-
rem = [0];
|
|
20928
|
-
}
|
|
20929
|
-
qd[i++] = k;
|
|
20930
|
-
if (cmp && rem[0]) {
|
|
20931
|
-
rem[remL++] = xd[xi] || 0;
|
|
20932
|
-
} else {
|
|
20933
|
-
rem = [xd[xi]];
|
|
20934
|
-
remL = 1;
|
|
20935
|
-
}
|
|
20936
|
-
} while ((xi++ < xL || rem[0] !== undefined) && sd--);
|
|
20937
|
-
more = rem[0] !== undefined;
|
|
20938
|
-
}
|
|
20939
|
-
if (!qd[0])
|
|
20940
|
-
qd.shift();
|
|
20941
|
-
}
|
|
20942
|
-
if (logBase == 1) {
|
|
20943
|
-
q.e = e;
|
|
20944
|
-
inexact = more;
|
|
20945
|
-
} else {
|
|
20946
|
-
for (i = 1, k = qd[0];k >= 10; k /= 10)
|
|
20947
|
-
i++;
|
|
20948
|
-
q.e = i + e * logBase - 1;
|
|
20949
|
-
finalise(q, dp ? pr + q.e + 1 : pr, rm, more);
|
|
20950
|
-
}
|
|
20951
|
-
return q;
|
|
20952
|
-
};
|
|
20953
|
-
}();
|
|
20954
|
-
function finalise(x, sd, rm, isTruncated) {
|
|
20955
|
-
var digits, i, j, k, rd, roundUp, w, xd, xdi, Ctor = x.constructor;
|
|
20956
|
-
out:
|
|
20957
|
-
if (sd != null) {
|
|
20958
|
-
xd = x.d;
|
|
20959
|
-
if (!xd)
|
|
20960
|
-
return x;
|
|
20961
|
-
for (digits = 1, k = xd[0];k >= 10; k /= 10)
|
|
20962
|
-
digits++;
|
|
20963
|
-
i = sd - digits;
|
|
20964
|
-
if (i < 0) {
|
|
20965
|
-
i += LOG_BASE;
|
|
20966
|
-
j = sd;
|
|
20967
|
-
w = xd[xdi = 0];
|
|
20968
|
-
rd = w / mathpow(10, digits - j - 1) % 10 | 0;
|
|
20969
|
-
} else {
|
|
20970
|
-
xdi = Math.ceil((i + 1) / LOG_BASE);
|
|
20971
|
-
k = xd.length;
|
|
20972
|
-
if (xdi >= k) {
|
|
20973
|
-
if (isTruncated) {
|
|
20974
|
-
for (;k++ <= xdi; )
|
|
20975
|
-
xd.push(0);
|
|
20976
|
-
w = rd = 0;
|
|
20977
|
-
digits = 1;
|
|
20978
|
-
i %= LOG_BASE;
|
|
20979
|
-
j = i - LOG_BASE + 1;
|
|
20980
|
-
} else {
|
|
20981
|
-
break out;
|
|
20982
|
-
}
|
|
20983
|
-
} else {
|
|
20984
|
-
w = k = xd[xdi];
|
|
20985
|
-
for (digits = 1;k >= 10; k /= 10)
|
|
20986
|
-
digits++;
|
|
20987
|
-
i %= LOG_BASE;
|
|
20988
|
-
j = i - LOG_BASE + digits;
|
|
20989
|
-
rd = j < 0 ? 0 : w / mathpow(10, digits - j - 1) % 10 | 0;
|
|
20990
|
-
}
|
|
20991
|
-
}
|
|
20992
|
-
isTruncated = isTruncated || sd < 0 || xd[xdi + 1] !== undefined || (j < 0 ? w : w % mathpow(10, digits - j - 1));
|
|
20993
|
-
roundUp = rm < 4 ? (rd || isTruncated) && (rm == 0 || rm == (x.s < 0 ? 3 : 2)) : rd > 5 || rd == 5 && (rm == 4 || isTruncated || rm == 6 && (i > 0 ? j > 0 ? w / mathpow(10, digits - j) : 0 : xd[xdi - 1]) % 10 & 1 || rm == (x.s < 0 ? 8 : 7));
|
|
20994
|
-
if (sd < 1 || !xd[0]) {
|
|
20995
|
-
xd.length = 0;
|
|
20996
|
-
if (roundUp) {
|
|
20997
|
-
sd -= x.e + 1;
|
|
20998
|
-
xd[0] = mathpow(10, (LOG_BASE - sd % LOG_BASE) % LOG_BASE);
|
|
20999
|
-
x.e = -sd || 0;
|
|
21000
|
-
} else {
|
|
21001
|
-
xd[0] = x.e = 0;
|
|
21002
|
-
}
|
|
21003
|
-
return x;
|
|
21004
|
-
}
|
|
21005
|
-
if (i == 0) {
|
|
21006
|
-
xd.length = xdi;
|
|
21007
|
-
k = 1;
|
|
21008
|
-
xdi--;
|
|
21009
|
-
} else {
|
|
21010
|
-
xd.length = xdi + 1;
|
|
21011
|
-
k = mathpow(10, LOG_BASE - i);
|
|
21012
|
-
xd[xdi] = j > 0 ? (w / mathpow(10, digits - j) % mathpow(10, j) | 0) * k : 0;
|
|
21013
|
-
}
|
|
21014
|
-
if (roundUp) {
|
|
21015
|
-
for (;; ) {
|
|
21016
|
-
if (xdi == 0) {
|
|
21017
|
-
for (i = 1, j = xd[0];j >= 10; j /= 10)
|
|
21018
|
-
i++;
|
|
21019
|
-
j = xd[0] += k;
|
|
21020
|
-
for (k = 1;j >= 10; j /= 10)
|
|
21021
|
-
k++;
|
|
21022
|
-
if (i != k) {
|
|
21023
|
-
x.e++;
|
|
21024
|
-
if (xd[0] == BASE)
|
|
21025
|
-
xd[0] = 1;
|
|
21026
|
-
}
|
|
21027
|
-
break;
|
|
21028
|
-
} else {
|
|
21029
|
-
xd[xdi] += k;
|
|
21030
|
-
if (xd[xdi] != BASE)
|
|
21031
|
-
break;
|
|
21032
|
-
xd[xdi--] = 0;
|
|
21033
|
-
k = 1;
|
|
21034
|
-
}
|
|
21035
|
-
}
|
|
21036
|
-
}
|
|
21037
|
-
for (i = xd.length;xd[--i] === 0; )
|
|
21038
|
-
xd.pop();
|
|
21039
|
-
}
|
|
21040
|
-
if (external2) {
|
|
21041
|
-
if (x.e > Ctor.maxE) {
|
|
21042
|
-
x.d = null;
|
|
21043
|
-
x.e = NaN;
|
|
21044
|
-
} else if (x.e < Ctor.minE) {
|
|
21045
|
-
x.e = 0;
|
|
21046
|
-
x.d = [0];
|
|
21047
|
-
}
|
|
21048
|
-
}
|
|
21049
|
-
return x;
|
|
21050
|
-
}
|
|
21051
|
-
function finiteToString(x, isExp, sd) {
|
|
21052
|
-
if (!x.isFinite())
|
|
21053
|
-
return nonFiniteToString(x);
|
|
21054
|
-
var k, e = x.e, str = digitsToString(x.d), len = str.length;
|
|
21055
|
-
if (isExp) {
|
|
21056
|
-
if (sd && (k = sd - len) > 0) {
|
|
21057
|
-
str = str.charAt(0) + "." + str.slice(1) + getZeroString(k);
|
|
21058
|
-
} else if (len > 1) {
|
|
21059
|
-
str = str.charAt(0) + "." + str.slice(1);
|
|
21060
|
-
}
|
|
21061
|
-
str = str + (x.e < 0 ? "e" : "e+") + x.e;
|
|
21062
|
-
} else if (e < 0) {
|
|
21063
|
-
str = "0." + getZeroString(-e - 1) + str;
|
|
21064
|
-
if (sd && (k = sd - len) > 0)
|
|
21065
|
-
str += getZeroString(k);
|
|
21066
|
-
} else if (e >= len) {
|
|
21067
|
-
str += getZeroString(e + 1 - len);
|
|
21068
|
-
if (sd && (k = sd - e - 1) > 0)
|
|
21069
|
-
str = str + "." + getZeroString(k);
|
|
21070
|
-
} else {
|
|
21071
|
-
if ((k = e + 1) < len)
|
|
21072
|
-
str = str.slice(0, k) + "." + str.slice(k);
|
|
21073
|
-
if (sd && (k = sd - len) > 0) {
|
|
21074
|
-
if (e + 1 === len)
|
|
21075
|
-
str += ".";
|
|
21076
|
-
str += getZeroString(k);
|
|
21077
|
-
}
|
|
21078
|
-
}
|
|
21079
|
-
return str;
|
|
21080
|
-
}
|
|
21081
|
-
function getBase10Exponent(digits, e) {
|
|
21082
|
-
var w = digits[0];
|
|
21083
|
-
for (e *= LOG_BASE;w >= 10; w /= 10)
|
|
21084
|
-
e++;
|
|
21085
|
-
return e;
|
|
21086
|
-
}
|
|
21087
|
-
function getLn10(Ctor, sd, pr) {
|
|
21088
|
-
if (sd > LN10_PRECISION) {
|
|
21089
|
-
external2 = true;
|
|
21090
|
-
if (pr)
|
|
21091
|
-
Ctor.precision = pr;
|
|
21092
|
-
throw Error(precisionLimitExceeded);
|
|
21093
|
-
}
|
|
21094
|
-
return finalise(new Ctor(LN10), sd, 1, true);
|
|
21095
|
-
}
|
|
21096
|
-
function getPi(Ctor, sd, rm) {
|
|
21097
|
-
if (sd > PI_PRECISION)
|
|
21098
|
-
throw Error(precisionLimitExceeded);
|
|
21099
|
-
return finalise(new Ctor(PI), sd, rm, true);
|
|
21100
|
-
}
|
|
21101
|
-
function getPrecision(digits) {
|
|
21102
|
-
var w = digits.length - 1, len = w * LOG_BASE + 1;
|
|
21103
|
-
w = digits[w];
|
|
21104
|
-
if (w) {
|
|
21105
|
-
for (;w % 10 == 0; w /= 10)
|
|
21106
|
-
len--;
|
|
21107
|
-
for (w = digits[0];w >= 10; w /= 10)
|
|
21108
|
-
len++;
|
|
21109
|
-
}
|
|
21110
|
-
return len;
|
|
21111
|
-
}
|
|
21112
|
-
function getZeroString(k) {
|
|
21113
|
-
var zs = "";
|
|
21114
|
-
for (;k--; )
|
|
21115
|
-
zs += "0";
|
|
21116
|
-
return zs;
|
|
21117
|
-
}
|
|
21118
|
-
function intPow(Ctor, x, n, pr) {
|
|
21119
|
-
var isTruncated, r = new Ctor(1), k = Math.ceil(pr / LOG_BASE + 4);
|
|
21120
|
-
external2 = false;
|
|
21121
|
-
for (;; ) {
|
|
21122
|
-
if (n % 2) {
|
|
21123
|
-
r = r.times(x);
|
|
21124
|
-
if (truncate(r.d, k))
|
|
21125
|
-
isTruncated = true;
|
|
21126
|
-
}
|
|
21127
|
-
n = mathfloor(n / 2);
|
|
21128
|
-
if (n === 0) {
|
|
21129
|
-
n = r.d.length - 1;
|
|
21130
|
-
if (isTruncated && r.d[n] === 0)
|
|
21131
|
-
++r.d[n];
|
|
21132
|
-
break;
|
|
21133
|
-
}
|
|
21134
|
-
x = x.times(x);
|
|
21135
|
-
truncate(x.d, k);
|
|
21136
|
-
}
|
|
21137
|
-
external2 = true;
|
|
21138
|
-
return r;
|
|
21139
|
-
}
|
|
21140
|
-
function isOdd(n) {
|
|
21141
|
-
return n.d[n.d.length - 1] & 1;
|
|
21142
|
-
}
|
|
21143
|
-
function maxOrMin(Ctor, args, n) {
|
|
21144
|
-
var k, y, x = new Ctor(args[0]), i = 0;
|
|
21145
|
-
for (;++i < args.length; ) {
|
|
21146
|
-
y = new Ctor(args[i]);
|
|
21147
|
-
if (!y.s) {
|
|
21148
|
-
x = y;
|
|
21149
|
-
break;
|
|
21150
|
-
}
|
|
21151
|
-
k = x.cmp(y);
|
|
21152
|
-
if (k === n || k === 0 && x.s === n) {
|
|
21153
|
-
x = y;
|
|
21154
|
-
}
|
|
21155
|
-
}
|
|
21156
|
-
return x;
|
|
21157
|
-
}
|
|
21158
|
-
function naturalExponential(x, sd) {
|
|
21159
|
-
var denominator, guard, j, pow, sum, t, wpr, rep = 0, i = 0, k = 0, Ctor = x.constructor, rm = Ctor.rounding, pr = Ctor.precision;
|
|
21160
|
-
if (!x.d || !x.d[0] || x.e > 17) {
|
|
21161
|
-
return new Ctor(x.d ? !x.d[0] ? 1 : x.s < 0 ? 0 : 1 / 0 : x.s ? x.s < 0 ? 0 : x : 0 / 0);
|
|
21162
|
-
}
|
|
21163
|
-
if (sd == null) {
|
|
21164
|
-
external2 = false;
|
|
21165
|
-
wpr = pr;
|
|
21166
|
-
} else {
|
|
21167
|
-
wpr = sd;
|
|
21168
|
-
}
|
|
21169
|
-
t = new Ctor(0.03125);
|
|
21170
|
-
while (x.e > -2) {
|
|
21171
|
-
x = x.times(t);
|
|
21172
|
-
k += 5;
|
|
21173
|
-
}
|
|
21174
|
-
guard = Math.log(mathpow(2, k)) / Math.LN10 * 2 + 5 | 0;
|
|
21175
|
-
wpr += guard;
|
|
21176
|
-
denominator = pow = sum = new Ctor(1);
|
|
21177
|
-
Ctor.precision = wpr;
|
|
21178
|
-
for (;; ) {
|
|
21179
|
-
pow = finalise(pow.times(x), wpr, 1);
|
|
21180
|
-
denominator = denominator.times(++i);
|
|
21181
|
-
t = sum.plus(divide(pow, denominator, wpr, 1));
|
|
21182
|
-
if (digitsToString(t.d).slice(0, wpr) === digitsToString(sum.d).slice(0, wpr)) {
|
|
21183
|
-
j = k;
|
|
21184
|
-
while (j--)
|
|
21185
|
-
sum = finalise(sum.times(sum), wpr, 1);
|
|
21186
|
-
if (sd == null) {
|
|
21187
|
-
if (rep < 3 && checkRoundingDigits(sum.d, wpr - guard, rm, rep)) {
|
|
21188
|
-
Ctor.precision = wpr += 10;
|
|
21189
|
-
denominator = pow = t = new Ctor(1);
|
|
21190
|
-
i = 0;
|
|
21191
|
-
rep++;
|
|
21192
|
-
} else {
|
|
21193
|
-
return finalise(sum, Ctor.precision = pr, rm, external2 = true);
|
|
21194
|
-
}
|
|
21195
|
-
} else {
|
|
21196
|
-
Ctor.precision = pr;
|
|
21197
|
-
return sum;
|
|
21198
|
-
}
|
|
21199
|
-
}
|
|
21200
|
-
sum = t;
|
|
21201
|
-
}
|
|
21202
|
-
}
|
|
21203
|
-
function naturalLogarithm(y, sd) {
|
|
21204
|
-
var c, c0, denominator, e, numerator, rep, sum, t, wpr, x1, x2, n = 1, guard = 10, x = y, xd = x.d, Ctor = x.constructor, rm = Ctor.rounding, pr = Ctor.precision;
|
|
21205
|
-
if (x.s < 0 || !xd || !xd[0] || !x.e && xd[0] == 1 && xd.length == 1) {
|
|
21206
|
-
return new Ctor(xd && !xd[0] ? -1 / 0 : x.s != 1 ? NaN : xd ? 0 : x);
|
|
21207
|
-
}
|
|
21208
|
-
if (sd == null) {
|
|
21209
|
-
external2 = false;
|
|
21210
|
-
wpr = pr;
|
|
21211
|
-
} else {
|
|
21212
|
-
wpr = sd;
|
|
21213
|
-
}
|
|
21214
|
-
Ctor.precision = wpr += guard;
|
|
21215
|
-
c = digitsToString(xd);
|
|
21216
|
-
c0 = c.charAt(0);
|
|
21217
|
-
if (Math.abs(e = x.e) < 1500000000000000) {
|
|
21218
|
-
while (c0 < 7 && c0 != 1 || c0 == 1 && c.charAt(1) > 3) {
|
|
21219
|
-
x = x.times(y);
|
|
21220
|
-
c = digitsToString(x.d);
|
|
21221
|
-
c0 = c.charAt(0);
|
|
21222
|
-
n++;
|
|
21223
|
-
}
|
|
21224
|
-
e = x.e;
|
|
21225
|
-
if (c0 > 1) {
|
|
21226
|
-
x = new Ctor("0." + c);
|
|
21227
|
-
e++;
|
|
21228
|
-
} else {
|
|
21229
|
-
x = new Ctor(c0 + "." + c.slice(1));
|
|
21230
|
-
}
|
|
21231
|
-
} else {
|
|
21232
|
-
t = getLn10(Ctor, wpr + 2, pr).times(e + "");
|
|
21233
|
-
x = naturalLogarithm(new Ctor(c0 + "." + c.slice(1)), wpr - guard).plus(t);
|
|
21234
|
-
Ctor.precision = pr;
|
|
21235
|
-
return sd == null ? finalise(x, pr, rm, external2 = true) : x;
|
|
21236
|
-
}
|
|
21237
|
-
x1 = x;
|
|
21238
|
-
sum = numerator = x = divide(x.minus(1), x.plus(1), wpr, 1);
|
|
21239
|
-
x2 = finalise(x.times(x), wpr, 1);
|
|
21240
|
-
denominator = 3;
|
|
21241
|
-
for (;; ) {
|
|
21242
|
-
numerator = finalise(numerator.times(x2), wpr, 1);
|
|
21243
|
-
t = sum.plus(divide(numerator, new Ctor(denominator), wpr, 1));
|
|
21244
|
-
if (digitsToString(t.d).slice(0, wpr) === digitsToString(sum.d).slice(0, wpr)) {
|
|
21245
|
-
sum = sum.times(2);
|
|
21246
|
-
if (e !== 0)
|
|
21247
|
-
sum = sum.plus(getLn10(Ctor, wpr + 2, pr).times(e + ""));
|
|
21248
|
-
sum = divide(sum, new Ctor(n), wpr, 1);
|
|
21249
|
-
if (sd == null) {
|
|
21250
|
-
if (checkRoundingDigits(sum.d, wpr - guard, rm, rep)) {
|
|
21251
|
-
Ctor.precision = wpr += guard;
|
|
21252
|
-
t = numerator = x = divide(x1.minus(1), x1.plus(1), wpr, 1);
|
|
21253
|
-
x2 = finalise(x.times(x), wpr, 1);
|
|
21254
|
-
denominator = rep = 1;
|
|
21255
|
-
} else {
|
|
21256
|
-
return finalise(sum, Ctor.precision = pr, rm, external2 = true);
|
|
21257
|
-
}
|
|
21258
|
-
} else {
|
|
21259
|
-
Ctor.precision = pr;
|
|
21260
|
-
return sum;
|
|
21261
|
-
}
|
|
21262
|
-
}
|
|
21263
|
-
sum = t;
|
|
21264
|
-
denominator += 2;
|
|
21265
|
-
}
|
|
21266
|
-
}
|
|
21267
|
-
function nonFiniteToString(x) {
|
|
21268
|
-
return String(x.s * x.s / 0);
|
|
21269
|
-
}
|
|
21270
|
-
function parseDecimal(x, str) {
|
|
21271
|
-
var e, i, len;
|
|
21272
|
-
if ((e = str.indexOf(".")) > -1)
|
|
21273
|
-
str = str.replace(".", "");
|
|
21274
|
-
if ((i = str.search(/e/i)) > 0) {
|
|
21275
|
-
if (e < 0)
|
|
21276
|
-
e = i;
|
|
21277
|
-
e += +str.slice(i + 1);
|
|
21278
|
-
str = str.substring(0, i);
|
|
21279
|
-
} else if (e < 0) {
|
|
21280
|
-
e = str.length;
|
|
21281
|
-
}
|
|
21282
|
-
for (i = 0;str.charCodeAt(i) === 48; i++)
|
|
21283
|
-
;
|
|
21284
|
-
for (len = str.length;str.charCodeAt(len - 1) === 48; --len)
|
|
21285
|
-
;
|
|
21286
|
-
str = str.slice(i, len);
|
|
21287
|
-
if (str) {
|
|
21288
|
-
len -= i;
|
|
21289
|
-
x.e = e = e - i - 1;
|
|
21290
|
-
x.d = [];
|
|
21291
|
-
i = (e + 1) % LOG_BASE;
|
|
21292
|
-
if (e < 0)
|
|
21293
|
-
i += LOG_BASE;
|
|
21294
|
-
if (i < len) {
|
|
21295
|
-
if (i)
|
|
21296
|
-
x.d.push(+str.slice(0, i));
|
|
21297
|
-
for (len -= LOG_BASE;i < len; )
|
|
21298
|
-
x.d.push(+str.slice(i, i += LOG_BASE));
|
|
21299
|
-
str = str.slice(i);
|
|
21300
|
-
i = LOG_BASE - str.length;
|
|
21301
|
-
} else {
|
|
21302
|
-
i -= len;
|
|
21303
|
-
}
|
|
21304
|
-
for (;i--; )
|
|
21305
|
-
str += "0";
|
|
21306
|
-
x.d.push(+str);
|
|
21307
|
-
if (external2) {
|
|
21308
|
-
if (x.e > x.constructor.maxE) {
|
|
21309
|
-
x.d = null;
|
|
21310
|
-
x.e = NaN;
|
|
21311
|
-
} else if (x.e < x.constructor.minE) {
|
|
21312
|
-
x.e = 0;
|
|
21313
|
-
x.d = [0];
|
|
21314
|
-
}
|
|
21315
|
-
}
|
|
21316
|
-
} else {
|
|
21317
|
-
x.e = 0;
|
|
21318
|
-
x.d = [0];
|
|
21319
|
-
}
|
|
21320
|
-
return x;
|
|
21321
|
-
}
|
|
21322
|
-
function parseOther(x, str) {
|
|
21323
|
-
var base, Ctor, divisor, i, isFloat, len, p, xd, xe;
|
|
21324
|
-
if (str.indexOf("_") > -1) {
|
|
21325
|
-
str = str.replace(/(\d)_(?=\d)/g, "$1");
|
|
21326
|
-
if (isDecimal.test(str))
|
|
21327
|
-
return parseDecimal(x, str);
|
|
21328
|
-
} else if (str === "Infinity" || str === "NaN") {
|
|
21329
|
-
if (!+str)
|
|
21330
|
-
x.s = NaN;
|
|
21331
|
-
x.e = NaN;
|
|
21332
|
-
x.d = null;
|
|
21333
|
-
return x;
|
|
21334
|
-
}
|
|
21335
|
-
if (isHex.test(str)) {
|
|
21336
|
-
base = 16;
|
|
21337
|
-
str = str.toLowerCase();
|
|
21338
|
-
} else if (isBinary.test(str)) {
|
|
21339
|
-
base = 2;
|
|
21340
|
-
} else if (isOctal.test(str)) {
|
|
21341
|
-
base = 8;
|
|
21342
|
-
} else {
|
|
21343
|
-
throw Error(invalidArgument + str);
|
|
21344
|
-
}
|
|
21345
|
-
i = str.search(/p/i);
|
|
21346
|
-
if (i > 0) {
|
|
21347
|
-
p = +str.slice(i + 1);
|
|
21348
|
-
str = str.substring(2, i);
|
|
21349
|
-
} else {
|
|
21350
|
-
str = str.slice(2);
|
|
21351
|
-
}
|
|
21352
|
-
i = str.indexOf(".");
|
|
21353
|
-
isFloat = i >= 0;
|
|
21354
|
-
Ctor = x.constructor;
|
|
21355
|
-
if (isFloat) {
|
|
21356
|
-
str = str.replace(".", "");
|
|
21357
|
-
len = str.length;
|
|
21358
|
-
i = len - i;
|
|
21359
|
-
divisor = intPow(Ctor, new Ctor(base), i, i * 2);
|
|
21360
|
-
}
|
|
21361
|
-
xd = convertBase(str, base, BASE);
|
|
21362
|
-
xe = xd.length - 1;
|
|
21363
|
-
for (i = xe;xd[i] === 0; --i)
|
|
21364
|
-
xd.pop();
|
|
21365
|
-
if (i < 0)
|
|
21366
|
-
return new Ctor(x.s * 0);
|
|
21367
|
-
x.e = getBase10Exponent(xd, xe);
|
|
21368
|
-
x.d = xd;
|
|
21369
|
-
external2 = false;
|
|
21370
|
-
if (isFloat)
|
|
21371
|
-
x = divide(x, divisor, len * 4);
|
|
21372
|
-
if (p)
|
|
21373
|
-
x = x.times(Math.abs(p) < 54 ? mathpow(2, p) : Decimal.pow(2, p));
|
|
21374
|
-
external2 = true;
|
|
21375
|
-
return x;
|
|
21376
|
-
}
|
|
21377
|
-
function sine(Ctor, x) {
|
|
21378
|
-
var k, len = x.d.length;
|
|
21379
|
-
if (len < 3) {
|
|
21380
|
-
return x.isZero() ? x : taylorSeries(Ctor, 2, x, x);
|
|
21381
|
-
}
|
|
21382
|
-
k = 1.4 * Math.sqrt(len);
|
|
21383
|
-
k = k > 16 ? 16 : k | 0;
|
|
21384
|
-
x = x.times(1 / tinyPow(5, k));
|
|
21385
|
-
x = taylorSeries(Ctor, 2, x, x);
|
|
21386
|
-
var sin2_x, d5 = new Ctor(5), d16 = new Ctor(16), d20 = new Ctor(20);
|
|
21387
|
-
for (;k--; ) {
|
|
21388
|
-
sin2_x = x.times(x);
|
|
21389
|
-
x = x.times(d5.plus(sin2_x.times(d16.times(sin2_x).minus(d20))));
|
|
21390
|
-
}
|
|
21391
|
-
return x;
|
|
21392
|
-
}
|
|
21393
|
-
function taylorSeries(Ctor, n, x, y, isHyperbolic) {
|
|
21394
|
-
var j, t, u, x2, i = 1, pr = Ctor.precision, k = Math.ceil(pr / LOG_BASE);
|
|
21395
|
-
external2 = false;
|
|
21396
|
-
x2 = x.times(x);
|
|
21397
|
-
u = new Ctor(y);
|
|
21398
|
-
for (;; ) {
|
|
21399
|
-
t = divide(u.times(x2), new Ctor(n++ * n++), pr, 1);
|
|
21400
|
-
u = isHyperbolic ? y.plus(t) : y.minus(t);
|
|
21401
|
-
y = divide(t.times(x2), new Ctor(n++ * n++), pr, 1);
|
|
21402
|
-
t = u.plus(y);
|
|
21403
|
-
if (t.d[k] !== undefined) {
|
|
21404
|
-
for (j = k;t.d[j] === u.d[j] && j--; )
|
|
21405
|
-
;
|
|
21406
|
-
if (j == -1)
|
|
21407
|
-
break;
|
|
21408
|
-
}
|
|
21409
|
-
j = u;
|
|
21410
|
-
u = y;
|
|
21411
|
-
y = t;
|
|
21412
|
-
t = j;
|
|
21413
|
-
i++;
|
|
21414
|
-
}
|
|
21415
|
-
external2 = true;
|
|
21416
|
-
t.d.length = k + 1;
|
|
21417
|
-
return t;
|
|
21418
|
-
}
|
|
21419
|
-
function tinyPow(b, e) {
|
|
21420
|
-
var n = b;
|
|
21421
|
-
while (--e)
|
|
21422
|
-
n *= b;
|
|
21423
|
-
return n;
|
|
21424
|
-
}
|
|
21425
|
-
function toLessThanHalfPi(Ctor, x) {
|
|
21426
|
-
var t, isNeg = x.s < 0, pi = getPi(Ctor, Ctor.precision, 1), halfPi = pi.times(0.5);
|
|
21427
|
-
x = x.abs();
|
|
21428
|
-
if (x.lte(halfPi)) {
|
|
21429
|
-
quadrant = isNeg ? 4 : 1;
|
|
21430
|
-
return x;
|
|
21431
|
-
}
|
|
21432
|
-
t = x.divToInt(pi);
|
|
21433
|
-
if (t.isZero()) {
|
|
21434
|
-
quadrant = isNeg ? 3 : 2;
|
|
21435
|
-
} else {
|
|
21436
|
-
x = x.minus(t.times(pi));
|
|
21437
|
-
if (x.lte(halfPi)) {
|
|
21438
|
-
quadrant = isOdd(t) ? isNeg ? 2 : 3 : isNeg ? 4 : 1;
|
|
21439
|
-
return x;
|
|
21440
|
-
}
|
|
21441
|
-
quadrant = isOdd(t) ? isNeg ? 1 : 4 : isNeg ? 3 : 2;
|
|
21442
|
-
}
|
|
21443
|
-
return x.minus(pi).abs();
|
|
21444
|
-
}
|
|
21445
|
-
function toStringBinary(x, baseOut, sd, rm) {
|
|
21446
|
-
var base, e, i, k, len, roundUp, str, xd, y, Ctor = x.constructor, isExp = sd !== undefined;
|
|
21447
|
-
if (isExp) {
|
|
21448
|
-
checkInt32(sd, 1, MAX_DIGITS);
|
|
21449
|
-
if (rm === undefined)
|
|
21450
|
-
rm = Ctor.rounding;
|
|
21451
|
-
else
|
|
21452
|
-
checkInt32(rm, 0, 8);
|
|
21453
|
-
} else {
|
|
21454
|
-
sd = Ctor.precision;
|
|
21455
|
-
rm = Ctor.rounding;
|
|
21456
|
-
}
|
|
21457
|
-
if (!x.isFinite()) {
|
|
21458
|
-
str = nonFiniteToString(x);
|
|
21459
|
-
} else {
|
|
21460
|
-
str = finiteToString(x);
|
|
21461
|
-
i = str.indexOf(".");
|
|
21462
|
-
if (isExp) {
|
|
21463
|
-
base = 2;
|
|
21464
|
-
if (baseOut == 16) {
|
|
21465
|
-
sd = sd * 4 - 3;
|
|
21466
|
-
} else if (baseOut == 8) {
|
|
21467
|
-
sd = sd * 3 - 2;
|
|
21468
|
-
}
|
|
21469
|
-
} else {
|
|
21470
|
-
base = baseOut;
|
|
21471
|
-
}
|
|
21472
|
-
if (i >= 0) {
|
|
21473
|
-
str = str.replace(".", "");
|
|
21474
|
-
y = new Ctor(1);
|
|
21475
|
-
y.e = str.length - i;
|
|
21476
|
-
y.d = convertBase(finiteToString(y), 10, base);
|
|
21477
|
-
y.e = y.d.length;
|
|
21478
|
-
}
|
|
21479
|
-
xd = convertBase(str, 10, base);
|
|
21480
|
-
e = len = xd.length;
|
|
21481
|
-
for (;xd[--len] == 0; )
|
|
21482
|
-
xd.pop();
|
|
21483
|
-
if (!xd[0]) {
|
|
21484
|
-
str = isExp ? "0p+0" : "0";
|
|
21485
|
-
} else {
|
|
21486
|
-
if (i < 0) {
|
|
21487
|
-
e--;
|
|
21488
|
-
} else {
|
|
21489
|
-
x = new Ctor(x);
|
|
21490
|
-
x.d = xd;
|
|
21491
|
-
x.e = e;
|
|
21492
|
-
x = divide(x, y, sd, rm, 0, base);
|
|
21493
|
-
xd = x.d;
|
|
21494
|
-
e = x.e;
|
|
21495
|
-
roundUp = inexact;
|
|
21496
|
-
}
|
|
21497
|
-
i = xd[sd];
|
|
21498
|
-
k = base / 2;
|
|
21499
|
-
roundUp = roundUp || xd[sd + 1] !== undefined;
|
|
21500
|
-
roundUp = rm < 4 ? (i !== undefined || roundUp) && (rm === 0 || rm === (x.s < 0 ? 3 : 2)) : i > k || i === k && (rm === 4 || roundUp || rm === 6 && xd[sd - 1] & 1 || rm === (x.s < 0 ? 8 : 7));
|
|
21501
|
-
xd.length = sd;
|
|
21502
|
-
if (roundUp) {
|
|
21503
|
-
for (;++xd[--sd] > base - 1; ) {
|
|
21504
|
-
xd[sd] = 0;
|
|
21505
|
-
if (!sd) {
|
|
21506
|
-
++e;
|
|
21507
|
-
xd.unshift(1);
|
|
21508
|
-
}
|
|
21509
|
-
}
|
|
21510
|
-
}
|
|
21511
|
-
for (len = xd.length;!xd[len - 1]; --len)
|
|
21512
|
-
;
|
|
21513
|
-
for (i = 0, str = "";i < len; i++)
|
|
21514
|
-
str += NUMERALS.charAt(xd[i]);
|
|
21515
|
-
if (isExp) {
|
|
21516
|
-
if (len > 1) {
|
|
21517
|
-
if (baseOut == 16 || baseOut == 8) {
|
|
21518
|
-
i = baseOut == 16 ? 4 : 3;
|
|
21519
|
-
for (--len;len % i; len++)
|
|
21520
|
-
str += "0";
|
|
21521
|
-
xd = convertBase(str, base, baseOut);
|
|
21522
|
-
for (len = xd.length;!xd[len - 1]; --len)
|
|
21523
|
-
;
|
|
21524
|
-
for (i = 1, str = "1.";i < len; i++)
|
|
21525
|
-
str += NUMERALS.charAt(xd[i]);
|
|
21526
|
-
} else {
|
|
21527
|
-
str = str.charAt(0) + "." + str.slice(1);
|
|
21528
|
-
}
|
|
21529
|
-
}
|
|
21530
|
-
str = str + (e < 0 ? "p" : "p+") + e;
|
|
21531
|
-
} else if (e < 0) {
|
|
21532
|
-
for (;++e; )
|
|
21533
|
-
str = "0" + str;
|
|
21534
|
-
str = "0." + str;
|
|
21535
|
-
} else {
|
|
21536
|
-
if (++e > len)
|
|
21537
|
-
for (e -= len;e--; )
|
|
21538
|
-
str += "0";
|
|
21539
|
-
else if (e < len)
|
|
21540
|
-
str = str.slice(0, e) + "." + str.slice(e);
|
|
21541
|
-
}
|
|
21542
|
-
}
|
|
21543
|
-
str = (baseOut == 16 ? "0x" : baseOut == 2 ? "0b" : baseOut == 8 ? "0o" : "") + str;
|
|
21544
|
-
}
|
|
21545
|
-
return x.s < 0 ? "-" + str : str;
|
|
21546
|
-
}
|
|
21547
|
-
function truncate(arr, len) {
|
|
21548
|
-
if (arr.length > len) {
|
|
21549
|
-
arr.length = len;
|
|
21550
|
-
return true;
|
|
21551
|
-
}
|
|
21552
|
-
}
|
|
21553
|
-
function abs(x) {
|
|
21554
|
-
return new this(x).abs();
|
|
21555
|
-
}
|
|
21556
|
-
function acos(x) {
|
|
21557
|
-
return new this(x).acos();
|
|
21558
|
-
}
|
|
21559
|
-
function acosh(x) {
|
|
21560
|
-
return new this(x).acosh();
|
|
21561
|
-
}
|
|
21562
|
-
function add(x, y) {
|
|
21563
|
-
return new this(x).plus(y);
|
|
21564
|
-
}
|
|
21565
|
-
function asin(x) {
|
|
21566
|
-
return new this(x).asin();
|
|
21567
|
-
}
|
|
21568
|
-
function asinh(x) {
|
|
21569
|
-
return new this(x).asinh();
|
|
21570
|
-
}
|
|
21571
|
-
function atan(x) {
|
|
21572
|
-
return new this(x).atan();
|
|
21573
|
-
}
|
|
21574
|
-
function atanh(x) {
|
|
21575
|
-
return new this(x).atanh();
|
|
21576
|
-
}
|
|
21577
|
-
function atan2(y, x) {
|
|
21578
|
-
y = new this(y);
|
|
21579
|
-
x = new this(x);
|
|
21580
|
-
var r, pr = this.precision, rm = this.rounding, wpr = pr + 4;
|
|
21581
|
-
if (!y.s || !x.s) {
|
|
21582
|
-
r = new this(NaN);
|
|
21583
|
-
} else if (!y.d && !x.d) {
|
|
21584
|
-
r = getPi(this, wpr, 1).times(x.s > 0 ? 0.25 : 0.75);
|
|
21585
|
-
r.s = y.s;
|
|
21586
|
-
} else if (!x.d || y.isZero()) {
|
|
21587
|
-
r = x.s < 0 ? getPi(this, pr, rm) : new this(0);
|
|
21588
|
-
r.s = y.s;
|
|
21589
|
-
} else if (!y.d || x.isZero()) {
|
|
21590
|
-
r = getPi(this, wpr, 1).times(0.5);
|
|
21591
|
-
r.s = y.s;
|
|
21592
|
-
} else if (x.s < 0) {
|
|
21593
|
-
this.precision = wpr;
|
|
21594
|
-
this.rounding = 1;
|
|
21595
|
-
r = this.atan(divide(y, x, wpr, 1));
|
|
21596
|
-
x = getPi(this, wpr, 1);
|
|
21597
|
-
this.precision = pr;
|
|
21598
|
-
this.rounding = rm;
|
|
21599
|
-
r = y.s < 0 ? r.minus(x) : r.plus(x);
|
|
21600
|
-
} else {
|
|
21601
|
-
r = this.atan(divide(y, x, wpr, 1));
|
|
21602
|
-
}
|
|
21603
|
-
return r;
|
|
21604
|
-
}
|
|
21605
|
-
function cbrt(x) {
|
|
21606
|
-
return new this(x).cbrt();
|
|
21607
|
-
}
|
|
21608
|
-
function ceil(x) {
|
|
21609
|
-
return finalise(x = new this(x), x.e + 1, 2);
|
|
21610
|
-
}
|
|
21611
|
-
function clamp(x, min, max) {
|
|
21612
|
-
return new this(x).clamp(min, max);
|
|
21613
|
-
}
|
|
21614
|
-
function config(obj) {
|
|
21615
|
-
if (!obj || typeof obj !== "object")
|
|
21616
|
-
throw Error(decimalError + "Object expected");
|
|
21617
|
-
var i, p, v, useDefaults = obj.defaults === true, ps = [
|
|
21618
|
-
"precision",
|
|
21619
|
-
1,
|
|
21620
|
-
MAX_DIGITS,
|
|
21621
|
-
"rounding",
|
|
21622
|
-
0,
|
|
21623
|
-
8,
|
|
21624
|
-
"toExpNeg",
|
|
21625
|
-
-EXP_LIMIT,
|
|
21626
|
-
0,
|
|
21627
|
-
"toExpPos",
|
|
21628
|
-
0,
|
|
21629
|
-
EXP_LIMIT,
|
|
21630
|
-
"maxE",
|
|
21631
|
-
0,
|
|
21632
|
-
EXP_LIMIT,
|
|
21633
|
-
"minE",
|
|
21634
|
-
-EXP_LIMIT,
|
|
21635
|
-
0,
|
|
21636
|
-
"modulo",
|
|
21637
|
-
0,
|
|
21638
|
-
9
|
|
21639
|
-
];
|
|
21640
|
-
for (i = 0;i < ps.length; i += 3) {
|
|
21641
|
-
if (p = ps[i], useDefaults)
|
|
21642
|
-
this[p] = DEFAULTS[p];
|
|
21643
|
-
if ((v = obj[p]) !== undefined) {
|
|
21644
|
-
if (mathfloor(v) === v && v >= ps[i + 1] && v <= ps[i + 2])
|
|
21645
|
-
this[p] = v;
|
|
21646
|
-
else
|
|
21647
|
-
throw Error(invalidArgument + p + ": " + v);
|
|
21648
|
-
}
|
|
21649
|
-
}
|
|
21650
|
-
if (p = "crypto", useDefaults)
|
|
21651
|
-
this[p] = DEFAULTS[p];
|
|
21652
|
-
if ((v = obj[p]) !== undefined) {
|
|
21653
|
-
if (v === true || v === false || v === 0 || v === 1) {
|
|
21654
|
-
if (v) {
|
|
21655
|
-
if (typeof crypto != "undefined" && crypto && (crypto.getRandomValues || crypto.randomBytes)) {
|
|
21656
|
-
this[p] = true;
|
|
21657
|
-
} else {
|
|
21658
|
-
throw Error(cryptoUnavailable);
|
|
21659
|
-
}
|
|
21660
|
-
} else {
|
|
21661
|
-
this[p] = false;
|
|
21662
|
-
}
|
|
21663
|
-
} else {
|
|
21664
|
-
throw Error(invalidArgument + p + ": " + v);
|
|
21665
|
-
}
|
|
21666
|
-
}
|
|
21667
|
-
return this;
|
|
21668
|
-
}
|
|
21669
|
-
function cos(x) {
|
|
21670
|
-
return new this(x).cos();
|
|
21671
|
-
}
|
|
21672
|
-
function cosh(x) {
|
|
21673
|
-
return new this(x).cosh();
|
|
21674
|
-
}
|
|
21675
|
-
function clone(obj) {
|
|
21676
|
-
var i, p, ps;
|
|
21677
|
-
function Decimal(v) {
|
|
21678
|
-
var e, i2, t, x = this;
|
|
21679
|
-
if (!(x instanceof Decimal))
|
|
21680
|
-
return new Decimal(v);
|
|
21681
|
-
x.constructor = Decimal;
|
|
21682
|
-
if (isDecimalInstance(v)) {
|
|
21683
|
-
x.s = v.s;
|
|
21684
|
-
if (external2) {
|
|
21685
|
-
if (!v.d || v.e > Decimal.maxE) {
|
|
21686
|
-
x.e = NaN;
|
|
21687
|
-
x.d = null;
|
|
21688
|
-
} else if (v.e < Decimal.minE) {
|
|
21689
|
-
x.e = 0;
|
|
21690
|
-
x.d = [0];
|
|
21691
|
-
} else {
|
|
21692
|
-
x.e = v.e;
|
|
21693
|
-
x.d = v.d.slice();
|
|
21694
|
-
}
|
|
21695
|
-
} else {
|
|
21696
|
-
x.e = v.e;
|
|
21697
|
-
x.d = v.d ? v.d.slice() : v.d;
|
|
21698
|
-
}
|
|
21699
|
-
return;
|
|
21700
|
-
}
|
|
21701
|
-
t = typeof v;
|
|
21702
|
-
if (t === "number") {
|
|
21703
|
-
if (v === 0) {
|
|
21704
|
-
x.s = 1 / v < 0 ? -1 : 1;
|
|
21705
|
-
x.e = 0;
|
|
21706
|
-
x.d = [0];
|
|
21707
|
-
return;
|
|
21708
|
-
}
|
|
21709
|
-
if (v < 0) {
|
|
21710
|
-
v = -v;
|
|
21711
|
-
x.s = -1;
|
|
21712
|
-
} else {
|
|
21713
|
-
x.s = 1;
|
|
21714
|
-
}
|
|
21715
|
-
if (v === ~~v && v < 1e7) {
|
|
21716
|
-
for (e = 0, i2 = v;i2 >= 10; i2 /= 10)
|
|
21717
|
-
e++;
|
|
21718
|
-
if (external2) {
|
|
21719
|
-
if (e > Decimal.maxE) {
|
|
21720
|
-
x.e = NaN;
|
|
21721
|
-
x.d = null;
|
|
21722
|
-
} else if (e < Decimal.minE) {
|
|
21723
|
-
x.e = 0;
|
|
21724
|
-
x.d = [0];
|
|
21725
|
-
} else {
|
|
21726
|
-
x.e = e;
|
|
21727
|
-
x.d = [v];
|
|
21728
|
-
}
|
|
21729
|
-
} else {
|
|
21730
|
-
x.e = e;
|
|
21731
|
-
x.d = [v];
|
|
21732
|
-
}
|
|
21733
|
-
return;
|
|
21734
|
-
}
|
|
21735
|
-
if (v * 0 !== 0) {
|
|
21736
|
-
if (!v)
|
|
21737
|
-
x.s = NaN;
|
|
21738
|
-
x.e = NaN;
|
|
21739
|
-
x.d = null;
|
|
21740
|
-
return;
|
|
21741
|
-
}
|
|
21742
|
-
return parseDecimal(x, v.toString());
|
|
21743
|
-
}
|
|
21744
|
-
if (t === "string") {
|
|
21745
|
-
if ((i2 = v.charCodeAt(0)) === 45) {
|
|
21746
|
-
v = v.slice(1);
|
|
21747
|
-
x.s = -1;
|
|
21748
|
-
} else {
|
|
21749
|
-
if (i2 === 43)
|
|
21750
|
-
v = v.slice(1);
|
|
21751
|
-
x.s = 1;
|
|
21752
|
-
}
|
|
21753
|
-
return isDecimal.test(v) ? parseDecimal(x, v) : parseOther(x, v);
|
|
21754
|
-
}
|
|
21755
|
-
if (t === "bigint") {
|
|
21756
|
-
if (v < 0) {
|
|
21757
|
-
v = -v;
|
|
21758
|
-
x.s = -1;
|
|
21759
|
-
} else {
|
|
21760
|
-
x.s = 1;
|
|
21761
|
-
}
|
|
21762
|
-
return parseDecimal(x, v.toString());
|
|
21763
|
-
}
|
|
21764
|
-
throw Error(invalidArgument + v);
|
|
21765
|
-
}
|
|
21766
|
-
Decimal.prototype = P;
|
|
21767
|
-
Decimal.ROUND_UP = 0;
|
|
21768
|
-
Decimal.ROUND_DOWN = 1;
|
|
21769
|
-
Decimal.ROUND_CEIL = 2;
|
|
21770
|
-
Decimal.ROUND_FLOOR = 3;
|
|
21771
|
-
Decimal.ROUND_HALF_UP = 4;
|
|
21772
|
-
Decimal.ROUND_HALF_DOWN = 5;
|
|
21773
|
-
Decimal.ROUND_HALF_EVEN = 6;
|
|
21774
|
-
Decimal.ROUND_HALF_CEIL = 7;
|
|
21775
|
-
Decimal.ROUND_HALF_FLOOR = 8;
|
|
21776
|
-
Decimal.EUCLID = 9;
|
|
21777
|
-
Decimal.config = Decimal.set = config;
|
|
21778
|
-
Decimal.clone = clone;
|
|
21779
|
-
Decimal.isDecimal = isDecimalInstance;
|
|
21780
|
-
Decimal.abs = abs;
|
|
21781
|
-
Decimal.acos = acos;
|
|
21782
|
-
Decimal.acosh = acosh;
|
|
21783
|
-
Decimal.add = add;
|
|
21784
|
-
Decimal.asin = asin;
|
|
21785
|
-
Decimal.asinh = asinh;
|
|
21786
|
-
Decimal.atan = atan;
|
|
21787
|
-
Decimal.atanh = atanh;
|
|
21788
|
-
Decimal.atan2 = atan2;
|
|
21789
|
-
Decimal.cbrt = cbrt;
|
|
21790
|
-
Decimal.ceil = ceil;
|
|
21791
|
-
Decimal.clamp = clamp;
|
|
21792
|
-
Decimal.cos = cos;
|
|
21793
|
-
Decimal.cosh = cosh;
|
|
21794
|
-
Decimal.div = div;
|
|
21795
|
-
Decimal.exp = exp;
|
|
21796
|
-
Decimal.floor = floor;
|
|
21797
|
-
Decimal.hypot = hypot;
|
|
21798
|
-
Decimal.ln = ln;
|
|
21799
|
-
Decimal.log = log;
|
|
21800
|
-
Decimal.log10 = log10;
|
|
21801
|
-
Decimal.log2 = log2;
|
|
21802
|
-
Decimal.max = max;
|
|
21803
|
-
Decimal.min = min;
|
|
21804
|
-
Decimal.mod = mod;
|
|
21805
|
-
Decimal.mul = mul;
|
|
21806
|
-
Decimal.pow = pow;
|
|
21807
|
-
Decimal.random = random;
|
|
21808
|
-
Decimal.round = round;
|
|
21809
|
-
Decimal.sign = sign;
|
|
21810
|
-
Decimal.sin = sin;
|
|
21811
|
-
Decimal.sinh = sinh;
|
|
21812
|
-
Decimal.sqrt = sqrt;
|
|
21813
|
-
Decimal.sub = sub;
|
|
21814
|
-
Decimal.sum = sum;
|
|
21815
|
-
Decimal.tan = tan;
|
|
21816
|
-
Decimal.tanh = tanh;
|
|
21817
|
-
Decimal.trunc = trunc;
|
|
21818
|
-
if (obj === undefined)
|
|
21819
|
-
obj = {};
|
|
21820
|
-
if (obj) {
|
|
21821
|
-
if (obj.defaults !== true) {
|
|
21822
|
-
ps = ["precision", "rounding", "toExpNeg", "toExpPos", "maxE", "minE", "modulo", "crypto"];
|
|
21823
|
-
for (i = 0;i < ps.length; )
|
|
21824
|
-
if (!obj.hasOwnProperty(p = ps[i++]))
|
|
21825
|
-
obj[p] = this[p];
|
|
21826
|
-
}
|
|
21827
|
-
}
|
|
21828
|
-
Decimal.config(obj);
|
|
21829
|
-
return Decimal;
|
|
21830
|
-
}
|
|
21831
|
-
function div(x, y) {
|
|
21832
|
-
return new this(x).div(y);
|
|
21833
|
-
}
|
|
21834
|
-
function exp(x) {
|
|
21835
|
-
return new this(x).exp();
|
|
21836
|
-
}
|
|
21837
|
-
function floor(x) {
|
|
21838
|
-
return finalise(x = new this(x), x.e + 1, 3);
|
|
21839
|
-
}
|
|
21840
|
-
function hypot() {
|
|
21841
|
-
var i, n, t = new this(0);
|
|
21842
|
-
external2 = false;
|
|
21843
|
-
for (i = 0;i < arguments.length; ) {
|
|
21844
|
-
n = new this(arguments[i++]);
|
|
21845
|
-
if (!n.d) {
|
|
21846
|
-
if (n.s) {
|
|
21847
|
-
external2 = true;
|
|
21848
|
-
return new this(1 / 0);
|
|
21849
|
-
}
|
|
21850
|
-
t = n;
|
|
21851
|
-
} else if (t.d) {
|
|
21852
|
-
t = t.plus(n.times(n));
|
|
21853
|
-
}
|
|
21854
|
-
}
|
|
21855
|
-
external2 = true;
|
|
21856
|
-
return t.sqrt();
|
|
21857
|
-
}
|
|
21858
|
-
function isDecimalInstance(obj) {
|
|
21859
|
-
return obj instanceof Decimal || obj && obj.toStringTag === tag || false;
|
|
21860
|
-
}
|
|
21861
|
-
function ln(x) {
|
|
21862
|
-
return new this(x).ln();
|
|
21863
|
-
}
|
|
21864
|
-
function log(x, y) {
|
|
21865
|
-
return new this(x).log(y);
|
|
21866
|
-
}
|
|
21867
|
-
function log2(x) {
|
|
21868
|
-
return new this(x).log(2);
|
|
21869
|
-
}
|
|
21870
|
-
function log10(x) {
|
|
21871
|
-
return new this(x).log(10);
|
|
21872
|
-
}
|
|
21873
|
-
function max() {
|
|
21874
|
-
return maxOrMin(this, arguments, -1);
|
|
21875
|
-
}
|
|
21876
|
-
function min() {
|
|
21877
|
-
return maxOrMin(this, arguments, 1);
|
|
21878
|
-
}
|
|
21879
|
-
function mod(x, y) {
|
|
21880
|
-
return new this(x).mod(y);
|
|
21881
|
-
}
|
|
21882
|
-
function mul(x, y) {
|
|
21883
|
-
return new this(x).mul(y);
|
|
21884
|
-
}
|
|
21885
|
-
function pow(x, y) {
|
|
21886
|
-
return new this(x).pow(y);
|
|
21887
|
-
}
|
|
21888
|
-
function random(sd) {
|
|
21889
|
-
var d, e, k, n, i = 0, r = new this(1), rd = [];
|
|
21890
|
-
if (sd === undefined)
|
|
21891
|
-
sd = this.precision;
|
|
21892
|
-
else
|
|
21893
|
-
checkInt32(sd, 1, MAX_DIGITS);
|
|
21894
|
-
k = Math.ceil(sd / LOG_BASE);
|
|
21895
|
-
if (!this.crypto) {
|
|
21896
|
-
for (;i < k; )
|
|
21897
|
-
rd[i++] = Math.random() * 1e7 | 0;
|
|
21898
|
-
} else if (crypto.getRandomValues) {
|
|
21899
|
-
d = crypto.getRandomValues(new Uint32Array(k));
|
|
21900
|
-
for (;i < k; ) {
|
|
21901
|
-
n = d[i];
|
|
21902
|
-
if (n >= 4290000000) {
|
|
21903
|
-
d[i] = crypto.getRandomValues(new Uint32Array(1))[0];
|
|
21904
|
-
} else {
|
|
21905
|
-
rd[i++] = n % 1e7;
|
|
21906
|
-
}
|
|
21907
|
-
}
|
|
21908
|
-
} else if (crypto.randomBytes) {
|
|
21909
|
-
d = crypto.randomBytes(k *= 4);
|
|
21910
|
-
for (;i < k; ) {
|
|
21911
|
-
n = d[i] + (d[i + 1] << 8) + (d[i + 2] << 16) + ((d[i + 3] & 127) << 24);
|
|
21912
|
-
if (n >= 2140000000) {
|
|
21913
|
-
crypto.randomBytes(4).copy(d, i);
|
|
21914
|
-
} else {
|
|
21915
|
-
rd.push(n % 1e7);
|
|
21916
|
-
i += 4;
|
|
21917
|
-
}
|
|
21918
|
-
}
|
|
21919
|
-
i = k / 4;
|
|
21920
|
-
} else {
|
|
21921
|
-
throw Error(cryptoUnavailable);
|
|
21922
|
-
}
|
|
21923
|
-
k = rd[--i];
|
|
21924
|
-
sd %= LOG_BASE;
|
|
21925
|
-
if (k && sd) {
|
|
21926
|
-
n = mathpow(10, LOG_BASE - sd);
|
|
21927
|
-
rd[i] = (k / n | 0) * n;
|
|
21928
|
-
}
|
|
21929
|
-
for (;rd[i] === 0; i--)
|
|
21930
|
-
rd.pop();
|
|
21931
|
-
if (i < 0) {
|
|
21932
|
-
e = 0;
|
|
21933
|
-
rd = [0];
|
|
21934
|
-
} else {
|
|
21935
|
-
e = -1;
|
|
21936
|
-
for (;rd[0] === 0; e -= LOG_BASE)
|
|
21937
|
-
rd.shift();
|
|
21938
|
-
for (k = 1, n = rd[0];n >= 10; n /= 10)
|
|
21939
|
-
k++;
|
|
21940
|
-
if (k < LOG_BASE)
|
|
21941
|
-
e -= LOG_BASE - k;
|
|
21942
|
-
}
|
|
21943
|
-
r.e = e;
|
|
21944
|
-
r.d = rd;
|
|
21945
|
-
return r;
|
|
21946
|
-
}
|
|
21947
|
-
function round(x) {
|
|
21948
|
-
return finalise(x = new this(x), x.e + 1, this.rounding);
|
|
21949
|
-
}
|
|
21950
|
-
function sign(x) {
|
|
21951
|
-
x = new this(x);
|
|
21952
|
-
return x.d ? x.d[0] ? x.s : 0 * x.s : x.s || NaN;
|
|
21953
|
-
}
|
|
21954
|
-
function sin(x) {
|
|
21955
|
-
return new this(x).sin();
|
|
21956
|
-
}
|
|
21957
|
-
function sinh(x) {
|
|
21958
|
-
return new this(x).sinh();
|
|
21959
|
-
}
|
|
21960
|
-
function sqrt(x) {
|
|
21961
|
-
return new this(x).sqrt();
|
|
21962
|
-
}
|
|
21963
|
-
function sub(x, y) {
|
|
21964
|
-
return new this(x).sub(y);
|
|
21965
|
-
}
|
|
21966
|
-
function sum() {
|
|
21967
|
-
var i = 0, args = arguments, x = new this(args[i]);
|
|
21968
|
-
external2 = false;
|
|
21969
|
-
for (;x.s && ++i < args.length; )
|
|
21970
|
-
x = x.plus(args[i]);
|
|
21971
|
-
external2 = true;
|
|
21972
|
-
return finalise(x, this.precision, this.rounding);
|
|
21973
|
-
}
|
|
21974
|
-
function tan(x) {
|
|
21975
|
-
return new this(x).tan();
|
|
21976
|
-
}
|
|
21977
|
-
function tanh(x) {
|
|
21978
|
-
return new this(x).tanh();
|
|
21979
|
-
}
|
|
21980
|
-
function trunc(x) {
|
|
21981
|
-
return finalise(x = new this(x), x.e + 1, 1);
|
|
21982
|
-
}
|
|
21983
|
-
P[Symbol.for("nodejs.util.inspect.custom")] = P.toString;
|
|
21984
|
-
P[Symbol.toStringTag] = "Decimal";
|
|
21985
|
-
var Decimal = P.constructor = clone(DEFAULTS);
|
|
21986
|
-
LN10 = new Decimal(LN10);
|
|
21987
|
-
PI = new Decimal(PI);
|
|
21988
|
-
var decimal_default = Decimal;
|
|
21989
|
-
|
|
21990
|
-
// src/common/base/other.ts
|
|
21991
|
-
var delay = (time = 1000) => {
|
|
21992
|
-
return new Promise((resolve2) => setTimeout(resolve2, time));
|
|
21993
|
-
};
|
|
21994
|
-
var calcJsText = (expr, context) => {
|
|
21995
|
-
const keys = Object.keys(context);
|
|
21996
|
-
const values = keys.map((key2) => context[key2]);
|
|
21997
|
-
return Function(...keys, `return (${expr})`)(...values);
|
|
21998
|
-
};
|
|
21999
|
-
var optionsToEnum = (options, text, key2) => {
|
|
22000
|
-
return options.reduce((acc, cur) => {
|
|
22001
|
-
acc[cur[key2]] = {
|
|
22002
|
-
text: cur[text]
|
|
22003
|
-
};
|
|
22004
|
-
return acc;
|
|
22005
|
-
}, {});
|
|
22006
|
-
};
|
|
22007
|
-
var performDecimalOperation = (num1, num2, operator) => {
|
|
22008
|
-
if (num1 === undefined || num2 === undefined || !operator) {
|
|
22009
|
-
return;
|
|
22010
|
-
}
|
|
22011
|
-
const decimalNum1 = new decimal_default(Number(num1));
|
|
22012
|
-
const decimalNum2 = new decimal_default(Number(num2));
|
|
22013
|
-
switch (operator) {
|
|
22014
|
-
case "+":
|
|
22015
|
-
return decimalNum1.plus(decimalNum2).toNumber();
|
|
22016
|
-
case "-":
|
|
22017
|
-
return decimalNum1.minus(decimalNum2).toNumber();
|
|
22018
|
-
case "*":
|
|
22019
|
-
return decimalNum1.times(decimalNum2).toNumber();
|
|
22020
|
-
case "/":
|
|
22021
|
-
if (num2 !== 0) {
|
|
22022
|
-
return decimalNum1.dividedBy(decimalNum2).toNumber();
|
|
22023
|
-
} else {
|
|
22024
|
-
console.error("Division by zero is not allowed.");
|
|
22025
|
-
return NaN;
|
|
22026
|
-
}
|
|
22027
|
-
default:
|
|
22028
|
-
console.error("Invalid operator:", operator);
|
|
22029
|
-
return NaN;
|
|
22030
|
-
}
|
|
22031
|
-
};
|
|
22032
|
-
var printConsoleLog = (type, path, params, response) => {
|
|
22033
|
-
const styles = {
|
|
22034
|
-
header: "color: #fff; background: #35495e; padding: 2px 8px; border-radius: 3px 0 0 3px;",
|
|
22035
|
-
value: "color: #35495e; background: #f0f4f8; padding: 2px 6px; border-radius: 0 3px 3px 0;",
|
|
22036
|
-
separator: "color: #409EFF; margin: 0 4px;"
|
|
22037
|
-
};
|
|
22038
|
-
console.groupCollapsed(`666 %c${type}%c${path}`, styles.header, styles.value);
|
|
22039
|
-
if (params) {
|
|
22040
|
-
console.table(params);
|
|
22041
|
-
}
|
|
22042
|
-
if (response) {
|
|
22043
|
-
console.table(response);
|
|
22044
|
-
}
|
|
22045
|
-
console.groupEnd();
|
|
22046
|
-
};
|
|
22047
|
-
|
|
22048
|
-
// src/common/base/array.ts
|
|
22049
|
-
var shuffleArray = (array) => {
|
|
22050
|
-
const shuffledArray = [...array];
|
|
22051
|
-
for (let i = shuffledArray.length - 1;i > 0; i--) {
|
|
22052
|
-
const j = Math.floor(Math.random() * (i + 1));
|
|
22053
|
-
[shuffledArray[i], shuffledArray[j]] = [shuffledArray[j], shuffledArray[i]];
|
|
22054
|
-
}
|
|
22055
|
-
return shuffledArray;
|
|
22056
|
-
};
|
|
22057
|
-
var removeSimilarDuplicates = (arr, threshold, isLog) => {
|
|
22058
|
-
const uniqueArray = [];
|
|
22059
|
-
const similarPairs = [];
|
|
22060
|
-
for (const str of arr) {
|
|
22061
|
-
const isSimilar = uniqueArray.some((uniqueStr) => {
|
|
22062
|
-
const distance = levenshteinDistance(str, uniqueStr);
|
|
22063
|
-
if (distance <= threshold) {
|
|
22064
|
-
similarPairs.push([str, uniqueStr]);
|
|
22065
|
-
return true;
|
|
22066
|
-
}
|
|
22067
|
-
return false;
|
|
22068
|
-
});
|
|
22069
|
-
if (!isSimilar) {
|
|
22070
|
-
uniqueArray.push(str);
|
|
22071
|
-
}
|
|
22072
|
-
}
|
|
22073
|
-
if (isLog) {
|
|
22074
|
-
if (similarPairs.length > 0) {
|
|
22075
|
-
similarPairs.forEach((pair) => {
|
|
22076
|
-
console.log(pair[0]);
|
|
22077
|
-
console.log(pair[1]);
|
|
22078
|
-
console.log();
|
|
22079
|
-
});
|
|
22080
|
-
} else {
|
|
22081
|
-
console.log("没有找到类似的字符串");
|
|
22082
|
-
}
|
|
22083
|
-
}
|
|
22084
|
-
return uniqueArray;
|
|
22085
|
-
};
|
|
22086
|
-
var getTotal = (arr, key2) => {
|
|
22087
|
-
if (!Array.isArray(arr) || !key2) {
|
|
22088
|
-
return 0;
|
|
22089
|
-
}
|
|
22090
|
-
return arr.reduce((total, item) => {
|
|
22091
|
-
const itemValue = Number(item[key2]);
|
|
22092
|
-
if (!isNaN(itemValue)) {
|
|
22093
|
-
return performDecimalOperation(total, itemValue, "+");
|
|
22094
|
-
}
|
|
22095
|
-
return total;
|
|
22096
|
-
}, 0);
|
|
22097
|
-
};
|
|
22098
|
-
|
|
22099
|
-
// src/common/base/number.ts
|
|
22100
|
-
var getRandomNum = (min2, max2) => {
|
|
22101
|
-
return Math.floor(Math.random() * (max2 - min2 + 1) + min2);
|
|
22102
|
-
};
|
|
22103
|
-
var limitDecimals = (v, num = 2, isForce) => {
|
|
22104
|
-
let value = parseFloat(v);
|
|
22105
|
-
if (isNaN(value)) {
|
|
22106
|
-
if (isForce) {
|
|
22107
|
-
value = 0;
|
|
22108
|
-
} else {
|
|
22109
|
-
return "";
|
|
22110
|
-
}
|
|
22111
|
-
}
|
|
22112
|
-
return value.toFixed(num).toString();
|
|
22113
|
-
};
|
|
22114
|
-
var formatFileSize = (bytes) => {
|
|
22115
|
-
if (!bytes || bytes === 0) {
|
|
22116
|
-
return "0 B";
|
|
22117
|
-
}
|
|
22118
|
-
const base = 1024;
|
|
22119
|
-
const sizes = ["B", "KB", "MB", "GB"];
|
|
22120
|
-
const index = Math.floor(Math.log(bytes) / Math.log(base));
|
|
22121
|
-
return `${(bytes / Math.pow(base, index)).toFixed(1).replace(/\.0$/, "")} ${sizes[index]}`;
|
|
22122
|
-
};
|
|
22123
|
-
var isValidNumber = (value) => {
|
|
22124
|
-
if (typeof value !== "number") {
|
|
22125
|
-
return false;
|
|
22126
|
-
}
|
|
22127
|
-
if (isNaN(value)) {
|
|
22128
|
-
return false;
|
|
22129
|
-
}
|
|
22130
|
-
if (value === Infinity || value === -Infinity) {
|
|
22131
|
-
return false;
|
|
22132
|
-
}
|
|
22133
|
-
return true;
|
|
22134
|
-
};
|
|
22135
|
-
var numberWithCommas = (x) => {
|
|
22136
|
-
if (x === undefined || x === null) {
|
|
22137
|
-
return "";
|
|
22138
|
-
}
|
|
22139
|
-
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
22140
|
-
};
|
|
22141
|
-
|
|
22142
|
-
// src/common/base/object.ts
|
|
22143
|
-
var findItem = (list, attr, value) => {
|
|
22144
|
-
return list.find((item) => value === undefined ? item[attr] : item[attr] === value);
|
|
22145
|
-
};
|
|
22146
|
-
var filterParams = (params, deep = false) => {
|
|
22147
|
-
const clean = (value) => {
|
|
22148
|
-
if (value === undefined || value === null) {
|
|
22149
|
-
return;
|
|
22150
|
-
}
|
|
22151
|
-
if (!deep) {
|
|
22152
|
-
return value;
|
|
22153
|
-
}
|
|
22154
|
-
if (Array.isArray(value)) {
|
|
22155
|
-
return value.map((v) => clean(v)).filter((v) => v !== undefined);
|
|
22156
|
-
}
|
|
22157
|
-
if (typeof value === "object") {
|
|
22158
|
-
return Object.entries(value).reduce((acc, [k, v]) => {
|
|
22159
|
-
const cleaned = clean(v);
|
|
22160
|
-
if (cleaned !== undefined)
|
|
22161
|
-
acc[k] = cleaned;
|
|
22162
|
-
return acc;
|
|
22163
|
-
}, {});
|
|
22164
|
-
}
|
|
22165
|
-
return value;
|
|
22166
|
-
};
|
|
22167
|
-
return clean(params);
|
|
22168
|
-
};
|
|
22169
|
-
var watch = {
|
|
22170
|
-
observe(obj, key2, watchFun) {
|
|
22171
|
-
const val = obj[key2];
|
|
22172
|
-
Object.defineProperty(obj, key2, {
|
|
22173
|
-
configurable: true,
|
|
22174
|
-
enumerable: true,
|
|
22175
|
-
set(value) {
|
|
22176
|
-
obj[key2] = value;
|
|
22177
|
-
watchFun(value, val);
|
|
22178
|
-
},
|
|
22179
|
-
get() {
|
|
22180
|
-
return val;
|
|
22181
|
-
}
|
|
22182
|
-
});
|
|
22183
|
-
},
|
|
22184
|
-
setWatcher(data = {}, watch2 = {}) {
|
|
22185
|
-
Object.keys(watch2).forEach((v) => {
|
|
22186
|
-
this.observe(data, v, watch2[v]);
|
|
22187
|
-
});
|
|
22188
|
-
}
|
|
22189
|
-
};
|
|
22190
|
-
|
|
22191
|
-
// src/common/base/promise.ts
|
|
22192
|
-
var executePromise = async (promise) => {
|
|
22193
|
-
const start = Date.now();
|
|
22194
|
-
const result = await promise;
|
|
22195
|
-
const time = Date.now() - start;
|
|
22196
|
-
return {
|
|
22197
|
-
result,
|
|
22198
|
-
time
|
|
22199
|
-
};
|
|
22200
|
-
};
|
|
22201
|
-
var retryPromise = async (promiseFn, retryInterval = 1000, retryCount = 3) => {
|
|
22202
|
-
try {
|
|
22203
|
-
return await promiseFn();
|
|
22204
|
-
} catch (error) {
|
|
22205
|
-
if (retryCount <= 0) {
|
|
22206
|
-
throw error;
|
|
22207
|
-
}
|
|
22208
|
-
await new Promise((resolve2) => setTimeout(resolve2, retryInterval));
|
|
22209
|
-
return retryPromise(promiseFn, retryCount - 1, retryInterval);
|
|
20361
|
+
var retryPromise = async (promiseFn, retryCount = 3, retryInterval = 1000) => {
|
|
20362
|
+
try {
|
|
20363
|
+
return await promiseFn();
|
|
20364
|
+
} catch (error) {
|
|
20365
|
+
if (retryCount <= 0) {
|
|
20366
|
+
throw error;
|
|
20367
|
+
}
|
|
20368
|
+
await new Promise((resolve2) => setTimeout(resolve2, retryInterval));
|
|
20369
|
+
return retryPromise(promiseFn, retryCount - 1, retryInterval);
|
|
22210
20370
|
}
|
|
22211
20371
|
};
|
|
22212
20372
|
// src/common/enum/index.ts
|
|
@@ -22214,10 +20374,10 @@ class EnumItem {
|
|
|
22214
20374
|
label;
|
|
22215
20375
|
value;
|
|
22216
20376
|
extra;
|
|
22217
|
-
constructor(
|
|
22218
|
-
this.value =
|
|
22219
|
-
this.label =
|
|
22220
|
-
this.extra =
|
|
20377
|
+
constructor(config) {
|
|
20378
|
+
this.value = config.value;
|
|
20379
|
+
this.label = config.label;
|
|
20380
|
+
this.extra = config.extra;
|
|
22221
20381
|
}
|
|
22222
20382
|
}
|
|
22223
20383
|
var Enum = {
|
|
@@ -22256,19 +20416,6 @@ var Enum = {
|
|
|
22256
20416
|
return enumObj;
|
|
22257
20417
|
}
|
|
22258
20418
|
};
|
|
22259
|
-
// src/common/image/index.ts
|
|
22260
|
-
async function imageToBase64(url) {
|
|
22261
|
-
try {
|
|
22262
|
-
const response = await axios_default.get(url, {
|
|
22263
|
-
responseType: "arraybuffer"
|
|
22264
|
-
});
|
|
22265
|
-
const base64String = Buffer.from(response.data).toString("base64");
|
|
22266
|
-
return `data:image/*;base64,${base64String}`;
|
|
22267
|
-
} catch (error) {
|
|
22268
|
-
console.error("Failed to fetch the image:", error);
|
|
22269
|
-
throw error;
|
|
22270
|
-
}
|
|
22271
|
-
}
|
|
22272
20419
|
// src/common/other/index.ts
|
|
22273
20420
|
function getPublicUrl(objectKey) {
|
|
22274
20421
|
if (!objectKey) {
|
|
@@ -22282,6 +20429,41 @@ function getPublicUrl(objectKey) {
|
|
|
22282
20429
|
const key2 = objectKey.startsWith("/") ? objectKey : `/${objectKey}`;
|
|
22283
20430
|
return `${baseUrl}${key2}`;
|
|
22284
20431
|
}
|
|
20432
|
+
// src/common/antd/index.ts
|
|
20433
|
+
var options2valueEnum = (options) => {
|
|
20434
|
+
return (options || []).reduce((acc, cur) => {
|
|
20435
|
+
acc[cur] = { text: cur };
|
|
20436
|
+
return acc;
|
|
20437
|
+
}, {});
|
|
20438
|
+
};
|
|
20439
|
+
var optionsToEnum = (options, text, key2) => {
|
|
20440
|
+
return options.reduce((acc, cur) => {
|
|
20441
|
+
acc[cur[key2]] = {
|
|
20442
|
+
text: cur[text]
|
|
20443
|
+
};
|
|
20444
|
+
return acc;
|
|
20445
|
+
}, {});
|
|
20446
|
+
};
|
|
20447
|
+
var transformOptions = (inputArray) => {
|
|
20448
|
+
if (!inputArray?.length) {
|
|
20449
|
+
return [];
|
|
20450
|
+
}
|
|
20451
|
+
return inputArray.map((item) => {
|
|
20452
|
+
if (typeof item === "string") {
|
|
20453
|
+
return { label: item, value: item };
|
|
20454
|
+
}
|
|
20455
|
+
return item;
|
|
20456
|
+
});
|
|
20457
|
+
};
|
|
20458
|
+
var getColumns = (dataSource) => {
|
|
20459
|
+
if (!Array.isArray(dataSource)) {
|
|
20460
|
+
return [];
|
|
20461
|
+
}
|
|
20462
|
+
return Object.keys(dataSource?.[0] || {}).map((item) => ({
|
|
20463
|
+
title: item,
|
|
20464
|
+
dataIndex: item
|
|
20465
|
+
}));
|
|
20466
|
+
};
|
|
22285
20467
|
// src/common/dayjs/index.ts
|
|
22286
20468
|
var import_dayjs = __toESM(require_dayjs_min(), 1);
|
|
22287
20469
|
var import_isBetween = __toESM(require_isBetween(), 1);
|
|
@@ -22311,138 +20493,62 @@ var Timezone;
|
|
|
22311
20493
|
Timezone2["EuropeLondon"] = "Europe/London";
|
|
22312
20494
|
Timezone2["EuropeBerlin"] = "Europe/Berlin";
|
|
22313
20495
|
})(Timezone ||= {});
|
|
22314
|
-
var initChinaDayjs = () => {
|
|
22315
|
-
import_dayjs.default.locale("zh-cn");
|
|
22316
|
-
import_dayjs.default.tz.setDefault("Asia/Shanghai" /* AsiaShanghai */);
|
|
22317
|
-
import_dayjs.default.updateLocale("zh-cn", {
|
|
22318
|
-
weekStart: 1
|
|
22319
|
-
});
|
|
22320
|
-
return import_dayjs.default;
|
|
22321
|
-
};
|
|
22322
|
-
var chinaDayjs = initChinaDayjs();
|
|
22323
20496
|
var dayjs_default = import_dayjs.default;
|
|
22324
20497
|
// src/web/element.ts
|
|
22325
20498
|
var scrollIntoView = (el, option) => {
|
|
22326
|
-
|
|
22327
|
-
return;
|
|
22328
|
-
}
|
|
22329
|
-
el.scrollIntoView({ behavior: "smooth", block: "start", ...option });
|
|
22330
|
-
};
|
|
22331
|
-
var getElement = (el) => {
|
|
22332
|
-
const element = typeof el === "string" ? document.querySelector(el) : el;
|
|
22333
|
-
if (!element) {
|
|
22334
|
-
return {
|
|
22335
|
-
element: null,
|
|
22336
|
-
originalStyle: {}
|
|
22337
|
-
};
|
|
22338
|
-
}
|
|
22339
|
-
return {
|
|
22340
|
-
element,
|
|
22341
|
-
originalStyle: window.getComputedStyle(element)
|
|
22342
|
-
};
|
|
20499
|
+
el?.scrollIntoView({ behavior: "smooth", block: "start", ...option });
|
|
22343
20500
|
};
|
|
22344
20501
|
var isElementInViewport = (el) => {
|
|
22345
|
-
const
|
|
20502
|
+
const element = document.querySelector(el);
|
|
22346
20503
|
if (!element) {
|
|
22347
20504
|
return;
|
|
22348
20505
|
}
|
|
22349
20506
|
const rect = element.getBoundingClientRect();
|
|
22350
20507
|
return rect.top >= 0 && rect.left >= 0 && rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) && rect.right <= (window.innerWidth || document.documentElement.clientWidth);
|
|
22351
20508
|
};
|
|
22352
|
-
|
|
22353
|
-
// src/web/style.ts
|
|
22354
|
-
var hexToRgba2 = (hexColor, a = 1) => {
|
|
22355
|
-
let red = parseInt(hexColor.substr(1, 2), 16);
|
|
22356
|
-
let green = parseInt(hexColor.substr(3, 2), 16);
|
|
22357
|
-
let blue = parseInt(hexColor.substr(5, 2), 16);
|
|
22358
|
-
return {
|
|
22359
|
-
nums: { red, green, blue },
|
|
22360
|
-
text: `rgba(${red}, ${green}, ${blue}, ${a})`
|
|
22361
|
-
};
|
|
22362
|
-
};
|
|
22363
|
-
var flashBackground = (el, color, a = 1) => {
|
|
22364
|
-
const { element, originalStyle } = getElement(el);
|
|
22365
|
-
if (!element) {
|
|
22366
|
-
return;
|
|
22367
|
-
}
|
|
22368
|
-
anime_es_default({
|
|
22369
|
-
targets: element,
|
|
22370
|
-
backgroundColor: [hexToRgba2(color, a).text, originalStyle.backgroundColor],
|
|
22371
|
-
duration: 1500,
|
|
22372
|
-
easing: "easeInOutSine",
|
|
22373
|
-
direction: "alternate",
|
|
22374
|
-
loop: false
|
|
22375
|
-
});
|
|
22376
|
-
};
|
|
22377
|
-
var flashBorder = (el, color, a = 1) => {
|
|
22378
|
-
const { element } = getElement(el);
|
|
22379
|
-
if (!element) {
|
|
22380
|
-
return;
|
|
22381
|
-
}
|
|
22382
|
-
anime_es_default({
|
|
22383
|
-
targets: element,
|
|
22384
|
-
border: [`1px solid ${hexToRgba2(color, a).text}`, "none"],
|
|
22385
|
-
duration: 1500,
|
|
22386
|
-
easing: "easeInOutSine",
|
|
22387
|
-
direction: "alternate",
|
|
22388
|
-
loop: false
|
|
22389
|
-
});
|
|
22390
|
-
};
|
|
22391
|
-
// src/web/location.ts
|
|
22392
|
-
var import_lodash = __toESM(require_lodash(), 1);
|
|
22393
|
-
var url2Params = (url = location.href) => {
|
|
22394
|
-
url = decodeURIComponent(url);
|
|
22395
|
-
let jsonList = {};
|
|
22396
|
-
if (url.indexOf("?") > -1) {
|
|
22397
|
-
let str = url.slice(url.indexOf("?") + 1);
|
|
22398
|
-
let strs = str.split("&");
|
|
22399
|
-
for (let i = 0;i < strs.length; i++) {
|
|
22400
|
-
jsonList[strs[i].split("=")[0]] = strs[i].split("=")[1];
|
|
22401
|
-
}
|
|
22402
|
-
}
|
|
22403
|
-
return jsonList || {};
|
|
22404
|
-
};
|
|
22405
|
-
var params2Url = (params) => {
|
|
22406
|
-
let url = "";
|
|
22407
|
-
for (let k in params) {
|
|
22408
|
-
if (k) {
|
|
22409
|
-
url += `${k}=${params[k]}&`;
|
|
22410
|
-
}
|
|
22411
|
-
}
|
|
22412
|
-
return url.substr(0, url.length - 1);
|
|
22413
|
-
};
|
|
22414
|
-
var setUrlParams = (key2, value, keepName) => {
|
|
22415
|
-
if (key2 === undefined || value === undefined)
|
|
22416
|
-
return;
|
|
22417
|
-
let allParams = url2Params();
|
|
22418
|
-
if (keepName) {
|
|
22419
|
-
allParams = import_lodash.pick(allParams, keepName) || {};
|
|
22420
|
-
}
|
|
22421
|
-
allParams[key2] = encodeURIComponent(value);
|
|
22422
|
-
const url = location.href;
|
|
22423
|
-
const sliceEnd = url.indexOf("?") === -1 ? url.length : url.indexOf("?");
|
|
22424
|
-
const domainPath = url.slice(0, sliceEnd);
|
|
22425
|
-
const params = params2Url(allParams);
|
|
22426
|
-
location.replace(`${domainPath}?${params}`);
|
|
22427
|
-
};
|
|
22428
|
-
var urlGetPath = (url = location.href) => {
|
|
22429
|
-
let lastIndex = url.indexOf("?");
|
|
22430
|
-
if (lastIndex === -1) {
|
|
22431
|
-
lastIndex = url.length;
|
|
22432
|
-
}
|
|
22433
|
-
return url.slice(0, lastIndex);
|
|
22434
|
-
};
|
|
22435
20509
|
// src/web/clipboard.ts
|
|
22436
20510
|
var readClipboard = async () => {
|
|
22437
20511
|
try {
|
|
22438
|
-
return
|
|
20512
|
+
return navigator.clipboard.readText();
|
|
22439
20513
|
} catch (error) {
|
|
22440
20514
|
return "";
|
|
22441
20515
|
}
|
|
22442
20516
|
};
|
|
20517
|
+
// src/web/download.ts
|
|
20518
|
+
var import_dayjs3 = __toESM(require_dayjs_min(), 1);
|
|
20519
|
+
var import_papaparse = __toESM(require_papaparse_min(), 1);
|
|
20520
|
+
var downloadDataSource = (dataSource, name, columns) => {
|
|
20521
|
+
if (!Array.isArray(dataSource)) {
|
|
20522
|
+
return;
|
|
20523
|
+
}
|
|
20524
|
+
dataSource = dataSource.map((item) => {
|
|
20525
|
+
const obj = {};
|
|
20526
|
+
for (const key2 in item) {
|
|
20527
|
+
if (item.hasOwnProperty(key2)) {
|
|
20528
|
+
const element = item[key2];
|
|
20529
|
+
if (key2 !== "rowSpan") {
|
|
20530
|
+
if (typeof element === "string" || typeof element === "number") {
|
|
20531
|
+
obj[key2] = element;
|
|
20532
|
+
} else if (Array.isArray(element)) {
|
|
20533
|
+
obj[key2] = element.join(",");
|
|
20534
|
+
} else if (typeof element === "object") {
|
|
20535
|
+
obj[key2] = JSON.stringify(element);
|
|
20536
|
+
}
|
|
20537
|
+
}
|
|
20538
|
+
}
|
|
20539
|
+
}
|
|
20540
|
+
return obj;
|
|
20541
|
+
});
|
|
20542
|
+
const csv = import_papaparse.default.unparse(dataSource, columns ? { columns: columns.map((i) => i.dataIndex) } : undefined);
|
|
20543
|
+
const blob = new Blob([csv], { type: "text/csv;charset=utf-8;" });
|
|
20544
|
+
const downloadLink = document.createElement("a");
|
|
20545
|
+
downloadLink.href = URL.createObjectURL(blob);
|
|
20546
|
+
downloadLink.download = (name ? `${name}_` : "") + import_dayjs3.default().format("YYYY-MM-DD HH:mm:ss") + ".csv";
|
|
20547
|
+
downloadLink.click();
|
|
20548
|
+
};
|
|
22443
20549
|
|
|
22444
20550
|
// src/web.ts
|
|
22445
|
-
var _ =
|
|
20551
|
+
var _ = import_lodash.default;
|
|
22446
20552
|
var export_md5 = import_md5.default;
|
|
22447
20553
|
var export_localforage = import_localforage.default;
|
|
22448
20554
|
var export_json5 = import_json53.default;
|
|
@@ -22452,47 +20558,40 @@ var export_classnames = import_classnames.default;
|
|
|
22452
20558
|
|
|
22453
20559
|
export {
|
|
22454
20560
|
exports_external as z,
|
|
22455
|
-
watch,
|
|
22456
20561
|
voidType as void,
|
|
22457
20562
|
util,
|
|
22458
|
-
urlGetPath,
|
|
22459
|
-
url2Params,
|
|
22460
20563
|
unknownType as unknown,
|
|
22461
20564
|
unionType as union,
|
|
22462
20565
|
undefinedType as undefined,
|
|
22463
20566
|
tupleType as tuple,
|
|
22464
20567
|
effectsType as transformer,
|
|
22465
|
-
|
|
20568
|
+
transformOptions,
|
|
22466
20569
|
symbolType as symbol,
|
|
22467
20570
|
stringType as string,
|
|
22468
20571
|
strictObjectType as strictObject,
|
|
22469
|
-
shuffleArray,
|
|
22470
|
-
setUrlParams,
|
|
22471
20572
|
setErrorMap,
|
|
22472
20573
|
setType as set,
|
|
22473
20574
|
scrollIntoView,
|
|
20575
|
+
safeJsonParse,
|
|
22474
20576
|
retryPromise,
|
|
22475
20577
|
replaceByVariables,
|
|
22476
20578
|
replaceByRules,
|
|
22477
|
-
replaceAll,
|
|
22478
20579
|
removeSimilarDuplicates,
|
|
22479
20580
|
recordType as record,
|
|
22480
20581
|
readClipboard,
|
|
22481
20582
|
quotelessJson,
|
|
22482
20583
|
promiseType as promise,
|
|
22483
|
-
|
|
20584
|
+
prettyBytes,
|
|
22484
20585
|
preprocessType as preprocess,
|
|
22485
20586
|
pipelineType as pipeline,
|
|
22486
|
-
performDecimalOperation,
|
|
22487
|
-
params2Url,
|
|
22488
20587
|
ostring,
|
|
22489
20588
|
optionsToEnum,
|
|
20589
|
+
options2valueEnum,
|
|
22490
20590
|
optionalType as optional,
|
|
22491
20591
|
onumber,
|
|
22492
20592
|
oboolean,
|
|
22493
20593
|
objectUtil,
|
|
22494
20594
|
objectType as object,
|
|
22495
|
-
numberWithCommas,
|
|
22496
20595
|
numberType as number,
|
|
22497
20596
|
nullableType as nullable,
|
|
22498
20597
|
nullType as null,
|
|
@@ -22502,53 +20601,40 @@ export {
|
|
|
22502
20601
|
export_md5 as md5,
|
|
22503
20602
|
mapType as map,
|
|
22504
20603
|
makeIssue,
|
|
20604
|
+
logNetwork,
|
|
22505
20605
|
export_localforage as localforage,
|
|
22506
20606
|
literalType as literal,
|
|
22507
|
-
limitDecimals,
|
|
22508
20607
|
levenshteinDistance,
|
|
22509
20608
|
lazyType as lazy,
|
|
22510
20609
|
late,
|
|
22511
|
-
jsonParse,
|
|
22512
20610
|
export_json5 as json5,
|
|
22513
|
-
isValidNumber,
|
|
22514
20611
|
isValid,
|
|
22515
|
-
|
|
20612
|
+
isJsonObject,
|
|
22516
20613
|
isElementInViewport,
|
|
22517
20614
|
isDirty,
|
|
22518
20615
|
isAsync,
|
|
22519
20616
|
isAborted,
|
|
22520
20617
|
intersectionType as intersection,
|
|
22521
20618
|
instanceOfType as instanceof,
|
|
22522
|
-
initChinaDayjs,
|
|
22523
|
-
imageToBase64,
|
|
22524
20619
|
hexToRgba2 as hexToRgba,
|
|
22525
20620
|
getType,
|
|
22526
|
-
getTotal,
|
|
22527
20621
|
getStrLength,
|
|
22528
20622
|
getSliceStr,
|
|
22529
20623
|
getRandomString,
|
|
22530
|
-
getRandomNum,
|
|
22531
20624
|
getRandomColor,
|
|
22532
20625
|
getPublicUrl,
|
|
22533
|
-
getProxyUrl,
|
|
22534
20626
|
getParsedType,
|
|
22535
|
-
getLength,
|
|
22536
20627
|
getErrorMap,
|
|
22537
|
-
|
|
22538
|
-
getCookie,
|
|
20628
|
+
getColumns,
|
|
22539
20629
|
getChineseByStr,
|
|
22540
|
-
getChinese,
|
|
22541
|
-
generateUniqueFileName,
|
|
22542
20630
|
generateAlphabetArray,
|
|
22543
20631
|
functionType as function,
|
|
22544
|
-
|
|
22545
|
-
flashBorder,
|
|
22546
|
-
flashBackground,
|
|
22547
|
-
findItem,
|
|
20632
|
+
findAttr,
|
|
22548
20633
|
filterParams,
|
|
22549
20634
|
executePromise,
|
|
22550
20635
|
enumType as enum,
|
|
22551
20636
|
effectsType as effect,
|
|
20637
|
+
downloadDataSource,
|
|
22552
20638
|
discriminatedUnionType as discriminatedUnion,
|
|
22553
20639
|
delay,
|
|
22554
20640
|
en_default as defaultErrorMap,
|
|
@@ -22560,7 +20646,6 @@ export {
|
|
|
22560
20646
|
export_consola as consola,
|
|
22561
20647
|
coerce,
|
|
22562
20648
|
export_classnames as classnames,
|
|
22563
|
-
chinaDayjs,
|
|
22564
20649
|
calcJsText,
|
|
22565
20650
|
booleanType as boolean,
|
|
22566
20651
|
bigIntType as bigint,
|
|
@@ -22568,7 +20653,6 @@ export {
|
|
|
22568
20653
|
arrayType as array,
|
|
22569
20654
|
anyType as any,
|
|
22570
20655
|
anime_es_default as anime,
|
|
22571
|
-
amount,
|
|
22572
20656
|
exports_ai as ai,
|
|
22573
20657
|
addIssueToContext,
|
|
22574
20658
|
_,
|