@lotics/cli 0.143.3 → 0.145.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.
@@ -2451,7 +2451,7 @@
2451
2451
  "../../node_modules/fast-formula-parser/formulas/helpers.js"(exports2, module2) {
2452
2452
  var FormulaError = require_error();
2453
2453
  var Collection = require_collection();
2454
- var Types = {
2454
+ var Types3 = {
2455
2455
  NUMBER: 0,
2456
2456
  ARRAY: 1,
2457
2457
  BOOLEAN: 2,
@@ -2465,16 +2465,16 @@
2465
2465
  };
2466
2466
  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];
2467
2467
  var ReversedTypes = {};
2468
- Object.keys(Types).forEach((key) => {
2469
- ReversedTypes[Types[key]] = key;
2468
+ Object.keys(Types3).forEach((key) => {
2469
+ ReversedTypes[Types3[key]] = key;
2470
2470
  });
2471
- var FormulaHelpers = class {
2471
+ var FormulaHelpers3 = class {
2472
2472
  constructor() {
2473
- this.Types = Types;
2473
+ this.Types = Types3;
2474
2474
  this.type2Number = {
2475
- number: Types.NUMBER,
2476
- boolean: Types.BOOLEAN,
2477
- string: Types.STRING,
2475
+ number: Types3.NUMBER,
2476
+ boolean: Types3.BOOLEAN,
2477
+ string: Types3.STRING,
2478
2478
  object: -1
2479
2479
  };
2480
2480
  }
@@ -2557,7 +2557,7 @@
2557
2557
  if (params.length < minSize)
2558
2558
  throw FormulaError.ARG_MISSING([valueType]);
2559
2559
  if (defValue == null) {
2560
- defValue = valueType === Types.NUMBER ? 0 : valueType == null ? null : "";
2560
+ defValue = valueType === Types3.NUMBER ? 0 : valueType == null ? null : "";
2561
2561
  }
2562
2562
  params.forEach((param) => {
2563
2563
  const { isCellRef, isRangeRef, isArray: isArray2 } = param;
@@ -2624,7 +2624,7 @@
2624
2624
  return param;
2625
2625
  if (param instanceof FormulaError)
2626
2626
  throw param;
2627
- if (type === Types.ARRAY) {
2627
+ if (type === Types3.ARRAY) {
2628
2628
  if (Array.isArray(param)) {
2629
2629
  return flat ? this.flattenDeep(param) : param;
2630
2630
  } else if (param instanceof Collection) {
@@ -2633,26 +2633,26 @@
2633
2633
  return flat ? [param] : [[param]];
2634
2634
  }
2635
2635
  throw FormulaError.VALUE;
2636
- } else if (type === Types.COLLECTIONS) {
2636
+ } else if (type === Types3.COLLECTIONS) {
2637
2637
  return param;
2638
2638
  }
2639
2639
  if (isArray2) {
2640
2640
  param = param[0][0];
2641
2641
  }
2642
2642
  const paramType = this.type(param);
2643
- if (type === Types.STRING) {
2644
- if (paramType === Types.BOOLEAN)
2643
+ if (type === Types3.STRING) {
2644
+ if (paramType === Types3.BOOLEAN)
2645
2645
  param = param ? "TRUE" : "FALSE";
2646
2646
  else
2647
2647
  param = `${param}`;
2648
- } else if (type === Types.BOOLEAN) {
2649
- if (paramType === Types.STRING)
2648
+ } else if (type === Types3.BOOLEAN) {
2649
+ if (paramType === Types3.STRING)
2650
2650
  throw FormulaError.VALUE;
2651
- if (paramType === Types.NUMBER)
2651
+ if (paramType === Types3.NUMBER)
2652
2652
  param = Boolean(param);
2653
- } else if (type === Types.NUMBER) {
2653
+ } else if (type === Types3.NUMBER) {
2654
2654
  param = this.acceptNumber(param, false);
2655
- } else if (type === Types.NUMBER_NO_BOOLEAN) {
2655
+ } else if (type === Types3.NUMBER_NO_BOOLEAN) {
2656
2656
  param = this.acceptNumber(param, false, false);
2657
2657
  } else {
2658
2658
  throw FormulaError.VALUE;
@@ -2663,15 +2663,15 @@
2663
2663
  let type = this.type2Number[typeof variable];
2664
2664
  if (type === -1) {
2665
2665
  if (Array.isArray(variable))
2666
- type = Types.ARRAY;
2666
+ type = Types3.ARRAY;
2667
2667
  else if (variable.ref) {
2668
2668
  if (variable.ref.from) {
2669
- type = Types.RANGE_REF;
2669
+ type = Types3.RANGE_REF;
2670
2670
  } else {
2671
- type = Types.CELL_REF;
2671
+ type = Types3.CELL_REF;
2672
2672
  }
2673
2673
  } else if (variable instanceof Collection)
2674
- type = Types.COLLECTIONS;
2674
+ type = Types3.COLLECTIONS;
2675
2675
  }
2676
2676
  return type;
2677
2677
  }
@@ -2690,10 +2690,10 @@
2690
2690
  retrieveRanges(context, range1, range2) {
2691
2691
  range2 = Address.extend(range1, range2);
2692
2692
  range1 = this.retrieveArg(context, range1);
2693
- range1 = H.accept(range1, Types.ARRAY, void 0, false, true);
2693
+ range1 = H.accept(range1, Types3.ARRAY, void 0, false, true);
2694
2694
  if (range2 !== range1) {
2695
2695
  range2 = this.retrieveArg(context, range2);
2696
- range2 = H.accept(range2, Types.ARRAY, void 0, false, true);
2696
+ range2 = H.accept(range2, Types3.ARRAY, void 0, false, true);
2697
2697
  } else
2698
2698
  range2 = range1;
2699
2699
  return [range1, range2];
@@ -2705,7 +2705,7 @@
2705
2705
  return { value: res.val, isArray: res.isArray, ref: arg.ref };
2706
2706
  }
2707
2707
  };
2708
- var H = new FormulaHelpers();
2708
+ var H = new FormulaHelpers3();
2709
2709
  var WildCard = {
2710
2710
  /**
2711
2711
  * @param {string|*} obj
@@ -2822,7 +2822,7 @@
2822
2822
  };
2823
2823
  module2.exports = {
2824
2824
  FormulaHelpers: H,
2825
- Types,
2825
+ Types: Types3,
2826
2826
  ReversedTypes,
2827
2827
  Factorials,
2828
2828
  WildCard,
@@ -2895,8 +2895,8 @@
2895
2895
  return new FormulaError("#N/A", `Function ${functionName} has too many arguments.`);
2896
2896
  };
2897
2897
  FormulaError.ARG_MISSING = (args) => {
2898
- const { Types } = require_helpers();
2899
- return new FormulaError("#N/A", `Argument type ${args.map((arg) => Types[arg]).join(", ")} is missing.`);
2898
+ const { Types: Types3 } = require_helpers();
2899
+ return new FormulaError("#N/A", `Argument type ${args.map((arg) => Types3[arg]).join(", ")} is missing.`);
2900
2900
  };
2901
2901
  FormulaError.ERROR = (msg, details) => {
2902
2902
  return new FormulaError("#ERROR!", msg, details);
@@ -4246,8 +4246,8 @@
4246
4246
  var require_text = __commonJS({
4247
4247
  "../../node_modules/fast-formula-parser/formulas/functions/text.js"(exports2, module2) {
4248
4248
  var FormulaError = require_error();
4249
- var { FormulaHelpers, Types, WildCard } = require_helpers();
4250
- var H = FormulaHelpers;
4249
+ var { FormulaHelpers: FormulaHelpers3, Types: Types3, WildCard } = require_helpers();
4250
+ var H = FormulaHelpers3;
4251
4251
  var ssf = require_ssf();
4252
4252
  var bahttext = require_src();
4253
4253
  var charsets = {
@@ -4273,11 +4273,11 @@
4273
4273
  var toHalfWidth = (str0) => sets.reduce((str, set) => str.replace(re(set, "full"), toHalf(set)), str0);
4274
4274
  var TextFunctions = {
4275
4275
  ASC: (text) => {
4276
- text = H.accept(text, Types.STRING);
4276
+ text = H.accept(text, Types3.STRING);
4277
4277
  return toHalfWidth(text);
4278
4278
  },
4279
4279
  BAHTTEXT: (number) => {
4280
- number = H.accept(number, Types.NUMBER);
4280
+ number = H.accept(number, Types3.NUMBER);
4281
4281
  try {
4282
4282
  return bahttext(number);
4283
4283
  } catch (e) {
@@ -4286,25 +4286,25 @@ ${e.toString()}`);
4286
4286
  }
4287
4287
  },
4288
4288
  CHAR: (number) => {
4289
- number = H.accept(number, Types.NUMBER);
4289
+ number = H.accept(number, Types3.NUMBER);
4290
4290
  if (number > 255 || number < 1)
4291
4291
  throw FormulaError.VALUE;
4292
4292
  return String.fromCharCode(number);
4293
4293
  },
4294
4294
  CLEAN: (text) => {
4295
- text = H.accept(text, Types.STRING);
4295
+ text = H.accept(text, Types3.STRING);
4296
4296
  return text.replace(/[\x00-\x1F]/g, "");
4297
4297
  },
4298
4298
  CODE: (text) => {
4299
- text = H.accept(text, Types.STRING);
4299
+ text = H.accept(text, Types3.STRING);
4300
4300
  if (text.length === 0)
4301
4301
  throw FormulaError.VALUE;
4302
4302
  return text.charCodeAt(0);
4303
4303
  },
4304
4304
  CONCAT: (...params) => {
4305
4305
  let text = "";
4306
- H.flattenParams(params, Types.STRING, false, (item) => {
4307
- item = H.accept(item, Types.STRING);
4306
+ H.flattenParams(params, Types3.STRING, false, (item) => {
4307
+ item = H.accept(item, Types3.STRING);
4308
4308
  text += item;
4309
4309
  });
4310
4310
  return text;
@@ -4314,30 +4314,30 @@ ${e.toString()}`);
4314
4314
  if (params.length === 0)
4315
4315
  throw Error("CONCATENATE need at least one argument.");
4316
4316
  params.forEach((param) => {
4317
- param = H.accept(param, Types.STRING);
4317
+ param = H.accept(param, Types3.STRING);
4318
4318
  text += param;
4319
4319
  });
4320
4320
  return text;
4321
4321
  },
4322
4322
  DBCS: (text) => {
4323
- text = H.accept(text, Types.STRING);
4323
+ text = H.accept(text, Types3.STRING);
4324
4324
  return toFullWidth(text);
4325
4325
  },
4326
4326
  DOLLAR: (number, decimals) => {
4327
- number = H.accept(number, Types.NUMBER);
4328
- decimals = H.accept(decimals, Types.NUMBER, 2);
4327
+ number = H.accept(number, Types3.NUMBER);
4328
+ decimals = H.accept(decimals, Types3.NUMBER, 2);
4329
4329
  const decimalString = Array(decimals).fill("0").join("");
4330
4330
  return ssf.format(`$#,##0.${decimalString}_);($#,##0.${decimalString})`, number).trim();
4331
4331
  },
4332
4332
  EXACT: (text1, text2) => {
4333
- text1 = H.accept(text1, [Types.STRING]);
4334
- text2 = H.accept(text2, [Types.STRING]);
4333
+ text1 = H.accept(text1, [Types3.STRING]);
4334
+ text2 = H.accept(text2, [Types3.STRING]);
4335
4335
  return text1 === text2;
4336
4336
  },
4337
4337
  FIND: (findText, withinText, startNum) => {
4338
- findText = H.accept(findText, Types.STRING);
4339
- withinText = H.accept(withinText, Types.STRING);
4340
- startNum = H.accept(startNum, Types.NUMBER, 1);
4338
+ findText = H.accept(findText, Types3.STRING);
4339
+ withinText = H.accept(withinText, Types3.STRING);
4340
+ startNum = H.accept(startNum, Types3.NUMBER, 1);
4341
4341
  if (startNum < 1 || startNum > withinText.length)
4342
4342
  throw FormulaError.VALUE;
4343
4343
  const res = withinText.indexOf(findText, startNum - 1);
@@ -4349,16 +4349,16 @@ ${e.toString()}`);
4349
4349
  return TextFunctions.FIND(...params);
4350
4350
  },
4351
4351
  FIXED: (number, decimals, noCommas) => {
4352
- number = H.accept(number, Types.NUMBER);
4353
- decimals = H.accept(decimals, Types.NUMBER, 2);
4354
- noCommas = H.accept(noCommas, Types.BOOLEAN, false);
4352
+ number = H.accept(number, Types3.NUMBER);
4353
+ decimals = H.accept(decimals, Types3.NUMBER, 2);
4354
+ noCommas = H.accept(noCommas, Types3.BOOLEAN, false);
4355
4355
  const decimalString = Array(decimals).fill("0").join("");
4356
4356
  const comma = noCommas ? "" : "#,";
4357
4357
  return ssf.format(`${comma}##0.${decimalString}_);(${comma}##0.${decimalString})`, number).trim();
4358
4358
  },
4359
4359
  LEFT: (text, numChars) => {
4360
- text = H.accept(text, Types.STRING);
4361
- numChars = H.accept(numChars, Types.NUMBER, 1);
4360
+ text = H.accept(text, Types3.STRING);
4361
+ numChars = H.accept(numChars, Types3.NUMBER, 1);
4362
4362
  if (numChars < 0)
4363
4363
  throw FormulaError.VALUE;
4364
4364
  if (numChars > text.length)
@@ -4369,20 +4369,20 @@ ${e.toString()}`);
4369
4369
  return TextFunctions.LEFT(...params);
4370
4370
  },
4371
4371
  LEN: (text) => {
4372
- text = H.accept(text, Types.STRING);
4372
+ text = H.accept(text, Types3.STRING);
4373
4373
  return text.length;
4374
4374
  },
4375
4375
  LENB: (...params) => {
4376
4376
  return TextFunctions.LEN(...params);
4377
4377
  },
4378
4378
  LOWER: (text) => {
4379
- text = H.accept(text, Types.STRING);
4379
+ text = H.accept(text, Types3.STRING);
4380
4380
  return text.toLowerCase();
4381
4381
  },
4382
4382
  MID: (text, startNum, numChars) => {
4383
- text = H.accept(text, Types.STRING);
4384
- startNum = H.accept(startNum, Types.NUMBER);
4385
- numChars = H.accept(numChars, Types.NUMBER);
4383
+ text = H.accept(text, Types3.STRING);
4384
+ startNum = H.accept(startNum, Types3.NUMBER);
4385
+ numChars = H.accept(numChars, Types3.NUMBER);
4386
4386
  if (startNum > text.length)
4387
4387
  return "";
4388
4388
  if (startNum < 1 || numChars < 1)
@@ -4393,9 +4393,9 @@ ${e.toString()}`);
4393
4393
  return TextFunctions.MID(...params);
4394
4394
  },
4395
4395
  NUMBERVALUE: (text, decimalSeparator, groupSeparator) => {
4396
- text = H.accept(text, Types.STRING);
4397
- decimalSeparator = H.accept(decimalSeparator, Types.STRING, ".");
4398
- groupSeparator = H.accept(groupSeparator, Types.STRING, ",");
4396
+ text = H.accept(text, Types3.STRING);
4397
+ decimalSeparator = H.accept(decimalSeparator, Types3.STRING, ".");
4398
+ groupSeparator = H.accept(groupSeparator, Types3.STRING, ",");
4399
4399
  if (text.length === 0)
4400
4400
  return 0;
4401
4401
  if (decimalSeparator.length === 0 || groupSeparator.length === 0)
@@ -4417,7 +4417,7 @@ ${e.toString()}`);
4417
4417
  PHONETIC: () => {
4418
4418
  },
4419
4419
  PROPER: (text) => {
4420
- text = H.accept(text, [Types.STRING]);
4420
+ text = H.accept(text, [Types3.STRING]);
4421
4421
  text = text.toLowerCase();
4422
4422
  text = text.charAt(0).toUpperCase() + text.slice(1);
4423
4423
  return text.replace(
@@ -4426,10 +4426,10 @@ ${e.toString()}`);
4426
4426
  );
4427
4427
  },
4428
4428
  REPLACE: (old_text, start_num, num_chars, new_text) => {
4429
- old_text = H.accept(old_text, [Types.STRING]);
4430
- start_num = H.accept(start_num, [Types.NUMBER]);
4431
- num_chars = H.accept(num_chars, [Types.NUMBER]);
4432
- new_text = H.accept(new_text, [Types.STRING]);
4429
+ old_text = H.accept(old_text, [Types3.STRING]);
4430
+ start_num = H.accept(start_num, [Types3.NUMBER]);
4431
+ num_chars = H.accept(num_chars, [Types3.NUMBER]);
4432
+ new_text = H.accept(new_text, [Types3.STRING]);
4433
4433
  let arr = old_text.split("");
4434
4434
  arr.splice(start_num - 1, num_chars, new_text);
4435
4435
  return arr.join("");
@@ -4438,8 +4438,8 @@ ${e.toString()}`);
4438
4438
  return TextFunctions.REPLACE(...params);
4439
4439
  },
4440
4440
  REPT: (text, number_times) => {
4441
- text = H.accept(text, Types.STRING);
4442
- number_times = H.accept(number_times, Types.NUMBER);
4441
+ text = H.accept(text, Types3.STRING);
4442
+ number_times = H.accept(number_times, Types3.NUMBER);
4443
4443
  let str = "";
4444
4444
  for (let i3 = 0; i3 < number_times; i3++) {
4445
4445
  str += text;
@@ -4447,8 +4447,8 @@ ${e.toString()}`);
4447
4447
  return str;
4448
4448
  },
4449
4449
  RIGHT: (text, numChars) => {
4450
- text = H.accept(text, Types.STRING);
4451
- numChars = H.accept(numChars, Types.NUMBER, 1);
4450
+ text = H.accept(text, Types3.STRING);
4451
+ numChars = H.accept(numChars, Types3.NUMBER, 1);
4452
4452
  if (numChars < 0)
4453
4453
  throw FormulaError.VALUE;
4454
4454
  const len = text.length;
@@ -4460,9 +4460,9 @@ ${e.toString()}`);
4460
4460
  return TextFunctions.RIGHT(...params);
4461
4461
  },
4462
4462
  SEARCH: (findText, withinText, startNum) => {
4463
- findText = H.accept(findText, Types.STRING);
4464
- withinText = H.accept(withinText, Types.STRING);
4465
- startNum = H.accept(startNum, Types.NUMBER, 1);
4463
+ findText = H.accept(findText, Types3.STRING);
4464
+ withinText = H.accept(withinText, Types3.STRING);
4465
+ startNum = H.accept(startNum, Types3.NUMBER, 1);
4466
4466
  if (startNum < 1 || startNum > withinText.length)
4467
4467
  throw FormulaError.VALUE;
4468
4468
  let findTextRegex = WildCard.isWildCard(findText) ? WildCard.toRegex(findText, "i") : findText;
@@ -4483,8 +4483,8 @@ ${e.toString()}`);
4483
4483
  return "";
4484
4484
  },
4485
4485
  TEXT: (value2, formatText) => {
4486
- value2 = H.accept(value2, Types.NUMBER);
4487
- formatText = H.accept(formatText, Types.STRING);
4486
+ value2 = H.accept(value2, Types3.NUMBER);
4487
+ formatText = H.accept(formatText, Types3.STRING);
4488
4488
  try {
4489
4489
  return ssf.format(formatText, value2);
4490
4490
  } catch (e) {
@@ -4495,11 +4495,11 @@ ${e.toString()}`);
4495
4495
  TEXTJOIN: (...params) => {
4496
4496
  },
4497
4497
  TRIM: (text) => {
4498
- text = H.accept(text, [Types.STRING]);
4498
+ text = H.accept(text, [Types3.STRING]);
4499
4499
  return text.replace(/^\s+|\s+$/g, "");
4500
4500
  },
4501
4501
  UNICHAR: (number) => {
4502
- number = H.accept(number, [Types.NUMBER]);
4502
+ number = H.accept(number, [Types3.NUMBER]);
4503
4503
  if (number <= 0)
4504
4504
  throw FormulaError.VALUE;
4505
4505
  return String.fromCharCode(number);
@@ -4516,7 +4516,7 @@ ${e.toString()}`);
4516
4516
  var require_operators = __commonJS({
4517
4517
  "../../node_modules/fast-formula-parser/formulas/operators.js"(exports2, module2) {
4518
4518
  var FormulaError = require_error();
4519
- var { FormulaHelpers } = require_helpers();
4519
+ var { FormulaHelpers: FormulaHelpers3 } = require_helpers();
4520
4520
  var Prefix = {
4521
4521
  unaryOp: (prefixes, value2, isArray2) => {
4522
4522
  let sign = 1;
@@ -4535,7 +4535,7 @@ ${e.toString()}`);
4535
4535
  return value2;
4536
4536
  }
4537
4537
  try {
4538
- value2 = FormulaHelpers.acceptNumber(value2, isArray2);
4538
+ value2 = FormulaHelpers3.acceptNumber(value2, isArray2);
4539
4539
  } catch (e) {
4540
4540
  if (e instanceof FormulaError) {
4541
4541
  if (Array.isArray(value2))
@@ -4550,7 +4550,7 @@ ${e.toString()}`);
4550
4550
  var Postfix = {
4551
4551
  percentOp: (value2, postfix, isArray2) => {
4552
4552
  try {
4553
- value2 = FormulaHelpers.acceptNumber(value2, isArray2);
4553
+ value2 = FormulaHelpers3.acceptNumber(value2, isArray2);
4554
4554
  } catch (e) {
4555
4555
  if (e instanceof FormulaError)
4556
4556
  return e;
@@ -4627,8 +4627,8 @@ ${e.toString()}`);
4627
4627
  if (value1 == null) value1 = 0;
4628
4628
  if (value2 == null) value2 = 0;
4629
4629
  try {
4630
- value1 = FormulaHelpers.acceptNumber(value1, isArray1);
4631
- value2 = FormulaHelpers.acceptNumber(value2, isArray2);
4630
+ value1 = FormulaHelpers3.acceptNumber(value1, isArray1);
4631
+ value2 = FormulaHelpers3.acceptNumber(value2, isArray2);
4632
4632
  } catch (e) {
4633
4633
  if (e instanceof FormulaError)
4634
4634
  return e;
@@ -4668,9 +4668,9 @@ ${e.toString()}`);
4668
4668
  var require_math = __commonJS({
4669
4669
  "../../node_modules/fast-formula-parser/formulas/functions/math.js"(exports2, module2) {
4670
4670
  var FormulaError = require_error();
4671
- var { FormulaHelpers, Types, Factorials, Criteria } = require_helpers();
4671
+ var { FormulaHelpers: FormulaHelpers3, Types: Types3, Factorials, Criteria } = require_helpers();
4672
4672
  var { Infix: Infix2 } = require_operators();
4673
- var H = FormulaHelpers;
4673
+ var H = FormulaHelpers3;
4674
4674
  var f = [];
4675
4675
  var fd2 = [];
4676
4676
  function factorial(n) {
@@ -4691,13 +4691,13 @@ ${e.toString()}`);
4691
4691
  }
4692
4692
  var MathFunctions = {
4693
4693
  ABS: (number) => {
4694
- number = H.accept(number, Types.NUMBER);
4694
+ number = H.accept(number, Types3.NUMBER);
4695
4695
  return Math.abs(number);
4696
4696
  },
4697
4697
  AGGREGATE: (functionNum, options, ref1, ...refs) => {
4698
4698
  },
4699
4699
  ARABIC: (text) => {
4700
- text = H.accept(text, Types.STRING).toUpperCase();
4700
+ text = H.accept(text, Types3.STRING).toUpperCase();
4701
4701
  if (!/^M*(?:D?C{0,3}|C[MD])(?:L?X{0,3}|X[CL])(?:V?I{0,3}|I[XV])$/.test(text)) {
4702
4702
  throw new FormulaError("#VALUE!", "Invalid roman numeral in ARABIC evaluation.");
4703
4703
  }
@@ -4722,13 +4722,13 @@ ${e.toString()}`);
4722
4722
  return r;
4723
4723
  },
4724
4724
  BASE: (number, radix, minLength) => {
4725
- number = H.accept(number, Types.NUMBER);
4725
+ number = H.accept(number, Types3.NUMBER);
4726
4726
  if (number < 0 || number >= 2 ** 53)
4727
4727
  throw FormulaError.NUM;
4728
- radix = H.accept(radix, Types.NUMBER);
4728
+ radix = H.accept(radix, Types3.NUMBER);
4729
4729
  if (radix < 2 || radix > 36)
4730
4730
  throw FormulaError.NUM;
4731
- minLength = H.accept(minLength, Types.NUMBER, 0);
4731
+ minLength = H.accept(minLength, Types3.NUMBER, 0);
4732
4732
  if (minLength < 0) {
4733
4733
  throw FormulaError.NUM;
4734
4734
  }
@@ -4736,8 +4736,8 @@ ${e.toString()}`);
4736
4736
  return new Array(Math.max(minLength + 1 - result.length, 0)).join("0") + result;
4737
4737
  },
4738
4738
  CEILING: (number, significance) => {
4739
- number = H.accept(number, Types.NUMBER);
4740
- significance = H.accept(significance, Types.NUMBER);
4739
+ number = H.accept(number, Types3.NUMBER);
4740
+ significance = H.accept(significance, Types3.NUMBER);
4741
4741
  if (significance === 0)
4742
4742
  return 0;
4743
4743
  if (number / significance % 1 === 0)
@@ -4752,9 +4752,9 @@ ${e.toString()}`);
4752
4752
  }
4753
4753
  },
4754
4754
  "CEILING.MATH": (number, significance, mode) => {
4755
- number = H.accept(number, Types.NUMBER);
4756
- significance = H.accept(significance, Types.NUMBER, number > 0 ? 1 : -1);
4757
- mode = H.accept(mode, Types.NUMBER, 0);
4755
+ number = H.accept(number, Types3.NUMBER);
4756
+ significance = H.accept(significance, Types3.NUMBER, number > 0 ? 1 : -1);
4757
+ mode = H.accept(mode, Types3.NUMBER, 0);
4758
4758
  if (number >= 0) {
4759
4759
  return MathFunctions.CEILING(number, significance);
4760
4760
  }
@@ -4762,21 +4762,21 @@ ${e.toString()}`);
4762
4762
  return MathFunctions.CEILING(number, significance) - offset;
4763
4763
  },
4764
4764
  "CEILING.PRECISE": (number, significance) => {
4765
- number = H.accept(number, Types.NUMBER);
4766
- significance = H.accept(significance, Types.NUMBER, 1);
4765
+ number = H.accept(number, Types3.NUMBER);
4766
+ significance = H.accept(significance, Types3.NUMBER, 1);
4767
4767
  return MathFunctions.CEILING(number, Math.abs(significance));
4768
4768
  },
4769
4769
  COMBIN: (number, numberChosen) => {
4770
- number = H.accept(number, Types.NUMBER);
4771
- numberChosen = H.accept(numberChosen, Types.NUMBER);
4770
+ number = H.accept(number, Types3.NUMBER);
4771
+ numberChosen = H.accept(numberChosen, Types3.NUMBER);
4772
4772
  if (number < 0 || numberChosen < 0 || number < numberChosen)
4773
4773
  throw FormulaError.NUM;
4774
4774
  const nFactorial = MathFunctions.FACT(number), kFactorial = MathFunctions.FACT(numberChosen);
4775
4775
  return nFactorial / kFactorial / MathFunctions.FACT(number - numberChosen);
4776
4776
  },
4777
4777
  COMBINA: (number, numberChosen) => {
4778
- number = H.accept(number, Types.NUMBER);
4779
- numberChosen = H.accept(numberChosen, Types.NUMBER);
4778
+ number = H.accept(number, Types3.NUMBER);
4779
+ numberChosen = H.accept(numberChosen, Types3.NUMBER);
4780
4780
  if ((number === 0 || number === 1) && numberChosen === 0)
4781
4781
  return 1;
4782
4782
  if (number < 0 || numberChosen < 0)
@@ -4784,8 +4784,8 @@ ${e.toString()}`);
4784
4784
  return MathFunctions.COMBIN(number + numberChosen - 1, number - 1);
4785
4785
  },
4786
4786
  DECIMAL: (text, radix) => {
4787
- text = H.accept(text, Types.STRING);
4788
- radix = H.accept(radix, Types.NUMBER);
4787
+ text = H.accept(text, Types3.STRING);
4788
+ radix = H.accept(radix, Types3.NUMBER);
4789
4789
  radix = Math.trunc(radix);
4790
4790
  if (radix < 2 || radix > 36)
4791
4791
  throw FormulaError.NUM;
@@ -4795,18 +4795,18 @@ ${e.toString()}`);
4795
4795
  return res;
4796
4796
  },
4797
4797
  DEGREES: (radians) => {
4798
- radians = H.accept(radians, Types.NUMBER);
4798
+ radians = H.accept(radians, Types3.NUMBER);
4799
4799
  return radians * (180 / Math.PI);
4800
4800
  },
4801
4801
  EVEN: (number) => {
4802
4802
  return MathFunctions.CEILING(number, -2);
4803
4803
  },
4804
4804
  EXP: (number) => {
4805
- number = H.accept(number, Types.NUMBER);
4805
+ number = H.accept(number, Types3.NUMBER);
4806
4806
  return Math.exp(number);
4807
4807
  },
4808
4808
  FACT: (number) => {
4809
- number = H.accept(number, Types.NUMBER);
4809
+ number = H.accept(number, Types3.NUMBER);
4810
4810
  number = Math.trunc(number);
4811
4811
  if (number > 170 || number < 0)
4812
4812
  throw FormulaError.NUM;
@@ -4815,7 +4815,7 @@ ${e.toString()}`);
4815
4815
  return factorial(number);
4816
4816
  },
4817
4817
  FACTDOUBLE: (number) => {
4818
- number = H.accept(number, Types.NUMBER);
4818
+ number = H.accept(number, Types3.NUMBER);
4819
4819
  number = Math.trunc(number);
4820
4820
  if (number < -1)
4821
4821
  throw FormulaError.NUM;
@@ -4824,8 +4824,8 @@ ${e.toString()}`);
4824
4824
  return factorialDouble(number);
4825
4825
  },
4826
4826
  FLOOR: (number, significance) => {
4827
- number = H.accept(number, Types.NUMBER);
4828
- significance = H.accept(significance, Types.NUMBER);
4827
+ number = H.accept(number, Types3.NUMBER);
4828
+ significance = H.accept(significance, Types3.NUMBER);
4829
4829
  if (significance === 0)
4830
4830
  return 0;
4831
4831
  if (number > 0 && significance < 0)
@@ -4842,17 +4842,17 @@ ${e.toString()}`);
4842
4842
  }
4843
4843
  },
4844
4844
  "FLOOR.MATH": (number, significance, mode) => {
4845
- number = H.accept(number, Types.NUMBER);
4846
- significance = H.accept(significance, Types.NUMBER, number > 0 ? 1 : -1);
4847
- mode = H.accept(mode, Types.NUMBER, 0);
4845
+ number = H.accept(number, Types3.NUMBER);
4846
+ significance = H.accept(significance, Types3.NUMBER, number > 0 ? 1 : -1);
4847
+ mode = H.accept(mode, Types3.NUMBER, 0);
4848
4848
  if (mode === 0 || number >= 0) {
4849
4849
  return MathFunctions.FLOOR(number, Math.abs(significance));
4850
4850
  }
4851
4851
  return MathFunctions.FLOOR(number, significance) + significance;
4852
4852
  },
4853
4853
  "FLOOR.PRECISE": (number, significance) => {
4854
- number = H.accept(number, Types.NUMBER);
4855
- significance = H.accept(significance, Types.NUMBER, 1);
4854
+ number = H.accept(number, Types3.NUMBER);
4855
+ significance = H.accept(significance, Types3.NUMBER, 1);
4856
4856
  return MathFunctions.FLOOR(number, Math.abs(significance));
4857
4857
  },
4858
4858
  GCD: (...params) => {
@@ -4883,7 +4883,7 @@ ${e.toString()}`);
4883
4883
  return x2;
4884
4884
  },
4885
4885
  INT: (number) => {
4886
- number = H.accept(number, Types.NUMBER);
4886
+ number = H.accept(number, Types3.NUMBER);
4887
4887
  return Math.floor(number);
4888
4888
  },
4889
4889
  "ISO.CEILING": (...params) => {
@@ -4917,20 +4917,20 @@ ${e.toString()}`);
4917
4917
  return a;
4918
4918
  },
4919
4919
  LN: (number) => {
4920
- number = H.accept(number, Types.NUMBER);
4920
+ number = H.accept(number, Types3.NUMBER);
4921
4921
  return Math.log(number);
4922
4922
  },
4923
4923
  LOG: (number, base2) => {
4924
- number = H.accept(number, Types.NUMBER);
4925
- base2 = H.accept(base2, Types.NUMBER, 10);
4924
+ number = H.accept(number, Types3.NUMBER);
4925
+ base2 = H.accept(base2, Types3.NUMBER, 10);
4926
4926
  return Math.log(number) / Math.log(base2);
4927
4927
  },
4928
4928
  LOG10: (number) => {
4929
- number = H.accept(number, Types.NUMBER);
4929
+ number = H.accept(number, Types3.NUMBER);
4930
4930
  return Math.log10(number);
4931
4931
  },
4932
4932
  MDETERM: (array) => {
4933
- array = H.accept(array, Types.ARRAY, void 0, false, true);
4933
+ array = H.accept(array, Types3.ARRAY, void 0, false, true);
4934
4934
  if (array[0].length !== array.length)
4935
4935
  throw FormulaError.VALUE;
4936
4936
  const numRow = array.length, numCol = array[0].length;
@@ -4954,8 +4954,8 @@ ${e.toString()}`);
4954
4954
  MINVERSE: (array) => {
4955
4955
  },
4956
4956
  MMULT: (array1, array2) => {
4957
- array1 = H.accept(array1, Types.ARRAY, void 0, false, true);
4958
- array2 = H.accept(array2, Types.ARRAY, void 0, false, true);
4957
+ array1 = H.accept(array1, Types3.ARRAY, void 0, false, true);
4958
+ array2 = H.accept(array2, Types3.ARRAY, void 0, false, true);
4959
4959
  const aNumRows = array1.length, aNumCols = array1[0].length, bNumRows = array2.length, bNumCols = array2[0].length, m = new Array(aNumRows);
4960
4960
  if (aNumCols !== bNumRows)
4961
4961
  throw FormulaError.VALUE;
@@ -4973,15 +4973,15 @@ ${e.toString()}`);
4973
4973
  return m;
4974
4974
  },
4975
4975
  MOD: (number, divisor) => {
4976
- number = H.accept(number, Types.NUMBER);
4977
- divisor = H.accept(divisor, Types.NUMBER);
4976
+ number = H.accept(number, Types3.NUMBER);
4977
+ divisor = H.accept(divisor, Types3.NUMBER);
4978
4978
  if (divisor === 0)
4979
4979
  throw FormulaError.DIV0;
4980
4980
  return number - divisor * MathFunctions.INT(number / divisor);
4981
4981
  },
4982
4982
  MROUND: (number, multiple) => {
4983
- number = H.accept(number, Types.NUMBER);
4984
- multiple = H.accept(multiple, Types.NUMBER);
4983
+ number = H.accept(number, Types3.NUMBER);
4984
+ multiple = H.accept(multiple, Types3.NUMBER);
4985
4985
  if (multiple === 0)
4986
4986
  return 0;
4987
4987
  if (number > 0 && multiple < 0 || number < 0 && multiple > 0)
@@ -4992,7 +4992,7 @@ ${e.toString()}`);
4992
4992
  },
4993
4993
  MULTINOMIAL: (...numbers2) => {
4994
4994
  let numerator = 0, denominator = 1;
4995
- H.flattenParams(numbers2, Types.NUMBER, false, (number) => {
4995
+ H.flattenParams(numbers2, Types3.NUMBER, false, (number) => {
4996
4996
  if (number < 0)
4997
4997
  throw FormulaError.NUM;
4998
4998
  numerator += number;
@@ -5001,7 +5001,7 @@ ${e.toString()}`);
5001
5001
  return factorial(numerator) / denominator;
5002
5002
  },
5003
5003
  MUNIT: (dimension) => {
5004
- dimension = H.accept(dimension, Types.NUMBER);
5004
+ dimension = H.accept(dimension, Types3.NUMBER);
5005
5005
  const matrix = [];
5006
5006
  for (let row = 0; row < dimension; row++) {
5007
5007
  const rowArr = [];
@@ -5016,7 +5016,7 @@ ${e.toString()}`);
5016
5016
  return matrix;
5017
5017
  },
5018
5018
  ODD: (number) => {
5019
- number = H.accept(number, Types.NUMBER);
5019
+ number = H.accept(number, Types3.NUMBER);
5020
5020
  if (number === 0)
5021
5021
  return 1;
5022
5022
  let temp = Math.ceil(Math.abs(number));
@@ -5027,8 +5027,8 @@ ${e.toString()}`);
5027
5027
  return Math.PI;
5028
5028
  },
5029
5029
  POWER: (number, power) => {
5030
- number = H.accept(number, Types.NUMBER);
5031
- power = H.accept(power, Types.NUMBER);
5030
+ number = H.accept(number, Types3.NUMBER);
5031
+ power = H.accept(power, Types3.NUMBER);
5032
5032
  return number ** power;
5033
5033
  },
5034
5034
  PRODUCT: (...numbers2) => {
@@ -5045,25 +5045,25 @@ ${e.toString()}`);
5045
5045
  return product;
5046
5046
  },
5047
5047
  QUOTIENT: (numerator, denominator) => {
5048
- numerator = H.accept(numerator, Types.NUMBER);
5049
- denominator = H.accept(denominator, Types.NUMBER);
5048
+ numerator = H.accept(numerator, Types3.NUMBER);
5049
+ denominator = H.accept(denominator, Types3.NUMBER);
5050
5050
  return Math.trunc(numerator / denominator);
5051
5051
  },
5052
5052
  RADIANS: (degrees) => {
5053
- degrees = H.accept(degrees, Types.NUMBER);
5053
+ degrees = H.accept(degrees, Types3.NUMBER);
5054
5054
  return degrees / 180 * Math.PI;
5055
5055
  },
5056
5056
  RAND: () => {
5057
5057
  return Math.random();
5058
5058
  },
5059
5059
  RANDBETWEEN: (bottom, top) => {
5060
- bottom = H.accept(bottom, Types.NUMBER);
5061
- top = H.accept(top, Types.NUMBER);
5060
+ bottom = H.accept(bottom, Types3.NUMBER);
5061
+ top = H.accept(top, Types3.NUMBER);
5062
5062
  return Math.floor(Math.random() * (top - bottom + 1) + bottom);
5063
5063
  },
5064
5064
  ROMAN: (number, form) => {
5065
- number = H.accept(number, Types.NUMBER);
5066
- form = H.accept(form, Types.NUMBER, 0);
5065
+ number = H.accept(number, Types3.NUMBER);
5066
+ form = H.accept(form, Types3.NUMBER, 0);
5067
5067
  if (form !== 0)
5068
5068
  throw Error("ROMAN: only allows form=0 (classic form).");
5069
5069
  const digits = String(number).split("");
@@ -5075,8 +5075,8 @@ ${e.toString()}`);
5075
5075
  return new Array(+digits.join("") + 1).join("M") + roman;
5076
5076
  },
5077
5077
  ROUND: (number, digits) => {
5078
- number = H.accept(number, Types.NUMBER);
5079
- digits = H.accept(digits, Types.NUMBER);
5078
+ number = H.accept(number, Types3.NUMBER);
5079
+ digits = H.accept(digits, Types3.NUMBER);
5080
5080
  const multiplier = Math.pow(10, Math.abs(digits));
5081
5081
  const sign = number > 0 ? 1 : -1;
5082
5082
  if (digits > 0) {
@@ -5088,8 +5088,8 @@ ${e.toString()}`);
5088
5088
  }
5089
5089
  },
5090
5090
  ROUNDDOWN: (number, digits) => {
5091
- number = H.accept(number, Types.NUMBER);
5092
- digits = H.accept(digits, Types.NUMBER);
5091
+ number = H.accept(number, Types3.NUMBER);
5092
+ digits = H.accept(digits, Types3.NUMBER);
5093
5093
  const multiplier = Math.pow(10, Math.abs(digits));
5094
5094
  const sign = number > 0 ? 1 : -1;
5095
5095
  if (digits > 0) {
@@ -5104,8 +5104,8 @@ ${e.toString()}`);
5104
5104
  }
5105
5105
  },
5106
5106
  ROUNDUP: (number, digits) => {
5107
- number = H.accept(number, Types.NUMBER);
5108
- digits = H.accept(digits, Types.NUMBER);
5107
+ number = H.accept(number, Types3.NUMBER);
5108
+ digits = H.accept(digits, Types3.NUMBER);
5109
5109
  const multiplier = Math.pow(10, Math.abs(digits));
5110
5110
  const sign = number > 0 ? 1 : -1;
5111
5111
  if (digits > 0) {
@@ -5120,11 +5120,11 @@ ${e.toString()}`);
5120
5120
  }
5121
5121
  },
5122
5122
  SERIESSUM: (x2, n, m, coefficients) => {
5123
- x2 = H.accept(x2, Types.NUMBER);
5124
- n = H.accept(n, Types.NUMBER);
5125
- m = H.accept(m, Types.NUMBER);
5123
+ x2 = H.accept(x2, Types3.NUMBER);
5124
+ n = H.accept(n, Types3.NUMBER);
5125
+ m = H.accept(m, Types3.NUMBER);
5126
5126
  let i3 = 0, result;
5127
- H.flattenParams([coefficients], Types.NUMBER, false, (coefficient) => {
5127
+ H.flattenParams([coefficients], Types3.NUMBER, false, (coefficient) => {
5128
5128
  if (typeof coefficient !== "number") {
5129
5129
  throw FormulaError.VALUE;
5130
5130
  }
@@ -5138,17 +5138,17 @@ ${e.toString()}`);
5138
5138
  return result;
5139
5139
  },
5140
5140
  SIGN: (number) => {
5141
- number = H.accept(number, Types.NUMBER);
5141
+ number = H.accept(number, Types3.NUMBER);
5142
5142
  return number > 0 ? 1 : number === 0 ? 0 : -1;
5143
5143
  },
5144
5144
  SQRT: (number) => {
5145
- number = H.accept(number, Types.NUMBER);
5145
+ number = H.accept(number, Types3.NUMBER);
5146
5146
  if (number < 0)
5147
5147
  throw FormulaError.NUM;
5148
5148
  return Math.sqrt(number);
5149
5149
  },
5150
5150
  SQRTPI: (number) => {
5151
- number = H.accept(number, Types.NUMBER);
5151
+ number = H.accept(number, Types3.NUMBER);
5152
5152
  if (number < 0)
5153
5153
  throw FormulaError.NUM;
5154
5154
  return Math.sqrt(number * Math.PI);
@@ -5159,7 +5159,7 @@ ${e.toString()}`);
5159
5159
  let result = 0;
5160
5160
  H.flattenParams(
5161
5161
  params,
5162
- Types.NUMBER,
5162
+ Types3.NUMBER,
5163
5163
  true,
5164
5164
  (item, info) => {
5165
5165
  if (info.isLiteral) {
@@ -5202,9 +5202,9 @@ ${e.toString()}`);
5202
5202
  SUMIFS: () => {
5203
5203
  },
5204
5204
  SUMPRODUCT: (array1, ...arrays) => {
5205
- array1 = H.accept(array1, Types.ARRAY, void 0, false, true);
5205
+ array1 = H.accept(array1, Types3.ARRAY, void 0, false, true);
5206
5206
  arrays.forEach((array) => {
5207
- array = H.accept(array, Types.ARRAY, void 0, false, true);
5207
+ array = H.accept(array, Types3.ARRAY, void 0, false, true);
5208
5208
  if (array1[0].length !== array[0].length || array1.length !== array.length)
5209
5209
  throw FormulaError.VALUE;
5210
5210
  for (let i3 = 0; i3 < array1.length; i3++) {
@@ -5229,7 +5229,7 @@ ${e.toString()}`);
5229
5229
  let result = 0;
5230
5230
  H.flattenParams(
5231
5231
  params,
5232
- Types.NUMBER,
5232
+ Types3.NUMBER,
5233
5233
  true,
5234
5234
  (item, info) => {
5235
5235
  if (info.isLiteral) {
@@ -5294,7 +5294,7 @@ ${e.toString()}`);
5294
5294
  return sum;
5295
5295
  },
5296
5296
  TRUNC: (number) => {
5297
- number = H.accept(number, Types.NUMBER);
5297
+ number = H.accept(number, Types3.NUMBER);
5298
5298
  return Math.trunc(number);
5299
5299
  }
5300
5300
  };
@@ -5306,71 +5306,71 @@ ${e.toString()}`);
5306
5306
  var require_trigonometry = __commonJS({
5307
5307
  "../../node_modules/fast-formula-parser/formulas/functions/trigonometry.js"(exports2, module2) {
5308
5308
  var FormulaError = require_error();
5309
- var { FormulaHelpers, Types } = require_helpers();
5310
- var H = FormulaHelpers;
5309
+ var { FormulaHelpers: FormulaHelpers3, Types: Types3 } = require_helpers();
5310
+ var H = FormulaHelpers3;
5311
5311
  var MAX_NUMBER = 2 ** 27 - 1;
5312
5312
  var TrigFunctions = {
5313
5313
  ACOS: (number) => {
5314
- number = H.accept(number, Types.NUMBER);
5314
+ number = H.accept(number, Types3.NUMBER);
5315
5315
  if (number > 1 || number < -1)
5316
5316
  throw FormulaError.NUM;
5317
5317
  return Math.acos(number);
5318
5318
  },
5319
5319
  ACOSH: (number) => {
5320
- number = H.accept(number, Types.NUMBER);
5320
+ number = H.accept(number, Types3.NUMBER);
5321
5321
  if (number < 1)
5322
5322
  throw FormulaError.NUM;
5323
5323
  return Math.acosh(number);
5324
5324
  },
5325
5325
  ACOT: (number) => {
5326
- number = H.accept(number, Types.NUMBER);
5326
+ number = H.accept(number, Types3.NUMBER);
5327
5327
  return Math.PI / 2 - Math.atan(number);
5328
5328
  },
5329
5329
  ACOTH: (number) => {
5330
- number = H.accept(number, Types.NUMBER);
5330
+ number = H.accept(number, Types3.NUMBER);
5331
5331
  if (Math.abs(number) <= 1)
5332
5332
  throw FormulaError.NUM;
5333
5333
  return Math.atanh(1 / number);
5334
5334
  },
5335
5335
  ASIN: (number) => {
5336
- number = H.accept(number, Types.NUMBER);
5336
+ number = H.accept(number, Types3.NUMBER);
5337
5337
  if (number > 1 || number < -1)
5338
5338
  throw FormulaError.NUM;
5339
5339
  return Math.asin(number);
5340
5340
  },
5341
5341
  ASINH: (number) => {
5342
- number = H.accept(number, Types.NUMBER);
5342
+ number = H.accept(number, Types3.NUMBER);
5343
5343
  return Math.asinh(number);
5344
5344
  },
5345
5345
  ATAN: (number) => {
5346
- number = H.accept(number, Types.NUMBER);
5346
+ number = H.accept(number, Types3.NUMBER);
5347
5347
  return Math.atan(number);
5348
5348
  },
5349
5349
  ATAN2: (x2, y) => {
5350
- x2 = H.accept(x2, Types.NUMBER);
5351
- y = H.accept(y, Types.NUMBER);
5350
+ x2 = H.accept(x2, Types3.NUMBER);
5351
+ y = H.accept(y, Types3.NUMBER);
5352
5352
  if (y === 0 && x2 === 0)
5353
5353
  throw FormulaError.DIV0;
5354
5354
  return Math.atan2(y, x2);
5355
5355
  },
5356
5356
  ATANH: (number) => {
5357
- number = H.accept(number, Types.NUMBER);
5357
+ number = H.accept(number, Types3.NUMBER);
5358
5358
  if (Math.abs(number) > 1)
5359
5359
  throw FormulaError.NUM;
5360
5360
  return Math.atanh(number);
5361
5361
  },
5362
5362
  COS: (number) => {
5363
- number = H.accept(number, Types.NUMBER);
5363
+ number = H.accept(number, Types3.NUMBER);
5364
5364
  if (Math.abs(number) > MAX_NUMBER)
5365
5365
  throw FormulaError.NUM;
5366
5366
  return Math.cos(number);
5367
5367
  },
5368
5368
  COSH: (number) => {
5369
- number = H.accept(number, Types.NUMBER);
5369
+ number = H.accept(number, Types3.NUMBER);
5370
5370
  return Math.cosh(number);
5371
5371
  },
5372
5372
  COT: (number) => {
5373
- number = H.accept(number, Types.NUMBER);
5373
+ number = H.accept(number, Types3.NUMBER);
5374
5374
  if (Math.abs(number) > MAX_NUMBER)
5375
5375
  throw FormulaError.NUM;
5376
5376
  if (number === 0)
@@ -5378,51 +5378,51 @@ ${e.toString()}`);
5378
5378
  return 1 / Math.tan(number);
5379
5379
  },
5380
5380
  COTH: (number) => {
5381
- number = H.accept(number, Types.NUMBER);
5381
+ number = H.accept(number, Types3.NUMBER);
5382
5382
  if (number === 0)
5383
5383
  throw FormulaError.DIV0;
5384
5384
  return 1 / Math.tanh(number);
5385
5385
  },
5386
5386
  CSC: (number) => {
5387
- number = H.accept(number, Types.NUMBER);
5387
+ number = H.accept(number, Types3.NUMBER);
5388
5388
  if (Math.abs(number) > MAX_NUMBER)
5389
5389
  throw FormulaError.NUM;
5390
5390
  return 1 / Math.sin(number);
5391
5391
  },
5392
5392
  CSCH: (number) => {
5393
- number = H.accept(number, Types.NUMBER);
5393
+ number = H.accept(number, Types3.NUMBER);
5394
5394
  if (number === 0)
5395
5395
  throw FormulaError.DIV0;
5396
5396
  return 1 / Math.sinh(number);
5397
5397
  },
5398
5398
  SEC: (number) => {
5399
- number = H.accept(number, Types.NUMBER);
5399
+ number = H.accept(number, Types3.NUMBER);
5400
5400
  if (Math.abs(number) > MAX_NUMBER)
5401
5401
  throw FormulaError.NUM;
5402
5402
  return 1 / Math.cos(number);
5403
5403
  },
5404
5404
  SECH: (number) => {
5405
- number = H.accept(number, Types.NUMBER);
5405
+ number = H.accept(number, Types3.NUMBER);
5406
5406
  return 1 / Math.cosh(number);
5407
5407
  },
5408
5408
  SIN: (number) => {
5409
- number = H.accept(number, Types.NUMBER);
5409
+ number = H.accept(number, Types3.NUMBER);
5410
5410
  if (Math.abs(number) > MAX_NUMBER)
5411
5411
  throw FormulaError.NUM;
5412
5412
  return Math.sin(number);
5413
5413
  },
5414
5414
  SINH: (number) => {
5415
- number = H.accept(number, Types.NUMBER);
5415
+ number = H.accept(number, Types3.NUMBER);
5416
5416
  return Math.sinh(number);
5417
5417
  },
5418
5418
  TAN: (number) => {
5419
- number = H.accept(number, Types.NUMBER);
5419
+ number = H.accept(number, Types3.NUMBER);
5420
5420
  if (Math.abs(number) > MAX_NUMBER)
5421
5421
  throw FormulaError.NUM;
5422
5422
  return Math.tan(number);
5423
5423
  },
5424
5424
  TANH: (number) => {
5425
- number = H.accept(number, Types.NUMBER);
5425
+ number = H.accept(number, Types3.NUMBER);
5426
5426
  return Math.tanh(number);
5427
5427
  }
5428
5428
  };
@@ -5434,8 +5434,8 @@ ${e.toString()}`);
5434
5434
  var require_logical = __commonJS({
5435
5435
  "../../node_modules/fast-formula-parser/formulas/functions/logical.js"(exports2, module2) {
5436
5436
  var FormulaError = require_error();
5437
- var { FormulaHelpers, Types } = require_helpers();
5438
- var H = FormulaHelpers;
5437
+ var { FormulaHelpers: FormulaHelpers3, Types: Types3 } = require_helpers();
5438
+ var H = FormulaHelpers3;
5439
5439
  function getNumLogicalValue(params) {
5440
5440
  let numTrue = 0, numFalse = 0;
5441
5441
  H.flattenParams(params, null, true, (val) => {
@@ -5468,7 +5468,7 @@ ${e.toString()}`);
5468
5468
  },
5469
5469
  // Special
5470
5470
  IF: (context, logicalTest, valueIfTrue, valueIfFalse) => {
5471
- logicalTest = H.accept(logicalTest, Types.BOOLEAN);
5471
+ logicalTest = H.accept(logicalTest, Types3.BOOLEAN);
5472
5472
  valueIfTrue = H.accept(valueIfTrue);
5473
5473
  valueIfFalse = H.accept(valueIfFalse, null, false);
5474
5474
  return logicalTest ? valueIfTrue : valueIfFalse;
@@ -5485,7 +5485,7 @@ ${e.toString()}`);
5485
5485
  if (params.length % 2 !== 0)
5486
5486
  return new FormulaError("#N/A", "IFS expects all arguments after position 0 to be in pairs.");
5487
5487
  for (let i3 = 0; i3 < params.length / 2; i3++) {
5488
- const logicalTest = H.accept(params[i3 * 2], Types.BOOLEAN);
5488
+ const logicalTest = H.accept(params[i3 * 2], Types3.BOOLEAN);
5489
5489
  const valueIfTrue = H.accept(params[i3 * 2 + 1]);
5490
5490
  if (logicalTest)
5491
5491
  return valueIfTrue;
@@ -5493,7 +5493,7 @@ ${e.toString()}`);
5493
5493
  return FormulaError.NA;
5494
5494
  },
5495
5495
  NOT: (logical) => {
5496
- logical = H.accept(logical, Types.BOOLEAN);
5496
+ logical = H.accept(logical, Types3.BOOLEAN);
5497
5497
  return !logical;
5498
5498
  },
5499
5499
  OR: (...params) => {
@@ -9603,8 +9603,8 @@ ${e.toString()}`);
9603
9603
  "../../node_modules/fast-formula-parser/formulas/functions/engineering.js"(exports2, module2) {
9604
9604
  var FormulaError = require_error();
9605
9605
  var TextFunctions = require_text();
9606
- var { FormulaHelpers, Types } = require_helpers();
9607
- var H = FormulaHelpers;
9606
+ var { FormulaHelpers: FormulaHelpers3, Types: Types3 } = require_helpers();
9607
+ var H = FormulaHelpers3;
9608
9608
  var bessel2 = require_bessel();
9609
9609
  var jStat2 = require_jstat();
9610
9610
  var MAX_OCT = 536870911;
@@ -9643,8 +9643,8 @@ ${e.toString()}`);
9643
9643
  }
9644
9644
  var EngineeringFunctions = {
9645
9645
  BESSELI: (x2, n) => {
9646
- x2 = H.accept(x2, Types.NUMBER_NO_BOOLEAN);
9647
- n = H.accept(n, Types.NUMBER_NO_BOOLEAN);
9646
+ x2 = H.accept(x2, Types3.NUMBER_NO_BOOLEAN);
9647
+ n = H.accept(n, Types3.NUMBER_NO_BOOLEAN);
9648
9648
  n = Math.trunc(n);
9649
9649
  if (n < 0) {
9650
9650
  throw FormulaError.NUM;
@@ -9652,8 +9652,8 @@ ${e.toString()}`);
9652
9652
  return bessel2.besseli(x2, n);
9653
9653
  },
9654
9654
  BESSELJ: (x2, n) => {
9655
- x2 = H.accept(x2, Types.NUMBER_NO_BOOLEAN);
9656
- n = H.accept(n, Types.NUMBER_NO_BOOLEAN);
9655
+ x2 = H.accept(x2, Types3.NUMBER_NO_BOOLEAN);
9656
+ n = H.accept(n, Types3.NUMBER_NO_BOOLEAN);
9657
9657
  n = Math.trunc(n);
9658
9658
  if (n < 0) {
9659
9659
  throw FormulaError.NUM;
@@ -9661,8 +9661,8 @@ ${e.toString()}`);
9661
9661
  return bessel2.besselj(x2, n);
9662
9662
  },
9663
9663
  BESSELK: (x2, n) => {
9664
- x2 = H.accept(x2, Types.NUMBER_NO_BOOLEAN);
9665
- n = H.accept(n, Types.NUMBER_NO_BOOLEAN);
9664
+ x2 = H.accept(x2, Types3.NUMBER_NO_BOOLEAN);
9665
+ n = H.accept(n, Types3.NUMBER_NO_BOOLEAN);
9666
9666
  n = Math.trunc(n);
9667
9667
  if (n < 0) {
9668
9668
  throw FormulaError.NUM;
@@ -9670,8 +9670,8 @@ ${e.toString()}`);
9670
9670
  return bessel2.besselk(x2, n);
9671
9671
  },
9672
9672
  BESSELY: (x2, n) => {
9673
- x2 = H.accept(x2, Types.NUMBER_NO_BOOLEAN);
9674
- n = H.accept(n, Types.NUMBER_NO_BOOLEAN);
9673
+ x2 = H.accept(x2, Types3.NUMBER_NO_BOOLEAN);
9674
+ n = H.accept(n, Types3.NUMBER_NO_BOOLEAN);
9675
9675
  n = Math.trunc(n);
9676
9676
  if (n < 0) {
9677
9677
  throw FormulaError.NUM;
@@ -9679,7 +9679,7 @@ ${e.toString()}`);
9679
9679
  return bessel2.bessely(x2, n);
9680
9680
  },
9681
9681
  BIN2DEC: (number) => {
9682
- number = H.accept(number, Types.NUMBER_NO_BOOLEAN);
9682
+ number = H.accept(number, Types3.NUMBER_NO_BOOLEAN);
9683
9683
  let numberStr = number.toString();
9684
9684
  if (numberStr.length > 10) {
9685
9685
  throw FormulaError.NUM;
@@ -9691,8 +9691,8 @@ ${e.toString()}`);
9691
9691
  }
9692
9692
  },
9693
9693
  BIN2HEX: (number, places) => {
9694
- number = H.accept(number, Types.NUMBER_NO_BOOLEAN);
9695
- places = H.accept(places, Types.NUMBER_NO_BOOLEAN, null);
9694
+ number = H.accept(number, Types3.NUMBER_NO_BOOLEAN);
9695
+ places = H.accept(places, Types3.NUMBER_NO_BOOLEAN, null);
9696
9696
  const numberStr = number.toString();
9697
9697
  if (numberStr.length > 10) {
9698
9698
  throw FormulaError.NUM;
@@ -9716,8 +9716,8 @@ ${e.toString()}`);
9716
9716
  }
9717
9717
  },
9718
9718
  BIN2OCT: (number, places) => {
9719
- number = H.accept(number, Types.NUMBER_NO_BOOLEAN);
9720
- places = H.accept(places, Types.NUMBER, null);
9719
+ number = H.accept(number, Types3.NUMBER_NO_BOOLEAN);
9720
+ places = H.accept(places, Types3.NUMBER, null);
9721
9721
  let numberStr = number.toString();
9722
9722
  if (numberStr.length > 10) {
9723
9723
  throw FormulaError.NUM;
@@ -9741,8 +9741,8 @@ ${e.toString()}`);
9741
9741
  }
9742
9742
  },
9743
9743
  BITAND: (number1, number2) => {
9744
- number1 = H.accept(number1, Types.NUMBER);
9745
- number2 = H.accept(number2, Types.NUMBER);
9744
+ number1 = H.accept(number1, Types3.NUMBER);
9745
+ number2 = H.accept(number2, Types3.NUMBER);
9746
9746
  if (number1 < 0 || number2 < 0) {
9747
9747
  throw FormulaError.NUM;
9748
9748
  }
@@ -9755,8 +9755,8 @@ ${e.toString()}`);
9755
9755
  return number1 & number2;
9756
9756
  },
9757
9757
  BITLSHIFT: (number, shiftAmount) => {
9758
- number = H.accept(number, Types.NUMBER);
9759
- shiftAmount = H.accept(shiftAmount, Types.NUMBER);
9758
+ number = H.accept(number, Types3.NUMBER);
9759
+ shiftAmount = H.accept(shiftAmount, Types3.NUMBER);
9760
9760
  shiftAmount = Math.trunc(shiftAmount);
9761
9761
  if (Math.abs(shiftAmount) > 53) {
9762
9762
  throw FormulaError.NUM;
@@ -9771,8 +9771,8 @@ ${e.toString()}`);
9771
9771
  return result;
9772
9772
  },
9773
9773
  BITOR: (number1, number2) => {
9774
- number1 = H.accept(number1, Types.NUMBER);
9775
- number2 = H.accept(number2, Types.NUMBER);
9774
+ number1 = H.accept(number1, Types3.NUMBER);
9775
+ number2 = H.accept(number2, Types3.NUMBER);
9776
9776
  if (number1 < 0 || number2 < 0) {
9777
9777
  throw FormulaError.NUM;
9778
9778
  }
@@ -9785,13 +9785,13 @@ ${e.toString()}`);
9785
9785
  return number1 | number2;
9786
9786
  },
9787
9787
  BITRSHIFT: (number, shiftAmount) => {
9788
- number = H.accept(number, Types.NUMBER);
9789
- shiftAmount = H.accept(shiftAmount, Types.NUMBER);
9788
+ number = H.accept(number, Types3.NUMBER);
9789
+ shiftAmount = H.accept(shiftAmount, Types3.NUMBER);
9790
9790
  return EngineeringFunctions.BITLSHIFT(number, -shiftAmount);
9791
9791
  },
9792
9792
  BITXOR: (number1, number2) => {
9793
- number1 = H.accept(number1, Types.NUMBER);
9794
- number2 = H.accept(number2, Types.NUMBER);
9793
+ number1 = H.accept(number1, Types3.NUMBER);
9794
+ number2 = H.accept(number2, Types3.NUMBER);
9795
9795
  if (number1 < 0 || number1 > 281474976710655 || Math.floor(number1) !== number1) {
9796
9796
  throw FormulaError.NUM;
9797
9797
  }
@@ -9801,9 +9801,9 @@ ${e.toString()}`);
9801
9801
  return number1 ^ number2;
9802
9802
  },
9803
9803
  COMPLEX: (realNum, iNum, suffix) => {
9804
- realNum = H.accept(realNum, Types.NUMBER_NO_BOOLEAN);
9805
- iNum = H.accept(iNum, Types.NUMBER_NO_BOOLEAN);
9806
- suffix = H.accept(suffix, Types.STRING, "i");
9804
+ realNum = H.accept(realNum, Types3.NUMBER_NO_BOOLEAN);
9805
+ iNum = H.accept(iNum, Types3.NUMBER_NO_BOOLEAN);
9806
+ suffix = H.accept(suffix, Types3.STRING, "i");
9807
9807
  if (suffix !== "i" && suffix !== "j") {
9808
9808
  throw FormulaError.VALUE;
9809
9809
  }
@@ -9831,8 +9831,8 @@ ${e.toString()}`);
9831
9831
  }
9832
9832
  },
9833
9833
  DEC2BIN: (number, places) => {
9834
- number = H.accept(number, Types.NUMBER);
9835
- places = H.accept(places, Types.NUMBER, null);
9834
+ number = H.accept(number, Types3.NUMBER);
9835
+ places = H.accept(places, Types3.NUMBER, null);
9836
9836
  if (number < MIN_BIN || number > MAX_BIN) {
9837
9837
  throw FormulaError.NUM;
9838
9838
  }
@@ -9853,8 +9853,8 @@ ${e.toString()}`);
9853
9853
  }
9854
9854
  },
9855
9855
  DEC2HEX: (number, places) => {
9856
- number = H.accept(number, Types.NUMBER);
9857
- places = H.accept(places, Types.NUMBER, null);
9856
+ number = H.accept(number, Types3.NUMBER);
9857
+ places = H.accept(places, Types3.NUMBER, null);
9858
9858
  if (number < -549755813888 || number > 549755813888) {
9859
9859
  throw FormulaError.NUM;
9860
9860
  }
@@ -9875,8 +9875,8 @@ ${e.toString()}`);
9875
9875
  }
9876
9876
  },
9877
9877
  DEC2OCT: (number, places) => {
9878
- number = H.accept(number, Types.NUMBER);
9879
- places = H.accept(places, Types.NUMBER, null);
9878
+ number = H.accept(number, Types3.NUMBER);
9879
+ places = H.accept(places, Types3.NUMBER, null);
9880
9880
  if (number < -536870912 || number > 536870912) {
9881
9881
  throw FormulaError.NUM;
9882
9882
  }
@@ -9897,27 +9897,27 @@ ${e.toString()}`);
9897
9897
  }
9898
9898
  },
9899
9899
  DELTA: (number1, number2) => {
9900
- number1 = H.accept(number1, Types.NUMBER_NO_BOOLEAN);
9901
- number2 = H.accept(number2, Types.NUMBER_NO_BOOLEAN, 0);
9900
+ number1 = H.accept(number1, Types3.NUMBER_NO_BOOLEAN);
9901
+ number2 = H.accept(number2, Types3.NUMBER_NO_BOOLEAN, 0);
9902
9902
  return number1 === number2 ? 1 : 0;
9903
9903
  },
9904
9904
  ERF: (lowerLimit, upperLimit) => {
9905
- lowerLimit = H.accept(lowerLimit, Types.NUMBER_NO_BOOLEAN);
9906
- upperLimit = H.accept(upperLimit, Types.NUMBER_NO_BOOLEAN, 0);
9905
+ lowerLimit = H.accept(lowerLimit, Types3.NUMBER_NO_BOOLEAN);
9906
+ upperLimit = H.accept(upperLimit, Types3.NUMBER_NO_BOOLEAN, 0);
9907
9907
  return jStat2.erf(lowerLimit);
9908
9908
  },
9909
9909
  ERFC: (x2) => {
9910
- x2 = H.accept(x2, Types.NUMBER_NO_BOOLEAN);
9910
+ x2 = H.accept(x2, Types3.NUMBER_NO_BOOLEAN);
9911
9911
  return jStat2.erfc(x2);
9912
9912
  },
9913
9913
  GESTEP: (number, step) => {
9914
- number = H.accept(number, Types.NUMBER_NO_BOOLEAN);
9915
- step = H.accept(step, Types.NUMBER_NO_BOOLEAN, 0);
9914
+ number = H.accept(number, Types3.NUMBER_NO_BOOLEAN);
9915
+ step = H.accept(step, Types3.NUMBER_NO_BOOLEAN, 0);
9916
9916
  return number >= step ? 1 : 0;
9917
9917
  },
9918
9918
  HEX2BIN: (number, places) => {
9919
- number = H.accept(number, Types.STRING);
9920
- places = H.accept(places, Types.NUMBER, null);
9919
+ number = H.accept(number, Types3.STRING);
9920
+ places = H.accept(places, Types3.NUMBER, null);
9921
9921
  if (number.length > 10 || !/^[0-9a-fA-F]*$/.test(number)) {
9922
9922
  throw FormulaError.NUM;
9923
9923
  }
@@ -9941,7 +9941,7 @@ ${e.toString()}`);
9941
9941
  }
9942
9942
  },
9943
9943
  HEX2DEC: (number) => {
9944
- number = H.accept(number, Types.STRING);
9944
+ number = H.accept(number, Types3.STRING);
9945
9945
  if (number.length > 10 || !/^[0-9a-fA-F]*$/.test(number)) {
9946
9946
  throw FormulaError.NUM;
9947
9947
  }
@@ -9949,7 +9949,7 @@ ${e.toString()}`);
9949
9949
  return result >= 549755813888 ? result - 1099511627776 : result;
9950
9950
  },
9951
9951
  HEX2OCT: (number, places) => {
9952
- number = H.accept(number, Types.STRING);
9952
+ number = H.accept(number, Types3.STRING);
9953
9953
  if (number.length > 10 || !/^[0-9a-fA-F]*$/.test(number)) {
9954
9954
  throw FormulaError.NUM;
9955
9955
  }
@@ -10060,7 +10060,7 @@ ${e.toString()}`);
10060
10060
  },
10061
10061
  IMPOWER: (iNumber, number) => {
10062
10062
  let { unit } = parseIM(iNumber);
10063
- number = H.accept(number, Types.NUMBER_NO_BOOLEAN);
10063
+ number = H.accept(number, Types3.NUMBER_NO_BOOLEAN);
10064
10064
  let p = Math.pow(EngineeringFunctions.IMABS(iNumber), number);
10065
10065
  let t = EngineeringFunctions.IMARGUMENT(iNumber);
10066
10066
  let real = p * Math.cos(number * t);
@@ -10142,8 +10142,8 @@ ${e.toString()}`);
10142
10142
  },
10143
10143
  // FIXME: need to check the test cases
10144
10144
  OCT2BIN: (number, places) => {
10145
- number = H.accept(number, Types.STRING);
10146
- places = H.accept(places, Types.NUMBER, null);
10145
+ number = H.accept(number, Types3.STRING);
10146
+ places = H.accept(places, Types3.NUMBER, null);
10147
10147
  if (number.length > 10) {
10148
10148
  throw FormulaError.NUM;
10149
10149
  }
@@ -10172,7 +10172,7 @@ ${e.toString()}`);
10172
10172
  return TextFunctions.REPT("0", places - result.length) + result;
10173
10173
  },
10174
10174
  OCT2DEC: (number) => {
10175
- number = H.accept(number, Types.STRING);
10175
+ number = H.accept(number, Types3.STRING);
10176
10176
  if (number.length > 10) {
10177
10177
  throw FormulaError.NUM;
10178
10178
  }
@@ -10185,8 +10185,8 @@ ${e.toString()}`);
10185
10185
  return result >= 536870912 ? result - 1073741824 : result;
10186
10186
  },
10187
10187
  OCT2HEX: (number, places) => {
10188
- number = H.accept(number, Types.STRING);
10189
- places = H.accept(places, Types.NUMBER_NO_BOOLEAN, null);
10188
+ number = H.accept(number, Types3.STRING);
10189
+ places = H.accept(places, Types3.NUMBER_NO_BOOLEAN, null);
10190
10190
  if (number.length > 10) {
10191
10191
  throw FormulaError.NUM;
10192
10192
  }
@@ -10219,16 +10219,16 @@ ${e.toString()}`);
10219
10219
  var require_reference = __commonJS({
10220
10220
  "../../node_modules/fast-formula-parser/formulas/functions/reference.js"(exports2, module2) {
10221
10221
  var FormulaError = require_error();
10222
- var { FormulaHelpers, Types, WildCard, Address } = require_helpers();
10222
+ var { FormulaHelpers: FormulaHelpers3, Types: Types3, WildCard, Address } = require_helpers();
10223
10223
  var Collection = require_collection();
10224
- var H = FormulaHelpers;
10224
+ var H = FormulaHelpers3;
10225
10225
  var ReferenceFunctions = {
10226
10226
  ADDRESS: (rowNumber, columnNumber, absNum, a1, sheetText) => {
10227
- rowNumber = H.accept(rowNumber, Types.NUMBER);
10228
- columnNumber = H.accept(columnNumber, Types.NUMBER);
10229
- absNum = H.accept(absNum, Types.NUMBER, 1);
10230
- a1 = H.accept(a1, Types.BOOLEAN, true);
10231
- sheetText = H.accept(sheetText, Types.STRING, "");
10227
+ rowNumber = H.accept(rowNumber, Types3.NUMBER);
10228
+ columnNumber = H.accept(columnNumber, Types3.NUMBER);
10229
+ absNum = H.accept(absNum, Types3.NUMBER, 1);
10230
+ a1 = H.accept(a1, Types3.BOOLEAN, true);
10231
+ sheetText = H.accept(sheetText, Types3.STRING, "");
10232
10232
  if (rowNumber < 1 || columnNumber < 1 || absNum < 1 || absNum > 4)
10233
10233
  throw FormulaError.VALUE;
10234
10234
  let result = "";
@@ -10298,14 +10298,14 @@ ${e.toString()}`);
10298
10298
  HLOOKUP: (lookupValue, tableArray, rowIndexNum, rangeLookup) => {
10299
10299
  lookupValue = H.accept(lookupValue);
10300
10300
  try {
10301
- tableArray = H.accept(tableArray, Types.ARRAY, void 0, false);
10301
+ tableArray = H.accept(tableArray, Types3.ARRAY, void 0, false);
10302
10302
  } catch (e) {
10303
10303
  if (e instanceof FormulaError)
10304
10304
  throw FormulaError.NA;
10305
10305
  throw e;
10306
10306
  }
10307
- rowIndexNum = H.accept(rowIndexNum, Types.NUMBER);
10308
- rangeLookup = H.accept(rangeLookup, Types.BOOLEAN, true);
10307
+ rowIndexNum = H.accept(rowIndexNum, Types3.NUMBER);
10308
+ rangeLookup = H.accept(rangeLookup, Types3.BOOLEAN, true);
10309
10309
  if (rowIndexNum < 1)
10310
10310
  throw FormulaError.VALUE;
10311
10311
  if (tableArray[rowIndexNum - 1] === void 0)
@@ -10350,14 +10350,14 @@ ${e.toString()}`);
10350
10350
  INDEX: (context, ranges, rowNum, colNum, areaNum) => {
10351
10351
  rowNum = context.utils.extractRefValue(rowNum);
10352
10352
  rowNum = { value: rowNum.val, isArray: rowNum.isArray };
10353
- rowNum = H.accept(rowNum, Types.NUMBER);
10353
+ rowNum = H.accept(rowNum, Types3.NUMBER);
10354
10354
  rowNum = Math.trunc(rowNum);
10355
10355
  if (colNum == null) {
10356
10356
  colNum = 1;
10357
10357
  } else {
10358
10358
  colNum = context.utils.extractRefValue(colNum);
10359
10359
  colNum = { value: colNum.val, isArray: colNum.isArray };
10360
- colNum = H.accept(colNum, Types.NUMBER, 1);
10360
+ colNum = H.accept(colNum, Types3.NUMBER, 1);
10361
10361
  colNum = Math.trunc(colNum);
10362
10362
  }
10363
10363
  if (areaNum == null) {
@@ -10365,7 +10365,7 @@ ${e.toString()}`);
10365
10365
  } else {
10366
10366
  areaNum = context.utils.extractRefValue(areaNum);
10367
10367
  areaNum = { value: areaNum.val, isArray: areaNum.isArray };
10368
- areaNum = H.accept(areaNum, Types.NUMBER, 1);
10368
+ areaNum = H.accept(areaNum, Types3.NUMBER, 1);
10369
10369
  areaNum = Math.trunc(areaNum);
10370
10370
  }
10371
10371
  let range = ranges;
@@ -10456,7 +10456,7 @@ ${e.toString()}`);
10456
10456
  }
10457
10457
  },
10458
10458
  TRANSPOSE: (array) => {
10459
- array = H.accept(array, Types.ARRAY, void 0, false);
10459
+ array = H.accept(array, Types3.ARRAY, void 0, false);
10460
10460
  const result = [];
10461
10461
  for (let i3 = 0; i3 < array[0].length; i3++) {
10462
10462
  result[i3] = [];
@@ -10469,14 +10469,14 @@ ${e.toString()}`);
10469
10469
  VLOOKUP: (lookupValue, tableArray, colIndexNum, rangeLookup) => {
10470
10470
  lookupValue = H.accept(lookupValue);
10471
10471
  try {
10472
- tableArray = H.accept(tableArray, Types.ARRAY, void 0, false);
10472
+ tableArray = H.accept(tableArray, Types3.ARRAY, void 0, false);
10473
10473
  } catch (e) {
10474
10474
  if (e instanceof FormulaError)
10475
10475
  throw FormulaError.NA;
10476
10476
  throw e;
10477
10477
  }
10478
- colIndexNum = H.accept(colIndexNum, Types.NUMBER);
10479
- rangeLookup = H.accept(rangeLookup, Types.BOOLEAN, true);
10478
+ colIndexNum = H.accept(colIndexNum, Types3.NUMBER);
10479
+ rangeLookup = H.accept(rangeLookup, Types3.BOOLEAN, true);
10480
10480
  if (colIndexNum < 1)
10481
10481
  throw FormulaError.VALUE;
10482
10482
  if (tableArray[0][colIndexNum - 1] === void 0)
@@ -10527,8 +10527,8 @@ ${e.toString()}`);
10527
10527
  var require_information = __commonJS({
10528
10528
  "../../node_modules/fast-formula-parser/formulas/functions/information.js"(exports2, module2) {
10529
10529
  var FormulaError = require_error();
10530
- var { FormulaHelpers, Types } = require_helpers();
10531
- var H = FormulaHelpers;
10530
+ var { FormulaHelpers: FormulaHelpers3, Types: Types3 } = require_helpers();
10531
+ var H = FormulaHelpers3;
10532
10532
  var error2Number = {
10533
10533
  "#NULL!": 1,
10534
10534
  "#DIV/0!": 2,
@@ -10563,7 +10563,7 @@ ${e.toString()}`);
10563
10563
  return value2 instanceof FormulaError;
10564
10564
  },
10565
10565
  ISEVEN: (number) => {
10566
- number = H.accept(number, Types.NUMBER);
10566
+ number = H.accept(number, Types3.NUMBER);
10567
10567
  number = Math.trunc(number);
10568
10568
  return number % 2 === 0;
10569
10569
  },
@@ -10645,48 +10645,48 @@ ${e.toString()}`);
10645
10645
  var require_distribution = __commonJS({
10646
10646
  "../../node_modules/fast-formula-parser/formulas/functions/distribution.js"(exports2, module2) {
10647
10647
  var FormulaError = require_error();
10648
- var { FormulaHelpers, Types } = require_helpers();
10649
- var H = FormulaHelpers;
10648
+ var { FormulaHelpers: FormulaHelpers3, Types: Types3 } = require_helpers();
10649
+ var H = FormulaHelpers3;
10650
10650
  var jStat2 = require_jstat();
10651
10651
  var MathFunctions = require_math();
10652
10652
  var SQRT2PI2 = 2.5066282746310002;
10653
10653
  var DistributionFunctions = {
10654
10654
  "BETA.DIST": (x2, alpha, beta, cumulative, a, b) => {
10655
- x2 = H.accept(x2, Types.NUMBER);
10656
- alpha = H.accept(alpha, Types.NUMBER);
10657
- beta = H.accept(beta, Types.NUMBER);
10658
- cumulative = H.accept(cumulative, Types.BOOLEAN);
10659
- a = H.accept(a, Types.NUMBER, 0);
10660
- b = H.accept(b, Types.NUMBER, 1);
10655
+ x2 = H.accept(x2, Types3.NUMBER);
10656
+ alpha = H.accept(alpha, Types3.NUMBER);
10657
+ beta = H.accept(beta, Types3.NUMBER);
10658
+ cumulative = H.accept(cumulative, Types3.BOOLEAN);
10659
+ a = H.accept(a, Types3.NUMBER, 0);
10660
+ b = H.accept(b, Types3.NUMBER, 1);
10661
10661
  if (alpha <= 0 || beta <= 0 || x2 < a || x2 > b || a === b)
10662
10662
  throw FormulaError.NUM;
10663
10663
  x2 = (x2 - a) / (b - a);
10664
10664
  return cumulative ? jStat2.beta.cdf(x2, alpha, beta) : jStat2.beta.pdf(x2, alpha, beta) / (b - a);
10665
10665
  },
10666
10666
  "BETA.INV": (probability, alpha, beta, a, b) => {
10667
- probability = H.accept(probability, Types.NUMBER);
10668
- alpha = H.accept(alpha, Types.NUMBER);
10669
- beta = H.accept(beta, Types.NUMBER);
10670
- a = H.accept(a, Types.NUMBER, 0);
10671
- b = H.accept(b, Types.NUMBER, 1);
10667
+ probability = H.accept(probability, Types3.NUMBER);
10668
+ alpha = H.accept(alpha, Types3.NUMBER);
10669
+ beta = H.accept(beta, Types3.NUMBER);
10670
+ a = H.accept(a, Types3.NUMBER, 0);
10671
+ b = H.accept(b, Types3.NUMBER, 1);
10672
10672
  if (alpha <= 0 || beta <= 0 || probability <= 0 || probability > 1)
10673
10673
  throw FormulaError.NUM;
10674
10674
  return jStat2.beta.inv(probability, alpha, beta) * (b - a) + a;
10675
10675
  },
10676
10676
  "BINOM.DIST": (numberS, trials, probabilityS, cumulative) => {
10677
- numberS = H.accept(numberS, Types.NUMBER);
10678
- trials = H.accept(trials, Types.NUMBER);
10679
- probabilityS = H.accept(probabilityS, Types.NUMBER);
10680
- cumulative = H.accept(cumulative, Types.BOOLEAN);
10677
+ numberS = H.accept(numberS, Types3.NUMBER);
10678
+ trials = H.accept(trials, Types3.NUMBER);
10679
+ probabilityS = H.accept(probabilityS, Types3.NUMBER);
10680
+ cumulative = H.accept(cumulative, Types3.BOOLEAN);
10681
10681
  if (trials < 0 || probabilityS < 0 || probabilityS > 1 || numberS < 0 || numberS > trials)
10682
10682
  throw FormulaError.NUM;
10683
10683
  return cumulative ? jStat2.binomial.cdf(numberS, trials, probabilityS) : jStat2.binomial.pdf(numberS, trials, probabilityS);
10684
10684
  },
10685
10685
  "BINOM.DIST.RANGE": (trials, probabilityS, numberS, numberS2) => {
10686
- trials = H.accept(trials, Types.NUMBER);
10687
- probabilityS = H.accept(probabilityS, Types.NUMBER);
10688
- numberS = H.accept(numberS, Types.NUMBER);
10689
- numberS2 = H.accept(numberS2, Types.NUMBER, numberS);
10686
+ trials = H.accept(trials, Types3.NUMBER);
10687
+ probabilityS = H.accept(probabilityS, Types3.NUMBER);
10688
+ numberS = H.accept(numberS, Types3.NUMBER);
10689
+ numberS2 = H.accept(numberS2, Types3.NUMBER, numberS);
10690
10690
  if (trials < 0 || probabilityS < 0 || probabilityS > 1 || numberS < 0 || numberS > trials || numberS2 < numberS || numberS2 > trials)
10691
10691
  throw FormulaError.NUM;
10692
10692
  let result = 0;
@@ -10696,9 +10696,9 @@ ${e.toString()}`);
10696
10696
  return result;
10697
10697
  },
10698
10698
  "BINOM.INV": (trials, probabilityS, alpha) => {
10699
- trials = H.accept(trials, Types.NUMBER);
10700
- probabilityS = H.accept(probabilityS, Types.NUMBER);
10701
- alpha = H.accept(alpha, Types.NUMBER);
10699
+ trials = H.accept(trials, Types3.NUMBER);
10700
+ probabilityS = H.accept(probabilityS, Types3.NUMBER);
10701
+ alpha = H.accept(alpha, Types3.NUMBER);
10702
10702
  if (trials < 0 || probabilityS < 0 || probabilityS > 1 || alpha < 0 || alpha > 1)
10703
10703
  throw FormulaError.NUM;
10704
10704
  let x2 = 0;
@@ -10710,41 +10710,41 @@ ${e.toString()}`);
10710
10710
  }
10711
10711
  },
10712
10712
  "CHISQ.DIST": (x2, degFreedom, cumulative) => {
10713
- x2 = H.accept(x2, Types.NUMBER);
10714
- degFreedom = H.accept(degFreedom, Types.NUMBER);
10715
- cumulative = H.accept(cumulative, Types.NUMBER);
10713
+ x2 = H.accept(x2, Types3.NUMBER);
10714
+ degFreedom = H.accept(degFreedom, Types3.NUMBER);
10715
+ cumulative = H.accept(cumulative, Types3.NUMBER);
10716
10716
  degFreedom = Math.trunc(degFreedom);
10717
10717
  if (x2 < 0 || degFreedom < 1 || degFreedom > 10 ** 10)
10718
10718
  throw FormulaError.NUM;
10719
10719
  return cumulative ? jStat2.chisquare.cdf(x2, degFreedom) : jStat2.chisquare.pdf(x2, degFreedom);
10720
10720
  },
10721
10721
  "CHISQ.DIST.RT": (x2, degFreedom) => {
10722
- x2 = H.accept(x2, Types.NUMBER);
10723
- degFreedom = H.accept(degFreedom, Types.NUMBER);
10722
+ x2 = H.accept(x2, Types3.NUMBER);
10723
+ degFreedom = H.accept(degFreedom, Types3.NUMBER);
10724
10724
  degFreedom = Math.trunc(degFreedom);
10725
10725
  if (x2 < 0 || degFreedom < 1 || degFreedom > 10 ** 10)
10726
10726
  throw FormulaError.NUM;
10727
10727
  return 1 - jStat2.chisquare.cdf(x2, degFreedom);
10728
10728
  },
10729
10729
  "CHISQ.INV": (probability, degFreedom) => {
10730
- probability = H.accept(probability, Types.NUMBER);
10731
- degFreedom = H.accept(degFreedom, Types.NUMBER);
10730
+ probability = H.accept(probability, Types3.NUMBER);
10731
+ degFreedom = H.accept(degFreedom, Types3.NUMBER);
10732
10732
  degFreedom = Math.trunc(degFreedom);
10733
10733
  if (probability < 0 || probability > 1 || degFreedom < 1 || degFreedom > 10 ** 10)
10734
10734
  throw FormulaError.NUM;
10735
10735
  return jStat2.chisquare.inv(probability, degFreedom);
10736
10736
  },
10737
10737
  "CHISQ.INV.RT": (probability, degFreedom) => {
10738
- probability = H.accept(probability, Types.NUMBER);
10739
- degFreedom = H.accept(degFreedom, Types.NUMBER);
10738
+ probability = H.accept(probability, Types3.NUMBER);
10739
+ degFreedom = H.accept(degFreedom, Types3.NUMBER);
10740
10740
  degFreedom = Math.trunc(degFreedom);
10741
10741
  if (probability < 0 || probability > 1 || degFreedom < 1 || degFreedom > 10 ** 10)
10742
10742
  throw FormulaError.NUM;
10743
10743
  return jStat2.chisquare.inv(1 - probability, degFreedom);
10744
10744
  },
10745
10745
  "CHISQ.TEST": (actualRange, expectedRange) => {
10746
- const actual = H.accept(actualRange, Types.ARRAY, void 0, false, false);
10747
- const expected = H.accept(expectedRange, Types.ARRAY, void 0, false, false);
10746
+ const actual = H.accept(actualRange, Types3.ARRAY, void 0, false, false);
10747
+ const expected = H.accept(expectedRange, Types3.ARRAY, void 0, false, false);
10748
10748
  if (actual.length !== expected.length || actual[0].length !== expected[0].length || actual.length === 1 && actual[0].length === 1)
10749
10749
  throw FormulaError.NA;
10750
10750
  const row = actual.length;
@@ -10781,18 +10781,18 @@ ${e.toString()}`);
10781
10781
  return 1 - p;
10782
10782
  },
10783
10783
  "CONFIDENCE.NORM": (alpha, std, size) => {
10784
- alpha = H.accept(alpha, Types.NUMBER);
10785
- std = H.accept(std, Types.NUMBER);
10786
- size = H.accept(size, Types.NUMBER);
10784
+ alpha = H.accept(alpha, Types3.NUMBER);
10785
+ std = H.accept(std, Types3.NUMBER);
10786
+ size = H.accept(size, Types3.NUMBER);
10787
10787
  size = Math.trunc(size);
10788
10788
  if (alpha <= 0 || alpha >= 1 || std <= 0 || size < 1)
10789
10789
  throw FormulaError.NUM;
10790
10790
  return jStat2.normalci(1, alpha, std, size)[1] - 1;
10791
10791
  },
10792
10792
  "CONFIDENCE.T": (alpha, std, size) => {
10793
- alpha = H.accept(alpha, Types.NUMBER);
10794
- std = H.accept(std, Types.NUMBER);
10795
- size = H.accept(size, Types.NUMBER);
10793
+ alpha = H.accept(alpha, Types3.NUMBER);
10794
+ std = H.accept(std, Types3.NUMBER);
10795
+ size = H.accept(size, Types3.NUMBER);
10796
10796
  size = Math.trunc(size);
10797
10797
  if (alpha <= 0 || alpha >= 1 || std <= 0 || size < 1)
10798
10798
  throw FormulaError.NUM;
@@ -10801,8 +10801,8 @@ ${e.toString()}`);
10801
10801
  return jStat2.tci(1, alpha, std, size)[1] - 1;
10802
10802
  },
10803
10803
  CORREL: (array1, array2) => {
10804
- array1 = H.accept(array1, Types.ARRAY, void 0, true, true);
10805
- array2 = H.accept(array2, Types.ARRAY, void 0, true, true);
10804
+ array1 = H.accept(array1, Types3.ARRAY, void 0, true, true);
10805
+ array2 = H.accept(array2, Types3.ARRAY, void 0, true, true);
10806
10806
  if (array1.length !== array2.length)
10807
10807
  throw FormulaError.NA;
10808
10808
  const filterArr1 = [], filterArr2 = [];
@@ -10817,8 +10817,8 @@ ${e.toString()}`);
10817
10817
  return jStat2.corrcoeff(filterArr1, filterArr2);
10818
10818
  },
10819
10819
  "COVARIANCE.P": (array1, array2) => {
10820
- array1 = H.accept(array1, Types.ARRAY, void 0, true, true);
10821
- array2 = H.accept(array2, Types.ARRAY, void 0, true, true);
10820
+ array1 = H.accept(array1, Types3.ARRAY, void 0, true, true);
10821
+ array2 = H.accept(array2, Types3.ARRAY, void 0, true, true);
10822
10822
  if (array1.length !== array2.length)
10823
10823
  throw FormulaError.NA;
10824
10824
  const filterArr1 = [], filterArr2 = [];
@@ -10836,8 +10836,8 @@ ${e.toString()}`);
10836
10836
  return result / filterArr1.length;
10837
10837
  },
10838
10838
  "COVARIANCE.S": (array1, array2) => {
10839
- array1 = H.accept(array1, Types.ARRAY, void 0, true, true);
10840
- array2 = H.accept(array2, Types.ARRAY, void 0, true, true);
10839
+ array1 = H.accept(array1, Types3.ARRAY, void 0, true, true);
10840
+ array2 = H.accept(array2, Types3.ARRAY, void 0, true, true);
10841
10841
  if (array1.length !== array2.length)
10842
10842
  throw FormulaError.NA;
10843
10843
  const filterArr1 = [], filterArr2 = [];
@@ -10853,7 +10853,7 @@ ${e.toString()}`);
10853
10853
  },
10854
10854
  DEVSQ: (...numbers2) => {
10855
10855
  let sum = 0, x2 = [];
10856
- H.flattenParams(numbers2, Types.NUMBER, true, (item, info) => {
10856
+ H.flattenParams(numbers2, Types3.NUMBER, true, (item, info) => {
10857
10857
  if (typeof item === "number") {
10858
10858
  sum += item;
10859
10859
  x2.push(item);
@@ -10867,18 +10867,18 @@ ${e.toString()}`);
10867
10867
  return sum;
10868
10868
  },
10869
10869
  "EXPON.DIST": (x2, lambda, cumulative) => {
10870
- x2 = H.accept(x2, Types.NUMBER);
10871
- lambda = H.accept(lambda, Types.NUMBER);
10872
- cumulative = H.accept(cumulative, Types.BOOLEAN);
10870
+ x2 = H.accept(x2, Types3.NUMBER);
10871
+ lambda = H.accept(lambda, Types3.NUMBER);
10872
+ cumulative = H.accept(cumulative, Types3.BOOLEAN);
10873
10873
  if (x2 < 0 || lambda <= 0)
10874
10874
  throw FormulaError.NUM;
10875
10875
  return cumulative ? jStat2.exponential.cdf(x2, lambda) : jStat2.exponential.pdf(x2, lambda);
10876
10876
  },
10877
10877
  "F.DIST": (x2, d1, d2, cumulative) => {
10878
- x2 = H.accept(x2, Types.NUMBER);
10879
- d1 = H.accept(d1, Types.NUMBER);
10880
- d2 = H.accept(d2, Types.NUMBER);
10881
- cumulative = H.accept(cumulative, Types.BOOLEAN);
10878
+ x2 = H.accept(x2, Types3.NUMBER);
10879
+ d1 = H.accept(d1, Types3.NUMBER);
10880
+ d2 = H.accept(d2, Types3.NUMBER);
10881
+ cumulative = H.accept(cumulative, Types3.BOOLEAN);
10882
10882
  if (x2 < 0 || d1 < 1 || d2 < 1) {
10883
10883
  throw FormulaError.NUM;
10884
10884
  }
@@ -10887,9 +10887,9 @@ ${e.toString()}`);
10887
10887
  return cumulative ? jStat2.centralF.cdf(x2, d1, d2) : jStat2.centralF.pdf(x2, d1, d2);
10888
10888
  },
10889
10889
  "F.DIST.RT": (x2, d1, d2) => {
10890
- x2 = H.accept(x2, Types.NUMBER);
10891
- d1 = H.accept(d1, Types.NUMBER);
10892
- d2 = H.accept(d2, Types.NUMBER);
10890
+ x2 = H.accept(x2, Types3.NUMBER);
10891
+ d1 = H.accept(d1, Types3.NUMBER);
10892
+ d2 = H.accept(d2, Types3.NUMBER);
10893
10893
  if (x2 < 0 || d1 < 1 || d2 < 1) {
10894
10894
  throw FormulaError.NUM;
10895
10895
  }
@@ -10898,9 +10898,9 @@ ${e.toString()}`);
10898
10898
  return 1 - jStat2.centralF.cdf(x2, d1, d2);
10899
10899
  },
10900
10900
  "F.INV": (probability, d1, d2) => {
10901
- probability = H.accept(probability, Types.NUMBER);
10902
- d1 = H.accept(d1, Types.NUMBER);
10903
- d2 = H.accept(d2, Types.NUMBER);
10901
+ probability = H.accept(probability, Types3.NUMBER);
10902
+ d1 = H.accept(d1, Types3.NUMBER);
10903
+ d2 = H.accept(d2, Types3.NUMBER);
10904
10904
  if (probability < 0 || probability > 1) {
10905
10905
  throw FormulaError.NUM;
10906
10906
  }
@@ -10912,9 +10912,9 @@ ${e.toString()}`);
10912
10912
  return jStat2.centralF.inv(probability, d1, d2);
10913
10913
  },
10914
10914
  "F.INV.RT": (probability, d1, d2) => {
10915
- probability = H.accept(probability, Types.NUMBER);
10916
- d1 = H.accept(d1, Types.NUMBER);
10917
- d2 = H.accept(d2, Types.NUMBER);
10915
+ probability = H.accept(probability, Types3.NUMBER);
10916
+ d1 = H.accept(d1, Types3.NUMBER);
10917
+ d2 = H.accept(d2, Types3.NUMBER);
10918
10918
  if (probability < 0 || probability > 1) {
10919
10919
  throw FormulaError.NUM;
10920
10920
  }
@@ -10932,8 +10932,8 @@ ${e.toString()}`);
10932
10932
  * https://en.wikipedia.org/wiki/F-test_of_equality_of_variances
10933
10933
  */
10934
10934
  "F.TEST": (array1, array2) => {
10935
- array1 = H.accept(array1, Types.ARRAY, void 0, true, true);
10936
- array2 = H.accept(array2, Types.ARRAY, void 0, true, true);
10935
+ array1 = H.accept(array1, Types3.ARRAY, void 0, true, true);
10936
+ array2 = H.accept(array2, Types3.ARRAY, void 0, true, true);
10937
10937
  const x1 = [], x2 = [];
10938
10938
  let x1Mean = 0, x2Mean = 0;
10939
10939
  for (let i3 = 0; i3 < Math.max(array1.length, array2.length); i3++) {
@@ -10962,22 +10962,22 @@ ${e.toString()}`);
10962
10962
  return jStat2.centralF.cdf(s1 / s2, x1.length - 1, x2.length - 1) * 2;
10963
10963
  },
10964
10964
  FISHER: (x2) => {
10965
- x2 = H.accept(x2, Types.NUMBER);
10965
+ x2 = H.accept(x2, Types3.NUMBER);
10966
10966
  if (x2 <= -1 || x2 >= 1) {
10967
10967
  throw FormulaError.NUM;
10968
10968
  }
10969
10969
  return Math.log((1 + x2) / (1 - x2)) / 2;
10970
10970
  },
10971
10971
  FISHERINV: (x2) => {
10972
- x2 = H.accept(x2, Types.NUMBER);
10972
+ x2 = H.accept(x2, Types3.NUMBER);
10973
10973
  let e2y = Math.exp(2 * x2);
10974
10974
  return (e2y - 1) / (e2y + 1);
10975
10975
  },
10976
10976
  // FIXME
10977
10977
  FORECAST: (x2, knownYs, knownXs) => {
10978
- x2 = H.accept(x2, Types.NUMBER);
10979
- knownYs = H.accept(knownYs, Types.ARRAY, void 0, true, true);
10980
- knownXs = H.accept(knownXs, Types.ARRAY, void 0, true, true);
10978
+ x2 = H.accept(x2, Types3.NUMBER);
10979
+ knownYs = H.accept(knownYs, Types3.ARRAY, void 0, true, true);
10980
+ knownXs = H.accept(knownXs, Types3.ARRAY, void 0, true, true);
10981
10981
  if (knownXs.length !== knownYs.length)
10982
10982
  throw FormulaError.NA;
10983
10983
  const filteredY = [], filteredX = [];
@@ -11015,8 +11015,8 @@ ${e.toString()}`);
11015
11015
  return DistributionFunctions.FORECAST(...params);
11016
11016
  },
11017
11017
  FREQUENCY: (dataArray, binsArray) => {
11018
- dataArray = H.accept(dataArray, Types.ARRAY, void 0, true, true);
11019
- binsArray = H.accept(binsArray, Types.ARRAY, void 0, true, true);
11018
+ dataArray = H.accept(dataArray, Types3.ARRAY, void 0, true, true);
11019
+ binsArray = H.accept(binsArray, Types3.ARRAY, void 0, true, true);
11020
11020
  const binsArrayFiltered = [];
11021
11021
  for (let i3 = 0; i3 < binsArray.length; i3++) {
11022
11022
  if (typeof binsArray[i3] !== "number")
@@ -11043,52 +11043,52 @@ ${e.toString()}`);
11043
11043
  return result;
11044
11044
  },
11045
11045
  GAMMA: (x2) => {
11046
- x2 = H.accept(x2, Types.NUMBER);
11046
+ x2 = H.accept(x2, Types3.NUMBER);
11047
11047
  if (x2 === 0 || x2 < 0 && x2 === Math.trunc(x2)) {
11048
11048
  throw FormulaError.NUM;
11049
11049
  }
11050
11050
  return jStat2.gammafn(x2);
11051
11051
  },
11052
11052
  "GAMMA.DIST": (x2, alpha, beta, cumulative) => {
11053
- x2 = H.accept(x2, Types.NUMBER);
11054
- alpha = H.accept(alpha, Types.NUMBER);
11055
- beta = H.accept(beta, Types.NUMBER);
11056
- cumulative = H.accept(cumulative, Types.BOOLEAN);
11053
+ x2 = H.accept(x2, Types3.NUMBER);
11054
+ alpha = H.accept(alpha, Types3.NUMBER);
11055
+ beta = H.accept(beta, Types3.NUMBER);
11056
+ cumulative = H.accept(cumulative, Types3.BOOLEAN);
11057
11057
  if (x2 < 0 || alpha <= 0 || beta <= 0) {
11058
11058
  throw FormulaError.NUM;
11059
11059
  }
11060
11060
  return cumulative ? jStat2.gamma.cdf(x2, alpha, beta, true) : jStat2.gamma.pdf(x2, alpha, beta, false);
11061
11061
  },
11062
11062
  "GAMMA.INV": (probability, alpha, beta) => {
11063
- probability = H.accept(probability, Types.NUMBER);
11064
- alpha = H.accept(alpha, Types.NUMBER);
11065
- beta = H.accept(beta, Types.NUMBER);
11063
+ probability = H.accept(probability, Types3.NUMBER);
11064
+ alpha = H.accept(alpha, Types3.NUMBER);
11065
+ beta = H.accept(beta, Types3.NUMBER);
11066
11066
  if (probability < 0 || probability > 1 || alpha <= 0 || beta <= 0) {
11067
11067
  throw FormulaError.NUM;
11068
11068
  }
11069
11069
  return jStat2.gamma.inv(probability, alpha, beta);
11070
11070
  },
11071
11071
  GAMMALN: (x2) => {
11072
- x2 = H.accept(x2, Types.NUMBER);
11072
+ x2 = H.accept(x2, Types3.NUMBER);
11073
11073
  if (x2 <= 0) {
11074
11074
  throw FormulaError.NUM;
11075
11075
  }
11076
11076
  return jStat2.gammaln(x2);
11077
11077
  },
11078
11078
  "GAMMALN.PRECISE": (x2) => {
11079
- x2 = H.accept(x2, Types.NUMBER);
11079
+ x2 = H.accept(x2, Types3.NUMBER);
11080
11080
  if (x2 <= 0) {
11081
11081
  throw FormulaError.NUM;
11082
11082
  }
11083
11083
  return jStat2.gammaln(x2);
11084
11084
  },
11085
11085
  GAUSS: (z) => {
11086
- z = H.accept(z, Types.NUMBER);
11086
+ z = H.accept(z, Types3.NUMBER);
11087
11087
  return jStat2.normal.cdf(z, 0, 1) - 0.5;
11088
11088
  },
11089
11089
  GEOMEAN: (...numbers2) => {
11090
11090
  const filterArr = [];
11091
- H.flattenParams(numbers2, Types.NUMBER, true, (item, info) => {
11091
+ H.flattenParams(numbers2, Types3.NUMBER, true, (item, info) => {
11092
11092
  if (typeof item === "number") {
11093
11093
  filterArr.push(item);
11094
11094
  }
@@ -11096,12 +11096,12 @@ ${e.toString()}`);
11096
11096
  return jStat2.geomean(filterArr);
11097
11097
  },
11098
11098
  GROWTH: (knownY, knownX, newX, useConst) => {
11099
- knownY = H.accept(knownY, Types.ARRAY, void 0, true, true);
11099
+ knownY = H.accept(knownY, Types3.ARRAY, void 0, true, true);
11100
11100
  for (let i3 = 0; i3 < knownY.length; i3++) {
11101
11101
  if (typeof knownY[i3] !== "number")
11102
11102
  throw FormulaError.VALUE;
11103
11103
  }
11104
- knownX = H.accept(knownX, Types.ARRAY, null, true, true);
11104
+ knownX = H.accept(knownX, Types3.ARRAY, null, true, true);
11105
11105
  const isKnownXOmitted = knownX == null;
11106
11106
  if (knownX == null) {
11107
11107
  knownX = [];
@@ -11116,7 +11116,7 @@ ${e.toString()}`);
11116
11116
  throw FormulaError.VALUE;
11117
11117
  }
11118
11118
  }
11119
- newX = H.accept(newX, Types.ARRAY, null, false, true);
11119
+ newX = H.accept(newX, Types3.ARRAY, null, false, true);
11120
11120
  if (newX == null && isKnownXOmitted) {
11121
11121
  newX = [];
11122
11122
  for (let i3 = 1; i3 <= knownY.length; i3++) {
@@ -11126,7 +11126,7 @@ ${e.toString()}`);
11126
11126
  } else if (newX == null) {
11127
11127
  newX = Array.isArray(knownX[0]) ? knownX : [knownX];
11128
11128
  }
11129
- useConst = H.accept(useConst, Types.BOOLEAN, true);
11129
+ useConst = H.accept(useConst, Types3.BOOLEAN, true);
11130
11130
  const n = knownY.length;
11131
11131
  let avg_x = 0, avg_y = 0, avg_xy = 0, avg_xx = 0;
11132
11132
  for (let i3 = 0; i3 < n; i3++) {
@@ -11163,7 +11163,7 @@ ${e.toString()}`);
11163
11163
  },
11164
11164
  HARMEAN: (...numbers2) => {
11165
11165
  let cnt = 0, denominator = 0;
11166
- H.flattenParams(numbers2, Types.NUMBER, true, (item, info) => {
11166
+ H.flattenParams(numbers2, Types3.NUMBER, true, (item, info) => {
11167
11167
  if (typeof item === "number") {
11168
11168
  denominator += 1 / item;
11169
11169
  cnt++;
@@ -11172,11 +11172,11 @@ ${e.toString()}`);
11172
11172
  return cnt / denominator;
11173
11173
  },
11174
11174
  "HYPGEOM.DIST": (sample_s, number_sample, population_s, number_pop, cumulative) => {
11175
- sample_s = H.accept(sample_s, Types.NUMBER);
11176
- number_sample = H.accept(number_sample, Types.NUMBER);
11177
- population_s = H.accept(population_s, Types.NUMBER);
11178
- number_pop = H.accept(number_pop, Types.NUMBER);
11179
- cumulative = H.accept(cumulative, Types.BOOLEAN);
11175
+ sample_s = H.accept(sample_s, Types3.NUMBER);
11176
+ number_sample = H.accept(number_sample, Types3.NUMBER);
11177
+ population_s = H.accept(population_s, Types3.NUMBER);
11178
+ number_pop = H.accept(number_pop, Types3.NUMBER);
11179
+ cumulative = H.accept(cumulative, Types3.BOOLEAN);
11180
11180
  sample_s = Math.trunc(sample_s);
11181
11181
  number_sample = Math.trunc(number_sample);
11182
11182
  population_s = Math.trunc(population_s);
@@ -11209,8 +11209,8 @@ ${e.toString()}`);
11209
11209
  return cumulative ? cdf(sample_s, number_sample, population_s, number_pop) : pdf(sample_s, number_sample, population_s, number_pop);
11210
11210
  },
11211
11211
  INTERCEPT: (knownYs, knownXs) => {
11212
- knownYs = H.accept(knownYs, Types.ARRAY, void 0, true, true);
11213
- knownXs = H.accept(knownXs, Types.ARRAY, void 0, true, true);
11212
+ knownYs = H.accept(knownYs, Types3.ARRAY, void 0, true, true);
11213
+ knownXs = H.accept(knownXs, Types3.ARRAY, void 0, true, true);
11214
11214
  if (knownXs.length !== knownYs.length)
11215
11215
  throw FormulaError.NA;
11216
11216
  const filteredY = [], filteredX = [];
@@ -11234,7 +11234,7 @@ ${e.toString()}`);
11234
11234
  },
11235
11235
  KURT: (...numbers2) => {
11236
11236
  let mean = 0, range = [];
11237
- H.flattenParams(numbers2, Types.NUMBER, true, (item, info) => {
11237
+ H.flattenParams(numbers2, Types3.NUMBER, true, (item, info) => {
11238
11238
  if (typeof item === "number") {
11239
11239
  mean += item;
11240
11240
  range.push(item);
@@ -11254,19 +11254,19 @@ ${e.toString()}`);
11254
11254
  LOGEST: () => {
11255
11255
  },
11256
11256
  "LOGNORM.DIST": (x2, mean, standard_dev, cumulative) => {
11257
- x2 = H.accept(x2, Types.NUMBER);
11258
- mean = H.accept(mean, Types.NUMBER);
11259
- standard_dev = H.accept(standard_dev, Types.NUMBER);
11260
- cumulative = H.accept(cumulative, Types.BOOLEAN);
11257
+ x2 = H.accept(x2, Types3.NUMBER);
11258
+ mean = H.accept(mean, Types3.NUMBER);
11259
+ standard_dev = H.accept(standard_dev, Types3.NUMBER);
11260
+ cumulative = H.accept(cumulative, Types3.BOOLEAN);
11261
11261
  if (x2 <= 0 || standard_dev <= 0) {
11262
11262
  throw FormulaError.NUM;
11263
11263
  }
11264
11264
  return cumulative ? jStat2.lognormal.cdf(x2, mean, standard_dev) : jStat2.lognormal.pdf(x2, mean, standard_dev);
11265
11265
  },
11266
11266
  "LOGNORM.INV": (probability, mean, standard_dev) => {
11267
- probability = H.accept(probability, Types.NUMBER);
11268
- mean = H.accept(mean, Types.NUMBER);
11269
- standard_dev = H.accept(standard_dev, Types.NUMBER);
11267
+ probability = H.accept(probability, Types3.NUMBER);
11268
+ mean = H.accept(mean, Types3.NUMBER);
11269
+ standard_dev = H.accept(standard_dev, Types3.NUMBER);
11270
11270
  if (probability <= 0 || probability >= 1) {
11271
11271
  throw FormulaError.NUM;
11272
11272
  }
@@ -11280,10 +11280,10 @@ ${e.toString()}`);
11280
11280
  "MODE.SNGL": () => {
11281
11281
  },
11282
11282
  "NEGBINOM.DIST": (number_f, number_s, probability_s, cumulative) => {
11283
- number_f = H.accept(number_f, Types.NUMBER);
11284
- number_s = H.accept(number_s, Types.NUMBER);
11285
- probability_s = H.accept(probability_s, Types.NUMBER);
11286
- cumulative = H.accept(cumulative, Types.BOOLEAN);
11283
+ number_f = H.accept(number_f, Types3.NUMBER);
11284
+ number_s = H.accept(number_s, Types3.NUMBER);
11285
+ probability_s = H.accept(probability_s, Types3.NUMBER);
11286
+ cumulative = H.accept(cumulative, Types3.BOOLEAN);
11287
11287
  number_f = Math.trunc(number_f);
11288
11288
  number_s = Math.trunc(number_s);
11289
11289
  if (probability_s < 0 || probability_s > 1) {
@@ -11295,19 +11295,19 @@ ${e.toString()}`);
11295
11295
  return cumulative ? jStat2.negbin.cdf(number_f, number_s, probability_s) : jStat2.negbin.pdf(number_f, number_s, probability_s);
11296
11296
  },
11297
11297
  "NORM.DIST": (x2, mean, standard_dev, cumulative) => {
11298
- x2 = H.accept(x2, Types.NUMBER);
11299
- mean = H.accept(mean, Types.NUMBER);
11300
- standard_dev = H.accept(standard_dev, Types.NUMBER);
11301
- cumulative = H.accept(cumulative, Types.BOOLEAN);
11298
+ x2 = H.accept(x2, Types3.NUMBER);
11299
+ mean = H.accept(mean, Types3.NUMBER);
11300
+ standard_dev = H.accept(standard_dev, Types3.NUMBER);
11301
+ cumulative = H.accept(cumulative, Types3.BOOLEAN);
11302
11302
  if (standard_dev <= 0) {
11303
11303
  throw FormulaError.NUM;
11304
11304
  }
11305
11305
  return cumulative ? jStat2.normal.cdf(x2, mean, standard_dev) : jStat2.normal.pdf(x2, mean, standard_dev);
11306
11306
  },
11307
11307
  "NORM.INV": (probability, mean, standard_dev) => {
11308
- probability = H.accept(probability, Types.NUMBER);
11309
- mean = H.accept(mean, Types.NUMBER);
11310
- standard_dev = H.accept(standard_dev, Types.NUMBER);
11308
+ probability = H.accept(probability, Types3.NUMBER);
11309
+ mean = H.accept(mean, Types3.NUMBER);
11310
+ standard_dev = H.accept(standard_dev, Types3.NUMBER);
11311
11311
  if (probability <= 0 || probability >= 1) {
11312
11312
  throw FormulaError.NUM;
11313
11313
  }
@@ -11317,12 +11317,12 @@ ${e.toString()}`);
11317
11317
  return jStat2.normal.inv(probability, mean, standard_dev);
11318
11318
  },
11319
11319
  "NORM.S.DIST": (z, cumulative) => {
11320
- z = H.accept(z, Types.NUMBER);
11321
- cumulative = H.accept(cumulative, Types.BOOLEAN);
11320
+ z = H.accept(z, Types3.NUMBER);
11321
+ cumulative = H.accept(cumulative, Types3.BOOLEAN);
11322
11322
  return cumulative ? jStat2.normal.cdf(z, 0, 1) : jStat2.normal.pdf(z, 0, 1);
11323
11323
  },
11324
11324
  "NORM.S.INV": (probability) => {
11325
- probability = H.accept(probability, Types.NUMBER);
11325
+ probability = H.accept(probability, Types3.NUMBER);
11326
11326
  if (probability <= 0 || probability >= 1) {
11327
11327
  throw FormulaError.NUM;
11328
11328
  }
@@ -11341,13 +11341,13 @@ ${e.toString()}`);
11341
11341
  PERMUTATIONA: () => {
11342
11342
  },
11343
11343
  PHI: (x2) => {
11344
- x2 = H.accept(x2, Types.NUMBER);
11344
+ x2 = H.accept(x2, Types3.NUMBER);
11345
11345
  return Math.exp(-0.5 * x2 * x2) / SQRT2PI2;
11346
11346
  },
11347
11347
  "POISSON.DIST": (x2, mean, cumulative) => {
11348
- x2 = H.accept(x2, Types.NUMBER);
11349
- mean = H.accept(mean, Types.NUMBER);
11350
- cumulative = H.accept(cumulative, Types.BOOLEAN);
11348
+ x2 = H.accept(x2, Types3.NUMBER);
11349
+ mean = H.accept(mean, Types3.NUMBER);
11350
+ cumulative = H.accept(cumulative, Types3.BOOLEAN);
11351
11351
  if (x2 < 0 || mean < 0) {
11352
11352
  throw FormulaError.NUM;
11353
11353
  }
@@ -11373,9 +11373,9 @@ ${e.toString()}`);
11373
11373
  SLOPE: () => {
11374
11374
  },
11375
11375
  STANDARDIZE: (x2, mean, standard_dev) => {
11376
- x2 = H.accept(x2, Types.NUMBER);
11377
- mean = H.accept(mean, Types.NUMBER);
11378
- standard_dev = H.accept(standard_dev, Types.NUMBER);
11376
+ x2 = H.accept(x2, Types3.NUMBER);
11377
+ mean = H.accept(mean, Types3.NUMBER);
11378
+ standard_dev = H.accept(standard_dev, Types3.NUMBER);
11379
11379
  if (standard_dev <= 0) {
11380
11380
  throw FormulaError.NUM;
11381
11381
  }
@@ -11392,33 +11392,33 @@ ${e.toString()}`);
11392
11392
  STEYX: () => {
11393
11393
  },
11394
11394
  "T.DIST": (x2, deg_freedom, cumulative) => {
11395
- x2 = H.accept(x2, Types.NUMBER);
11396
- deg_freedom = H.accept(deg_freedom, Types.NUMBER);
11397
- cumulative = H.accept(cumulative, Types.BOOLEAN);
11395
+ x2 = H.accept(x2, Types3.NUMBER);
11396
+ deg_freedom = H.accept(deg_freedom, Types3.NUMBER);
11397
+ cumulative = H.accept(cumulative, Types3.BOOLEAN);
11398
11398
  if (deg_freedom < 1) {
11399
11399
  throw FormulaError.NUM;
11400
11400
  }
11401
11401
  return cumulative ? jStat2.studentt.cdf(x2, deg_freedom) : jStat2.studentt.pdf(x2, deg_freedom);
11402
11402
  },
11403
11403
  "T.DIST.2T": (x2, deg_freedom) => {
11404
- x2 = H.accept(x2, Types.NUMBER);
11405
- deg_freedom = H.accept(deg_freedom, Types.NUMBER);
11404
+ x2 = H.accept(x2, Types3.NUMBER);
11405
+ deg_freedom = H.accept(deg_freedom, Types3.NUMBER);
11406
11406
  if (deg_freedom < 1 || x2 < 0) {
11407
11407
  throw FormulaError.NUM;
11408
11408
  }
11409
11409
  return (1 - jStat2.studentt.cdf(x2, deg_freedom)) * 2;
11410
11410
  },
11411
11411
  "T.DIST.RT": (x2, deg_freedom) => {
11412
- x2 = H.accept(x2, Types.NUMBER);
11413
- deg_freedom = H.accept(deg_freedom, Types.NUMBER);
11412
+ x2 = H.accept(x2, Types3.NUMBER);
11413
+ deg_freedom = H.accept(deg_freedom, Types3.NUMBER);
11414
11414
  if (deg_freedom < 1) {
11415
11415
  throw FormulaError.NUM;
11416
11416
  }
11417
11417
  return 1 - jStat2.studentt.cdf(x2, deg_freedom);
11418
11418
  },
11419
11419
  "T.INV": (probability, deg_freedom) => {
11420
- probability = H.accept(probability, Types.NUMBER);
11421
- deg_freedom = H.accept(deg_freedom, Types.NUMBER);
11420
+ probability = H.accept(probability, Types3.NUMBER);
11421
+ deg_freedom = H.accept(deg_freedom, Types3.NUMBER);
11422
11422
  if (probability <= 0 || probability > 1 || deg_freedom < 1) {
11423
11423
  throw FormulaError.NUM;
11424
11424
  }
@@ -11426,8 +11426,8 @@ ${e.toString()}`);
11426
11426
  return jStat2.studentt.inv(probability, deg_freedom);
11427
11427
  },
11428
11428
  "T.INV.2T": (probability, deg_freedom) => {
11429
- probability = H.accept(probability, Types.NUMBER);
11430
- deg_freedom = H.accept(deg_freedom, Types.NUMBER);
11429
+ probability = H.accept(probability, Types3.NUMBER);
11430
+ deg_freedom = H.accept(deg_freedom, Types3.NUMBER);
11431
11431
  if (probability <= 0 || probability > 1 || deg_freedom < 1) {
11432
11432
  throw FormulaError.NUM;
11433
11433
  }
@@ -11449,10 +11449,10 @@ ${e.toString()}`);
11449
11449
  "VARPA": () => {
11450
11450
  },
11451
11451
  "WEIBULL.DIST": (x2, alpha, beta, cumulative) => {
11452
- x2 = H.accept(x2, Types.NUMBER);
11453
- alpha = H.accept(alpha, Types.NUMBER);
11454
- beta = H.accept(beta, Types.NUMBER);
11455
- cumulative = H.accept(cumulative, Types.BOOLEAN);
11452
+ x2 = H.accept(x2, Types3.NUMBER);
11453
+ alpha = H.accept(alpha, Types3.NUMBER);
11454
+ beta = H.accept(beta, Types3.NUMBER);
11455
+ cumulative = H.accept(cumulative, Types3.BOOLEAN);
11456
11456
  if (x2 < 0 || alpha <= 0 || beta <= 0) {
11457
11457
  throw FormulaError.NUM;
11458
11458
  }
@@ -11471,15 +11471,15 @@ ${e.toString()}`);
11471
11471
  var require_statistical = __commonJS({
11472
11472
  "../../node_modules/fast-formula-parser/formulas/functions/statistical.js"(exports2, module2) {
11473
11473
  var FormulaError = require_error();
11474
- var { FormulaHelpers, Types, Criteria, Address } = require_helpers();
11474
+ var { FormulaHelpers: FormulaHelpers3, Types: Types3, Criteria, Address } = require_helpers();
11475
11475
  var { Infix: Infix2 } = require_operators();
11476
- var H = FormulaHelpers;
11476
+ var H = FormulaHelpers3;
11477
11477
  var { DistributionFunctions } = require_distribution();
11478
11478
  var StatisticalFunctions = {
11479
11479
  AVEDEV: (...numbers2) => {
11480
11480
  let sum = 0;
11481
11481
  const arr = [];
11482
- H.flattenParams(numbers2, Types.NUMBER, true, (item, info) => {
11482
+ H.flattenParams(numbers2, Types3.NUMBER, true, (item, info) => {
11483
11483
  if (typeof item === "number") {
11484
11484
  sum += item;
11485
11485
  arr.push(item);
@@ -11494,7 +11494,7 @@ ${e.toString()}`);
11494
11494
  },
11495
11495
  AVERAGE: (...numbers2) => {
11496
11496
  let sum = 0, cnt = 0;
11497
- H.flattenParams(numbers2, Types.NUMBER, true, (item, info) => {
11497
+ H.flattenParams(numbers2, Types3.NUMBER, true, (item, info) => {
11498
11498
  if (typeof item === "number") {
11499
11499
  sum += item;
11500
11500
  cnt++;
@@ -11504,7 +11504,7 @@ ${e.toString()}`);
11504
11504
  },
11505
11505
  AVERAGEA: (...numbers2) => {
11506
11506
  let sum = 0, cnt = 0;
11507
- H.flattenParams(numbers2, Types.NUMBER, true, (item, info) => {
11507
+ H.flattenParams(numbers2, Types3.NUMBER, true, (item, info) => {
11508
11508
  const type = typeof item;
11509
11509
  if (type === "number") {
11510
11510
  sum += item;
@@ -11563,7 +11563,7 @@ ${e.toString()}`);
11563
11563
  return cnt;
11564
11564
  },
11565
11565
  COUNTIF: (range, criteria) => {
11566
- range = H.accept(range, Types.ARRAY, void 0, false, true);
11566
+ range = H.accept(range, Types3.ARRAY, void 0, false, true);
11567
11567
  const isCriteriaArray = criteria.isArray;
11568
11568
  criteria = H.accept(criteria);
11569
11569
  let cnt = 0;
@@ -11611,8 +11611,8 @@ ${e.toString()}`);
11611
11611
  var require_date = __commonJS({
11612
11612
  "../../node_modules/fast-formula-parser/formulas/functions/date.js"(exports2, module2) {
11613
11613
  var FormulaError = require_error();
11614
- var { FormulaHelpers, Types } = require_helpers();
11615
- var H = FormulaHelpers;
11614
+ var { FormulaHelpers: FormulaHelpers3, Types: Types3 } = require_helpers();
11615
+ var H = FormulaHelpers3;
11616
11616
  var MS_PER_DAY2 = 1e3 * 60 * 60 * 24;
11617
11617
  var d1900 = new Date(Date.UTC(1900, 0, 1));
11618
11618
  var WEEK_STARTS2 = [
@@ -11764,9 +11764,9 @@ ${e.toString()}`);
11764
11764
  }
11765
11765
  var DateFunctions = {
11766
11766
  DATE: (year, month, day) => {
11767
- year = H.accept(year, Types.NUMBER);
11768
- month = H.accept(month, Types.NUMBER);
11769
- day = H.accept(day, Types.NUMBER);
11767
+ year = H.accept(year, Types3.NUMBER);
11768
+ month = H.accept(month, Types3.NUMBER);
11769
+ day = H.accept(day, Types3.NUMBER);
11770
11770
  if (year < 0 || year >= 1e4)
11771
11771
  throw FormulaError.NUM;
11772
11772
  if (year < 1900) {
@@ -11777,7 +11777,7 @@ ${e.toString()}`);
11777
11777
  DATEDIF: (startDate, endDate, unit) => {
11778
11778
  startDate = parseDate2(startDate);
11779
11779
  endDate = parseDate2(endDate);
11780
- unit = H.accept(unit, Types.STRING).toLowerCase();
11780
+ unit = H.accept(unit, Types3.STRING).toLowerCase();
11781
11781
  if (startDate > endDate)
11782
11782
  throw FormulaError.NUM;
11783
11783
  const yearDiff = endDate.getUTCFullYear() - startDate.getUTCFullYear();
@@ -11819,7 +11819,7 @@ ${e.toString()}`);
11819
11819
  * @param {string} dateText
11820
11820
  */
11821
11821
  DATEVALUE: (dateText) => {
11822
- dateText = H.accept(dateText, Types.STRING);
11822
+ dateText = H.accept(dateText, Types3.STRING);
11823
11823
  const { date: date2, isDateGiven } = parseDateWithExtra(dateText);
11824
11824
  if (!isDateGiven) return 0;
11825
11825
  const serial = toSerial(date2);
@@ -11843,7 +11843,7 @@ ${e.toString()}`);
11843
11843
  DAYS360: (startDate, endDate, method) => {
11844
11844
  startDate = parseDate2(startDate);
11845
11845
  endDate = parseDate2(endDate);
11846
- method = H.accept(method, Types.BOOLEAN, false);
11846
+ method = H.accept(method, Types3.BOOLEAN, false);
11847
11847
  if (startDate.getUTCDate() === 31) {
11848
11848
  startDate.setUTCDate(30);
11849
11849
  }
@@ -11861,13 +11861,13 @@ ${e.toString()}`);
11861
11861
  },
11862
11862
  EDATE: (startDate, months) => {
11863
11863
  startDate = parseDate2(startDate);
11864
- months = H.accept(months, Types.NUMBER);
11864
+ months = H.accept(months, Types3.NUMBER);
11865
11865
  startDate.setUTCMonth(startDate.getUTCMonth() + months);
11866
11866
  return toSerial(startDate);
11867
11867
  },
11868
11868
  EOMONTH: (startDate, months) => {
11869
11869
  startDate = parseDate2(startDate);
11870
- months = H.accept(months, Types.NUMBER);
11870
+ months = H.accept(months, Types3.NUMBER);
11871
11871
  startDate.setUTCMonth(startDate.getUTCMonth() + months + 1, 0);
11872
11872
  return toSerial(startDate);
11873
11873
  },
@@ -11903,7 +11903,7 @@ ${e.toString()}`);
11903
11903
  }
11904
11904
  const holidaysArr = [];
11905
11905
  if (holidays != null) {
11906
- H.flattenParams([holidays], Types.NUMBER, false, (item) => {
11906
+ H.flattenParams([holidays], Types3.NUMBER, false, (item) => {
11907
11907
  holidaysArr.push(parseDate2(item));
11908
11908
  });
11909
11909
  }
@@ -11952,7 +11952,7 @@ ${e.toString()}`);
11952
11952
  }
11953
11953
  const holidaysArr = [];
11954
11954
  if (holidays != null) {
11955
- H.flattenParams([holidays], Types.NUMBER, false, (item) => {
11955
+ H.flattenParams([holidays], Types3.NUMBER, false, (item) => {
11956
11956
  holidaysArr.push(parseDate2(item));
11957
11957
  });
11958
11958
  }
@@ -11996,9 +11996,9 @@ ${e.toString()}`);
11996
11996
  return date2.getUTCSeconds();
11997
11997
  },
11998
11998
  TIME: (hour, minute, second) => {
11999
- hour = H.accept(hour, Types.NUMBER);
12000
- minute = H.accept(minute, Types.NUMBER);
12001
- second = H.accept(second, Types.NUMBER);
11999
+ hour = H.accept(hour, Types3.NUMBER);
12000
+ minute = H.accept(minute, Types3.NUMBER);
12001
+ second = H.accept(second, Types3.NUMBER);
12002
12002
  if (hour < 0 || hour > 32767 || minute < 0 || minute > 32767 || second < 0 || second > 32767)
12003
12003
  throw FormulaError.NUM;
12004
12004
  return (3600 * hour + 60 * minute + second) / 86400;
@@ -12013,7 +12013,7 @@ ${e.toString()}`);
12013
12013
  },
12014
12014
  WEEKDAY: (serialOrString, returnType) => {
12015
12015
  const date2 = parseDate2(serialOrString);
12016
- returnType = H.accept(returnType, Types.NUMBER, 1);
12016
+ returnType = H.accept(returnType, Types3.NUMBER, 1);
12017
12017
  const day = date2.getUTCDay();
12018
12018
  const weekTypes = WEEK_TYPES2[returnType];
12019
12019
  if (!weekTypes)
@@ -12022,7 +12022,7 @@ ${e.toString()}`);
12022
12022
  },
12023
12023
  WEEKNUM: (serialOrString, returnType) => {
12024
12024
  const date2 = parseDate2(serialOrString);
12025
- returnType = H.accept(returnType, Types.NUMBER, 1);
12025
+ returnType = H.accept(returnType, Types3.NUMBER, 1);
12026
12026
  if (returnType === 21) {
12027
12027
  return DateFunctions.ISOWEEKNUM(serialOrString);
12028
12028
  }
@@ -12036,7 +12036,7 @@ ${e.toString()}`);
12036
12036
  },
12037
12037
  "WORKDAY.INTL": (startDate, days, weekend, holidays) => {
12038
12038
  startDate = parseDate2(startDate);
12039
- days = H.accept(days, Types.NUMBER);
12039
+ days = H.accept(days, Types3.NUMBER);
12040
12040
  weekend = H.accept(weekend, null, 1);
12041
12041
  if (weekend === "1111111")
12042
12042
  throw FormulaError.VALUE;
@@ -12059,7 +12059,7 @@ ${e.toString()}`);
12059
12059
  }
12060
12060
  const holidaysArr = [];
12061
12061
  if (holidays != null) {
12062
- H.flattenParams([holidays], Types.NUMBER, false, (item) => {
12062
+ H.flattenParams([holidays], Types3.NUMBER, false, (item) => {
12063
12063
  holidaysArr.push(parseDate2(item));
12064
12064
  });
12065
12065
  }
@@ -12100,7 +12100,7 @@ ${e.toString()}`);
12100
12100
  startDate = endDate;
12101
12101
  endDate = temp;
12102
12102
  }
12103
- basis = H.accept(basis, Types.NUMBER, 0);
12103
+ basis = H.accept(basis, Types3.NUMBER, 0);
12104
12104
  basis = Math.trunc(basis);
12105
12105
  if (basis < 0 || basis > 4)
12106
12106
  throw FormulaError.VALUE;
@@ -12149,18 +12149,18 @@ ${e.toString()}`);
12149
12149
  var require_web = __commonJS({
12150
12150
  "../../node_modules/fast-formula-parser/formulas/functions/web.js"(exports2, module2) {
12151
12151
  var FormulaError = require_error();
12152
- var { FormulaHelpers, Types } = require_helpers();
12153
- var H = FormulaHelpers;
12152
+ var { FormulaHelpers: FormulaHelpers3, Types: Types3 } = require_helpers();
12153
+ var H = FormulaHelpers3;
12154
12154
  var WebFunctions = {
12155
12155
  ENCODEURL: (text) => {
12156
- return encodeURIComponent(H.accept(text, Types.STRING));
12156
+ return encodeURIComponent(H.accept(text, Types3.STRING));
12157
12157
  },
12158
12158
  FILTERXML: () => {
12159
12159
  },
12160
12160
  WEBSERVICE: (context, url) => {
12161
12161
  throw FormulaError.ERROR("WEBSERVICE is not supported in sync mode.");
12162
12162
  if (typeof fetch === "function") {
12163
- url = H.accept(url, Types.STRING);
12163
+ url = H.accept(url, Types3.STRING);
12164
12164
  return fetch(url).then((res) => res.text());
12165
12165
  } else {
12166
12166
  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})");
@@ -21488,7 +21488,7 @@ ${e.toString()}`);
21488
21488
  var DateFunctions = require_date();
21489
21489
  var WebFunctions = require_web();
21490
21490
  var FormulaError = require_error();
21491
- var { FormulaHelpers } = require_helpers();
21491
+ var { FormulaHelpers: FormulaHelpers3 } = require_helpers();
21492
21492
  var { Parser, allTokens } = require_parsing();
21493
21493
  var lexer = require_lexing();
21494
21494
  var Utils = require_utils2();
@@ -21586,10 +21586,10 @@ ${e.toString()}`);
21586
21586
  * @return {*}
21587
21587
  */
21588
21588
  retrieveRef(valueOrRef) {
21589
- if (FormulaHelpers.isRangeRef(valueOrRef)) {
21589
+ if (FormulaHelpers3.isRangeRef(valueOrRef)) {
21590
21590
  return this.getRange(valueOrRef.ref);
21591
21591
  }
21592
- if (FormulaHelpers.isCellRef(valueOrRef)) {
21592
+ if (FormulaHelpers3.isCellRef(valueOrRef)) {
21593
21593
  return this.getCell(valueOrRef.ref);
21594
21594
  }
21595
21595
  return valueOrRef;
@@ -21616,8 +21616,8 @@ ${e.toString()}`);
21616
21616
  return {
21617
21617
  value: res.val,
21618
21618
  isArray: res.isArray,
21619
- isRangeRef: !!FormulaHelpers.isRangeRef(arg),
21620
- isCellRef: !!FormulaHelpers.isCellRef(arg)
21619
+ isRangeRef: !!FormulaHelpers3.isRangeRef(arg),
21620
+ isCellRef: !!FormulaHelpers3.isCellRef(arg)
21621
21621
  };
21622
21622
  });
21623
21623
  }
@@ -21657,14 +21657,14 @@ ${e.toString()}`);
21657
21657
  awaitedArgs.push(await arg);
21658
21658
  }
21659
21659
  const res = await this._callFunction(name2, awaitedArgs);
21660
- return FormulaHelpers.checkFunctionResult(res);
21660
+ return FormulaHelpers3.checkFunctionResult(res);
21661
21661
  }
21662
21662
  callFunction(name2, args) {
21663
21663
  if (this.async) {
21664
21664
  return this.callFunctionAsync(name2, args);
21665
21665
  } else {
21666
21666
  const res = this._callFunction(name2, args);
21667
- return FormulaHelpers.checkFunctionResult(res);
21667
+ return FormulaHelpers3.checkFunctionResult(res);
21668
21668
  }
21669
21669
  }
21670
21670
  /**
@@ -21796,7 +21796,7 @@ ${e.toString()}`);
21796
21796
  };
21797
21797
  module2.exports = {
21798
21798
  FormulaParser: FormulaParser2,
21799
- FormulaHelpers
21799
+ FormulaHelpers: FormulaHelpers3
21800
21800
  };
21801
21801
  }
21802
21802
  });
@@ -21805,7 +21805,7 @@ ${e.toString()}`);
21805
21805
  var require_utils3 = __commonJS({
21806
21806
  "../../node_modules/fast-formula-parser/grammar/dependency/utils.js"(exports2, module2) {
21807
21807
  var FormulaError = require_error();
21808
- var { FormulaHelpers, Types, Address } = require_helpers();
21808
+ var { FormulaHelpers: FormulaHelpers3, Types: Types3, Address } = require_helpers();
21809
21809
  var { Prefix, Postfix, Infix: Infix2, Operators } = require_operators();
21810
21810
  var Collection = require_collection();
21811
21811
  var MAX_ROW = 1048576;
@@ -22057,7 +22057,7 @@ ${e.toString()}`);
22057
22057
  var require_hooks2 = __commonJS({
22058
22058
  "../../node_modules/fast-formula-parser/grammar/dependency/hooks.js"(exports2, module2) {
22059
22059
  var FormulaError = require_error();
22060
- var { FormulaHelpers } = require_helpers();
22060
+ var { FormulaHelpers: FormulaHelpers3 } = require_helpers();
22061
22061
  var { Parser } = require_parsing();
22062
22062
  var lexer = require_lexing();
22063
22063
  var Utils = require_utils3();
@@ -22122,7 +22122,7 @@ ${e.toString()}`);
22122
22122
  const res = { ref: this.onVariable(name2, this.position.sheet) };
22123
22123
  if (res.ref == null)
22124
22124
  return FormulaError.NAME;
22125
- if (FormulaHelpers.isCellRef(res))
22125
+ if (FormulaHelpers3.isCellRef(res))
22126
22126
  this.getCell(res.ref);
22127
22127
  else {
22128
22128
  this.getRange(res.ref);
@@ -22135,10 +22135,10 @@ ${e.toString()}`);
22135
22135
  * @return {*}
22136
22136
  */
22137
22137
  retrieveRef(valueOrRef) {
22138
- if (FormulaHelpers.isRangeRef(valueOrRef)) {
22138
+ if (FormulaHelpers3.isRangeRef(valueOrRef)) {
22139
22139
  return this.getRange(valueOrRef.ref);
22140
22140
  }
22141
- if (FormulaHelpers.isCellRef(valueOrRef)) {
22141
+ if (FormulaHelpers3.isCellRef(valueOrRef)) {
22142
22142
  return this.getCell(valueOrRef.ref);
22143
22143
  }
22144
22144
  return valueOrRef;
@@ -62024,6 +62024,90 @@ ${e.toString()}`);
62024
62024
  }
62025
62025
  return result;
62026
62026
  }
62027
+ /**
62028
+ * Every cell that participates in a circular reference, in one pass.
62029
+ *
62030
+ * `detectCycle` answers the same question for ONE cell, which is what an edit
62031
+ * needs; asking it per cell to check a whole workbook is worse than quadratic
62032
+ * — 512 ms at 1,000 formula cells and it does not finish at 10,000, so a batch
62033
+ * recompute would hang. This is Tarjan's strongly-connected-components
62034
+ * algorithm over the same precedents graph: O(V+E), one pass, every cycle at
62035
+ * once. A cell is circular if it sits in an SCC larger than one, or if it
62036
+ * references itself directly.
62037
+ *
62038
+ * Iterative rather than recursive on purpose: a cascading column is an
62039
+ * ordinary shape and a 10,000-deep chain would overflow the stack.
62040
+ *
62041
+ * **Coarse nodes are deliberately not expanded.** A whole-column node stands
62042
+ * for a range that may have been over-approximated (a bounded `A1:A15000`
62043
+ * collapses to all of column A), so following it could report a cycle that
62044
+ * does not exist — and the one thing worse than a wrong number here is
62045
+ * `#CIRC!` written into a correct customer document. The cost is that
62046
+ * `A1 = SUM(A:A)` is not caught in a batch recompute; it still is on an edit,
62047
+ * where `detectCycle` compares against the origin's own coarse nodes.
62048
+ */
62049
+ findCycles() {
62050
+ const circular = /* @__PURE__ */ new Set();
62051
+ let nextIndex = 0;
62052
+ const index = /* @__PURE__ */ new Map();
62053
+ const lowLink = /* @__PURE__ */ new Map();
62054
+ const onStack = /* @__PURE__ */ new Set();
62055
+ const stack = [];
62056
+ for (const root of this.precedents.keys()) {
62057
+ if (index.has(root)) continue;
62058
+ const frames = [{ node: root, prec: this.exactPrecedents(root), i: 0 }];
62059
+ index.set(root, nextIndex);
62060
+ lowLink.set(root, nextIndex);
62061
+ nextIndex++;
62062
+ stack.push(root);
62063
+ onStack.add(root);
62064
+ while (frames.length > 0) {
62065
+ const frame = frames[frames.length - 1];
62066
+ if (frame.i < frame.prec.length) {
62067
+ const next = frame.prec[frame.i++];
62068
+ if (next === frame.node) {
62069
+ circular.add(next);
62070
+ continue;
62071
+ }
62072
+ if (!index.has(next)) {
62073
+ index.set(next, nextIndex);
62074
+ lowLink.set(next, nextIndex);
62075
+ nextIndex++;
62076
+ stack.push(next);
62077
+ onStack.add(next);
62078
+ frames.push({ node: next, prec: this.exactPrecedents(next), i: 0 });
62079
+ } else if (onStack.has(next)) {
62080
+ lowLink.set(frame.node, Math.min(lowLink.get(frame.node), index.get(next)));
62081
+ }
62082
+ continue;
62083
+ }
62084
+ frames.pop();
62085
+ const parent = frames[frames.length - 1];
62086
+ if (parent) {
62087
+ lowLink.set(parent.node, Math.min(lowLink.get(parent.node), lowLink.get(frame.node)));
62088
+ }
62089
+ if (lowLink.get(frame.node) === index.get(frame.node)) {
62090
+ const component = [];
62091
+ for (; ; ) {
62092
+ const member = stack.pop();
62093
+ onStack.delete(member);
62094
+ component.push(member);
62095
+ if (member === frame.node) break;
62096
+ }
62097
+ if (component.length > 1) for (const member of component) circular.add(member);
62098
+ }
62099
+ }
62100
+ }
62101
+ return circular;
62102
+ }
62103
+ /** Precedents that are real cells — coarse nodes are skipped (see `findCycles`). */
62104
+ exactPrecedents(cell) {
62105
+ const prec = this.precedents.get(cell);
62106
+ if (!prec) return [];
62107
+ const out = [];
62108
+ for (const p of prec) if (!isCoarseKey(p)) out.push(p);
62109
+ return out;
62110
+ }
62027
62111
  /** Detect if `cell` appears in its own transitive precedent chain (circular reference). */
62028
62112
  detectCycle(cell) {
62029
62113
  const visited = /* @__PURE__ */ new Set();
@@ -62149,12 +62233,17 @@ ${e.toString()}`);
62149
62233
  };
62150
62234
  }
62151
62235
 
62152
- // ../xlsx/src/blank_comparison.ts
62236
+ // ../xlsx/src/blank_semantics.ts
62153
62237
  var import_operators = __toESM(require_operators(), 1);
62238
+ var import_helpers = __toESM(require_helpers(), 1);
62154
62239
  var patched = false;
62155
62240
  function applyExcelBlankSemantics() {
62156
62241
  if (patched) return;
62157
62242
  patched = true;
62243
+ patchComparison();
62244
+ patchArgumentCoercion();
62245
+ }
62246
+ function patchComparison() {
62158
62247
  const original = import_operators.Infix.compareOp;
62159
62248
  import_operators.Infix.compareOp = (value1, infix, value2, isArray1, isArray2) => {
62160
62249
  if (value1 == null && typeof value2 === "string") value1 = "";
@@ -62162,8 +62251,27 @@ ${e.toString()}`);
62162
62251
  return original(value1, infix, value2, isArray1, isArray2);
62163
62252
  };
62164
62253
  }
62254
+ function isBlankCell(param) {
62255
+ if (typeof param !== "object" || param === null || Array.isArray(param)) return false;
62256
+ if (!("value" in param) || param.value != null) return false;
62257
+ return !("omitted" in param) || !param.omitted;
62258
+ }
62259
+ function patchArgumentCoercion() {
62260
+ const original = import_helpers.FormulaHelpers.accept.bind(import_helpers.FormulaHelpers);
62261
+ import_helpers.FormulaHelpers.accept = (param, type, defValue, flat, allowSingleValue) => {
62262
+ const want = Array.isArray(type) ? type[0] : type;
62263
+ if (isBlankCell(param)) {
62264
+ if (want === import_helpers.Types.STRING) return "";
62265
+ if (want === import_helpers.Types.NUMBER || want === import_helpers.Types.NUMBER_NO_BOOLEAN) return 0;
62266
+ if (want === import_helpers.Types.BOOLEAN) return false;
62267
+ if (want == null) return null;
62268
+ }
62269
+ return original(param, want, defValue, flat, allowSingleValue);
62270
+ };
62271
+ }
62165
62272
 
62166
62273
  // ../xlsx/src/formula_engine.ts
62274
+ var import_helpers2 = __toESM(require_helpers(), 1);
62167
62275
  var unwrapArg = (a) => a !== null && typeof a === "object" && "value" in a ? a.value : a;
62168
62276
  function adaptFormulajs(fn) {
62169
62277
  return (...args) => fn(...args.map(unwrapArg));
@@ -62222,20 +62330,84 @@ ${e.toString()}`);
62222
62330
  * cannot draw, refuse what you cannot read.
62223
62331
  */
62224
62332
  this.unreadableFormulas = /* @__PURE__ */ new Set();
62333
+ /**
62334
+ * Cells found to be circular by the batch pass, held so evaluation refuses
62335
+ * them.
62336
+ *
62337
+ * Leaving them out of the seed list is NOT enough: `getRecalcOrder` pulls in
62338
+ * transitive dependents, so any cycle fed by another FORMULA gets evaluated
62339
+ * anyway and overwrites its `#CIRC!` with the parser's generic `#ERROR!` —
62340
+ * which sends a reader hunting a broken formula instead of the cycle that is
62341
+ * actually there. A cycle fed by a formula rather than a constant is the
62342
+ * ordinary case, so the guard has to sit at evaluation.
62343
+ */
62344
+ this.circularFormulas = /* @__PURE__ */ new Set();
62225
62345
  applyExcelBlankSemantics();
62226
62346
  this.workbook = workbook;
62227
62347
  this.parser = new import_fast_formula_parser.default({
62228
62348
  onCell: (ref2) => this.resolveCell(ref2),
62229
62349
  onRange: (ref2) => this.resolveRange(ref2),
62230
- onVariable: (name2) => this.resolveVariable(name2),
62350
+ onVariable: (name2, sheet) => this.resolveVariable(name2, sheet),
62231
62351
  functions: formulajsBridge(),
62232
62352
  // A handful of names (CHOOSE among them) are dispatched through the
62233
62353
  // context-aware path, where a plain `functions` entry is never consulted.
62234
62354
  // Register there too, dropping the context argument the parser prepends —
62235
62355
  // formulajs has no use for it.
62236
- functionsNeedContext: formulajsBridgeWithContext()
62356
+ functionsNeedContext: {
62357
+ ...formulajsBridgeWithContext(),
62358
+ // INDEX is the one bridged function the parser hands a RAW REFERENCE
62359
+ // rather than values, because it sits in the parser's
62360
+ // `funsNeedContextAndNoDataRetrieve` set. The generic bridge unwraps an
62361
+ // argument by reading `.value`; a `{ref}` has none, so the descriptor
62362
+ // itself reached formulajs, which wants a 2D array — every INDEX in
62363
+ // every workbook returned `#VALUE!`. One real file lost 10 of its 13
62364
+ // formulas to it, 8 of them cascading from 2 roots.
62365
+ //
62366
+ // It resolves here rather than in the bridge because the bridge is
62367
+ // memoized per PROCESS and knows no workbook, so it structurally cannot
62368
+ // resolve a reference. `lazy_ref_arguments.test.ts` pins that INDEX is
62369
+ // still the only name in that position — if upstream ever adds another,
62370
+ // that test fails instead of the function silently returning `#VALUE!`.
62371
+ INDEX: (_context, ref2, ...rest2) => INDEX(
62372
+ this.resolveRefAsGrid(ref2),
62373
+ ...rest2.map((a) => this.resolveRefOrValue(a))
62374
+ ),
62375
+ // IF sits in that same `noDataRetrieve` set, and the parser's own
62376
+ // implementation forgets to resolve the one argument that needs it:
62377
+ // the condition arrives as a raw `{ref}` and is handed straight to
62378
+ // `accept(_, Types.BOOLEAN)`, which has no branch for a reference and
62379
+ // returns the descriptor unchanged. A descriptor is an object, and
62380
+ // every object is truthy — so `IF(<any cell>, a, b)` returns `a`
62381
+ // unconditionally, including when the cell holds 0, FALSE, or nothing.
62382
+ // Verified against the unconfigured library, so it is upstream's bug
62383
+ // and not a consequence of this engine's configuration.
62384
+ //
62385
+ // It stays quiet in most workbooks because the common form is
62386
+ // `IF(A1="", …)` — a comparison, which evaluates to a real boolean
62387
+ // before IF ever sees it. Only a bare cell reference as the condition
62388
+ // is affected, which is exactly how a boolean or checkbox column gets
62389
+ // tested.
62390
+ //
62391
+ // The condition is coerced by handing the resolved value back to the
62392
+ // library's own `accept`, so blank/0/text/error all keep Excel's
62393
+ // answers rather than a second opinion invented here.
62394
+ IF: (_context, condition, whenTrue, whenFalse) => {
62395
+ const resolved = this.resolveRefOrValue(condition);
62396
+ const test = import_helpers2.FormulaHelpers.accept(
62397
+ { value: resolved, isArray: Array.isArray(resolved) },
62398
+ import_helpers2.Types.BOOLEAN
62399
+ );
62400
+ const branch = test ? whenTrue : whenFalse;
62401
+ if (branch === null) return 0;
62402
+ if (branch === void 0) return false;
62403
+ const taken = this.resolveRefOrValue(branch);
62404
+ return taken ?? 0;
62405
+ }
62406
+ }
62407
+ });
62408
+ this.depParser = new import_fast_formula_parser.default.DepParser({
62409
+ onVariable: (name2, sheet) => this.resolveVariable(name2, sheet)
62237
62410
  });
62238
- this.depParser = new import_fast_formula_parser.default.DepParser();
62239
62411
  }
62240
62412
  // ===========================================================================
62241
62413
  // Initialization — build graph and evaluate missing values
@@ -62279,12 +62451,14 @@ ${e.toString()}`);
62279
62451
  * show stale values.
62280
62452
  */
62281
62453
  evaluateAll() {
62454
+ this.circularFormulas = this.graph.findCycles();
62455
+ for (const key of this.circularFormulas) this.setCellError(key, "#CIRC!");
62282
62456
  const all = [];
62283
62457
  for (const sheet of this.workbook.sheets) {
62284
62458
  for (const [ref2, cell] of sheet.cells) {
62285
- if (cell.formula) {
62286
- all.push(cellKey({ sheet: sheet.name, ref: ref2 }));
62287
- }
62459
+ if (!cell.formula) continue;
62460
+ const key = cellKey({ sheet: sheet.name, ref: ref2 });
62461
+ if (!this.circularFormulas.has(key)) all.push(key);
62288
62462
  }
62289
62463
  }
62290
62464
  this.evaluateSet(all);
@@ -62308,6 +62482,7 @@ ${e.toString()}`);
62308
62482
  const { deps, readable } = this.analyzeFormula(formula, sheetName);
62309
62483
  this.graph.setDependencies(key, deps);
62310
62484
  this.unreadableFormulas.delete(key);
62485
+ this.circularFormulas.delete(key);
62311
62486
  if (!readable) {
62312
62487
  this.setCellError(key, "#ERROR!");
62313
62488
  return;
@@ -62321,6 +62496,7 @@ ${e.toString()}`);
62321
62496
  } else {
62322
62497
  this.graph.removeCell(key);
62323
62498
  this.unreadableFormulas.delete(key);
62499
+ this.circularFormulas.delete(key);
62324
62500
  }
62325
62501
  const order = this.graph.getRecalcOrder([key]);
62326
62502
  for (const depKey of order) {
@@ -62338,6 +62514,7 @@ ${e.toString()}`);
62338
62514
  /** Evaluate a single formula cell and update its value. */
62339
62515
  evaluateCell(key) {
62340
62516
  if (this.unreadableFormulas.has(key)) return;
62517
+ if (this.circularFormulas.has(key)) return;
62341
62518
  const { sheet: sheetName, ref: ref2 } = parseCellKey(key);
62342
62519
  const sheetIndex = this.workbook.sheets.findIndex((s) => s.name === sheetName);
62343
62520
  if (sheetIndex < 0) return;
@@ -62348,11 +62525,7 @@ ${e.toString()}`);
62348
62525
  if (!rc) return;
62349
62526
  const expandedFormula = expandStructuredRefs(cell.formula, sheet.tables, rc.row);
62350
62527
  try {
62351
- const raw = this.parser.parse(expandedFormula, {
62352
- sheet: sheetName,
62353
- row: rc.row,
62354
- col: rc.col
62355
- });
62528
+ const raw = this.parse(expandedFormula, sheetName, rc.row, rc.col);
62356
62529
  const result = normalizeResult(raw);
62357
62530
  cell.value = result.value;
62358
62531
  cell.error = result.error;
@@ -62437,6 +62610,10 @@ ${e.toString()}`);
62437
62610
  }
62438
62611
  return { deps: refs, readable: true };
62439
62612
  }
62613
+ /** Cells in a circular reference, by key. Exposed so the cost can be measured. */
62614
+ graphCycles() {
62615
+ return this.graph.findCycles();
62616
+ }
62440
62617
  /** Formula cells the parser could not read, by key. Read by the recompute report. */
62441
62618
  unreadable() {
62442
62619
  return this.unreadableFormulas;
@@ -62445,17 +62622,54 @@ ${e.toString()}`);
62445
62622
  // Cell value resolution callbacks
62446
62623
  // ===========================================================================
62447
62624
  resolveCell(ref2) {
62448
- const sheetName = ref2.sheet ?? this.workbook.sheets[0]?.name ?? "Sheet1";
62625
+ const sheetName = ref2.sheet ?? this.evaluatingSheet ?? this.workbook.sheets[0]?.name ?? "Sheet1";
62449
62626
  const sheet = this.workbook.sheets.find((s) => s.name === sheetName);
62450
62627
  if (!sheet) return null;
62451
62628
  const cellRef = rowColToRef(ref2.row, ref2.col);
62452
62629
  const cell = sheet.getCell(cellRef);
62453
62630
  if (!cell) return null;
62454
- if (cell.error) throw new Error(cell.error);
62631
+ if (cell.error) return new import_fast_formula_parser.default.FormulaError(cell.error);
62455
62632
  return cell.value;
62456
62633
  }
62634
+ /**
62635
+ * Resolve a parser reference descriptor to the value behind it — a 2D grid
62636
+ * for a range, a scalar for a single cell.
62637
+ *
62638
+ * The descriptor shapes are exactly what `resolveRange` and `resolveCell`
62639
+ * already take (`{from, to, sheet?}` and `{row, col, sheet?}`), so this reuses
62640
+ * them rather than re-deriving anything, and the whole-column clamp comes
62641
+ * along unchanged.
62642
+ *
62643
+ * Needed for EVERY argument, not just the array: a function in the parser's
62644
+ * `noDataRetrieve` set gets none of its arguments materialized, so
62645
+ * `INDEX(range, A1, A2)` — the form the real workbook used — arrives with the
62646
+ * row and column as references too.
62647
+ */
62648
+ resolveRefOrValue(arg) {
62649
+ const ref2 = arg?.ref;
62650
+ if (ref2 && typeof ref2 === "object") {
62651
+ if ("from" in ref2 && "to" in ref2) {
62652
+ return this.resolveRange(ref2);
62653
+ }
62654
+ if ("row" in ref2 && "col" in ref2) {
62655
+ return this.resolveCell(ref2);
62656
+ }
62657
+ }
62658
+ return unwrapArg(arg);
62659
+ }
62660
+ /**
62661
+ * The same, forced to the 2D shape an array argument must have.
62662
+ *
62663
+ * Deliberately not `CellValue[][]`: a cell holding an error resolves to a
62664
+ * `FormulaError`, which the receiving function is expected to propagate. A
62665
+ * cast narrowing that away would be a false promise, not a safe one.
62666
+ */
62667
+ resolveRefAsGrid(arg) {
62668
+ const value2 = this.resolveRefOrValue(arg);
62669
+ return Array.isArray(value2) ? value2 : [[value2]];
62670
+ }
62457
62671
  resolveRange(ref2) {
62458
- const sheetName = ref2.sheet ?? this.workbook.sheets[0]?.name ?? "Sheet1";
62672
+ const sheetName = ref2.sheet ?? this.evaluatingSheet ?? this.workbook.sheets[0]?.name ?? "Sheet1";
62459
62673
  const sheet = this.workbook.sheets.find((s) => s.name === sheetName);
62460
62674
  if (!sheet) return [[]];
62461
62675
  let lastRow = ref2.to.row;
@@ -62478,34 +62692,42 @@ ${e.toString()}`);
62478
62692
  // ===========================================================================
62479
62693
  // Named range resolution
62480
62694
  // ===========================================================================
62481
- resolveVariable(name2) {
62695
+ /**
62696
+ * Resolve a defined name to the REFERENCE it stands for.
62697
+ *
62698
+ * A reference, not a value: the parser wraps whatever comes back as
62699
+ * `{ref: …}` and materializes it itself through `onCell`/`onRange`. Returning
62700
+ * the resolved value instead — which this used to do — produced `{ref: 11}`,
62701
+ * whose `.row` is undefined, so **every** formula naming a range answered
62702
+ * `#VALUE!`. Same value-vs-reference confusion as INDEX and IF above, in the
62703
+ * one callback where the library documents the contract the other way round.
62704
+ *
62705
+ * Returning `null` is the "no such name" signal the parser turns into
62706
+ * `#NAME?`, which is also Excel's answer for a name that resolves to a
62707
+ * constant or a formula rather than a reference — unsupported, and loud.
62708
+ *
62709
+ * `sheetName` is the position the parser is evaluating at, which is what an
62710
+ * unqualified expression is relative to.
62711
+ */
62712
+ resolveVariable(name2, sheetName) {
62482
62713
  const rangeExpr = this.workbook.namedRanges.get(name2);
62483
62714
  if (rangeExpr === void 0) return null;
62484
62715
  const cleaned = rangeExpr.replace(/\$/g, "");
62485
62716
  const sheetMatch = cleaned.match(/^(.+?)!(.+)$/);
62486
- const sheetName = sheetMatch ? sheetMatch[1].replace(/^'|'$/g, "") : this.workbook.sheets[0]?.name ?? "Sheet1";
62717
+ const sheet = sheetMatch ? sheetMatch[1].replace(/^'|'$/g, "") : sheetName;
62487
62718
  const rangeStr = sheetMatch ? sheetMatch[2] : cleaned;
62488
- const sheet = this.workbook.sheets.find((s) => s.name === sheetName);
62489
- if (!sheet) return null;
62719
+ if (!this.workbook.sheets.some((s) => s.name === sheet)) return null;
62490
62720
  const rangeMatch = rangeStr.match(/^([A-Z]+)(\d+):([A-Z]+)(\d+)$/);
62491
62721
  if (rangeMatch) {
62492
- const fromRow = parseInt(rangeMatch[2], 10);
62493
- const fromCol = colLettersToNum(rangeMatch[1]);
62494
- const toRow = parseInt(rangeMatch[4], 10);
62495
- const toCol = colLettersToNum(rangeMatch[3]);
62496
- return this.resolveRange({
62497
- from: { row: fromRow, col: fromCol },
62498
- to: { row: toRow, col: toCol },
62499
- sheet: sheetName
62500
- });
62722
+ return {
62723
+ from: { row: parseInt(rangeMatch[2], 10), col: colLettersToNum(rangeMatch[1]) },
62724
+ to: { row: parseInt(rangeMatch[4], 10), col: colLettersToNum(rangeMatch[3]) },
62725
+ sheet
62726
+ };
62501
62727
  }
62502
62728
  const cellMatch = rangeStr.match(/^([A-Z]+)(\d+)$/);
62503
62729
  if (cellMatch) {
62504
- return this.resolveCell({
62505
- row: parseInt(cellMatch[2], 10),
62506
- col: colLettersToNum(cellMatch[1]),
62507
- sheet: sheetName
62508
- });
62730
+ return { row: parseInt(cellMatch[2], 10), col: colLettersToNum(cellMatch[1]), sheet };
62509
62731
  }
62510
62732
  return null;
62511
62733
  }
@@ -62515,12 +62737,33 @@ ${e.toString()}`);
62515
62737
  /** Evaluate an arbitrary formula expression. Used by CF expression rules. */
62516
62738
  evaluateExpression(formula, sheetName, row, col) {
62517
62739
  try {
62518
- return this.parser.parse(formula, { sheet: sheetName, row, col });
62740
+ return this.parse(formula, sheetName, row, col);
62519
62741
  } catch (err2) {
62520
62742
  if (isFormulaError(err2)) return null;
62521
62743
  throw err2;
62522
62744
  }
62523
62745
  }
62746
+ /**
62747
+ * The one place a formula is handed to the parser, so the sheet it belongs to
62748
+ * is recorded for the duration.
62749
+ *
62750
+ * An UNQUALIFIED reference means "this formula's sheet", and for the ordinary
62751
+ * `onCell`/`onRange` path the parser fills that in from the position below.
62752
+ * The functions in its `noDataRetrieve` set are the exception: their arguments
62753
+ * arrive as raw descriptors that were never resolved, and those carry only
62754
+ * `{address, row, col}` — no sheet at all. Resolving one against the first
62755
+ * sheet in the workbook reads a different sheet's cell, silently, and a blank
62756
+ * there is indistinguishable from a real empty one.
62757
+ */
62758
+ parse(formula, sheetName, row, col) {
62759
+ const previous = this.evaluatingSheet;
62760
+ this.evaluatingSheet = sheetName;
62761
+ try {
62762
+ return this.parser.parse(formula, { sheet: sheetName, row, col });
62763
+ } finally {
62764
+ this.evaluatingSheet = previous;
62765
+ }
62766
+ }
62524
62767
  /** Get the dependency graph (for testing/debugging). */
62525
62768
  get deps() {
62526
62769
  return this.graph;
@@ -62536,7 +62779,7 @@ ${e.toString()}`);
62536
62779
  return v instanceof Error && typeof v.name === "string" && v.name.startsWith("#");
62537
62780
  }
62538
62781
  function normalizeResult(result) {
62539
- if (result === null || result === void 0) return { value: null };
62782
+ if (result === null || result === void 0) return { value: 0 };
62540
62783
  if (typeof result === "number") return { value: result };
62541
62784
  if (typeof result === "boolean") return { value: result };
62542
62785
  if (typeof result === "string") return { value: result };
@@ -62573,7 +62816,7 @@ ${e.toString()}`);
62573
62816
  continue;
62574
62817
  }
62575
62818
  if (cell.value === null) {
62576
- unevaluated.push({ sheet: sheet.name, ref: ref2, formula: cell.formula, error: cell.error ?? "#ERROR!" });
62819
+ unevaluated.push({ sheet: sheet.name, ref: ref2, formula: cell.formula, error: cell.error ?? "#NO_VALUE!" });
62577
62820
  }
62578
62821
  }
62579
62822
  }