@univerjs/engine-formula 1.0.0-alpha.8 → 1.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.js +1175 -982
- package/lib/es/index.js +1177 -984
- package/lib/index.js +1177 -984
- package/lib/types/basics/common.d.ts +2 -0
- package/lib/types/basics/regex.d.ts +4 -4
- package/lib/types/controllers/formula-calculation-trigger.controller.d.ts +1 -2
- package/lib/types/controllers/formula.controller.d.ts +1 -1
- package/lib/types/engine/analysis/lexer-tree-builder.d.ts +4 -0
- package/lib/types/engine/analysis/lexer.d.ts +4 -2
- package/lib/types/engine/ast-node/base-ast-node.d.ts +1 -0
- package/lib/types/engine/ast-node/function-node.d.ts +1 -0
- package/lib/types/engine/ast-node/union-node.d.ts +8 -2
- package/lib/types/engine/reference-object/base-reference-object.d.ts +2 -1
- package/lib/types/engine/reference-object/multi-area-reference-object.d.ts +11 -3
- package/lib/types/engine/reference-object/table-reference-object.d.ts +1 -1
- package/lib/types/engine/utils/generate-ast-node.d.ts +1 -1
- package/lib/types/engine/value-object/array-value-object.d.ts +1 -1
- package/lib/types/functions/base-function.d.ts +6 -2
- package/lib/types/functions/compatibility/rank/index.d.ts +1 -0
- package/lib/types/functions/information/isblank/index.d.ts +3 -3
- package/lib/types/functions/logical/percentof/index.d.ts +5 -6
- package/lib/types/functions/lookup/choose/index.d.ts +1 -0
- package/lib/types/functions/lookup/function-map.d.ts +4 -1
- package/lib/types/functions/lookup/match/index.d.ts +1 -0
- package/lib/types/functions/lookup/xlookup/index.d.ts +4 -0
- package/lib/types/functions/math/sumproduct/index.d.ts +1 -0
- package/lib/types/functions/statistical/median/index.d.ts +1 -0
- package/lib/types/functions/statistical/percentile-exc/index.d.ts +1 -0
- package/lib/types/functions/statistical/percentile-inc/index.d.ts +1 -0
- package/lib/types/functions/statistical/rank-avg/index.d.ts +1 -0
- package/lib/types/functions/statistical/rank-eq/index.d.ts +1 -0
- package/lib/types/functions/text/textjoin/index.d.ts +1 -0
- package/lib/types/services/register-other-formula.service.d.ts +3 -3
- package/lib/types/services/runtime.service.d.ts +2 -0
- package/lib/umd/index.js +4 -4
- package/package.json +4 -4
package/lib/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { AbsoluteRefType, AsyncLock, BooleanNumber, BuildTextUtils, CellValueType, CommandType, DataStreamTreeTokenType, Disposable, DisposableCollection, ICommandService, IConfigService, IUniverInstanceService, Inject, Injector, LRUMap, LifecycleService, LifecycleStages, LocaleService, LocaleType, MAX_COLUMN_COUNT, MAX_ROW_COUNT, ObjectMatrix, Optional, Plugin, RANGE_TYPE, RTree, Rectangle, RichTextBuilder, Styles, Tools, UniverInstanceType, cellToRange, columnLabelToNumber, createIdentifier, generateRandomId, getNumfmtParseValueFilter, hashAlgorithm, isFormulaId, isFormulaString, isNodeEnv, isNullCell, isRealNum, isTextFormat, isValidRange, merge, moveRangeByOffset, numfmt, regexp, requestImmediateMacroTask, sortRules, toDisposable, touchDependencies } from "@univerjs/core";
|
|
1
|
+
import { AbsoluteRefType, AsyncLock, BooleanNumber, BuildTextUtils, CellValueType, CommandType, DataStreamTreeTokenType, Disposable, DisposableCollection, ICommandService, IConfigService, IUniverInstanceService, Inject, Injector, LRUMap, LifecycleService, LifecycleStages, LocaleService, LocaleType, MAX_COLUMN_COUNT, MAX_ROW_COUNT, ObjectMatrix, Optional, Plugin, RANGE_TYPE, RTree, Rectangle, RichTextBuilder, Styles, Tools, UniverInstanceType, cellToRange, columnLabelToNumber, createBaseFormulaTableNameMap, createIdentifier, generateRandomId, getBaseFormulaTableName, getNumfmtParseValueFilter, hashAlgorithm, isFormulaId, isFormulaString, isNodeEnv, isNullCell, isRealNum, isTextFormat, isValidRange, merge, moveRangeByOffset, numfmt, regexp, requestImmediateMacroTask, sortRules, toDisposable, touchDependencies } from "@univerjs/core";
|
|
2
2
|
import IntervalTree from "@flatten-js/interval-tree";
|
|
3
|
-
import { BehaviorSubject, Observable, Subject,
|
|
3
|
+
import { BehaviorSubject, Observable, Subject, combineLatest, distinctUntilChanged, filter, map, shareReplay, take } from "rxjs";
|
|
4
4
|
import Decimal from "decimal.js";
|
|
5
5
|
import { DataSyncPrimaryController } from "@univerjs/rpc";
|
|
6
6
|
|
|
@@ -1229,13 +1229,8 @@ var InvertedIndexCache = class {
|
|
|
1229
1229
|
const rowsForEmpty = columnMap.get(DEFAULT_EMPTY_CELL_KEY);
|
|
1230
1230
|
if (rowsForEmpty) rows.push(...rowsForEmpty);
|
|
1231
1231
|
result.matchingRows = rows.filter((row) => rowsInCache.some(([start, end]) => row >= start && row <= end));
|
|
1232
|
-
} else if (_value === DEFAULT_EMPTY_CELL_KEY)
|
|
1233
|
-
|
|
1234
|
-
result.matchingRows = Array.from((_columnMap$get = columnMap.get(DEFAULT_EMPTY_CELL_KEY)) !== null && _columnMap$get !== void 0 ? _columnMap$get : []).filter((row) => rowsInCache.some(([start, end]) => row >= start && row <= end));
|
|
1235
|
-
} else {
|
|
1236
|
-
var _columnMap$get2;
|
|
1237
|
-
result.matchingRows = Array.from((_columnMap$get2 = columnMap.get(_value)) !== null && _columnMap$get2 !== void 0 ? _columnMap$get2 : []).filter((row) => rowsInCache.some(([start, end]) => row >= start && row <= end));
|
|
1238
|
-
}
|
|
1232
|
+
} else if (_value === DEFAULT_EMPTY_CELL_KEY) result.matchingRows = Array.from(columnMap.get(DEFAULT_EMPTY_CELL_KEY) ?? []).filter((row) => rowsInCache.some(([start, end]) => row >= start && row <= end));
|
|
1233
|
+
else result.matchingRows = Array.from(columnMap.get(_value) ?? []).filter((row) => rowsInCache.some(([start, end]) => row >= start && row <= end));
|
|
1239
1234
|
return result;
|
|
1240
1235
|
}
|
|
1241
1236
|
setContinueBuildingCache(unitId, sheetId, column, startRow, endRow) {
|
|
@@ -1448,11 +1443,12 @@ const REFERENCE_REGEX_SINGLE_ROW = `^${UNIT_NAME_SHEET_NAME_REGEX}\\s*?\\${"$"}?
|
|
|
1448
1443
|
const REFERENCE_REGEX_SINGLE_ROW_PRECOMPILING = new RegExp(REFERENCE_REGEX_SINGLE_ROW);
|
|
1449
1444
|
const REFERENCE_REGEX_SINGLE_COLUMN = `^${UNIT_NAME_SHEET_NAME_REGEX}\\s*?\\${"$"}?${COLUMN_REGEX}$`;
|
|
1450
1445
|
const REFERENCE_REGEX_SINGLE_COLUMN_PRECOMPILING = new RegExp(REFERENCE_REGEX_SINGLE_COLUMN);
|
|
1451
|
-
const TABLE_NAME_REGEX = "((?![~!@#$%^&*()
|
|
1446
|
+
const TABLE_NAME_REGEX = "((?![~!@#$%^&*()+<>?:,./;’,。、‘:“《》?~!@#¥%……()【】\\[\\]\\/\\\\]).)+";
|
|
1452
1447
|
const TABLE_TITLE_REGEX = "\\[#.+\\]\\s*?,\\s*?";
|
|
1453
|
-
const TABLE_CONTENT_REGEX = "\\[
|
|
1448
|
+
const TABLE_CONTENT_REGEX = "\\[[^#]*#?\\]";
|
|
1454
1449
|
const TABLE_MULTIPLE_COLUMN_REGEX = `${TABLE_CONTENT_REGEX}${RANGE_SYMBOL}${TABLE_CONTENT_REGEX}`;
|
|
1455
|
-
const
|
|
1450
|
+
const TABLE_BRACKETED_UNIT_QUALIFIER_REGEX = "\\[(?:[^\\]]|\\]\\])+\\]";
|
|
1451
|
+
const TABLE_UNIT_QUALIFIER_REGEX = `(?:(?:${TABLE_BRACKETED_UNIT_QUALIFIER_REGEX}|'(?:[^']|'')+'|[^\\s!\\[\\]]+)!)?(?:${TABLE_BRACKETED_UNIT_QUALIFIER_REGEX})?`;
|
|
1456
1452
|
const REFERENCE_TABLE_ALL_COLUMN_REGEX = `^${TABLE_UNIT_QUALIFIER_REGEX}${TABLE_NAME_REGEX}$`;
|
|
1457
1453
|
const REFERENCE_TABLE_SINGLE_COLUMN_REGEX = `^${TABLE_UNIT_QUALIFIER_REGEX}${TABLE_NAME_REGEX}(${TABLE_CONTENT_REGEX}|\\[${TABLE_TITLE_REGEX}${TABLE_CONTENT_REGEX}\\])+$`;
|
|
1458
1454
|
const REFERENCE_TABLE_MULTIPLE_COLUMN_REGEX = `^${TABLE_UNIT_QUALIFIER_REGEX}${TABLE_NAME_REGEX}(\\[${TABLE_MULTIPLE_COLUMN_REGEX}\\])?$|^${TABLE_UNIT_QUALIFIER_REGEX}${TABLE_NAME_REGEX}(\\[${TABLE_TITLE_REGEX}${TABLE_MULTIPLE_COLUMN_REGEX}\\])?$`;
|
|
@@ -1909,8 +1905,13 @@ function splitTableStructuredRef(ref) {
|
|
|
1909
1905
|
}
|
|
1910
1906
|
quoteOpen = !quoteOpen;
|
|
1911
1907
|
} else if (!quoteOpen && char === "[") bracketDepth++;
|
|
1912
|
-
else if (!quoteOpen && char === "]")
|
|
1913
|
-
|
|
1908
|
+
else if (!quoteOpen && char === "]") {
|
|
1909
|
+
if (bracketDepth > 0 && tableRef[i + 1] === "]") {
|
|
1910
|
+
i++;
|
|
1911
|
+
continue;
|
|
1912
|
+
}
|
|
1913
|
+
bracketDepth--;
|
|
1914
|
+
} else if (!quoteOpen && bracketDepth === 0 && char === "!") {
|
|
1914
1915
|
qualifierEnd = i;
|
|
1915
1916
|
break;
|
|
1916
1917
|
}
|
|
@@ -1918,8 +1919,10 @@ function splitTableStructuredRef(ref) {
|
|
|
1918
1919
|
if (qualifierEnd >= 0) {
|
|
1919
1920
|
unitQualifier = tableRef.slice(0, qualifierEnd).trim();
|
|
1920
1921
|
tableRef = tableRef.slice(qualifierEnd + 1);
|
|
1921
|
-
|
|
1922
|
-
|
|
1922
|
+
const isQuotedQualifier = unitQualifier.startsWith("'") && unitQualifier.endsWith("'");
|
|
1923
|
+
const isBracketedQualifier = !isQuotedQualifier && unitQualifier.startsWith("[") && unitQualifier.endsWith("]");
|
|
1924
|
+
if (isQuotedQualifier) unitQualifier = unitQualifier.slice(1, -1);
|
|
1925
|
+
else if (isBracketedQualifier) unitQualifier = unitQualifier.slice(1, -1).replaceAll("]]", "]");
|
|
1923
1926
|
unitQualifier = unquoteSheetName(unitQualifier);
|
|
1924
1927
|
} else if (tableRef.startsWith("[")) {
|
|
1925
1928
|
const legacyQualifierEnd = tableRef.indexOf("]");
|
|
@@ -2069,7 +2072,6 @@ let DefinedNamesService = class DefinedNamesService extends Disposable {
|
|
|
2069
2072
|
const nameMap = this._definedNameMap[unitId];
|
|
2070
2073
|
if (nameMap === void 0) return null;
|
|
2071
2074
|
if (sheetId) {
|
|
2072
|
-
var _workbookScope;
|
|
2073
2075
|
const normalizedName = name.toLowerCase();
|
|
2074
2076
|
let workbookScope = null;
|
|
2075
2077
|
let firstMatch = null;
|
|
@@ -2081,7 +2083,7 @@ let DefinedNamesService = class DefinedNamesService extends Disposable {
|
|
|
2081
2083
|
if (workbookScope == null) workbookScope = item;
|
|
2082
2084
|
}
|
|
2083
2085
|
}
|
|
2084
|
-
return
|
|
2086
|
+
return workbookScope ?? firstMatch;
|
|
2085
2087
|
}
|
|
2086
2088
|
const cachedMap = this._nameCacheMap[unitId];
|
|
2087
2089
|
if (cachedMap) return cachedMap[name.toLowerCase()] || null;
|
|
@@ -2383,7 +2385,7 @@ var SuperTableService = class extends Disposable {
|
|
|
2383
2385
|
}
|
|
2384
2386
|
hasTable(unitId, tableName) {
|
|
2385
2387
|
const unitIdMap = this._tableMap.get(unitId);
|
|
2386
|
-
if (unitIdMap) return unitIdMap.keys().some((name) => name.toLowerCase() === tableName.toLowerCase());
|
|
2388
|
+
if (unitIdMap) return Array.from(unitIdMap.keys()).some((name) => name.toLowerCase() === tableName.toLowerCase());
|
|
2387
2389
|
return false;
|
|
2388
2390
|
}
|
|
2389
2391
|
_update() {
|
|
@@ -3793,9 +3795,11 @@ var LexerTreeBuilder = class extends Disposable {
|
|
|
3793
3795
|
return this._nodeMaker(formulaString);
|
|
3794
3796
|
}
|
|
3795
3797
|
treeBuilder(formulaString, transformSuffix = true, injectDefinedNameParam) {
|
|
3796
|
-
|
|
3798
|
+
const isCacheable = !/\b(?:LET|LAMBDA)\s*\(/iu.test(formulaString);
|
|
3799
|
+
const cacheKey = injectDefinedNameParam == null ? formulaString : `${injectDefinedNameParam.unitId ?? ""}\0${injectDefinedNameParam.sheetId ?? ""}\0${injectDefinedNameParam.refOffsetX}\0${injectDefinedNameParam.refOffsetY}\0${formulaString}`;
|
|
3800
|
+
if (transformSuffix === true && isCacheable) {
|
|
3797
3801
|
var _this$_simpleCheckDef;
|
|
3798
|
-
const lexerNode = FormulaLexerNodeCache.get(
|
|
3802
|
+
const lexerNode = FormulaLexerNodeCache.get(cacheKey);
|
|
3799
3803
|
const simpleCheckDefinedNameResult = injectDefinedNameParam && ((_this$_simpleCheckDef = this._simpleCheckDefinedName) === null || _this$_simpleCheckDef === void 0 ? void 0 : _this$_simpleCheckDef.call(this, formulaString, injectDefinedNameParam));
|
|
3800
3804
|
if (lexerNode && !simpleCheckDefinedNameResult) return lexerNode;
|
|
3801
3805
|
}
|
|
@@ -3827,13 +3831,13 @@ var LexerTreeBuilder = class extends Disposable {
|
|
|
3827
3831
|
if (node) this._currentLexerNode = node;
|
|
3828
3832
|
if (transformSuffix) {
|
|
3829
3833
|
if (!this._suffixExpressionHandler(this._currentLexerNode)) return "#VALUE!";
|
|
3830
|
-
FormulaLexerNodeCache.set(
|
|
3834
|
+
if (isCacheable) FormulaLexerNodeCache.set(cacheKey, this._currentLexerNode);
|
|
3831
3835
|
}
|
|
3832
3836
|
if (currentHasDefinedName) this._currentLexerNode.setDefinedNames(currentDefinedNames);
|
|
3833
3837
|
return this._currentLexerNode;
|
|
3834
3838
|
}
|
|
3835
3839
|
_handleDefinedName(sequenceArray, param) {
|
|
3836
|
-
const { unitId, sheetId,
|
|
3840
|
+
const { unitId, sheetId, hasFunction, getValueByName } = param;
|
|
3837
3841
|
if (unitId == null) return {
|
|
3838
3842
|
sequenceString: "",
|
|
3839
3843
|
hasDefinedName: false,
|
|
@@ -3852,11 +3856,19 @@ var LexerTreeBuilder = class extends Disposable {
|
|
|
3852
3856
|
const { nodeType, token: tokenRaw } = node;
|
|
3853
3857
|
let token = tokenRaw;
|
|
3854
3858
|
if (nodeType === 4 || nodeType === 3) {
|
|
3855
|
-
if (nodeType === 3)
|
|
3859
|
+
if (nodeType === 3) {
|
|
3860
|
+
const nextNode = sequenceNodes[i + 1];
|
|
3861
|
+
if (typeof nextNode === "string" && nextNode.trim() === "(" && hasFunction(tokenRaw.trim().toUpperCase())) {
|
|
3862
|
+
sequenceString += tokenRaw;
|
|
3863
|
+
continue;
|
|
3864
|
+
}
|
|
3865
|
+
token = this._getHasSheetNameDefinedName(tokenRaw, unitId, param);
|
|
3866
|
+
}
|
|
3856
3867
|
const definedNameToken = token.trim();
|
|
3857
3868
|
const definedContent = getValueByName(unitId, definedNameToken, sheetId);
|
|
3858
3869
|
if (definedContent) {
|
|
3859
|
-
const
|
|
3870
|
+
const refOffsetX = definedContent.localSheetId === "AllDefaultWorkbook" ? param.refOffsetX - 1 : param.refOffsetX;
|
|
3871
|
+
const refString = definedContent.formulaOrRefString.startsWith("=") ? definedContent.formulaOrRefString : this._moveDefinedNameRefOffset(definedContent.formulaOrRefString, refOffsetX, param.refOffsetY);
|
|
3860
3872
|
const nestedDefinedNameParam = this._handleNestedDefinedName(refString, param);
|
|
3861
3873
|
if (nestedDefinedNameParam == null || typeof nestedDefinedNameParam !== "object") {
|
|
3862
3874
|
sequenceString += nestedDefinedNameParam || "#NAME?";
|
|
@@ -3883,6 +3895,28 @@ var LexerTreeBuilder = class extends Disposable {
|
|
|
3883
3895
|
definedNames
|
|
3884
3896
|
};
|
|
3885
3897
|
}
|
|
3898
|
+
_moveDefinedNameRefOffset(formulaString, refOffsetX, refOffsetY) {
|
|
3899
|
+
const sequenceNodes = this.sequenceNodesBuilder(formulaString);
|
|
3900
|
+
if (sequenceNodes == null) return formulaString;
|
|
3901
|
+
return generateStringWithSequence(sequenceNodes.map((node) => {
|
|
3902
|
+
if (typeof node === "string" || node.nodeType !== 4) return node;
|
|
3903
|
+
const sequenceGrid = deserializeRangeWithSheetWithCache(node.token);
|
|
3904
|
+
const range = moveRangeByOffset(sequenceGrid.range, refOffsetX, refOffsetY);
|
|
3905
|
+
const wrap = (value, limit) => (value % limit + limit) % limit;
|
|
3906
|
+
range.startRow = wrap(range.startRow, MAX_ROW_COUNT);
|
|
3907
|
+
range.endRow = wrap(range.endRow, MAX_ROW_COUNT);
|
|
3908
|
+
range.startColumn = wrap(range.startColumn, MAX_COLUMN_COUNT);
|
|
3909
|
+
range.endColumn = wrap(range.endColumn, MAX_COLUMN_COUNT);
|
|
3910
|
+
return {
|
|
3911
|
+
...node,
|
|
3912
|
+
token: serializeRangeToRefString({
|
|
3913
|
+
range,
|
|
3914
|
+
unitId: sequenceGrid.unitId,
|
|
3915
|
+
sheetName: sequenceGrid.sheetName
|
|
3916
|
+
})
|
|
3917
|
+
};
|
|
3918
|
+
}));
|
|
3919
|
+
}
|
|
3886
3920
|
_getHasSheetNameDefinedName(tokenRaw, unitId, param) {
|
|
3887
3921
|
if (!tokenRaw.includes("!")) return tokenRaw;
|
|
3888
3922
|
const parts = tokenRaw.split("!");
|
|
@@ -4309,7 +4343,7 @@ var LexerTreeBuilder = class extends Disposable {
|
|
|
4309
4343
|
}
|
|
4310
4344
|
this._resetSegment();
|
|
4311
4345
|
continue;
|
|
4312
|
-
} else if (currentString === "(" && this.isSingleQuotationClose() && this.isDoubleQuotationClose()) if (this._segmentCount() > 0 || this.isLambdaOpen()) {
|
|
4346
|
+
} else if (currentString === "(" && this.isSingleQuotationClose() && this.isDoubleQuotationClose() && this.isSquareBracketClose()) if (this._segmentCount() > 0 || this.isLambdaOpen()) {
|
|
4313
4347
|
if (this.isLambdaClose()) {
|
|
4314
4348
|
this._newAndPushCurrentLexerNode(this._segment, cur);
|
|
4315
4349
|
this._resetSegment();
|
|
@@ -4337,7 +4371,7 @@ var LexerTreeBuilder = class extends Disposable {
|
|
|
4337
4371
|
this._openBracketNormalIndex();
|
|
4338
4372
|
this._resetSegment();
|
|
4339
4373
|
}
|
|
4340
|
-
else if (currentString === ")" && this.isSingleQuotationClose() && this.isDoubleQuotationClose()) {
|
|
4374
|
+
else if (currentString === ")" && this.isSingleQuotationClose() && this.isDoubleQuotationClose() && this.isSquareBracketClose()) {
|
|
4341
4375
|
if (this._formulaErrorLastTokenCheck(formulaChars, cur - 1)) this._formalErrorOccurred();
|
|
4342
4376
|
this._pushNodeToChildren(this._segment);
|
|
4343
4377
|
this._resetSegment();
|
|
@@ -5053,9 +5087,11 @@ let FormulaDataModel = class FormulaDataModel extends Disposable {
|
|
|
5053
5087
|
const unitId = base.getUnitId();
|
|
5054
5088
|
formulaData[unitId] = {};
|
|
5055
5089
|
const tables = Object.values(snapshot.tables);
|
|
5090
|
+
const formulaTableNames = createBaseFormulaTableNameMap(snapshot);
|
|
5056
5091
|
for (let j = 0; j < tables.length; j++) {
|
|
5057
5092
|
const table = tables[j];
|
|
5058
5093
|
const tableFormulaData = {};
|
|
5094
|
+
const normalizedFormulaByFieldId = /* @__PURE__ */ new Map();
|
|
5059
5095
|
const recordOrder = table.recordOrder;
|
|
5060
5096
|
if (!recordOrder) {
|
|
5061
5097
|
formulaData[unitId][table.id] = tableFormulaData;
|
|
@@ -5065,15 +5101,20 @@ let FormulaDataModel = class FormulaDataModel extends Disposable {
|
|
|
5065
5101
|
const recordId = recordOrder[row];
|
|
5066
5102
|
if (!table.records[recordId]) continue;
|
|
5067
5103
|
for (let col = 0; col < table.fieldOrder.length; col++) {
|
|
5068
|
-
var _field$config
|
|
5104
|
+
var _field$config;
|
|
5069
5105
|
const fieldId = table.fieldOrder[col];
|
|
5070
5106
|
const field = table.fields[fieldId];
|
|
5071
5107
|
if (!field || field.type !== "formula") continue;
|
|
5072
|
-
const formula = String((
|
|
5108
|
+
const formula = String(((_field$config = field.config) === null || _field$config === void 0 ? void 0 : _field$config.formula) ?? "").trim();
|
|
5073
5109
|
if (!formula) continue;
|
|
5074
|
-
|
|
5110
|
+
let normalizedFormula = normalizedFormulaByFieldId.get(field.id);
|
|
5111
|
+
if (normalizedFormula == null) {
|
|
5112
|
+
normalizedFormula = normalizeBaseFormulaForEngine(formula, table, snapshot, formulaTableNames);
|
|
5113
|
+
normalizedFormulaByFieldId.set(field.id, normalizedFormula);
|
|
5114
|
+
}
|
|
5115
|
+
tableFormulaData[row] ??= {};
|
|
5075
5116
|
tableFormulaData[row][col] = {
|
|
5076
|
-
f:
|
|
5117
|
+
f: normalizedFormula,
|
|
5077
5118
|
si: field.id
|
|
5078
5119
|
};
|
|
5079
5120
|
}
|
|
@@ -5201,16 +5242,17 @@ let FormulaDataModel = class FormulaDataModel extends Disposable {
|
|
|
5201
5242
|
};
|
|
5202
5243
|
const baseData = {};
|
|
5203
5244
|
const tableNameMap = {};
|
|
5245
|
+
const formulaTableNames = createBaseFormulaTableNameMap(snapshot);
|
|
5204
5246
|
for (const table of Object.values(snapshot.tables)) {
|
|
5205
|
-
var _table$recordOrder
|
|
5247
|
+
var _table$recordOrder;
|
|
5206
5248
|
baseData[table.id] = {
|
|
5207
5249
|
cellData: new ObjectMatrix(buildBaseRuntimeCellData(table)),
|
|
5208
|
-
rowCount: (
|
|
5250
|
+
rowCount: ((_table$recordOrder = table.recordOrder) === null || _table$recordOrder === void 0 ? void 0 : _table$recordOrder.length) ?? 0,
|
|
5209
5251
|
columnCount: table.fieldOrder.length,
|
|
5210
5252
|
rowData: {},
|
|
5211
5253
|
columnData: {}
|
|
5212
5254
|
};
|
|
5213
|
-
tableNameMap
|
|
5255
|
+
addEngineBaseTableNameMappings(tableNameMap, table, formulaTableNames);
|
|
5214
5256
|
}
|
|
5215
5257
|
allUnitData[unitId] = baseData;
|
|
5216
5258
|
unitStylesData[unitId] = new Styles();
|
|
@@ -5248,7 +5290,7 @@ let FormulaDataModel = class FormulaDataModel extends Disposable {
|
|
|
5248
5290
|
return rowData;
|
|
5249
5291
|
}
|
|
5250
5292
|
updateFormulaData(unitId, sheetId, cellValue) {
|
|
5251
|
-
var _this$_univerInstance, _formulaData$unitId
|
|
5293
|
+
var _this$_univerInstance, _formulaData$unitId;
|
|
5252
5294
|
const cellMatrix = new ObjectMatrix(cellValue);
|
|
5253
5295
|
const newSheetFormulaDataMatrix = new ObjectMatrix();
|
|
5254
5296
|
const worksheetCellMatrix = (_this$_univerInstance = this._univerInstanceService.getUnit(unitId)) === null || _this$_univerInstance === void 0 || (_this$_univerInstance = _this$_univerInstance.getSheetBySheetId(sheetId)) === null || _this$_univerInstance === void 0 ? void 0 : _this$_univerInstance.getCellMatrix();
|
|
@@ -5283,7 +5325,7 @@ let FormulaDataModel = class FormulaDataModel extends Disposable {
|
|
|
5283
5325
|
const formulaData = {};
|
|
5284
5326
|
initSheetFormulaData(formulaData, unitId, sheetId, sharedFormulaCellMatrix);
|
|
5285
5327
|
const deleteFormulaIdMap = /* @__PURE__ */ new Map();
|
|
5286
|
-
const sheetFormulaDataMatrix = new ObjectMatrix((
|
|
5328
|
+
const sheetFormulaDataMatrix = new ObjectMatrix(((_formulaData$unitId = formulaData[unitId]) === null || _formulaData$unitId === void 0 ? void 0 : _formulaData$unitId[sheetId]) ?? {});
|
|
5287
5329
|
cellMatrix.forValue((r, c, cell) => {
|
|
5288
5330
|
var _worksheetCellMatrix$;
|
|
5289
5331
|
if (!isFormulaId(worksheetCellMatrix === null || worksheetCellMatrix === void 0 || (_worksheetCellMatrix$ = worksheetCellMatrix.getValue(r, c)) === null || _worksheetCellMatrix$ === void 0 ? void 0 : _worksheetCellMatrix$.si) && !isFormulaId(cell === null || cell === void 0 ? void 0 : cell.si)) return;
|
|
@@ -5480,7 +5522,7 @@ let FormulaDataModel = class FormulaDataModel extends Disposable {
|
|
|
5480
5522
|
if (isFormulaString(cell === null || cell === void 0 ? void 0 : cell.f) && isFormulaId(formulaId)) formulaIds.add(String(formulaId));
|
|
5481
5523
|
});
|
|
5482
5524
|
cellMatrix.forValue((row, column, cell) => {
|
|
5483
|
-
var
|
|
5525
|
+
var _this$_arrayFormulaRa7, _this$_arrayFormulaCe5;
|
|
5484
5526
|
const ref = cell === null || cell === void 0 ? void 0 : cell.ref;
|
|
5485
5527
|
const formula = cell === null || cell === void 0 ? void 0 : cell.f;
|
|
5486
5528
|
const formulaId = cell === null || cell === void 0 ? void 0 : cell.si;
|
|
@@ -5492,8 +5534,8 @@ let FormulaDataModel = class FormulaDataModel extends Disposable {
|
|
|
5492
5534
|
if (range.startRow === row && range.endRow === row && range.startColumn === column && range.endColumn === column && !isArrayConstantFormula(formula)) return true;
|
|
5493
5535
|
if (!this._arrayFormulaRange[unitId]) this._arrayFormulaRange[unitId] = {};
|
|
5494
5536
|
if (!this._arrayFormulaCellData[unitId]) this._arrayFormulaCellData[unitId] = {};
|
|
5495
|
-
|
|
5496
|
-
|
|
5537
|
+
arrayFormulaRangeMatrix ??= new ObjectMatrix((_this$_arrayFormulaRa7 = this._arrayFormulaRange[unitId]) === null || _this$_arrayFormulaRa7 === void 0 ? void 0 : _this$_arrayFormulaRa7[sheetId]);
|
|
5538
|
+
arrayFormulaCellDataMatrix ??= new ObjectMatrix((_this$_arrayFormulaCe5 = this._arrayFormulaCellData[unitId]) === null || _this$_arrayFormulaCe5 === void 0 ? void 0 : _this$_arrayFormulaCe5[sheetId]);
|
|
5497
5539
|
if (arrayFormulaRangeMatrix.getValue(row, column) == null) arrayFormulaRangeMatrix.setValue(row, column, range);
|
|
5498
5540
|
for (let r = range.startRow; r <= range.endRow; r++) for (let c = range.startColumn; c <= range.endColumn; c++) {
|
|
5499
5541
|
if (arrayFormulaCellDataMatrix.getValue(r, c) != null) continue;
|
|
@@ -5554,31 +5596,47 @@ function initSheetFormulaData(formulaData, unitId, sheetId, cellMatrix) {
|
|
|
5554
5596
|
return { [unitId]: { [sheetId]: newSheetFormulaData } };
|
|
5555
5597
|
}
|
|
5556
5598
|
const BASE_LEGACY_FIELD_REF_PATTERN = /\{([^}]+)\}/g;
|
|
5557
|
-
const
|
|
5558
|
-
const
|
|
5599
|
+
const BASE_TABLE_SCOPED_FIELD_REF_PATTERN = /\b([A-Z_][\w.]*)\[\[\s*#(This Row|Data)\s*\],\s*\[([^\]]+)\]\]/gi;
|
|
5600
|
+
const BASE_TABLE_CURRENT_ROW_FIELD_REF_PATTERN = /\b([A-Z_][\w.]*)\[@\[([^\]]+)\]\]/gi;
|
|
5601
|
+
const BASE_TABLE_FIELD_REF_PATTERN = /\b([A-Z_][\w.]*)\[([^\[\]#]+)\]/gi;
|
|
5602
|
+
const BASE_SCOPED_FIELD_REF_PATTERN = /(^|[^\w\[])\[\[\s*#(This Row|Data)\s*\],\s*\[([^\]]+)\]\]/gi;
|
|
5603
|
+
const BASE_CURRENT_ROW_FIELD_REF_PATTERN = /(^|[^\w\[])\[@\[([^\]]+)\]\](?!\])/g;
|
|
5604
|
+
const BASE_BRACKET_FIELD_REF_PATTERN = /(^|[^\w\[])\[@?([^\[\]#]+)\](?!\])/g;
|
|
5559
5605
|
const BASE_EXTERNAL_A1_REF_PATTERN = /(?:'\[[^\]]+\](?:[^']|'')+'|\[[^\]]+\][^\s'!]+)!\$?[A-Z]{1,3}\$?\d+(?::\$?[A-Z]{1,3}\$?\d+)?/gi;
|
|
5560
5606
|
const BASE_EXTERNAL_STRUCTURED_REFERENCE_PREFIX = /(?:'((?:[^']|'')+)'|\[[^\]]+\]|[A-Za-z0-9_.-]+)![^\s!\[\]]+\[/g;
|
|
5561
|
-
function normalizeBaseFormulaForEngine(formula, currentTable, snapshot) {
|
|
5607
|
+
function normalizeBaseFormulaForEngine(formula, currentTable, snapshot, formulaTableNames) {
|
|
5562
5608
|
const refs = [];
|
|
5563
5609
|
const hold = (ref) => {
|
|
5564
5610
|
return `__BASE_FORMULA_REF_${refs.push(ref) - 1}__`;
|
|
5565
5611
|
};
|
|
5566
|
-
return
|
|
5567
|
-
const targetTable = resolveBaseFormulaTable(sourceTableName, currentTable, snapshot);
|
|
5568
|
-
|
|
5569
|
-
|
|
5570
|
-
|
|
5571
|
-
|
|
5572
|
-
|
|
5612
|
+
return protectBaseFormulaParts(formula, hold).replace(BASE_LEGACY_FIELD_REF_PATTERN, (_match, fieldName) => hold(createEngineThisRowRef(currentTable, fieldName, formulaTableNames))).replace(BASE_TABLE_SCOPED_FIELD_REF_PATTERN, (_match, sourceTableName, scope, fieldName) => {
|
|
5613
|
+
const targetTable = resolveBaseFormulaTable(sourceTableName, currentTable, snapshot, formulaTableNames);
|
|
5614
|
+
if (!targetTable) return `${sourceTableName}[[#${scope}],[${fieldName}]]`;
|
|
5615
|
+
return hold(scope.toLowerCase() === "data" ? createEngineColumnRef(targetTable, fieldName, formulaTableNames) : createEngineThisRowRef(targetTable, fieldName, formulaTableNames));
|
|
5616
|
+
}).replace(BASE_TABLE_CURRENT_ROW_FIELD_REF_PATTERN, (_match, sourceTableName, fieldName) => {
|
|
5617
|
+
const targetTable = resolveBaseFormulaTable(sourceTableName, currentTable, snapshot, formulaTableNames);
|
|
5618
|
+
return targetTable ? hold(createEngineThisRowRef(targetTable, fieldName, formulaTableNames)) : `${sourceTableName}[@[${fieldName}]]`;
|
|
5619
|
+
}).replace(BASE_SCOPED_FIELD_REF_PATTERN, (_match, prefix, scope, fieldName) => `${prefix}${hold(scope.toLowerCase() === "data" ? createEngineColumnRef(currentTable, fieldName, formulaTableNames) : createEngineThisRowRef(currentTable, fieldName, formulaTableNames))}`).replace(BASE_CURRENT_ROW_FIELD_REF_PATTERN, (_match, prefix, fieldName) => `${prefix}${hold(createEngineThisRowRef(currentTable, fieldName, formulaTableNames))}`).replace(BASE_TABLE_FIELD_REF_PATTERN, (_match, sourceTableName, fieldName) => {
|
|
5620
|
+
const targetTable = resolveBaseFormulaTable(sourceTableName, currentTable, snapshot, formulaTableNames);
|
|
5621
|
+
if (targetTable) return hold(createEngineColumnRef(targetTable, fieldName, formulaTableNames));
|
|
5622
|
+
return `${sourceTableName}[${fieldName}]`;
|
|
5623
|
+
}).replace(BASE_BRACKET_FIELD_REF_PATTERN, (_match, prefix, fieldName) => `${prefix}${hold(createEngineThisRowRef(currentTable, fieldName, formulaTableNames))}`).replace(/__BASE_FORMULA_REF_(\d+)__/g, (_match, index) => refs[Number(index)] ?? "");
|
|
5573
5624
|
}
|
|
5574
5625
|
function protectBaseExternalReferences(formula, replace) {
|
|
5575
5626
|
return protectBaseExternalStructuredReferences(formula.replace(BASE_EXTERNAL_A1_REF_PATTERN, (reference, offset) => isInsideBaseFormulaString(formula, offset) ? reference : replace(reference)), replace);
|
|
5576
5627
|
}
|
|
5628
|
+
function protectBaseFormulaParts(formula, replace) {
|
|
5629
|
+
return protectBaseFormulaStrings(protectBaseExternalReferences(formula, replace), replace);
|
|
5630
|
+
}
|
|
5631
|
+
function protectBaseFormulaStrings(formula, replace) {
|
|
5632
|
+
return formula.replace(/"(?:""|[^"])*"/g, replace);
|
|
5633
|
+
}
|
|
5577
5634
|
function protectBaseExternalStructuredReferences(formula, replace) {
|
|
5578
5635
|
const spans = [];
|
|
5579
5636
|
BASE_EXTERNAL_STRUCTURED_REFERENCE_PREFIX.lastIndex = 0;
|
|
5580
|
-
|
|
5581
|
-
|
|
5637
|
+
while (true) {
|
|
5638
|
+
const match = BASE_EXTERNAL_STRUCTURED_REFERENCE_PREFIX.exec(formula);
|
|
5639
|
+
if (match == null) break;
|
|
5582
5640
|
if (isInsideBaseFormulaString(formula, match.index)) continue;
|
|
5583
5641
|
const openBracket = BASE_EXTERNAL_STRUCTURED_REFERENCE_PREFIX.lastIndex - 1;
|
|
5584
5642
|
let depth = 0;
|
|
@@ -5618,17 +5676,20 @@ function isInsideBaseFormulaString(formula, position) {
|
|
|
5618
5676
|
}
|
|
5619
5677
|
return inString;
|
|
5620
5678
|
}
|
|
5621
|
-
function createEngineThisRowRef(table, fieldName,
|
|
5622
|
-
return `${
|
|
5679
|
+
function createEngineThisRowRef(table, fieldName, formulaTableNames) {
|
|
5680
|
+
return `${formulaTableNames.get(table.id) ?? getBaseFormulaTableName(table, { tables: { [table.id]: table } })}[[#This Row],[${fieldName}]]`;
|
|
5623
5681
|
}
|
|
5624
|
-
function
|
|
5625
|
-
|
|
5626
|
-
|
|
5627
|
-
|
|
5628
|
-
|
|
5629
|
-
|
|
5630
|
-
|
|
5631
|
-
return
|
|
5682
|
+
function createEngineColumnRef(table, fieldName, formulaTableNames) {
|
|
5683
|
+
return `${formulaTableNames.get(table.id) ?? getBaseFormulaTableName(table, { tables: { [table.id]: table } })}[[#Data],[${fieldName}]]`;
|
|
5684
|
+
}
|
|
5685
|
+
function addEngineBaseTableNameMappings(tableNameMap, table, formulaTableNames) {
|
|
5686
|
+
tableNameMap[formulaTableNames.get(table.id) ?? table.name] = table.id;
|
|
5687
|
+
}
|
|
5688
|
+
function createStableExcelTableName(tableId) {
|
|
5689
|
+
return `_T_${Array.from(tableId, (character) => {
|
|
5690
|
+
var _character$codePointA;
|
|
5691
|
+
return /[A-Za-z0-9]/.test(character) ? character : `_x${((_character$codePointA = character.codePointAt(0)) === null || _character$codePointA === void 0 ? void 0 : _character$codePointA.toString(16)) ?? "0"}_`;
|
|
5692
|
+
}).join("")}`;
|
|
5632
5693
|
}
|
|
5633
5694
|
function buildBaseRuntimeCellData(table) {
|
|
5634
5695
|
const cellData = { ...table.cellData };
|
|
@@ -5645,8 +5706,7 @@ function buildBaseRuntimeCellData(table) {
|
|
|
5645
5706
|
if (table.records[recordId]) recordOrder.push(recordId);
|
|
5646
5707
|
}
|
|
5647
5708
|
} else {
|
|
5648
|
-
|
|
5649
|
-
const allRecords = Object.values((_table$records = table.records) !== null && _table$records !== void 0 ? _table$records : {});
|
|
5709
|
+
const allRecords = Object.values(table.records ?? {});
|
|
5650
5710
|
const records = [];
|
|
5651
5711
|
for (let i = 0; i < allRecords.length; i++) {
|
|
5652
5712
|
const record = allRecords[i];
|
|
@@ -5665,9 +5725,8 @@ function buildBaseRuntimeCellData(table) {
|
|
|
5665
5725
|
if (!record) continue;
|
|
5666
5726
|
cellData[row] = { ...cellData[row] };
|
|
5667
5727
|
for (let col = 0; col < fieldOrder.length; col++) {
|
|
5668
|
-
var _record$values;
|
|
5669
5728
|
const fieldId = fieldOrder[col];
|
|
5670
|
-
if (!Object.prototype.hasOwnProperty.call(
|
|
5729
|
+
if (!Object.prototype.hasOwnProperty.call(record.values ?? {}, fieldId)) continue;
|
|
5671
5730
|
cellData[row][col] = toBaseRuntimeCellData(record.values[fieldId], table.fields[fieldId]);
|
|
5672
5731
|
}
|
|
5673
5732
|
}
|
|
@@ -5684,10 +5743,9 @@ function toBaseRuntimeCellData(value, field) {
|
|
|
5684
5743
|
t: CellValueType.STRING
|
|
5685
5744
|
};
|
|
5686
5745
|
if ((field === null || field === void 0 ? void 0 : field.type) === "link" && value && typeof value === "object") {
|
|
5687
|
-
var _ref, _link$text;
|
|
5688
5746
|
const link = value;
|
|
5689
5747
|
return {
|
|
5690
|
-
v: String(
|
|
5748
|
+
v: String(link.text ?? link.url ?? ""),
|
|
5691
5749
|
t: CellValueType.STRING
|
|
5692
5750
|
};
|
|
5693
5751
|
}
|
|
@@ -5701,8 +5759,7 @@ function toBaseRuntimeCellData(value, field) {
|
|
|
5701
5759
|
};
|
|
5702
5760
|
}
|
|
5703
5761
|
function normalizeBaseCellData(cell) {
|
|
5704
|
-
|
|
5705
|
-
const type = inferBaseRuntimeCellType((_cell$v = cell.v) !== null && _cell$v !== void 0 ? _cell$v : null);
|
|
5762
|
+
const type = inferBaseRuntimeCellType(cell.v ?? null);
|
|
5706
5763
|
return {
|
|
5707
5764
|
...cell,
|
|
5708
5765
|
t: type
|
|
@@ -5720,11 +5777,13 @@ function isArrayConstantFormula(formula) {
|
|
|
5720
5777
|
function isBaseCellData(value) {
|
|
5721
5778
|
return !!value && typeof value === "object" && (Object.prototype.hasOwnProperty.call(value, "v") || Object.prototype.hasOwnProperty.call(value, "t") || Object.prototype.hasOwnProperty.call(value, "p") || Object.prototype.hasOwnProperty.call(value, "f") || Object.prototype.hasOwnProperty.call(value, "si"));
|
|
5722
5779
|
}
|
|
5723
|
-
function resolveBaseFormulaTable(tableName, currentTable, snapshot) {
|
|
5724
|
-
if (!tableName
|
|
5725
|
-
const
|
|
5726
|
-
|
|
5727
|
-
|
|
5780
|
+
function resolveBaseFormulaTable(tableName, currentTable, snapshot, formulaTableNames) {
|
|
5781
|
+
if (!tableName) return currentTable;
|
|
5782
|
+
const normalizedName = tableName.toLowerCase();
|
|
5783
|
+
const matches = Object.values(snapshot.tables).filter((table) => {
|
|
5784
|
+
var _formulaTableNames$ge;
|
|
5785
|
+
return table.id.toLowerCase() === normalizedName || table.name.toLowerCase() === normalizedName || ((_formulaTableNames$ge = formulaTableNames.get(table.id)) === null || _formulaTableNames$ge === void 0 ? void 0 : _formulaTableNames$ge.toLowerCase()) === normalizedName || createStableExcelTableName(table.id).toLowerCase() === normalizedName;
|
|
5786
|
+
});
|
|
5728
5787
|
return matches.length === 1 ? matches[0] : void 0;
|
|
5729
5788
|
}
|
|
5730
5789
|
|
|
@@ -5754,9 +5813,8 @@ var SheetRowFilteredService = class extends Disposable {
|
|
|
5754
5813
|
this._getRowFilteredCallback = callback;
|
|
5755
5814
|
}
|
|
5756
5815
|
getRowFiltered(unitId, subUnitId, row) {
|
|
5757
|
-
var _this$_getRowFiltered;
|
|
5758
5816
|
if (!this._getRowFilteredCallback) return false;
|
|
5759
|
-
return
|
|
5817
|
+
return this._getRowFilteredCallback(unitId, subUnitId, row) ?? false;
|
|
5760
5818
|
}
|
|
5761
5819
|
};
|
|
5762
5820
|
const ISheetRowFilteredService = createIdentifier("univer.formula.sheet-row-filtered.service");
|
|
@@ -5889,7 +5947,6 @@ let FormulaCurrentConfigService = class FormulaCurrentConfigService extends Disp
|
|
|
5889
5947
|
return this._localeService.getCurrentLocale();
|
|
5890
5948
|
}
|
|
5891
5949
|
getSheetsInfo() {
|
|
5892
|
-
var _this$_sheetIdToNameM;
|
|
5893
5950
|
const workbook = this._univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_SHEET);
|
|
5894
5951
|
if (!workbook) return {
|
|
5895
5952
|
sheetOrder: [],
|
|
@@ -5898,7 +5955,7 @@ let FormulaCurrentConfigService = class FormulaCurrentConfigService extends Disp
|
|
|
5898
5955
|
const { id, sheetOrder } = workbook.getSnapshot();
|
|
5899
5956
|
return {
|
|
5900
5957
|
sheetOrder,
|
|
5901
|
-
sheetNameMap:
|
|
5958
|
+
sheetNameMap: this._sheetIdToNameMap[id] ?? {}
|
|
5902
5959
|
};
|
|
5903
5960
|
}
|
|
5904
5961
|
getSheetRowColumnCount(unitId, sheetId) {
|
|
@@ -5925,7 +5982,6 @@ let FormulaCurrentConfigService = class FormulaCurrentConfigService extends Disp
|
|
|
5925
5982
|
return filteredOutRows;
|
|
5926
5983
|
}
|
|
5927
5984
|
load(config) {
|
|
5928
|
-
var _config$externalRefer;
|
|
5929
5985
|
this._calculationGeneration++;
|
|
5930
5986
|
if (config.allUnitData && config.unitSheetNameMap && config.unitStylesData) {
|
|
5931
5987
|
this._unitData = config.allUnitData;
|
|
@@ -5951,7 +6007,7 @@ let FormulaCurrentConfigService = class FormulaCurrentConfigService extends Disp
|
|
|
5951
6007
|
this._dirtySuperTableMap = config.dirtySuperTableMap || {};
|
|
5952
6008
|
this._dirtyUnitFeatureMap = config.dirtyUnitFeatureMap;
|
|
5953
6009
|
this._dirtyUnitOtherFormulaMap = config.dirtyUnitOtherFormulaMap;
|
|
5954
|
-
this._externalReferences =
|
|
6010
|
+
this._externalReferences = config.externalReferences ?? {};
|
|
5955
6011
|
this._excludedCell = config.excludedCell;
|
|
5956
6012
|
this._mergeNameMap(this._sheetNameMap, this._dirtyNameMap);
|
|
5957
6013
|
}
|
|
@@ -6015,13 +6071,12 @@ let FormulaCurrentConfigService = class FormulaCurrentConfigService extends Disp
|
|
|
6015
6071
|
});
|
|
6016
6072
|
}
|
|
6017
6073
|
_loadSheetData() {
|
|
6018
|
-
var _workbook$getUnitId, _worksheet$getSheetId;
|
|
6019
6074
|
const workbook = this._univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_SHEET);
|
|
6020
6075
|
const worksheet = workbook === null || workbook === void 0 ? void 0 : workbook.getActiveSheet();
|
|
6021
6076
|
const base = workbook ? null : this._univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_BASE);
|
|
6022
6077
|
const table = base ? getFirstBaseTable(base.getSnapshot().tables, base.getSnapshot().tableOrder) : null;
|
|
6023
|
-
this._executeUnitId = (
|
|
6024
|
-
this._executeSubUnitId = (
|
|
6078
|
+
this._executeUnitId = (workbook === null || workbook === void 0 ? void 0 : workbook.getUnitId()) ?? (base === null || base === void 0 ? void 0 : base.getUnitId());
|
|
6079
|
+
this._executeSubUnitId = (worksheet === null || worksheet === void 0 ? void 0 : worksheet.getSheetId()) ?? (table === null || table === void 0 ? void 0 : table.id);
|
|
6025
6080
|
return this._formulaDataModel.getCalculateData();
|
|
6026
6081
|
}
|
|
6027
6082
|
/**
|
|
@@ -6053,29 +6108,334 @@ FormulaCurrentConfigService = __decorate([
|
|
|
6053
6108
|
__decorateParam(3, Inject(ISheetRowFilteredService))
|
|
6054
6109
|
], FormulaCurrentConfigService);
|
|
6055
6110
|
function getFirstBaseTable(tables, tableOrder) {
|
|
6056
|
-
var _Object$values$;
|
|
6057
6111
|
for (const tableId of tableOrder) {
|
|
6058
6112
|
const table = tables[tableId];
|
|
6059
6113
|
if (table) return table;
|
|
6060
6114
|
}
|
|
6061
|
-
return
|
|
6115
|
+
return Object.values(tables)[0] ?? null;
|
|
6062
6116
|
}
|
|
6063
6117
|
const IFormulaCurrentConfigService = createIdentifier("univer.formula.current-data.service");
|
|
6064
6118
|
|
|
6119
|
+
//#endregion
|
|
6120
|
+
//#region src/engine/ast-node/node-type.ts
|
|
6121
|
+
const NODE_ORDER_MAP = /* @__PURE__ */ new Map([
|
|
6122
|
+
[1, 7],
|
|
6123
|
+
[2, 9],
|
|
6124
|
+
[3, 8],
|
|
6125
|
+
[4, 6],
|
|
6126
|
+
[5, 1],
|
|
6127
|
+
[6, 2],
|
|
6128
|
+
[9, 10],
|
|
6129
|
+
[10, 3],
|
|
6130
|
+
[11, 4],
|
|
6131
|
+
[12, 5]
|
|
6132
|
+
]);
|
|
6133
|
+
|
|
6134
|
+
//#endregion
|
|
6135
|
+
//#region src/engine/ast-node/base-ast-node.ts
|
|
6136
|
+
var BaseAstNode = class {
|
|
6137
|
+
constructor(_token) {
|
|
6138
|
+
this._token = _token;
|
|
6139
|
+
_defineProperty(this, "_children", []);
|
|
6140
|
+
_defineProperty(this, "_definedNames", void 0);
|
|
6141
|
+
_defineProperty(this, "_parent", void 0);
|
|
6142
|
+
_defineProperty(this, "_valueObject", void 0);
|
|
6143
|
+
_defineProperty(this, "_calculateState", false);
|
|
6144
|
+
_defineProperty(this, "_async", false);
|
|
6145
|
+
_defineProperty(this, "_address", false);
|
|
6146
|
+
_defineProperty(this, "_isForcedCalculateFunction", false);
|
|
6147
|
+
}
|
|
6148
|
+
dispose() {
|
|
6149
|
+
var _this$_valueObject;
|
|
6150
|
+
this._children.forEach((node) => {
|
|
6151
|
+
node.dispose();
|
|
6152
|
+
});
|
|
6153
|
+
(_this$_valueObject = this._valueObject) === null || _this$_valueObject === void 0 || _this$_valueObject.dispose();
|
|
6154
|
+
this._valueObject = null;
|
|
6155
|
+
this._children = [];
|
|
6156
|
+
this._definedNames = null;
|
|
6157
|
+
this._parent = null;
|
|
6158
|
+
}
|
|
6159
|
+
get nodeType() {
|
|
6160
|
+
return 8;
|
|
6161
|
+
}
|
|
6162
|
+
resetCalculationState() {
|
|
6163
|
+
this._children.forEach((node) => {
|
|
6164
|
+
node.resetCalculationState();
|
|
6165
|
+
});
|
|
6166
|
+
this._valueObject = null;
|
|
6167
|
+
this._calculateState = false;
|
|
6168
|
+
}
|
|
6169
|
+
isAsync() {
|
|
6170
|
+
return this._async;
|
|
6171
|
+
}
|
|
6172
|
+
isAddress() {
|
|
6173
|
+
return this._address;
|
|
6174
|
+
}
|
|
6175
|
+
isForcedCalculateFunction() {
|
|
6176
|
+
return this._isForcedCalculateFunction;
|
|
6177
|
+
}
|
|
6178
|
+
setAsync() {
|
|
6179
|
+
this._async = true;
|
|
6180
|
+
}
|
|
6181
|
+
setAddress() {
|
|
6182
|
+
this._address = true;
|
|
6183
|
+
}
|
|
6184
|
+
getParent() {
|
|
6185
|
+
return this._parent;
|
|
6186
|
+
}
|
|
6187
|
+
setParent(node) {
|
|
6188
|
+
this._parent = node;
|
|
6189
|
+
node.addChildren(this);
|
|
6190
|
+
}
|
|
6191
|
+
setForcedCalculateFunction() {
|
|
6192
|
+
this._isForcedCalculateFunction = true;
|
|
6193
|
+
}
|
|
6194
|
+
getChildren() {
|
|
6195
|
+
return this._children;
|
|
6196
|
+
}
|
|
6197
|
+
addChildren(...astNode) {
|
|
6198
|
+
this._children.push(...astNode);
|
|
6199
|
+
}
|
|
6200
|
+
getToken() {
|
|
6201
|
+
return this._token;
|
|
6202
|
+
}
|
|
6203
|
+
setValue(value) {
|
|
6204
|
+
this._valueObject = value;
|
|
6205
|
+
}
|
|
6206
|
+
getValue() {
|
|
6207
|
+
return this._valueObject;
|
|
6208
|
+
}
|
|
6209
|
+
preservesLazyIfReferenceArray(_child) {
|
|
6210
|
+
return false;
|
|
6211
|
+
}
|
|
6212
|
+
isCalculated() {
|
|
6213
|
+
return this._calculateState;
|
|
6214
|
+
}
|
|
6215
|
+
setCalculated() {
|
|
6216
|
+
this._calculateState = true;
|
|
6217
|
+
}
|
|
6218
|
+
execute() {}
|
|
6219
|
+
setNotEmpty(state = true) {}
|
|
6220
|
+
async executeAsync() {
|
|
6221
|
+
return Promise.resolve(0);
|
|
6222
|
+
}
|
|
6223
|
+
serialize() {
|
|
6224
|
+
const token = this.getToken();
|
|
6225
|
+
const children = this.getChildren();
|
|
6226
|
+
const childrenSerialization = [];
|
|
6227
|
+
const childrenCount = children.length;
|
|
6228
|
+
for (let i = 0; i < childrenCount; i++) {
|
|
6229
|
+
const item = children[i];
|
|
6230
|
+
childrenSerialization.push(item.serialize());
|
|
6231
|
+
}
|
|
6232
|
+
const result = {
|
|
6233
|
+
token,
|
|
6234
|
+
nodeType: this.nodeType
|
|
6235
|
+
};
|
|
6236
|
+
if (childrenCount > 0) result.children = childrenSerialization;
|
|
6237
|
+
return result;
|
|
6238
|
+
}
|
|
6239
|
+
hasDefinedName(definedName) {
|
|
6240
|
+
var _this$_definedNames;
|
|
6241
|
+
return ((_this$_definedNames = this._definedNames) === null || _this$_definedNames === void 0 ? void 0 : _this$_definedNames.includes(definedName)) || false;
|
|
6242
|
+
}
|
|
6243
|
+
setDefinedNames(definedNames) {
|
|
6244
|
+
this._definedNames = definedNames;
|
|
6245
|
+
}
|
|
6246
|
+
getDefinedNames() {
|
|
6247
|
+
return this._definedNames;
|
|
6248
|
+
}
|
|
6249
|
+
};
|
|
6250
|
+
var ErrorNode = class ErrorNode extends BaseAstNode {
|
|
6251
|
+
constructor(errorType) {
|
|
6252
|
+
super(errorType);
|
|
6253
|
+
_defineProperty(this, "_errorValueObject", void 0);
|
|
6254
|
+
this._errorValueObject = ErrorValueObject.create(errorType);
|
|
6255
|
+
}
|
|
6256
|
+
get nodeType() {
|
|
6257
|
+
return 7;
|
|
6258
|
+
}
|
|
6259
|
+
static create(errorType) {
|
|
6260
|
+
return new ErrorNode(errorType);
|
|
6261
|
+
}
|
|
6262
|
+
getValue() {
|
|
6263
|
+
return this._errorValueObject;
|
|
6264
|
+
}
|
|
6265
|
+
};
|
|
6266
|
+
|
|
6267
|
+
//#endregion
|
|
6268
|
+
//#region src/engine/utils/generate-ast-node.ts
|
|
6269
|
+
const FORMULA_CACHE_LRU_COUNT$1 = 5e3;
|
|
6270
|
+
const FORMULA_AST_CACHE = new FormulaAstLRU(FORMULA_CACHE_LRU_COUNT$1);
|
|
6271
|
+
const DIRTY_DEFINED_NAME_SET_CACHE = /* @__PURE__ */ new WeakMap();
|
|
6272
|
+
const DIRTY_SUPER_TABLE_PATTERN_CACHE = /* @__PURE__ */ new WeakMap();
|
|
6273
|
+
function generateAstNode(unitId, formulaString, lexer, astTreeBuilder, currentConfigService, subUnitId, definedNameRefOffsetX = 0, definedNameRefOffsetY = 0) {
|
|
6274
|
+
if (subUnitId) {
|
|
6275
|
+
currentConfigService.setExecuteUnitId(unitId);
|
|
6276
|
+
currentConfigService.setExecuteSubUnitId(subUnitId);
|
|
6277
|
+
}
|
|
6278
|
+
const cacheKey = `${unitId}:${subUnitId ?? currentConfigService.getExecuteSubUnitId() ?? ""}:${definedNameRefOffsetX}:${definedNameRefOffsetY}:${formulaString}`;
|
|
6279
|
+
let astNode = FORMULA_AST_CACHE.get(cacheKey);
|
|
6280
|
+
if (!(checkIsChangedByDefinedName(unitId, formulaString, currentConfigService) || checkIsChangedBySuperTable(unitId, formulaString, currentConfigService)) && astNode && !isDirtyDefinedForNode(astNode, currentConfigService, unitId)) return astNode;
|
|
6281
|
+
const lexerNode = lexer.treeBuilder(formulaString, true, unitId, definedNameRefOffsetX, definedNameRefOffsetY);
|
|
6282
|
+
if (ERROR_TYPE_SET.has(lexerNode)) return ErrorNode.create(lexerNode);
|
|
6283
|
+
astNode = astTreeBuilder.parse(lexerNode);
|
|
6284
|
+
if (astNode == null) {
|
|
6285
|
+
console.error("generateAstNode astNode is null");
|
|
6286
|
+
return ErrorNode.create(lexerNode);
|
|
6287
|
+
}
|
|
6288
|
+
FORMULA_AST_CACHE.set(cacheKey, astNode);
|
|
6289
|
+
return astNode;
|
|
6290
|
+
}
|
|
6291
|
+
function checkIsChangedByDefinedName(unitId, formula, currentConfigService) {
|
|
6292
|
+
const unitDefinedNameMap = currentConfigService.getDirtyDefinedNameMap()[unitId];
|
|
6293
|
+
if (unitDefinedNameMap == null) return false;
|
|
6294
|
+
return getNormalizedDirtyDefinedNameSet(unitDefinedNameMap).has(normalizeFormulaText(formula));
|
|
6295
|
+
}
|
|
6296
|
+
function normalizeFormulaText(formula) {
|
|
6297
|
+
return formula.startsWith("=") ? formula.slice(1) : formula;
|
|
6298
|
+
}
|
|
6299
|
+
function checkIsChangedBySuperTable(unitId, formula, currentConfigService) {
|
|
6300
|
+
var _currentConfigService;
|
|
6301
|
+
const getDirtySuperTableMap = (_currentConfigService = currentConfigService.getDirtySuperTableMap) === null || _currentConfigService === void 0 ? void 0 : _currentConfigService.bind(currentConfigService);
|
|
6302
|
+
const changedSuperTableMap = getDirtySuperTableMap === null || getDirtySuperTableMap === void 0 ? void 0 : getDirtySuperTableMap();
|
|
6303
|
+
const unitSuperTableMap = changedSuperTableMap === null || changedSuperTableMap === void 0 ? void 0 : changedSuperTableMap[unitId];
|
|
6304
|
+
if (unitSuperTableMap == null) return false;
|
|
6305
|
+
const tableReferencePattern = getDirtySuperTableReferencePattern(unitSuperTableMap);
|
|
6306
|
+
return (tableReferencePattern === null || tableReferencePattern === void 0 ? void 0 : tableReferencePattern.test(normalizeFormulaText(formula))) ?? false;
|
|
6307
|
+
}
|
|
6308
|
+
function getNormalizedDirtyDefinedNameSet(unitDefinedNameMap) {
|
|
6309
|
+
let normalizedNameSet = DIRTY_DEFINED_NAME_SET_CACHE.get(unitDefinedNameMap);
|
|
6310
|
+
if (normalizedNameSet == null) {
|
|
6311
|
+
normalizedNameSet = new Set(Object.keys(unitDefinedNameMap).map(normalizeFormulaText));
|
|
6312
|
+
DIRTY_DEFINED_NAME_SET_CACHE.set(unitDefinedNameMap, normalizedNameSet);
|
|
6313
|
+
}
|
|
6314
|
+
return normalizedNameSet;
|
|
6315
|
+
}
|
|
6316
|
+
function getDirtySuperTableReferencePattern(unitSuperTableMap) {
|
|
6317
|
+
let tableReferencePattern = DIRTY_SUPER_TABLE_PATTERN_CACHE.get(unitSuperTableMap);
|
|
6318
|
+
if (tableReferencePattern === void 0) {
|
|
6319
|
+
const tableNames = Object.keys(unitSuperTableMap).filter((tableName) => tableName.length > 0);
|
|
6320
|
+
tableReferencePattern = tableNames.length > 0 ? regexp.createRegExpFromSafeFragment(`(^|[^A-Za-z0-9_])${regexp.or(...tableNames)}(\\s*\\[|$|[^A-Za-z0-9_])`, "i") : null;
|
|
6321
|
+
DIRTY_SUPER_TABLE_PATTERN_CACHE.set(unitSuperTableMap, tableReferencePattern);
|
|
6322
|
+
}
|
|
6323
|
+
return tableReferencePattern;
|
|
6324
|
+
}
|
|
6325
|
+
function isDirtyDefinedForNode(node, currentConfigService, unitId) {
|
|
6326
|
+
const definedNameMap = currentConfigService.getDirtyDefinedNameMap();
|
|
6327
|
+
const executeUnitId = unitId;
|
|
6328
|
+
if (executeUnitId != null && definedNameMap[executeUnitId] != null) {
|
|
6329
|
+
const names = Object.keys(definedNameMap[executeUnitId]);
|
|
6330
|
+
for (let i = 0, len = names.length; i < len; i++) {
|
|
6331
|
+
const name = names[i];
|
|
6332
|
+
if (node.hasDefinedName(name)) return true;
|
|
6333
|
+
}
|
|
6334
|
+
}
|
|
6335
|
+
return false;
|
|
6336
|
+
}
|
|
6337
|
+
function includeDefinedName(tree, node, currentConfigService) {
|
|
6338
|
+
/**
|
|
6339
|
+
* Detect whether the dirty map contains a defined name.
|
|
6340
|
+
*/
|
|
6341
|
+
if (node != null) {
|
|
6342
|
+
if (isDirtyDefinedForNode(node, currentConfigService, tree.unitId)) return true;
|
|
6343
|
+
}
|
|
6344
|
+
return false;
|
|
6345
|
+
}
|
|
6346
|
+
|
|
6347
|
+
//#endregion
|
|
6348
|
+
//#region src/services/function.service.ts
|
|
6349
|
+
const IFunctionService = createIdentifier("univer.formula-function.service");
|
|
6350
|
+
var FunctionService = class extends Disposable {
|
|
6351
|
+
constructor(..._args) {
|
|
6352
|
+
super(..._args);
|
|
6353
|
+
_defineProperty(this, "_functionExecutors", /* @__PURE__ */ new Map());
|
|
6354
|
+
_defineProperty(this, "_functionDescriptions", /* @__PURE__ */ new Map());
|
|
6355
|
+
}
|
|
6356
|
+
dispose() {
|
|
6357
|
+
super.dispose();
|
|
6358
|
+
this._functionExecutors.clear();
|
|
6359
|
+
this._functionDescriptions.clear();
|
|
6360
|
+
}
|
|
6361
|
+
registerExecutors(...functions) {
|
|
6362
|
+
for (let i = 0; i < functions.length; i++) {
|
|
6363
|
+
const func = functions[i];
|
|
6364
|
+
this._functionExecutors.set(func.name, func);
|
|
6365
|
+
}
|
|
6366
|
+
}
|
|
6367
|
+
getExecutors() {
|
|
6368
|
+
return this._functionExecutors;
|
|
6369
|
+
}
|
|
6370
|
+
getExecutor(functionToken) {
|
|
6371
|
+
return this._functionExecutors.get(functionToken);
|
|
6372
|
+
}
|
|
6373
|
+
hasExecutor(functionToken) {
|
|
6374
|
+
return this._functionExecutors.has(functionToken);
|
|
6375
|
+
}
|
|
6376
|
+
unregisterExecutors(...functionTokens) {
|
|
6377
|
+
for (let i = 0; i < functionTokens.length; i++) {
|
|
6378
|
+
const functionToken = functionTokens[i];
|
|
6379
|
+
this._functionExecutors.delete(functionToken);
|
|
6380
|
+
}
|
|
6381
|
+
}
|
|
6382
|
+
registerDescriptions(...descriptions) {
|
|
6383
|
+
for (let i = 0; i < descriptions.length; i++) {
|
|
6384
|
+
const description = descriptions[i];
|
|
6385
|
+
this._functionDescriptions.set(description.functionName, description);
|
|
6386
|
+
}
|
|
6387
|
+
return toDisposable(() => {
|
|
6388
|
+
for (let i = 0; i < descriptions.length; i++) {
|
|
6389
|
+
const description = descriptions[i];
|
|
6390
|
+
this._functionDescriptions.delete(description.functionName);
|
|
6391
|
+
}
|
|
6392
|
+
});
|
|
6393
|
+
}
|
|
6394
|
+
getDescriptions() {
|
|
6395
|
+
return this._functionDescriptions;
|
|
6396
|
+
}
|
|
6397
|
+
getDescription(functionToken) {
|
|
6398
|
+
return this._functionDescriptions.get(functionToken);
|
|
6399
|
+
}
|
|
6400
|
+
hasDescription(functionToken) {
|
|
6401
|
+
return this._functionDescriptions.has(functionToken);
|
|
6402
|
+
}
|
|
6403
|
+
unregisterDescriptions(...functionTokens) {
|
|
6404
|
+
for (let i = 0; i < functionTokens.length; i++) {
|
|
6405
|
+
const functionToken = functionTokens[i];
|
|
6406
|
+
this._functionDescriptions.delete(functionToken);
|
|
6407
|
+
}
|
|
6408
|
+
}
|
|
6409
|
+
clearDescriptions() {
|
|
6410
|
+
this._functionDescriptions.clear();
|
|
6411
|
+
}
|
|
6412
|
+
deleteFormulaAstCacheKey(...functionToken) {
|
|
6413
|
+
FORMULA_AST_CACHE.forEach((_, key) => {
|
|
6414
|
+
functionToken.forEach((token) => {
|
|
6415
|
+
if (key.includes(token)) FORMULA_AST_CACHE.delete(key);
|
|
6416
|
+
});
|
|
6417
|
+
});
|
|
6418
|
+
}
|
|
6419
|
+
};
|
|
6420
|
+
|
|
6065
6421
|
//#endregion
|
|
6066
6422
|
//#region src/engine/analysis/lexer.ts
|
|
6067
6423
|
let Lexer = class Lexer extends Disposable {
|
|
6068
|
-
constructor(_definedNamesService, _lexerTreeBuilder, _formulaCurrentConfigService) {
|
|
6424
|
+
constructor(_definedNamesService, _lexerTreeBuilder, _formulaCurrentConfigService, _functionService) {
|
|
6069
6425
|
super();
|
|
6070
6426
|
this._definedNamesService = _definedNamesService;
|
|
6071
6427
|
this._lexerTreeBuilder = _lexerTreeBuilder;
|
|
6072
6428
|
this._formulaCurrentConfigService = _formulaCurrentConfigService;
|
|
6429
|
+
this._functionService = _functionService;
|
|
6073
6430
|
}
|
|
6074
|
-
treeBuilder(formulaString, transformSuffix = true, unitId) {
|
|
6431
|
+
treeBuilder(formulaString, transformSuffix = true, unitId, refOffsetX = 0, refOffsetY = 0) {
|
|
6075
6432
|
if (this._definedNamesService.getAllDefinedNamesIsEmpty()) return this._lexerTreeBuilder.treeBuilder(formulaString, transformSuffix);
|
|
6076
6433
|
return this._lexerTreeBuilder.treeBuilder(formulaString, transformSuffix, {
|
|
6077
|
-
unitId: unitId
|
|
6434
|
+
unitId: unitId ?? this._formulaCurrentConfigService.getExecuteUnitId(),
|
|
6078
6435
|
sheetId: this._formulaCurrentConfigService.getExecuteSubUnitId(),
|
|
6436
|
+
refOffsetX,
|
|
6437
|
+
refOffsetY,
|
|
6438
|
+
hasFunction: this._functionService.hasExecutor.bind(this._functionService),
|
|
6079
6439
|
getValueByName: this._definedNamesService.getValueByName.bind(this._definedNamesService),
|
|
6080
6440
|
getDirtyDefinedNameMap: this._formulaCurrentConfigService.getDirtyDefinedNameMap.bind(this._formulaCurrentConfigService),
|
|
6081
6441
|
getSheetName: this._formulaCurrentConfigService.getSheetName.bind(this._formulaCurrentConfigService)
|
|
@@ -6085,13 +6445,13 @@ let Lexer = class Lexer extends Disposable {
|
|
|
6085
6445
|
Lexer = __decorate([
|
|
6086
6446
|
__decorateParam(0, IDefinedNamesService),
|
|
6087
6447
|
__decorateParam(1, Inject(LexerTreeBuilder)),
|
|
6088
|
-
__decorateParam(2, IFormulaCurrentConfigService)
|
|
6448
|
+
__decorateParam(2, IFormulaCurrentConfigService),
|
|
6449
|
+
__decorateParam(3, IFunctionService)
|
|
6089
6450
|
], Lexer);
|
|
6090
6451
|
|
|
6091
6452
|
//#endregion
|
|
6092
6453
|
//#region src/engine/utils/cell.ts
|
|
6093
6454
|
function getCellValue(cell) {
|
|
6094
|
-
var _cell$v;
|
|
6095
6455
|
if (cell === null) return 0;
|
|
6096
6456
|
if (cell === null || cell === void 0 ? void 0 : cell.p) {
|
|
6097
6457
|
const body = cell === null || cell === void 0 ? void 0 : cell.p.body;
|
|
@@ -6099,7 +6459,7 @@ function getCellValue(cell) {
|
|
|
6099
6459
|
const data = body.dataStream;
|
|
6100
6460
|
return normalizeRichTextFormulaValue(BuildTextUtils.transform.getPlainText(data));
|
|
6101
6461
|
}
|
|
6102
|
-
return (
|
|
6462
|
+
return (cell === null || cell === void 0 ? void 0 : cell.v) ?? 0;
|
|
6103
6463
|
}
|
|
6104
6464
|
function normalizeRichTextFormulaValue(value) {
|
|
6105
6465
|
return value.replace(/\r\n|\r|\n/g, "\r\n");
|
|
@@ -7265,9 +7625,8 @@ var StringValueObject = class StringValueObject extends BaseValueObject {
|
|
|
7265
7625
|
if (cached && options && this.checkCacheByOptions(cached, options)) return cached;
|
|
7266
7626
|
const instance = new StringValueObject(value);
|
|
7267
7627
|
if (options === null || options === void 0 ? void 0 : options.isHyperlink) {
|
|
7268
|
-
var _options$hyperlinkUrl;
|
|
7269
7628
|
instance._isHyperlink = options.isHyperlink;
|
|
7270
|
-
instance._hyperlinkUrl =
|
|
7629
|
+
instance._hyperlinkUrl = options.hyperlinkUrl ?? "";
|
|
7271
7630
|
}
|
|
7272
7631
|
if (options === null || options === void 0 ? void 0 : options.isImage) {
|
|
7273
7632
|
instance._isImage = options.isImage;
|
|
@@ -7808,11 +8167,16 @@ var ArrayValueObject = class ArrayValueObject extends BaseValueObject {
|
|
|
7808
8167
|
* the sequential matching approach is only used for special matches in XLOOKUP and XMATCH.
|
|
7809
8168
|
* For example, when match_mode is set to 1 and -1 for an exact match. If not found, it returns the next smaller item.
|
|
7810
8169
|
*/
|
|
7811
|
-
orderSearch(valueObject, searchType = 1, isDesc = false, isFuzzyMatching = false) {
|
|
8170
|
+
orderSearch(valueObject, searchType = 1, isDesc = false, isFuzzyMatching = false, keepFirstNearest = false) {
|
|
7812
8171
|
let result;
|
|
7813
8172
|
let maxOrMin;
|
|
7814
8173
|
let resultPosition;
|
|
7815
8174
|
let maxOrMinPosition;
|
|
8175
|
+
const _isNearer = (itemValue, currentValue) => {
|
|
8176
|
+
const distance = itemValue.minus(valueObject).abs();
|
|
8177
|
+
const currentDistance = currentValue.minus(valueObject).abs();
|
|
8178
|
+
return keepFirstNearest ? distance.isLessThan(currentDistance).getValue() === true : distance.isLessThanOrEqual(currentDistance).getValue() === true;
|
|
8179
|
+
};
|
|
7816
8180
|
const _handleMatch = (itemValue, row, column) => {
|
|
7817
8181
|
if (itemValue == null || itemValue.isNull()) return true;
|
|
7818
8182
|
let matchObject;
|
|
@@ -7829,7 +8193,7 @@ var ArrayValueObject = class ArrayValueObject extends BaseValueObject {
|
|
|
7829
8193
|
}
|
|
7830
8194
|
if (searchType === 2) {
|
|
7831
8195
|
if (itemValue.isGreaterThan(valueObject).getValue() === true) {
|
|
7832
|
-
if (maxOrMin == null || itemValue
|
|
8196
|
+
if (maxOrMin == null || _isNearer(itemValue, maxOrMin)) {
|
|
7833
8197
|
maxOrMin = itemValue;
|
|
7834
8198
|
maxOrMinPosition = {
|
|
7835
8199
|
row,
|
|
@@ -7839,7 +8203,7 @@ var ArrayValueObject = class ArrayValueObject extends BaseValueObject {
|
|
|
7839
8203
|
}
|
|
7840
8204
|
} else if (searchType === 1) {
|
|
7841
8205
|
if (itemValue.isLessThan(valueObject).getValue() === true) {
|
|
7842
|
-
if (maxOrMin == null || itemValue
|
|
8206
|
+
if (maxOrMin == null || _isNearer(itemValue, maxOrMin)) {
|
|
7843
8207
|
maxOrMin = itemValue;
|
|
7844
8208
|
maxOrMinPosition = {
|
|
7845
8209
|
row,
|
|
@@ -8342,11 +8706,12 @@ var ArrayValueObject = class ArrayValueObject extends BaseValueObject {
|
|
|
8342
8706
|
const sheetId = this.getSheetId();
|
|
8343
8707
|
const startRow = this.getCurrentRow();
|
|
8344
8708
|
const startColumn = this.getCurrentColumn();
|
|
8709
|
+
const isWildcardComparison = batchOperatorType === 5 && valueObject.isString() && isWildcard(String(valueObject.getValue()));
|
|
8345
8710
|
/**
|
|
8346
8711
|
* If comparison operations are conducted for a single numerical value,
|
|
8347
8712
|
* then retrieve the judgment from the inverted index. This enhances performance.
|
|
8348
8713
|
*/
|
|
8349
|
-
if (batchOperatorType === 5 && this._useInvertedIndexCache) {
|
|
8714
|
+
if (batchOperatorType === 5 && this._useInvertedIndexCache && !isWildcardComparison) {
|
|
8350
8715
|
const { rowsInCache, rowsNotInCache } = CELL_INVERTED_INDEX_CACHE.canUseCache(unitId, sheetId, column + startColumn, startRow, startRow + rowCount - 1);
|
|
8351
8716
|
if (rowsInCache.length > 0) {
|
|
8352
8717
|
if (operator === "=" && !(valueObject.isString() && isWildcard(valueObject.getValue()))) {
|
|
@@ -8575,6 +8940,7 @@ var ValueObjectFactory = class {
|
|
|
8575
8940
|
const rawValueUpper = rawValue.toLocaleUpperCase().trim();
|
|
8576
8941
|
if (ERROR_TYPE_SET.has(rawValueUpper)) return ErrorValueObject.create(rawValueUpper);
|
|
8577
8942
|
if (rawValueUpper === "TRUE" || rawValueUpper === "FALSE") return createBooleanValueObjectByRawValue(rawValue);
|
|
8943
|
+
if (isStringWrappedByDoubleQuotes(rawValue)) return createStringValueObjectByRawValue(rawValue);
|
|
8578
8944
|
if (isRealNum(rawValue) && Number(rawValue).toString() === rawValue.trim()) return NumberValueObject.create(Number(rawValue));
|
|
8579
8945
|
if (!isIgnoreNumberPattern) {
|
|
8580
8946
|
const { isNumberPattern, value, pattern } = stringIsNumberPattern(rawValue);
|
|
@@ -8595,8 +8961,8 @@ function isStringWrappedByDoubleQuotes(input) {
|
|
|
8595
8961
|
|
|
8596
8962
|
//#endregion
|
|
8597
8963
|
//#region src/engine/reference-object/base-reference-object.ts
|
|
8598
|
-
const FORMULA_CACHE_LRU_COUNT
|
|
8599
|
-
const FORMULA_REF_TO_ARRAY_CACHE = new FormulaAstLRU(FORMULA_CACHE_LRU_COUNT
|
|
8964
|
+
const FORMULA_CACHE_LRU_COUNT = 1e4;
|
|
8965
|
+
const FORMULA_REF_TO_ARRAY_CACHE = new FormulaAstLRU(FORMULA_CACHE_LRU_COUNT);
|
|
8600
8966
|
var BaseReferenceObject = class extends ObjectClassType {
|
|
8601
8967
|
constructor(_token) {
|
|
8602
8968
|
super();
|
|
@@ -8733,6 +9099,7 @@ var BaseReferenceObject = class extends ObjectClassType {
|
|
|
8733
9099
|
}
|
|
8734
9100
|
setForcedSheetId(sheetNameMap) {
|
|
8735
9101
|
var _sheetNameMap$this$ge;
|
|
9102
|
+
if (!this._forcedSheetName) return;
|
|
8736
9103
|
this._forcedSheetId = (_sheetNameMap$this$ge = sheetNameMap[this.getUnitId()]) === null || _sheetNameMap$this$ge === void 0 ? void 0 : _sheetNameMap$this$ge[this._forcedSheetName];
|
|
8737
9104
|
}
|
|
8738
9105
|
setForcedSheetIdDirect(sheetId) {
|
|
@@ -8954,11 +9321,9 @@ var BaseReferenceObject = class extends ObjectClassType {
|
|
|
8954
9321
|
return getRuntimeFeatureCell(row, column, this.getSheetId(), this.getUnitId(), this._runtimeFeatureCellData);
|
|
8955
9322
|
}
|
|
8956
9323
|
getCellByPosition(rowRaw, columnRaw) {
|
|
8957
|
-
|
|
8958
|
-
|
|
8959
|
-
const
|
|
8960
|
-
if (!row) row = rangeData.startRow;
|
|
8961
|
-
if (!column) column = rangeData.startColumn;
|
|
9324
|
+
const range = this.getRangePosition();
|
|
9325
|
+
const row = rowRaw ?? range.startRow;
|
|
9326
|
+
const column = columnRaw ?? range.startColumn;
|
|
8962
9327
|
const cell = this.getCellData(row, column);
|
|
8963
9328
|
if (!cell) return NullValueObject.create();
|
|
8964
9329
|
return this.getCellValueObject(cell);
|
|
@@ -9028,6 +9393,9 @@ var BaseReferenceObject = class extends ObjectClassType {
|
|
|
9028
9393
|
unitId: this.getUnitId()
|
|
9029
9394
|
};
|
|
9030
9395
|
}
|
|
9396
|
+
toUnitRanges() {
|
|
9397
|
+
return [this.toUnitRange()];
|
|
9398
|
+
}
|
|
9031
9399
|
_checkIfWorksheetMiss() {
|
|
9032
9400
|
if ((this._forcedSheetId == null || this._forcedSheetId.length === 0) && this._forcedSheetName.length > 0) return true;
|
|
9033
9401
|
return false;
|
|
@@ -9132,7 +9500,7 @@ var CellReferenceObject = class extends BaseReferenceObject {
|
|
|
9132
9500
|
unionBy(referenceObject) {
|
|
9133
9501
|
if (!referenceObject.isCell()) return ErrorValueObject.create("#REF!");
|
|
9134
9502
|
const cellReferenceObject = referenceObject;
|
|
9135
|
-
const newRangeData = this.unionRange(this.
|
|
9503
|
+
const newRangeData = this.unionRange(this.getRangePosition(), cellReferenceObject.getRangePosition());
|
|
9136
9504
|
return this._createRange(newRangeData);
|
|
9137
9505
|
}
|
|
9138
9506
|
unionRange(rangeData1, rangeData2) {
|
|
@@ -9174,8 +9542,6 @@ var CellReferenceObject = class extends BaseReferenceObject {
|
|
|
9174
9542
|
rangeReferenceObject.setArrayFormulaCellData(this.getArrayFormulaCellData());
|
|
9175
9543
|
rangeReferenceObject.setRuntimeArrayFormulaCellData(this.getRuntimeArrayFormulaCellData());
|
|
9176
9544
|
rangeReferenceObject.setRuntimeFeatureCellData(this.getRuntimeFeatureCellData());
|
|
9177
|
-
const { x, y } = this.getRefOffset();
|
|
9178
|
-
rangeReferenceObject.setRefOffset(x, y);
|
|
9179
9545
|
const forceSheetId = this.getForcedSheetId();
|
|
9180
9546
|
rangeReferenceObject.setForcedSheetName(this.getForcedSheetName());
|
|
9181
9547
|
if (forceSheetId != null) rangeReferenceObject.setForcedSheetIdDirect(forceSheetId);
|
|
@@ -9296,7 +9662,7 @@ function expandArrayValueObject(rowCount, columnCount, valueObject, defaultValue
|
|
|
9296
9662
|
continue;
|
|
9297
9663
|
}
|
|
9298
9664
|
if (r >= valueRowCount || c >= valueColumnCount) {
|
|
9299
|
-
row.push(defaultValue
|
|
9665
|
+
row.push(defaultValue ?? NullValueObject.create());
|
|
9300
9666
|
continue;
|
|
9301
9667
|
}
|
|
9302
9668
|
const value = valueObject.get(r, c);
|
|
@@ -9634,8 +10000,11 @@ function filterSameValueObjectResult(array, range, criteria) {
|
|
|
9634
10000
|
return array.mapValue((valueObject, r, c) => {
|
|
9635
10001
|
const rangeValueObject = range.get(r, c);
|
|
9636
10002
|
const isBlankStringCriteria = criteriaObject.isString() && criteriaObject.getValue() === "";
|
|
10003
|
+
if (isBlankStringCriteria && (operator === ">" || operator === ">=" || operator === "<" || operator === "<=")) return BooleanValueObject.create(false);
|
|
9637
10004
|
if (operator === "<>" && isBlankStringCriteria && (rangeValueObject === null || rangeValueObject === void 0 ? void 0 : rangeValueObject.isString()) && rangeValueObject.getValue() === "") return BooleanValueObject.create(true);
|
|
9638
|
-
if (criteriaObject.isString() && criteriaObject.getValue()
|
|
10005
|
+
if (criteriaObject.isString() && isWildcard(`${criteriaObject.getValue()}`) && (rangeValueObject === null || rangeValueObject === void 0 ? void 0 : rangeValueObject.isString()) && rangeValueObject.getValue() === "") return valueObject;
|
|
10006
|
+
if (criteriaObject.isString() && criteriaObject.getValue() !== "" && (operator === "<" || operator === "<=") && (rangeValueObject === null || rangeValueObject === void 0 ? void 0 : rangeValueObject.isString()) && rangeValueObject.getValue() === "") return BooleanValueObject.create(true);
|
|
10007
|
+
if (criteriaObject.isString() && criteriaObject.getValue() !== "" && (operator === "<" || operator === "<=") && (rangeValueObject == null || rangeValueObject.isNull())) return BooleanValueObject.create(false);
|
|
9639
10008
|
if (criteriaObject.isString() && (rangeValueObject === null || rangeValueObject === void 0 ? void 0 : rangeValueObject.isString()) && (operator === "<" || operator === "<=") && isSameLowerBoundBucket(rangeValueObject.getValue(), criteriaObject.getValue())) return BooleanValueObject.create(false);
|
|
9640
10009
|
if ((rangeValueObject === null || rangeValueObject === void 0 ? void 0 : rangeValueObject.isNumber()) && criteriaObject.isString()) {
|
|
9641
10010
|
const criteriaNumber = criteriaObject.convertToNumberObjectValue();
|
|
@@ -9804,12 +10173,12 @@ let FormulaRuntimeService = class FormulaRuntimeService extends Disposable {
|
|
|
9804
10173
|
return this._currentColumn;
|
|
9805
10174
|
}
|
|
9806
10175
|
get currentRowCount() {
|
|
9807
|
-
var _this$_functionRefInf
|
|
9808
|
-
return (_this$_functionRefInf =
|
|
10176
|
+
var _this$_functionRefInf;
|
|
10177
|
+
return ((_this$_functionRefInf = this._functionRefInfoOverrideStack[this._functionRefInfoOverrideStack.length - 1]) === null || _this$_functionRefInf === void 0 ? void 0 : _this$_functionRefInf.rowCount) ?? this._currentRowCount;
|
|
9809
10178
|
}
|
|
9810
10179
|
get currentColumnCount() {
|
|
9811
|
-
var _this$
|
|
9812
|
-
return (
|
|
10180
|
+
var _this$_functionRefInf2;
|
|
10181
|
+
return ((_this$_functionRefInf2 = this._functionRefInfoOverrideStack[this._functionRefInfoOverrideStack.length - 1]) === null || _this$_functionRefInf2 === void 0 ? void 0 : _this$_functionRefInf2.columnCount) ?? this._currentColumnCount;
|
|
9813
10182
|
}
|
|
9814
10183
|
get currentSubUnitId() {
|
|
9815
10184
|
return this._currentSubUnitId;
|
|
@@ -9928,6 +10297,9 @@ let FormulaRuntimeService = class FormulaRuntimeService extends Disposable {
|
|
|
9928
10297
|
this._functionRefInfoOverrideStack.pop();
|
|
9929
10298
|
};
|
|
9930
10299
|
}
|
|
10300
|
+
hasFunctionRefInfoOverride() {
|
|
10301
|
+
return this._functionRefInfoOverrideStack.length > 0;
|
|
10302
|
+
}
|
|
9931
10303
|
clearFunctionDefinitionPrivacyVar() {
|
|
9932
10304
|
this._functionDefinitionPrivacyVar.clear();
|
|
9933
10305
|
}
|
|
@@ -10245,151 +10617,6 @@ let FormulaRuntimeService = class FormulaRuntimeService extends Disposable {
|
|
|
10245
10617
|
FormulaRuntimeService = __decorate([__decorateParam(0, IFormulaCurrentConfigService), __decorateParam(1, IHyperlinkEngineFormulaService)], FormulaRuntimeService);
|
|
10246
10618
|
const IFormulaRuntimeService = createIdentifier("univer.formula.runtime.service");
|
|
10247
10619
|
|
|
10248
|
-
//#endregion
|
|
10249
|
-
//#region src/engine/ast-node/node-type.ts
|
|
10250
|
-
const NODE_ORDER_MAP = /* @__PURE__ */ new Map([
|
|
10251
|
-
[1, 7],
|
|
10252
|
-
[2, 9],
|
|
10253
|
-
[3, 8],
|
|
10254
|
-
[4, 6],
|
|
10255
|
-
[5, 1],
|
|
10256
|
-
[6, 2],
|
|
10257
|
-
[9, 10],
|
|
10258
|
-
[10, 3],
|
|
10259
|
-
[11, 4],
|
|
10260
|
-
[12, 5]
|
|
10261
|
-
]);
|
|
10262
|
-
|
|
10263
|
-
//#endregion
|
|
10264
|
-
//#region src/engine/ast-node/base-ast-node.ts
|
|
10265
|
-
var BaseAstNode = class {
|
|
10266
|
-
constructor(_token) {
|
|
10267
|
-
this._token = _token;
|
|
10268
|
-
_defineProperty(this, "_children", []);
|
|
10269
|
-
_defineProperty(this, "_definedNames", void 0);
|
|
10270
|
-
_defineProperty(this, "_parent", void 0);
|
|
10271
|
-
_defineProperty(this, "_valueObject", void 0);
|
|
10272
|
-
_defineProperty(this, "_calculateState", false);
|
|
10273
|
-
_defineProperty(this, "_async", false);
|
|
10274
|
-
_defineProperty(this, "_address", false);
|
|
10275
|
-
_defineProperty(this, "_isForcedCalculateFunction", false);
|
|
10276
|
-
}
|
|
10277
|
-
dispose() {
|
|
10278
|
-
var _this$_valueObject;
|
|
10279
|
-
this._children.forEach((node) => {
|
|
10280
|
-
node.dispose();
|
|
10281
|
-
});
|
|
10282
|
-
(_this$_valueObject = this._valueObject) === null || _this$_valueObject === void 0 || _this$_valueObject.dispose();
|
|
10283
|
-
this._valueObject = null;
|
|
10284
|
-
this._children = [];
|
|
10285
|
-
this._definedNames = null;
|
|
10286
|
-
this._parent = null;
|
|
10287
|
-
}
|
|
10288
|
-
get nodeType() {
|
|
10289
|
-
return 8;
|
|
10290
|
-
}
|
|
10291
|
-
resetCalculationState() {
|
|
10292
|
-
this._children.forEach((node) => {
|
|
10293
|
-
node.resetCalculationState();
|
|
10294
|
-
});
|
|
10295
|
-
this._valueObject = null;
|
|
10296
|
-
this._calculateState = false;
|
|
10297
|
-
}
|
|
10298
|
-
isAsync() {
|
|
10299
|
-
return this._async;
|
|
10300
|
-
}
|
|
10301
|
-
isAddress() {
|
|
10302
|
-
return this._address;
|
|
10303
|
-
}
|
|
10304
|
-
isForcedCalculateFunction() {
|
|
10305
|
-
return this._isForcedCalculateFunction;
|
|
10306
|
-
}
|
|
10307
|
-
setAsync() {
|
|
10308
|
-
this._async = true;
|
|
10309
|
-
}
|
|
10310
|
-
setAddress() {
|
|
10311
|
-
this._address = true;
|
|
10312
|
-
}
|
|
10313
|
-
getParent() {
|
|
10314
|
-
return this._parent;
|
|
10315
|
-
}
|
|
10316
|
-
setParent(node) {
|
|
10317
|
-
this._parent = node;
|
|
10318
|
-
node.addChildren(this);
|
|
10319
|
-
}
|
|
10320
|
-
setForcedCalculateFunction() {
|
|
10321
|
-
this._isForcedCalculateFunction = true;
|
|
10322
|
-
}
|
|
10323
|
-
getChildren() {
|
|
10324
|
-
return this._children;
|
|
10325
|
-
}
|
|
10326
|
-
addChildren(...astNode) {
|
|
10327
|
-
this._children.push(...astNode);
|
|
10328
|
-
}
|
|
10329
|
-
getToken() {
|
|
10330
|
-
return this._token;
|
|
10331
|
-
}
|
|
10332
|
-
setValue(value) {
|
|
10333
|
-
this._valueObject = value;
|
|
10334
|
-
}
|
|
10335
|
-
getValue() {
|
|
10336
|
-
return this._valueObject;
|
|
10337
|
-
}
|
|
10338
|
-
isCalculated() {
|
|
10339
|
-
return this._calculateState;
|
|
10340
|
-
}
|
|
10341
|
-
setCalculated() {
|
|
10342
|
-
this._calculateState = true;
|
|
10343
|
-
}
|
|
10344
|
-
execute() {}
|
|
10345
|
-
setNotEmpty(state = true) {}
|
|
10346
|
-
async executeAsync() {
|
|
10347
|
-
return Promise.resolve(0);
|
|
10348
|
-
}
|
|
10349
|
-
serialize() {
|
|
10350
|
-
const token = this.getToken();
|
|
10351
|
-
const children = this.getChildren();
|
|
10352
|
-
const childrenSerialization = [];
|
|
10353
|
-
const childrenCount = children.length;
|
|
10354
|
-
for (let i = 0; i < childrenCount; i++) {
|
|
10355
|
-
const item = children[i];
|
|
10356
|
-
childrenSerialization.push(item.serialize());
|
|
10357
|
-
}
|
|
10358
|
-
const result = {
|
|
10359
|
-
token,
|
|
10360
|
-
nodeType: this.nodeType
|
|
10361
|
-
};
|
|
10362
|
-
if (childrenCount > 0) result.children = childrenSerialization;
|
|
10363
|
-
return result;
|
|
10364
|
-
}
|
|
10365
|
-
hasDefinedName(definedName) {
|
|
10366
|
-
var _this$_definedNames;
|
|
10367
|
-
return ((_this$_definedNames = this._definedNames) === null || _this$_definedNames === void 0 ? void 0 : _this$_definedNames.includes(definedName)) || false;
|
|
10368
|
-
}
|
|
10369
|
-
setDefinedNames(definedNames) {
|
|
10370
|
-
this._definedNames = definedNames;
|
|
10371
|
-
}
|
|
10372
|
-
getDefinedNames() {
|
|
10373
|
-
return this._definedNames;
|
|
10374
|
-
}
|
|
10375
|
-
};
|
|
10376
|
-
var ErrorNode = class ErrorNode extends BaseAstNode {
|
|
10377
|
-
constructor(errorType) {
|
|
10378
|
-
super(errorType);
|
|
10379
|
-
_defineProperty(this, "_errorValueObject", void 0);
|
|
10380
|
-
this._errorValueObject = ErrorValueObject.create(errorType);
|
|
10381
|
-
}
|
|
10382
|
-
get nodeType() {
|
|
10383
|
-
return 7;
|
|
10384
|
-
}
|
|
10385
|
-
static create(errorType) {
|
|
10386
|
-
return new ErrorNode(errorType);
|
|
10387
|
-
}
|
|
10388
|
-
getValue() {
|
|
10389
|
-
return this._errorValueObject;
|
|
10390
|
-
}
|
|
10391
|
-
};
|
|
10392
|
-
|
|
10393
10620
|
//#endregion
|
|
10394
10621
|
//#region src/engine/ast-node/base-ast-node-factory.ts
|
|
10395
10622
|
var BaseAstNodeFactory = class {
|
|
@@ -10455,161 +10682,6 @@ const COLUMN_LIKE_FUNCTION_NAMES = new Set(ALL_GROUPS.flatMap((g) => Object.valu
|
|
|
10455
10682
|
return idx > 0 && idx <= MAX_COLUMN_COUNT;
|
|
10456
10683
|
}));
|
|
10457
10684
|
|
|
10458
|
-
//#endregion
|
|
10459
|
-
//#region src/engine/utils/generate-ast-node.ts
|
|
10460
|
-
const FORMULA_CACHE_LRU_COUNT = 5e3;
|
|
10461
|
-
const FORMULA_AST_CACHE = new FormulaAstLRU(FORMULA_CACHE_LRU_COUNT);
|
|
10462
|
-
const DIRTY_DEFINED_NAME_SET_CACHE = /* @__PURE__ */ new WeakMap();
|
|
10463
|
-
const DIRTY_SUPER_TABLE_PATTERN_CACHE = /* @__PURE__ */ new WeakMap();
|
|
10464
|
-
function generateAstNode(unitId, formulaString, lexer, astTreeBuilder, currentConfigService, subUnitId) {
|
|
10465
|
-
var _ref;
|
|
10466
|
-
if (subUnitId) {
|
|
10467
|
-
currentConfigService.setExecuteUnitId(unitId);
|
|
10468
|
-
currentConfigService.setExecuteSubUnitId(subUnitId);
|
|
10469
|
-
}
|
|
10470
|
-
const cacheKey = `${unitId}:${(_ref = subUnitId !== null && subUnitId !== void 0 ? subUnitId : currentConfigService.getExecuteSubUnitId()) !== null && _ref !== void 0 ? _ref : ""}:${formulaString}`;
|
|
10471
|
-
let astNode = FORMULA_AST_CACHE.get(cacheKey);
|
|
10472
|
-
if (!(checkIsChangedByDefinedName(unitId, formulaString, currentConfigService) || checkIsChangedBySuperTable(unitId, formulaString, currentConfigService)) && astNode && !isDirtyDefinedForNode(astNode, currentConfigService, unitId)) return astNode;
|
|
10473
|
-
const lexerNode = lexer.treeBuilder(formulaString, true, unitId);
|
|
10474
|
-
if (ERROR_TYPE_SET.has(lexerNode)) return ErrorNode.create(lexerNode);
|
|
10475
|
-
astNode = astTreeBuilder.parse(lexerNode);
|
|
10476
|
-
if (astNode == null) {
|
|
10477
|
-
console.error("generateAstNode astNode is null");
|
|
10478
|
-
return ErrorNode.create(lexerNode);
|
|
10479
|
-
}
|
|
10480
|
-
FORMULA_AST_CACHE.set(cacheKey, astNode);
|
|
10481
|
-
return astNode;
|
|
10482
|
-
}
|
|
10483
|
-
function checkIsChangedByDefinedName(unitId, formula, currentConfigService) {
|
|
10484
|
-
const unitDefinedNameMap = currentConfigService.getDirtyDefinedNameMap()[unitId];
|
|
10485
|
-
if (unitDefinedNameMap == null) return false;
|
|
10486
|
-
return getNormalizedDirtyDefinedNameSet(unitDefinedNameMap).has(normalizeFormulaText(formula));
|
|
10487
|
-
}
|
|
10488
|
-
function normalizeFormulaText(formula) {
|
|
10489
|
-
return formula.startsWith("=") ? formula.slice(1) : formula;
|
|
10490
|
-
}
|
|
10491
|
-
function checkIsChangedBySuperTable(unitId, formula, currentConfigService) {
|
|
10492
|
-
var _currentConfigService, _tableReferencePatter;
|
|
10493
|
-
const getDirtySuperTableMap = (_currentConfigService = currentConfigService.getDirtySuperTableMap) === null || _currentConfigService === void 0 ? void 0 : _currentConfigService.bind(currentConfigService);
|
|
10494
|
-
const changedSuperTableMap = getDirtySuperTableMap === null || getDirtySuperTableMap === void 0 ? void 0 : getDirtySuperTableMap();
|
|
10495
|
-
const unitSuperTableMap = changedSuperTableMap === null || changedSuperTableMap === void 0 ? void 0 : changedSuperTableMap[unitId];
|
|
10496
|
-
if (unitSuperTableMap == null) return false;
|
|
10497
|
-
const tableReferencePattern = getDirtySuperTableReferencePattern(unitSuperTableMap);
|
|
10498
|
-
return (_tableReferencePatter = tableReferencePattern === null || tableReferencePattern === void 0 ? void 0 : tableReferencePattern.test(normalizeFormulaText(formula))) !== null && _tableReferencePatter !== void 0 ? _tableReferencePatter : false;
|
|
10499
|
-
}
|
|
10500
|
-
function getNormalizedDirtyDefinedNameSet(unitDefinedNameMap) {
|
|
10501
|
-
let normalizedNameSet = DIRTY_DEFINED_NAME_SET_CACHE.get(unitDefinedNameMap);
|
|
10502
|
-
if (normalizedNameSet == null) {
|
|
10503
|
-
normalizedNameSet = new Set(Object.keys(unitDefinedNameMap).map(normalizeFormulaText));
|
|
10504
|
-
DIRTY_DEFINED_NAME_SET_CACHE.set(unitDefinedNameMap, normalizedNameSet);
|
|
10505
|
-
}
|
|
10506
|
-
return normalizedNameSet;
|
|
10507
|
-
}
|
|
10508
|
-
function getDirtySuperTableReferencePattern(unitSuperTableMap) {
|
|
10509
|
-
let tableReferencePattern = DIRTY_SUPER_TABLE_PATTERN_CACHE.get(unitSuperTableMap);
|
|
10510
|
-
if (tableReferencePattern === void 0) {
|
|
10511
|
-
const tableNames = Object.keys(unitSuperTableMap).filter((tableName) => tableName.length > 0);
|
|
10512
|
-
tableReferencePattern = tableNames.length > 0 ? regexp.createRegExpFromSafeFragment(`(^|[^A-Za-z0-9_])${regexp.or(...tableNames)}(\\s*\\[|$|[^A-Za-z0-9_])`, "i") : null;
|
|
10513
|
-
DIRTY_SUPER_TABLE_PATTERN_CACHE.set(unitSuperTableMap, tableReferencePattern);
|
|
10514
|
-
}
|
|
10515
|
-
return tableReferencePattern;
|
|
10516
|
-
}
|
|
10517
|
-
function isDirtyDefinedForNode(node, currentConfigService, unitId) {
|
|
10518
|
-
const definedNameMap = currentConfigService.getDirtyDefinedNameMap();
|
|
10519
|
-
const executeUnitId = unitId;
|
|
10520
|
-
if (executeUnitId != null && definedNameMap[executeUnitId] != null) {
|
|
10521
|
-
const names = Object.keys(definedNameMap[executeUnitId]);
|
|
10522
|
-
for (let i = 0, len = names.length; i < len; i++) {
|
|
10523
|
-
const name = names[i];
|
|
10524
|
-
if (node.hasDefinedName(name)) return true;
|
|
10525
|
-
}
|
|
10526
|
-
}
|
|
10527
|
-
return false;
|
|
10528
|
-
}
|
|
10529
|
-
function includeDefinedName(tree, node, currentConfigService) {
|
|
10530
|
-
/**
|
|
10531
|
-
* Detect whether the dirty map contains a defined name.
|
|
10532
|
-
*/
|
|
10533
|
-
if (node != null) {
|
|
10534
|
-
if (isDirtyDefinedForNode(node, currentConfigService, tree.unitId)) return true;
|
|
10535
|
-
}
|
|
10536
|
-
return false;
|
|
10537
|
-
}
|
|
10538
|
-
|
|
10539
|
-
//#endregion
|
|
10540
|
-
//#region src/services/function.service.ts
|
|
10541
|
-
const IFunctionService = createIdentifier("univer.formula-function.service");
|
|
10542
|
-
var FunctionService = class extends Disposable {
|
|
10543
|
-
constructor(..._args) {
|
|
10544
|
-
super(..._args);
|
|
10545
|
-
_defineProperty(this, "_functionExecutors", /* @__PURE__ */ new Map());
|
|
10546
|
-
_defineProperty(this, "_functionDescriptions", /* @__PURE__ */ new Map());
|
|
10547
|
-
}
|
|
10548
|
-
dispose() {
|
|
10549
|
-
super.dispose();
|
|
10550
|
-
this._functionExecutors.clear();
|
|
10551
|
-
this._functionDescriptions.clear();
|
|
10552
|
-
}
|
|
10553
|
-
registerExecutors(...functions) {
|
|
10554
|
-
for (let i = 0; i < functions.length; i++) {
|
|
10555
|
-
const func = functions[i];
|
|
10556
|
-
this._functionExecutors.set(func.name, func);
|
|
10557
|
-
}
|
|
10558
|
-
}
|
|
10559
|
-
getExecutors() {
|
|
10560
|
-
return this._functionExecutors;
|
|
10561
|
-
}
|
|
10562
|
-
getExecutor(functionToken) {
|
|
10563
|
-
return this._functionExecutors.get(functionToken);
|
|
10564
|
-
}
|
|
10565
|
-
hasExecutor(functionToken) {
|
|
10566
|
-
return this._functionExecutors.has(functionToken);
|
|
10567
|
-
}
|
|
10568
|
-
unregisterExecutors(...functionTokens) {
|
|
10569
|
-
for (let i = 0; i < functionTokens.length; i++) {
|
|
10570
|
-
const functionToken = functionTokens[i];
|
|
10571
|
-
this._functionExecutors.delete(functionToken);
|
|
10572
|
-
}
|
|
10573
|
-
}
|
|
10574
|
-
registerDescriptions(...descriptions) {
|
|
10575
|
-
for (let i = 0; i < descriptions.length; i++) {
|
|
10576
|
-
const description = descriptions[i];
|
|
10577
|
-
this._functionDescriptions.set(description.functionName, description);
|
|
10578
|
-
}
|
|
10579
|
-
return toDisposable(() => {
|
|
10580
|
-
for (let i = 0; i < descriptions.length; i++) {
|
|
10581
|
-
const description = descriptions[i];
|
|
10582
|
-
this._functionDescriptions.delete(description.functionName);
|
|
10583
|
-
}
|
|
10584
|
-
});
|
|
10585
|
-
}
|
|
10586
|
-
getDescriptions() {
|
|
10587
|
-
return this._functionDescriptions;
|
|
10588
|
-
}
|
|
10589
|
-
getDescription(functionToken) {
|
|
10590
|
-
return this._functionDescriptions.get(functionToken);
|
|
10591
|
-
}
|
|
10592
|
-
hasDescription(functionToken) {
|
|
10593
|
-
return this._functionDescriptions.has(functionToken);
|
|
10594
|
-
}
|
|
10595
|
-
unregisterDescriptions(...functionTokens) {
|
|
10596
|
-
for (let i = 0; i < functionTokens.length; i++) {
|
|
10597
|
-
const functionToken = functionTokens[i];
|
|
10598
|
-
this._functionDescriptions.delete(functionToken);
|
|
10599
|
-
}
|
|
10600
|
-
}
|
|
10601
|
-
clearDescriptions() {
|
|
10602
|
-
this._functionDescriptions.clear();
|
|
10603
|
-
}
|
|
10604
|
-
deleteFormulaAstCacheKey(...functionToken) {
|
|
10605
|
-
FORMULA_AST_CACHE.forEach((_, key) => {
|
|
10606
|
-
functionToken.forEach((token) => {
|
|
10607
|
-
if (key.includes(token)) FORMULA_AST_CACHE.delete(key);
|
|
10608
|
-
});
|
|
10609
|
-
});
|
|
10610
|
-
}
|
|
10611
|
-
};
|
|
10612
|
-
|
|
10613
10685
|
//#endregion
|
|
10614
10686
|
//#region src/services/unit-reference-resolver.service.ts
|
|
10615
10687
|
const IFormulaUnitReferenceResolver = createIdentifier("univer.formula.unit-reference-resolver");
|
|
@@ -10681,9 +10753,10 @@ var PrefixNode = class extends BaseAstNode {
|
|
|
10681
10753
|
this.setValue(result);
|
|
10682
10754
|
}
|
|
10683
10755
|
_handlerAT(value) {
|
|
10684
|
-
if (
|
|
10756
|
+
if (value instanceof ArrayValueObject) return value.get(0, 0) ?? ErrorValueObject.create("#VALUE!");
|
|
10757
|
+
if (!value.isReferenceObject()) return value;
|
|
10685
10758
|
const currentValue = value;
|
|
10686
|
-
if (currentValue.isCell()) return
|
|
10759
|
+
if (currentValue.isCell()) return currentValue.getCellByPosition();
|
|
10687
10760
|
if (this._preserveAtRangeForFormula2LookupArray()) return currentValue;
|
|
10688
10761
|
const runtimeService = this._runtimeService;
|
|
10689
10762
|
const currentRow = runtimeService.currentRow || 0;
|
|
@@ -10701,7 +10774,7 @@ var PrefixNode = class extends BaseAstNode {
|
|
|
10701
10774
|
let parent = node.getParent();
|
|
10702
10775
|
let sawCompareOperator = false;
|
|
10703
10776
|
while (parent != null) {
|
|
10704
|
-
if (parent.nodeType === 3) sawCompareOperator
|
|
10777
|
+
if (parent.nodeType === 3) sawCompareOperator ||= OPERATOR_TOKEN_COMPARE_SET.has(parent.getToken());
|
|
10705
10778
|
if (parent.nodeType === 4) {
|
|
10706
10779
|
const functionName = parent.getToken().toUpperCase();
|
|
10707
10780
|
if (sawCompareOperator && functionName === "XMATCH") return parent.getChildren().indexOf(node) === 1;
|
|
@@ -10787,6 +10860,9 @@ var FunctionNode = class extends BaseAstNode {
|
|
|
10787
10860
|
get nodeType() {
|
|
10788
10861
|
return 4;
|
|
10789
10862
|
}
|
|
10863
|
+
preservesLazyIfReferenceArray(child) {
|
|
10864
|
+
return this._functionExecutor.lazyIfReferenceArrayArgumentIndexes.includes(this.getChildren().indexOf(child));
|
|
10865
|
+
}
|
|
10790
10866
|
async executeAsync() {
|
|
10791
10867
|
const children = this.getChildren();
|
|
10792
10868
|
this._compatibility();
|
|
@@ -10845,6 +10921,7 @@ var FunctionNode = class extends BaseAstNode {
|
|
|
10845
10921
|
if (!this._functionExecutor.returnsLegacyArrayAsScalar || !isTopLevel || !result.isArray()) return result;
|
|
10846
10922
|
const array = result;
|
|
10847
10923
|
if (array.getRowCount() <= 1 && array.getColumnCount() <= 1) return result;
|
|
10924
|
+
if (this._runtimeService.hasFunctionRefInfoOverride() && (this._runtimeService.currentRowCount > 1 || this._runtimeService.currentColumnCount > 1)) return result;
|
|
10848
10925
|
return array.getFirstCell();
|
|
10849
10926
|
}
|
|
10850
10927
|
/**
|
|
@@ -10936,10 +11013,7 @@ var FunctionNode = class extends BaseAstNode {
|
|
|
10936
11013
|
if (minParams !== -1 && maxParams !== -1 && (children.length < minParams || children.length > maxParams)) return ErrorValueObject.create("#N/A");
|
|
10937
11014
|
this._setRefInfo();
|
|
10938
11015
|
this._handleAddressFunction();
|
|
10939
|
-
return this._functionExecutor.calculateAst(children, (node) =>
|
|
10940
|
-
var _this$_getChildVarian;
|
|
10941
|
-
return (_this$_getChildVarian = this._getChildVariant(node)) !== null && _this$_getChildVarian !== void 0 ? _this$_getChildVarian : null;
|
|
10942
|
-
});
|
|
11016
|
+
return this._functionExecutor.calculateAst(children, (node) => this._getChildVariant(node) ?? null);
|
|
10943
11017
|
}
|
|
10944
11018
|
async _calculateAsync(variants) {
|
|
10945
11019
|
const { minParams, maxParams } = this._functionExecutor;
|
|
@@ -11211,7 +11285,6 @@ let Interpreter = class Interpreter extends Disposable {
|
|
|
11211
11285
|
return true;
|
|
11212
11286
|
}
|
|
11213
11287
|
async _executeLazyIfErrorAsync(node, refOffsetX, refOffsetY) {
|
|
11214
|
-
var _children$1$getValue;
|
|
11215
11288
|
const children = node.getChildren();
|
|
11216
11289
|
if (children.length !== 2) return false;
|
|
11217
11290
|
await this._executeAsync(children[0], refOffsetX, refOffsetY);
|
|
@@ -11223,11 +11296,10 @@ let Interpreter = class Interpreter extends Disposable {
|
|
|
11223
11296
|
return true;
|
|
11224
11297
|
}
|
|
11225
11298
|
await this._executeAsync(children[1], refOffsetX, refOffsetY);
|
|
11226
|
-
node.setValue(
|
|
11299
|
+
node.setValue(children[1].getValue() ?? ErrorValueObject.create("#VALUE!"));
|
|
11227
11300
|
return true;
|
|
11228
11301
|
}
|
|
11229
11302
|
_executeLazyIfError(node, refOffsetX, refOffsetY) {
|
|
11230
|
-
var _children$1$getValue2;
|
|
11231
11303
|
const children = node.getChildren();
|
|
11232
11304
|
if (children.length !== 2) return false;
|
|
11233
11305
|
this._execute(children[0], refOffsetX, refOffsetY);
|
|
@@ -11239,7 +11311,7 @@ let Interpreter = class Interpreter extends Disposable {
|
|
|
11239
11311
|
return true;
|
|
11240
11312
|
}
|
|
11241
11313
|
this._execute(children[1], refOffsetX, refOffsetY);
|
|
11242
|
-
node.setValue(
|
|
11314
|
+
node.setValue(children[1].getValue() ?? ErrorValueObject.create("#VALUE!"));
|
|
11243
11315
|
return true;
|
|
11244
11316
|
}
|
|
11245
11317
|
_toLazyIfErrorValue(value) {
|
|
@@ -11255,12 +11327,13 @@ let Interpreter = class Interpreter extends Disposable {
|
|
|
11255
11327
|
}
|
|
11256
11328
|
_toLazyIfSelectedValue(value, node) {
|
|
11257
11329
|
if (value == null) return ErrorValueObject.create("#VALUE!");
|
|
11330
|
+
const preserveArray = this._preserveLazyIfSelectedReferenceArray(node);
|
|
11258
11331
|
if (value.isReferenceObject()) {
|
|
11259
11332
|
const reference = value;
|
|
11260
|
-
if (
|
|
11333
|
+
if (preserveArray) return reference.toArrayValueObject();
|
|
11261
11334
|
value = this._implicitLazyIfReferenceValue(reference);
|
|
11262
11335
|
}
|
|
11263
|
-
if (value.isArray()) value = this._implicitLazyIfArrayValue(value);
|
|
11336
|
+
if (value.isArray() && !preserveArray) value = this._implicitLazyIfArrayValue(value);
|
|
11264
11337
|
if (!value.isArray()) {
|
|
11265
11338
|
const baseValue = value;
|
|
11266
11339
|
return baseValue.isNull() ? NumberValueObject.create(0) : baseValue;
|
|
@@ -11281,7 +11354,7 @@ let Interpreter = class Interpreter extends Disposable {
|
|
|
11281
11354
|
let child = node;
|
|
11282
11355
|
let parent = child.getParent();
|
|
11283
11356
|
while (parent != null) {
|
|
11284
|
-
if (parent.nodeType === 4) return parent.
|
|
11357
|
+
if (parent.nodeType === 4) return parent.preservesLazyIfReferenceArray(child);
|
|
11285
11358
|
child = parent;
|
|
11286
11359
|
parent = parent.getParent();
|
|
11287
11360
|
}
|
|
@@ -11770,6 +11843,7 @@ var TableReferenceObject = class extends BaseReferenceObject {
|
|
|
11770
11843
|
const tableStartRow = range.startRow;
|
|
11771
11844
|
const tableEndRow = range.endRow;
|
|
11772
11845
|
const dataStartRow = tableStartRow + (this._tableData.showHeader === false ? 0 : 1);
|
|
11846
|
+
const dataEndRow = tableEndRow - (this._tableData.showFooter === true ? 1 : 0);
|
|
11773
11847
|
let startRow = -1;
|
|
11774
11848
|
let endRow = -1;
|
|
11775
11849
|
switch (type) {
|
|
@@ -11779,7 +11853,7 @@ var TableReferenceObject = class extends BaseReferenceObject {
|
|
|
11779
11853
|
break;
|
|
11780
11854
|
case "#Data":
|
|
11781
11855
|
startRow = dataStartRow;
|
|
11782
|
-
endRow =
|
|
11856
|
+
endRow = dataEndRow;
|
|
11783
11857
|
break;
|
|
11784
11858
|
case "#Headers":
|
|
11785
11859
|
if (this._tableData.showHeader === false) {
|
|
@@ -11795,14 +11869,14 @@ var TableReferenceObject = class extends BaseReferenceObject {
|
|
|
11795
11869
|
endRow = tableEndRow;
|
|
11796
11870
|
break;
|
|
11797
11871
|
case "#This Row": {
|
|
11798
|
-
const r = this._resolveThisRow(
|
|
11872
|
+
const r = this._resolveThisRow(dataStartRow, dataEndRow);
|
|
11799
11873
|
startRow = r;
|
|
11800
11874
|
endRow = r;
|
|
11801
11875
|
break;
|
|
11802
11876
|
}
|
|
11803
11877
|
default:
|
|
11804
11878
|
startRow = dataStartRow;
|
|
11805
|
-
endRow =
|
|
11879
|
+
endRow = dataEndRow;
|
|
11806
11880
|
break;
|
|
11807
11881
|
}
|
|
11808
11882
|
this.setRangeData({
|
|
@@ -11829,7 +11903,8 @@ var TableReferenceObject = class extends BaseReferenceObject {
|
|
|
11829
11903
|
getCellData(row, column) {
|
|
11830
11904
|
if (this._isCurrentRowForRange) {
|
|
11831
11905
|
const { startRow, endRow } = this._tableData.range;
|
|
11832
|
-
|
|
11906
|
+
const lastCurrentRow = endRow - (this._tableData.showFooter === true ? 1 : 0);
|
|
11907
|
+
if (row < startRow || row > lastCurrentRow) return { v: "#N/A" };
|
|
11833
11908
|
}
|
|
11834
11909
|
return super.getCellData(row, column);
|
|
11835
11910
|
}
|
|
@@ -11854,10 +11929,9 @@ var TableReferenceObject = class extends BaseReferenceObject {
|
|
|
11854
11929
|
* - Has comma: Left is Section, right is column/column range
|
|
11855
11930
|
*/
|
|
11856
11931
|
_parseStructuredRef(raw, titleMap) {
|
|
11857
|
-
var _range$startColumn, _range$endColumn;
|
|
11858
11932
|
const { range } = this._tableData;
|
|
11859
|
-
const fullStartCol =
|
|
11860
|
-
const fullEndCol =
|
|
11933
|
+
const fullStartCol = range.startColumn ?? 0;
|
|
11934
|
+
const fullEndCol = range.endColumn ?? 0;
|
|
11861
11935
|
if (!raw || raw.trim().length === 0) return {
|
|
11862
11936
|
startColumn: fullStartCol,
|
|
11863
11937
|
endColumn: fullEndCol,
|
|
@@ -11909,6 +11983,14 @@ var TableReferenceObject = class extends BaseReferenceObject {
|
|
|
11909
11983
|
const sectionRaw = body.slice(0, commaAt).trim();
|
|
11910
11984
|
const columnsRaw = body.slice(commaAt + 1).trim();
|
|
11911
11985
|
const section = this._parseSectionMaybeBracketed(sectionRaw);
|
|
11986
|
+
if (section === void 0) {
|
|
11987
|
+
const { startColumn, endColumn } = this._parseColumnOrRange(body, titleMap, fullStartCol);
|
|
11988
|
+
return {
|
|
11989
|
+
startColumn,
|
|
11990
|
+
endColumn,
|
|
11991
|
+
type: "#Data"
|
|
11992
|
+
};
|
|
11993
|
+
}
|
|
11912
11994
|
const { startColumn, endColumn } = this._parseColumnOrRange(columnsRaw, titleMap, fullStartCol);
|
|
11913
11995
|
return {
|
|
11914
11996
|
startColumn,
|
|
@@ -11937,13 +12019,12 @@ var TableReferenceObject = class extends BaseReferenceObject {
|
|
|
11937
12019
|
}
|
|
11938
12020
|
/**
|
|
11939
12021
|
* Parse Section, compatible with both "[#Data]" and "#Data" inputs
|
|
11940
|
-
* Returns TableOptionType if matched; returns
|
|
12022
|
+
* Returns TableOptionType if matched; returns undefined when the comma belongs to a column title.
|
|
11941
12023
|
*/
|
|
11942
12024
|
_parseSectionMaybeBracketed(raw) {
|
|
11943
12025
|
const x = raw.trim();
|
|
11944
12026
|
const inner = x.startsWith("[") && x.endsWith("]") ? this._stripOuterBracketOnce(x) : x;
|
|
11945
|
-
|
|
11946
|
-
return typeMaybe !== null && typeMaybe !== void 0 ? typeMaybe : "#Data";
|
|
12027
|
+
return this._mapSection(inner);
|
|
11947
12028
|
}
|
|
11948
12029
|
/**
|
|
11949
12030
|
* Section mapping: Only accepts keywords starting with #.
|
|
@@ -11968,6 +12049,14 @@ var TableReferenceObject = class extends BaseReferenceObject {
|
|
|
11968
12049
|
*/
|
|
11969
12050
|
_parseColumnOrRange(raw, titleMap, fullStartCol) {
|
|
11970
12051
|
const s = raw.trim();
|
|
12052
|
+
const singleColumnIndex = this._titleToIndex(this._stripOuterBracketIfAny(s), titleMap);
|
|
12053
|
+
if (singleColumnIndex !== -1) {
|
|
12054
|
+
const column = fullStartCol + singleColumnIndex;
|
|
12055
|
+
return {
|
|
12056
|
+
startColumn: column,
|
|
12057
|
+
endColumn: column
|
|
12058
|
+
};
|
|
12059
|
+
}
|
|
11971
12060
|
const colonAt = this._findColonAtTopLevel(s);
|
|
11972
12061
|
if (colonAt === -1) {
|
|
11973
12062
|
const name = this._stripOuterBracketIfAny(s);
|
|
@@ -12020,9 +12109,9 @@ var TableReferenceObject = class extends BaseReferenceObject {
|
|
|
12020
12109
|
return -1;
|
|
12021
12110
|
}
|
|
12022
12111
|
/** Resolve #This Row's row number; takes first data row (tableStartRow+1) when no context available */
|
|
12023
|
-
_resolveThisRow(
|
|
12112
|
+
_resolveThisRow(dataStartRow, dataEndRow) {
|
|
12024
12113
|
this._isCurrentRowForRange = true;
|
|
12025
|
-
return Math.min(
|
|
12114
|
+
return Math.min(dataStartRow, dataEndRow);
|
|
12026
12115
|
}
|
|
12027
12116
|
};
|
|
12028
12117
|
|
|
@@ -12209,12 +12298,11 @@ let ReferenceNodeFactory = class ReferenceNodeFactory extends BaseAstNodeFactory
|
|
|
12209
12298
|
return this._superTableService.getTableMap(unitId);
|
|
12210
12299
|
}
|
|
12211
12300
|
_getNode(tokenTrim, isLexerNode, isPrepareMerge, param) {
|
|
12212
|
-
var _tableMap$has;
|
|
12213
12301
|
const currentConfigService = this._currentConfigService;
|
|
12214
12302
|
const runtimeService = this._formulaRuntimeService;
|
|
12215
12303
|
const makeRef = (type) => new ReferenceNode(currentConfigService, runtimeService, tokenTrim, type, this._unitReferenceResolver, this._superTableService, this._externalReferenceDataLoader, isPrepareMerge);
|
|
12216
12304
|
const tableMap = this._getTableMap();
|
|
12217
|
-
if ((
|
|
12305
|
+
if ((tableMap === null || tableMap === void 0 ? void 0 : tableMap.has(tokenTrim)) ?? false) return this._getTableReferenceNode(tokenTrim, isPrepareMerge, true);
|
|
12218
12306
|
if (regexTestSingeRange(tokenTrim)) return makeRef(0);
|
|
12219
12307
|
const parentIsUnion = isLexerNode && this._checkParentIsUnionOperator(param);
|
|
12220
12308
|
if (parentIsUnion && regexTestSingleRow(tokenTrim)) return makeRef(2);
|
|
@@ -12329,11 +12417,253 @@ SuffixNodeFactory = __decorate([
|
|
|
12329
12417
|
__decorateParam(2, IFormulaCurrentConfigService)
|
|
12330
12418
|
], SuffixNodeFactory);
|
|
12331
12419
|
|
|
12420
|
+
//#endregion
|
|
12421
|
+
//#region src/engine/reference-object/multi-area-reference-object.ts
|
|
12422
|
+
var MultiAreaReferenceObject = class extends BaseReferenceObject {
|
|
12423
|
+
constructor(token, areas = [], _arrayMode = "first-cell-grid") {
|
|
12424
|
+
super(token);
|
|
12425
|
+
this._arrayMode = _arrayMode;
|
|
12426
|
+
_defineProperty(this, "_areas", []);
|
|
12427
|
+
this._areas = areas;
|
|
12428
|
+
}
|
|
12429
|
+
dispose() {
|
|
12430
|
+
this._areas.forEach((row) => {
|
|
12431
|
+
row.forEach((a) => a.dispose());
|
|
12432
|
+
});
|
|
12433
|
+
this._areas = [];
|
|
12434
|
+
super.dispose();
|
|
12435
|
+
}
|
|
12436
|
+
getAreas() {
|
|
12437
|
+
return this._areas;
|
|
12438
|
+
}
|
|
12439
|
+
setAreas(areas) {
|
|
12440
|
+
this._areas = areas;
|
|
12441
|
+
}
|
|
12442
|
+
/**
|
|
12443
|
+
* Append an area:
|
|
12444
|
+
* - If a single AreaValue is passed, it will be wrapped as one row.
|
|
12445
|
+
* - If an AreaValue[] is passed, it will be inserted as an entire row.
|
|
12446
|
+
*/
|
|
12447
|
+
addArea(area) {
|
|
12448
|
+
if (Array.isArray(area)) this._areas.push(area);
|
|
12449
|
+
else this._areas.push([area]);
|
|
12450
|
+
}
|
|
12451
|
+
/** Flatten the 2D areas to reuse 1D logic */
|
|
12452
|
+
_flatAreas() {
|
|
12453
|
+
return this._areas.flat();
|
|
12454
|
+
}
|
|
12455
|
+
isMultiArea() {
|
|
12456
|
+
return true;
|
|
12457
|
+
}
|
|
12458
|
+
isRange() {
|
|
12459
|
+
return false;
|
|
12460
|
+
}
|
|
12461
|
+
isCell() {
|
|
12462
|
+
return false;
|
|
12463
|
+
}
|
|
12464
|
+
isRow() {
|
|
12465
|
+
return false;
|
|
12466
|
+
}
|
|
12467
|
+
isColumn() {
|
|
12468
|
+
return false;
|
|
12469
|
+
}
|
|
12470
|
+
getRowCount() {
|
|
12471
|
+
if (this._arrayMode === "first-cell-grid") return this._areas.length;
|
|
12472
|
+
let total = 0;
|
|
12473
|
+
for (const a of this._flatAreas()) if (a instanceof BaseReferenceObject) total += a.getRowCount();
|
|
12474
|
+
return total;
|
|
12475
|
+
}
|
|
12476
|
+
getColumnCount() {
|
|
12477
|
+
if (this._arrayMode === "first-cell-grid") return this._areas.reduce((max, row) => Math.max(max, row.length), 0);
|
|
12478
|
+
return this._flatAreas().reduce((max, area) => area instanceof BaseReferenceObject ? Math.max(max, area.getColumnCount()) : max, 0);
|
|
12479
|
+
}
|
|
12480
|
+
isExceedRange() {
|
|
12481
|
+
return this._flatAreas().some((a) => {
|
|
12482
|
+
return a instanceof BaseReferenceObject && a.isExceedRange();
|
|
12483
|
+
});
|
|
12484
|
+
}
|
|
12485
|
+
setRefOffset(x = 0, y = 0) {
|
|
12486
|
+
super.setRefOffset(x, y);
|
|
12487
|
+
this._flatAreas().forEach((a) => {
|
|
12488
|
+
if (a instanceof BaseReferenceObject) a.setRefOffset(x, y);
|
|
12489
|
+
});
|
|
12490
|
+
}
|
|
12491
|
+
_getReferenceArea() {
|
|
12492
|
+
return this._flatAreas().find((area) => area instanceof BaseReferenceObject);
|
|
12493
|
+
}
|
|
12494
|
+
/**
|
|
12495
|
+
* Multi-area reference may span multiple sheets, but Excel requires
|
|
12496
|
+
* them to be in the same sheet for most functions. We follow Excel semantics
|
|
12497
|
+
* by returning the first area’s identifiers.
|
|
12498
|
+
*/
|
|
12499
|
+
getUnitId() {
|
|
12500
|
+
var _this$_getReferenceAr;
|
|
12501
|
+
return ((_this$_getReferenceAr = this._getReferenceArea()) === null || _this$_getReferenceAr === void 0 ? void 0 : _this$_getReferenceAr.getUnitId()) ?? super.getUnitId();
|
|
12502
|
+
}
|
|
12503
|
+
getSheetId() {
|
|
12504
|
+
var _this$_getReferenceAr2;
|
|
12505
|
+
return ((_this$_getReferenceAr2 = this._getReferenceArea()) === null || _this$_getReferenceAr2 === void 0 ? void 0 : _this$_getReferenceAr2.getSheetId()) ?? super.getSheetId();
|
|
12506
|
+
}
|
|
12507
|
+
getActiveSheetRowCount() {
|
|
12508
|
+
var _this$_getReferenceAr3;
|
|
12509
|
+
return ((_this$_getReferenceAr3 = this._getReferenceArea()) === null || _this$_getReferenceAr3 === void 0 ? void 0 : _this$_getReferenceAr3.getActiveSheetRowCount()) ?? 0;
|
|
12510
|
+
}
|
|
12511
|
+
getActiveSheetColumnCount() {
|
|
12512
|
+
var _this$_getReferenceAr4;
|
|
12513
|
+
return ((_this$_getReferenceAr4 = this._getReferenceArea()) === null || _this$_getReferenceAr4 === void 0 ? void 0 : _this$_getReferenceAr4.getActiveSheetColumnCount()) ?? 0;
|
|
12514
|
+
}
|
|
12515
|
+
/**
|
|
12516
|
+
* Iterate through all areas in order, flattening the multi-area into
|
|
12517
|
+
* a sequence of cells.
|
|
12518
|
+
*
|
|
12519
|
+
* Note: The order here is "row-major":
|
|
12520
|
+
* iterate by the row order of _areas, then within each row by the area order.
|
|
12521
|
+
*/
|
|
12522
|
+
iterator(callback) {
|
|
12523
|
+
for (const row of this._areas) {
|
|
12524
|
+
let stopRow = false;
|
|
12525
|
+
for (const area of row) {
|
|
12526
|
+
if (!(area instanceof BaseReferenceObject)) continue;
|
|
12527
|
+
let stopArea = false;
|
|
12528
|
+
area.iterator((v, r, c) => {
|
|
12529
|
+
const res = callback(v, r, c);
|
|
12530
|
+
if (res === false) {
|
|
12531
|
+
stopArea = true;
|
|
12532
|
+
stopRow = true;
|
|
12533
|
+
return false;
|
|
12534
|
+
}
|
|
12535
|
+
return res;
|
|
12536
|
+
});
|
|
12537
|
+
if (stopArea) break;
|
|
12538
|
+
}
|
|
12539
|
+
if (stopRow) return;
|
|
12540
|
+
}
|
|
12541
|
+
}
|
|
12542
|
+
/**
|
|
12543
|
+
* Excel defines the "first cell" of a multi-area reference
|
|
12544
|
+
* as the first cell of the first area.
|
|
12545
|
+
*/
|
|
12546
|
+
getFirstCell() {
|
|
12547
|
+
const first = this._getReferenceArea();
|
|
12548
|
+
if (!first) return super.getFirstCell();
|
|
12549
|
+
return first.getFirstCell();
|
|
12550
|
+
}
|
|
12551
|
+
/**
|
|
12552
|
+
* For multi-area, we only take the *first cell* of each area and
|
|
12553
|
+
* arrange them into a 2D ArrayValueObject:
|
|
12554
|
+
*
|
|
12555
|
+
* - outer `_areas` dimension => rows
|
|
12556
|
+
* - inner `_areas[row]` dimension => columns
|
|
12557
|
+
*/
|
|
12558
|
+
toArrayValueObject() {
|
|
12559
|
+
if (this._arrayMode === "stack-areas") return this._stackAreas();
|
|
12560
|
+
const rows = this._areas.length;
|
|
12561
|
+
if (rows === 0) return createNewArray([], 0, 0);
|
|
12562
|
+
const cols = this.getColumnCount();
|
|
12563
|
+
const result = [];
|
|
12564
|
+
for (let r = 0; r < rows; r++) {
|
|
12565
|
+
const rowAreas = this._areas[r] ?? [];
|
|
12566
|
+
result[r] = [];
|
|
12567
|
+
for (let c = 0; c < cols; c++) {
|
|
12568
|
+
const area = rowAreas[c];
|
|
12569
|
+
if (!area) {
|
|
12570
|
+
result[r][c] = NullValueObject.create();
|
|
12571
|
+
continue;
|
|
12572
|
+
}
|
|
12573
|
+
if (area instanceof ErrorValueObject) {
|
|
12574
|
+
result[r][c] = area;
|
|
12575
|
+
continue;
|
|
12576
|
+
}
|
|
12577
|
+
result[r][c] = area.toArrayValueObject(false).getRealValue(0, 0) ?? NullValueObject.create();
|
|
12578
|
+
}
|
|
12579
|
+
}
|
|
12580
|
+
return createNewArray(result, rows, cols);
|
|
12581
|
+
}
|
|
12582
|
+
_stackAreas() {
|
|
12583
|
+
const result = [];
|
|
12584
|
+
const cols = this.getColumnCount();
|
|
12585
|
+
for (const area of this._flatAreas()) {
|
|
12586
|
+
if (area instanceof ErrorValueObject) {
|
|
12587
|
+
const row = new Array(cols).fill(NullValueObject.create());
|
|
12588
|
+
row[0] = area;
|
|
12589
|
+
result.push(row);
|
|
12590
|
+
continue;
|
|
12591
|
+
}
|
|
12592
|
+
const array = area.toArrayValueObject(false);
|
|
12593
|
+
for (let r = 0; r < array.getRowCount(); r++) {
|
|
12594
|
+
const row = [];
|
|
12595
|
+
for (let c = 0; c < cols; c++) row[c] = array.getRealValue(r, c) ?? NullValueObject.create();
|
|
12596
|
+
result.push(row);
|
|
12597
|
+
}
|
|
12598
|
+
}
|
|
12599
|
+
return createNewArray(result, result.length, cols);
|
|
12600
|
+
}
|
|
12601
|
+
getRangePosition() {
|
|
12602
|
+
const flat = this._flatAreas();
|
|
12603
|
+
if (!flat.length) return super.getRangePosition();
|
|
12604
|
+
let minStartRow = Number.POSITIVE_INFINITY;
|
|
12605
|
+
let minStartColumn = Number.POSITIVE_INFINITY;
|
|
12606
|
+
let maxEndRow = Number.NEGATIVE_INFINITY;
|
|
12607
|
+
let maxEndColumn = Number.NEGATIVE_INFINITY;
|
|
12608
|
+
for (const area of flat) {
|
|
12609
|
+
if (!(area instanceof BaseReferenceObject)) continue;
|
|
12610
|
+
const { startRow, startColumn, endRow, endColumn } = area.getRangePosition();
|
|
12611
|
+
if (!Number.isFinite(startRow) || !Number.isFinite(startColumn) || !Number.isFinite(endRow) || !Number.isFinite(endColumn)) continue;
|
|
12612
|
+
if (startRow < minStartRow) minStartRow = startRow;
|
|
12613
|
+
if (startColumn < minStartColumn) minStartColumn = startColumn;
|
|
12614
|
+
if (endRow > maxEndRow) maxEndRow = endRow;
|
|
12615
|
+
if (endColumn > maxEndColumn) maxEndColumn = maxEndColumn < endColumn ? endColumn : maxEndColumn;
|
|
12616
|
+
}
|
|
12617
|
+
if (!Number.isFinite(minStartRow) || !Number.isFinite(minStartColumn) || !Number.isFinite(maxEndRow) || !Number.isFinite(maxEndColumn)) return super.getRangePosition();
|
|
12618
|
+
return {
|
|
12619
|
+
startRow: minStartRow,
|
|
12620
|
+
startColumn: minStartColumn,
|
|
12621
|
+
endRow: maxEndRow,
|
|
12622
|
+
endColumn: maxEndColumn
|
|
12623
|
+
};
|
|
12624
|
+
}
|
|
12625
|
+
toUnitRange() {
|
|
12626
|
+
return {
|
|
12627
|
+
range: this.getRangePosition(),
|
|
12628
|
+
sheetId: this.getSheetId(),
|
|
12629
|
+
unitId: this.getUnitId()
|
|
12630
|
+
};
|
|
12631
|
+
}
|
|
12632
|
+
toUnitRanges() {
|
|
12633
|
+
return this._flatAreas().filter((area) => area instanceof BaseReferenceObject).flatMap((area) => area.toUnitRanges());
|
|
12634
|
+
}
|
|
12635
|
+
getRangeData() {
|
|
12636
|
+
const flat = this._flatAreas();
|
|
12637
|
+
if (!flat.length) return super.getRangeData();
|
|
12638
|
+
let minStartRow = Number.POSITIVE_INFINITY;
|
|
12639
|
+
let minStartColumn = Number.POSITIVE_INFINITY;
|
|
12640
|
+
let maxEndRow = Number.NEGATIVE_INFINITY;
|
|
12641
|
+
let maxEndColumn = Number.NEGATIVE_INFINITY;
|
|
12642
|
+
for (const area of flat) {
|
|
12643
|
+
if (!(area instanceof BaseReferenceObject)) continue;
|
|
12644
|
+
const { startRow, startColumn, endRow, endColumn } = area.getRangeData();
|
|
12645
|
+
if (!Number.isFinite(startRow) || !Number.isFinite(startColumn) || !Number.isFinite(endRow) || !Number.isFinite(endColumn)) continue;
|
|
12646
|
+
if (startRow < minStartRow) minStartRow = startRow;
|
|
12647
|
+
if (startColumn < minStartColumn) minStartColumn = startColumn;
|
|
12648
|
+
if (endRow > maxEndRow) maxEndRow = endRow;
|
|
12649
|
+
if (endColumn > maxEndColumn) maxEndColumn = endColumn;
|
|
12650
|
+
}
|
|
12651
|
+
if (!Number.isFinite(minStartRow) || !Number.isFinite(minStartColumn) || !Number.isFinite(maxEndRow) || !Number.isFinite(maxEndColumn)) return super.getRangeData();
|
|
12652
|
+
return {
|
|
12653
|
+
startRow: minStartRow,
|
|
12654
|
+
startColumn: minStartColumn,
|
|
12655
|
+
endRow: maxEndRow,
|
|
12656
|
+
endColumn: maxEndColumn
|
|
12657
|
+
};
|
|
12658
|
+
}
|
|
12659
|
+
};
|
|
12660
|
+
|
|
12332
12661
|
//#endregion
|
|
12333
12662
|
//#region src/engine/ast-node/union-node.ts
|
|
12334
12663
|
var UnionNode = class extends BaseAstNode {
|
|
12335
|
-
constructor(operatorString) {
|
|
12664
|
+
constructor(operatorString, _currentConfigService) {
|
|
12336
12665
|
super(operatorString);
|
|
12666
|
+
this._currentConfigService = _currentConfigService;
|
|
12337
12667
|
}
|
|
12338
12668
|
get nodeType() {
|
|
12339
12669
|
return 10;
|
|
@@ -12350,28 +12680,74 @@ var UnionNode = class extends BaseAstNode {
|
|
|
12350
12680
|
return;
|
|
12351
12681
|
}
|
|
12352
12682
|
let result;
|
|
12353
|
-
if (this.getToken() === ":") result = this._unionFunction(leftNode, rightNode);
|
|
12683
|
+
if (this.getToken() === ":") result = this._createThreeDimensionalReference(leftChild.getToken(), rightNode) ?? this._unionFunction(leftNode, rightNode);
|
|
12354
12684
|
else result = ErrorValueObject.create("#NAME?");
|
|
12355
12685
|
this.setValue(result);
|
|
12356
12686
|
}
|
|
12687
|
+
_createThreeDimensionalReference(firstSheetToken, rightNode) {
|
|
12688
|
+
if (!(rightNode instanceof BaseReferenceObject)) return;
|
|
12689
|
+
const source = rightNode;
|
|
12690
|
+
const firstSheetName = this._normalizeSheetName(firstSheetToken);
|
|
12691
|
+
const lastSheetName = this._normalizeSheetName(source.getForcedSheetName());
|
|
12692
|
+
if (!firstSheetName || !lastSheetName) return;
|
|
12693
|
+
const { sheetOrder, sheetNameMap } = this._currentConfigService.getSheetsInfo();
|
|
12694
|
+
const sheetIdsByName = new Map(Object.entries(sheetNameMap).map(([sheetId, sheetName]) => [sheetName.toLocaleLowerCase(), sheetId]));
|
|
12695
|
+
const firstSheetId = sheetIdsByName.get(firstSheetName.toLocaleLowerCase());
|
|
12696
|
+
const lastSheetId = sheetIdsByName.get(lastSheetName.toLocaleLowerCase());
|
|
12697
|
+
const firstIndex = firstSheetId == null ? -1 : sheetOrder.indexOf(firstSheetId);
|
|
12698
|
+
const lastIndex = lastSheetId == null ? -1 : sheetOrder.indexOf(lastSheetId);
|
|
12699
|
+
if (firstIndex < 0 || lastIndex < 0) return;
|
|
12700
|
+
const startIndex = Math.min(firstIndex, lastIndex);
|
|
12701
|
+
const endIndex = Math.max(firstIndex, lastIndex);
|
|
12702
|
+
const areas = sheetOrder.slice(startIndex, endIndex + 1).map((sheetId) => {
|
|
12703
|
+
const reference = new RangeReferenceObject(source.getRangeData(), sheetId, source.getUnitId());
|
|
12704
|
+
this._copyReferenceContext(source, reference);
|
|
12705
|
+
reference.setForcedSheetIdDirect(sheetId);
|
|
12706
|
+
reference.setForcedSheetName(sheetNameMap[sheetId] ?? "");
|
|
12707
|
+
return [reference];
|
|
12708
|
+
});
|
|
12709
|
+
return new MultiAreaReferenceObject(`${firstSheetToken}:${source.getToken()}`, areas, "stack-areas");
|
|
12710
|
+
}
|
|
12711
|
+
_normalizeSheetName(token) {
|
|
12712
|
+
const trimmed = token.trim();
|
|
12713
|
+
if (trimmed.startsWith("'") && trimmed.endsWith("'")) return trimmed.slice(1, -1).replace(/''/g, "'");
|
|
12714
|
+
return trimmed;
|
|
12715
|
+
}
|
|
12716
|
+
_copyReferenceContext(source, target) {
|
|
12717
|
+
target.setDefaultUnitId(source.getDefaultUnitId());
|
|
12718
|
+
target.setDefaultSheetId(source.getDefaultSheetId());
|
|
12719
|
+
target.setUnitData(source.getUnitData());
|
|
12720
|
+
target.setUnitStylesData(source.getUnitStylesData());
|
|
12721
|
+
target.setFilteredOutRows(source.getFilteredOutRows());
|
|
12722
|
+
target.setRuntimeData(source.getRuntimeData());
|
|
12723
|
+
target.setArrayFormulaCellData(source.getArrayFormulaCellData());
|
|
12724
|
+
target.setArrayFormulaRange(source.getArrayFormulaRange());
|
|
12725
|
+
target.setRuntimeArrayFormulaCellData(source.getRuntimeArrayFormulaCellData());
|
|
12726
|
+
target.setRuntimeArrayFormulaRange(source.getRuntimeArrayFormulaRange());
|
|
12727
|
+
target.setRuntimeFeatureCellData(source.getRuntimeFeatureCellData());
|
|
12728
|
+
const currentRow = source.getCurrentRow();
|
|
12729
|
+
const currentColumn = source.getCurrentColumn();
|
|
12730
|
+
if (currentRow != null && currentColumn != null) target.setCurrentRowAndColumn(currentRow, currentColumn);
|
|
12731
|
+
const { x, y } = source.getRefOffset();
|
|
12732
|
+
target.setRefOffset(x, y);
|
|
12733
|
+
}
|
|
12357
12734
|
_unionFunction(variant1, variant2) {
|
|
12358
12735
|
if (variant1.isError() || variant2.isError()) return ErrorValueObject.create("#REF!");
|
|
12359
|
-
if (!variant1
|
|
12360
|
-
variant1 = variant1;
|
|
12361
|
-
variant2 = variant2;
|
|
12736
|
+
if (!(variant1 instanceof BaseReferenceObject) || !(variant2 instanceof BaseReferenceObject)) return ErrorValueObject.create("#REF!");
|
|
12362
12737
|
return getRangeReferenceObjectFromCache(variant1, variant2);
|
|
12363
12738
|
}
|
|
12364
12739
|
};
|
|
12365
12740
|
let UnionNodeFactory = class UnionNodeFactory extends BaseAstNodeFactory {
|
|
12366
|
-
constructor(_functionService) {
|
|
12741
|
+
constructor(_functionService, _currentConfigService) {
|
|
12367
12742
|
super();
|
|
12368
12743
|
this._functionService = _functionService;
|
|
12744
|
+
this._currentConfigService = _currentConfigService;
|
|
12369
12745
|
}
|
|
12370
12746
|
get zIndex() {
|
|
12371
12747
|
return NODE_ORDER_MAP.get(10) || 100;
|
|
12372
12748
|
}
|
|
12373
12749
|
create(param) {
|
|
12374
|
-
return new UnionNode(param);
|
|
12750
|
+
return new UnionNode(param, this._currentConfigService);
|
|
12375
12751
|
}
|
|
12376
12752
|
checkAndCreateNodeType(param) {
|
|
12377
12753
|
if (!(param instanceof LexerNode)) return;
|
|
@@ -12381,7 +12757,7 @@ let UnionNodeFactory = class UnionNodeFactory extends BaseAstNodeFactory {
|
|
|
12381
12757
|
return this.create(tokenTrim);
|
|
12382
12758
|
}
|
|
12383
12759
|
};
|
|
12384
|
-
UnionNodeFactory = __decorate([__decorateParam(0, IFunctionService)], UnionNodeFactory);
|
|
12760
|
+
UnionNodeFactory = __decorate([__decorateParam(0, IFunctionService), __decorateParam(1, IFormulaCurrentConfigService)], UnionNodeFactory);
|
|
12385
12761
|
|
|
12386
12762
|
//#endregion
|
|
12387
12763
|
//#region src/engine/ast-node/value-node.ts
|
|
@@ -12402,8 +12778,8 @@ var ValueNode = class extends BaseAstNode {
|
|
|
12402
12778
|
const parent = this.getParent();
|
|
12403
12779
|
let isIgnoreNumberPattern = true;
|
|
12404
12780
|
if ((parent === null || parent === void 0 ? void 0 : parent.nodeType) === 4) {
|
|
12405
|
-
var _isFunctionExecutorAr
|
|
12406
|
-
isIgnoreNumberPattern = (_isFunctionExecutorAr =
|
|
12781
|
+
var _isFunctionExecutorAr;
|
|
12782
|
+
isIgnoreNumberPattern = ((_isFunctionExecutorAr = parent.isFunctionExecutorArgumentsIgnoreNumberPattern) === null || _isFunctionExecutorAr === void 0 ? void 0 : _isFunctionExecutorAr.call(parent)) ?? true;
|
|
12407
12783
|
}
|
|
12408
12784
|
this.setValue(ValueObjectFactory.create(token, isIgnoreNumberPattern));
|
|
12409
12785
|
}
|
|
@@ -12628,7 +13004,7 @@ let AstTreeBuilder = class AstTreeBuilder extends Disposable {
|
|
|
12628
13004
|
if (astNode == null) {
|
|
12629
13005
|
const aggregatorNode = this._createGroupByAggregatorTokenNode(item);
|
|
12630
13006
|
if (aggregatorNode != null) return aggregatorNode;
|
|
12631
|
-
return new ErrorFunctionNode();
|
|
13007
|
+
return new ErrorFunctionNode(typeof item === "string" ? item : item.getToken());
|
|
12632
13008
|
}
|
|
12633
13009
|
return astNode;
|
|
12634
13010
|
}
|
|
@@ -13287,8 +13663,8 @@ var FormulaDependencyTreeVirtual = class extends FormulaDependencyTreeCalculator
|
|
|
13287
13663
|
return this.refTree.subUnitId;
|
|
13288
13664
|
}
|
|
13289
13665
|
get formula() {
|
|
13290
|
-
var _this$refTree
|
|
13291
|
-
return (
|
|
13666
|
+
var _this$refTree;
|
|
13667
|
+
return ((_this$refTree = this.refTree) === null || _this$refTree === void 0 ? void 0 : _this$refTree.formula) ?? "";
|
|
13292
13668
|
}
|
|
13293
13669
|
get nodeData() {
|
|
13294
13670
|
return {
|
|
@@ -13522,13 +13898,12 @@ var FormulaDependencyTreeModel = class {
|
|
|
13522
13898
|
this.refOffsetY = tree.refOffsetY;
|
|
13523
13899
|
this.rangeList = tree.rangeList;
|
|
13524
13900
|
if (tree.isVirtual) {
|
|
13525
|
-
var _refTree
|
|
13526
|
-
this.refTreeId = (
|
|
13901
|
+
var _refTree;
|
|
13902
|
+
this.refTreeId = ((_refTree = tree.refTree) === null || _refTree === void 0 ? void 0 : _refTree.treeId) ?? -1;
|
|
13527
13903
|
} else {
|
|
13528
|
-
var _formulaId, _featureId;
|
|
13529
13904
|
this.formula = tree.formula;
|
|
13530
|
-
this.formulaId =
|
|
13531
|
-
this.featureId =
|
|
13905
|
+
this.formulaId = tree.formulaId ?? void 0;
|
|
13906
|
+
this.featureId = tree.featureId ?? void 0;
|
|
13532
13907
|
this.type = tree.type;
|
|
13533
13908
|
}
|
|
13534
13909
|
}
|
|
@@ -13716,14 +14091,13 @@ let FormulaDependencyGenerator = class FormulaDependencyGenerator extends Dispos
|
|
|
13716
14091
|
const columnCount = sheetSize.columnCount > 0 ? sheetSize.columnCount : 1;
|
|
13717
14092
|
const subFormulaDataKeys = Object.keys(subFormulaData);
|
|
13718
14093
|
for (const subFormulaDataId of subFormulaDataKeys) {
|
|
13719
|
-
var _treeMatrix$getValue;
|
|
13720
14094
|
const hasOtherFormula = this._dependencyManagerService.hasOtherFormulaDataMainData(subFormulaDataId);
|
|
13721
14095
|
const { f: formulaString, ranges } = subFormulaData[subFormulaDataId];
|
|
13722
14096
|
let isCache = false;
|
|
13723
14097
|
if (hasOtherFormula) isCache = true;
|
|
13724
14098
|
const { firstRow, firstColumn } = this._getFirstCellOfRange(ranges);
|
|
13725
14099
|
const treeMatrix = this._dependencyManagerService.getOtherFormulaDependency(unitId, subUnitId, subFormulaDataId);
|
|
13726
|
-
const firstFDtree = new FormulaDependencyTree((
|
|
14100
|
+
const firstFDtree = new FormulaDependencyTree((treeMatrix === null || treeMatrix === void 0 ? void 0 : treeMatrix.getValue(0, 0)) ?? generateRandomDependencyTreeId(this._dependencyManagerService));
|
|
13727
14101
|
for (let i = 0; i < ranges.length; i++) {
|
|
13728
14102
|
const range = ranges[i];
|
|
13729
14103
|
const { startRow, startColumn } = range;
|
|
@@ -13857,7 +14231,7 @@ let FormulaDependencyGenerator = class FormulaDependencyGenerator extends Dispos
|
|
|
13857
14231
|
return this._dependencyTreeCache.get(treeId);
|
|
13858
14232
|
}
|
|
13859
14233
|
_getTreeNode(tree) {
|
|
13860
|
-
return generateAstNode(tree.unitId, tree.formula, this._lexer, this._astTreeBuilder, this._currentConfigService, tree.subUnitId);
|
|
14234
|
+
return generateAstNode(tree.unitId, tree.formula, this._lexer, this._astTreeBuilder, this._currentConfigService, tree.subUnitId, tree.column, tree.row);
|
|
13861
14235
|
}
|
|
13862
14236
|
*_traverse(treeList, skippedTreeIds) {
|
|
13863
14237
|
const stack = treeList;
|
|
@@ -14093,15 +14467,13 @@ let FormulaDependencyGenerator = class FormulaDependencyGenerator extends Dispos
|
|
|
14093
14467
|
}
|
|
14094
14468
|
}
|
|
14095
14469
|
async _executeNode(node, refOffsetX = 0, refOffsetY = 0) {
|
|
14096
|
-
let value;
|
|
14097
14470
|
const nodeData = {
|
|
14098
14471
|
node,
|
|
14099
14472
|
refOffsetX,
|
|
14100
14473
|
refOffsetY
|
|
14101
14474
|
};
|
|
14102
|
-
|
|
14103
|
-
|
|
14104
|
-
return value;
|
|
14475
|
+
const value = this._interpreter.checkAsyncNode(node) ? await this._interpreter.executeAsync(nodeData) : this._interpreter.execute(nodeData);
|
|
14476
|
+
return value instanceof BaseReferenceObject ? value : null;
|
|
14105
14477
|
}
|
|
14106
14478
|
/**
|
|
14107
14479
|
* Calculate the range required for collection in advance,
|
|
@@ -14118,8 +14490,8 @@ let FormulaDependencyGenerator = class FormulaDependencyGenerator extends Dispos
|
|
|
14118
14490
|
const rangeList = [];
|
|
14119
14491
|
for (let i = 0, len = preCalculateNodeList.length; i < len; i++) {
|
|
14120
14492
|
const node = preCalculateNodeList[i];
|
|
14121
|
-
const
|
|
14122
|
-
rangeList.push(
|
|
14493
|
+
const value = await this._executeNode(node, refOffsetX, refOffsetY);
|
|
14494
|
+
if (value != null) rangeList.push(...value.toUnitRanges());
|
|
14123
14495
|
node.setValue(null);
|
|
14124
14496
|
}
|
|
14125
14497
|
return rangeList;
|
|
@@ -14254,8 +14626,8 @@ let FormulaDependencyGenerator = class FormulaDependencyGenerator extends Dispos
|
|
|
14254
14626
|
const rangeList = [];
|
|
14255
14627
|
for (let i = 0, len = referenceFunctionList.length; i < len; i++) {
|
|
14256
14628
|
const node = referenceFunctionList[i];
|
|
14257
|
-
const
|
|
14258
|
-
rangeList.push(
|
|
14629
|
+
const value = await this._executeNode(node, refOffsetX, refOffsetY);
|
|
14630
|
+
if (value != null) rangeList.push(...value.toUnitRanges());
|
|
14259
14631
|
node.setValue(null);
|
|
14260
14632
|
}
|
|
14261
14633
|
return rangeList;
|
|
@@ -14628,7 +15000,7 @@ let CalculateFormulaService = class CalculateFormulaService extends Disposable {
|
|
|
14628
15000
|
while (treeList.length > 0) {
|
|
14629
15001
|
const tree = treeList.pop();
|
|
14630
15002
|
this._runtimeService.setCurrent(tree.row, tree.column, tree.rowCount, tree.columnCount, tree.subUnitId, tree.unitId);
|
|
14631
|
-
const node = generateAstNode(tree.unitId, tree.formula, this._lexer, this._astTreeBuilder, this._currentConfigService, tree.subUnitId);
|
|
15003
|
+
const node = generateAstNode(tree.unitId, tree.formula, this._lexer, this._astTreeBuilder, this._currentConfigService, tree.subUnitId, tree.column, tree.row);
|
|
14632
15004
|
const nodeData = {
|
|
14633
15005
|
node,
|
|
14634
15006
|
refOffsetX: tree.refOffsetX,
|
|
@@ -14910,7 +15282,7 @@ let CalculateController = class CalculateController extends Disposable {
|
|
|
14910
15282
|
if (dependencyTreeModelData.length > 0) this._commandService.executeCommand(SetFormulaDependencyCalculationResultMutation.id, { result: dependencyTreeModelData }, { onlyLocal: true });
|
|
14911
15283
|
}
|
|
14912
15284
|
async _applyResult(data) {
|
|
14913
|
-
const { unitData, unitOtherData, arrayFormulaRange, arrayFormulaCellData, clearArrayFormulaCellData, arrayFormulaEmbedded, imageFormulaData
|
|
15285
|
+
const { unitData, unitOtherData, arrayFormulaRange, arrayFormulaCellData, clearArrayFormulaCellData, arrayFormulaEmbedded, imageFormulaData } = data;
|
|
14914
15286
|
if (!unitData) {
|
|
14915
15287
|
this._applyTreeResult(data);
|
|
14916
15288
|
console.error("No sheetData from Formula Engine!");
|
|
@@ -15046,8 +15418,7 @@ var FormulaCalculationSessionService = class extends Disposable {
|
|
|
15046
15418
|
}
|
|
15047
15419
|
markResultApplied(type = "sheet", result) {
|
|
15048
15420
|
if (result && this._currentResult !== result) {
|
|
15049
|
-
|
|
15050
|
-
const types = (_this$_preAppliedResu = this._preAppliedResultTypes.get(result)) !== null && _this$_preAppliedResu !== void 0 ? _this$_preAppliedResu : /* @__PURE__ */ new Set();
|
|
15421
|
+
const types = this._preAppliedResultTypes.get(result) ?? /* @__PURE__ */ new Set();
|
|
15051
15422
|
types.add(type);
|
|
15052
15423
|
this._preAppliedResultTypes.set(result, types);
|
|
15053
15424
|
return;
|
|
@@ -15223,13 +15594,13 @@ let RegisterOtherFormulaService = class RegisterOtherFormulaService extends Disp
|
|
|
15223
15594
|
this._activeDirtyManagerService = _activeDirtyManagerService;
|
|
15224
15595
|
this._lifecycleService = _lifecycleService;
|
|
15225
15596
|
_defineProperty(this, "_formulaCacheMap", /* @__PURE__ */ new Map());
|
|
15597
|
+
_defineProperty(this, "_mutationSyncHandler", void 0);
|
|
15226
15598
|
_defineProperty(this, "_formulaChangeWithRange$", new Subject());
|
|
15227
15599
|
_defineProperty(this, "formulaChangeWithRange$", this._formulaChangeWithRange$.asObservable());
|
|
15228
15600
|
_defineProperty(this, "_formulaResult$", new Subject());
|
|
15229
15601
|
_defineProperty(this, "formulaResult$", this._formulaResult$.asObservable());
|
|
15230
15602
|
_defineProperty(this, "_otherFormulaResultApplied$", new Subject());
|
|
15231
15603
|
_defineProperty(this, "otherFormulaResultApplied$", this._otherFormulaResultApplied$.asObservable());
|
|
15232
|
-
_defineProperty(this, "calculateStarted$", new BehaviorSubject(false));
|
|
15233
15604
|
this._initFormulaRegister();
|
|
15234
15605
|
this._initFormulaCalculationResultChange();
|
|
15235
15606
|
}
|
|
@@ -15238,7 +15609,6 @@ let RegisterOtherFormulaService = class RegisterOtherFormulaService extends Disp
|
|
|
15238
15609
|
this._formulaChangeWithRange$.complete();
|
|
15239
15610
|
this._formulaResult$.complete();
|
|
15240
15611
|
this._otherFormulaResultApplied$.complete();
|
|
15241
|
-
this.calculateStarted$.complete();
|
|
15242
15612
|
}
|
|
15243
15613
|
_ensureCacheMap(unitId, subUnitId) {
|
|
15244
15614
|
let unitMap = this._formulaCacheMap.get(unitId);
|
|
@@ -15264,6 +15634,7 @@ let RegisterOtherFormulaService = class RegisterOtherFormulaService extends Disp
|
|
|
15264
15634
|
}
|
|
15265
15635
|
});
|
|
15266
15636
|
const handleRegister = (option) => {
|
|
15637
|
+
var _this$_mutationSyncHa;
|
|
15267
15638
|
const { unitId, subUnitId, formulaText, formulaId, ranges } = option;
|
|
15268
15639
|
if (!this._ensureCacheMap(unitId, subUnitId).has(formulaId)) return;
|
|
15269
15640
|
const params = {
|
|
@@ -15274,13 +15645,29 @@ let RegisterOtherFormulaService = class RegisterOtherFormulaService extends Disp
|
|
|
15274
15645
|
ranges
|
|
15275
15646
|
} }
|
|
15276
15647
|
};
|
|
15277
|
-
this.
|
|
15648
|
+
const waitForMutationSync = (_this$_mutationSyncHa = this._mutationSyncHandler) === null || _this$_mutationSyncHa === void 0 ? void 0 : _this$_mutationSyncHa.call(this, unitId);
|
|
15649
|
+
this._commandService.executeCommand(SetOtherFormulaMutation.id, params, { onlyLocal: true }).then(async () => {
|
|
15650
|
+
if (this._disposed) return;
|
|
15651
|
+
await (waitForMutationSync === null || waitForMutationSync === void 0 ? void 0 : waitForMutationSync());
|
|
15278
15652
|
if (this._disposed) return;
|
|
15279
15653
|
this._commandService.executeCommand(OtherFormulaMarkDirty.id, { [unitId]: { [subUnitId]: { [formulaId]: true } } }, { onlyLocal: true });
|
|
15280
15654
|
});
|
|
15281
15655
|
};
|
|
15282
|
-
this.disposeWithMe(this._formulaChangeWithRange$.
|
|
15283
|
-
|
|
15656
|
+
this.disposeWithMe(this._formulaChangeWithRange$.subscribe((option) => {
|
|
15657
|
+
if (this._commandService.hasCommand(SetOtherFormulaMutation.id) && this._commandService.hasCommand(OtherFormulaMarkDirty.id)) {
|
|
15658
|
+
handleRegister(option);
|
|
15659
|
+
return;
|
|
15660
|
+
}
|
|
15661
|
+
this._lifecycleService.onStage(LifecycleStages.Ready).then(() => {
|
|
15662
|
+
if (!this._disposed) handleRegister(option);
|
|
15663
|
+
});
|
|
15664
|
+
}));
|
|
15665
|
+
}
|
|
15666
|
+
setMutationSyncHandler(handler) {
|
|
15667
|
+
this._mutationSyncHandler = handler;
|
|
15668
|
+
return toDisposable(() => {
|
|
15669
|
+
if (this._mutationSyncHandler === handler) this._mutationSyncHandler = void 0;
|
|
15670
|
+
});
|
|
15284
15671
|
}
|
|
15285
15672
|
_initFormulaCalculationResultChange() {
|
|
15286
15673
|
this.disposeWithMe(this._commandService.onCommandExecuted((commandInfo) => {
|
|
@@ -15352,11 +15739,13 @@ let RegisterOtherFormulaService = class RegisterOtherFormulaService extends Disp
|
|
|
15352
15739
|
return Object.fromEntries(Array.from(unitMap.entries(), ([subUnitId, formulas]) => [subUnitId, Object.fromEntries(Array.from(formulas.keys(), (formulaId) => [formulaId, true]))]));
|
|
15353
15740
|
}
|
|
15354
15741
|
deleteFormula(unitId, subUnitId, formulaIdList) {
|
|
15742
|
+
var _this$_mutationSyncHa2;
|
|
15355
15743
|
const params = {
|
|
15356
15744
|
unitId,
|
|
15357
15745
|
subUnitId,
|
|
15358
15746
|
formulaIdList
|
|
15359
15747
|
};
|
|
15748
|
+
(_this$_mutationSyncHa2 = this._mutationSyncHandler) === null || _this$_mutationSyncHa2 === void 0 || _this$_mutationSyncHa2.call(this, unitId);
|
|
15360
15749
|
this._commandService.executeCommand(RemoveOtherFormulaMutation.id, params, { onlyLocal: true });
|
|
15361
15750
|
const cacheMap = this._ensureCacheMap(unitId, subUnitId);
|
|
15362
15751
|
formulaIdList.forEach((id) => cacheMap.delete(id));
|
|
@@ -15609,8 +15998,7 @@ function refactorReferenceSegment(segment, oldName, newName) {
|
|
|
15609
15998
|
const escapedName = newName.replace(/'/g, "''");
|
|
15610
15999
|
return quote ? `'[${escapedName}]${sheetName}'!` : `[${newName}]${sheetName}!`;
|
|
15611
16000
|
}).replace(TABLE_UNIT_QUALIFIER, (token, boundary, quoted, bracketed, plain) => {
|
|
15612
|
-
|
|
15613
|
-
if (!equalsQualifier((_ref = (_ref2 = quoted !== null && quoted !== void 0 ? quoted : bracketed) !== null && _ref2 !== void 0 ? _ref2 : plain) !== null && _ref !== void 0 ? _ref : "", oldName)) return token;
|
|
16001
|
+
if (!equalsQualifier(quoted ?? bracketed ?? plain ?? "", oldName)) return token;
|
|
15614
16002
|
if (quoted != null) return `${boundary}'${newName.replace(/'/g, "''")}'!`;
|
|
15615
16003
|
if (bracketed != null) return `${boundary}[${newName}]!`;
|
|
15616
16004
|
return `${boundary}${quoteQualifier(newName)}!`;
|
|
@@ -15668,11 +16056,10 @@ function shouldAppendOpenBracket(functionType) {
|
|
|
15668
16056
|
return functionType !== 16 && functionType !== 17;
|
|
15669
16057
|
}
|
|
15670
16058
|
function getFormulaReplaceResult(nodes, index, formulaName, functionType) {
|
|
15671
|
-
var _cloneNodes$pop;
|
|
15672
16059
|
if (index === -1) return;
|
|
15673
16060
|
const cloneNodes = [...nodes];
|
|
15674
16061
|
const lastNodes = cloneNodes.splice(index + 1);
|
|
15675
|
-
const oldNode =
|
|
16062
|
+
const oldNode = cloneNodes.pop() ?? "";
|
|
15676
16063
|
let offset = (typeof oldNode === "string" ? oldNode.length : oldNode.token.length) - formulaName.length;
|
|
15677
16064
|
cloneNodes.push(formulaName);
|
|
15678
16065
|
if (lastNodes[0] !== "(" && shouldAppendOpenBracket(functionType)) {
|
|
@@ -15734,12 +16121,11 @@ function isFormulaReferenceAddingTextContext(formulaText, offset) {
|
|
|
15734
16121
|
return Boolean(character && matchRefDrawToken(character) && (!nextCharacter || isFormulaLexerToken(nextCharacter) && nextCharacter !== "("));
|
|
15735
16122
|
}
|
|
15736
16123
|
function resolveFormulaReferenceEditingContext(options) {
|
|
15737
|
-
var _options$selectionSta, _options$selectionEnd;
|
|
15738
16124
|
const { formulaText, sequenceNodes } = options;
|
|
15739
16125
|
const offset = Math.max(0, Math.min(options.offset, formulaText.length));
|
|
15740
16126
|
let nodeIndex = getFormulaSequenceNodeIndex(sequenceNodes, offset);
|
|
15741
|
-
const selectionStart =
|
|
15742
|
-
const selectionEnd =
|
|
16127
|
+
const selectionStart = options.selectionStart ?? offset;
|
|
16128
|
+
const selectionEnd = options.selectionEnd ?? selectionStart;
|
|
15743
16129
|
if (selectionEnd > selectionStart) nodeIndex = sequenceNodes.findIndex((node) => typeof node !== "string" && isFormulaReferenceNode(node) && node.startIndex < selectionEnd && node.endIndex + 1 > selectionStart);
|
|
15744
16130
|
const referenceIndex = getFormulaReferenceIndex(sequenceNodes, nodeIndex);
|
|
15745
16131
|
if (referenceIndex !== -1) return {
|
|
@@ -15756,7 +16142,7 @@ function resolveFormulaReferenceEditingContext(options) {
|
|
|
15756
16142
|
};
|
|
15757
16143
|
}
|
|
15758
16144
|
function getFormulaHighlightDataStream(leadingCharacter, sequenceNodes, sourceText) {
|
|
15759
|
-
return `${leadingCharacter}${sourceText
|
|
16145
|
+
return `${leadingCharacter}${sourceText ?? sequenceNodes.map((node) => typeof node === "string" ? node : node.token).join("")}\r\n`;
|
|
15760
16146
|
}
|
|
15761
16147
|
function buildFormulaTextRuns(descriptionService, colors, sequenceNodes, options) {
|
|
15762
16148
|
const textRuns = [];
|
|
@@ -15766,16 +16152,15 @@ function buildFormulaTextRuns(descriptionService, colors, sequenceNodes, options
|
|
|
15766
16152
|
for (let index = 0; index < sequenceNodes.length; index++) {
|
|
15767
16153
|
const node = sequenceNodes[index];
|
|
15768
16154
|
if (typeof node === "string") {
|
|
15769
|
-
var _textRuns
|
|
15770
|
-
const start = (
|
|
16155
|
+
var _textRuns;
|
|
16156
|
+
const start = ((_textRuns = textRuns[textRuns.length - 1]) === null || _textRuns === void 0 ? void 0 : _textRuns.ed) ?? 0;
|
|
15771
16157
|
textRuns.push(createTextRun(start, start + node.length, colors.plainTextColor));
|
|
15772
16158
|
continue;
|
|
15773
16159
|
}
|
|
15774
16160
|
let color = colors.plainTextColor;
|
|
15775
16161
|
if (!descriptionService.hasDefinedNameDescription(node.token.trim())) {
|
|
15776
16162
|
if (isFormulaReferenceNode(node)) {
|
|
15777
|
-
|
|
15778
|
-
color = (_referenceColors$get = referenceColors.get(node.token)) !== null && _referenceColors$get !== void 0 ? _referenceColors$get : colors.formulaRefColors[refColorIndex % colors.formulaRefColors.length];
|
|
16163
|
+
color = referenceColors.get(node.token) ?? colors.formulaRefColors[refColorIndex % colors.formulaRefColors.length];
|
|
15779
16164
|
if (!referenceColors.has(node.token)) {
|
|
15780
16165
|
referenceColors.set(node.token, color);
|
|
15781
16166
|
refColorIndex += 1;
|
|
@@ -15827,13 +16212,13 @@ function applyTextRunColor(textRuns, start, end, color) {
|
|
|
15827
16212
|
continue;
|
|
15828
16213
|
}
|
|
15829
16214
|
if (run.st < start) {
|
|
15830
|
-
var _run$ts
|
|
15831
|
-
nextRuns.push(createTextRun(run.st, start, (
|
|
16215
|
+
var _run$ts;
|
|
16216
|
+
nextRuns.push(createTextRun(run.st, start, ((_run$ts = run.ts) === null || _run$ts === void 0 || (_run$ts = _run$ts.cl) === null || _run$ts === void 0 ? void 0 : _run$ts.rgb) ?? color));
|
|
15832
16217
|
}
|
|
15833
16218
|
nextRuns.push(createTextRun(Math.max(run.st, start), Math.min(run.ed, end), color));
|
|
15834
16219
|
if (run.ed > end) {
|
|
15835
|
-
var _run$
|
|
15836
|
-
nextRuns.push(createTextRun(end, run.ed, (
|
|
16220
|
+
var _run$ts2;
|
|
16221
|
+
nextRuns.push(createTextRun(end, run.ed, ((_run$ts2 = run.ts) === null || _run$ts2 === void 0 || (_run$ts2 = _run$ts2.cl) === null || _run$ts2 === void 0 ? void 0 : _run$ts2.rgb) ?? color));
|
|
15837
16222
|
}
|
|
15838
16223
|
}
|
|
15839
16224
|
textRuns.splice(0, textRuns.length, ...nextRuns);
|
|
@@ -16029,6 +16414,14 @@ var BaseFunction = class {
|
|
|
16029
16414
|
"needsAstChildren",
|
|
16030
16415
|
false
|
|
16031
16416
|
);
|
|
16417
|
+
_defineProperty(
|
|
16418
|
+
this,
|
|
16419
|
+
/**
|
|
16420
|
+
* Arguments that preserve a selected lazy IF branch as a reference array.
|
|
16421
|
+
*/
|
|
16422
|
+
"lazyIfReferenceArrayArgumentIndexes",
|
|
16423
|
+
[]
|
|
16424
|
+
);
|
|
16032
16425
|
_defineProperty(
|
|
16033
16426
|
this,
|
|
16034
16427
|
/**
|
|
@@ -16241,8 +16634,8 @@ var BaseFunction = class {
|
|
|
16241
16634
|
if (isFirst) return this._getOneFirstByRaw(resultArrayValue);
|
|
16242
16635
|
return this._getOneLastByRaw(resultArrayValue);
|
|
16243
16636
|
}
|
|
16244
|
-
orderSearch(value, searchArray, resultArray, searchType = 1, isDesc = false) {
|
|
16245
|
-
const position = searchArray.orderSearch(value, searchType, isDesc);
|
|
16637
|
+
orderSearch(value, searchArray, resultArray, searchType = 1, isDesc = false, keepFirstNearest = false) {
|
|
16638
|
+
const position = searchArray.orderSearch(value, searchType, isDesc, false, keepFirstNearest);
|
|
16246
16639
|
if (position == null) return ErrorValueObject.create("#N/A");
|
|
16247
16640
|
const resultValue = resultArray.get(position.row, position.column) || NullValueObject.create();
|
|
16248
16641
|
if (resultValue.isNull()) return ErrorValueObject.create("#N/A");
|
|
@@ -16272,8 +16665,8 @@ var BaseFunction = class {
|
|
|
16272
16665
|
if (axis === 0) return resultArray.slice([position.row, position.row + 1]);
|
|
16273
16666
|
return resultArray.slice(void 0, [position.column, position.column + 1]);
|
|
16274
16667
|
}
|
|
16275
|
-
orderSearchExpand(value, searchArray, resultArray, searchType = 1, isDesc = false, axis = 0) {
|
|
16276
|
-
const position = searchArray.orderSearch(value, searchType, isDesc);
|
|
16668
|
+
orderSearchExpand(value, searchArray, resultArray, searchType = 1, isDesc = false, axis = 0, keepFirstNearest = false) {
|
|
16669
|
+
const position = searchArray.orderSearch(value, searchType, isDesc, false, keepFirstNearest);
|
|
16277
16670
|
if (position == null) return ErrorValueObject.create("#N/A");
|
|
16278
16671
|
if (axis === 0) return resultArray.slice([position.row, position.row + 1]);
|
|
16279
16672
|
return resultArray.slice(void 0, [position.column, position.column + 1]);
|
|
@@ -18212,7 +18605,7 @@ function getAggregateResult(options, refs) {
|
|
|
18212
18605
|
return result;
|
|
18213
18606
|
}
|
|
18214
18607
|
function getArrayValuesByAggregateIgnoreOptions(array, options, formulaDataModel) {
|
|
18215
|
-
const { ignoreRowHidden = false, ignoreErrorValues = false, ignoreNested = false } = options
|
|
18608
|
+
const { ignoreRowHidden = false, ignoreErrorValues = false, ignoreNested = false } = options ?? {};
|
|
18216
18609
|
const values = [];
|
|
18217
18610
|
if (array.isReferenceObject()) {
|
|
18218
18611
|
var _unitData$unitId2;
|
|
@@ -18338,8 +18731,8 @@ var BetaInv = class extends BaseFunction {
|
|
|
18338
18731
|
_defineProperty(this, "maxParams", 5);
|
|
18339
18732
|
}
|
|
18340
18733
|
calculate(probability, alpha, beta, A, B) {
|
|
18341
|
-
let _A = A
|
|
18342
|
-
let _B = B
|
|
18734
|
+
let _A = A ?? NumberValueObject.create(0);
|
|
18735
|
+
let _B = B ?? NumberValueObject.create(1);
|
|
18343
18736
|
if (_A.isNull()) _A = NumberValueObject.create(0);
|
|
18344
18737
|
if (_B.isNull()) _B = NumberValueObject.create(1);
|
|
18345
18738
|
const maxRowLength = Math.max(probability.isArray() ? probability.getRowCount() : 1, alpha.isArray() ? alpha.getRowCount() : 1, beta.isArray() ? beta.getRowCount() : 1, _A.isArray() ? _A.getRowCount() : 1, _B.isArray() ? _B.getRowCount() : 1);
|
|
@@ -19142,6 +19535,7 @@ var PercentileInc = class extends BaseFunction {
|
|
|
19142
19535
|
super(..._args);
|
|
19143
19536
|
_defineProperty(this, "minParams", 2);
|
|
19144
19537
|
_defineProperty(this, "maxParams", 2);
|
|
19538
|
+
_defineProperty(this, "lazyIfReferenceArrayArgumentIndexes", [0]);
|
|
19145
19539
|
}
|
|
19146
19540
|
calculate(array, k) {
|
|
19147
19541
|
const arrayValues = getArrayValuesByAggregateIgnoreOptions(array);
|
|
@@ -19171,7 +19565,7 @@ var PercentrankInc = class extends BaseFunction {
|
|
|
19171
19565
|
}
|
|
19172
19566
|
calculate(array, x, significance) {
|
|
19173
19567
|
const arrayValues = this._getValues(array);
|
|
19174
|
-
let _significance = significance
|
|
19568
|
+
let _significance = significance ?? NumberValueObject.create(3);
|
|
19175
19569
|
if (_significance.isNull()) _significance = NumberValueObject.create(3);
|
|
19176
19570
|
const maxRowLength = Math.max(x.isArray() ? x.getRowCount() : 1, _significance.isArray() ? _significance.getRowCount() : 1);
|
|
19177
19571
|
const maxColumnLength = Math.max(x.isArray() ? x.getColumnCount() : 1, _significance.isArray() ? _significance.getColumnCount() : 1);
|
|
@@ -19733,8 +20127,8 @@ var Betadist = class extends BaseFunction {
|
|
|
19733
20127
|
_defineProperty(this, "maxParams", 5);
|
|
19734
20128
|
}
|
|
19735
20129
|
calculate(x, alpha, beta, A, B) {
|
|
19736
|
-
let _A = A
|
|
19737
|
-
let _B = B
|
|
20130
|
+
let _A = A ?? NumberValueObject.create(0);
|
|
20131
|
+
let _B = B ?? NumberValueObject.create(1);
|
|
19738
20132
|
if (_A.isNull()) _A = NumberValueObject.create(0);
|
|
19739
20133
|
if (_B.isNull()) _B = NumberValueObject.create(1);
|
|
19740
20134
|
const maxRowLength = Math.max(x.isArray() ? x.getRowCount() : 1, alpha.isArray() ? alpha.getRowCount() : 1, beta.isArray() ? beta.getRowCount() : 1, _A.isArray() ? _A.getRowCount() : 1, _B.isArray() ? _B.getRowCount() : 1);
|
|
@@ -19990,12 +20384,13 @@ var Rank = class extends BaseFunction {
|
|
|
19990
20384
|
_defineProperty(this, "minParams", 2);
|
|
19991
20385
|
_defineProperty(this, "maxParams", 3);
|
|
19992
20386
|
_defineProperty(this, "needsReferenceObject", true);
|
|
20387
|
+
_defineProperty(this, "lazyIfReferenceArrayArgumentIndexes", [1]);
|
|
19993
20388
|
}
|
|
19994
20389
|
calculate(number, ref, order) {
|
|
19995
20390
|
let _number = number;
|
|
19996
20391
|
if (_number.isReferenceObject()) _number = _number.toArrayValueObject();
|
|
19997
20392
|
const { refHasError, refErrorObject, refNumbers } = this._checkRefReferenceObject(ref);
|
|
19998
|
-
let _order = order
|
|
20393
|
+
let _order = order ?? NumberValueObject.create(0);
|
|
19999
20394
|
if (_order.isReferenceObject()) _order = _order.toArrayValueObject();
|
|
20000
20395
|
const maxRowLength = Math.max(_number.isArray() ? _number.getRowCount() : 1, _order.isArray() ? _order.getRowCount() : 1);
|
|
20001
20396
|
const maxColumnLength = Math.max(_number.isArray() ? _number.getColumnCount() : 1, _order.isArray() ? _order.getColumnCount() : 1);
|
|
@@ -21032,7 +21427,7 @@ var Days360 = class extends BaseFunction {
|
|
|
21032
21427
|
_defineProperty(this, "maxParams", 3);
|
|
21033
21428
|
}
|
|
21034
21429
|
calculate(startDate, endDate, method) {
|
|
21035
|
-
const _method = method
|
|
21430
|
+
const _method = method ?? BooleanValueObject.create(false);
|
|
21036
21431
|
if (startDate.isError()) return startDate;
|
|
21037
21432
|
if (endDate.isError()) return endDate;
|
|
21038
21433
|
if (_method.isError()) return _method;
|
|
@@ -21146,7 +21541,7 @@ var Epochtodate = class extends BaseFunction {
|
|
|
21146
21541
|
_defineProperty(this, "needsReferenceObject", true);
|
|
21147
21542
|
}
|
|
21148
21543
|
calculate(timestamp, unit) {
|
|
21149
|
-
const _unit = unit
|
|
21544
|
+
const _unit = unit ?? NumberValueObject.create(1);
|
|
21150
21545
|
const { isError, errorObject, timestampIsReferenceObject, timestampObject, unitObject } = this._checkVariants(timestamp, _unit);
|
|
21151
21546
|
if (isError) return errorObject;
|
|
21152
21547
|
if (timestampObject.isNull() || timestampObject.isBoolean() || timestampObject.isString()) return ErrorValueObject.create("#VALUE!");
|
|
@@ -21653,7 +22048,7 @@ var Today = class extends BaseFunction {
|
|
|
21653
22048
|
}
|
|
21654
22049
|
calculate() {
|
|
21655
22050
|
const now = /* @__PURE__ */ new Date();
|
|
21656
|
-
const currentSerial = excelDateSerial(new Date(Date.UTC(now.
|
|
22051
|
+
const currentSerial = excelDateSerial(new Date(Date.UTC(now.getFullYear(), now.getMonth(), now.getDate())));
|
|
21657
22052
|
return NumberValueObject.create(currentSerial, DEFAULT_DATE_FORMAT);
|
|
21658
22053
|
}
|
|
21659
22054
|
};
|
|
@@ -21759,7 +22154,7 @@ var Weekday = class extends BaseFunction {
|
|
|
21759
22154
|
});
|
|
21760
22155
|
}
|
|
21761
22156
|
calculate(serialNumber, returnType) {
|
|
21762
|
-
const _returnType = returnType
|
|
22157
|
+
const _returnType = returnType ?? NumberValueObject.create(1);
|
|
21763
22158
|
if (serialNumber.isError()) return serialNumber;
|
|
21764
22159
|
if (_returnType.isError()) return _returnType;
|
|
21765
22160
|
const maxRowLength = Math.max(serialNumber.isArray() ? serialNumber.getRowCount() : 1, _returnType.isArray() ? _returnType.getRowCount() : 1);
|
|
@@ -21813,7 +22208,7 @@ var Weeknum = class extends BaseFunction {
|
|
|
21813
22208
|
}
|
|
21814
22209
|
calculate(serialNumber, returnType) {
|
|
21815
22210
|
let _serialNumber = serialNumber;
|
|
21816
|
-
let _returnType = returnType
|
|
22211
|
+
let _returnType = returnType ?? NumberValueObject.create(1);
|
|
21817
22212
|
if (_serialNumber.isArray()) {
|
|
21818
22213
|
const rowCount = _serialNumber.getRowCount();
|
|
21819
22214
|
const columnCount = _serialNumber.getColumnCount();
|
|
@@ -21947,7 +22342,7 @@ var WorkdayIntl = class extends BaseFunction {
|
|
|
21947
22342
|
return this._handleSingleObject(startDate, days, weekend, holidays);
|
|
21948
22343
|
}
|
|
21949
22344
|
_handleSingleObject(startDate, days, weekend, holidays) {
|
|
21950
|
-
const _weekend = weekend
|
|
22345
|
+
const _weekend = weekend ?? NumberValueObject.create(1);
|
|
21951
22346
|
const _startDate = this._checkArrayError(startDate);
|
|
21952
22347
|
if (_startDate.isError()) return _startDate;
|
|
21953
22348
|
const _days = this._checkArrayError(days);
|
|
@@ -22044,7 +22439,7 @@ var Yearfrac = class extends BaseFunction {
|
|
|
22044
22439
|
_defineProperty(this, "maxParams", 3);
|
|
22045
22440
|
}
|
|
22046
22441
|
calculate(startDate, endDate, basis) {
|
|
22047
|
-
let _basis = basis
|
|
22442
|
+
let _basis = basis ?? NumberValueObject.create(0);
|
|
22048
22443
|
const _startDate = checkVariantErrorIsArray(startDate);
|
|
22049
22444
|
if (_startDate.isError()) return _startDate;
|
|
22050
22445
|
const _endDate = checkVariantErrorIsArray(endDate);
|
|
@@ -22889,7 +23284,7 @@ var Complex = class extends BaseFunction {
|
|
|
22889
23284
|
_defineProperty(this, "maxParams", 3);
|
|
22890
23285
|
}
|
|
22891
23286
|
calculate(realNum, iNum, suffix) {
|
|
22892
|
-
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(realNum, iNum, suffix
|
|
23287
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(realNum, iNum, suffix ?? StringValueObject.create("i"));
|
|
22893
23288
|
if (isError) return errorObject;
|
|
22894
23289
|
const [realNumObject, iNumObject, suffixObject] = variants;
|
|
22895
23290
|
const realNumValue = +realNumObject.getValue();
|
|
@@ -24689,7 +25084,7 @@ var Delta = class extends BaseFunction {
|
|
|
24689
25084
|
_defineProperty(this, "maxParams", 2);
|
|
24690
25085
|
}
|
|
24691
25086
|
calculate(number1, number2) {
|
|
24692
|
-
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(number1, number2
|
|
25087
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(number1, number2 ?? NumberValueObject.create(0));
|
|
24693
25088
|
if (isError) return errorObject;
|
|
24694
25089
|
const [number1Object, number2Object] = variants;
|
|
24695
25090
|
const number1Value = +number1Object.getValue();
|
|
@@ -24797,7 +25192,7 @@ var Gestep = class extends BaseFunction {
|
|
|
24797
25192
|
}
|
|
24798
25193
|
calculate(number, step) {
|
|
24799
25194
|
if (number.isNull()) return ErrorValueObject.create("#N/A");
|
|
24800
|
-
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(number, step
|
|
25195
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(number, step ?? NumberValueObject.create(0));
|
|
24801
25196
|
if (isError) return errorObject;
|
|
24802
25197
|
const [numberObject, stepObject] = variants;
|
|
24803
25198
|
const numberValue = +numberObject.getValue();
|
|
@@ -25193,7 +25588,7 @@ var Imlog = class extends BaseFunction {
|
|
|
25193
25588
|
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(inumber);
|
|
25194
25589
|
if (isError) return errorObject;
|
|
25195
25590
|
const [inumberObject] = variants;
|
|
25196
|
-
let _base = base
|
|
25591
|
+
let _base = base ?? NumberValueObject.create(10);
|
|
25197
25592
|
if (_base.isArray()) {
|
|
25198
25593
|
const rowCount = _base.getRowCount();
|
|
25199
25594
|
const columnCount = _base.getColumnCount();
|
|
@@ -26056,8 +26451,8 @@ var Accrint = class extends BaseFunction {
|
|
|
26056
26451
|
_defineProperty(this, "maxParams", 8);
|
|
26057
26452
|
}
|
|
26058
26453
|
calculate(issue, firstInterest, settlement, rate, par, frequency, basis, calcMethod) {
|
|
26059
|
-
const _basis = basis
|
|
26060
|
-
const _calcMethod = calcMethod
|
|
26454
|
+
const _basis = basis ?? NumberValueObject.create(0);
|
|
26455
|
+
const _calcMethod = calcMethod ?? BooleanValueObject.create(true);
|
|
26061
26456
|
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(issue, firstInterest, settlement, rate, par, frequency, _basis);
|
|
26062
26457
|
if (isError) return errorObject;
|
|
26063
26458
|
const [issueObject, firstInterestObject, settlementObject, rateObject, parObject, frequencyObject, basisObject] = variants;
|
|
@@ -26136,7 +26531,7 @@ var Accrintm = class extends BaseFunction {
|
|
|
26136
26531
|
_defineProperty(this, "maxParams", 5);
|
|
26137
26532
|
}
|
|
26138
26533
|
calculate(issue, settlement, rate, par, basis) {
|
|
26139
|
-
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(issue, settlement, rate, par, basis
|
|
26534
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(issue, settlement, rate, par, basis ?? NumberValueObject.create(0));
|
|
26140
26535
|
if (isError) return errorObject;
|
|
26141
26536
|
const [issueObject, settlementObject, rateObject, parObject, basisObject] = variants;
|
|
26142
26537
|
const issueSerialNumber = getDateSerialNumberByObject(issueObject);
|
|
@@ -26164,7 +26559,7 @@ var Amorlinc = class extends BaseFunction {
|
|
|
26164
26559
|
_defineProperty(this, "maxParams", 7);
|
|
26165
26560
|
}
|
|
26166
26561
|
calculate(cost, datePurchased, firstPeriod, salvage, period, rate, basis) {
|
|
26167
|
-
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(cost, datePurchased, firstPeriod, salvage, period, rate, basis
|
|
26562
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(cost, datePurchased, firstPeriod, salvage, period, rate, basis ?? NumberValueObject.create(0));
|
|
26168
26563
|
if (isError) return errorObject;
|
|
26169
26564
|
const [costObject, datePurchasedObject, firstPeriodObject, salvageObject, periodObject, rateObject, basisObject] = variants;
|
|
26170
26565
|
const datePurchasedSerialNumber = getDateSerialNumberByObject(datePurchasedObject);
|
|
@@ -26211,7 +26606,7 @@ var Coupdaybs = class extends BaseFunction {
|
|
|
26211
26606
|
_defineProperty(this, "maxParams", 4);
|
|
26212
26607
|
}
|
|
26213
26608
|
calculate(settlement, maturity, frequency, basis) {
|
|
26214
|
-
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(settlement, maturity, frequency, basis
|
|
26609
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(settlement, maturity, frequency, basis ?? NumberValueObject.create(0));
|
|
26215
26610
|
if (isError) return errorObject;
|
|
26216
26611
|
const [settlementObject, maturityObject, frequencyObject, basisObject] = variants;
|
|
26217
26612
|
const settlementSerialNumber = getDateSerialNumberByObject(settlementObject);
|
|
@@ -26240,7 +26635,7 @@ var Coupdays = class extends BaseFunction {
|
|
|
26240
26635
|
_defineProperty(this, "maxParams", 4);
|
|
26241
26636
|
}
|
|
26242
26637
|
calculate(settlement, maturity, frequency, basis) {
|
|
26243
|
-
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(settlement, maturity, frequency, basis
|
|
26638
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(settlement, maturity, frequency, basis ?? NumberValueObject.create(0));
|
|
26244
26639
|
if (isError) return errorObject;
|
|
26245
26640
|
const [settlementObject, maturityObject, frequencyObject, basisObject] = variants;
|
|
26246
26641
|
const settlementSerialNumber = getDateSerialNumberByObject(settlementObject);
|
|
@@ -26269,7 +26664,7 @@ var Coupdaysnc = class extends BaseFunction {
|
|
|
26269
26664
|
_defineProperty(this, "maxParams", 4);
|
|
26270
26665
|
}
|
|
26271
26666
|
calculate(settlement, maturity, frequency, basis) {
|
|
26272
|
-
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(settlement, maturity, frequency, basis
|
|
26667
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(settlement, maturity, frequency, basis ?? NumberValueObject.create(0));
|
|
26273
26668
|
if (isError) return errorObject;
|
|
26274
26669
|
const [settlementObject, maturityObject, frequencyObject, basisObject] = variants;
|
|
26275
26670
|
const settlementSerialNumber = getDateSerialNumberByObject(settlementObject);
|
|
@@ -26304,7 +26699,7 @@ var Coupncd = class extends BaseFunction {
|
|
|
26304
26699
|
_defineProperty(this, "maxParams", 4);
|
|
26305
26700
|
}
|
|
26306
26701
|
calculate(settlement, maturity, frequency, basis) {
|
|
26307
|
-
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(settlement, maturity, frequency, basis
|
|
26702
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(settlement, maturity, frequency, basis ?? NumberValueObject.create(0));
|
|
26308
26703
|
if (isError) return errorObject;
|
|
26309
26704
|
const [settlementObject, maturityObject, frequencyObject, basisObject] = variants;
|
|
26310
26705
|
const settlementSerialNumber = getDateSerialNumberByObject(settlementObject);
|
|
@@ -26333,7 +26728,7 @@ var Coupnum = class extends BaseFunction {
|
|
|
26333
26728
|
_defineProperty(this, "maxParams", 4);
|
|
26334
26729
|
}
|
|
26335
26730
|
calculate(settlement, maturity, frequency, basis) {
|
|
26336
|
-
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(settlement, maturity, frequency, basis
|
|
26731
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(settlement, maturity, frequency, basis ?? NumberValueObject.create(0));
|
|
26337
26732
|
if (isError) return errorObject;
|
|
26338
26733
|
const [settlementObject, maturityObject, frequencyObject, basisObject] = variants;
|
|
26339
26734
|
const settlementSerialNumber = getDateSerialNumberByObject(settlementObject);
|
|
@@ -26363,7 +26758,7 @@ var Couppcd = class extends BaseFunction {
|
|
|
26363
26758
|
_defineProperty(this, "maxParams", 4);
|
|
26364
26759
|
}
|
|
26365
26760
|
calculate(settlement, maturity, frequency, basis) {
|
|
26366
|
-
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(settlement, maturity, frequency, basis
|
|
26761
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(settlement, maturity, frequency, basis ?? NumberValueObject.create(0));
|
|
26367
26762
|
if (isError) return errorObject;
|
|
26368
26763
|
const [settlementObject, maturityObject, frequencyObject, basisObject] = variants;
|
|
26369
26764
|
const settlementSerialNumber = getDateSerialNumberByObject(settlementObject);
|
|
@@ -26476,7 +26871,7 @@ var Db = class extends BaseFunction {
|
|
|
26476
26871
|
_defineProperty(this, "needsLocale", true);
|
|
26477
26872
|
}
|
|
26478
26873
|
calculate(cost, salvage, life, period, month) {
|
|
26479
|
-
let _month = month
|
|
26874
|
+
let _month = month ?? NumberValueObject.create(12);
|
|
26480
26875
|
if (_month.isNull()) _month = NumberValueObject.create(12);
|
|
26481
26876
|
const maxRowLength = Math.max(cost.isArray() ? cost.getRowCount() : 1, salvage.isArray() ? salvage.getRowCount() : 1, life.isArray() ? life.getRowCount() : 1, period.isArray() ? period.getRowCount() : 1, _month.isArray() ? _month.getRowCount() : 1);
|
|
26482
26877
|
const maxColumnLength = Math.max(cost.isArray() ? cost.getColumnCount() : 1, salvage.isArray() ? salvage.getColumnCount() : 1, life.isArray() ? life.getColumnCount() : 1, period.isArray() ? period.getColumnCount() : 1, _month.isArray() ? _month.getColumnCount() : 1);
|
|
@@ -26532,7 +26927,7 @@ var Ddb = class extends BaseFunction {
|
|
|
26532
26927
|
_defineProperty(this, "needsLocale", true);
|
|
26533
26928
|
}
|
|
26534
26929
|
calculate(cost, salvage, life, period, factor) {
|
|
26535
|
-
let _factor = factor
|
|
26930
|
+
let _factor = factor ?? NumberValueObject.create(2);
|
|
26536
26931
|
if (_factor.isNull()) _factor = NumberValueObject.create(2);
|
|
26537
26932
|
const maxRowLength = Math.max(cost.isArray() ? cost.getRowCount() : 1, salvage.isArray() ? salvage.getRowCount() : 1, life.isArray() ? life.getRowCount() : 1, period.isArray() ? period.getRowCount() : 1, _factor.isArray() ? _factor.getRowCount() : 1);
|
|
26538
26933
|
const maxColumnLength = Math.max(cost.isArray() ? cost.getColumnCount() : 1, salvage.isArray() ? salvage.getColumnCount() : 1, life.isArray() ? life.getColumnCount() : 1, period.isArray() ? period.getColumnCount() : 1, _factor.isArray() ? _factor.getColumnCount() : 1);
|
|
@@ -26570,7 +26965,7 @@ var Disc = class extends BaseFunction {
|
|
|
26570
26965
|
_defineProperty(this, "maxParams", 5);
|
|
26571
26966
|
}
|
|
26572
26967
|
calculate(settlement, maturity, pr, redemption, basis) {
|
|
26573
|
-
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(settlement, maturity, pr, redemption, basis
|
|
26968
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(settlement, maturity, pr, redemption, basis ?? NumberValueObject.create(0));
|
|
26574
26969
|
if (isError) return errorObject;
|
|
26575
26970
|
const [settlementObject, maturityObject, prObject, redemptionObject, basisObject] = variants;
|
|
26576
26971
|
const settlementSerialNumber = getDateSerialNumberByObject(settlementObject);
|
|
@@ -26647,7 +27042,7 @@ var Duration = class extends BaseFunction {
|
|
|
26647
27042
|
_defineProperty(this, "maxParams", 6);
|
|
26648
27043
|
}
|
|
26649
27044
|
calculate(settlement, maturity, coupon, yld, frequency, basis) {
|
|
26650
|
-
let _basis = basis
|
|
27045
|
+
let _basis = basis ?? NumberValueObject.create(0);
|
|
26651
27046
|
if (_basis.isNull()) _basis = NumberValueObject.create(0);
|
|
26652
27047
|
const { isError, errorObject, variants } = checkVariantsErrorIsNullorArrayOrBoolean(settlement, maturity, coupon, yld, frequency, _basis);
|
|
26653
27048
|
if (isError) return errorObject;
|
|
@@ -26704,8 +27099,8 @@ var Fv = class extends BaseFunction {
|
|
|
26704
27099
|
_defineProperty(this, "needsLocale", true);
|
|
26705
27100
|
}
|
|
26706
27101
|
calculate(rate, nper, pmt, pv, type) {
|
|
26707
|
-
const _pv = pv
|
|
26708
|
-
const _type = type
|
|
27102
|
+
const _pv = pv ?? NumberValueObject.create(0);
|
|
27103
|
+
const _type = type ?? NumberValueObject.create(0);
|
|
26709
27104
|
const maxRowLength = Math.max(rate.isArray() ? rate.getRowCount() : 1, nper.isArray() ? nper.getRowCount() : 1, pmt.isArray() ? pmt.getRowCount() : 1, _pv.isArray() ? _pv.getRowCount() : 1, _type.isArray() ? _type.getRowCount() : 1);
|
|
26710
27105
|
const maxColumnLength = Math.max(rate.isArray() ? rate.getColumnCount() : 1, nper.isArray() ? nper.getColumnCount() : 1, pmt.isArray() ? pmt.getColumnCount() : 1, _pv.isArray() ? _pv.getColumnCount() : 1, _type.isArray() ? _type.getColumnCount() : 1);
|
|
26711
27106
|
const rateArray = expandArrayValueObject(maxRowLength, maxColumnLength, rate, ErrorValueObject.create("#N/A"));
|
|
@@ -26770,7 +27165,7 @@ var Intrate = class extends BaseFunction {
|
|
|
26770
27165
|
_defineProperty(this, "maxParams", 5);
|
|
26771
27166
|
}
|
|
26772
27167
|
calculate(settlement, maturity, investment, redemption, basis) {
|
|
26773
|
-
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(settlement, maturity, investment, redemption, basis
|
|
27168
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(settlement, maturity, investment, redemption, basis ?? NumberValueObject.create(0));
|
|
26774
27169
|
if (isError) return errorObject;
|
|
26775
27170
|
const [settlementObject, maturityObject, investmentObject, redemptionObject, basisObject] = variants;
|
|
26776
27171
|
const settlementSerialNumber = getDateSerialNumberByObject(settlementObject);
|
|
@@ -26798,8 +27193,8 @@ var Ipmt = class extends BaseFunction {
|
|
|
26798
27193
|
_defineProperty(this, "needsLocale", true);
|
|
26799
27194
|
}
|
|
26800
27195
|
calculate(rate, per, nper, pv, fv, type) {
|
|
26801
|
-
const _fv = fv
|
|
26802
|
-
const _type = type
|
|
27196
|
+
const _fv = fv ?? NumberValueObject.create(0);
|
|
27197
|
+
const _type = type ?? NumberValueObject.create(0);
|
|
26803
27198
|
const maxRowLength = Math.max(rate.isArray() ? rate.getRowCount() : 1, per.isArray() ? per.getRowCount() : 1, nper.isArray() ? nper.getRowCount() : 1, pv.isArray() ? pv.getRowCount() : 1, _fv.isArray() ? _fv.getRowCount() : 1, _type.isArray() ? _type.getRowCount() : 1);
|
|
26804
27199
|
const maxColumnLength = Math.max(rate.isArray() ? rate.getColumnCount() : 1, per.isArray() ? per.getColumnCount() : 1, nper.isArray() ? nper.getColumnCount() : 1, pv.isArray() ? pv.getColumnCount() : 1, _fv.isArray() ? _fv.getColumnCount() : 1, _type.isArray() ? _type.getColumnCount() : 1);
|
|
26805
27200
|
const rateArray = expandArrayValueObject(maxRowLength, maxColumnLength, rate, ErrorValueObject.create("#N/A"));
|
|
@@ -26838,7 +27233,7 @@ var Irr = class extends BaseFunction {
|
|
|
26838
27233
|
_defineProperty(this, "maxParams", 2);
|
|
26839
27234
|
}
|
|
26840
27235
|
calculate(values, guess) {
|
|
26841
|
-
let _guess = guess
|
|
27236
|
+
let _guess = guess ?? NumberValueObject.create(.1);
|
|
26842
27237
|
if (_guess.isNull()) _guess = NumberValueObject.create(.1);
|
|
26843
27238
|
if (_guess.isArray()) return _guess.map((guessObject, rowIndex, columnIndex) => this._handleSingleObject(values, guessObject, rowIndex, columnIndex));
|
|
26844
27239
|
return this._handleSingleObject(values, _guess);
|
|
@@ -26937,7 +27332,7 @@ var Mduration = class extends BaseFunction {
|
|
|
26937
27332
|
_defineProperty(this, "maxParams", 6);
|
|
26938
27333
|
}
|
|
26939
27334
|
calculate(settlement, maturity, coupon, yld, frequency, basis) {
|
|
26940
|
-
let _basis = basis
|
|
27335
|
+
let _basis = basis ?? NumberValueObject.create(0);
|
|
26941
27336
|
if (_basis.isNull()) _basis = NumberValueObject.create(0);
|
|
26942
27337
|
const { isError, errorObject, variants } = checkVariantsErrorIsNullorArrayOrBoolean(settlement, maturity, coupon, yld, frequency, _basis);
|
|
26943
27338
|
if (isError) return errorObject;
|
|
@@ -27093,8 +27488,8 @@ var Nper = class extends BaseFunction {
|
|
|
27093
27488
|
_defineProperty(this, "maxParams", 5);
|
|
27094
27489
|
}
|
|
27095
27490
|
calculate(rate, pmt, pv, fv, type) {
|
|
27096
|
-
const _fv = fv
|
|
27097
|
-
const _type = type
|
|
27491
|
+
const _fv = fv ?? NumberValueObject.create(0);
|
|
27492
|
+
const _type = type ?? NumberValueObject.create(0);
|
|
27098
27493
|
const maxRowLength = Math.max(rate.isArray() ? rate.getRowCount() : 1, pmt.isArray() ? pmt.getRowCount() : 1, pv.isArray() ? pv.getRowCount() : 1, _fv.isArray() ? _fv.getRowCount() : 1, _type.isArray() ? _type.getRowCount() : 1);
|
|
27099
27494
|
const maxColumnLength = Math.max(rate.isArray() ? rate.getColumnCount() : 1, pmt.isArray() ? pmt.getColumnCount() : 1, pv.isArray() ? pv.getColumnCount() : 1, _fv.isArray() ? _fv.getColumnCount() : 1, _type.isArray() ? _type.getColumnCount() : 1);
|
|
27100
27495
|
const rateArray = expandArrayValueObject(maxRowLength, maxColumnLength, rate, ErrorValueObject.create("#N/A"));
|
|
@@ -27205,7 +27600,7 @@ var Oddfprice = class extends BaseFunction {
|
|
|
27205
27600
|
_defineProperty(this, "maxParams", 9);
|
|
27206
27601
|
}
|
|
27207
27602
|
calculate(settlement, maturity, issue, firstCoupon, rate, yld, redemption, frequency, basis) {
|
|
27208
|
-
let _basis = basis
|
|
27603
|
+
let _basis = basis ?? NumberValueObject.create(0);
|
|
27209
27604
|
if (_basis.isNull()) _basis = NumberValueObject.create(0);
|
|
27210
27605
|
const { isError, errorObject, variants } = checkVariantsErrorIsNullorArrayOrBoolean(settlement, maturity, issue, firstCoupon, rate, yld, redemption, frequency, _basis);
|
|
27211
27606
|
if (isError) return errorObject;
|
|
@@ -27249,7 +27644,7 @@ var Oddfyield = class extends BaseFunction {
|
|
|
27249
27644
|
_defineProperty(this, "maxParams", 9);
|
|
27250
27645
|
}
|
|
27251
27646
|
calculate(settlement, maturity, issue, firstCoupon, rate, pr, redemption, frequency, basis) {
|
|
27252
|
-
let _basis = basis
|
|
27647
|
+
let _basis = basis ?? NumberValueObject.create(0);
|
|
27253
27648
|
if (_basis.isNull()) _basis = NumberValueObject.create(0);
|
|
27254
27649
|
const { isError, errorObject, variants } = checkVariantsErrorIsNullorArrayOrBoolean(settlement, maturity, issue, firstCoupon, rate, pr, redemption, frequency, _basis);
|
|
27255
27650
|
if (isError) return errorObject;
|
|
@@ -27302,7 +27697,7 @@ var Oddlprice = class extends BaseFunction {
|
|
|
27302
27697
|
_defineProperty(this, "maxParams", 8);
|
|
27303
27698
|
}
|
|
27304
27699
|
calculate(settlement, maturity, lastInterest, rate, yld, redemption, frequency, basis) {
|
|
27305
|
-
let _basis = basis
|
|
27700
|
+
let _basis = basis ?? NumberValueObject.create(0);
|
|
27306
27701
|
if (_basis.isNull()) _basis = NumberValueObject.create(0);
|
|
27307
27702
|
const { isError, errorObject, variants } = checkVariantsErrorIsNullorArrayOrBoolean(settlement, maturity, lastInterest, rate, yld, redemption, frequency, _basis);
|
|
27308
27703
|
if (isError) return errorObject;
|
|
@@ -27387,7 +27782,7 @@ var Oddlyield = class extends BaseFunction {
|
|
|
27387
27782
|
_defineProperty(this, "maxParams", 9);
|
|
27388
27783
|
}
|
|
27389
27784
|
calculate(settlement, maturity, lastInterest, rate, pr, redemption, frequency, basis) {
|
|
27390
|
-
let _basis = basis
|
|
27785
|
+
let _basis = basis ?? NumberValueObject.create(0);
|
|
27391
27786
|
if (_basis.isNull()) _basis = NumberValueObject.create(0);
|
|
27392
27787
|
const { isError, errorObject, variants } = checkVariantsErrorIsNullorArrayOrBoolean(settlement, maturity, lastInterest, rate, pr, redemption, frequency, _basis);
|
|
27393
27788
|
if (isError) return errorObject;
|
|
@@ -27504,8 +27899,8 @@ var Pmt = class extends BaseFunction {
|
|
|
27504
27899
|
_defineProperty(this, "needsLocale", true);
|
|
27505
27900
|
}
|
|
27506
27901
|
calculate(rate, nper, pv, fv, type) {
|
|
27507
|
-
const _fv = fv
|
|
27508
|
-
const _type = type
|
|
27902
|
+
const _fv = fv ?? NumberValueObject.create(0);
|
|
27903
|
+
const _type = type ?? NumberValueObject.create(0);
|
|
27509
27904
|
const maxRowLength = Math.max(rate.isArray() ? rate.getRowCount() : 1, nper.isArray() ? nper.getRowCount() : 1, pv.isArray() ? pv.getRowCount() : 1, _fv.isArray() ? _fv.getRowCount() : 1, _type.isArray() ? _type.getRowCount() : 1);
|
|
27510
27905
|
const maxColumnLength = Math.max(rate.isArray() ? rate.getColumnCount() : 1, nper.isArray() ? nper.getColumnCount() : 1, pv.isArray() ? pv.getColumnCount() : 1, _fv.isArray() ? _fv.getColumnCount() : 1, _type.isArray() ? _type.getColumnCount() : 1);
|
|
27511
27906
|
const rateArray = expandArrayValueObject(maxRowLength, maxColumnLength, rate, ErrorValueObject.create("#N/A"));
|
|
@@ -27543,8 +27938,8 @@ var Ppmt = class extends BaseFunction {
|
|
|
27543
27938
|
_defineProperty(this, "needsLocale", true);
|
|
27544
27939
|
}
|
|
27545
27940
|
calculate(rate, per, nper, pv, fv, type) {
|
|
27546
|
-
const _fv = fv
|
|
27547
|
-
const _type = type
|
|
27941
|
+
const _fv = fv ?? NumberValueObject.create(0);
|
|
27942
|
+
const _type = type ?? NumberValueObject.create(0);
|
|
27548
27943
|
const maxRowLength = Math.max(rate.isArray() ? rate.getRowCount() : 1, per.isArray() ? per.getRowCount() : 1, nper.isArray() ? nper.getRowCount() : 1, pv.isArray() ? pv.getRowCount() : 1, _fv.isArray() ? _fv.getRowCount() : 1, _type.isArray() ? _type.getRowCount() : 1);
|
|
27549
27944
|
const maxColumnLength = Math.max(rate.isArray() ? rate.getColumnCount() : 1, per.isArray() ? per.getColumnCount() : 1, nper.isArray() ? nper.getColumnCount() : 1, pv.isArray() ? pv.getColumnCount() : 1, _fv.isArray() ? _fv.getColumnCount() : 1, _type.isArray() ? _type.getColumnCount() : 1);
|
|
27550
27945
|
const rateArray = expandArrayValueObject(maxRowLength, maxColumnLength, rate, ErrorValueObject.create("#N/A"));
|
|
@@ -27583,7 +27978,7 @@ var Price = class extends BaseFunction {
|
|
|
27583
27978
|
_defineProperty(this, "maxParams", 7);
|
|
27584
27979
|
}
|
|
27585
27980
|
calculate(settlement, maturity, rate, yld, redemption, frequency, basis) {
|
|
27586
|
-
let _basis = basis
|
|
27981
|
+
let _basis = basis ?? NumberValueObject.create(0);
|
|
27587
27982
|
if (_basis.isNull()) _basis = NumberValueObject.create(0);
|
|
27588
27983
|
const { isError, errorObject, variants } = checkVariantsErrorIsNullorArrayOrBoolean(settlement, maturity, rate, yld, redemption, frequency, _basis);
|
|
27589
27984
|
if (isError) return errorObject;
|
|
@@ -27617,7 +28012,7 @@ var Pricedisc = class extends BaseFunction {
|
|
|
27617
28012
|
_defineProperty(this, "maxParams", 5);
|
|
27618
28013
|
}
|
|
27619
28014
|
calculate(settlement, maturity, discount, redemption, basis) {
|
|
27620
|
-
let _basis = basis
|
|
28015
|
+
let _basis = basis ?? NumberValueObject.create(0);
|
|
27621
28016
|
if (_basis.isNull()) _basis = NumberValueObject.create(0);
|
|
27622
28017
|
const { isError, errorObject, variants } = checkVariantsErrorIsNullorArrayOrBoolean(settlement, maturity, discount, redemption, _basis);
|
|
27623
28018
|
if (isError) return errorObject;
|
|
@@ -27646,7 +28041,7 @@ var Pricemat = class extends BaseFunction {
|
|
|
27646
28041
|
_defineProperty(this, "maxParams", 6);
|
|
27647
28042
|
}
|
|
27648
28043
|
calculate(settlement, maturity, issue, rate, yld, basis) {
|
|
27649
|
-
let _basis = basis
|
|
28044
|
+
let _basis = basis ?? NumberValueObject.create(0);
|
|
27650
28045
|
if (_basis.isNull()) _basis = NumberValueObject.create(0);
|
|
27651
28046
|
const { isError, errorObject, variants } = checkVariantsErrorIsNullorArrayOrBoolean(settlement, maturity, issue, rate, yld, _basis);
|
|
27652
28047
|
if (isError) return errorObject;
|
|
@@ -27685,8 +28080,8 @@ var Pv = class extends BaseFunction {
|
|
|
27685
28080
|
_defineProperty(this, "needsLocale", true);
|
|
27686
28081
|
}
|
|
27687
28082
|
calculate(rate, nper, pmt, fv, type) {
|
|
27688
|
-
const _fv = fv
|
|
27689
|
-
const _type = type
|
|
28083
|
+
const _fv = fv ?? NumberValueObject.create(0);
|
|
28084
|
+
const _type = type ?? NumberValueObject.create(0);
|
|
27690
28085
|
const maxRowLength = Math.max(rate.isArray() ? rate.getRowCount() : 1, nper.isArray() ? nper.getRowCount() : 1, pmt.isArray() ? pmt.getRowCount() : 1, _fv.isArray() ? _fv.getRowCount() : 1, _type.isArray() ? _type.getRowCount() : 1);
|
|
27691
28086
|
const maxColumnLength = Math.max(rate.isArray() ? rate.getColumnCount() : 1, nper.isArray() ? nper.getColumnCount() : 1, pmt.isArray() ? pmt.getColumnCount() : 1, _fv.isArray() ? _fv.getColumnCount() : 1, _type.isArray() ? _type.getColumnCount() : 1);
|
|
27692
28087
|
const rateArray = expandArrayValueObject(maxRowLength, maxColumnLength, rate, ErrorValueObject.create("#N/A"));
|
|
@@ -27723,9 +28118,9 @@ var Rate = class extends BaseFunction {
|
|
|
27723
28118
|
_defineProperty(this, "maxParams", 6);
|
|
27724
28119
|
}
|
|
27725
28120
|
calculate(nper, pmt, pv, fv, type, guess) {
|
|
27726
|
-
const _fv = fv
|
|
27727
|
-
const _type = type
|
|
27728
|
-
const _guess = guess
|
|
28121
|
+
const _fv = fv ?? NumberValueObject.create(0);
|
|
28122
|
+
const _type = type ?? NumberValueObject.create(0);
|
|
28123
|
+
const _guess = guess ?? NumberValueObject.create(.1);
|
|
27729
28124
|
const maxRowLength = Math.max(nper.isArray() ? nper.getRowCount() : 1, pmt.isArray() ? pmt.getRowCount() : 1, pv.isArray() ? pv.getRowCount() : 1, _fv.isArray() ? _fv.getRowCount() : 1, _type.isArray() ? _type.getRowCount() : 1, _guess.isArray() ? _guess.getRowCount() : 1);
|
|
27730
28125
|
const maxColumnLength = Math.max(nper.isArray() ? nper.getColumnCount() : 1, pmt.isArray() ? pmt.getColumnCount() : 1, pv.isArray() ? pv.getColumnCount() : 1, _fv.isArray() ? _fv.getColumnCount() : 1, _type.isArray() ? _type.getColumnCount() : 1, _guess.isArray() ? _guess.getColumnCount() : 1);
|
|
27731
28126
|
const nperArray = expandArrayValueObject(maxRowLength, maxColumnLength, nper, ErrorValueObject.create("#N/A"));
|
|
@@ -27810,7 +28205,7 @@ var Received = class extends BaseFunction {
|
|
|
27810
28205
|
_defineProperty(this, "maxParams", 5);
|
|
27811
28206
|
}
|
|
27812
28207
|
calculate(settlement, maturity, investment, discount, basis) {
|
|
27813
|
-
let _basis = basis
|
|
28208
|
+
let _basis = basis ?? NumberValueObject.create(0);
|
|
27814
28209
|
if (_basis.isNull()) _basis = NumberValueObject.create(0);
|
|
27815
28210
|
const { isError, errorObject, variants } = checkVariantsErrorIsNullorArrayOrBoolean(settlement, maturity, investment, discount, _basis);
|
|
27816
28211
|
if (isError) return errorObject;
|
|
@@ -28032,9 +28427,9 @@ var Vdb = class extends BaseFunction {
|
|
|
28032
28427
|
_defineProperty(this, "needsLocale", true);
|
|
28033
28428
|
}
|
|
28034
28429
|
calculate(cost, salvage, life, startPeriod, endPeriod, factor, noSwitch) {
|
|
28035
|
-
let _factor = factor
|
|
28430
|
+
let _factor = factor ?? NumberValueObject.create(2);
|
|
28036
28431
|
if (_factor.isNull()) _factor = NumberValueObject.create(2);
|
|
28037
|
-
let _noSwitch = noSwitch
|
|
28432
|
+
let _noSwitch = noSwitch ?? BooleanValueObject.create(false);
|
|
28038
28433
|
if (_noSwitch.isNull()) _noSwitch = BooleanValueObject.create(false);
|
|
28039
28434
|
const maxRowLength = Math.max(cost.isArray() ? cost.getRowCount() : 1, salvage.isArray() ? salvage.getRowCount() : 1, life.isArray() ? life.getRowCount() : 1, startPeriod.isArray() ? startPeriod.getRowCount() : 1, endPeriod.isArray() ? endPeriod.getRowCount() : 1, _factor.isArray() ? _factor.getRowCount() : 1, _noSwitch.isArray() ? _noSwitch.getRowCount() : 1);
|
|
28040
28435
|
const maxColumnLength = Math.max(cost.isArray() ? cost.getColumnCount() : 1, salvage.isArray() ? salvage.getColumnCount() : 1, life.isArray() ? life.getColumnCount() : 1, startPeriod.isArray() ? startPeriod.getColumnCount() : 1, endPeriod.isArray() ? endPeriod.getColumnCount() : 1, _factor.isArray() ? _factor.getColumnCount() : 1, _noSwitch.isArray() ? _noSwitch.getColumnCount() : 1);
|
|
@@ -28128,7 +28523,7 @@ var Xirr = class extends BaseFunction {
|
|
|
28128
28523
|
if (values.isNull() || dates.isNull()) return ErrorValueObject.create("#N/A");
|
|
28129
28524
|
const { isError, errorObejct, _values, _dates } = this._checkErrors(values, dates);
|
|
28130
28525
|
if (isError) return errorObejct;
|
|
28131
|
-
let _guess = guess
|
|
28526
|
+
let _guess = guess ?? NumberValueObject.create(.1);
|
|
28132
28527
|
if (_guess.isNull()) _guess = NumberValueObject.create(.1);
|
|
28133
28528
|
const { isError: _isError_guess, errorObject: _errorObject_guess, variants } = checkVariantsErrorIsArrayOrBoolean(_guess);
|
|
28134
28529
|
if (_isError_guess) return _errorObject_guess;
|
|
@@ -28471,7 +28866,7 @@ var Yield = class extends BaseFunction {
|
|
|
28471
28866
|
_defineProperty(this, "maxParams", 7);
|
|
28472
28867
|
}
|
|
28473
28868
|
calculate(settlement, maturity, rate, pr, redemption, frequency, basis) {
|
|
28474
|
-
let _basis = basis
|
|
28869
|
+
let _basis = basis ?? NumberValueObject.create(0);
|
|
28475
28870
|
if (_basis.isNull()) _basis = NumberValueObject.create(0);
|
|
28476
28871
|
const { isError, errorObject, variants } = checkVariantsErrorIsNullorArrayOrBoolean(settlement, maturity, rate, pr, redemption, frequency, _basis);
|
|
28477
28872
|
if (isError) return errorObject;
|
|
@@ -28524,7 +28919,7 @@ var Yielddisc = class extends BaseFunction {
|
|
|
28524
28919
|
_defineProperty(this, "maxParams", 5);
|
|
28525
28920
|
}
|
|
28526
28921
|
calculate(settlement, maturity, pr, redemption, basis) {
|
|
28527
|
-
let _basis = basis
|
|
28922
|
+
let _basis = basis ?? NumberValueObject.create(0);
|
|
28528
28923
|
if (_basis.isNull()) _basis = NumberValueObject.create(0);
|
|
28529
28924
|
const { isError, errorObject, variants } = checkVariantsErrorIsNullorArrayOrBoolean(settlement, maturity, pr, redemption, _basis);
|
|
28530
28925
|
if (isError) return errorObject;
|
|
@@ -28553,7 +28948,7 @@ var Yieldmat = class extends BaseFunction {
|
|
|
28553
28948
|
_defineProperty(this, "maxParams", 6);
|
|
28554
28949
|
}
|
|
28555
28950
|
calculate(settlement, maturity, issue, rate, pr, basis) {
|
|
28556
|
-
let _basis = basis
|
|
28951
|
+
let _basis = basis ?? NumberValueObject.create(0);
|
|
28557
28952
|
if (_basis.isNull()) _basis = NumberValueObject.create(0);
|
|
28558
28953
|
const { isError, errorObject, variants } = checkVariantsErrorIsNullorArrayOrBoolean(settlement, maturity, issue, rate, pr, _basis);
|
|
28559
28954
|
if (isError) return errorObject;
|
|
@@ -28688,6 +29083,7 @@ var Cell = class extends BaseFunction {
|
|
|
28688
29083
|
if (_reference.isError()) return _reference;
|
|
28689
29084
|
if (!_reference.isReferenceObject()) return ErrorValueObject.create("#N/A");
|
|
28690
29085
|
const { columnData, defaultColumnWidth } = _reference.getCurrentActiveSheetData();
|
|
29086
|
+
const forcedSheetName = _reference.getForcedSheetName();
|
|
28691
29087
|
_reference = _reference.toArrayValueObject();
|
|
28692
29088
|
const _currentRow = _reference.getCurrentRow();
|
|
28693
29089
|
const _currentColumn = _reference.getCurrentColumn();
|
|
@@ -28695,7 +29091,7 @@ var Cell = class extends BaseFunction {
|
|
|
28695
29091
|
const infoTypeValue = `${infoType.getValue()}`;
|
|
28696
29092
|
let result;
|
|
28697
29093
|
switch (infoTypeValue.toLocaleLowerCase()) {
|
|
28698
|
-
case "address": return StringValueObject.create(
|
|
29094
|
+
case "address": return StringValueObject.create(`${forcedSheetName ? `${addQuotesBothSides(forcedSheetName)}!` : ""}$${Tools.chatAtABC(_currentColumn)}$${_currentRow + 1}`);
|
|
28699
29095
|
case "col": return NumberValueObject.create(_currentColumn + 1);
|
|
28700
29096
|
case "color": return NumberValueObject.create(0);
|
|
28701
29097
|
case "contents": return _reference;
|
|
@@ -28764,7 +29160,7 @@ var Isbetween = class extends BaseFunction {
|
|
|
28764
29160
|
_defineProperty(this, "maxParams", 5);
|
|
28765
29161
|
}
|
|
28766
29162
|
calculate(valueToCompare, lowerValue, upperValue, lowerValueIsInclusive, upperValueIsInclusive) {
|
|
28767
|
-
const { isError, errorObject, variants } = checkVariantsErrorIsArray(valueToCompare, lowerValue, upperValue, lowerValueIsInclusive
|
|
29163
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsArray(valueToCompare, lowerValue, upperValue, lowerValueIsInclusive ?? BooleanValueObject.create(true), upperValueIsInclusive ?? BooleanValueObject.create(true));
|
|
28768
29164
|
if (isError) return errorObject;
|
|
28769
29165
|
const [valueToCompareObject, lowerValueObject, upperValueObject, lowerValueIsInclusiveObject, upperValueIsInclusiveObject] = variants;
|
|
28770
29166
|
if (lowerValueIsInclusiveObject.isString() || upperValueIsInclusiveObject.isString()) return ErrorValueObject.create("#VALUE!");
|
|
@@ -28786,8 +29182,13 @@ var Isblank = class extends BaseFunction {
|
|
|
28786
29182
|
super(..._args);
|
|
28787
29183
|
_defineProperty(this, "minParams", 1);
|
|
28788
29184
|
_defineProperty(this, "maxParams", 1);
|
|
29185
|
+
_defineProperty(this, "needsReferenceObject", true);
|
|
28789
29186
|
}
|
|
28790
29187
|
calculate(value) {
|
|
29188
|
+
if (value instanceof BaseReferenceObject) {
|
|
29189
|
+
const array = value.toArrayValueObject(false).mapValue((valueObject) => BooleanValueObject.create(valueObject.isNull()));
|
|
29190
|
+
return array.getRowCount() === 1 && array.getColumnCount() === 1 ? array.getFirstCell() : array;
|
|
29191
|
+
}
|
|
28791
29192
|
if (value.isNull()) return BooleanValueObject.create(true);
|
|
28792
29193
|
else if (value.isArray()) return value.mapValue((valueObject) => {
|
|
28793
29194
|
if (valueObject.isNull()) return BooleanValueObject.create(true);
|
|
@@ -29550,10 +29951,7 @@ var Groupby = class extends BaseFunction {
|
|
|
29550
29951
|
return {
|
|
29551
29952
|
rowCount: array.getRowCount(),
|
|
29552
29953
|
columnCount: array.getColumnCount(),
|
|
29553
|
-
valueAt: (row, column) =>
|
|
29554
|
-
var _array$get;
|
|
29555
|
-
return (_array$get = array.get(row, column)) !== null && _array$get !== void 0 ? _array$get : NullValueObject.create();
|
|
29556
|
-
}
|
|
29954
|
+
valueAt: (row, column) => array.get(row, column) ?? NullValueObject.create()
|
|
29557
29955
|
};
|
|
29558
29956
|
}
|
|
29559
29957
|
return {
|
|
@@ -29623,10 +30021,7 @@ var Groupby = class extends BaseFunction {
|
|
|
29623
30021
|
}
|
|
29624
30022
|
}
|
|
29625
30023
|
_sum(values) {
|
|
29626
|
-
return values.reduce((sum, value) =>
|
|
29627
|
-
var _this$_numericValue;
|
|
29628
|
-
return sum + ((_this$_numericValue = this._numericValue(value)) !== null && _this$_numericValue !== void 0 ? _this$_numericValue : 0);
|
|
29629
|
-
}, 0);
|
|
30024
|
+
return values.reduce((sum, value) => sum + (this._numericValue(value) ?? 0), 0);
|
|
29630
30025
|
}
|
|
29631
30026
|
_numericValue(value) {
|
|
29632
30027
|
return value.isNumber() ? Number(value.getValue()) : void 0;
|
|
@@ -29634,10 +30029,7 @@ var Groupby = class extends BaseFunction {
|
|
|
29634
30029
|
_numberValue(variant) {
|
|
29635
30030
|
if (variant == null || variant.isError()) return 0;
|
|
29636
30031
|
if (variant.isReferenceObject()) variant = variant.getFirstCell();
|
|
29637
|
-
if (variant.isArray())
|
|
29638
|
-
var _get;
|
|
29639
|
-
variant = (_get = variant.get(0, 0)) !== null && _get !== void 0 ? _get : NullValueObject.create();
|
|
29640
|
-
}
|
|
30032
|
+
if (variant.isArray()) variant = variant.get(0, 0) ?? NullValueObject.create();
|
|
29641
30033
|
const value = variant.getValue();
|
|
29642
30034
|
return typeof value === "number" ? Math.trunc(value) : Math.trunc(Number(value) || 0);
|
|
29643
30035
|
}
|
|
@@ -30074,20 +30466,72 @@ var Or = class extends BaseFunction {
|
|
|
30074
30466
|
}
|
|
30075
30467
|
};
|
|
30076
30468
|
|
|
30469
|
+
//#endregion
|
|
30470
|
+
//#region src/functions/math/sum/index.ts
|
|
30471
|
+
var Sum = class extends BaseFunction {
|
|
30472
|
+
constructor(..._args) {
|
|
30473
|
+
super(..._args);
|
|
30474
|
+
_defineProperty(this, "minParams", 1);
|
|
30475
|
+
_defineProperty(this, "maxParams", 255);
|
|
30476
|
+
}
|
|
30477
|
+
calculate(...variants) {
|
|
30478
|
+
let accumulatorAll = NumberValueObject.create(0);
|
|
30479
|
+
for (let i = 0; i < variants.length; i++) {
|
|
30480
|
+
let variant = variants[i];
|
|
30481
|
+
variant = this._legacyImplicitDerivedArray(variant);
|
|
30482
|
+
if (variant.isString()) variant = variant.convertToNumberObjectValue();
|
|
30483
|
+
if (variant.isError()) return variant;
|
|
30484
|
+
if (variant.isArray()) variant = variant.sum();
|
|
30485
|
+
if (variant.isError()) return variant;
|
|
30486
|
+
accumulatorAll = accumulatorAll.plus(variant);
|
|
30487
|
+
if (accumulatorAll.isError()) return accumulatorAll;
|
|
30488
|
+
}
|
|
30489
|
+
return accumulatorAll;
|
|
30490
|
+
}
|
|
30491
|
+
_legacyImplicitDerivedArray(variant) {
|
|
30492
|
+
if (!variant.isArray()) return variant;
|
|
30493
|
+
const array = variant;
|
|
30494
|
+
if (array.usesInvertedIndexCache() || !array.usesLegacyImplicitForAggregate()) return variant;
|
|
30495
|
+
const startRow = array.getCurrentRow();
|
|
30496
|
+
const startColumn = array.getCurrentColumn();
|
|
30497
|
+
if (startRow < 0 || startColumn < 0) return variant;
|
|
30498
|
+
const rowCount = array.getRowCount();
|
|
30499
|
+
const columnCount = array.getColumnCount();
|
|
30500
|
+
let rowIndex = -1;
|
|
30501
|
+
let columnIndex = -1;
|
|
30502
|
+
if (rowCount === 1) {
|
|
30503
|
+
rowIndex = 0;
|
|
30504
|
+
columnIndex = this.column - startColumn;
|
|
30505
|
+
} else if (columnCount === 1) {
|
|
30506
|
+
rowIndex = this.row - startRow;
|
|
30507
|
+
columnIndex = 0;
|
|
30508
|
+
} else {
|
|
30509
|
+
rowIndex = this.row - startRow;
|
|
30510
|
+
columnIndex = this.column - startColumn;
|
|
30511
|
+
}
|
|
30512
|
+
if (rowIndex < 0 || rowIndex >= rowCount || columnIndex < 0 || columnIndex >= columnCount) return variant;
|
|
30513
|
+
return array.get(rowIndex, columnIndex) || variant;
|
|
30514
|
+
}
|
|
30515
|
+
};
|
|
30516
|
+
|
|
30077
30517
|
//#endregion
|
|
30078
30518
|
//#region src/functions/logical/percentof/index.ts
|
|
30079
30519
|
/**
|
|
30080
|
-
* PERCENTOF is
|
|
30081
|
-
*
|
|
30520
|
+
* PERCENTOF is logically equivalent to SUM(dataSubset) / SUM(dataAll).
|
|
30521
|
+
* GROUPBY also consumes the function name as an aggregator token through its AST path.
|
|
30082
30522
|
*/
|
|
30083
|
-
var Percentof = class extends
|
|
30523
|
+
var Percentof = class extends Sum {
|
|
30084
30524
|
constructor(..._args) {
|
|
30085
30525
|
super(..._args);
|
|
30086
|
-
_defineProperty(this, "minParams",
|
|
30087
|
-
_defineProperty(this, "maxParams",
|
|
30526
|
+
_defineProperty(this, "minParams", 2);
|
|
30527
|
+
_defineProperty(this, "maxParams", 2);
|
|
30088
30528
|
}
|
|
30089
|
-
calculate(
|
|
30090
|
-
|
|
30529
|
+
calculate(dataSubset, dataAll) {
|
|
30530
|
+
const subsetTotal = super.calculate(dataSubset);
|
|
30531
|
+
if (subsetTotal.isError()) return subsetTotal;
|
|
30532
|
+
const allTotal = super.calculate(dataAll);
|
|
30533
|
+
if (allTotal.isError()) return allTotal;
|
|
30534
|
+
return subsetTotal.divided(allTotal);
|
|
30091
30535
|
}
|
|
30092
30536
|
};
|
|
30093
30537
|
|
|
@@ -30496,6 +30940,7 @@ var Choose = class extends BaseFunction {
|
|
|
30496
30940
|
super(..._args);
|
|
30497
30941
|
_defineProperty(this, "minParams", 2);
|
|
30498
30942
|
_defineProperty(this, "maxParams", 255);
|
|
30943
|
+
_defineProperty(this, "lazyIfReferenceArrayArgumentIndexes", Array.from({ length: this.maxParams - 1 }, (_, index) => index + 1));
|
|
30499
30944
|
_defineProperty(this, "needsReferenceObject", true);
|
|
30500
30945
|
}
|
|
30501
30946
|
calculate(indexNum, ...variants) {
|
|
@@ -30680,7 +31125,7 @@ var Drop = class extends BaseFunction {
|
|
|
30680
31125
|
_defineProperty(this, "maxParams", 3);
|
|
30681
31126
|
}
|
|
30682
31127
|
calculate(array, rows, columns) {
|
|
30683
|
-
const _columns = columns
|
|
31128
|
+
const _columns = columns ?? NumberValueObject.create(0);
|
|
30684
31129
|
const arrayRowCount = array.isArray() ? array.getRowCount() : 1;
|
|
30685
31130
|
const arrayColumnCount = array.isArray() ? array.getColumnCount() : 1;
|
|
30686
31131
|
const maxRowLength = Math.max(rows.isArray() ? rows.getRowCount() : 1, _columns.isArray() ? _columns.getRowCount() : 1);
|
|
@@ -30755,8 +31200,8 @@ var Expand = class extends BaseFunction {
|
|
|
30755
31200
|
const arrayRowCount = array.isArray() ? array.getRowCount() : 1;
|
|
30756
31201
|
const arrayColumnCount = array.isArray() ? array.getColumnCount() : 1;
|
|
30757
31202
|
let _rows = rows;
|
|
30758
|
-
let _columns = columns
|
|
30759
|
-
const _padWith = padWith
|
|
31203
|
+
let _columns = columns ?? NumberValueObject.create(arrayColumnCount);
|
|
31204
|
+
const _padWith = padWith ?? ErrorValueObject.create("#N/A");
|
|
30760
31205
|
if (rows.isNull()) _rows = NumberValueObject.create(arrayRowCount);
|
|
30761
31206
|
if (_columns.isNull()) _columns = NumberValueObject.create(arrayColumnCount);
|
|
30762
31207
|
const maxRowLength = Math.max(_rows.isArray() ? _rows.getRowCount() : 1, _columns.isArray() ? _columns.getRowCount() : 1);
|
|
@@ -30848,7 +31293,7 @@ var Filter = class extends BaseFunction {
|
|
|
30848
31293
|
_defineProperty(this, "maxParams", 3);
|
|
30849
31294
|
}
|
|
30850
31295
|
calculate(array, include, ifEmpty) {
|
|
30851
|
-
const _ifEmpty = ifEmpty
|
|
31296
|
+
const _ifEmpty = ifEmpty ?? ErrorValueObject.create("#CALC!");
|
|
30852
31297
|
if (array.isError()) return array;
|
|
30853
31298
|
if (include.isError()) return include;
|
|
30854
31299
|
const arrayRowCount = array.isArray() ? array.getRowCount() : 1;
|
|
@@ -31100,7 +31545,7 @@ var ImageFunction = class extends BaseFunction {
|
|
|
31100
31545
|
if (altText.isBoolean()) altTextValue = altText.getValue() ? "TRUE" : "FALSE";
|
|
31101
31546
|
else if (!altText.isNull()) altTextValue = `${altText.getValue()}`;
|
|
31102
31547
|
}
|
|
31103
|
-
let _sizing = sizing
|
|
31548
|
+
let _sizing = sizing ?? NumberValueObject.create(0);
|
|
31104
31549
|
if (_sizing.isString()) _sizing = _sizing.convertToNumberObjectValue();
|
|
31105
31550
|
if (_sizing.isError()) return _sizing;
|
|
31106
31551
|
const sizingValue = Math.abs(Math.trunc(+_sizing.getValue()));
|
|
@@ -31110,11 +31555,11 @@ var ImageFunction = class extends BaseFunction {
|
|
|
31110
31555
|
1,
|
|
31111
31556
|
2
|
|
31112
31557
|
].includes(sizingValue) && (height || width)) return ErrorValueObject.create("#VALUE!");
|
|
31113
|
-
let _height = height
|
|
31558
|
+
let _height = height ?? NumberValueObject.create(0);
|
|
31114
31559
|
if (_height.isString()) _height = _height.convertToNumberObjectValue();
|
|
31115
31560
|
if (_height.isError()) return _height;
|
|
31116
31561
|
const heightValue = Math.ceil(+_height.getValue());
|
|
31117
|
-
let _width = width
|
|
31562
|
+
let _width = width ?? NumberValueObject.create(0);
|
|
31118
31563
|
if (_width.isString()) _width = _width.convertToNumberObjectValue();
|
|
31119
31564
|
if (_width.isError()) return _width;
|
|
31120
31565
|
const widthValue = Math.ceil(+_width.getValue());
|
|
@@ -31156,7 +31601,7 @@ var Index = class extends BaseFunction {
|
|
|
31156
31601
|
if (rowNum.isReferenceObject()) _rowNum = rowNum.toArrayValueObject();
|
|
31157
31602
|
let _columnNum = columnNum;
|
|
31158
31603
|
if (_columnNum === null || _columnNum === void 0 ? void 0 : _columnNum.isReferenceObject()) _columnNum = columnNum.toArrayValueObject();
|
|
31159
|
-
let _areaNum = areaNum
|
|
31604
|
+
let _areaNum = areaNum ?? NumberValueObject.create(1);
|
|
31160
31605
|
if (_areaNum.isReferenceObject()) _areaNum = areaNum.toArrayValueObject();
|
|
31161
31606
|
const maxRowLength = Math.max(_rowNum.isArray() ? _rowNum.getRowCount() : 1, (_columnNum === null || _columnNum === void 0 ? void 0 : _columnNum.isArray()) ? _columnNum.getRowCount() : 1, _areaNum.isArray() ? _areaNum.getRowCount() : 1);
|
|
31162
31607
|
const maxColumnLength = Math.max(_rowNum.isArray() ? _rowNum.getColumnCount() : 1, (_columnNum === null || _columnNum === void 0 ? void 0 : _columnNum.isArray()) ? _columnNum.getColumnCount() : 1, _areaNum.isArray() ? _areaNum.getColumnCount() : 1);
|
|
@@ -31416,6 +31861,7 @@ var Match = class extends BaseFunction {
|
|
|
31416
31861
|
super(..._args);
|
|
31417
31862
|
_defineProperty(this, "minParams", 2);
|
|
31418
31863
|
_defineProperty(this, "maxParams", 3);
|
|
31864
|
+
_defineProperty(this, "lazyIfReferenceArrayArgumentIndexes", [1]);
|
|
31419
31865
|
}
|
|
31420
31866
|
calculate(lookupValue, lookupArray, matchType) {
|
|
31421
31867
|
if (lookupValue.isError()) return lookupValue;
|
|
@@ -31448,236 +31894,6 @@ var Match = class extends BaseFunction {
|
|
|
31448
31894
|
}
|
|
31449
31895
|
};
|
|
31450
31896
|
|
|
31451
|
-
//#endregion
|
|
31452
|
-
//#region src/engine/reference-object/multi-area-reference-object.ts
|
|
31453
|
-
var MultiAreaReferenceObject = class extends BaseReferenceObject {
|
|
31454
|
-
constructor(token, areas = []) {
|
|
31455
|
-
super(token);
|
|
31456
|
-
_defineProperty(this, "_areas", []);
|
|
31457
|
-
this._areas = areas;
|
|
31458
|
-
}
|
|
31459
|
-
dispose() {
|
|
31460
|
-
this._areas.forEach((row) => {
|
|
31461
|
-
row.forEach((a) => a.dispose());
|
|
31462
|
-
});
|
|
31463
|
-
this._areas = [];
|
|
31464
|
-
super.dispose();
|
|
31465
|
-
}
|
|
31466
|
-
getAreas() {
|
|
31467
|
-
return this._areas;
|
|
31468
|
-
}
|
|
31469
|
-
setAreas(areas) {
|
|
31470
|
-
this._areas = areas;
|
|
31471
|
-
}
|
|
31472
|
-
/**
|
|
31473
|
-
* Append an area:
|
|
31474
|
-
* - If a single AreaValue is passed, it will be wrapped as one row.
|
|
31475
|
-
* - If an AreaValue[] is passed, it will be inserted as an entire row.
|
|
31476
|
-
*/
|
|
31477
|
-
addArea(area) {
|
|
31478
|
-
if (Array.isArray(area)) this._areas.push(area);
|
|
31479
|
-
else this._areas.push([area]);
|
|
31480
|
-
}
|
|
31481
|
-
/** Flatten the 2D areas to reuse 1D logic */
|
|
31482
|
-
_flatAreas() {
|
|
31483
|
-
return this._areas.flat();
|
|
31484
|
-
}
|
|
31485
|
-
isMultiArea() {
|
|
31486
|
-
return true;
|
|
31487
|
-
}
|
|
31488
|
-
isRange() {
|
|
31489
|
-
return false;
|
|
31490
|
-
}
|
|
31491
|
-
isCell() {
|
|
31492
|
-
return false;
|
|
31493
|
-
}
|
|
31494
|
-
isRow() {
|
|
31495
|
-
return false;
|
|
31496
|
-
}
|
|
31497
|
-
isColumn() {
|
|
31498
|
-
return false;
|
|
31499
|
-
}
|
|
31500
|
-
getRowCount() {
|
|
31501
|
-
let total = 0;
|
|
31502
|
-
for (const a of this._flatAreas()) {
|
|
31503
|
-
if (a.isError()) continue;
|
|
31504
|
-
total += a.getRowCount();
|
|
31505
|
-
}
|
|
31506
|
-
return total;
|
|
31507
|
-
}
|
|
31508
|
-
getColumnCount() {
|
|
31509
|
-
let total = 0;
|
|
31510
|
-
for (const a of this._flatAreas()) {
|
|
31511
|
-
if (a.isError()) continue;
|
|
31512
|
-
total += a.getColumnCount();
|
|
31513
|
-
}
|
|
31514
|
-
return total;
|
|
31515
|
-
}
|
|
31516
|
-
isExceedRange() {
|
|
31517
|
-
return this._flatAreas().some((a) => {
|
|
31518
|
-
if (a.isError()) return false;
|
|
31519
|
-
return a.isExceedRange();
|
|
31520
|
-
});
|
|
31521
|
-
}
|
|
31522
|
-
setRefOffset(x = 0, y = 0) {
|
|
31523
|
-
super.setRefOffset(x, y);
|
|
31524
|
-
this._flatAreas().forEach((a) => {
|
|
31525
|
-
if (a.isError()) return;
|
|
31526
|
-
a.setRefOffset(x, y);
|
|
31527
|
-
});
|
|
31528
|
-
}
|
|
31529
|
-
_getReferenceArea() {
|
|
31530
|
-
return this._flatAreas().find((a) => !a.isError());
|
|
31531
|
-
}
|
|
31532
|
-
/**
|
|
31533
|
-
* Multi-area reference may span multiple sheets, but Excel requires
|
|
31534
|
-
* them to be in the same sheet for most functions. We follow Excel semantics
|
|
31535
|
-
* by returning the first area’s identifiers.
|
|
31536
|
-
*/
|
|
31537
|
-
getUnitId() {
|
|
31538
|
-
var _this$_getReferenceAr, _this$_getReferenceAr2;
|
|
31539
|
-
return (_this$_getReferenceAr = (_this$_getReferenceAr2 = this._getReferenceArea()) === null || _this$_getReferenceAr2 === void 0 ? void 0 : _this$_getReferenceAr2.getUnitId()) !== null && _this$_getReferenceAr !== void 0 ? _this$_getReferenceAr : super.getUnitId();
|
|
31540
|
-
}
|
|
31541
|
-
getSheetId() {
|
|
31542
|
-
var _this$_getReferenceAr3, _this$_getReferenceAr4;
|
|
31543
|
-
return (_this$_getReferenceAr3 = (_this$_getReferenceAr4 = this._getReferenceArea()) === null || _this$_getReferenceAr4 === void 0 ? void 0 : _this$_getReferenceAr4.getSheetId()) !== null && _this$_getReferenceAr3 !== void 0 ? _this$_getReferenceAr3 : super.getSheetId();
|
|
31544
|
-
}
|
|
31545
|
-
getActiveSheetRowCount() {
|
|
31546
|
-
var _this$_getReferenceAr5, _this$_getReferenceAr6;
|
|
31547
|
-
return (_this$_getReferenceAr5 = (_this$_getReferenceAr6 = this._getReferenceArea()) === null || _this$_getReferenceAr6 === void 0 ? void 0 : _this$_getReferenceAr6.getActiveSheetRowCount()) !== null && _this$_getReferenceAr5 !== void 0 ? _this$_getReferenceAr5 : 0;
|
|
31548
|
-
}
|
|
31549
|
-
getActiveSheetColumnCount() {
|
|
31550
|
-
var _this$_getReferenceAr7, _this$_getReferenceAr8;
|
|
31551
|
-
return (_this$_getReferenceAr7 = (_this$_getReferenceAr8 = this._getReferenceArea()) === null || _this$_getReferenceAr8 === void 0 ? void 0 : _this$_getReferenceAr8.getActiveSheetColumnCount()) !== null && _this$_getReferenceAr7 !== void 0 ? _this$_getReferenceAr7 : 0;
|
|
31552
|
-
}
|
|
31553
|
-
/**
|
|
31554
|
-
* Iterate through all areas in order, flattening the multi-area into
|
|
31555
|
-
* a sequence of cells.
|
|
31556
|
-
*
|
|
31557
|
-
* Note: The order here is "row-major":
|
|
31558
|
-
* iterate by the row order of _areas, then within each row by the area order.
|
|
31559
|
-
*/
|
|
31560
|
-
iterator(callback) {
|
|
31561
|
-
for (const row of this._areas) {
|
|
31562
|
-
let stopRow = false;
|
|
31563
|
-
for (const area of row) {
|
|
31564
|
-
if (area.isError()) continue;
|
|
31565
|
-
let stopArea = false;
|
|
31566
|
-
area.iterator((v, r, c) => {
|
|
31567
|
-
const res = callback(v, r, c);
|
|
31568
|
-
if (res === false) {
|
|
31569
|
-
stopArea = true;
|
|
31570
|
-
stopRow = true;
|
|
31571
|
-
return false;
|
|
31572
|
-
}
|
|
31573
|
-
return res;
|
|
31574
|
-
});
|
|
31575
|
-
if (stopArea) break;
|
|
31576
|
-
}
|
|
31577
|
-
if (stopRow) return;
|
|
31578
|
-
}
|
|
31579
|
-
}
|
|
31580
|
-
/**
|
|
31581
|
-
* Excel defines the "first cell" of a multi-area reference
|
|
31582
|
-
* as the first cell of the first area.
|
|
31583
|
-
*/
|
|
31584
|
-
getFirstCell() {
|
|
31585
|
-
const first = this._getReferenceArea();
|
|
31586
|
-
if (!first) return super.getFirstCell();
|
|
31587
|
-
return first.getFirstCell();
|
|
31588
|
-
}
|
|
31589
|
-
/**
|
|
31590
|
-
* For multi-area, we only take the *first cell* of each area and
|
|
31591
|
-
* arrange them into a 2D ArrayValueObject:
|
|
31592
|
-
*
|
|
31593
|
-
* - outer `_areas` dimension => rows
|
|
31594
|
-
* - inner `_areas[row]` dimension => columns
|
|
31595
|
-
*/
|
|
31596
|
-
toArrayValueObject() {
|
|
31597
|
-
var _this$_areas$0$length, _this$_areas$;
|
|
31598
|
-
const rows = this._areas.length;
|
|
31599
|
-
if (rows === 0) return createNewArray([], 0, 0);
|
|
31600
|
-
const cols = (_this$_areas$0$length = (_this$_areas$ = this._areas[0]) === null || _this$_areas$ === void 0 ? void 0 : _this$_areas$.length) !== null && _this$_areas$0$length !== void 0 ? _this$_areas$0$length : 0;
|
|
31601
|
-
const result = [];
|
|
31602
|
-
for (let r = 0; r < rows; r++) {
|
|
31603
|
-
const rowAreas = this._areas[r];
|
|
31604
|
-
if (!rowAreas) continue;
|
|
31605
|
-
result[r] = result[r] || [];
|
|
31606
|
-
for (let c = 0; c < cols; c++) {
|
|
31607
|
-
const area = rowAreas[c];
|
|
31608
|
-
if (!area) continue;
|
|
31609
|
-
if (area.isError()) {
|
|
31610
|
-
result[r][c] = area;
|
|
31611
|
-
continue;
|
|
31612
|
-
}
|
|
31613
|
-
let firstValue = null;
|
|
31614
|
-
area.iterator((v) => {
|
|
31615
|
-
firstValue = v !== null && v !== void 0 ? v : null;
|
|
31616
|
-
return false;
|
|
31617
|
-
});
|
|
31618
|
-
if (firstValue != null) result[r][c] = firstValue;
|
|
31619
|
-
result[r][c] = NullValueObject.create();
|
|
31620
|
-
}
|
|
31621
|
-
}
|
|
31622
|
-
return createNewArray(result, rows, cols);
|
|
31623
|
-
}
|
|
31624
|
-
getRangePosition() {
|
|
31625
|
-
const flat = this._flatAreas();
|
|
31626
|
-
if (!flat.length) return super.getRangePosition();
|
|
31627
|
-
let minStartRow = Number.POSITIVE_INFINITY;
|
|
31628
|
-
let minStartColumn = Number.POSITIVE_INFINITY;
|
|
31629
|
-
let maxEndRow = Number.NEGATIVE_INFINITY;
|
|
31630
|
-
let maxEndColumn = Number.NEGATIVE_INFINITY;
|
|
31631
|
-
for (const area of flat) {
|
|
31632
|
-
if (area.isError()) continue;
|
|
31633
|
-
const { startRow, startColumn, endRow, endColumn } = area.getRangePosition();
|
|
31634
|
-
if (!Number.isFinite(startRow) || !Number.isFinite(startColumn) || !Number.isFinite(endRow) || !Number.isFinite(endColumn)) continue;
|
|
31635
|
-
if (startRow < minStartRow) minStartRow = startRow;
|
|
31636
|
-
if (startColumn < minStartColumn) minStartColumn = startColumn;
|
|
31637
|
-
if (endRow > maxEndRow) maxEndRow = endRow;
|
|
31638
|
-
if (endColumn > maxEndColumn) maxEndColumn = maxEndColumn < endColumn ? endColumn : maxEndColumn;
|
|
31639
|
-
}
|
|
31640
|
-
if (!Number.isFinite(minStartRow) || !Number.isFinite(minStartColumn) || !Number.isFinite(maxEndRow) || !Number.isFinite(maxEndColumn)) return super.getRangePosition();
|
|
31641
|
-
return {
|
|
31642
|
-
startRow: minStartRow,
|
|
31643
|
-
startColumn: minStartColumn,
|
|
31644
|
-
endRow: maxEndRow,
|
|
31645
|
-
endColumn: maxEndColumn
|
|
31646
|
-
};
|
|
31647
|
-
}
|
|
31648
|
-
toUnitRange() {
|
|
31649
|
-
return {
|
|
31650
|
-
range: this.getRangePosition(),
|
|
31651
|
-
sheetId: this.getSheetId(),
|
|
31652
|
-
unitId: this.getUnitId()
|
|
31653
|
-
};
|
|
31654
|
-
}
|
|
31655
|
-
getRangeData() {
|
|
31656
|
-
const flat = this._flatAreas();
|
|
31657
|
-
if (!flat.length) return super.getRangeData();
|
|
31658
|
-
let minStartRow = Number.POSITIVE_INFINITY;
|
|
31659
|
-
let minStartColumn = Number.POSITIVE_INFINITY;
|
|
31660
|
-
let maxEndRow = Number.NEGATIVE_INFINITY;
|
|
31661
|
-
let maxEndColumn = Number.NEGATIVE_INFINITY;
|
|
31662
|
-
for (const area of flat) {
|
|
31663
|
-
if (area.isError()) continue;
|
|
31664
|
-
const { startRow, startColumn, endRow, endColumn } = area.getRangeData();
|
|
31665
|
-
if (!Number.isFinite(startRow) || !Number.isFinite(startColumn) || !Number.isFinite(endRow) || !Number.isFinite(endColumn)) continue;
|
|
31666
|
-
if (startRow < minStartRow) minStartRow = startRow;
|
|
31667
|
-
if (startColumn < minStartColumn) minStartColumn = startColumn;
|
|
31668
|
-
if (endRow > maxEndRow) maxEndRow = endRow;
|
|
31669
|
-
if (endColumn > maxEndColumn) maxEndColumn = endColumn;
|
|
31670
|
-
}
|
|
31671
|
-
if (!Number.isFinite(minStartRow) || !Number.isFinite(minStartColumn) || !Number.isFinite(maxEndRow) || !Number.isFinite(maxEndColumn)) return super.getRangeData();
|
|
31672
|
-
return {
|
|
31673
|
-
startRow: minStartRow,
|
|
31674
|
-
startColumn: minStartColumn,
|
|
31675
|
-
endRow: maxEndRow,
|
|
31676
|
-
endColumn: maxEndColumn
|
|
31677
|
-
};
|
|
31678
|
-
}
|
|
31679
|
-
};
|
|
31680
|
-
|
|
31681
31897
|
//#endregion
|
|
31682
31898
|
//#region src/functions/lookup/offset/index.ts
|
|
31683
31899
|
var Offset = class extends BaseFunction {
|
|
@@ -31703,10 +31919,10 @@ var Offset = class extends BaseFunction {
|
|
|
31703
31919
|
if (_rows.isReferenceObject()) _rows = _rows.toArrayValueObject();
|
|
31704
31920
|
let _columns = columns;
|
|
31705
31921
|
if (_columns.isReferenceObject()) _columns = _columns.toArrayValueObject();
|
|
31706
|
-
let _height = height
|
|
31922
|
+
let _height = height ?? NumberValueObject.create(rowCount);
|
|
31707
31923
|
if (_height.isReferenceObject()) _height = _height.toArrayValueObject();
|
|
31708
31924
|
if (_height.isNull()) _height = NumberValueObject.create(rowCount);
|
|
31709
|
-
let _width = width
|
|
31925
|
+
let _width = width ?? NumberValueObject.create(columnCount);
|
|
31710
31926
|
if (_width.isReferenceObject()) _width = _width.toArrayValueObject();
|
|
31711
31927
|
if (_width.isNull()) _width = NumberValueObject.create(columnCount);
|
|
31712
31928
|
const maxRowLength = Math.max(_rows.isArray() ? _rows.getRowCount() : 1, _columns.isArray() ? _columns.getRowCount() : 1, _height.isArray() ? _height.getRowCount() : 1, _width.isArray() ? _width.getRowCount() : 1);
|
|
@@ -31843,9 +32059,9 @@ var Sort = class extends BaseFunction {
|
|
|
31843
32059
|
_defineProperty(this, "maxParams", 4);
|
|
31844
32060
|
}
|
|
31845
32061
|
calculate(array, sortIndex, sortOrder, byCol) {
|
|
31846
|
-
let _sortIndex = sortIndex
|
|
31847
|
-
let _sortOrder = sortOrder
|
|
31848
|
-
const _byCol = byCol
|
|
32062
|
+
let _sortIndex = sortIndex ?? NumberValueObject.create(1);
|
|
32063
|
+
let _sortOrder = sortOrder ?? NumberValueObject.create(1);
|
|
32064
|
+
const _byCol = byCol ?? BooleanValueObject.create(false);
|
|
31849
32065
|
if (_sortIndex.isNull()) _sortIndex = NumberValueObject.create(1);
|
|
31850
32066
|
if (_sortOrder.isNull()) _sortOrder = NumberValueObject.create(1);
|
|
31851
32067
|
if (_byCol.isArray()) {
|
|
@@ -32182,7 +32398,7 @@ var Take = class extends BaseFunction {
|
|
|
32182
32398
|
const arrayRowCount = array.isArray() ? array.getRowCount() : 1;
|
|
32183
32399
|
const arrayColumnCount = array.isArray() ? array.getColumnCount() : 1;
|
|
32184
32400
|
let _rows = rows;
|
|
32185
|
-
let _columns = columns
|
|
32401
|
+
let _columns = columns ?? NumberValueObject.create(arrayColumnCount);
|
|
32186
32402
|
if (rows.isNull()) _rows = NumberValueObject.create(arrayRowCount);
|
|
32187
32403
|
if (_columns.isNull()) _columns = NumberValueObject.create(arrayColumnCount);
|
|
32188
32404
|
const maxRowLength = Math.max(_rows.isArray() ? _rows.getRowCount() : 1, _columns.isArray() ? _columns.getRowCount() : 1);
|
|
@@ -32257,8 +32473,8 @@ var Tocol = class extends BaseFunction {
|
|
|
32257
32473
|
_defineProperty(this, "maxParams", 3);
|
|
32258
32474
|
}
|
|
32259
32475
|
calculate(array, ignore, scanByColumn) {
|
|
32260
|
-
const _ignore = ignore
|
|
32261
|
-
const _scanByColumn = scanByColumn
|
|
32476
|
+
const _ignore = ignore ?? NumberValueObject.create(0);
|
|
32477
|
+
const _scanByColumn = scanByColumn ?? BooleanValueObject.create(false);
|
|
32262
32478
|
const maxRowLength = Math.max(_ignore.isArray() ? _ignore.getRowCount() : 1, _scanByColumn.isArray() ? _scanByColumn.getRowCount() : 1);
|
|
32263
32479
|
const maxColumnLength = Math.max(_ignore.isArray() ? _ignore.getColumnCount() : 1, _scanByColumn.isArray() ? _scanByColumn.getColumnCount() : 1);
|
|
32264
32480
|
const ignoreArray = expandArrayValueObject(maxRowLength, maxColumnLength, _ignore, ErrorValueObject.create("#N/A"));
|
|
@@ -32333,8 +32549,8 @@ var Torow = class extends BaseFunction {
|
|
|
32333
32549
|
_defineProperty(this, "maxParams", 3);
|
|
32334
32550
|
}
|
|
32335
32551
|
calculate(array, ignore, scanByColumn) {
|
|
32336
|
-
const _ignore = ignore
|
|
32337
|
-
const _scanByColumn = scanByColumn
|
|
32552
|
+
const _ignore = ignore ?? NumberValueObject.create(0);
|
|
32553
|
+
const _scanByColumn = scanByColumn ?? BooleanValueObject.create(false);
|
|
32338
32554
|
const maxRowLength = Math.max(_ignore.isArray() ? _ignore.getRowCount() : 1, _scanByColumn.isArray() ? _scanByColumn.getRowCount() : 1);
|
|
32339
32555
|
const maxColumnLength = Math.max(_ignore.isArray() ? _ignore.getColumnCount() : 1, _scanByColumn.isArray() ? _scanByColumn.getColumnCount() : 1);
|
|
32340
32556
|
const ignoreArray = expandArrayValueObject(maxRowLength, maxColumnLength, _ignore, ErrorValueObject.create("#N/A"));
|
|
@@ -32429,8 +32645,8 @@ var Unique = class extends BaseFunction {
|
|
|
32429
32645
|
_defineProperty(this, "maxParams", 3);
|
|
32430
32646
|
}
|
|
32431
32647
|
calculate(array, byCol, exactlyOnce) {
|
|
32432
|
-
const _byCol = byCol
|
|
32433
|
-
const _exactlyOnce = exactlyOnce
|
|
32648
|
+
const _byCol = byCol ?? BooleanValueObject.create(false);
|
|
32649
|
+
const _exactlyOnce = exactlyOnce ?? BooleanValueObject.create(false);
|
|
32434
32650
|
const arrayRowCount = array.isArray() ? array.getRowCount() : 1;
|
|
32435
32651
|
const arrayColumnCount = array.isArray() ? array.getColumnCount() : 1;
|
|
32436
32652
|
const maxRowLength = Math.max(_byCol.isArray() ? _byCol.getRowCount() : 1, _exactlyOnce.isArray() ? _exactlyOnce.getRowCount() : 1);
|
|
@@ -32559,7 +32775,7 @@ var Vlookup = class extends BaseFunction {
|
|
|
32559
32775
|
if (!tableArray.isArray()) return ErrorValueObject.create("#VALUE!");
|
|
32560
32776
|
if (colIndexNum.isError()) return colIndexNum;
|
|
32561
32777
|
if (rangeLookup === null || rangeLookup === void 0 ? void 0 : rangeLookup.isError()) return rangeLookup;
|
|
32562
|
-
const _rangeLookup = rangeLookup
|
|
32778
|
+
const _rangeLookup = rangeLookup ?? BooleanValueObject.create(true);
|
|
32563
32779
|
if (isSingleValueObject(lookupValue) && isSingleValueObject(_rangeLookup) && colIndexNum.isArray()) return this._handleArrayColIndexNum(lookupValue, tableArray, colIndexNum, _rangeLookup);
|
|
32564
32780
|
return this._handleNonArrayColIndexNum(lookupValue, tableArray, colIndexNum, _rangeLookup);
|
|
32565
32781
|
}
|
|
@@ -32682,7 +32898,7 @@ var Wrapcols = class extends BaseFunction {
|
|
|
32682
32898
|
_defineProperty(this, "maxParams", 3);
|
|
32683
32899
|
}
|
|
32684
32900
|
calculate(vector, wrapCount, padWith) {
|
|
32685
|
-
let _padWith = padWith
|
|
32901
|
+
let _padWith = padWith ?? ErrorValueObject.create("#N/A");
|
|
32686
32902
|
if (_padWith.isNull()) _padWith = ErrorValueObject.create("#N/A");
|
|
32687
32903
|
const vectorRowCount = vector.isArray() ? vector.getRowCount() : 1;
|
|
32688
32904
|
const vectorColumnCount = vector.isArray() ? vector.getColumnCount() : 1;
|
|
@@ -32737,7 +32953,7 @@ var Wraprows = class extends BaseFunction {
|
|
|
32737
32953
|
_defineProperty(this, "maxParams", 3);
|
|
32738
32954
|
}
|
|
32739
32955
|
calculate(vector, wrapCount, padWith) {
|
|
32740
|
-
let _padWith = padWith
|
|
32956
|
+
let _padWith = padWith ?? ErrorValueObject.create("#N/A");
|
|
32741
32957
|
if (_padWith.isNull()) _padWith = ErrorValueObject.create("#N/A");
|
|
32742
32958
|
const vectorRowCount = vector.isArray() ? vector.getRowCount() : 1;
|
|
32743
32959
|
const vectorColumnCount = vector.isArray() ? vector.getColumnCount() : 1;
|
|
@@ -32795,13 +33011,13 @@ var Xlookup = class extends BaseFunction {
|
|
|
32795
33011
|
_defineProperty(this, "maxParams", 6);
|
|
32796
33012
|
}
|
|
32797
33013
|
calculate(lookupValue, lookupArray, returnArray, ifNotFound, matchMode, searchMode) {
|
|
32798
|
-
let _ifNotFound = ifNotFound
|
|
33014
|
+
let _ifNotFound = ifNotFound ?? ErrorValueObject.create("#N/A");
|
|
32799
33015
|
if (ifNotFound === null || ifNotFound === void 0 ? void 0 : ifNotFound.isNull()) _ifNotFound = ErrorValueObject.create("#N/A");
|
|
32800
|
-
let _matchMode = matchMode
|
|
33016
|
+
let _matchMode = matchMode ?? NumberValueObject.create(0);
|
|
32801
33017
|
if (matchMode === null || matchMode === void 0 ? void 0 : matchMode.isNull()) _matchMode = NumberValueObject.create(0);
|
|
32802
|
-
let _searchMode = searchMode
|
|
33018
|
+
let _searchMode = searchMode ?? NumberValueObject.create(1);
|
|
32803
33019
|
if (searchMode === null || searchMode === void 0 ? void 0 : searchMode.isNull()) _searchMode = NumberValueObject.create(1);
|
|
32804
|
-
const _lookupValue = this._legacyImplicitLookupValue(lookupValue);
|
|
33020
|
+
const _lookupValue = this.currentFormulaRowCount > 1 || this.currentFormulaColumnCount > 1 ? lookupValue : this._legacyImplicitLookupValue(lookupValue);
|
|
32805
33021
|
if (_lookupValue.isError()) return _lookupValue;
|
|
32806
33022
|
const rowCountLookup = lookupArray.isArray() ? lookupArray.getRowCount() : 1;
|
|
32807
33023
|
const columnCountLookup = lookupArray.isArray() ? lookupArray.getColumnCount() : 1;
|
|
@@ -32883,8 +33099,8 @@ var Xlookup = class extends BaseFunction {
|
|
|
32883
33099
|
return this.binarySearchExpand(value, searchArray, resultArray, axis, searchType, matchType);
|
|
32884
33100
|
}
|
|
32885
33101
|
if (matchModeValue === 2) return this.fuzzySearchExpand(value, searchArray, resultArray, searchModeValue !== -1, axis);
|
|
32886
|
-
if (matchModeValue === -1 || matchModeValue === 1) return this.orderSearchExpand(value, searchArray, resultArray, matchModeValue === 1 ? 2 : 1, searchModeValue === -1, axis);
|
|
32887
|
-
return this.
|
|
33102
|
+
if (matchModeValue === -1 || matchModeValue === 1) return this.orderSearchExpand(value, searchArray, resultArray, matchModeValue === 1 ? 2 : 1, searchModeValue === -1, axis, true);
|
|
33103
|
+
return this._exactSearchExpand(value, searchArray, resultArray, searchModeValue !== -1, axis);
|
|
32888
33104
|
}
|
|
32889
33105
|
_handleSingleObject(value, searchArray, resultArray, matchModeValue, searchModeValue) {
|
|
32890
33106
|
if ((searchModeValue === 2 || searchModeValue === -2) && matchModeValue !== 2) {
|
|
@@ -32893,8 +33109,38 @@ var Xlookup = class extends BaseFunction {
|
|
|
32893
33109
|
return this.binarySearch(value, searchArray, resultArray, searchType, matchType);
|
|
32894
33110
|
}
|
|
32895
33111
|
if (matchModeValue === 2) return this.fuzzySearch(value, searchArray, resultArray, searchModeValue !== -1);
|
|
32896
|
-
if (matchModeValue === -1 || matchModeValue === 1) return this.orderSearch(value, searchArray, resultArray, matchModeValue === 1 ? 2 : 1, searchModeValue === -1);
|
|
32897
|
-
return this.
|
|
33112
|
+
if (matchModeValue === -1 || matchModeValue === 1) return this.orderSearch(value, searchArray, resultArray, matchModeValue === 1 ? 2 : 1, searchModeValue === -1, true);
|
|
33113
|
+
return this._exactSearch(value, searchArray, resultArray, searchModeValue !== -1);
|
|
33114
|
+
}
|
|
33115
|
+
_exactSearch(value, searchArray, resultArray, isFirst) {
|
|
33116
|
+
const position = this._findExactPosition(value, searchArray, isFirst);
|
|
33117
|
+
if (position == null) return ErrorValueObject.create("#N/A");
|
|
33118
|
+
return resultArray.get(position.row, position.column) ?? ErrorValueObject.create("#N/A");
|
|
33119
|
+
}
|
|
33120
|
+
_exactSearchExpand(value, searchArray, resultArray, isFirst, axis) {
|
|
33121
|
+
const position = this._findExactPosition(value, searchArray, isFirst);
|
|
33122
|
+
if (position == null) return ErrorValueObject.create("#N/A");
|
|
33123
|
+
return axis === 0 ? resultArray.slice([position.row, position.row + 1]) ?? ErrorValueObject.create("#N/A") : resultArray.slice(void 0, [position.column, position.column + 1]) ?? ErrorValueObject.create("#N/A");
|
|
33124
|
+
}
|
|
33125
|
+
_findExactPosition(value, searchArray, isFirst) {
|
|
33126
|
+
let position;
|
|
33127
|
+
const find = (candidate, row, column) => {
|
|
33128
|
+
if (candidate != null && this._isExactMatch(candidate, value)) {
|
|
33129
|
+
position = {
|
|
33130
|
+
row,
|
|
33131
|
+
column
|
|
33132
|
+
};
|
|
33133
|
+
return false;
|
|
33134
|
+
}
|
|
33135
|
+
};
|
|
33136
|
+
if (isFirst) searchArray.iterator(find);
|
|
33137
|
+
else searchArray.iteratorReverse(find);
|
|
33138
|
+
return position;
|
|
33139
|
+
}
|
|
33140
|
+
_isExactMatch(candidate, value) {
|
|
33141
|
+
if (candidate.isError() || value.isError()) return candidate.isError() && value.isError() && candidate.getValue() === value.getValue();
|
|
33142
|
+
if (candidate.isNull() !== value.isNull() || candidate.isNumber() !== value.isNumber() || candidate.isString() !== value.isString() || candidate.isBoolean() !== value.isBoolean()) return false;
|
|
33143
|
+
return candidate.isEqual(value).getValue() === true;
|
|
32898
33144
|
}
|
|
32899
33145
|
_blankResultAsZero(value) {
|
|
32900
33146
|
if (value.isNull()) return NumberValueObject.create(0);
|
|
@@ -33437,7 +33683,7 @@ var Base = class extends BaseFunction {
|
|
|
33437
33683
|
_defineProperty(this, "maxParams", 3);
|
|
33438
33684
|
}
|
|
33439
33685
|
calculate(number, radix, minLength) {
|
|
33440
|
-
const _minLength = minLength
|
|
33686
|
+
const _minLength = minLength ?? NumberValueObject.create(0);
|
|
33441
33687
|
if (number.isError()) return number;
|
|
33442
33688
|
if (radix.isError()) return radix;
|
|
33443
33689
|
if (_minLength.isError()) return _minLength;
|
|
@@ -33519,8 +33765,8 @@ var CeilingMath = class extends BaseFunction {
|
|
|
33519
33765
|
_defineProperty(this, "maxParams", 3);
|
|
33520
33766
|
}
|
|
33521
33767
|
calculate(number, significance, mode) {
|
|
33522
|
-
const _significance = significance
|
|
33523
|
-
const _mode = mode
|
|
33768
|
+
const _significance = significance ?? NumberValueObject.create(1);
|
|
33769
|
+
const _mode = mode ?? NumberValueObject.create(0);
|
|
33524
33770
|
if (number.isError()) return number;
|
|
33525
33771
|
if (_significance.isError()) return _significance;
|
|
33526
33772
|
if (_mode.isError()) return _mode;
|
|
@@ -33565,7 +33811,7 @@ var CeilingPrecise = class extends BaseFunction {
|
|
|
33565
33811
|
_defineProperty(this, "maxParams", 2);
|
|
33566
33812
|
}
|
|
33567
33813
|
calculate(number, significance) {
|
|
33568
|
-
const _significance = significance
|
|
33814
|
+
const _significance = significance ?? NumberValueObject.create(1);
|
|
33569
33815
|
if (number.isError()) return number;
|
|
33570
33816
|
if (_significance.isError()) return _significance;
|
|
33571
33817
|
const maxRowLength = Math.max(number.isArray() ? number.getRowCount() : 1, _significance.isArray() ? _significance.getRowCount() : 1);
|
|
@@ -33979,8 +34225,8 @@ var FloorMath = class extends BaseFunction {
|
|
|
33979
34225
|
_defineProperty(this, "maxParams", 3);
|
|
33980
34226
|
}
|
|
33981
34227
|
calculate(number, significance, mode) {
|
|
33982
|
-
const _significance = significance
|
|
33983
|
-
const _mode = mode
|
|
34228
|
+
const _significance = significance ?? NumberValueObject.create(1);
|
|
34229
|
+
const _mode = mode ?? NumberValueObject.create(0);
|
|
33984
34230
|
const maxRowLength = Math.max(number.isArray() ? number.getRowCount() : 1, _significance.isArray() ? _significance.getRowCount() : 1, _mode.isArray() ? _mode.getRowCount() : 1);
|
|
33985
34231
|
const maxColumnLength = Math.max(number.isArray() ? number.getColumnCount() : 1, _significance.isArray() ? _significance.getColumnCount() : 1, _mode.isArray() ? _mode.getColumnCount() : 1);
|
|
33986
34232
|
const numberArray = expandArrayValueObject(maxRowLength, maxColumnLength, number, ErrorValueObject.create("#N/A"));
|
|
@@ -34019,7 +34265,7 @@ var FloorPrecise = class extends BaseFunction {
|
|
|
34019
34265
|
_defineProperty(this, "maxParams", 2);
|
|
34020
34266
|
}
|
|
34021
34267
|
calculate(number, significance) {
|
|
34022
|
-
const _significance = significance
|
|
34268
|
+
const _significance = significance ?? NumberValueObject.create(1);
|
|
34023
34269
|
if (number.isError()) return number;
|
|
34024
34270
|
if (_significance.isError()) return _significance;
|
|
34025
34271
|
const maxRowLength = Math.max(number.isArray() ? number.getRowCount() : 1, _significance.isArray() ? _significance.getRowCount() : 1);
|
|
@@ -34219,7 +34465,7 @@ var Log = class extends BaseFunction {
|
|
|
34219
34465
|
_defineProperty(this, "maxParams", 2);
|
|
34220
34466
|
}
|
|
34221
34467
|
calculate(number, base) {
|
|
34222
|
-
const _base = base
|
|
34468
|
+
const _base = base ?? NumberValueObject.create(10);
|
|
34223
34469
|
if (number.isError()) return number;
|
|
34224
34470
|
if (_base.isError()) return _base;
|
|
34225
34471
|
const maxRowLength = Math.max(number.isArray() ? number.getRowCount() : 1, _base.isArray() ? _base.getRowCount() : 1);
|
|
@@ -34732,11 +34978,11 @@ var Randarray = class extends BaseFunction {
|
|
|
34732
34978
|
if (min === null || min === void 0 ? void 0 : min.isError()) return min;
|
|
34733
34979
|
if (max === null || max === void 0 ? void 0 : max.isError()) return max;
|
|
34734
34980
|
if (wholeNumber === null || wholeNumber === void 0 ? void 0 : wholeNumber.isError()) return wholeNumber;
|
|
34735
|
-
const _rows = rows
|
|
34736
|
-
const _columns = columns
|
|
34737
|
-
const _min = min
|
|
34738
|
-
const _max = max
|
|
34739
|
-
const _wholeNumber = wholeNumber
|
|
34981
|
+
const _rows = rows ?? NumberValueObject.create(1);
|
|
34982
|
+
const _columns = columns ?? NumberValueObject.create(1);
|
|
34983
|
+
const _min = min ?? NumberValueObject.create(0);
|
|
34984
|
+
const _max = max ?? NumberValueObject.create(1);
|
|
34985
|
+
const _wholeNumber = wholeNumber ?? NumberValueObject.create(0);
|
|
34740
34986
|
return this._calculateResult(_rows, _columns, _min, _max, _wholeNumber);
|
|
34741
34987
|
}
|
|
34742
34988
|
_calculateResult(rows, columns, min, max, wholeNumber) {
|
|
@@ -34883,7 +35129,7 @@ var Roman = class extends BaseFunction {
|
|
|
34883
35129
|
_defineProperty(this, "maxParams", 2);
|
|
34884
35130
|
}
|
|
34885
35131
|
calculate(number, form) {
|
|
34886
|
-
const _form = form
|
|
35132
|
+
const _form = form ?? NumberValueObject.create(0);
|
|
34887
35133
|
const maxRowLength = Math.max(number.isArray() ? number.getRowCount() : 1, _form.isArray() ? _form.getRowCount() : 1);
|
|
34888
35134
|
const maxColumnLength = Math.max(number.isArray() ? number.getColumnCount() : 1, _form.isArray() ? _form.getColumnCount() : 1);
|
|
34889
35135
|
const numberArray = expandArrayValueObject(maxRowLength, maxColumnLength, number, ErrorValueObject.create("#N/A"));
|
|
@@ -35090,9 +35336,9 @@ var Sequence = class extends BaseFunction {
|
|
|
35090
35336
|
}
|
|
35091
35337
|
calculate(rows, columns, start, step) {
|
|
35092
35338
|
let _rows = rows;
|
|
35093
|
-
let _columns = columns
|
|
35094
|
-
let _start = start
|
|
35095
|
-
let _step = step
|
|
35339
|
+
let _columns = columns ?? NumberValueObject.create(1);
|
|
35340
|
+
let _start = start ?? NumberValueObject.create(1);
|
|
35341
|
+
let _step = step ?? NumberValueObject.create(1);
|
|
35096
35342
|
if (_rows.isNull()) _rows = NumberValueObject.create(1);
|
|
35097
35343
|
if (_columns.isNull()) _columns = NumberValueObject.create(1);
|
|
35098
35344
|
if (_start.isNull()) _start = NumberValueObject.create(1);
|
|
@@ -35446,8 +35692,7 @@ var Subtotal = class extends BaseFunction {
|
|
|
35446
35692
|
multiAreaRefs.forEach((ref) => {
|
|
35447
35693
|
const rowAreas = ref.getAreas().map((row) => {
|
|
35448
35694
|
if (!row || row.length === 0) return ref;
|
|
35449
|
-
|
|
35450
|
-
return firstNonError !== null && firstNonError !== void 0 ? firstNonError : row[0];
|
|
35695
|
+
return row.find((a) => !a.isError()) ?? row[0];
|
|
35451
35696
|
});
|
|
35452
35697
|
multiAreaInfoMap.set(ref, {
|
|
35453
35698
|
ref,
|
|
@@ -35462,54 +35707,6 @@ var Subtotal = class extends BaseFunction {
|
|
|
35462
35707
|
}
|
|
35463
35708
|
};
|
|
35464
35709
|
|
|
35465
|
-
//#endregion
|
|
35466
|
-
//#region src/functions/math/sum/index.ts
|
|
35467
|
-
var Sum = class extends BaseFunction {
|
|
35468
|
-
constructor(..._args) {
|
|
35469
|
-
super(..._args);
|
|
35470
|
-
_defineProperty(this, "minParams", 1);
|
|
35471
|
-
_defineProperty(this, "maxParams", 255);
|
|
35472
|
-
}
|
|
35473
|
-
calculate(...variants) {
|
|
35474
|
-
let accumulatorAll = NumberValueObject.create(0);
|
|
35475
|
-
for (let i = 0; i < variants.length; i++) {
|
|
35476
|
-
let variant = variants[i];
|
|
35477
|
-
variant = this._legacyImplicitDerivedArray(variant);
|
|
35478
|
-
if (variant.isString()) variant = variant.convertToNumberObjectValue();
|
|
35479
|
-
if (variant.isError()) return variant;
|
|
35480
|
-
if (variant.isArray()) variant = variant.sum();
|
|
35481
|
-
if (variant.isError()) return variant;
|
|
35482
|
-
accumulatorAll = accumulatorAll.plus(variant);
|
|
35483
|
-
if (accumulatorAll.isError()) return accumulatorAll;
|
|
35484
|
-
}
|
|
35485
|
-
return accumulatorAll;
|
|
35486
|
-
}
|
|
35487
|
-
_legacyImplicitDerivedArray(variant) {
|
|
35488
|
-
if (!variant.isArray()) return variant;
|
|
35489
|
-
const array = variant;
|
|
35490
|
-
if (array.usesInvertedIndexCache() || !array.usesLegacyImplicitForAggregate()) return variant;
|
|
35491
|
-
const startRow = array.getCurrentRow();
|
|
35492
|
-
const startColumn = array.getCurrentColumn();
|
|
35493
|
-
if (startRow < 0 || startColumn < 0) return variant;
|
|
35494
|
-
const rowCount = array.getRowCount();
|
|
35495
|
-
const columnCount = array.getColumnCount();
|
|
35496
|
-
let rowIndex = -1;
|
|
35497
|
-
let columnIndex = -1;
|
|
35498
|
-
if (rowCount === 1) {
|
|
35499
|
-
rowIndex = 0;
|
|
35500
|
-
columnIndex = this.column - startColumn;
|
|
35501
|
-
} else if (columnCount === 1) {
|
|
35502
|
-
rowIndex = this.row - startRow;
|
|
35503
|
-
columnIndex = 0;
|
|
35504
|
-
} else {
|
|
35505
|
-
rowIndex = this.row - startRow;
|
|
35506
|
-
columnIndex = this.column - startColumn;
|
|
35507
|
-
}
|
|
35508
|
-
if (rowIndex < 0 || rowIndex >= rowCount || columnIndex < 0 || columnIndex >= columnCount) return variant;
|
|
35509
|
-
return array.get(rowIndex, columnIndex) || variant;
|
|
35510
|
-
}
|
|
35511
|
-
};
|
|
35512
|
-
|
|
35513
35710
|
//#endregion
|
|
35514
35711
|
//#region src/functions/math/sumif/index.ts
|
|
35515
35712
|
var Sumif = class extends BaseFunction {
|
|
@@ -35596,6 +35793,7 @@ var Sumproduct = class extends BaseFunction {
|
|
|
35596
35793
|
super(..._args);
|
|
35597
35794
|
_defineProperty(this, "minParams", 1);
|
|
35598
35795
|
_defineProperty(this, "maxParams", 255);
|
|
35796
|
+
_defineProperty(this, "lazyIfReferenceArrayArgumentIndexes", Array.from({ length: this.maxParams }, (_, index) => index));
|
|
35599
35797
|
}
|
|
35600
35798
|
calculate(array1, ...variants) {
|
|
35601
35799
|
if (array1.isError()) return array1;
|
|
@@ -35658,8 +35856,7 @@ var Sumproduct = class extends BaseFunction {
|
|
|
35658
35856
|
*/
|
|
35659
35857
|
_getVariantCell(variant, row, col) {
|
|
35660
35858
|
if (!variant.isArray()) return variant;
|
|
35661
|
-
|
|
35662
|
-
return cell !== null && cell !== void 0 ? cell : null;
|
|
35859
|
+
return variant.get(row, col) ?? null;
|
|
35663
35860
|
}
|
|
35664
35861
|
_initArray1(array1) {
|
|
35665
35862
|
let _array1 = array1;
|
|
@@ -35941,7 +36138,7 @@ var Trunc = class extends BaseFunction {
|
|
|
35941
36138
|
_defineProperty(this, "maxParams", 2);
|
|
35942
36139
|
}
|
|
35943
36140
|
calculate(number, numDigits) {
|
|
35944
|
-
const _numDigits = numDigits
|
|
36141
|
+
const _numDigits = numDigits ?? NumberValueObject.create(0);
|
|
35945
36142
|
const maxRowLength = Math.max(number.isArray() ? number.getRowCount() : 1, _numDigits.isArray() ? _numDigits.getRowCount() : 1);
|
|
35946
36143
|
const maxColumnLength = Math.max(number.isArray() ? number.getColumnCount() : 1, _numDigits.isArray() ? _numDigits.getColumnCount() : 1);
|
|
35947
36144
|
const numberArray = expandArrayValueObject(maxRowLength, maxColumnLength, number, ErrorValueObject.create("#N/A"));
|
|
@@ -36586,8 +36783,8 @@ var BetaDist = class extends BaseFunction {
|
|
|
36586
36783
|
_defineProperty(this, "maxParams", 6);
|
|
36587
36784
|
}
|
|
36588
36785
|
calculate(x, alpha, beta, cumulative, A, B) {
|
|
36589
|
-
let _A = A
|
|
36590
|
-
let _B = B
|
|
36786
|
+
let _A = A ?? NumberValueObject.create(0);
|
|
36787
|
+
let _B = B ?? NumberValueObject.create(1);
|
|
36591
36788
|
if (_A.isNull()) _A = NumberValueObject.create(0);
|
|
36592
36789
|
if (_B.isNull()) _B = NumberValueObject.create(1);
|
|
36593
36790
|
const maxRowLength = Math.max(x.isArray() ? x.getRowCount() : 1, alpha.isArray() ? alpha.getRowCount() : 1, beta.isArray() ? beta.getRowCount() : 1, cumulative.isArray() ? cumulative.getRowCount() : 1, _A.isArray() ? _A.getRowCount() : 1, _B.isArray() ? _B.getRowCount() : 1);
|
|
@@ -36642,7 +36839,7 @@ var BinomDistRange = class extends BaseFunction {
|
|
|
36642
36839
|
_defineProperty(this, "maxParams", 4);
|
|
36643
36840
|
}
|
|
36644
36841
|
calculate(trials, probabilityS, numberS, numberS2) {
|
|
36645
|
-
let _numberS2 = numberS2
|
|
36842
|
+
let _numberS2 = numberS2 ?? numberS;
|
|
36646
36843
|
if (_numberS2.isNull()) _numberS2 = numberS;
|
|
36647
36844
|
const maxRowLength = Math.max(trials.isArray() ? trials.getRowCount() : 1, probabilityS.isArray() ? probabilityS.getRowCount() : 1, numberS.isArray() ? numberS.getRowCount() : 1, _numberS2.isArray() ? _numberS2.getRowCount() : 1);
|
|
36648
36845
|
const maxColumnLength = Math.max(trials.isArray() ? trials.getColumnCount() : 1, probabilityS.isArray() ? probabilityS.getColumnCount() : 1, numberS.isArray() ? numberS.getColumnCount() : 1, _numberS2.isArray() ? _numberS2.getColumnCount() : 1);
|
|
@@ -37515,7 +37712,7 @@ var Growth = class extends BaseFunction {
|
|
|
37515
37712
|
if (knownXsValues instanceof ErrorValueObject) return knownXsValues;
|
|
37516
37713
|
const newXsValues = this._getNewXsValues(knownXsValues, newXs);
|
|
37517
37714
|
if (newXsValues instanceof ErrorValueObject) return newXsValues;
|
|
37518
|
-
let _constb = constb
|
|
37715
|
+
let _constb = constb ?? BooleanValueObject.create(true);
|
|
37519
37716
|
if (_constb.isArray()) _constb = _constb.get(0, 0);
|
|
37520
37717
|
if (_constb.isString()) _constb = _constb.convertToNumberObjectValue();
|
|
37521
37718
|
if (_constb.isError()) return _constb;
|
|
@@ -37795,9 +37992,9 @@ var Linest = class extends BaseFunction {
|
|
|
37795
37992
|
if (knownYsValues instanceof ErrorValueObject) return knownYsValues;
|
|
37796
37993
|
const knownXsValues = this._getKnownXsValues(knownYsValues, knownXs);
|
|
37797
37994
|
if (knownXsValues instanceof ErrorValueObject) return knownXsValues;
|
|
37798
|
-
let _constb = constb
|
|
37995
|
+
let _constb = constb ?? BooleanValueObject.create(true);
|
|
37799
37996
|
if (_constb.isArray()) _constb = _constb.get(0, 0);
|
|
37800
|
-
let _stats = stats
|
|
37997
|
+
let _stats = stats ?? BooleanValueObject.create(false);
|
|
37801
37998
|
if (_stats.isArray()) _stats = _stats.get(0, 0);
|
|
37802
37999
|
const { isError: _isError, errorObject: _errorObject, variants } = checkVariantsErrorIsStringToNumber(_constb, _stats);
|
|
37803
38000
|
if (_isError) return _errorObject;
|
|
@@ -37952,9 +38149,9 @@ var Logest = class extends BaseFunction {
|
|
|
37952
38149
|
if (knownYsValues instanceof ErrorValueObject) return knownYsValues;
|
|
37953
38150
|
const knownXsValues = this._getKnownXsValues(knownYsValues, knownXs);
|
|
37954
38151
|
if (knownXsValues instanceof ErrorValueObject) return knownXsValues;
|
|
37955
|
-
let _constb = constb
|
|
38152
|
+
let _constb = constb ?? BooleanValueObject.create(true);
|
|
37956
38153
|
if (_constb.isArray()) _constb = _constb.get(0, 0);
|
|
37957
|
-
let _stats = stats
|
|
38154
|
+
let _stats = stats ?? BooleanValueObject.create(false);
|
|
37958
38155
|
if (_stats.isArray()) _stats = _stats.get(0, 0);
|
|
37959
38156
|
const { isError: _isError, errorObject: _errorObject, variants } = checkVariantsErrorIsStringToNumber(_constb, _stats);
|
|
37960
38157
|
if (_isError) return _errorObject;
|
|
@@ -38294,6 +38491,7 @@ var Median = class extends BaseFunction {
|
|
|
38294
38491
|
super(..._args);
|
|
38295
38492
|
_defineProperty(this, "minParams", 1);
|
|
38296
38493
|
_defineProperty(this, "maxParams", 255);
|
|
38494
|
+
_defineProperty(this, "lazyIfReferenceArrayArgumentIndexes", Array.from({ length: this.maxParams }, (_, index) => index));
|
|
38297
38495
|
}
|
|
38298
38496
|
calculate(...variants) {
|
|
38299
38497
|
const values = [];
|
|
@@ -38624,6 +38822,7 @@ var PercentileExc = class extends BaseFunction {
|
|
|
38624
38822
|
super(..._args);
|
|
38625
38823
|
_defineProperty(this, "minParams", 2);
|
|
38626
38824
|
_defineProperty(this, "maxParams", 2);
|
|
38825
|
+
_defineProperty(this, "lazyIfReferenceArrayArgumentIndexes", [0]);
|
|
38627
38826
|
}
|
|
38628
38827
|
calculate(array, k) {
|
|
38629
38828
|
const arrayValues = getArrayValuesByAggregateIgnoreOptions(array);
|
|
@@ -38653,7 +38852,7 @@ var PercentrankExc = class extends BaseFunction {
|
|
|
38653
38852
|
}
|
|
38654
38853
|
calculate(array, x, significance) {
|
|
38655
38854
|
const arrayValues = this._getValues(array);
|
|
38656
|
-
let _significance = significance
|
|
38855
|
+
let _significance = significance ?? NumberValueObject.create(3);
|
|
38657
38856
|
if (_significance.isNull()) _significance = NumberValueObject.create(3);
|
|
38658
38857
|
const maxRowLength = Math.max(x.isArray() ? x.getRowCount() : 1, _significance.isArray() ? _significance.getRowCount() : 1);
|
|
38659
38858
|
const maxColumnLength = Math.max(x.isArray() ? x.getColumnCount() : 1, _significance.isArray() ? _significance.getColumnCount() : 1);
|
|
@@ -38816,7 +39015,7 @@ var Prob = class extends BaseFunction {
|
|
|
38816
39015
|
}
|
|
38817
39016
|
calculate(xRange, probRange, lowerLimit, upperLimit) {
|
|
38818
39017
|
const { isError, errorObject, xRangeValues, probRangeValues } = this._handleXRangeAndProbRange(xRange, probRange);
|
|
38819
|
-
let _upperLimit = upperLimit
|
|
39018
|
+
let _upperLimit = upperLimit ?? lowerLimit;
|
|
38820
39019
|
if (upperLimit === null || upperLimit === void 0 ? void 0 : upperLimit.isNull()) _upperLimit = lowerLimit;
|
|
38821
39020
|
const maxRowLength = Math.max(lowerLimit.isArray() ? lowerLimit.getRowCount() : 1, _upperLimit.isArray() ? _upperLimit.getRowCount() : 1);
|
|
38822
39021
|
const maxColumnLength = Math.max(lowerLimit.isArray() ? lowerLimit.getColumnCount() : 1, _upperLimit.isArray() ? _upperLimit.getColumnCount() : 1);
|
|
@@ -38941,12 +39140,13 @@ var RankAvg = class extends BaseFunction {
|
|
|
38941
39140
|
_defineProperty(this, "minParams", 2);
|
|
38942
39141
|
_defineProperty(this, "maxParams", 3);
|
|
38943
39142
|
_defineProperty(this, "needsReferenceObject", true);
|
|
39143
|
+
_defineProperty(this, "lazyIfReferenceArrayArgumentIndexes", [1]);
|
|
38944
39144
|
}
|
|
38945
39145
|
calculate(number, ref, order) {
|
|
38946
39146
|
let _number = number;
|
|
38947
39147
|
if (_number.isReferenceObject()) _number = _number.toArrayValueObject();
|
|
38948
39148
|
const { refHasError, refErrorObject, refNumbers } = this._checkRefReferenceObject(ref);
|
|
38949
|
-
let _order = order
|
|
39149
|
+
let _order = order ?? NumberValueObject.create(0);
|
|
38950
39150
|
if (_order.isReferenceObject()) _order = _order.toArrayValueObject();
|
|
38951
39151
|
const maxRowLength = Math.max(_number.isArray() ? _number.getRowCount() : 1, _order.isArray() ? _order.getRowCount() : 1);
|
|
38952
39152
|
const maxColumnLength = Math.max(_number.isArray() ? _number.getColumnCount() : 1, _order.isArray() ? _order.getColumnCount() : 1);
|
|
@@ -39015,12 +39215,13 @@ var RankEq = class extends BaseFunction {
|
|
|
39015
39215
|
_defineProperty(this, "minParams", 2);
|
|
39016
39216
|
_defineProperty(this, "maxParams", 3);
|
|
39017
39217
|
_defineProperty(this, "needsReferenceObject", true);
|
|
39218
|
+
_defineProperty(this, "lazyIfReferenceArrayArgumentIndexes", [1]);
|
|
39018
39219
|
}
|
|
39019
39220
|
calculate(number, ref, order) {
|
|
39020
39221
|
let _number = number;
|
|
39021
39222
|
if (_number.isReferenceObject()) _number = _number.toArrayValueObject();
|
|
39022
39223
|
const { refHasError, refErrorObject, refNumbers } = this._checkRefReferenceObject(ref);
|
|
39023
|
-
let _order = order
|
|
39224
|
+
let _order = order ?? NumberValueObject.create(0);
|
|
39024
39225
|
if (_order.isReferenceObject()) _order = _order.toArrayValueObject();
|
|
39025
39226
|
const maxRowLength = Math.max(_number.isArray() ? _number.getRowCount() : 1, _order.isArray() ? _order.getRowCount() : 1);
|
|
39026
39227
|
const maxColumnLength = Math.max(_number.isArray() ? _number.getColumnCount() : 1, _order.isArray() ? _order.getColumnCount() : 1);
|
|
@@ -39579,7 +39780,7 @@ var Trend = class extends BaseFunction {
|
|
|
39579
39780
|
if (knownXsValues instanceof ErrorValueObject) return knownXsValues;
|
|
39580
39781
|
const newXsValues = this._getNewXsValues(knownXsValues, newXs);
|
|
39581
39782
|
if (newXsValues instanceof ErrorValueObject) return newXsValues;
|
|
39582
|
-
let _constb = constb
|
|
39783
|
+
let _constb = constb ?? BooleanValueObject.create(true);
|
|
39583
39784
|
if (_constb.isArray()) _constb = _constb.get(0, 0);
|
|
39584
39785
|
if (_constb.isString()) _constb = _constb.convertToNumberObjectValue();
|
|
39585
39786
|
if (_constb.isError()) return _constb;
|
|
@@ -39848,7 +40049,7 @@ var Arraytotext = class extends BaseFunction {
|
|
|
39848
40049
|
_defineProperty(this, "maxParams", 2);
|
|
39849
40050
|
}
|
|
39850
40051
|
calculate(array, format) {
|
|
39851
|
-
let _format = format
|
|
40052
|
+
let _format = format ?? NumberValueObject.create(0);
|
|
39852
40053
|
if (format === null || format === void 0 ? void 0 : format.isNull()) _format = NumberValueObject.create(0);
|
|
39853
40054
|
if (_format.isArray()) {
|
|
39854
40055
|
const resultArray = _format.mapValue((formatObject) => this._handleSingleObject(array, formatObject));
|
|
@@ -40158,12 +40359,11 @@ var Concatenate = class extends BaseFunction {
|
|
|
40158
40359
|
return arrayValue.getUnitId() !== "" && arrayValue.getSheetId() !== "" && arrayValue.getCurrentRow() >= 0 && arrayValue.getCurrentColumn() >= 0;
|
|
40159
40360
|
});
|
|
40160
40361
|
for (const textValue of textValues) result = expandArrayValueObject(maxRowLength, maxColumnLength, textValue, ErrorValueObject.create("#N/A")).mapValue((textValueObject, rowIndex, columnIndex) => {
|
|
40161
|
-
var _resultValueObject$ge, _textValueObject$getV;
|
|
40162
40362
|
const resultValueObject = result && result.get(rowIndex, columnIndex);
|
|
40163
40363
|
if (resultValueObject === null || resultValueObject === void 0 ? void 0 : resultValueObject.isError()) return resultValueObject;
|
|
40164
40364
|
if (textValueObject.isError()) return textValueObject;
|
|
40165
|
-
const resultValueObjectString = (resultValueObject === null || resultValueObject === void 0 ? void 0 : resultValueObject.isNull()) ? "" : formatValueForFormulaText((
|
|
40166
|
-
const textValueObjectString = (textValueObject === null || textValueObject === void 0 ? void 0 : textValueObject.isNull()) ? "" : formatValueForFormulaText((
|
|
40365
|
+
const resultValueObjectString = (resultValueObject === null || resultValueObject === void 0 ? void 0 : resultValueObject.isNull()) ? "" : formatValueForFormulaText((resultValueObject === null || resultValueObject === void 0 ? void 0 : resultValueObject.getValue()) ?? null);
|
|
40366
|
+
const textValueObjectString = (textValueObject === null || textValueObject === void 0 ? void 0 : textValueObject.isNull()) ? "" : formatValueForFormulaText((textValueObject === null || textValueObject === void 0 ? void 0 : textValueObject.getValue()) ?? null);
|
|
40167
40367
|
return StringValueObject.create(`${resultValueObjectString}${textValueObjectString}`);
|
|
40168
40368
|
});
|
|
40169
40369
|
if (!result) return ErrorValueObject.create("#VALUE!");
|
|
@@ -40219,7 +40419,7 @@ var Dollar = class extends BaseFunction {
|
|
|
40219
40419
|
_defineProperty(this, "needsLocale", true);
|
|
40220
40420
|
}
|
|
40221
40421
|
calculate(number, decimals) {
|
|
40222
|
-
let _decimals = decimals
|
|
40422
|
+
let _decimals = decimals ?? NumberValueObject.create(2);
|
|
40223
40423
|
if (_decimals.isNull()) _decimals = NumberValueObject.create(2);
|
|
40224
40424
|
const maxRowLength = Math.max(number.isArray() ? number.getRowCount() : 1, _decimals.isArray() ? _decimals.getRowCount() : 1);
|
|
40225
40425
|
const maxColumnLength = Math.max(number.isArray() ? number.getColumnCount() : 1, _decimals.isArray() ? _decimals.getColumnCount() : 1);
|
|
@@ -40318,7 +40518,7 @@ var Find = class extends BaseFunction {
|
|
|
40318
40518
|
_defineProperty(this, "maxParams", 3);
|
|
40319
40519
|
}
|
|
40320
40520
|
calculate(findText, withinText, startNum) {
|
|
40321
|
-
const _startNum = startNum
|
|
40521
|
+
const _startNum = startNum ?? NumberValueObject.create(1);
|
|
40322
40522
|
const maxRowLength = Math.max(findText.isArray() ? findText.getRowCount() : 1, withinText.isArray() ? withinText.getRowCount() : 1, _startNum.isArray() ? _startNum.getRowCount() : 1);
|
|
40323
40523
|
const maxColumnLength = Math.max(findText.isArray() ? findText.getColumnCount() : 1, withinText.isArray() ? withinText.getColumnCount() : 1, _startNum.isArray() ? _startNum.getColumnCount() : 1);
|
|
40324
40524
|
const findTextArray = expandArrayValueObject(maxRowLength, maxColumnLength, findText, ErrorValueObject.create("#N/A"));
|
|
@@ -40412,7 +40612,7 @@ var Findb = class extends BaseFunction {
|
|
|
40412
40612
|
_defineProperty(this, "maxParams", 3);
|
|
40413
40613
|
}
|
|
40414
40614
|
calculate(findText, withinText, startNum) {
|
|
40415
|
-
const _startNum = startNum
|
|
40615
|
+
const _startNum = startNum ?? NumberValueObject.create(1);
|
|
40416
40616
|
const maxRowLength = Math.max(findText.isArray() ? findText.getRowCount() : 1, withinText.isArray() ? withinText.getRowCount() : 1, _startNum.isArray() ? _startNum.getRowCount() : 1);
|
|
40417
40617
|
const maxColumnLength = Math.max(findText.isArray() ? findText.getColumnCount() : 1, withinText.isArray() ? withinText.getColumnCount() : 1, _startNum.isArray() ? _startNum.getColumnCount() : 1);
|
|
40418
40618
|
const findTextArray = expandArrayValueObject(maxRowLength, maxColumnLength, findText, ErrorValueObject.create("#N/A"));
|
|
@@ -40454,9 +40654,9 @@ var Fixed = class extends BaseFunction {
|
|
|
40454
40654
|
_defineProperty(this, "maxParams", 3);
|
|
40455
40655
|
}
|
|
40456
40656
|
calculate(number, decimals, noCommas) {
|
|
40457
|
-
let _decimals = decimals
|
|
40657
|
+
let _decimals = decimals ?? NumberValueObject.create(2);
|
|
40458
40658
|
if (_decimals.isNull()) _decimals = NumberValueObject.create(2);
|
|
40459
|
-
let _noCommas = noCommas
|
|
40659
|
+
let _noCommas = noCommas ?? BooleanValueObject.create(false);
|
|
40460
40660
|
if (_noCommas.isNull()) _noCommas = BooleanValueObject.create(false);
|
|
40461
40661
|
const maxRowLength = Math.max(number.isArray() ? number.getRowCount() : 1, _decimals.isArray() ? _decimals.getRowCount() : 1, _noCommas.isArray() ? _noCommas.getRowCount() : 1);
|
|
40462
40662
|
const maxColumnLength = Math.max(number.isArray() ? number.getColumnCount() : 1, _decimals.isArray() ? _decimals.getColumnCount() : 1, _noCommas.isArray() ? _noCommas.getColumnCount() : 1);
|
|
@@ -40503,7 +40703,7 @@ var Left = class extends BaseFunction {
|
|
|
40503
40703
|
_defineProperty(this, "maxParams", 2);
|
|
40504
40704
|
}
|
|
40505
40705
|
calculate(text, numChars) {
|
|
40506
|
-
const _numChars = numChars
|
|
40706
|
+
const _numChars = numChars ?? NumberValueObject.create(1);
|
|
40507
40707
|
const maxRowLength = Math.max(text.isArray() ? text.getRowCount() : 1, _numChars.isArray() ? _numChars.getRowCount() : 1);
|
|
40508
40708
|
const maxColumnLength = Math.max(text.isArray() ? text.getColumnCount() : 1, _numChars.isArray() ? _numChars.getColumnCount() : 1);
|
|
40509
40709
|
const textArray = expandArrayValueObject(maxRowLength, maxColumnLength, text, ErrorValueObject.create("#N/A"));
|
|
@@ -40540,7 +40740,7 @@ var Leftb = class extends BaseFunction {
|
|
|
40540
40740
|
_defineProperty(this, "maxParams", 2);
|
|
40541
40741
|
}
|
|
40542
40742
|
calculate(text, numBytes) {
|
|
40543
|
-
const _numBytes = numBytes
|
|
40743
|
+
const _numBytes = numBytes ?? NumberValueObject.create(1);
|
|
40544
40744
|
const maxRowLength = Math.max(text.isArray() ? text.getRowCount() : 1, _numBytes.isArray() ? _numBytes.getRowCount() : 1);
|
|
40545
40745
|
const maxColumnLength = Math.max(text.isArray() ? text.getColumnCount() : 1, _numBytes.isArray() ? _numBytes.getColumnCount() : 1);
|
|
40546
40746
|
const textArray = expandArrayValueObject(maxRowLength, maxColumnLength, text, NullValueObject.create());
|
|
@@ -40855,7 +41055,7 @@ var Numbervalue = class extends BaseFunction {
|
|
|
40855
41055
|
return true;
|
|
40856
41056
|
}
|
|
40857
41057
|
calculate(text, decimalSeparator, groupSeparator) {
|
|
40858
|
-
const _decimalSeparator = decimalSeparator
|
|
41058
|
+
const _decimalSeparator = decimalSeparator ?? StringValueObject.create(".");
|
|
40859
41059
|
const maxRowLength = Math.max(text.isArray() ? text.getRowCount() : 1, _decimalSeparator.isArray() ? _decimalSeparator.getRowCount() : 1, (groupSeparator === null || groupSeparator === void 0 ? void 0 : groupSeparator.isArray()) ? groupSeparator.getRowCount() : 1);
|
|
40860
41060
|
const maxColumnLength = Math.max(text.isArray() ? text.getColumnCount() : 1, _decimalSeparator.isArray() ? _decimalSeparator.getColumnCount() : 1, (groupSeparator === null || groupSeparator === void 0 ? void 0 : groupSeparator.isArray()) ? groupSeparator.getColumnCount() : 1);
|
|
40861
41061
|
const textArray = expandArrayValueObject(maxRowLength, maxColumnLength, text, ErrorValueObject.create("#N/A"));
|
|
@@ -41386,8 +41586,7 @@ function isValidRegExp(regExpString) {
|
|
|
41386
41586
|
return !(/\(\?<=.*?\)/g.test(regExpString) && !/\[.*?(\?<=.*?)\]/g.test(regExpString) || /\(\?<!.*?\)/g.test(regExpString) && !/\[.*?(\?<!.*?)\]/g.test(regExpString));
|
|
41387
41587
|
}
|
|
41388
41588
|
function isSafeRegExp(regExp, options) {
|
|
41389
|
-
|
|
41390
|
-
const limit = (_options$limit = options === null || options === void 0 ? void 0 : options.limit) !== null && _options$limit !== void 0 ? _options$limit : 25;
|
|
41589
|
+
const limit = (options === null || options === void 0 ? void 0 : options.limit) ?? 25;
|
|
41391
41590
|
let str;
|
|
41392
41591
|
if (Object.prototype.toString.call(regExp) === "[object RegExp]") str = regExp.source;
|
|
41393
41592
|
else if (regExp && typeof regExp !== "string") str = `${regExp}`;
|
|
@@ -41667,7 +41866,7 @@ var Right = class extends BaseFunction {
|
|
|
41667
41866
|
_defineProperty(this, "maxParams", 2);
|
|
41668
41867
|
}
|
|
41669
41868
|
calculate(text, numChars) {
|
|
41670
|
-
const _numChars = numChars
|
|
41869
|
+
const _numChars = numChars ?? NumberValueObject.create(1);
|
|
41671
41870
|
const maxRowLength = Math.max(text.isArray() ? text.getRowCount() : 1, _numChars.isArray() ? _numChars.getRowCount() : 1);
|
|
41672
41871
|
const maxColumnLength = Math.max(text.isArray() ? text.getColumnCount() : 1, _numChars.isArray() ? _numChars.getColumnCount() : 1);
|
|
41673
41872
|
const textArray = expandArrayValueObject(maxRowLength, maxColumnLength, text, ErrorValueObject.create("#N/A"));
|
|
@@ -41704,7 +41903,7 @@ var Rightb = class extends BaseFunction {
|
|
|
41704
41903
|
_defineProperty(this, "maxParams", 2);
|
|
41705
41904
|
}
|
|
41706
41905
|
calculate(text, numBytes) {
|
|
41707
|
-
const _numBytes = numBytes
|
|
41906
|
+
const _numBytes = numBytes ?? NumberValueObject.create(1);
|
|
41708
41907
|
const maxRowLength = Math.max(text.isArray() ? text.getRowCount() : 1, _numBytes.isArray() ? _numBytes.getRowCount() : 1);
|
|
41709
41908
|
const maxColumnLength = Math.max(text.isArray() ? text.getColumnCount() : 1, _numBytes.isArray() ? _numBytes.getColumnCount() : 1);
|
|
41710
41909
|
const textArray = expandArrayValueObject(maxRowLength, maxColumnLength, text, ErrorValueObject.create("#N/A"));
|
|
@@ -41747,7 +41946,7 @@ var Search = class extends BaseFunction {
|
|
|
41747
41946
|
_defineProperty(this, "maxParams", 3);
|
|
41748
41947
|
}
|
|
41749
41948
|
calculate(findText, withinText, startNum) {
|
|
41750
|
-
const _startNum = startNum
|
|
41949
|
+
const _startNum = startNum ?? NumberValueObject.create(1);
|
|
41751
41950
|
const maxRowLength = Math.max(findText.isArray() ? findText.getRowCount() : 1, withinText.isArray() ? withinText.getRowCount() : 1, _startNum.isArray() ? _startNum.getRowCount() : 1);
|
|
41752
41951
|
const maxColumnLength = Math.max(findText.isArray() ? findText.getColumnCount() : 1, withinText.isArray() ? withinText.getColumnCount() : 1, _startNum.isArray() ? _startNum.getColumnCount() : 1);
|
|
41753
41952
|
const findTextArray = expandArrayValueObject(maxRowLength, maxColumnLength, findText, ErrorValueObject.create("#N/A"));
|
|
@@ -41788,7 +41987,7 @@ var Searchb = class extends BaseFunction {
|
|
|
41788
41987
|
_defineProperty(this, "maxParams", 3);
|
|
41789
41988
|
}
|
|
41790
41989
|
calculate(findText, withinText, startNum) {
|
|
41791
|
-
const _startNum = startNum
|
|
41990
|
+
const _startNum = startNum ?? NumberValueObject.create(1);
|
|
41792
41991
|
const maxRowLength = Math.max(findText.isArray() ? findText.getRowCount() : 1, withinText.isArray() ? withinText.getRowCount() : 1, _startNum.isArray() ? _startNum.getRowCount() : 1);
|
|
41793
41992
|
const maxColumnLength = Math.max(findText.isArray() ? findText.getColumnCount() : 1, withinText.isArray() ? withinText.getColumnCount() : 1, _startNum.isArray() ? _startNum.getColumnCount() : 1);
|
|
41794
41993
|
const findTextArray = expandArrayValueObject(maxRowLength, maxColumnLength, findText, ErrorValueObject.create("#N/A"));
|
|
@@ -41961,15 +42160,15 @@ var Textafter = class extends BaseFunction {
|
|
|
41961
42160
|
}
|
|
41962
42161
|
calculate(text, delimiter, instanceNum, matchMode, matchEnd, ifNotFound) {
|
|
41963
42162
|
let instanceNumIsNull = false;
|
|
41964
|
-
let _instanceNum = instanceNum
|
|
42163
|
+
let _instanceNum = instanceNum ?? NumberValueObject.create(1);
|
|
41965
42164
|
if (_instanceNum.isNull()) {
|
|
41966
42165
|
instanceNumIsNull = true;
|
|
41967
42166
|
_instanceNum = NumberValueObject.create(1);
|
|
41968
42167
|
}
|
|
41969
42168
|
const onlyThreeVariant = !matchMode;
|
|
41970
|
-
const _matchMode = matchMode
|
|
41971
|
-
const _matchEnd = matchEnd
|
|
41972
|
-
const _ifNotFound = ifNotFound
|
|
42169
|
+
const _matchMode = matchMode ?? NumberValueObject.create(0);
|
|
42170
|
+
const _matchEnd = matchEnd ?? NumberValueObject.create(0);
|
|
42171
|
+
const _ifNotFound = ifNotFound ?? ErrorValueObject.create("#N/A");
|
|
41973
42172
|
const maxRowLength = Math.max(text.isArray() ? text.getRowCount() : 1, _instanceNum.isArray() ? _instanceNum.getRowCount() : 1, _matchMode.isArray() ? _matchMode.getRowCount() : 1, _matchEnd.isArray() ? _matchEnd.getRowCount() : 1, _ifNotFound.isArray() ? _ifNotFound.getRowCount() : 1);
|
|
41974
42173
|
const maxColumnLength = Math.max(text.isArray() ? text.getColumnCount() : 1, _instanceNum.isArray() ? _instanceNum.getColumnCount() : 1, _matchMode.isArray() ? _matchMode.getColumnCount() : 1, _matchEnd.isArray() ? _matchEnd.getColumnCount() : 1, _ifNotFound.isArray() ? _ifNotFound.getColumnCount() : 1);
|
|
41975
42174
|
const textArray = expandArrayValueObject(maxRowLength, maxColumnLength, text, ErrorValueObject.create("#N/A"));
|
|
@@ -42104,15 +42303,15 @@ var Textbefore = class extends BaseFunction {
|
|
|
42104
42303
|
}
|
|
42105
42304
|
calculate(text, delimiter, instanceNum, matchMode, matchEnd, ifNotFound) {
|
|
42106
42305
|
let instanceNumIsNull = false;
|
|
42107
|
-
let _instanceNum = instanceNum
|
|
42306
|
+
let _instanceNum = instanceNum ?? NumberValueObject.create(1);
|
|
42108
42307
|
if (_instanceNum.isNull()) {
|
|
42109
42308
|
instanceNumIsNull = true;
|
|
42110
42309
|
_instanceNum = NumberValueObject.create(1);
|
|
42111
42310
|
}
|
|
42112
42311
|
const onlyThreeVariant = !matchMode;
|
|
42113
|
-
const _matchMode = matchMode
|
|
42114
|
-
const _matchEnd = matchEnd
|
|
42115
|
-
const _ifNotFound = ifNotFound
|
|
42312
|
+
const _matchMode = matchMode ?? NumberValueObject.create(0);
|
|
42313
|
+
const _matchEnd = matchEnd ?? NumberValueObject.create(0);
|
|
42314
|
+
const _ifNotFound = ifNotFound ?? ErrorValueObject.create("#N/A");
|
|
42116
42315
|
const maxRowLength = Math.max(text.isArray() ? text.getRowCount() : 1, _instanceNum.isArray() ? _instanceNum.getRowCount() : 1, _matchMode.isArray() ? _matchMode.getRowCount() : 1, _matchEnd.isArray() ? _matchEnd.getRowCount() : 1, _ifNotFound.isArray() ? _ifNotFound.getRowCount() : 1);
|
|
42117
42316
|
const maxColumnLength = Math.max(text.isArray() ? text.getColumnCount() : 1, _instanceNum.isArray() ? _instanceNum.getColumnCount() : 1, _matchMode.isArray() ? _matchMode.getColumnCount() : 1, _matchEnd.isArray() ? _matchEnd.getColumnCount() : 1, _ifNotFound.isArray() ? _ifNotFound.getColumnCount() : 1);
|
|
42118
42317
|
const textArray = expandArrayValueObject(maxRowLength, maxColumnLength, text, ErrorValueObject.create("#N/A"));
|
|
@@ -42243,6 +42442,7 @@ var Textjoin = class extends BaseFunction {
|
|
|
42243
42442
|
super(..._args);
|
|
42244
42443
|
_defineProperty(this, "minParams", 3);
|
|
42245
42444
|
_defineProperty(this, "maxParams", 255);
|
|
42445
|
+
_defineProperty(this, "lazyIfReferenceArrayArgumentIndexes", Array.from({ length: this.maxParams - 2 }, (_, index) => index + 2));
|
|
42246
42446
|
}
|
|
42247
42447
|
calculate(delimiter, ignoreEmpty, ...variants) {
|
|
42248
42448
|
const delimiterValues = this._getDelimiterValues(delimiter);
|
|
@@ -42320,10 +42520,10 @@ var Textsplit = class extends BaseFunction {
|
|
|
42320
42520
|
_defineProperty(this, "maxParams", 6);
|
|
42321
42521
|
}
|
|
42322
42522
|
calculate(text, colDelimiter, rowDelimiter, ignoreEmpty, matchMode, padWith) {
|
|
42323
|
-
let _rowDelimiter = rowDelimiter
|
|
42324
|
-
const _ignoreEmpty = ignoreEmpty
|
|
42325
|
-
const _matchMode = matchMode
|
|
42326
|
-
const _padWith = padWith
|
|
42523
|
+
let _rowDelimiter = rowDelimiter ?? StringValueObject.create("\\s");
|
|
42524
|
+
const _ignoreEmpty = ignoreEmpty ?? NumberValueObject.create(0);
|
|
42525
|
+
const _matchMode = matchMode ?? NumberValueObject.create(0);
|
|
42526
|
+
const _padWith = padWith ?? StringValueObject.create("#N/A");
|
|
42327
42527
|
const { _variant, values: rowDelimiterValue } = this._getStringValues(_rowDelimiter, false);
|
|
42328
42528
|
_rowDelimiter = _variant;
|
|
42329
42529
|
const allowBlankColDelimiter = rowDelimiter != null && !rowDelimiter.isNull() && !_rowDelimiter.isError() && rowDelimiterValue.length > 0;
|
|
@@ -42599,7 +42799,7 @@ var Valuetotext = class extends BaseFunction {
|
|
|
42599
42799
|
_defineProperty(this, "maxParams", 2);
|
|
42600
42800
|
}
|
|
42601
42801
|
calculate(value, format) {
|
|
42602
|
-
const _format = format
|
|
42802
|
+
const _format = format ?? NumberValueObject.create(0);
|
|
42603
42803
|
const maxRowLength = Math.max(value.isArray() ? value.getRowCount() : 1, _format.isArray() ? _format.getRowCount() : 1);
|
|
42604
42804
|
const maxColumnLength = Math.max(value.isArray() ? value.getColumnCount() : 1, _format.isArray() ? _format.getColumnCount() : 1);
|
|
42605
42805
|
const valueArray = expandArrayValueObject(maxRowLength, maxColumnLength, value, ErrorValueObject.create("#N/A"));
|
|
@@ -42877,7 +43077,7 @@ function getObjectValue(result, isUseStrip = false) {
|
|
|
42877
43077
|
//#endregion
|
|
42878
43078
|
//#region package.json
|
|
42879
43079
|
var name = "@univerjs/engine-formula";
|
|
42880
|
-
var version = "1.0.0-
|
|
43080
|
+
var version = "1.0.0-beta.1";
|
|
42881
43081
|
|
|
42882
43082
|
//#endregion
|
|
42883
43083
|
//#region src/services/global-computing-status.service.ts
|
|
@@ -43069,14 +43269,13 @@ function createEmptyDirtyData() {
|
|
|
43069
43269
|
};
|
|
43070
43270
|
}
|
|
43071
43271
|
function mergeDirtyData(left, right) {
|
|
43072
|
-
var _right$dirtyRanges, _left$dirtySuperTable;
|
|
43073
43272
|
const dirtyRanges = [...left.dirtyRanges];
|
|
43074
|
-
mergeDirtyRanges(dirtyRanges,
|
|
43273
|
+
mergeDirtyRanges(dirtyRanges, right.dirtyRanges ?? []);
|
|
43075
43274
|
return {
|
|
43076
43275
|
dirtyRanges,
|
|
43077
43276
|
dirtyNameMap: mergeDirtyUnitStringMap(left.dirtyNameMap, right.dirtyNameMap),
|
|
43078
43277
|
dirtyDefinedNameMap: mergeDirtyUnitStringMap(left.dirtyDefinedNameMap, right.dirtyDefinedNameMap),
|
|
43079
|
-
dirtySuperTableMap: mergeDirtyUnitStringMap(
|
|
43278
|
+
dirtySuperTableMap: mergeDirtyUnitStringMap(left.dirtySuperTableMap ?? {}, right.dirtySuperTableMap),
|
|
43080
43279
|
dirtyUnitFeatureMap: mergeDirtyUnitNestedMap(left.dirtyUnitFeatureMap, right.dirtyUnitFeatureMap),
|
|
43081
43280
|
dirtyUnitOtherFormulaMap: mergeDirtyUnitNestedMap(left.dirtyUnitOtherFormulaMap, right.dirtyUnitOtherFormulaMap),
|
|
43082
43281
|
clearDependencyTreeCache: mergeDirtyUnitStringMap(left.clearDependencyTreeCache, right.clearDependencyTreeCache),
|
|
@@ -43106,7 +43305,7 @@ function getDirtyRangeKey({ unitId, sheetId, range }) {
|
|
|
43106
43305
|
}
|
|
43107
43306
|
function mergeDirtyUnitStringMap(left, right) {
|
|
43108
43307
|
const result = { ...left };
|
|
43109
|
-
Object.entries(right
|
|
43308
|
+
Object.entries(right ?? {}).forEach(([unitId, values]) => {
|
|
43110
43309
|
result[unitId] = {
|
|
43111
43310
|
...result[unitId],
|
|
43112
43311
|
...values
|
|
@@ -43116,9 +43315,9 @@ function mergeDirtyUnitStringMap(left, right) {
|
|
|
43116
43315
|
}
|
|
43117
43316
|
function mergeDirtyUnitNestedMap(left, right) {
|
|
43118
43317
|
const result = { ...left };
|
|
43119
|
-
Object.entries(right
|
|
43318
|
+
Object.entries(right ?? {}).forEach(([unitId, sheets]) => {
|
|
43120
43319
|
const unitResult = { ...result[unitId] };
|
|
43121
|
-
Object.entries(sheets
|
|
43320
|
+
Object.entries(sheets ?? {}).forEach(([sheetId, values]) => {
|
|
43122
43321
|
unitResult[sheetId] = {
|
|
43123
43322
|
...unitResult[sheetId],
|
|
43124
43323
|
...values
|
|
@@ -43149,7 +43348,7 @@ function dirtyDataIntersects(left, right) {
|
|
|
43149
43348
|
].some(([leftMap, rightMap]) => hasSameNestedKey(leftMap, rightMap));
|
|
43150
43349
|
}
|
|
43151
43350
|
function clearedSheetIntersects(cleared, dirty) {
|
|
43152
|
-
return Object.entries(cleared.clearDependencyTreeCache).some(([unitId, sheets]) => Object.keys(sheets
|
|
43351
|
+
return Object.entries(cleared.clearDependencyTreeCache).some(([unitId, sheets]) => Object.keys(sheets ?? {}).some((sheetId) => {
|
|
43153
43352
|
var _dirty$dirtyNameMap$u, _dirty$dirtyUnitFeatu, _dirty$dirtyUnitOther;
|
|
43154
43353
|
return dirty.dirtyRanges.some((range) => range.unitId === unitId && range.sheetId === sheetId) || ((_dirty$dirtyNameMap$u = dirty.dirtyNameMap[unitId]) === null || _dirty$dirtyNameMap$u === void 0 ? void 0 : _dirty$dirtyNameMap$u[sheetId]) != null || ((_dirty$dirtyUnitFeatu = dirty.dirtyUnitFeatureMap[unitId]) === null || _dirty$dirtyUnitFeatu === void 0 ? void 0 : _dirty$dirtyUnitFeatu[sheetId]) != null || ((_dirty$dirtyUnitOther = dirty.dirtyUnitOtherFormulaMap[unitId]) === null || _dirty$dirtyUnitOther === void 0 ? void 0 : _dirty$dirtyUnitOther[sheetId]) != null;
|
|
43155
43354
|
}));
|
|
@@ -43178,12 +43377,9 @@ function hasSameNestedKey(left, right) {
|
|
|
43178
43377
|
* limitations under the License.
|
|
43179
43378
|
*/
|
|
43180
43379
|
let FormulaCalculationTriggerController = class FormulaCalculationTriggerController extends Disposable {
|
|
43181
|
-
constructor(formulaCalculationTriggerService,
|
|
43380
|
+
constructor(formulaCalculationTriggerService, lifecycleService) {
|
|
43182
43381
|
super();
|
|
43183
|
-
const start = () =>
|
|
43184
|
-
formulaCalculationTriggerService.start();
|
|
43185
|
-
registerOtherFormulaService.calculateStarted$.next(true);
|
|
43186
|
-
};
|
|
43382
|
+
const start = () => formulaCalculationTriggerService.start();
|
|
43187
43383
|
if (isNodeEnv()) {
|
|
43188
43384
|
start();
|
|
43189
43385
|
return;
|
|
@@ -43191,11 +43387,7 @@ let FormulaCalculationTriggerController = class FormulaCalculationTriggerControl
|
|
|
43191
43387
|
this.disposeWithMe(lifecycleService.lifecycle$.pipe(filter((stage) => stage >= LifecycleStages.Rendered), take(1)).subscribe(start));
|
|
43192
43388
|
}
|
|
43193
43389
|
};
|
|
43194
|
-
FormulaCalculationTriggerController = __decorate([
|
|
43195
|
-
__decorateParam(0, Inject(FormulaCalculationTriggerService)),
|
|
43196
|
-
__decorateParam(1, Inject(RegisterOtherFormulaService)),
|
|
43197
|
-
__decorateParam(2, Inject(LifecycleService))
|
|
43198
|
-
], FormulaCalculationTriggerController);
|
|
43390
|
+
FormulaCalculationTriggerController = __decorate([__decorateParam(0, Inject(FormulaCalculationTriggerService)), __decorateParam(1, Inject(LifecycleService))], FormulaCalculationTriggerController);
|
|
43199
43391
|
|
|
43200
43392
|
//#endregion
|
|
43201
43393
|
//#region src/controllers/formula.controller.ts
|
|
@@ -43218,10 +43410,12 @@ let FormulaController = class FormulaController extends Disposable {
|
|
|
43218
43410
|
_syncOtherFormulaUnits() {
|
|
43219
43411
|
const dataSyncPrimaryController = this._dataSyncPrimaryController;
|
|
43220
43412
|
if (!dataSyncPrimaryController) return;
|
|
43221
|
-
this.disposeWithMe(this._registerOtherFormulaService.
|
|
43222
|
-
if (this._syncedOtherFormulaUnits.has(unitId))
|
|
43223
|
-
|
|
43224
|
-
|
|
43413
|
+
this.disposeWithMe(this._registerOtherFormulaService.setMutationSyncHandler((unitId) => {
|
|
43414
|
+
if (!this._syncedOtherFormulaUnits.has(unitId)) {
|
|
43415
|
+
this._syncedOtherFormulaUnits.add(unitId);
|
|
43416
|
+
this.disposeWithMe(dataSyncPrimaryController.syncUnitMutations(unitId));
|
|
43417
|
+
}
|
|
43418
|
+
return () => dataSyncPrimaryController.waitForPendingMutations();
|
|
43225
43419
|
}));
|
|
43226
43420
|
}
|
|
43227
43421
|
_registerCommands() {
|
|
@@ -43262,9 +43456,8 @@ let FormulaController = class FormulaController extends Disposable {
|
|
|
43262
43456
|
});
|
|
43263
43457
|
}
|
|
43264
43458
|
_registerFunctions() {
|
|
43265
|
-
var _config$function;
|
|
43266
43459
|
const config = this._configService.getConfig(ENGINE_FORMULA_PLUGIN_CONFIG_KEY);
|
|
43267
|
-
const functions = ALL_IMPLEMENTED_FUNCTIONS.concat((
|
|
43460
|
+
const functions = ALL_IMPLEMENTED_FUNCTIONS.concat((config === null || config === void 0 ? void 0 : config.function) ?? []).map((registerObject) => {
|
|
43268
43461
|
const Func = registerObject[0];
|
|
43269
43462
|
const name = registerObject[1];
|
|
43270
43463
|
return new Func(name);
|
|
@@ -56463,7 +56656,7 @@ let RegisterFunctionService = class RegisterFunctionService extends Disposable {
|
|
|
56463
56656
|
const { locales, description, calculate } = params;
|
|
56464
56657
|
if (locales) this._localeService.load(locales);
|
|
56465
56658
|
const disposables = new DisposableCollection();
|
|
56466
|
-
const descriptions = description
|
|
56659
|
+
const descriptions = description ?? calculate.map(([_func, functionName, functionIntroduction]) => {
|
|
56467
56660
|
return {
|
|
56468
56661
|
functionName,
|
|
56469
56662
|
functionType: 15,
|