@lotics/cli 0.143.3 → 0.144.0
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/render_page.js +716 -473
- package/dist/src/cli.js +768 -491
- package/dist/src/client.js +8 -0
- package/docs/cli_reference.md +2 -2
- package/package.json +1 -1
package/dist/src/cli.js
CHANGED
|
@@ -14657,7 +14657,7 @@ var require_helpers = __commonJS({
|
|
|
14657
14657
|
"../../node_modules/fast-formula-parser/formulas/helpers.js"(exports2, module2) {
|
|
14658
14658
|
var FormulaError = require_error();
|
|
14659
14659
|
var Collection = require_collection();
|
|
14660
|
-
var
|
|
14660
|
+
var Types3 = {
|
|
14661
14661
|
NUMBER: 0,
|
|
14662
14662
|
ARRAY: 1,
|
|
14663
14663
|
BOOLEAN: 2,
|
|
@@ -14671,16 +14671,16 @@ var require_helpers = __commonJS({
|
|
|
14671
14671
|
};
|
|
14672
14672
|
var Factorials = [1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880, 3628800, 39916800, 479001600, 6227020800, 87178291200, 1307674368e3, 20922789888e3, 355687428096e3, 6402373705728e3, 121645100408832e3, 243290200817664e4, 5109094217170944e4, 11240007277776077e5, 2585201673888498e7, 6204484017332394e8, 15511210043330986e9, 40329146112660565e10, 10888869450418352e12, 30488834461171387e13, 8841761993739702e15, 26525285981219107e16, 8222838654177922e18, 2631308369336935e20, 8683317618811886e21, 29523279903960416e22, 10333147966386145e24, 37199332678990125e25, 13763753091226346e27, 5230226174666011e29, 20397882081197444e30, 8159152832478977e32, 3345252661316381e34, 140500611775288e37, 6041526306337383e37, 2658271574788449e39, 11962222086548019e40, 5502622159812089e42, 25862324151116818e43, 12413915592536073e45, 6082818640342675e47, 30414093201713376e48, 15511187532873822e50, 8065817517094388e52, 42748832840600255e53, 2308436973392414e56, 12696403353658276e57, 7109985878048635e59, 40526919504877214e60, 23505613312828785e62, 13868311854568984e64, 832098711274139e67, 5075802138772248e68, 3146997326038794e70, 198260831540444e73, 12688693218588417e73, 8247650592082472e75, 5443449390774431e77, 3647111091818868e79, 24800355424368305e80, 1711224524281413e83, 11978571669969892e84, 8504785885678623e86, 61234458376886085e87, 44701154615126844e89, 3307885441519386e92, 248091408113954e95, 18854947016660504e95, 14518309202828587e97, 11324281178206297e99, 8946182130782976e101, 7156945704626381e103, 5797126020747368e105, 4753643337012842e107, 3945523969720659e109, 3314240134565353e111, 281710411438055e114, 24227095383672734e114, 2107757298379528e117, 18548264225739844e118, 1650795516090846e121, 14857159644817615e122, 1352001527678403e125, 12438414054641308e126, 11567725070816416e128, 1087366156656743e131, 1032997848823906e133, 9916779348709496e134, 9619275968248212e136, 9426890448883248e138, 9332621544394415e140, 9332621544394415e142];
|
|
14673
14673
|
var ReversedTypes = {};
|
|
14674
|
-
Object.keys(
|
|
14675
|
-
ReversedTypes[
|
|
14674
|
+
Object.keys(Types3).forEach((key) => {
|
|
14675
|
+
ReversedTypes[Types3[key]] = key;
|
|
14676
14676
|
});
|
|
14677
|
-
var
|
|
14677
|
+
var FormulaHelpers3 = class {
|
|
14678
14678
|
constructor() {
|
|
14679
|
-
this.Types =
|
|
14679
|
+
this.Types = Types3;
|
|
14680
14680
|
this.type2Number = {
|
|
14681
|
-
number:
|
|
14682
|
-
boolean:
|
|
14683
|
-
string:
|
|
14681
|
+
number: Types3.NUMBER,
|
|
14682
|
+
boolean: Types3.BOOLEAN,
|
|
14683
|
+
string: Types3.STRING,
|
|
14684
14684
|
object: -1
|
|
14685
14685
|
};
|
|
14686
14686
|
}
|
|
@@ -14763,7 +14763,7 @@ var require_helpers = __commonJS({
|
|
|
14763
14763
|
if (params.length < minSize)
|
|
14764
14764
|
throw FormulaError.ARG_MISSING([valueType]);
|
|
14765
14765
|
if (defValue == null) {
|
|
14766
|
-
defValue = valueType ===
|
|
14766
|
+
defValue = valueType === Types3.NUMBER ? 0 : valueType == null ? null : "";
|
|
14767
14767
|
}
|
|
14768
14768
|
params.forEach((param) => {
|
|
14769
14769
|
const { isCellRef, isRangeRef, isArray: isArray3 } = param;
|
|
@@ -14830,7 +14830,7 @@ var require_helpers = __commonJS({
|
|
|
14830
14830
|
return param;
|
|
14831
14831
|
if (param instanceof FormulaError)
|
|
14832
14832
|
throw param;
|
|
14833
|
-
if (type ===
|
|
14833
|
+
if (type === Types3.ARRAY) {
|
|
14834
14834
|
if (Array.isArray(param)) {
|
|
14835
14835
|
return flat ? this.flattenDeep(param) : param;
|
|
14836
14836
|
} else if (param instanceof Collection) {
|
|
@@ -14839,26 +14839,26 @@ var require_helpers = __commonJS({
|
|
|
14839
14839
|
return flat ? [param] : [[param]];
|
|
14840
14840
|
}
|
|
14841
14841
|
throw FormulaError.VALUE;
|
|
14842
|
-
} else if (type ===
|
|
14842
|
+
} else if (type === Types3.COLLECTIONS) {
|
|
14843
14843
|
return param;
|
|
14844
14844
|
}
|
|
14845
14845
|
if (isArray3) {
|
|
14846
14846
|
param = param[0][0];
|
|
14847
14847
|
}
|
|
14848
14848
|
const paramType = this.type(param);
|
|
14849
|
-
if (type ===
|
|
14850
|
-
if (paramType ===
|
|
14849
|
+
if (type === Types3.STRING) {
|
|
14850
|
+
if (paramType === Types3.BOOLEAN)
|
|
14851
14851
|
param = param ? "TRUE" : "FALSE";
|
|
14852
14852
|
else
|
|
14853
14853
|
param = `${param}`;
|
|
14854
|
-
} else if (type ===
|
|
14855
|
-
if (paramType ===
|
|
14854
|
+
} else if (type === Types3.BOOLEAN) {
|
|
14855
|
+
if (paramType === Types3.STRING)
|
|
14856
14856
|
throw FormulaError.VALUE;
|
|
14857
|
-
if (paramType ===
|
|
14857
|
+
if (paramType === Types3.NUMBER)
|
|
14858
14858
|
param = Boolean(param);
|
|
14859
|
-
} else if (type ===
|
|
14859
|
+
} else if (type === Types3.NUMBER) {
|
|
14860
14860
|
param = this.acceptNumber(param, false);
|
|
14861
|
-
} else if (type ===
|
|
14861
|
+
} else if (type === Types3.NUMBER_NO_BOOLEAN) {
|
|
14862
14862
|
param = this.acceptNumber(param, false, false);
|
|
14863
14863
|
} else {
|
|
14864
14864
|
throw FormulaError.VALUE;
|
|
@@ -14869,15 +14869,15 @@ var require_helpers = __commonJS({
|
|
|
14869
14869
|
let type = this.type2Number[typeof variable];
|
|
14870
14870
|
if (type === -1) {
|
|
14871
14871
|
if (Array.isArray(variable))
|
|
14872
|
-
type =
|
|
14872
|
+
type = Types3.ARRAY;
|
|
14873
14873
|
else if (variable.ref) {
|
|
14874
14874
|
if (variable.ref.from) {
|
|
14875
|
-
type =
|
|
14875
|
+
type = Types3.RANGE_REF;
|
|
14876
14876
|
} else {
|
|
14877
|
-
type =
|
|
14877
|
+
type = Types3.CELL_REF;
|
|
14878
14878
|
}
|
|
14879
14879
|
} else if (variable instanceof Collection)
|
|
14880
|
-
type =
|
|
14880
|
+
type = Types3.COLLECTIONS;
|
|
14881
14881
|
}
|
|
14882
14882
|
return type;
|
|
14883
14883
|
}
|
|
@@ -14896,10 +14896,10 @@ var require_helpers = __commonJS({
|
|
|
14896
14896
|
retrieveRanges(context, range1, range2) {
|
|
14897
14897
|
range2 = Address.extend(range1, range2);
|
|
14898
14898
|
range1 = this.retrieveArg(context, range1);
|
|
14899
|
-
range1 = H.accept(range1,
|
|
14899
|
+
range1 = H.accept(range1, Types3.ARRAY, void 0, false, true);
|
|
14900
14900
|
if (range2 !== range1) {
|
|
14901
14901
|
range2 = this.retrieveArg(context, range2);
|
|
14902
|
-
range2 = H.accept(range2,
|
|
14902
|
+
range2 = H.accept(range2, Types3.ARRAY, void 0, false, true);
|
|
14903
14903
|
} else
|
|
14904
14904
|
range2 = range1;
|
|
14905
14905
|
return [range1, range2];
|
|
@@ -14911,7 +14911,7 @@ var require_helpers = __commonJS({
|
|
|
14911
14911
|
return { value: res.val, isArray: res.isArray, ref: arg.ref };
|
|
14912
14912
|
}
|
|
14913
14913
|
};
|
|
14914
|
-
var H = new
|
|
14914
|
+
var H = new FormulaHelpers3();
|
|
14915
14915
|
var WildCard = {
|
|
14916
14916
|
/**
|
|
14917
14917
|
* @param {string|*} obj
|
|
@@ -15028,7 +15028,7 @@ var require_helpers = __commonJS({
|
|
|
15028
15028
|
};
|
|
15029
15029
|
module2.exports = {
|
|
15030
15030
|
FormulaHelpers: H,
|
|
15031
|
-
Types,
|
|
15031
|
+
Types: Types3,
|
|
15032
15032
|
ReversedTypes,
|
|
15033
15033
|
Factorials,
|
|
15034
15034
|
WildCard,
|
|
@@ -15101,8 +15101,8 @@ var require_error = __commonJS({
|
|
|
15101
15101
|
return new FormulaError("#N/A", `Function ${functionName} has too many arguments.`);
|
|
15102
15102
|
};
|
|
15103
15103
|
FormulaError.ARG_MISSING = (args) => {
|
|
15104
|
-
const { Types } = require_helpers();
|
|
15105
|
-
return new FormulaError("#N/A", `Argument type ${args.map((arg) =>
|
|
15104
|
+
const { Types: Types3 } = require_helpers();
|
|
15105
|
+
return new FormulaError("#N/A", `Argument type ${args.map((arg) => Types3[arg]).join(", ")} is missing.`);
|
|
15106
15106
|
};
|
|
15107
15107
|
FormulaError.ERROR = (msg, details) => {
|
|
15108
15108
|
return new FormulaError("#ERROR!", msg, details);
|
|
@@ -16452,8 +16452,8 @@ var require_src = __commonJS({
|
|
|
16452
16452
|
var require_text = __commonJS({
|
|
16453
16453
|
"../../node_modules/fast-formula-parser/formulas/functions/text.js"(exports2, module2) {
|
|
16454
16454
|
var FormulaError = require_error();
|
|
16455
|
-
var { FormulaHelpers, Types, WildCard } = require_helpers();
|
|
16456
|
-
var H =
|
|
16455
|
+
var { FormulaHelpers: FormulaHelpers3, Types: Types3, WildCard } = require_helpers();
|
|
16456
|
+
var H = FormulaHelpers3;
|
|
16457
16457
|
var ssf = require_ssf();
|
|
16458
16458
|
var bahttext = require_src();
|
|
16459
16459
|
var charsets = {
|
|
@@ -16479,11 +16479,11 @@ var require_text = __commonJS({
|
|
|
16479
16479
|
var toHalfWidth = (str0) => sets.reduce((str, set2) => str.replace(re2(set2, "full"), toHalf(set2)), str0);
|
|
16480
16480
|
var TextFunctions = {
|
|
16481
16481
|
ASC: (text) => {
|
|
16482
|
-
text = H.accept(text,
|
|
16482
|
+
text = H.accept(text, Types3.STRING);
|
|
16483
16483
|
return toHalfWidth(text);
|
|
16484
16484
|
},
|
|
16485
16485
|
BAHTTEXT: (number4) => {
|
|
16486
|
-
number4 = H.accept(number4,
|
|
16486
|
+
number4 = H.accept(number4, Types3.NUMBER);
|
|
16487
16487
|
try {
|
|
16488
16488
|
return bahttext(number4);
|
|
16489
16489
|
} catch (e) {
|
|
@@ -16492,25 +16492,25 @@ ${e.toString()}`);
|
|
|
16492
16492
|
}
|
|
16493
16493
|
},
|
|
16494
16494
|
CHAR: (number4) => {
|
|
16495
|
-
number4 = H.accept(number4,
|
|
16495
|
+
number4 = H.accept(number4, Types3.NUMBER);
|
|
16496
16496
|
if (number4 > 255 || number4 < 1)
|
|
16497
16497
|
throw FormulaError.VALUE;
|
|
16498
16498
|
return String.fromCharCode(number4);
|
|
16499
16499
|
},
|
|
16500
16500
|
CLEAN: (text) => {
|
|
16501
|
-
text = H.accept(text,
|
|
16501
|
+
text = H.accept(text, Types3.STRING);
|
|
16502
16502
|
return text.replace(/[\x00-\x1F]/g, "");
|
|
16503
16503
|
},
|
|
16504
16504
|
CODE: (text) => {
|
|
16505
|
-
text = H.accept(text,
|
|
16505
|
+
text = H.accept(text, Types3.STRING);
|
|
16506
16506
|
if (text.length === 0)
|
|
16507
16507
|
throw FormulaError.VALUE;
|
|
16508
16508
|
return text.charCodeAt(0);
|
|
16509
16509
|
},
|
|
16510
16510
|
CONCAT: (...params) => {
|
|
16511
16511
|
let text = "";
|
|
16512
|
-
H.flattenParams(params,
|
|
16513
|
-
item = H.accept(item,
|
|
16512
|
+
H.flattenParams(params, Types3.STRING, false, (item) => {
|
|
16513
|
+
item = H.accept(item, Types3.STRING);
|
|
16514
16514
|
text += item;
|
|
16515
16515
|
});
|
|
16516
16516
|
return text;
|
|
@@ -16520,30 +16520,30 @@ ${e.toString()}`);
|
|
|
16520
16520
|
if (params.length === 0)
|
|
16521
16521
|
throw Error("CONCATENATE need at least one argument.");
|
|
16522
16522
|
params.forEach((param) => {
|
|
16523
|
-
param = H.accept(param,
|
|
16523
|
+
param = H.accept(param, Types3.STRING);
|
|
16524
16524
|
text += param;
|
|
16525
16525
|
});
|
|
16526
16526
|
return text;
|
|
16527
16527
|
},
|
|
16528
16528
|
DBCS: (text) => {
|
|
16529
|
-
text = H.accept(text,
|
|
16529
|
+
text = H.accept(text, Types3.STRING);
|
|
16530
16530
|
return toFullWidth(text);
|
|
16531
16531
|
},
|
|
16532
16532
|
DOLLAR: (number4, decimals) => {
|
|
16533
|
-
number4 = H.accept(number4,
|
|
16534
|
-
decimals = H.accept(decimals,
|
|
16533
|
+
number4 = H.accept(number4, Types3.NUMBER);
|
|
16534
|
+
decimals = H.accept(decimals, Types3.NUMBER, 2);
|
|
16535
16535
|
const decimalString = Array(decimals).fill("0").join("");
|
|
16536
16536
|
return ssf.format(`$#,##0.${decimalString}_);($#,##0.${decimalString})`, number4).trim();
|
|
16537
16537
|
},
|
|
16538
16538
|
EXACT: (text1, text2) => {
|
|
16539
|
-
text1 = H.accept(text1, [
|
|
16540
|
-
text2 = H.accept(text2, [
|
|
16539
|
+
text1 = H.accept(text1, [Types3.STRING]);
|
|
16540
|
+
text2 = H.accept(text2, [Types3.STRING]);
|
|
16541
16541
|
return text1 === text2;
|
|
16542
16542
|
},
|
|
16543
16543
|
FIND: (findText, withinText, startNum) => {
|
|
16544
|
-
findText = H.accept(findText,
|
|
16545
|
-
withinText = H.accept(withinText,
|
|
16546
|
-
startNum = H.accept(startNum,
|
|
16544
|
+
findText = H.accept(findText, Types3.STRING);
|
|
16545
|
+
withinText = H.accept(withinText, Types3.STRING);
|
|
16546
|
+
startNum = H.accept(startNum, Types3.NUMBER, 1);
|
|
16547
16547
|
if (startNum < 1 || startNum > withinText.length)
|
|
16548
16548
|
throw FormulaError.VALUE;
|
|
16549
16549
|
const res = withinText.indexOf(findText, startNum - 1);
|
|
@@ -16555,16 +16555,16 @@ ${e.toString()}`);
|
|
|
16555
16555
|
return TextFunctions.FIND(...params);
|
|
16556
16556
|
},
|
|
16557
16557
|
FIXED: (number4, decimals, noCommas) => {
|
|
16558
|
-
number4 = H.accept(number4,
|
|
16559
|
-
decimals = H.accept(decimals,
|
|
16560
|
-
noCommas = H.accept(noCommas,
|
|
16558
|
+
number4 = H.accept(number4, Types3.NUMBER);
|
|
16559
|
+
decimals = H.accept(decimals, Types3.NUMBER, 2);
|
|
16560
|
+
noCommas = H.accept(noCommas, Types3.BOOLEAN, false);
|
|
16561
16561
|
const decimalString = Array(decimals).fill("0").join("");
|
|
16562
16562
|
const comma = noCommas ? "" : "#,";
|
|
16563
16563
|
return ssf.format(`${comma}##0.${decimalString}_);(${comma}##0.${decimalString})`, number4).trim();
|
|
16564
16564
|
},
|
|
16565
16565
|
LEFT: (text, numChars) => {
|
|
16566
|
-
text = H.accept(text,
|
|
16567
|
-
numChars = H.accept(numChars,
|
|
16566
|
+
text = H.accept(text, Types3.STRING);
|
|
16567
|
+
numChars = H.accept(numChars, Types3.NUMBER, 1);
|
|
16568
16568
|
if (numChars < 0)
|
|
16569
16569
|
throw FormulaError.VALUE;
|
|
16570
16570
|
if (numChars > text.length)
|
|
@@ -16575,20 +16575,20 @@ ${e.toString()}`);
|
|
|
16575
16575
|
return TextFunctions.LEFT(...params);
|
|
16576
16576
|
},
|
|
16577
16577
|
LEN: (text) => {
|
|
16578
|
-
text = H.accept(text,
|
|
16578
|
+
text = H.accept(text, Types3.STRING);
|
|
16579
16579
|
return text.length;
|
|
16580
16580
|
},
|
|
16581
16581
|
LENB: (...params) => {
|
|
16582
16582
|
return TextFunctions.LEN(...params);
|
|
16583
16583
|
},
|
|
16584
16584
|
LOWER: (text) => {
|
|
16585
|
-
text = H.accept(text,
|
|
16585
|
+
text = H.accept(text, Types3.STRING);
|
|
16586
16586
|
return text.toLowerCase();
|
|
16587
16587
|
},
|
|
16588
16588
|
MID: (text, startNum, numChars) => {
|
|
16589
|
-
text = H.accept(text,
|
|
16590
|
-
startNum = H.accept(startNum,
|
|
16591
|
-
numChars = H.accept(numChars,
|
|
16589
|
+
text = H.accept(text, Types3.STRING);
|
|
16590
|
+
startNum = H.accept(startNum, Types3.NUMBER);
|
|
16591
|
+
numChars = H.accept(numChars, Types3.NUMBER);
|
|
16592
16592
|
if (startNum > text.length)
|
|
16593
16593
|
return "";
|
|
16594
16594
|
if (startNum < 1 || numChars < 1)
|
|
@@ -16599,9 +16599,9 @@ ${e.toString()}`);
|
|
|
16599
16599
|
return TextFunctions.MID(...params);
|
|
16600
16600
|
},
|
|
16601
16601
|
NUMBERVALUE: (text, decimalSeparator, groupSeparator) => {
|
|
16602
|
-
text = H.accept(text,
|
|
16603
|
-
decimalSeparator = H.accept(decimalSeparator,
|
|
16604
|
-
groupSeparator = H.accept(groupSeparator,
|
|
16602
|
+
text = H.accept(text, Types3.STRING);
|
|
16603
|
+
decimalSeparator = H.accept(decimalSeparator, Types3.STRING, ".");
|
|
16604
|
+
groupSeparator = H.accept(groupSeparator, Types3.STRING, ",");
|
|
16605
16605
|
if (text.length === 0)
|
|
16606
16606
|
return 0;
|
|
16607
16607
|
if (decimalSeparator.length === 0 || groupSeparator.length === 0)
|
|
@@ -16623,7 +16623,7 @@ ${e.toString()}`);
|
|
|
16623
16623
|
PHONETIC: () => {
|
|
16624
16624
|
},
|
|
16625
16625
|
PROPER: (text) => {
|
|
16626
|
-
text = H.accept(text, [
|
|
16626
|
+
text = H.accept(text, [Types3.STRING]);
|
|
16627
16627
|
text = text.toLowerCase();
|
|
16628
16628
|
text = text.charAt(0).toUpperCase() + text.slice(1);
|
|
16629
16629
|
return text.replace(
|
|
@@ -16632,10 +16632,10 @@ ${e.toString()}`);
|
|
|
16632
16632
|
);
|
|
16633
16633
|
},
|
|
16634
16634
|
REPLACE: (old_text, start_num, num_chars, new_text) => {
|
|
16635
|
-
old_text = H.accept(old_text, [
|
|
16636
|
-
start_num = H.accept(start_num, [
|
|
16637
|
-
num_chars = H.accept(num_chars, [
|
|
16638
|
-
new_text = H.accept(new_text, [
|
|
16635
|
+
old_text = H.accept(old_text, [Types3.STRING]);
|
|
16636
|
+
start_num = H.accept(start_num, [Types3.NUMBER]);
|
|
16637
|
+
num_chars = H.accept(num_chars, [Types3.NUMBER]);
|
|
16638
|
+
new_text = H.accept(new_text, [Types3.STRING]);
|
|
16639
16639
|
let arr = old_text.split("");
|
|
16640
16640
|
arr.splice(start_num - 1, num_chars, new_text);
|
|
16641
16641
|
return arr.join("");
|
|
@@ -16644,8 +16644,8 @@ ${e.toString()}`);
|
|
|
16644
16644
|
return TextFunctions.REPLACE(...params);
|
|
16645
16645
|
},
|
|
16646
16646
|
REPT: (text, number_times) => {
|
|
16647
|
-
text = H.accept(text,
|
|
16648
|
-
number_times = H.accept(number_times,
|
|
16647
|
+
text = H.accept(text, Types3.STRING);
|
|
16648
|
+
number_times = H.accept(number_times, Types3.NUMBER);
|
|
16649
16649
|
let str = "";
|
|
16650
16650
|
for (let i2 = 0; i2 < number_times; i2++) {
|
|
16651
16651
|
str += text;
|
|
@@ -16653,8 +16653,8 @@ ${e.toString()}`);
|
|
|
16653
16653
|
return str;
|
|
16654
16654
|
},
|
|
16655
16655
|
RIGHT: (text, numChars) => {
|
|
16656
|
-
text = H.accept(text,
|
|
16657
|
-
numChars = H.accept(numChars,
|
|
16656
|
+
text = H.accept(text, Types3.STRING);
|
|
16657
|
+
numChars = H.accept(numChars, Types3.NUMBER, 1);
|
|
16658
16658
|
if (numChars < 0)
|
|
16659
16659
|
throw FormulaError.VALUE;
|
|
16660
16660
|
const len = text.length;
|
|
@@ -16666,9 +16666,9 @@ ${e.toString()}`);
|
|
|
16666
16666
|
return TextFunctions.RIGHT(...params);
|
|
16667
16667
|
},
|
|
16668
16668
|
SEARCH: (findText, withinText, startNum) => {
|
|
16669
|
-
findText = H.accept(findText,
|
|
16670
|
-
withinText = H.accept(withinText,
|
|
16671
|
-
startNum = H.accept(startNum,
|
|
16669
|
+
findText = H.accept(findText, Types3.STRING);
|
|
16670
|
+
withinText = H.accept(withinText, Types3.STRING);
|
|
16671
|
+
startNum = H.accept(startNum, Types3.NUMBER, 1);
|
|
16672
16672
|
if (startNum < 1 || startNum > withinText.length)
|
|
16673
16673
|
throw FormulaError.VALUE;
|
|
16674
16674
|
let findTextRegex = WildCard.isWildCard(findText) ? WildCard.toRegex(findText, "i") : findText;
|
|
@@ -16689,8 +16689,8 @@ ${e.toString()}`);
|
|
|
16689
16689
|
return "";
|
|
16690
16690
|
},
|
|
16691
16691
|
TEXT: (value2, formatText) => {
|
|
16692
|
-
value2 = H.accept(value2,
|
|
16693
|
-
formatText = H.accept(formatText,
|
|
16692
|
+
value2 = H.accept(value2, Types3.NUMBER);
|
|
16693
|
+
formatText = H.accept(formatText, Types3.STRING);
|
|
16694
16694
|
try {
|
|
16695
16695
|
return ssf.format(formatText, value2);
|
|
16696
16696
|
} catch (e) {
|
|
@@ -16701,11 +16701,11 @@ ${e.toString()}`);
|
|
|
16701
16701
|
TEXTJOIN: (...params) => {
|
|
16702
16702
|
},
|
|
16703
16703
|
TRIM: (text) => {
|
|
16704
|
-
text = H.accept(text, [
|
|
16704
|
+
text = H.accept(text, [Types3.STRING]);
|
|
16705
16705
|
return text.replace(/^\s+|\s+$/g, "");
|
|
16706
16706
|
},
|
|
16707
16707
|
UNICHAR: (number4) => {
|
|
16708
|
-
number4 = H.accept(number4, [
|
|
16708
|
+
number4 = H.accept(number4, [Types3.NUMBER]);
|
|
16709
16709
|
if (number4 <= 0)
|
|
16710
16710
|
throw FormulaError.VALUE;
|
|
16711
16711
|
return String.fromCharCode(number4);
|
|
@@ -16722,7 +16722,7 @@ ${e.toString()}`);
|
|
|
16722
16722
|
var require_operators = __commonJS({
|
|
16723
16723
|
"../../node_modules/fast-formula-parser/formulas/operators.js"(exports2, module2) {
|
|
16724
16724
|
var FormulaError = require_error();
|
|
16725
|
-
var { FormulaHelpers } = require_helpers();
|
|
16725
|
+
var { FormulaHelpers: FormulaHelpers3 } = require_helpers();
|
|
16726
16726
|
var Prefix = {
|
|
16727
16727
|
unaryOp: (prefixes, value2, isArray3) => {
|
|
16728
16728
|
let sign = 1;
|
|
@@ -16741,7 +16741,7 @@ var require_operators = __commonJS({
|
|
|
16741
16741
|
return value2;
|
|
16742
16742
|
}
|
|
16743
16743
|
try {
|
|
16744
|
-
value2 =
|
|
16744
|
+
value2 = FormulaHelpers3.acceptNumber(value2, isArray3);
|
|
16745
16745
|
} catch (e) {
|
|
16746
16746
|
if (e instanceof FormulaError) {
|
|
16747
16747
|
if (Array.isArray(value2))
|
|
@@ -16756,7 +16756,7 @@ var require_operators = __commonJS({
|
|
|
16756
16756
|
var Postfix = {
|
|
16757
16757
|
percentOp: (value2, postfix, isArray3) => {
|
|
16758
16758
|
try {
|
|
16759
|
-
value2 =
|
|
16759
|
+
value2 = FormulaHelpers3.acceptNumber(value2, isArray3);
|
|
16760
16760
|
} catch (e) {
|
|
16761
16761
|
if (e instanceof FormulaError)
|
|
16762
16762
|
return e;
|
|
@@ -16833,8 +16833,8 @@ var require_operators = __commonJS({
|
|
|
16833
16833
|
if (value1 == null) value1 = 0;
|
|
16834
16834
|
if (value2 == null) value2 = 0;
|
|
16835
16835
|
try {
|
|
16836
|
-
value1 =
|
|
16837
|
-
value2 =
|
|
16836
|
+
value1 = FormulaHelpers3.acceptNumber(value1, isArray1);
|
|
16837
|
+
value2 = FormulaHelpers3.acceptNumber(value2, isArray22);
|
|
16838
16838
|
} catch (e) {
|
|
16839
16839
|
if (e instanceof FormulaError)
|
|
16840
16840
|
return e;
|
|
@@ -16874,9 +16874,9 @@ var require_operators = __commonJS({
|
|
|
16874
16874
|
var require_math = __commonJS({
|
|
16875
16875
|
"../../node_modules/fast-formula-parser/formulas/functions/math.js"(exports2, module2) {
|
|
16876
16876
|
var FormulaError = require_error();
|
|
16877
|
-
var { FormulaHelpers, Types, Factorials, Criteria } = require_helpers();
|
|
16877
|
+
var { FormulaHelpers: FormulaHelpers3, Types: Types3, Factorials, Criteria } = require_helpers();
|
|
16878
16878
|
var { Infix: Infix2 } = require_operators();
|
|
16879
|
-
var H =
|
|
16879
|
+
var H = FormulaHelpers3;
|
|
16880
16880
|
var f = [];
|
|
16881
16881
|
var fd2 = [];
|
|
16882
16882
|
function factorial(n) {
|
|
@@ -16897,13 +16897,13 @@ var require_math = __commonJS({
|
|
|
16897
16897
|
}
|
|
16898
16898
|
var MathFunctions = {
|
|
16899
16899
|
ABS: (number4) => {
|
|
16900
|
-
number4 = H.accept(number4,
|
|
16900
|
+
number4 = H.accept(number4, Types3.NUMBER);
|
|
16901
16901
|
return Math.abs(number4);
|
|
16902
16902
|
},
|
|
16903
16903
|
AGGREGATE: (functionNum, options, ref1, ...refs) => {
|
|
16904
16904
|
},
|
|
16905
16905
|
ARABIC: (text) => {
|
|
16906
|
-
text = H.accept(text,
|
|
16906
|
+
text = H.accept(text, Types3.STRING).toUpperCase();
|
|
16907
16907
|
if (!/^M*(?:D?C{0,3}|C[MD])(?:L?X{0,3}|X[CL])(?:V?I{0,3}|I[XV])$/.test(text)) {
|
|
16908
16908
|
throw new FormulaError("#VALUE!", "Invalid roman numeral in ARABIC evaluation.");
|
|
16909
16909
|
}
|
|
@@ -16928,13 +16928,13 @@ var require_math = __commonJS({
|
|
|
16928
16928
|
return r;
|
|
16929
16929
|
},
|
|
16930
16930
|
BASE: (number4, radix, minLength) => {
|
|
16931
|
-
number4 = H.accept(number4,
|
|
16931
|
+
number4 = H.accept(number4, Types3.NUMBER);
|
|
16932
16932
|
if (number4 < 0 || number4 >= 2 ** 53)
|
|
16933
16933
|
throw FormulaError.NUM;
|
|
16934
|
-
radix = H.accept(radix,
|
|
16934
|
+
radix = H.accept(radix, Types3.NUMBER);
|
|
16935
16935
|
if (radix < 2 || radix > 36)
|
|
16936
16936
|
throw FormulaError.NUM;
|
|
16937
|
-
minLength = H.accept(minLength,
|
|
16937
|
+
minLength = H.accept(minLength, Types3.NUMBER, 0);
|
|
16938
16938
|
if (minLength < 0) {
|
|
16939
16939
|
throw FormulaError.NUM;
|
|
16940
16940
|
}
|
|
@@ -16942,8 +16942,8 @@ var require_math = __commonJS({
|
|
|
16942
16942
|
return new Array(Math.max(minLength + 1 - result.length, 0)).join("0") + result;
|
|
16943
16943
|
},
|
|
16944
16944
|
CEILING: (number4, significance) => {
|
|
16945
|
-
number4 = H.accept(number4,
|
|
16946
|
-
significance = H.accept(significance,
|
|
16945
|
+
number4 = H.accept(number4, Types3.NUMBER);
|
|
16946
|
+
significance = H.accept(significance, Types3.NUMBER);
|
|
16947
16947
|
if (significance === 0)
|
|
16948
16948
|
return 0;
|
|
16949
16949
|
if (number4 / significance % 1 === 0)
|
|
@@ -16958,9 +16958,9 @@ var require_math = __commonJS({
|
|
|
16958
16958
|
}
|
|
16959
16959
|
},
|
|
16960
16960
|
"CEILING.MATH": (number4, significance, mode) => {
|
|
16961
|
-
number4 = H.accept(number4,
|
|
16962
|
-
significance = H.accept(significance,
|
|
16963
|
-
mode = H.accept(mode,
|
|
16961
|
+
number4 = H.accept(number4, Types3.NUMBER);
|
|
16962
|
+
significance = H.accept(significance, Types3.NUMBER, number4 > 0 ? 1 : -1);
|
|
16963
|
+
mode = H.accept(mode, Types3.NUMBER, 0);
|
|
16964
16964
|
if (number4 >= 0) {
|
|
16965
16965
|
return MathFunctions.CEILING(number4, significance);
|
|
16966
16966
|
}
|
|
@@ -16968,21 +16968,21 @@ var require_math = __commonJS({
|
|
|
16968
16968
|
return MathFunctions.CEILING(number4, significance) - offset;
|
|
16969
16969
|
},
|
|
16970
16970
|
"CEILING.PRECISE": (number4, significance) => {
|
|
16971
|
-
number4 = H.accept(number4,
|
|
16972
|
-
significance = H.accept(significance,
|
|
16971
|
+
number4 = H.accept(number4, Types3.NUMBER);
|
|
16972
|
+
significance = H.accept(significance, Types3.NUMBER, 1);
|
|
16973
16973
|
return MathFunctions.CEILING(number4, Math.abs(significance));
|
|
16974
16974
|
},
|
|
16975
16975
|
COMBIN: (number4, numberChosen) => {
|
|
16976
|
-
number4 = H.accept(number4,
|
|
16977
|
-
numberChosen = H.accept(numberChosen,
|
|
16976
|
+
number4 = H.accept(number4, Types3.NUMBER);
|
|
16977
|
+
numberChosen = H.accept(numberChosen, Types3.NUMBER);
|
|
16978
16978
|
if (number4 < 0 || numberChosen < 0 || number4 < numberChosen)
|
|
16979
16979
|
throw FormulaError.NUM;
|
|
16980
16980
|
const nFactorial = MathFunctions.FACT(number4), kFactorial = MathFunctions.FACT(numberChosen);
|
|
16981
16981
|
return nFactorial / kFactorial / MathFunctions.FACT(number4 - numberChosen);
|
|
16982
16982
|
},
|
|
16983
16983
|
COMBINA: (number4, numberChosen) => {
|
|
16984
|
-
number4 = H.accept(number4,
|
|
16985
|
-
numberChosen = H.accept(numberChosen,
|
|
16984
|
+
number4 = H.accept(number4, Types3.NUMBER);
|
|
16985
|
+
numberChosen = H.accept(numberChosen, Types3.NUMBER);
|
|
16986
16986
|
if ((number4 === 0 || number4 === 1) && numberChosen === 0)
|
|
16987
16987
|
return 1;
|
|
16988
16988
|
if (number4 < 0 || numberChosen < 0)
|
|
@@ -16990,8 +16990,8 @@ var require_math = __commonJS({
|
|
|
16990
16990
|
return MathFunctions.COMBIN(number4 + numberChosen - 1, number4 - 1);
|
|
16991
16991
|
},
|
|
16992
16992
|
DECIMAL: (text, radix) => {
|
|
16993
|
-
text = H.accept(text,
|
|
16994
|
-
radix = H.accept(radix,
|
|
16993
|
+
text = H.accept(text, Types3.STRING);
|
|
16994
|
+
radix = H.accept(radix, Types3.NUMBER);
|
|
16995
16995
|
radix = Math.trunc(radix);
|
|
16996
16996
|
if (radix < 2 || radix > 36)
|
|
16997
16997
|
throw FormulaError.NUM;
|
|
@@ -17001,18 +17001,18 @@ var require_math = __commonJS({
|
|
|
17001
17001
|
return res;
|
|
17002
17002
|
},
|
|
17003
17003
|
DEGREES: (radians) => {
|
|
17004
|
-
radians = H.accept(radians,
|
|
17004
|
+
radians = H.accept(radians, Types3.NUMBER);
|
|
17005
17005
|
return radians * (180 / Math.PI);
|
|
17006
17006
|
},
|
|
17007
17007
|
EVEN: (number4) => {
|
|
17008
17008
|
return MathFunctions.CEILING(number4, -2);
|
|
17009
17009
|
},
|
|
17010
17010
|
EXP: (number4) => {
|
|
17011
|
-
number4 = H.accept(number4,
|
|
17011
|
+
number4 = H.accept(number4, Types3.NUMBER);
|
|
17012
17012
|
return Math.exp(number4);
|
|
17013
17013
|
},
|
|
17014
17014
|
FACT: (number4) => {
|
|
17015
|
-
number4 = H.accept(number4,
|
|
17015
|
+
number4 = H.accept(number4, Types3.NUMBER);
|
|
17016
17016
|
number4 = Math.trunc(number4);
|
|
17017
17017
|
if (number4 > 170 || number4 < 0)
|
|
17018
17018
|
throw FormulaError.NUM;
|
|
@@ -17021,7 +17021,7 @@ var require_math = __commonJS({
|
|
|
17021
17021
|
return factorial(number4);
|
|
17022
17022
|
},
|
|
17023
17023
|
FACTDOUBLE: (number4) => {
|
|
17024
|
-
number4 = H.accept(number4,
|
|
17024
|
+
number4 = H.accept(number4, Types3.NUMBER);
|
|
17025
17025
|
number4 = Math.trunc(number4);
|
|
17026
17026
|
if (number4 < -1)
|
|
17027
17027
|
throw FormulaError.NUM;
|
|
@@ -17030,8 +17030,8 @@ var require_math = __commonJS({
|
|
|
17030
17030
|
return factorialDouble(number4);
|
|
17031
17031
|
},
|
|
17032
17032
|
FLOOR: (number4, significance) => {
|
|
17033
|
-
number4 = H.accept(number4,
|
|
17034
|
-
significance = H.accept(significance,
|
|
17033
|
+
number4 = H.accept(number4, Types3.NUMBER);
|
|
17034
|
+
significance = H.accept(significance, Types3.NUMBER);
|
|
17035
17035
|
if (significance === 0)
|
|
17036
17036
|
return 0;
|
|
17037
17037
|
if (number4 > 0 && significance < 0)
|
|
@@ -17048,17 +17048,17 @@ var require_math = __commonJS({
|
|
|
17048
17048
|
}
|
|
17049
17049
|
},
|
|
17050
17050
|
"FLOOR.MATH": (number4, significance, mode) => {
|
|
17051
|
-
number4 = H.accept(number4,
|
|
17052
|
-
significance = H.accept(significance,
|
|
17053
|
-
mode = H.accept(mode,
|
|
17051
|
+
number4 = H.accept(number4, Types3.NUMBER);
|
|
17052
|
+
significance = H.accept(significance, Types3.NUMBER, number4 > 0 ? 1 : -1);
|
|
17053
|
+
mode = H.accept(mode, Types3.NUMBER, 0);
|
|
17054
17054
|
if (mode === 0 || number4 >= 0) {
|
|
17055
17055
|
return MathFunctions.FLOOR(number4, Math.abs(significance));
|
|
17056
17056
|
}
|
|
17057
17057
|
return MathFunctions.FLOOR(number4, significance) + significance;
|
|
17058
17058
|
},
|
|
17059
17059
|
"FLOOR.PRECISE": (number4, significance) => {
|
|
17060
|
-
number4 = H.accept(number4,
|
|
17061
|
-
significance = H.accept(significance,
|
|
17060
|
+
number4 = H.accept(number4, Types3.NUMBER);
|
|
17061
|
+
significance = H.accept(significance, Types3.NUMBER, 1);
|
|
17062
17062
|
return MathFunctions.FLOOR(number4, Math.abs(significance));
|
|
17063
17063
|
},
|
|
17064
17064
|
GCD: (...params) => {
|
|
@@ -17089,7 +17089,7 @@ var require_math = __commonJS({
|
|
|
17089
17089
|
return x2;
|
|
17090
17090
|
},
|
|
17091
17091
|
INT: (number4) => {
|
|
17092
|
-
number4 = H.accept(number4,
|
|
17092
|
+
number4 = H.accept(number4, Types3.NUMBER);
|
|
17093
17093
|
return Math.floor(number4);
|
|
17094
17094
|
},
|
|
17095
17095
|
"ISO.CEILING": (...params) => {
|
|
@@ -17123,20 +17123,20 @@ var require_math = __commonJS({
|
|
|
17123
17123
|
return a;
|
|
17124
17124
|
},
|
|
17125
17125
|
LN: (number4) => {
|
|
17126
|
-
number4 = H.accept(number4,
|
|
17126
|
+
number4 = H.accept(number4, Types3.NUMBER);
|
|
17127
17127
|
return Math.log(number4);
|
|
17128
17128
|
},
|
|
17129
17129
|
LOG: (number4, base) => {
|
|
17130
|
-
number4 = H.accept(number4,
|
|
17131
|
-
base = H.accept(base,
|
|
17130
|
+
number4 = H.accept(number4, Types3.NUMBER);
|
|
17131
|
+
base = H.accept(base, Types3.NUMBER, 10);
|
|
17132
17132
|
return Math.log(number4) / Math.log(base);
|
|
17133
17133
|
},
|
|
17134
17134
|
LOG10: (number4) => {
|
|
17135
|
-
number4 = H.accept(number4,
|
|
17135
|
+
number4 = H.accept(number4, Types3.NUMBER);
|
|
17136
17136
|
return Math.log10(number4);
|
|
17137
17137
|
},
|
|
17138
17138
|
MDETERM: (array2) => {
|
|
17139
|
-
array2 = H.accept(array2,
|
|
17139
|
+
array2 = H.accept(array2, Types3.ARRAY, void 0, false, true);
|
|
17140
17140
|
if (array2[0].length !== array2.length)
|
|
17141
17141
|
throw FormulaError.VALUE;
|
|
17142
17142
|
const numRow = array2.length, numCol = array2[0].length;
|
|
@@ -17160,8 +17160,8 @@ var require_math = __commonJS({
|
|
|
17160
17160
|
MINVERSE: (array2) => {
|
|
17161
17161
|
},
|
|
17162
17162
|
MMULT: (array1, array2) => {
|
|
17163
|
-
array1 = H.accept(array1,
|
|
17164
|
-
array2 = H.accept(array2,
|
|
17163
|
+
array1 = H.accept(array1, Types3.ARRAY, void 0, false, true);
|
|
17164
|
+
array2 = H.accept(array2, Types3.ARRAY, void 0, false, true);
|
|
17165
17165
|
const aNumRows = array1.length, aNumCols = array1[0].length, bNumRows = array2.length, bNumCols = array2[0].length, m = new Array(aNumRows);
|
|
17166
17166
|
if (aNumCols !== bNumRows)
|
|
17167
17167
|
throw FormulaError.VALUE;
|
|
@@ -17179,15 +17179,15 @@ var require_math = __commonJS({
|
|
|
17179
17179
|
return m;
|
|
17180
17180
|
},
|
|
17181
17181
|
MOD: (number4, divisor) => {
|
|
17182
|
-
number4 = H.accept(number4,
|
|
17183
|
-
divisor = H.accept(divisor,
|
|
17182
|
+
number4 = H.accept(number4, Types3.NUMBER);
|
|
17183
|
+
divisor = H.accept(divisor, Types3.NUMBER);
|
|
17184
17184
|
if (divisor === 0)
|
|
17185
17185
|
throw FormulaError.DIV0;
|
|
17186
17186
|
return number4 - divisor * MathFunctions.INT(number4 / divisor);
|
|
17187
17187
|
},
|
|
17188
17188
|
MROUND: (number4, multiple) => {
|
|
17189
|
-
number4 = H.accept(number4,
|
|
17190
|
-
multiple = H.accept(multiple,
|
|
17189
|
+
number4 = H.accept(number4, Types3.NUMBER);
|
|
17190
|
+
multiple = H.accept(multiple, Types3.NUMBER);
|
|
17191
17191
|
if (multiple === 0)
|
|
17192
17192
|
return 0;
|
|
17193
17193
|
if (number4 > 0 && multiple < 0 || number4 < 0 && multiple > 0)
|
|
@@ -17198,7 +17198,7 @@ var require_math = __commonJS({
|
|
|
17198
17198
|
},
|
|
17199
17199
|
MULTINOMIAL: (...numbers2) => {
|
|
17200
17200
|
let numerator = 0, denominator = 1;
|
|
17201
|
-
H.flattenParams(numbers2,
|
|
17201
|
+
H.flattenParams(numbers2, Types3.NUMBER, false, (number4) => {
|
|
17202
17202
|
if (number4 < 0)
|
|
17203
17203
|
throw FormulaError.NUM;
|
|
17204
17204
|
numerator += number4;
|
|
@@ -17207,7 +17207,7 @@ var require_math = __commonJS({
|
|
|
17207
17207
|
return factorial(numerator) / denominator;
|
|
17208
17208
|
},
|
|
17209
17209
|
MUNIT: (dimension) => {
|
|
17210
|
-
dimension = H.accept(dimension,
|
|
17210
|
+
dimension = H.accept(dimension, Types3.NUMBER);
|
|
17211
17211
|
const matrix = [];
|
|
17212
17212
|
for (let row = 0; row < dimension; row++) {
|
|
17213
17213
|
const rowArr = [];
|
|
@@ -17222,7 +17222,7 @@ var require_math = __commonJS({
|
|
|
17222
17222
|
return matrix;
|
|
17223
17223
|
},
|
|
17224
17224
|
ODD: (number4) => {
|
|
17225
|
-
number4 = H.accept(number4,
|
|
17225
|
+
number4 = H.accept(number4, Types3.NUMBER);
|
|
17226
17226
|
if (number4 === 0)
|
|
17227
17227
|
return 1;
|
|
17228
17228
|
let temp = Math.ceil(Math.abs(number4));
|
|
@@ -17233,8 +17233,8 @@ var require_math = __commonJS({
|
|
|
17233
17233
|
return Math.PI;
|
|
17234
17234
|
},
|
|
17235
17235
|
POWER: (number4, power) => {
|
|
17236
|
-
number4 = H.accept(number4,
|
|
17237
|
-
power = H.accept(power,
|
|
17236
|
+
number4 = H.accept(number4, Types3.NUMBER);
|
|
17237
|
+
power = H.accept(power, Types3.NUMBER);
|
|
17238
17238
|
return number4 ** power;
|
|
17239
17239
|
},
|
|
17240
17240
|
PRODUCT: (...numbers2) => {
|
|
@@ -17251,25 +17251,25 @@ var require_math = __commonJS({
|
|
|
17251
17251
|
return product;
|
|
17252
17252
|
},
|
|
17253
17253
|
QUOTIENT: (numerator, denominator) => {
|
|
17254
|
-
numerator = H.accept(numerator,
|
|
17255
|
-
denominator = H.accept(denominator,
|
|
17254
|
+
numerator = H.accept(numerator, Types3.NUMBER);
|
|
17255
|
+
denominator = H.accept(denominator, Types3.NUMBER);
|
|
17256
17256
|
return Math.trunc(numerator / denominator);
|
|
17257
17257
|
},
|
|
17258
17258
|
RADIANS: (degrees) => {
|
|
17259
|
-
degrees = H.accept(degrees,
|
|
17259
|
+
degrees = H.accept(degrees, Types3.NUMBER);
|
|
17260
17260
|
return degrees / 180 * Math.PI;
|
|
17261
17261
|
},
|
|
17262
17262
|
RAND: () => {
|
|
17263
17263
|
return Math.random();
|
|
17264
17264
|
},
|
|
17265
17265
|
RANDBETWEEN: (bottom, top) => {
|
|
17266
|
-
bottom = H.accept(bottom,
|
|
17267
|
-
top = H.accept(top,
|
|
17266
|
+
bottom = H.accept(bottom, Types3.NUMBER);
|
|
17267
|
+
top = H.accept(top, Types3.NUMBER);
|
|
17268
17268
|
return Math.floor(Math.random() * (top - bottom + 1) + bottom);
|
|
17269
17269
|
},
|
|
17270
17270
|
ROMAN: (number4, form) => {
|
|
17271
|
-
number4 = H.accept(number4,
|
|
17272
|
-
form = H.accept(form,
|
|
17271
|
+
number4 = H.accept(number4, Types3.NUMBER);
|
|
17272
|
+
form = H.accept(form, Types3.NUMBER, 0);
|
|
17273
17273
|
if (form !== 0)
|
|
17274
17274
|
throw Error("ROMAN: only allows form=0 (classic form).");
|
|
17275
17275
|
const digits = String(number4).split("");
|
|
@@ -17281,8 +17281,8 @@ var require_math = __commonJS({
|
|
|
17281
17281
|
return new Array(+digits.join("") + 1).join("M") + roman;
|
|
17282
17282
|
},
|
|
17283
17283
|
ROUND: (number4, digits) => {
|
|
17284
|
-
number4 = H.accept(number4,
|
|
17285
|
-
digits = H.accept(digits,
|
|
17284
|
+
number4 = H.accept(number4, Types3.NUMBER);
|
|
17285
|
+
digits = H.accept(digits, Types3.NUMBER);
|
|
17286
17286
|
const multiplier = Math.pow(10, Math.abs(digits));
|
|
17287
17287
|
const sign = number4 > 0 ? 1 : -1;
|
|
17288
17288
|
if (digits > 0) {
|
|
@@ -17294,8 +17294,8 @@ var require_math = __commonJS({
|
|
|
17294
17294
|
}
|
|
17295
17295
|
},
|
|
17296
17296
|
ROUNDDOWN: (number4, digits) => {
|
|
17297
|
-
number4 = H.accept(number4,
|
|
17298
|
-
digits = H.accept(digits,
|
|
17297
|
+
number4 = H.accept(number4, Types3.NUMBER);
|
|
17298
|
+
digits = H.accept(digits, Types3.NUMBER);
|
|
17299
17299
|
const multiplier = Math.pow(10, Math.abs(digits));
|
|
17300
17300
|
const sign = number4 > 0 ? 1 : -1;
|
|
17301
17301
|
if (digits > 0) {
|
|
@@ -17310,8 +17310,8 @@ var require_math = __commonJS({
|
|
|
17310
17310
|
}
|
|
17311
17311
|
},
|
|
17312
17312
|
ROUNDUP: (number4, digits) => {
|
|
17313
|
-
number4 = H.accept(number4,
|
|
17314
|
-
digits = H.accept(digits,
|
|
17313
|
+
number4 = H.accept(number4, Types3.NUMBER);
|
|
17314
|
+
digits = H.accept(digits, Types3.NUMBER);
|
|
17315
17315
|
const multiplier = Math.pow(10, Math.abs(digits));
|
|
17316
17316
|
const sign = number4 > 0 ? 1 : -1;
|
|
17317
17317
|
if (digits > 0) {
|
|
@@ -17326,11 +17326,11 @@ var require_math = __commonJS({
|
|
|
17326
17326
|
}
|
|
17327
17327
|
},
|
|
17328
17328
|
SERIESSUM: (x2, n, m, coefficients) => {
|
|
17329
|
-
x2 = H.accept(x2,
|
|
17330
|
-
n = H.accept(n,
|
|
17331
|
-
m = H.accept(m,
|
|
17329
|
+
x2 = H.accept(x2, Types3.NUMBER);
|
|
17330
|
+
n = H.accept(n, Types3.NUMBER);
|
|
17331
|
+
m = H.accept(m, Types3.NUMBER);
|
|
17332
17332
|
let i2 = 0, result;
|
|
17333
|
-
H.flattenParams([coefficients],
|
|
17333
|
+
H.flattenParams([coefficients], Types3.NUMBER, false, (coefficient) => {
|
|
17334
17334
|
if (typeof coefficient !== "number") {
|
|
17335
17335
|
throw FormulaError.VALUE;
|
|
17336
17336
|
}
|
|
@@ -17344,17 +17344,17 @@ var require_math = __commonJS({
|
|
|
17344
17344
|
return result;
|
|
17345
17345
|
},
|
|
17346
17346
|
SIGN: (number4) => {
|
|
17347
|
-
number4 = H.accept(number4,
|
|
17347
|
+
number4 = H.accept(number4, Types3.NUMBER);
|
|
17348
17348
|
return number4 > 0 ? 1 : number4 === 0 ? 0 : -1;
|
|
17349
17349
|
},
|
|
17350
17350
|
SQRT: (number4) => {
|
|
17351
|
-
number4 = H.accept(number4,
|
|
17351
|
+
number4 = H.accept(number4, Types3.NUMBER);
|
|
17352
17352
|
if (number4 < 0)
|
|
17353
17353
|
throw FormulaError.NUM;
|
|
17354
17354
|
return Math.sqrt(number4);
|
|
17355
17355
|
},
|
|
17356
17356
|
SQRTPI: (number4) => {
|
|
17357
|
-
number4 = H.accept(number4,
|
|
17357
|
+
number4 = H.accept(number4, Types3.NUMBER);
|
|
17358
17358
|
if (number4 < 0)
|
|
17359
17359
|
throw FormulaError.NUM;
|
|
17360
17360
|
return Math.sqrt(number4 * Math.PI);
|
|
@@ -17365,7 +17365,7 @@ var require_math = __commonJS({
|
|
|
17365
17365
|
let result = 0;
|
|
17366
17366
|
H.flattenParams(
|
|
17367
17367
|
params,
|
|
17368
|
-
|
|
17368
|
+
Types3.NUMBER,
|
|
17369
17369
|
true,
|
|
17370
17370
|
(item, info) => {
|
|
17371
17371
|
if (info.isLiteral) {
|
|
@@ -17408,9 +17408,9 @@ var require_math = __commonJS({
|
|
|
17408
17408
|
SUMIFS: () => {
|
|
17409
17409
|
},
|
|
17410
17410
|
SUMPRODUCT: (array1, ...arrays) => {
|
|
17411
|
-
array1 = H.accept(array1,
|
|
17411
|
+
array1 = H.accept(array1, Types3.ARRAY, void 0, false, true);
|
|
17412
17412
|
arrays.forEach((array2) => {
|
|
17413
|
-
array2 = H.accept(array2,
|
|
17413
|
+
array2 = H.accept(array2, Types3.ARRAY, void 0, false, true);
|
|
17414
17414
|
if (array1[0].length !== array2[0].length || array1.length !== array2.length)
|
|
17415
17415
|
throw FormulaError.VALUE;
|
|
17416
17416
|
for (let i2 = 0; i2 < array1.length; i2++) {
|
|
@@ -17435,7 +17435,7 @@ var require_math = __commonJS({
|
|
|
17435
17435
|
let result = 0;
|
|
17436
17436
|
H.flattenParams(
|
|
17437
17437
|
params,
|
|
17438
|
-
|
|
17438
|
+
Types3.NUMBER,
|
|
17439
17439
|
true,
|
|
17440
17440
|
(item, info) => {
|
|
17441
17441
|
if (info.isLiteral) {
|
|
@@ -17500,7 +17500,7 @@ var require_math = __commonJS({
|
|
|
17500
17500
|
return sum2;
|
|
17501
17501
|
},
|
|
17502
17502
|
TRUNC: (number4) => {
|
|
17503
|
-
number4 = H.accept(number4,
|
|
17503
|
+
number4 = H.accept(number4, Types3.NUMBER);
|
|
17504
17504
|
return Math.trunc(number4);
|
|
17505
17505
|
}
|
|
17506
17506
|
};
|
|
@@ -17512,71 +17512,71 @@ var require_math = __commonJS({
|
|
|
17512
17512
|
var require_trigonometry = __commonJS({
|
|
17513
17513
|
"../../node_modules/fast-formula-parser/formulas/functions/trigonometry.js"(exports2, module2) {
|
|
17514
17514
|
var FormulaError = require_error();
|
|
17515
|
-
var { FormulaHelpers, Types } = require_helpers();
|
|
17516
|
-
var H =
|
|
17515
|
+
var { FormulaHelpers: FormulaHelpers3, Types: Types3 } = require_helpers();
|
|
17516
|
+
var H = FormulaHelpers3;
|
|
17517
17517
|
var MAX_NUMBER = 2 ** 27 - 1;
|
|
17518
17518
|
var TrigFunctions = {
|
|
17519
17519
|
ACOS: (number4) => {
|
|
17520
|
-
number4 = H.accept(number4,
|
|
17520
|
+
number4 = H.accept(number4, Types3.NUMBER);
|
|
17521
17521
|
if (number4 > 1 || number4 < -1)
|
|
17522
17522
|
throw FormulaError.NUM;
|
|
17523
17523
|
return Math.acos(number4);
|
|
17524
17524
|
},
|
|
17525
17525
|
ACOSH: (number4) => {
|
|
17526
|
-
number4 = H.accept(number4,
|
|
17526
|
+
number4 = H.accept(number4, Types3.NUMBER);
|
|
17527
17527
|
if (number4 < 1)
|
|
17528
17528
|
throw FormulaError.NUM;
|
|
17529
17529
|
return Math.acosh(number4);
|
|
17530
17530
|
},
|
|
17531
17531
|
ACOT: (number4) => {
|
|
17532
|
-
number4 = H.accept(number4,
|
|
17532
|
+
number4 = H.accept(number4, Types3.NUMBER);
|
|
17533
17533
|
return Math.PI / 2 - Math.atan(number4);
|
|
17534
17534
|
},
|
|
17535
17535
|
ACOTH: (number4) => {
|
|
17536
|
-
number4 = H.accept(number4,
|
|
17536
|
+
number4 = H.accept(number4, Types3.NUMBER);
|
|
17537
17537
|
if (Math.abs(number4) <= 1)
|
|
17538
17538
|
throw FormulaError.NUM;
|
|
17539
17539
|
return Math.atanh(1 / number4);
|
|
17540
17540
|
},
|
|
17541
17541
|
ASIN: (number4) => {
|
|
17542
|
-
number4 = H.accept(number4,
|
|
17542
|
+
number4 = H.accept(number4, Types3.NUMBER);
|
|
17543
17543
|
if (number4 > 1 || number4 < -1)
|
|
17544
17544
|
throw FormulaError.NUM;
|
|
17545
17545
|
return Math.asin(number4);
|
|
17546
17546
|
},
|
|
17547
17547
|
ASINH: (number4) => {
|
|
17548
|
-
number4 = H.accept(number4,
|
|
17548
|
+
number4 = H.accept(number4, Types3.NUMBER);
|
|
17549
17549
|
return Math.asinh(number4);
|
|
17550
17550
|
},
|
|
17551
17551
|
ATAN: (number4) => {
|
|
17552
|
-
number4 = H.accept(number4,
|
|
17552
|
+
number4 = H.accept(number4, Types3.NUMBER);
|
|
17553
17553
|
return Math.atan(number4);
|
|
17554
17554
|
},
|
|
17555
17555
|
ATAN2: (x2, y) => {
|
|
17556
|
-
x2 = H.accept(x2,
|
|
17557
|
-
y = H.accept(y,
|
|
17556
|
+
x2 = H.accept(x2, Types3.NUMBER);
|
|
17557
|
+
y = H.accept(y, Types3.NUMBER);
|
|
17558
17558
|
if (y === 0 && x2 === 0)
|
|
17559
17559
|
throw FormulaError.DIV0;
|
|
17560
17560
|
return Math.atan2(y, x2);
|
|
17561
17561
|
},
|
|
17562
17562
|
ATANH: (number4) => {
|
|
17563
|
-
number4 = H.accept(number4,
|
|
17563
|
+
number4 = H.accept(number4, Types3.NUMBER);
|
|
17564
17564
|
if (Math.abs(number4) > 1)
|
|
17565
17565
|
throw FormulaError.NUM;
|
|
17566
17566
|
return Math.atanh(number4);
|
|
17567
17567
|
},
|
|
17568
17568
|
COS: (number4) => {
|
|
17569
|
-
number4 = H.accept(number4,
|
|
17569
|
+
number4 = H.accept(number4, Types3.NUMBER);
|
|
17570
17570
|
if (Math.abs(number4) > MAX_NUMBER)
|
|
17571
17571
|
throw FormulaError.NUM;
|
|
17572
17572
|
return Math.cos(number4);
|
|
17573
17573
|
},
|
|
17574
17574
|
COSH: (number4) => {
|
|
17575
|
-
number4 = H.accept(number4,
|
|
17575
|
+
number4 = H.accept(number4, Types3.NUMBER);
|
|
17576
17576
|
return Math.cosh(number4);
|
|
17577
17577
|
},
|
|
17578
17578
|
COT: (number4) => {
|
|
17579
|
-
number4 = H.accept(number4,
|
|
17579
|
+
number4 = H.accept(number4, Types3.NUMBER);
|
|
17580
17580
|
if (Math.abs(number4) > MAX_NUMBER)
|
|
17581
17581
|
throw FormulaError.NUM;
|
|
17582
17582
|
if (number4 === 0)
|
|
@@ -17584,51 +17584,51 @@ var require_trigonometry = __commonJS({
|
|
|
17584
17584
|
return 1 / Math.tan(number4);
|
|
17585
17585
|
},
|
|
17586
17586
|
COTH: (number4) => {
|
|
17587
|
-
number4 = H.accept(number4,
|
|
17587
|
+
number4 = H.accept(number4, Types3.NUMBER);
|
|
17588
17588
|
if (number4 === 0)
|
|
17589
17589
|
throw FormulaError.DIV0;
|
|
17590
17590
|
return 1 / Math.tanh(number4);
|
|
17591
17591
|
},
|
|
17592
17592
|
CSC: (number4) => {
|
|
17593
|
-
number4 = H.accept(number4,
|
|
17593
|
+
number4 = H.accept(number4, Types3.NUMBER);
|
|
17594
17594
|
if (Math.abs(number4) > MAX_NUMBER)
|
|
17595
17595
|
throw FormulaError.NUM;
|
|
17596
17596
|
return 1 / Math.sin(number4);
|
|
17597
17597
|
},
|
|
17598
17598
|
CSCH: (number4) => {
|
|
17599
|
-
number4 = H.accept(number4,
|
|
17599
|
+
number4 = H.accept(number4, Types3.NUMBER);
|
|
17600
17600
|
if (number4 === 0)
|
|
17601
17601
|
throw FormulaError.DIV0;
|
|
17602
17602
|
return 1 / Math.sinh(number4);
|
|
17603
17603
|
},
|
|
17604
17604
|
SEC: (number4) => {
|
|
17605
|
-
number4 = H.accept(number4,
|
|
17605
|
+
number4 = H.accept(number4, Types3.NUMBER);
|
|
17606
17606
|
if (Math.abs(number4) > MAX_NUMBER)
|
|
17607
17607
|
throw FormulaError.NUM;
|
|
17608
17608
|
return 1 / Math.cos(number4);
|
|
17609
17609
|
},
|
|
17610
17610
|
SECH: (number4) => {
|
|
17611
|
-
number4 = H.accept(number4,
|
|
17611
|
+
number4 = H.accept(number4, Types3.NUMBER);
|
|
17612
17612
|
return 1 / Math.cosh(number4);
|
|
17613
17613
|
},
|
|
17614
17614
|
SIN: (number4) => {
|
|
17615
|
-
number4 = H.accept(number4,
|
|
17615
|
+
number4 = H.accept(number4, Types3.NUMBER);
|
|
17616
17616
|
if (Math.abs(number4) > MAX_NUMBER)
|
|
17617
17617
|
throw FormulaError.NUM;
|
|
17618
17618
|
return Math.sin(number4);
|
|
17619
17619
|
},
|
|
17620
17620
|
SINH: (number4) => {
|
|
17621
|
-
number4 = H.accept(number4,
|
|
17621
|
+
number4 = H.accept(number4, Types3.NUMBER);
|
|
17622
17622
|
return Math.sinh(number4);
|
|
17623
17623
|
},
|
|
17624
17624
|
TAN: (number4) => {
|
|
17625
|
-
number4 = H.accept(number4,
|
|
17625
|
+
number4 = H.accept(number4, Types3.NUMBER);
|
|
17626
17626
|
if (Math.abs(number4) > MAX_NUMBER)
|
|
17627
17627
|
throw FormulaError.NUM;
|
|
17628
17628
|
return Math.tan(number4);
|
|
17629
17629
|
},
|
|
17630
17630
|
TANH: (number4) => {
|
|
17631
|
-
number4 = H.accept(number4,
|
|
17631
|
+
number4 = H.accept(number4, Types3.NUMBER);
|
|
17632
17632
|
return Math.tanh(number4);
|
|
17633
17633
|
}
|
|
17634
17634
|
};
|
|
@@ -17640,8 +17640,8 @@ var require_trigonometry = __commonJS({
|
|
|
17640
17640
|
var require_logical = __commonJS({
|
|
17641
17641
|
"../../node_modules/fast-formula-parser/formulas/functions/logical.js"(exports2, module2) {
|
|
17642
17642
|
var FormulaError = require_error();
|
|
17643
|
-
var { FormulaHelpers, Types } = require_helpers();
|
|
17644
|
-
var H =
|
|
17643
|
+
var { FormulaHelpers: FormulaHelpers3, Types: Types3 } = require_helpers();
|
|
17644
|
+
var H = FormulaHelpers3;
|
|
17645
17645
|
function getNumLogicalValue(params) {
|
|
17646
17646
|
let numTrue = 0, numFalse = 0;
|
|
17647
17647
|
H.flattenParams(params, null, true, (val) => {
|
|
@@ -17674,7 +17674,7 @@ var require_logical = __commonJS({
|
|
|
17674
17674
|
},
|
|
17675
17675
|
// Special
|
|
17676
17676
|
IF: (context, logicalTest, valueIfTrue, valueIfFalse) => {
|
|
17677
|
-
logicalTest = H.accept(logicalTest,
|
|
17677
|
+
logicalTest = H.accept(logicalTest, Types3.BOOLEAN);
|
|
17678
17678
|
valueIfTrue = H.accept(valueIfTrue);
|
|
17679
17679
|
valueIfFalse = H.accept(valueIfFalse, null, false);
|
|
17680
17680
|
return logicalTest ? valueIfTrue : valueIfFalse;
|
|
@@ -17691,7 +17691,7 @@ var require_logical = __commonJS({
|
|
|
17691
17691
|
if (params.length % 2 !== 0)
|
|
17692
17692
|
return new FormulaError("#N/A", "IFS expects all arguments after position 0 to be in pairs.");
|
|
17693
17693
|
for (let i2 = 0; i2 < params.length / 2; i2++) {
|
|
17694
|
-
const logicalTest = H.accept(params[i2 * 2],
|
|
17694
|
+
const logicalTest = H.accept(params[i2 * 2], Types3.BOOLEAN);
|
|
17695
17695
|
const valueIfTrue = H.accept(params[i2 * 2 + 1]);
|
|
17696
17696
|
if (logicalTest)
|
|
17697
17697
|
return valueIfTrue;
|
|
@@ -17699,7 +17699,7 @@ var require_logical = __commonJS({
|
|
|
17699
17699
|
return FormulaError.NA;
|
|
17700
17700
|
},
|
|
17701
17701
|
NOT: (logical) => {
|
|
17702
|
-
logical = H.accept(logical,
|
|
17702
|
+
logical = H.accept(logical, Types3.BOOLEAN);
|
|
17703
17703
|
return !logical;
|
|
17704
17704
|
},
|
|
17705
17705
|
OR: (...params) => {
|
|
@@ -21809,8 +21809,8 @@ var require_engineering = __commonJS({
|
|
|
21809
21809
|
"../../node_modules/fast-formula-parser/formulas/functions/engineering.js"(exports2, module2) {
|
|
21810
21810
|
var FormulaError = require_error();
|
|
21811
21811
|
var TextFunctions = require_text();
|
|
21812
|
-
var { FormulaHelpers, Types } = require_helpers();
|
|
21813
|
-
var H =
|
|
21812
|
+
var { FormulaHelpers: FormulaHelpers3, Types: Types3 } = require_helpers();
|
|
21813
|
+
var H = FormulaHelpers3;
|
|
21814
21814
|
var bessel2 = require_bessel();
|
|
21815
21815
|
var jStat2 = require_jstat();
|
|
21816
21816
|
var MAX_OCT = 536870911;
|
|
@@ -21849,8 +21849,8 @@ var require_engineering = __commonJS({
|
|
|
21849
21849
|
}
|
|
21850
21850
|
var EngineeringFunctions = {
|
|
21851
21851
|
BESSELI: (x2, n) => {
|
|
21852
|
-
x2 = H.accept(x2,
|
|
21853
|
-
n = H.accept(n,
|
|
21852
|
+
x2 = H.accept(x2, Types3.NUMBER_NO_BOOLEAN);
|
|
21853
|
+
n = H.accept(n, Types3.NUMBER_NO_BOOLEAN);
|
|
21854
21854
|
n = Math.trunc(n);
|
|
21855
21855
|
if (n < 0) {
|
|
21856
21856
|
throw FormulaError.NUM;
|
|
@@ -21858,8 +21858,8 @@ var require_engineering = __commonJS({
|
|
|
21858
21858
|
return bessel2.besseli(x2, n);
|
|
21859
21859
|
},
|
|
21860
21860
|
BESSELJ: (x2, n) => {
|
|
21861
|
-
x2 = H.accept(x2,
|
|
21862
|
-
n = H.accept(n,
|
|
21861
|
+
x2 = H.accept(x2, Types3.NUMBER_NO_BOOLEAN);
|
|
21862
|
+
n = H.accept(n, Types3.NUMBER_NO_BOOLEAN);
|
|
21863
21863
|
n = Math.trunc(n);
|
|
21864
21864
|
if (n < 0) {
|
|
21865
21865
|
throw FormulaError.NUM;
|
|
@@ -21867,8 +21867,8 @@ var require_engineering = __commonJS({
|
|
|
21867
21867
|
return bessel2.besselj(x2, n);
|
|
21868
21868
|
},
|
|
21869
21869
|
BESSELK: (x2, n) => {
|
|
21870
|
-
x2 = H.accept(x2,
|
|
21871
|
-
n = H.accept(n,
|
|
21870
|
+
x2 = H.accept(x2, Types3.NUMBER_NO_BOOLEAN);
|
|
21871
|
+
n = H.accept(n, Types3.NUMBER_NO_BOOLEAN);
|
|
21872
21872
|
n = Math.trunc(n);
|
|
21873
21873
|
if (n < 0) {
|
|
21874
21874
|
throw FormulaError.NUM;
|
|
@@ -21876,8 +21876,8 @@ var require_engineering = __commonJS({
|
|
|
21876
21876
|
return bessel2.besselk(x2, n);
|
|
21877
21877
|
},
|
|
21878
21878
|
BESSELY: (x2, n) => {
|
|
21879
|
-
x2 = H.accept(x2,
|
|
21880
|
-
n = H.accept(n,
|
|
21879
|
+
x2 = H.accept(x2, Types3.NUMBER_NO_BOOLEAN);
|
|
21880
|
+
n = H.accept(n, Types3.NUMBER_NO_BOOLEAN);
|
|
21881
21881
|
n = Math.trunc(n);
|
|
21882
21882
|
if (n < 0) {
|
|
21883
21883
|
throw FormulaError.NUM;
|
|
@@ -21885,7 +21885,7 @@ var require_engineering = __commonJS({
|
|
|
21885
21885
|
return bessel2.bessely(x2, n);
|
|
21886
21886
|
},
|
|
21887
21887
|
BIN2DEC: (number4) => {
|
|
21888
|
-
number4 = H.accept(number4,
|
|
21888
|
+
number4 = H.accept(number4, Types3.NUMBER_NO_BOOLEAN);
|
|
21889
21889
|
let numberStr = number4.toString();
|
|
21890
21890
|
if (numberStr.length > 10) {
|
|
21891
21891
|
throw FormulaError.NUM;
|
|
@@ -21897,8 +21897,8 @@ var require_engineering = __commonJS({
|
|
|
21897
21897
|
}
|
|
21898
21898
|
},
|
|
21899
21899
|
BIN2HEX: (number4, places) => {
|
|
21900
|
-
number4 = H.accept(number4,
|
|
21901
|
-
places = H.accept(places,
|
|
21900
|
+
number4 = H.accept(number4, Types3.NUMBER_NO_BOOLEAN);
|
|
21901
|
+
places = H.accept(places, Types3.NUMBER_NO_BOOLEAN, null);
|
|
21902
21902
|
const numberStr = number4.toString();
|
|
21903
21903
|
if (numberStr.length > 10) {
|
|
21904
21904
|
throw FormulaError.NUM;
|
|
@@ -21922,8 +21922,8 @@ var require_engineering = __commonJS({
|
|
|
21922
21922
|
}
|
|
21923
21923
|
},
|
|
21924
21924
|
BIN2OCT: (number4, places) => {
|
|
21925
|
-
number4 = H.accept(number4,
|
|
21926
|
-
places = H.accept(places,
|
|
21925
|
+
number4 = H.accept(number4, Types3.NUMBER_NO_BOOLEAN);
|
|
21926
|
+
places = H.accept(places, Types3.NUMBER, null);
|
|
21927
21927
|
let numberStr = number4.toString();
|
|
21928
21928
|
if (numberStr.length > 10) {
|
|
21929
21929
|
throw FormulaError.NUM;
|
|
@@ -21947,8 +21947,8 @@ var require_engineering = __commonJS({
|
|
|
21947
21947
|
}
|
|
21948
21948
|
},
|
|
21949
21949
|
BITAND: (number1, number22) => {
|
|
21950
|
-
number1 = H.accept(number1,
|
|
21951
|
-
number22 = H.accept(number22,
|
|
21950
|
+
number1 = H.accept(number1, Types3.NUMBER);
|
|
21951
|
+
number22 = H.accept(number22, Types3.NUMBER);
|
|
21952
21952
|
if (number1 < 0 || number22 < 0) {
|
|
21953
21953
|
throw FormulaError.NUM;
|
|
21954
21954
|
}
|
|
@@ -21961,8 +21961,8 @@ var require_engineering = __commonJS({
|
|
|
21961
21961
|
return number1 & number22;
|
|
21962
21962
|
},
|
|
21963
21963
|
BITLSHIFT: (number4, shiftAmount) => {
|
|
21964
|
-
number4 = H.accept(number4,
|
|
21965
|
-
shiftAmount = H.accept(shiftAmount,
|
|
21964
|
+
number4 = H.accept(number4, Types3.NUMBER);
|
|
21965
|
+
shiftAmount = H.accept(shiftAmount, Types3.NUMBER);
|
|
21966
21966
|
shiftAmount = Math.trunc(shiftAmount);
|
|
21967
21967
|
if (Math.abs(shiftAmount) > 53) {
|
|
21968
21968
|
throw FormulaError.NUM;
|
|
@@ -21977,8 +21977,8 @@ var require_engineering = __commonJS({
|
|
|
21977
21977
|
return result;
|
|
21978
21978
|
},
|
|
21979
21979
|
BITOR: (number1, number22) => {
|
|
21980
|
-
number1 = H.accept(number1,
|
|
21981
|
-
number22 = H.accept(number22,
|
|
21980
|
+
number1 = H.accept(number1, Types3.NUMBER);
|
|
21981
|
+
number22 = H.accept(number22, Types3.NUMBER);
|
|
21982
21982
|
if (number1 < 0 || number22 < 0) {
|
|
21983
21983
|
throw FormulaError.NUM;
|
|
21984
21984
|
}
|
|
@@ -21991,13 +21991,13 @@ var require_engineering = __commonJS({
|
|
|
21991
21991
|
return number1 | number22;
|
|
21992
21992
|
},
|
|
21993
21993
|
BITRSHIFT: (number4, shiftAmount) => {
|
|
21994
|
-
number4 = H.accept(number4,
|
|
21995
|
-
shiftAmount = H.accept(shiftAmount,
|
|
21994
|
+
number4 = H.accept(number4, Types3.NUMBER);
|
|
21995
|
+
shiftAmount = H.accept(shiftAmount, Types3.NUMBER);
|
|
21996
21996
|
return EngineeringFunctions.BITLSHIFT(number4, -shiftAmount);
|
|
21997
21997
|
},
|
|
21998
21998
|
BITXOR: (number1, number22) => {
|
|
21999
|
-
number1 = H.accept(number1,
|
|
22000
|
-
number22 = H.accept(number22,
|
|
21999
|
+
number1 = H.accept(number1, Types3.NUMBER);
|
|
22000
|
+
number22 = H.accept(number22, Types3.NUMBER);
|
|
22001
22001
|
if (number1 < 0 || number1 > 281474976710655 || Math.floor(number1) !== number1) {
|
|
22002
22002
|
throw FormulaError.NUM;
|
|
22003
22003
|
}
|
|
@@ -22007,9 +22007,9 @@ var require_engineering = __commonJS({
|
|
|
22007
22007
|
return number1 ^ number22;
|
|
22008
22008
|
},
|
|
22009
22009
|
COMPLEX: (realNum, iNum, suffix) => {
|
|
22010
|
-
realNum = H.accept(realNum,
|
|
22011
|
-
iNum = H.accept(iNum,
|
|
22012
|
-
suffix = H.accept(suffix,
|
|
22010
|
+
realNum = H.accept(realNum, Types3.NUMBER_NO_BOOLEAN);
|
|
22011
|
+
iNum = H.accept(iNum, Types3.NUMBER_NO_BOOLEAN);
|
|
22012
|
+
suffix = H.accept(suffix, Types3.STRING, "i");
|
|
22013
22013
|
if (suffix !== "i" && suffix !== "j") {
|
|
22014
22014
|
throw FormulaError.VALUE;
|
|
22015
22015
|
}
|
|
@@ -22037,8 +22037,8 @@ var require_engineering = __commonJS({
|
|
|
22037
22037
|
}
|
|
22038
22038
|
},
|
|
22039
22039
|
DEC2BIN: (number4, places) => {
|
|
22040
|
-
number4 = H.accept(number4,
|
|
22041
|
-
places = H.accept(places,
|
|
22040
|
+
number4 = H.accept(number4, Types3.NUMBER);
|
|
22041
|
+
places = H.accept(places, Types3.NUMBER, null);
|
|
22042
22042
|
if (number4 < MIN_BIN || number4 > MAX_BIN) {
|
|
22043
22043
|
throw FormulaError.NUM;
|
|
22044
22044
|
}
|
|
@@ -22059,8 +22059,8 @@ var require_engineering = __commonJS({
|
|
|
22059
22059
|
}
|
|
22060
22060
|
},
|
|
22061
22061
|
DEC2HEX: (number4, places) => {
|
|
22062
|
-
number4 = H.accept(number4,
|
|
22063
|
-
places = H.accept(places,
|
|
22062
|
+
number4 = H.accept(number4, Types3.NUMBER);
|
|
22063
|
+
places = H.accept(places, Types3.NUMBER, null);
|
|
22064
22064
|
if (number4 < -549755813888 || number4 > 549755813888) {
|
|
22065
22065
|
throw FormulaError.NUM;
|
|
22066
22066
|
}
|
|
@@ -22081,8 +22081,8 @@ var require_engineering = __commonJS({
|
|
|
22081
22081
|
}
|
|
22082
22082
|
},
|
|
22083
22083
|
DEC2OCT: (number4, places) => {
|
|
22084
|
-
number4 = H.accept(number4,
|
|
22085
|
-
places = H.accept(places,
|
|
22084
|
+
number4 = H.accept(number4, Types3.NUMBER);
|
|
22085
|
+
places = H.accept(places, Types3.NUMBER, null);
|
|
22086
22086
|
if (number4 < -536870912 || number4 > 536870912) {
|
|
22087
22087
|
throw FormulaError.NUM;
|
|
22088
22088
|
}
|
|
@@ -22103,27 +22103,27 @@ var require_engineering = __commonJS({
|
|
|
22103
22103
|
}
|
|
22104
22104
|
},
|
|
22105
22105
|
DELTA: (number1, number22) => {
|
|
22106
|
-
number1 = H.accept(number1,
|
|
22107
|
-
number22 = H.accept(number22,
|
|
22106
|
+
number1 = H.accept(number1, Types3.NUMBER_NO_BOOLEAN);
|
|
22107
|
+
number22 = H.accept(number22, Types3.NUMBER_NO_BOOLEAN, 0);
|
|
22108
22108
|
return number1 === number22 ? 1 : 0;
|
|
22109
22109
|
},
|
|
22110
22110
|
ERF: (lowerLimit, upperLimit) => {
|
|
22111
|
-
lowerLimit = H.accept(lowerLimit,
|
|
22112
|
-
upperLimit = H.accept(upperLimit,
|
|
22111
|
+
lowerLimit = H.accept(lowerLimit, Types3.NUMBER_NO_BOOLEAN);
|
|
22112
|
+
upperLimit = H.accept(upperLimit, Types3.NUMBER_NO_BOOLEAN, 0);
|
|
22113
22113
|
return jStat2.erf(lowerLimit);
|
|
22114
22114
|
},
|
|
22115
22115
|
ERFC: (x2) => {
|
|
22116
|
-
x2 = H.accept(x2,
|
|
22116
|
+
x2 = H.accept(x2, Types3.NUMBER_NO_BOOLEAN);
|
|
22117
22117
|
return jStat2.erfc(x2);
|
|
22118
22118
|
},
|
|
22119
22119
|
GESTEP: (number4, step) => {
|
|
22120
|
-
number4 = H.accept(number4,
|
|
22121
|
-
step = H.accept(step,
|
|
22120
|
+
number4 = H.accept(number4, Types3.NUMBER_NO_BOOLEAN);
|
|
22121
|
+
step = H.accept(step, Types3.NUMBER_NO_BOOLEAN, 0);
|
|
22122
22122
|
return number4 >= step ? 1 : 0;
|
|
22123
22123
|
},
|
|
22124
22124
|
HEX2BIN: (number4, places) => {
|
|
22125
|
-
number4 = H.accept(number4,
|
|
22126
|
-
places = H.accept(places,
|
|
22125
|
+
number4 = H.accept(number4, Types3.STRING);
|
|
22126
|
+
places = H.accept(places, Types3.NUMBER, null);
|
|
22127
22127
|
if (number4.length > 10 || !/^[0-9a-fA-F]*$/.test(number4)) {
|
|
22128
22128
|
throw FormulaError.NUM;
|
|
22129
22129
|
}
|
|
@@ -22147,7 +22147,7 @@ var require_engineering = __commonJS({
|
|
|
22147
22147
|
}
|
|
22148
22148
|
},
|
|
22149
22149
|
HEX2DEC: (number4) => {
|
|
22150
|
-
number4 = H.accept(number4,
|
|
22150
|
+
number4 = H.accept(number4, Types3.STRING);
|
|
22151
22151
|
if (number4.length > 10 || !/^[0-9a-fA-F]*$/.test(number4)) {
|
|
22152
22152
|
throw FormulaError.NUM;
|
|
22153
22153
|
}
|
|
@@ -22155,7 +22155,7 @@ var require_engineering = __commonJS({
|
|
|
22155
22155
|
return result >= 549755813888 ? result - 1099511627776 : result;
|
|
22156
22156
|
},
|
|
22157
22157
|
HEX2OCT: (number4, places) => {
|
|
22158
|
-
number4 = H.accept(number4,
|
|
22158
|
+
number4 = H.accept(number4, Types3.STRING);
|
|
22159
22159
|
if (number4.length > 10 || !/^[0-9a-fA-F]*$/.test(number4)) {
|
|
22160
22160
|
throw FormulaError.NUM;
|
|
22161
22161
|
}
|
|
@@ -22266,7 +22266,7 @@ var require_engineering = __commonJS({
|
|
|
22266
22266
|
},
|
|
22267
22267
|
IMPOWER: (iNumber, number4) => {
|
|
22268
22268
|
let { unit } = parseIM(iNumber);
|
|
22269
|
-
number4 = H.accept(number4,
|
|
22269
|
+
number4 = H.accept(number4, Types3.NUMBER_NO_BOOLEAN);
|
|
22270
22270
|
let p = Math.pow(EngineeringFunctions.IMABS(iNumber), number4);
|
|
22271
22271
|
let t = EngineeringFunctions.IMARGUMENT(iNumber);
|
|
22272
22272
|
let real = p * Math.cos(number4 * t);
|
|
@@ -22348,8 +22348,8 @@ var require_engineering = __commonJS({
|
|
|
22348
22348
|
},
|
|
22349
22349
|
// FIXME: need to check the test cases
|
|
22350
22350
|
OCT2BIN: (number4, places) => {
|
|
22351
|
-
number4 = H.accept(number4,
|
|
22352
|
-
places = H.accept(places,
|
|
22351
|
+
number4 = H.accept(number4, Types3.STRING);
|
|
22352
|
+
places = H.accept(places, Types3.NUMBER, null);
|
|
22353
22353
|
if (number4.length > 10) {
|
|
22354
22354
|
throw FormulaError.NUM;
|
|
22355
22355
|
}
|
|
@@ -22378,7 +22378,7 @@ var require_engineering = __commonJS({
|
|
|
22378
22378
|
return TextFunctions.REPT("0", places - result.length) + result;
|
|
22379
22379
|
},
|
|
22380
22380
|
OCT2DEC: (number4) => {
|
|
22381
|
-
number4 = H.accept(number4,
|
|
22381
|
+
number4 = H.accept(number4, Types3.STRING);
|
|
22382
22382
|
if (number4.length > 10) {
|
|
22383
22383
|
throw FormulaError.NUM;
|
|
22384
22384
|
}
|
|
@@ -22391,8 +22391,8 @@ var require_engineering = __commonJS({
|
|
|
22391
22391
|
return result >= 536870912 ? result - 1073741824 : result;
|
|
22392
22392
|
},
|
|
22393
22393
|
OCT2HEX: (number4, places) => {
|
|
22394
|
-
number4 = H.accept(number4,
|
|
22395
|
-
places = H.accept(places,
|
|
22394
|
+
number4 = H.accept(number4, Types3.STRING);
|
|
22395
|
+
places = H.accept(places, Types3.NUMBER_NO_BOOLEAN, null);
|
|
22396
22396
|
if (number4.length > 10) {
|
|
22397
22397
|
throw FormulaError.NUM;
|
|
22398
22398
|
}
|
|
@@ -22425,16 +22425,16 @@ var require_engineering = __commonJS({
|
|
|
22425
22425
|
var require_reference = __commonJS({
|
|
22426
22426
|
"../../node_modules/fast-formula-parser/formulas/functions/reference.js"(exports2, module2) {
|
|
22427
22427
|
var FormulaError = require_error();
|
|
22428
|
-
var { FormulaHelpers, Types, WildCard, Address } = require_helpers();
|
|
22428
|
+
var { FormulaHelpers: FormulaHelpers3, Types: Types3, WildCard, Address } = require_helpers();
|
|
22429
22429
|
var Collection = require_collection();
|
|
22430
|
-
var H =
|
|
22430
|
+
var H = FormulaHelpers3;
|
|
22431
22431
|
var ReferenceFunctions = {
|
|
22432
22432
|
ADDRESS: (rowNumber, columnNumber, absNum, a1, sheetText) => {
|
|
22433
|
-
rowNumber = H.accept(rowNumber,
|
|
22434
|
-
columnNumber = H.accept(columnNumber,
|
|
22435
|
-
absNum = H.accept(absNum,
|
|
22436
|
-
a1 = H.accept(a1,
|
|
22437
|
-
sheetText = H.accept(sheetText,
|
|
22433
|
+
rowNumber = H.accept(rowNumber, Types3.NUMBER);
|
|
22434
|
+
columnNumber = H.accept(columnNumber, Types3.NUMBER);
|
|
22435
|
+
absNum = H.accept(absNum, Types3.NUMBER, 1);
|
|
22436
|
+
a1 = H.accept(a1, Types3.BOOLEAN, true);
|
|
22437
|
+
sheetText = H.accept(sheetText, Types3.STRING, "");
|
|
22438
22438
|
if (rowNumber < 1 || columnNumber < 1 || absNum < 1 || absNum > 4)
|
|
22439
22439
|
throw FormulaError.VALUE;
|
|
22440
22440
|
let result = "";
|
|
@@ -22504,14 +22504,14 @@ var require_reference = __commonJS({
|
|
|
22504
22504
|
HLOOKUP: (lookupValue, tableArray, rowIndexNum, rangeLookup) => {
|
|
22505
22505
|
lookupValue = H.accept(lookupValue);
|
|
22506
22506
|
try {
|
|
22507
|
-
tableArray = H.accept(tableArray,
|
|
22507
|
+
tableArray = H.accept(tableArray, Types3.ARRAY, void 0, false);
|
|
22508
22508
|
} catch (e) {
|
|
22509
22509
|
if (e instanceof FormulaError)
|
|
22510
22510
|
throw FormulaError.NA;
|
|
22511
22511
|
throw e;
|
|
22512
22512
|
}
|
|
22513
|
-
rowIndexNum = H.accept(rowIndexNum,
|
|
22514
|
-
rangeLookup = H.accept(rangeLookup,
|
|
22513
|
+
rowIndexNum = H.accept(rowIndexNum, Types3.NUMBER);
|
|
22514
|
+
rangeLookup = H.accept(rangeLookup, Types3.BOOLEAN, true);
|
|
22515
22515
|
if (rowIndexNum < 1)
|
|
22516
22516
|
throw FormulaError.VALUE;
|
|
22517
22517
|
if (tableArray[rowIndexNum - 1] === void 0)
|
|
@@ -22556,14 +22556,14 @@ var require_reference = __commonJS({
|
|
|
22556
22556
|
INDEX: (context, ranges, rowNum, colNum, areaNum) => {
|
|
22557
22557
|
rowNum = context.utils.extractRefValue(rowNum);
|
|
22558
22558
|
rowNum = { value: rowNum.val, isArray: rowNum.isArray };
|
|
22559
|
-
rowNum = H.accept(rowNum,
|
|
22559
|
+
rowNum = H.accept(rowNum, Types3.NUMBER);
|
|
22560
22560
|
rowNum = Math.trunc(rowNum);
|
|
22561
22561
|
if (colNum == null) {
|
|
22562
22562
|
colNum = 1;
|
|
22563
22563
|
} else {
|
|
22564
22564
|
colNum = context.utils.extractRefValue(colNum);
|
|
22565
22565
|
colNum = { value: colNum.val, isArray: colNum.isArray };
|
|
22566
|
-
colNum = H.accept(colNum,
|
|
22566
|
+
colNum = H.accept(colNum, Types3.NUMBER, 1);
|
|
22567
22567
|
colNum = Math.trunc(colNum);
|
|
22568
22568
|
}
|
|
22569
22569
|
if (areaNum == null) {
|
|
@@ -22571,7 +22571,7 @@ var require_reference = __commonJS({
|
|
|
22571
22571
|
} else {
|
|
22572
22572
|
areaNum = context.utils.extractRefValue(areaNum);
|
|
22573
22573
|
areaNum = { value: areaNum.val, isArray: areaNum.isArray };
|
|
22574
|
-
areaNum = H.accept(areaNum,
|
|
22574
|
+
areaNum = H.accept(areaNum, Types3.NUMBER, 1);
|
|
22575
22575
|
areaNum = Math.trunc(areaNum);
|
|
22576
22576
|
}
|
|
22577
22577
|
let range2 = ranges;
|
|
@@ -22662,7 +22662,7 @@ var require_reference = __commonJS({
|
|
|
22662
22662
|
}
|
|
22663
22663
|
},
|
|
22664
22664
|
TRANSPOSE: (array2) => {
|
|
22665
|
-
array2 = H.accept(array2,
|
|
22665
|
+
array2 = H.accept(array2, Types3.ARRAY, void 0, false);
|
|
22666
22666
|
const result = [];
|
|
22667
22667
|
for (let i2 = 0; i2 < array2[0].length; i2++) {
|
|
22668
22668
|
result[i2] = [];
|
|
@@ -22675,14 +22675,14 @@ var require_reference = __commonJS({
|
|
|
22675
22675
|
VLOOKUP: (lookupValue, tableArray, colIndexNum, rangeLookup) => {
|
|
22676
22676
|
lookupValue = H.accept(lookupValue);
|
|
22677
22677
|
try {
|
|
22678
|
-
tableArray = H.accept(tableArray,
|
|
22678
|
+
tableArray = H.accept(tableArray, Types3.ARRAY, void 0, false);
|
|
22679
22679
|
} catch (e) {
|
|
22680
22680
|
if (e instanceof FormulaError)
|
|
22681
22681
|
throw FormulaError.NA;
|
|
22682
22682
|
throw e;
|
|
22683
22683
|
}
|
|
22684
|
-
colIndexNum = H.accept(colIndexNum,
|
|
22685
|
-
rangeLookup = H.accept(rangeLookup,
|
|
22684
|
+
colIndexNum = H.accept(colIndexNum, Types3.NUMBER);
|
|
22685
|
+
rangeLookup = H.accept(rangeLookup, Types3.BOOLEAN, true);
|
|
22686
22686
|
if (colIndexNum < 1)
|
|
22687
22687
|
throw FormulaError.VALUE;
|
|
22688
22688
|
if (tableArray[0][colIndexNum - 1] === void 0)
|
|
@@ -22733,8 +22733,8 @@ var require_reference = __commonJS({
|
|
|
22733
22733
|
var require_information = __commonJS({
|
|
22734
22734
|
"../../node_modules/fast-formula-parser/formulas/functions/information.js"(exports2, module2) {
|
|
22735
22735
|
var FormulaError = require_error();
|
|
22736
|
-
var { FormulaHelpers, Types } = require_helpers();
|
|
22737
|
-
var H =
|
|
22736
|
+
var { FormulaHelpers: FormulaHelpers3, Types: Types3 } = require_helpers();
|
|
22737
|
+
var H = FormulaHelpers3;
|
|
22738
22738
|
var error2Number = {
|
|
22739
22739
|
"#NULL!": 1,
|
|
22740
22740
|
"#DIV/0!": 2,
|
|
@@ -22769,7 +22769,7 @@ var require_information = __commonJS({
|
|
|
22769
22769
|
return value2 instanceof FormulaError;
|
|
22770
22770
|
},
|
|
22771
22771
|
ISEVEN: (number4) => {
|
|
22772
|
-
number4 = H.accept(number4,
|
|
22772
|
+
number4 = H.accept(number4, Types3.NUMBER);
|
|
22773
22773
|
number4 = Math.trunc(number4);
|
|
22774
22774
|
return number4 % 2 === 0;
|
|
22775
22775
|
},
|
|
@@ -22851,48 +22851,48 @@ var require_information = __commonJS({
|
|
|
22851
22851
|
var require_distribution = __commonJS({
|
|
22852
22852
|
"../../node_modules/fast-formula-parser/formulas/functions/distribution.js"(exports2, module2) {
|
|
22853
22853
|
var FormulaError = require_error();
|
|
22854
|
-
var { FormulaHelpers, Types } = require_helpers();
|
|
22855
|
-
var H =
|
|
22854
|
+
var { FormulaHelpers: FormulaHelpers3, Types: Types3 } = require_helpers();
|
|
22855
|
+
var H = FormulaHelpers3;
|
|
22856
22856
|
var jStat2 = require_jstat();
|
|
22857
22857
|
var MathFunctions = require_math();
|
|
22858
22858
|
var SQRT2PI2 = 2.5066282746310002;
|
|
22859
22859
|
var DistributionFunctions = {
|
|
22860
22860
|
"BETA.DIST": (x2, alpha, beta, cumulative, a, b) => {
|
|
22861
|
-
x2 = H.accept(x2,
|
|
22862
|
-
alpha = H.accept(alpha,
|
|
22863
|
-
beta = H.accept(beta,
|
|
22864
|
-
cumulative = H.accept(cumulative,
|
|
22865
|
-
a = H.accept(a,
|
|
22866
|
-
b = H.accept(b,
|
|
22861
|
+
x2 = H.accept(x2, Types3.NUMBER);
|
|
22862
|
+
alpha = H.accept(alpha, Types3.NUMBER);
|
|
22863
|
+
beta = H.accept(beta, Types3.NUMBER);
|
|
22864
|
+
cumulative = H.accept(cumulative, Types3.BOOLEAN);
|
|
22865
|
+
a = H.accept(a, Types3.NUMBER, 0);
|
|
22866
|
+
b = H.accept(b, Types3.NUMBER, 1);
|
|
22867
22867
|
if (alpha <= 0 || beta <= 0 || x2 < a || x2 > b || a === b)
|
|
22868
22868
|
throw FormulaError.NUM;
|
|
22869
22869
|
x2 = (x2 - a) / (b - a);
|
|
22870
22870
|
return cumulative ? jStat2.beta.cdf(x2, alpha, beta) : jStat2.beta.pdf(x2, alpha, beta) / (b - a);
|
|
22871
22871
|
},
|
|
22872
22872
|
"BETA.INV": (probability, alpha, beta, a, b) => {
|
|
22873
|
-
probability = H.accept(probability,
|
|
22874
|
-
alpha = H.accept(alpha,
|
|
22875
|
-
beta = H.accept(beta,
|
|
22876
|
-
a = H.accept(a,
|
|
22877
|
-
b = H.accept(b,
|
|
22873
|
+
probability = H.accept(probability, Types3.NUMBER);
|
|
22874
|
+
alpha = H.accept(alpha, Types3.NUMBER);
|
|
22875
|
+
beta = H.accept(beta, Types3.NUMBER);
|
|
22876
|
+
a = H.accept(a, Types3.NUMBER, 0);
|
|
22877
|
+
b = H.accept(b, Types3.NUMBER, 1);
|
|
22878
22878
|
if (alpha <= 0 || beta <= 0 || probability <= 0 || probability > 1)
|
|
22879
22879
|
throw FormulaError.NUM;
|
|
22880
22880
|
return jStat2.beta.inv(probability, alpha, beta) * (b - a) + a;
|
|
22881
22881
|
},
|
|
22882
22882
|
"BINOM.DIST": (numberS, trials, probabilityS, cumulative) => {
|
|
22883
|
-
numberS = H.accept(numberS,
|
|
22884
|
-
trials = H.accept(trials,
|
|
22885
|
-
probabilityS = H.accept(probabilityS,
|
|
22886
|
-
cumulative = H.accept(cumulative,
|
|
22883
|
+
numberS = H.accept(numberS, Types3.NUMBER);
|
|
22884
|
+
trials = H.accept(trials, Types3.NUMBER);
|
|
22885
|
+
probabilityS = H.accept(probabilityS, Types3.NUMBER);
|
|
22886
|
+
cumulative = H.accept(cumulative, Types3.BOOLEAN);
|
|
22887
22887
|
if (trials < 0 || probabilityS < 0 || probabilityS > 1 || numberS < 0 || numberS > trials)
|
|
22888
22888
|
throw FormulaError.NUM;
|
|
22889
22889
|
return cumulative ? jStat2.binomial.cdf(numberS, trials, probabilityS) : jStat2.binomial.pdf(numberS, trials, probabilityS);
|
|
22890
22890
|
},
|
|
22891
22891
|
"BINOM.DIST.RANGE": (trials, probabilityS, numberS, numberS2) => {
|
|
22892
|
-
trials = H.accept(trials,
|
|
22893
|
-
probabilityS = H.accept(probabilityS,
|
|
22894
|
-
numberS = H.accept(numberS,
|
|
22895
|
-
numberS2 = H.accept(numberS2,
|
|
22892
|
+
trials = H.accept(trials, Types3.NUMBER);
|
|
22893
|
+
probabilityS = H.accept(probabilityS, Types3.NUMBER);
|
|
22894
|
+
numberS = H.accept(numberS, Types3.NUMBER);
|
|
22895
|
+
numberS2 = H.accept(numberS2, Types3.NUMBER, numberS);
|
|
22896
22896
|
if (trials < 0 || probabilityS < 0 || probabilityS > 1 || numberS < 0 || numberS > trials || numberS2 < numberS || numberS2 > trials)
|
|
22897
22897
|
throw FormulaError.NUM;
|
|
22898
22898
|
let result = 0;
|
|
@@ -22902,9 +22902,9 @@ var require_distribution = __commonJS({
|
|
|
22902
22902
|
return result;
|
|
22903
22903
|
},
|
|
22904
22904
|
"BINOM.INV": (trials, probabilityS, alpha) => {
|
|
22905
|
-
trials = H.accept(trials,
|
|
22906
|
-
probabilityS = H.accept(probabilityS,
|
|
22907
|
-
alpha = H.accept(alpha,
|
|
22905
|
+
trials = H.accept(trials, Types3.NUMBER);
|
|
22906
|
+
probabilityS = H.accept(probabilityS, Types3.NUMBER);
|
|
22907
|
+
alpha = H.accept(alpha, Types3.NUMBER);
|
|
22908
22908
|
if (trials < 0 || probabilityS < 0 || probabilityS > 1 || alpha < 0 || alpha > 1)
|
|
22909
22909
|
throw FormulaError.NUM;
|
|
22910
22910
|
let x2 = 0;
|
|
@@ -22916,41 +22916,41 @@ var require_distribution = __commonJS({
|
|
|
22916
22916
|
}
|
|
22917
22917
|
},
|
|
22918
22918
|
"CHISQ.DIST": (x2, degFreedom, cumulative) => {
|
|
22919
|
-
x2 = H.accept(x2,
|
|
22920
|
-
degFreedom = H.accept(degFreedom,
|
|
22921
|
-
cumulative = H.accept(cumulative,
|
|
22919
|
+
x2 = H.accept(x2, Types3.NUMBER);
|
|
22920
|
+
degFreedom = H.accept(degFreedom, Types3.NUMBER);
|
|
22921
|
+
cumulative = H.accept(cumulative, Types3.NUMBER);
|
|
22922
22922
|
degFreedom = Math.trunc(degFreedom);
|
|
22923
22923
|
if (x2 < 0 || degFreedom < 1 || degFreedom > 10 ** 10)
|
|
22924
22924
|
throw FormulaError.NUM;
|
|
22925
22925
|
return cumulative ? jStat2.chisquare.cdf(x2, degFreedom) : jStat2.chisquare.pdf(x2, degFreedom);
|
|
22926
22926
|
},
|
|
22927
22927
|
"CHISQ.DIST.RT": (x2, degFreedom) => {
|
|
22928
|
-
x2 = H.accept(x2,
|
|
22929
|
-
degFreedom = H.accept(degFreedom,
|
|
22928
|
+
x2 = H.accept(x2, Types3.NUMBER);
|
|
22929
|
+
degFreedom = H.accept(degFreedom, Types3.NUMBER);
|
|
22930
22930
|
degFreedom = Math.trunc(degFreedom);
|
|
22931
22931
|
if (x2 < 0 || degFreedom < 1 || degFreedom > 10 ** 10)
|
|
22932
22932
|
throw FormulaError.NUM;
|
|
22933
22933
|
return 1 - jStat2.chisquare.cdf(x2, degFreedom);
|
|
22934
22934
|
},
|
|
22935
22935
|
"CHISQ.INV": (probability, degFreedom) => {
|
|
22936
|
-
probability = H.accept(probability,
|
|
22937
|
-
degFreedom = H.accept(degFreedom,
|
|
22936
|
+
probability = H.accept(probability, Types3.NUMBER);
|
|
22937
|
+
degFreedom = H.accept(degFreedom, Types3.NUMBER);
|
|
22938
22938
|
degFreedom = Math.trunc(degFreedom);
|
|
22939
22939
|
if (probability < 0 || probability > 1 || degFreedom < 1 || degFreedom > 10 ** 10)
|
|
22940
22940
|
throw FormulaError.NUM;
|
|
22941
22941
|
return jStat2.chisquare.inv(probability, degFreedom);
|
|
22942
22942
|
},
|
|
22943
22943
|
"CHISQ.INV.RT": (probability, degFreedom) => {
|
|
22944
|
-
probability = H.accept(probability,
|
|
22945
|
-
degFreedom = H.accept(degFreedom,
|
|
22944
|
+
probability = H.accept(probability, Types3.NUMBER);
|
|
22945
|
+
degFreedom = H.accept(degFreedom, Types3.NUMBER);
|
|
22946
22946
|
degFreedom = Math.trunc(degFreedom);
|
|
22947
22947
|
if (probability < 0 || probability > 1 || degFreedom < 1 || degFreedom > 10 ** 10)
|
|
22948
22948
|
throw FormulaError.NUM;
|
|
22949
22949
|
return jStat2.chisquare.inv(1 - probability, degFreedom);
|
|
22950
22950
|
},
|
|
22951
22951
|
"CHISQ.TEST": (actualRange, expectedRange) => {
|
|
22952
|
-
const actual = H.accept(actualRange,
|
|
22953
|
-
const expected = H.accept(expectedRange,
|
|
22952
|
+
const actual = H.accept(actualRange, Types3.ARRAY, void 0, false, false);
|
|
22953
|
+
const expected = H.accept(expectedRange, Types3.ARRAY, void 0, false, false);
|
|
22954
22954
|
if (actual.length !== expected.length || actual[0].length !== expected[0].length || actual.length === 1 && actual[0].length === 1)
|
|
22955
22955
|
throw FormulaError.NA;
|
|
22956
22956
|
const row = actual.length;
|
|
@@ -22987,18 +22987,18 @@ var require_distribution = __commonJS({
|
|
|
22987
22987
|
return 1 - p;
|
|
22988
22988
|
},
|
|
22989
22989
|
"CONFIDENCE.NORM": (alpha, std, size2) => {
|
|
22990
|
-
alpha = H.accept(alpha,
|
|
22991
|
-
std = H.accept(std,
|
|
22992
|
-
size2 = H.accept(size2,
|
|
22990
|
+
alpha = H.accept(alpha, Types3.NUMBER);
|
|
22991
|
+
std = H.accept(std, Types3.NUMBER);
|
|
22992
|
+
size2 = H.accept(size2, Types3.NUMBER);
|
|
22993
22993
|
size2 = Math.trunc(size2);
|
|
22994
22994
|
if (alpha <= 0 || alpha >= 1 || std <= 0 || size2 < 1)
|
|
22995
22995
|
throw FormulaError.NUM;
|
|
22996
22996
|
return jStat2.normalci(1, alpha, std, size2)[1] - 1;
|
|
22997
22997
|
},
|
|
22998
22998
|
"CONFIDENCE.T": (alpha, std, size2) => {
|
|
22999
|
-
alpha = H.accept(alpha,
|
|
23000
|
-
std = H.accept(std,
|
|
23001
|
-
size2 = H.accept(size2,
|
|
22999
|
+
alpha = H.accept(alpha, Types3.NUMBER);
|
|
23000
|
+
std = H.accept(std, Types3.NUMBER);
|
|
23001
|
+
size2 = H.accept(size2, Types3.NUMBER);
|
|
23002
23002
|
size2 = Math.trunc(size2);
|
|
23003
23003
|
if (alpha <= 0 || alpha >= 1 || std <= 0 || size2 < 1)
|
|
23004
23004
|
throw FormulaError.NUM;
|
|
@@ -23007,8 +23007,8 @@ var require_distribution = __commonJS({
|
|
|
23007
23007
|
return jStat2.tci(1, alpha, std, size2)[1] - 1;
|
|
23008
23008
|
},
|
|
23009
23009
|
CORREL: (array1, array2) => {
|
|
23010
|
-
array1 = H.accept(array1,
|
|
23011
|
-
array2 = H.accept(array2,
|
|
23010
|
+
array1 = H.accept(array1, Types3.ARRAY, void 0, true, true);
|
|
23011
|
+
array2 = H.accept(array2, Types3.ARRAY, void 0, true, true);
|
|
23012
23012
|
if (array1.length !== array2.length)
|
|
23013
23013
|
throw FormulaError.NA;
|
|
23014
23014
|
const filterArr1 = [], filterArr2 = [];
|
|
@@ -23023,8 +23023,8 @@ var require_distribution = __commonJS({
|
|
|
23023
23023
|
return jStat2.corrcoeff(filterArr1, filterArr2);
|
|
23024
23024
|
},
|
|
23025
23025
|
"COVARIANCE.P": (array1, array2) => {
|
|
23026
|
-
array1 = H.accept(array1,
|
|
23027
|
-
array2 = H.accept(array2,
|
|
23026
|
+
array1 = H.accept(array1, Types3.ARRAY, void 0, true, true);
|
|
23027
|
+
array2 = H.accept(array2, Types3.ARRAY, void 0, true, true);
|
|
23028
23028
|
if (array1.length !== array2.length)
|
|
23029
23029
|
throw FormulaError.NA;
|
|
23030
23030
|
const filterArr1 = [], filterArr2 = [];
|
|
@@ -23042,8 +23042,8 @@ var require_distribution = __commonJS({
|
|
|
23042
23042
|
return result / filterArr1.length;
|
|
23043
23043
|
},
|
|
23044
23044
|
"COVARIANCE.S": (array1, array2) => {
|
|
23045
|
-
array1 = H.accept(array1,
|
|
23046
|
-
array2 = H.accept(array2,
|
|
23045
|
+
array1 = H.accept(array1, Types3.ARRAY, void 0, true, true);
|
|
23046
|
+
array2 = H.accept(array2, Types3.ARRAY, void 0, true, true);
|
|
23047
23047
|
if (array1.length !== array2.length)
|
|
23048
23048
|
throw FormulaError.NA;
|
|
23049
23049
|
const filterArr1 = [], filterArr2 = [];
|
|
@@ -23059,7 +23059,7 @@ var require_distribution = __commonJS({
|
|
|
23059
23059
|
},
|
|
23060
23060
|
DEVSQ: (...numbers2) => {
|
|
23061
23061
|
let sum2 = 0, x2 = [];
|
|
23062
|
-
H.flattenParams(numbers2,
|
|
23062
|
+
H.flattenParams(numbers2, Types3.NUMBER, true, (item, info) => {
|
|
23063
23063
|
if (typeof item === "number") {
|
|
23064
23064
|
sum2 += item;
|
|
23065
23065
|
x2.push(item);
|
|
@@ -23073,18 +23073,18 @@ var require_distribution = __commonJS({
|
|
|
23073
23073
|
return sum2;
|
|
23074
23074
|
},
|
|
23075
23075
|
"EXPON.DIST": (x2, lambda, cumulative) => {
|
|
23076
|
-
x2 = H.accept(x2,
|
|
23077
|
-
lambda = H.accept(lambda,
|
|
23078
|
-
cumulative = H.accept(cumulative,
|
|
23076
|
+
x2 = H.accept(x2, Types3.NUMBER);
|
|
23077
|
+
lambda = H.accept(lambda, Types3.NUMBER);
|
|
23078
|
+
cumulative = H.accept(cumulative, Types3.BOOLEAN);
|
|
23079
23079
|
if (x2 < 0 || lambda <= 0)
|
|
23080
23080
|
throw FormulaError.NUM;
|
|
23081
23081
|
return cumulative ? jStat2.exponential.cdf(x2, lambda) : jStat2.exponential.pdf(x2, lambda);
|
|
23082
23082
|
},
|
|
23083
23083
|
"F.DIST": (x2, d1, d2, cumulative) => {
|
|
23084
|
-
x2 = H.accept(x2,
|
|
23085
|
-
d1 = H.accept(d1,
|
|
23086
|
-
d2 = H.accept(d2,
|
|
23087
|
-
cumulative = H.accept(cumulative,
|
|
23084
|
+
x2 = H.accept(x2, Types3.NUMBER);
|
|
23085
|
+
d1 = H.accept(d1, Types3.NUMBER);
|
|
23086
|
+
d2 = H.accept(d2, Types3.NUMBER);
|
|
23087
|
+
cumulative = H.accept(cumulative, Types3.BOOLEAN);
|
|
23088
23088
|
if (x2 < 0 || d1 < 1 || d2 < 1) {
|
|
23089
23089
|
throw FormulaError.NUM;
|
|
23090
23090
|
}
|
|
@@ -23093,9 +23093,9 @@ var require_distribution = __commonJS({
|
|
|
23093
23093
|
return cumulative ? jStat2.centralF.cdf(x2, d1, d2) : jStat2.centralF.pdf(x2, d1, d2);
|
|
23094
23094
|
},
|
|
23095
23095
|
"F.DIST.RT": (x2, d1, d2) => {
|
|
23096
|
-
x2 = H.accept(x2,
|
|
23097
|
-
d1 = H.accept(d1,
|
|
23098
|
-
d2 = H.accept(d2,
|
|
23096
|
+
x2 = H.accept(x2, Types3.NUMBER);
|
|
23097
|
+
d1 = H.accept(d1, Types3.NUMBER);
|
|
23098
|
+
d2 = H.accept(d2, Types3.NUMBER);
|
|
23099
23099
|
if (x2 < 0 || d1 < 1 || d2 < 1) {
|
|
23100
23100
|
throw FormulaError.NUM;
|
|
23101
23101
|
}
|
|
@@ -23104,9 +23104,9 @@ var require_distribution = __commonJS({
|
|
|
23104
23104
|
return 1 - jStat2.centralF.cdf(x2, d1, d2);
|
|
23105
23105
|
},
|
|
23106
23106
|
"F.INV": (probability, d1, d2) => {
|
|
23107
|
-
probability = H.accept(probability,
|
|
23108
|
-
d1 = H.accept(d1,
|
|
23109
|
-
d2 = H.accept(d2,
|
|
23107
|
+
probability = H.accept(probability, Types3.NUMBER);
|
|
23108
|
+
d1 = H.accept(d1, Types3.NUMBER);
|
|
23109
|
+
d2 = H.accept(d2, Types3.NUMBER);
|
|
23110
23110
|
if (probability < 0 || probability > 1) {
|
|
23111
23111
|
throw FormulaError.NUM;
|
|
23112
23112
|
}
|
|
@@ -23118,9 +23118,9 @@ var require_distribution = __commonJS({
|
|
|
23118
23118
|
return jStat2.centralF.inv(probability, d1, d2);
|
|
23119
23119
|
},
|
|
23120
23120
|
"F.INV.RT": (probability, d1, d2) => {
|
|
23121
|
-
probability = H.accept(probability,
|
|
23122
|
-
d1 = H.accept(d1,
|
|
23123
|
-
d2 = H.accept(d2,
|
|
23121
|
+
probability = H.accept(probability, Types3.NUMBER);
|
|
23122
|
+
d1 = H.accept(d1, Types3.NUMBER);
|
|
23123
|
+
d2 = H.accept(d2, Types3.NUMBER);
|
|
23124
23124
|
if (probability < 0 || probability > 1) {
|
|
23125
23125
|
throw FormulaError.NUM;
|
|
23126
23126
|
}
|
|
@@ -23138,8 +23138,8 @@ var require_distribution = __commonJS({
|
|
|
23138
23138
|
* https://en.wikipedia.org/wiki/F-test_of_equality_of_variances
|
|
23139
23139
|
*/
|
|
23140
23140
|
"F.TEST": (array1, array2) => {
|
|
23141
|
-
array1 = H.accept(array1,
|
|
23142
|
-
array2 = H.accept(array2,
|
|
23141
|
+
array1 = H.accept(array1, Types3.ARRAY, void 0, true, true);
|
|
23142
|
+
array2 = H.accept(array2, Types3.ARRAY, void 0, true, true);
|
|
23143
23143
|
const x1 = [], x2 = [];
|
|
23144
23144
|
let x1Mean = 0, x2Mean = 0;
|
|
23145
23145
|
for (let i2 = 0; i2 < Math.max(array1.length, array2.length); i2++) {
|
|
@@ -23168,22 +23168,22 @@ var require_distribution = __commonJS({
|
|
|
23168
23168
|
return jStat2.centralF.cdf(s1 / s2, x1.length - 1, x2.length - 1) * 2;
|
|
23169
23169
|
},
|
|
23170
23170
|
FISHER: (x2) => {
|
|
23171
|
-
x2 = H.accept(x2,
|
|
23171
|
+
x2 = H.accept(x2, Types3.NUMBER);
|
|
23172
23172
|
if (x2 <= -1 || x2 >= 1) {
|
|
23173
23173
|
throw FormulaError.NUM;
|
|
23174
23174
|
}
|
|
23175
23175
|
return Math.log((1 + x2) / (1 - x2)) / 2;
|
|
23176
23176
|
},
|
|
23177
23177
|
FISHERINV: (x2) => {
|
|
23178
|
-
x2 = H.accept(x2,
|
|
23178
|
+
x2 = H.accept(x2, Types3.NUMBER);
|
|
23179
23179
|
let e2y = Math.exp(2 * x2);
|
|
23180
23180
|
return (e2y - 1) / (e2y + 1);
|
|
23181
23181
|
},
|
|
23182
23182
|
// FIXME
|
|
23183
23183
|
FORECAST: (x2, knownYs, knownXs) => {
|
|
23184
|
-
x2 = H.accept(x2,
|
|
23185
|
-
knownYs = H.accept(knownYs,
|
|
23186
|
-
knownXs = H.accept(knownXs,
|
|
23184
|
+
x2 = H.accept(x2, Types3.NUMBER);
|
|
23185
|
+
knownYs = H.accept(knownYs, Types3.ARRAY, void 0, true, true);
|
|
23186
|
+
knownXs = H.accept(knownXs, Types3.ARRAY, void 0, true, true);
|
|
23187
23187
|
if (knownXs.length !== knownYs.length)
|
|
23188
23188
|
throw FormulaError.NA;
|
|
23189
23189
|
const filteredY = [], filteredX = [];
|
|
@@ -23221,8 +23221,8 @@ var require_distribution = __commonJS({
|
|
|
23221
23221
|
return DistributionFunctions.FORECAST(...params);
|
|
23222
23222
|
},
|
|
23223
23223
|
FREQUENCY: (dataArray, binsArray) => {
|
|
23224
|
-
dataArray = H.accept(dataArray,
|
|
23225
|
-
binsArray = H.accept(binsArray,
|
|
23224
|
+
dataArray = H.accept(dataArray, Types3.ARRAY, void 0, true, true);
|
|
23225
|
+
binsArray = H.accept(binsArray, Types3.ARRAY, void 0, true, true);
|
|
23226
23226
|
const binsArrayFiltered = [];
|
|
23227
23227
|
for (let i2 = 0; i2 < binsArray.length; i2++) {
|
|
23228
23228
|
if (typeof binsArray[i2] !== "number")
|
|
@@ -23249,52 +23249,52 @@ var require_distribution = __commonJS({
|
|
|
23249
23249
|
return result;
|
|
23250
23250
|
},
|
|
23251
23251
|
GAMMA: (x2) => {
|
|
23252
|
-
x2 = H.accept(x2,
|
|
23252
|
+
x2 = H.accept(x2, Types3.NUMBER);
|
|
23253
23253
|
if (x2 === 0 || x2 < 0 && x2 === Math.trunc(x2)) {
|
|
23254
23254
|
throw FormulaError.NUM;
|
|
23255
23255
|
}
|
|
23256
23256
|
return jStat2.gammafn(x2);
|
|
23257
23257
|
},
|
|
23258
23258
|
"GAMMA.DIST": (x2, alpha, beta, cumulative) => {
|
|
23259
|
-
x2 = H.accept(x2,
|
|
23260
|
-
alpha = H.accept(alpha,
|
|
23261
|
-
beta = H.accept(beta,
|
|
23262
|
-
cumulative = H.accept(cumulative,
|
|
23259
|
+
x2 = H.accept(x2, Types3.NUMBER);
|
|
23260
|
+
alpha = H.accept(alpha, Types3.NUMBER);
|
|
23261
|
+
beta = H.accept(beta, Types3.NUMBER);
|
|
23262
|
+
cumulative = H.accept(cumulative, Types3.BOOLEAN);
|
|
23263
23263
|
if (x2 < 0 || alpha <= 0 || beta <= 0) {
|
|
23264
23264
|
throw FormulaError.NUM;
|
|
23265
23265
|
}
|
|
23266
23266
|
return cumulative ? jStat2.gamma.cdf(x2, alpha, beta, true) : jStat2.gamma.pdf(x2, alpha, beta, false);
|
|
23267
23267
|
},
|
|
23268
23268
|
"GAMMA.INV": (probability, alpha, beta) => {
|
|
23269
|
-
probability = H.accept(probability,
|
|
23270
|
-
alpha = H.accept(alpha,
|
|
23271
|
-
beta = H.accept(beta,
|
|
23269
|
+
probability = H.accept(probability, Types3.NUMBER);
|
|
23270
|
+
alpha = H.accept(alpha, Types3.NUMBER);
|
|
23271
|
+
beta = H.accept(beta, Types3.NUMBER);
|
|
23272
23272
|
if (probability < 0 || probability > 1 || alpha <= 0 || beta <= 0) {
|
|
23273
23273
|
throw FormulaError.NUM;
|
|
23274
23274
|
}
|
|
23275
23275
|
return jStat2.gamma.inv(probability, alpha, beta);
|
|
23276
23276
|
},
|
|
23277
23277
|
GAMMALN: (x2) => {
|
|
23278
|
-
x2 = H.accept(x2,
|
|
23278
|
+
x2 = H.accept(x2, Types3.NUMBER);
|
|
23279
23279
|
if (x2 <= 0) {
|
|
23280
23280
|
throw FormulaError.NUM;
|
|
23281
23281
|
}
|
|
23282
23282
|
return jStat2.gammaln(x2);
|
|
23283
23283
|
},
|
|
23284
23284
|
"GAMMALN.PRECISE": (x2) => {
|
|
23285
|
-
x2 = H.accept(x2,
|
|
23285
|
+
x2 = H.accept(x2, Types3.NUMBER);
|
|
23286
23286
|
if (x2 <= 0) {
|
|
23287
23287
|
throw FormulaError.NUM;
|
|
23288
23288
|
}
|
|
23289
23289
|
return jStat2.gammaln(x2);
|
|
23290
23290
|
},
|
|
23291
23291
|
GAUSS: (z2) => {
|
|
23292
|
-
z2 = H.accept(z2,
|
|
23292
|
+
z2 = H.accept(z2, Types3.NUMBER);
|
|
23293
23293
|
return jStat2.normal.cdf(z2, 0, 1) - 0.5;
|
|
23294
23294
|
},
|
|
23295
23295
|
GEOMEAN: (...numbers2) => {
|
|
23296
23296
|
const filterArr = [];
|
|
23297
|
-
H.flattenParams(numbers2,
|
|
23297
|
+
H.flattenParams(numbers2, Types3.NUMBER, true, (item, info) => {
|
|
23298
23298
|
if (typeof item === "number") {
|
|
23299
23299
|
filterArr.push(item);
|
|
23300
23300
|
}
|
|
@@ -23302,12 +23302,12 @@ var require_distribution = __commonJS({
|
|
|
23302
23302
|
return jStat2.geomean(filterArr);
|
|
23303
23303
|
},
|
|
23304
23304
|
GROWTH: (knownY, knownX, newX, useConst) => {
|
|
23305
|
-
knownY = H.accept(knownY,
|
|
23305
|
+
knownY = H.accept(knownY, Types3.ARRAY, void 0, true, true);
|
|
23306
23306
|
for (let i2 = 0; i2 < knownY.length; i2++) {
|
|
23307
23307
|
if (typeof knownY[i2] !== "number")
|
|
23308
23308
|
throw FormulaError.VALUE;
|
|
23309
23309
|
}
|
|
23310
|
-
knownX = H.accept(knownX,
|
|
23310
|
+
knownX = H.accept(knownX, Types3.ARRAY, null, true, true);
|
|
23311
23311
|
const isKnownXOmitted = knownX == null;
|
|
23312
23312
|
if (knownX == null) {
|
|
23313
23313
|
knownX = [];
|
|
@@ -23322,7 +23322,7 @@ var require_distribution = __commonJS({
|
|
|
23322
23322
|
throw FormulaError.VALUE;
|
|
23323
23323
|
}
|
|
23324
23324
|
}
|
|
23325
|
-
newX = H.accept(newX,
|
|
23325
|
+
newX = H.accept(newX, Types3.ARRAY, null, false, true);
|
|
23326
23326
|
if (newX == null && isKnownXOmitted) {
|
|
23327
23327
|
newX = [];
|
|
23328
23328
|
for (let i2 = 1; i2 <= knownY.length; i2++) {
|
|
@@ -23332,7 +23332,7 @@ var require_distribution = __commonJS({
|
|
|
23332
23332
|
} else if (newX == null) {
|
|
23333
23333
|
newX = Array.isArray(knownX[0]) ? knownX : [knownX];
|
|
23334
23334
|
}
|
|
23335
|
-
useConst = H.accept(useConst,
|
|
23335
|
+
useConst = H.accept(useConst, Types3.BOOLEAN, true);
|
|
23336
23336
|
const n = knownY.length;
|
|
23337
23337
|
let avg_x = 0, avg_y = 0, avg_xy = 0, avg_xx = 0;
|
|
23338
23338
|
for (let i2 = 0; i2 < n; i2++) {
|
|
@@ -23369,7 +23369,7 @@ var require_distribution = __commonJS({
|
|
|
23369
23369
|
},
|
|
23370
23370
|
HARMEAN: (...numbers2) => {
|
|
23371
23371
|
let cnt = 0, denominator = 0;
|
|
23372
|
-
H.flattenParams(numbers2,
|
|
23372
|
+
H.flattenParams(numbers2, Types3.NUMBER, true, (item, info) => {
|
|
23373
23373
|
if (typeof item === "number") {
|
|
23374
23374
|
denominator += 1 / item;
|
|
23375
23375
|
cnt++;
|
|
@@ -23378,11 +23378,11 @@ var require_distribution = __commonJS({
|
|
|
23378
23378
|
return cnt / denominator;
|
|
23379
23379
|
},
|
|
23380
23380
|
"HYPGEOM.DIST": (sample_s, number_sample, population_s, number_pop, cumulative) => {
|
|
23381
|
-
sample_s = H.accept(sample_s,
|
|
23382
|
-
number_sample = H.accept(number_sample,
|
|
23383
|
-
population_s = H.accept(population_s,
|
|
23384
|
-
number_pop = H.accept(number_pop,
|
|
23385
|
-
cumulative = H.accept(cumulative,
|
|
23381
|
+
sample_s = H.accept(sample_s, Types3.NUMBER);
|
|
23382
|
+
number_sample = H.accept(number_sample, Types3.NUMBER);
|
|
23383
|
+
population_s = H.accept(population_s, Types3.NUMBER);
|
|
23384
|
+
number_pop = H.accept(number_pop, Types3.NUMBER);
|
|
23385
|
+
cumulative = H.accept(cumulative, Types3.BOOLEAN);
|
|
23386
23386
|
sample_s = Math.trunc(sample_s);
|
|
23387
23387
|
number_sample = Math.trunc(number_sample);
|
|
23388
23388
|
population_s = Math.trunc(population_s);
|
|
@@ -23415,8 +23415,8 @@ var require_distribution = __commonJS({
|
|
|
23415
23415
|
return cumulative ? cdf(sample_s, number_sample, population_s, number_pop) : pdf(sample_s, number_sample, population_s, number_pop);
|
|
23416
23416
|
},
|
|
23417
23417
|
INTERCEPT: (knownYs, knownXs) => {
|
|
23418
|
-
knownYs = H.accept(knownYs,
|
|
23419
|
-
knownXs = H.accept(knownXs,
|
|
23418
|
+
knownYs = H.accept(knownYs, Types3.ARRAY, void 0, true, true);
|
|
23419
|
+
knownXs = H.accept(knownXs, Types3.ARRAY, void 0, true, true);
|
|
23420
23420
|
if (knownXs.length !== knownYs.length)
|
|
23421
23421
|
throw FormulaError.NA;
|
|
23422
23422
|
const filteredY = [], filteredX = [];
|
|
@@ -23440,7 +23440,7 @@ var require_distribution = __commonJS({
|
|
|
23440
23440
|
},
|
|
23441
23441
|
KURT: (...numbers2) => {
|
|
23442
23442
|
let mean2 = 0, range2 = [];
|
|
23443
|
-
H.flattenParams(numbers2,
|
|
23443
|
+
H.flattenParams(numbers2, Types3.NUMBER, true, (item, info) => {
|
|
23444
23444
|
if (typeof item === "number") {
|
|
23445
23445
|
mean2 += item;
|
|
23446
23446
|
range2.push(item);
|
|
@@ -23460,19 +23460,19 @@ var require_distribution = __commonJS({
|
|
|
23460
23460
|
LOGEST: () => {
|
|
23461
23461
|
},
|
|
23462
23462
|
"LOGNORM.DIST": (x2, mean2, standard_dev, cumulative) => {
|
|
23463
|
-
x2 = H.accept(x2,
|
|
23464
|
-
mean2 = H.accept(mean2,
|
|
23465
|
-
standard_dev = H.accept(standard_dev,
|
|
23466
|
-
cumulative = H.accept(cumulative,
|
|
23463
|
+
x2 = H.accept(x2, Types3.NUMBER);
|
|
23464
|
+
mean2 = H.accept(mean2, Types3.NUMBER);
|
|
23465
|
+
standard_dev = H.accept(standard_dev, Types3.NUMBER);
|
|
23466
|
+
cumulative = H.accept(cumulative, Types3.BOOLEAN);
|
|
23467
23467
|
if (x2 <= 0 || standard_dev <= 0) {
|
|
23468
23468
|
throw FormulaError.NUM;
|
|
23469
23469
|
}
|
|
23470
23470
|
return cumulative ? jStat2.lognormal.cdf(x2, mean2, standard_dev) : jStat2.lognormal.pdf(x2, mean2, standard_dev);
|
|
23471
23471
|
},
|
|
23472
23472
|
"LOGNORM.INV": (probability, mean2, standard_dev) => {
|
|
23473
|
-
probability = H.accept(probability,
|
|
23474
|
-
mean2 = H.accept(mean2,
|
|
23475
|
-
standard_dev = H.accept(standard_dev,
|
|
23473
|
+
probability = H.accept(probability, Types3.NUMBER);
|
|
23474
|
+
mean2 = H.accept(mean2, Types3.NUMBER);
|
|
23475
|
+
standard_dev = H.accept(standard_dev, Types3.NUMBER);
|
|
23476
23476
|
if (probability <= 0 || probability >= 1) {
|
|
23477
23477
|
throw FormulaError.NUM;
|
|
23478
23478
|
}
|
|
@@ -23486,10 +23486,10 @@ var require_distribution = __commonJS({
|
|
|
23486
23486
|
"MODE.SNGL": () => {
|
|
23487
23487
|
},
|
|
23488
23488
|
"NEGBINOM.DIST": (number_f, number_s, probability_s, cumulative) => {
|
|
23489
|
-
number_f = H.accept(number_f,
|
|
23490
|
-
number_s = H.accept(number_s,
|
|
23491
|
-
probability_s = H.accept(probability_s,
|
|
23492
|
-
cumulative = H.accept(cumulative,
|
|
23489
|
+
number_f = H.accept(number_f, Types3.NUMBER);
|
|
23490
|
+
number_s = H.accept(number_s, Types3.NUMBER);
|
|
23491
|
+
probability_s = H.accept(probability_s, Types3.NUMBER);
|
|
23492
|
+
cumulative = H.accept(cumulative, Types3.BOOLEAN);
|
|
23493
23493
|
number_f = Math.trunc(number_f);
|
|
23494
23494
|
number_s = Math.trunc(number_s);
|
|
23495
23495
|
if (probability_s < 0 || probability_s > 1) {
|
|
@@ -23501,19 +23501,19 @@ var require_distribution = __commonJS({
|
|
|
23501
23501
|
return cumulative ? jStat2.negbin.cdf(number_f, number_s, probability_s) : jStat2.negbin.pdf(number_f, number_s, probability_s);
|
|
23502
23502
|
},
|
|
23503
23503
|
"NORM.DIST": (x2, mean2, standard_dev, cumulative) => {
|
|
23504
|
-
x2 = H.accept(x2,
|
|
23505
|
-
mean2 = H.accept(mean2,
|
|
23506
|
-
standard_dev = H.accept(standard_dev,
|
|
23507
|
-
cumulative = H.accept(cumulative,
|
|
23504
|
+
x2 = H.accept(x2, Types3.NUMBER);
|
|
23505
|
+
mean2 = H.accept(mean2, Types3.NUMBER);
|
|
23506
|
+
standard_dev = H.accept(standard_dev, Types3.NUMBER);
|
|
23507
|
+
cumulative = H.accept(cumulative, Types3.BOOLEAN);
|
|
23508
23508
|
if (standard_dev <= 0) {
|
|
23509
23509
|
throw FormulaError.NUM;
|
|
23510
23510
|
}
|
|
23511
23511
|
return cumulative ? jStat2.normal.cdf(x2, mean2, standard_dev) : jStat2.normal.pdf(x2, mean2, standard_dev);
|
|
23512
23512
|
},
|
|
23513
23513
|
"NORM.INV": (probability, mean2, standard_dev) => {
|
|
23514
|
-
probability = H.accept(probability,
|
|
23515
|
-
mean2 = H.accept(mean2,
|
|
23516
|
-
standard_dev = H.accept(standard_dev,
|
|
23514
|
+
probability = H.accept(probability, Types3.NUMBER);
|
|
23515
|
+
mean2 = H.accept(mean2, Types3.NUMBER);
|
|
23516
|
+
standard_dev = H.accept(standard_dev, Types3.NUMBER);
|
|
23517
23517
|
if (probability <= 0 || probability >= 1) {
|
|
23518
23518
|
throw FormulaError.NUM;
|
|
23519
23519
|
}
|
|
@@ -23523,12 +23523,12 @@ var require_distribution = __commonJS({
|
|
|
23523
23523
|
return jStat2.normal.inv(probability, mean2, standard_dev);
|
|
23524
23524
|
},
|
|
23525
23525
|
"NORM.S.DIST": (z2, cumulative) => {
|
|
23526
|
-
z2 = H.accept(z2,
|
|
23527
|
-
cumulative = H.accept(cumulative,
|
|
23526
|
+
z2 = H.accept(z2, Types3.NUMBER);
|
|
23527
|
+
cumulative = H.accept(cumulative, Types3.BOOLEAN);
|
|
23528
23528
|
return cumulative ? jStat2.normal.cdf(z2, 0, 1) : jStat2.normal.pdf(z2, 0, 1);
|
|
23529
23529
|
},
|
|
23530
23530
|
"NORM.S.INV": (probability) => {
|
|
23531
|
-
probability = H.accept(probability,
|
|
23531
|
+
probability = H.accept(probability, Types3.NUMBER);
|
|
23532
23532
|
if (probability <= 0 || probability >= 1) {
|
|
23533
23533
|
throw FormulaError.NUM;
|
|
23534
23534
|
}
|
|
@@ -23547,13 +23547,13 @@ var require_distribution = __commonJS({
|
|
|
23547
23547
|
PERMUTATIONA: () => {
|
|
23548
23548
|
},
|
|
23549
23549
|
PHI: (x2) => {
|
|
23550
|
-
x2 = H.accept(x2,
|
|
23550
|
+
x2 = H.accept(x2, Types3.NUMBER);
|
|
23551
23551
|
return Math.exp(-0.5 * x2 * x2) / SQRT2PI2;
|
|
23552
23552
|
},
|
|
23553
23553
|
"POISSON.DIST": (x2, mean2, cumulative) => {
|
|
23554
|
-
x2 = H.accept(x2,
|
|
23555
|
-
mean2 = H.accept(mean2,
|
|
23556
|
-
cumulative = H.accept(cumulative,
|
|
23554
|
+
x2 = H.accept(x2, Types3.NUMBER);
|
|
23555
|
+
mean2 = H.accept(mean2, Types3.NUMBER);
|
|
23556
|
+
cumulative = H.accept(cumulative, Types3.BOOLEAN);
|
|
23557
23557
|
if (x2 < 0 || mean2 < 0) {
|
|
23558
23558
|
throw FormulaError.NUM;
|
|
23559
23559
|
}
|
|
@@ -23579,9 +23579,9 @@ var require_distribution = __commonJS({
|
|
|
23579
23579
|
SLOPE: () => {
|
|
23580
23580
|
},
|
|
23581
23581
|
STANDARDIZE: (x2, mean2, standard_dev) => {
|
|
23582
|
-
x2 = H.accept(x2,
|
|
23583
|
-
mean2 = H.accept(mean2,
|
|
23584
|
-
standard_dev = H.accept(standard_dev,
|
|
23582
|
+
x2 = H.accept(x2, Types3.NUMBER);
|
|
23583
|
+
mean2 = H.accept(mean2, Types3.NUMBER);
|
|
23584
|
+
standard_dev = H.accept(standard_dev, Types3.NUMBER);
|
|
23585
23585
|
if (standard_dev <= 0) {
|
|
23586
23586
|
throw FormulaError.NUM;
|
|
23587
23587
|
}
|
|
@@ -23598,33 +23598,33 @@ var require_distribution = __commonJS({
|
|
|
23598
23598
|
STEYX: () => {
|
|
23599
23599
|
},
|
|
23600
23600
|
"T.DIST": (x2, deg_freedom, cumulative) => {
|
|
23601
|
-
x2 = H.accept(x2,
|
|
23602
|
-
deg_freedom = H.accept(deg_freedom,
|
|
23603
|
-
cumulative = H.accept(cumulative,
|
|
23601
|
+
x2 = H.accept(x2, Types3.NUMBER);
|
|
23602
|
+
deg_freedom = H.accept(deg_freedom, Types3.NUMBER);
|
|
23603
|
+
cumulative = H.accept(cumulative, Types3.BOOLEAN);
|
|
23604
23604
|
if (deg_freedom < 1) {
|
|
23605
23605
|
throw FormulaError.NUM;
|
|
23606
23606
|
}
|
|
23607
23607
|
return cumulative ? jStat2.studentt.cdf(x2, deg_freedom) : jStat2.studentt.pdf(x2, deg_freedom);
|
|
23608
23608
|
},
|
|
23609
23609
|
"T.DIST.2T": (x2, deg_freedom) => {
|
|
23610
|
-
x2 = H.accept(x2,
|
|
23611
|
-
deg_freedom = H.accept(deg_freedom,
|
|
23610
|
+
x2 = H.accept(x2, Types3.NUMBER);
|
|
23611
|
+
deg_freedom = H.accept(deg_freedom, Types3.NUMBER);
|
|
23612
23612
|
if (deg_freedom < 1 || x2 < 0) {
|
|
23613
23613
|
throw FormulaError.NUM;
|
|
23614
23614
|
}
|
|
23615
23615
|
return (1 - jStat2.studentt.cdf(x2, deg_freedom)) * 2;
|
|
23616
23616
|
},
|
|
23617
23617
|
"T.DIST.RT": (x2, deg_freedom) => {
|
|
23618
|
-
x2 = H.accept(x2,
|
|
23619
|
-
deg_freedom = H.accept(deg_freedom,
|
|
23618
|
+
x2 = H.accept(x2, Types3.NUMBER);
|
|
23619
|
+
deg_freedom = H.accept(deg_freedom, Types3.NUMBER);
|
|
23620
23620
|
if (deg_freedom < 1) {
|
|
23621
23621
|
throw FormulaError.NUM;
|
|
23622
23622
|
}
|
|
23623
23623
|
return 1 - jStat2.studentt.cdf(x2, deg_freedom);
|
|
23624
23624
|
},
|
|
23625
23625
|
"T.INV": (probability, deg_freedom) => {
|
|
23626
|
-
probability = H.accept(probability,
|
|
23627
|
-
deg_freedom = H.accept(deg_freedom,
|
|
23626
|
+
probability = H.accept(probability, Types3.NUMBER);
|
|
23627
|
+
deg_freedom = H.accept(deg_freedom, Types3.NUMBER);
|
|
23628
23628
|
if (probability <= 0 || probability > 1 || deg_freedom < 1) {
|
|
23629
23629
|
throw FormulaError.NUM;
|
|
23630
23630
|
}
|
|
@@ -23632,8 +23632,8 @@ var require_distribution = __commonJS({
|
|
|
23632
23632
|
return jStat2.studentt.inv(probability, deg_freedom);
|
|
23633
23633
|
},
|
|
23634
23634
|
"T.INV.2T": (probability, deg_freedom) => {
|
|
23635
|
-
probability = H.accept(probability,
|
|
23636
|
-
deg_freedom = H.accept(deg_freedom,
|
|
23635
|
+
probability = H.accept(probability, Types3.NUMBER);
|
|
23636
|
+
deg_freedom = H.accept(deg_freedom, Types3.NUMBER);
|
|
23637
23637
|
if (probability <= 0 || probability > 1 || deg_freedom < 1) {
|
|
23638
23638
|
throw FormulaError.NUM;
|
|
23639
23639
|
}
|
|
@@ -23655,10 +23655,10 @@ var require_distribution = __commonJS({
|
|
|
23655
23655
|
"VARPA": () => {
|
|
23656
23656
|
},
|
|
23657
23657
|
"WEIBULL.DIST": (x2, alpha, beta, cumulative) => {
|
|
23658
|
-
x2 = H.accept(x2,
|
|
23659
|
-
alpha = H.accept(alpha,
|
|
23660
|
-
beta = H.accept(beta,
|
|
23661
|
-
cumulative = H.accept(cumulative,
|
|
23658
|
+
x2 = H.accept(x2, Types3.NUMBER);
|
|
23659
|
+
alpha = H.accept(alpha, Types3.NUMBER);
|
|
23660
|
+
beta = H.accept(beta, Types3.NUMBER);
|
|
23661
|
+
cumulative = H.accept(cumulative, Types3.BOOLEAN);
|
|
23662
23662
|
if (x2 < 0 || alpha <= 0 || beta <= 0) {
|
|
23663
23663
|
throw FormulaError.NUM;
|
|
23664
23664
|
}
|
|
@@ -23677,15 +23677,15 @@ var require_distribution = __commonJS({
|
|
|
23677
23677
|
var require_statistical = __commonJS({
|
|
23678
23678
|
"../../node_modules/fast-formula-parser/formulas/functions/statistical.js"(exports2, module2) {
|
|
23679
23679
|
var FormulaError = require_error();
|
|
23680
|
-
var { FormulaHelpers, Types, Criteria, Address } = require_helpers();
|
|
23680
|
+
var { FormulaHelpers: FormulaHelpers3, Types: Types3, Criteria, Address } = require_helpers();
|
|
23681
23681
|
var { Infix: Infix2 } = require_operators();
|
|
23682
|
-
var H =
|
|
23682
|
+
var H = FormulaHelpers3;
|
|
23683
23683
|
var { DistributionFunctions } = require_distribution();
|
|
23684
23684
|
var StatisticalFunctions = {
|
|
23685
23685
|
AVEDEV: (...numbers2) => {
|
|
23686
23686
|
let sum2 = 0;
|
|
23687
23687
|
const arr = [];
|
|
23688
|
-
H.flattenParams(numbers2,
|
|
23688
|
+
H.flattenParams(numbers2, Types3.NUMBER, true, (item, info) => {
|
|
23689
23689
|
if (typeof item === "number") {
|
|
23690
23690
|
sum2 += item;
|
|
23691
23691
|
arr.push(item);
|
|
@@ -23700,7 +23700,7 @@ var require_statistical = __commonJS({
|
|
|
23700
23700
|
},
|
|
23701
23701
|
AVERAGE: (...numbers2) => {
|
|
23702
23702
|
let sum2 = 0, cnt = 0;
|
|
23703
|
-
H.flattenParams(numbers2,
|
|
23703
|
+
H.flattenParams(numbers2, Types3.NUMBER, true, (item, info) => {
|
|
23704
23704
|
if (typeof item === "number") {
|
|
23705
23705
|
sum2 += item;
|
|
23706
23706
|
cnt++;
|
|
@@ -23710,7 +23710,7 @@ var require_statistical = __commonJS({
|
|
|
23710
23710
|
},
|
|
23711
23711
|
AVERAGEA: (...numbers2) => {
|
|
23712
23712
|
let sum2 = 0, cnt = 0;
|
|
23713
|
-
H.flattenParams(numbers2,
|
|
23713
|
+
H.flattenParams(numbers2, Types3.NUMBER, true, (item, info) => {
|
|
23714
23714
|
const type = typeof item;
|
|
23715
23715
|
if (type === "number") {
|
|
23716
23716
|
sum2 += item;
|
|
@@ -23769,7 +23769,7 @@ var require_statistical = __commonJS({
|
|
|
23769
23769
|
return cnt;
|
|
23770
23770
|
},
|
|
23771
23771
|
COUNTIF: (range2, criteria) => {
|
|
23772
|
-
range2 = H.accept(range2,
|
|
23772
|
+
range2 = H.accept(range2, Types3.ARRAY, void 0, false, true);
|
|
23773
23773
|
const isCriteriaArray = criteria.isArray;
|
|
23774
23774
|
criteria = H.accept(criteria);
|
|
23775
23775
|
let cnt = 0;
|
|
@@ -23817,8 +23817,8 @@ var require_statistical = __commonJS({
|
|
|
23817
23817
|
var require_date = __commonJS({
|
|
23818
23818
|
"../../node_modules/fast-formula-parser/formulas/functions/date.js"(exports2, module2) {
|
|
23819
23819
|
var FormulaError = require_error();
|
|
23820
|
-
var { FormulaHelpers, Types } = require_helpers();
|
|
23821
|
-
var H =
|
|
23820
|
+
var { FormulaHelpers: FormulaHelpers3, Types: Types3 } = require_helpers();
|
|
23821
|
+
var H = FormulaHelpers3;
|
|
23822
23822
|
var MS_PER_DAY2 = 1e3 * 60 * 60 * 24;
|
|
23823
23823
|
var d1900 = new Date(Date.UTC(1900, 0, 1));
|
|
23824
23824
|
var WEEK_STARTS2 = [
|
|
@@ -23970,9 +23970,9 @@ var require_date = __commonJS({
|
|
|
23970
23970
|
}
|
|
23971
23971
|
var DateFunctions = {
|
|
23972
23972
|
DATE: (year, month, day) => {
|
|
23973
|
-
year = H.accept(year,
|
|
23974
|
-
month = H.accept(month,
|
|
23975
|
-
day = H.accept(day,
|
|
23973
|
+
year = H.accept(year, Types3.NUMBER);
|
|
23974
|
+
month = H.accept(month, Types3.NUMBER);
|
|
23975
|
+
day = H.accept(day, Types3.NUMBER);
|
|
23976
23976
|
if (year < 0 || year >= 1e4)
|
|
23977
23977
|
throw FormulaError.NUM;
|
|
23978
23978
|
if (year < 1900) {
|
|
@@ -23983,7 +23983,7 @@ var require_date = __commonJS({
|
|
|
23983
23983
|
DATEDIF: (startDate, endDate, unit) => {
|
|
23984
23984
|
startDate = parseDate2(startDate);
|
|
23985
23985
|
endDate = parseDate2(endDate);
|
|
23986
|
-
unit = H.accept(unit,
|
|
23986
|
+
unit = H.accept(unit, Types3.STRING).toLowerCase();
|
|
23987
23987
|
if (startDate > endDate)
|
|
23988
23988
|
throw FormulaError.NUM;
|
|
23989
23989
|
const yearDiff = endDate.getUTCFullYear() - startDate.getUTCFullYear();
|
|
@@ -24025,7 +24025,7 @@ var require_date = __commonJS({
|
|
|
24025
24025
|
* @param {string} dateText
|
|
24026
24026
|
*/
|
|
24027
24027
|
DATEVALUE: (dateText) => {
|
|
24028
|
-
dateText = H.accept(dateText,
|
|
24028
|
+
dateText = H.accept(dateText, Types3.STRING);
|
|
24029
24029
|
const { date: date6, isDateGiven } = parseDateWithExtra(dateText);
|
|
24030
24030
|
if (!isDateGiven) return 0;
|
|
24031
24031
|
const serial = toSerial(date6);
|
|
@@ -24049,7 +24049,7 @@ var require_date = __commonJS({
|
|
|
24049
24049
|
DAYS360: (startDate, endDate, method) => {
|
|
24050
24050
|
startDate = parseDate2(startDate);
|
|
24051
24051
|
endDate = parseDate2(endDate);
|
|
24052
|
-
method = H.accept(method,
|
|
24052
|
+
method = H.accept(method, Types3.BOOLEAN, false);
|
|
24053
24053
|
if (startDate.getUTCDate() === 31) {
|
|
24054
24054
|
startDate.setUTCDate(30);
|
|
24055
24055
|
}
|
|
@@ -24067,13 +24067,13 @@ var require_date = __commonJS({
|
|
|
24067
24067
|
},
|
|
24068
24068
|
EDATE: (startDate, months) => {
|
|
24069
24069
|
startDate = parseDate2(startDate);
|
|
24070
|
-
months = H.accept(months,
|
|
24070
|
+
months = H.accept(months, Types3.NUMBER);
|
|
24071
24071
|
startDate.setUTCMonth(startDate.getUTCMonth() + months);
|
|
24072
24072
|
return toSerial(startDate);
|
|
24073
24073
|
},
|
|
24074
24074
|
EOMONTH: (startDate, months) => {
|
|
24075
24075
|
startDate = parseDate2(startDate);
|
|
24076
|
-
months = H.accept(months,
|
|
24076
|
+
months = H.accept(months, Types3.NUMBER);
|
|
24077
24077
|
startDate.setUTCMonth(startDate.getUTCMonth() + months + 1, 0);
|
|
24078
24078
|
return toSerial(startDate);
|
|
24079
24079
|
},
|
|
@@ -24109,7 +24109,7 @@ var require_date = __commonJS({
|
|
|
24109
24109
|
}
|
|
24110
24110
|
const holidaysArr = [];
|
|
24111
24111
|
if (holidays != null) {
|
|
24112
|
-
H.flattenParams([holidays],
|
|
24112
|
+
H.flattenParams([holidays], Types3.NUMBER, false, (item) => {
|
|
24113
24113
|
holidaysArr.push(parseDate2(item));
|
|
24114
24114
|
});
|
|
24115
24115
|
}
|
|
@@ -24158,7 +24158,7 @@ var require_date = __commonJS({
|
|
|
24158
24158
|
}
|
|
24159
24159
|
const holidaysArr = [];
|
|
24160
24160
|
if (holidays != null) {
|
|
24161
|
-
H.flattenParams([holidays],
|
|
24161
|
+
H.flattenParams([holidays], Types3.NUMBER, false, (item) => {
|
|
24162
24162
|
holidaysArr.push(parseDate2(item));
|
|
24163
24163
|
});
|
|
24164
24164
|
}
|
|
@@ -24202,9 +24202,9 @@ var require_date = __commonJS({
|
|
|
24202
24202
|
return date6.getUTCSeconds();
|
|
24203
24203
|
},
|
|
24204
24204
|
TIME: (hour, minute, second) => {
|
|
24205
|
-
hour = H.accept(hour,
|
|
24206
|
-
minute = H.accept(minute,
|
|
24207
|
-
second = H.accept(second,
|
|
24205
|
+
hour = H.accept(hour, Types3.NUMBER);
|
|
24206
|
+
minute = H.accept(minute, Types3.NUMBER);
|
|
24207
|
+
second = H.accept(second, Types3.NUMBER);
|
|
24208
24208
|
if (hour < 0 || hour > 32767 || minute < 0 || minute > 32767 || second < 0 || second > 32767)
|
|
24209
24209
|
throw FormulaError.NUM;
|
|
24210
24210
|
return (3600 * hour + 60 * minute + second) / 86400;
|
|
@@ -24219,7 +24219,7 @@ var require_date = __commonJS({
|
|
|
24219
24219
|
},
|
|
24220
24220
|
WEEKDAY: (serialOrString, returnType) => {
|
|
24221
24221
|
const date6 = parseDate2(serialOrString);
|
|
24222
|
-
returnType = H.accept(returnType,
|
|
24222
|
+
returnType = H.accept(returnType, Types3.NUMBER, 1);
|
|
24223
24223
|
const day = date6.getUTCDay();
|
|
24224
24224
|
const weekTypes = WEEK_TYPES2[returnType];
|
|
24225
24225
|
if (!weekTypes)
|
|
@@ -24228,7 +24228,7 @@ var require_date = __commonJS({
|
|
|
24228
24228
|
},
|
|
24229
24229
|
WEEKNUM: (serialOrString, returnType) => {
|
|
24230
24230
|
const date6 = parseDate2(serialOrString);
|
|
24231
|
-
returnType = H.accept(returnType,
|
|
24231
|
+
returnType = H.accept(returnType, Types3.NUMBER, 1);
|
|
24232
24232
|
if (returnType === 21) {
|
|
24233
24233
|
return DateFunctions.ISOWEEKNUM(serialOrString);
|
|
24234
24234
|
}
|
|
@@ -24242,7 +24242,7 @@ var require_date = __commonJS({
|
|
|
24242
24242
|
},
|
|
24243
24243
|
"WORKDAY.INTL": (startDate, days, weekend, holidays) => {
|
|
24244
24244
|
startDate = parseDate2(startDate);
|
|
24245
|
-
days = H.accept(days,
|
|
24245
|
+
days = H.accept(days, Types3.NUMBER);
|
|
24246
24246
|
weekend = H.accept(weekend, null, 1);
|
|
24247
24247
|
if (weekend === "1111111")
|
|
24248
24248
|
throw FormulaError.VALUE;
|
|
@@ -24265,7 +24265,7 @@ var require_date = __commonJS({
|
|
|
24265
24265
|
}
|
|
24266
24266
|
const holidaysArr = [];
|
|
24267
24267
|
if (holidays != null) {
|
|
24268
|
-
H.flattenParams([holidays],
|
|
24268
|
+
H.flattenParams([holidays], Types3.NUMBER, false, (item) => {
|
|
24269
24269
|
holidaysArr.push(parseDate2(item));
|
|
24270
24270
|
});
|
|
24271
24271
|
}
|
|
@@ -24306,7 +24306,7 @@ var require_date = __commonJS({
|
|
|
24306
24306
|
startDate = endDate;
|
|
24307
24307
|
endDate = temp;
|
|
24308
24308
|
}
|
|
24309
|
-
basis = H.accept(basis,
|
|
24309
|
+
basis = H.accept(basis, Types3.NUMBER, 0);
|
|
24310
24310
|
basis = Math.trunc(basis);
|
|
24311
24311
|
if (basis < 0 || basis > 4)
|
|
24312
24312
|
throw FormulaError.VALUE;
|
|
@@ -24355,18 +24355,18 @@ var require_date = __commonJS({
|
|
|
24355
24355
|
var require_web = __commonJS({
|
|
24356
24356
|
"../../node_modules/fast-formula-parser/formulas/functions/web.js"(exports2, module2) {
|
|
24357
24357
|
var FormulaError = require_error();
|
|
24358
|
-
var { FormulaHelpers, Types } = require_helpers();
|
|
24359
|
-
var H =
|
|
24358
|
+
var { FormulaHelpers: FormulaHelpers3, Types: Types3 } = require_helpers();
|
|
24359
|
+
var H = FormulaHelpers3;
|
|
24360
24360
|
var WebFunctions = {
|
|
24361
24361
|
ENCODEURL: (text) => {
|
|
24362
|
-
return encodeURIComponent(H.accept(text,
|
|
24362
|
+
return encodeURIComponent(H.accept(text, Types3.STRING));
|
|
24363
24363
|
},
|
|
24364
24364
|
FILTERXML: () => {
|
|
24365
24365
|
},
|
|
24366
24366
|
WEBSERVICE: (context, url2) => {
|
|
24367
24367
|
throw FormulaError.ERROR("WEBSERVICE is not supported in sync mode.");
|
|
24368
24368
|
if (typeof fetch === "function") {
|
|
24369
|
-
url2 = H.accept(url2,
|
|
24369
|
+
url2 = H.accept(url2, Types3.STRING);
|
|
24370
24370
|
return fetch(url2).then((res) => res.text());
|
|
24371
24371
|
} else {
|
|
24372
24372
|
throw FormulaError.ERROR("WEBSERVICE only available to browser with fetch.If you want to use WEBSERVICE in Node.js, please override this function: \nnew FormulaParser({\n functionsNeedContext: {\n WEBSERVICE: (context, url) => {...}}\n})");
|
|
@@ -33694,7 +33694,7 @@ var require_hooks = __commonJS({
|
|
|
33694
33694
|
var DateFunctions = require_date();
|
|
33695
33695
|
var WebFunctions = require_web();
|
|
33696
33696
|
var FormulaError = require_error();
|
|
33697
|
-
var { FormulaHelpers } = require_helpers();
|
|
33697
|
+
var { FormulaHelpers: FormulaHelpers3 } = require_helpers();
|
|
33698
33698
|
var { Parser, allTokens } = require_parsing();
|
|
33699
33699
|
var lexer = require_lexing();
|
|
33700
33700
|
var Utils = require_utils2();
|
|
@@ -33792,10 +33792,10 @@ var require_hooks = __commonJS({
|
|
|
33792
33792
|
* @return {*}
|
|
33793
33793
|
*/
|
|
33794
33794
|
retrieveRef(valueOrRef) {
|
|
33795
|
-
if (
|
|
33795
|
+
if (FormulaHelpers3.isRangeRef(valueOrRef)) {
|
|
33796
33796
|
return this.getRange(valueOrRef.ref);
|
|
33797
33797
|
}
|
|
33798
|
-
if (
|
|
33798
|
+
if (FormulaHelpers3.isCellRef(valueOrRef)) {
|
|
33799
33799
|
return this.getCell(valueOrRef.ref);
|
|
33800
33800
|
}
|
|
33801
33801
|
return valueOrRef;
|
|
@@ -33822,8 +33822,8 @@ var require_hooks = __commonJS({
|
|
|
33822
33822
|
return {
|
|
33823
33823
|
value: res.val,
|
|
33824
33824
|
isArray: res.isArray,
|
|
33825
|
-
isRangeRef: !!
|
|
33826
|
-
isCellRef: !!
|
|
33825
|
+
isRangeRef: !!FormulaHelpers3.isRangeRef(arg),
|
|
33826
|
+
isCellRef: !!FormulaHelpers3.isCellRef(arg)
|
|
33827
33827
|
};
|
|
33828
33828
|
});
|
|
33829
33829
|
}
|
|
@@ -33863,14 +33863,14 @@ var require_hooks = __commonJS({
|
|
|
33863
33863
|
awaitedArgs.push(await arg);
|
|
33864
33864
|
}
|
|
33865
33865
|
const res = await this._callFunction(name2, awaitedArgs);
|
|
33866
|
-
return
|
|
33866
|
+
return FormulaHelpers3.checkFunctionResult(res);
|
|
33867
33867
|
}
|
|
33868
33868
|
callFunction(name2, args) {
|
|
33869
33869
|
if (this.async) {
|
|
33870
33870
|
return this.callFunctionAsync(name2, args);
|
|
33871
33871
|
} else {
|
|
33872
33872
|
const res = this._callFunction(name2, args);
|
|
33873
|
-
return
|
|
33873
|
+
return FormulaHelpers3.checkFunctionResult(res);
|
|
33874
33874
|
}
|
|
33875
33875
|
}
|
|
33876
33876
|
/**
|
|
@@ -34002,7 +34002,7 @@ var require_hooks = __commonJS({
|
|
|
34002
34002
|
};
|
|
34003
34003
|
module2.exports = {
|
|
34004
34004
|
FormulaParser: FormulaParser2,
|
|
34005
|
-
FormulaHelpers
|
|
34005
|
+
FormulaHelpers: FormulaHelpers3
|
|
34006
34006
|
};
|
|
34007
34007
|
}
|
|
34008
34008
|
});
|
|
@@ -34011,7 +34011,7 @@ var require_hooks = __commonJS({
|
|
|
34011
34011
|
var require_utils3 = __commonJS({
|
|
34012
34012
|
"../../node_modules/fast-formula-parser/grammar/dependency/utils.js"(exports2, module2) {
|
|
34013
34013
|
var FormulaError = require_error();
|
|
34014
|
-
var { FormulaHelpers, Types, Address } = require_helpers();
|
|
34014
|
+
var { FormulaHelpers: FormulaHelpers3, Types: Types3, Address } = require_helpers();
|
|
34015
34015
|
var { Prefix, Postfix, Infix: Infix2, Operators } = require_operators();
|
|
34016
34016
|
var Collection = require_collection();
|
|
34017
34017
|
var MAX_ROW2 = 1048576;
|
|
@@ -34263,7 +34263,7 @@ var require_utils3 = __commonJS({
|
|
|
34263
34263
|
var require_hooks2 = __commonJS({
|
|
34264
34264
|
"../../node_modules/fast-formula-parser/grammar/dependency/hooks.js"(exports2, module2) {
|
|
34265
34265
|
var FormulaError = require_error();
|
|
34266
|
-
var { FormulaHelpers } = require_helpers();
|
|
34266
|
+
var { FormulaHelpers: FormulaHelpers3 } = require_helpers();
|
|
34267
34267
|
var { Parser } = require_parsing();
|
|
34268
34268
|
var lexer = require_lexing();
|
|
34269
34269
|
var Utils = require_utils3();
|
|
@@ -34328,7 +34328,7 @@ var require_hooks2 = __commonJS({
|
|
|
34328
34328
|
const res = { ref: this.onVariable(name2, this.position.sheet) };
|
|
34329
34329
|
if (res.ref == null)
|
|
34330
34330
|
return FormulaError.NAME;
|
|
34331
|
-
if (
|
|
34331
|
+
if (FormulaHelpers3.isCellRef(res))
|
|
34332
34332
|
this.getCell(res.ref);
|
|
34333
34333
|
else {
|
|
34334
34334
|
this.getRange(res.ref);
|
|
@@ -34341,10 +34341,10 @@ var require_hooks2 = __commonJS({
|
|
|
34341
34341
|
* @return {*}
|
|
34342
34342
|
*/
|
|
34343
34343
|
retrieveRef(valueOrRef) {
|
|
34344
|
-
if (
|
|
34344
|
+
if (FormulaHelpers3.isRangeRef(valueOrRef)) {
|
|
34345
34345
|
return this.getRange(valueOrRef.ref);
|
|
34346
34346
|
}
|
|
34347
|
-
if (
|
|
34347
|
+
if (FormulaHelpers3.isCellRef(valueOrRef)) {
|
|
34348
34348
|
return this.getCell(valueOrRef.ref);
|
|
34349
34349
|
}
|
|
34350
34350
|
return valueOrRef;
|
|
@@ -45080,6 +45080,7 @@ var LoticsClient = class {
|
|
|
45080
45080
|
}
|
|
45081
45081
|
const buffer = Buffer.from(await response.arrayBuffer());
|
|
45082
45082
|
const absolutePath = path2.resolve(outputPath);
|
|
45083
|
+
await fs2.promises.mkdir(path2.dirname(absolutePath), { recursive: true });
|
|
45083
45084
|
await fs2.promises.writeFile(absolutePath, buffer);
|
|
45084
45085
|
return absolutePath;
|
|
45085
45086
|
}
|
|
@@ -45097,6 +45098,7 @@ var LoticsClient = class {
|
|
|
45097
45098
|
const originalFilename = match2?.[1] ?? fileId;
|
|
45098
45099
|
const buffer = Buffer.from(await response.arrayBuffer());
|
|
45099
45100
|
const dir = outputDir ? path2.resolve(outputDir) : process.cwd();
|
|
45101
|
+
await fs2.promises.mkdir(dir, { recursive: true });
|
|
45100
45102
|
const filename = findAvailableFilename(dir, originalFilename, options?.reserved);
|
|
45101
45103
|
const absolutePath = path2.join(dir, filename);
|
|
45102
45104
|
await fs2.promises.writeFile(absolutePath, buffer);
|
|
@@ -45838,10 +45840,13 @@ var COMMANDS = [
|
|
|
45838
45840
|
help: [
|
|
45839
45841
|
" lotics app create <name> [path] Create a new custom-code app + scaffold locally",
|
|
45840
45842
|
" lotics app pull <app_id> [path] Bootstrap full local env (source + npm install + types)",
|
|
45841
|
-
" lotics app deploy -m <
|
|
45843
|
+
" lotics app deploy [--prune] -m <msg> Build + upload current dir as a new version \u2014 COMMIT",
|
|
45842
45844
|
" (-m is required \u2014 it's the version's audit trail;",
|
|
45843
45845
|
" carries code + queries only \u2014 workflow bindings are",
|
|
45844
|
-
" managed by set_app_workflow / remove_app_workflow
|
|
45846
|
+
" managed by set_app_workflow / remove_app_workflow.",
|
|
45847
|
+
" --prune also UNBINDS aliases this bundle no longer",
|
|
45848
|
+
" names; off by default because `app workflow run` and",
|
|
45849
|
+
" chat reach a binding the bundle never calls)",
|
|
45845
45850
|
" lotics app versions [app_id] Show deploy history newest-first (version,",
|
|
45846
45851
|
" timestamp, deployer, build status, -m message;",
|
|
45847
45852
|
" * marks the currently served version)",
|
|
@@ -71258,11 +71263,16 @@ var memberSchema = zod_default.object({
|
|
|
71258
71263
|
member_id: zod_default.string().describe("Unique identifier for the member"),
|
|
71259
71264
|
organization_id: zod_default.string().describe("Organization ID the member belongs to"),
|
|
71260
71265
|
name: zod_default.string().describe("Display name of the member"),
|
|
71261
|
-
email_address: zod_default.string().describe(
|
|
71266
|
+
email_address: zod_default.string().describe(
|
|
71267
|
+
"What the member types to sign in: an email address for a self-managed member, an administrator-issued name (e.g. giamdoc.sunrise) for an admin-managed one. The latter is NOT an address and cannot receive mail \u2014 the field name predates the split."
|
|
71268
|
+
),
|
|
71262
71269
|
role: zod_default.enum(["owner", "admin", "member"]).describe("Organization role"),
|
|
71263
71270
|
image: zod_default.string().nullable().optional().describe("URL to the member's profile picture"),
|
|
71264
71271
|
account_type: zod_default.enum(["self_managed", "admin_managed"]).describe(
|
|
71265
|
-
"How the account is credentialed. admin_managed means an admin chose the sign-in
|
|
71272
|
+
"How the account is credentialed. admin_managed means an admin chose the sign-in name and set the password; the account has NO email address at all, so nothing can be mailed to it until the member claims one they control."
|
|
71273
|
+
),
|
|
71274
|
+
archived: zod_default.boolean().optional().describe(
|
|
71275
|
+
"True when this person has been removed from the organization. The membership survives removal so records naming them keep resolving; it grants nothing. Optional because an older server omits it \u2014 absent means active."
|
|
71266
71276
|
)
|
|
71267
71277
|
});
|
|
71268
71278
|
var pendingInvitationSchema = zod_default.object({
|
|
@@ -73026,12 +73036,16 @@ async function appDeploy(client, args) {
|
|
|
73026
73036
|
warnIfInertAgentTools(liveAfter);
|
|
73027
73037
|
}
|
|
73028
73038
|
if (liveAfter) {
|
|
73029
|
-
|
|
73030
|
-
|
|
73031
|
-
|
|
73032
|
-
|
|
73033
|
-
|
|
73034
|
-
|
|
73039
|
+
if (args.prune) {
|
|
73040
|
+
await pruneOrphanedBindings(
|
|
73041
|
+
client,
|
|
73042
|
+
meta3.app_id,
|
|
73043
|
+
orphanedBindings(called, liveAfter),
|
|
73044
|
+
called.dynamic
|
|
73045
|
+
);
|
|
73046
|
+
} else {
|
|
73047
|
+
warnAboutOrphanedBindings(called, liveAfter);
|
|
73048
|
+
}
|
|
73035
73049
|
}
|
|
73036
73050
|
} catch (err2) {
|
|
73037
73051
|
const e = err2;
|
|
@@ -73318,22 +73332,35 @@ function warnAboutOrphanedBindings(called, live) {
|
|
|
73318
73332
|
` + lines.join("\n") + (called.dynamic.length > 0 ? `
|
|
73319
73333
|
|
|
73320
73334
|
This app computes an alias at runtime, so one of these may be called after
|
|
73321
|
-
all \u2014
|
|
73322
|
-
literal
|
|
73335
|
+
all \u2014 and \`--prune\` therefore leaves them ALL in place. Make those call
|
|
73336
|
+
sites literal to prune them.` : `
|
|
73323
73337
|
|
|
73324
|
-
|
|
73338
|
+
Nothing is removed automatically: a binding is also reachable by
|
|
73339
|
+
\`lotics app workflow run\` and from chat, neither of which leaves a call
|
|
73340
|
+
site to find. If these really are dead: lotics app deploy --prune`)
|
|
73325
73341
|
);
|
|
73326
73342
|
return lines.length;
|
|
73327
73343
|
}
|
|
73328
73344
|
async function pruneOrphanedBindings(client, appId, orphans, dynamic) {
|
|
73329
73345
|
const targets = [
|
|
73330
|
-
...orphans.queries.map((alias) => ({
|
|
73346
|
+
...orphans.queries.map((alias) => ({
|
|
73347
|
+
tool: "remove_app_query",
|
|
73348
|
+
alias,
|
|
73349
|
+
label: `query ${alias}`,
|
|
73350
|
+
restore: `lotics app query set ${alias}`
|
|
73351
|
+
})),
|
|
73331
73352
|
...orphans.workflows.map((alias) => ({
|
|
73332
73353
|
tool: "remove_app_workflow",
|
|
73333
73354
|
alias,
|
|
73334
|
-
label: `workflow ${alias}
|
|
73355
|
+
label: `workflow ${alias}`,
|
|
73356
|
+
restore: `lotics app workflow set ${alias}`
|
|
73335
73357
|
})),
|
|
73336
|
-
...orphans.agents.map((alias) => ({
|
|
73358
|
+
...orphans.agents.map((alias) => ({
|
|
73359
|
+
tool: "remove_app_agent",
|
|
73360
|
+
alias,
|
|
73361
|
+
label: `agent ${alias}`,
|
|
73362
|
+
restore: `lotics app agent set ${alias}`
|
|
73363
|
+
}))
|
|
73337
73364
|
];
|
|
73338
73365
|
if (targets.length === 0) return 0;
|
|
73339
73366
|
if (dynamic.length > 0) {
|
|
@@ -73353,7 +73380,7 @@ async function pruneOrphanedBindings(client, appId, orphans, dynamic) {
|
|
|
73353
73380
|
console.error(` \u2717 could not unbind ${target.label} \u2014 ${res.error}`);
|
|
73354
73381
|
continue;
|
|
73355
73382
|
}
|
|
73356
|
-
console.error(` \u2713 unbound ${target.label}`);
|
|
73383
|
+
console.error(` \u2713 unbound ${target.label} \u2014 restore: ${target.restore}`);
|
|
73357
73384
|
}
|
|
73358
73385
|
return failed;
|
|
73359
73386
|
}
|
|
@@ -74121,6 +74148,7 @@ function parseArgs(argv) {
|
|
|
74121
74148
|
yes: false,
|
|
74122
74149
|
printCreated: false,
|
|
74123
74150
|
cleanup: false,
|
|
74151
|
+
prune: false,
|
|
74124
74152
|
version: false,
|
|
74125
74153
|
help: false
|
|
74126
74154
|
};
|
|
@@ -74200,6 +74228,9 @@ function parseArgs(argv) {
|
|
|
74200
74228
|
case "--cleanup":
|
|
74201
74229
|
flags.cleanup = true;
|
|
74202
74230
|
break;
|
|
74231
|
+
case "--prune":
|
|
74232
|
+
flags.prune = true;
|
|
74233
|
+
break;
|
|
74203
74234
|
case "--version":
|
|
74204
74235
|
case "-v":
|
|
74205
74236
|
flags.version = true;
|
|
@@ -94322,6 +94353,90 @@ var DependencyGraph = class {
|
|
|
94322
94353
|
}
|
|
94323
94354
|
return result;
|
|
94324
94355
|
}
|
|
94356
|
+
/**
|
|
94357
|
+
* Every cell that participates in a circular reference, in one pass.
|
|
94358
|
+
*
|
|
94359
|
+
* `detectCycle` answers the same question for ONE cell, which is what an edit
|
|
94360
|
+
* needs; asking it per cell to check a whole workbook is worse than quadratic
|
|
94361
|
+
* — 512 ms at 1,000 formula cells and it does not finish at 10,000, so a batch
|
|
94362
|
+
* recompute would hang. This is Tarjan's strongly-connected-components
|
|
94363
|
+
* algorithm over the same precedents graph: O(V+E), one pass, every cycle at
|
|
94364
|
+
* once. A cell is circular if it sits in an SCC larger than one, or if it
|
|
94365
|
+
* references itself directly.
|
|
94366
|
+
*
|
|
94367
|
+
* Iterative rather than recursive on purpose: a cascading column is an
|
|
94368
|
+
* ordinary shape and a 10,000-deep chain would overflow the stack.
|
|
94369
|
+
*
|
|
94370
|
+
* **Coarse nodes are deliberately not expanded.** A whole-column node stands
|
|
94371
|
+
* for a range that may have been over-approximated (a bounded `A1:A15000`
|
|
94372
|
+
* collapses to all of column A), so following it could report a cycle that
|
|
94373
|
+
* does not exist — and the one thing worse than a wrong number here is
|
|
94374
|
+
* `#CIRC!` written into a correct customer document. The cost is that
|
|
94375
|
+
* `A1 = SUM(A:A)` is not caught in a batch recompute; it still is on an edit,
|
|
94376
|
+
* where `detectCycle` compares against the origin's own coarse nodes.
|
|
94377
|
+
*/
|
|
94378
|
+
findCycles() {
|
|
94379
|
+
const circular = /* @__PURE__ */ new Set();
|
|
94380
|
+
let nextIndex = 0;
|
|
94381
|
+
const index = /* @__PURE__ */ new Map();
|
|
94382
|
+
const lowLink = /* @__PURE__ */ new Map();
|
|
94383
|
+
const onStack = /* @__PURE__ */ new Set();
|
|
94384
|
+
const stack = [];
|
|
94385
|
+
for (const root of this.precedents.keys()) {
|
|
94386
|
+
if (index.has(root)) continue;
|
|
94387
|
+
const frames = [{ node: root, prec: this.exactPrecedents(root), i: 0 }];
|
|
94388
|
+
index.set(root, nextIndex);
|
|
94389
|
+
lowLink.set(root, nextIndex);
|
|
94390
|
+
nextIndex++;
|
|
94391
|
+
stack.push(root);
|
|
94392
|
+
onStack.add(root);
|
|
94393
|
+
while (frames.length > 0) {
|
|
94394
|
+
const frame = frames[frames.length - 1];
|
|
94395
|
+
if (frame.i < frame.prec.length) {
|
|
94396
|
+
const next = frame.prec[frame.i++];
|
|
94397
|
+
if (next === frame.node) {
|
|
94398
|
+
circular.add(next);
|
|
94399
|
+
continue;
|
|
94400
|
+
}
|
|
94401
|
+
if (!index.has(next)) {
|
|
94402
|
+
index.set(next, nextIndex);
|
|
94403
|
+
lowLink.set(next, nextIndex);
|
|
94404
|
+
nextIndex++;
|
|
94405
|
+
stack.push(next);
|
|
94406
|
+
onStack.add(next);
|
|
94407
|
+
frames.push({ node: next, prec: this.exactPrecedents(next), i: 0 });
|
|
94408
|
+
} else if (onStack.has(next)) {
|
|
94409
|
+
lowLink.set(frame.node, Math.min(lowLink.get(frame.node), index.get(next)));
|
|
94410
|
+
}
|
|
94411
|
+
continue;
|
|
94412
|
+
}
|
|
94413
|
+
frames.pop();
|
|
94414
|
+
const parent = frames[frames.length - 1];
|
|
94415
|
+
if (parent) {
|
|
94416
|
+
lowLink.set(parent.node, Math.min(lowLink.get(parent.node), lowLink.get(frame.node)));
|
|
94417
|
+
}
|
|
94418
|
+
if (lowLink.get(frame.node) === index.get(frame.node)) {
|
|
94419
|
+
const component = [];
|
|
94420
|
+
for (; ; ) {
|
|
94421
|
+
const member = stack.pop();
|
|
94422
|
+
onStack.delete(member);
|
|
94423
|
+
component.push(member);
|
|
94424
|
+
if (member === frame.node) break;
|
|
94425
|
+
}
|
|
94426
|
+
if (component.length > 1) for (const member of component) circular.add(member);
|
|
94427
|
+
}
|
|
94428
|
+
}
|
|
94429
|
+
}
|
|
94430
|
+
return circular;
|
|
94431
|
+
}
|
|
94432
|
+
/** Precedents that are real cells — coarse nodes are skipped (see `findCycles`). */
|
|
94433
|
+
exactPrecedents(cell) {
|
|
94434
|
+
const prec = this.precedents.get(cell);
|
|
94435
|
+
if (!prec) return [];
|
|
94436
|
+
const out = [];
|
|
94437
|
+
for (const p of prec) if (!isCoarseKey(p)) out.push(p);
|
|
94438
|
+
return out;
|
|
94439
|
+
}
|
|
94325
94440
|
/** Detect if `cell` appears in its own transitive precedent chain (circular reference). */
|
|
94326
94441
|
detectCycle(cell) {
|
|
94327
94442
|
const visited = /* @__PURE__ */ new Set();
|
|
@@ -94447,12 +94562,17 @@ function parseTableRange(ref2) {
|
|
|
94447
94562
|
};
|
|
94448
94563
|
}
|
|
94449
94564
|
|
|
94450
|
-
// ../xlsx/src/
|
|
94565
|
+
// ../xlsx/src/blank_semantics.ts
|
|
94451
94566
|
var import_operators = __toESM(require_operators(), 1);
|
|
94567
|
+
var import_helpers = __toESM(require_helpers(), 1);
|
|
94452
94568
|
var patched = false;
|
|
94453
94569
|
function applyExcelBlankSemantics() {
|
|
94454
94570
|
if (patched) return;
|
|
94455
94571
|
patched = true;
|
|
94572
|
+
patchComparison();
|
|
94573
|
+
patchArgumentCoercion();
|
|
94574
|
+
}
|
|
94575
|
+
function patchComparison() {
|
|
94456
94576
|
const original = import_operators.Infix.compareOp;
|
|
94457
94577
|
import_operators.Infix.compareOp = (value1, infix, value2, isArray1, isArray22) => {
|
|
94458
94578
|
if (value1 == null && typeof value2 === "string") value1 = "";
|
|
@@ -94460,8 +94580,27 @@ function applyExcelBlankSemantics() {
|
|
|
94460
94580
|
return original(value1, infix, value2, isArray1, isArray22);
|
|
94461
94581
|
};
|
|
94462
94582
|
}
|
|
94583
|
+
function isBlankCell(param) {
|
|
94584
|
+
if (typeof param !== "object" || param === null || Array.isArray(param)) return false;
|
|
94585
|
+
if (!("value" in param) || param.value != null) return false;
|
|
94586
|
+
return !("omitted" in param) || !param.omitted;
|
|
94587
|
+
}
|
|
94588
|
+
function patchArgumentCoercion() {
|
|
94589
|
+
const original = import_helpers.FormulaHelpers.accept.bind(import_helpers.FormulaHelpers);
|
|
94590
|
+
import_helpers.FormulaHelpers.accept = (param, type, defValue, flat, allowSingleValue) => {
|
|
94591
|
+
const want = Array.isArray(type) ? type[0] : type;
|
|
94592
|
+
if (isBlankCell(param)) {
|
|
94593
|
+
if (want === import_helpers.Types.STRING) return "";
|
|
94594
|
+
if (want === import_helpers.Types.NUMBER || want === import_helpers.Types.NUMBER_NO_BOOLEAN) return 0;
|
|
94595
|
+
if (want === import_helpers.Types.BOOLEAN) return false;
|
|
94596
|
+
if (want == null) return null;
|
|
94597
|
+
}
|
|
94598
|
+
return original(param, want, defValue, flat, allowSingleValue);
|
|
94599
|
+
};
|
|
94600
|
+
}
|
|
94463
94601
|
|
|
94464
94602
|
// ../xlsx/src/formula_engine.ts
|
|
94603
|
+
var import_helpers2 = __toESM(require_helpers(), 1);
|
|
94465
94604
|
var unwrapArg = (a) => a !== null && typeof a === "object" && "value" in a ? a.value : a;
|
|
94466
94605
|
function adaptFormulajs(fn) {
|
|
94467
94606
|
return (...args) => fn(...args.map(unwrapArg));
|
|
@@ -94520,20 +94659,84 @@ var FormulaEngine = class _FormulaEngine {
|
|
|
94520
94659
|
* cannot draw, refuse what you cannot read.
|
|
94521
94660
|
*/
|
|
94522
94661
|
this.unreadableFormulas = /* @__PURE__ */ new Set();
|
|
94662
|
+
/**
|
|
94663
|
+
* Cells found to be circular by the batch pass, held so evaluation refuses
|
|
94664
|
+
* them.
|
|
94665
|
+
*
|
|
94666
|
+
* Leaving them out of the seed list is NOT enough: `getRecalcOrder` pulls in
|
|
94667
|
+
* transitive dependents, so any cycle fed by another FORMULA gets evaluated
|
|
94668
|
+
* anyway and overwrites its `#CIRC!` with the parser's generic `#ERROR!` —
|
|
94669
|
+
* which sends a reader hunting a broken formula instead of the cycle that is
|
|
94670
|
+
* actually there. A cycle fed by a formula rather than a constant is the
|
|
94671
|
+
* ordinary case, so the guard has to sit at evaluation.
|
|
94672
|
+
*/
|
|
94673
|
+
this.circularFormulas = /* @__PURE__ */ new Set();
|
|
94523
94674
|
applyExcelBlankSemantics();
|
|
94524
94675
|
this.workbook = workbook;
|
|
94525
94676
|
this.parser = new import_fast_formula_parser.default({
|
|
94526
94677
|
onCell: (ref2) => this.resolveCell(ref2),
|
|
94527
94678
|
onRange: (ref2) => this.resolveRange(ref2),
|
|
94528
|
-
onVariable: (name2) => this.resolveVariable(name2),
|
|
94679
|
+
onVariable: (name2, sheet) => this.resolveVariable(name2, sheet),
|
|
94529
94680
|
functions: formulajsBridge(),
|
|
94530
94681
|
// A handful of names (CHOOSE among them) are dispatched through the
|
|
94531
94682
|
// context-aware path, where a plain `functions` entry is never consulted.
|
|
94532
94683
|
// Register there too, dropping the context argument the parser prepends —
|
|
94533
94684
|
// formulajs has no use for it.
|
|
94534
|
-
functionsNeedContext:
|
|
94685
|
+
functionsNeedContext: {
|
|
94686
|
+
...formulajsBridgeWithContext(),
|
|
94687
|
+
// INDEX is the one bridged function the parser hands a RAW REFERENCE
|
|
94688
|
+
// rather than values, because it sits in the parser's
|
|
94689
|
+
// `funsNeedContextAndNoDataRetrieve` set. The generic bridge unwraps an
|
|
94690
|
+
// argument by reading `.value`; a `{ref}` has none, so the descriptor
|
|
94691
|
+
// itself reached formulajs, which wants a 2D array — every INDEX in
|
|
94692
|
+
// every workbook returned `#VALUE!`. One real file lost 10 of its 13
|
|
94693
|
+
// formulas to it, 8 of them cascading from 2 roots.
|
|
94694
|
+
//
|
|
94695
|
+
// It resolves here rather than in the bridge because the bridge is
|
|
94696
|
+
// memoized per PROCESS and knows no workbook, so it structurally cannot
|
|
94697
|
+
// resolve a reference. `lazy_ref_arguments.test.ts` pins that INDEX is
|
|
94698
|
+
// still the only name in that position — if upstream ever adds another,
|
|
94699
|
+
// that test fails instead of the function silently returning `#VALUE!`.
|
|
94700
|
+
INDEX: (_context, ref2, ...rest2) => INDEX(
|
|
94701
|
+
this.resolveRefAsGrid(ref2),
|
|
94702
|
+
...rest2.map((a) => this.resolveRefOrValue(a))
|
|
94703
|
+
),
|
|
94704
|
+
// IF sits in that same `noDataRetrieve` set, and the parser's own
|
|
94705
|
+
// implementation forgets to resolve the one argument that needs it:
|
|
94706
|
+
// the condition arrives as a raw `{ref}` and is handed straight to
|
|
94707
|
+
// `accept(_, Types.BOOLEAN)`, which has no branch for a reference and
|
|
94708
|
+
// returns the descriptor unchanged. A descriptor is an object, and
|
|
94709
|
+
// every object is truthy — so `IF(<any cell>, a, b)` returns `a`
|
|
94710
|
+
// unconditionally, including when the cell holds 0, FALSE, or nothing.
|
|
94711
|
+
// Verified against the unconfigured library, so it is upstream's bug
|
|
94712
|
+
// and not a consequence of this engine's configuration.
|
|
94713
|
+
//
|
|
94714
|
+
// It stays quiet in most workbooks because the common form is
|
|
94715
|
+
// `IF(A1="", …)` — a comparison, which evaluates to a real boolean
|
|
94716
|
+
// before IF ever sees it. Only a bare cell reference as the condition
|
|
94717
|
+
// is affected, which is exactly how a boolean or checkbox column gets
|
|
94718
|
+
// tested.
|
|
94719
|
+
//
|
|
94720
|
+
// The condition is coerced by handing the resolved value back to the
|
|
94721
|
+
// library's own `accept`, so blank/0/text/error all keep Excel's
|
|
94722
|
+
// answers rather than a second opinion invented here.
|
|
94723
|
+
IF: (_context, condition, whenTrue, whenFalse) => {
|
|
94724
|
+
const resolved = this.resolveRefOrValue(condition);
|
|
94725
|
+
const test = import_helpers2.FormulaHelpers.accept(
|
|
94726
|
+
{ value: resolved, isArray: Array.isArray(resolved) },
|
|
94727
|
+
import_helpers2.Types.BOOLEAN
|
|
94728
|
+
);
|
|
94729
|
+
const branch = test ? whenTrue : whenFalse;
|
|
94730
|
+
if (branch === null) return 0;
|
|
94731
|
+
if (branch === void 0) return false;
|
|
94732
|
+
const taken = this.resolveRefOrValue(branch);
|
|
94733
|
+
return taken ?? 0;
|
|
94734
|
+
}
|
|
94735
|
+
}
|
|
94736
|
+
});
|
|
94737
|
+
this.depParser = new import_fast_formula_parser.default.DepParser({
|
|
94738
|
+
onVariable: (name2, sheet) => this.resolveVariable(name2, sheet)
|
|
94535
94739
|
});
|
|
94536
|
-
this.depParser = new import_fast_formula_parser.default.DepParser();
|
|
94537
94740
|
}
|
|
94538
94741
|
// ===========================================================================
|
|
94539
94742
|
// Initialization — build graph and evaluate missing values
|
|
@@ -94577,12 +94780,14 @@ var FormulaEngine = class _FormulaEngine {
|
|
|
94577
94780
|
* show stale values.
|
|
94578
94781
|
*/
|
|
94579
94782
|
evaluateAll() {
|
|
94783
|
+
this.circularFormulas = this.graph.findCycles();
|
|
94784
|
+
for (const key of this.circularFormulas) this.setCellError(key, "#CIRC!");
|
|
94580
94785
|
const all = [];
|
|
94581
94786
|
for (const sheet of this.workbook.sheets) {
|
|
94582
94787
|
for (const [ref2, cell] of sheet.cells) {
|
|
94583
|
-
if (cell.formula)
|
|
94584
|
-
|
|
94585
|
-
|
|
94788
|
+
if (!cell.formula) continue;
|
|
94789
|
+
const key = cellKey({ sheet: sheet.name, ref: ref2 });
|
|
94790
|
+
if (!this.circularFormulas.has(key)) all.push(key);
|
|
94586
94791
|
}
|
|
94587
94792
|
}
|
|
94588
94793
|
this.evaluateSet(all);
|
|
@@ -94606,6 +94811,7 @@ var FormulaEngine = class _FormulaEngine {
|
|
|
94606
94811
|
const { deps, readable } = this.analyzeFormula(formula, sheetName);
|
|
94607
94812
|
this.graph.setDependencies(key, deps);
|
|
94608
94813
|
this.unreadableFormulas.delete(key);
|
|
94814
|
+
this.circularFormulas.delete(key);
|
|
94609
94815
|
if (!readable) {
|
|
94610
94816
|
this.setCellError(key, "#ERROR!");
|
|
94611
94817
|
return;
|
|
@@ -94619,6 +94825,7 @@ var FormulaEngine = class _FormulaEngine {
|
|
|
94619
94825
|
} else {
|
|
94620
94826
|
this.graph.removeCell(key);
|
|
94621
94827
|
this.unreadableFormulas.delete(key);
|
|
94828
|
+
this.circularFormulas.delete(key);
|
|
94622
94829
|
}
|
|
94623
94830
|
const order = this.graph.getRecalcOrder([key]);
|
|
94624
94831
|
for (const depKey of order) {
|
|
@@ -94636,6 +94843,7 @@ var FormulaEngine = class _FormulaEngine {
|
|
|
94636
94843
|
/** Evaluate a single formula cell and update its value. */
|
|
94637
94844
|
evaluateCell(key) {
|
|
94638
94845
|
if (this.unreadableFormulas.has(key)) return;
|
|
94846
|
+
if (this.circularFormulas.has(key)) return;
|
|
94639
94847
|
const { sheet: sheetName, ref: ref2 } = parseCellKey(key);
|
|
94640
94848
|
const sheetIndex = this.workbook.sheets.findIndex((s) => s.name === sheetName);
|
|
94641
94849
|
if (sheetIndex < 0) return;
|
|
@@ -94646,11 +94854,7 @@ var FormulaEngine = class _FormulaEngine {
|
|
|
94646
94854
|
if (!rc) return;
|
|
94647
94855
|
const expandedFormula = expandStructuredRefs(cell.formula, sheet.tables, rc.row);
|
|
94648
94856
|
try {
|
|
94649
|
-
const raw = this.
|
|
94650
|
-
sheet: sheetName,
|
|
94651
|
-
row: rc.row,
|
|
94652
|
-
col: rc.col
|
|
94653
|
-
});
|
|
94857
|
+
const raw = this.parse(expandedFormula, sheetName, rc.row, rc.col);
|
|
94654
94858
|
const result = normalizeResult(raw);
|
|
94655
94859
|
cell.value = result.value;
|
|
94656
94860
|
cell.error = result.error;
|
|
@@ -94735,6 +94939,10 @@ var FormulaEngine = class _FormulaEngine {
|
|
|
94735
94939
|
}
|
|
94736
94940
|
return { deps: refs, readable: true };
|
|
94737
94941
|
}
|
|
94942
|
+
/** Cells in a circular reference, by key. Exposed so the cost can be measured. */
|
|
94943
|
+
graphCycles() {
|
|
94944
|
+
return this.graph.findCycles();
|
|
94945
|
+
}
|
|
94738
94946
|
/** Formula cells the parser could not read, by key. Read by the recompute report. */
|
|
94739
94947
|
unreadable() {
|
|
94740
94948
|
return this.unreadableFormulas;
|
|
@@ -94743,13 +94951,13 @@ var FormulaEngine = class _FormulaEngine {
|
|
|
94743
94951
|
// Cell value resolution callbacks
|
|
94744
94952
|
// ===========================================================================
|
|
94745
94953
|
resolveCell(ref2) {
|
|
94746
|
-
const sheetName = ref2.sheet ?? this.workbook.sheets[0]?.name ?? "Sheet1";
|
|
94954
|
+
const sheetName = ref2.sheet ?? this.evaluatingSheet ?? this.workbook.sheets[0]?.name ?? "Sheet1";
|
|
94747
94955
|
const sheet = this.workbook.sheets.find((s) => s.name === sheetName);
|
|
94748
94956
|
if (!sheet) return null;
|
|
94749
94957
|
const cellRef = rowColToRef(ref2.row, ref2.col);
|
|
94750
94958
|
const cell = sheet.getCell(cellRef);
|
|
94751
94959
|
if (!cell) return null;
|
|
94752
|
-
if (cell.error)
|
|
94960
|
+
if (cell.error) return new import_fast_formula_parser.default.FormulaError(cell.error);
|
|
94753
94961
|
return cell.value;
|
|
94754
94962
|
}
|
|
94755
94963
|
static {
|
|
@@ -94759,8 +94967,45 @@ var FormulaEngine = class _FormulaEngine {
|
|
|
94759
94967
|
*/
|
|
94760
94968
|
this.OVERSIZED_RANGE_CELLS = 1e5;
|
|
94761
94969
|
}
|
|
94970
|
+
/**
|
|
94971
|
+
* Resolve a parser reference descriptor to the value behind it — a 2D grid
|
|
94972
|
+
* for a range, a scalar for a single cell.
|
|
94973
|
+
*
|
|
94974
|
+
* The descriptor shapes are exactly what `resolveRange` and `resolveCell`
|
|
94975
|
+
* already take (`{from, to, sheet?}` and `{row, col, sheet?}`), so this reuses
|
|
94976
|
+
* them rather than re-deriving anything, and the whole-column clamp comes
|
|
94977
|
+
* along unchanged.
|
|
94978
|
+
*
|
|
94979
|
+
* Needed for EVERY argument, not just the array: a function in the parser's
|
|
94980
|
+
* `noDataRetrieve` set gets none of its arguments materialized, so
|
|
94981
|
+
* `INDEX(range, A1, A2)` — the form the real workbook used — arrives with the
|
|
94982
|
+
* row and column as references too.
|
|
94983
|
+
*/
|
|
94984
|
+
resolveRefOrValue(arg) {
|
|
94985
|
+
const ref2 = arg?.ref;
|
|
94986
|
+
if (ref2 && typeof ref2 === "object") {
|
|
94987
|
+
if ("from" in ref2 && "to" in ref2) {
|
|
94988
|
+
return this.resolveRange(ref2);
|
|
94989
|
+
}
|
|
94990
|
+
if ("row" in ref2 && "col" in ref2) {
|
|
94991
|
+
return this.resolveCell(ref2);
|
|
94992
|
+
}
|
|
94993
|
+
}
|
|
94994
|
+
return unwrapArg(arg);
|
|
94995
|
+
}
|
|
94996
|
+
/**
|
|
94997
|
+
* The same, forced to the 2D shape an array argument must have.
|
|
94998
|
+
*
|
|
94999
|
+
* Deliberately not `CellValue[][]`: a cell holding an error resolves to a
|
|
95000
|
+
* `FormulaError`, which the receiving function is expected to propagate. A
|
|
95001
|
+
* cast narrowing that away would be a false promise, not a safe one.
|
|
95002
|
+
*/
|
|
95003
|
+
resolveRefAsGrid(arg) {
|
|
95004
|
+
const value2 = this.resolveRefOrValue(arg);
|
|
95005
|
+
return Array.isArray(value2) ? value2 : [[value2]];
|
|
95006
|
+
}
|
|
94762
95007
|
resolveRange(ref2) {
|
|
94763
|
-
const sheetName = ref2.sheet ?? this.workbook.sheets[0]?.name ?? "Sheet1";
|
|
95008
|
+
const sheetName = ref2.sheet ?? this.evaluatingSheet ?? this.workbook.sheets[0]?.name ?? "Sheet1";
|
|
94764
95009
|
const sheet = this.workbook.sheets.find((s) => s.name === sheetName);
|
|
94765
95010
|
if (!sheet) return [[]];
|
|
94766
95011
|
let lastRow = ref2.to.row;
|
|
@@ -94783,34 +95028,42 @@ var FormulaEngine = class _FormulaEngine {
|
|
|
94783
95028
|
// ===========================================================================
|
|
94784
95029
|
// Named range resolution
|
|
94785
95030
|
// ===========================================================================
|
|
94786
|
-
|
|
95031
|
+
/**
|
|
95032
|
+
* Resolve a defined name to the REFERENCE it stands for.
|
|
95033
|
+
*
|
|
95034
|
+
* A reference, not a value: the parser wraps whatever comes back as
|
|
95035
|
+
* `{ref: …}` and materializes it itself through `onCell`/`onRange`. Returning
|
|
95036
|
+
* the resolved value instead — which this used to do — produced `{ref: 11}`,
|
|
95037
|
+
* whose `.row` is undefined, so **every** formula naming a range answered
|
|
95038
|
+
* `#VALUE!`. Same value-vs-reference confusion as INDEX and IF above, in the
|
|
95039
|
+
* one callback where the library documents the contract the other way round.
|
|
95040
|
+
*
|
|
95041
|
+
* Returning `null` is the "no such name" signal the parser turns into
|
|
95042
|
+
* `#NAME?`, which is also Excel's answer for a name that resolves to a
|
|
95043
|
+
* constant or a formula rather than a reference — unsupported, and loud.
|
|
95044
|
+
*
|
|
95045
|
+
* `sheetName` is the position the parser is evaluating at, which is what an
|
|
95046
|
+
* unqualified expression is relative to.
|
|
95047
|
+
*/
|
|
95048
|
+
resolveVariable(name2, sheetName) {
|
|
94787
95049
|
const rangeExpr = this.workbook.namedRanges.get(name2);
|
|
94788
95050
|
if (rangeExpr === void 0) return null;
|
|
94789
95051
|
const cleaned = rangeExpr.replace(/\$/g, "");
|
|
94790
95052
|
const sheetMatch = cleaned.match(/^(.+?)!(.+)$/);
|
|
94791
|
-
const
|
|
95053
|
+
const sheet = sheetMatch ? sheetMatch[1].replace(/^'|'$/g, "") : sheetName;
|
|
94792
95054
|
const rangeStr = sheetMatch ? sheetMatch[2] : cleaned;
|
|
94793
|
-
|
|
94794
|
-
if (!sheet) return null;
|
|
95055
|
+
if (!this.workbook.sheets.some((s) => s.name === sheet)) return null;
|
|
94795
95056
|
const rangeMatch = rangeStr.match(/^([A-Z]+)(\d+):([A-Z]+)(\d+)$/);
|
|
94796
95057
|
if (rangeMatch) {
|
|
94797
|
-
|
|
94798
|
-
|
|
94799
|
-
|
|
94800
|
-
|
|
94801
|
-
|
|
94802
|
-
from: { row: fromRow, col: fromCol },
|
|
94803
|
-
to: { row: toRow, col: toCol },
|
|
94804
|
-
sheet: sheetName
|
|
94805
|
-
});
|
|
95058
|
+
return {
|
|
95059
|
+
from: { row: parseInt(rangeMatch[2], 10), col: colLettersToNum(rangeMatch[1]) },
|
|
95060
|
+
to: { row: parseInt(rangeMatch[4], 10), col: colLettersToNum(rangeMatch[3]) },
|
|
95061
|
+
sheet
|
|
95062
|
+
};
|
|
94806
95063
|
}
|
|
94807
95064
|
const cellMatch = rangeStr.match(/^([A-Z]+)(\d+)$/);
|
|
94808
95065
|
if (cellMatch) {
|
|
94809
|
-
return
|
|
94810
|
-
row: parseInt(cellMatch[2], 10),
|
|
94811
|
-
col: colLettersToNum(cellMatch[1]),
|
|
94812
|
-
sheet: sheetName
|
|
94813
|
-
});
|
|
95066
|
+
return { row: parseInt(cellMatch[2], 10), col: colLettersToNum(cellMatch[1]), sheet };
|
|
94814
95067
|
}
|
|
94815
95068
|
return null;
|
|
94816
95069
|
}
|
|
@@ -94820,12 +95073,33 @@ var FormulaEngine = class _FormulaEngine {
|
|
|
94820
95073
|
/** Evaluate an arbitrary formula expression. Used by CF expression rules. */
|
|
94821
95074
|
evaluateExpression(formula, sheetName, row, col) {
|
|
94822
95075
|
try {
|
|
94823
|
-
return this.
|
|
95076
|
+
return this.parse(formula, sheetName, row, col);
|
|
94824
95077
|
} catch (err2) {
|
|
94825
95078
|
if (isFormulaError2(err2)) return null;
|
|
94826
95079
|
throw err2;
|
|
94827
95080
|
}
|
|
94828
95081
|
}
|
|
95082
|
+
/**
|
|
95083
|
+
* The one place a formula is handed to the parser, so the sheet it belongs to
|
|
95084
|
+
* is recorded for the duration.
|
|
95085
|
+
*
|
|
95086
|
+
* An UNQUALIFIED reference means "this formula's sheet", and for the ordinary
|
|
95087
|
+
* `onCell`/`onRange` path the parser fills that in from the position below.
|
|
95088
|
+
* The functions in its `noDataRetrieve` set are the exception: their arguments
|
|
95089
|
+
* arrive as raw descriptors that were never resolved, and those carry only
|
|
95090
|
+
* `{address, row, col}` — no sheet at all. Resolving one against the first
|
|
95091
|
+
* sheet in the workbook reads a different sheet's cell, silently, and a blank
|
|
95092
|
+
* there is indistinguishable from a real empty one.
|
|
95093
|
+
*/
|
|
95094
|
+
parse(formula, sheetName, row, col) {
|
|
95095
|
+
const previous = this.evaluatingSheet;
|
|
95096
|
+
this.evaluatingSheet = sheetName;
|
|
95097
|
+
try {
|
|
95098
|
+
return this.parser.parse(formula, { sheet: sheetName, row, col });
|
|
95099
|
+
} finally {
|
|
95100
|
+
this.evaluatingSheet = previous;
|
|
95101
|
+
}
|
|
95102
|
+
}
|
|
94829
95103
|
/** Get the dependency graph (for testing/debugging). */
|
|
94830
95104
|
get deps() {
|
|
94831
95105
|
return this.graph;
|
|
@@ -94835,7 +95109,7 @@ function isFormulaError2(v) {
|
|
|
94835
95109
|
return v instanceof Error && typeof v.name === "string" && v.name.startsWith("#");
|
|
94836
95110
|
}
|
|
94837
95111
|
function normalizeResult(result) {
|
|
94838
|
-
if (result === null || result === void 0) return { value:
|
|
95112
|
+
if (result === null || result === void 0) return { value: 0 };
|
|
94839
95113
|
if (typeof result === "number") return { value: result };
|
|
94840
95114
|
if (typeof result === "boolean") return { value: result };
|
|
94841
95115
|
if (typeof result === "string") return { value: result };
|
|
@@ -94872,7 +95146,7 @@ function collectRecomputeReport(workbook, unreadable) {
|
|
|
94872
95146
|
continue;
|
|
94873
95147
|
}
|
|
94874
95148
|
if (cell.value === null) {
|
|
94875
|
-
unevaluated.push({ sheet: sheet.name, ref: ref2, formula: cell.formula, error: cell.error ?? "#
|
|
95149
|
+
unevaluated.push({ sheet: sheet.name, ref: ref2, formula: cell.formula, error: cell.error ?? "#NO_VALUE!" });
|
|
94876
95150
|
}
|
|
94877
95151
|
}
|
|
94878
95152
|
}
|
|
@@ -103013,7 +103287,10 @@ Available workspaces:`);
|
|
|
103013
103287
|
return;
|
|
103014
103288
|
}
|
|
103015
103289
|
if (subcommand === "deploy") {
|
|
103016
|
-
await appDeploy(client, {
|
|
103290
|
+
await appDeploy(client, {
|
|
103291
|
+
message: (flags.message ?? toolArgs)?.trim() || void 0,
|
|
103292
|
+
prune: flags.prune
|
|
103293
|
+
});
|
|
103017
103294
|
return;
|
|
103018
103295
|
}
|
|
103019
103296
|
if (subcommand === "subdomain") {
|