@odoo/o-spreadsheet 16.1.28 → 16.1.33

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.
@@ -305,15 +305,76 @@ for (let font of fontSizes) {
305
305
  // -----------------------------------------------------------------------------
306
306
  // Date Type
307
307
  // -----------------------------------------------------------------------------
308
+ /**
309
+ * A DateTime object that can be used to manipulate spreadsheet dates.
310
+ * Conceptually, a spreadsheet date is simply a number with a date format,
311
+ * and it is timezone-agnostic.
312
+ * This DateTime object consistently uses UTC time to represent a naive date and time.
313
+ */
314
+ class DateTime {
315
+ constructor(year, month, day, hours = 0, minutes = 0, seconds = 0) {
316
+ this.jsDate = new Date(Date.UTC(year, month, day, hours, minutes, seconds, 0));
317
+ }
318
+ static fromTimestamp(timestamp) {
319
+ const date = new Date(timestamp);
320
+ return new DateTime(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate(), date.getUTCHours(), date.getUTCMinutes(), date.getUTCSeconds());
321
+ }
322
+ static now() {
323
+ const now = new Date();
324
+ return new DateTime(now.getFullYear(), now.getMonth(), now.getDate(), now.getHours(), now.getMinutes(), now.getSeconds());
325
+ }
326
+ toString() {
327
+ return this.jsDate.toString();
328
+ }
329
+ getTime() {
330
+ return this.jsDate.getTime();
331
+ }
332
+ getFullYear() {
333
+ return this.jsDate.getUTCFullYear();
334
+ }
335
+ getMonth() {
336
+ return this.jsDate.getUTCMonth();
337
+ }
338
+ getDate() {
339
+ return this.jsDate.getUTCDate();
340
+ }
341
+ getDay() {
342
+ return this.jsDate.getUTCDay();
343
+ }
344
+ getHours() {
345
+ return this.jsDate.getUTCHours();
346
+ }
347
+ getMinutes() {
348
+ return this.jsDate.getUTCMinutes();
349
+ }
350
+ getSeconds() {
351
+ return this.jsDate.getUTCSeconds();
352
+ }
353
+ setFullYear(year) {
354
+ this.jsDate.setFullYear(year);
355
+ }
356
+ setDate(date) {
357
+ this.jsDate.setUTCDate(date);
358
+ }
359
+ setHours(hours) {
360
+ this.jsDate.setUTCHours(hours);
361
+ }
362
+ setMinutes(minutes) {
363
+ this.jsDate.setUTCMinutes(minutes);
364
+ }
365
+ setSeconds(seconds) {
366
+ this.jsDate.setUTCSeconds(seconds);
367
+ }
368
+ }
308
369
  // -----------------------------------------------------------------------------
309
370
  // Parsing
310
371
  // -----------------------------------------------------------------------------
311
- const INITIAL_1900_DAY = new Date(1899, 11, 30);
372
+ const INITIAL_1900_DAY = new DateTime(1899, 11, 30);
312
373
  const MS_PER_DAY = 24 * 60 * 60 * 1000;
313
374
  const CURRENT_MILLENIAL = 2000; // note: don't forget to update this in 2999
314
- const CURRENT_YEAR = new Date().getFullYear();
315
- const INITIAL_JS_DAY = new Date(0);
316
- const DATE_JS_1900_OFFSET = INITIAL_JS_DAY - INITIAL_1900_DAY;
375
+ const CURRENT_YEAR = DateTime.now().getFullYear();
376
+ const INITIAL_JS_DAY = DateTime.fromTimestamp(0);
377
+ const DATE_JS_1900_OFFSET = INITIAL_JS_DAY.getTime() - INITIAL_1900_DAY.getTime();
317
378
  const mdyDateRegexp = /^\d{1,2}(\/|-|\s)\d{1,2}((\/|-|\s)\d{1,4})?$/;
318
379
  const ymdDateRegexp = /^\d{3,4}(\/|-|\s)\d{1,2}(\/|-|\s)\d{1,2}$/;
319
380
  const timeRegexp = /((\d+(:\d+)?(:\d+)?\s*(AM|PM))|(\d+:\d+(:\d+)?))$/;
@@ -362,7 +423,7 @@ function _parseDateTime(str) {
362
423
  return {
363
424
  value: date.value + time.value,
364
425
  format: date.format + " " + (time.format === "hhhh:mm:ss" ? "hh:mm:ss" : time.format),
365
- jsDate: new Date(date.jsDate.getFullYear() + time.jsDate.getFullYear() - 1899, date.jsDate.getMonth() + time.jsDate.getMonth() - 11, date.jsDate.getDate() + time.jsDate.getDate() - 30, date.jsDate.getHours() + time.jsDate.getHours(), date.jsDate.getMinutes() + time.jsDate.getMinutes(), date.jsDate.getSeconds() + time.jsDate.getSeconds()),
426
+ jsDate: new DateTime(date.jsDate.getFullYear() + time.jsDate.getFullYear() - 1899, date.jsDate.getMonth() + time.jsDate.getMonth() - 11, date.jsDate.getDate() + time.jsDate.getDate() - 30, date.jsDate.getHours() + time.jsDate.getHours(), date.jsDate.getMinutes() + time.jsDate.getMinutes(), date.jsDate.getSeconds() + time.jsDate.getSeconds()),
366
427
  };
367
428
  }
368
429
  return date || time;
@@ -379,13 +440,13 @@ function parseDate(str, dateFormat) {
379
440
  const day = Number(parts[dayIndex]);
380
441
  const leadingZero = (parts[monthIndex].length === 2 && month < 10) || (parts[dayIndex].length === 2 && day < 10);
381
442
  const year = parts[yearIndex] ? inferYear(parts[yearIndex]) : CURRENT_YEAR;
382
- const jsDate = new Date(year, month - 1, day);
443
+ const jsDate = new DateTime(year, month - 1, day);
383
444
  const sep = str.match(/\/|-|\s/)[0];
384
445
  if (jsDate.getMonth() !== month - 1 || jsDate.getDate() !== day) {
385
446
  // invalid date
386
447
  return null;
387
448
  }
388
- const delta = jsDate - INITIAL_1900_DAY;
449
+ const delta = jsDate.getTime() - INITIAL_1900_DAY.getTime();
389
450
  let format = leadingZero ? `mm${sep}dd` : `m${sep}d`;
390
451
  if (parts[yearIndex]) {
391
452
  format = isMDY ? format + sep + "yyyy" : "yyyy" + sep + format;
@@ -445,7 +506,7 @@ function parseTime(str) {
445
506
  if (hours >= 24) {
446
507
  format = "hhhh:mm:ss";
447
508
  }
448
- const jsDate = new Date(1899, 11, 30, hours, minutes, seconds);
509
+ const jsDate = new DateTime(1899, 11, 30, hours, minutes, seconds);
449
510
  return {
450
511
  value: hours / 24 + minutes / 1440 + seconds / 86400,
451
512
  format: format,
@@ -459,7 +520,7 @@ function parseTime(str) {
459
520
  // -----------------------------------------------------------------------------
460
521
  function numberToJsDate(value) {
461
522
  const truncValue = Math.trunc(value);
462
- let date = new Date(truncValue * MS_PER_DAY - DATE_JS_1900_OFFSET);
523
+ let date = DateTime.fromTimestamp(truncValue * MS_PER_DAY - DATE_JS_1900_OFFSET);
463
524
  let time = value - truncValue;
464
525
  time = time < 0 ? 1 + time : time;
465
526
  const hours = Math.round(time * 24);
@@ -476,7 +537,7 @@ function jsDateToRoundNumber(date) {
476
537
  }
477
538
  /** Return the number of days in the current month of the given date */
478
539
  function getDaysInMonth(date) {
479
- return new Date(date.getFullYear(), date.getMonth() + 1, 0).getDate();
540
+ return new DateTime(date.getFullYear(), date.getMonth() + 1, 0).getDate();
480
541
  }
481
542
  function isLastDayOfMonth(date) {
482
543
  return getDaysInMonth(date) === date.getDate();
@@ -494,7 +555,7 @@ function addMonthsToDate(date, months, keepEndOfMonth) {
494
555
  const yStart = date.getFullYear();
495
556
  const mStart = date.getMonth();
496
557
  const dStart = date.getDate();
497
- const jsDate = new Date(yStart, mStart + months);
558
+ const jsDate = new DateTime(yStart, mStart + months, 1);
498
559
  if (keepEndOfMonth && dStart === getDaysInMonth(date)) {
499
560
  jsDate.setDate(getDaysInMonth(jsDate));
500
561
  }
@@ -848,7 +909,7 @@ function isBoolean(str) {
848
909
  function isDateTime(str) {
849
910
  return parseDateTime(str) !== null;
850
911
  }
851
- const MARKDOWN_LINK_REGEX = /^\[([^\[]+)\]\((.+)\)$/;
912
+ const MARKDOWN_LINK_REGEX = /^\[(.+)\]\((.+)\)$/;
852
913
  //link must start with http or https
853
914
  //https://stackoverflow.com/a/3809435/4760614
854
915
  const WEB_LINK_REGEX = /^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,4}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)$/;
@@ -1343,8 +1404,10 @@ function isSameColor(color1, color2) {
1343
1404
  const cellReference = new RegExp(/\$?([A-Z]{1,3})\$?([0-9]{1,7})/, "i");
1344
1405
  // Same as above, but matches the exact string (nothing before or after)
1345
1406
  const singleCellReference = new RegExp(/^\$?([A-Z]{1,3})\$?([0-9]{1,7})$/, "i");
1346
- /** Reference of a column header (eg. A, AB) */
1347
- const colHeader = new RegExp(/^([A-Z]{1,3})+$/, "i");
1407
+ /** Reference of a column header (eg. A, AB, $A) */
1408
+ const colHeader = new RegExp(/^\$?([A-Z]{1,3})+$/, "i");
1409
+ /** Reference of a row header (eg. 1, $1) */
1410
+ const rowHeader = new RegExp(/^\$?([0-9]{1,7})+$/, "i");
1348
1411
  /** Reference of a column (eg. A, $CA, Sheet1!B) */
1349
1412
  const colReference = new RegExp(/^\s*('.+'!|[^']+!)?\$?([A-Z]{1,3})$/, "i");
1350
1413
  /** Reference of a row (eg. 1, 59, Sheet1!9) */
@@ -1374,6 +1437,9 @@ function isRowReference(xc) {
1374
1437
  function isColHeader(str) {
1375
1438
  return colHeader.test(str);
1376
1439
  }
1440
+ function isRowHeader(str) {
1441
+ return rowHeader.test(str);
1442
+ }
1377
1443
  /**
1378
1444
  * Return true if the given xc is the reference of a single cell,
1379
1445
  * without any specified sheet (e.g. A1)
@@ -1872,7 +1938,7 @@ function formatJSTime(jsDate, format) {
1872
1938
  .map((p) => {
1873
1939
  switch (p) {
1874
1940
  case "hhhh":
1875
- const helapsedHours = Math.floor((jsDate.getTime() - INITIAL_1900_DAY) / (60 * 60 * 1000));
1941
+ const helapsedHours = Math.floor((jsDate.getTime() - INITIAL_1900_DAY.getTime()) / (60 * 60 * 1000));
1876
1942
  return helapsedHours.toString();
1877
1943
  case "hh":
1878
1944
  return hours.toString().padStart(2, "0");
@@ -1935,27 +2001,30 @@ function detectFormat(content) {
1935
2001
  }
1936
2002
  function createLargeNumberFormat(format, magnitude, postFix) {
1937
2003
  const internalFormat = parseFormat(format || "#,##0");
1938
- const largeNumberFormat = internalFormat
1939
- .map((formatPart) => {
1940
- if (formatPart.type === "NUMBER") {
1941
- return [
1942
- {
1943
- ...formatPart,
1944
- format: {
1945
- ...formatPart.format,
1946
- magnitude,
1947
- decimalPart: undefined,
1948
- },
1949
- },
1950
- {
1951
- type: "STRING",
1952
- format: postFix,
1953
- },
1954
- ];
2004
+ const largeNumberFormat = [];
2005
+ for (let i = 0; i < internalFormat.length; i++) {
2006
+ const formatPart = internalFormat[i];
2007
+ if (formatPart.type !== "NUMBER") {
2008
+ largeNumberFormat.push(formatPart);
2009
+ continue;
1955
2010
  }
1956
- return formatPart;
1957
- })
1958
- .flat();
2011
+ largeNumberFormat.push({
2012
+ ...formatPart,
2013
+ format: {
2014
+ ...formatPart.format,
2015
+ magnitude,
2016
+ decimalPart: undefined,
2017
+ },
2018
+ });
2019
+ largeNumberFormat.push({
2020
+ type: "STRING",
2021
+ format: postFix,
2022
+ });
2023
+ const nextFormatPart = internalFormat[i + 1];
2024
+ if ((nextFormatPart === null || nextFormatPart === void 0 ? void 0 : nextFormatPart.type) === "STRING" && ["k", "m", "b"].includes(nextFormatPart.format)) {
2025
+ i++;
2026
+ }
2027
+ }
1959
2028
  return convertInternalFormatToFormat(largeNumberFormat);
1960
2029
  }
1961
2030
  function changeDecimalPlaces(format, step) {
@@ -2163,18 +2232,10 @@ class RangeImpl {
2163
2232
  if (isFullCol) {
2164
2233
  parts[0].rowFixed = parts[0].rowFixed || parts[1].rowFixed;
2165
2234
  parts[1].rowFixed = parts[0].rowFixed || parts[1].rowFixed;
2166
- if (zone.left === zone.right) {
2167
- parts[0].colFixed = parts[0].colFixed || parts[1].colFixed;
2168
- parts[1].colFixed = parts[0].colFixed || parts[1].colFixed;
2169
- }
2170
2235
  }
2171
2236
  if (isFullRow) {
2172
2237
  parts[0].colFixed = parts[0].colFixed || parts[1].colFixed;
2173
2238
  parts[1].colFixed = parts[0].colFixed || parts[1].colFixed;
2174
- if (zone.top === zone.bottom) {
2175
- parts[0].rowFixed = parts[0].rowFixed || parts[1].rowFixed;
2176
- parts[1].rowFixed = parts[0].rowFixed || parts[1].rowFixed;
2177
- }
2178
2239
  }
2179
2240
  return parts;
2180
2241
  }
@@ -3608,64 +3669,65 @@ var CommandResult;
3608
3669
  CommandResult[CommandResult["InvalidFigureId"] = 28] = "InvalidFigureId";
3609
3670
  CommandResult[CommandResult["InputAlreadyFocused"] = 29] = "InputAlreadyFocused";
3610
3671
  CommandResult[CommandResult["MaximumRangesReached"] = 30] = "MaximumRangesReached";
3611
- CommandResult[CommandResult["InvalidChartDefinition"] = 31] = "InvalidChartDefinition";
3612
- CommandResult[CommandResult["InvalidDataSet"] = 32] = "InvalidDataSet";
3613
- CommandResult[CommandResult["InvalidLabelRange"] = 33] = "InvalidLabelRange";
3614
- CommandResult[CommandResult["InvalidScorecardKeyValue"] = 34] = "InvalidScorecardKeyValue";
3615
- CommandResult[CommandResult["InvalidScorecardBaseline"] = 35] = "InvalidScorecardBaseline";
3616
- CommandResult[CommandResult["InvalidGaugeDataRange"] = 36] = "InvalidGaugeDataRange";
3617
- CommandResult[CommandResult["EmptyGaugeRangeMin"] = 37] = "EmptyGaugeRangeMin";
3618
- CommandResult[CommandResult["GaugeRangeMinNaN"] = 38] = "GaugeRangeMinNaN";
3619
- CommandResult[CommandResult["EmptyGaugeRangeMax"] = 39] = "EmptyGaugeRangeMax";
3620
- CommandResult[CommandResult["GaugeRangeMaxNaN"] = 40] = "GaugeRangeMaxNaN";
3621
- CommandResult[CommandResult["GaugeRangeMinBiggerThanRangeMax"] = 41] = "GaugeRangeMinBiggerThanRangeMax";
3622
- CommandResult[CommandResult["GaugeLowerInflectionPointNaN"] = 42] = "GaugeLowerInflectionPointNaN";
3623
- CommandResult[CommandResult["GaugeUpperInflectionPointNaN"] = 43] = "GaugeUpperInflectionPointNaN";
3624
- CommandResult[CommandResult["GaugeLowerBiggerThanUpper"] = 44] = "GaugeLowerBiggerThanUpper";
3625
- CommandResult[CommandResult["InvalidAutofillSelection"] = 45] = "InvalidAutofillSelection";
3626
- CommandResult[CommandResult["WrongComposerSelection"] = 46] = "WrongComposerSelection";
3627
- CommandResult[CommandResult["MinBiggerThanMax"] = 47] = "MinBiggerThanMax";
3628
- CommandResult[CommandResult["LowerBiggerThanUpper"] = 48] = "LowerBiggerThanUpper";
3629
- CommandResult[CommandResult["MidBiggerThanMax"] = 49] = "MidBiggerThanMax";
3630
- CommandResult[CommandResult["MinBiggerThanMid"] = 50] = "MinBiggerThanMid";
3631
- CommandResult[CommandResult["FirstArgMissing"] = 51] = "FirstArgMissing";
3632
- CommandResult[CommandResult["SecondArgMissing"] = 52] = "SecondArgMissing";
3633
- CommandResult[CommandResult["MinNaN"] = 53] = "MinNaN";
3634
- CommandResult[CommandResult["MidNaN"] = 54] = "MidNaN";
3635
- CommandResult[CommandResult["MaxNaN"] = 55] = "MaxNaN";
3636
- CommandResult[CommandResult["ValueUpperInflectionNaN"] = 56] = "ValueUpperInflectionNaN";
3637
- CommandResult[CommandResult["ValueLowerInflectionNaN"] = 57] = "ValueLowerInflectionNaN";
3638
- CommandResult[CommandResult["MinInvalidFormula"] = 58] = "MinInvalidFormula";
3639
- CommandResult[CommandResult["MidInvalidFormula"] = 59] = "MidInvalidFormula";
3640
- CommandResult[CommandResult["MaxInvalidFormula"] = 60] = "MaxInvalidFormula";
3641
- CommandResult[CommandResult["ValueUpperInvalidFormula"] = 61] = "ValueUpperInvalidFormula";
3642
- CommandResult[CommandResult["ValueLowerInvalidFormula"] = 62] = "ValueLowerInvalidFormula";
3643
- CommandResult[CommandResult["InvalidSortZone"] = 63] = "InvalidSortZone";
3644
- CommandResult[CommandResult["WaitingSessionConfirmation"] = 64] = "WaitingSessionConfirmation";
3645
- CommandResult[CommandResult["MergeOverlap"] = 65] = "MergeOverlap";
3646
- CommandResult[CommandResult["TooManyHiddenElements"] = 66] = "TooManyHiddenElements";
3647
- CommandResult[CommandResult["Readonly"] = 67] = "Readonly";
3648
- CommandResult[CommandResult["InvalidViewportSize"] = 68] = "InvalidViewportSize";
3649
- CommandResult[CommandResult["InvalidScrollingDirection"] = 69] = "InvalidScrollingDirection";
3650
- CommandResult[CommandResult["FigureDoesNotExist"] = 70] = "FigureDoesNotExist";
3651
- CommandResult[CommandResult["InvalidConditionalFormatId"] = 71] = "InvalidConditionalFormatId";
3652
- CommandResult[CommandResult["InvalidCellPopover"] = 72] = "InvalidCellPopover";
3653
- CommandResult[CommandResult["EmptyTarget"] = 73] = "EmptyTarget";
3654
- CommandResult[CommandResult["InvalidFreezeQuantity"] = 74] = "InvalidFreezeQuantity";
3655
- CommandResult[CommandResult["FrozenPaneOverlap"] = 75] = "FrozenPaneOverlap";
3656
- CommandResult[CommandResult["ValuesNotChanged"] = 76] = "ValuesNotChanged";
3657
- CommandResult[CommandResult["InvalidFilterZone"] = 77] = "InvalidFilterZone";
3658
- CommandResult[CommandResult["FilterOverlap"] = 78] = "FilterOverlap";
3659
- CommandResult[CommandResult["FilterNotFound"] = 79] = "FilterNotFound";
3660
- CommandResult[CommandResult["MergeInFilter"] = 80] = "MergeInFilter";
3661
- CommandResult[CommandResult["NonContinuousTargets"] = 81] = "NonContinuousTargets";
3662
- CommandResult[CommandResult["DuplicatedFigureId"] = 82] = "DuplicatedFigureId";
3663
- CommandResult[CommandResult["InvalidSelectionStep"] = 83] = "InvalidSelectionStep";
3664
- CommandResult[CommandResult["DuplicatedChartId"] = 84] = "DuplicatedChartId";
3665
- CommandResult[CommandResult["ChartDoesNotExist"] = 85] = "ChartDoesNotExist";
3666
- CommandResult[CommandResult["InvalidHeaderIndex"] = 86] = "InvalidHeaderIndex";
3667
- CommandResult[CommandResult["InvalidQuantity"] = 87] = "InvalidQuantity";
3668
- CommandResult[CommandResult["NoChanges"] = 88] = "NoChanges";
3672
+ CommandResult[CommandResult["InvalidInputId"] = 31] = "InvalidInputId";
3673
+ CommandResult[CommandResult["InvalidChartDefinition"] = 32] = "InvalidChartDefinition";
3674
+ CommandResult[CommandResult["InvalidDataSet"] = 33] = "InvalidDataSet";
3675
+ CommandResult[CommandResult["InvalidLabelRange"] = 34] = "InvalidLabelRange";
3676
+ CommandResult[CommandResult["InvalidScorecardKeyValue"] = 35] = "InvalidScorecardKeyValue";
3677
+ CommandResult[CommandResult["InvalidScorecardBaseline"] = 36] = "InvalidScorecardBaseline";
3678
+ CommandResult[CommandResult["InvalidGaugeDataRange"] = 37] = "InvalidGaugeDataRange";
3679
+ CommandResult[CommandResult["EmptyGaugeRangeMin"] = 38] = "EmptyGaugeRangeMin";
3680
+ CommandResult[CommandResult["GaugeRangeMinNaN"] = 39] = "GaugeRangeMinNaN";
3681
+ CommandResult[CommandResult["EmptyGaugeRangeMax"] = 40] = "EmptyGaugeRangeMax";
3682
+ CommandResult[CommandResult["GaugeRangeMaxNaN"] = 41] = "GaugeRangeMaxNaN";
3683
+ CommandResult[CommandResult["GaugeRangeMinBiggerThanRangeMax"] = 42] = "GaugeRangeMinBiggerThanRangeMax";
3684
+ CommandResult[CommandResult["GaugeLowerInflectionPointNaN"] = 43] = "GaugeLowerInflectionPointNaN";
3685
+ CommandResult[CommandResult["GaugeUpperInflectionPointNaN"] = 44] = "GaugeUpperInflectionPointNaN";
3686
+ CommandResult[CommandResult["GaugeLowerBiggerThanUpper"] = 45] = "GaugeLowerBiggerThanUpper";
3687
+ CommandResult[CommandResult["InvalidAutofillSelection"] = 46] = "InvalidAutofillSelection";
3688
+ CommandResult[CommandResult["WrongComposerSelection"] = 47] = "WrongComposerSelection";
3689
+ CommandResult[CommandResult["MinBiggerThanMax"] = 48] = "MinBiggerThanMax";
3690
+ CommandResult[CommandResult["LowerBiggerThanUpper"] = 49] = "LowerBiggerThanUpper";
3691
+ CommandResult[CommandResult["MidBiggerThanMax"] = 50] = "MidBiggerThanMax";
3692
+ CommandResult[CommandResult["MinBiggerThanMid"] = 51] = "MinBiggerThanMid";
3693
+ CommandResult[CommandResult["FirstArgMissing"] = 52] = "FirstArgMissing";
3694
+ CommandResult[CommandResult["SecondArgMissing"] = 53] = "SecondArgMissing";
3695
+ CommandResult[CommandResult["MinNaN"] = 54] = "MinNaN";
3696
+ CommandResult[CommandResult["MidNaN"] = 55] = "MidNaN";
3697
+ CommandResult[CommandResult["MaxNaN"] = 56] = "MaxNaN";
3698
+ CommandResult[CommandResult["ValueUpperInflectionNaN"] = 57] = "ValueUpperInflectionNaN";
3699
+ CommandResult[CommandResult["ValueLowerInflectionNaN"] = 58] = "ValueLowerInflectionNaN";
3700
+ CommandResult[CommandResult["MinInvalidFormula"] = 59] = "MinInvalidFormula";
3701
+ CommandResult[CommandResult["MidInvalidFormula"] = 60] = "MidInvalidFormula";
3702
+ CommandResult[CommandResult["MaxInvalidFormula"] = 61] = "MaxInvalidFormula";
3703
+ CommandResult[CommandResult["ValueUpperInvalidFormula"] = 62] = "ValueUpperInvalidFormula";
3704
+ CommandResult[CommandResult["ValueLowerInvalidFormula"] = 63] = "ValueLowerInvalidFormula";
3705
+ CommandResult[CommandResult["InvalidSortZone"] = 64] = "InvalidSortZone";
3706
+ CommandResult[CommandResult["WaitingSessionConfirmation"] = 65] = "WaitingSessionConfirmation";
3707
+ CommandResult[CommandResult["MergeOverlap"] = 66] = "MergeOverlap";
3708
+ CommandResult[CommandResult["TooManyHiddenElements"] = 67] = "TooManyHiddenElements";
3709
+ CommandResult[CommandResult["Readonly"] = 68] = "Readonly";
3710
+ CommandResult[CommandResult["InvalidViewportSize"] = 69] = "InvalidViewportSize";
3711
+ CommandResult[CommandResult["InvalidScrollingDirection"] = 70] = "InvalidScrollingDirection";
3712
+ CommandResult[CommandResult["FigureDoesNotExist"] = 71] = "FigureDoesNotExist";
3713
+ CommandResult[CommandResult["InvalidConditionalFormatId"] = 72] = "InvalidConditionalFormatId";
3714
+ CommandResult[CommandResult["InvalidCellPopover"] = 73] = "InvalidCellPopover";
3715
+ CommandResult[CommandResult["EmptyTarget"] = 74] = "EmptyTarget";
3716
+ CommandResult[CommandResult["InvalidFreezeQuantity"] = 75] = "InvalidFreezeQuantity";
3717
+ CommandResult[CommandResult["FrozenPaneOverlap"] = 76] = "FrozenPaneOverlap";
3718
+ CommandResult[CommandResult["ValuesNotChanged"] = 77] = "ValuesNotChanged";
3719
+ CommandResult[CommandResult["InvalidFilterZone"] = 78] = "InvalidFilterZone";
3720
+ CommandResult[CommandResult["FilterOverlap"] = 79] = "FilterOverlap";
3721
+ CommandResult[CommandResult["FilterNotFound"] = 80] = "FilterNotFound";
3722
+ CommandResult[CommandResult["MergeInFilter"] = 81] = "MergeInFilter";
3723
+ CommandResult[CommandResult["NonContinuousTargets"] = 82] = "NonContinuousTargets";
3724
+ CommandResult[CommandResult["DuplicatedFigureId"] = 83] = "DuplicatedFigureId";
3725
+ CommandResult[CommandResult["InvalidSelectionStep"] = 84] = "InvalidSelectionStep";
3726
+ CommandResult[CommandResult["DuplicatedChartId"] = 85] = "DuplicatedChartId";
3727
+ CommandResult[CommandResult["ChartDoesNotExist"] = 86] = "ChartDoesNotExist";
3728
+ CommandResult[CommandResult["InvalidHeaderIndex"] = 87] = "InvalidHeaderIndex";
3729
+ CommandResult[CommandResult["InvalidQuantity"] = 88] = "InvalidQuantity";
3730
+ CommandResult[CommandResult["NoChanges"] = 89] = "NoChanges";
3669
3731
  })(CommandResult || (CommandResult = {}));
3670
3732
 
3671
3733
  function isMatrix(x) {
@@ -3939,11 +4001,11 @@ function checkDataset(definition) {
3939
4001
  if (definition.dataSets) {
3940
4002
  const invalidRanges = definition.dataSets.find((range) => !rangeReference.test(range)) !== undefined;
3941
4003
  if (invalidRanges) {
3942
- return 32 /* CommandResult.InvalidDataSet */;
4004
+ return 33 /* CommandResult.InvalidDataSet */;
3943
4005
  }
3944
4006
  const zones = definition.dataSets.map(toUnboundedZone);
3945
4007
  if (zones.some((zone) => zone.top !== zone.bottom && isFullRow(zone))) {
3946
- return 32 /* CommandResult.InvalidDataSet */;
4008
+ return 33 /* CommandResult.InvalidDataSet */;
3947
4009
  }
3948
4010
  }
3949
4011
  return 0 /* CommandResult.Success */;
@@ -3952,7 +4014,7 @@ function checkLabelRange(definition) {
3952
4014
  if (definition.labelRange) {
3953
4015
  const invalidLabels = !rangeReference.test(definition.labelRange || "");
3954
4016
  if (invalidLabels) {
3955
- return 33 /* CommandResult.InvalidLabelRange */;
4017
+ return 34 /* CommandResult.InvalidLabelRange */;
3956
4018
  }
3957
4019
  }
3958
4020
  return 0 /* CommandResult.Success */;
@@ -4025,22 +4087,22 @@ function getChartPositionAtCenterOfViewport(getters, chartSize) {
4025
4087
  const CfTerms = {
4026
4088
  Errors: {
4027
4089
  [25 /* CommandResult.InvalidRange */]: _lt("The range is invalid"),
4028
- [51 /* CommandResult.FirstArgMissing */]: _lt("The argument is missing. Please provide a value"),
4029
- [52 /* CommandResult.SecondArgMissing */]: _lt("The second argument is missing. Please provide a value"),
4030
- [53 /* CommandResult.MinNaN */]: _lt("The minpoint must be a number"),
4031
- [54 /* CommandResult.MidNaN */]: _lt("The midpoint must be a number"),
4032
- [55 /* CommandResult.MaxNaN */]: _lt("The maxpoint must be a number"),
4033
- [56 /* CommandResult.ValueUpperInflectionNaN */]: _lt("The first value must be a number"),
4034
- [57 /* CommandResult.ValueLowerInflectionNaN */]: _lt("The second value must be a number"),
4035
- [47 /* CommandResult.MinBiggerThanMax */]: _lt("Minimum must be smaller then Maximum"),
4036
- [50 /* CommandResult.MinBiggerThanMid */]: _lt("Minimum must be smaller then Midpoint"),
4037
- [49 /* CommandResult.MidBiggerThanMax */]: _lt("Midpoint must be smaller then Maximum"),
4038
- [48 /* CommandResult.LowerBiggerThanUpper */]: _lt("Lower inflection point must be smaller than upper inflection point"),
4039
- [58 /* CommandResult.MinInvalidFormula */]: _lt("Invalid Minpoint formula"),
4040
- [60 /* CommandResult.MaxInvalidFormula */]: _lt("Invalid Maxpoint formula"),
4041
- [59 /* CommandResult.MidInvalidFormula */]: _lt("Invalid Midpoint formula"),
4042
- [61 /* CommandResult.ValueUpperInvalidFormula */]: _lt("Invalid upper inflection point formula"),
4043
- [62 /* CommandResult.ValueLowerInvalidFormula */]: _lt("Invalid lower inflection point formula"),
4090
+ [52 /* CommandResult.FirstArgMissing */]: _lt("The argument is missing. Please provide a value"),
4091
+ [53 /* CommandResult.SecondArgMissing */]: _lt("The second argument is missing. Please provide a value"),
4092
+ [54 /* CommandResult.MinNaN */]: _lt("The minpoint must be a number"),
4093
+ [55 /* CommandResult.MidNaN */]: _lt("The midpoint must be a number"),
4094
+ [56 /* CommandResult.MaxNaN */]: _lt("The maxpoint must be a number"),
4095
+ [57 /* CommandResult.ValueUpperInflectionNaN */]: _lt("The first value must be a number"),
4096
+ [58 /* CommandResult.ValueLowerInflectionNaN */]: _lt("The second value must be a number"),
4097
+ [48 /* CommandResult.MinBiggerThanMax */]: _lt("Minimum must be smaller then Maximum"),
4098
+ [51 /* CommandResult.MinBiggerThanMid */]: _lt("Minimum must be smaller then Midpoint"),
4099
+ [50 /* CommandResult.MidBiggerThanMax */]: _lt("Midpoint must be smaller then Maximum"),
4100
+ [49 /* CommandResult.LowerBiggerThanUpper */]: _lt("Lower inflection point must be smaller than upper inflection point"),
4101
+ [59 /* CommandResult.MinInvalidFormula */]: _lt("Invalid Minpoint formula"),
4102
+ [61 /* CommandResult.MaxInvalidFormula */]: _lt("Invalid Maxpoint formula"),
4103
+ [60 /* CommandResult.MidInvalidFormula */]: _lt("Invalid Midpoint formula"),
4104
+ [62 /* CommandResult.ValueUpperInvalidFormula */]: _lt("Invalid upper inflection point formula"),
4105
+ [63 /* CommandResult.ValueLowerInvalidFormula */]: _lt("Invalid lower inflection point formula"),
4044
4106
  [24 /* CommandResult.EmptyRange */]: _lt("A range needs to be defined"),
4045
4107
  Unexpected: _lt("The rule is invalid for an unknown reason"),
4046
4108
  },
@@ -4068,20 +4130,20 @@ const ChartTerms = {
4068
4130
  Errors: {
4069
4131
  Unexpected: _lt("The chart definition is invalid for an unknown reason"),
4070
4132
  // BASIC CHART ERRORS (LINE | BAR | PIE)
4071
- [32 /* CommandResult.InvalidDataSet */]: _lt("The dataset is invalid"),
4072
- [33 /* CommandResult.InvalidLabelRange */]: _lt("Labels are invalid"),
4133
+ [33 /* CommandResult.InvalidDataSet */]: _lt("The dataset is invalid"),
4134
+ [34 /* CommandResult.InvalidLabelRange */]: _lt("Labels are invalid"),
4073
4135
  // SCORECARD CHART ERRORS
4074
- [34 /* CommandResult.InvalidScorecardKeyValue */]: _lt("The key value is invalid"),
4075
- [35 /* CommandResult.InvalidScorecardBaseline */]: _lt("The baseline value is invalid"),
4136
+ [35 /* CommandResult.InvalidScorecardKeyValue */]: _lt("The key value is invalid"),
4137
+ [36 /* CommandResult.InvalidScorecardBaseline */]: _lt("The baseline value is invalid"),
4076
4138
  // GAUGE CHART ERRORS
4077
- [36 /* CommandResult.InvalidGaugeDataRange */]: _lt("The data range is invalid"),
4078
- [37 /* CommandResult.EmptyGaugeRangeMin */]: _lt("A minimum range limit value is needed"),
4079
- [38 /* CommandResult.GaugeRangeMinNaN */]: _lt("The minimum range limit value must be a number"),
4080
- [39 /* CommandResult.EmptyGaugeRangeMax */]: _lt("A maximum range limit value is needed"),
4081
- [40 /* CommandResult.GaugeRangeMaxNaN */]: _lt("The maximum range limit value must be a number"),
4082
- [41 /* CommandResult.GaugeRangeMinBiggerThanRangeMax */]: _lt("Minimum range limit must be smaller than maximum range limit"),
4083
- [42 /* CommandResult.GaugeLowerInflectionPointNaN */]: _lt("The lower inflection point value must be a number"),
4084
- [43 /* CommandResult.GaugeUpperInflectionPointNaN */]: _lt("The upper inflection point value must be a number"),
4139
+ [37 /* CommandResult.InvalidGaugeDataRange */]: _lt("The data range is invalid"),
4140
+ [38 /* CommandResult.EmptyGaugeRangeMin */]: _lt("A minimum range limit value is needed"),
4141
+ [39 /* CommandResult.GaugeRangeMinNaN */]: _lt("The minimum range limit value must be a number"),
4142
+ [40 /* CommandResult.EmptyGaugeRangeMax */]: _lt("A maximum range limit value is needed"),
4143
+ [41 /* CommandResult.GaugeRangeMaxNaN */]: _lt("The maximum range limit value must be a number"),
4144
+ [42 /* CommandResult.GaugeRangeMinBiggerThanRangeMax */]: _lt("Minimum range limit must be smaller than maximum range limit"),
4145
+ [43 /* CommandResult.GaugeLowerInflectionPointNaN */]: _lt("The lower inflection point value must be a number"),
4146
+ [44 /* CommandResult.GaugeUpperInflectionPointNaN */]: _lt("The upper inflection point value must be a number"),
4085
4147
  },
4086
4148
  };
4087
4149
  const NumberFormatTerms = {
@@ -4453,7 +4515,7 @@ function createBarChartRuntime(chart, getters) {
4453
4515
 
4454
4516
  function isDataRangeValid(definition) {
4455
4517
  return definition.dataRange && !rangeReference.test(definition.dataRange)
4456
- ? 36 /* CommandResult.InvalidGaugeDataRange */
4518
+ ? 37 /* CommandResult.InvalidGaugeDataRange */
4457
4519
  : 0 /* CommandResult.Success */;
4458
4520
  }
4459
4521
  function checkRangeLimits(check, batchValidations) {
@@ -4485,7 +4547,7 @@ function checkInflectionPointsValue(check, batchValidations) {
4485
4547
  function checkRangeMinBiggerThanRangeMax(definition) {
4486
4548
  if (definition.sectionRule) {
4487
4549
  if (Number(definition.sectionRule.rangeMin) >= Number(definition.sectionRule.rangeMax)) {
4488
- return 41 /* CommandResult.GaugeRangeMinBiggerThanRangeMax */;
4550
+ return 42 /* CommandResult.GaugeRangeMinBiggerThanRangeMax */;
4489
4551
  }
4490
4552
  }
4491
4553
  return 0 /* CommandResult.Success */;
@@ -4494,9 +4556,9 @@ function checkEmpty(value, valueName) {
4494
4556
  if (value === "") {
4495
4557
  switch (valueName) {
4496
4558
  case "rangeMin":
4497
- return 37 /* CommandResult.EmptyGaugeRangeMin */;
4559
+ return 38 /* CommandResult.EmptyGaugeRangeMin */;
4498
4560
  case "rangeMax":
4499
- return 39 /* CommandResult.EmptyGaugeRangeMax */;
4561
+ return 40 /* CommandResult.EmptyGaugeRangeMax */;
4500
4562
  }
4501
4563
  }
4502
4564
  return 0 /* CommandResult.Success */;
@@ -4505,13 +4567,13 @@ function checkNaN(value, valueName) {
4505
4567
  if (isNaN(value)) {
4506
4568
  switch (valueName) {
4507
4569
  case "rangeMin":
4508
- return 38 /* CommandResult.GaugeRangeMinNaN */;
4570
+ return 39 /* CommandResult.GaugeRangeMinNaN */;
4509
4571
  case "rangeMax":
4510
- return 40 /* CommandResult.GaugeRangeMaxNaN */;
4572
+ return 41 /* CommandResult.GaugeRangeMaxNaN */;
4511
4573
  case "lowerInflectionPointValue":
4512
- return 42 /* CommandResult.GaugeLowerInflectionPointNaN */;
4574
+ return 43 /* CommandResult.GaugeLowerInflectionPointNaN */;
4513
4575
  case "upperInflectionPointValue":
4514
- return 43 /* CommandResult.GaugeUpperInflectionPointNaN */;
4576
+ return 44 /* CommandResult.GaugeUpperInflectionPointNaN */;
4515
4577
  }
4516
4578
  }
4517
4579
  return 0 /* CommandResult.Success */;
@@ -5262,12 +5324,12 @@ function createPieChartRuntime(chart, getters) {
5262
5324
 
5263
5325
  function checkKeyValue(definition) {
5264
5326
  return definition.keyValue && !rangeReference.test(definition.keyValue)
5265
- ? 34 /* CommandResult.InvalidScorecardKeyValue */
5327
+ ? 35 /* CommandResult.InvalidScorecardKeyValue */
5266
5328
  : 0 /* CommandResult.Success */;
5267
5329
  }
5268
5330
  function checkBaseline(definition) {
5269
5331
  return definition.baseline && !rangeReference.test(definition.baseline)
5270
- ? 35 /* CommandResult.InvalidScorecardBaseline */
5332
+ ? 36 /* CommandResult.InvalidScorecardBaseline */
5271
5333
  : 0 /* CommandResult.Success */;
5272
5334
  }
5273
5335
  class ScorecardChart extends AbstractChart {
@@ -5701,6 +5763,7 @@ function getMenuDescription(node) {
5701
5763
  return node.description ? node.description : "";
5702
5764
  }
5703
5765
 
5766
+ const macRegex = /Mac/i;
5704
5767
  /**
5705
5768
  * Return true if the event was triggered from
5706
5769
  * a child element.
@@ -5718,6 +5781,17 @@ function gridOverlayPosition() {
5718
5781
  }
5719
5782
  function getOpenedMenus() {
5720
5783
  return Array.from(document.querySelectorAll(".o-spreadsheet .o-menu"));
5784
+ }
5785
+ function isMacOS() {
5786
+ return Boolean(macRegex.test(navigator.userAgent));
5787
+ }
5788
+ /**
5789
+ * @param {KeyboardEvent | MouseEvent} ev
5790
+ * @returns Returns true if the event was triggered with the "ctrl" modifier pressed.
5791
+ * On Mac, this is the "meta" or "command" key.
5792
+ */
5793
+ function isCtrlKey(ev) {
5794
+ return isMacOS() ? ev.metaKey : ev.ctrlKey;
5721
5795
  }
5722
5796
 
5723
5797
  /**
@@ -6297,7 +6371,7 @@ function handlePasteResult(env, result) {
6297
6371
  else if (result.reasons.includes(22 /* CommandResult.WrongFigurePasteOption */)) {
6298
6372
  env.raiseError(PasteInteractiveContent.wrongFigurePasteOption);
6299
6373
  }
6300
- else if (result.reasons.includes(75 /* CommandResult.FrozenPaneOverlap */)) {
6374
+ else if (result.reasons.includes(76 /* CommandResult.FrozenPaneOverlap */)) {
6301
6375
  env.raiseError(PasteInteractiveContent.frozenPaneOverlap);
6302
6376
  }
6303
6377
  }
@@ -6584,7 +6658,7 @@ function interactiveSortSelection(env, sheetId, anchor, zone, sortDirection) {
6584
6658
  });
6585
6659
  }
6586
6660
  }
6587
- if (result.isCancelledBecause(63 /* CommandResult.InvalidSortZone */)) {
6661
+ if (result.isCancelledBecause(64 /* CommandResult.InvalidSortZone */)) {
6588
6662
  const { col, row } = anchor;
6589
6663
  env.model.selection.selectZone({ cell: { col, row }, zone });
6590
6664
  env.raiseError(_lt("Cannot sort. To sort, select only cells or only merges that have the same size."));
@@ -6598,13 +6672,13 @@ const AddFilterInteractiveContent = {
6598
6672
  };
6599
6673
  function interactiveAddFilter(env, sheetId, target) {
6600
6674
  const result = env.model.dispatch("CREATE_FILTER_TABLE", { target, sheetId });
6601
- if (result.isCancelledBecause(78 /* CommandResult.FilterOverlap */)) {
6675
+ if (result.isCancelledBecause(79 /* CommandResult.FilterOverlap */)) {
6602
6676
  env.raiseError(AddFilterInteractiveContent.filterOverlap);
6603
6677
  }
6604
- else if (result.isCancelledBecause(80 /* CommandResult.MergeInFilter */)) {
6678
+ else if (result.isCancelledBecause(81 /* CommandResult.MergeInFilter */)) {
6605
6679
  env.raiseError(AddFilterInteractiveContent.mergeInFilter);
6606
6680
  }
6607
- else if (result.isCancelledBecause(81 /* CommandResult.NonContinuousTargets */)) {
6681
+ else if (result.isCancelledBecause(82 /* CommandResult.NonContinuousTargets */)) {
6608
6682
  env.raiseError(AddFilterInteractiveContent.nonContinuousTargets);
6609
6683
  }
6610
6684
  }
@@ -10878,7 +10952,7 @@ const DATE = {
10878
10952
  if (_year < 1900) {
10879
10953
  _year += 1900;
10880
10954
  }
10881
- const jsDate = new Date(_year, _month - 1, _day);
10955
+ const jsDate = new DateTime(_year, _month - 1, _day);
10882
10956
  const result = jsDateToRoundNumber(jsDate);
10883
10957
  assert(() => result >= 0, _lt(`The function [[FUNCTION_NAME]] result must be greater than or equal 01/01/1900.`));
10884
10958
  return result;
@@ -10990,7 +11064,7 @@ const EOMONTH = {
10990
11064
  const _months = Math.trunc(toNumber(months));
10991
11065
  const yStart = _startDate.getFullYear();
10992
11066
  const mStart = _startDate.getMonth();
10993
- const jsDate = new Date(yStart, mStart + _months + 1, 0);
11067
+ const jsDate = new DateTime(yStart, mStart + _months + 1, 0);
10994
11068
  return jsDateToRoundNumber(jsDate);
10995
11069
  },
10996
11070
  isExported: true,
@@ -11029,17 +11103,17 @@ const ISOWEEKNUM = {
11029
11103
  // The first week of the year is the week that contains the first
11030
11104
  // Thursday of the year.
11031
11105
  let firstThursday = 1;
11032
- while (new Date(y, 0, firstThursday).getDay() !== 4) {
11106
+ while (new DateTime(y, 0, firstThursday).getDay() !== 4) {
11033
11107
  firstThursday += 1;
11034
11108
  }
11035
- const firstDayOfFirstWeek = new Date(y, 0, firstThursday - 3);
11109
+ const firstDayOfFirstWeek = new DateTime(y, 0, firstThursday - 3);
11036
11110
  // The last week of the year is the week that contains the last Thursday of
11037
11111
  // the year.
11038
11112
  let lastThursday = 31;
11039
- while (new Date(y, 11, lastThursday).getDay() !== 4) {
11113
+ while (new DateTime(y, 11, lastThursday).getDay() !== 4) {
11040
11114
  lastThursday -= 1;
11041
11115
  }
11042
- const lastDayOfLastWeek = new Date(y, 11, lastThursday + 3);
11116
+ const lastDayOfLastWeek = new DateTime(y, 11, lastThursday + 3);
11043
11117
  // B - If our date > lastDayOfLastWeek then it's in the weeks of the year after
11044
11118
  // If our date < firstDayOfFirstWeek then it's in the weeks of the year before
11045
11119
  let offsetYear;
@@ -11065,17 +11139,17 @@ const ISOWEEKNUM = {
11065
11139
  case 1:
11066
11140
  // firstDay is the 1st day of the 1st week of the year after
11067
11141
  // firstDay = lastDayOfLastWeek + 1 Day
11068
- firstDay = new Date(y, 11, lastThursday + 3 + 1);
11142
+ firstDay = new DateTime(y, 11, lastThursday + 3 + 1);
11069
11143
  break;
11070
11144
  case -1:
11071
11145
  // firstDay is the 1st day of the 1st week of the previous year.
11072
11146
  // The first week of the previous year is the week that contains the
11073
11147
  // first Thursday of the previous year.
11074
11148
  let firstThursdayPreviousYear = 1;
11075
- while (new Date(y - 1, 0, firstThursdayPreviousYear).getDay() !== 4) {
11149
+ while (new DateTime(y - 1, 0, firstThursdayPreviousYear).getDay() !== 4) {
11076
11150
  firstThursdayPreviousYear += 1;
11077
11151
  }
11078
- firstDay = new Date(y - 1, 0, firstThursdayPreviousYear - 3);
11152
+ firstDay = new DateTime(y - 1, 0, firstThursdayPreviousYear - 3);
11079
11153
  break;
11080
11154
  }
11081
11155
  const diff = (_date.getTime() - firstDay.getTime()) / MS_PER_DAY;
@@ -11214,8 +11288,8 @@ const NETWORKDAYS_INTL = {
11214
11288
  });
11215
11289
  }
11216
11290
  const invertDate = _startDate.getTime() > _endDate.getTime();
11217
- const stopDate = new Date((invertDate ? _startDate : _endDate).getTime());
11218
- let stepDate = new Date((invertDate ? _endDate : _startDate).getTime());
11291
+ const stopDate = DateTime.fromTimestamp((invertDate ? _startDate : _endDate).getTime());
11292
+ let stepDate = DateTime.fromTimestamp((invertDate ? _endDate : _startDate).getTime());
11219
11293
  const timeStopDate = stopDate.getTime();
11220
11294
  let timeStepDate = stepDate.getTime();
11221
11295
  let netWorkingDay = 0;
@@ -11239,8 +11313,7 @@ const NOW = {
11239
11313
  returns: ["DATE"],
11240
11314
  computeFormat: () => "m/d/yyyy hh:mm:ss",
11241
11315
  compute: function () {
11242
- let today = new Date();
11243
- today.setMilliseconds(0);
11316
+ let today = DateTime.now();
11244
11317
  const delta = today.getTime() - INITIAL_1900_DAY.getTime();
11245
11318
  const time = today.getHours() / 24 + today.getMinutes() / 1440 + today.getSeconds() / 86400;
11246
11319
  return Math.floor(delta / MS_PER_DAY) + time;
@@ -11314,8 +11387,8 @@ const TODAY = {
11314
11387
  returns: ["DATE"],
11315
11388
  computeFormat: () => "m/d/yyyy",
11316
11389
  compute: function () {
11317
- const today = new Date();
11318
- const jsDate = new Date(today.getFullYear(), today.getMonth(), today.getDate());
11390
+ const today = DateTime.now();
11391
+ const jsDate = new DateTime(today.getFullYear(), today.getMonth(), today.getDate());
11319
11392
  return jsDateToRoundNumber(jsDate);
11320
11393
  },
11321
11394
  isExported: true,
@@ -11370,10 +11443,10 @@ const WEEKNUM = {
11370
11443
  }
11371
11444
  const y = _date.getFullYear();
11372
11445
  let dayStart = 1;
11373
- let startDayOfFirstWeek = new Date(y, 0, dayStart);
11446
+ let startDayOfFirstWeek = new DateTime(y, 0, dayStart);
11374
11447
  while (startDayOfFirstWeek.getDay() !== startDayOfWeek) {
11375
11448
  dayStart += 1;
11376
- startDayOfFirstWeek = new Date(y, 0, dayStart);
11449
+ startDayOfFirstWeek = new DateTime(y, 0, dayStart);
11377
11450
  }
11378
11451
  const dif = (_date.getTime() - startDayOfFirstWeek.getTime()) / MS_PER_DAY;
11379
11452
  if (dif < 0) {
@@ -11427,7 +11500,7 @@ const WORKDAY_INTL = {
11427
11500
  timesHoliday.add(holiday.getTime());
11428
11501
  });
11429
11502
  }
11430
- let stepDate = new Date(_startDate.getTime());
11503
+ let stepDate = DateTime.fromTimestamp(_startDate.getTime());
11431
11504
  let timeStepDate = stepDate.getTime();
11432
11505
  const unitDay = Math.sign(_numDays);
11433
11506
  let stepDay = Math.abs(_numDays);
@@ -11493,7 +11566,7 @@ const MONTH_START = {
11493
11566
  const _startDate = toJsDate(date);
11494
11567
  const yStart = _startDate.getFullYear();
11495
11568
  const mStart = _startDate.getMonth();
11496
- const jsDate = new Date(yStart, mStart, 1);
11569
+ const jsDate = new DateTime(yStart, mStart, 1);
11497
11570
  return jsDateToRoundNumber(jsDate);
11498
11571
  },
11499
11572
  };
@@ -11537,7 +11610,7 @@ const QUARTER_START = {
11537
11610
  compute: function (date) {
11538
11611
  const quarter = QUARTER.compute(date);
11539
11612
  const year = YEAR.compute(date);
11540
- const jsDate = new Date(year, (quarter - 1) * 3, 1);
11613
+ const jsDate = new DateTime(year, (quarter - 1) * 3, 1);
11541
11614
  return jsDateToRoundNumber(jsDate);
11542
11615
  },
11543
11616
  };
@@ -11554,7 +11627,7 @@ const QUARTER_END = {
11554
11627
  compute: function (date) {
11555
11628
  const quarter = QUARTER.compute(date);
11556
11629
  const year = YEAR.compute(date);
11557
- const jsDate = new Date(year, quarter * 3, 0);
11630
+ const jsDate = new DateTime(year, quarter * 3, 0);
11558
11631
  return jsDateToRoundNumber(jsDate);
11559
11632
  },
11560
11633
  };
@@ -11570,7 +11643,7 @@ const YEAR_START = {
11570
11643
  computeFormat: () => "m/d/yyyy",
11571
11644
  compute: function (date) {
11572
11645
  const year = YEAR.compute(date);
11573
- const jsDate = new Date(year, 0, 1);
11646
+ const jsDate = new DateTime(year, 0, 1);
11574
11647
  return jsDateToRoundNumber(jsDate);
11575
11648
  },
11576
11649
  };
@@ -11586,7 +11659,7 @@ const YEAR_END = {
11586
11659
  computeFormat: () => "m/d/yyyy",
11587
11660
  compute: function (date) {
11588
11661
  const year = YEAR.compute(date);
11589
- const jsDate = new Date(year + 1, 0, 0);
11662
+ const jsDate = new DateTime(year + 1, 0, 0);
11590
11663
  return jsDateToRoundNumber(jsDate);
11591
11664
  },
11592
11665
  };
@@ -11720,7 +11793,7 @@ function assertDeprecationFactorStrictlyPositive(factor) {
11720
11793
  function assertSettlementLessThanOneYearBeforeMaturity(settlement, maturity) {
11721
11794
  const startDate = toJsDate(settlement);
11722
11795
  const endDate = toJsDate(maturity);
11723
- const startDatePlusOneYear = new Date(startDate);
11796
+ const startDatePlusOneYear = toJsDate(settlement);
11724
11797
  startDatePlusOneYear.setFullYear(startDate.getFullYear() + 1);
11725
11798
  assert(() => endDate.getTime() <= startDatePlusOneYear.getTime(), _lt("The settlement date (%s) must at most one year after the maturity date (%s).", settlement.toString(), maturity.toString()));
11726
11799
  }
@@ -15646,7 +15719,7 @@ const machine = {
15646
15719
  SPACE: goTo(State.RightRef),
15647
15720
  NUMBER: goTo(State.Found),
15648
15721
  REFERENCE: goTo(State.Found, (token) => isSingleCellReference(token.value)),
15649
- SYMBOL: goTo(State.Found, (token) => isColHeader(token.value)),
15722
+ SYMBOL: goTo(State.Found, (token) => isColHeader(token.value) || isRowHeader(token.value)),
15650
15723
  },
15651
15724
  [State.RightColumnRef]: {
15652
15725
  SPACE: goTo(State.RightColumnRef),
@@ -15657,6 +15730,7 @@ const machine = {
15657
15730
  SPACE: goTo(State.RightRowRef),
15658
15731
  NUMBER: goTo(State.Found),
15659
15732
  REFERENCE: goTo(State.Found, (token) => isSingleCellReference(token.value)),
15733
+ SYMBOL: goTo(State.Found, (token) => isRowHeader(token.value)),
15660
15734
  },
15661
15735
  [State.Found]: {},
15662
15736
  };
@@ -16166,6 +16240,10 @@ function setXcToReferenceType(xc, referenceType) {
16166
16240
  return xc.slice(0, indexOfNumber) + "$" + xc.slice(indexOfNumber);
16167
16241
  case "colrow":
16168
16242
  indexOfNumber = xc.search(/[0-9]/);
16243
+ if (indexOfNumber === -1 || indexOfNumber === 0) {
16244
+ // no row number (eg. A) or no column (eg. 1)
16245
+ return "$" + xc;
16246
+ }
16169
16247
  xc = xc.slice(0, indexOfNumber) + "$" + xc.slice(indexOfNumber);
16170
16248
  return "$" + xc;
16171
16249
  case "none":
@@ -16551,7 +16629,7 @@ class EditionPlugin extends UIPlugin {
16551
16629
  validateSelection(length, start, end) {
16552
16630
  return start >= 0 && start <= length && end >= 0 && end <= length
16553
16631
  ? 0 /* CommandResult.Success */
16554
- : 46 /* CommandResult.WrongComposerSelection */;
16632
+ : 47 /* CommandResult.WrongComposerSelection */;
16555
16633
  }
16556
16634
  onColumnsRemoved(cmd) {
16557
16635
  if (cmd.elements.includes(this.col) && this.mode !== "inactive") {
@@ -16865,9 +16943,10 @@ class EditionPlugin extends UIPlugin {
16865
16943
  */
16866
16944
  getReferencedRanges() {
16867
16945
  const editionSheetId = this.getters.getEditionSheet();
16868
- return this.currentTokens
16946
+ const referenceRanges = this.currentTokens
16869
16947
  .filter((token) => token.type === "REFERENCE")
16870
16948
  .map((token) => this.getters.getRangeFromSheetXC(editionSheetId, token.value));
16949
+ return referenceRanges.filter((range) => !range.invalidSheetName && !range.invalidXc);
16871
16950
  }
16872
16951
  /**
16873
16952
  * Function used to determine when composer selection can start.
@@ -16939,10 +17018,10 @@ const arrowMap = {
16939
17018
  function updateSelectionWithArrowKeys(ev, selection) {
16940
17019
  const direction = arrowMap[ev.key];
16941
17020
  if (ev.shiftKey) {
16942
- selection.resizeAnchorZone(direction, ev.ctrlKey ? "end" : 1);
17021
+ selection.resizeAnchorZone(direction, isCtrlKey(ev) ? "end" : 1);
16943
17022
  }
16944
17023
  else {
16945
- selection.moveAnchorCell(direction, ev.ctrlKey ? "end" : 1);
17024
+ selection.moveAnchorCell(direction, isCtrlKey(ev) ? "end" : 1);
16946
17025
  }
16947
17026
  }
16948
17027
 
@@ -19305,7 +19384,7 @@ function interactiveFreezeColumnsRows(env, dimension, base) {
19305
19384
  const sheetId = env.model.getters.getActiveSheetId();
19306
19385
  const cmd = dimension === "COL" ? "FREEZE_COLUMNS" : "FREEZE_ROWS";
19307
19386
  const result = env.model.dispatch(cmd, { sheetId, quantity: base });
19308
- if (result.isCancelledBecause(65 /* CommandResult.MergeOverlap */)) {
19387
+ if (result.isCancelledBecause(66 /* CommandResult.MergeOverlap */)) {
19309
19388
  env.raiseError(MergeErrorMessage);
19310
19389
  }
19311
19390
  }
@@ -20020,11 +20099,11 @@ class LineBarPieConfigPanel extends Component {
20020
20099
  }
20021
20100
  get isDatasetInvalid() {
20022
20101
  var _a;
20023
- return !!((_a = this.state.datasetDispatchResult) === null || _a === void 0 ? void 0 : _a.isCancelledBecause(32 /* CommandResult.InvalidDataSet */));
20102
+ return !!((_a = this.state.datasetDispatchResult) === null || _a === void 0 ? void 0 : _a.isCancelledBecause(33 /* CommandResult.InvalidDataSet */));
20024
20103
  }
20025
20104
  get isLabelInvalid() {
20026
20105
  var _a;
20027
- return !!((_a = this.state.labelsDispatchResult) === null || _a === void 0 ? void 0 : _a.isCancelledBecause(33 /* CommandResult.InvalidLabelRange */));
20106
+ return !!((_a = this.state.labelsDispatchResult) === null || _a === void 0 ? void 0 : _a.isCancelledBecause(34 /* CommandResult.InvalidLabelRange */));
20028
20107
  }
20029
20108
  onUpdateDataSetsHaveTitle(ev) {
20030
20109
  this.props.updateChart(this.props.figureId, {
@@ -20397,7 +20476,7 @@ class GaugeChartConfigPanel extends Component {
20397
20476
  }
20398
20477
  get isDataRangeInvalid() {
20399
20478
  var _a;
20400
- return !!((_a = this.state.dataRangeDispatchResult) === null || _a === void 0 ? void 0 : _a.isCancelledBecause(36 /* CommandResult.InvalidGaugeDataRange */));
20479
+ return !!((_a = this.state.dataRangeDispatchResult) === null || _a === void 0 ? void 0 : _a.isCancelledBecause(37 /* CommandResult.InvalidGaugeDataRange */));
20401
20480
  }
20402
20481
  onDataRangeChanged(ranges) {
20403
20482
  this.dataRange = ranges[0];
@@ -20489,28 +20568,28 @@ class GaugeChartDesignPanel extends Component {
20489
20568
  }
20490
20569
  isRangeMinInvalid() {
20491
20570
  var _a, _b, _c;
20492
- return !!(((_a = this.state.sectionRuleDispatchResult) === null || _a === void 0 ? void 0 : _a.isCancelledBecause(37 /* CommandResult.EmptyGaugeRangeMin */)) ||
20493
- ((_b = this.state.sectionRuleDispatchResult) === null || _b === void 0 ? void 0 : _b.isCancelledBecause(38 /* CommandResult.GaugeRangeMinNaN */)) ||
20494
- ((_c = this.state.sectionRuleDispatchResult) === null || _c === void 0 ? void 0 : _c.isCancelledBecause(41 /* CommandResult.GaugeRangeMinBiggerThanRangeMax */)));
20571
+ return !!(((_a = this.state.sectionRuleDispatchResult) === null || _a === void 0 ? void 0 : _a.isCancelledBecause(38 /* CommandResult.EmptyGaugeRangeMin */)) ||
20572
+ ((_b = this.state.sectionRuleDispatchResult) === null || _b === void 0 ? void 0 : _b.isCancelledBecause(39 /* CommandResult.GaugeRangeMinNaN */)) ||
20573
+ ((_c = this.state.sectionRuleDispatchResult) === null || _c === void 0 ? void 0 : _c.isCancelledBecause(42 /* CommandResult.GaugeRangeMinBiggerThanRangeMax */)));
20495
20574
  }
20496
20575
  isRangeMaxInvalid() {
20497
20576
  var _a, _b, _c;
20498
- return !!(((_a = this.state.sectionRuleDispatchResult) === null || _a === void 0 ? void 0 : _a.isCancelledBecause(39 /* CommandResult.EmptyGaugeRangeMax */)) ||
20499
- ((_b = this.state.sectionRuleDispatchResult) === null || _b === void 0 ? void 0 : _b.isCancelledBecause(40 /* CommandResult.GaugeRangeMaxNaN */)) ||
20500
- ((_c = this.state.sectionRuleDispatchResult) === null || _c === void 0 ? void 0 : _c.isCancelledBecause(41 /* CommandResult.GaugeRangeMinBiggerThanRangeMax */)));
20577
+ return !!(((_a = this.state.sectionRuleDispatchResult) === null || _a === void 0 ? void 0 : _a.isCancelledBecause(40 /* CommandResult.EmptyGaugeRangeMax */)) ||
20578
+ ((_b = this.state.sectionRuleDispatchResult) === null || _b === void 0 ? void 0 : _b.isCancelledBecause(41 /* CommandResult.GaugeRangeMaxNaN */)) ||
20579
+ ((_c = this.state.sectionRuleDispatchResult) === null || _c === void 0 ? void 0 : _c.isCancelledBecause(42 /* CommandResult.GaugeRangeMinBiggerThanRangeMax */)));
20501
20580
  }
20502
20581
  // ---------------------------------------------------------------------------
20503
20582
  // COLOR_SECTION_TEMPLATE
20504
20583
  // ---------------------------------------------------------------------------
20505
20584
  get isLowerInflectionPointInvalid() {
20506
20585
  var _a, _b;
20507
- return !!(((_a = this.state.sectionRuleDispatchResult) === null || _a === void 0 ? void 0 : _a.isCancelledBecause(42 /* CommandResult.GaugeLowerInflectionPointNaN */)) ||
20508
- ((_b = this.state.sectionRuleDispatchResult) === null || _b === void 0 ? void 0 : _b.isCancelledBecause(44 /* CommandResult.GaugeLowerBiggerThanUpper */)));
20586
+ return !!(((_a = this.state.sectionRuleDispatchResult) === null || _a === void 0 ? void 0 : _a.isCancelledBecause(43 /* CommandResult.GaugeLowerInflectionPointNaN */)) ||
20587
+ ((_b = this.state.sectionRuleDispatchResult) === null || _b === void 0 ? void 0 : _b.isCancelledBecause(45 /* CommandResult.GaugeLowerBiggerThanUpper */)));
20509
20588
  }
20510
20589
  get isUpperInflectionPointInvalid() {
20511
20590
  var _a, _b;
20512
- return !!(((_a = this.state.sectionRuleDispatchResult) === null || _a === void 0 ? void 0 : _a.isCancelledBecause(43 /* CommandResult.GaugeUpperInflectionPointNaN */)) ||
20513
- ((_b = this.state.sectionRuleDispatchResult) === null || _b === void 0 ? void 0 : _b.isCancelledBecause(44 /* CommandResult.GaugeLowerBiggerThanUpper */)));
20591
+ return !!(((_a = this.state.sectionRuleDispatchResult) === null || _a === void 0 ? void 0 : _a.isCancelledBecause(44 /* CommandResult.GaugeUpperInflectionPointNaN */)) ||
20592
+ ((_b = this.state.sectionRuleDispatchResult) === null || _b === void 0 ? void 0 : _b.isCancelledBecause(45 /* CommandResult.GaugeLowerBiggerThanUpper */)));
20514
20593
  }
20515
20594
  updateInflectionPointValue(attr, ev) {
20516
20595
  const sectionRule = deepCopy(this.props.definition.sectionRule);
@@ -20623,11 +20702,11 @@ class ScorecardChartConfigPanel extends Component {
20623
20702
  }
20624
20703
  get isKeyValueInvalid() {
20625
20704
  var _a;
20626
- return !!((_a = this.state.keyValueDispatchResult) === null || _a === void 0 ? void 0 : _a.isCancelledBecause(34 /* CommandResult.InvalidScorecardKeyValue */));
20705
+ return !!((_a = this.state.keyValueDispatchResult) === null || _a === void 0 ? void 0 : _a.isCancelledBecause(35 /* CommandResult.InvalidScorecardKeyValue */));
20627
20706
  }
20628
20707
  get isBaselineInvalid() {
20629
20708
  var _a;
20630
- return !!((_a = this.state.keyValueDispatchResult) === null || _a === void 0 ? void 0 : _a.isCancelledBecause(35 /* CommandResult.InvalidScorecardBaseline */));
20709
+ return !!((_a = this.state.keyValueDispatchResult) === null || _a === void 0 ? void 0 : _a.isCancelledBecause(36 /* CommandResult.InvalidScorecardBaseline */));
20631
20710
  }
20632
20711
  onKeyValueRangeChanged(ranges) {
20633
20712
  this.keyValue = ranges[0];
@@ -21483,11 +21562,11 @@ class ConditionalFormattingPanel extends Component {
21483
21562
  ****************************************************************************/
21484
21563
  get isValue1Invalid() {
21485
21564
  var _a;
21486
- return !!((_a = this.state.errors) === null || _a === void 0 ? void 0 : _a.includes(51 /* CommandResult.FirstArgMissing */));
21565
+ return !!((_a = this.state.errors) === null || _a === void 0 ? void 0 : _a.includes(52 /* CommandResult.FirstArgMissing */));
21487
21566
  }
21488
21567
  get isValue2Invalid() {
21489
21568
  var _a;
21490
- return !!((_a = this.state.errors) === null || _a === void 0 ? void 0 : _a.includes(52 /* CommandResult.SecondArgMissing */));
21569
+ return !!((_a = this.state.errors) === null || _a === void 0 ? void 0 : _a.includes(53 /* CommandResult.SecondArgMissing */));
21491
21570
  }
21492
21571
  toggleStyle(tool) {
21493
21572
  const style = this.state.rules.cellIs.style;
@@ -21504,17 +21583,17 @@ class ConditionalFormattingPanel extends Component {
21504
21583
  isValueInvalid(threshold) {
21505
21584
  switch (threshold) {
21506
21585
  case "minimum":
21507
- return (this.state.errors.includes(58 /* CommandResult.MinInvalidFormula */) ||
21508
- this.state.errors.includes(50 /* CommandResult.MinBiggerThanMid */) ||
21509
- this.state.errors.includes(47 /* CommandResult.MinBiggerThanMax */) ||
21510
- this.state.errors.includes(53 /* CommandResult.MinNaN */));
21586
+ return (this.state.errors.includes(59 /* CommandResult.MinInvalidFormula */) ||
21587
+ this.state.errors.includes(51 /* CommandResult.MinBiggerThanMid */) ||
21588
+ this.state.errors.includes(48 /* CommandResult.MinBiggerThanMax */) ||
21589
+ this.state.errors.includes(54 /* CommandResult.MinNaN */));
21511
21590
  case "midpoint":
21512
- return (this.state.errors.includes(59 /* CommandResult.MidInvalidFormula */) ||
21513
- this.state.errors.includes(54 /* CommandResult.MidNaN */) ||
21514
- this.state.errors.includes(49 /* CommandResult.MidBiggerThanMax */));
21591
+ return (this.state.errors.includes(60 /* CommandResult.MidInvalidFormula */) ||
21592
+ this.state.errors.includes(55 /* CommandResult.MidNaN */) ||
21593
+ this.state.errors.includes(50 /* CommandResult.MidBiggerThanMax */));
21515
21594
  case "maximum":
21516
- return (this.state.errors.includes(60 /* CommandResult.MaxInvalidFormula */) ||
21517
- this.state.errors.includes(55 /* CommandResult.MaxNaN */));
21595
+ return (this.state.errors.includes(61 /* CommandResult.MaxInvalidFormula */) ||
21596
+ this.state.errors.includes(56 /* CommandResult.MaxNaN */));
21518
21597
  default:
21519
21598
  return false;
21520
21599
  }
@@ -21563,13 +21642,13 @@ class ConditionalFormattingPanel extends Component {
21563
21642
  isInflectionPointInvalid(inflectionPoint) {
21564
21643
  switch (inflectionPoint) {
21565
21644
  case "lowerInflectionPoint":
21566
- return (this.state.errors.includes(57 /* CommandResult.ValueLowerInflectionNaN */) ||
21567
- this.state.errors.includes(62 /* CommandResult.ValueLowerInvalidFormula */) ||
21568
- this.state.errors.includes(48 /* CommandResult.LowerBiggerThanUpper */));
21645
+ return (this.state.errors.includes(58 /* CommandResult.ValueLowerInflectionNaN */) ||
21646
+ this.state.errors.includes(63 /* CommandResult.ValueLowerInvalidFormula */) ||
21647
+ this.state.errors.includes(49 /* CommandResult.LowerBiggerThanUpper */));
21569
21648
  case "upperInflectionPoint":
21570
- return (this.state.errors.includes(56 /* CommandResult.ValueUpperInflectionNaN */) ||
21571
- this.state.errors.includes(61 /* CommandResult.ValueUpperInvalidFormula */) ||
21572
- this.state.errors.includes(48 /* CommandResult.LowerBiggerThanUpper */));
21649
+ return (this.state.errors.includes(57 /* CommandResult.ValueUpperInflectionNaN */) ||
21650
+ this.state.errors.includes(62 /* CommandResult.ValueUpperInvalidFormula */) ||
21651
+ this.state.errors.includes(49 /* CommandResult.LowerBiggerThanUpper */));
21573
21652
  default:
21574
21653
  return true;
21575
21654
  }
@@ -22599,7 +22678,10 @@ class GridOverlay extends Component {
22599
22678
  return;
22600
22679
  }
22601
22680
  const [col, row] = this.getCartesianCoordinates(ev);
22602
- this.props.onCellClicked(col, row, { shiftKey: ev.shiftKey, ctrlKey: ev.ctrlKey });
22681
+ this.props.onCellClicked(col, row, {
22682
+ expandZone: ev.shiftKey,
22683
+ addZone: isCtrlKey(ev),
22684
+ });
22603
22685
  }
22604
22686
  onDoubleClick(ev) {
22605
22687
  const [col, row] = this.getCartesianCoordinates(ev);
@@ -22687,6 +22769,7 @@ class AbstractResizer extends Component {
22687
22769
  draggerShadowThickness: 0,
22688
22770
  delta: 0,
22689
22771
  base: 0,
22772
+ position: "before",
22690
22773
  });
22691
22774
  }
22692
22775
  _computeHandleDisplay(ev) {
@@ -22812,11 +22895,13 @@ class AbstractResizer extends Component {
22812
22895
  this.state.draggerLinePosition = dimensions.start;
22813
22896
  this.state.draggerShadowPosition = dimensions.start;
22814
22897
  this.state.base = elementIndex;
22898
+ this.state.position = "before";
22815
22899
  }
22816
22900
  else if (this._getSelectedZoneEnd() < elementIndex) {
22817
22901
  this.state.draggerLinePosition = dimensions.end;
22818
22902
  this.state.draggerShadowPosition = dimensions.end - this.state.draggerShadowThickness;
22819
- this.state.base = elementIndex + 1;
22903
+ this.state.base = elementIndex;
22904
+ this.state.position = "after";
22820
22905
  }
22821
22906
  else {
22822
22907
  this.state.draggerLinePosition = startDimensions.start;
@@ -22840,7 +22925,7 @@ class AbstractResizer extends Component {
22840
22925
  this._increaseSelection(index);
22841
22926
  }
22842
22927
  else {
22843
- this._selectElement(index, ev.ctrlKey);
22928
+ this._selectElement(index, isCtrlKey(ev));
22844
22929
  }
22845
22930
  this.lastSelectedElementIndex = index;
22846
22931
  const mouseMoveSelect = (col, row) => {
@@ -22853,7 +22938,7 @@ class AbstractResizer extends Component {
22853
22938
  const mouseUpSelect = () => {
22854
22939
  this.state.isSelecting = false;
22855
22940
  this.lastSelectedElementIndex = null;
22856
- this.env.model.dispatch(ev.ctrlKey ? "PREPARE_SELECTION_INPUT_EXPANSION" : "STOP_SELECTION_INPUT");
22941
+ this.env.model.dispatch(isCtrlKey(ev) ? "PREPARE_SELECTION_INPUT_EXPANSION" : "STOP_SELECTION_INPUT");
22857
22942
  this._computeGrabDisplay(ev);
22858
22943
  };
22859
22944
  dragAndDropBeyondTheViewport(this.env, mouseMoveSelect, mouseUpSelect);
@@ -22997,13 +23082,14 @@ class ColResizer extends AbstractResizer {
22997
23082
  dimension: "COL",
22998
23083
  base: this.state.base,
22999
23084
  elements,
23085
+ position: this.state.position,
23000
23086
  });
23001
23087
  if (!result.isSuccessful && result.reasons.includes(2 /* CommandResult.WillRemoveExistingMerge */)) {
23002
23088
  this.env.raiseError(MergeErrorMessage);
23003
23089
  }
23004
23090
  }
23005
- _selectElement(index, ctrlKey) {
23006
- this.env.model.selection.selectColumn(index, ctrlKey ? "newAnchor" : "overrideSelection");
23091
+ _selectElement(index, addDistinctHeader) {
23092
+ this.env.model.selection.selectColumn(index, addDistinctHeader ? "newAnchor" : "overrideSelection");
23007
23093
  }
23008
23094
  _increaseSelection(index) {
23009
23095
  this.env.model.selection.selectColumn(index, "updateAnchor");
@@ -23169,13 +23255,14 @@ class RowResizer extends AbstractResizer {
23169
23255
  dimension: "ROW",
23170
23256
  base: this.state.base,
23171
23257
  elements,
23258
+ position: this.state.position,
23172
23259
  });
23173
23260
  if (!result.isSuccessful && result.reasons.includes(2 /* CommandResult.WillRemoveExistingMerge */)) {
23174
23261
  this.env.raiseError(MergeErrorMessage);
23175
23262
  }
23176
23263
  }
23177
- _selectElement(index, ctrlKey) {
23178
- this.env.model.selection.selectRow(index, ctrlKey ? "newAnchor" : "overrideSelection");
23264
+ _selectElement(index, addDistinctHeader) {
23265
+ this.env.model.selection.selectRow(index, addDistinctHeader ? "newAnchor" : "overrideSelection");
23179
23266
  }
23180
23267
  _increaseSelection(index) {
23181
23268
  this.env.model.selection.selectRow(index, "updateAnchor");
@@ -23277,8 +23364,8 @@ function useWheelHandler(handler) {
23277
23364
  return val * (deltaMode === 0 ? 1 : DEFAULT_CELL_HEIGHT);
23278
23365
  }
23279
23366
  const onMouseWheel = (ev) => {
23280
- const deltaX = normalize(ev.shiftKey ? ev.deltaY : ev.deltaX, ev.deltaMode);
23281
- const deltaY = normalize(ev.shiftKey ? ev.deltaX : ev.deltaY, ev.deltaMode);
23367
+ const deltaX = normalize(ev.shiftKey && !isMacOS() ? ev.deltaY : ev.deltaX, ev.deltaMode);
23368
+ const deltaY = normalize(ev.shiftKey && !isMacOS() ? ev.deltaX : ev.deltaY, ev.deltaMode);
23282
23369
  handler(deltaX, deltaY);
23283
23370
  };
23284
23371
  return onMouseWheel;
@@ -23922,8 +24009,8 @@ class Grid extends Component {
23922
24009
  // ---------------------------------------------------------------------------
23923
24010
  // Zone selection with mouse
23924
24011
  // ---------------------------------------------------------------------------
23925
- onCellClicked(col, row, { ctrlKey, shiftKey }) {
23926
- if (ctrlKey) {
24012
+ onCellClicked(col, row, { addZone, expandZone }) {
24013
+ if (addZone) {
23927
24014
  this.env.model.dispatch("PREPARE_SELECTION_INPUT_EXPANSION");
23928
24015
  }
23929
24016
  if (this.env.model.getters.hasOpenedPopover()) {
@@ -23932,10 +24019,10 @@ class Grid extends Component {
23932
24019
  if (this.env.model.getters.getEditionMode() === "editing") {
23933
24020
  this.env.model.dispatch("STOP_EDITION");
23934
24021
  }
23935
- if (shiftKey) {
24022
+ if (expandZone) {
23936
24023
  this.env.model.selection.setAnchorCorner(col, row);
23937
24024
  }
23938
- else if (ctrlKey) {
24025
+ else if (addZone) {
23939
24026
  this.env.model.selection.addCellToSelection(col, row);
23940
24027
  }
23941
24028
  else {
@@ -23997,9 +24084,7 @@ class Grid extends Component {
23997
24084
  return;
23998
24085
  }
23999
24086
  let keyDownString = "";
24000
- if (ev.ctrlKey)
24001
- keyDownString += "CTRL+";
24002
- if (ev.metaKey)
24087
+ if (isCtrlKey(ev))
24003
24088
  keyDownString += "CTRL+";
24004
24089
  if (ev.altKey)
24005
24090
  keyDownString += "ALT+";
@@ -28359,7 +28444,7 @@ class BordersPlugin extends CorePlugin {
28359
28444
  const currentBorder = this.getCellBorder(cmd);
28360
28445
  const areAllNewBordersUndefined = !((_a = cmd.border) === null || _a === void 0 ? void 0 : _a.bottom) && !((_b = cmd.border) === null || _b === void 0 ? void 0 : _b.left) && !((_c = cmd.border) === null || _c === void 0 ? void 0 : _c.right) && !((_d = cmd.border) === null || _d === void 0 ? void 0 : _d.top);
28361
28446
  if ((!currentBorder && areAllNewBordersUndefined) || deepEquals(currentBorder, cmd.border)) {
28362
- return 88 /* CommandResult.NoChanges */;
28447
+ return 89 /* CommandResult.NoChanges */;
28363
28448
  }
28364
28449
  return 0 /* CommandResult.Success */;
28365
28450
  }
@@ -28881,9 +28966,9 @@ class CellPlugin extends CorePlugin {
28881
28966
  checkUselessClearCell(cmd) {
28882
28967
  const cell = this.getters.getCell(cmd);
28883
28968
  if (!cell)
28884
- return 88 /* CommandResult.NoChanges */;
28969
+ return 89 /* CommandResult.NoChanges */;
28885
28970
  if (!cell.content && !cell.style && !cell.format) {
28886
- return 88 /* CommandResult.NoChanges */;
28971
+ return 89 /* CommandResult.NoChanges */;
28887
28972
  }
28888
28973
  return 0 /* CommandResult.Success */;
28889
28974
  }
@@ -29092,13 +29177,13 @@ class ChartPlugin extends CorePlugin {
29092
29177
  }
29093
29178
  checkChartDuplicate(cmd) {
29094
29179
  return this.getters.getFigureSheetId(cmd.id)
29095
- ? 84 /* CommandResult.DuplicatedChartId */
29180
+ ? 85 /* CommandResult.DuplicatedChartId */
29096
29181
  : 0 /* CommandResult.Success */;
29097
29182
  }
29098
29183
  checkChartExists(cmd) {
29099
29184
  return this.getters.getFigureSheetId(cmd.id)
29100
29185
  ? 0 /* CommandResult.Success */
29101
- : 85 /* CommandResult.ChartDoesNotExist */;
29186
+ : 86 /* CommandResult.ChartDoesNotExist */;
29102
29187
  }
29103
29188
  }
29104
29189
  ChartPlugin.getters = [
@@ -29300,10 +29385,10 @@ class ConditionalFormatPlugin extends CorePlugin {
29300
29385
  return 27 /* CommandResult.InvalidSheetId */;
29301
29386
  const ruleIndex = this.cfRules[sheetId].findIndex((cf) => cf.id === cfId);
29302
29387
  if (ruleIndex === -1)
29303
- return 71 /* CommandResult.InvalidConditionalFormatId */;
29388
+ return 72 /* CommandResult.InvalidConditionalFormatId */;
29304
29389
  const cfIndex2 = direction === "up" ? ruleIndex - 1 : ruleIndex + 1;
29305
29390
  if (cfIndex2 < 0 || cfIndex2 >= this.cfRules[sheetId].length) {
29306
- return 71 /* CommandResult.InvalidConditionalFormatId */;
29391
+ return 72 /* CommandResult.InvalidConditionalFormatId */;
29307
29392
  }
29308
29393
  return 0 /* CommandResult.Success */;
29309
29394
  }
@@ -29344,10 +29429,10 @@ class ConditionalFormatPlugin extends CorePlugin {
29344
29429
  const errors = [];
29345
29430
  const isEmpty = (value) => value === undefined || value === "";
29346
29431
  if (expectedNumber >= 1 && isEmpty(rule.values[0])) {
29347
- errors.push(51 /* CommandResult.FirstArgMissing */);
29432
+ errors.push(52 /* CommandResult.FirstArgMissing */);
29348
29433
  }
29349
29434
  if (expectedNumber >= 2 && isEmpty(rule.values[1])) {
29350
- errors.push(52 /* CommandResult.SecondArgMissing */);
29435
+ errors.push(53 /* CommandResult.SecondArgMissing */);
29351
29436
  }
29352
29437
  return errors.length ? errors : 0 /* CommandResult.Success */;
29353
29438
  }
@@ -29359,15 +29444,15 @@ class ConditionalFormatPlugin extends CorePlugin {
29359
29444
  (threshold.value === "" || isNaN(threshold.value))) {
29360
29445
  switch (thresholdName) {
29361
29446
  case "min":
29362
- return 53 /* CommandResult.MinNaN */;
29447
+ return 54 /* CommandResult.MinNaN */;
29363
29448
  case "max":
29364
- return 55 /* CommandResult.MaxNaN */;
29449
+ return 56 /* CommandResult.MaxNaN */;
29365
29450
  case "mid":
29366
- return 54 /* CommandResult.MidNaN */;
29451
+ return 55 /* CommandResult.MidNaN */;
29367
29452
  case "upperInflectionPoint":
29368
- return 56 /* CommandResult.ValueUpperInflectionNaN */;
29453
+ return 57 /* CommandResult.ValueUpperInflectionNaN */;
29369
29454
  case "lowerInflectionPoint":
29370
- return 57 /* CommandResult.ValueLowerInflectionNaN */;
29455
+ return 58 /* CommandResult.ValueLowerInflectionNaN */;
29371
29456
  }
29372
29457
  }
29373
29458
  return 0 /* CommandResult.Success */;
@@ -29381,15 +29466,15 @@ class ConditionalFormatPlugin extends CorePlugin {
29381
29466
  catch (error) {
29382
29467
  switch (thresholdName) {
29383
29468
  case "min":
29384
- return 58 /* CommandResult.MinInvalidFormula */;
29469
+ return 59 /* CommandResult.MinInvalidFormula */;
29385
29470
  case "max":
29386
- return 60 /* CommandResult.MaxInvalidFormula */;
29471
+ return 61 /* CommandResult.MaxInvalidFormula */;
29387
29472
  case "mid":
29388
- return 59 /* CommandResult.MidInvalidFormula */;
29473
+ return 60 /* CommandResult.MidInvalidFormula */;
29389
29474
  case "upperInflectionPoint":
29390
- return 61 /* CommandResult.ValueUpperInvalidFormula */;
29475
+ return 62 /* CommandResult.ValueUpperInvalidFormula */;
29391
29476
  case "lowerInflectionPoint":
29392
- return 62 /* CommandResult.ValueLowerInvalidFormula */;
29477
+ return 63 /* CommandResult.ValueLowerInvalidFormula */;
29393
29478
  }
29394
29479
  }
29395
29480
  return 0 /* CommandResult.Success */;
@@ -29406,7 +29491,7 @@ class ConditionalFormatPlugin extends CorePlugin {
29406
29491
  if (["number", "percentage", "percentile"].includes(rule.lowerInflectionPoint.type) &&
29407
29492
  rule.lowerInflectionPoint.type === rule.upperInflectionPoint.type &&
29408
29493
  Number(minValue) > Number(maxValue)) {
29409
- return 48 /* CommandResult.LowerBiggerThanUpper */;
29494
+ return 49 /* CommandResult.LowerBiggerThanUpper */;
29410
29495
  }
29411
29496
  return 0 /* CommandResult.Success */;
29412
29497
  }
@@ -29416,7 +29501,7 @@ class ConditionalFormatPlugin extends CorePlugin {
29416
29501
  if (["number", "percentage", "percentile"].includes(rule.minimum.type) &&
29417
29502
  rule.minimum.type === rule.maximum.type &&
29418
29503
  stringToNumber(minValue) >= stringToNumber(maxValue)) {
29419
- return 47 /* CommandResult.MinBiggerThanMax */;
29504
+ return 48 /* CommandResult.MinBiggerThanMax */;
29420
29505
  }
29421
29506
  return 0 /* CommandResult.Success */;
29422
29507
  }
@@ -29428,7 +29513,7 @@ class ConditionalFormatPlugin extends CorePlugin {
29428
29513
  ["number", "percentage", "percentile"].includes(rule.midpoint.type) &&
29429
29514
  rule.midpoint.type === rule.maximum.type &&
29430
29515
  stringToNumber(midValue) >= stringToNumber(maxValue)) {
29431
- return 49 /* CommandResult.MidBiggerThanMax */;
29516
+ return 50 /* CommandResult.MidBiggerThanMax */;
29432
29517
  }
29433
29518
  return 0 /* CommandResult.Success */;
29434
29519
  }
@@ -29440,7 +29525,7 @@ class ConditionalFormatPlugin extends CorePlugin {
29440
29525
  ["number", "percentage", "percentile"].includes(rule.midpoint.type) &&
29441
29526
  rule.minimum.type === rule.midpoint.type &&
29442
29527
  stringToNumber(minValue) >= stringToNumber(midValue)) {
29443
- return 50 /* CommandResult.MinBiggerThanMid */;
29528
+ return 51 /* CommandResult.MinBiggerThanMid */;
29444
29529
  }
29445
29530
  return 0 /* CommandResult.Success */;
29446
29531
  }
@@ -29541,13 +29626,13 @@ class FigurePlugin extends CorePlugin {
29541
29626
  checkFigureExists(sheetId, figureId) {
29542
29627
  var _a;
29543
29628
  if (((_a = this.figures[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId]) === undefined) {
29544
- return 70 /* CommandResult.FigureDoesNotExist */;
29629
+ return 71 /* CommandResult.FigureDoesNotExist */;
29545
29630
  }
29546
29631
  return 0 /* CommandResult.Success */;
29547
29632
  }
29548
29633
  checkFigureDuplicate(figureId) {
29549
29634
  if (Object.values(this.figures).find((sheet) => sheet === null || sheet === void 0 ? void 0 : sheet[figureId])) {
29550
- return 82 /* CommandResult.DuplicatedFigureId */;
29635
+ return 83 /* CommandResult.DuplicatedFigureId */;
29551
29636
  }
29552
29637
  return 0 /* CommandResult.Success */;
29553
29638
  }
@@ -29649,12 +29734,12 @@ class FiltersPlugin extends CorePlugin {
29649
29734
  switch (cmd.type) {
29650
29735
  case "CREATE_FILTER_TABLE":
29651
29736
  if (!areZonesContinuous(...cmd.target)) {
29652
- return 81 /* CommandResult.NonContinuousTargets */;
29737
+ return 82 /* CommandResult.NonContinuousTargets */;
29653
29738
  }
29654
29739
  const zone = union(...cmd.target);
29655
29740
  const checkFilterOverlap = () => {
29656
29741
  if (this.getFilterTables(cmd.sheetId).some((filter) => overlap(filter.zone, zone))) {
29657
- return 78 /* CommandResult.FilterOverlap */;
29742
+ return 79 /* CommandResult.FilterOverlap */;
29658
29743
  }
29659
29744
  return 0 /* CommandResult.Success */;
29660
29745
  };
@@ -29662,7 +29747,7 @@ class FiltersPlugin extends CorePlugin {
29662
29747
  const mergesInTarget = this.getters.getMergesInZone(cmd.sheetId, zone);
29663
29748
  for (let merge of mergesInTarget) {
29664
29749
  if (overlap(zone, merge)) {
29665
- return 80 /* CommandResult.MergeInFilter */;
29750
+ return 81 /* CommandResult.MergeInFilter */;
29666
29751
  }
29667
29752
  }
29668
29753
  return 0 /* CommandResult.Success */;
@@ -29672,7 +29757,7 @@ class FiltersPlugin extends CorePlugin {
29672
29757
  for (let merge of cmd.target) {
29673
29758
  for (let filterTable of this.getFilterTables(cmd.sheetId)) {
29674
29759
  if (overlap(filterTable.zone, merge)) {
29675
- return 80 /* CommandResult.MergeInFilter */;
29760
+ return 81 /* CommandResult.MergeInFilter */;
29676
29761
  }
29677
29762
  }
29678
29763
  }
@@ -30172,10 +30257,10 @@ class HeaderVisibilityPlugin extends CorePlugin {
30172
30257
  : this.getters.getNumberRows(cmd.sheetId);
30173
30258
  const hiddenElements = new Set((hiddenGroup || []).flat().concat(cmd.elements));
30174
30259
  if (hiddenElements.size >= elements) {
30175
- return 66 /* CommandResult.TooManyHiddenElements */;
30260
+ return 67 /* CommandResult.TooManyHiddenElements */;
30176
30261
  }
30177
30262
  else if (Math.min(...cmd.elements) < 0 || Math.max(...cmd.elements) > elements) {
30178
- return 86 /* CommandResult.InvalidHeaderIndex */;
30263
+ return 87 /* CommandResult.InvalidHeaderIndex */;
30179
30264
  }
30180
30265
  else {
30181
30266
  return 0 /* CommandResult.Success */;
@@ -30701,7 +30786,7 @@ class MergePlugin extends CorePlugin {
30701
30786
  for (const zone of target) {
30702
30787
  for (const zone2 of target) {
30703
30788
  if (zone !== zone2 && overlap(zone, zone2)) {
30704
- return 65 /* CommandResult.MergeOverlap */;
30789
+ return 66 /* CommandResult.MergeOverlap */;
30705
30790
  }
30706
30791
  }
30707
30792
  }
@@ -30715,7 +30800,7 @@ class MergePlugin extends CorePlugin {
30715
30800
  for (const zone of target) {
30716
30801
  if ((zone.left < xSplit && zone.right >= xSplit) ||
30717
30802
  (zone.top < ySplit && zone.bottom >= ySplit)) {
30718
- return 75 /* CommandResult.FrozenPaneOverlap */;
30803
+ return 76 /* CommandResult.FrozenPaneOverlap */;
30719
30804
  }
30720
30805
  }
30721
30806
  return 0 /* CommandResult.Success */;
@@ -31247,9 +31332,10 @@ class RangeAdapter {
31247
31332
  * Get a Xc string that represent a part of a range
31248
31333
  */
31249
31334
  getRangePartString(range, part) {
31250
- const colFixed = range.parts && range.parts[part].colFixed ? "$" : "";
31335
+ var _a, _b;
31336
+ const colFixed = range.parts && ((_a = range.parts[part]) === null || _a === void 0 ? void 0 : _a.colFixed) ? "$" : "";
31251
31337
  const col = part === 0 ? numberToLetters(range.zone.left) : numberToLetters(range.zone.right);
31252
- const rowFixed = range.parts && range.parts[part].rowFixed ? "$" : "";
31338
+ const rowFixed = range.parts && ((_b = range.parts[part]) === null || _b === void 0 ? void 0 : _b.rowFixed) ? "$" : "";
31253
31339
  const row = part === 0 ? String(range.zone.top + 1) : String(range.zone.bottom + 1);
31254
31340
  let str = "";
31255
31341
  if (range.isFullCol) {
@@ -31347,11 +31433,11 @@ class SheetPlugin extends CorePlugin {
31347
31433
  const elements = cmd.dimension === "COL"
31348
31434
  ? this.getNumberCols(cmd.sheetId)
31349
31435
  : this.getNumberRows(cmd.sheetId);
31350
- if (cmd.base < 0 || cmd.base > elements) {
31351
- return 86 /* CommandResult.InvalidHeaderIndex */;
31436
+ if (cmd.base < 0 || cmd.base >= elements) {
31437
+ return 87 /* CommandResult.InvalidHeaderIndex */;
31352
31438
  }
31353
31439
  else if (cmd.quantity <= 0) {
31354
- return 87 /* CommandResult.InvalidQuantity */;
31440
+ return 88 /* CommandResult.InvalidQuantity */;
31355
31441
  }
31356
31442
  return 0 /* CommandResult.Success */;
31357
31443
  case "REMOVE_COLUMNS_ROWS": {
@@ -31359,7 +31445,7 @@ class SheetPlugin extends CorePlugin {
31359
31445
  ? this.getNumberCols(cmd.sheetId)
31360
31446
  : this.getNumberRows(cmd.sheetId);
31361
31447
  if (Math.min(...cmd.elements) < 0 || Math.max(...cmd.elements) > elements) {
31362
- return 86 /* CommandResult.InvalidHeaderIndex */;
31448
+ return 87 /* CommandResult.InvalidHeaderIndex */;
31363
31449
  }
31364
31450
  else if (this.checkElementsIncludeAllNonFrozenHeaders(cmd.sheetId, cmd.dimension, cmd.elements)) {
31365
31451
  return 8 /* CommandResult.NotEnoughElements */;
@@ -31803,18 +31889,18 @@ class SheetPlugin extends CorePlugin {
31803
31889
  checkRowFreezeQuantity(cmd) {
31804
31890
  return cmd.quantity >= 1 && cmd.quantity < this.getNumberRows(cmd.sheetId)
31805
31891
  ? 0 /* CommandResult.Success */
31806
- : 74 /* CommandResult.InvalidFreezeQuantity */;
31892
+ : 75 /* CommandResult.InvalidFreezeQuantity */;
31807
31893
  }
31808
31894
  checkColFreezeQuantity(cmd) {
31809
31895
  return cmd.quantity >= 1 && cmd.quantity < this.getNumberCols(cmd.sheetId)
31810
31896
  ? 0 /* CommandResult.Success */
31811
- : 74 /* CommandResult.InvalidFreezeQuantity */;
31897
+ : 75 /* CommandResult.InvalidFreezeQuantity */;
31812
31898
  }
31813
31899
  checkRowFreezeOverlapMerge(cmd) {
31814
31900
  const merges = this.getters.getMerges(cmd.sheetId);
31815
31901
  for (let merge of merges) {
31816
31902
  if (merge.top < cmd.quantity && cmd.quantity <= merge.bottom) {
31817
- return 65 /* CommandResult.MergeOverlap */;
31903
+ return 66 /* CommandResult.MergeOverlap */;
31818
31904
  }
31819
31905
  }
31820
31906
  return 0 /* CommandResult.Success */;
@@ -31823,7 +31909,7 @@ class SheetPlugin extends CorePlugin {
31823
31909
  const merges = this.getters.getMerges(cmd.sheetId);
31824
31910
  for (let merge of merges) {
31825
31911
  if (merge.left < cmd.quantity && cmd.quantity <= merge.right) {
31826
- return 65 /* CommandResult.MergeOverlap */;
31912
+ return 66 /* CommandResult.MergeOverlap */;
31827
31913
  }
31828
31914
  }
31829
31915
  return 0 /* CommandResult.Success */;
@@ -32370,13 +32456,18 @@ class EvaluationPlugin extends UIPlugin {
32370
32456
  // Getters
32371
32457
  // ---------------------------------------------------------------------------
32372
32458
  evaluateFormula(formulaString, sheetId = this.getters.getActiveSheetId()) {
32373
- const compiledFormula = compile(formulaString);
32374
- const params = this.getCompilationParameters((cell) => this.getEvaluatedCell(this.getters.getCellPosition(cell.id)));
32375
- const ranges = [];
32376
- for (let xc of compiledFormula.dependencies) {
32377
- ranges.push(this.getters.getRangeFromSheetXC(sheetId, xc));
32459
+ try {
32460
+ const compiledFormula = compile(formulaString);
32461
+ const params = this.getCompilationParameters((cell) => this.getEvaluatedCell(this.getters.getCellPosition(cell.id)));
32462
+ const ranges = [];
32463
+ for (let xc of compiledFormula.dependencies) {
32464
+ ranges.push(this.getters.getRangeFromSheetXC(sheetId, xc));
32465
+ }
32466
+ return compiledFormula.execute(ranges, ...params).value;
32467
+ }
32468
+ catch (error) {
32469
+ return error instanceof EvaluationError ? error.errorType : CellErrorType.GenericError;
32378
32470
  }
32379
- return compiledFormula.execute(ranges, ...params).value;
32380
32471
  }
32381
32472
  /**
32382
32473
  * Return the value of each cell in the range as they are displayed in the grid.
@@ -32555,10 +32646,8 @@ class EvaluationPlugin extends UIPlugin {
32555
32646
  * that are actually present in the grid.
32556
32647
  */
32557
32648
  function range(range) {
32649
+ assertRangeValid(range);
32558
32650
  const sheetId = range.sheetId;
32559
- if (!isZoneValid(range.zone)) {
32560
- throw new InvalidReferenceError();
32561
- }
32562
32651
  // Performance issue: Avoid fetching data on positions that are out of the spreadsheet
32563
32652
  // e.g. A1:ZZZ9999 in a sheet with 10 cols and 10 rows should ignore everything past J10 and return a 10x10 array
32564
32653
  const sheetZone = getters.getSheetZone(sheetId);
@@ -32593,23 +32682,26 @@ class EvaluationPlugin extends UIPlugin {
32593
32682
  * The `compute` of the formula's function must process it completely
32594
32683
  */
32595
32684
  function refFn(range, isMeta, functionName, paramNumber) {
32685
+ assertRangeValid(range);
32596
32686
  if (isMeta) {
32597
32687
  // Use zoneToXc of zone instead of getRangeString to avoid sending unbounded ranges
32598
32688
  return { value: zoneToXc(range.zone) };
32599
32689
  }
32600
- if (!isZoneValid(range.zone)) {
32601
- throw new InvalidReferenceError();
32602
- }
32603
32690
  // if the formula definition could have accepted a range, we would pass through the _range function and not here
32604
32691
  if (range.zone.bottom !== range.zone.top || range.zone.left !== range.zone.right) {
32605
32692
  throw new Error(paramNumber
32606
32693
  ? _lt("Function %s expects the parameter %s to be a single value or a single cell reference, not a range.", functionName.toString(), paramNumber.toString())
32607
32694
  : _lt("Function %s expects its parameters to be single values or single cell references, not ranges.", functionName.toString()));
32608
32695
  }
32696
+ return readCell(range);
32697
+ }
32698
+ function assertRangeValid(range) {
32699
+ if (!isZoneValid(range.zone)) {
32700
+ throw new InvalidReferenceError();
32701
+ }
32609
32702
  if (range.invalidSheetName) {
32610
32703
  throw new Error(_lt("Invalid sheet name: %s", range.invalidSheetName));
32611
32704
  }
32612
- return readCell(range);
32613
32705
  }
32614
32706
  return [refFn, range, evalContext];
32615
32707
  }
@@ -32868,39 +32960,34 @@ class EvaluationConditionalFormatPlugin extends UIPlugin {
32868
32960
  this.computedIcons[sheetId] = {};
32869
32961
  const computedStyle = this.computedStyles[sheetId];
32870
32962
  for (let cf of this.getters.getConditionalFormats(sheetId).reverse()) {
32871
- try {
32872
- switch (cf.rule.type) {
32873
- case "ColorScaleRule":
32874
- for (let range of cf.ranges) {
32875
- this.applyColorScale(range, cf.rule);
32876
- }
32877
- break;
32878
- case "IconSetRule":
32879
- for (let range of cf.ranges) {
32880
- this.applyIcon(range, cf.rule);
32881
- }
32882
- break;
32883
- default:
32884
- for (let ref of cf.ranges) {
32885
- const zone = this.getters.getRangeFromSheetXC(sheetId, ref).zone;
32886
- for (let row = zone.top; row <= zone.bottom; row++) {
32887
- for (let col = zone.left; col <= zone.right; col++) {
32888
- const pr = this.rulePredicate[cf.rule.type];
32889
- let cell = this.getters.getEvaluatedCell({ sheetId, col, row });
32890
- if (pr && pr(cell, cf.rule)) {
32891
- if (!computedStyle[col])
32892
- computedStyle[col] = [];
32893
- // we must combine all the properties of all the CF rules applied to the given cell
32894
- computedStyle[col][row] = Object.assign(((_a = computedStyle[col]) === null || _a === void 0 ? void 0 : _a[row]) || {}, cf.rule.style);
32895
- }
32963
+ switch (cf.rule.type) {
32964
+ case "ColorScaleRule":
32965
+ for (let range of cf.ranges) {
32966
+ this.applyColorScale(range, cf.rule);
32967
+ }
32968
+ break;
32969
+ case "IconSetRule":
32970
+ for (let range of cf.ranges) {
32971
+ this.applyIcon(range, cf.rule);
32972
+ }
32973
+ break;
32974
+ default:
32975
+ for (let ref of cf.ranges) {
32976
+ const zone = this.getters.getRangeFromSheetXC(sheetId, ref).zone;
32977
+ for (let row = zone.top; row <= zone.bottom; row++) {
32978
+ for (let col = zone.left; col <= zone.right; col++) {
32979
+ const pr = this.rulePredicate[cf.rule.type];
32980
+ let cell = this.getters.getEvaluatedCell({ sheetId, col, row });
32981
+ if (pr && pr(cell, cf.rule)) {
32982
+ if (!computedStyle[col])
32983
+ computedStyle[col] = [];
32984
+ // we must combine all the properties of all the CF rules applied to the given cell
32985
+ computedStyle[col][row] = Object.assign(((_a = computedStyle[col]) === null || _a === void 0 ? void 0 : _a[row]) || {}, cf.rule.style);
32896
32986
  }
32897
32987
  }
32898
32988
  }
32899
- break;
32900
- }
32901
- }
32902
- catch (_) {
32903
- // we don't care about the errors within the evaluation of a rule
32989
+ }
32990
+ break;
32904
32991
  }
32905
32992
  }
32906
32993
  }
@@ -32925,7 +33012,7 @@ class EvaluationConditionalFormatPlugin extends UIPlugin {
32925
33012
  return percentile(rangeValues, Number(threshold.value) / 100, true);
32926
33013
  case "formula":
32927
33014
  const value = threshold.value && this.getters.evaluateFormula(threshold.value);
32928
- return !(value instanceof Promise) ? value : null;
33015
+ return typeof value === "number" ? value : null;
32929
33016
  default:
32930
33017
  return null;
32931
33018
  }
@@ -33113,7 +33200,7 @@ class FilterEvaluationPlugin extends UIPlugin {
33113
33200
  switch (cmd.type) {
33114
33201
  case "UPDATE_FILTER":
33115
33202
  if (!this.getters.getFilterId(cmd)) {
33116
- return 79 /* CommandResult.FilterNotFound */;
33203
+ return 80 /* CommandResult.FilterNotFound */;
33117
33204
  }
33118
33205
  break;
33119
33206
  }
@@ -34059,7 +34146,7 @@ class SheetViewPlugin extends UIPlugin {
34059
34146
  }
34060
34147
  checkPositiveDimension(cmd) {
34061
34148
  if (cmd.width < 0 || cmd.height < 0) {
34062
- return 68 /* CommandResult.InvalidViewportSize */;
34149
+ return 69 /* CommandResult.InvalidViewportSize */;
34063
34150
  }
34064
34151
  return 0 /* CommandResult.Success */;
34065
34152
  }
@@ -34069,7 +34156,7 @@ class SheetViewPlugin extends UIPlugin {
34069
34156
  cmd.gridOffsetY === this.gridOffsetY &&
34070
34157
  cmd.width === width &&
34071
34158
  cmd.height === height) {
34072
- return 76 /* CommandResult.ValuesNotChanged */;
34159
+ return 77 /* CommandResult.ValuesNotChanged */;
34073
34160
  }
34074
34161
  return 0 /* CommandResult.Success */;
34075
34162
  }
@@ -34077,7 +34164,7 @@ class SheetViewPlugin extends UIPlugin {
34077
34164
  const pane = this.getMainInternalViewport(this.getters.getActiveSheetId());
34078
34165
  if ((!pane.canScrollHorizontally && offsetX > 0) ||
34079
34166
  (!pane.canScrollVertically && offsetY > 0)) {
34080
- return 69 /* CommandResult.InvalidScrollingDirection */;
34167
+ return 70 /* CommandResult.InvalidScrollingDirection */;
34081
34168
  }
34082
34169
  return 0 /* CommandResult.Success */;
34083
34170
  }
@@ -34333,7 +34420,7 @@ class AutofillPlugin extends UIPlugin {
34333
34420
  if (this.lastCellSelected.col !== undefined && this.lastCellSelected.row !== undefined) {
34334
34421
  return 0 /* CommandResult.Success */;
34335
34422
  }
34336
- return 45 /* CommandResult.InvalidAutofillSelection */;
34423
+ return 46 /* CommandResult.InvalidAutofillSelection */;
34337
34424
  case "AUTOFILL_AUTO":
34338
34425
  const zone = this.getters.getSelectedZone();
34339
34426
  return zone.top === zone.bottom
@@ -34487,24 +34574,27 @@ class AutofillPlugin extends UIPlugin {
34487
34574
  * autofiller
34488
34575
  */
34489
34576
  autofillAuto() {
34577
+ var _a, _b;
34490
34578
  const zone = this.getters.getSelectedZone();
34491
34579
  const sheetId = this.getters.getActiveSheetId();
34492
34580
  let col = zone.left;
34493
34581
  let row = zone.bottom;
34494
34582
  if (col > 0) {
34495
- let left = this.getters.getEvaluatedCell({ sheetId, col: col - 1, row });
34496
- while (left.type !== CellValueType.empty) {
34583
+ let leftPosition = { sheetId, col: col - 1, row };
34584
+ while (this.getters.getEvaluatedCell(leftPosition).type !== CellValueType.empty ||
34585
+ ((_a = this.getters.getCell(leftPosition)) === null || _a === void 0 ? void 0 : _a.content)) {
34497
34586
  row += 1;
34498
- left = this.getters.getEvaluatedCell({ sheetId, col: col - 1, row });
34587
+ leftPosition = { sheetId, col: col - 1, row };
34499
34588
  }
34500
34589
  }
34501
34590
  if (row === zone.bottom) {
34502
34591
  col = zone.right;
34503
34592
  if (col <= this.getters.getNumberCols(sheetId)) {
34504
- let right = this.getters.getEvaluatedCell({ sheetId, col: col + 1, row });
34505
- while (right.type !== CellValueType.empty) {
34593
+ let rightPosition = { sheetId, col: col + 1, row };
34594
+ while (this.getters.getEvaluatedCell(rightPosition).type !== CellValueType.empty ||
34595
+ ((_b = this.getters.getCell(rightPosition)) === null || _b === void 0 ? void 0 : _b.content)) {
34506
34596
  row += 1;
34507
- right = this.getters.getEvaluatedCell({ sheetId, col: col + 1, row });
34597
+ rightPosition = { sheetId, col: col + 1, row };
34508
34598
  }
34509
34599
  }
34510
34600
  }
@@ -34932,7 +35022,7 @@ class CellPopoverPlugin extends UIPlugin {
34932
35022
  cellPopoverRegistry.get(cmd.popoverType);
34933
35023
  }
34934
35024
  catch (error) {
34935
- return 72 /* CommandResult.InvalidCellPopover */;
35025
+ return 73 /* CommandResult.InvalidCellPopover */;
34936
35026
  }
34937
35027
  return 0 /* CommandResult.Success */;
34938
35028
  default:
@@ -36135,21 +36225,6 @@ class SelectionInputPlugin extends UIPlugin {
36135
36225
  // ---------------------------------------------------------------------------
36136
36226
  // Command Handling
36137
36227
  // ---------------------------------------------------------------------------
36138
- allowDispatch(cmd) {
36139
- switch (cmd.type) {
36140
- case "ADD_EMPTY_RANGE":
36141
- if (this.inputHasSingleRange && this.ranges.length === 1) {
36142
- return 30 /* CommandResult.MaximumRangesReached */;
36143
- }
36144
- break;
36145
- case "CHANGE_RANGE":
36146
- if (this.inputHasSingleRange && cmd.value.split(",").length > 1) {
36147
- return 30 /* CommandResult.MaximumRangesReached */;
36148
- }
36149
- break;
36150
- }
36151
- return 0 /* CommandResult.Success */;
36152
- }
36153
36228
  handleEvent(event) {
36154
36229
  const xc = zoneToXc(event.anchor.zone);
36155
36230
  const inputSheetId = this.activeSheet;
@@ -36361,6 +36436,15 @@ class SelectionInputsManagerPlugin extends UIPlugin {
36361
36436
  // ---------------------------------------------------------------------------
36362
36437
  allowDispatch(cmd) {
36363
36438
  var _a, _b;
36439
+ switch (cmd.type) {
36440
+ case "FOCUS_RANGE":
36441
+ case "CHANGE_RANGE":
36442
+ case "ADD_EMPTY_RANGE":
36443
+ case "REMOVE_RANGE":
36444
+ if (!this.inputs[cmd.id]) {
36445
+ return 31 /* CommandResult.InvalidInputId */;
36446
+ }
36447
+ }
36364
36448
  switch (cmd.type) {
36365
36449
  case "FOCUS_RANGE":
36366
36450
  const index = (_a = this.currentInput) === null || _a === void 0 ? void 0 : _a.getIndex(cmd.rangeId);
@@ -36368,9 +36452,19 @@ class SelectionInputsManagerPlugin extends UIPlugin {
36368
36452
  return 29 /* CommandResult.InputAlreadyFocused */;
36369
36453
  }
36370
36454
  break;
36371
- }
36372
- if (this.currentInput) {
36373
- return this.currentInput.allowDispatch(cmd);
36455
+ case "ADD_EMPTY_RANGE":
36456
+ const input = this.inputs[cmd.id];
36457
+ if (input.inputHasSingleRange && input.ranges.length === 1) {
36458
+ return 30 /* CommandResult.MaximumRangesReached */;
36459
+ }
36460
+ break;
36461
+ case "CHANGE_RANGE": {
36462
+ const input = this.inputs[cmd.id];
36463
+ if (input.inputHasSingleRange && cmd.value.split(",").length > 1) {
36464
+ return 30 /* CommandResult.MaximumRangesReached */;
36465
+ }
36466
+ break;
36467
+ }
36374
36468
  }
36375
36469
  return 0 /* CommandResult.Success */;
36376
36470
  }
@@ -37353,7 +37447,7 @@ class SortPlugin extends UIPlugin {
37353
37447
  /*Test the presence of single cells*/
37354
37448
  const singleCells = positions(zone).some(({ col, row }) => !this.getters.isInMerge({ sheetId, col, row }));
37355
37449
  if (singleCells) {
37356
- return 63 /* CommandResult.InvalidSortZone */;
37450
+ return 64 /* CommandResult.InvalidSortZone */;
37357
37451
  }
37358
37452
  return 0 /* CommandResult.Success */;
37359
37453
  }
@@ -37372,7 +37466,7 @@ class SortPlugin extends UIPlugin {
37372
37466
  ];
37373
37467
  return widthCurrent === widthFirst && heightCurrent === heightFirst;
37374
37468
  })) {
37375
- return 63 /* CommandResult.InvalidSortZone */;
37469
+ return 64 /* CommandResult.InvalidSortZone */;
37376
37470
  }
37377
37471
  return 0 /* CommandResult.Success */;
37378
37472
  }
@@ -38000,7 +38094,7 @@ class ClipboardCellsState extends ClipboardCellsAbstractState {
38000
38094
  for (const zone of this.getPasteZones(target)) {
38001
38095
  if ((zone.left < xSplit && zone.right >= xSplit) ||
38002
38096
  (zone.top < ySplit && zone.bottom >= ySplit)) {
38003
- return 75 /* CommandResult.FrozenPaneOverlap */;
38097
+ return 76 /* CommandResult.FrozenPaneOverlap */;
38004
38098
  }
38005
38099
  }
38006
38100
  return 0 /* CommandResult.Success */;
@@ -38388,7 +38482,7 @@ class ClipboardFigureState {
38388
38482
  }
38389
38483
  isPasteAllowed(target, option) {
38390
38484
  if (target.length === 0) {
38391
- return 73 /* CommandResult.EmptyTarget */;
38485
+ return 74 /* CommandResult.EmptyTarget */;
38392
38486
  }
38393
38487
  if ((option === null || option === void 0 ? void 0 : option.pasteOption) !== undefined) {
38394
38488
  return 22 /* CommandResult.WrongFigurePasteOption */;
@@ -39236,7 +39330,7 @@ class GridSelectionPlugin extends UIPlugin {
39236
39330
  sheetId: cmd.sheetId,
39237
39331
  base: cmd.base,
39238
39332
  quantity: thickness,
39239
- position: "before",
39333
+ position: cmd.position,
39240
39334
  });
39241
39335
  const isCol = cmd.dimension === "COL";
39242
39336
  const start = cmd.elements[0];
@@ -39253,12 +39347,13 @@ class GridSelectionPlugin extends UIPlugin {
39253
39347
  },
39254
39348
  ];
39255
39349
  const state = new ClipboardCellsState(target, "CUT", this.getters, this.dispatch, this.selection);
39350
+ const base = isBasedBefore ? cmd.base : cmd.base + 1;
39256
39351
  const pasteTarget = [
39257
39352
  {
39258
- left: isCol ? cmd.base : 0,
39259
- right: isCol ? cmd.base + thickness - 1 : this.getters.getNumberCols(cmd.sheetId) - 1,
39260
- top: !isCol ? cmd.base : 0,
39261
- bottom: !isCol ? cmd.base + thickness - 1 : this.getters.getNumberRows(cmd.sheetId) - 1,
39353
+ left: isCol ? base : 0,
39354
+ right: isCol ? base + thickness - 1 : this.getters.getNumberCols(cmd.sheetId) - 1,
39355
+ top: !isCol ? base : 0,
39356
+ bottom: !isCol ? base + thickness - 1 : this.getters.getNumberRows(cmd.sheetId) - 1,
39262
39357
  },
39263
39358
  ];
39264
39359
  state.paste(pasteTarget, { selectTarget: true });
@@ -39295,6 +39390,11 @@ class GridSelectionPlugin extends UIPlugin {
39295
39390
  doesElementsHaveCommonMerges(id, cmd.base - 1, cmd.base)) {
39296
39391
  return 2 /* CommandResult.WillRemoveExistingMerge */;
39297
39392
  }
39393
+ const headers = [cmd.base, ...cmd.elements];
39394
+ const maxHeaderValue = isCol ? this.getters.getNumberCols(id) : this.getters.getNumberRows(id);
39395
+ if (headers.some((h) => h < 0 || h >= maxHeaderValue)) {
39396
+ return 87 /* CommandResult.InvalidHeaderIndex */;
39397
+ }
39298
39398
  return 0 /* CommandResult.Success */;
39299
39399
  }
39300
39400
  //-------------------------------------------
@@ -40101,7 +40201,7 @@ const AddMergeInteractiveContent = {
40101
40201
  };
40102
40202
  function interactiveAddMerge(env, sheetId, target) {
40103
40203
  const result = env.model.dispatch("ADD_MERGE", { sheetId, target });
40104
- if (result.isCancelledBecause(80 /* CommandResult.MergeInFilter */)) {
40204
+ if (result.isCancelledBecause(81 /* CommandResult.MergeInFilter */)) {
40105
40205
  env.raiseError(AddMergeInteractiveContent.MergeInFilter);
40106
40206
  }
40107
40207
  else if (result.isCancelledBecause(3 /* CommandResult.MergeIsDestructive */)) {
@@ -40848,7 +40948,7 @@ class Spreadsheet extends Component {
40848
40948
  }
40849
40949
  onKeydown(ev) {
40850
40950
  let keyDownString = "";
40851
- if (ev.ctrlKey || ev.metaKey) {
40951
+ if (isCtrlKey(ev)) {
40852
40952
  keyDownString += "CTRL+";
40853
40953
  }
40854
40954
  keyDownString += ev.key.toUpperCase();
@@ -41976,7 +42076,7 @@ class SelectionStreamProcessor {
41976
42076
  */
41977
42077
  moveAnchorCell(direction, step = 1) {
41978
42078
  if (step !== "end" && step <= 0) {
41979
- return new DispatchResult(83 /* CommandResult.InvalidSelectionStep */);
42079
+ return new DispatchResult(84 /* CommandResult.InvalidSelectionStep */);
41980
42080
  }
41981
42081
  const { col, row } = this.getNextAvailablePosition(direction, step);
41982
42082
  return this.selectCell(col, row);
@@ -42022,7 +42122,7 @@ class SelectionStreamProcessor {
42022
42122
  */
42023
42123
  resizeAnchorZone(direction, step = 1) {
42024
42124
  if (step !== "end" && step <= 0) {
42025
- return new DispatchResult(83 /* CommandResult.InvalidSelectionStep */);
42125
+ return new DispatchResult(84 /* CommandResult.InvalidSelectionStep */);
42026
42126
  }
42027
42127
  const sheetId = this.getters.getActiveSheetId();
42028
42128
  const anchor = this.anchor;
@@ -43982,10 +44082,10 @@ class Model extends EventBus {
43982
44082
  const command = { ...payload, type };
43983
44083
  let status = this.status;
43984
44084
  if (this.getters.isReadonly() && !canExecuteInReadonly(command)) {
43985
- return new DispatchResult(67 /* CommandResult.Readonly */);
44085
+ return new DispatchResult(68 /* CommandResult.Readonly */);
43986
44086
  }
43987
44087
  if (!this.session.canApplyOptimisticUpdate()) {
43988
- return new DispatchResult(64 /* CommandResult.WaitingSessionConfirmation */);
44088
+ return new DispatchResult(65 /* CommandResult.WaitingSessionConfirmation */);
43989
44089
  }
43990
44090
  switch (status) {
43991
44091
  case 0 /* Status.Ready */:
@@ -44445,6 +44545,6 @@ function addFunction(functionName, functionDescription) {
44445
44545
  export { AbstractChart, CommandResult, CorePlugin, DATETIME_FORMAT, DispatchResult, EvaluationError, Model, Registry, Revision, SPREADSHEET_DIMENSIONS, Spreadsheet, UIPlugin, __info__, addFunction, astToFormula, compile, components, convertAstNodes, coreTypes, findCellInNewZone, functionCache, helpers, invalidateEvaluationCommands, links, load, parse, readonlyAllowedCommands, registries, setTranslationMethod, tokenize };
44446
44546
 
44447
44547
 
44448
- __info__.version = '16.1.28';
44449
- __info__.date = '2023-11-24T13:11:01.992Z';
44450
- __info__.hash = '257f369';
44548
+ __info__.version = '16.1.33';
44549
+ __info__.date = '2024-01-29T13:49:43.259Z';
44550
+ __info__.hash = 'd3b27dd';