@univerjs/engine-formula 1.0.0-alpha.8 → 1.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.js +955 -857
- package/lib/es/index.js +955 -857
- package/lib/index.js +955 -857
- package/lib/types/basics/regex.d.ts +4 -4
- 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/functions/base-function.d.ts +4 -0
- 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/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/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/umd/index.js +4 -4
- package/package.json +4 -4
package/lib/index.js
CHANGED
|
@@ -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,9 +1443,9 @@ 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
1450
|
const TABLE_UNIT_QUALIFIER_REGEX = `(?:(?:${UNIT_NAME_REGEX}|'(?:[^']|'')+'|[^\\s!\\[\\]]+)!)?(?:${UNIT_NAME_REGEX})?`;
|
|
1456
1451
|
const REFERENCE_TABLE_ALL_COLUMN_REGEX = `^${TABLE_UNIT_QUALIFIER_REGEX}${TABLE_NAME_REGEX}$`;
|
|
@@ -2069,7 +2064,6 @@ let DefinedNamesService = class DefinedNamesService extends Disposable {
|
|
|
2069
2064
|
const nameMap = this._definedNameMap[unitId];
|
|
2070
2065
|
if (nameMap === void 0) return null;
|
|
2071
2066
|
if (sheetId) {
|
|
2072
|
-
var _workbookScope;
|
|
2073
2067
|
const normalizedName = name.toLowerCase();
|
|
2074
2068
|
let workbookScope = null;
|
|
2075
2069
|
let firstMatch = null;
|
|
@@ -2081,7 +2075,7 @@ let DefinedNamesService = class DefinedNamesService extends Disposable {
|
|
|
2081
2075
|
if (workbookScope == null) workbookScope = item;
|
|
2082
2076
|
}
|
|
2083
2077
|
}
|
|
2084
|
-
return
|
|
2078
|
+
return workbookScope ?? firstMatch;
|
|
2085
2079
|
}
|
|
2086
2080
|
const cachedMap = this._nameCacheMap[unitId];
|
|
2087
2081
|
if (cachedMap) return cachedMap[name.toLowerCase()] || null;
|
|
@@ -2383,7 +2377,7 @@ var SuperTableService = class extends Disposable {
|
|
|
2383
2377
|
}
|
|
2384
2378
|
hasTable(unitId, tableName) {
|
|
2385
2379
|
const unitIdMap = this._tableMap.get(unitId);
|
|
2386
|
-
if (unitIdMap) return unitIdMap.keys().some((name) => name.toLowerCase() === tableName.toLowerCase());
|
|
2380
|
+
if (unitIdMap) return Array.from(unitIdMap.keys()).some((name) => name.toLowerCase() === tableName.toLowerCase());
|
|
2387
2381
|
return false;
|
|
2388
2382
|
}
|
|
2389
2383
|
_update() {
|
|
@@ -3793,9 +3787,11 @@ var LexerTreeBuilder = class extends Disposable {
|
|
|
3793
3787
|
return this._nodeMaker(formulaString);
|
|
3794
3788
|
}
|
|
3795
3789
|
treeBuilder(formulaString, transformSuffix = true, injectDefinedNameParam) {
|
|
3796
|
-
|
|
3790
|
+
const isCacheable = !/\b(?:LET|LAMBDA)\s*\(/iu.test(formulaString);
|
|
3791
|
+
const cacheKey = injectDefinedNameParam == null ? formulaString : `${injectDefinedNameParam.unitId ?? ""}\0${injectDefinedNameParam.sheetId ?? ""}\0${injectDefinedNameParam.refOffsetX}\0${injectDefinedNameParam.refOffsetY}\0${formulaString}`;
|
|
3792
|
+
if (transformSuffix === true && isCacheable) {
|
|
3797
3793
|
var _this$_simpleCheckDef;
|
|
3798
|
-
const lexerNode = FormulaLexerNodeCache.get(
|
|
3794
|
+
const lexerNode = FormulaLexerNodeCache.get(cacheKey);
|
|
3799
3795
|
const simpleCheckDefinedNameResult = injectDefinedNameParam && ((_this$_simpleCheckDef = this._simpleCheckDefinedName) === null || _this$_simpleCheckDef === void 0 ? void 0 : _this$_simpleCheckDef.call(this, formulaString, injectDefinedNameParam));
|
|
3800
3796
|
if (lexerNode && !simpleCheckDefinedNameResult) return lexerNode;
|
|
3801
3797
|
}
|
|
@@ -3827,13 +3823,13 @@ var LexerTreeBuilder = class extends Disposable {
|
|
|
3827
3823
|
if (node) this._currentLexerNode = node;
|
|
3828
3824
|
if (transformSuffix) {
|
|
3829
3825
|
if (!this._suffixExpressionHandler(this._currentLexerNode)) return "#VALUE!";
|
|
3830
|
-
FormulaLexerNodeCache.set(
|
|
3826
|
+
if (isCacheable) FormulaLexerNodeCache.set(cacheKey, this._currentLexerNode);
|
|
3831
3827
|
}
|
|
3832
3828
|
if (currentHasDefinedName) this._currentLexerNode.setDefinedNames(currentDefinedNames);
|
|
3833
3829
|
return this._currentLexerNode;
|
|
3834
3830
|
}
|
|
3835
3831
|
_handleDefinedName(sequenceArray, param) {
|
|
3836
|
-
const { unitId, sheetId,
|
|
3832
|
+
const { unitId, sheetId, hasFunction, getValueByName } = param;
|
|
3837
3833
|
if (unitId == null) return {
|
|
3838
3834
|
sequenceString: "",
|
|
3839
3835
|
hasDefinedName: false,
|
|
@@ -3852,11 +3848,19 @@ var LexerTreeBuilder = class extends Disposable {
|
|
|
3852
3848
|
const { nodeType, token: tokenRaw } = node;
|
|
3853
3849
|
let token = tokenRaw;
|
|
3854
3850
|
if (nodeType === 4 || nodeType === 3) {
|
|
3855
|
-
if (nodeType === 3)
|
|
3851
|
+
if (nodeType === 3) {
|
|
3852
|
+
const nextNode = sequenceNodes[i + 1];
|
|
3853
|
+
if (typeof nextNode === "string" && nextNode.trim() === "(" && hasFunction(tokenRaw.trim().toUpperCase())) {
|
|
3854
|
+
sequenceString += tokenRaw;
|
|
3855
|
+
continue;
|
|
3856
|
+
}
|
|
3857
|
+
token = this._getHasSheetNameDefinedName(tokenRaw, unitId, param);
|
|
3858
|
+
}
|
|
3856
3859
|
const definedNameToken = token.trim();
|
|
3857
3860
|
const definedContent = getValueByName(unitId, definedNameToken, sheetId);
|
|
3858
3861
|
if (definedContent) {
|
|
3859
|
-
const
|
|
3862
|
+
const refOffsetX = definedContent.localSheetId === "AllDefaultWorkbook" ? param.refOffsetX - 1 : param.refOffsetX;
|
|
3863
|
+
const refString = definedContent.formulaOrRefString.startsWith("=") ? definedContent.formulaOrRefString : this._moveDefinedNameRefOffset(definedContent.formulaOrRefString, refOffsetX, param.refOffsetY);
|
|
3860
3864
|
const nestedDefinedNameParam = this._handleNestedDefinedName(refString, param);
|
|
3861
3865
|
if (nestedDefinedNameParam == null || typeof nestedDefinedNameParam !== "object") {
|
|
3862
3866
|
sequenceString += nestedDefinedNameParam || "#NAME?";
|
|
@@ -3883,6 +3887,28 @@ var LexerTreeBuilder = class extends Disposable {
|
|
|
3883
3887
|
definedNames
|
|
3884
3888
|
};
|
|
3885
3889
|
}
|
|
3890
|
+
_moveDefinedNameRefOffset(formulaString, refOffsetX, refOffsetY) {
|
|
3891
|
+
const sequenceNodes = this.sequenceNodesBuilder(formulaString);
|
|
3892
|
+
if (sequenceNodes == null) return formulaString;
|
|
3893
|
+
return generateStringWithSequence(sequenceNodes.map((node) => {
|
|
3894
|
+
if (typeof node === "string" || node.nodeType !== 4) return node;
|
|
3895
|
+
const sequenceGrid = deserializeRangeWithSheetWithCache(node.token);
|
|
3896
|
+
const range = moveRangeByOffset(sequenceGrid.range, refOffsetX, refOffsetY);
|
|
3897
|
+
const wrap = (value, limit) => (value % limit + limit) % limit;
|
|
3898
|
+
range.startRow = wrap(range.startRow, MAX_ROW_COUNT);
|
|
3899
|
+
range.endRow = wrap(range.endRow, MAX_ROW_COUNT);
|
|
3900
|
+
range.startColumn = wrap(range.startColumn, MAX_COLUMN_COUNT);
|
|
3901
|
+
range.endColumn = wrap(range.endColumn, MAX_COLUMN_COUNT);
|
|
3902
|
+
return {
|
|
3903
|
+
...node,
|
|
3904
|
+
token: serializeRangeToRefString({
|
|
3905
|
+
range,
|
|
3906
|
+
unitId: sequenceGrid.unitId,
|
|
3907
|
+
sheetName: sequenceGrid.sheetName
|
|
3908
|
+
})
|
|
3909
|
+
};
|
|
3910
|
+
}));
|
|
3911
|
+
}
|
|
3886
3912
|
_getHasSheetNameDefinedName(tokenRaw, unitId, param) {
|
|
3887
3913
|
if (!tokenRaw.includes("!")) return tokenRaw;
|
|
3888
3914
|
const parts = tokenRaw.split("!");
|
|
@@ -4309,7 +4335,7 @@ var LexerTreeBuilder = class extends Disposable {
|
|
|
4309
4335
|
}
|
|
4310
4336
|
this._resetSegment();
|
|
4311
4337
|
continue;
|
|
4312
|
-
} else if (currentString === "(" && this.isSingleQuotationClose() && this.isDoubleQuotationClose()) if (this._segmentCount() > 0 || this.isLambdaOpen()) {
|
|
4338
|
+
} else if (currentString === "(" && this.isSingleQuotationClose() && this.isDoubleQuotationClose() && this.isSquareBracketClose()) if (this._segmentCount() > 0 || this.isLambdaOpen()) {
|
|
4313
4339
|
if (this.isLambdaClose()) {
|
|
4314
4340
|
this._newAndPushCurrentLexerNode(this._segment, cur);
|
|
4315
4341
|
this._resetSegment();
|
|
@@ -4337,7 +4363,7 @@ var LexerTreeBuilder = class extends Disposable {
|
|
|
4337
4363
|
this._openBracketNormalIndex();
|
|
4338
4364
|
this._resetSegment();
|
|
4339
4365
|
}
|
|
4340
|
-
else if (currentString === ")" && this.isSingleQuotationClose() && this.isDoubleQuotationClose()) {
|
|
4366
|
+
else if (currentString === ")" && this.isSingleQuotationClose() && this.isDoubleQuotationClose() && this.isSquareBracketClose()) {
|
|
4341
4367
|
if (this._formulaErrorLastTokenCheck(formulaChars, cur - 1)) this._formalErrorOccurred();
|
|
4342
4368
|
this._pushNodeToChildren(this._segment);
|
|
4343
4369
|
this._resetSegment();
|
|
@@ -5065,13 +5091,13 @@ let FormulaDataModel = class FormulaDataModel extends Disposable {
|
|
|
5065
5091
|
const recordId = recordOrder[row];
|
|
5066
5092
|
if (!table.records[recordId]) continue;
|
|
5067
5093
|
for (let col = 0; col < table.fieldOrder.length; col++) {
|
|
5068
|
-
var _field$config
|
|
5094
|
+
var _field$config;
|
|
5069
5095
|
const fieldId = table.fieldOrder[col];
|
|
5070
5096
|
const field = table.fields[fieldId];
|
|
5071
5097
|
if (!field || field.type !== "formula") continue;
|
|
5072
|
-
const formula = String((
|
|
5098
|
+
const formula = String(((_field$config = field.config) === null || _field$config === void 0 ? void 0 : _field$config.formula) ?? "").trim();
|
|
5073
5099
|
if (!formula) continue;
|
|
5074
|
-
|
|
5100
|
+
tableFormulaData[row] ??= {};
|
|
5075
5101
|
tableFormulaData[row][col] = {
|
|
5076
5102
|
f: normalizeBaseFormulaForEngine(formula, table, snapshot),
|
|
5077
5103
|
si: field.id
|
|
@@ -5202,10 +5228,10 @@ let FormulaDataModel = class FormulaDataModel extends Disposable {
|
|
|
5202
5228
|
const baseData = {};
|
|
5203
5229
|
const tableNameMap = {};
|
|
5204
5230
|
for (const table of Object.values(snapshot.tables)) {
|
|
5205
|
-
var _table$recordOrder
|
|
5231
|
+
var _table$recordOrder;
|
|
5206
5232
|
baseData[table.id] = {
|
|
5207
5233
|
cellData: new ObjectMatrix(buildBaseRuntimeCellData(table)),
|
|
5208
|
-
rowCount: (
|
|
5234
|
+
rowCount: ((_table$recordOrder = table.recordOrder) === null || _table$recordOrder === void 0 ? void 0 : _table$recordOrder.length) ?? 0,
|
|
5209
5235
|
columnCount: table.fieldOrder.length,
|
|
5210
5236
|
rowData: {},
|
|
5211
5237
|
columnData: {}
|
|
@@ -5248,7 +5274,7 @@ let FormulaDataModel = class FormulaDataModel extends Disposable {
|
|
|
5248
5274
|
return rowData;
|
|
5249
5275
|
}
|
|
5250
5276
|
updateFormulaData(unitId, sheetId, cellValue) {
|
|
5251
|
-
var _this$_univerInstance, _formulaData$unitId
|
|
5277
|
+
var _this$_univerInstance, _formulaData$unitId;
|
|
5252
5278
|
const cellMatrix = new ObjectMatrix(cellValue);
|
|
5253
5279
|
const newSheetFormulaDataMatrix = new ObjectMatrix();
|
|
5254
5280
|
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 +5309,7 @@ let FormulaDataModel = class FormulaDataModel extends Disposable {
|
|
|
5283
5309
|
const formulaData = {};
|
|
5284
5310
|
initSheetFormulaData(formulaData, unitId, sheetId, sharedFormulaCellMatrix);
|
|
5285
5311
|
const deleteFormulaIdMap = /* @__PURE__ */ new Map();
|
|
5286
|
-
const sheetFormulaDataMatrix = new ObjectMatrix((
|
|
5312
|
+
const sheetFormulaDataMatrix = new ObjectMatrix(((_formulaData$unitId = formulaData[unitId]) === null || _formulaData$unitId === void 0 ? void 0 : _formulaData$unitId[sheetId]) ?? {});
|
|
5287
5313
|
cellMatrix.forValue((r, c, cell) => {
|
|
5288
5314
|
var _worksheetCellMatrix$;
|
|
5289
5315
|
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 +5506,7 @@ let FormulaDataModel = class FormulaDataModel extends Disposable {
|
|
|
5480
5506
|
if (isFormulaString(cell === null || cell === void 0 ? void 0 : cell.f) && isFormulaId(formulaId)) formulaIds.add(String(formulaId));
|
|
5481
5507
|
});
|
|
5482
5508
|
cellMatrix.forValue((row, column, cell) => {
|
|
5483
|
-
var
|
|
5509
|
+
var _this$_arrayFormulaRa7, _this$_arrayFormulaCe5;
|
|
5484
5510
|
const ref = cell === null || cell === void 0 ? void 0 : cell.ref;
|
|
5485
5511
|
const formula = cell === null || cell === void 0 ? void 0 : cell.f;
|
|
5486
5512
|
const formulaId = cell === null || cell === void 0 ? void 0 : cell.si;
|
|
@@ -5492,8 +5518,8 @@ let FormulaDataModel = class FormulaDataModel extends Disposable {
|
|
|
5492
5518
|
if (range.startRow === row && range.endRow === row && range.startColumn === column && range.endColumn === column && !isArrayConstantFormula(formula)) return true;
|
|
5493
5519
|
if (!this._arrayFormulaRange[unitId]) this._arrayFormulaRange[unitId] = {};
|
|
5494
5520
|
if (!this._arrayFormulaCellData[unitId]) this._arrayFormulaCellData[unitId] = {};
|
|
5495
|
-
|
|
5496
|
-
|
|
5521
|
+
arrayFormulaRangeMatrix ??= new ObjectMatrix((_this$_arrayFormulaRa7 = this._arrayFormulaRange[unitId]) === null || _this$_arrayFormulaRa7 === void 0 ? void 0 : _this$_arrayFormulaRa7[sheetId]);
|
|
5522
|
+
arrayFormulaCellDataMatrix ??= new ObjectMatrix((_this$_arrayFormulaCe5 = this._arrayFormulaCellData[unitId]) === null || _this$_arrayFormulaCe5 === void 0 ? void 0 : _this$_arrayFormulaCe5[sheetId]);
|
|
5497
5523
|
if (arrayFormulaRangeMatrix.getValue(row, column) == null) arrayFormulaRangeMatrix.setValue(row, column, range);
|
|
5498
5524
|
for (let r = range.startRow; r <= range.endRow; r++) for (let c = range.startColumn; c <= range.endColumn; c++) {
|
|
5499
5525
|
if (arrayFormulaCellDataMatrix.getValue(r, c) != null) continue;
|
|
@@ -5565,11 +5591,8 @@ function normalizeBaseFormulaForEngine(formula, currentTable, snapshot) {
|
|
|
5565
5591
|
};
|
|
5566
5592
|
return protectBaseExternalReferences(formula, hold).replace(BASE_LEGACY_FIELD_REF_PATTERN, (_match, fieldName) => hold(createEngineThisRowRef(currentTable, fieldName, snapshot))).replace(BASE_TABLE_FIELD_REF_PATTERN, (_match, sourceTableName, fieldName) => {
|
|
5567
5593
|
const targetTable = resolveBaseFormulaTable(sourceTableName, currentTable, snapshot);
|
|
5568
|
-
return targetTable ? hold(
|
|
5569
|
-
}).replace(BASE_BRACKET_FIELD_REF_PATTERN, (_match, prefix, fieldName) => `${prefix}${hold(createEngineThisRowRef(currentTable, fieldName, snapshot))}`).replace(/__BASE_FORMULA_REF_(\d+)__/g, (_match, index) =>
|
|
5570
|
-
var _refs$Number;
|
|
5571
|
-
return (_refs$Number = refs[Number(index)]) !== null && _refs$Number !== void 0 ? _refs$Number : "";
|
|
5572
|
-
});
|
|
5594
|
+
return targetTable ? hold(createEngineColumnRef(targetTable, fieldName, snapshot)) : `${sourceTableName}[${fieldName}]`;
|
|
5595
|
+
}).replace(BASE_BRACKET_FIELD_REF_PATTERN, (_match, prefix, fieldName) => `${prefix}${hold(createEngineThisRowRef(currentTable, fieldName, snapshot))}`).replace(/__BASE_FORMULA_REF_(\d+)__/g, (_match, index) => refs[Number(index)] ?? "");
|
|
5573
5596
|
}
|
|
5574
5597
|
function protectBaseExternalReferences(formula, replace) {
|
|
5575
5598
|
return protectBaseExternalStructuredReferences(formula.replace(BASE_EXTERNAL_A1_REF_PATTERN, (reference, offset) => isInsideBaseFormulaString(formula, offset) ? reference : replace(reference)), replace);
|
|
@@ -5621,6 +5644,9 @@ function isInsideBaseFormulaString(formula, position) {
|
|
|
5621
5644
|
function createEngineThisRowRef(table, fieldName, snapshot) {
|
|
5622
5645
|
return `${getEngineBaseTableName(table, snapshot)}[[#This Row],[${fieldName}]]`;
|
|
5623
5646
|
}
|
|
5647
|
+
function createEngineColumnRef(table, fieldName, snapshot) {
|
|
5648
|
+
return `${getEngineBaseTableName(table, snapshot)}[[#Data],[${fieldName}]]`;
|
|
5649
|
+
}
|
|
5624
5650
|
function getEngineBaseTableName(table, snapshot) {
|
|
5625
5651
|
const tables = Object.values(snapshot.tables);
|
|
5626
5652
|
let sameNameCount = 0;
|
|
@@ -5645,8 +5671,7 @@ function buildBaseRuntimeCellData(table) {
|
|
|
5645
5671
|
if (table.records[recordId]) recordOrder.push(recordId);
|
|
5646
5672
|
}
|
|
5647
5673
|
} else {
|
|
5648
|
-
|
|
5649
|
-
const allRecords = Object.values((_table$records = table.records) !== null && _table$records !== void 0 ? _table$records : {});
|
|
5674
|
+
const allRecords = Object.values(table.records ?? {});
|
|
5650
5675
|
const records = [];
|
|
5651
5676
|
for (let i = 0; i < allRecords.length; i++) {
|
|
5652
5677
|
const record = allRecords[i];
|
|
@@ -5665,9 +5690,8 @@ function buildBaseRuntimeCellData(table) {
|
|
|
5665
5690
|
if (!record) continue;
|
|
5666
5691
|
cellData[row] = { ...cellData[row] };
|
|
5667
5692
|
for (let col = 0; col < fieldOrder.length; col++) {
|
|
5668
|
-
var _record$values;
|
|
5669
5693
|
const fieldId = fieldOrder[col];
|
|
5670
|
-
if (!Object.prototype.hasOwnProperty.call(
|
|
5694
|
+
if (!Object.prototype.hasOwnProperty.call(record.values ?? {}, fieldId)) continue;
|
|
5671
5695
|
cellData[row][col] = toBaseRuntimeCellData(record.values[fieldId], table.fields[fieldId]);
|
|
5672
5696
|
}
|
|
5673
5697
|
}
|
|
@@ -5684,10 +5708,9 @@ function toBaseRuntimeCellData(value, field) {
|
|
|
5684
5708
|
t: CellValueType.STRING
|
|
5685
5709
|
};
|
|
5686
5710
|
if ((field === null || field === void 0 ? void 0 : field.type) === "link" && value && typeof value === "object") {
|
|
5687
|
-
var _ref, _link$text;
|
|
5688
5711
|
const link = value;
|
|
5689
5712
|
return {
|
|
5690
|
-
v: String(
|
|
5713
|
+
v: String(link.text ?? link.url ?? ""),
|
|
5691
5714
|
t: CellValueType.STRING
|
|
5692
5715
|
};
|
|
5693
5716
|
}
|
|
@@ -5701,8 +5724,7 @@ function toBaseRuntimeCellData(value, field) {
|
|
|
5701
5724
|
};
|
|
5702
5725
|
}
|
|
5703
5726
|
function normalizeBaseCellData(cell) {
|
|
5704
|
-
|
|
5705
|
-
const type = inferBaseRuntimeCellType((_cell$v = cell.v) !== null && _cell$v !== void 0 ? _cell$v : null);
|
|
5727
|
+
const type = inferBaseRuntimeCellType(cell.v ?? null);
|
|
5706
5728
|
return {
|
|
5707
5729
|
...cell,
|
|
5708
5730
|
t: type
|
|
@@ -5754,9 +5776,8 @@ var SheetRowFilteredService = class extends Disposable {
|
|
|
5754
5776
|
this._getRowFilteredCallback = callback;
|
|
5755
5777
|
}
|
|
5756
5778
|
getRowFiltered(unitId, subUnitId, row) {
|
|
5757
|
-
var _this$_getRowFiltered;
|
|
5758
5779
|
if (!this._getRowFilteredCallback) return false;
|
|
5759
|
-
return
|
|
5780
|
+
return this._getRowFilteredCallback(unitId, subUnitId, row) ?? false;
|
|
5760
5781
|
}
|
|
5761
5782
|
};
|
|
5762
5783
|
const ISheetRowFilteredService = createIdentifier("univer.formula.sheet-row-filtered.service");
|
|
@@ -5889,7 +5910,6 @@ let FormulaCurrentConfigService = class FormulaCurrentConfigService extends Disp
|
|
|
5889
5910
|
return this._localeService.getCurrentLocale();
|
|
5890
5911
|
}
|
|
5891
5912
|
getSheetsInfo() {
|
|
5892
|
-
var _this$_sheetIdToNameM;
|
|
5893
5913
|
const workbook = this._univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_SHEET);
|
|
5894
5914
|
if (!workbook) return {
|
|
5895
5915
|
sheetOrder: [],
|
|
@@ -5898,7 +5918,7 @@ let FormulaCurrentConfigService = class FormulaCurrentConfigService extends Disp
|
|
|
5898
5918
|
const { id, sheetOrder } = workbook.getSnapshot();
|
|
5899
5919
|
return {
|
|
5900
5920
|
sheetOrder,
|
|
5901
|
-
sheetNameMap:
|
|
5921
|
+
sheetNameMap: this._sheetIdToNameMap[id] ?? {}
|
|
5902
5922
|
};
|
|
5903
5923
|
}
|
|
5904
5924
|
getSheetRowColumnCount(unitId, sheetId) {
|
|
@@ -5925,7 +5945,6 @@ let FormulaCurrentConfigService = class FormulaCurrentConfigService extends Disp
|
|
|
5925
5945
|
return filteredOutRows;
|
|
5926
5946
|
}
|
|
5927
5947
|
load(config) {
|
|
5928
|
-
var _config$externalRefer;
|
|
5929
5948
|
this._calculationGeneration++;
|
|
5930
5949
|
if (config.allUnitData && config.unitSheetNameMap && config.unitStylesData) {
|
|
5931
5950
|
this._unitData = config.allUnitData;
|
|
@@ -5951,7 +5970,7 @@ let FormulaCurrentConfigService = class FormulaCurrentConfigService extends Disp
|
|
|
5951
5970
|
this._dirtySuperTableMap = config.dirtySuperTableMap || {};
|
|
5952
5971
|
this._dirtyUnitFeatureMap = config.dirtyUnitFeatureMap;
|
|
5953
5972
|
this._dirtyUnitOtherFormulaMap = config.dirtyUnitOtherFormulaMap;
|
|
5954
|
-
this._externalReferences =
|
|
5973
|
+
this._externalReferences = config.externalReferences ?? {};
|
|
5955
5974
|
this._excludedCell = config.excludedCell;
|
|
5956
5975
|
this._mergeNameMap(this._sheetNameMap, this._dirtyNameMap);
|
|
5957
5976
|
}
|
|
@@ -6015,13 +6034,12 @@ let FormulaCurrentConfigService = class FormulaCurrentConfigService extends Disp
|
|
|
6015
6034
|
});
|
|
6016
6035
|
}
|
|
6017
6036
|
_loadSheetData() {
|
|
6018
|
-
var _workbook$getUnitId, _worksheet$getSheetId;
|
|
6019
6037
|
const workbook = this._univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_SHEET);
|
|
6020
6038
|
const worksheet = workbook === null || workbook === void 0 ? void 0 : workbook.getActiveSheet();
|
|
6021
6039
|
const base = workbook ? null : this._univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_BASE);
|
|
6022
6040
|
const table = base ? getFirstBaseTable(base.getSnapshot().tables, base.getSnapshot().tableOrder) : null;
|
|
6023
|
-
this._executeUnitId = (
|
|
6024
|
-
this._executeSubUnitId = (
|
|
6041
|
+
this._executeUnitId = (workbook === null || workbook === void 0 ? void 0 : workbook.getUnitId()) ?? (base === null || base === void 0 ? void 0 : base.getUnitId());
|
|
6042
|
+
this._executeSubUnitId = (worksheet === null || worksheet === void 0 ? void 0 : worksheet.getSheetId()) ?? (table === null || table === void 0 ? void 0 : table.id);
|
|
6025
6043
|
return this._formulaDataModel.getCalculateData();
|
|
6026
6044
|
}
|
|
6027
6045
|
/**
|
|
@@ -6053,29 +6071,334 @@ FormulaCurrentConfigService = __decorate([
|
|
|
6053
6071
|
__decorateParam(3, Inject(ISheetRowFilteredService))
|
|
6054
6072
|
], FormulaCurrentConfigService);
|
|
6055
6073
|
function getFirstBaseTable(tables, tableOrder) {
|
|
6056
|
-
var _Object$values$;
|
|
6057
6074
|
for (const tableId of tableOrder) {
|
|
6058
6075
|
const table = tables[tableId];
|
|
6059
6076
|
if (table) return table;
|
|
6060
6077
|
}
|
|
6061
|
-
return
|
|
6078
|
+
return Object.values(tables)[0] ?? null;
|
|
6062
6079
|
}
|
|
6063
6080
|
const IFormulaCurrentConfigService = createIdentifier("univer.formula.current-data.service");
|
|
6064
6081
|
|
|
6082
|
+
//#endregion
|
|
6083
|
+
//#region src/engine/ast-node/node-type.ts
|
|
6084
|
+
const NODE_ORDER_MAP = /* @__PURE__ */ new Map([
|
|
6085
|
+
[1, 7],
|
|
6086
|
+
[2, 9],
|
|
6087
|
+
[3, 8],
|
|
6088
|
+
[4, 6],
|
|
6089
|
+
[5, 1],
|
|
6090
|
+
[6, 2],
|
|
6091
|
+
[9, 10],
|
|
6092
|
+
[10, 3],
|
|
6093
|
+
[11, 4],
|
|
6094
|
+
[12, 5]
|
|
6095
|
+
]);
|
|
6096
|
+
|
|
6097
|
+
//#endregion
|
|
6098
|
+
//#region src/engine/ast-node/base-ast-node.ts
|
|
6099
|
+
var BaseAstNode = class {
|
|
6100
|
+
constructor(_token) {
|
|
6101
|
+
this._token = _token;
|
|
6102
|
+
_defineProperty(this, "_children", []);
|
|
6103
|
+
_defineProperty(this, "_definedNames", void 0);
|
|
6104
|
+
_defineProperty(this, "_parent", void 0);
|
|
6105
|
+
_defineProperty(this, "_valueObject", void 0);
|
|
6106
|
+
_defineProperty(this, "_calculateState", false);
|
|
6107
|
+
_defineProperty(this, "_async", false);
|
|
6108
|
+
_defineProperty(this, "_address", false);
|
|
6109
|
+
_defineProperty(this, "_isForcedCalculateFunction", false);
|
|
6110
|
+
}
|
|
6111
|
+
dispose() {
|
|
6112
|
+
var _this$_valueObject;
|
|
6113
|
+
this._children.forEach((node) => {
|
|
6114
|
+
node.dispose();
|
|
6115
|
+
});
|
|
6116
|
+
(_this$_valueObject = this._valueObject) === null || _this$_valueObject === void 0 || _this$_valueObject.dispose();
|
|
6117
|
+
this._valueObject = null;
|
|
6118
|
+
this._children = [];
|
|
6119
|
+
this._definedNames = null;
|
|
6120
|
+
this._parent = null;
|
|
6121
|
+
}
|
|
6122
|
+
get nodeType() {
|
|
6123
|
+
return 8;
|
|
6124
|
+
}
|
|
6125
|
+
resetCalculationState() {
|
|
6126
|
+
this._children.forEach((node) => {
|
|
6127
|
+
node.resetCalculationState();
|
|
6128
|
+
});
|
|
6129
|
+
this._valueObject = null;
|
|
6130
|
+
this._calculateState = false;
|
|
6131
|
+
}
|
|
6132
|
+
isAsync() {
|
|
6133
|
+
return this._async;
|
|
6134
|
+
}
|
|
6135
|
+
isAddress() {
|
|
6136
|
+
return this._address;
|
|
6137
|
+
}
|
|
6138
|
+
isForcedCalculateFunction() {
|
|
6139
|
+
return this._isForcedCalculateFunction;
|
|
6140
|
+
}
|
|
6141
|
+
setAsync() {
|
|
6142
|
+
this._async = true;
|
|
6143
|
+
}
|
|
6144
|
+
setAddress() {
|
|
6145
|
+
this._address = true;
|
|
6146
|
+
}
|
|
6147
|
+
getParent() {
|
|
6148
|
+
return this._parent;
|
|
6149
|
+
}
|
|
6150
|
+
setParent(node) {
|
|
6151
|
+
this._parent = node;
|
|
6152
|
+
node.addChildren(this);
|
|
6153
|
+
}
|
|
6154
|
+
setForcedCalculateFunction() {
|
|
6155
|
+
this._isForcedCalculateFunction = true;
|
|
6156
|
+
}
|
|
6157
|
+
getChildren() {
|
|
6158
|
+
return this._children;
|
|
6159
|
+
}
|
|
6160
|
+
addChildren(...astNode) {
|
|
6161
|
+
this._children.push(...astNode);
|
|
6162
|
+
}
|
|
6163
|
+
getToken() {
|
|
6164
|
+
return this._token;
|
|
6165
|
+
}
|
|
6166
|
+
setValue(value) {
|
|
6167
|
+
this._valueObject = value;
|
|
6168
|
+
}
|
|
6169
|
+
getValue() {
|
|
6170
|
+
return this._valueObject;
|
|
6171
|
+
}
|
|
6172
|
+
preservesLazyIfReferenceArray(_child) {
|
|
6173
|
+
return false;
|
|
6174
|
+
}
|
|
6175
|
+
isCalculated() {
|
|
6176
|
+
return this._calculateState;
|
|
6177
|
+
}
|
|
6178
|
+
setCalculated() {
|
|
6179
|
+
this._calculateState = true;
|
|
6180
|
+
}
|
|
6181
|
+
execute() {}
|
|
6182
|
+
setNotEmpty(state = true) {}
|
|
6183
|
+
async executeAsync() {
|
|
6184
|
+
return Promise.resolve(0);
|
|
6185
|
+
}
|
|
6186
|
+
serialize() {
|
|
6187
|
+
const token = this.getToken();
|
|
6188
|
+
const children = this.getChildren();
|
|
6189
|
+
const childrenSerialization = [];
|
|
6190
|
+
const childrenCount = children.length;
|
|
6191
|
+
for (let i = 0; i < childrenCount; i++) {
|
|
6192
|
+
const item = children[i];
|
|
6193
|
+
childrenSerialization.push(item.serialize());
|
|
6194
|
+
}
|
|
6195
|
+
const result = {
|
|
6196
|
+
token,
|
|
6197
|
+
nodeType: this.nodeType
|
|
6198
|
+
};
|
|
6199
|
+
if (childrenCount > 0) result.children = childrenSerialization;
|
|
6200
|
+
return result;
|
|
6201
|
+
}
|
|
6202
|
+
hasDefinedName(definedName) {
|
|
6203
|
+
var _this$_definedNames;
|
|
6204
|
+
return ((_this$_definedNames = this._definedNames) === null || _this$_definedNames === void 0 ? void 0 : _this$_definedNames.includes(definedName)) || false;
|
|
6205
|
+
}
|
|
6206
|
+
setDefinedNames(definedNames) {
|
|
6207
|
+
this._definedNames = definedNames;
|
|
6208
|
+
}
|
|
6209
|
+
getDefinedNames() {
|
|
6210
|
+
return this._definedNames;
|
|
6211
|
+
}
|
|
6212
|
+
};
|
|
6213
|
+
var ErrorNode = class ErrorNode extends BaseAstNode {
|
|
6214
|
+
constructor(errorType) {
|
|
6215
|
+
super(errorType);
|
|
6216
|
+
_defineProperty(this, "_errorValueObject", void 0);
|
|
6217
|
+
this._errorValueObject = ErrorValueObject.create(errorType);
|
|
6218
|
+
}
|
|
6219
|
+
get nodeType() {
|
|
6220
|
+
return 7;
|
|
6221
|
+
}
|
|
6222
|
+
static create(errorType) {
|
|
6223
|
+
return new ErrorNode(errorType);
|
|
6224
|
+
}
|
|
6225
|
+
getValue() {
|
|
6226
|
+
return this._errorValueObject;
|
|
6227
|
+
}
|
|
6228
|
+
};
|
|
6229
|
+
|
|
6230
|
+
//#endregion
|
|
6231
|
+
//#region src/engine/utils/generate-ast-node.ts
|
|
6232
|
+
const FORMULA_CACHE_LRU_COUNT$1 = 5e3;
|
|
6233
|
+
const FORMULA_AST_CACHE = new FormulaAstLRU(FORMULA_CACHE_LRU_COUNT$1);
|
|
6234
|
+
const DIRTY_DEFINED_NAME_SET_CACHE = /* @__PURE__ */ new WeakMap();
|
|
6235
|
+
const DIRTY_SUPER_TABLE_PATTERN_CACHE = /* @__PURE__ */ new WeakMap();
|
|
6236
|
+
function generateAstNode(unitId, formulaString, lexer, astTreeBuilder, currentConfigService, subUnitId, definedNameRefOffsetX = 0, definedNameRefOffsetY = 0) {
|
|
6237
|
+
if (subUnitId) {
|
|
6238
|
+
currentConfigService.setExecuteUnitId(unitId);
|
|
6239
|
+
currentConfigService.setExecuteSubUnitId(subUnitId);
|
|
6240
|
+
}
|
|
6241
|
+
const cacheKey = `${unitId}:${subUnitId ?? currentConfigService.getExecuteSubUnitId() ?? ""}:${definedNameRefOffsetX}:${definedNameRefOffsetY}:${formulaString}`;
|
|
6242
|
+
let astNode = FORMULA_AST_CACHE.get(cacheKey);
|
|
6243
|
+
if (!(checkIsChangedByDefinedName(unitId, formulaString, currentConfigService) || checkIsChangedBySuperTable(unitId, formulaString, currentConfigService)) && astNode && !isDirtyDefinedForNode(astNode, currentConfigService, unitId)) return astNode;
|
|
6244
|
+
const lexerNode = lexer.treeBuilder(formulaString, true, unitId, definedNameRefOffsetX, definedNameRefOffsetY);
|
|
6245
|
+
if (ERROR_TYPE_SET.has(lexerNode)) return ErrorNode.create(lexerNode);
|
|
6246
|
+
astNode = astTreeBuilder.parse(lexerNode);
|
|
6247
|
+
if (astNode == null) {
|
|
6248
|
+
console.error("generateAstNode astNode is null");
|
|
6249
|
+
return ErrorNode.create(lexerNode);
|
|
6250
|
+
}
|
|
6251
|
+
FORMULA_AST_CACHE.set(cacheKey, astNode);
|
|
6252
|
+
return astNode;
|
|
6253
|
+
}
|
|
6254
|
+
function checkIsChangedByDefinedName(unitId, formula, currentConfigService) {
|
|
6255
|
+
const unitDefinedNameMap = currentConfigService.getDirtyDefinedNameMap()[unitId];
|
|
6256
|
+
if (unitDefinedNameMap == null) return false;
|
|
6257
|
+
return getNormalizedDirtyDefinedNameSet(unitDefinedNameMap).has(normalizeFormulaText(formula));
|
|
6258
|
+
}
|
|
6259
|
+
function normalizeFormulaText(formula) {
|
|
6260
|
+
return formula.startsWith("=") ? formula.slice(1) : formula;
|
|
6261
|
+
}
|
|
6262
|
+
function checkIsChangedBySuperTable(unitId, formula, currentConfigService) {
|
|
6263
|
+
var _currentConfigService;
|
|
6264
|
+
const getDirtySuperTableMap = (_currentConfigService = currentConfigService.getDirtySuperTableMap) === null || _currentConfigService === void 0 ? void 0 : _currentConfigService.bind(currentConfigService);
|
|
6265
|
+
const changedSuperTableMap = getDirtySuperTableMap === null || getDirtySuperTableMap === void 0 ? void 0 : getDirtySuperTableMap();
|
|
6266
|
+
const unitSuperTableMap = changedSuperTableMap === null || changedSuperTableMap === void 0 ? void 0 : changedSuperTableMap[unitId];
|
|
6267
|
+
if (unitSuperTableMap == null) return false;
|
|
6268
|
+
const tableReferencePattern = getDirtySuperTableReferencePattern(unitSuperTableMap);
|
|
6269
|
+
return (tableReferencePattern === null || tableReferencePattern === void 0 ? void 0 : tableReferencePattern.test(normalizeFormulaText(formula))) ?? false;
|
|
6270
|
+
}
|
|
6271
|
+
function getNormalizedDirtyDefinedNameSet(unitDefinedNameMap) {
|
|
6272
|
+
let normalizedNameSet = DIRTY_DEFINED_NAME_SET_CACHE.get(unitDefinedNameMap);
|
|
6273
|
+
if (normalizedNameSet == null) {
|
|
6274
|
+
normalizedNameSet = new Set(Object.keys(unitDefinedNameMap).map(normalizeFormulaText));
|
|
6275
|
+
DIRTY_DEFINED_NAME_SET_CACHE.set(unitDefinedNameMap, normalizedNameSet);
|
|
6276
|
+
}
|
|
6277
|
+
return normalizedNameSet;
|
|
6278
|
+
}
|
|
6279
|
+
function getDirtySuperTableReferencePattern(unitSuperTableMap) {
|
|
6280
|
+
let tableReferencePattern = DIRTY_SUPER_TABLE_PATTERN_CACHE.get(unitSuperTableMap);
|
|
6281
|
+
if (tableReferencePattern === void 0) {
|
|
6282
|
+
const tableNames = Object.keys(unitSuperTableMap).filter((tableName) => tableName.length > 0);
|
|
6283
|
+
tableReferencePattern = tableNames.length > 0 ? regexp.createRegExpFromSafeFragment(`(^|[^A-Za-z0-9_])${regexp.or(...tableNames)}(\\s*\\[|$|[^A-Za-z0-9_])`, "i") : null;
|
|
6284
|
+
DIRTY_SUPER_TABLE_PATTERN_CACHE.set(unitSuperTableMap, tableReferencePattern);
|
|
6285
|
+
}
|
|
6286
|
+
return tableReferencePattern;
|
|
6287
|
+
}
|
|
6288
|
+
function isDirtyDefinedForNode(node, currentConfigService, unitId) {
|
|
6289
|
+
const definedNameMap = currentConfigService.getDirtyDefinedNameMap();
|
|
6290
|
+
const executeUnitId = unitId;
|
|
6291
|
+
if (executeUnitId != null && definedNameMap[executeUnitId] != null) {
|
|
6292
|
+
const names = Object.keys(definedNameMap[executeUnitId]);
|
|
6293
|
+
for (let i = 0, len = names.length; i < len; i++) {
|
|
6294
|
+
const name = names[i];
|
|
6295
|
+
if (node.hasDefinedName(name)) return true;
|
|
6296
|
+
}
|
|
6297
|
+
}
|
|
6298
|
+
return false;
|
|
6299
|
+
}
|
|
6300
|
+
function includeDefinedName(tree, node, currentConfigService) {
|
|
6301
|
+
/**
|
|
6302
|
+
* Detect whether the dirty map contains a defined name.
|
|
6303
|
+
*/
|
|
6304
|
+
if (node != null) {
|
|
6305
|
+
if (isDirtyDefinedForNode(node, currentConfigService, tree.unitId)) return true;
|
|
6306
|
+
}
|
|
6307
|
+
return false;
|
|
6308
|
+
}
|
|
6309
|
+
|
|
6310
|
+
//#endregion
|
|
6311
|
+
//#region src/services/function.service.ts
|
|
6312
|
+
const IFunctionService = createIdentifier("univer.formula-function.service");
|
|
6313
|
+
var FunctionService = class extends Disposable {
|
|
6314
|
+
constructor(..._args) {
|
|
6315
|
+
super(..._args);
|
|
6316
|
+
_defineProperty(this, "_functionExecutors", /* @__PURE__ */ new Map());
|
|
6317
|
+
_defineProperty(this, "_functionDescriptions", /* @__PURE__ */ new Map());
|
|
6318
|
+
}
|
|
6319
|
+
dispose() {
|
|
6320
|
+
super.dispose();
|
|
6321
|
+
this._functionExecutors.clear();
|
|
6322
|
+
this._functionDescriptions.clear();
|
|
6323
|
+
}
|
|
6324
|
+
registerExecutors(...functions) {
|
|
6325
|
+
for (let i = 0; i < functions.length; i++) {
|
|
6326
|
+
const func = functions[i];
|
|
6327
|
+
this._functionExecutors.set(func.name, func);
|
|
6328
|
+
}
|
|
6329
|
+
}
|
|
6330
|
+
getExecutors() {
|
|
6331
|
+
return this._functionExecutors;
|
|
6332
|
+
}
|
|
6333
|
+
getExecutor(functionToken) {
|
|
6334
|
+
return this._functionExecutors.get(functionToken);
|
|
6335
|
+
}
|
|
6336
|
+
hasExecutor(functionToken) {
|
|
6337
|
+
return this._functionExecutors.has(functionToken);
|
|
6338
|
+
}
|
|
6339
|
+
unregisterExecutors(...functionTokens) {
|
|
6340
|
+
for (let i = 0; i < functionTokens.length; i++) {
|
|
6341
|
+
const functionToken = functionTokens[i];
|
|
6342
|
+
this._functionExecutors.delete(functionToken);
|
|
6343
|
+
}
|
|
6344
|
+
}
|
|
6345
|
+
registerDescriptions(...descriptions) {
|
|
6346
|
+
for (let i = 0; i < descriptions.length; i++) {
|
|
6347
|
+
const description = descriptions[i];
|
|
6348
|
+
this._functionDescriptions.set(description.functionName, description);
|
|
6349
|
+
}
|
|
6350
|
+
return toDisposable(() => {
|
|
6351
|
+
for (let i = 0; i < descriptions.length; i++) {
|
|
6352
|
+
const description = descriptions[i];
|
|
6353
|
+
this._functionDescriptions.delete(description.functionName);
|
|
6354
|
+
}
|
|
6355
|
+
});
|
|
6356
|
+
}
|
|
6357
|
+
getDescriptions() {
|
|
6358
|
+
return this._functionDescriptions;
|
|
6359
|
+
}
|
|
6360
|
+
getDescription(functionToken) {
|
|
6361
|
+
return this._functionDescriptions.get(functionToken);
|
|
6362
|
+
}
|
|
6363
|
+
hasDescription(functionToken) {
|
|
6364
|
+
return this._functionDescriptions.has(functionToken);
|
|
6365
|
+
}
|
|
6366
|
+
unregisterDescriptions(...functionTokens) {
|
|
6367
|
+
for (let i = 0; i < functionTokens.length; i++) {
|
|
6368
|
+
const functionToken = functionTokens[i];
|
|
6369
|
+
this._functionDescriptions.delete(functionToken);
|
|
6370
|
+
}
|
|
6371
|
+
}
|
|
6372
|
+
clearDescriptions() {
|
|
6373
|
+
this._functionDescriptions.clear();
|
|
6374
|
+
}
|
|
6375
|
+
deleteFormulaAstCacheKey(...functionToken) {
|
|
6376
|
+
FORMULA_AST_CACHE.forEach((_, key) => {
|
|
6377
|
+
functionToken.forEach((token) => {
|
|
6378
|
+
if (key.includes(token)) FORMULA_AST_CACHE.delete(key);
|
|
6379
|
+
});
|
|
6380
|
+
});
|
|
6381
|
+
}
|
|
6382
|
+
};
|
|
6383
|
+
|
|
6065
6384
|
//#endregion
|
|
6066
6385
|
//#region src/engine/analysis/lexer.ts
|
|
6067
6386
|
let Lexer = class Lexer extends Disposable {
|
|
6068
|
-
constructor(_definedNamesService, _lexerTreeBuilder, _formulaCurrentConfigService) {
|
|
6387
|
+
constructor(_definedNamesService, _lexerTreeBuilder, _formulaCurrentConfigService, _functionService) {
|
|
6069
6388
|
super();
|
|
6070
6389
|
this._definedNamesService = _definedNamesService;
|
|
6071
6390
|
this._lexerTreeBuilder = _lexerTreeBuilder;
|
|
6072
6391
|
this._formulaCurrentConfigService = _formulaCurrentConfigService;
|
|
6392
|
+
this._functionService = _functionService;
|
|
6073
6393
|
}
|
|
6074
|
-
treeBuilder(formulaString, transformSuffix = true, unitId) {
|
|
6394
|
+
treeBuilder(formulaString, transformSuffix = true, unitId, refOffsetX = 0, refOffsetY = 0) {
|
|
6075
6395
|
if (this._definedNamesService.getAllDefinedNamesIsEmpty()) return this._lexerTreeBuilder.treeBuilder(formulaString, transformSuffix);
|
|
6076
6396
|
return this._lexerTreeBuilder.treeBuilder(formulaString, transformSuffix, {
|
|
6077
|
-
unitId: unitId
|
|
6397
|
+
unitId: unitId ?? this._formulaCurrentConfigService.getExecuteUnitId(),
|
|
6078
6398
|
sheetId: this._formulaCurrentConfigService.getExecuteSubUnitId(),
|
|
6399
|
+
refOffsetX,
|
|
6400
|
+
refOffsetY,
|
|
6401
|
+
hasFunction: this._functionService.hasExecutor.bind(this._functionService),
|
|
6079
6402
|
getValueByName: this._definedNamesService.getValueByName.bind(this._definedNamesService),
|
|
6080
6403
|
getDirtyDefinedNameMap: this._formulaCurrentConfigService.getDirtyDefinedNameMap.bind(this._formulaCurrentConfigService),
|
|
6081
6404
|
getSheetName: this._formulaCurrentConfigService.getSheetName.bind(this._formulaCurrentConfigService)
|
|
@@ -6085,13 +6408,13 @@ let Lexer = class Lexer extends Disposable {
|
|
|
6085
6408
|
Lexer = __decorate([
|
|
6086
6409
|
__decorateParam(0, IDefinedNamesService),
|
|
6087
6410
|
__decorateParam(1, Inject(LexerTreeBuilder)),
|
|
6088
|
-
__decorateParam(2, IFormulaCurrentConfigService)
|
|
6411
|
+
__decorateParam(2, IFormulaCurrentConfigService),
|
|
6412
|
+
__decorateParam(3, IFunctionService)
|
|
6089
6413
|
], Lexer);
|
|
6090
6414
|
|
|
6091
6415
|
//#endregion
|
|
6092
6416
|
//#region src/engine/utils/cell.ts
|
|
6093
6417
|
function getCellValue(cell) {
|
|
6094
|
-
var _cell$v;
|
|
6095
6418
|
if (cell === null) return 0;
|
|
6096
6419
|
if (cell === null || cell === void 0 ? void 0 : cell.p) {
|
|
6097
6420
|
const body = cell === null || cell === void 0 ? void 0 : cell.p.body;
|
|
@@ -6099,7 +6422,7 @@ function getCellValue(cell) {
|
|
|
6099
6422
|
const data = body.dataStream;
|
|
6100
6423
|
return normalizeRichTextFormulaValue(BuildTextUtils.transform.getPlainText(data));
|
|
6101
6424
|
}
|
|
6102
|
-
return (
|
|
6425
|
+
return (cell === null || cell === void 0 ? void 0 : cell.v) ?? 0;
|
|
6103
6426
|
}
|
|
6104
6427
|
function normalizeRichTextFormulaValue(value) {
|
|
6105
6428
|
return value.replace(/\r\n|\r|\n/g, "\r\n");
|
|
@@ -7265,9 +7588,8 @@ var StringValueObject = class StringValueObject extends BaseValueObject {
|
|
|
7265
7588
|
if (cached && options && this.checkCacheByOptions(cached, options)) return cached;
|
|
7266
7589
|
const instance = new StringValueObject(value);
|
|
7267
7590
|
if (options === null || options === void 0 ? void 0 : options.isHyperlink) {
|
|
7268
|
-
var _options$hyperlinkUrl;
|
|
7269
7591
|
instance._isHyperlink = options.isHyperlink;
|
|
7270
|
-
instance._hyperlinkUrl =
|
|
7592
|
+
instance._hyperlinkUrl = options.hyperlinkUrl ?? "";
|
|
7271
7593
|
}
|
|
7272
7594
|
if (options === null || options === void 0 ? void 0 : options.isImage) {
|
|
7273
7595
|
instance._isImage = options.isImage;
|
|
@@ -8575,6 +8897,7 @@ var ValueObjectFactory = class {
|
|
|
8575
8897
|
const rawValueUpper = rawValue.toLocaleUpperCase().trim();
|
|
8576
8898
|
if (ERROR_TYPE_SET.has(rawValueUpper)) return ErrorValueObject.create(rawValueUpper);
|
|
8577
8899
|
if (rawValueUpper === "TRUE" || rawValueUpper === "FALSE") return createBooleanValueObjectByRawValue(rawValue);
|
|
8900
|
+
if (isStringWrappedByDoubleQuotes(rawValue)) return createStringValueObjectByRawValue(rawValue);
|
|
8578
8901
|
if (isRealNum(rawValue) && Number(rawValue).toString() === rawValue.trim()) return NumberValueObject.create(Number(rawValue));
|
|
8579
8902
|
if (!isIgnoreNumberPattern) {
|
|
8580
8903
|
const { isNumberPattern, value, pattern } = stringIsNumberPattern(rawValue);
|
|
@@ -8595,8 +8918,8 @@ function isStringWrappedByDoubleQuotes(input) {
|
|
|
8595
8918
|
|
|
8596
8919
|
//#endregion
|
|
8597
8920
|
//#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
|
|
8921
|
+
const FORMULA_CACHE_LRU_COUNT = 1e4;
|
|
8922
|
+
const FORMULA_REF_TO_ARRAY_CACHE = new FormulaAstLRU(FORMULA_CACHE_LRU_COUNT);
|
|
8600
8923
|
var BaseReferenceObject = class extends ObjectClassType {
|
|
8601
8924
|
constructor(_token) {
|
|
8602
8925
|
super();
|
|
@@ -8954,11 +9277,9 @@ var BaseReferenceObject = class extends ObjectClassType {
|
|
|
8954
9277
|
return getRuntimeFeatureCell(row, column, this.getSheetId(), this.getUnitId(), this._runtimeFeatureCellData);
|
|
8955
9278
|
}
|
|
8956
9279
|
getCellByPosition(rowRaw, columnRaw) {
|
|
8957
|
-
|
|
8958
|
-
|
|
8959
|
-
const
|
|
8960
|
-
if (!row) row = rangeData.startRow;
|
|
8961
|
-
if (!column) column = rangeData.startColumn;
|
|
9280
|
+
const range = this.getRangePosition();
|
|
9281
|
+
const row = rowRaw ?? range.startRow;
|
|
9282
|
+
const column = columnRaw ?? range.startColumn;
|
|
8962
9283
|
const cell = this.getCellData(row, column);
|
|
8963
9284
|
if (!cell) return NullValueObject.create();
|
|
8964
9285
|
return this.getCellValueObject(cell);
|
|
@@ -9028,6 +9349,9 @@ var BaseReferenceObject = class extends ObjectClassType {
|
|
|
9028
9349
|
unitId: this.getUnitId()
|
|
9029
9350
|
};
|
|
9030
9351
|
}
|
|
9352
|
+
toUnitRanges() {
|
|
9353
|
+
return [this.toUnitRange()];
|
|
9354
|
+
}
|
|
9031
9355
|
_checkIfWorksheetMiss() {
|
|
9032
9356
|
if ((this._forcedSheetId == null || this._forcedSheetId.length === 0) && this._forcedSheetName.length > 0) return true;
|
|
9033
9357
|
return false;
|
|
@@ -9296,7 +9620,7 @@ function expandArrayValueObject(rowCount, columnCount, valueObject, defaultValue
|
|
|
9296
9620
|
continue;
|
|
9297
9621
|
}
|
|
9298
9622
|
if (r >= valueRowCount || c >= valueColumnCount) {
|
|
9299
|
-
row.push(defaultValue
|
|
9623
|
+
row.push(defaultValue ?? NullValueObject.create());
|
|
9300
9624
|
continue;
|
|
9301
9625
|
}
|
|
9302
9626
|
const value = valueObject.get(r, c);
|
|
@@ -9634,8 +9958,11 @@ function filterSameValueObjectResult(array, range, criteria) {
|
|
|
9634
9958
|
return array.mapValue((valueObject, r, c) => {
|
|
9635
9959
|
const rangeValueObject = range.get(r, c);
|
|
9636
9960
|
const isBlankStringCriteria = criteriaObject.isString() && criteriaObject.getValue() === "";
|
|
9961
|
+
if (isBlankStringCriteria && (operator === ">" || operator === ">=" || operator === "<" || operator === "<=")) return BooleanValueObject.create(false);
|
|
9637
9962
|
if (operator === "<>" && isBlankStringCriteria && (rangeValueObject === null || rangeValueObject === void 0 ? void 0 : rangeValueObject.isString()) && rangeValueObject.getValue() === "") return BooleanValueObject.create(true);
|
|
9638
|
-
if (criteriaObject.isString() && criteriaObject.getValue()
|
|
9963
|
+
if (criteriaObject.isString() && isWildcard(`${criteriaObject.getValue()}`) && (rangeValueObject === null || rangeValueObject === void 0 ? void 0 : rangeValueObject.isString()) && rangeValueObject.getValue() === "") return valueObject;
|
|
9964
|
+
if (criteriaObject.isString() && criteriaObject.getValue() !== "" && (operator === "<" || operator === "<=") && (rangeValueObject === null || rangeValueObject === void 0 ? void 0 : rangeValueObject.isString()) && rangeValueObject.getValue() === "") return BooleanValueObject.create(true);
|
|
9965
|
+
if (criteriaObject.isString() && criteriaObject.getValue() !== "" && (operator === "<" || operator === "<=") && (rangeValueObject == null || rangeValueObject.isNull())) return BooleanValueObject.create(false);
|
|
9639
9966
|
if (criteriaObject.isString() && (rangeValueObject === null || rangeValueObject === void 0 ? void 0 : rangeValueObject.isString()) && (operator === "<" || operator === "<=") && isSameLowerBoundBucket(rangeValueObject.getValue(), criteriaObject.getValue())) return BooleanValueObject.create(false);
|
|
9640
9967
|
if ((rangeValueObject === null || rangeValueObject === void 0 ? void 0 : rangeValueObject.isNumber()) && criteriaObject.isString()) {
|
|
9641
9968
|
const criteriaNumber = criteriaObject.convertToNumberObjectValue();
|
|
@@ -9804,12 +10131,12 @@ let FormulaRuntimeService = class FormulaRuntimeService extends Disposable {
|
|
|
9804
10131
|
return this._currentColumn;
|
|
9805
10132
|
}
|
|
9806
10133
|
get currentRowCount() {
|
|
9807
|
-
var _this$_functionRefInf
|
|
9808
|
-
return (_this$_functionRefInf =
|
|
10134
|
+
var _this$_functionRefInf;
|
|
10135
|
+
return ((_this$_functionRefInf = this._functionRefInfoOverrideStack[this._functionRefInfoOverrideStack.length - 1]) === null || _this$_functionRefInf === void 0 ? void 0 : _this$_functionRefInf.rowCount) ?? this._currentRowCount;
|
|
9809
10136
|
}
|
|
9810
10137
|
get currentColumnCount() {
|
|
9811
|
-
var _this$
|
|
9812
|
-
return (
|
|
10138
|
+
var _this$_functionRefInf2;
|
|
10139
|
+
return ((_this$_functionRefInf2 = this._functionRefInfoOverrideStack[this._functionRefInfoOverrideStack.length - 1]) === null || _this$_functionRefInf2 === void 0 ? void 0 : _this$_functionRefInf2.columnCount) ?? this._currentColumnCount;
|
|
9813
10140
|
}
|
|
9814
10141
|
get currentSubUnitId() {
|
|
9815
10142
|
return this._currentSubUnitId;
|
|
@@ -10245,151 +10572,6 @@ let FormulaRuntimeService = class FormulaRuntimeService extends Disposable {
|
|
|
10245
10572
|
FormulaRuntimeService = __decorate([__decorateParam(0, IFormulaCurrentConfigService), __decorateParam(1, IHyperlinkEngineFormulaService)], FormulaRuntimeService);
|
|
10246
10573
|
const IFormulaRuntimeService = createIdentifier("univer.formula.runtime.service");
|
|
10247
10574
|
|
|
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
10575
|
//#endregion
|
|
10394
10576
|
//#region src/engine/ast-node/base-ast-node-factory.ts
|
|
10395
10577
|
var BaseAstNodeFactory = class {
|
|
@@ -10455,161 +10637,6 @@ const COLUMN_LIKE_FUNCTION_NAMES = new Set(ALL_GROUPS.flatMap((g) => Object.valu
|
|
|
10455
10637
|
return idx > 0 && idx <= MAX_COLUMN_COUNT;
|
|
10456
10638
|
}));
|
|
10457
10639
|
|
|
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
10640
|
//#endregion
|
|
10614
10641
|
//#region src/services/unit-reference-resolver.service.ts
|
|
10615
10642
|
const IFormulaUnitReferenceResolver = createIdentifier("univer.formula.unit-reference-resolver");
|
|
@@ -10681,7 +10708,8 @@ var PrefixNode = class extends BaseAstNode {
|
|
|
10681
10708
|
this.setValue(result);
|
|
10682
10709
|
}
|
|
10683
10710
|
_handlerAT(value) {
|
|
10684
|
-
if (
|
|
10711
|
+
if (value instanceof ArrayValueObject) return value.get(0, 0) ?? ErrorValueObject.create("#VALUE!");
|
|
10712
|
+
if (!value.isReferenceObject()) return value;
|
|
10685
10713
|
const currentValue = value;
|
|
10686
10714
|
if (currentValue.isCell()) return ErrorValueObject.create("#VALUE!");
|
|
10687
10715
|
if (this._preserveAtRangeForFormula2LookupArray()) return currentValue;
|
|
@@ -10701,7 +10729,7 @@ var PrefixNode = class extends BaseAstNode {
|
|
|
10701
10729
|
let parent = node.getParent();
|
|
10702
10730
|
let sawCompareOperator = false;
|
|
10703
10731
|
while (parent != null) {
|
|
10704
|
-
if (parent.nodeType === 3) sawCompareOperator
|
|
10732
|
+
if (parent.nodeType === 3) sawCompareOperator ||= OPERATOR_TOKEN_COMPARE_SET.has(parent.getToken());
|
|
10705
10733
|
if (parent.nodeType === 4) {
|
|
10706
10734
|
const functionName = parent.getToken().toUpperCase();
|
|
10707
10735
|
if (sawCompareOperator && functionName === "XMATCH") return parent.getChildren().indexOf(node) === 1;
|
|
@@ -10787,6 +10815,9 @@ var FunctionNode = class extends BaseAstNode {
|
|
|
10787
10815
|
get nodeType() {
|
|
10788
10816
|
return 4;
|
|
10789
10817
|
}
|
|
10818
|
+
preservesLazyIfReferenceArray(child) {
|
|
10819
|
+
return this._functionExecutor.lazyIfReferenceArrayArgumentIndexes.includes(this.getChildren().indexOf(child));
|
|
10820
|
+
}
|
|
10790
10821
|
async executeAsync() {
|
|
10791
10822
|
const children = this.getChildren();
|
|
10792
10823
|
this._compatibility();
|
|
@@ -10936,10 +10967,7 @@ var FunctionNode = class extends BaseAstNode {
|
|
|
10936
10967
|
if (minParams !== -1 && maxParams !== -1 && (children.length < minParams || children.length > maxParams)) return ErrorValueObject.create("#N/A");
|
|
10937
10968
|
this._setRefInfo();
|
|
10938
10969
|
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
|
-
});
|
|
10970
|
+
return this._functionExecutor.calculateAst(children, (node) => this._getChildVariant(node) ?? null);
|
|
10943
10971
|
}
|
|
10944
10972
|
async _calculateAsync(variants) {
|
|
10945
10973
|
const { minParams, maxParams } = this._functionExecutor;
|
|
@@ -11211,7 +11239,6 @@ let Interpreter = class Interpreter extends Disposable {
|
|
|
11211
11239
|
return true;
|
|
11212
11240
|
}
|
|
11213
11241
|
async _executeLazyIfErrorAsync(node, refOffsetX, refOffsetY) {
|
|
11214
|
-
var _children$1$getValue;
|
|
11215
11242
|
const children = node.getChildren();
|
|
11216
11243
|
if (children.length !== 2) return false;
|
|
11217
11244
|
await this._executeAsync(children[0], refOffsetX, refOffsetY);
|
|
@@ -11223,11 +11250,10 @@ let Interpreter = class Interpreter extends Disposable {
|
|
|
11223
11250
|
return true;
|
|
11224
11251
|
}
|
|
11225
11252
|
await this._executeAsync(children[1], refOffsetX, refOffsetY);
|
|
11226
|
-
node.setValue(
|
|
11253
|
+
node.setValue(children[1].getValue() ?? ErrorValueObject.create("#VALUE!"));
|
|
11227
11254
|
return true;
|
|
11228
11255
|
}
|
|
11229
11256
|
_executeLazyIfError(node, refOffsetX, refOffsetY) {
|
|
11230
|
-
var _children$1$getValue2;
|
|
11231
11257
|
const children = node.getChildren();
|
|
11232
11258
|
if (children.length !== 2) return false;
|
|
11233
11259
|
this._execute(children[0], refOffsetX, refOffsetY);
|
|
@@ -11239,7 +11265,7 @@ let Interpreter = class Interpreter extends Disposable {
|
|
|
11239
11265
|
return true;
|
|
11240
11266
|
}
|
|
11241
11267
|
this._execute(children[1], refOffsetX, refOffsetY);
|
|
11242
|
-
node.setValue(
|
|
11268
|
+
node.setValue(children[1].getValue() ?? ErrorValueObject.create("#VALUE!"));
|
|
11243
11269
|
return true;
|
|
11244
11270
|
}
|
|
11245
11271
|
_toLazyIfErrorValue(value) {
|
|
@@ -11255,12 +11281,13 @@ let Interpreter = class Interpreter extends Disposable {
|
|
|
11255
11281
|
}
|
|
11256
11282
|
_toLazyIfSelectedValue(value, node) {
|
|
11257
11283
|
if (value == null) return ErrorValueObject.create("#VALUE!");
|
|
11284
|
+
const preserveArray = this._preserveLazyIfSelectedReferenceArray(node);
|
|
11258
11285
|
if (value.isReferenceObject()) {
|
|
11259
11286
|
const reference = value;
|
|
11260
|
-
if (
|
|
11287
|
+
if (preserveArray) return reference.toArrayValueObject();
|
|
11261
11288
|
value = this._implicitLazyIfReferenceValue(reference);
|
|
11262
11289
|
}
|
|
11263
|
-
if (value.isArray()) value = this._implicitLazyIfArrayValue(value);
|
|
11290
|
+
if (value.isArray() && !preserveArray) value = this._implicitLazyIfArrayValue(value);
|
|
11264
11291
|
if (!value.isArray()) {
|
|
11265
11292
|
const baseValue = value;
|
|
11266
11293
|
return baseValue.isNull() ? NumberValueObject.create(0) : baseValue;
|
|
@@ -11281,7 +11308,7 @@ let Interpreter = class Interpreter extends Disposable {
|
|
|
11281
11308
|
let child = node;
|
|
11282
11309
|
let parent = child.getParent();
|
|
11283
11310
|
while (parent != null) {
|
|
11284
|
-
if (parent.nodeType === 4) return parent.
|
|
11311
|
+
if (parent.nodeType === 4) return parent.preservesLazyIfReferenceArray(child);
|
|
11285
11312
|
child = parent;
|
|
11286
11313
|
parent = parent.getParent();
|
|
11287
11314
|
}
|
|
@@ -11854,10 +11881,9 @@ var TableReferenceObject = class extends BaseReferenceObject {
|
|
|
11854
11881
|
* - Has comma: Left is Section, right is column/column range
|
|
11855
11882
|
*/
|
|
11856
11883
|
_parseStructuredRef(raw, titleMap) {
|
|
11857
|
-
var _range$startColumn, _range$endColumn;
|
|
11858
11884
|
const { range } = this._tableData;
|
|
11859
|
-
const fullStartCol =
|
|
11860
|
-
const fullEndCol =
|
|
11885
|
+
const fullStartCol = range.startColumn ?? 0;
|
|
11886
|
+
const fullEndCol = range.endColumn ?? 0;
|
|
11861
11887
|
if (!raw || raw.trim().length === 0) return {
|
|
11862
11888
|
startColumn: fullStartCol,
|
|
11863
11889
|
endColumn: fullEndCol,
|
|
@@ -11909,6 +11935,14 @@ var TableReferenceObject = class extends BaseReferenceObject {
|
|
|
11909
11935
|
const sectionRaw = body.slice(0, commaAt).trim();
|
|
11910
11936
|
const columnsRaw = body.slice(commaAt + 1).trim();
|
|
11911
11937
|
const section = this._parseSectionMaybeBracketed(sectionRaw);
|
|
11938
|
+
if (section === void 0) {
|
|
11939
|
+
const { startColumn, endColumn } = this._parseColumnOrRange(body, titleMap, fullStartCol);
|
|
11940
|
+
return {
|
|
11941
|
+
startColumn,
|
|
11942
|
+
endColumn,
|
|
11943
|
+
type: "#Data"
|
|
11944
|
+
};
|
|
11945
|
+
}
|
|
11912
11946
|
const { startColumn, endColumn } = this._parseColumnOrRange(columnsRaw, titleMap, fullStartCol);
|
|
11913
11947
|
return {
|
|
11914
11948
|
startColumn,
|
|
@@ -11937,13 +11971,12 @@ var TableReferenceObject = class extends BaseReferenceObject {
|
|
|
11937
11971
|
}
|
|
11938
11972
|
/**
|
|
11939
11973
|
* Parse Section, compatible with both "[#Data]" and "#Data" inputs
|
|
11940
|
-
* Returns TableOptionType if matched; returns
|
|
11974
|
+
* Returns TableOptionType if matched; returns undefined when the comma belongs to a column title.
|
|
11941
11975
|
*/
|
|
11942
11976
|
_parseSectionMaybeBracketed(raw) {
|
|
11943
11977
|
const x = raw.trim();
|
|
11944
11978
|
const inner = x.startsWith("[") && x.endsWith("]") ? this._stripOuterBracketOnce(x) : x;
|
|
11945
|
-
|
|
11946
|
-
return typeMaybe !== null && typeMaybe !== void 0 ? typeMaybe : "#Data";
|
|
11979
|
+
return this._mapSection(inner);
|
|
11947
11980
|
}
|
|
11948
11981
|
/**
|
|
11949
11982
|
* Section mapping: Only accepts keywords starting with #.
|
|
@@ -11968,6 +12001,14 @@ var TableReferenceObject = class extends BaseReferenceObject {
|
|
|
11968
12001
|
*/
|
|
11969
12002
|
_parseColumnOrRange(raw, titleMap, fullStartCol) {
|
|
11970
12003
|
const s = raw.trim();
|
|
12004
|
+
const singleColumnIndex = this._titleToIndex(this._stripOuterBracketIfAny(s), titleMap);
|
|
12005
|
+
if (singleColumnIndex !== -1) {
|
|
12006
|
+
const column = fullStartCol + singleColumnIndex;
|
|
12007
|
+
return {
|
|
12008
|
+
startColumn: column,
|
|
12009
|
+
endColumn: column
|
|
12010
|
+
};
|
|
12011
|
+
}
|
|
11971
12012
|
const colonAt = this._findColonAtTopLevel(s);
|
|
11972
12013
|
if (colonAt === -1) {
|
|
11973
12014
|
const name = this._stripOuterBracketIfAny(s);
|
|
@@ -12209,12 +12250,11 @@ let ReferenceNodeFactory = class ReferenceNodeFactory extends BaseAstNodeFactory
|
|
|
12209
12250
|
return this._superTableService.getTableMap(unitId);
|
|
12210
12251
|
}
|
|
12211
12252
|
_getNode(tokenTrim, isLexerNode, isPrepareMerge, param) {
|
|
12212
|
-
var _tableMap$has;
|
|
12213
12253
|
const currentConfigService = this._currentConfigService;
|
|
12214
12254
|
const runtimeService = this._formulaRuntimeService;
|
|
12215
12255
|
const makeRef = (type) => new ReferenceNode(currentConfigService, runtimeService, tokenTrim, type, this._unitReferenceResolver, this._superTableService, this._externalReferenceDataLoader, isPrepareMerge);
|
|
12216
12256
|
const tableMap = this._getTableMap();
|
|
12217
|
-
if ((
|
|
12257
|
+
if ((tableMap === null || tableMap === void 0 ? void 0 : tableMap.has(tokenTrim)) ?? false) return this._getTableReferenceNode(tokenTrim, isPrepareMerge, true);
|
|
12218
12258
|
if (regexTestSingeRange(tokenTrim)) return makeRef(0);
|
|
12219
12259
|
const parentIsUnion = isLexerNode && this._checkParentIsUnionOperator(param);
|
|
12220
12260
|
if (parentIsUnion && regexTestSingleRow(tokenTrim)) return makeRef(2);
|
|
@@ -12329,11 +12369,253 @@ SuffixNodeFactory = __decorate([
|
|
|
12329
12369
|
__decorateParam(2, IFormulaCurrentConfigService)
|
|
12330
12370
|
], SuffixNodeFactory);
|
|
12331
12371
|
|
|
12372
|
+
//#endregion
|
|
12373
|
+
//#region src/engine/reference-object/multi-area-reference-object.ts
|
|
12374
|
+
var MultiAreaReferenceObject = class extends BaseReferenceObject {
|
|
12375
|
+
constructor(token, areas = [], _arrayMode = "first-cell-grid") {
|
|
12376
|
+
super(token);
|
|
12377
|
+
this._arrayMode = _arrayMode;
|
|
12378
|
+
_defineProperty(this, "_areas", []);
|
|
12379
|
+
this._areas = areas;
|
|
12380
|
+
}
|
|
12381
|
+
dispose() {
|
|
12382
|
+
this._areas.forEach((row) => {
|
|
12383
|
+
row.forEach((a) => a.dispose());
|
|
12384
|
+
});
|
|
12385
|
+
this._areas = [];
|
|
12386
|
+
super.dispose();
|
|
12387
|
+
}
|
|
12388
|
+
getAreas() {
|
|
12389
|
+
return this._areas;
|
|
12390
|
+
}
|
|
12391
|
+
setAreas(areas) {
|
|
12392
|
+
this._areas = areas;
|
|
12393
|
+
}
|
|
12394
|
+
/**
|
|
12395
|
+
* Append an area:
|
|
12396
|
+
* - If a single AreaValue is passed, it will be wrapped as one row.
|
|
12397
|
+
* - If an AreaValue[] is passed, it will be inserted as an entire row.
|
|
12398
|
+
*/
|
|
12399
|
+
addArea(area) {
|
|
12400
|
+
if (Array.isArray(area)) this._areas.push(area);
|
|
12401
|
+
else this._areas.push([area]);
|
|
12402
|
+
}
|
|
12403
|
+
/** Flatten the 2D areas to reuse 1D logic */
|
|
12404
|
+
_flatAreas() {
|
|
12405
|
+
return this._areas.flat();
|
|
12406
|
+
}
|
|
12407
|
+
isMultiArea() {
|
|
12408
|
+
return true;
|
|
12409
|
+
}
|
|
12410
|
+
isRange() {
|
|
12411
|
+
return false;
|
|
12412
|
+
}
|
|
12413
|
+
isCell() {
|
|
12414
|
+
return false;
|
|
12415
|
+
}
|
|
12416
|
+
isRow() {
|
|
12417
|
+
return false;
|
|
12418
|
+
}
|
|
12419
|
+
isColumn() {
|
|
12420
|
+
return false;
|
|
12421
|
+
}
|
|
12422
|
+
getRowCount() {
|
|
12423
|
+
if (this._arrayMode === "first-cell-grid") return this._areas.length;
|
|
12424
|
+
let total = 0;
|
|
12425
|
+
for (const a of this._flatAreas()) if (a instanceof BaseReferenceObject) total += a.getRowCount();
|
|
12426
|
+
return total;
|
|
12427
|
+
}
|
|
12428
|
+
getColumnCount() {
|
|
12429
|
+
if (this._arrayMode === "first-cell-grid") return this._areas.reduce((max, row) => Math.max(max, row.length), 0);
|
|
12430
|
+
return this._flatAreas().reduce((max, area) => area instanceof BaseReferenceObject ? Math.max(max, area.getColumnCount()) : max, 0);
|
|
12431
|
+
}
|
|
12432
|
+
isExceedRange() {
|
|
12433
|
+
return this._flatAreas().some((a) => {
|
|
12434
|
+
return a instanceof BaseReferenceObject && a.isExceedRange();
|
|
12435
|
+
});
|
|
12436
|
+
}
|
|
12437
|
+
setRefOffset(x = 0, y = 0) {
|
|
12438
|
+
super.setRefOffset(x, y);
|
|
12439
|
+
this._flatAreas().forEach((a) => {
|
|
12440
|
+
if (a instanceof BaseReferenceObject) a.setRefOffset(x, y);
|
|
12441
|
+
});
|
|
12442
|
+
}
|
|
12443
|
+
_getReferenceArea() {
|
|
12444
|
+
return this._flatAreas().find((area) => area instanceof BaseReferenceObject);
|
|
12445
|
+
}
|
|
12446
|
+
/**
|
|
12447
|
+
* Multi-area reference may span multiple sheets, but Excel requires
|
|
12448
|
+
* them to be in the same sheet for most functions. We follow Excel semantics
|
|
12449
|
+
* by returning the first area’s identifiers.
|
|
12450
|
+
*/
|
|
12451
|
+
getUnitId() {
|
|
12452
|
+
var _this$_getReferenceAr;
|
|
12453
|
+
return ((_this$_getReferenceAr = this._getReferenceArea()) === null || _this$_getReferenceAr === void 0 ? void 0 : _this$_getReferenceAr.getUnitId()) ?? super.getUnitId();
|
|
12454
|
+
}
|
|
12455
|
+
getSheetId() {
|
|
12456
|
+
var _this$_getReferenceAr2;
|
|
12457
|
+
return ((_this$_getReferenceAr2 = this._getReferenceArea()) === null || _this$_getReferenceAr2 === void 0 ? void 0 : _this$_getReferenceAr2.getSheetId()) ?? super.getSheetId();
|
|
12458
|
+
}
|
|
12459
|
+
getActiveSheetRowCount() {
|
|
12460
|
+
var _this$_getReferenceAr3;
|
|
12461
|
+
return ((_this$_getReferenceAr3 = this._getReferenceArea()) === null || _this$_getReferenceAr3 === void 0 ? void 0 : _this$_getReferenceAr3.getActiveSheetRowCount()) ?? 0;
|
|
12462
|
+
}
|
|
12463
|
+
getActiveSheetColumnCount() {
|
|
12464
|
+
var _this$_getReferenceAr4;
|
|
12465
|
+
return ((_this$_getReferenceAr4 = this._getReferenceArea()) === null || _this$_getReferenceAr4 === void 0 ? void 0 : _this$_getReferenceAr4.getActiveSheetColumnCount()) ?? 0;
|
|
12466
|
+
}
|
|
12467
|
+
/**
|
|
12468
|
+
* Iterate through all areas in order, flattening the multi-area into
|
|
12469
|
+
* a sequence of cells.
|
|
12470
|
+
*
|
|
12471
|
+
* Note: The order here is "row-major":
|
|
12472
|
+
* iterate by the row order of _areas, then within each row by the area order.
|
|
12473
|
+
*/
|
|
12474
|
+
iterator(callback) {
|
|
12475
|
+
for (const row of this._areas) {
|
|
12476
|
+
let stopRow = false;
|
|
12477
|
+
for (const area of row) {
|
|
12478
|
+
if (!(area instanceof BaseReferenceObject)) continue;
|
|
12479
|
+
let stopArea = false;
|
|
12480
|
+
area.iterator((v, r, c) => {
|
|
12481
|
+
const res = callback(v, r, c);
|
|
12482
|
+
if (res === false) {
|
|
12483
|
+
stopArea = true;
|
|
12484
|
+
stopRow = true;
|
|
12485
|
+
return false;
|
|
12486
|
+
}
|
|
12487
|
+
return res;
|
|
12488
|
+
});
|
|
12489
|
+
if (stopArea) break;
|
|
12490
|
+
}
|
|
12491
|
+
if (stopRow) return;
|
|
12492
|
+
}
|
|
12493
|
+
}
|
|
12494
|
+
/**
|
|
12495
|
+
* Excel defines the "first cell" of a multi-area reference
|
|
12496
|
+
* as the first cell of the first area.
|
|
12497
|
+
*/
|
|
12498
|
+
getFirstCell() {
|
|
12499
|
+
const first = this._getReferenceArea();
|
|
12500
|
+
if (!first) return super.getFirstCell();
|
|
12501
|
+
return first.getFirstCell();
|
|
12502
|
+
}
|
|
12503
|
+
/**
|
|
12504
|
+
* For multi-area, we only take the *first cell* of each area and
|
|
12505
|
+
* arrange them into a 2D ArrayValueObject:
|
|
12506
|
+
*
|
|
12507
|
+
* - outer `_areas` dimension => rows
|
|
12508
|
+
* - inner `_areas[row]` dimension => columns
|
|
12509
|
+
*/
|
|
12510
|
+
toArrayValueObject() {
|
|
12511
|
+
if (this._arrayMode === "stack-areas") return this._stackAreas();
|
|
12512
|
+
const rows = this._areas.length;
|
|
12513
|
+
if (rows === 0) return createNewArray([], 0, 0);
|
|
12514
|
+
const cols = this.getColumnCount();
|
|
12515
|
+
const result = [];
|
|
12516
|
+
for (let r = 0; r < rows; r++) {
|
|
12517
|
+
const rowAreas = this._areas[r] ?? [];
|
|
12518
|
+
result[r] = [];
|
|
12519
|
+
for (let c = 0; c < cols; c++) {
|
|
12520
|
+
const area = rowAreas[c];
|
|
12521
|
+
if (!area) {
|
|
12522
|
+
result[r][c] = NullValueObject.create();
|
|
12523
|
+
continue;
|
|
12524
|
+
}
|
|
12525
|
+
if (area instanceof ErrorValueObject) {
|
|
12526
|
+
result[r][c] = area;
|
|
12527
|
+
continue;
|
|
12528
|
+
}
|
|
12529
|
+
result[r][c] = area.toArrayValueObject(false).getRealValue(0, 0) ?? NullValueObject.create();
|
|
12530
|
+
}
|
|
12531
|
+
}
|
|
12532
|
+
return createNewArray(result, rows, cols);
|
|
12533
|
+
}
|
|
12534
|
+
_stackAreas() {
|
|
12535
|
+
const result = [];
|
|
12536
|
+
const cols = this.getColumnCount();
|
|
12537
|
+
for (const area of this._flatAreas()) {
|
|
12538
|
+
if (area instanceof ErrorValueObject) {
|
|
12539
|
+
const row = new Array(cols).fill(NullValueObject.create());
|
|
12540
|
+
row[0] = area;
|
|
12541
|
+
result.push(row);
|
|
12542
|
+
continue;
|
|
12543
|
+
}
|
|
12544
|
+
const array = area.toArrayValueObject(false);
|
|
12545
|
+
for (let r = 0; r < array.getRowCount(); r++) {
|
|
12546
|
+
const row = [];
|
|
12547
|
+
for (let c = 0; c < cols; c++) row[c] = array.getRealValue(r, c) ?? NullValueObject.create();
|
|
12548
|
+
result.push(row);
|
|
12549
|
+
}
|
|
12550
|
+
}
|
|
12551
|
+
return createNewArray(result, result.length, cols);
|
|
12552
|
+
}
|
|
12553
|
+
getRangePosition() {
|
|
12554
|
+
const flat = this._flatAreas();
|
|
12555
|
+
if (!flat.length) return super.getRangePosition();
|
|
12556
|
+
let minStartRow = Number.POSITIVE_INFINITY;
|
|
12557
|
+
let minStartColumn = Number.POSITIVE_INFINITY;
|
|
12558
|
+
let maxEndRow = Number.NEGATIVE_INFINITY;
|
|
12559
|
+
let maxEndColumn = Number.NEGATIVE_INFINITY;
|
|
12560
|
+
for (const area of flat) {
|
|
12561
|
+
if (!(area instanceof BaseReferenceObject)) continue;
|
|
12562
|
+
const { startRow, startColumn, endRow, endColumn } = area.getRangePosition();
|
|
12563
|
+
if (!Number.isFinite(startRow) || !Number.isFinite(startColumn) || !Number.isFinite(endRow) || !Number.isFinite(endColumn)) continue;
|
|
12564
|
+
if (startRow < minStartRow) minStartRow = startRow;
|
|
12565
|
+
if (startColumn < minStartColumn) minStartColumn = startColumn;
|
|
12566
|
+
if (endRow > maxEndRow) maxEndRow = endRow;
|
|
12567
|
+
if (endColumn > maxEndColumn) maxEndColumn = maxEndColumn < endColumn ? endColumn : maxEndColumn;
|
|
12568
|
+
}
|
|
12569
|
+
if (!Number.isFinite(minStartRow) || !Number.isFinite(minStartColumn) || !Number.isFinite(maxEndRow) || !Number.isFinite(maxEndColumn)) return super.getRangePosition();
|
|
12570
|
+
return {
|
|
12571
|
+
startRow: minStartRow,
|
|
12572
|
+
startColumn: minStartColumn,
|
|
12573
|
+
endRow: maxEndRow,
|
|
12574
|
+
endColumn: maxEndColumn
|
|
12575
|
+
};
|
|
12576
|
+
}
|
|
12577
|
+
toUnitRange() {
|
|
12578
|
+
return {
|
|
12579
|
+
range: this.getRangePosition(),
|
|
12580
|
+
sheetId: this.getSheetId(),
|
|
12581
|
+
unitId: this.getUnitId()
|
|
12582
|
+
};
|
|
12583
|
+
}
|
|
12584
|
+
toUnitRanges() {
|
|
12585
|
+
return this._flatAreas().filter((area) => area instanceof BaseReferenceObject).flatMap((area) => area.toUnitRanges());
|
|
12586
|
+
}
|
|
12587
|
+
getRangeData() {
|
|
12588
|
+
const flat = this._flatAreas();
|
|
12589
|
+
if (!flat.length) return super.getRangeData();
|
|
12590
|
+
let minStartRow = Number.POSITIVE_INFINITY;
|
|
12591
|
+
let minStartColumn = Number.POSITIVE_INFINITY;
|
|
12592
|
+
let maxEndRow = Number.NEGATIVE_INFINITY;
|
|
12593
|
+
let maxEndColumn = Number.NEGATIVE_INFINITY;
|
|
12594
|
+
for (const area of flat) {
|
|
12595
|
+
if (!(area instanceof BaseReferenceObject)) continue;
|
|
12596
|
+
const { startRow, startColumn, endRow, endColumn } = area.getRangeData();
|
|
12597
|
+
if (!Number.isFinite(startRow) || !Number.isFinite(startColumn) || !Number.isFinite(endRow) || !Number.isFinite(endColumn)) continue;
|
|
12598
|
+
if (startRow < minStartRow) minStartRow = startRow;
|
|
12599
|
+
if (startColumn < minStartColumn) minStartColumn = startColumn;
|
|
12600
|
+
if (endRow > maxEndRow) maxEndRow = endRow;
|
|
12601
|
+
if (endColumn > maxEndColumn) maxEndColumn = endColumn;
|
|
12602
|
+
}
|
|
12603
|
+
if (!Number.isFinite(minStartRow) || !Number.isFinite(minStartColumn) || !Number.isFinite(maxEndRow) || !Number.isFinite(maxEndColumn)) return super.getRangeData();
|
|
12604
|
+
return {
|
|
12605
|
+
startRow: minStartRow,
|
|
12606
|
+
startColumn: minStartColumn,
|
|
12607
|
+
endRow: maxEndRow,
|
|
12608
|
+
endColumn: maxEndColumn
|
|
12609
|
+
};
|
|
12610
|
+
}
|
|
12611
|
+
};
|
|
12612
|
+
|
|
12332
12613
|
//#endregion
|
|
12333
12614
|
//#region src/engine/ast-node/union-node.ts
|
|
12334
12615
|
var UnionNode = class extends BaseAstNode {
|
|
12335
|
-
constructor(operatorString) {
|
|
12616
|
+
constructor(operatorString, _currentConfigService) {
|
|
12336
12617
|
super(operatorString);
|
|
12618
|
+
this._currentConfigService = _currentConfigService;
|
|
12337
12619
|
}
|
|
12338
12620
|
get nodeType() {
|
|
12339
12621
|
return 10;
|
|
@@ -12350,28 +12632,74 @@ var UnionNode = class extends BaseAstNode {
|
|
|
12350
12632
|
return;
|
|
12351
12633
|
}
|
|
12352
12634
|
let result;
|
|
12353
|
-
if (this.getToken() === ":") result = this._unionFunction(leftNode, rightNode);
|
|
12635
|
+
if (this.getToken() === ":") result = this._createThreeDimensionalReference(leftChild.getToken(), rightNode) ?? this._unionFunction(leftNode, rightNode);
|
|
12354
12636
|
else result = ErrorValueObject.create("#NAME?");
|
|
12355
12637
|
this.setValue(result);
|
|
12356
12638
|
}
|
|
12639
|
+
_createThreeDimensionalReference(firstSheetToken, rightNode) {
|
|
12640
|
+
if (!(rightNode instanceof BaseReferenceObject)) return;
|
|
12641
|
+
const source = rightNode;
|
|
12642
|
+
const firstSheetName = this._normalizeSheetName(firstSheetToken);
|
|
12643
|
+
const lastSheetName = this._normalizeSheetName(source.getForcedSheetName());
|
|
12644
|
+
if (!firstSheetName || !lastSheetName) return;
|
|
12645
|
+
const { sheetOrder, sheetNameMap } = this._currentConfigService.getSheetsInfo();
|
|
12646
|
+
const sheetIdsByName = new Map(Object.entries(sheetNameMap).map(([sheetId, sheetName]) => [sheetName.toLocaleLowerCase(), sheetId]));
|
|
12647
|
+
const firstSheetId = sheetIdsByName.get(firstSheetName.toLocaleLowerCase());
|
|
12648
|
+
const lastSheetId = sheetIdsByName.get(lastSheetName.toLocaleLowerCase());
|
|
12649
|
+
const firstIndex = firstSheetId == null ? -1 : sheetOrder.indexOf(firstSheetId);
|
|
12650
|
+
const lastIndex = lastSheetId == null ? -1 : sheetOrder.indexOf(lastSheetId);
|
|
12651
|
+
if (firstIndex < 0 || lastIndex < 0) return;
|
|
12652
|
+
const startIndex = Math.min(firstIndex, lastIndex);
|
|
12653
|
+
const endIndex = Math.max(firstIndex, lastIndex);
|
|
12654
|
+
const areas = sheetOrder.slice(startIndex, endIndex + 1).map((sheetId) => {
|
|
12655
|
+
const reference = new RangeReferenceObject(source.getRangeData(), sheetId, source.getUnitId());
|
|
12656
|
+
this._copyReferenceContext(source, reference);
|
|
12657
|
+
reference.setForcedSheetIdDirect(sheetId);
|
|
12658
|
+
reference.setForcedSheetName(sheetNameMap[sheetId] ?? "");
|
|
12659
|
+
return [reference];
|
|
12660
|
+
});
|
|
12661
|
+
return new MultiAreaReferenceObject(`${firstSheetToken}:${source.getToken()}`, areas, "stack-areas");
|
|
12662
|
+
}
|
|
12663
|
+
_normalizeSheetName(token) {
|
|
12664
|
+
const trimmed = token.trim();
|
|
12665
|
+
if (trimmed.startsWith("'") && trimmed.endsWith("'")) return trimmed.slice(1, -1).replace(/''/g, "'");
|
|
12666
|
+
return trimmed;
|
|
12667
|
+
}
|
|
12668
|
+
_copyReferenceContext(source, target) {
|
|
12669
|
+
target.setDefaultUnitId(source.getDefaultUnitId());
|
|
12670
|
+
target.setDefaultSheetId(source.getDefaultSheetId());
|
|
12671
|
+
target.setUnitData(source.getUnitData());
|
|
12672
|
+
target.setUnitStylesData(source.getUnitStylesData());
|
|
12673
|
+
target.setFilteredOutRows(source.getFilteredOutRows());
|
|
12674
|
+
target.setRuntimeData(source.getRuntimeData());
|
|
12675
|
+
target.setArrayFormulaCellData(source.getArrayFormulaCellData());
|
|
12676
|
+
target.setArrayFormulaRange(source.getArrayFormulaRange());
|
|
12677
|
+
target.setRuntimeArrayFormulaCellData(source.getRuntimeArrayFormulaCellData());
|
|
12678
|
+
target.setRuntimeArrayFormulaRange(source.getRuntimeArrayFormulaRange());
|
|
12679
|
+
target.setRuntimeFeatureCellData(source.getRuntimeFeatureCellData());
|
|
12680
|
+
const currentRow = source.getCurrentRow();
|
|
12681
|
+
const currentColumn = source.getCurrentColumn();
|
|
12682
|
+
if (currentRow != null && currentColumn != null) target.setCurrentRowAndColumn(currentRow, currentColumn);
|
|
12683
|
+
const { x, y } = source.getRefOffset();
|
|
12684
|
+
target.setRefOffset(x, y);
|
|
12685
|
+
}
|
|
12357
12686
|
_unionFunction(variant1, variant2) {
|
|
12358
12687
|
if (variant1.isError() || variant2.isError()) return ErrorValueObject.create("#REF!");
|
|
12359
|
-
if (!variant1
|
|
12360
|
-
variant1 = variant1;
|
|
12361
|
-
variant2 = variant2;
|
|
12688
|
+
if (!(variant1 instanceof BaseReferenceObject) || !(variant2 instanceof BaseReferenceObject)) return ErrorValueObject.create("#REF!");
|
|
12362
12689
|
return getRangeReferenceObjectFromCache(variant1, variant2);
|
|
12363
12690
|
}
|
|
12364
12691
|
};
|
|
12365
12692
|
let UnionNodeFactory = class UnionNodeFactory extends BaseAstNodeFactory {
|
|
12366
|
-
constructor(_functionService) {
|
|
12693
|
+
constructor(_functionService, _currentConfigService) {
|
|
12367
12694
|
super();
|
|
12368
12695
|
this._functionService = _functionService;
|
|
12696
|
+
this._currentConfigService = _currentConfigService;
|
|
12369
12697
|
}
|
|
12370
12698
|
get zIndex() {
|
|
12371
12699
|
return NODE_ORDER_MAP.get(10) || 100;
|
|
12372
12700
|
}
|
|
12373
12701
|
create(param) {
|
|
12374
|
-
return new UnionNode(param);
|
|
12702
|
+
return new UnionNode(param, this._currentConfigService);
|
|
12375
12703
|
}
|
|
12376
12704
|
checkAndCreateNodeType(param) {
|
|
12377
12705
|
if (!(param instanceof LexerNode)) return;
|
|
@@ -12381,7 +12709,7 @@ let UnionNodeFactory = class UnionNodeFactory extends BaseAstNodeFactory {
|
|
|
12381
12709
|
return this.create(tokenTrim);
|
|
12382
12710
|
}
|
|
12383
12711
|
};
|
|
12384
|
-
UnionNodeFactory = __decorate([__decorateParam(0, IFunctionService)], UnionNodeFactory);
|
|
12712
|
+
UnionNodeFactory = __decorate([__decorateParam(0, IFunctionService), __decorateParam(1, IFormulaCurrentConfigService)], UnionNodeFactory);
|
|
12385
12713
|
|
|
12386
12714
|
//#endregion
|
|
12387
12715
|
//#region src/engine/ast-node/value-node.ts
|
|
@@ -12402,8 +12730,8 @@ var ValueNode = class extends BaseAstNode {
|
|
|
12402
12730
|
const parent = this.getParent();
|
|
12403
12731
|
let isIgnoreNumberPattern = true;
|
|
12404
12732
|
if ((parent === null || parent === void 0 ? void 0 : parent.nodeType) === 4) {
|
|
12405
|
-
var _isFunctionExecutorAr
|
|
12406
|
-
isIgnoreNumberPattern = (_isFunctionExecutorAr =
|
|
12733
|
+
var _isFunctionExecutorAr;
|
|
12734
|
+
isIgnoreNumberPattern = ((_isFunctionExecutorAr = parent.isFunctionExecutorArgumentsIgnoreNumberPattern) === null || _isFunctionExecutorAr === void 0 ? void 0 : _isFunctionExecutorAr.call(parent)) ?? true;
|
|
12407
12735
|
}
|
|
12408
12736
|
this.setValue(ValueObjectFactory.create(token, isIgnoreNumberPattern));
|
|
12409
12737
|
}
|
|
@@ -12628,7 +12956,7 @@ let AstTreeBuilder = class AstTreeBuilder extends Disposable {
|
|
|
12628
12956
|
if (astNode == null) {
|
|
12629
12957
|
const aggregatorNode = this._createGroupByAggregatorTokenNode(item);
|
|
12630
12958
|
if (aggregatorNode != null) return aggregatorNode;
|
|
12631
|
-
return new ErrorFunctionNode();
|
|
12959
|
+
return new ErrorFunctionNode(typeof item === "string" ? item : item.getToken());
|
|
12632
12960
|
}
|
|
12633
12961
|
return astNode;
|
|
12634
12962
|
}
|
|
@@ -13287,8 +13615,8 @@ var FormulaDependencyTreeVirtual = class extends FormulaDependencyTreeCalculator
|
|
|
13287
13615
|
return this.refTree.subUnitId;
|
|
13288
13616
|
}
|
|
13289
13617
|
get formula() {
|
|
13290
|
-
var _this$refTree
|
|
13291
|
-
return (
|
|
13618
|
+
var _this$refTree;
|
|
13619
|
+
return ((_this$refTree = this.refTree) === null || _this$refTree === void 0 ? void 0 : _this$refTree.formula) ?? "";
|
|
13292
13620
|
}
|
|
13293
13621
|
get nodeData() {
|
|
13294
13622
|
return {
|
|
@@ -13522,13 +13850,12 @@ var FormulaDependencyTreeModel = class {
|
|
|
13522
13850
|
this.refOffsetY = tree.refOffsetY;
|
|
13523
13851
|
this.rangeList = tree.rangeList;
|
|
13524
13852
|
if (tree.isVirtual) {
|
|
13525
|
-
var _refTree
|
|
13526
|
-
this.refTreeId = (
|
|
13853
|
+
var _refTree;
|
|
13854
|
+
this.refTreeId = ((_refTree = tree.refTree) === null || _refTree === void 0 ? void 0 : _refTree.treeId) ?? -1;
|
|
13527
13855
|
} else {
|
|
13528
|
-
var _formulaId, _featureId;
|
|
13529
13856
|
this.formula = tree.formula;
|
|
13530
|
-
this.formulaId =
|
|
13531
|
-
this.featureId =
|
|
13857
|
+
this.formulaId = tree.formulaId ?? void 0;
|
|
13858
|
+
this.featureId = tree.featureId ?? void 0;
|
|
13532
13859
|
this.type = tree.type;
|
|
13533
13860
|
}
|
|
13534
13861
|
}
|
|
@@ -13716,14 +14043,13 @@ let FormulaDependencyGenerator = class FormulaDependencyGenerator extends Dispos
|
|
|
13716
14043
|
const columnCount = sheetSize.columnCount > 0 ? sheetSize.columnCount : 1;
|
|
13717
14044
|
const subFormulaDataKeys = Object.keys(subFormulaData);
|
|
13718
14045
|
for (const subFormulaDataId of subFormulaDataKeys) {
|
|
13719
|
-
var _treeMatrix$getValue;
|
|
13720
14046
|
const hasOtherFormula = this._dependencyManagerService.hasOtherFormulaDataMainData(subFormulaDataId);
|
|
13721
14047
|
const { f: formulaString, ranges } = subFormulaData[subFormulaDataId];
|
|
13722
14048
|
let isCache = false;
|
|
13723
14049
|
if (hasOtherFormula) isCache = true;
|
|
13724
14050
|
const { firstRow, firstColumn } = this._getFirstCellOfRange(ranges);
|
|
13725
14051
|
const treeMatrix = this._dependencyManagerService.getOtherFormulaDependency(unitId, subUnitId, subFormulaDataId);
|
|
13726
|
-
const firstFDtree = new FormulaDependencyTree((
|
|
14052
|
+
const firstFDtree = new FormulaDependencyTree((treeMatrix === null || treeMatrix === void 0 ? void 0 : treeMatrix.getValue(0, 0)) ?? generateRandomDependencyTreeId(this._dependencyManagerService));
|
|
13727
14053
|
for (let i = 0; i < ranges.length; i++) {
|
|
13728
14054
|
const range = ranges[i];
|
|
13729
14055
|
const { startRow, startColumn } = range;
|
|
@@ -13857,7 +14183,7 @@ let FormulaDependencyGenerator = class FormulaDependencyGenerator extends Dispos
|
|
|
13857
14183
|
return this._dependencyTreeCache.get(treeId);
|
|
13858
14184
|
}
|
|
13859
14185
|
_getTreeNode(tree) {
|
|
13860
|
-
return generateAstNode(tree.unitId, tree.formula, this._lexer, this._astTreeBuilder, this._currentConfigService, tree.subUnitId);
|
|
14186
|
+
return generateAstNode(tree.unitId, tree.formula, this._lexer, this._astTreeBuilder, this._currentConfigService, tree.subUnitId, tree.column, tree.row);
|
|
13861
14187
|
}
|
|
13862
14188
|
*_traverse(treeList, skippedTreeIds) {
|
|
13863
14189
|
const stack = treeList;
|
|
@@ -14093,15 +14419,13 @@ let FormulaDependencyGenerator = class FormulaDependencyGenerator extends Dispos
|
|
|
14093
14419
|
}
|
|
14094
14420
|
}
|
|
14095
14421
|
async _executeNode(node, refOffsetX = 0, refOffsetY = 0) {
|
|
14096
|
-
let value;
|
|
14097
14422
|
const nodeData = {
|
|
14098
14423
|
node,
|
|
14099
14424
|
refOffsetX,
|
|
14100
14425
|
refOffsetY
|
|
14101
14426
|
};
|
|
14102
|
-
|
|
14103
|
-
|
|
14104
|
-
return value;
|
|
14427
|
+
const value = this._interpreter.checkAsyncNode(node) ? await this._interpreter.executeAsync(nodeData) : this._interpreter.execute(nodeData);
|
|
14428
|
+
return value instanceof BaseReferenceObject ? value : null;
|
|
14105
14429
|
}
|
|
14106
14430
|
/**
|
|
14107
14431
|
* Calculate the range required for collection in advance,
|
|
@@ -14118,8 +14442,8 @@ let FormulaDependencyGenerator = class FormulaDependencyGenerator extends Dispos
|
|
|
14118
14442
|
const rangeList = [];
|
|
14119
14443
|
for (let i = 0, len = preCalculateNodeList.length; i < len; i++) {
|
|
14120
14444
|
const node = preCalculateNodeList[i];
|
|
14121
|
-
const
|
|
14122
|
-
rangeList.push(
|
|
14445
|
+
const value = await this._executeNode(node, refOffsetX, refOffsetY);
|
|
14446
|
+
if (value != null) rangeList.push(...value.toUnitRanges());
|
|
14123
14447
|
node.setValue(null);
|
|
14124
14448
|
}
|
|
14125
14449
|
return rangeList;
|
|
@@ -14254,8 +14578,8 @@ let FormulaDependencyGenerator = class FormulaDependencyGenerator extends Dispos
|
|
|
14254
14578
|
const rangeList = [];
|
|
14255
14579
|
for (let i = 0, len = referenceFunctionList.length; i < len; i++) {
|
|
14256
14580
|
const node = referenceFunctionList[i];
|
|
14257
|
-
const
|
|
14258
|
-
rangeList.push(
|
|
14581
|
+
const value = await this._executeNode(node, refOffsetX, refOffsetY);
|
|
14582
|
+
if (value != null) rangeList.push(...value.toUnitRanges());
|
|
14259
14583
|
node.setValue(null);
|
|
14260
14584
|
}
|
|
14261
14585
|
return rangeList;
|
|
@@ -14628,7 +14952,7 @@ let CalculateFormulaService = class CalculateFormulaService extends Disposable {
|
|
|
14628
14952
|
while (treeList.length > 0) {
|
|
14629
14953
|
const tree = treeList.pop();
|
|
14630
14954
|
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);
|
|
14955
|
+
const node = generateAstNode(tree.unitId, tree.formula, this._lexer, this._astTreeBuilder, this._currentConfigService, tree.subUnitId, tree.column, tree.row);
|
|
14632
14956
|
const nodeData = {
|
|
14633
14957
|
node,
|
|
14634
14958
|
refOffsetX: tree.refOffsetX,
|
|
@@ -14910,7 +15234,7 @@ let CalculateController = class CalculateController extends Disposable {
|
|
|
14910
15234
|
if (dependencyTreeModelData.length > 0) this._commandService.executeCommand(SetFormulaDependencyCalculationResultMutation.id, { result: dependencyTreeModelData }, { onlyLocal: true });
|
|
14911
15235
|
}
|
|
14912
15236
|
async _applyResult(data) {
|
|
14913
|
-
const { unitData, unitOtherData, arrayFormulaRange, arrayFormulaCellData, clearArrayFormulaCellData, arrayFormulaEmbedded, imageFormulaData
|
|
15237
|
+
const { unitData, unitOtherData, arrayFormulaRange, arrayFormulaCellData, clearArrayFormulaCellData, arrayFormulaEmbedded, imageFormulaData } = data;
|
|
14914
15238
|
if (!unitData) {
|
|
14915
15239
|
this._applyTreeResult(data);
|
|
14916
15240
|
console.error("No sheetData from Formula Engine!");
|
|
@@ -15046,8 +15370,7 @@ var FormulaCalculationSessionService = class extends Disposable {
|
|
|
15046
15370
|
}
|
|
15047
15371
|
markResultApplied(type = "sheet", result) {
|
|
15048
15372
|
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();
|
|
15373
|
+
const types = this._preAppliedResultTypes.get(result) ?? /* @__PURE__ */ new Set();
|
|
15051
15374
|
types.add(type);
|
|
15052
15375
|
this._preAppliedResultTypes.set(result, types);
|
|
15053
15376
|
return;
|
|
@@ -15609,8 +15932,7 @@ function refactorReferenceSegment(segment, oldName, newName) {
|
|
|
15609
15932
|
const escapedName = newName.replace(/'/g, "''");
|
|
15610
15933
|
return quote ? `'[${escapedName}]${sheetName}'!` : `[${newName}]${sheetName}!`;
|
|
15611
15934
|
}).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;
|
|
15935
|
+
if (!equalsQualifier(quoted ?? bracketed ?? plain ?? "", oldName)) return token;
|
|
15614
15936
|
if (quoted != null) return `${boundary}'${newName.replace(/'/g, "''")}'!`;
|
|
15615
15937
|
if (bracketed != null) return `${boundary}[${newName}]!`;
|
|
15616
15938
|
return `${boundary}${quoteQualifier(newName)}!`;
|
|
@@ -15668,11 +15990,10 @@ function shouldAppendOpenBracket(functionType) {
|
|
|
15668
15990
|
return functionType !== 16 && functionType !== 17;
|
|
15669
15991
|
}
|
|
15670
15992
|
function getFormulaReplaceResult(nodes, index, formulaName, functionType) {
|
|
15671
|
-
var _cloneNodes$pop;
|
|
15672
15993
|
if (index === -1) return;
|
|
15673
15994
|
const cloneNodes = [...nodes];
|
|
15674
15995
|
const lastNodes = cloneNodes.splice(index + 1);
|
|
15675
|
-
const oldNode =
|
|
15996
|
+
const oldNode = cloneNodes.pop() ?? "";
|
|
15676
15997
|
let offset = (typeof oldNode === "string" ? oldNode.length : oldNode.token.length) - formulaName.length;
|
|
15677
15998
|
cloneNodes.push(formulaName);
|
|
15678
15999
|
if (lastNodes[0] !== "(" && shouldAppendOpenBracket(functionType)) {
|
|
@@ -15734,12 +16055,11 @@ function isFormulaReferenceAddingTextContext(formulaText, offset) {
|
|
|
15734
16055
|
return Boolean(character && matchRefDrawToken(character) && (!nextCharacter || isFormulaLexerToken(nextCharacter) && nextCharacter !== "("));
|
|
15735
16056
|
}
|
|
15736
16057
|
function resolveFormulaReferenceEditingContext(options) {
|
|
15737
|
-
var _options$selectionSta, _options$selectionEnd;
|
|
15738
16058
|
const { formulaText, sequenceNodes } = options;
|
|
15739
16059
|
const offset = Math.max(0, Math.min(options.offset, formulaText.length));
|
|
15740
16060
|
let nodeIndex = getFormulaSequenceNodeIndex(sequenceNodes, offset);
|
|
15741
|
-
const selectionStart =
|
|
15742
|
-
const selectionEnd =
|
|
16061
|
+
const selectionStart = options.selectionStart ?? offset;
|
|
16062
|
+
const selectionEnd = options.selectionEnd ?? selectionStart;
|
|
15743
16063
|
if (selectionEnd > selectionStart) nodeIndex = sequenceNodes.findIndex((node) => typeof node !== "string" && isFormulaReferenceNode(node) && node.startIndex < selectionEnd && node.endIndex + 1 > selectionStart);
|
|
15744
16064
|
const referenceIndex = getFormulaReferenceIndex(sequenceNodes, nodeIndex);
|
|
15745
16065
|
if (referenceIndex !== -1) return {
|
|
@@ -15756,7 +16076,7 @@ function resolveFormulaReferenceEditingContext(options) {
|
|
|
15756
16076
|
};
|
|
15757
16077
|
}
|
|
15758
16078
|
function getFormulaHighlightDataStream(leadingCharacter, sequenceNodes, sourceText) {
|
|
15759
|
-
return `${leadingCharacter}${sourceText
|
|
16079
|
+
return `${leadingCharacter}${sourceText ?? sequenceNodes.map((node) => typeof node === "string" ? node : node.token).join("")}\r\n`;
|
|
15760
16080
|
}
|
|
15761
16081
|
function buildFormulaTextRuns(descriptionService, colors, sequenceNodes, options) {
|
|
15762
16082
|
const textRuns = [];
|
|
@@ -15766,16 +16086,15 @@ function buildFormulaTextRuns(descriptionService, colors, sequenceNodes, options
|
|
|
15766
16086
|
for (let index = 0; index < sequenceNodes.length; index++) {
|
|
15767
16087
|
const node = sequenceNodes[index];
|
|
15768
16088
|
if (typeof node === "string") {
|
|
15769
|
-
var _textRuns
|
|
15770
|
-
const start = (
|
|
16089
|
+
var _textRuns;
|
|
16090
|
+
const start = ((_textRuns = textRuns[textRuns.length - 1]) === null || _textRuns === void 0 ? void 0 : _textRuns.ed) ?? 0;
|
|
15771
16091
|
textRuns.push(createTextRun(start, start + node.length, colors.plainTextColor));
|
|
15772
16092
|
continue;
|
|
15773
16093
|
}
|
|
15774
16094
|
let color = colors.plainTextColor;
|
|
15775
16095
|
if (!descriptionService.hasDefinedNameDescription(node.token.trim())) {
|
|
15776
16096
|
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];
|
|
16097
|
+
color = referenceColors.get(node.token) ?? colors.formulaRefColors[refColorIndex % colors.formulaRefColors.length];
|
|
15779
16098
|
if (!referenceColors.has(node.token)) {
|
|
15780
16099
|
referenceColors.set(node.token, color);
|
|
15781
16100
|
refColorIndex += 1;
|
|
@@ -15827,13 +16146,13 @@ function applyTextRunColor(textRuns, start, end, color) {
|
|
|
15827
16146
|
continue;
|
|
15828
16147
|
}
|
|
15829
16148
|
if (run.st < start) {
|
|
15830
|
-
var _run$ts
|
|
15831
|
-
nextRuns.push(createTextRun(run.st, start, (
|
|
16149
|
+
var _run$ts;
|
|
16150
|
+
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
16151
|
}
|
|
15833
16152
|
nextRuns.push(createTextRun(Math.max(run.st, start), Math.min(run.ed, end), color));
|
|
15834
16153
|
if (run.ed > end) {
|
|
15835
|
-
var _run$
|
|
15836
|
-
nextRuns.push(createTextRun(end, run.ed, (
|
|
16154
|
+
var _run$ts2;
|
|
16155
|
+
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
16156
|
}
|
|
15838
16157
|
}
|
|
15839
16158
|
textRuns.splice(0, textRuns.length, ...nextRuns);
|
|
@@ -16029,6 +16348,14 @@ var BaseFunction = class {
|
|
|
16029
16348
|
"needsAstChildren",
|
|
16030
16349
|
false
|
|
16031
16350
|
);
|
|
16351
|
+
_defineProperty(
|
|
16352
|
+
this,
|
|
16353
|
+
/**
|
|
16354
|
+
* Arguments that preserve a selected lazy IF branch as a reference array.
|
|
16355
|
+
*/
|
|
16356
|
+
"lazyIfReferenceArrayArgumentIndexes",
|
|
16357
|
+
[]
|
|
16358
|
+
);
|
|
16032
16359
|
_defineProperty(
|
|
16033
16360
|
this,
|
|
16034
16361
|
/**
|
|
@@ -18212,7 +18539,7 @@ function getAggregateResult(options, refs) {
|
|
|
18212
18539
|
return result;
|
|
18213
18540
|
}
|
|
18214
18541
|
function getArrayValuesByAggregateIgnoreOptions(array, options, formulaDataModel) {
|
|
18215
|
-
const { ignoreRowHidden = false, ignoreErrorValues = false, ignoreNested = false } = options
|
|
18542
|
+
const { ignoreRowHidden = false, ignoreErrorValues = false, ignoreNested = false } = options ?? {};
|
|
18216
18543
|
const values = [];
|
|
18217
18544
|
if (array.isReferenceObject()) {
|
|
18218
18545
|
var _unitData$unitId2;
|
|
@@ -18338,8 +18665,8 @@ var BetaInv = class extends BaseFunction {
|
|
|
18338
18665
|
_defineProperty(this, "maxParams", 5);
|
|
18339
18666
|
}
|
|
18340
18667
|
calculate(probability, alpha, beta, A, B) {
|
|
18341
|
-
let _A = A
|
|
18342
|
-
let _B = B
|
|
18668
|
+
let _A = A ?? NumberValueObject.create(0);
|
|
18669
|
+
let _B = B ?? NumberValueObject.create(1);
|
|
18343
18670
|
if (_A.isNull()) _A = NumberValueObject.create(0);
|
|
18344
18671
|
if (_B.isNull()) _B = NumberValueObject.create(1);
|
|
18345
18672
|
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 +19469,7 @@ var PercentileInc = class extends BaseFunction {
|
|
|
19142
19469
|
super(..._args);
|
|
19143
19470
|
_defineProperty(this, "minParams", 2);
|
|
19144
19471
|
_defineProperty(this, "maxParams", 2);
|
|
19472
|
+
_defineProperty(this, "lazyIfReferenceArrayArgumentIndexes", [0]);
|
|
19145
19473
|
}
|
|
19146
19474
|
calculate(array, k) {
|
|
19147
19475
|
const arrayValues = getArrayValuesByAggregateIgnoreOptions(array);
|
|
@@ -19171,7 +19499,7 @@ var PercentrankInc = class extends BaseFunction {
|
|
|
19171
19499
|
}
|
|
19172
19500
|
calculate(array, x, significance) {
|
|
19173
19501
|
const arrayValues = this._getValues(array);
|
|
19174
|
-
let _significance = significance
|
|
19502
|
+
let _significance = significance ?? NumberValueObject.create(3);
|
|
19175
19503
|
if (_significance.isNull()) _significance = NumberValueObject.create(3);
|
|
19176
19504
|
const maxRowLength = Math.max(x.isArray() ? x.getRowCount() : 1, _significance.isArray() ? _significance.getRowCount() : 1);
|
|
19177
19505
|
const maxColumnLength = Math.max(x.isArray() ? x.getColumnCount() : 1, _significance.isArray() ? _significance.getColumnCount() : 1);
|
|
@@ -19733,8 +20061,8 @@ var Betadist = class extends BaseFunction {
|
|
|
19733
20061
|
_defineProperty(this, "maxParams", 5);
|
|
19734
20062
|
}
|
|
19735
20063
|
calculate(x, alpha, beta, A, B) {
|
|
19736
|
-
let _A = A
|
|
19737
|
-
let _B = B
|
|
20064
|
+
let _A = A ?? NumberValueObject.create(0);
|
|
20065
|
+
let _B = B ?? NumberValueObject.create(1);
|
|
19738
20066
|
if (_A.isNull()) _A = NumberValueObject.create(0);
|
|
19739
20067
|
if (_B.isNull()) _B = NumberValueObject.create(1);
|
|
19740
20068
|
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 +20318,13 @@ var Rank = class extends BaseFunction {
|
|
|
19990
20318
|
_defineProperty(this, "minParams", 2);
|
|
19991
20319
|
_defineProperty(this, "maxParams", 3);
|
|
19992
20320
|
_defineProperty(this, "needsReferenceObject", true);
|
|
20321
|
+
_defineProperty(this, "lazyIfReferenceArrayArgumentIndexes", [1]);
|
|
19993
20322
|
}
|
|
19994
20323
|
calculate(number, ref, order) {
|
|
19995
20324
|
let _number = number;
|
|
19996
20325
|
if (_number.isReferenceObject()) _number = _number.toArrayValueObject();
|
|
19997
20326
|
const { refHasError, refErrorObject, refNumbers } = this._checkRefReferenceObject(ref);
|
|
19998
|
-
let _order = order
|
|
20327
|
+
let _order = order ?? NumberValueObject.create(0);
|
|
19999
20328
|
if (_order.isReferenceObject()) _order = _order.toArrayValueObject();
|
|
20000
20329
|
const maxRowLength = Math.max(_number.isArray() ? _number.getRowCount() : 1, _order.isArray() ? _order.getRowCount() : 1);
|
|
20001
20330
|
const maxColumnLength = Math.max(_number.isArray() ? _number.getColumnCount() : 1, _order.isArray() ? _order.getColumnCount() : 1);
|
|
@@ -21032,7 +21361,7 @@ var Days360 = class extends BaseFunction {
|
|
|
21032
21361
|
_defineProperty(this, "maxParams", 3);
|
|
21033
21362
|
}
|
|
21034
21363
|
calculate(startDate, endDate, method) {
|
|
21035
|
-
const _method = method
|
|
21364
|
+
const _method = method ?? BooleanValueObject.create(false);
|
|
21036
21365
|
if (startDate.isError()) return startDate;
|
|
21037
21366
|
if (endDate.isError()) return endDate;
|
|
21038
21367
|
if (_method.isError()) return _method;
|
|
@@ -21146,7 +21475,7 @@ var Epochtodate = class extends BaseFunction {
|
|
|
21146
21475
|
_defineProperty(this, "needsReferenceObject", true);
|
|
21147
21476
|
}
|
|
21148
21477
|
calculate(timestamp, unit) {
|
|
21149
|
-
const _unit = unit
|
|
21478
|
+
const _unit = unit ?? NumberValueObject.create(1);
|
|
21150
21479
|
const { isError, errorObject, timestampIsReferenceObject, timestampObject, unitObject } = this._checkVariants(timestamp, _unit);
|
|
21151
21480
|
if (isError) return errorObject;
|
|
21152
21481
|
if (timestampObject.isNull() || timestampObject.isBoolean() || timestampObject.isString()) return ErrorValueObject.create("#VALUE!");
|
|
@@ -21653,7 +21982,7 @@ var Today = class extends BaseFunction {
|
|
|
21653
21982
|
}
|
|
21654
21983
|
calculate() {
|
|
21655
21984
|
const now = /* @__PURE__ */ new Date();
|
|
21656
|
-
const currentSerial = excelDateSerial(new Date(Date.UTC(now.
|
|
21985
|
+
const currentSerial = excelDateSerial(new Date(Date.UTC(now.getFullYear(), now.getMonth(), now.getDate())));
|
|
21657
21986
|
return NumberValueObject.create(currentSerial, DEFAULT_DATE_FORMAT);
|
|
21658
21987
|
}
|
|
21659
21988
|
};
|
|
@@ -21759,7 +22088,7 @@ var Weekday = class extends BaseFunction {
|
|
|
21759
22088
|
});
|
|
21760
22089
|
}
|
|
21761
22090
|
calculate(serialNumber, returnType) {
|
|
21762
|
-
const _returnType = returnType
|
|
22091
|
+
const _returnType = returnType ?? NumberValueObject.create(1);
|
|
21763
22092
|
if (serialNumber.isError()) return serialNumber;
|
|
21764
22093
|
if (_returnType.isError()) return _returnType;
|
|
21765
22094
|
const maxRowLength = Math.max(serialNumber.isArray() ? serialNumber.getRowCount() : 1, _returnType.isArray() ? _returnType.getRowCount() : 1);
|
|
@@ -21813,7 +22142,7 @@ var Weeknum = class extends BaseFunction {
|
|
|
21813
22142
|
}
|
|
21814
22143
|
calculate(serialNumber, returnType) {
|
|
21815
22144
|
let _serialNumber = serialNumber;
|
|
21816
|
-
let _returnType = returnType
|
|
22145
|
+
let _returnType = returnType ?? NumberValueObject.create(1);
|
|
21817
22146
|
if (_serialNumber.isArray()) {
|
|
21818
22147
|
const rowCount = _serialNumber.getRowCount();
|
|
21819
22148
|
const columnCount = _serialNumber.getColumnCount();
|
|
@@ -21947,7 +22276,7 @@ var WorkdayIntl = class extends BaseFunction {
|
|
|
21947
22276
|
return this._handleSingleObject(startDate, days, weekend, holidays);
|
|
21948
22277
|
}
|
|
21949
22278
|
_handleSingleObject(startDate, days, weekend, holidays) {
|
|
21950
|
-
const _weekend = weekend
|
|
22279
|
+
const _weekend = weekend ?? NumberValueObject.create(1);
|
|
21951
22280
|
const _startDate = this._checkArrayError(startDate);
|
|
21952
22281
|
if (_startDate.isError()) return _startDate;
|
|
21953
22282
|
const _days = this._checkArrayError(days);
|
|
@@ -22044,7 +22373,7 @@ var Yearfrac = class extends BaseFunction {
|
|
|
22044
22373
|
_defineProperty(this, "maxParams", 3);
|
|
22045
22374
|
}
|
|
22046
22375
|
calculate(startDate, endDate, basis) {
|
|
22047
|
-
let _basis = basis
|
|
22376
|
+
let _basis = basis ?? NumberValueObject.create(0);
|
|
22048
22377
|
const _startDate = checkVariantErrorIsArray(startDate);
|
|
22049
22378
|
if (_startDate.isError()) return _startDate;
|
|
22050
22379
|
const _endDate = checkVariantErrorIsArray(endDate);
|
|
@@ -22889,7 +23218,7 @@ var Complex = class extends BaseFunction {
|
|
|
22889
23218
|
_defineProperty(this, "maxParams", 3);
|
|
22890
23219
|
}
|
|
22891
23220
|
calculate(realNum, iNum, suffix) {
|
|
22892
|
-
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(realNum, iNum, suffix
|
|
23221
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(realNum, iNum, suffix ?? StringValueObject.create("i"));
|
|
22893
23222
|
if (isError) return errorObject;
|
|
22894
23223
|
const [realNumObject, iNumObject, suffixObject] = variants;
|
|
22895
23224
|
const realNumValue = +realNumObject.getValue();
|
|
@@ -24689,7 +25018,7 @@ var Delta = class extends BaseFunction {
|
|
|
24689
25018
|
_defineProperty(this, "maxParams", 2);
|
|
24690
25019
|
}
|
|
24691
25020
|
calculate(number1, number2) {
|
|
24692
|
-
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(number1, number2
|
|
25021
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(number1, number2 ?? NumberValueObject.create(0));
|
|
24693
25022
|
if (isError) return errorObject;
|
|
24694
25023
|
const [number1Object, number2Object] = variants;
|
|
24695
25024
|
const number1Value = +number1Object.getValue();
|
|
@@ -24797,7 +25126,7 @@ var Gestep = class extends BaseFunction {
|
|
|
24797
25126
|
}
|
|
24798
25127
|
calculate(number, step) {
|
|
24799
25128
|
if (number.isNull()) return ErrorValueObject.create("#N/A");
|
|
24800
|
-
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(number, step
|
|
25129
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(number, step ?? NumberValueObject.create(0));
|
|
24801
25130
|
if (isError) return errorObject;
|
|
24802
25131
|
const [numberObject, stepObject] = variants;
|
|
24803
25132
|
const numberValue = +numberObject.getValue();
|
|
@@ -25193,7 +25522,7 @@ var Imlog = class extends BaseFunction {
|
|
|
25193
25522
|
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(inumber);
|
|
25194
25523
|
if (isError) return errorObject;
|
|
25195
25524
|
const [inumberObject] = variants;
|
|
25196
|
-
let _base = base
|
|
25525
|
+
let _base = base ?? NumberValueObject.create(10);
|
|
25197
25526
|
if (_base.isArray()) {
|
|
25198
25527
|
const rowCount = _base.getRowCount();
|
|
25199
25528
|
const columnCount = _base.getColumnCount();
|
|
@@ -26056,8 +26385,8 @@ var Accrint = class extends BaseFunction {
|
|
|
26056
26385
|
_defineProperty(this, "maxParams", 8);
|
|
26057
26386
|
}
|
|
26058
26387
|
calculate(issue, firstInterest, settlement, rate, par, frequency, basis, calcMethod) {
|
|
26059
|
-
const _basis = basis
|
|
26060
|
-
const _calcMethod = calcMethod
|
|
26388
|
+
const _basis = basis ?? NumberValueObject.create(0);
|
|
26389
|
+
const _calcMethod = calcMethod ?? BooleanValueObject.create(true);
|
|
26061
26390
|
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(issue, firstInterest, settlement, rate, par, frequency, _basis);
|
|
26062
26391
|
if (isError) return errorObject;
|
|
26063
26392
|
const [issueObject, firstInterestObject, settlementObject, rateObject, parObject, frequencyObject, basisObject] = variants;
|
|
@@ -26136,7 +26465,7 @@ var Accrintm = class extends BaseFunction {
|
|
|
26136
26465
|
_defineProperty(this, "maxParams", 5);
|
|
26137
26466
|
}
|
|
26138
26467
|
calculate(issue, settlement, rate, par, basis) {
|
|
26139
|
-
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(issue, settlement, rate, par, basis
|
|
26468
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(issue, settlement, rate, par, basis ?? NumberValueObject.create(0));
|
|
26140
26469
|
if (isError) return errorObject;
|
|
26141
26470
|
const [issueObject, settlementObject, rateObject, parObject, basisObject] = variants;
|
|
26142
26471
|
const issueSerialNumber = getDateSerialNumberByObject(issueObject);
|
|
@@ -26164,7 +26493,7 @@ var Amorlinc = class extends BaseFunction {
|
|
|
26164
26493
|
_defineProperty(this, "maxParams", 7);
|
|
26165
26494
|
}
|
|
26166
26495
|
calculate(cost, datePurchased, firstPeriod, salvage, period, rate, basis) {
|
|
26167
|
-
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(cost, datePurchased, firstPeriod, salvage, period, rate, basis
|
|
26496
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(cost, datePurchased, firstPeriod, salvage, period, rate, basis ?? NumberValueObject.create(0));
|
|
26168
26497
|
if (isError) return errorObject;
|
|
26169
26498
|
const [costObject, datePurchasedObject, firstPeriodObject, salvageObject, periodObject, rateObject, basisObject] = variants;
|
|
26170
26499
|
const datePurchasedSerialNumber = getDateSerialNumberByObject(datePurchasedObject);
|
|
@@ -26211,7 +26540,7 @@ var Coupdaybs = class extends BaseFunction {
|
|
|
26211
26540
|
_defineProperty(this, "maxParams", 4);
|
|
26212
26541
|
}
|
|
26213
26542
|
calculate(settlement, maturity, frequency, basis) {
|
|
26214
|
-
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(settlement, maturity, frequency, basis
|
|
26543
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(settlement, maturity, frequency, basis ?? NumberValueObject.create(0));
|
|
26215
26544
|
if (isError) return errorObject;
|
|
26216
26545
|
const [settlementObject, maturityObject, frequencyObject, basisObject] = variants;
|
|
26217
26546
|
const settlementSerialNumber = getDateSerialNumberByObject(settlementObject);
|
|
@@ -26240,7 +26569,7 @@ var Coupdays = class extends BaseFunction {
|
|
|
26240
26569
|
_defineProperty(this, "maxParams", 4);
|
|
26241
26570
|
}
|
|
26242
26571
|
calculate(settlement, maturity, frequency, basis) {
|
|
26243
|
-
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(settlement, maturity, frequency, basis
|
|
26572
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(settlement, maturity, frequency, basis ?? NumberValueObject.create(0));
|
|
26244
26573
|
if (isError) return errorObject;
|
|
26245
26574
|
const [settlementObject, maturityObject, frequencyObject, basisObject] = variants;
|
|
26246
26575
|
const settlementSerialNumber = getDateSerialNumberByObject(settlementObject);
|
|
@@ -26269,7 +26598,7 @@ var Coupdaysnc = class extends BaseFunction {
|
|
|
26269
26598
|
_defineProperty(this, "maxParams", 4);
|
|
26270
26599
|
}
|
|
26271
26600
|
calculate(settlement, maturity, frequency, basis) {
|
|
26272
|
-
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(settlement, maturity, frequency, basis
|
|
26601
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(settlement, maturity, frequency, basis ?? NumberValueObject.create(0));
|
|
26273
26602
|
if (isError) return errorObject;
|
|
26274
26603
|
const [settlementObject, maturityObject, frequencyObject, basisObject] = variants;
|
|
26275
26604
|
const settlementSerialNumber = getDateSerialNumberByObject(settlementObject);
|
|
@@ -26304,7 +26633,7 @@ var Coupncd = class extends BaseFunction {
|
|
|
26304
26633
|
_defineProperty(this, "maxParams", 4);
|
|
26305
26634
|
}
|
|
26306
26635
|
calculate(settlement, maturity, frequency, basis) {
|
|
26307
|
-
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(settlement, maturity, frequency, basis
|
|
26636
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(settlement, maturity, frequency, basis ?? NumberValueObject.create(0));
|
|
26308
26637
|
if (isError) return errorObject;
|
|
26309
26638
|
const [settlementObject, maturityObject, frequencyObject, basisObject] = variants;
|
|
26310
26639
|
const settlementSerialNumber = getDateSerialNumberByObject(settlementObject);
|
|
@@ -26333,7 +26662,7 @@ var Coupnum = class extends BaseFunction {
|
|
|
26333
26662
|
_defineProperty(this, "maxParams", 4);
|
|
26334
26663
|
}
|
|
26335
26664
|
calculate(settlement, maturity, frequency, basis) {
|
|
26336
|
-
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(settlement, maturity, frequency, basis
|
|
26665
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(settlement, maturity, frequency, basis ?? NumberValueObject.create(0));
|
|
26337
26666
|
if (isError) return errorObject;
|
|
26338
26667
|
const [settlementObject, maturityObject, frequencyObject, basisObject] = variants;
|
|
26339
26668
|
const settlementSerialNumber = getDateSerialNumberByObject(settlementObject);
|
|
@@ -26363,7 +26692,7 @@ var Couppcd = class extends BaseFunction {
|
|
|
26363
26692
|
_defineProperty(this, "maxParams", 4);
|
|
26364
26693
|
}
|
|
26365
26694
|
calculate(settlement, maturity, frequency, basis) {
|
|
26366
|
-
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(settlement, maturity, frequency, basis
|
|
26695
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(settlement, maturity, frequency, basis ?? NumberValueObject.create(0));
|
|
26367
26696
|
if (isError) return errorObject;
|
|
26368
26697
|
const [settlementObject, maturityObject, frequencyObject, basisObject] = variants;
|
|
26369
26698
|
const settlementSerialNumber = getDateSerialNumberByObject(settlementObject);
|
|
@@ -26476,7 +26805,7 @@ var Db = class extends BaseFunction {
|
|
|
26476
26805
|
_defineProperty(this, "needsLocale", true);
|
|
26477
26806
|
}
|
|
26478
26807
|
calculate(cost, salvage, life, period, month) {
|
|
26479
|
-
let _month = month
|
|
26808
|
+
let _month = month ?? NumberValueObject.create(12);
|
|
26480
26809
|
if (_month.isNull()) _month = NumberValueObject.create(12);
|
|
26481
26810
|
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
26811
|
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 +26861,7 @@ var Ddb = class extends BaseFunction {
|
|
|
26532
26861
|
_defineProperty(this, "needsLocale", true);
|
|
26533
26862
|
}
|
|
26534
26863
|
calculate(cost, salvage, life, period, factor) {
|
|
26535
|
-
let _factor = factor
|
|
26864
|
+
let _factor = factor ?? NumberValueObject.create(2);
|
|
26536
26865
|
if (_factor.isNull()) _factor = NumberValueObject.create(2);
|
|
26537
26866
|
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
26867
|
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 +26899,7 @@ var Disc = class extends BaseFunction {
|
|
|
26570
26899
|
_defineProperty(this, "maxParams", 5);
|
|
26571
26900
|
}
|
|
26572
26901
|
calculate(settlement, maturity, pr, redemption, basis) {
|
|
26573
|
-
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(settlement, maturity, pr, redemption, basis
|
|
26902
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(settlement, maturity, pr, redemption, basis ?? NumberValueObject.create(0));
|
|
26574
26903
|
if (isError) return errorObject;
|
|
26575
26904
|
const [settlementObject, maturityObject, prObject, redemptionObject, basisObject] = variants;
|
|
26576
26905
|
const settlementSerialNumber = getDateSerialNumberByObject(settlementObject);
|
|
@@ -26647,7 +26976,7 @@ var Duration = class extends BaseFunction {
|
|
|
26647
26976
|
_defineProperty(this, "maxParams", 6);
|
|
26648
26977
|
}
|
|
26649
26978
|
calculate(settlement, maturity, coupon, yld, frequency, basis) {
|
|
26650
|
-
let _basis = basis
|
|
26979
|
+
let _basis = basis ?? NumberValueObject.create(0);
|
|
26651
26980
|
if (_basis.isNull()) _basis = NumberValueObject.create(0);
|
|
26652
26981
|
const { isError, errorObject, variants } = checkVariantsErrorIsNullorArrayOrBoolean(settlement, maturity, coupon, yld, frequency, _basis);
|
|
26653
26982
|
if (isError) return errorObject;
|
|
@@ -26704,8 +27033,8 @@ var Fv = class extends BaseFunction {
|
|
|
26704
27033
|
_defineProperty(this, "needsLocale", true);
|
|
26705
27034
|
}
|
|
26706
27035
|
calculate(rate, nper, pmt, pv, type) {
|
|
26707
|
-
const _pv = pv
|
|
26708
|
-
const _type = type
|
|
27036
|
+
const _pv = pv ?? NumberValueObject.create(0);
|
|
27037
|
+
const _type = type ?? NumberValueObject.create(0);
|
|
26709
27038
|
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
27039
|
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
27040
|
const rateArray = expandArrayValueObject(maxRowLength, maxColumnLength, rate, ErrorValueObject.create("#N/A"));
|
|
@@ -26770,7 +27099,7 @@ var Intrate = class extends BaseFunction {
|
|
|
26770
27099
|
_defineProperty(this, "maxParams", 5);
|
|
26771
27100
|
}
|
|
26772
27101
|
calculate(settlement, maturity, investment, redemption, basis) {
|
|
26773
|
-
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(settlement, maturity, investment, redemption, basis
|
|
27102
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(settlement, maturity, investment, redemption, basis ?? NumberValueObject.create(0));
|
|
26774
27103
|
if (isError) return errorObject;
|
|
26775
27104
|
const [settlementObject, maturityObject, investmentObject, redemptionObject, basisObject] = variants;
|
|
26776
27105
|
const settlementSerialNumber = getDateSerialNumberByObject(settlementObject);
|
|
@@ -26798,8 +27127,8 @@ var Ipmt = class extends BaseFunction {
|
|
|
26798
27127
|
_defineProperty(this, "needsLocale", true);
|
|
26799
27128
|
}
|
|
26800
27129
|
calculate(rate, per, nper, pv, fv, type) {
|
|
26801
|
-
const _fv = fv
|
|
26802
|
-
const _type = type
|
|
27130
|
+
const _fv = fv ?? NumberValueObject.create(0);
|
|
27131
|
+
const _type = type ?? NumberValueObject.create(0);
|
|
26803
27132
|
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
27133
|
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
27134
|
const rateArray = expandArrayValueObject(maxRowLength, maxColumnLength, rate, ErrorValueObject.create("#N/A"));
|
|
@@ -26838,7 +27167,7 @@ var Irr = class extends BaseFunction {
|
|
|
26838
27167
|
_defineProperty(this, "maxParams", 2);
|
|
26839
27168
|
}
|
|
26840
27169
|
calculate(values, guess) {
|
|
26841
|
-
let _guess = guess
|
|
27170
|
+
let _guess = guess ?? NumberValueObject.create(.1);
|
|
26842
27171
|
if (_guess.isNull()) _guess = NumberValueObject.create(.1);
|
|
26843
27172
|
if (_guess.isArray()) return _guess.map((guessObject, rowIndex, columnIndex) => this._handleSingleObject(values, guessObject, rowIndex, columnIndex));
|
|
26844
27173
|
return this._handleSingleObject(values, _guess);
|
|
@@ -26937,7 +27266,7 @@ var Mduration = class extends BaseFunction {
|
|
|
26937
27266
|
_defineProperty(this, "maxParams", 6);
|
|
26938
27267
|
}
|
|
26939
27268
|
calculate(settlement, maturity, coupon, yld, frequency, basis) {
|
|
26940
|
-
let _basis = basis
|
|
27269
|
+
let _basis = basis ?? NumberValueObject.create(0);
|
|
26941
27270
|
if (_basis.isNull()) _basis = NumberValueObject.create(0);
|
|
26942
27271
|
const { isError, errorObject, variants } = checkVariantsErrorIsNullorArrayOrBoolean(settlement, maturity, coupon, yld, frequency, _basis);
|
|
26943
27272
|
if (isError) return errorObject;
|
|
@@ -27093,8 +27422,8 @@ var Nper = class extends BaseFunction {
|
|
|
27093
27422
|
_defineProperty(this, "maxParams", 5);
|
|
27094
27423
|
}
|
|
27095
27424
|
calculate(rate, pmt, pv, fv, type) {
|
|
27096
|
-
const _fv = fv
|
|
27097
|
-
const _type = type
|
|
27425
|
+
const _fv = fv ?? NumberValueObject.create(0);
|
|
27426
|
+
const _type = type ?? NumberValueObject.create(0);
|
|
27098
27427
|
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
27428
|
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
27429
|
const rateArray = expandArrayValueObject(maxRowLength, maxColumnLength, rate, ErrorValueObject.create("#N/A"));
|
|
@@ -27205,7 +27534,7 @@ var Oddfprice = class extends BaseFunction {
|
|
|
27205
27534
|
_defineProperty(this, "maxParams", 9);
|
|
27206
27535
|
}
|
|
27207
27536
|
calculate(settlement, maturity, issue, firstCoupon, rate, yld, redemption, frequency, basis) {
|
|
27208
|
-
let _basis = basis
|
|
27537
|
+
let _basis = basis ?? NumberValueObject.create(0);
|
|
27209
27538
|
if (_basis.isNull()) _basis = NumberValueObject.create(0);
|
|
27210
27539
|
const { isError, errorObject, variants } = checkVariantsErrorIsNullorArrayOrBoolean(settlement, maturity, issue, firstCoupon, rate, yld, redemption, frequency, _basis);
|
|
27211
27540
|
if (isError) return errorObject;
|
|
@@ -27249,7 +27578,7 @@ var Oddfyield = class extends BaseFunction {
|
|
|
27249
27578
|
_defineProperty(this, "maxParams", 9);
|
|
27250
27579
|
}
|
|
27251
27580
|
calculate(settlement, maturity, issue, firstCoupon, rate, pr, redemption, frequency, basis) {
|
|
27252
|
-
let _basis = basis
|
|
27581
|
+
let _basis = basis ?? NumberValueObject.create(0);
|
|
27253
27582
|
if (_basis.isNull()) _basis = NumberValueObject.create(0);
|
|
27254
27583
|
const { isError, errorObject, variants } = checkVariantsErrorIsNullorArrayOrBoolean(settlement, maturity, issue, firstCoupon, rate, pr, redemption, frequency, _basis);
|
|
27255
27584
|
if (isError) return errorObject;
|
|
@@ -27302,7 +27631,7 @@ var Oddlprice = class extends BaseFunction {
|
|
|
27302
27631
|
_defineProperty(this, "maxParams", 8);
|
|
27303
27632
|
}
|
|
27304
27633
|
calculate(settlement, maturity, lastInterest, rate, yld, redemption, frequency, basis) {
|
|
27305
|
-
let _basis = basis
|
|
27634
|
+
let _basis = basis ?? NumberValueObject.create(0);
|
|
27306
27635
|
if (_basis.isNull()) _basis = NumberValueObject.create(0);
|
|
27307
27636
|
const { isError, errorObject, variants } = checkVariantsErrorIsNullorArrayOrBoolean(settlement, maturity, lastInterest, rate, yld, redemption, frequency, _basis);
|
|
27308
27637
|
if (isError) return errorObject;
|
|
@@ -27387,7 +27716,7 @@ var Oddlyield = class extends BaseFunction {
|
|
|
27387
27716
|
_defineProperty(this, "maxParams", 9);
|
|
27388
27717
|
}
|
|
27389
27718
|
calculate(settlement, maturity, lastInterest, rate, pr, redemption, frequency, basis) {
|
|
27390
|
-
let _basis = basis
|
|
27719
|
+
let _basis = basis ?? NumberValueObject.create(0);
|
|
27391
27720
|
if (_basis.isNull()) _basis = NumberValueObject.create(0);
|
|
27392
27721
|
const { isError, errorObject, variants } = checkVariantsErrorIsNullorArrayOrBoolean(settlement, maturity, lastInterest, rate, pr, redemption, frequency, _basis);
|
|
27393
27722
|
if (isError) return errorObject;
|
|
@@ -27504,8 +27833,8 @@ var Pmt = class extends BaseFunction {
|
|
|
27504
27833
|
_defineProperty(this, "needsLocale", true);
|
|
27505
27834
|
}
|
|
27506
27835
|
calculate(rate, nper, pv, fv, type) {
|
|
27507
|
-
const _fv = fv
|
|
27508
|
-
const _type = type
|
|
27836
|
+
const _fv = fv ?? NumberValueObject.create(0);
|
|
27837
|
+
const _type = type ?? NumberValueObject.create(0);
|
|
27509
27838
|
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
27839
|
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
27840
|
const rateArray = expandArrayValueObject(maxRowLength, maxColumnLength, rate, ErrorValueObject.create("#N/A"));
|
|
@@ -27543,8 +27872,8 @@ var Ppmt = class extends BaseFunction {
|
|
|
27543
27872
|
_defineProperty(this, "needsLocale", true);
|
|
27544
27873
|
}
|
|
27545
27874
|
calculate(rate, per, nper, pv, fv, type) {
|
|
27546
|
-
const _fv = fv
|
|
27547
|
-
const _type = type
|
|
27875
|
+
const _fv = fv ?? NumberValueObject.create(0);
|
|
27876
|
+
const _type = type ?? NumberValueObject.create(0);
|
|
27548
27877
|
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
27878
|
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
27879
|
const rateArray = expandArrayValueObject(maxRowLength, maxColumnLength, rate, ErrorValueObject.create("#N/A"));
|
|
@@ -27583,7 +27912,7 @@ var Price = class extends BaseFunction {
|
|
|
27583
27912
|
_defineProperty(this, "maxParams", 7);
|
|
27584
27913
|
}
|
|
27585
27914
|
calculate(settlement, maturity, rate, yld, redemption, frequency, basis) {
|
|
27586
|
-
let _basis = basis
|
|
27915
|
+
let _basis = basis ?? NumberValueObject.create(0);
|
|
27587
27916
|
if (_basis.isNull()) _basis = NumberValueObject.create(0);
|
|
27588
27917
|
const { isError, errorObject, variants } = checkVariantsErrorIsNullorArrayOrBoolean(settlement, maturity, rate, yld, redemption, frequency, _basis);
|
|
27589
27918
|
if (isError) return errorObject;
|
|
@@ -27617,7 +27946,7 @@ var Pricedisc = class extends BaseFunction {
|
|
|
27617
27946
|
_defineProperty(this, "maxParams", 5);
|
|
27618
27947
|
}
|
|
27619
27948
|
calculate(settlement, maturity, discount, redemption, basis) {
|
|
27620
|
-
let _basis = basis
|
|
27949
|
+
let _basis = basis ?? NumberValueObject.create(0);
|
|
27621
27950
|
if (_basis.isNull()) _basis = NumberValueObject.create(0);
|
|
27622
27951
|
const { isError, errorObject, variants } = checkVariantsErrorIsNullorArrayOrBoolean(settlement, maturity, discount, redemption, _basis);
|
|
27623
27952
|
if (isError) return errorObject;
|
|
@@ -27646,7 +27975,7 @@ var Pricemat = class extends BaseFunction {
|
|
|
27646
27975
|
_defineProperty(this, "maxParams", 6);
|
|
27647
27976
|
}
|
|
27648
27977
|
calculate(settlement, maturity, issue, rate, yld, basis) {
|
|
27649
|
-
let _basis = basis
|
|
27978
|
+
let _basis = basis ?? NumberValueObject.create(0);
|
|
27650
27979
|
if (_basis.isNull()) _basis = NumberValueObject.create(0);
|
|
27651
27980
|
const { isError, errorObject, variants } = checkVariantsErrorIsNullorArrayOrBoolean(settlement, maturity, issue, rate, yld, _basis);
|
|
27652
27981
|
if (isError) return errorObject;
|
|
@@ -27685,8 +28014,8 @@ var Pv = class extends BaseFunction {
|
|
|
27685
28014
|
_defineProperty(this, "needsLocale", true);
|
|
27686
28015
|
}
|
|
27687
28016
|
calculate(rate, nper, pmt, fv, type) {
|
|
27688
|
-
const _fv = fv
|
|
27689
|
-
const _type = type
|
|
28017
|
+
const _fv = fv ?? NumberValueObject.create(0);
|
|
28018
|
+
const _type = type ?? NumberValueObject.create(0);
|
|
27690
28019
|
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
28020
|
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
28021
|
const rateArray = expandArrayValueObject(maxRowLength, maxColumnLength, rate, ErrorValueObject.create("#N/A"));
|
|
@@ -27723,9 +28052,9 @@ var Rate = class extends BaseFunction {
|
|
|
27723
28052
|
_defineProperty(this, "maxParams", 6);
|
|
27724
28053
|
}
|
|
27725
28054
|
calculate(nper, pmt, pv, fv, type, guess) {
|
|
27726
|
-
const _fv = fv
|
|
27727
|
-
const _type = type
|
|
27728
|
-
const _guess = guess
|
|
28055
|
+
const _fv = fv ?? NumberValueObject.create(0);
|
|
28056
|
+
const _type = type ?? NumberValueObject.create(0);
|
|
28057
|
+
const _guess = guess ?? NumberValueObject.create(.1);
|
|
27729
28058
|
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
28059
|
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
28060
|
const nperArray = expandArrayValueObject(maxRowLength, maxColumnLength, nper, ErrorValueObject.create("#N/A"));
|
|
@@ -27810,7 +28139,7 @@ var Received = class extends BaseFunction {
|
|
|
27810
28139
|
_defineProperty(this, "maxParams", 5);
|
|
27811
28140
|
}
|
|
27812
28141
|
calculate(settlement, maturity, investment, discount, basis) {
|
|
27813
|
-
let _basis = basis
|
|
28142
|
+
let _basis = basis ?? NumberValueObject.create(0);
|
|
27814
28143
|
if (_basis.isNull()) _basis = NumberValueObject.create(0);
|
|
27815
28144
|
const { isError, errorObject, variants } = checkVariantsErrorIsNullorArrayOrBoolean(settlement, maturity, investment, discount, _basis);
|
|
27816
28145
|
if (isError) return errorObject;
|
|
@@ -28032,9 +28361,9 @@ var Vdb = class extends BaseFunction {
|
|
|
28032
28361
|
_defineProperty(this, "needsLocale", true);
|
|
28033
28362
|
}
|
|
28034
28363
|
calculate(cost, salvage, life, startPeriod, endPeriod, factor, noSwitch) {
|
|
28035
|
-
let _factor = factor
|
|
28364
|
+
let _factor = factor ?? NumberValueObject.create(2);
|
|
28036
28365
|
if (_factor.isNull()) _factor = NumberValueObject.create(2);
|
|
28037
|
-
let _noSwitch = noSwitch
|
|
28366
|
+
let _noSwitch = noSwitch ?? BooleanValueObject.create(false);
|
|
28038
28367
|
if (_noSwitch.isNull()) _noSwitch = BooleanValueObject.create(false);
|
|
28039
28368
|
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
28369
|
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 +28457,7 @@ var Xirr = class extends BaseFunction {
|
|
|
28128
28457
|
if (values.isNull() || dates.isNull()) return ErrorValueObject.create("#N/A");
|
|
28129
28458
|
const { isError, errorObejct, _values, _dates } = this._checkErrors(values, dates);
|
|
28130
28459
|
if (isError) return errorObejct;
|
|
28131
|
-
let _guess = guess
|
|
28460
|
+
let _guess = guess ?? NumberValueObject.create(.1);
|
|
28132
28461
|
if (_guess.isNull()) _guess = NumberValueObject.create(.1);
|
|
28133
28462
|
const { isError: _isError_guess, errorObject: _errorObject_guess, variants } = checkVariantsErrorIsArrayOrBoolean(_guess);
|
|
28134
28463
|
if (_isError_guess) return _errorObject_guess;
|
|
@@ -28471,7 +28800,7 @@ var Yield = class extends BaseFunction {
|
|
|
28471
28800
|
_defineProperty(this, "maxParams", 7);
|
|
28472
28801
|
}
|
|
28473
28802
|
calculate(settlement, maturity, rate, pr, redemption, frequency, basis) {
|
|
28474
|
-
let _basis = basis
|
|
28803
|
+
let _basis = basis ?? NumberValueObject.create(0);
|
|
28475
28804
|
if (_basis.isNull()) _basis = NumberValueObject.create(0);
|
|
28476
28805
|
const { isError, errorObject, variants } = checkVariantsErrorIsNullorArrayOrBoolean(settlement, maturity, rate, pr, redemption, frequency, _basis);
|
|
28477
28806
|
if (isError) return errorObject;
|
|
@@ -28524,7 +28853,7 @@ var Yielddisc = class extends BaseFunction {
|
|
|
28524
28853
|
_defineProperty(this, "maxParams", 5);
|
|
28525
28854
|
}
|
|
28526
28855
|
calculate(settlement, maturity, pr, redemption, basis) {
|
|
28527
|
-
let _basis = basis
|
|
28856
|
+
let _basis = basis ?? NumberValueObject.create(0);
|
|
28528
28857
|
if (_basis.isNull()) _basis = NumberValueObject.create(0);
|
|
28529
28858
|
const { isError, errorObject, variants } = checkVariantsErrorIsNullorArrayOrBoolean(settlement, maturity, pr, redemption, _basis);
|
|
28530
28859
|
if (isError) return errorObject;
|
|
@@ -28553,7 +28882,7 @@ var Yieldmat = class extends BaseFunction {
|
|
|
28553
28882
|
_defineProperty(this, "maxParams", 6);
|
|
28554
28883
|
}
|
|
28555
28884
|
calculate(settlement, maturity, issue, rate, pr, basis) {
|
|
28556
|
-
let _basis = basis
|
|
28885
|
+
let _basis = basis ?? NumberValueObject.create(0);
|
|
28557
28886
|
if (_basis.isNull()) _basis = NumberValueObject.create(0);
|
|
28558
28887
|
const { isError, errorObject, variants } = checkVariantsErrorIsNullorArrayOrBoolean(settlement, maturity, issue, rate, pr, _basis);
|
|
28559
28888
|
if (isError) return errorObject;
|
|
@@ -28688,6 +29017,7 @@ var Cell = class extends BaseFunction {
|
|
|
28688
29017
|
if (_reference.isError()) return _reference;
|
|
28689
29018
|
if (!_reference.isReferenceObject()) return ErrorValueObject.create("#N/A");
|
|
28690
29019
|
const { columnData, defaultColumnWidth } = _reference.getCurrentActiveSheetData();
|
|
29020
|
+
const forcedSheetName = _reference.getForcedSheetName();
|
|
28691
29021
|
_reference = _reference.toArrayValueObject();
|
|
28692
29022
|
const _currentRow = _reference.getCurrentRow();
|
|
28693
29023
|
const _currentColumn = _reference.getCurrentColumn();
|
|
@@ -28695,7 +29025,7 @@ var Cell = class extends BaseFunction {
|
|
|
28695
29025
|
const infoTypeValue = `${infoType.getValue()}`;
|
|
28696
29026
|
let result;
|
|
28697
29027
|
switch (infoTypeValue.toLocaleLowerCase()) {
|
|
28698
|
-
case "address": return StringValueObject.create(
|
|
29028
|
+
case "address": return StringValueObject.create(`${forcedSheetName ? `${addQuotesBothSides(forcedSheetName)}!` : ""}$${Tools.chatAtABC(_currentColumn)}$${_currentRow + 1}`);
|
|
28699
29029
|
case "col": return NumberValueObject.create(_currentColumn + 1);
|
|
28700
29030
|
case "color": return NumberValueObject.create(0);
|
|
28701
29031
|
case "contents": return _reference;
|
|
@@ -28764,7 +29094,7 @@ var Isbetween = class extends BaseFunction {
|
|
|
28764
29094
|
_defineProperty(this, "maxParams", 5);
|
|
28765
29095
|
}
|
|
28766
29096
|
calculate(valueToCompare, lowerValue, upperValue, lowerValueIsInclusive, upperValueIsInclusive) {
|
|
28767
|
-
const { isError, errorObject, variants } = checkVariantsErrorIsArray(valueToCompare, lowerValue, upperValue, lowerValueIsInclusive
|
|
29097
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsArray(valueToCompare, lowerValue, upperValue, lowerValueIsInclusive ?? BooleanValueObject.create(true), upperValueIsInclusive ?? BooleanValueObject.create(true));
|
|
28768
29098
|
if (isError) return errorObject;
|
|
28769
29099
|
const [valueToCompareObject, lowerValueObject, upperValueObject, lowerValueIsInclusiveObject, upperValueIsInclusiveObject] = variants;
|
|
28770
29100
|
if (lowerValueIsInclusiveObject.isString() || upperValueIsInclusiveObject.isString()) return ErrorValueObject.create("#VALUE!");
|
|
@@ -28786,8 +29116,13 @@ var Isblank = class extends BaseFunction {
|
|
|
28786
29116
|
super(..._args);
|
|
28787
29117
|
_defineProperty(this, "minParams", 1);
|
|
28788
29118
|
_defineProperty(this, "maxParams", 1);
|
|
29119
|
+
_defineProperty(this, "needsReferenceObject", true);
|
|
28789
29120
|
}
|
|
28790
29121
|
calculate(value) {
|
|
29122
|
+
if (value instanceof BaseReferenceObject) {
|
|
29123
|
+
const array = value.toArrayValueObject(false).mapValue((valueObject) => BooleanValueObject.create(valueObject.isNull()));
|
|
29124
|
+
return array.getRowCount() === 1 && array.getColumnCount() === 1 ? array.getFirstCell() : array;
|
|
29125
|
+
}
|
|
28791
29126
|
if (value.isNull()) return BooleanValueObject.create(true);
|
|
28792
29127
|
else if (value.isArray()) return value.mapValue((valueObject) => {
|
|
28793
29128
|
if (valueObject.isNull()) return BooleanValueObject.create(true);
|
|
@@ -29550,10 +29885,7 @@ var Groupby = class extends BaseFunction {
|
|
|
29550
29885
|
return {
|
|
29551
29886
|
rowCount: array.getRowCount(),
|
|
29552
29887
|
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
|
-
}
|
|
29888
|
+
valueAt: (row, column) => array.get(row, column) ?? NullValueObject.create()
|
|
29557
29889
|
};
|
|
29558
29890
|
}
|
|
29559
29891
|
return {
|
|
@@ -29623,10 +29955,7 @@ var Groupby = class extends BaseFunction {
|
|
|
29623
29955
|
}
|
|
29624
29956
|
}
|
|
29625
29957
|
_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);
|
|
29958
|
+
return values.reduce((sum, value) => sum + (this._numericValue(value) ?? 0), 0);
|
|
29630
29959
|
}
|
|
29631
29960
|
_numericValue(value) {
|
|
29632
29961
|
return value.isNumber() ? Number(value.getValue()) : void 0;
|
|
@@ -29634,10 +29963,7 @@ var Groupby = class extends BaseFunction {
|
|
|
29634
29963
|
_numberValue(variant) {
|
|
29635
29964
|
if (variant == null || variant.isError()) return 0;
|
|
29636
29965
|
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
|
-
}
|
|
29966
|
+
if (variant.isArray()) variant = variant.get(0, 0) ?? NullValueObject.create();
|
|
29641
29967
|
const value = variant.getValue();
|
|
29642
29968
|
return typeof value === "number" ? Math.trunc(value) : Math.trunc(Number(value) || 0);
|
|
29643
29969
|
}
|
|
@@ -30496,6 +30822,7 @@ var Choose = class extends BaseFunction {
|
|
|
30496
30822
|
super(..._args);
|
|
30497
30823
|
_defineProperty(this, "minParams", 2);
|
|
30498
30824
|
_defineProperty(this, "maxParams", 255);
|
|
30825
|
+
_defineProperty(this, "lazyIfReferenceArrayArgumentIndexes", Array.from({ length: this.maxParams - 1 }, (_, index) => index + 1));
|
|
30499
30826
|
_defineProperty(this, "needsReferenceObject", true);
|
|
30500
30827
|
}
|
|
30501
30828
|
calculate(indexNum, ...variants) {
|
|
@@ -30680,7 +31007,7 @@ var Drop = class extends BaseFunction {
|
|
|
30680
31007
|
_defineProperty(this, "maxParams", 3);
|
|
30681
31008
|
}
|
|
30682
31009
|
calculate(array, rows, columns) {
|
|
30683
|
-
const _columns = columns
|
|
31010
|
+
const _columns = columns ?? NumberValueObject.create(0);
|
|
30684
31011
|
const arrayRowCount = array.isArray() ? array.getRowCount() : 1;
|
|
30685
31012
|
const arrayColumnCount = array.isArray() ? array.getColumnCount() : 1;
|
|
30686
31013
|
const maxRowLength = Math.max(rows.isArray() ? rows.getRowCount() : 1, _columns.isArray() ? _columns.getRowCount() : 1);
|
|
@@ -30755,8 +31082,8 @@ var Expand = class extends BaseFunction {
|
|
|
30755
31082
|
const arrayRowCount = array.isArray() ? array.getRowCount() : 1;
|
|
30756
31083
|
const arrayColumnCount = array.isArray() ? array.getColumnCount() : 1;
|
|
30757
31084
|
let _rows = rows;
|
|
30758
|
-
let _columns = columns
|
|
30759
|
-
const _padWith = padWith
|
|
31085
|
+
let _columns = columns ?? NumberValueObject.create(arrayColumnCount);
|
|
31086
|
+
const _padWith = padWith ?? ErrorValueObject.create("#N/A");
|
|
30760
31087
|
if (rows.isNull()) _rows = NumberValueObject.create(arrayRowCount);
|
|
30761
31088
|
if (_columns.isNull()) _columns = NumberValueObject.create(arrayColumnCount);
|
|
30762
31089
|
const maxRowLength = Math.max(_rows.isArray() ? _rows.getRowCount() : 1, _columns.isArray() ? _columns.getRowCount() : 1);
|
|
@@ -30848,7 +31175,7 @@ var Filter = class extends BaseFunction {
|
|
|
30848
31175
|
_defineProperty(this, "maxParams", 3);
|
|
30849
31176
|
}
|
|
30850
31177
|
calculate(array, include, ifEmpty) {
|
|
30851
|
-
const _ifEmpty = ifEmpty
|
|
31178
|
+
const _ifEmpty = ifEmpty ?? ErrorValueObject.create("#CALC!");
|
|
30852
31179
|
if (array.isError()) return array;
|
|
30853
31180
|
if (include.isError()) return include;
|
|
30854
31181
|
const arrayRowCount = array.isArray() ? array.getRowCount() : 1;
|
|
@@ -31100,7 +31427,7 @@ var ImageFunction = class extends BaseFunction {
|
|
|
31100
31427
|
if (altText.isBoolean()) altTextValue = altText.getValue() ? "TRUE" : "FALSE";
|
|
31101
31428
|
else if (!altText.isNull()) altTextValue = `${altText.getValue()}`;
|
|
31102
31429
|
}
|
|
31103
|
-
let _sizing = sizing
|
|
31430
|
+
let _sizing = sizing ?? NumberValueObject.create(0);
|
|
31104
31431
|
if (_sizing.isString()) _sizing = _sizing.convertToNumberObjectValue();
|
|
31105
31432
|
if (_sizing.isError()) return _sizing;
|
|
31106
31433
|
const sizingValue = Math.abs(Math.trunc(+_sizing.getValue()));
|
|
@@ -31110,11 +31437,11 @@ var ImageFunction = class extends BaseFunction {
|
|
|
31110
31437
|
1,
|
|
31111
31438
|
2
|
|
31112
31439
|
].includes(sizingValue) && (height || width)) return ErrorValueObject.create("#VALUE!");
|
|
31113
|
-
let _height = height
|
|
31440
|
+
let _height = height ?? NumberValueObject.create(0);
|
|
31114
31441
|
if (_height.isString()) _height = _height.convertToNumberObjectValue();
|
|
31115
31442
|
if (_height.isError()) return _height;
|
|
31116
31443
|
const heightValue = Math.ceil(+_height.getValue());
|
|
31117
|
-
let _width = width
|
|
31444
|
+
let _width = width ?? NumberValueObject.create(0);
|
|
31118
31445
|
if (_width.isString()) _width = _width.convertToNumberObjectValue();
|
|
31119
31446
|
if (_width.isError()) return _width;
|
|
31120
31447
|
const widthValue = Math.ceil(+_width.getValue());
|
|
@@ -31156,7 +31483,7 @@ var Index = class extends BaseFunction {
|
|
|
31156
31483
|
if (rowNum.isReferenceObject()) _rowNum = rowNum.toArrayValueObject();
|
|
31157
31484
|
let _columnNum = columnNum;
|
|
31158
31485
|
if (_columnNum === null || _columnNum === void 0 ? void 0 : _columnNum.isReferenceObject()) _columnNum = columnNum.toArrayValueObject();
|
|
31159
|
-
let _areaNum = areaNum
|
|
31486
|
+
let _areaNum = areaNum ?? NumberValueObject.create(1);
|
|
31160
31487
|
if (_areaNum.isReferenceObject()) _areaNum = areaNum.toArrayValueObject();
|
|
31161
31488
|
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
31489
|
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 +31743,7 @@ var Match = class extends BaseFunction {
|
|
|
31416
31743
|
super(..._args);
|
|
31417
31744
|
_defineProperty(this, "minParams", 2);
|
|
31418
31745
|
_defineProperty(this, "maxParams", 3);
|
|
31746
|
+
_defineProperty(this, "lazyIfReferenceArrayArgumentIndexes", [1]);
|
|
31419
31747
|
}
|
|
31420
31748
|
calculate(lookupValue, lookupArray, matchType) {
|
|
31421
31749
|
if (lookupValue.isError()) return lookupValue;
|
|
@@ -31448,236 +31776,6 @@ var Match = class extends BaseFunction {
|
|
|
31448
31776
|
}
|
|
31449
31777
|
};
|
|
31450
31778
|
|
|
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
31779
|
//#endregion
|
|
31682
31780
|
//#region src/functions/lookup/offset/index.ts
|
|
31683
31781
|
var Offset = class extends BaseFunction {
|
|
@@ -31703,10 +31801,10 @@ var Offset = class extends BaseFunction {
|
|
|
31703
31801
|
if (_rows.isReferenceObject()) _rows = _rows.toArrayValueObject();
|
|
31704
31802
|
let _columns = columns;
|
|
31705
31803
|
if (_columns.isReferenceObject()) _columns = _columns.toArrayValueObject();
|
|
31706
|
-
let _height = height
|
|
31804
|
+
let _height = height ?? NumberValueObject.create(rowCount);
|
|
31707
31805
|
if (_height.isReferenceObject()) _height = _height.toArrayValueObject();
|
|
31708
31806
|
if (_height.isNull()) _height = NumberValueObject.create(rowCount);
|
|
31709
|
-
let _width = width
|
|
31807
|
+
let _width = width ?? NumberValueObject.create(columnCount);
|
|
31710
31808
|
if (_width.isReferenceObject()) _width = _width.toArrayValueObject();
|
|
31711
31809
|
if (_width.isNull()) _width = NumberValueObject.create(columnCount);
|
|
31712
31810
|
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 +31941,9 @@ var Sort = class extends BaseFunction {
|
|
|
31843
31941
|
_defineProperty(this, "maxParams", 4);
|
|
31844
31942
|
}
|
|
31845
31943
|
calculate(array, sortIndex, sortOrder, byCol) {
|
|
31846
|
-
let _sortIndex = sortIndex
|
|
31847
|
-
let _sortOrder = sortOrder
|
|
31848
|
-
const _byCol = byCol
|
|
31944
|
+
let _sortIndex = sortIndex ?? NumberValueObject.create(1);
|
|
31945
|
+
let _sortOrder = sortOrder ?? NumberValueObject.create(1);
|
|
31946
|
+
const _byCol = byCol ?? BooleanValueObject.create(false);
|
|
31849
31947
|
if (_sortIndex.isNull()) _sortIndex = NumberValueObject.create(1);
|
|
31850
31948
|
if (_sortOrder.isNull()) _sortOrder = NumberValueObject.create(1);
|
|
31851
31949
|
if (_byCol.isArray()) {
|
|
@@ -32182,7 +32280,7 @@ var Take = class extends BaseFunction {
|
|
|
32182
32280
|
const arrayRowCount = array.isArray() ? array.getRowCount() : 1;
|
|
32183
32281
|
const arrayColumnCount = array.isArray() ? array.getColumnCount() : 1;
|
|
32184
32282
|
let _rows = rows;
|
|
32185
|
-
let _columns = columns
|
|
32283
|
+
let _columns = columns ?? NumberValueObject.create(arrayColumnCount);
|
|
32186
32284
|
if (rows.isNull()) _rows = NumberValueObject.create(arrayRowCount);
|
|
32187
32285
|
if (_columns.isNull()) _columns = NumberValueObject.create(arrayColumnCount);
|
|
32188
32286
|
const maxRowLength = Math.max(_rows.isArray() ? _rows.getRowCount() : 1, _columns.isArray() ? _columns.getRowCount() : 1);
|
|
@@ -32257,8 +32355,8 @@ var Tocol = class extends BaseFunction {
|
|
|
32257
32355
|
_defineProperty(this, "maxParams", 3);
|
|
32258
32356
|
}
|
|
32259
32357
|
calculate(array, ignore, scanByColumn) {
|
|
32260
|
-
const _ignore = ignore
|
|
32261
|
-
const _scanByColumn = scanByColumn
|
|
32358
|
+
const _ignore = ignore ?? NumberValueObject.create(0);
|
|
32359
|
+
const _scanByColumn = scanByColumn ?? BooleanValueObject.create(false);
|
|
32262
32360
|
const maxRowLength = Math.max(_ignore.isArray() ? _ignore.getRowCount() : 1, _scanByColumn.isArray() ? _scanByColumn.getRowCount() : 1);
|
|
32263
32361
|
const maxColumnLength = Math.max(_ignore.isArray() ? _ignore.getColumnCount() : 1, _scanByColumn.isArray() ? _scanByColumn.getColumnCount() : 1);
|
|
32264
32362
|
const ignoreArray = expandArrayValueObject(maxRowLength, maxColumnLength, _ignore, ErrorValueObject.create("#N/A"));
|
|
@@ -32333,8 +32431,8 @@ var Torow = class extends BaseFunction {
|
|
|
32333
32431
|
_defineProperty(this, "maxParams", 3);
|
|
32334
32432
|
}
|
|
32335
32433
|
calculate(array, ignore, scanByColumn) {
|
|
32336
|
-
const _ignore = ignore
|
|
32337
|
-
const _scanByColumn = scanByColumn
|
|
32434
|
+
const _ignore = ignore ?? NumberValueObject.create(0);
|
|
32435
|
+
const _scanByColumn = scanByColumn ?? BooleanValueObject.create(false);
|
|
32338
32436
|
const maxRowLength = Math.max(_ignore.isArray() ? _ignore.getRowCount() : 1, _scanByColumn.isArray() ? _scanByColumn.getRowCount() : 1);
|
|
32339
32437
|
const maxColumnLength = Math.max(_ignore.isArray() ? _ignore.getColumnCount() : 1, _scanByColumn.isArray() ? _scanByColumn.getColumnCount() : 1);
|
|
32340
32438
|
const ignoreArray = expandArrayValueObject(maxRowLength, maxColumnLength, _ignore, ErrorValueObject.create("#N/A"));
|
|
@@ -32429,8 +32527,8 @@ var Unique = class extends BaseFunction {
|
|
|
32429
32527
|
_defineProperty(this, "maxParams", 3);
|
|
32430
32528
|
}
|
|
32431
32529
|
calculate(array, byCol, exactlyOnce) {
|
|
32432
|
-
const _byCol = byCol
|
|
32433
|
-
const _exactlyOnce = exactlyOnce
|
|
32530
|
+
const _byCol = byCol ?? BooleanValueObject.create(false);
|
|
32531
|
+
const _exactlyOnce = exactlyOnce ?? BooleanValueObject.create(false);
|
|
32434
32532
|
const arrayRowCount = array.isArray() ? array.getRowCount() : 1;
|
|
32435
32533
|
const arrayColumnCount = array.isArray() ? array.getColumnCount() : 1;
|
|
32436
32534
|
const maxRowLength = Math.max(_byCol.isArray() ? _byCol.getRowCount() : 1, _exactlyOnce.isArray() ? _exactlyOnce.getRowCount() : 1);
|
|
@@ -32559,7 +32657,7 @@ var Vlookup = class extends BaseFunction {
|
|
|
32559
32657
|
if (!tableArray.isArray()) return ErrorValueObject.create("#VALUE!");
|
|
32560
32658
|
if (colIndexNum.isError()) return colIndexNum;
|
|
32561
32659
|
if (rangeLookup === null || rangeLookup === void 0 ? void 0 : rangeLookup.isError()) return rangeLookup;
|
|
32562
|
-
const _rangeLookup = rangeLookup
|
|
32660
|
+
const _rangeLookup = rangeLookup ?? BooleanValueObject.create(true);
|
|
32563
32661
|
if (isSingleValueObject(lookupValue) && isSingleValueObject(_rangeLookup) && colIndexNum.isArray()) return this._handleArrayColIndexNum(lookupValue, tableArray, colIndexNum, _rangeLookup);
|
|
32564
32662
|
return this._handleNonArrayColIndexNum(lookupValue, tableArray, colIndexNum, _rangeLookup);
|
|
32565
32663
|
}
|
|
@@ -32682,7 +32780,7 @@ var Wrapcols = class extends BaseFunction {
|
|
|
32682
32780
|
_defineProperty(this, "maxParams", 3);
|
|
32683
32781
|
}
|
|
32684
32782
|
calculate(vector, wrapCount, padWith) {
|
|
32685
|
-
let _padWith = padWith
|
|
32783
|
+
let _padWith = padWith ?? ErrorValueObject.create("#N/A");
|
|
32686
32784
|
if (_padWith.isNull()) _padWith = ErrorValueObject.create("#N/A");
|
|
32687
32785
|
const vectorRowCount = vector.isArray() ? vector.getRowCount() : 1;
|
|
32688
32786
|
const vectorColumnCount = vector.isArray() ? vector.getColumnCount() : 1;
|
|
@@ -32737,7 +32835,7 @@ var Wraprows = class extends BaseFunction {
|
|
|
32737
32835
|
_defineProperty(this, "maxParams", 3);
|
|
32738
32836
|
}
|
|
32739
32837
|
calculate(vector, wrapCount, padWith) {
|
|
32740
|
-
let _padWith = padWith
|
|
32838
|
+
let _padWith = padWith ?? ErrorValueObject.create("#N/A");
|
|
32741
32839
|
if (_padWith.isNull()) _padWith = ErrorValueObject.create("#N/A");
|
|
32742
32840
|
const vectorRowCount = vector.isArray() ? vector.getRowCount() : 1;
|
|
32743
32841
|
const vectorColumnCount = vector.isArray() ? vector.getColumnCount() : 1;
|
|
@@ -32795,13 +32893,13 @@ var Xlookup = class extends BaseFunction {
|
|
|
32795
32893
|
_defineProperty(this, "maxParams", 6);
|
|
32796
32894
|
}
|
|
32797
32895
|
calculate(lookupValue, lookupArray, returnArray, ifNotFound, matchMode, searchMode) {
|
|
32798
|
-
let _ifNotFound = ifNotFound
|
|
32896
|
+
let _ifNotFound = ifNotFound ?? ErrorValueObject.create("#N/A");
|
|
32799
32897
|
if (ifNotFound === null || ifNotFound === void 0 ? void 0 : ifNotFound.isNull()) _ifNotFound = ErrorValueObject.create("#N/A");
|
|
32800
|
-
let _matchMode = matchMode
|
|
32898
|
+
let _matchMode = matchMode ?? NumberValueObject.create(0);
|
|
32801
32899
|
if (matchMode === null || matchMode === void 0 ? void 0 : matchMode.isNull()) _matchMode = NumberValueObject.create(0);
|
|
32802
|
-
let _searchMode = searchMode
|
|
32900
|
+
let _searchMode = searchMode ?? NumberValueObject.create(1);
|
|
32803
32901
|
if (searchMode === null || searchMode === void 0 ? void 0 : searchMode.isNull()) _searchMode = NumberValueObject.create(1);
|
|
32804
|
-
const _lookupValue = this._legacyImplicitLookupValue(lookupValue);
|
|
32902
|
+
const _lookupValue = this.currentFormulaRowCount > 1 || this.currentFormulaColumnCount > 1 ? lookupValue : this._legacyImplicitLookupValue(lookupValue);
|
|
32805
32903
|
if (_lookupValue.isError()) return _lookupValue;
|
|
32806
32904
|
const rowCountLookup = lookupArray.isArray() ? lookupArray.getRowCount() : 1;
|
|
32807
32905
|
const columnCountLookup = lookupArray.isArray() ? lookupArray.getColumnCount() : 1;
|
|
@@ -33437,7 +33535,7 @@ var Base = class extends BaseFunction {
|
|
|
33437
33535
|
_defineProperty(this, "maxParams", 3);
|
|
33438
33536
|
}
|
|
33439
33537
|
calculate(number, radix, minLength) {
|
|
33440
|
-
const _minLength = minLength
|
|
33538
|
+
const _minLength = minLength ?? NumberValueObject.create(0);
|
|
33441
33539
|
if (number.isError()) return number;
|
|
33442
33540
|
if (radix.isError()) return radix;
|
|
33443
33541
|
if (_minLength.isError()) return _minLength;
|
|
@@ -33519,8 +33617,8 @@ var CeilingMath = class extends BaseFunction {
|
|
|
33519
33617
|
_defineProperty(this, "maxParams", 3);
|
|
33520
33618
|
}
|
|
33521
33619
|
calculate(number, significance, mode) {
|
|
33522
|
-
const _significance = significance
|
|
33523
|
-
const _mode = mode
|
|
33620
|
+
const _significance = significance ?? NumberValueObject.create(1);
|
|
33621
|
+
const _mode = mode ?? NumberValueObject.create(0);
|
|
33524
33622
|
if (number.isError()) return number;
|
|
33525
33623
|
if (_significance.isError()) return _significance;
|
|
33526
33624
|
if (_mode.isError()) return _mode;
|
|
@@ -33565,7 +33663,7 @@ var CeilingPrecise = class extends BaseFunction {
|
|
|
33565
33663
|
_defineProperty(this, "maxParams", 2);
|
|
33566
33664
|
}
|
|
33567
33665
|
calculate(number, significance) {
|
|
33568
|
-
const _significance = significance
|
|
33666
|
+
const _significance = significance ?? NumberValueObject.create(1);
|
|
33569
33667
|
if (number.isError()) return number;
|
|
33570
33668
|
if (_significance.isError()) return _significance;
|
|
33571
33669
|
const maxRowLength = Math.max(number.isArray() ? number.getRowCount() : 1, _significance.isArray() ? _significance.getRowCount() : 1);
|
|
@@ -33979,8 +34077,8 @@ var FloorMath = class extends BaseFunction {
|
|
|
33979
34077
|
_defineProperty(this, "maxParams", 3);
|
|
33980
34078
|
}
|
|
33981
34079
|
calculate(number, significance, mode) {
|
|
33982
|
-
const _significance = significance
|
|
33983
|
-
const _mode = mode
|
|
34080
|
+
const _significance = significance ?? NumberValueObject.create(1);
|
|
34081
|
+
const _mode = mode ?? NumberValueObject.create(0);
|
|
33984
34082
|
const maxRowLength = Math.max(number.isArray() ? number.getRowCount() : 1, _significance.isArray() ? _significance.getRowCount() : 1, _mode.isArray() ? _mode.getRowCount() : 1);
|
|
33985
34083
|
const maxColumnLength = Math.max(number.isArray() ? number.getColumnCount() : 1, _significance.isArray() ? _significance.getColumnCount() : 1, _mode.isArray() ? _mode.getColumnCount() : 1);
|
|
33986
34084
|
const numberArray = expandArrayValueObject(maxRowLength, maxColumnLength, number, ErrorValueObject.create("#N/A"));
|
|
@@ -34019,7 +34117,7 @@ var FloorPrecise = class extends BaseFunction {
|
|
|
34019
34117
|
_defineProperty(this, "maxParams", 2);
|
|
34020
34118
|
}
|
|
34021
34119
|
calculate(number, significance) {
|
|
34022
|
-
const _significance = significance
|
|
34120
|
+
const _significance = significance ?? NumberValueObject.create(1);
|
|
34023
34121
|
if (number.isError()) return number;
|
|
34024
34122
|
if (_significance.isError()) return _significance;
|
|
34025
34123
|
const maxRowLength = Math.max(number.isArray() ? number.getRowCount() : 1, _significance.isArray() ? _significance.getRowCount() : 1);
|
|
@@ -34219,7 +34317,7 @@ var Log = class extends BaseFunction {
|
|
|
34219
34317
|
_defineProperty(this, "maxParams", 2);
|
|
34220
34318
|
}
|
|
34221
34319
|
calculate(number, base) {
|
|
34222
|
-
const _base = base
|
|
34320
|
+
const _base = base ?? NumberValueObject.create(10);
|
|
34223
34321
|
if (number.isError()) return number;
|
|
34224
34322
|
if (_base.isError()) return _base;
|
|
34225
34323
|
const maxRowLength = Math.max(number.isArray() ? number.getRowCount() : 1, _base.isArray() ? _base.getRowCount() : 1);
|
|
@@ -34732,11 +34830,11 @@ var Randarray = class extends BaseFunction {
|
|
|
34732
34830
|
if (min === null || min === void 0 ? void 0 : min.isError()) return min;
|
|
34733
34831
|
if (max === null || max === void 0 ? void 0 : max.isError()) return max;
|
|
34734
34832
|
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
|
|
34833
|
+
const _rows = rows ?? NumberValueObject.create(1);
|
|
34834
|
+
const _columns = columns ?? NumberValueObject.create(1);
|
|
34835
|
+
const _min = min ?? NumberValueObject.create(0);
|
|
34836
|
+
const _max = max ?? NumberValueObject.create(1);
|
|
34837
|
+
const _wholeNumber = wholeNumber ?? NumberValueObject.create(0);
|
|
34740
34838
|
return this._calculateResult(_rows, _columns, _min, _max, _wholeNumber);
|
|
34741
34839
|
}
|
|
34742
34840
|
_calculateResult(rows, columns, min, max, wholeNumber) {
|
|
@@ -34883,7 +34981,7 @@ var Roman = class extends BaseFunction {
|
|
|
34883
34981
|
_defineProperty(this, "maxParams", 2);
|
|
34884
34982
|
}
|
|
34885
34983
|
calculate(number, form) {
|
|
34886
|
-
const _form = form
|
|
34984
|
+
const _form = form ?? NumberValueObject.create(0);
|
|
34887
34985
|
const maxRowLength = Math.max(number.isArray() ? number.getRowCount() : 1, _form.isArray() ? _form.getRowCount() : 1);
|
|
34888
34986
|
const maxColumnLength = Math.max(number.isArray() ? number.getColumnCount() : 1, _form.isArray() ? _form.getColumnCount() : 1);
|
|
34889
34987
|
const numberArray = expandArrayValueObject(maxRowLength, maxColumnLength, number, ErrorValueObject.create("#N/A"));
|
|
@@ -35090,9 +35188,9 @@ var Sequence = class extends BaseFunction {
|
|
|
35090
35188
|
}
|
|
35091
35189
|
calculate(rows, columns, start, step) {
|
|
35092
35190
|
let _rows = rows;
|
|
35093
|
-
let _columns = columns
|
|
35094
|
-
let _start = start
|
|
35095
|
-
let _step = step
|
|
35191
|
+
let _columns = columns ?? NumberValueObject.create(1);
|
|
35192
|
+
let _start = start ?? NumberValueObject.create(1);
|
|
35193
|
+
let _step = step ?? NumberValueObject.create(1);
|
|
35096
35194
|
if (_rows.isNull()) _rows = NumberValueObject.create(1);
|
|
35097
35195
|
if (_columns.isNull()) _columns = NumberValueObject.create(1);
|
|
35098
35196
|
if (_start.isNull()) _start = NumberValueObject.create(1);
|
|
@@ -35446,8 +35544,7 @@ var Subtotal = class extends BaseFunction {
|
|
|
35446
35544
|
multiAreaRefs.forEach((ref) => {
|
|
35447
35545
|
const rowAreas = ref.getAreas().map((row) => {
|
|
35448
35546
|
if (!row || row.length === 0) return ref;
|
|
35449
|
-
|
|
35450
|
-
return firstNonError !== null && firstNonError !== void 0 ? firstNonError : row[0];
|
|
35547
|
+
return row.find((a) => !a.isError()) ?? row[0];
|
|
35451
35548
|
});
|
|
35452
35549
|
multiAreaInfoMap.set(ref, {
|
|
35453
35550
|
ref,
|
|
@@ -35596,6 +35693,7 @@ var Sumproduct = class extends BaseFunction {
|
|
|
35596
35693
|
super(..._args);
|
|
35597
35694
|
_defineProperty(this, "minParams", 1);
|
|
35598
35695
|
_defineProperty(this, "maxParams", 255);
|
|
35696
|
+
_defineProperty(this, "lazyIfReferenceArrayArgumentIndexes", Array.from({ length: this.maxParams }, (_, index) => index));
|
|
35599
35697
|
}
|
|
35600
35698
|
calculate(array1, ...variants) {
|
|
35601
35699
|
if (array1.isError()) return array1;
|
|
@@ -35658,8 +35756,7 @@ var Sumproduct = class extends BaseFunction {
|
|
|
35658
35756
|
*/
|
|
35659
35757
|
_getVariantCell(variant, row, col) {
|
|
35660
35758
|
if (!variant.isArray()) return variant;
|
|
35661
|
-
|
|
35662
|
-
return cell !== null && cell !== void 0 ? cell : null;
|
|
35759
|
+
return variant.get(row, col) ?? null;
|
|
35663
35760
|
}
|
|
35664
35761
|
_initArray1(array1) {
|
|
35665
35762
|
let _array1 = array1;
|
|
@@ -35941,7 +36038,7 @@ var Trunc = class extends BaseFunction {
|
|
|
35941
36038
|
_defineProperty(this, "maxParams", 2);
|
|
35942
36039
|
}
|
|
35943
36040
|
calculate(number, numDigits) {
|
|
35944
|
-
const _numDigits = numDigits
|
|
36041
|
+
const _numDigits = numDigits ?? NumberValueObject.create(0);
|
|
35945
36042
|
const maxRowLength = Math.max(number.isArray() ? number.getRowCount() : 1, _numDigits.isArray() ? _numDigits.getRowCount() : 1);
|
|
35946
36043
|
const maxColumnLength = Math.max(number.isArray() ? number.getColumnCount() : 1, _numDigits.isArray() ? _numDigits.getColumnCount() : 1);
|
|
35947
36044
|
const numberArray = expandArrayValueObject(maxRowLength, maxColumnLength, number, ErrorValueObject.create("#N/A"));
|
|
@@ -36586,8 +36683,8 @@ var BetaDist = class extends BaseFunction {
|
|
|
36586
36683
|
_defineProperty(this, "maxParams", 6);
|
|
36587
36684
|
}
|
|
36588
36685
|
calculate(x, alpha, beta, cumulative, A, B) {
|
|
36589
|
-
let _A = A
|
|
36590
|
-
let _B = B
|
|
36686
|
+
let _A = A ?? NumberValueObject.create(0);
|
|
36687
|
+
let _B = B ?? NumberValueObject.create(1);
|
|
36591
36688
|
if (_A.isNull()) _A = NumberValueObject.create(0);
|
|
36592
36689
|
if (_B.isNull()) _B = NumberValueObject.create(1);
|
|
36593
36690
|
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 +36739,7 @@ var BinomDistRange = class extends BaseFunction {
|
|
|
36642
36739
|
_defineProperty(this, "maxParams", 4);
|
|
36643
36740
|
}
|
|
36644
36741
|
calculate(trials, probabilityS, numberS, numberS2) {
|
|
36645
|
-
let _numberS2 = numberS2
|
|
36742
|
+
let _numberS2 = numberS2 ?? numberS;
|
|
36646
36743
|
if (_numberS2.isNull()) _numberS2 = numberS;
|
|
36647
36744
|
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
36745
|
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 +37612,7 @@ var Growth = class extends BaseFunction {
|
|
|
37515
37612
|
if (knownXsValues instanceof ErrorValueObject) return knownXsValues;
|
|
37516
37613
|
const newXsValues = this._getNewXsValues(knownXsValues, newXs);
|
|
37517
37614
|
if (newXsValues instanceof ErrorValueObject) return newXsValues;
|
|
37518
|
-
let _constb = constb
|
|
37615
|
+
let _constb = constb ?? BooleanValueObject.create(true);
|
|
37519
37616
|
if (_constb.isArray()) _constb = _constb.get(0, 0);
|
|
37520
37617
|
if (_constb.isString()) _constb = _constb.convertToNumberObjectValue();
|
|
37521
37618
|
if (_constb.isError()) return _constb;
|
|
@@ -37795,9 +37892,9 @@ var Linest = class extends BaseFunction {
|
|
|
37795
37892
|
if (knownYsValues instanceof ErrorValueObject) return knownYsValues;
|
|
37796
37893
|
const knownXsValues = this._getKnownXsValues(knownYsValues, knownXs);
|
|
37797
37894
|
if (knownXsValues instanceof ErrorValueObject) return knownXsValues;
|
|
37798
|
-
let _constb = constb
|
|
37895
|
+
let _constb = constb ?? BooleanValueObject.create(true);
|
|
37799
37896
|
if (_constb.isArray()) _constb = _constb.get(0, 0);
|
|
37800
|
-
let _stats = stats
|
|
37897
|
+
let _stats = stats ?? BooleanValueObject.create(false);
|
|
37801
37898
|
if (_stats.isArray()) _stats = _stats.get(0, 0);
|
|
37802
37899
|
const { isError: _isError, errorObject: _errorObject, variants } = checkVariantsErrorIsStringToNumber(_constb, _stats);
|
|
37803
37900
|
if (_isError) return _errorObject;
|
|
@@ -37952,9 +38049,9 @@ var Logest = class extends BaseFunction {
|
|
|
37952
38049
|
if (knownYsValues instanceof ErrorValueObject) return knownYsValues;
|
|
37953
38050
|
const knownXsValues = this._getKnownXsValues(knownYsValues, knownXs);
|
|
37954
38051
|
if (knownXsValues instanceof ErrorValueObject) return knownXsValues;
|
|
37955
|
-
let _constb = constb
|
|
38052
|
+
let _constb = constb ?? BooleanValueObject.create(true);
|
|
37956
38053
|
if (_constb.isArray()) _constb = _constb.get(0, 0);
|
|
37957
|
-
let _stats = stats
|
|
38054
|
+
let _stats = stats ?? BooleanValueObject.create(false);
|
|
37958
38055
|
if (_stats.isArray()) _stats = _stats.get(0, 0);
|
|
37959
38056
|
const { isError: _isError, errorObject: _errorObject, variants } = checkVariantsErrorIsStringToNumber(_constb, _stats);
|
|
37960
38057
|
if (_isError) return _errorObject;
|
|
@@ -38294,6 +38391,7 @@ var Median = class extends BaseFunction {
|
|
|
38294
38391
|
super(..._args);
|
|
38295
38392
|
_defineProperty(this, "minParams", 1);
|
|
38296
38393
|
_defineProperty(this, "maxParams", 255);
|
|
38394
|
+
_defineProperty(this, "lazyIfReferenceArrayArgumentIndexes", Array.from({ length: this.maxParams }, (_, index) => index));
|
|
38297
38395
|
}
|
|
38298
38396
|
calculate(...variants) {
|
|
38299
38397
|
const values = [];
|
|
@@ -38624,6 +38722,7 @@ var PercentileExc = class extends BaseFunction {
|
|
|
38624
38722
|
super(..._args);
|
|
38625
38723
|
_defineProperty(this, "minParams", 2);
|
|
38626
38724
|
_defineProperty(this, "maxParams", 2);
|
|
38725
|
+
_defineProperty(this, "lazyIfReferenceArrayArgumentIndexes", [0]);
|
|
38627
38726
|
}
|
|
38628
38727
|
calculate(array, k) {
|
|
38629
38728
|
const arrayValues = getArrayValuesByAggregateIgnoreOptions(array);
|
|
@@ -38653,7 +38752,7 @@ var PercentrankExc = class extends BaseFunction {
|
|
|
38653
38752
|
}
|
|
38654
38753
|
calculate(array, x, significance) {
|
|
38655
38754
|
const arrayValues = this._getValues(array);
|
|
38656
|
-
let _significance = significance
|
|
38755
|
+
let _significance = significance ?? NumberValueObject.create(3);
|
|
38657
38756
|
if (_significance.isNull()) _significance = NumberValueObject.create(3);
|
|
38658
38757
|
const maxRowLength = Math.max(x.isArray() ? x.getRowCount() : 1, _significance.isArray() ? _significance.getRowCount() : 1);
|
|
38659
38758
|
const maxColumnLength = Math.max(x.isArray() ? x.getColumnCount() : 1, _significance.isArray() ? _significance.getColumnCount() : 1);
|
|
@@ -38816,7 +38915,7 @@ var Prob = class extends BaseFunction {
|
|
|
38816
38915
|
}
|
|
38817
38916
|
calculate(xRange, probRange, lowerLimit, upperLimit) {
|
|
38818
38917
|
const { isError, errorObject, xRangeValues, probRangeValues } = this._handleXRangeAndProbRange(xRange, probRange);
|
|
38819
|
-
let _upperLimit = upperLimit
|
|
38918
|
+
let _upperLimit = upperLimit ?? lowerLimit;
|
|
38820
38919
|
if (upperLimit === null || upperLimit === void 0 ? void 0 : upperLimit.isNull()) _upperLimit = lowerLimit;
|
|
38821
38920
|
const maxRowLength = Math.max(lowerLimit.isArray() ? lowerLimit.getRowCount() : 1, _upperLimit.isArray() ? _upperLimit.getRowCount() : 1);
|
|
38822
38921
|
const maxColumnLength = Math.max(lowerLimit.isArray() ? lowerLimit.getColumnCount() : 1, _upperLimit.isArray() ? _upperLimit.getColumnCount() : 1);
|
|
@@ -38941,12 +39040,13 @@ var RankAvg = class extends BaseFunction {
|
|
|
38941
39040
|
_defineProperty(this, "minParams", 2);
|
|
38942
39041
|
_defineProperty(this, "maxParams", 3);
|
|
38943
39042
|
_defineProperty(this, "needsReferenceObject", true);
|
|
39043
|
+
_defineProperty(this, "lazyIfReferenceArrayArgumentIndexes", [1]);
|
|
38944
39044
|
}
|
|
38945
39045
|
calculate(number, ref, order) {
|
|
38946
39046
|
let _number = number;
|
|
38947
39047
|
if (_number.isReferenceObject()) _number = _number.toArrayValueObject();
|
|
38948
39048
|
const { refHasError, refErrorObject, refNumbers } = this._checkRefReferenceObject(ref);
|
|
38949
|
-
let _order = order
|
|
39049
|
+
let _order = order ?? NumberValueObject.create(0);
|
|
38950
39050
|
if (_order.isReferenceObject()) _order = _order.toArrayValueObject();
|
|
38951
39051
|
const maxRowLength = Math.max(_number.isArray() ? _number.getRowCount() : 1, _order.isArray() ? _order.getRowCount() : 1);
|
|
38952
39052
|
const maxColumnLength = Math.max(_number.isArray() ? _number.getColumnCount() : 1, _order.isArray() ? _order.getColumnCount() : 1);
|
|
@@ -39015,12 +39115,13 @@ var RankEq = class extends BaseFunction {
|
|
|
39015
39115
|
_defineProperty(this, "minParams", 2);
|
|
39016
39116
|
_defineProperty(this, "maxParams", 3);
|
|
39017
39117
|
_defineProperty(this, "needsReferenceObject", true);
|
|
39118
|
+
_defineProperty(this, "lazyIfReferenceArrayArgumentIndexes", [1]);
|
|
39018
39119
|
}
|
|
39019
39120
|
calculate(number, ref, order) {
|
|
39020
39121
|
let _number = number;
|
|
39021
39122
|
if (_number.isReferenceObject()) _number = _number.toArrayValueObject();
|
|
39022
39123
|
const { refHasError, refErrorObject, refNumbers } = this._checkRefReferenceObject(ref);
|
|
39023
|
-
let _order = order
|
|
39124
|
+
let _order = order ?? NumberValueObject.create(0);
|
|
39024
39125
|
if (_order.isReferenceObject()) _order = _order.toArrayValueObject();
|
|
39025
39126
|
const maxRowLength = Math.max(_number.isArray() ? _number.getRowCount() : 1, _order.isArray() ? _order.getRowCount() : 1);
|
|
39026
39127
|
const maxColumnLength = Math.max(_number.isArray() ? _number.getColumnCount() : 1, _order.isArray() ? _order.getColumnCount() : 1);
|
|
@@ -39579,7 +39680,7 @@ var Trend = class extends BaseFunction {
|
|
|
39579
39680
|
if (knownXsValues instanceof ErrorValueObject) return knownXsValues;
|
|
39580
39681
|
const newXsValues = this._getNewXsValues(knownXsValues, newXs);
|
|
39581
39682
|
if (newXsValues instanceof ErrorValueObject) return newXsValues;
|
|
39582
|
-
let _constb = constb
|
|
39683
|
+
let _constb = constb ?? BooleanValueObject.create(true);
|
|
39583
39684
|
if (_constb.isArray()) _constb = _constb.get(0, 0);
|
|
39584
39685
|
if (_constb.isString()) _constb = _constb.convertToNumberObjectValue();
|
|
39585
39686
|
if (_constb.isError()) return _constb;
|
|
@@ -39848,7 +39949,7 @@ var Arraytotext = class extends BaseFunction {
|
|
|
39848
39949
|
_defineProperty(this, "maxParams", 2);
|
|
39849
39950
|
}
|
|
39850
39951
|
calculate(array, format) {
|
|
39851
|
-
let _format = format
|
|
39952
|
+
let _format = format ?? NumberValueObject.create(0);
|
|
39852
39953
|
if (format === null || format === void 0 ? void 0 : format.isNull()) _format = NumberValueObject.create(0);
|
|
39853
39954
|
if (_format.isArray()) {
|
|
39854
39955
|
const resultArray = _format.mapValue((formatObject) => this._handleSingleObject(array, formatObject));
|
|
@@ -40158,12 +40259,11 @@ var Concatenate = class extends BaseFunction {
|
|
|
40158
40259
|
return arrayValue.getUnitId() !== "" && arrayValue.getSheetId() !== "" && arrayValue.getCurrentRow() >= 0 && arrayValue.getCurrentColumn() >= 0;
|
|
40159
40260
|
});
|
|
40160
40261
|
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
40262
|
const resultValueObject = result && result.get(rowIndex, columnIndex);
|
|
40163
40263
|
if (resultValueObject === null || resultValueObject === void 0 ? void 0 : resultValueObject.isError()) return resultValueObject;
|
|
40164
40264
|
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((
|
|
40265
|
+
const resultValueObjectString = (resultValueObject === null || resultValueObject === void 0 ? void 0 : resultValueObject.isNull()) ? "" : formatValueForFormulaText((resultValueObject === null || resultValueObject === void 0 ? void 0 : resultValueObject.getValue()) ?? null);
|
|
40266
|
+
const textValueObjectString = (textValueObject === null || textValueObject === void 0 ? void 0 : textValueObject.isNull()) ? "" : formatValueForFormulaText((textValueObject === null || textValueObject === void 0 ? void 0 : textValueObject.getValue()) ?? null);
|
|
40167
40267
|
return StringValueObject.create(`${resultValueObjectString}${textValueObjectString}`);
|
|
40168
40268
|
});
|
|
40169
40269
|
if (!result) return ErrorValueObject.create("#VALUE!");
|
|
@@ -40219,7 +40319,7 @@ var Dollar = class extends BaseFunction {
|
|
|
40219
40319
|
_defineProperty(this, "needsLocale", true);
|
|
40220
40320
|
}
|
|
40221
40321
|
calculate(number, decimals) {
|
|
40222
|
-
let _decimals = decimals
|
|
40322
|
+
let _decimals = decimals ?? NumberValueObject.create(2);
|
|
40223
40323
|
if (_decimals.isNull()) _decimals = NumberValueObject.create(2);
|
|
40224
40324
|
const maxRowLength = Math.max(number.isArray() ? number.getRowCount() : 1, _decimals.isArray() ? _decimals.getRowCount() : 1);
|
|
40225
40325
|
const maxColumnLength = Math.max(number.isArray() ? number.getColumnCount() : 1, _decimals.isArray() ? _decimals.getColumnCount() : 1);
|
|
@@ -40318,7 +40418,7 @@ var Find = class extends BaseFunction {
|
|
|
40318
40418
|
_defineProperty(this, "maxParams", 3);
|
|
40319
40419
|
}
|
|
40320
40420
|
calculate(findText, withinText, startNum) {
|
|
40321
|
-
const _startNum = startNum
|
|
40421
|
+
const _startNum = startNum ?? NumberValueObject.create(1);
|
|
40322
40422
|
const maxRowLength = Math.max(findText.isArray() ? findText.getRowCount() : 1, withinText.isArray() ? withinText.getRowCount() : 1, _startNum.isArray() ? _startNum.getRowCount() : 1);
|
|
40323
40423
|
const maxColumnLength = Math.max(findText.isArray() ? findText.getColumnCount() : 1, withinText.isArray() ? withinText.getColumnCount() : 1, _startNum.isArray() ? _startNum.getColumnCount() : 1);
|
|
40324
40424
|
const findTextArray = expandArrayValueObject(maxRowLength, maxColumnLength, findText, ErrorValueObject.create("#N/A"));
|
|
@@ -40412,7 +40512,7 @@ var Findb = class extends BaseFunction {
|
|
|
40412
40512
|
_defineProperty(this, "maxParams", 3);
|
|
40413
40513
|
}
|
|
40414
40514
|
calculate(findText, withinText, startNum) {
|
|
40415
|
-
const _startNum = startNum
|
|
40515
|
+
const _startNum = startNum ?? NumberValueObject.create(1);
|
|
40416
40516
|
const maxRowLength = Math.max(findText.isArray() ? findText.getRowCount() : 1, withinText.isArray() ? withinText.getRowCount() : 1, _startNum.isArray() ? _startNum.getRowCount() : 1);
|
|
40417
40517
|
const maxColumnLength = Math.max(findText.isArray() ? findText.getColumnCount() : 1, withinText.isArray() ? withinText.getColumnCount() : 1, _startNum.isArray() ? _startNum.getColumnCount() : 1);
|
|
40418
40518
|
const findTextArray = expandArrayValueObject(maxRowLength, maxColumnLength, findText, ErrorValueObject.create("#N/A"));
|
|
@@ -40454,9 +40554,9 @@ var Fixed = class extends BaseFunction {
|
|
|
40454
40554
|
_defineProperty(this, "maxParams", 3);
|
|
40455
40555
|
}
|
|
40456
40556
|
calculate(number, decimals, noCommas) {
|
|
40457
|
-
let _decimals = decimals
|
|
40557
|
+
let _decimals = decimals ?? NumberValueObject.create(2);
|
|
40458
40558
|
if (_decimals.isNull()) _decimals = NumberValueObject.create(2);
|
|
40459
|
-
let _noCommas = noCommas
|
|
40559
|
+
let _noCommas = noCommas ?? BooleanValueObject.create(false);
|
|
40460
40560
|
if (_noCommas.isNull()) _noCommas = BooleanValueObject.create(false);
|
|
40461
40561
|
const maxRowLength = Math.max(number.isArray() ? number.getRowCount() : 1, _decimals.isArray() ? _decimals.getRowCount() : 1, _noCommas.isArray() ? _noCommas.getRowCount() : 1);
|
|
40462
40562
|
const maxColumnLength = Math.max(number.isArray() ? number.getColumnCount() : 1, _decimals.isArray() ? _decimals.getColumnCount() : 1, _noCommas.isArray() ? _noCommas.getColumnCount() : 1);
|
|
@@ -40503,7 +40603,7 @@ var Left = class extends BaseFunction {
|
|
|
40503
40603
|
_defineProperty(this, "maxParams", 2);
|
|
40504
40604
|
}
|
|
40505
40605
|
calculate(text, numChars) {
|
|
40506
|
-
const _numChars = numChars
|
|
40606
|
+
const _numChars = numChars ?? NumberValueObject.create(1);
|
|
40507
40607
|
const maxRowLength = Math.max(text.isArray() ? text.getRowCount() : 1, _numChars.isArray() ? _numChars.getRowCount() : 1);
|
|
40508
40608
|
const maxColumnLength = Math.max(text.isArray() ? text.getColumnCount() : 1, _numChars.isArray() ? _numChars.getColumnCount() : 1);
|
|
40509
40609
|
const textArray = expandArrayValueObject(maxRowLength, maxColumnLength, text, ErrorValueObject.create("#N/A"));
|
|
@@ -40540,7 +40640,7 @@ var Leftb = class extends BaseFunction {
|
|
|
40540
40640
|
_defineProperty(this, "maxParams", 2);
|
|
40541
40641
|
}
|
|
40542
40642
|
calculate(text, numBytes) {
|
|
40543
|
-
const _numBytes = numBytes
|
|
40643
|
+
const _numBytes = numBytes ?? NumberValueObject.create(1);
|
|
40544
40644
|
const maxRowLength = Math.max(text.isArray() ? text.getRowCount() : 1, _numBytes.isArray() ? _numBytes.getRowCount() : 1);
|
|
40545
40645
|
const maxColumnLength = Math.max(text.isArray() ? text.getColumnCount() : 1, _numBytes.isArray() ? _numBytes.getColumnCount() : 1);
|
|
40546
40646
|
const textArray = expandArrayValueObject(maxRowLength, maxColumnLength, text, NullValueObject.create());
|
|
@@ -40855,7 +40955,7 @@ var Numbervalue = class extends BaseFunction {
|
|
|
40855
40955
|
return true;
|
|
40856
40956
|
}
|
|
40857
40957
|
calculate(text, decimalSeparator, groupSeparator) {
|
|
40858
|
-
const _decimalSeparator = decimalSeparator
|
|
40958
|
+
const _decimalSeparator = decimalSeparator ?? StringValueObject.create(".");
|
|
40859
40959
|
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
40960
|
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
40961
|
const textArray = expandArrayValueObject(maxRowLength, maxColumnLength, text, ErrorValueObject.create("#N/A"));
|
|
@@ -41386,8 +41486,7 @@ function isValidRegExp(regExpString) {
|
|
|
41386
41486
|
return !(/\(\?<=.*?\)/g.test(regExpString) && !/\[.*?(\?<=.*?)\]/g.test(regExpString) || /\(\?<!.*?\)/g.test(regExpString) && !/\[.*?(\?<!.*?)\]/g.test(regExpString));
|
|
41387
41487
|
}
|
|
41388
41488
|
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;
|
|
41489
|
+
const limit = (options === null || options === void 0 ? void 0 : options.limit) ?? 25;
|
|
41391
41490
|
let str;
|
|
41392
41491
|
if (Object.prototype.toString.call(regExp) === "[object RegExp]") str = regExp.source;
|
|
41393
41492
|
else if (regExp && typeof regExp !== "string") str = `${regExp}`;
|
|
@@ -41667,7 +41766,7 @@ var Right = class extends BaseFunction {
|
|
|
41667
41766
|
_defineProperty(this, "maxParams", 2);
|
|
41668
41767
|
}
|
|
41669
41768
|
calculate(text, numChars) {
|
|
41670
|
-
const _numChars = numChars
|
|
41769
|
+
const _numChars = numChars ?? NumberValueObject.create(1);
|
|
41671
41770
|
const maxRowLength = Math.max(text.isArray() ? text.getRowCount() : 1, _numChars.isArray() ? _numChars.getRowCount() : 1);
|
|
41672
41771
|
const maxColumnLength = Math.max(text.isArray() ? text.getColumnCount() : 1, _numChars.isArray() ? _numChars.getColumnCount() : 1);
|
|
41673
41772
|
const textArray = expandArrayValueObject(maxRowLength, maxColumnLength, text, ErrorValueObject.create("#N/A"));
|
|
@@ -41704,7 +41803,7 @@ var Rightb = class extends BaseFunction {
|
|
|
41704
41803
|
_defineProperty(this, "maxParams", 2);
|
|
41705
41804
|
}
|
|
41706
41805
|
calculate(text, numBytes) {
|
|
41707
|
-
const _numBytes = numBytes
|
|
41806
|
+
const _numBytes = numBytes ?? NumberValueObject.create(1);
|
|
41708
41807
|
const maxRowLength = Math.max(text.isArray() ? text.getRowCount() : 1, _numBytes.isArray() ? _numBytes.getRowCount() : 1);
|
|
41709
41808
|
const maxColumnLength = Math.max(text.isArray() ? text.getColumnCount() : 1, _numBytes.isArray() ? _numBytes.getColumnCount() : 1);
|
|
41710
41809
|
const textArray = expandArrayValueObject(maxRowLength, maxColumnLength, text, ErrorValueObject.create("#N/A"));
|
|
@@ -41747,7 +41846,7 @@ var Search = class extends BaseFunction {
|
|
|
41747
41846
|
_defineProperty(this, "maxParams", 3);
|
|
41748
41847
|
}
|
|
41749
41848
|
calculate(findText, withinText, startNum) {
|
|
41750
|
-
const _startNum = startNum
|
|
41849
|
+
const _startNum = startNum ?? NumberValueObject.create(1);
|
|
41751
41850
|
const maxRowLength = Math.max(findText.isArray() ? findText.getRowCount() : 1, withinText.isArray() ? withinText.getRowCount() : 1, _startNum.isArray() ? _startNum.getRowCount() : 1);
|
|
41752
41851
|
const maxColumnLength = Math.max(findText.isArray() ? findText.getColumnCount() : 1, withinText.isArray() ? withinText.getColumnCount() : 1, _startNum.isArray() ? _startNum.getColumnCount() : 1);
|
|
41753
41852
|
const findTextArray = expandArrayValueObject(maxRowLength, maxColumnLength, findText, ErrorValueObject.create("#N/A"));
|
|
@@ -41788,7 +41887,7 @@ var Searchb = class extends BaseFunction {
|
|
|
41788
41887
|
_defineProperty(this, "maxParams", 3);
|
|
41789
41888
|
}
|
|
41790
41889
|
calculate(findText, withinText, startNum) {
|
|
41791
|
-
const _startNum = startNum
|
|
41890
|
+
const _startNum = startNum ?? NumberValueObject.create(1);
|
|
41792
41891
|
const maxRowLength = Math.max(findText.isArray() ? findText.getRowCount() : 1, withinText.isArray() ? withinText.getRowCount() : 1, _startNum.isArray() ? _startNum.getRowCount() : 1);
|
|
41793
41892
|
const maxColumnLength = Math.max(findText.isArray() ? findText.getColumnCount() : 1, withinText.isArray() ? withinText.getColumnCount() : 1, _startNum.isArray() ? _startNum.getColumnCount() : 1);
|
|
41794
41893
|
const findTextArray = expandArrayValueObject(maxRowLength, maxColumnLength, findText, ErrorValueObject.create("#N/A"));
|
|
@@ -41961,15 +42060,15 @@ var Textafter = class extends BaseFunction {
|
|
|
41961
42060
|
}
|
|
41962
42061
|
calculate(text, delimiter, instanceNum, matchMode, matchEnd, ifNotFound) {
|
|
41963
42062
|
let instanceNumIsNull = false;
|
|
41964
|
-
let _instanceNum = instanceNum
|
|
42063
|
+
let _instanceNum = instanceNum ?? NumberValueObject.create(1);
|
|
41965
42064
|
if (_instanceNum.isNull()) {
|
|
41966
42065
|
instanceNumIsNull = true;
|
|
41967
42066
|
_instanceNum = NumberValueObject.create(1);
|
|
41968
42067
|
}
|
|
41969
42068
|
const onlyThreeVariant = !matchMode;
|
|
41970
|
-
const _matchMode = matchMode
|
|
41971
|
-
const _matchEnd = matchEnd
|
|
41972
|
-
const _ifNotFound = ifNotFound
|
|
42069
|
+
const _matchMode = matchMode ?? NumberValueObject.create(0);
|
|
42070
|
+
const _matchEnd = matchEnd ?? NumberValueObject.create(0);
|
|
42071
|
+
const _ifNotFound = ifNotFound ?? ErrorValueObject.create("#N/A");
|
|
41973
42072
|
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
42073
|
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
42074
|
const textArray = expandArrayValueObject(maxRowLength, maxColumnLength, text, ErrorValueObject.create("#N/A"));
|
|
@@ -42104,15 +42203,15 @@ var Textbefore = class extends BaseFunction {
|
|
|
42104
42203
|
}
|
|
42105
42204
|
calculate(text, delimiter, instanceNum, matchMode, matchEnd, ifNotFound) {
|
|
42106
42205
|
let instanceNumIsNull = false;
|
|
42107
|
-
let _instanceNum = instanceNum
|
|
42206
|
+
let _instanceNum = instanceNum ?? NumberValueObject.create(1);
|
|
42108
42207
|
if (_instanceNum.isNull()) {
|
|
42109
42208
|
instanceNumIsNull = true;
|
|
42110
42209
|
_instanceNum = NumberValueObject.create(1);
|
|
42111
42210
|
}
|
|
42112
42211
|
const onlyThreeVariant = !matchMode;
|
|
42113
|
-
const _matchMode = matchMode
|
|
42114
|
-
const _matchEnd = matchEnd
|
|
42115
|
-
const _ifNotFound = ifNotFound
|
|
42212
|
+
const _matchMode = matchMode ?? NumberValueObject.create(0);
|
|
42213
|
+
const _matchEnd = matchEnd ?? NumberValueObject.create(0);
|
|
42214
|
+
const _ifNotFound = ifNotFound ?? ErrorValueObject.create("#N/A");
|
|
42116
42215
|
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
42216
|
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
42217
|
const textArray = expandArrayValueObject(maxRowLength, maxColumnLength, text, ErrorValueObject.create("#N/A"));
|
|
@@ -42243,6 +42342,7 @@ var Textjoin = class extends BaseFunction {
|
|
|
42243
42342
|
super(..._args);
|
|
42244
42343
|
_defineProperty(this, "minParams", 3);
|
|
42245
42344
|
_defineProperty(this, "maxParams", 255);
|
|
42345
|
+
_defineProperty(this, "lazyIfReferenceArrayArgumentIndexes", Array.from({ length: this.maxParams - 2 }, (_, index) => index + 2));
|
|
42246
42346
|
}
|
|
42247
42347
|
calculate(delimiter, ignoreEmpty, ...variants) {
|
|
42248
42348
|
const delimiterValues = this._getDelimiterValues(delimiter);
|
|
@@ -42320,10 +42420,10 @@ var Textsplit = class extends BaseFunction {
|
|
|
42320
42420
|
_defineProperty(this, "maxParams", 6);
|
|
42321
42421
|
}
|
|
42322
42422
|
calculate(text, colDelimiter, rowDelimiter, ignoreEmpty, matchMode, padWith) {
|
|
42323
|
-
let _rowDelimiter = rowDelimiter
|
|
42324
|
-
const _ignoreEmpty = ignoreEmpty
|
|
42325
|
-
const _matchMode = matchMode
|
|
42326
|
-
const _padWith = padWith
|
|
42423
|
+
let _rowDelimiter = rowDelimiter ?? StringValueObject.create("\\s");
|
|
42424
|
+
const _ignoreEmpty = ignoreEmpty ?? NumberValueObject.create(0);
|
|
42425
|
+
const _matchMode = matchMode ?? NumberValueObject.create(0);
|
|
42426
|
+
const _padWith = padWith ?? StringValueObject.create("#N/A");
|
|
42327
42427
|
const { _variant, values: rowDelimiterValue } = this._getStringValues(_rowDelimiter, false);
|
|
42328
42428
|
_rowDelimiter = _variant;
|
|
42329
42429
|
const allowBlankColDelimiter = rowDelimiter != null && !rowDelimiter.isNull() && !_rowDelimiter.isError() && rowDelimiterValue.length > 0;
|
|
@@ -42599,7 +42699,7 @@ var Valuetotext = class extends BaseFunction {
|
|
|
42599
42699
|
_defineProperty(this, "maxParams", 2);
|
|
42600
42700
|
}
|
|
42601
42701
|
calculate(value, format) {
|
|
42602
|
-
const _format = format
|
|
42702
|
+
const _format = format ?? NumberValueObject.create(0);
|
|
42603
42703
|
const maxRowLength = Math.max(value.isArray() ? value.getRowCount() : 1, _format.isArray() ? _format.getRowCount() : 1);
|
|
42604
42704
|
const maxColumnLength = Math.max(value.isArray() ? value.getColumnCount() : 1, _format.isArray() ? _format.getColumnCount() : 1);
|
|
42605
42705
|
const valueArray = expandArrayValueObject(maxRowLength, maxColumnLength, value, ErrorValueObject.create("#N/A"));
|
|
@@ -42877,7 +42977,7 @@ function getObjectValue(result, isUseStrip = false) {
|
|
|
42877
42977
|
//#endregion
|
|
42878
42978
|
//#region package.json
|
|
42879
42979
|
var name = "@univerjs/engine-formula";
|
|
42880
|
-
var version = "1.0.0-
|
|
42980
|
+
var version = "1.0.0-beta.0";
|
|
42881
42981
|
|
|
42882
42982
|
//#endregion
|
|
42883
42983
|
//#region src/services/global-computing-status.service.ts
|
|
@@ -43069,14 +43169,13 @@ function createEmptyDirtyData() {
|
|
|
43069
43169
|
};
|
|
43070
43170
|
}
|
|
43071
43171
|
function mergeDirtyData(left, right) {
|
|
43072
|
-
var _right$dirtyRanges, _left$dirtySuperTable;
|
|
43073
43172
|
const dirtyRanges = [...left.dirtyRanges];
|
|
43074
|
-
mergeDirtyRanges(dirtyRanges,
|
|
43173
|
+
mergeDirtyRanges(dirtyRanges, right.dirtyRanges ?? []);
|
|
43075
43174
|
return {
|
|
43076
43175
|
dirtyRanges,
|
|
43077
43176
|
dirtyNameMap: mergeDirtyUnitStringMap(left.dirtyNameMap, right.dirtyNameMap),
|
|
43078
43177
|
dirtyDefinedNameMap: mergeDirtyUnitStringMap(left.dirtyDefinedNameMap, right.dirtyDefinedNameMap),
|
|
43079
|
-
dirtySuperTableMap: mergeDirtyUnitStringMap(
|
|
43178
|
+
dirtySuperTableMap: mergeDirtyUnitStringMap(left.dirtySuperTableMap ?? {}, right.dirtySuperTableMap),
|
|
43080
43179
|
dirtyUnitFeatureMap: mergeDirtyUnitNestedMap(left.dirtyUnitFeatureMap, right.dirtyUnitFeatureMap),
|
|
43081
43180
|
dirtyUnitOtherFormulaMap: mergeDirtyUnitNestedMap(left.dirtyUnitOtherFormulaMap, right.dirtyUnitOtherFormulaMap),
|
|
43082
43181
|
clearDependencyTreeCache: mergeDirtyUnitStringMap(left.clearDependencyTreeCache, right.clearDependencyTreeCache),
|
|
@@ -43106,7 +43205,7 @@ function getDirtyRangeKey({ unitId, sheetId, range }) {
|
|
|
43106
43205
|
}
|
|
43107
43206
|
function mergeDirtyUnitStringMap(left, right) {
|
|
43108
43207
|
const result = { ...left };
|
|
43109
|
-
Object.entries(right
|
|
43208
|
+
Object.entries(right ?? {}).forEach(([unitId, values]) => {
|
|
43110
43209
|
result[unitId] = {
|
|
43111
43210
|
...result[unitId],
|
|
43112
43211
|
...values
|
|
@@ -43116,9 +43215,9 @@ function mergeDirtyUnitStringMap(left, right) {
|
|
|
43116
43215
|
}
|
|
43117
43216
|
function mergeDirtyUnitNestedMap(left, right) {
|
|
43118
43217
|
const result = { ...left };
|
|
43119
|
-
Object.entries(right
|
|
43218
|
+
Object.entries(right ?? {}).forEach(([unitId, sheets]) => {
|
|
43120
43219
|
const unitResult = { ...result[unitId] };
|
|
43121
|
-
Object.entries(sheets
|
|
43220
|
+
Object.entries(sheets ?? {}).forEach(([sheetId, values]) => {
|
|
43122
43221
|
unitResult[sheetId] = {
|
|
43123
43222
|
...unitResult[sheetId],
|
|
43124
43223
|
...values
|
|
@@ -43149,7 +43248,7 @@ function dirtyDataIntersects(left, right) {
|
|
|
43149
43248
|
].some(([leftMap, rightMap]) => hasSameNestedKey(leftMap, rightMap));
|
|
43150
43249
|
}
|
|
43151
43250
|
function clearedSheetIntersects(cleared, dirty) {
|
|
43152
|
-
return Object.entries(cleared.clearDependencyTreeCache).some(([unitId, sheets]) => Object.keys(sheets
|
|
43251
|
+
return Object.entries(cleared.clearDependencyTreeCache).some(([unitId, sheets]) => Object.keys(sheets ?? {}).some((sheetId) => {
|
|
43153
43252
|
var _dirty$dirtyNameMap$u, _dirty$dirtyUnitFeatu, _dirty$dirtyUnitOther;
|
|
43154
43253
|
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
43254
|
}));
|
|
@@ -43262,9 +43361,8 @@ let FormulaController = class FormulaController extends Disposable {
|
|
|
43262
43361
|
});
|
|
43263
43362
|
}
|
|
43264
43363
|
_registerFunctions() {
|
|
43265
|
-
var _config$function;
|
|
43266
43364
|
const config = this._configService.getConfig(ENGINE_FORMULA_PLUGIN_CONFIG_KEY);
|
|
43267
|
-
const functions = ALL_IMPLEMENTED_FUNCTIONS.concat((
|
|
43365
|
+
const functions = ALL_IMPLEMENTED_FUNCTIONS.concat((config === null || config === void 0 ? void 0 : config.function) ?? []).map((registerObject) => {
|
|
43268
43366
|
const Func = registerObject[0];
|
|
43269
43367
|
const name = registerObject[1];
|
|
43270
43368
|
return new Func(name);
|
|
@@ -56463,7 +56561,7 @@ let RegisterFunctionService = class RegisterFunctionService extends Disposable {
|
|
|
56463
56561
|
const { locales, description, calculate } = params;
|
|
56464
56562
|
if (locales) this._localeService.load(locales);
|
|
56465
56563
|
const disposables = new DisposableCollection();
|
|
56466
|
-
const descriptions = description
|
|
56564
|
+
const descriptions = description ?? calculate.map(([_func, functionName, functionIntroduction]) => {
|
|
56467
56565
|
return {
|
|
56468
56566
|
functionName,
|
|
56469
56567
|
functionType: 15,
|