@odoo/o-spreadsheet 16.2.0-alpha.0 → 16.2.0-alpha.2

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.
@@ -5569,28 +5569,28 @@ function useSpreadsheetRect() {
5569
5569
  return position;
5570
5570
  }
5571
5571
  /**
5572
- * Return the component (or ref's component) top left position (in pixels) relative
5572
+ * Return the component (or ref's component) BoundingRect, relative
5573
5573
  * to the upper left corner of the screen (<body> element).
5574
5574
  *
5575
5575
  * Note: when used with a <Portal/> component, it will
5576
5576
  * return the portal position, not the teleported position.
5577
5577
  */
5578
- function useAbsolutePosition(ref) {
5579
- const position = owl.useState({ x: 0, y: 0 });
5580
- function updateElPosition() {
5578
+ function useAbsoluteBoundingRect(ref) {
5579
+ const rect = owl.useState({ x: 0, y: 0, width: 0, height: 0 });
5580
+ function updateElRect() {
5581
5581
  const el = ref.el;
5582
5582
  if (el === null) {
5583
5583
  return;
5584
5584
  }
5585
- const { top, left } = el.getBoundingClientRect();
5586
- if (left !== position.x || top !== position.y) {
5587
- position.x = left;
5588
- position.y = top;
5589
- }
5585
+ const { top, left, width, height } = el.getBoundingClientRect();
5586
+ rect.x = left;
5587
+ rect.y = top;
5588
+ rect.width = width;
5589
+ rect.height = height;
5590
5590
  }
5591
- owl.onMounted(updateElPosition);
5592
- owl.onPatched(updateElPosition);
5593
- return position;
5591
+ owl.onMounted(updateElRect);
5592
+ owl.onPatched(updateElRect);
5593
+ return rect;
5594
5594
  }
5595
5595
  /**
5596
5596
  * Get the rectangle inside which a popover should stay when being displayed.
@@ -5955,7 +5955,7 @@ class Menu extends owl.Component {
5955
5955
  menuItems: [],
5956
5956
  });
5957
5957
  this.menuRef = owl.useRef("menu");
5958
- this.position = useAbsolutePosition(this.menuRef);
5958
+ this.position = useAbsoluteBoundingRect(this.menuRef);
5959
5959
  }
5960
5960
  setup() {
5961
5961
  owl.useExternalListener(window, "click", this.onExternalClick, { capture: true });
@@ -6123,8 +6123,8 @@ class ChartFigure extends owl.Component {
6123
6123
  this.menuState = owl.useState({ isOpen: false, position: null, menuItems: [] });
6124
6124
  this.chartContainerRef = owl.useRef("chartContainer");
6125
6125
  this.menuButtonRef = owl.useRef("menuButton");
6126
- this.menuButtonPosition = useAbsolutePosition(this.menuButtonRef);
6127
- this.position = useAbsolutePosition(this.chartContainerRef);
6126
+ this.menuButtonRect = useAbsoluteBoundingRect(this.menuButtonRef);
6127
+ this.position = useAbsoluteBoundingRect(this.chartContainerRef);
6128
6128
  }
6129
6129
  getMenuItemRegistry() {
6130
6130
  const registry = new MenuItemRegistry();
@@ -6178,11 +6178,12 @@ class ChartFigure extends owl.Component {
6178
6178
  this.openContextMenu(position);
6179
6179
  }
6180
6180
  showMenu() {
6181
- const position = {
6182
- x: this.menuButtonPosition.x - MENU_WIDTH,
6183
- y: this.menuButtonPosition.y,
6181
+ const { x, y, width } = this.menuButtonRect;
6182
+ const menuPosition = {
6183
+ x: x >= MENU_WIDTH ? x - MENU_WIDTH : x + width,
6184
+ y: y,
6184
6185
  };
6185
- this.openContextMenu(position);
6186
+ this.openContextMenu(menuPosition);
6186
6187
  }
6187
6188
  openContextMenu(position) {
6188
6189
  const registry = this.getMenuItemRegistry();
@@ -17040,7 +17041,7 @@ class LinkEditor extends owl.Component {
17040
17041
  isOpen: false,
17041
17042
  });
17042
17043
  this.linkEditorRef = owl.useRef("linkEditor");
17043
- this.position = useAbsolutePosition(this.linkEditorRef);
17044
+ this.position = useAbsoluteBoundingRect(this.linkEditorRef);
17044
17045
  this.urlInput = owl.useRef("urlInput");
17045
17046
  }
17046
17047
  setup() {
@@ -17159,8 +17160,8 @@ class ImageFigure extends owl.Component {
17159
17160
  });
17160
17161
  this.imageContainerRef = owl.useRef("o-image");
17161
17162
  this.menuButtonRef = owl.useRef("menuButton");
17162
- this.menuButtonPosition = useAbsolutePosition(this.menuButtonRef);
17163
- this.position = useAbsolutePosition(this.imageContainerRef);
17163
+ this.menuButtonRect = useAbsoluteBoundingRect(this.menuButtonRef);
17164
+ this.position = useAbsoluteBoundingRect(this.imageContainerRef);
17164
17165
  this.menuItems = createMenu([
17165
17166
  {
17166
17167
  id: "copy",
@@ -17217,11 +17218,12 @@ class ImageFigure extends owl.Component {
17217
17218
  this.openContextMenu(position);
17218
17219
  }
17219
17220
  showMenu() {
17220
- const position = {
17221
- x: this.menuButtonPosition.x - MENU_WIDTH,
17222
- y: this.menuButtonPosition.y,
17221
+ const { x, y, width } = this.menuButtonRect;
17222
+ const menuPosition = {
17223
+ x: x >= MENU_WIDTH ? x - MENU_WIDTH : x + width,
17224
+ y: y,
17223
17225
  };
17224
- this.openContextMenu(position);
17226
+ this.openContextMenu(menuPosition);
17225
17227
  }
17226
17228
  openContextMenu(position) {
17227
17229
  this.menuState.isOpen = true;
@@ -18994,7 +18996,6 @@ class ChartPanel extends owl.Component {
18994
18996
  ...this.getChartDefinition(),
18995
18997
  ...updateDefinition,
18996
18998
  };
18997
- // TODORAR add a putain de test - c'est faux de nouveau ...
18998
18999
  return this.env.model.dispatch("UPDATE_CHART", {
18999
19000
  definition,
19000
19001
  id: this.figureId,
@@ -19007,7 +19008,6 @@ class ChartPanel extends owl.Component {
19007
19008
  throw new Error("Chart not defined.");
19008
19009
  }
19009
19010
  const definition = getChartDefinitionFromContextCreation(context, type);
19010
- // TODORAR add a putain de test - c'est faux de nouveau ...
19011
19011
  this.env.model.dispatch("UPDATE_CHART", {
19012
19012
  definition,
19013
19013
  id: this.figureId,
@@ -22002,7 +22002,7 @@ class Grid extends owl.Component {
22002
22002
  });
22003
22003
  this.gridRef = owl.useRef("grid");
22004
22004
  this.hiddenInput = owl.useRef("hiddenInput");
22005
- this.canvasPosition = useAbsolutePosition(this.gridRef);
22005
+ this.canvasPosition = useAbsoluteBoundingRect(this.gridRef);
22006
22006
  this.hoveredCell = owl.useState({ col: undefined, row: undefined });
22007
22007
  owl.useChildSubEnv({ getPopoverContainerRect: () => this.getGridRect() });
22008
22008
  owl.useExternalListener(document.body, "cut", this.copy.bind(this, true));
@@ -28140,9 +28140,6 @@ class ChartPlugin extends CorePlugin {
28140
28140
  return figureId in (this.charts[sheetId] || {});
28141
28141
  }
28142
28142
  getChartIds(sheetId) {
28143
- // TODORAR refaire ce shit truc
28144
- // on veut un truc du genre Object.keys(this.charts[sheetId] || {} a mon avis
28145
- // return (Object.values(this.charts[sheetId] || {}).filter(isDefined) as AbstractChart[]).map((chart) => chart.id);
28146
28143
  return Object.keys(this.charts[sheetId] || {});
28147
28144
  }
28148
28145
  getChartDefinition(sheetId, figureId) {
@@ -40056,7 +40053,7 @@ let tKey = 1;
40056
40053
  class SpreadsheetDashboard extends owl.Component {
40057
40054
  setup() {
40058
40055
  const gridRef = owl.useRef("grid");
40059
- this.canvasPosition = useAbsolutePosition(gridRef);
40056
+ this.canvasPosition = useAbsoluteBoundingRect(gridRef);
40060
40057
  this.hoveredCell = owl.useState({ col: undefined, row: undefined });
40061
40058
  owl.useChildSubEnv({ getPopoverContainerRect: () => this.getGridRect() });
40062
40059
  useGridDrawing("canvas", this.env.model, () => this.env.model.getters.getSheetViewDimension());
@@ -44849,6 +44846,6 @@ exports.setTranslationMethod = setTranslationMethod;
44849
44846
  exports.tokenize = tokenize;
44850
44847
 
44851
44848
 
44852
- __info__.version = '16.2.0-alpha.0';
44853
- __info__.date = '2023-02-28T08:16:17.842Z';
44854
- __info__.hash = '2855f54';
44849
+ __info__.version = '16.2.0-alpha.2';
44850
+ __info__.date = '2023-03-01T14:43:49.348Z';
44851
+ __info__.hash = 'eb626ad';
@@ -5359,7 +5359,7 @@ declare class ChartFigure extends Component<Props$q, SpreadsheetChildEnv> {
5359
5359
  private menuState;
5360
5360
  private chartContainerRef;
5361
5361
  private menuButtonRef;
5362
- private menuButtonPosition;
5362
+ private menuButtonRect;
5363
5363
  private position;
5364
5364
  private getMenuItemRegistry;
5365
5365
  get chartType(): ChartType;
@@ -5565,28 +5565,28 @@ function useSpreadsheetRect() {
5565
5565
  return position;
5566
5566
  }
5567
5567
  /**
5568
- * Return the component (or ref's component) top left position (in pixels) relative
5568
+ * Return the component (or ref's component) BoundingRect, relative
5569
5569
  * to the upper left corner of the screen (<body> element).
5570
5570
  *
5571
5571
  * Note: when used with a <Portal/> component, it will
5572
5572
  * return the portal position, not the teleported position.
5573
5573
  */
5574
- function useAbsolutePosition(ref) {
5575
- const position = useState({ x: 0, y: 0 });
5576
- function updateElPosition() {
5574
+ function useAbsoluteBoundingRect(ref) {
5575
+ const rect = useState({ x: 0, y: 0, width: 0, height: 0 });
5576
+ function updateElRect() {
5577
5577
  const el = ref.el;
5578
5578
  if (el === null) {
5579
5579
  return;
5580
5580
  }
5581
- const { top, left } = el.getBoundingClientRect();
5582
- if (left !== position.x || top !== position.y) {
5583
- position.x = left;
5584
- position.y = top;
5585
- }
5581
+ const { top, left, width, height } = el.getBoundingClientRect();
5582
+ rect.x = left;
5583
+ rect.y = top;
5584
+ rect.width = width;
5585
+ rect.height = height;
5586
5586
  }
5587
- onMounted(updateElPosition);
5588
- onPatched(updateElPosition);
5589
- return position;
5587
+ onMounted(updateElRect);
5588
+ onPatched(updateElRect);
5589
+ return rect;
5590
5590
  }
5591
5591
  /**
5592
5592
  * Get the rectangle inside which a popover should stay when being displayed.
@@ -5951,7 +5951,7 @@ class Menu extends Component {
5951
5951
  menuItems: [],
5952
5952
  });
5953
5953
  this.menuRef = useRef("menu");
5954
- this.position = useAbsolutePosition(this.menuRef);
5954
+ this.position = useAbsoluteBoundingRect(this.menuRef);
5955
5955
  }
5956
5956
  setup() {
5957
5957
  useExternalListener(window, "click", this.onExternalClick, { capture: true });
@@ -6119,8 +6119,8 @@ class ChartFigure extends Component {
6119
6119
  this.menuState = useState({ isOpen: false, position: null, menuItems: [] });
6120
6120
  this.chartContainerRef = useRef("chartContainer");
6121
6121
  this.menuButtonRef = useRef("menuButton");
6122
- this.menuButtonPosition = useAbsolutePosition(this.menuButtonRef);
6123
- this.position = useAbsolutePosition(this.chartContainerRef);
6122
+ this.menuButtonRect = useAbsoluteBoundingRect(this.menuButtonRef);
6123
+ this.position = useAbsoluteBoundingRect(this.chartContainerRef);
6124
6124
  }
6125
6125
  getMenuItemRegistry() {
6126
6126
  const registry = new MenuItemRegistry();
@@ -6174,11 +6174,12 @@ class ChartFigure extends Component {
6174
6174
  this.openContextMenu(position);
6175
6175
  }
6176
6176
  showMenu() {
6177
- const position = {
6178
- x: this.menuButtonPosition.x - MENU_WIDTH,
6179
- y: this.menuButtonPosition.y,
6177
+ const { x, y, width } = this.menuButtonRect;
6178
+ const menuPosition = {
6179
+ x: x >= MENU_WIDTH ? x - MENU_WIDTH : x + width,
6180
+ y: y,
6180
6181
  };
6181
- this.openContextMenu(position);
6182
+ this.openContextMenu(menuPosition);
6182
6183
  }
6183
6184
  openContextMenu(position) {
6184
6185
  const registry = this.getMenuItemRegistry();
@@ -17036,7 +17037,7 @@ class LinkEditor extends Component {
17036
17037
  isOpen: false,
17037
17038
  });
17038
17039
  this.linkEditorRef = useRef("linkEditor");
17039
- this.position = useAbsolutePosition(this.linkEditorRef);
17040
+ this.position = useAbsoluteBoundingRect(this.linkEditorRef);
17040
17041
  this.urlInput = useRef("urlInput");
17041
17042
  }
17042
17043
  setup() {
@@ -17155,8 +17156,8 @@ class ImageFigure extends Component {
17155
17156
  });
17156
17157
  this.imageContainerRef = useRef("o-image");
17157
17158
  this.menuButtonRef = useRef("menuButton");
17158
- this.menuButtonPosition = useAbsolutePosition(this.menuButtonRef);
17159
- this.position = useAbsolutePosition(this.imageContainerRef);
17159
+ this.menuButtonRect = useAbsoluteBoundingRect(this.menuButtonRef);
17160
+ this.position = useAbsoluteBoundingRect(this.imageContainerRef);
17160
17161
  this.menuItems = createMenu([
17161
17162
  {
17162
17163
  id: "copy",
@@ -17213,11 +17214,12 @@ class ImageFigure extends Component {
17213
17214
  this.openContextMenu(position);
17214
17215
  }
17215
17216
  showMenu() {
17216
- const position = {
17217
- x: this.menuButtonPosition.x - MENU_WIDTH,
17218
- y: this.menuButtonPosition.y,
17217
+ const { x, y, width } = this.menuButtonRect;
17218
+ const menuPosition = {
17219
+ x: x >= MENU_WIDTH ? x - MENU_WIDTH : x + width,
17220
+ y: y,
17219
17221
  };
17220
- this.openContextMenu(position);
17222
+ this.openContextMenu(menuPosition);
17221
17223
  }
17222
17224
  openContextMenu(position) {
17223
17225
  this.menuState.isOpen = true;
@@ -18990,7 +18992,6 @@ class ChartPanel extends Component {
18990
18992
  ...this.getChartDefinition(),
18991
18993
  ...updateDefinition,
18992
18994
  };
18993
- // TODORAR add a putain de test - c'est faux de nouveau ...
18994
18995
  return this.env.model.dispatch("UPDATE_CHART", {
18995
18996
  definition,
18996
18997
  id: this.figureId,
@@ -19003,7 +19004,6 @@ class ChartPanel extends Component {
19003
19004
  throw new Error("Chart not defined.");
19004
19005
  }
19005
19006
  const definition = getChartDefinitionFromContextCreation(context, type);
19006
- // TODORAR add a putain de test - c'est faux de nouveau ...
19007
19007
  this.env.model.dispatch("UPDATE_CHART", {
19008
19008
  definition,
19009
19009
  id: this.figureId,
@@ -21998,7 +21998,7 @@ class Grid extends Component {
21998
21998
  });
21999
21999
  this.gridRef = useRef("grid");
22000
22000
  this.hiddenInput = useRef("hiddenInput");
22001
- this.canvasPosition = useAbsolutePosition(this.gridRef);
22001
+ this.canvasPosition = useAbsoluteBoundingRect(this.gridRef);
22002
22002
  this.hoveredCell = useState({ col: undefined, row: undefined });
22003
22003
  useChildSubEnv({ getPopoverContainerRect: () => this.getGridRect() });
22004
22004
  useExternalListener(document.body, "cut", this.copy.bind(this, true));
@@ -28136,9 +28136,6 @@ class ChartPlugin extends CorePlugin {
28136
28136
  return figureId in (this.charts[sheetId] || {});
28137
28137
  }
28138
28138
  getChartIds(sheetId) {
28139
- // TODORAR refaire ce shit truc
28140
- // on veut un truc du genre Object.keys(this.charts[sheetId] || {} a mon avis
28141
- // return (Object.values(this.charts[sheetId] || {}).filter(isDefined) as AbstractChart[]).map((chart) => chart.id);
28142
28139
  return Object.keys(this.charts[sheetId] || {});
28143
28140
  }
28144
28141
  getChartDefinition(sheetId, figureId) {
@@ -40052,7 +40049,7 @@ let tKey = 1;
40052
40049
  class SpreadsheetDashboard extends Component {
40053
40050
  setup() {
40054
40051
  const gridRef = useRef("grid");
40055
- this.canvasPosition = useAbsolutePosition(gridRef);
40052
+ this.canvasPosition = useAbsoluteBoundingRect(gridRef);
40056
40053
  this.hoveredCell = useState({ col: undefined, row: undefined });
40057
40054
  useChildSubEnv({ getPopoverContainerRect: () => this.getGridRect() });
40058
40055
  useGridDrawing("canvas", this.env.model, () => this.env.model.getters.getSheetViewDimension());
@@ -44817,6 +44814,6 @@ function addFunction(functionName, functionDescription) {
44817
44814
  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 };
44818
44815
 
44819
44816
 
44820
- __info__.version = '16.2.0-alpha.0';
44821
- __info__.date = '2023-02-28T08:16:17.842Z';
44822
- __info__.hash = '2855f54';
44817
+ __info__.version = '16.2.0-alpha.2';
44818
+ __info__.date = '2023-03-01T14:43:49.348Z';
44819
+ __info__.hash = 'eb626ad';
@@ -5566,28 +5566,28 @@
5566
5566
  return position;
5567
5567
  }
5568
5568
  /**
5569
- * Return the component (or ref's component) top left position (in pixels) relative
5569
+ * Return the component (or ref's component) BoundingRect, relative
5570
5570
  * to the upper left corner of the screen (<body> element).
5571
5571
  *
5572
5572
  * Note: when used with a <Portal/> component, it will
5573
5573
  * return the portal position, not the teleported position.
5574
5574
  */
5575
- function useAbsolutePosition(ref) {
5576
- const position = owl.useState({ x: 0, y: 0 });
5577
- function updateElPosition() {
5575
+ function useAbsoluteBoundingRect(ref) {
5576
+ const rect = owl.useState({ x: 0, y: 0, width: 0, height: 0 });
5577
+ function updateElRect() {
5578
5578
  const el = ref.el;
5579
5579
  if (el === null) {
5580
5580
  return;
5581
5581
  }
5582
- const { top, left } = el.getBoundingClientRect();
5583
- if (left !== position.x || top !== position.y) {
5584
- position.x = left;
5585
- position.y = top;
5586
- }
5582
+ const { top, left, width, height } = el.getBoundingClientRect();
5583
+ rect.x = left;
5584
+ rect.y = top;
5585
+ rect.width = width;
5586
+ rect.height = height;
5587
5587
  }
5588
- owl.onMounted(updateElPosition);
5589
- owl.onPatched(updateElPosition);
5590
- return position;
5588
+ owl.onMounted(updateElRect);
5589
+ owl.onPatched(updateElRect);
5590
+ return rect;
5591
5591
  }
5592
5592
  /**
5593
5593
  * Get the rectangle inside which a popover should stay when being displayed.
@@ -5952,7 +5952,7 @@
5952
5952
  menuItems: [],
5953
5953
  });
5954
5954
  this.menuRef = owl.useRef("menu");
5955
- this.position = useAbsolutePosition(this.menuRef);
5955
+ this.position = useAbsoluteBoundingRect(this.menuRef);
5956
5956
  }
5957
5957
  setup() {
5958
5958
  owl.useExternalListener(window, "click", this.onExternalClick, { capture: true });
@@ -6120,8 +6120,8 @@
6120
6120
  this.menuState = owl.useState({ isOpen: false, position: null, menuItems: [] });
6121
6121
  this.chartContainerRef = owl.useRef("chartContainer");
6122
6122
  this.menuButtonRef = owl.useRef("menuButton");
6123
- this.menuButtonPosition = useAbsolutePosition(this.menuButtonRef);
6124
- this.position = useAbsolutePosition(this.chartContainerRef);
6123
+ this.menuButtonRect = useAbsoluteBoundingRect(this.menuButtonRef);
6124
+ this.position = useAbsoluteBoundingRect(this.chartContainerRef);
6125
6125
  }
6126
6126
  getMenuItemRegistry() {
6127
6127
  const registry = new MenuItemRegistry();
@@ -6175,11 +6175,12 @@
6175
6175
  this.openContextMenu(position);
6176
6176
  }
6177
6177
  showMenu() {
6178
- const position = {
6179
- x: this.menuButtonPosition.x - MENU_WIDTH,
6180
- y: this.menuButtonPosition.y,
6178
+ const { x, y, width } = this.menuButtonRect;
6179
+ const menuPosition = {
6180
+ x: x >= MENU_WIDTH ? x - MENU_WIDTH : x + width,
6181
+ y: y,
6181
6182
  };
6182
- this.openContextMenu(position);
6183
+ this.openContextMenu(menuPosition);
6183
6184
  }
6184
6185
  openContextMenu(position) {
6185
6186
  const registry = this.getMenuItemRegistry();
@@ -17037,7 +17038,7 @@
17037
17038
  isOpen: false,
17038
17039
  });
17039
17040
  this.linkEditorRef = owl.useRef("linkEditor");
17040
- this.position = useAbsolutePosition(this.linkEditorRef);
17041
+ this.position = useAbsoluteBoundingRect(this.linkEditorRef);
17041
17042
  this.urlInput = owl.useRef("urlInput");
17042
17043
  }
17043
17044
  setup() {
@@ -17156,8 +17157,8 @@
17156
17157
  });
17157
17158
  this.imageContainerRef = owl.useRef("o-image");
17158
17159
  this.menuButtonRef = owl.useRef("menuButton");
17159
- this.menuButtonPosition = useAbsolutePosition(this.menuButtonRef);
17160
- this.position = useAbsolutePosition(this.imageContainerRef);
17160
+ this.menuButtonRect = useAbsoluteBoundingRect(this.menuButtonRef);
17161
+ this.position = useAbsoluteBoundingRect(this.imageContainerRef);
17161
17162
  this.menuItems = createMenu([
17162
17163
  {
17163
17164
  id: "copy",
@@ -17214,11 +17215,12 @@
17214
17215
  this.openContextMenu(position);
17215
17216
  }
17216
17217
  showMenu() {
17217
- const position = {
17218
- x: this.menuButtonPosition.x - MENU_WIDTH,
17219
- y: this.menuButtonPosition.y,
17218
+ const { x, y, width } = this.menuButtonRect;
17219
+ const menuPosition = {
17220
+ x: x >= MENU_WIDTH ? x - MENU_WIDTH : x + width,
17221
+ y: y,
17220
17222
  };
17221
- this.openContextMenu(position);
17223
+ this.openContextMenu(menuPosition);
17222
17224
  }
17223
17225
  openContextMenu(position) {
17224
17226
  this.menuState.isOpen = true;
@@ -18991,7 +18993,6 @@
18991
18993
  ...this.getChartDefinition(),
18992
18994
  ...updateDefinition,
18993
18995
  };
18994
- // TODORAR add a putain de test - c'est faux de nouveau ...
18995
18996
  return this.env.model.dispatch("UPDATE_CHART", {
18996
18997
  definition,
18997
18998
  id: this.figureId,
@@ -19004,7 +19005,6 @@
19004
19005
  throw new Error("Chart not defined.");
19005
19006
  }
19006
19007
  const definition = getChartDefinitionFromContextCreation(context, type);
19007
- // TODORAR add a putain de test - c'est faux de nouveau ...
19008
19008
  this.env.model.dispatch("UPDATE_CHART", {
19009
19009
  definition,
19010
19010
  id: this.figureId,
@@ -21999,7 +21999,7 @@
21999
21999
  });
22000
22000
  this.gridRef = owl.useRef("grid");
22001
22001
  this.hiddenInput = owl.useRef("hiddenInput");
22002
- this.canvasPosition = useAbsolutePosition(this.gridRef);
22002
+ this.canvasPosition = useAbsoluteBoundingRect(this.gridRef);
22003
22003
  this.hoveredCell = owl.useState({ col: undefined, row: undefined });
22004
22004
  owl.useChildSubEnv({ getPopoverContainerRect: () => this.getGridRect() });
22005
22005
  owl.useExternalListener(document.body, "cut", this.copy.bind(this, true));
@@ -28137,9 +28137,6 @@
28137
28137
  return figureId in (this.charts[sheetId] || {});
28138
28138
  }
28139
28139
  getChartIds(sheetId) {
28140
- // TODORAR refaire ce shit truc
28141
- // on veut un truc du genre Object.keys(this.charts[sheetId] || {} a mon avis
28142
- // return (Object.values(this.charts[sheetId] || {}).filter(isDefined) as AbstractChart[]).map((chart) => chart.id);
28143
28140
  return Object.keys(this.charts[sheetId] || {});
28144
28141
  }
28145
28142
  getChartDefinition(sheetId, figureId) {
@@ -40053,7 +40050,7 @@
40053
40050
  class SpreadsheetDashboard extends owl.Component {
40054
40051
  setup() {
40055
40052
  const gridRef = owl.useRef("grid");
40056
- this.canvasPosition = useAbsolutePosition(gridRef);
40053
+ this.canvasPosition = useAbsoluteBoundingRect(gridRef);
40057
40054
  this.hoveredCell = owl.useState({ col: undefined, row: undefined });
40058
40055
  owl.useChildSubEnv({ getPopoverContainerRect: () => this.getGridRect() });
40059
40056
  useGridDrawing("canvas", this.env.model, () => this.env.model.getters.getSheetViewDimension());
@@ -44848,9 +44845,9 @@
44848
44845
  Object.defineProperty(exports, '__esModule', { value: true });
44849
44846
 
44850
44847
 
44851
- __info__.version = '16.2.0-alpha.0';
44852
- __info__.date = '2023-02-28T08:16:17.842Z';
44853
- __info__.hash = '2855f54';
44848
+ __info__.version = '16.2.0-alpha.2';
44849
+ __info__.date = '2023-03-01T14:43:49.348Z';
44850
+ __info__.hash = 'eb626ad';
44854
44851
 
44855
44852
 
44856
44853
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);
@@ -49,7 +49,7 @@
49
49
  }
50
50
  }
51
51
  }
52
- `;class go extends t.Component{constructor(){super(...arguments),this.ctx=document.createElement("canvas").getContext("2d")}get runtime(){return this.env.model.getters.getChartRuntime(this.env.model.getters.getActiveSheetId(),this.props.figure.id)}get title(){return this.runtime.title}get keyValue(){return this.runtime.keyValue}get baseline(){return this.runtime.baselineDisplay}get baselineDescr(){const e=this.runtime.baselineDescr||"";return this.baseline&&e?" "+e:e}get baselineArrowDirection(){return this.runtime.baselineArrow}get backgroundColor(){return this.runtime.background}get primaryFontColor(){return this.runtime.fontColor}get secondaryFontColor(){return Ct(this.primaryFontColor)<=.3?"#757575":"#bbbbbb"}get figure(){return this.props.figure}get chartStyle(){return ho({padding:`${this.chartPadding}px`,background:this.backgroundColor})}get chartContentStyle(){return ho({height:`${this.getDrawableHeight()}px`})}get chartPadding(){return.02*this.props.figure.width}getTextStyles(){const e=.96*this.props.figure.width,t=this.getWidestElement(),i=t.getElementMaxFontSize(this.getDrawableHeight(),this);let o=function(e,t,i,o=.25){let n=1;if(i(n)>e)return n;if(i(t)<e)return t;let s=(n+t)/2,r=i(s),a=0;for(;Math.abs(r-e)>o&&a<20;)r>=e?t=(n+t)/2:n=(n+t)/2,s=(n+t)/2,r=i(s),a++;return s}(e,i,(e=>t.getElementWidth(e,this.ctx,this)))/i;const n=(new mo).getElementMaxFontSize(this.getDrawableHeight(),this)*o,s=(new po).getElementMaxFontSize(this.getDrawableHeight(),this)*o;return{titleStyle:this.getTextStyle({fontSize:18,color:this.secondaryFontColor}),keyStyle:this.getTextStyle({fontSize:n,cellStyle:this.runtime.keyValueStyle,color:this.primaryFontColor}),baselineStyle:this.getTextStyle({fontSize:s}),baselineValueStyle:this.getTextStyle({fontSize:s,cellStyle:this.runtime.baselineStyle,color:this.runtime.baselineColor||this.secondaryFontColor}),baselineDescrStyle:this.getTextStyle({fontSize:.9*s,color:this.secondaryFontColor})}}getTextStyle(e){const t=co(e.cellStyle);return t["font-size"]=`${e.fontSize}px`,t.display="inline-block",!t.color&&e.color&&(t.color=e.color),ho(t)}getDrawableHeight(){const e=2*this.chartPadding;let t=this.props.figure.height-e;return t-=this.title?18*uo:0,t}getWidestElement(){const e=new po,t=new mo;return e.getElementWidth(.35,this.ctx,this)>t.getElementWidth(.65,this.ctx,this)?e:t}}go.template="o-spreadsheet-ScorecardChart";class po{getElementWidth(e,t,i){if(!i.runtime)return 0;const o=i.baseline,n="neutral"!==i.baselineArrowDirection?"A "+o:o;t.font=`${e}px ${q}`;let s=t.measureText(n).width;return t.font=`${.9*e}px ${q}`,s+=t.measureText(i.baselineDescr).width,s}getElementMaxFontSize(e,t){if(!t.runtime)return 0;return(""!==t.baseline||t.baselineDescr?.35*e:0)/uo}}class mo{getElementWidth(e,t,i){if(!i.runtime)return 0;const o=i.keyValue||"";return t.font=`${e}px ${q}`,t.measureText(o).width}getElementMaxFontSize(e,t){if(!t.runtime)return 0;return(""!==t.baseline||t.baselineDescr?.65*e:e)/uo}}function fo(e){return 8===(e=ft(e).replace("#","")).length?e.slice(6)+e.slice(0,6):e}go.props={figure:Object};class vo{constructor(e,t,i){this.title=e.title,this.sheetId=t,this.getters=i}static validateChartDefinition(e,t){throw new Error("This method should be implemented by sub class")}static transformDefinition(e,t){throw new Error("This method should be implemented by sub class")}static getDefinitionFromContextCreation(e){throw new Error("This method should be implemented by sub class")}}function bo(e,t){return"REMOVE_COLUMNS_ROWS"===t.type?Ui(e,"COL"===t.dimension?"left":"top",t.elements):"ADD_COLUMNS_ROWS"===t.type?ki(e,"COL"===t.dimension?"left":"top",t.base,t.position,t.quantity):{...e}}var So,Co;!function(e){e.boolean="boolean",e.number="number",e.text="text",e.empty="empty",e.error="error"}(So||(So={})),function(e){e.PlainText="text/plain",e.Html="text/html"}(Co||(Co={}));const Eo=new Set(["RENAME_SHEET","DELETE_SHEET","CREATE_SHEET","ADD_COLUMNS_ROWS","REMOVE_COLUMNS_ROWS","DELETE_CELL","INSERT_CELL","UNDO","REDO"]),wo=new Set([...Eo,"DUPLICATE_SHEET","EVALUATE_CELLS","ADD_CONDITIONAL_FORMAT","REMOVE_CONDITIONAL_FORMAT","MOVE_CONDITIONAL_FORMAT"]),yo=new Set(["START","ACTIVATE_SHEET","COPY","PREPARE_SELECTION_INPUT_EXPANSION","STOP_SELECTION_INPUT","RESIZE_SHEETVIEW","SET_VIEWPORT_OFFSET","SELECT_SEARCH_NEXT_MATCH","SELECT_SEARCH_PREVIOUS_MATCH","REFRESH_SEARCH","UPDATE_SEARCH","CLEAR_SEARCH","EVALUATE_CELLS","SET_CURRENT_CONTENT","SET_FORMULA_VISIBILITY","OPEN_CELL_POPOVER","CLOSE_CELL_POPOVER","UPDATE_FILTER"]),xo=new Set(["UPDATE_CELL","UPDATE_CELL_POSITION","CLEAR_CELL","DELETE_CONTENT","ADD_COLUMNS_ROWS","REMOVE_COLUMNS_ROWS","RESIZE_COLUMNS_ROWS","HIDE_COLUMNS_ROWS","UNHIDE_COLUMNS_ROWS","SET_GRID_LINES_VISIBILITY","UNFREEZE_COLUMNS","UNFREEZE_ROWS","FREEZE_COLUMNS","FREEZE_ROWS","UNFREEZE_COLUMNS_ROWS","ADD_MERGE","REMOVE_MERGE","CREATE_SHEET","DELETE_SHEET","DUPLICATE_SHEET","MOVE_SHEET","RENAME_SHEET","HIDE_SHEET","SHOW_SHEET","MOVE_RANGES","ADD_CONDITIONAL_FORMAT","REMOVE_CONDITIONAL_FORMAT","MOVE_CONDITIONAL_FORMAT","CREATE_FIGURE","DELETE_FIGURE","UPDATE_FIGURE","SET_FORMATTING","CLEAR_FORMATTING","SET_BORDER","CREATE_CHART","UPDATE_CHART","CREATE_FILTER_TABLE","REMOVE_FILTER_TABLE","CREATE_IMAGE"]);function Io(e){return xo.has(e.type)}class Ro{constructor(e=[]){Array.isArray(e)||(e=[e]),e=[...new Set(e)],this.reasons=e.filter((e=>0!==e))}static get Success(){return new Ro}get isSuccessful(){return 0===this.reasons.length}isCancelledBecause(e){return this.reasons.includes(e)}}var To,Ao,Mo;function Oo(e,t,i,o){let n=!1;const s=[];for(let o in i){let r=i[o];if(r.labelCell){const e=Fo(r.labelCell,t);r.labelCell!==e&&(n=!0,r={...r,labelCell:e})}const a=Fo(r.dataRange,t);void 0===a||e.getRangeString(a,a.sheetId)===Y?(n=!0,r=void 0):a!==r.dataRange&&(n=!0,r={...r,dataRange:a}),s[o]=r}let r=o;const a=Fo(r,t);a!==r&&(n=!0,r=a);return{isStale:n,dataSets:s.filter(et),labelRange:r}}function No(e,t,i){return i.map((i=>({dataRange:Ri(e,t,i.dataRange),labelCell:i.labelCell?Ri(e,t,i.labelCell):void 0})))}function _o(e,t,i){return i?Ri(e,t,i):void 0}function Fo(e,t){if(!e)return;const i=t(e);switch(i.changeType){case"NONE":return e;case"REMOVE":return;default:return i.range}}function Do(e,t,i,o){const n=[];for(const s of t){const t=e.getRangeFromSheetXC(i,s),{unboundedZone:r,sheetId:a,invalidSheetName:l}=t;if(!l)if(r.left!==r.right&&r.top!==r.bottom){if(void 0===r.right)continue;for(let t=r.left;t<=r.right;t++){const i={...r,left:t,right:t};n.push(ko(e,a,i,o?{top:i.top,bottom:i.top,left:i.left,right:i.left}:void 0))}}else r.left===r.right&&r.top===r.bottom?o||n.push(ko(e,a,r,void 0)):n.push(ko(e,a,r,o?{top:r.top,bottom:r.top,left:r.left,right:r.left}:void 0))}return n}function ko(e,t,i,o){if(i.left!==i.right&&i.top!==i.bottom)throw new Error(`Zone should be a single column or row: ${Di(i)}`);if(o){const n=Di(i),s=Di(o);return{labelCell:e.getRangeFromSheetXC(t,s),dataRange:e.getRangeFromSheetXC(t,n)}}return{labelCell:void 0,dataRange:e.getRangeFromSheetXC(t,Di(i))}}function Lo(e,t){var i;const o=null===(i=t.labelCell)||void 0===i?void 0:i.zone;let n=t.dataRange.zone;if(o){const{height:e,width:t}=Zi(n);1===e?n={...n,left:n.left+1}:1===t&&(n={...n,top:n.top+1})}const s=t.dataRange.clone({zone:n});return{label:t.labelCell?e.getRangeString(t.labelCell,"forceSheetReference"):void 0,range:e.getRangeString(s,"forceSheetReference")}}function Po(e,t){let i;if(e.labelRange){const o=bo(Ni(e.labelRange),t);i=o?Di(o):void 0}const o=e.dataSets.map(Ni).map((e=>bo(e,t))).filter(et).map(Di);return{...e,labelRange:i,dataSets:o}}e.CommandResult=void 0,(To=e.CommandResult||(e.CommandResult={}))[To.Success=0]="Success",To[To.CancelledForUnknownReason=1]="CancelledForUnknownReason",To[To.WillRemoveExistingMerge=2]="WillRemoveExistingMerge",To[To.MergeIsDestructive=3]="MergeIsDestructive",To[To.CellIsMerged=4]="CellIsMerged",To[To.InvalidTarget=5]="InvalidTarget",To[To.EmptyUndoStack=6]="EmptyUndoStack",To[To.EmptyRedoStack=7]="EmptyRedoStack",To[To.NotEnoughElements=8]="NotEnoughElements",To[To.NotEnoughSheets=9]="NotEnoughSheets",To[To.MissingSheetName=10]="MissingSheetName",To[To.DuplicatedSheetName=11]="DuplicatedSheetName",To[To.DuplicatedSheetId=12]="DuplicatedSheetId",To[To.ForbiddenCharactersInSheetName=13]="ForbiddenCharactersInSheetName",To[To.WrongSheetMove=14]="WrongSheetMove",To[To.WrongSheetPosition=15]="WrongSheetPosition",To[To.InvalidAnchorZone=16]="InvalidAnchorZone",To[To.SelectionOutOfBound=17]="SelectionOutOfBound",To[To.TargetOutOfSheet=18]="TargetOutOfSheet",To[To.WrongCutSelection=19]="WrongCutSelection",To[To.WrongPasteSelection=20]="WrongPasteSelection",To[To.WrongPasteOption=21]="WrongPasteOption",To[To.WrongFigurePasteOption=22]="WrongFigurePasteOption",To[To.EmptyClipboard=23]="EmptyClipboard",To[To.EmptyRange=24]="EmptyRange",To[To.InvalidRange=25]="InvalidRange",To[To.InvalidZones=26]="InvalidZones",To[To.InvalidSheetId=27]="InvalidSheetId",To[To.DuplicatedImageId=28]="DuplicatedImageId",To[To.InputAlreadyFocused=29]="InputAlreadyFocused",To[To.MaximumRangesReached=30]="MaximumRangesReached",To[To.InvalidChartDefinition=31]="InvalidChartDefinition",To[To.InvalidDataSet=32]="InvalidDataSet",To[To.InvalidLabelRange=33]="InvalidLabelRange",To[To.InvalidScorecardKeyValue=34]="InvalidScorecardKeyValue",To[To.InvalidScorecardBaseline=35]="InvalidScorecardBaseline",To[To.InvalidGaugeDataRange=36]="InvalidGaugeDataRange",To[To.EmptyGaugeRangeMin=37]="EmptyGaugeRangeMin",To[To.GaugeRangeMinNaN=38]="GaugeRangeMinNaN",To[To.EmptyGaugeRangeMax=39]="EmptyGaugeRangeMax",To[To.GaugeRangeMaxNaN=40]="GaugeRangeMaxNaN",To[To.GaugeRangeMinBiggerThanRangeMax=41]="GaugeRangeMinBiggerThanRangeMax",To[To.GaugeLowerInflectionPointNaN=42]="GaugeLowerInflectionPointNaN",To[To.GaugeUpperInflectionPointNaN=43]="GaugeUpperInflectionPointNaN",To[To.GaugeLowerBiggerThanUpper=44]="GaugeLowerBiggerThanUpper",To[To.InvalidAutofillSelection=45]="InvalidAutofillSelection",To[To.WrongComposerSelection=46]="WrongComposerSelection",To[To.MinBiggerThanMax=47]="MinBiggerThanMax",To[To.LowerBiggerThanUpper=48]="LowerBiggerThanUpper",To[To.MidBiggerThanMax=49]="MidBiggerThanMax",To[To.MinBiggerThanMid=50]="MinBiggerThanMid",To[To.FirstArgMissing=51]="FirstArgMissing",To[To.SecondArgMissing=52]="SecondArgMissing",To[To.MinNaN=53]="MinNaN",To[To.MidNaN=54]="MidNaN",To[To.MaxNaN=55]="MaxNaN",To[To.ValueUpperInflectionNaN=56]="ValueUpperInflectionNaN",To[To.ValueLowerInflectionNaN=57]="ValueLowerInflectionNaN",To[To.MinInvalidFormula=58]="MinInvalidFormula",To[To.MidInvalidFormula=59]="MidInvalidFormula",To[To.MaxInvalidFormula=60]="MaxInvalidFormula",To[To.ValueUpperInvalidFormula=61]="ValueUpperInvalidFormula",To[To.ValueLowerInvalidFormula=62]="ValueLowerInvalidFormula",To[To.InvalidSortZone=63]="InvalidSortZone",To[To.WaitingSessionConfirmation=64]="WaitingSessionConfirmation",To[To.MergeOverlap=65]="MergeOverlap",To[To.TooManyHiddenElements=66]="TooManyHiddenElements",To[To.Readonly=67]="Readonly",To[To.InvalidViewportSize=68]="InvalidViewportSize",To[To.InvalidScrollingDirection=69]="InvalidScrollingDirection",To[To.FigureDoesNotExist=70]="FigureDoesNotExist",To[To.InvalidConditionalFormatId=71]="InvalidConditionalFormatId",To[To.InvalidCellPopover=72]="InvalidCellPopover",To[To.EmptyTarget=73]="EmptyTarget",To[To.InvalidFreezeQuantity=74]="InvalidFreezeQuantity",To[To.FrozenPaneOverlap=75]="FrozenPaneOverlap",To[To.ValuesNotChanged=76]="ValuesNotChanged",To[To.InvalidFilterZone=77]="InvalidFilterZone",To[To.FilterOverlap=78]="FilterOverlap",To[To.FilterNotFound=79]="FilterNotFound",To[To.MergeInFilter=80]="MergeInFilter",To[To.NonContinuousTargets=81]="NonContinuousTargets",To[To.DuplicatedFigureId=82]="DuplicatedFigureId",To[To.InvalidSelectionStep=83]="InvalidSelectionStep",To[To.DuplicatedChartId=84]="DuplicatedChartId",function(e){e.UP="up",e.DOWN="down",e.LEFT="left",e.RIGHT="right"}(Ao||(Ao={})),function(e){e[e.Background=0]="Background",e[e.Highlights=1]="Highlights",e[e.Clipboard=2]="Clipboard",e[e.Search=3]="Search",e[e.Chart=4]="Chart",e[e.Autofill=5]="Autofill",e[e.Selection=6]="Selection",e[e.Headers=7]="Headers"}(Mo||(Mo={}));const Uo=["rgb(31,119,180)","rgb(255,127,14)","rgb(174,199,232)","rgb(255,187,120)","rgb(44,160,44)","rgb(152,223,138)","rgb(214,39,40)","rgb(255,152,150)","rgb(148,103,189)","rgb(197,176,213)","rgb(140,86,75)","rgb(196,156,148)","rgb(227,119,194)","rgb(247,182,210)","rgb(127,127,127)","rgb(199,199,199)","rgb(188,189,34)","rgb(219,219,141)","rgb(23,190,207)","rgb(158,218,229)"];class Vo{constructor(){this.graphColorIndex=0}next(){return Uo[this.graphColorIndex++%Uo.length]}}function zo(e){return e&&Ct(e)<.3?"#FFFFFF":"#000000"}function Bo(e){if(e.dataSets){const t=void 0!==e.dataSets.find((e=>!Ot.test(e)));if(t)return 32;if(e.dataSets.map(Ni).some((e=>e.top!==e.bottom&&eo(e))))return 32}return 0}function Ho(e){if(e.labelRange){if(!Ot.test(e.labelRange||""))return 33}return 0}function $o(e,t,i){if(e){if("text"===i||(null==t?void 0:t.type)!==So.number||e.type!==So.number)return e.formattedValue;{let o=t.value-e.value;if("percentage"===i&&0!==o&&(o=o/e.value*100),"percentage"!==i&&e.format)return li(o,e.format);const n=Math.abs(parseFloat(o.toFixed(2))).toLocaleString();return"percentage"===i?n+"%":n}}return""}function Wo(e,t,i,o,n){if("text"===t||(null==e?void 0:e.type)!==So.number||(null==i?void 0:i.type)!==So.number)return;const s=i.value-e.value;return s>0?o:s<0?n:void 0}function Go(e,t,i){if("text"===i||(null==e?void 0:e.type)!==So.number||(null==t?void 0:t.type)!==So.number)return"neutral";const o=t.value-e.value;return o>0?"up":o<0?"down":"neutral"}const qo={Errors:{25:s("The range is invalid"),51:s("The argument is missing. Please provide a value"),52:s("The second argument is missing. Please provide a value"),53:s("The minpoint must be a number"),54:s("The midpoint must be a number"),55:s("The maxpoint must be a number"),56:s("The first value must be a number"),57:s("The second value must be a number"),47:s("Minimum must be smaller then Maximum"),50:s("Minimum must be smaller then Midpoint"),49:s("Midpoint must be smaller then Maximum"),48:s("Lower inflection point must be smaller than upper inflection point"),58:s("Invalid Minpoint formula"),60:s("Invalid Maxpoint formula"),59:s("Invalid Midpoint formula"),61:s("Invalid upper inflection point formula"),62:s("Invalid lower inflection point formula"),24:s("A range needs to be defined"),Unexpected:s("The rule is invalid for an unknown reason")},ColorScale:s("Color scale"),IconSet:s("Icon set")},Zo={IsEmpty:s("Is empty"),IsNotEmpty:s("Is not empty"),ContainsText:s("Contains"),NotContains:s("Does not contain"),BeginsWith:s("Starts with"),EndsWith:s("Ends with"),Equal:s("Is equal to"),NotEqual:s("Is not equal to"),GreaterThan:s("Is greater than"),GreaterThanOrEqual:s("Is greater than or equal to"),LessThan:s("Is less than"),LessThanOrEqual:s("Is less than or equal to"),Between:s("Is between"),NotBetween:s("Is not between")},jo={Series:s("Series"),Errors:{Unexpected:s("The chart definition is invalid for an unknown reason"),32:s("The dataset is invalid"),33:s("Labels are invalid"),34:s("The key value is invalid"),35:s("The baseline value is invalid"),36:s("The data range is invalid"),37:s("A minimum range limit value is needed"),38:s("The minimum range limit value must be a number"),39:s("A maximum range limit value is needed"),40:s("The maximum range limit value must be a number"),41:s("Minimum range limit must be smaller than maximum range limit"),42:s("The lower inflection point value must be a number"),43:s("The upper inflection point value must be a number")}},Xo={Automatic:s("Automatic"),Number:s("Number"),Percent:s("Percent"),Currency:s("Currency"),CurrencyRounded:s("Currency rounded"),Date:s("Date"),Time:s("Time"),DateTime:s("Date time"),Duration:s("Duration"),CustomCurrency:s("Custom currency")},Yo={Custom:s("Custom")},Ko=s("Merged cells are preventing this operation. Unmerge those cells and try again.");function Qo(e,t){if(t.dataRange){const i=t.labelCell?[Di(t.labelCell.zone)]:[],o=Gi([Di(t.dataRange.zone)],i)[0];if(void 0===o)return[];const n=e.getRangeFromSheetXC(t.dataRange.sheetId,o);return e.getRangeValues(n).map((e=>""===e?void 0:e))}return[]}function Jo(e,t){const i=ze(0,Math.max(e.length,...t.map((e=>{var t;return(null===(t=e.data)||void 0===t?void 0:t.length)||0})))).filter((i=>{const o=e[i],n=t.map((e=>{var t;return null===(t=e.data)||void 0===t?void 0:t[i]}));return o||n.some((e=>0===e||Boolean(e)))}));return{labels:i.map((t=>e[t]||"")),dataSetsValues:t.map((e=>({...e,data:i.map((t=>e.data[t]))})))}}function en(e,t){const i=new Set(e),o={};i.forEach((e=>{o[e]=new Array(t.length).fill(0)}));for(const i of ze(0,e.length)){const s=e[i];for(const e of ze(0,t.length))o[s][e]+="number"==typeof(n=t[e].data[i])?n:0}var n;return{labels:Object.keys(o),dataSetsValues:t.map(((e,t)=>({...e,data:Object.values(o).map((e=>e[t]))})))}}function tn(e){return e?e.length>Q?e.substring(0,Q)+"…":e:""}function on(e,t,i,o){return{type:e.type,options:{responsive:!0,maintainAspectRatio:!1,layout:{padding:{left:20,right:20,top:e.title?10:25,bottom:10}},elements:{line:{fill:!1},point:{hitRadius:15}},animation:{duration:0},hover:{animationDuration:10},responsiveAnimationDuration:0,title:{display:!!e.title,fontSize:22,fontStyle:"normal",text:n(e.title),fontColor:i},legend:{onClick:void 0},tooltips:{callbacks:{label:function(e,t){var i,n,s,r,a;let l=null===(n=null===(i=t.datasets)||void 0===i?void 0:i[e.datasetIndex||0])||void 0===n?void 0:n.label;const c=""!==e.yLabel?e.yLabel:null===(a=null===(r=null===(s=t.datasets)||void 0===s?void 0:s[e.datasetIndex||0])||void 0===r?void 0:r.data)||void 0===a?void 0:a[e.index||0],h=o&&"number"==typeof c?li(c,o):(null==c?void 0:c.toLocaleString())||"";return l?`${l}: ${h}`:h}}}},data:{labels:t.map(tn),datasets:[]}}}function nn(e,t,i){let o={values:[],formattedValues:[]};if(i)i.invalidXc||i.invalidSheetName||(o={formattedValues:e.getRangeFormattedValues(i),values:e.getRangeValues(i).map((e=>String(e)))});else if(1===t.length)for(let i=0;i<Qo(e,t[0]).length;i++)o.formattedValues.push(""),o.values.push("");else if(t[0]){o={formattedValues:ze(0,Qo(e,t[0]).length).map((e=>e.toString())),values:o.formattedValues}}return o}function sn(e,t){for(const i of t){const t=e.getRangeFormats(i.dataRange).find((e=>void 0!==e&&!ui(e)));if(t)return t}}function rn(e,t){const i=[];for(const[o,n]of Object.entries(t)){let t;if(n.labelCell){const i=n.labelCell,s=i?e.getEvaluatedCell({sheetId:i.sheetId,col:i.zone.left,row:i.zone.top}):void 0;t=s&&i?tn(s.formattedValue):t=`${jo.Series} ${parseInt(o)+1}`}else t=t=`${jo.Series} ${parseInt(o)+1}`;let s=n.dataRange?Qo(e,n):[];i.push({data:s,label:t})}return i}function an(e){return 0===e?"origin":e-1}class ln extends vo{constructor(e,t,i){super(e,t,i),this.type="bar",this.dataSets=Do(i,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=Ti(i,t,e.labelRange),this.background=e.background,this.verticalAxisPosition=e.verticalAxisPosition,this.legendPosition=e.legendPosition,this.stacked=e.stacked,this.aggregated=e.aggregated}static transformDefinition(e,t){return Po(e,t)}static validateChartDefinition(e,t){return e.checkValidations(t,Bo,Ho)}static getDefinitionFromContextCreation(e){return{background:e.background,dataSets:e.range?e.range:[],dataSetsHaveTitle:!1,stacked:!1,aggregated:!1,legendPosition:"top",title:e.title||"",type:"bar",verticalAxisPosition:"left",labelRange:e.auxiliaryRange||void 0}}getContextCreation(){return{background:this.background,title:this.title,range:this.dataSets.map((e=>this.getters.getRangeString(e.dataRange,this.sheetId))),auxiliaryRange:this.labelRange?this.getters.getRangeString(this.labelRange,this.sheetId):void 0}}copyForSheetId(e){const t=No(this.sheetId,e,this.dataSets),i=_o(this.sheetId,e,this.labelRange),o=this.getDefinitionWithSpecificDataSets(t,i,e);return new ln(o,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,e);return new ln(t,e,this.getters)}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getDefinitionWithSpecificDataSets(e,t,i){return{type:"bar",dataSetsHaveTitle:!!e.length&&Boolean(e[0].labelCell),background:this.background,dataSets:e.map((e=>this.getters.getRangeString(e.dataRange,i||this.sheetId))),legendPosition:this.legendPosition,verticalAxisPosition:this.verticalAxisPosition,labelRange:t?this.getters.getRangeString(t,i||this.sheetId):void 0,title:this.title,stacked:this.stacked,aggregated:this.aggregated}}getDefinitionForExcel(){if(this.aggregated)return;const e=this.dataSets.map((e=>Lo(this.getters,e))).filter((e=>""!==e.range));return{...this.getDefinition(),backgroundColor:fo(this.background||w),fontColor:fo(zo(this.background)),dataSets:e}}updateRanges(e){const{dataSets:t,labelRange:i,isStale:o}=Oo(this.getters,e,this.dataSets,this.labelRange);if(!o)return this;const n=this.getDefinitionWithSpecificDataSets(t,i);return new ln(n,this.sheetId,this.getters)}}function cn(e){return e.dataRange&&!Ot.test(e.dataRange)?36:0}function hn(e,t){return t((t=>t.sectionRule?e(t.sectionRule.rangeMin,"rangeMin"):0),(t=>t.sectionRule?e(t.sectionRule.rangeMax,"rangeMax"):0))}function dn(e){return e.sectionRule&&Number(e.sectionRule.rangeMin)>=Number(e.sectionRule.rangeMax)?41:0}function un(e,t){if(""===e)switch(t){case"rangeMin":return 37;case"rangeMax":return 39}return 0}function gn(e,t){if(isNaN(e))switch(t){case"rangeMin":return 38;case"rangeMax":return 40;case"lowerInflectionPointValue":return 42;case"upperInflectionPointValue":return 43}return 0}class pn extends vo{constructor(e,t,i){super(e,t,i),this.type="gauge",this.dataRange=Ti(this.getters,this.sheetId,e.dataRange),this.sectionRule=e.sectionRule,this.background=e.background}static validateChartDefinition(e,t){return e.checkValidations(t,cn,e.chainValidations(hn(un,e.batchValidations),hn(gn,e.batchValidations),dn),e.chainValidations((i=gn,(0,e.batchValidations)((e=>e.sectionRule?i(e.sectionRule.lowerInflectionPoint.value,"lowerInflectionPointValue"):0),(e=>e.sectionRule?i(e.sectionRule.upperInflectionPoint.value,"upperInflectionPointValue"):0)))));var i}static transformDefinition(e,t){let i;return e.dataRange&&(i=bo(Ni(e.dataRange),t)),{...e,dataRange:i?Di(i):void 0}}static getDefinitionFromContextCreation(e){return{background:e.background,title:e.title||"",type:"gauge",dataRange:e.range?e.range[0]:void 0,sectionRule:{colors:{lowerColor:"#cc0000",middleColor:"#f1c232",upperColor:"#6aa84f"},rangeMin:"0",rangeMax:"100",lowerInflectionPoint:{type:"percentage",value:"15"},upperInflectionPoint:{type:"percentage",value:"40"}}}}copyForSheetId(e){const t=_o(this.sheetId,e,this.dataRange),i=this.getDefinitionWithSpecificRanges(t,e);return new pn(i,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificRanges(this.dataRange,e);return new pn(t,e,this.getters)}getDefinition(){return this.getDefinitionWithSpecificRanges(this.dataRange)}getDefinitionWithSpecificRanges(e,t){return{background:this.background,sectionRule:this.sectionRule,title:this.title,type:"gauge",dataRange:e?this.getters.getRangeString(e,t||this.sheetId):void 0}}getDefinitionForExcel(){}getContextCreation(){return{background:this.background,title:this.title,range:this.dataRange?[this.getters.getRangeString(this.dataRange,this.sheetId)]:void 0}}updateRanges(e){const t=Fo(this.dataRange,e);if(this.dataRange===t)return this;const i=this.getDefinitionWithSpecificRanges(t);return new pn(i,this.sheetId,this.getters)}}const mn={second:1e3,minute:6e4,hour:36e5,day:864e5,month:2592e6,year:31536e6},fn={inSeconds:function(e){return Math.floor(e/mn.second)},inMinutes:function(e){return Math.floor(e/mn.minute)},inHours:function(e){return Math.floor(e/mn.hour)},inDays:function(e){return Math.floor(e/mn.day)},inMonths:function(e){return Math.floor(e/mn.month)},inYears:function(e){return Math.floor(e/mn.year)}},vn=/^((d|dd|m|mm|yyyy|yy|hh|h|ss|a)(-|:|\s|\/))*(d|dd|m|mm|yyyy|yy|hh|h|ss|a)$/i;function bn(e,t){const i=function(e){const t=(e=(e=e.replace(/y/g,"Y")).replace(/d/g,"D")).indexOf("h");e=t>=0?e.slice(0,t).replace(/m/g,"M")+e.slice(t):e.replace(/m/g,"M");e.includes("a")||(e=e.replace(/h/g,"H"));return e}(t),o=function(e,t){const i=e.map((e=>{var t;return null===(t=Se(e))||void 0===t?void 0:t.jsDate}));if(i.some((e=>void 0===e))||e.length<2)return;const o=i.map((e=>e.getTime())),n=Math.max(...o)-Math.min(...o),s=function(e){if(e.includes("s"))return"second";if(e.includes("m"))return"minute";if(e.includes("h")||e.includes("H"))return"hour";if(e.includes("D"))return"day";if(e.includes("M"))return"month";return"year"}(t);if(mn.second>=mn[s]&&fn.inSeconds(n)<180)return"second";if(mn.minute>=mn[s]&&fn.inMinutes(n)<180)return"minute";if(mn.hour>=mn[s]&&fn.inHours(n)<96)return"hour";if(mn.day>=mn[s]&&fn.inDays(n)<90)return"day";if(mn.month>=mn[s]&&fn.inMonths(n)<36)return"month";return"year"}(e,i),n={};return o&&(n[o]=i),{parser:i,displayFormats:n,unit:o}}class Sn extends vo{constructor(e,t,i){super(e,t,i),this.type="line",this.dataSets=Do(this.getters,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=Ti(this.getters,t,e.labelRange),this.background=e.background,this.verticalAxisPosition=e.verticalAxisPosition,this.legendPosition=e.legendPosition,this.labelsAsText=e.labelsAsText,this.stacked=e.stacked,this.aggregated=e.aggregated}static validateChartDefinition(e,t){return e.checkValidations(t,Bo,Ho)}static transformDefinition(e,t){return Po(e,t)}static getDefinitionFromContextCreation(e){return{background:e.background,dataSets:e.range?e.range:[],dataSetsHaveTitle:!1,labelsAsText:!1,legendPosition:"top",title:e.title||"",type:"line",verticalAxisPosition:"left",labelRange:e.auxiliaryRange||void 0,stacked:!1,aggregated:!1}}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getDefinitionWithSpecificDataSets(e,t,i){return{type:"line",dataSetsHaveTitle:!!e.length&&Boolean(e[0].labelCell),background:this.background,dataSets:e.map((e=>this.getters.getRangeString(e.dataRange,i||this.sheetId))),legendPosition:this.legendPosition,verticalAxisPosition:this.verticalAxisPosition,labelRange:t?this.getters.getRangeString(t,i||this.sheetId):void 0,title:this.title,labelsAsText:this.labelsAsText,stacked:this.stacked,aggregated:this.aggregated}}getContextCreation(){return{background:this.background,title:this.title,range:this.dataSets.map((e=>this.getters.getRangeString(e.dataRange,this.sheetId))),auxiliaryRange:this.labelRange?this.getters.getRangeString(this.labelRange,this.sheetId):void 0}}updateRanges(e){const{dataSets:t,labelRange:i,isStale:o}=Oo(this.getters,e,this.dataSets,this.labelRange);if(!o)return this;const n=this.getDefinitionWithSpecificDataSets(t,i);return new Sn(n,this.sheetId,this.getters)}getDefinitionForExcel(){if(this.aggregated)return;const e=this.dataSets.map((e=>Lo(this.getters,e))).filter((e=>""!==e.range));return{...this.getDefinition(),backgroundColor:fo(this.background||w),fontColor:fo(zo(this.background)),dataSets:e}}copyForSheetId(e){const t=No(this.sheetId,e,this.dataSets),i=_o(this.sheetId,e,this.labelRange),o=this.getDefinitionWithSpecificDataSets(t,i,e);return new Sn(o,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,e);return new Sn(t,e,this.getters)}}function Cn(e,t){return wn(e,t)||yn(e,t)}function En(e,t){return function(e,t){return!e.labelsAsText&&wn(e.labelRange,t)}(e,t)?"time":function(e,t){return!e.labelsAsText&&yn(e.labelRange,t)}(e,t)?"linear":"category"}function wn(e,t){if(!e||!yn(e,t))return!1;const i=t.getEvaluatedCell({sheetId:e.sheetId,col:e.zone.left,row:e.zone.top}).format;return Boolean(i&&vn.test(i))}function yn(e,t){if(!e)return!1;const i=t.getRangeValues(e);return!i.some((e=>isNaN(Number(e))&&e))&&!i.every((e=>!e))}class xn extends vo{constructor(e,t,i){super(e,t,i),this.type="pie",this.dataSets=Do(i,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=Ti(i,t,e.labelRange),this.background=e.background,this.legendPosition=e.legendPosition,this.aggregated=e.aggregated}static transformDefinition(e,t){return Po(e,t)}static validateChartDefinition(e,t){return e.checkValidations(t,Bo,Ho)}static getDefinitionFromContextCreation(e){return{background:e.background,dataSets:e.range?e.range:[],dataSetsHaveTitle:!1,legendPosition:"top",title:e.title||"",type:"pie",labelRange:e.auxiliaryRange||void 0,aggregated:!1}}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getContextCreation(){return{background:this.background,title:this.title,range:this.dataSets.map((e=>this.getters.getRangeString(e.dataRange,this.sheetId))),auxiliaryRange:this.labelRange?this.getters.getRangeString(this.labelRange,this.sheetId):void 0}}getDefinitionWithSpecificDataSets(e,t,i){return{type:"pie",dataSetsHaveTitle:!!e.length&&Boolean(e[0].labelCell),background:this.background,dataSets:e.map((e=>this.getters.getRangeString(e.dataRange,i||this.sheetId))),legendPosition:this.legendPosition,labelRange:t?this.getters.getRangeString(t,i||this.sheetId):void 0,title:this.title,aggregated:this.aggregated}}copyForSheetId(e){const t=No(this.sheetId,e,this.dataSets),i=_o(this.sheetId,e,this.labelRange),o=this.getDefinitionWithSpecificDataSets(t,i,e);return new xn(o,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,e);return new xn(t,e,this.getters)}getDefinitionForExcel(){if(this.aggregated)return;const e=this.dataSets.map((e=>Lo(this.getters,e))).filter((e=>""!==e.range));return{...this.getDefinition(),backgroundColor:fo(this.background||w),fontColor:fo(zo(this.background)),verticalAxisPosition:"left",dataSets:e}}updateRanges(e){const{dataSets:t,labelRange:i,isStale:o}=Oo(this.getters,e,this.dataSets,this.labelRange);if(!o)return this;const n=this.getDefinitionWithSpecificDataSets(t,i);return new xn(n,this.sheetId,this.getters)}}function In(e,t){const i=[],o=Math.max(...t.map((e=>e.data.length)));for(let t=0;t<=o;t++)i.push(e.next());return i}function Rn(e){return e.keyValue&&!Ot.test(e.keyValue)?34:0}function Tn(e){return e.baseline&&!Ot.test(e.baseline)?35:0}class An extends vo{constructor(e,t,i){super(e,t,i),this.type="scorecard",this.keyValue=Ti(i,t,e.keyValue),this.baseline=Ti(i,t,e.baseline),this.baselineMode=e.baselineMode,this.baselineDescr=e.baselineDescr,this.background=e.background,this.baselineColorUp=e.baselineColorUp,this.baselineColorDown=e.baselineColorDown}static validateChartDefinition(e,t){return e.checkValidations(t,Rn,Tn)}static getDefinitionFromContextCreation(e){return{background:e.background,type:"scorecard",keyValue:e.range?e.range[0]:void 0,title:e.title||"",baselineMode:ee,baselineColorUp:te,baselineColorDown:ie,baseline:e.auxiliaryRange||""}}static transformDefinition(e,t){let i,o;return e.baseline&&(i=bo(Ni(e.baseline),t)),e.keyValue&&(o=bo(Ni(e.keyValue),t)),{...e,baseline:i?Di(i):void 0,keyValue:o?Di(o):void 0}}copyForSheetId(e){const t=_o(this.sheetId,e,this.baseline),i=_o(this.sheetId,e,this.keyValue),o=this.getDefinitionWithSpecificRanges(t,i,e);return new An(o,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificRanges(this.baseline,this.keyValue,e);return new An(t,e,this.getters)}getDefinition(){return this.getDefinitionWithSpecificRanges(this.baseline,this.keyValue)}getContextCreation(){return{background:this.background,title:this.title,range:this.keyValue?[this.getters.getRangeString(this.keyValue,this.sheetId)]:void 0,auxiliaryRange:this.baseline?this.getters.getRangeString(this.baseline,this.sheetId):void 0}}getDefinitionWithSpecificRanges(e,t,i){return{baselineColorDown:this.baselineColorDown,baselineColorUp:this.baselineColorUp,baselineMode:this.baselineMode,title:this.title,type:"scorecard",background:this.background,baseline:e?this.getters.getRangeString(e,i||this.sheetId):void 0,baselineDescr:this.baselineDescr,keyValue:t?this.getters.getRangeString(t,i||this.sheetId):void 0}}getDefinitionForExcel(){}updateRanges(e){const t=Fo(this.baseline,e),i=Fo(this.keyValue,e);if(this.baseline===t&&this.keyValue===i)return this;const o=this.getDefinitionWithSpecificRanges(t,i);return new An(o,this.sheetId,this.getters)}}class Mn{constructor(){this.content={}}add(e,t){return this.content[e]=t,this}get(e){const t=this.content[e];if(!t&&!(e in this.content))throw new Error(`Cannot find ${e} in this registry!`);return t}contains(e){return e in this.content}getAll(){return Object.values(this.content)}getKeys(){return Object.keys(this.content)}remove(e){delete this.content[e]}}const On=new Mn;On.add("bar",{match:e=>"bar"===e,createChart:(e,t,i)=>new ln(e,t,i),getChartRuntime:function(e,t){let i=nn(t,e.dataSets,e.labelRange).formattedValues,o=rn(t,e.dataSets);({labels:i,dataSetsValues:o}=Jo(i,o)),e.aggregated&&({labels:i,dataSetsValues:o}=en(i,o));const n=function(e,t,i){var o;const n=zo(e.background),s=on(e,t,n,i),r={labels:{fontColor:n}};return!e.labelRange&&1===e.dataSets.length||"none"===e.legendPosition?r.display=!1:r.position=e.legendPosition,s.options.legend={...null===(o=s.options)||void 0===o?void 0:o.legend,...r},s.options.layout={padding:{left:20,right:20,top:e.title?10:25,bottom:10}},s.options.scales={xAxes:[{ticks:{maxRotation:60,minRotation:15,padding:5,labelOffset:2,fontColor:n}}],yAxes:[{position:e.verticalAxisPosition,ticks:{fontColor:n,beginAtZero:!0,callback:e=>i?li(e,i):(null==e?void 0:e.toLocaleString())||e}}]},e.stacked&&(s.options.scales.xAxes[0].stacked=!0,s.options.scales.yAxes[0].stacked=!0),s}(e,i,sn(t,e.dataSets)),s=new Vo;for(let{label:e,data:t}of o){const i=s.next(),o={label:e,data:t,borderColor:i,backgroundColor:i};n.data.datasets.push(o)}return{chartJsConfig:n,background:e.background||w}},validateChartDefinition:(e,t)=>ln.validateChartDefinition(e,t),transformDefinition:(e,t)=>ln.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>ln.getDefinitionFromContextCreation(e),name:s("Bar"),sequence:10}),On.add("line",{match:e=>"line"===e,createChart:(e,t,i)=>new Sn(e,t,i),getChartRuntime:function(e,t){const i=En(e,t),o=nn(t,e.dataSets,e.labelRange);let n="linear"===i?o.values:o.formattedValues,s=rn(t,e.dataSets);({labels:n,dataSetsValues:s}=Jo(n,s)),"time"===i&&({labels:n,dataSetsValues:s}=function(e,t){if(0===e.length||e.every((e=>!e)))return{labels:e,dataSetsValues:t};const i=[...e],o=Ne(t);for(let e=0;e<i.length;e++)if(!i[e]){i[e]=st(i,e);for(let t of o)t.data[e]=void 0}return{labels:i,dataSetsValues:o}}(n,s)),e.aggregated&&({labels:n,dataSetsValues:s}=en(n,s));const r=sn(t,e.dataSets),a=function(e,t,i){var o;const n=zo(e.background),s=on(e,t,n,i),r={labels:{fontColor:n,generateLabels(e){const{data:t}=e,i=window.Chart.defaults.global.legend.labels.generateLabels(e);for(const[e,o]of i.entries())o.fillStyle=t.datasets[e].borderColor;return i}}};return!e.labelRange&&1===e.dataSets.length||"none"===e.legendPosition?r.display=!1:r.position=e.legendPosition,s.options.legend={...null===(o=s.options)||void 0===o?void 0:o.legend,...r},s.options.layout={padding:{left:20,right:20,top:e.title?10:25,bottom:10}},s.options.scales={xAxes:[{ticks:{maxRotation:60,minRotation:15,padding:5,labelOffset:2,fontColor:n}}],yAxes:[{position:e.verticalAxisPosition,ticks:{fontColor:n,beginAtZero:!0,callback:e=>i?li(e,i):(null==e?void 0:e.toLocaleString())||e}}]},e.stacked&&(s.options.scales.yAxes[0].stacked=!0),s}(e,n,r),l=function(e,t){if(t)return e.getEvaluatedCell({sheetId:t.sheetId,col:t.zone.left,row:t.zone.top}).format}(t,e.labelRange);"time"===i?(a.options.scales.xAxes[0].type="time",a.options.scales.xAxes[0].time=bn(n,l),a.options.scales.xAxes[0].ticks.maxTicksLimit=15):"linear"===i&&(a.options.scales.xAxes[0].type="linear",a.options.scales.xAxes[0].ticks.callback=e=>li(e,l),a.options.tooltips.callbacks.title=e=>{var t;return li((null===(t=e[0])||void 0===t?void 0:t.xLabel)||"",l)});const c=new Vo;for(let[t,{label:o,data:r}]of s.entries()){["linear","time"].includes(i)&&(r=r.map(((e,t)=>({x:n[t]||void 0,y:e}))));const s=c.next();let l=wt(s);e.stacked&&(l.a=oe);const h={label:o,data:r,lineTension:0,borderColor:s,backgroundColor:Et(l),pointBackgroundColor:s,fill:!!e.stacked&&an(t)};a.data.datasets.push(h)}return{chartJsConfig:a,background:e.background||w}},validateChartDefinition:(e,t)=>Sn.validateChartDefinition(e,t),transformDefinition:(e,t)=>Sn.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>Sn.getDefinitionFromContextCreation(e),name:s("Line"),sequence:20}),On.add("pie",{match:e=>"pie"===e,createChart:(e,t,i)=>new xn(e,t,i),getChartRuntime:function(e,t){let i=nn(t,e.dataSets,e.labelRange).formattedValues,o=rn(t,e.dataSets);({labels:i,dataSetsValues:o}=Jo(i,o)),e.aggregated&&({labels:i,dataSetsValues:o}=en(i,o));const n=function(e,t,i){var o;const n=zo(e.background),s=on(e,t,n,i),r={labels:{fontColor:n}};return!e.labelRange&&1===e.dataSets.length||"none"===e.legendPosition?r.display=!1:r.position=e.legendPosition,s.options.legend={...null===(o=s.options)||void 0===o?void 0:o.legend,...r},s.options.layout={padding:{left:20,right:20,top:e.title?10:25,bottom:10}},s.options.tooltips.callbacks.title=function(e,t){return t.datasets[e[0].datasetIndex].label},s}(e,i,sn(t,e.dataSets)),s=new Vo;for(let{label:e,data:t}of o){const i={label:e,data:t,borderColor:"#FFFFFF",backgroundColor:In(s,o)};n.data.datasets.push(i)}return{chartJsConfig:n,background:e.background||w}},validateChartDefinition:(e,t)=>xn.validateChartDefinition(e,t),transformDefinition:(e,t)=>xn.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>xn.getDefinitionFromContextCreation(e),name:s("Pie"),sequence:30}),On.add("scorecard",{match:e=>"scorecard"===e,createChart:(e,t,i)=>new An(e,t,i),getChartRuntime:function(e,t){let i,o,s="",r="";if(e.keyValue){const o={sheetId:e.keyValue.sheetId,col:e.keyValue.zone.left,row:e.keyValue.zone.top};i=t.getEvaluatedCell(o),s=String(i.value),r=i.formattedValue}const a=e.baseline;if(a){const i={sheetId:e.baseline.sheetId,col:e.baseline.zone.left,row:e.baseline.zone.top};o=t.getEvaluatedCell(i)}const l=t.getBackgroundOfSingleCellChart(e.background,e.keyValue);return{title:n(e.title),keyValue:r||s,baselineDisplay:$o(o,i,e.baselineMode),baselineArrow:Go(o,i,e.baselineMode),baselineColor:Wo(o,e.baselineMode,i,e.baselineColorUp,e.baselineColorDown),baselineDescr:e.baselineDescr?n(e.baselineDescr):"",fontColor:zo(l),background:l,baselineStyle:"percentage"!==e.baselineMode&&a?t.getCellStyle({sheetId:a.sheetId,col:a.zone.left,row:a.zone.top}):void 0,keyValueStyle:e.keyValue?t.getCellStyle({sheetId:e.keyValue.sheetId,col:e.keyValue.zone.left,row:e.keyValue.zone.top}):void 0}},validateChartDefinition:(e,t)=>An.validateChartDefinition(e,t),transformDefinition:(e,t)=>An.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>An.getDefinitionFromContextCreation(e),name:s("Scorecard"),sequence:40}),On.add("gauge",{match:e=>"gauge"===e,createChart:(e,t,i)=>new pn(e,t,i),getChartRuntime:function(e,t){const i=function(e){const t=on(e,[],zo(e.background));return t.options.hover=void 0,t.options.events=[],t.options.layout={padding:{left:30,right:30,top:e.title?10:25,bottom:25}},t.options.needle={radiusPercentage:2,widthPercentage:3.2,lengthPercentage:80,color:"#000000"},t.options.valueLabel={display:!1,formatter:null,color:"#FFFFFF",backgroundColor:"#000000",fontSize:30,borderRadius:5,padding:{top:5,right:5,bottom:5,left:5},bottomMarginPercentage:5},t}(e),o=e.sectionRule.colors,n=e.sectionRule.lowerInflectionPoint,s=e.sectionRule.upperInflectionPoint,r=Number(n.value),a=Number(s.value),l=Number(e.sectionRule.rangeMin),c=Number(e.sectionRule.rangeMax),h=c-l,d=[];if(""!==n.value){const e="number"===n.type?r:l+h*r/100;d.push({value:De(e,l,c),color:o.lowerColor})}if(""!==s.value){const e="number"===s.type?a:l+h*a/100;d.push({value:De(e,l,c),color:o.middleColor})}const u=[],g=[];d.sort(((e,t)=>e.value-t.value)).map((e=>{u.push(e.value),g.push(e.color)})),u.push(c),g.push(o.upperColor);const p=e.dataRange,m=h/30;let f=l-m,v=null,b=!1;if(void 0!==p){const e=t.getEvaluatedCell({sheetId:p.sheetId,col:p.zone.left,row:p.zone.top});e.type===So.number&&(f=De(e.value,l-m,c+m),v=()=>t.getRangeFormattedValues(p)[0],b=!0)}return i.options.valueLabel.display=b,i.options.valueLabel.formatter=v,i.data.datasets.push({data:u,minValue:Number(e.sectionRule.rangeMin),value:f,backgroundColor:g}),{chartJsConfig:i,background:t.getBackgroundOfSingleCellChart(e.background,p)}},validateChartDefinition:(e,t)=>pn.validateChartDefinition(e,t),transformDefinition:(e,t)=>pn.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>pn.getDefinitionFromContextCreation(e),name:s("Gauge"),sequence:50});const Nn=new Mn;function _n(e){return e.map(Dn).sort(((e,t)=>e.sequence-t.sequence))}Nn.add("line",oo),Nn.add("bar",oo),Nn.add("pie",oo),Nn.add("gauge",oo),Nn.add("scorecard",go);const Fn=new Oi;function Dn(e){const t=e.name,i=e.children;return{id:e.id||Fn.uuidv4(),name:"function"==typeof t?t:()=>t,isVisible:e.isVisible?e.isVisible:()=>!0,isEnabled:e.isEnabled?e.isEnabled:()=>!0,action:e.action,children:i?e=>i.map((t=>"function"==typeof t?t(e):t)).flat().map(Dn):()=>[],isReadonlyAllowed:e.isReadonlyAllowed||!1,separator:e.separator||!1,icon:e.icon,description:e.description||"",textColor:e.textColor,sequence:e.sequence||0}}class kn extends Mn{add(e,t){return void 0===t.id&&(t.id=e),this.content[e]=t,this}addChild(e,t,i){"function"!=typeof i&&void 0===i.id&&(i.id=e);const o=t.splice(0,1)[0];let n=this.content[o];if(!n)throw new Error(`Path ${o+":"+t.join(":")} not found`);for(let e of t){const i=n.children;if(!i||"function"==typeof i)throw new Error(`${e} is either not a node or it's dynamically computed`);if(n=i.find((t=>t.id===e)),!n)throw new Error(`Path ${o+":"+t.join(":")} not found`)}return n.children||(n.children=[]),n.children.push(i),this}getMenuItems(){return _n(this.getAll())}}function Ln(){const e=t.useState({x:0,y:0,width:0,height:0});let i=document.querySelector(".o-spreadsheet");function o(){if(i||(i=document.querySelector(".o-spreadsheet")),i){const{top:t,left:o,width:n,height:s}=i.getBoundingClientRect();e.x=o,e.y=t,e.width=n,e.height=s}}return o(),t.onMounted(o),t.onPatched(o),e}function Pn(e){const i=t.useState({x:0,y:0});function o(){const t=e.el;if(null===t)return;const{top:o,left:n}=t.getBoundingClientRect();n===i.x&&o===i.y||(i.x=n,i.y=o)}return t.onMounted(o),t.onPatched(o),i}function Un(e,t){return!!t.target&&e.contains(t.target)}function Vn(){const e=document.querySelector(".o-grid-overlay");if(e){const{top:t,left:i}=null==e?void 0:e.getBoundingClientRect();return{top:t,left:i}}throw new Error("Can't find spreadsheet position")}function zn(e){const t=e.getBoundingClientRect();return{x:t.x,y:t.y,width:t.width,height:t.height}}function*Bn(e){if(yield e,e.hasChildNodes())for(let t of e.childNodes)yield*Bn(t)}function Hn(e,t){return(i=zi($n(e),$n(t)))?{x:i.left,y:i.top,width:i.right-i.left,height:i.bottom-i.top}:void 0;var i}function $n(e){return{left:e.x,top:e.y,right:e.x+e.width,bottom:e.y+e.height}}ro`
52
+ `;class go extends t.Component{constructor(){super(...arguments),this.ctx=document.createElement("canvas").getContext("2d")}get runtime(){return this.env.model.getters.getChartRuntime(this.env.model.getters.getActiveSheetId(),this.props.figure.id)}get title(){return this.runtime.title}get keyValue(){return this.runtime.keyValue}get baseline(){return this.runtime.baselineDisplay}get baselineDescr(){const e=this.runtime.baselineDescr||"";return this.baseline&&e?" "+e:e}get baselineArrowDirection(){return this.runtime.baselineArrow}get backgroundColor(){return this.runtime.background}get primaryFontColor(){return this.runtime.fontColor}get secondaryFontColor(){return Ct(this.primaryFontColor)<=.3?"#757575":"#bbbbbb"}get figure(){return this.props.figure}get chartStyle(){return ho({padding:`${this.chartPadding}px`,background:this.backgroundColor})}get chartContentStyle(){return ho({height:`${this.getDrawableHeight()}px`})}get chartPadding(){return.02*this.props.figure.width}getTextStyles(){const e=.96*this.props.figure.width,t=this.getWidestElement(),i=t.getElementMaxFontSize(this.getDrawableHeight(),this);let o=function(e,t,i,o=.25){let n=1;if(i(n)>e)return n;if(i(t)<e)return t;let s=(n+t)/2,r=i(s),a=0;for(;Math.abs(r-e)>o&&a<20;)r>=e?t=(n+t)/2:n=(n+t)/2,s=(n+t)/2,r=i(s),a++;return s}(e,i,(e=>t.getElementWidth(e,this.ctx,this)))/i;const n=(new mo).getElementMaxFontSize(this.getDrawableHeight(),this)*o,s=(new po).getElementMaxFontSize(this.getDrawableHeight(),this)*o;return{titleStyle:this.getTextStyle({fontSize:18,color:this.secondaryFontColor}),keyStyle:this.getTextStyle({fontSize:n,cellStyle:this.runtime.keyValueStyle,color:this.primaryFontColor}),baselineStyle:this.getTextStyle({fontSize:s}),baselineValueStyle:this.getTextStyle({fontSize:s,cellStyle:this.runtime.baselineStyle,color:this.runtime.baselineColor||this.secondaryFontColor}),baselineDescrStyle:this.getTextStyle({fontSize:.9*s,color:this.secondaryFontColor})}}getTextStyle(e){const t=co(e.cellStyle);return t["font-size"]=`${e.fontSize}px`,t.display="inline-block",!t.color&&e.color&&(t.color=e.color),ho(t)}getDrawableHeight(){const e=2*this.chartPadding;let t=this.props.figure.height-e;return t-=this.title?18*uo:0,t}getWidestElement(){const e=new po,t=new mo;return e.getElementWidth(.35,this.ctx,this)>t.getElementWidth(.65,this.ctx,this)?e:t}}go.template="o-spreadsheet-ScorecardChart";class po{getElementWidth(e,t,i){if(!i.runtime)return 0;const o=i.baseline,n="neutral"!==i.baselineArrowDirection?"A "+o:o;t.font=`${e}px ${q}`;let s=t.measureText(n).width;return t.font=`${.9*e}px ${q}`,s+=t.measureText(i.baselineDescr).width,s}getElementMaxFontSize(e,t){if(!t.runtime)return 0;return(""!==t.baseline||t.baselineDescr?.35*e:0)/uo}}class mo{getElementWidth(e,t,i){if(!i.runtime)return 0;const o=i.keyValue||"";return t.font=`${e}px ${q}`,t.measureText(o).width}getElementMaxFontSize(e,t){if(!t.runtime)return 0;return(""!==t.baseline||t.baselineDescr?.65*e:e)/uo}}function fo(e){return 8===(e=ft(e).replace("#","")).length?e.slice(6)+e.slice(0,6):e}go.props={figure:Object};class vo{constructor(e,t,i){this.title=e.title,this.sheetId=t,this.getters=i}static validateChartDefinition(e,t){throw new Error("This method should be implemented by sub class")}static transformDefinition(e,t){throw new Error("This method should be implemented by sub class")}static getDefinitionFromContextCreation(e){throw new Error("This method should be implemented by sub class")}}function bo(e,t){return"REMOVE_COLUMNS_ROWS"===t.type?Ui(e,"COL"===t.dimension?"left":"top",t.elements):"ADD_COLUMNS_ROWS"===t.type?ki(e,"COL"===t.dimension?"left":"top",t.base,t.position,t.quantity):{...e}}var So,Co;!function(e){e.boolean="boolean",e.number="number",e.text="text",e.empty="empty",e.error="error"}(So||(So={})),function(e){e.PlainText="text/plain",e.Html="text/html"}(Co||(Co={}));const Eo=new Set(["RENAME_SHEET","DELETE_SHEET","CREATE_SHEET","ADD_COLUMNS_ROWS","REMOVE_COLUMNS_ROWS","DELETE_CELL","INSERT_CELL","UNDO","REDO"]),wo=new Set([...Eo,"DUPLICATE_SHEET","EVALUATE_CELLS","ADD_CONDITIONAL_FORMAT","REMOVE_CONDITIONAL_FORMAT","MOVE_CONDITIONAL_FORMAT"]),yo=new Set(["START","ACTIVATE_SHEET","COPY","PREPARE_SELECTION_INPUT_EXPANSION","STOP_SELECTION_INPUT","RESIZE_SHEETVIEW","SET_VIEWPORT_OFFSET","SELECT_SEARCH_NEXT_MATCH","SELECT_SEARCH_PREVIOUS_MATCH","REFRESH_SEARCH","UPDATE_SEARCH","CLEAR_SEARCH","EVALUATE_CELLS","SET_CURRENT_CONTENT","SET_FORMULA_VISIBILITY","OPEN_CELL_POPOVER","CLOSE_CELL_POPOVER","UPDATE_FILTER"]),xo=new Set(["UPDATE_CELL","UPDATE_CELL_POSITION","CLEAR_CELL","DELETE_CONTENT","ADD_COLUMNS_ROWS","REMOVE_COLUMNS_ROWS","RESIZE_COLUMNS_ROWS","HIDE_COLUMNS_ROWS","UNHIDE_COLUMNS_ROWS","SET_GRID_LINES_VISIBILITY","UNFREEZE_COLUMNS","UNFREEZE_ROWS","FREEZE_COLUMNS","FREEZE_ROWS","UNFREEZE_COLUMNS_ROWS","ADD_MERGE","REMOVE_MERGE","CREATE_SHEET","DELETE_SHEET","DUPLICATE_SHEET","MOVE_SHEET","RENAME_SHEET","HIDE_SHEET","SHOW_SHEET","MOVE_RANGES","ADD_CONDITIONAL_FORMAT","REMOVE_CONDITIONAL_FORMAT","MOVE_CONDITIONAL_FORMAT","CREATE_FIGURE","DELETE_FIGURE","UPDATE_FIGURE","SET_FORMATTING","CLEAR_FORMATTING","SET_BORDER","CREATE_CHART","UPDATE_CHART","CREATE_FILTER_TABLE","REMOVE_FILTER_TABLE","CREATE_IMAGE"]);function Io(e){return xo.has(e.type)}class Ro{constructor(e=[]){Array.isArray(e)||(e=[e]),e=[...new Set(e)],this.reasons=e.filter((e=>0!==e))}static get Success(){return new Ro}get isSuccessful(){return 0===this.reasons.length}isCancelledBecause(e){return this.reasons.includes(e)}}var To,Ao,Mo;function Oo(e,t,i,o){let n=!1;const s=[];for(let o in i){let r=i[o];if(r.labelCell){const e=Fo(r.labelCell,t);r.labelCell!==e&&(n=!0,r={...r,labelCell:e})}const a=Fo(r.dataRange,t);void 0===a||e.getRangeString(a,a.sheetId)===Y?(n=!0,r=void 0):a!==r.dataRange&&(n=!0,r={...r,dataRange:a}),s[o]=r}let r=o;const a=Fo(r,t);a!==r&&(n=!0,r=a);return{isStale:n,dataSets:s.filter(et),labelRange:r}}function No(e,t,i){return i.map((i=>({dataRange:Ri(e,t,i.dataRange),labelCell:i.labelCell?Ri(e,t,i.labelCell):void 0})))}function _o(e,t,i){return i?Ri(e,t,i):void 0}function Fo(e,t){if(!e)return;const i=t(e);switch(i.changeType){case"NONE":return e;case"REMOVE":return;default:return i.range}}function Do(e,t,i,o){const n=[];for(const s of t){const t=e.getRangeFromSheetXC(i,s),{unboundedZone:r,sheetId:a,invalidSheetName:l}=t;if(!l)if(r.left!==r.right&&r.top!==r.bottom){if(void 0===r.right)continue;for(let t=r.left;t<=r.right;t++){const i={...r,left:t,right:t};n.push(ko(e,a,i,o?{top:i.top,bottom:i.top,left:i.left,right:i.left}:void 0))}}else r.left===r.right&&r.top===r.bottom?o||n.push(ko(e,a,r,void 0)):n.push(ko(e,a,r,o?{top:r.top,bottom:r.top,left:r.left,right:r.left}:void 0))}return n}function ko(e,t,i,o){if(i.left!==i.right&&i.top!==i.bottom)throw new Error(`Zone should be a single column or row: ${Di(i)}`);if(o){const n=Di(i),s=Di(o);return{labelCell:e.getRangeFromSheetXC(t,s),dataRange:e.getRangeFromSheetXC(t,n)}}return{labelCell:void 0,dataRange:e.getRangeFromSheetXC(t,Di(i))}}function Lo(e,t){var i;const o=null===(i=t.labelCell)||void 0===i?void 0:i.zone;let n=t.dataRange.zone;if(o){const{height:e,width:t}=Zi(n);1===e?n={...n,left:n.left+1}:1===t&&(n={...n,top:n.top+1})}const s=t.dataRange.clone({zone:n});return{label:t.labelCell?e.getRangeString(t.labelCell,"forceSheetReference"):void 0,range:e.getRangeString(s,"forceSheetReference")}}function Po(e,t){let i;if(e.labelRange){const o=bo(Ni(e.labelRange),t);i=o?Di(o):void 0}const o=e.dataSets.map(Ni).map((e=>bo(e,t))).filter(et).map(Di);return{...e,labelRange:i,dataSets:o}}e.CommandResult=void 0,(To=e.CommandResult||(e.CommandResult={}))[To.Success=0]="Success",To[To.CancelledForUnknownReason=1]="CancelledForUnknownReason",To[To.WillRemoveExistingMerge=2]="WillRemoveExistingMerge",To[To.MergeIsDestructive=3]="MergeIsDestructive",To[To.CellIsMerged=4]="CellIsMerged",To[To.InvalidTarget=5]="InvalidTarget",To[To.EmptyUndoStack=6]="EmptyUndoStack",To[To.EmptyRedoStack=7]="EmptyRedoStack",To[To.NotEnoughElements=8]="NotEnoughElements",To[To.NotEnoughSheets=9]="NotEnoughSheets",To[To.MissingSheetName=10]="MissingSheetName",To[To.DuplicatedSheetName=11]="DuplicatedSheetName",To[To.DuplicatedSheetId=12]="DuplicatedSheetId",To[To.ForbiddenCharactersInSheetName=13]="ForbiddenCharactersInSheetName",To[To.WrongSheetMove=14]="WrongSheetMove",To[To.WrongSheetPosition=15]="WrongSheetPosition",To[To.InvalidAnchorZone=16]="InvalidAnchorZone",To[To.SelectionOutOfBound=17]="SelectionOutOfBound",To[To.TargetOutOfSheet=18]="TargetOutOfSheet",To[To.WrongCutSelection=19]="WrongCutSelection",To[To.WrongPasteSelection=20]="WrongPasteSelection",To[To.WrongPasteOption=21]="WrongPasteOption",To[To.WrongFigurePasteOption=22]="WrongFigurePasteOption",To[To.EmptyClipboard=23]="EmptyClipboard",To[To.EmptyRange=24]="EmptyRange",To[To.InvalidRange=25]="InvalidRange",To[To.InvalidZones=26]="InvalidZones",To[To.InvalidSheetId=27]="InvalidSheetId",To[To.DuplicatedImageId=28]="DuplicatedImageId",To[To.InputAlreadyFocused=29]="InputAlreadyFocused",To[To.MaximumRangesReached=30]="MaximumRangesReached",To[To.InvalidChartDefinition=31]="InvalidChartDefinition",To[To.InvalidDataSet=32]="InvalidDataSet",To[To.InvalidLabelRange=33]="InvalidLabelRange",To[To.InvalidScorecardKeyValue=34]="InvalidScorecardKeyValue",To[To.InvalidScorecardBaseline=35]="InvalidScorecardBaseline",To[To.InvalidGaugeDataRange=36]="InvalidGaugeDataRange",To[To.EmptyGaugeRangeMin=37]="EmptyGaugeRangeMin",To[To.GaugeRangeMinNaN=38]="GaugeRangeMinNaN",To[To.EmptyGaugeRangeMax=39]="EmptyGaugeRangeMax",To[To.GaugeRangeMaxNaN=40]="GaugeRangeMaxNaN",To[To.GaugeRangeMinBiggerThanRangeMax=41]="GaugeRangeMinBiggerThanRangeMax",To[To.GaugeLowerInflectionPointNaN=42]="GaugeLowerInflectionPointNaN",To[To.GaugeUpperInflectionPointNaN=43]="GaugeUpperInflectionPointNaN",To[To.GaugeLowerBiggerThanUpper=44]="GaugeLowerBiggerThanUpper",To[To.InvalidAutofillSelection=45]="InvalidAutofillSelection",To[To.WrongComposerSelection=46]="WrongComposerSelection",To[To.MinBiggerThanMax=47]="MinBiggerThanMax",To[To.LowerBiggerThanUpper=48]="LowerBiggerThanUpper",To[To.MidBiggerThanMax=49]="MidBiggerThanMax",To[To.MinBiggerThanMid=50]="MinBiggerThanMid",To[To.FirstArgMissing=51]="FirstArgMissing",To[To.SecondArgMissing=52]="SecondArgMissing",To[To.MinNaN=53]="MinNaN",To[To.MidNaN=54]="MidNaN",To[To.MaxNaN=55]="MaxNaN",To[To.ValueUpperInflectionNaN=56]="ValueUpperInflectionNaN",To[To.ValueLowerInflectionNaN=57]="ValueLowerInflectionNaN",To[To.MinInvalidFormula=58]="MinInvalidFormula",To[To.MidInvalidFormula=59]="MidInvalidFormula",To[To.MaxInvalidFormula=60]="MaxInvalidFormula",To[To.ValueUpperInvalidFormula=61]="ValueUpperInvalidFormula",To[To.ValueLowerInvalidFormula=62]="ValueLowerInvalidFormula",To[To.InvalidSortZone=63]="InvalidSortZone",To[To.WaitingSessionConfirmation=64]="WaitingSessionConfirmation",To[To.MergeOverlap=65]="MergeOverlap",To[To.TooManyHiddenElements=66]="TooManyHiddenElements",To[To.Readonly=67]="Readonly",To[To.InvalidViewportSize=68]="InvalidViewportSize",To[To.InvalidScrollingDirection=69]="InvalidScrollingDirection",To[To.FigureDoesNotExist=70]="FigureDoesNotExist",To[To.InvalidConditionalFormatId=71]="InvalidConditionalFormatId",To[To.InvalidCellPopover=72]="InvalidCellPopover",To[To.EmptyTarget=73]="EmptyTarget",To[To.InvalidFreezeQuantity=74]="InvalidFreezeQuantity",To[To.FrozenPaneOverlap=75]="FrozenPaneOverlap",To[To.ValuesNotChanged=76]="ValuesNotChanged",To[To.InvalidFilterZone=77]="InvalidFilterZone",To[To.FilterOverlap=78]="FilterOverlap",To[To.FilterNotFound=79]="FilterNotFound",To[To.MergeInFilter=80]="MergeInFilter",To[To.NonContinuousTargets=81]="NonContinuousTargets",To[To.DuplicatedFigureId=82]="DuplicatedFigureId",To[To.InvalidSelectionStep=83]="InvalidSelectionStep",To[To.DuplicatedChartId=84]="DuplicatedChartId",function(e){e.UP="up",e.DOWN="down",e.LEFT="left",e.RIGHT="right"}(Ao||(Ao={})),function(e){e[e.Background=0]="Background",e[e.Highlights=1]="Highlights",e[e.Clipboard=2]="Clipboard",e[e.Search=3]="Search",e[e.Chart=4]="Chart",e[e.Autofill=5]="Autofill",e[e.Selection=6]="Selection",e[e.Headers=7]="Headers"}(Mo||(Mo={}));const Uo=["rgb(31,119,180)","rgb(255,127,14)","rgb(174,199,232)","rgb(255,187,120)","rgb(44,160,44)","rgb(152,223,138)","rgb(214,39,40)","rgb(255,152,150)","rgb(148,103,189)","rgb(197,176,213)","rgb(140,86,75)","rgb(196,156,148)","rgb(227,119,194)","rgb(247,182,210)","rgb(127,127,127)","rgb(199,199,199)","rgb(188,189,34)","rgb(219,219,141)","rgb(23,190,207)","rgb(158,218,229)"];class Vo{constructor(){this.graphColorIndex=0}next(){return Uo[this.graphColorIndex++%Uo.length]}}function zo(e){return e&&Ct(e)<.3?"#FFFFFF":"#000000"}function Bo(e){if(e.dataSets){const t=void 0!==e.dataSets.find((e=>!Ot.test(e)));if(t)return 32;if(e.dataSets.map(Ni).some((e=>e.top!==e.bottom&&eo(e))))return 32}return 0}function Ho(e){if(e.labelRange){if(!Ot.test(e.labelRange||""))return 33}return 0}function $o(e,t,i){if(e){if("text"===i||(null==t?void 0:t.type)!==So.number||e.type!==So.number)return e.formattedValue;{let o=t.value-e.value;if("percentage"===i&&0!==o&&(o=o/e.value*100),"percentage"!==i&&e.format)return li(o,e.format);const n=Math.abs(parseFloat(o.toFixed(2))).toLocaleString();return"percentage"===i?n+"%":n}}return""}function Wo(e,t,i,o,n){if("text"===t||(null==e?void 0:e.type)!==So.number||(null==i?void 0:i.type)!==So.number)return;const s=i.value-e.value;return s>0?o:s<0?n:void 0}function Go(e,t,i){if("text"===i||(null==e?void 0:e.type)!==So.number||(null==t?void 0:t.type)!==So.number)return"neutral";const o=t.value-e.value;return o>0?"up":o<0?"down":"neutral"}const qo={Errors:{25:s("The range is invalid"),51:s("The argument is missing. Please provide a value"),52:s("The second argument is missing. Please provide a value"),53:s("The minpoint must be a number"),54:s("The midpoint must be a number"),55:s("The maxpoint must be a number"),56:s("The first value must be a number"),57:s("The second value must be a number"),47:s("Minimum must be smaller then Maximum"),50:s("Minimum must be smaller then Midpoint"),49:s("Midpoint must be smaller then Maximum"),48:s("Lower inflection point must be smaller than upper inflection point"),58:s("Invalid Minpoint formula"),60:s("Invalid Maxpoint formula"),59:s("Invalid Midpoint formula"),61:s("Invalid upper inflection point formula"),62:s("Invalid lower inflection point formula"),24:s("A range needs to be defined"),Unexpected:s("The rule is invalid for an unknown reason")},ColorScale:s("Color scale"),IconSet:s("Icon set")},Zo={IsEmpty:s("Is empty"),IsNotEmpty:s("Is not empty"),ContainsText:s("Contains"),NotContains:s("Does not contain"),BeginsWith:s("Starts with"),EndsWith:s("Ends with"),Equal:s("Is equal to"),NotEqual:s("Is not equal to"),GreaterThan:s("Is greater than"),GreaterThanOrEqual:s("Is greater than or equal to"),LessThan:s("Is less than"),LessThanOrEqual:s("Is less than or equal to"),Between:s("Is between"),NotBetween:s("Is not between")},jo={Series:s("Series"),Errors:{Unexpected:s("The chart definition is invalid for an unknown reason"),32:s("The dataset is invalid"),33:s("Labels are invalid"),34:s("The key value is invalid"),35:s("The baseline value is invalid"),36:s("The data range is invalid"),37:s("A minimum range limit value is needed"),38:s("The minimum range limit value must be a number"),39:s("A maximum range limit value is needed"),40:s("The maximum range limit value must be a number"),41:s("Minimum range limit must be smaller than maximum range limit"),42:s("The lower inflection point value must be a number"),43:s("The upper inflection point value must be a number")}},Xo={Automatic:s("Automatic"),Number:s("Number"),Percent:s("Percent"),Currency:s("Currency"),CurrencyRounded:s("Currency rounded"),Date:s("Date"),Time:s("Time"),DateTime:s("Date time"),Duration:s("Duration"),CustomCurrency:s("Custom currency")},Yo={Custom:s("Custom")},Ko=s("Merged cells are preventing this operation. Unmerge those cells and try again.");function Qo(e,t){if(t.dataRange){const i=t.labelCell?[Di(t.labelCell.zone)]:[],o=Gi([Di(t.dataRange.zone)],i)[0];if(void 0===o)return[];const n=e.getRangeFromSheetXC(t.dataRange.sheetId,o);return e.getRangeValues(n).map((e=>""===e?void 0:e))}return[]}function Jo(e,t){const i=ze(0,Math.max(e.length,...t.map((e=>{var t;return(null===(t=e.data)||void 0===t?void 0:t.length)||0})))).filter((i=>{const o=e[i],n=t.map((e=>{var t;return null===(t=e.data)||void 0===t?void 0:t[i]}));return o||n.some((e=>0===e||Boolean(e)))}));return{labels:i.map((t=>e[t]||"")),dataSetsValues:t.map((e=>({...e,data:i.map((t=>e.data[t]))})))}}function en(e,t){const i=new Set(e),o={};i.forEach((e=>{o[e]=new Array(t.length).fill(0)}));for(const i of ze(0,e.length)){const s=e[i];for(const e of ze(0,t.length))o[s][e]+="number"==typeof(n=t[e].data[i])?n:0}var n;return{labels:Object.keys(o),dataSetsValues:t.map(((e,t)=>({...e,data:Object.values(o).map((e=>e[t]))})))}}function tn(e){return e?e.length>Q?e.substring(0,Q)+"…":e:""}function on(e,t,i,o){return{type:e.type,options:{responsive:!0,maintainAspectRatio:!1,layout:{padding:{left:20,right:20,top:e.title?10:25,bottom:10}},elements:{line:{fill:!1},point:{hitRadius:15}},animation:{duration:0},hover:{animationDuration:10},responsiveAnimationDuration:0,title:{display:!!e.title,fontSize:22,fontStyle:"normal",text:n(e.title),fontColor:i},legend:{onClick:void 0},tooltips:{callbacks:{label:function(e,t){var i,n,s,r,a;let l=null===(n=null===(i=t.datasets)||void 0===i?void 0:i[e.datasetIndex||0])||void 0===n?void 0:n.label;const c=""!==e.yLabel?e.yLabel:null===(a=null===(r=null===(s=t.datasets)||void 0===s?void 0:s[e.datasetIndex||0])||void 0===r?void 0:r.data)||void 0===a?void 0:a[e.index||0],h=o&&"number"==typeof c?li(c,o):(null==c?void 0:c.toLocaleString())||"";return l?`${l}: ${h}`:h}}}},data:{labels:t.map(tn),datasets:[]}}}function nn(e,t,i){let o={values:[],formattedValues:[]};if(i)i.invalidXc||i.invalidSheetName||(o={formattedValues:e.getRangeFormattedValues(i),values:e.getRangeValues(i).map((e=>String(e)))});else if(1===t.length)for(let i=0;i<Qo(e,t[0]).length;i++)o.formattedValues.push(""),o.values.push("");else if(t[0]){o={formattedValues:ze(0,Qo(e,t[0]).length).map((e=>e.toString())),values:o.formattedValues}}return o}function sn(e,t){for(const i of t){const t=e.getRangeFormats(i.dataRange).find((e=>void 0!==e&&!ui(e)));if(t)return t}}function rn(e,t){const i=[];for(const[o,n]of Object.entries(t)){let t;if(n.labelCell){const i=n.labelCell,s=i?e.getEvaluatedCell({sheetId:i.sheetId,col:i.zone.left,row:i.zone.top}):void 0;t=s&&i?tn(s.formattedValue):t=`${jo.Series} ${parseInt(o)+1}`}else t=t=`${jo.Series} ${parseInt(o)+1}`;let s=n.dataRange?Qo(e,n):[];i.push({data:s,label:t})}return i}function an(e){return 0===e?"origin":e-1}class ln extends vo{constructor(e,t,i){super(e,t,i),this.type="bar",this.dataSets=Do(i,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=Ti(i,t,e.labelRange),this.background=e.background,this.verticalAxisPosition=e.verticalAxisPosition,this.legendPosition=e.legendPosition,this.stacked=e.stacked,this.aggregated=e.aggregated}static transformDefinition(e,t){return Po(e,t)}static validateChartDefinition(e,t){return e.checkValidations(t,Bo,Ho)}static getDefinitionFromContextCreation(e){return{background:e.background,dataSets:e.range?e.range:[],dataSetsHaveTitle:!1,stacked:!1,aggregated:!1,legendPosition:"top",title:e.title||"",type:"bar",verticalAxisPosition:"left",labelRange:e.auxiliaryRange||void 0}}getContextCreation(){return{background:this.background,title:this.title,range:this.dataSets.map((e=>this.getters.getRangeString(e.dataRange,this.sheetId))),auxiliaryRange:this.labelRange?this.getters.getRangeString(this.labelRange,this.sheetId):void 0}}copyForSheetId(e){const t=No(this.sheetId,e,this.dataSets),i=_o(this.sheetId,e,this.labelRange),o=this.getDefinitionWithSpecificDataSets(t,i,e);return new ln(o,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,e);return new ln(t,e,this.getters)}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getDefinitionWithSpecificDataSets(e,t,i){return{type:"bar",dataSetsHaveTitle:!!e.length&&Boolean(e[0].labelCell),background:this.background,dataSets:e.map((e=>this.getters.getRangeString(e.dataRange,i||this.sheetId))),legendPosition:this.legendPosition,verticalAxisPosition:this.verticalAxisPosition,labelRange:t?this.getters.getRangeString(t,i||this.sheetId):void 0,title:this.title,stacked:this.stacked,aggregated:this.aggregated}}getDefinitionForExcel(){if(this.aggregated)return;const e=this.dataSets.map((e=>Lo(this.getters,e))).filter((e=>""!==e.range));return{...this.getDefinition(),backgroundColor:fo(this.background||w),fontColor:fo(zo(this.background)),dataSets:e}}updateRanges(e){const{dataSets:t,labelRange:i,isStale:o}=Oo(this.getters,e,this.dataSets,this.labelRange);if(!o)return this;const n=this.getDefinitionWithSpecificDataSets(t,i);return new ln(n,this.sheetId,this.getters)}}function cn(e){return e.dataRange&&!Ot.test(e.dataRange)?36:0}function hn(e,t){return t((t=>t.sectionRule?e(t.sectionRule.rangeMin,"rangeMin"):0),(t=>t.sectionRule?e(t.sectionRule.rangeMax,"rangeMax"):0))}function dn(e){return e.sectionRule&&Number(e.sectionRule.rangeMin)>=Number(e.sectionRule.rangeMax)?41:0}function un(e,t){if(""===e)switch(t){case"rangeMin":return 37;case"rangeMax":return 39}return 0}function gn(e,t){if(isNaN(e))switch(t){case"rangeMin":return 38;case"rangeMax":return 40;case"lowerInflectionPointValue":return 42;case"upperInflectionPointValue":return 43}return 0}class pn extends vo{constructor(e,t,i){super(e,t,i),this.type="gauge",this.dataRange=Ti(this.getters,this.sheetId,e.dataRange),this.sectionRule=e.sectionRule,this.background=e.background}static validateChartDefinition(e,t){return e.checkValidations(t,cn,e.chainValidations(hn(un,e.batchValidations),hn(gn,e.batchValidations),dn),e.chainValidations((i=gn,(0,e.batchValidations)((e=>e.sectionRule?i(e.sectionRule.lowerInflectionPoint.value,"lowerInflectionPointValue"):0),(e=>e.sectionRule?i(e.sectionRule.upperInflectionPoint.value,"upperInflectionPointValue"):0)))));var i}static transformDefinition(e,t){let i;return e.dataRange&&(i=bo(Ni(e.dataRange),t)),{...e,dataRange:i?Di(i):void 0}}static getDefinitionFromContextCreation(e){return{background:e.background,title:e.title||"",type:"gauge",dataRange:e.range?e.range[0]:void 0,sectionRule:{colors:{lowerColor:"#cc0000",middleColor:"#f1c232",upperColor:"#6aa84f"},rangeMin:"0",rangeMax:"100",lowerInflectionPoint:{type:"percentage",value:"15"},upperInflectionPoint:{type:"percentage",value:"40"}}}}copyForSheetId(e){const t=_o(this.sheetId,e,this.dataRange),i=this.getDefinitionWithSpecificRanges(t,e);return new pn(i,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificRanges(this.dataRange,e);return new pn(t,e,this.getters)}getDefinition(){return this.getDefinitionWithSpecificRanges(this.dataRange)}getDefinitionWithSpecificRanges(e,t){return{background:this.background,sectionRule:this.sectionRule,title:this.title,type:"gauge",dataRange:e?this.getters.getRangeString(e,t||this.sheetId):void 0}}getDefinitionForExcel(){}getContextCreation(){return{background:this.background,title:this.title,range:this.dataRange?[this.getters.getRangeString(this.dataRange,this.sheetId)]:void 0}}updateRanges(e){const t=Fo(this.dataRange,e);if(this.dataRange===t)return this;const i=this.getDefinitionWithSpecificRanges(t);return new pn(i,this.sheetId,this.getters)}}const mn={second:1e3,minute:6e4,hour:36e5,day:864e5,month:2592e6,year:31536e6},fn={inSeconds:function(e){return Math.floor(e/mn.second)},inMinutes:function(e){return Math.floor(e/mn.minute)},inHours:function(e){return Math.floor(e/mn.hour)},inDays:function(e){return Math.floor(e/mn.day)},inMonths:function(e){return Math.floor(e/mn.month)},inYears:function(e){return Math.floor(e/mn.year)}},vn=/^((d|dd|m|mm|yyyy|yy|hh|h|ss|a)(-|:|\s|\/))*(d|dd|m|mm|yyyy|yy|hh|h|ss|a)$/i;function bn(e,t){const i=function(e){const t=(e=(e=e.replace(/y/g,"Y")).replace(/d/g,"D")).indexOf("h");e=t>=0?e.slice(0,t).replace(/m/g,"M")+e.slice(t):e.replace(/m/g,"M");e.includes("a")||(e=e.replace(/h/g,"H"));return e}(t),o=function(e,t){const i=e.map((e=>{var t;return null===(t=Se(e))||void 0===t?void 0:t.jsDate}));if(i.some((e=>void 0===e))||e.length<2)return;const o=i.map((e=>e.getTime())),n=Math.max(...o)-Math.min(...o),s=function(e){if(e.includes("s"))return"second";if(e.includes("m"))return"minute";if(e.includes("h")||e.includes("H"))return"hour";if(e.includes("D"))return"day";if(e.includes("M"))return"month";return"year"}(t);if(mn.second>=mn[s]&&fn.inSeconds(n)<180)return"second";if(mn.minute>=mn[s]&&fn.inMinutes(n)<180)return"minute";if(mn.hour>=mn[s]&&fn.inHours(n)<96)return"hour";if(mn.day>=mn[s]&&fn.inDays(n)<90)return"day";if(mn.month>=mn[s]&&fn.inMonths(n)<36)return"month";return"year"}(e,i),n={};return o&&(n[o]=i),{parser:i,displayFormats:n,unit:o}}class Sn extends vo{constructor(e,t,i){super(e,t,i),this.type="line",this.dataSets=Do(this.getters,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=Ti(this.getters,t,e.labelRange),this.background=e.background,this.verticalAxisPosition=e.verticalAxisPosition,this.legendPosition=e.legendPosition,this.labelsAsText=e.labelsAsText,this.stacked=e.stacked,this.aggregated=e.aggregated}static validateChartDefinition(e,t){return e.checkValidations(t,Bo,Ho)}static transformDefinition(e,t){return Po(e,t)}static getDefinitionFromContextCreation(e){return{background:e.background,dataSets:e.range?e.range:[],dataSetsHaveTitle:!1,labelsAsText:!1,legendPosition:"top",title:e.title||"",type:"line",verticalAxisPosition:"left",labelRange:e.auxiliaryRange||void 0,stacked:!1,aggregated:!1}}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getDefinitionWithSpecificDataSets(e,t,i){return{type:"line",dataSetsHaveTitle:!!e.length&&Boolean(e[0].labelCell),background:this.background,dataSets:e.map((e=>this.getters.getRangeString(e.dataRange,i||this.sheetId))),legendPosition:this.legendPosition,verticalAxisPosition:this.verticalAxisPosition,labelRange:t?this.getters.getRangeString(t,i||this.sheetId):void 0,title:this.title,labelsAsText:this.labelsAsText,stacked:this.stacked,aggregated:this.aggregated}}getContextCreation(){return{background:this.background,title:this.title,range:this.dataSets.map((e=>this.getters.getRangeString(e.dataRange,this.sheetId))),auxiliaryRange:this.labelRange?this.getters.getRangeString(this.labelRange,this.sheetId):void 0}}updateRanges(e){const{dataSets:t,labelRange:i,isStale:o}=Oo(this.getters,e,this.dataSets,this.labelRange);if(!o)return this;const n=this.getDefinitionWithSpecificDataSets(t,i);return new Sn(n,this.sheetId,this.getters)}getDefinitionForExcel(){if(this.aggregated)return;const e=this.dataSets.map((e=>Lo(this.getters,e))).filter((e=>""!==e.range));return{...this.getDefinition(),backgroundColor:fo(this.background||w),fontColor:fo(zo(this.background)),dataSets:e}}copyForSheetId(e){const t=No(this.sheetId,e,this.dataSets),i=_o(this.sheetId,e,this.labelRange),o=this.getDefinitionWithSpecificDataSets(t,i,e);return new Sn(o,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,e);return new Sn(t,e,this.getters)}}function Cn(e,t){return wn(e,t)||yn(e,t)}function En(e,t){return function(e,t){return!e.labelsAsText&&wn(e.labelRange,t)}(e,t)?"time":function(e,t){return!e.labelsAsText&&yn(e.labelRange,t)}(e,t)?"linear":"category"}function wn(e,t){if(!e||!yn(e,t))return!1;const i=t.getEvaluatedCell({sheetId:e.sheetId,col:e.zone.left,row:e.zone.top}).format;return Boolean(i&&vn.test(i))}function yn(e,t){if(!e)return!1;const i=t.getRangeValues(e);return!i.some((e=>isNaN(Number(e))&&e))&&!i.every((e=>!e))}class xn extends vo{constructor(e,t,i){super(e,t,i),this.type="pie",this.dataSets=Do(i,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=Ti(i,t,e.labelRange),this.background=e.background,this.legendPosition=e.legendPosition,this.aggregated=e.aggregated}static transformDefinition(e,t){return Po(e,t)}static validateChartDefinition(e,t){return e.checkValidations(t,Bo,Ho)}static getDefinitionFromContextCreation(e){return{background:e.background,dataSets:e.range?e.range:[],dataSetsHaveTitle:!1,legendPosition:"top",title:e.title||"",type:"pie",labelRange:e.auxiliaryRange||void 0,aggregated:!1}}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getContextCreation(){return{background:this.background,title:this.title,range:this.dataSets.map((e=>this.getters.getRangeString(e.dataRange,this.sheetId))),auxiliaryRange:this.labelRange?this.getters.getRangeString(this.labelRange,this.sheetId):void 0}}getDefinitionWithSpecificDataSets(e,t,i){return{type:"pie",dataSetsHaveTitle:!!e.length&&Boolean(e[0].labelCell),background:this.background,dataSets:e.map((e=>this.getters.getRangeString(e.dataRange,i||this.sheetId))),legendPosition:this.legendPosition,labelRange:t?this.getters.getRangeString(t,i||this.sheetId):void 0,title:this.title,aggregated:this.aggregated}}copyForSheetId(e){const t=No(this.sheetId,e,this.dataSets),i=_o(this.sheetId,e,this.labelRange),o=this.getDefinitionWithSpecificDataSets(t,i,e);return new xn(o,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,e);return new xn(t,e,this.getters)}getDefinitionForExcel(){if(this.aggregated)return;const e=this.dataSets.map((e=>Lo(this.getters,e))).filter((e=>""!==e.range));return{...this.getDefinition(),backgroundColor:fo(this.background||w),fontColor:fo(zo(this.background)),verticalAxisPosition:"left",dataSets:e}}updateRanges(e){const{dataSets:t,labelRange:i,isStale:o}=Oo(this.getters,e,this.dataSets,this.labelRange);if(!o)return this;const n=this.getDefinitionWithSpecificDataSets(t,i);return new xn(n,this.sheetId,this.getters)}}function In(e,t){const i=[],o=Math.max(...t.map((e=>e.data.length)));for(let t=0;t<=o;t++)i.push(e.next());return i}function Rn(e){return e.keyValue&&!Ot.test(e.keyValue)?34:0}function Tn(e){return e.baseline&&!Ot.test(e.baseline)?35:0}class An extends vo{constructor(e,t,i){super(e,t,i),this.type="scorecard",this.keyValue=Ti(i,t,e.keyValue),this.baseline=Ti(i,t,e.baseline),this.baselineMode=e.baselineMode,this.baselineDescr=e.baselineDescr,this.background=e.background,this.baselineColorUp=e.baselineColorUp,this.baselineColorDown=e.baselineColorDown}static validateChartDefinition(e,t){return e.checkValidations(t,Rn,Tn)}static getDefinitionFromContextCreation(e){return{background:e.background,type:"scorecard",keyValue:e.range?e.range[0]:void 0,title:e.title||"",baselineMode:ee,baselineColorUp:te,baselineColorDown:ie,baseline:e.auxiliaryRange||""}}static transformDefinition(e,t){let i,o;return e.baseline&&(i=bo(Ni(e.baseline),t)),e.keyValue&&(o=bo(Ni(e.keyValue),t)),{...e,baseline:i?Di(i):void 0,keyValue:o?Di(o):void 0}}copyForSheetId(e){const t=_o(this.sheetId,e,this.baseline),i=_o(this.sheetId,e,this.keyValue),o=this.getDefinitionWithSpecificRanges(t,i,e);return new An(o,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificRanges(this.baseline,this.keyValue,e);return new An(t,e,this.getters)}getDefinition(){return this.getDefinitionWithSpecificRanges(this.baseline,this.keyValue)}getContextCreation(){return{background:this.background,title:this.title,range:this.keyValue?[this.getters.getRangeString(this.keyValue,this.sheetId)]:void 0,auxiliaryRange:this.baseline?this.getters.getRangeString(this.baseline,this.sheetId):void 0}}getDefinitionWithSpecificRanges(e,t,i){return{baselineColorDown:this.baselineColorDown,baselineColorUp:this.baselineColorUp,baselineMode:this.baselineMode,title:this.title,type:"scorecard",background:this.background,baseline:e?this.getters.getRangeString(e,i||this.sheetId):void 0,baselineDescr:this.baselineDescr,keyValue:t?this.getters.getRangeString(t,i||this.sheetId):void 0}}getDefinitionForExcel(){}updateRanges(e){const t=Fo(this.baseline,e),i=Fo(this.keyValue,e);if(this.baseline===t&&this.keyValue===i)return this;const o=this.getDefinitionWithSpecificRanges(t,i);return new An(o,this.sheetId,this.getters)}}class Mn{constructor(){this.content={}}add(e,t){return this.content[e]=t,this}get(e){const t=this.content[e];if(!t&&!(e in this.content))throw new Error(`Cannot find ${e} in this registry!`);return t}contains(e){return e in this.content}getAll(){return Object.values(this.content)}getKeys(){return Object.keys(this.content)}remove(e){delete this.content[e]}}const On=new Mn;On.add("bar",{match:e=>"bar"===e,createChart:(e,t,i)=>new ln(e,t,i),getChartRuntime:function(e,t){let i=nn(t,e.dataSets,e.labelRange).formattedValues,o=rn(t,e.dataSets);({labels:i,dataSetsValues:o}=Jo(i,o)),e.aggregated&&({labels:i,dataSetsValues:o}=en(i,o));const n=function(e,t,i){var o;const n=zo(e.background),s=on(e,t,n,i),r={labels:{fontColor:n}};return!e.labelRange&&1===e.dataSets.length||"none"===e.legendPosition?r.display=!1:r.position=e.legendPosition,s.options.legend={...null===(o=s.options)||void 0===o?void 0:o.legend,...r},s.options.layout={padding:{left:20,right:20,top:e.title?10:25,bottom:10}},s.options.scales={xAxes:[{ticks:{maxRotation:60,minRotation:15,padding:5,labelOffset:2,fontColor:n}}],yAxes:[{position:e.verticalAxisPosition,ticks:{fontColor:n,beginAtZero:!0,callback:e=>i?li(e,i):(null==e?void 0:e.toLocaleString())||e}}]},e.stacked&&(s.options.scales.xAxes[0].stacked=!0,s.options.scales.yAxes[0].stacked=!0),s}(e,i,sn(t,e.dataSets)),s=new Vo;for(let{label:e,data:t}of o){const i=s.next(),o={label:e,data:t,borderColor:i,backgroundColor:i};n.data.datasets.push(o)}return{chartJsConfig:n,background:e.background||w}},validateChartDefinition:(e,t)=>ln.validateChartDefinition(e,t),transformDefinition:(e,t)=>ln.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>ln.getDefinitionFromContextCreation(e),name:s("Bar"),sequence:10}),On.add("line",{match:e=>"line"===e,createChart:(e,t,i)=>new Sn(e,t,i),getChartRuntime:function(e,t){const i=En(e,t),o=nn(t,e.dataSets,e.labelRange);let n="linear"===i?o.values:o.formattedValues,s=rn(t,e.dataSets);({labels:n,dataSetsValues:s}=Jo(n,s)),"time"===i&&({labels:n,dataSetsValues:s}=function(e,t){if(0===e.length||e.every((e=>!e)))return{labels:e,dataSetsValues:t};const i=[...e],o=Ne(t);for(let e=0;e<i.length;e++)if(!i[e]){i[e]=st(i,e);for(let t of o)t.data[e]=void 0}return{labels:i,dataSetsValues:o}}(n,s)),e.aggregated&&({labels:n,dataSetsValues:s}=en(n,s));const r=sn(t,e.dataSets),a=function(e,t,i){var o;const n=zo(e.background),s=on(e,t,n,i),r={labels:{fontColor:n,generateLabels(e){const{data:t}=e,i=window.Chart.defaults.global.legend.labels.generateLabels(e);for(const[e,o]of i.entries())o.fillStyle=t.datasets[e].borderColor;return i}}};return!e.labelRange&&1===e.dataSets.length||"none"===e.legendPosition?r.display=!1:r.position=e.legendPosition,s.options.legend={...null===(o=s.options)||void 0===o?void 0:o.legend,...r},s.options.layout={padding:{left:20,right:20,top:e.title?10:25,bottom:10}},s.options.scales={xAxes:[{ticks:{maxRotation:60,minRotation:15,padding:5,labelOffset:2,fontColor:n}}],yAxes:[{position:e.verticalAxisPosition,ticks:{fontColor:n,beginAtZero:!0,callback:e=>i?li(e,i):(null==e?void 0:e.toLocaleString())||e}}]},e.stacked&&(s.options.scales.yAxes[0].stacked=!0),s}(e,n,r),l=function(e,t){if(t)return e.getEvaluatedCell({sheetId:t.sheetId,col:t.zone.left,row:t.zone.top}).format}(t,e.labelRange);"time"===i?(a.options.scales.xAxes[0].type="time",a.options.scales.xAxes[0].time=bn(n,l),a.options.scales.xAxes[0].ticks.maxTicksLimit=15):"linear"===i&&(a.options.scales.xAxes[0].type="linear",a.options.scales.xAxes[0].ticks.callback=e=>li(e,l),a.options.tooltips.callbacks.title=e=>{var t;return li((null===(t=e[0])||void 0===t?void 0:t.xLabel)||"",l)});const c=new Vo;for(let[t,{label:o,data:r}]of s.entries()){["linear","time"].includes(i)&&(r=r.map(((e,t)=>({x:n[t]||void 0,y:e}))));const s=c.next();let l=wt(s);e.stacked&&(l.a=oe);const h={label:o,data:r,lineTension:0,borderColor:s,backgroundColor:Et(l),pointBackgroundColor:s,fill:!!e.stacked&&an(t)};a.data.datasets.push(h)}return{chartJsConfig:a,background:e.background||w}},validateChartDefinition:(e,t)=>Sn.validateChartDefinition(e,t),transformDefinition:(e,t)=>Sn.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>Sn.getDefinitionFromContextCreation(e),name:s("Line"),sequence:20}),On.add("pie",{match:e=>"pie"===e,createChart:(e,t,i)=>new xn(e,t,i),getChartRuntime:function(e,t){let i=nn(t,e.dataSets,e.labelRange).formattedValues,o=rn(t,e.dataSets);({labels:i,dataSetsValues:o}=Jo(i,o)),e.aggregated&&({labels:i,dataSetsValues:o}=en(i,o));const n=function(e,t,i){var o;const n=zo(e.background),s=on(e,t,n,i),r={labels:{fontColor:n}};return!e.labelRange&&1===e.dataSets.length||"none"===e.legendPosition?r.display=!1:r.position=e.legendPosition,s.options.legend={...null===(o=s.options)||void 0===o?void 0:o.legend,...r},s.options.layout={padding:{left:20,right:20,top:e.title?10:25,bottom:10}},s.options.tooltips.callbacks.title=function(e,t){return t.datasets[e[0].datasetIndex].label},s}(e,i,sn(t,e.dataSets)),s=new Vo;for(let{label:e,data:t}of o){const i={label:e,data:t,borderColor:"#FFFFFF",backgroundColor:In(s,o)};n.data.datasets.push(i)}return{chartJsConfig:n,background:e.background||w}},validateChartDefinition:(e,t)=>xn.validateChartDefinition(e,t),transformDefinition:(e,t)=>xn.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>xn.getDefinitionFromContextCreation(e),name:s("Pie"),sequence:30}),On.add("scorecard",{match:e=>"scorecard"===e,createChart:(e,t,i)=>new An(e,t,i),getChartRuntime:function(e,t){let i,o,s="",r="";if(e.keyValue){const o={sheetId:e.keyValue.sheetId,col:e.keyValue.zone.left,row:e.keyValue.zone.top};i=t.getEvaluatedCell(o),s=String(i.value),r=i.formattedValue}const a=e.baseline;if(a){const i={sheetId:e.baseline.sheetId,col:e.baseline.zone.left,row:e.baseline.zone.top};o=t.getEvaluatedCell(i)}const l=t.getBackgroundOfSingleCellChart(e.background,e.keyValue);return{title:n(e.title),keyValue:r||s,baselineDisplay:$o(o,i,e.baselineMode),baselineArrow:Go(o,i,e.baselineMode),baselineColor:Wo(o,e.baselineMode,i,e.baselineColorUp,e.baselineColorDown),baselineDescr:e.baselineDescr?n(e.baselineDescr):"",fontColor:zo(l),background:l,baselineStyle:"percentage"!==e.baselineMode&&a?t.getCellStyle({sheetId:a.sheetId,col:a.zone.left,row:a.zone.top}):void 0,keyValueStyle:e.keyValue?t.getCellStyle({sheetId:e.keyValue.sheetId,col:e.keyValue.zone.left,row:e.keyValue.zone.top}):void 0}},validateChartDefinition:(e,t)=>An.validateChartDefinition(e,t),transformDefinition:(e,t)=>An.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>An.getDefinitionFromContextCreation(e),name:s("Scorecard"),sequence:40}),On.add("gauge",{match:e=>"gauge"===e,createChart:(e,t,i)=>new pn(e,t,i),getChartRuntime:function(e,t){const i=function(e){const t=on(e,[],zo(e.background));return t.options.hover=void 0,t.options.events=[],t.options.layout={padding:{left:30,right:30,top:e.title?10:25,bottom:25}},t.options.needle={radiusPercentage:2,widthPercentage:3.2,lengthPercentage:80,color:"#000000"},t.options.valueLabel={display:!1,formatter:null,color:"#FFFFFF",backgroundColor:"#000000",fontSize:30,borderRadius:5,padding:{top:5,right:5,bottom:5,left:5},bottomMarginPercentage:5},t}(e),o=e.sectionRule.colors,n=e.sectionRule.lowerInflectionPoint,s=e.sectionRule.upperInflectionPoint,r=Number(n.value),a=Number(s.value),l=Number(e.sectionRule.rangeMin),c=Number(e.sectionRule.rangeMax),h=c-l,d=[];if(""!==n.value){const e="number"===n.type?r:l+h*r/100;d.push({value:De(e,l,c),color:o.lowerColor})}if(""!==s.value){const e="number"===s.type?a:l+h*a/100;d.push({value:De(e,l,c),color:o.middleColor})}const u=[],g=[];d.sort(((e,t)=>e.value-t.value)).map((e=>{u.push(e.value),g.push(e.color)})),u.push(c),g.push(o.upperColor);const p=e.dataRange,m=h/30;let f=l-m,v=null,b=!1;if(void 0!==p){const e=t.getEvaluatedCell({sheetId:p.sheetId,col:p.zone.left,row:p.zone.top});e.type===So.number&&(f=De(e.value,l-m,c+m),v=()=>t.getRangeFormattedValues(p)[0],b=!0)}return i.options.valueLabel.display=b,i.options.valueLabel.formatter=v,i.data.datasets.push({data:u,minValue:Number(e.sectionRule.rangeMin),value:f,backgroundColor:g}),{chartJsConfig:i,background:t.getBackgroundOfSingleCellChart(e.background,p)}},validateChartDefinition:(e,t)=>pn.validateChartDefinition(e,t),transformDefinition:(e,t)=>pn.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>pn.getDefinitionFromContextCreation(e),name:s("Gauge"),sequence:50});const Nn=new Mn;function _n(e){return e.map(Dn).sort(((e,t)=>e.sequence-t.sequence))}Nn.add("line",oo),Nn.add("bar",oo),Nn.add("pie",oo),Nn.add("gauge",oo),Nn.add("scorecard",go);const Fn=new Oi;function Dn(e){const t=e.name,i=e.children;return{id:e.id||Fn.uuidv4(),name:"function"==typeof t?t:()=>t,isVisible:e.isVisible?e.isVisible:()=>!0,isEnabled:e.isEnabled?e.isEnabled:()=>!0,action:e.action,children:i?e=>i.map((t=>"function"==typeof t?t(e):t)).flat().map(Dn):()=>[],isReadonlyAllowed:e.isReadonlyAllowed||!1,separator:e.separator||!1,icon:e.icon,description:e.description||"",textColor:e.textColor,sequence:e.sequence||0}}class kn extends Mn{add(e,t){return void 0===t.id&&(t.id=e),this.content[e]=t,this}addChild(e,t,i){"function"!=typeof i&&void 0===i.id&&(i.id=e);const o=t.splice(0,1)[0];let n=this.content[o];if(!n)throw new Error(`Path ${o+":"+t.join(":")} not found`);for(let e of t){const i=n.children;if(!i||"function"==typeof i)throw new Error(`${e} is either not a node or it's dynamically computed`);if(n=i.find((t=>t.id===e)),!n)throw new Error(`Path ${o+":"+t.join(":")} not found`)}return n.children||(n.children=[]),n.children.push(i),this}getMenuItems(){return _n(this.getAll())}}function Ln(){const e=t.useState({x:0,y:0,width:0,height:0});let i=document.querySelector(".o-spreadsheet");function o(){if(i||(i=document.querySelector(".o-spreadsheet")),i){const{top:t,left:o,width:n,height:s}=i.getBoundingClientRect();e.x=o,e.y=t,e.width=n,e.height=s}}return o(),t.onMounted(o),t.onPatched(o),e}function Pn(e){const i=t.useState({x:0,y:0,width:0,height:0});function o(){const t=e.el;if(null===t)return;const{top:o,left:n,width:s,height:r}=t.getBoundingClientRect();i.x=n,i.y=o,i.width=s,i.height=r}return t.onMounted(o),t.onPatched(o),i}function Un(e,t){return!!t.target&&e.contains(t.target)}function Vn(){const e=document.querySelector(".o-grid-overlay");if(e){const{top:t,left:i}=null==e?void 0:e.getBoundingClientRect();return{top:t,left:i}}throw new Error("Can't find spreadsheet position")}function zn(e){const t=e.getBoundingClientRect();return{x:t.x,y:t.y,width:t.width,height:t.height}}function*Bn(e){if(yield e,e.hasChildNodes())for(let t of e.childNodes)yield*Bn(t)}function Hn(e,t){return(i=zi($n(e),$n(t)))?{x:i.left,y:i.top,width:i.right-i.left,height:i.bottom-i.top}:void 0;var i}function $n(e){return{left:e.x,top:e.y,right:e.x+e.width,bottom:e.y+e.height}}ro`
53
53
  .o-popover {
54
54
  position: absolute;
55
55
  z-index: ${le.Popover};
@@ -114,7 +114,7 @@
114
114
  height: 100%;
115
115
  position: relative;
116
116
  }
117
- `;class Xn extends t.Component{constructor(){super(...arguments),this.menuState=t.useState({isOpen:!1,position:null,menuItems:[]}),this.chartContainerRef=t.useRef("chartContainer"),this.menuButtonRef=t.useRef("menuButton"),this.menuButtonPosition=Pn(this.menuButtonRef),this.position=Pn(this.chartContainerRef)}getMenuItemRegistry(){const e=new kn;return e.add("edit",{name:s("Edit"),sequence:1,action:()=>{this.env.model.dispatch("SELECT_FIGURE",{id:this.props.figure.id}),this.env.openSidePanel("ChartPanel")}}),e.add("copy",{name:s("Copy"),sequence:2,action:async()=>{this.env.model.dispatch("SELECT_FIGURE",{id:this.props.figure.id}),this.env.model.dispatch("COPY"),await this.env.clipboard.write(this.env.model.getters.getClipboardContent())}}),e.add("cut",{name:s("Cut"),sequence:3,action:async()=>{this.env.model.dispatch("SELECT_FIGURE",{id:this.props.figure.id}),this.env.model.dispatch("CUT"),await this.env.clipboard.write(this.env.model.getters.getClipboardContent())}}),e.add("delete",{name:s("Delete"),sequence:10,action:()=>{this.env.model.dispatch("DELETE_FIGURE",{sheetId:this.env.model.getters.getActiveSheetId(),id:this.props.figure.id}),this.props.onFigureDeleted()}}),e}get chartType(){return this.env.model.getters.getChartType(this.env.model.getters.getActiveSheetId(),this.props.figure.id)}onContextMenu(e){const t={x:this.position.x+e.offsetX,y:this.position.y+e.offsetY};this.openContextMenu(t)}showMenu(){const e={x:this.menuButtonPosition.x-H,y:this.menuButtonPosition.y};this.openContextMenu(e)}openContextMenu(e){const t=this.getMenuItemRegistry();this.menuState.isOpen=!0,this.menuState.menuItems=t.getMenuItems(),this.menuState.position=e}get chartComponent(){const e=this.chartType,t=Nn.get(e);if(!t)throw new Error(`Component is not defined for type ${e}`);return t}}function Yn(e){const t=e.model.dispatch("CUT");t.isSuccessful||t.isCancelledBecause(19)&&e.raiseError(s("This operation is not allowed with multiple selections."))}Xn.template="o-spreadsheet-ChartFigure",Xn.components={Menu:jn},Xn.props={figure:Object,onFigureDeleted:Function};const Kn={wrongPasteSelection:s("This operation is not allowed with multiple selections."),willRemoveExistingMerge:s("This operation is not possible due to a merge. Please remove the merges first than try again."),wrongFigurePasteOption:s("Cannot do a special paste of a figure."),frozenPaneOverlap:s("Cannot paste merged cells over a frozen pane.")};function Qn(e,t){t.isSuccessful||(t.reasons.includes(20)?e.raiseError(Kn.wrongPasteSelection):t.reasons.includes(2)?e.raiseError(Kn.willRemoveExistingMerge):t.reasons.includes(22)?e.raiseError(Kn.wrongFigurePasteOption):t.reasons.includes(75)&&e.raiseError(Kn.frozenPaneOverlap))}function Jn(e,t,i){const o=e.model.dispatch("PASTE",{target:t,pasteOption:i});Qn(e,o)}function es(e,t,i){const o=e.model.dispatch("PASTE_FROM_OS_CLIPBOARD",{target:t,text:i});Qn(e,o)}function ts(e,t){const i=On.getAll().find((t=>t.match(e.type)));if(!i)throw new Error("Unknown chart type.");return i.transformDefinition(e,t)}function is(e,t){var i;let o=e;e.left!==e.right&&(o={...e,left:e.left+1});const s=[Di(o)],r=t.getActiveSheetId(),a=t.getCell({sheetId:r,col:e.left,row:e.top});if(1===to(e)&&(null==a?void 0:a.content))return{type:"scorecard",title:"",background:(null===(i=a.style)||void 0===i?void 0:i.fillColor)||void 0,keyValue:Di(e),baselineMode:ee,baselineColorUp:te,baselineColorDown:ie};let l="";const c=t.getEvaluatedCellsInZone(r,{...o,bottom:o.top}),h=!!c.find((e=>e.type!==So.empty&&e.type!==So.number));if(h){const e=c.filter((e=>e.type!==So.error&&e.type!==So.empty)).map((e=>e.formattedValue)),t=e.splice(-1)[0];l=e.join(", "),t&&(l+=(l?" "+n("and")+" ":"")+t)}let d;e.left!==e.right&&(d=Di({...e,right:e.left,top:h?e.top+1:e.top}));const u=o.right===o.left?"none":"top";return Cn(d?t.getRangeFromSheetXC(r,d):void 0,t)?{title:l,dataSets:s,labelsAsText:!1,stacked:!1,aggregated:!1,labelRange:d,type:"line",dataSetsHaveTitle:h,verticalAxisPosition:"left",legendPosition:u}:{title:l,dataSets:s,labelRange:d,type:"bar",stacked:!1,aggregated:!1,dataSetsHaveTitle:h,verticalAxisPosition:"left",legendPosition:u}}function os(e,t){const i=Ne(t),o=e.getSheetViewDimension(),n=o.width,s=o.height;if(i.width>n){const e=n/i.width;i.width=n,i.height=i.height*e}if(i.height>s){const e=s/i.height;i.height=s,i.width=i.width*e}return i}const ns=[So.number,So.error,So.text,So.boolean];function ss(e,t,i,o,n){let r=Ro.Success,a=o.right>o.left;if(e.model.getters.doesIntersectMerge(t,o)){let i;a=!1;for(let n=o.top;n<=o.bottom;n++){i=[];for(let s=o.left;s<=o.right;s++){let o=e.model.getters.getMerge({sheetId:t,col:s,row:n});o&&!i.includes(o.id.toString())&&i.push(o.id.toString())}if(i.length>=2){a=!0;break}}}const{col:l,row:c}=i;if(a)r=e.model.dispatch("SORT_CELLS",{sheetId:t,col:l,row:c,zone:o,sortDirection:n});else{const i=e.model.getters.getContiguousZone(t,o);Bi(i,o)?r=e.model.dispatch("SORT_CELLS",{sheetId:t,col:l,row:c,zone:o,sortDirection:n}):e.askConfirmation(s("We found data next to your selection. Since this data was not selected, it will not be sorted. Do you want to extend your selection?"),(()=>{o=i,r=e.model.dispatch("SORT_CELLS",{sheetId:t,col:l,row:c,zone:o,sortDirection:n})}),(()=>{r=e.model.dispatch("SORT_CELLS",{sheetId:t,col:l,row:c,zone:o,sortDirection:n})}))}if(r.isCancelledBecause(63)){const{col:t,row:n}=i;e.model.selection.selectZone({cell:{col:t,row:n},zone:o}),e.raiseError(s("Cannot sort. To sort, select only cells or only merges that have the same size."))}}const rs={filterOverlap:s("You cannot create overlapping filters."),nonContinuousTargets:s("A filter can only be created on a continuous selection."),mergeInFilter:s("You can't create a filter over a range that contains a merge.")};function as(e,t,i){const o=e.model.dispatch("CREATE_FILTER_TABLE",{target:i,sheetId:t});o.isCancelledBecause(78)?e.raiseError(rs.filterOverlap):o.isCancelledBecause(80)?e.raiseError(rs.mergeInFilter):o.isCancelledBecause(81)&&e.raiseError(rs.nonContinuousTargets)}function ls(e){const t=e.model.getters.getActiveCols();if(t.size)return t.size;{const t=e.model.getters.getSelectedZones()[0];return t.right-t.left+1}}function cs(e){const t=e.model.getters.getActiveRows();if(t.size)return t.size;{const t=e.model.getters.getSelectedZones()[0];return t.bottom-t.top+1}}function hs(e,t){e.model.dispatch("SET_FORMATTING",{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones(),format:t})}function ds(e,t){e.model.dispatch("SET_FORMATTING",{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones(),style:t})}const us=async e=>{e.model.dispatch("COPY"),await e.clipboard.write(e.model.getters.getClipboardContent())},gs=async e=>{Yn(e),await e.clipboard.write(e.model.getters.getClipboardContent())},ps=async e=>fs(e),ms=async e=>fs(e,"onlyValue");async function fs(e,t){const i=e.model.getters.getClipboardTextContent(),o=await e.clipboard.readText();switch(o.status){case"ok":const n=e.model.getters.getSelectedZones();o&&o.content!==i?es(e,n,o.content):Jn(e,n,t);break;case"notImplemented":e.raiseError(s("Pasting from the context menu is not supported in this browser. Use keyboard shortcuts ctrl+c / ctrl+v instead."));break;case"permissionDenied":e.raiseError(s("Access to the clipboard denied by the browser. Please enable clipboard permission for this page in your browser settings."))}}const vs=e=>Jn(e,e.model.getters.getSelectedZones(),"onlyFormat"),bs=e=>!e.model.getters.isCutOperation(),Ss=e=>{if(e.model.getters.getSelectedZones().length>1)return s("Delete rows");let t,i;const o=e.model.getters.getActiveRows();if(0!==o.size)t=Math.min(...o),i=Math.max(...o);else{const o=e.model.getters.getSelectedZones()[0];t=o.top,i=o.bottom}return t===i?s("Delete row %s",(t+1).toString()):s("Delete rows %s - %s",(t+1).toString(),(i+1).toString())},Cs=e=>{let t=[...e.model.getters.getActiveRows()];if(!t.length){const i=e.model.getters.getSelectedZones()[0];for(let e=i.top;e<=i.bottom;e++)t.push(e)}e.model.dispatch("REMOVE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"ROW",elements:t})},Es=e=>{if(e.model.getters.getSelectedZones().length>1)return s("Delete columns");let t,i;const o=e.model.getters.getActiveCols();if(0!==o.size)t=Math.min(...o),i=Math.max(...o);else{const o=e.model.getters.getSelectedZones()[0];t=o.left,i=o.right}return t===i?s("Delete column %s",Lt(t)):s("Delete columns %s - %s",Lt(t),Lt(i))},ws=e=>{let t=[...e.model.getters.getActiveCols()];if(!t.length){const i=e.model.getters.getSelectedZones()[0];for(let e=i.left;e<=i.right;e++)t.push(e)}e.model.dispatch("REMOVE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"COL",elements:t})},ys=e=>{const t=e.model.getters.getSelectedZone(),i=e.model.dispatch("INSERT_CELL",{zone:t,shiftDimension:"ROW"});Qn(e,i)},xs=e=>{const t=e.model.getters.getSelectedZone(),i=e.model.dispatch("INSERT_CELL",{zone:t,shiftDimension:"COL"});Qn(e,i)},Is=e=>{const t=e.model.getters.getSelectedZone(),i=e.model.dispatch("DELETE_CELL",{zone:t,shiftDimension:"ROW"});Qn(e,i)},Rs=e=>{const t=e.model.getters.getSelectedZone(),i=e.model.dispatch("DELETE_CELL",{zone:t,shiftDimension:"COL"});Qn(e,i)},Ts=e=>{const t=e.model.getters.getActiveRows();let i,o;if(t.size)i=Math.min(...t),o=t.size;else{const t=e.model.getters.getSelectedZones()[0];i=t.top,o=t.bottom-t.top+1}e.model.dispatch("ADD_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),position:"before",base:i,quantity:o,dimension:"ROW"})},As=e=>{const t=e.model.getters.getActiveRows();let i,o;if(t.size)i=Math.max(...t),o=t.size;else{const t=e.model.getters.getSelectedZones()[0];i=t.bottom,o=t.bottom-t.top+1}e.model.dispatch("ADD_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),position:"after",base:i,quantity:o,dimension:"ROW"})},Ms=e=>{const t=e.model.getters.getActiveCols();let i,o;if(t.size)i=Math.min(...t),o=t.size;else{const t=e.model.getters.getSelectedZones()[0];i=t.left,o=t.right-t.left+1}e.model.dispatch("ADD_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),position:"before",dimension:"COL",base:i,quantity:o})},Os=e=>{const t=e.model.getters.getActiveCols();let i,o;if(t.size)i=Math.max(...t),o=t.size;else{const t=e.model.getters.getSelectedZones()[0];i=t.right,o=t.right-t.left+1}e.model.dispatch("ADD_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),position:"after",dimension:"COL",base:i,quantity:o})};const Ns=e=>{e.openSidePanel("ConditionalFormatting",{selection:e.model.getters.getSelectedZones()})},_s=e=>{let{col:t,row:i}=e.model.getters.getActivePosition();e.model.dispatch("OPEN_CELL_POPOVER",{col:t,row:i,popoverType:"LinkEditor"})},Fs=e=>{const t=e.model.getters.getActiveSheetId(),i=e.model.getters.getSelectedZones();return e.model.getters.doesZonesContainFilter(t,i)},Ds=e=>{const{anchor:t,zones:i}=e.model.getters.getSelection(),o=e.model.getters.getActiveSheetId();ss(e,o,t.cell,i[0],"ascending")},ks=e=>{const{anchor:t,zones:i}=e.model.getters.getSelection(),o=e.model.getters.getActiveSheetId();ss(e,o,t.cell,i[0],"descending")},Ls=e=>1===e.model.getters.getSelectedZones().length,Ps=new kn;Ps.add("cut",{name:s("Cut"),description:"Ctrl+X",sequence:10,action:gs}).add("copy",{name:s("Copy"),description:"Ctrl+C",sequence:20,isReadonlyAllowed:!0,action:us}).add("paste",{name:s("Paste"),description:"Ctrl+V",sequence:30,action:ps}).add("paste_special",{name:s("Paste special"),sequence:40,separator:!0,isVisible:bs}).addChild("paste_value_only",["paste_special"],{name:s("Paste values only"),sequence:10,action:ms}).addChild("paste_format_only",["paste_special"],{name:s("Paste format only"),sequence:20,action:vs}).add("add_row_before",{name:e=>{const t=cs(e);return 1===t?s("Insert row"):s("Insert %s rows",t.toString())},sequence:70,action:Ts,isVisible:Ls}).add("add_column_before",{name:e=>{const t=ls(e);return 1===t?s("Insert column"):s("Insert %s columns",t.toString())},sequence:90,action:Ms,isVisible:Ls}).add("insert_cell",{name:s("Insert cells"),sequence:100,isVisible:Ls,separator:!0}).addChild("insert_cell_down",["insert_cell"],{name:s("Shift down"),sequence:10,action:ys}).addChild("insert_cell_right",["insert_cell"],{name:s("Shift right"),sequence:20,action:xs}).add("delete_row",{name:Ss,sequence:110,action:Cs,isVisible:Ls}).add("delete_column",{name:Es,sequence:120,action:ws,isVisible:Ls}).add("delete_cell",{name:s("Delete cells"),sequence:130,isVisible:Ls}).addChild("delete_cell_up",["delete_cell"],{name:s("Shift up"),sequence:10,action:Is}).addChild("delete_cell_down",["delete_cell"],{name:s("Shift left"),sequence:20,action:Rs}).add("insert_link",{name:s("Insert link"),separator:!0,sequence:150,action:_s});const Us=new kn;Us.add("cut",{name:s("Cut"),description:"Ctrl+X",sequence:10,action:gs}).add("copy",{name:s("Copy"),description:"Ctrl+C",sequence:20,isReadonlyAllowed:!0,action:us}).add("paste",{name:s("Paste"),description:"Ctrl+V",sequence:30,action:ps}).add("paste_special",{name:s("Paste special"),sequence:40,separator:!0,isVisible:bs}).addChild("paste_value_only",["paste_special"],{name:s("Paste value only"),sequence:10,action:ms}).addChild("paste_format_only",["paste_special"],{name:s("Paste format only"),sequence:20,action:vs}).add("sort_columns",{name:e=>e.model.getters.getActiveCols().size>1?s("Sort columns"):s("Sort column"),sequence:50,isVisible:Ls,separator:!0}).addChild("sort_ascending",["sort_columns"],{name:s("Ascending (A ⟶ Z)"),sequence:10,action:Ds}).addChild("sort_descending",["sort_columns"],{name:s("Descending (Z ⟶ A)"),sequence:20,action:ks}).add("add_column_before",{name:e=>{const t=ls(e);return 1===t?s("Insert column left"):s("Insert %s columns left",t.toString())},sequence:70,action:Ms}).add("add_column_after",{name:e=>{const t=ls(e);return 1===t?s("Insert column right"):s("Insert %s columns right",t.toString())},sequence:80,action:Os}).add("delete_column",{name:Es,sequence:90,action:ws}).add("clear_column",{name:e=>{if(e.model.getters.getSelectedZones().length>1)return s("Clear columns");let t,i;const o=e.model.getters.getActiveCols();if(0!==o.size)t=Math.min(...o),i=Math.max(...o);else{const o=e.model.getters.getSelectedZones()[0];t=o.left,i=o.right}return t===i?s("Clear column %s",Lt(t)):s("Clear columns %s - %s",Lt(t),Lt(i))},sequence:100,action:e=>{const t=e.model.getters.getActiveSheetId(),i=[...e.model.getters.getActiveCols()].map((i=>e.model.getters.getColsZone(t,i,i)));e.model.dispatch("DELETE_CONTENT",{target:i,sheetId:e.model.getters.getActiveSheetId()})}}).add("hide_columns",{name:e=>{const t=e.model.getters.getElementsFromSelection("COL");let i=t[0],o=t[t.length-1];return 1===t.length?s("Hide column %s",Lt(i).toString()):o-i+1===t.length?s("Hide columns %s - %s",Lt(i).toString(),Lt(o).toString()):s("Hide columns")},sequence:85,action:e=>{const t=e.model.getters.getElementsFromSelection("COL");e.model.dispatch("HIDE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"COL",elements:t})},isVisible:e=>{const t=e.model.getters.getActiveSheetId(),i=e.model.getters.getHiddenColsGroups(t).flat();return e.model.getters.getNumberCols(t)>i.length+e.model.getters.getElementsFromSelection("COL").length},separator:!0}).add("unhide_columns",{name:s("Unhide columns"),sequence:86,action:e=>{const t=e.model.getters.getElementsFromSelection("COL");e.model.dispatch("UNHIDE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"COL",elements:t})},isVisible:e=>{const t=e.model.getters.getHiddenColsGroups(e.model.getters.getActiveSheetId()).flat();return e.model.getters.getElementsFromSelection("COL").some((e=>t.includes(e)))},separator:!0}).add("conditional_formatting",{name:s("Conditional formatting"),sequence:110,action:Ns});const Vs=new kn;function zs(e,t,i=(()=>{})){const o=e=>{e.preventDefault(),i(e)},n=t=>{t.preventDefault(),e(t)},s=e=>{e.preventDefault(),t(e),window.removeEventListener("mousedown",o),window.removeEventListener("mouseup",s),window.removeEventListener("dragstart",r),window.removeEventListener("mousemove",n),window.removeEventListener("wheel",n)};function r(e){e.preventDefault()}window.addEventListener("mousedown",o),window.addEventListener("mouseup",s),window.addEventListener("dragstart",r),window.addEventListener("mousemove",n),window.addEventListener("wheel",n,{passive:!1})}function Bs(e,t,i,o=!1){let n,s,r,a,l,c=null;const h=e.model.getters,d=h.getActiveSheetId(),u=Vn();let g,p;const m=i=>{if(n=i,c)return;const{x:r,y:f}=h.getMainViewportCoordinates();let{top:v,left:b,bottom:S,right:C}=h.getActiveMainViewport(),{scrollX:E,scrollY:w}=h.getActiveSheetDOMScrollInfo();const{xSplit:y,ySplit:x}=h.getPaneDivisions(d);let I=!1,R=zt;const T=n.clientX-u.left;if(g=h.getColIndex(T),"vertical"!==o){const t=s.clientX-u.left,i=h.getEdgeScrollCol(T,t,a);if(i.canEdgeScroll){let t;switch(I=!0,R=Math.min(R,i.delay),i.direction){case"reset":g=y,t=y;break;case 1:g=C,t=b+1;break;case-1:for(g=b-1;e.model.getters.isColHidden(d,g);)g--;t=g}E=h.getColDimensions(d,t).start-r}}const A=n.clientY-u.top;if(p=h.getRowIndex(A),"horizontal"!==o){const t=s.clientY-u.top,i=h.getEdgeScrollRow(A,t,l);if(i.canEdgeScroll){let t;switch(I=!0,R=Math.min(R,i.delay),i.direction){case"reset":p=x,t=x;break;case 1:p=S,t=v+i.direction;break;case-1:for(p=v-1;e.model.getters.isRowHidden(d,p);)p--;t=p}w=e.model.getters.getRowDimensions(d,t).start-f}}I||(-1===p&&(p=A<0?0:h.getNumberRows(d)-1),-1===g&&T<0&&(g=T<0?0:h.getNumberCols(d)-1)),t(g,p,n),I&&(e.model.dispatch("SET_VIEWPORT_OFFSET",{offsetX:E,offsetY:w}),c=setTimeout((()=>{c=null,m(n)}),Math.round(R))),s=n};zs(m,(()=>{clearTimeout(c),i()}),(e=>{s=e,r=e,a=r.clientX-u.left,l=r.clientY-u.top}))}Vs.add("cut",{name:s("Cut"),sequence:10,description:"Ctrl+X",action:gs}).add("copy",{name:s("Copy"),description:"Ctrl+C",sequence:20,isReadonlyAllowed:!0,action:us}).add("paste",{name:s("Paste"),description:"Ctrl+V",sequence:30,action:ps}).add("paste_special",{name:s("Paste special"),sequence:40,separator:!0,isVisible:bs}).addChild("paste_value_only",["paste_special"],{name:s("Paste value only"),sequence:10,action:ms}).addChild("paste_format_only",["paste_special"],{name:s("Paste format only"),sequence:20,action:vs}).add("add_row_before",{name:e=>{const t=cs(e);return 1===t?s("Insert row above"):s("Insert %s rows above",t.toString())},sequence:50,action:Ts}).add("add_row_after",{name:e=>{const t=cs(e);return 1===t?s("Insert row below"):s("Insert %s rows below",t.toString())},sequence:60,action:As}).add("delete_row",{name:Ss,sequence:70,action:Cs}).add("clear_row",{name:e=>{if(e.model.getters.getSelectedZones().length>1)return s("Clear rows");let t,i;const o=e.model.getters.getActiveRows();if(0!==o.size)t=Math.min(...o),i=Math.max(...o);else{const o=e.model.getters.getSelectedZones()[0];t=o.top,i=o.bottom}return t===i?s("Clear row %s",(t+1).toString()):s("Clear rows %s - %s",(t+1).toString(),(i+1).toString())},sequence:80,action:e=>{const t=e.model.getters.getActiveSheetId(),i=[...e.model.getters.getActiveRows()].map((i=>e.model.getters.getRowsZone(t,i,i)));e.model.dispatch("DELETE_CONTENT",{target:i,sheetId:e.model.getters.getActiveSheetId()})}}).add("hide_rows",{name:e=>{const t=e.model.getters.getElementsFromSelection("ROW");let i=t[0],o=t[t.length-1];return 1===t.length?s("Hide row %s",(i+1).toString()):o-i+1===t.length?s("Hide rows %s - %s",(i+1).toString(),(o+1).toString()):s("Hide rows")},sequence:85,action:e=>{const t=e.model.getters.getElementsFromSelection("ROW");e.model.dispatch("HIDE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"ROW",elements:t})},isVisible:e=>{const t=e.model.getters.getActiveSheetId(),i=e.model.getters.getHiddenRowsGroups(t).flat();return e.model.getters.getNumberRows(t)>i.length+e.model.getters.getElementsFromSelection("ROW").length},separator:!0}).add("unhide_rows",{name:s("Unhide rows"),sequence:86,action:e=>{const t=e.model.getters.getElementsFromSelection("ROW");e.model.dispatch("UNHIDE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"ROW",elements:t})},isVisible:e=>{const t=e.model.getters.getHiddenRowsGroups(e.model.getters.getActiveSheetId()).flat();return e.model.getters.getElementsFromSelection("ROW").some((e=>t.includes(e)))},separator:!0}).add("conditional_formatting",{name:s("Conditional formatting"),sequence:90,action:Ns}),ro`
117
+ `;class Xn extends t.Component{constructor(){super(...arguments),this.menuState=t.useState({isOpen:!1,position:null,menuItems:[]}),this.chartContainerRef=t.useRef("chartContainer"),this.menuButtonRef=t.useRef("menuButton"),this.menuButtonRect=Pn(this.menuButtonRef),this.position=Pn(this.chartContainerRef)}getMenuItemRegistry(){const e=new kn;return e.add("edit",{name:s("Edit"),sequence:1,action:()=>{this.env.model.dispatch("SELECT_FIGURE",{id:this.props.figure.id}),this.env.openSidePanel("ChartPanel")}}),e.add("copy",{name:s("Copy"),sequence:2,action:async()=>{this.env.model.dispatch("SELECT_FIGURE",{id:this.props.figure.id}),this.env.model.dispatch("COPY"),await this.env.clipboard.write(this.env.model.getters.getClipboardContent())}}),e.add("cut",{name:s("Cut"),sequence:3,action:async()=>{this.env.model.dispatch("SELECT_FIGURE",{id:this.props.figure.id}),this.env.model.dispatch("CUT"),await this.env.clipboard.write(this.env.model.getters.getClipboardContent())}}),e.add("delete",{name:s("Delete"),sequence:10,action:()=>{this.env.model.dispatch("DELETE_FIGURE",{sheetId:this.env.model.getters.getActiveSheetId(),id:this.props.figure.id}),this.props.onFigureDeleted()}}),e}get chartType(){return this.env.model.getters.getChartType(this.env.model.getters.getActiveSheetId(),this.props.figure.id)}onContextMenu(e){const t={x:this.position.x+e.offsetX,y:this.position.y+e.offsetY};this.openContextMenu(t)}showMenu(){const{x:e,y:t,width:i}=this.menuButtonRect,o={x:e>=H?e-H:e+i,y:t};this.openContextMenu(o)}openContextMenu(e){const t=this.getMenuItemRegistry();this.menuState.isOpen=!0,this.menuState.menuItems=t.getMenuItems(),this.menuState.position=e}get chartComponent(){const e=this.chartType,t=Nn.get(e);if(!t)throw new Error(`Component is not defined for type ${e}`);return t}}function Yn(e){const t=e.model.dispatch("CUT");t.isSuccessful||t.isCancelledBecause(19)&&e.raiseError(s("This operation is not allowed with multiple selections."))}Xn.template="o-spreadsheet-ChartFigure",Xn.components={Menu:jn},Xn.props={figure:Object,onFigureDeleted:Function};const Kn={wrongPasteSelection:s("This operation is not allowed with multiple selections."),willRemoveExistingMerge:s("This operation is not possible due to a merge. Please remove the merges first than try again."),wrongFigurePasteOption:s("Cannot do a special paste of a figure."),frozenPaneOverlap:s("Cannot paste merged cells over a frozen pane.")};function Qn(e,t){t.isSuccessful||(t.reasons.includes(20)?e.raiseError(Kn.wrongPasteSelection):t.reasons.includes(2)?e.raiseError(Kn.willRemoveExistingMerge):t.reasons.includes(22)?e.raiseError(Kn.wrongFigurePasteOption):t.reasons.includes(75)&&e.raiseError(Kn.frozenPaneOverlap))}function Jn(e,t,i){const o=e.model.dispatch("PASTE",{target:t,pasteOption:i});Qn(e,o)}function es(e,t,i){const o=e.model.dispatch("PASTE_FROM_OS_CLIPBOARD",{target:t,text:i});Qn(e,o)}function ts(e,t){const i=On.getAll().find((t=>t.match(e.type)));if(!i)throw new Error("Unknown chart type.");return i.transformDefinition(e,t)}function is(e,t){var i;let o=e;e.left!==e.right&&(o={...e,left:e.left+1});const s=[Di(o)],r=t.getActiveSheetId(),a=t.getCell({sheetId:r,col:e.left,row:e.top});if(1===to(e)&&(null==a?void 0:a.content))return{type:"scorecard",title:"",background:(null===(i=a.style)||void 0===i?void 0:i.fillColor)||void 0,keyValue:Di(e),baselineMode:ee,baselineColorUp:te,baselineColorDown:ie};let l="";const c=t.getEvaluatedCellsInZone(r,{...o,bottom:o.top}),h=!!c.find((e=>e.type!==So.empty&&e.type!==So.number));if(h){const e=c.filter((e=>e.type!==So.error&&e.type!==So.empty)).map((e=>e.formattedValue)),t=e.splice(-1)[0];l=e.join(", "),t&&(l+=(l?" "+n("and")+" ":"")+t)}let d;e.left!==e.right&&(d=Di({...e,right:e.left,top:h?e.top+1:e.top}));const u=o.right===o.left?"none":"top";return Cn(d?t.getRangeFromSheetXC(r,d):void 0,t)?{title:l,dataSets:s,labelsAsText:!1,stacked:!1,aggregated:!1,labelRange:d,type:"line",dataSetsHaveTitle:h,verticalAxisPosition:"left",legendPosition:u}:{title:l,dataSets:s,labelRange:d,type:"bar",stacked:!1,aggregated:!1,dataSetsHaveTitle:h,verticalAxisPosition:"left",legendPosition:u}}function os(e,t){const i=Ne(t),o=e.getSheetViewDimension(),n=o.width,s=o.height;if(i.width>n){const e=n/i.width;i.width=n,i.height=i.height*e}if(i.height>s){const e=s/i.height;i.height=s,i.width=i.width*e}return i}const ns=[So.number,So.error,So.text,So.boolean];function ss(e,t,i,o,n){let r=Ro.Success,a=o.right>o.left;if(e.model.getters.doesIntersectMerge(t,o)){let i;a=!1;for(let n=o.top;n<=o.bottom;n++){i=[];for(let s=o.left;s<=o.right;s++){let o=e.model.getters.getMerge({sheetId:t,col:s,row:n});o&&!i.includes(o.id.toString())&&i.push(o.id.toString())}if(i.length>=2){a=!0;break}}}const{col:l,row:c}=i;if(a)r=e.model.dispatch("SORT_CELLS",{sheetId:t,col:l,row:c,zone:o,sortDirection:n});else{const i=e.model.getters.getContiguousZone(t,o);Bi(i,o)?r=e.model.dispatch("SORT_CELLS",{sheetId:t,col:l,row:c,zone:o,sortDirection:n}):e.askConfirmation(s("We found data next to your selection. Since this data was not selected, it will not be sorted. Do you want to extend your selection?"),(()=>{o=i,r=e.model.dispatch("SORT_CELLS",{sheetId:t,col:l,row:c,zone:o,sortDirection:n})}),(()=>{r=e.model.dispatch("SORT_CELLS",{sheetId:t,col:l,row:c,zone:o,sortDirection:n})}))}if(r.isCancelledBecause(63)){const{col:t,row:n}=i;e.model.selection.selectZone({cell:{col:t,row:n},zone:o}),e.raiseError(s("Cannot sort. To sort, select only cells or only merges that have the same size."))}}const rs={filterOverlap:s("You cannot create overlapping filters."),nonContinuousTargets:s("A filter can only be created on a continuous selection."),mergeInFilter:s("You can't create a filter over a range that contains a merge.")};function as(e,t,i){const o=e.model.dispatch("CREATE_FILTER_TABLE",{target:i,sheetId:t});o.isCancelledBecause(78)?e.raiseError(rs.filterOverlap):o.isCancelledBecause(80)?e.raiseError(rs.mergeInFilter):o.isCancelledBecause(81)&&e.raiseError(rs.nonContinuousTargets)}function ls(e){const t=e.model.getters.getActiveCols();if(t.size)return t.size;{const t=e.model.getters.getSelectedZones()[0];return t.right-t.left+1}}function cs(e){const t=e.model.getters.getActiveRows();if(t.size)return t.size;{const t=e.model.getters.getSelectedZones()[0];return t.bottom-t.top+1}}function hs(e,t){e.model.dispatch("SET_FORMATTING",{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones(),format:t})}function ds(e,t){e.model.dispatch("SET_FORMATTING",{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones(),style:t})}const us=async e=>{e.model.dispatch("COPY"),await e.clipboard.write(e.model.getters.getClipboardContent())},gs=async e=>{Yn(e),await e.clipboard.write(e.model.getters.getClipboardContent())},ps=async e=>fs(e),ms=async e=>fs(e,"onlyValue");async function fs(e,t){const i=e.model.getters.getClipboardTextContent(),o=await e.clipboard.readText();switch(o.status){case"ok":const n=e.model.getters.getSelectedZones();o&&o.content!==i?es(e,n,o.content):Jn(e,n,t);break;case"notImplemented":e.raiseError(s("Pasting from the context menu is not supported in this browser. Use keyboard shortcuts ctrl+c / ctrl+v instead."));break;case"permissionDenied":e.raiseError(s("Access to the clipboard denied by the browser. Please enable clipboard permission for this page in your browser settings."))}}const vs=e=>Jn(e,e.model.getters.getSelectedZones(),"onlyFormat"),bs=e=>!e.model.getters.isCutOperation(),Ss=e=>{if(e.model.getters.getSelectedZones().length>1)return s("Delete rows");let t,i;const o=e.model.getters.getActiveRows();if(0!==o.size)t=Math.min(...o),i=Math.max(...o);else{const o=e.model.getters.getSelectedZones()[0];t=o.top,i=o.bottom}return t===i?s("Delete row %s",(t+1).toString()):s("Delete rows %s - %s",(t+1).toString(),(i+1).toString())},Cs=e=>{let t=[...e.model.getters.getActiveRows()];if(!t.length){const i=e.model.getters.getSelectedZones()[0];for(let e=i.top;e<=i.bottom;e++)t.push(e)}e.model.dispatch("REMOVE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"ROW",elements:t})},Es=e=>{if(e.model.getters.getSelectedZones().length>1)return s("Delete columns");let t,i;const o=e.model.getters.getActiveCols();if(0!==o.size)t=Math.min(...o),i=Math.max(...o);else{const o=e.model.getters.getSelectedZones()[0];t=o.left,i=o.right}return t===i?s("Delete column %s",Lt(t)):s("Delete columns %s - %s",Lt(t),Lt(i))},ws=e=>{let t=[...e.model.getters.getActiveCols()];if(!t.length){const i=e.model.getters.getSelectedZones()[0];for(let e=i.left;e<=i.right;e++)t.push(e)}e.model.dispatch("REMOVE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"COL",elements:t})},ys=e=>{const t=e.model.getters.getSelectedZone(),i=e.model.dispatch("INSERT_CELL",{zone:t,shiftDimension:"ROW"});Qn(e,i)},xs=e=>{const t=e.model.getters.getSelectedZone(),i=e.model.dispatch("INSERT_CELL",{zone:t,shiftDimension:"COL"});Qn(e,i)},Is=e=>{const t=e.model.getters.getSelectedZone(),i=e.model.dispatch("DELETE_CELL",{zone:t,shiftDimension:"ROW"});Qn(e,i)},Rs=e=>{const t=e.model.getters.getSelectedZone(),i=e.model.dispatch("DELETE_CELL",{zone:t,shiftDimension:"COL"});Qn(e,i)},Ts=e=>{const t=e.model.getters.getActiveRows();let i,o;if(t.size)i=Math.min(...t),o=t.size;else{const t=e.model.getters.getSelectedZones()[0];i=t.top,o=t.bottom-t.top+1}e.model.dispatch("ADD_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),position:"before",base:i,quantity:o,dimension:"ROW"})},As=e=>{const t=e.model.getters.getActiveRows();let i,o;if(t.size)i=Math.max(...t),o=t.size;else{const t=e.model.getters.getSelectedZones()[0];i=t.bottom,o=t.bottom-t.top+1}e.model.dispatch("ADD_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),position:"after",base:i,quantity:o,dimension:"ROW"})},Ms=e=>{const t=e.model.getters.getActiveCols();let i,o;if(t.size)i=Math.min(...t),o=t.size;else{const t=e.model.getters.getSelectedZones()[0];i=t.left,o=t.right-t.left+1}e.model.dispatch("ADD_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),position:"before",dimension:"COL",base:i,quantity:o})},Os=e=>{const t=e.model.getters.getActiveCols();let i,o;if(t.size)i=Math.max(...t),o=t.size;else{const t=e.model.getters.getSelectedZones()[0];i=t.right,o=t.right-t.left+1}e.model.dispatch("ADD_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),position:"after",dimension:"COL",base:i,quantity:o})};const Ns=e=>{e.openSidePanel("ConditionalFormatting",{selection:e.model.getters.getSelectedZones()})},_s=e=>{let{col:t,row:i}=e.model.getters.getActivePosition();e.model.dispatch("OPEN_CELL_POPOVER",{col:t,row:i,popoverType:"LinkEditor"})},Fs=e=>{const t=e.model.getters.getActiveSheetId(),i=e.model.getters.getSelectedZones();return e.model.getters.doesZonesContainFilter(t,i)},Ds=e=>{const{anchor:t,zones:i}=e.model.getters.getSelection(),o=e.model.getters.getActiveSheetId();ss(e,o,t.cell,i[0],"ascending")},ks=e=>{const{anchor:t,zones:i}=e.model.getters.getSelection(),o=e.model.getters.getActiveSheetId();ss(e,o,t.cell,i[0],"descending")},Ls=e=>1===e.model.getters.getSelectedZones().length,Ps=new kn;Ps.add("cut",{name:s("Cut"),description:"Ctrl+X",sequence:10,action:gs}).add("copy",{name:s("Copy"),description:"Ctrl+C",sequence:20,isReadonlyAllowed:!0,action:us}).add("paste",{name:s("Paste"),description:"Ctrl+V",sequence:30,action:ps}).add("paste_special",{name:s("Paste special"),sequence:40,separator:!0,isVisible:bs}).addChild("paste_value_only",["paste_special"],{name:s("Paste values only"),sequence:10,action:ms}).addChild("paste_format_only",["paste_special"],{name:s("Paste format only"),sequence:20,action:vs}).add("add_row_before",{name:e=>{const t=cs(e);return 1===t?s("Insert row"):s("Insert %s rows",t.toString())},sequence:70,action:Ts,isVisible:Ls}).add("add_column_before",{name:e=>{const t=ls(e);return 1===t?s("Insert column"):s("Insert %s columns",t.toString())},sequence:90,action:Ms,isVisible:Ls}).add("insert_cell",{name:s("Insert cells"),sequence:100,isVisible:Ls,separator:!0}).addChild("insert_cell_down",["insert_cell"],{name:s("Shift down"),sequence:10,action:ys}).addChild("insert_cell_right",["insert_cell"],{name:s("Shift right"),sequence:20,action:xs}).add("delete_row",{name:Ss,sequence:110,action:Cs,isVisible:Ls}).add("delete_column",{name:Es,sequence:120,action:ws,isVisible:Ls}).add("delete_cell",{name:s("Delete cells"),sequence:130,isVisible:Ls}).addChild("delete_cell_up",["delete_cell"],{name:s("Shift up"),sequence:10,action:Is}).addChild("delete_cell_down",["delete_cell"],{name:s("Shift left"),sequence:20,action:Rs}).add("insert_link",{name:s("Insert link"),separator:!0,sequence:150,action:_s});const Us=new kn;Us.add("cut",{name:s("Cut"),description:"Ctrl+X",sequence:10,action:gs}).add("copy",{name:s("Copy"),description:"Ctrl+C",sequence:20,isReadonlyAllowed:!0,action:us}).add("paste",{name:s("Paste"),description:"Ctrl+V",sequence:30,action:ps}).add("paste_special",{name:s("Paste special"),sequence:40,separator:!0,isVisible:bs}).addChild("paste_value_only",["paste_special"],{name:s("Paste value only"),sequence:10,action:ms}).addChild("paste_format_only",["paste_special"],{name:s("Paste format only"),sequence:20,action:vs}).add("sort_columns",{name:e=>e.model.getters.getActiveCols().size>1?s("Sort columns"):s("Sort column"),sequence:50,isVisible:Ls,separator:!0}).addChild("sort_ascending",["sort_columns"],{name:s("Ascending (A ⟶ Z)"),sequence:10,action:Ds}).addChild("sort_descending",["sort_columns"],{name:s("Descending (Z ⟶ A)"),sequence:20,action:ks}).add("add_column_before",{name:e=>{const t=ls(e);return 1===t?s("Insert column left"):s("Insert %s columns left",t.toString())},sequence:70,action:Ms}).add("add_column_after",{name:e=>{const t=ls(e);return 1===t?s("Insert column right"):s("Insert %s columns right",t.toString())},sequence:80,action:Os}).add("delete_column",{name:Es,sequence:90,action:ws}).add("clear_column",{name:e=>{if(e.model.getters.getSelectedZones().length>1)return s("Clear columns");let t,i;const o=e.model.getters.getActiveCols();if(0!==o.size)t=Math.min(...o),i=Math.max(...o);else{const o=e.model.getters.getSelectedZones()[0];t=o.left,i=o.right}return t===i?s("Clear column %s",Lt(t)):s("Clear columns %s - %s",Lt(t),Lt(i))},sequence:100,action:e=>{const t=e.model.getters.getActiveSheetId(),i=[...e.model.getters.getActiveCols()].map((i=>e.model.getters.getColsZone(t,i,i)));e.model.dispatch("DELETE_CONTENT",{target:i,sheetId:e.model.getters.getActiveSheetId()})}}).add("hide_columns",{name:e=>{const t=e.model.getters.getElementsFromSelection("COL");let i=t[0],o=t[t.length-1];return 1===t.length?s("Hide column %s",Lt(i).toString()):o-i+1===t.length?s("Hide columns %s - %s",Lt(i).toString(),Lt(o).toString()):s("Hide columns")},sequence:85,action:e=>{const t=e.model.getters.getElementsFromSelection("COL");e.model.dispatch("HIDE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"COL",elements:t})},isVisible:e=>{const t=e.model.getters.getActiveSheetId(),i=e.model.getters.getHiddenColsGroups(t).flat();return e.model.getters.getNumberCols(t)>i.length+e.model.getters.getElementsFromSelection("COL").length},separator:!0}).add("unhide_columns",{name:s("Unhide columns"),sequence:86,action:e=>{const t=e.model.getters.getElementsFromSelection("COL");e.model.dispatch("UNHIDE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"COL",elements:t})},isVisible:e=>{const t=e.model.getters.getHiddenColsGroups(e.model.getters.getActiveSheetId()).flat();return e.model.getters.getElementsFromSelection("COL").some((e=>t.includes(e)))},separator:!0}).add("conditional_formatting",{name:s("Conditional formatting"),sequence:110,action:Ns});const Vs=new kn;function zs(e,t,i=(()=>{})){const o=e=>{e.preventDefault(),i(e)},n=t=>{t.preventDefault(),e(t)},s=e=>{e.preventDefault(),t(e),window.removeEventListener("mousedown",o),window.removeEventListener("mouseup",s),window.removeEventListener("dragstart",r),window.removeEventListener("mousemove",n),window.removeEventListener("wheel",n)};function r(e){e.preventDefault()}window.addEventListener("mousedown",o),window.addEventListener("mouseup",s),window.addEventListener("dragstart",r),window.addEventListener("mousemove",n),window.addEventListener("wheel",n,{passive:!1})}function Bs(e,t,i,o=!1){let n,s,r,a,l,c=null;const h=e.model.getters,d=h.getActiveSheetId(),u=Vn();let g,p;const m=i=>{if(n=i,c)return;const{x:r,y:f}=h.getMainViewportCoordinates();let{top:v,left:b,bottom:S,right:C}=h.getActiveMainViewport(),{scrollX:E,scrollY:w}=h.getActiveSheetDOMScrollInfo();const{xSplit:y,ySplit:x}=h.getPaneDivisions(d);let I=!1,R=zt;const T=n.clientX-u.left;if(g=h.getColIndex(T),"vertical"!==o){const t=s.clientX-u.left,i=h.getEdgeScrollCol(T,t,a);if(i.canEdgeScroll){let t;switch(I=!0,R=Math.min(R,i.delay),i.direction){case"reset":g=y,t=y;break;case 1:g=C,t=b+1;break;case-1:for(g=b-1;e.model.getters.isColHidden(d,g);)g--;t=g}E=h.getColDimensions(d,t).start-r}}const A=n.clientY-u.top;if(p=h.getRowIndex(A),"horizontal"!==o){const t=s.clientY-u.top,i=h.getEdgeScrollRow(A,t,l);if(i.canEdgeScroll){let t;switch(I=!0,R=Math.min(R,i.delay),i.direction){case"reset":p=x,t=x;break;case 1:p=S,t=v+i.direction;break;case-1:for(p=v-1;e.model.getters.isRowHidden(d,p);)p--;t=p}w=e.model.getters.getRowDimensions(d,t).start-f}}I||(-1===p&&(p=A<0?0:h.getNumberRows(d)-1),-1===g&&T<0&&(g=T<0?0:h.getNumberCols(d)-1)),t(g,p,n),I&&(e.model.dispatch("SET_VIEWPORT_OFFSET",{offsetX:E,offsetY:w}),c=setTimeout((()=>{c=null,m(n)}),Math.round(R))),s=n};zs(m,(()=>{clearTimeout(c),i()}),(e=>{s=e,r=e,a=r.clientX-u.left,l=r.clientY-u.top}))}Vs.add("cut",{name:s("Cut"),sequence:10,description:"Ctrl+X",action:gs}).add("copy",{name:s("Copy"),description:"Ctrl+C",sequence:20,isReadonlyAllowed:!0,action:us}).add("paste",{name:s("Paste"),description:"Ctrl+V",sequence:30,action:ps}).add("paste_special",{name:s("Paste special"),sequence:40,separator:!0,isVisible:bs}).addChild("paste_value_only",["paste_special"],{name:s("Paste value only"),sequence:10,action:ms}).addChild("paste_format_only",["paste_special"],{name:s("Paste format only"),sequence:20,action:vs}).add("add_row_before",{name:e=>{const t=cs(e);return 1===t?s("Insert row above"):s("Insert %s rows above",t.toString())},sequence:50,action:Ts}).add("add_row_after",{name:e=>{const t=cs(e);return 1===t?s("Insert row below"):s("Insert %s rows below",t.toString())},sequence:60,action:As}).add("delete_row",{name:Ss,sequence:70,action:Cs}).add("clear_row",{name:e=>{if(e.model.getters.getSelectedZones().length>1)return s("Clear rows");let t,i;const o=e.model.getters.getActiveRows();if(0!==o.size)t=Math.min(...o),i=Math.max(...o);else{const o=e.model.getters.getSelectedZones()[0];t=o.top,i=o.bottom}return t===i?s("Clear row %s",(t+1).toString()):s("Clear rows %s - %s",(t+1).toString(),(i+1).toString())},sequence:80,action:e=>{const t=e.model.getters.getActiveSheetId(),i=[...e.model.getters.getActiveRows()].map((i=>e.model.getters.getRowsZone(t,i,i)));e.model.dispatch("DELETE_CONTENT",{target:i,sheetId:e.model.getters.getActiveSheetId()})}}).add("hide_rows",{name:e=>{const t=e.model.getters.getElementsFromSelection("ROW");let i=t[0],o=t[t.length-1];return 1===t.length?s("Hide row %s",(i+1).toString()):o-i+1===t.length?s("Hide rows %s - %s",(i+1).toString(),(o+1).toString()):s("Hide rows")},sequence:85,action:e=>{const t=e.model.getters.getElementsFromSelection("ROW");e.model.dispatch("HIDE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"ROW",elements:t})},isVisible:e=>{const t=e.model.getters.getActiveSheetId(),i=e.model.getters.getHiddenRowsGroups(t).flat();return e.model.getters.getNumberRows(t)>i.length+e.model.getters.getElementsFromSelection("ROW").length},separator:!0}).add("unhide_rows",{name:s("Unhide rows"),sequence:86,action:e=>{const t=e.model.getters.getElementsFromSelection("ROW");e.model.dispatch("UNHIDE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"ROW",elements:t})},isVisible:e=>{const t=e.model.getters.getHiddenRowsGroups(e.model.getters.getActiveSheetId()).flat();return e.model.getters.getElementsFromSelection("ROW").some((e=>t.includes(e)))},separator:!0}).add("conditional_formatting",{name:s("Conditional formatting"),sequence:90,action:Ns}),ro`
118
118
  .o-autofill {
119
119
  position: absolute;
120
120
  height: ${8}px;
@@ -513,7 +513,7 @@
513
513
  }
514
514
  }
515
515
  }
516
- `;class Qu extends t.Component{constructor(){super(...arguments),this.menuItems=Ku.getMenuItems(),this.link=t.useState(this.defaultState),this.menu=t.useState({isOpen:!1}),this.linkEditorRef=t.useRef("linkEditor"),this.position=Pn(this.linkEditorRef),this.urlInput=t.useRef("urlInput")}setup(){t.onMounted((()=>{var e;return null===(e=this.urlInput.el)||void 0===e?void 0:e.focus()}))}get defaultState(){const{col:e,row:t}=this.props.cellPosition,i=this.env.model.getters.getActiveSheetId(),o=this.env.model.getters.getEvaluatedCell({sheetId:i,col:e,row:t});return o.link?{url:o.link.url,label:o.formattedValue,isUrlEditable:o.link.isUrlEditable}:{label:o.formattedValue,url:"",isUrlEditable:!0}}get menuPosition(){return{x:this.position.x+320-12-2,y:this.position.y+100}}onSpecialLink(e){const{detail:t}=e,i=Tu(t);i&&(this.link.url=i.url,this.link.label=i.label,this.link.isUrlEditable=i.isUrlEditable)}getUrlRepresentation(e){return Iu(e,this.env.model.getters)}openMenu(){this.menu.isOpen=!0}removeLink(){this.link.url="",this.link.isUrlEditable=!0}save(){var e,t;const{col:i,row:o}=this.props.cellPosition,n=this.link.label||this.link.url;this.env.model.dispatch("UPDATE_CELL",{col:i,row:o,sheetId:this.env.model.getters.getActiveSheetId(),content:je(n,this.link.url)}),null===(t=(e=this.props).onClosed)||void 0===t||t.call(e)}cancel(){var e,t;null===(t=(e=this.props).onClosed)||void 0===t||t.call(e)}onKeyDown(e){switch(e.key){case"Enter":this.link.url&&this.save(),e.stopPropagation();break;case"Escape":this.cancel(),e.stopPropagation()}}}Qu.template="o-spreadsheet-LinkEditor",Qu.components={Menu:jn};const Ju={onOpen:(e,t)=>({isOpen:!0,props:{cellPosition:e},Component:Qu,cellCorner:"BottomLeft"})};Qu.props={cellPosition:Object,onClosed:{type:Function,optional:!0}};const eg=new Mn;eg.add("ErrorToolTip",Wu).add("LinkCell",Yu).add("LinkEditor",Ju).add("FilterMenu",ju);const tg=new Mn;class ig extends t.Component{constructor(){super(...arguments),this.menuState=t.useState({isOpen:!1,position:null}),this.imageContainerRef=t.useRef("o-image"),this.menuButtonRef=t.useRef("menuButton"),this.menuButtonPosition=Pn(this.menuButtonRef),this.position=Pn(this.imageContainerRef),this.menuItems=_n([{id:"copy",name:s("Copy"),description:"Ctrl+C",action:async()=>{this.env.model.dispatch("SELECT_FIGURE",{id:this.figureId}),this.env.model.dispatch("COPY"),await this.env.clipboard.write(this.env.model.getters.getClipboardContent())}},{id:"cut",name:s("Cut"),description:"Ctrl+X",action:async()=>{this.env.model.dispatch("SELECT_FIGURE",{id:this.figureId}),this.env.model.dispatch("CUT"),await this.env.clipboard.write(this.env.model.getters.getClipboardContent())}},{id:"reset_size",name:s("Reset size"),action:()=>{const e=this.env.model.getters.getImage(this.env.model.getters.getActiveSheetId(),this.figureId).size,{height:t,width:i}=os(this.env.model.getters,e);this.env.model.dispatch("UPDATE_FIGURE",{sheetId:this.env.model.getters.getActiveSheetId(),id:this.figureId,height:t,width:i})}},{id:"delete",name:s("Delete image"),description:"delete",action:()=>{this.env.model.dispatch("DELETE_FIGURE",{sheetId:this.env.model.getters.getActiveSheetId(),id:this.figureId})}}])}onContextMenu(e){const t={x:this.position.x+e.offsetX,y:this.position.y+e.offsetY};this.openContextMenu(t)}showMenu(){const e={x:this.menuButtonPosition.x-H,y:this.menuButtonPosition.y};this.openContextMenu(e)}openContextMenu(e){this.menuState.isOpen=!0,this.menuState.position=e}get figureId(){return this.props.figure.id}get getImagePath(){return this.env.model.getters.getImage(this.env.model.getters.getActiveSheetId(),this.figureId).path}}ig.template="o-spreadsheet-ImageFigure",ig.components={Menu:jn},ig.props={figure:Object,onFigureDeleted:Function};const og=new Mn;og.add("chart",{Component:Xn,SidePanelComponent:"ChartPanel"}),og.add("image",{Component:ig,keepRatio:!0,minFigSize:20,borderWidth:0});const ng=(new Mn).add("ADD_COLUMNS_ROWS",(function(e){const t=[];let i=e.base;"after"===e.position&&i++;for(let o=0;o<e.quantity;o++)t.push(o+i);return[{type:"REMOVE_COLUMNS_ROWS",dimension:e.dimension,elements:t,sheetId:e.sheetId}]})).add("REMOVE_COLUMNS_ROWS",(function(e){const t=[],i=[...e.elements].sort(((e,t)=>e-t));for(let o of Be(i)){const i=0===o[0]?0:o[0]-1,n=0===o[0]?"before":"after";t.push({type:"ADD_COLUMNS_ROWS",dimension:e.dimension,quantity:o.length,base:i,sheetId:e.sheetId,position:n})}return t})).add("ADD_MERGE",(function(e){return[{type:"REMOVE_MERGE",sheetId:e.sheetId,target:e.target}]})).add("REMOVE_MERGE",(function(e){return[{type:"ADD_MERGE",sheetId:e.sheetId,target:e.target}]})).add("CREATE_SHEET",(function(e){return[{type:"DELETE_SHEET",sheetId:e.sheetId}]})).add("DELETE_SHEET",(function(e){return[{type:"CREATE_SHEET",sheetId:e.sheetId,position:1}]})).add("DUPLICATE_SHEET",(function(e){return[{type:"DELETE_SHEET",sheetId:e.sheetIdTo}]})).add("CREATE_FIGURE",(function(e){return[{type:"DELETE_FIGURE",id:e.figure.id,sheetId:e.sheetId}]})).add("CREATE_CHART",(function(e){return[{type:"DELETE_FIGURE",id:e.id,sheetId:e.sheetId}]})).add("HIDE_COLUMNS_ROWS",(function(e){return[{type:"UNHIDE_COLUMNS_ROWS",sheetId:e.sheetId,dimension:e.dimension,elements:e.elements}]})).add("UNHIDE_COLUMNS_ROWS",(function(e){return[{type:"HIDE_COLUMNS_ROWS",sheetId:e.sheetId,dimension:e.dimension,elements:e.elements}]}));for(const e of xo.values())ng.contains(e)||ng.add(e,sg);function sg(e){return[e]}function rg(e,t,i){const o=e.model.getters.getActiveSheetId(),n="COL"===t?"FREEZE_COLUMNS":"FREEZE_ROWS";e.model.dispatch(n,{sheetId:o,quantity:i}).isCancelledBecause(65)&&e.raiseError(Ko)}const ag=new kn;ag.add("file",{name:s("File"),sequence:10}).add("edit",{name:s("Edit"),sequence:20}).add("view",{name:s("View"),sequence:30}).add("insert",{name:s("Insert"),sequence:40}).add("format",{name:s("Format"),sequence:50}).add("data",{name:s("Data"),sequence:60}).addChild("save",["file"],{name:s("Save"),description:"Ctrl+S",sequence:10,action:()=>console.log("Not implemented")}).addChild("undo",["edit"],{name:s("Undo"),description:"Ctrl+Z",sequence:10,action:e=>e.model.dispatch("REQUEST_UNDO")}).addChild("redo",["edit"],{name:s("Redo"),description:"Ctrl+Y",sequence:20,action:e=>e.model.dispatch("REQUEST_REDO"),separator:!0}).addChild("copy",["edit"],{name:s("Copy"),description:"Ctrl+C",sequence:30,isReadonlyAllowed:!0,action:us}).addChild("cut",["edit"],{name:s("Cut"),description:"Ctrl+X",sequence:40,action:gs}).addChild("paste",["edit"],{name:s("Paste"),description:"Ctrl+V",sequence:50,action:ps}).addChild("paste_special",["edit"],{name:s("Paste special"),sequence:60,separator:!0,isVisible:bs}).addChild("paste_special_value",["edit","paste_special"],{name:s("Paste value only"),sequence:10,action:ms}).addChild("paste_special_format",["edit","paste_special"],{name:s("Paste format only"),sequence:20,action:vs}).addChild("sort_range",["data"],{name:s("Sort range"),sequence:20,isVisible:Ls,separator:!0}).addChild("sort_ascending",["data","sort_range"],{name:s("Ascending (A ⟶ Z)"),sequence:10,action:Ds}).addChild("sort_descending",["data","sort_range"],{name:s("Descending (Z ⟶ A)"),sequence:20,action:ks}).addChild("find_and_replace",["edit"],{name:s("Find and replace"),description:"Ctrl+H",sequence:65,isReadonlyAllowed:!0,action:e=>{e.openSidePanel("FindAndReplace",{})},separator:!0}).addChild("edit_delete_cell_values",["edit"],{name:s("Delete values"),sequence:70,action:e=>e.model.dispatch("DELETE_CONTENT",{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones()})}).addChild("edit_delete_row",["edit"],{name:Ss,sequence:80,action:Cs}).addChild("edit_delete_column",["edit"],{name:Es,sequence:90,action:ws}).addChild("edit_delete_cell_shift_up",["edit"],{name:s("Delete cell and shift up"),sequence:93,action:Is}).addChild("edit_delete_cell_shift_left",["edit"],{name:s("Delete cell and shift left"),sequence:97,action:Rs}).addChild("edit_unhide_columns",["edit"],{name:s("Unhide all columns"),sequence:100,action:e=>{const t=e.model.getters.getActiveSheetId();e.model.dispatch("UNHIDE_COLUMNS_ROWS",{sheetId:t,dimension:"COL",elements:Array.from(Array(e.model.getters.getNumberCols(t)).keys())})},isVisible:e=>e.model.getters.getHiddenColsGroups(e.model.getters.getActiveSheetId()).length>0}).addChild("edit_unhide_rows",["edit"],{name:s("Unhide all rows"),sequence:100,action:e=>{const t=e.model.getters.getActiveSheetId();e.model.dispatch("UNHIDE_COLUMNS_ROWS",{sheetId:t,dimension:"ROW",elements:Array.from(Array(e.model.getters.getNumberRows(t)).keys())})},isVisible:e=>e.model.getters.getHiddenRowsGroups(e.model.getters.getActiveSheetId()).length>0}).addChild("insert_row_before",["insert"],{name:e=>{const t=cs(e);return 1===t?s("Row above"):s("%s Rows above",t.toString())},sequence:10,action:Ts,isVisible:e=>0===e.model.getters.getActiveCols().size}).addChild("insert_row_after",["insert"],{name:e=>{const t=cs(e);return 1===t?s("Row below"):s("%s Rows below",t.toString())},sequence:20,action:As,isVisible:e=>0===e.model.getters.getActiveCols().size,separator:!0}).addChild("insert_column_before",["insert"],{name:e=>{const t=ls(e);return 1===t?s("Column left"):s("%s Columns left",t.toString())},sequence:30,action:Ms,isVisible:e=>0===e.model.getters.getActiveRows().size}).addChild("insert_column_after",["insert"],{name:e=>{const t=ls(e);return 1===t?s("Column right"):s("%s Columns right",t.toString())},sequence:40,action:Os,isVisible:e=>0===e.model.getters.getActiveRows().size,separator:!0}).addChild("insert_insert_cell_shift_down",["insert"],{name:s("Insert cells and shift down"),sequence:43,action:ys}).addChild("insert_insert_cell_shift_right",["insert"],{name:s("Insert cells and shift right"),sequence:47,action:xs,separator:!0}).addChild("insert_chart",["insert"],{name:s("Chart"),sequence:50,action:e=>{const t=e.model.getters,i=e.model.uuidGenerator.uuidv4(),o=t.getActiveSheetId();1===to(e.model.getters.getSelectedZone())&&e.model.selection.selectTableAroundSelection();const n={width:536,height:335},s=function(e,t){const{x:i,y:o}=e.getMainViewportCoordinates(),{scrollX:n,scrollY:s}=e.getActiveSheetScrollInfo(),{width:r,height:a}=e.getVisibleRect(e.getActiveMainViewport());return{x:i+n+Math.max(0,(r-t.width)/2),y:o+s+Math.max(0,(a-t.height)/2)}}(t,n);e.model.dispatch("CREATE_CHART",{sheetId:o,id:i,position:s,size:n,definition:is(e.model.getters.getSelectedZone(),e.model.getters)}).isSuccessful&&(e.model.dispatch("SELECT_FIGURE",{id:i}),e.openSidePanel("ChartPanel"))}}).addChild("insert_image",["insert"],{name:s("Image"),sequence:55,action:async e=>{if(e.imageProvider){const t=e.model.getters.getActiveSheetId(),i=e.model.uuidGenerator.uuidv4(),o=await async function(e){try{return await e.imageProvider.requestImage()}catch{return void e.raiseError(s("An unexpected error occurred during the image transfer"))}}(e);if(!o)throw new Error("No image provider was given to the environment");const n=os(e.model.getters,o.size),r=function(e,t){const{x:i,y:o}=e.getMainViewportCoordinates(),{scrollX:n,scrollY:s}=e.getActiveSheetScrollInfo(),r=e.getSheetViewDimension(),a=e.getVisibleRect(e.getActiveMainViewport()),l=Math.min(a.width,r.width-i),c=Math.min(a.height,r.height-o);return{x:i+n+Math.max(0,(l-t.width)/2),y:o+s+Math.max(0,(c-t.height)/2)}}(e.model.getters,n);e.model.dispatch("CREATE_IMAGE",{sheetId:t,figureId:i,position:r,size:n,definition:o})}},isVisible:e=>void 0!==e.imageProvider}).addChild("insert_function",["insert"],{name:s("Function"),sequence:60}).addChild("insert_function_sum",["insert","insert_function"],{name:s("SUM"),action:e=>e.startCellEdition("=SUM("),sequence:0}).addChild("insert_function_average",["insert","insert_function"],{name:s("AVERAGE"),action:e=>e.startCellEdition("=AVERAGE("),sequence:10}).addChild("insert_function_count",["insert","insert_function"],{name:s("COUNT"),action:e=>e.startCellEdition("=COUNT("),sequence:20}).addChild("insert_function_max",["insert","insert_function"],{name:s("MAX"),action:e=>e.startCellEdition("=MAX("),sequence:30}).addChild("insert_function_min",["insert","insert_function"],{name:s("MIN"),action:e=>e.startCellEdition("=MIN("),sequence:40,separator:!0}).addChild("categorie_function_all",["insert","insert_function"],{name:s("All"),sequence:50}).addChild("all_function_list",["insert","insert_function","categorie_function_all"],(()=>lg(iu.getKeys()))).addChild("categories_function_list",["insert","insert_function"],(()=>{const e=iu.content;return[...new Set(iu.getAll().map((e=>e.category)))].filter(et).sort().map(((t,i)=>{const o=Object.keys(e).filter((i=>e[i].category===t));return{name:t,sequence:60+10*i,children:lg(o)}}))})).addChild("insert_link",["insert"],{name:s("Link"),separator:!0,sequence:70,action:_s}).addChild("insert_sheet",["insert"],{name:s("New sheet"),sequence:80,action:e=>{const t=e.model.getters.getActiveSheetId(),i=e.model.getters.getSheetIds().indexOf(t)+1,o=e.model.uuidGenerator.uuidv4();e.model.dispatch("CREATE_SHEET",{sheetId:o,position:i}),e.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:t,sheetIdTo:o})},separator:!0}).addChild("unfreeze_panes",["view"],{name:s("Unfreeze"),sequence:4,isVisible:e=>{const{xSplit:t,ySplit:i}=e.model.getters.getPaneDivisions(e.model.getters.getActiveSheetId());return t+i>0},action:e=>e.model.dispatch("UNFREEZE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId()})}).addChild("freeze_panes",["view"],{name:s("Freeze"),sequence:5,separator:!0}).addChild("unfreeze_rows",["view","freeze_panes"],{name:s("No rows"),action:e=>e.model.dispatch("UNFREEZE_ROWS",{sheetId:e.model.getters.getActiveSheetId()}),isReadonlyAllowed:!0,sequence:5,isVisible:e=>!!e.model.getters.getPaneDivisions(e.model.getters.getActiveSheetId()).ySplit}).addChild("freeze_first_row",["view","freeze_panes"],{name:s("1 row"),action:e=>rg(e,"ROW",1),isReadonlyAllowed:!0,sequence:10}).addChild("freeze_second_row",["view","freeze_panes"],{name:s("2 rows"),action:e=>rg(e,"ROW",2),isReadonlyAllowed:!0,sequence:15}).addChild("freeze_current_row",["view","freeze_panes"],{name:s("Up to current row"),action:e=>{const{bottom:t}=e.model.getters.getSelectedZone();rg(e,"ROW",t+1)},isReadonlyAllowed:!0,sequence:20,separator:!0}).addChild("unfreeze_columns",["view","freeze_panes"],{name:s("No columns"),action:e=>e.model.dispatch("UNFREEZE_COLUMNS",{sheetId:e.model.getters.getActiveSheetId()}),isReadonlyAllowed:!0,sequence:25,isVisible:e=>!!e.model.getters.getPaneDivisions(e.model.getters.getActiveSheetId()).xSplit}).addChild("freeze_first_col",["view","freeze_panes"],{name:s("1 column"),action:e=>rg(e,"COL",1),isReadonlyAllowed:!0,sequence:30}).addChild("freeze_second_col",["view","freeze_panes"],{name:s("2 columns"),action:e=>rg(e,"COL",2),isReadonlyAllowed:!0,sequence:35}).addChild("freeze_current_col",["view","freeze_panes"],{name:s("Up to current column"),action:e=>{const{right:t}=e.model.getters.getSelectedZone();rg(e,"COL",t+1)},isReadonlyAllowed:!0,sequence:40}).addChild("view_gridlines",["view"],{name:e=>e.model.getters.getGridLinesVisibility(e.model.getters.getActiveSheetId())?s("Hide gridlines"):s("Show gridlines"),action:e=>{const t=e.model.getters.getActiveSheetId();e.model.dispatch("SET_GRID_LINES_VISIBILITY",{sheetId:t,areGridLinesVisible:!e.model.getters.getGridLinesVisibility(t)})},sequence:10}).addChild("view_formulas",["view"],{name:e=>e.model.getters.shouldShowFormulas()?s("Hide formulas"):s("Show formulas"),action:e=>e.model.dispatch("SET_FORMULA_VISIBILITY",{show:!e.model.getters.shouldShowFormulas()}),isReadonlyAllowed:!0,sequence:15}).addChild("format_number",["format"],{name:s("Numbers"),sequence:10,separator:!0}).addChild("format_number_automatic",["format","format_number"],{name:Xo.Automatic,sequence:10,separator:!0,action:e=>hs(e,"")}).addChild("format_number_number",["format","format_number"],{name:Xo.Number,description:"1,000.12",sequence:20,action:e=>hs(e,"#,##0.00")}).addChild("format_number_percent",["format","format_number"],{name:Xo.Percent,description:"10.12%",sequence:30,separator:!0,action:e=>hs(e,"0.00%")}).addChild("format_number_currency",["format","format_number"],{name:Xo.Currency,description:"$1,000.12",sequence:37,action:e=>hs(e,"[$$]#,##0.00")}).addChild("format_number_currency_rounded",["format","format_number"],{name:Xo.CurrencyRounded,description:"$1,000",sequence:38,action:e=>hs(e,"[$$]#,##0")}).addChild("format_custom_currency",["format","format_number"],{name:Xo.CustomCurrency,sequence:39,separator:!0,isVisible:e=>void 0!==e.loadCurrencies,action:e=>{e.openSidePanel("CustomCurrency",{})}}).addChild("format_number_date",["format","format_number"],{name:Xo.Date,description:"9/26/2008",sequence:40,action:e=>hs(e,"m/d/yyyy")}).addChild("format_number_time",["format","format_number"],{name:Xo.Time,description:"10:43:00 PM",sequence:50,action:e=>hs(e,"hh:mm:ss a")}).addChild("format_number_date_time",["format","format_number"],{name:Xo.DateTime,description:"9/26/2008 22:43:00",sequence:60,action:e=>hs(e,"m/d/yyyy hh:mm:ss")}).addChild("format_number_duration",["format","format_number"],{name:Xo.Duration,description:"27:51:38",sequence:70,separator:!0,action:e=>hs(e,"hhhh:mm:ss")}).addChild("format_bold",["format"],{name:s("Bold"),sequence:20,description:"Ctrl+B",action:e=>ds(e,{bold:!e.model.getters.getCurrentStyle().bold})}).addChild("format_italic",["format"],{name:s("Italic"),sequence:30,description:"Ctrl+I",action:e=>ds(e,{italic:!e.model.getters.getCurrentStyle().italic})}).addChild("format_underline",["format"],{name:s("Underline"),description:"Ctrl+U",sequence:40,action:e=>ds(e,{underline:!e.model.getters.getCurrentStyle().underline})}).addChild("format_strikethrough",["format"],{name:s("Strikethrough"),sequence:50,action:e=>ds(e,{strikethrough:!e.model.getters.getCurrentStyle().strikethrough}),separator:!0}).addChild("format_font_size",["format"],{name:s("Font size"),sequence:60,separator:!0}).addChild("format_alignment",["format"],{name:s("Alignment"),sequence:70}).addChild("format_alignment_left",["format","format_alignment"],{name:"Left",sequence:10,action:e=>ds(e,{align:"left"})}).addChild("format_alignment_center",["format","format_alignment"],{name:"Center",sequence:20,action:e=>ds(e,{align:"center"})}).addChild("format_alignment_right",["format","format_alignment"],{name:"Right",sequence:30,action:e=>ds(e,{align:"right"}),separator:!0}).addChild("format_alignment_top",["format","format_alignment"],{name:"Top",sequence:40,action:e=>ds(e,{verticalAlign:"top"})}).addChild("format_alignment_middle",["format","format_alignment"],{name:"Middle",sequence:50,action:e=>ds(e,{verticalAlign:"middle"})}).addChild("format_alignment_bottom",["format","format_alignment"],{name:"Bottom",sequence:60,action:e=>ds(e,{verticalAlign:"bottom"}),separator:!0}).addChild("format_wrapping",["format"],{name:s("Wrapping"),sequence:80,separator:!0}).addChild("format_wrapping_overflow",["format","format_wrapping"],{name:s("Overflow"),sequence:10,action:e=>ds(e,{wrapping:"overflow"})}).addChild("format_wrapping_wrap",["format","format_wrapping"],{name:s("Wrap"),sequence:20,action:e=>ds(e,{wrapping:"wrap"})}).addChild("format_wrapping_clip",["format","format_wrapping"],{name:s("Clip"),sequence:30,action:e=>ds(e,{wrapping:"clip"})}).addChild("format_cf",["format"],{name:s("Conditional formatting"),sequence:90,action:Ns,separator:!0}).addChild("format_clearFormat",["format"],{name:s("Clear formatting"),sequence:100,action:e=>{e.model.dispatch("CLEAR_FORMATTING",{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones()})},separator:!0}).addChild("add_data_filter",["data"],{name:s("Create filter"),sequence:10,action:e=>{const t=e.model.getters.getActiveSheetId(),i=e.model.getters.getSelection().zones;as(e,t,i)},isVisible:e=>!Fs(e),isEnabled:e=>(e=>io(...e.model.getters.getSelectedZones()))(e)}).addChild("remove_data_filter",["data"],{name:s("Remove filter"),sequence:10,action:e=>{const t=e.model.getters.getActiveSheetId();e.model.dispatch("REMOVE_FILTER_TABLE",{sheetId:t,target:e.model.getters.getSelectedZones()})},isVisible:Fs});for(let e of he)ag.addChild(`format_font_size_${e}`,["format","format_font_size"],{name:e.toString(),sequence:e,action:t=>ds(t,{fontSize:e})});function lg(e){return e.sort().map(((e,t)=>({name:e,sequence:10*t,action:t=>t.startCellEdition(`=${e}(`)})))}const cg=new class extends Mn{addTransformation(e,t,i){for(let o of t)this.content[o]||(this.content[o]=new Map),this.content[o].set(e,i);return this}getTransformation(e,t){return this.content[e]&&this.content[e].get(t)}},hg=new Oi;ro`
516
+ `;class Qu extends t.Component{constructor(){super(...arguments),this.menuItems=Ku.getMenuItems(),this.link=t.useState(this.defaultState),this.menu=t.useState({isOpen:!1}),this.linkEditorRef=t.useRef("linkEditor"),this.position=Pn(this.linkEditorRef),this.urlInput=t.useRef("urlInput")}setup(){t.onMounted((()=>{var e;return null===(e=this.urlInput.el)||void 0===e?void 0:e.focus()}))}get defaultState(){const{col:e,row:t}=this.props.cellPosition,i=this.env.model.getters.getActiveSheetId(),o=this.env.model.getters.getEvaluatedCell({sheetId:i,col:e,row:t});return o.link?{url:o.link.url,label:o.formattedValue,isUrlEditable:o.link.isUrlEditable}:{label:o.formattedValue,url:"",isUrlEditable:!0}}get menuPosition(){return{x:this.position.x+320-12-2,y:this.position.y+100}}onSpecialLink(e){const{detail:t}=e,i=Tu(t);i&&(this.link.url=i.url,this.link.label=i.label,this.link.isUrlEditable=i.isUrlEditable)}getUrlRepresentation(e){return Iu(e,this.env.model.getters)}openMenu(){this.menu.isOpen=!0}removeLink(){this.link.url="",this.link.isUrlEditable=!0}save(){var e,t;const{col:i,row:o}=this.props.cellPosition,n=this.link.label||this.link.url;this.env.model.dispatch("UPDATE_CELL",{col:i,row:o,sheetId:this.env.model.getters.getActiveSheetId(),content:je(n,this.link.url)}),null===(t=(e=this.props).onClosed)||void 0===t||t.call(e)}cancel(){var e,t;null===(t=(e=this.props).onClosed)||void 0===t||t.call(e)}onKeyDown(e){switch(e.key){case"Enter":this.link.url&&this.save(),e.stopPropagation();break;case"Escape":this.cancel(),e.stopPropagation()}}}Qu.template="o-spreadsheet-LinkEditor",Qu.components={Menu:jn};const Ju={onOpen:(e,t)=>({isOpen:!0,props:{cellPosition:e},Component:Qu,cellCorner:"BottomLeft"})};Qu.props={cellPosition:Object,onClosed:{type:Function,optional:!0}};const eg=new Mn;eg.add("ErrorToolTip",Wu).add("LinkCell",Yu).add("LinkEditor",Ju).add("FilterMenu",ju);const tg=new Mn;class ig extends t.Component{constructor(){super(...arguments),this.menuState=t.useState({isOpen:!1,position:null}),this.imageContainerRef=t.useRef("o-image"),this.menuButtonRef=t.useRef("menuButton"),this.menuButtonRect=Pn(this.menuButtonRef),this.position=Pn(this.imageContainerRef),this.menuItems=_n([{id:"copy",name:s("Copy"),description:"Ctrl+C",action:async()=>{this.env.model.dispatch("SELECT_FIGURE",{id:this.figureId}),this.env.model.dispatch("COPY"),await this.env.clipboard.write(this.env.model.getters.getClipboardContent())}},{id:"cut",name:s("Cut"),description:"Ctrl+X",action:async()=>{this.env.model.dispatch("SELECT_FIGURE",{id:this.figureId}),this.env.model.dispatch("CUT"),await this.env.clipboard.write(this.env.model.getters.getClipboardContent())}},{id:"reset_size",name:s("Reset size"),action:()=>{const e=this.env.model.getters.getImage(this.env.model.getters.getActiveSheetId(),this.figureId).size,{height:t,width:i}=os(this.env.model.getters,e);this.env.model.dispatch("UPDATE_FIGURE",{sheetId:this.env.model.getters.getActiveSheetId(),id:this.figureId,height:t,width:i})}},{id:"delete",name:s("Delete image"),description:"delete",action:()=>{this.env.model.dispatch("DELETE_FIGURE",{sheetId:this.env.model.getters.getActiveSheetId(),id:this.figureId})}}])}onContextMenu(e){const t={x:this.position.x+e.offsetX,y:this.position.y+e.offsetY};this.openContextMenu(t)}showMenu(){const{x:e,y:t,width:i}=this.menuButtonRect,o={x:e>=H?e-H:e+i,y:t};this.openContextMenu(o)}openContextMenu(e){this.menuState.isOpen=!0,this.menuState.position=e}get figureId(){return this.props.figure.id}get getImagePath(){return this.env.model.getters.getImage(this.env.model.getters.getActiveSheetId(),this.figureId).path}}ig.template="o-spreadsheet-ImageFigure",ig.components={Menu:jn},ig.props={figure:Object,onFigureDeleted:Function};const og=new Mn;og.add("chart",{Component:Xn,SidePanelComponent:"ChartPanel"}),og.add("image",{Component:ig,keepRatio:!0,minFigSize:20,borderWidth:0});const ng=(new Mn).add("ADD_COLUMNS_ROWS",(function(e){const t=[];let i=e.base;"after"===e.position&&i++;for(let o=0;o<e.quantity;o++)t.push(o+i);return[{type:"REMOVE_COLUMNS_ROWS",dimension:e.dimension,elements:t,sheetId:e.sheetId}]})).add("REMOVE_COLUMNS_ROWS",(function(e){const t=[],i=[...e.elements].sort(((e,t)=>e-t));for(let o of Be(i)){const i=0===o[0]?0:o[0]-1,n=0===o[0]?"before":"after";t.push({type:"ADD_COLUMNS_ROWS",dimension:e.dimension,quantity:o.length,base:i,sheetId:e.sheetId,position:n})}return t})).add("ADD_MERGE",(function(e){return[{type:"REMOVE_MERGE",sheetId:e.sheetId,target:e.target}]})).add("REMOVE_MERGE",(function(e){return[{type:"ADD_MERGE",sheetId:e.sheetId,target:e.target}]})).add("CREATE_SHEET",(function(e){return[{type:"DELETE_SHEET",sheetId:e.sheetId}]})).add("DELETE_SHEET",(function(e){return[{type:"CREATE_SHEET",sheetId:e.sheetId,position:1}]})).add("DUPLICATE_SHEET",(function(e){return[{type:"DELETE_SHEET",sheetId:e.sheetIdTo}]})).add("CREATE_FIGURE",(function(e){return[{type:"DELETE_FIGURE",id:e.figure.id,sheetId:e.sheetId}]})).add("CREATE_CHART",(function(e){return[{type:"DELETE_FIGURE",id:e.id,sheetId:e.sheetId}]})).add("HIDE_COLUMNS_ROWS",(function(e){return[{type:"UNHIDE_COLUMNS_ROWS",sheetId:e.sheetId,dimension:e.dimension,elements:e.elements}]})).add("UNHIDE_COLUMNS_ROWS",(function(e){return[{type:"HIDE_COLUMNS_ROWS",sheetId:e.sheetId,dimension:e.dimension,elements:e.elements}]}));for(const e of xo.values())ng.contains(e)||ng.add(e,sg);function sg(e){return[e]}function rg(e,t,i){const o=e.model.getters.getActiveSheetId(),n="COL"===t?"FREEZE_COLUMNS":"FREEZE_ROWS";e.model.dispatch(n,{sheetId:o,quantity:i}).isCancelledBecause(65)&&e.raiseError(Ko)}const ag=new kn;ag.add("file",{name:s("File"),sequence:10}).add("edit",{name:s("Edit"),sequence:20}).add("view",{name:s("View"),sequence:30}).add("insert",{name:s("Insert"),sequence:40}).add("format",{name:s("Format"),sequence:50}).add("data",{name:s("Data"),sequence:60}).addChild("save",["file"],{name:s("Save"),description:"Ctrl+S",sequence:10,action:()=>console.log("Not implemented")}).addChild("undo",["edit"],{name:s("Undo"),description:"Ctrl+Z",sequence:10,action:e=>e.model.dispatch("REQUEST_UNDO")}).addChild("redo",["edit"],{name:s("Redo"),description:"Ctrl+Y",sequence:20,action:e=>e.model.dispatch("REQUEST_REDO"),separator:!0}).addChild("copy",["edit"],{name:s("Copy"),description:"Ctrl+C",sequence:30,isReadonlyAllowed:!0,action:us}).addChild("cut",["edit"],{name:s("Cut"),description:"Ctrl+X",sequence:40,action:gs}).addChild("paste",["edit"],{name:s("Paste"),description:"Ctrl+V",sequence:50,action:ps}).addChild("paste_special",["edit"],{name:s("Paste special"),sequence:60,separator:!0,isVisible:bs}).addChild("paste_special_value",["edit","paste_special"],{name:s("Paste value only"),sequence:10,action:ms}).addChild("paste_special_format",["edit","paste_special"],{name:s("Paste format only"),sequence:20,action:vs}).addChild("sort_range",["data"],{name:s("Sort range"),sequence:20,isVisible:Ls,separator:!0}).addChild("sort_ascending",["data","sort_range"],{name:s("Ascending (A ⟶ Z)"),sequence:10,action:Ds}).addChild("sort_descending",["data","sort_range"],{name:s("Descending (Z ⟶ A)"),sequence:20,action:ks}).addChild("find_and_replace",["edit"],{name:s("Find and replace"),description:"Ctrl+H",sequence:65,isReadonlyAllowed:!0,action:e=>{e.openSidePanel("FindAndReplace",{})},separator:!0}).addChild("edit_delete_cell_values",["edit"],{name:s("Delete values"),sequence:70,action:e=>e.model.dispatch("DELETE_CONTENT",{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones()})}).addChild("edit_delete_row",["edit"],{name:Ss,sequence:80,action:Cs}).addChild("edit_delete_column",["edit"],{name:Es,sequence:90,action:ws}).addChild("edit_delete_cell_shift_up",["edit"],{name:s("Delete cell and shift up"),sequence:93,action:Is}).addChild("edit_delete_cell_shift_left",["edit"],{name:s("Delete cell and shift left"),sequence:97,action:Rs}).addChild("edit_unhide_columns",["edit"],{name:s("Unhide all columns"),sequence:100,action:e=>{const t=e.model.getters.getActiveSheetId();e.model.dispatch("UNHIDE_COLUMNS_ROWS",{sheetId:t,dimension:"COL",elements:Array.from(Array(e.model.getters.getNumberCols(t)).keys())})},isVisible:e=>e.model.getters.getHiddenColsGroups(e.model.getters.getActiveSheetId()).length>0}).addChild("edit_unhide_rows",["edit"],{name:s("Unhide all rows"),sequence:100,action:e=>{const t=e.model.getters.getActiveSheetId();e.model.dispatch("UNHIDE_COLUMNS_ROWS",{sheetId:t,dimension:"ROW",elements:Array.from(Array(e.model.getters.getNumberRows(t)).keys())})},isVisible:e=>e.model.getters.getHiddenRowsGroups(e.model.getters.getActiveSheetId()).length>0}).addChild("insert_row_before",["insert"],{name:e=>{const t=cs(e);return 1===t?s("Row above"):s("%s Rows above",t.toString())},sequence:10,action:Ts,isVisible:e=>0===e.model.getters.getActiveCols().size}).addChild("insert_row_after",["insert"],{name:e=>{const t=cs(e);return 1===t?s("Row below"):s("%s Rows below",t.toString())},sequence:20,action:As,isVisible:e=>0===e.model.getters.getActiveCols().size,separator:!0}).addChild("insert_column_before",["insert"],{name:e=>{const t=ls(e);return 1===t?s("Column left"):s("%s Columns left",t.toString())},sequence:30,action:Ms,isVisible:e=>0===e.model.getters.getActiveRows().size}).addChild("insert_column_after",["insert"],{name:e=>{const t=ls(e);return 1===t?s("Column right"):s("%s Columns right",t.toString())},sequence:40,action:Os,isVisible:e=>0===e.model.getters.getActiveRows().size,separator:!0}).addChild("insert_insert_cell_shift_down",["insert"],{name:s("Insert cells and shift down"),sequence:43,action:ys}).addChild("insert_insert_cell_shift_right",["insert"],{name:s("Insert cells and shift right"),sequence:47,action:xs,separator:!0}).addChild("insert_chart",["insert"],{name:s("Chart"),sequence:50,action:e=>{const t=e.model.getters,i=e.model.uuidGenerator.uuidv4(),o=t.getActiveSheetId();1===to(e.model.getters.getSelectedZone())&&e.model.selection.selectTableAroundSelection();const n={width:536,height:335},s=function(e,t){const{x:i,y:o}=e.getMainViewportCoordinates(),{scrollX:n,scrollY:s}=e.getActiveSheetScrollInfo(),{width:r,height:a}=e.getVisibleRect(e.getActiveMainViewport());return{x:i+n+Math.max(0,(r-t.width)/2),y:o+s+Math.max(0,(a-t.height)/2)}}(t,n);e.model.dispatch("CREATE_CHART",{sheetId:o,id:i,position:s,size:n,definition:is(e.model.getters.getSelectedZone(),e.model.getters)}).isSuccessful&&(e.model.dispatch("SELECT_FIGURE",{id:i}),e.openSidePanel("ChartPanel"))}}).addChild("insert_image",["insert"],{name:s("Image"),sequence:55,action:async e=>{if(e.imageProvider){const t=e.model.getters.getActiveSheetId(),i=e.model.uuidGenerator.uuidv4(),o=await async function(e){try{return await e.imageProvider.requestImage()}catch{return void e.raiseError(s("An unexpected error occurred during the image transfer"))}}(e);if(!o)throw new Error("No image provider was given to the environment");const n=os(e.model.getters,o.size),r=function(e,t){const{x:i,y:o}=e.getMainViewportCoordinates(),{scrollX:n,scrollY:s}=e.getActiveSheetScrollInfo(),r=e.getSheetViewDimension(),a=e.getVisibleRect(e.getActiveMainViewport()),l=Math.min(a.width,r.width-i),c=Math.min(a.height,r.height-o);return{x:i+n+Math.max(0,(l-t.width)/2),y:o+s+Math.max(0,(c-t.height)/2)}}(e.model.getters,n);e.model.dispatch("CREATE_IMAGE",{sheetId:t,figureId:i,position:r,size:n,definition:o})}},isVisible:e=>void 0!==e.imageProvider}).addChild("insert_function",["insert"],{name:s("Function"),sequence:60}).addChild("insert_function_sum",["insert","insert_function"],{name:s("SUM"),action:e=>e.startCellEdition("=SUM("),sequence:0}).addChild("insert_function_average",["insert","insert_function"],{name:s("AVERAGE"),action:e=>e.startCellEdition("=AVERAGE("),sequence:10}).addChild("insert_function_count",["insert","insert_function"],{name:s("COUNT"),action:e=>e.startCellEdition("=COUNT("),sequence:20}).addChild("insert_function_max",["insert","insert_function"],{name:s("MAX"),action:e=>e.startCellEdition("=MAX("),sequence:30}).addChild("insert_function_min",["insert","insert_function"],{name:s("MIN"),action:e=>e.startCellEdition("=MIN("),sequence:40,separator:!0}).addChild("categorie_function_all",["insert","insert_function"],{name:s("All"),sequence:50}).addChild("all_function_list",["insert","insert_function","categorie_function_all"],(()=>lg(iu.getKeys()))).addChild("categories_function_list",["insert","insert_function"],(()=>{const e=iu.content;return[...new Set(iu.getAll().map((e=>e.category)))].filter(et).sort().map(((t,i)=>{const o=Object.keys(e).filter((i=>e[i].category===t));return{name:t,sequence:60+10*i,children:lg(o)}}))})).addChild("insert_link",["insert"],{name:s("Link"),separator:!0,sequence:70,action:_s}).addChild("insert_sheet",["insert"],{name:s("New sheet"),sequence:80,action:e=>{const t=e.model.getters.getActiveSheetId(),i=e.model.getters.getSheetIds().indexOf(t)+1,o=e.model.uuidGenerator.uuidv4();e.model.dispatch("CREATE_SHEET",{sheetId:o,position:i}),e.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:t,sheetIdTo:o})},separator:!0}).addChild("unfreeze_panes",["view"],{name:s("Unfreeze"),sequence:4,isVisible:e=>{const{xSplit:t,ySplit:i}=e.model.getters.getPaneDivisions(e.model.getters.getActiveSheetId());return t+i>0},action:e=>e.model.dispatch("UNFREEZE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId()})}).addChild("freeze_panes",["view"],{name:s("Freeze"),sequence:5,separator:!0}).addChild("unfreeze_rows",["view","freeze_panes"],{name:s("No rows"),action:e=>e.model.dispatch("UNFREEZE_ROWS",{sheetId:e.model.getters.getActiveSheetId()}),isReadonlyAllowed:!0,sequence:5,isVisible:e=>!!e.model.getters.getPaneDivisions(e.model.getters.getActiveSheetId()).ySplit}).addChild("freeze_first_row",["view","freeze_panes"],{name:s("1 row"),action:e=>rg(e,"ROW",1),isReadonlyAllowed:!0,sequence:10}).addChild("freeze_second_row",["view","freeze_panes"],{name:s("2 rows"),action:e=>rg(e,"ROW",2),isReadonlyAllowed:!0,sequence:15}).addChild("freeze_current_row",["view","freeze_panes"],{name:s("Up to current row"),action:e=>{const{bottom:t}=e.model.getters.getSelectedZone();rg(e,"ROW",t+1)},isReadonlyAllowed:!0,sequence:20,separator:!0}).addChild("unfreeze_columns",["view","freeze_panes"],{name:s("No columns"),action:e=>e.model.dispatch("UNFREEZE_COLUMNS",{sheetId:e.model.getters.getActiveSheetId()}),isReadonlyAllowed:!0,sequence:25,isVisible:e=>!!e.model.getters.getPaneDivisions(e.model.getters.getActiveSheetId()).xSplit}).addChild("freeze_first_col",["view","freeze_panes"],{name:s("1 column"),action:e=>rg(e,"COL",1),isReadonlyAllowed:!0,sequence:30}).addChild("freeze_second_col",["view","freeze_panes"],{name:s("2 columns"),action:e=>rg(e,"COL",2),isReadonlyAllowed:!0,sequence:35}).addChild("freeze_current_col",["view","freeze_panes"],{name:s("Up to current column"),action:e=>{const{right:t}=e.model.getters.getSelectedZone();rg(e,"COL",t+1)},isReadonlyAllowed:!0,sequence:40}).addChild("view_gridlines",["view"],{name:e=>e.model.getters.getGridLinesVisibility(e.model.getters.getActiveSheetId())?s("Hide gridlines"):s("Show gridlines"),action:e=>{const t=e.model.getters.getActiveSheetId();e.model.dispatch("SET_GRID_LINES_VISIBILITY",{sheetId:t,areGridLinesVisible:!e.model.getters.getGridLinesVisibility(t)})},sequence:10}).addChild("view_formulas",["view"],{name:e=>e.model.getters.shouldShowFormulas()?s("Hide formulas"):s("Show formulas"),action:e=>e.model.dispatch("SET_FORMULA_VISIBILITY",{show:!e.model.getters.shouldShowFormulas()}),isReadonlyAllowed:!0,sequence:15}).addChild("format_number",["format"],{name:s("Numbers"),sequence:10,separator:!0}).addChild("format_number_automatic",["format","format_number"],{name:Xo.Automatic,sequence:10,separator:!0,action:e=>hs(e,"")}).addChild("format_number_number",["format","format_number"],{name:Xo.Number,description:"1,000.12",sequence:20,action:e=>hs(e,"#,##0.00")}).addChild("format_number_percent",["format","format_number"],{name:Xo.Percent,description:"10.12%",sequence:30,separator:!0,action:e=>hs(e,"0.00%")}).addChild("format_number_currency",["format","format_number"],{name:Xo.Currency,description:"$1,000.12",sequence:37,action:e=>hs(e,"[$$]#,##0.00")}).addChild("format_number_currency_rounded",["format","format_number"],{name:Xo.CurrencyRounded,description:"$1,000",sequence:38,action:e=>hs(e,"[$$]#,##0")}).addChild("format_custom_currency",["format","format_number"],{name:Xo.CustomCurrency,sequence:39,separator:!0,isVisible:e=>void 0!==e.loadCurrencies,action:e=>{e.openSidePanel("CustomCurrency",{})}}).addChild("format_number_date",["format","format_number"],{name:Xo.Date,description:"9/26/2008",sequence:40,action:e=>hs(e,"m/d/yyyy")}).addChild("format_number_time",["format","format_number"],{name:Xo.Time,description:"10:43:00 PM",sequence:50,action:e=>hs(e,"hh:mm:ss a")}).addChild("format_number_date_time",["format","format_number"],{name:Xo.DateTime,description:"9/26/2008 22:43:00",sequence:60,action:e=>hs(e,"m/d/yyyy hh:mm:ss")}).addChild("format_number_duration",["format","format_number"],{name:Xo.Duration,description:"27:51:38",sequence:70,separator:!0,action:e=>hs(e,"hhhh:mm:ss")}).addChild("format_bold",["format"],{name:s("Bold"),sequence:20,description:"Ctrl+B",action:e=>ds(e,{bold:!e.model.getters.getCurrentStyle().bold})}).addChild("format_italic",["format"],{name:s("Italic"),sequence:30,description:"Ctrl+I",action:e=>ds(e,{italic:!e.model.getters.getCurrentStyle().italic})}).addChild("format_underline",["format"],{name:s("Underline"),description:"Ctrl+U",sequence:40,action:e=>ds(e,{underline:!e.model.getters.getCurrentStyle().underline})}).addChild("format_strikethrough",["format"],{name:s("Strikethrough"),sequence:50,action:e=>ds(e,{strikethrough:!e.model.getters.getCurrentStyle().strikethrough}),separator:!0}).addChild("format_font_size",["format"],{name:s("Font size"),sequence:60,separator:!0}).addChild("format_alignment",["format"],{name:s("Alignment"),sequence:70}).addChild("format_alignment_left",["format","format_alignment"],{name:"Left",sequence:10,action:e=>ds(e,{align:"left"})}).addChild("format_alignment_center",["format","format_alignment"],{name:"Center",sequence:20,action:e=>ds(e,{align:"center"})}).addChild("format_alignment_right",["format","format_alignment"],{name:"Right",sequence:30,action:e=>ds(e,{align:"right"}),separator:!0}).addChild("format_alignment_top",["format","format_alignment"],{name:"Top",sequence:40,action:e=>ds(e,{verticalAlign:"top"})}).addChild("format_alignment_middle",["format","format_alignment"],{name:"Middle",sequence:50,action:e=>ds(e,{verticalAlign:"middle"})}).addChild("format_alignment_bottom",["format","format_alignment"],{name:"Bottom",sequence:60,action:e=>ds(e,{verticalAlign:"bottom"}),separator:!0}).addChild("format_wrapping",["format"],{name:s("Wrapping"),sequence:80,separator:!0}).addChild("format_wrapping_overflow",["format","format_wrapping"],{name:s("Overflow"),sequence:10,action:e=>ds(e,{wrapping:"overflow"})}).addChild("format_wrapping_wrap",["format","format_wrapping"],{name:s("Wrap"),sequence:20,action:e=>ds(e,{wrapping:"wrap"})}).addChild("format_wrapping_clip",["format","format_wrapping"],{name:s("Clip"),sequence:30,action:e=>ds(e,{wrapping:"clip"})}).addChild("format_cf",["format"],{name:s("Conditional formatting"),sequence:90,action:Ns,separator:!0}).addChild("format_clearFormat",["format"],{name:s("Clear formatting"),sequence:100,action:e=>{e.model.dispatch("CLEAR_FORMATTING",{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones()})},separator:!0}).addChild("add_data_filter",["data"],{name:s("Create filter"),sequence:10,action:e=>{const t=e.model.getters.getActiveSheetId(),i=e.model.getters.getSelection().zones;as(e,t,i)},isVisible:e=>!Fs(e),isEnabled:e=>(e=>io(...e.model.getters.getSelectedZones()))(e)}).addChild("remove_data_filter",["data"],{name:s("Remove filter"),sequence:10,action:e=>{const t=e.model.getters.getActiveSheetId();e.model.dispatch("REMOVE_FILTER_TABLE",{sheetId:t,target:e.model.getters.getSelectedZones()})},isVisible:Fs});for(let e of he)ag.addChild(`format_font_size_${e}`,["format","format_font_size"],{name:e.toString(),sequence:e,action:t=>ds(t,{fontSize:e})});function lg(e){return e.sort().map(((e,t)=>({name:e,sequence:10*t,action:t=>t.startCellEdition(`=${e}(`)})))}const cg=new class extends Mn{addTransformation(e,t,i){for(let o of t)this.content[o]||(this.content[o]=new Map),this.content[o].set(e,i);return this}getTransformation(e,t){return this.content[e]&&this.content[e].get(t)}},hg=new Oi;ro`
517
517
  .o-selection {
518
518
  .o-selection-input {
519
519
  display: flex;
@@ -2407,4 +2407,4 @@
2407
2407
  <tableParts count="${e.filterTables.length}">
2408
2408
  ${Wm(a)}
2409
2409
  </tableParts>
2410
- `}var XS;!function(e){e[e.Ready=0]="Ready",e[e.Running=1]="Running",e[e.RunningCore=2]="RunningCore",e[e.Finalizing=3]="Finalizing"}(XS||(XS={}));const YS={},KS={MIN_ROW_HEIGHT:10,MIN_COL_WIDTH:5,HEADER_HEIGHT:O,HEADER_WIDTH:N,TOPBAR_HEIGHT:63,BOTTOMBAR_HEIGHT:36,DEFAULT_CELL_WIDTH:_,DEFAULT_CELL_HEIGHT:F,SCROLLBAR_WIDTH:D},QS={autofillModifiersRegistry:Lu,autofillRulesRegistry:Pu,cellMenuRegistry:Ps,colMenuRegistry:Us,linkMenuRegistry:Ku,functionRegistry:iu,featurePluginRegistry:Rb,statefulUIPluginRegistry:Tb,coreViewsPluginRegistry:Ab,corePluginRegistry:Ib,rowMenuRegistry:Vs,sidePanelRegistry:Lg,figureRegistry:og,chartSidePanelComponentRegistry:Tg,chartComponentRegistry:Nn,chartRegistry:On,topbarMenuRegistry:ag,topbarComponentRegistry:Pg,clickableCellRegistry:Mb,otRegistry:cg,inverseCommandRegistry:ng,urlRegistry:Eu,cellPopoverRegistry:eg},JS={arg:Zs,toBoolean:or,toJsDate:nr,toNumber:Qs,toString:er,toXC:Vt,toZone:_i,toCartesian:Ut,numberToLetters:Lt,UuidGenerator:Oi,formatValue:li,computeTextWidth:Le,createEmptyWorkbookData:Uf,createEmptySheet:Pf,createEmptyExcelSheet:Vf,getDefaultChartJsRuntime:on,chartFontColor:zo,ChartColors:Vo,EvaluationError:c,CellErrorLevel:l,getFillingMode:an,rgbaToHex:Et,colorToRGBA:wt,positionToZone:Ji,isDefined:et,lazy:nt},eC={isMarkdownLink:qe,parseMarkdownLink:Xe,markdownLink:je,openLink:Ru,urlRepresentation:Iu},tC={ChartPanel:Ag,ChartFigure:Xn,ChartJsComponent:oo,Grid:op,GridOverlay:Bg,ScorecardChart:go,LineConfigPanel:yg,LineBarPieDesignPanel:Sg,BarConfigPanel:gg,LineBarPieConfigPanel:ug,GaugeChartConfigPanel:Eg,GaugeChartDesignPanel:wg,ScorecardChartConfigPanel:Ig,ScorecardChartDesignPanel:Rg};e.AbstractChart=vo,e.CorePlugin=Bf,e.DATETIME_FORMAT=X,e.DispatchResult=Ro,e.EvaluationError=c,e.Model=class extends Yv{constructor(e={},i={},o=[],n=new Oi,s=!0){super(),this.corePlugins=[],this.featurePlugins=[],this.statefulUIPlugins=[],this.coreViewsPlugins=[],this.isReplayingCommand=!1,this.renderers=[],this.status=0,this.dispatch=(e,t)=>{const i={...t,type:e};let o=this.status;if(this.getters.isReadonly()&&(n=i,!yo.has(n.type)))return new Ro(67);var n;if(!this.session.canApplyOptimisticUpdate())return new Ro(64);switch(o){case 0:const t=this.checkDispatchAllowed(i);if(!t.isSuccessful)return t;this.status=1;const{changes:o,commands:n}=this.state.recordChanges((()=>{Io(i)&&this.state.addCommand(i),this.dispatchToHandlers(this.handlers,i),this.finalize()}));this.session.save(n,o),this.status=0,this.trigger("update");break;case 1:if(Io(i)){const e=this.checkDispatchAllowed(i);if(!e.isSuccessful)return e;this.state.addCommand(i)}this.dispatchToHandlers(this.handlers,i);break;case 3:throw new Error("Cannot dispatch commands in the finalize state");case 2:if(Io(i))throw new Error(`A UI plugin cannot dispatch ${e} while handling a core command`);this.dispatchToHandlers(this.handlers,i)}return Ro.Success},this.dispatchFromCorePlugin=(e,t)=>{const i={...t,type:e},o=this.status;this.status=2;const n=this.isReplayingCommand?[this.range,...this.corePlugins,...this.coreViewsPlugins]:this.handlers;return this.dispatchToHandlers(n,i),this.status=o,Ro.Success},o=kf(e,o);const r=Ff(e,s);this.state=new hS,this.uuidGenerator=n,this.config=this.setupConfig(i),this.session=this.setupSession(r.revisionId),this.history=new aS(this.dispatchFromCorePlugin,this.session),this.coreGetters={},this.range=new Av(this.coreGetters),this.coreGetters.getRangeString=this.range.getRangeString.bind(this.range),this.coreGetters.getRangeFromSheetXC=this.range.getRangeFromSheetXC.bind(this.range),this.coreGetters.createAdaptedRanges=this.range.createAdaptedRanges.bind(this.range),this.coreGetters.getRangeDataFromXc=this.range.getRangeDataFromXc.bind(this.range),this.coreGetters.getRangeDataFromZone=this.range.getRangeDataFromZone.bind(this.range),this.coreGetters.getRangeFromRangeData=this.range.getRangeFromRangeData.bind(this.range),this.coreGetters.getSelectionRangeString=this.range.getSelectionRangeString.bind(this.range),this.getters={isReadonly:()=>"readonly"===this.config.mode||"dashboard"===this.config.mode,isDashboard:()=>"dashboard"===this.config.mode,canUndo:this.history.canUndo.bind(this.history),canRedo:this.history.canRedo.bind(this.history),getClient:this.session.getClient.bind(this.session),getConnectedClients:this.session.getConnectedClients.bind(this.session),isFullySynchronized:this.session.isFullySynchronized.bind(this.session)},this.uuidGenerator.setIsFastStrategy(!0),this.selection=new cS(this.getters),this.corePluginConfig=this.setupCorePluginConfig(),this.uiPluginConfig=this.setupUiPluginConfig();for(let e of Ib.getAll())this.setupCorePlugin(e,r);Object.assign(this.getters,this.coreGetters);for(let e of Tb.getAll())this.statefulUIPlugins.push(this.setupUiPlugin(e));for(let e of Ab.getAll())this.coreViewsPlugins.push(this.setupUiPlugin(e));for(let e of Rb.getAll())this.featurePlugins.push(this.setupUiPlugin(e));this.uuidGenerator.setIsFastStrategy(!1),this.dispatch("START"),this.selection.observe(this,{handleEvent:()=>this.trigger("update")}),this.setupSessionEvents(),this.session.loadInitialMessages(o),this.joinSession(),i.snapshotRequested&&(this.session.snapshot(this.exportData()),this.garbageCollectExternalResources()),t.markRaw(this)}get handlers(){return[this.range,...this.corePlugins,...this.allUIPlugins,this.history]}get allUIPlugins(){return[...this.statefulUIPlugins,...this.coreViewsPlugins,...this.featurePlugins]}joinSession(){this.session.join(this.config.client)}leaveSession(){this.session.leave()}setupUiPlugin(e){const t=new e(this.uiPluginConfig);for(let i of e.getters){if(!(i in t))throw new Error(`Invalid getter name: ${i} for plugin ${t.constructor}`);if(i in this.getters)throw new Error(`Getter "${i}" is already defined.`);this.getters[i]=t[i].bind(t)}const i=e.layers.map((e=>[t,e]));return this.renderers.push(...i),this.renderers.sort(((e,t)=>e[1]-t[1])),t}setupCorePlugin(e,t){const i=new e(this.corePluginConfig);for(let t of e.getters){if(!(t in i))throw new Error(`Invalid getter name: ${t} for plugin ${i.constructor}`);if(t in this.coreGetters)throw new Error(`Getter "${t}" is already defined.`);this.coreGetters[t]=i[t].bind(i)}i.import(t),this.corePlugins.push(i)}onRemoteRevisionReceived({commands:e}){for(let t of e){const e=this.status;this.status=2,this.dispatchToHandlers(this.statefulUIPlugins,t),this.status=e}this.finalize()}setupSession(e){return new sb(sS(e,this.state.recordChanges.bind(this.state),(e=>{this.checkDispatchAllowed(e).isSuccessful&&(this.isReplayingCommand=!0,this.dispatchToHandlers([this.range,...this.corePlugins,...this.coreViewsPlugins],e),this.isReplayingCommand=!1)})),this.config.transportService,e)}setupSessionEvents(){this.session.on("remote-revision-received",this,this.onRemoteRevisionReceived),this.session.on("revision-redone",this,this.finalize),this.session.on("revision-undone",this,this.finalize),this.session.on("unexpected-revision-id",this,(()=>this.trigger("unexpected-revision-id"))),this.session.on("collaborative-event-received",this,(()=>{this.trigger("update")}))}setupConfig(e){const t=e.client||{id:this.uuidGenerator.uuidv4(),name:s("Anonymous").toString()},i=e.transportService||new Yb;return{...e,mode:e.mode||"normal",custom:e.custom||{},external:e.external||{},transportService:i,client:t,moveClient:()=>{},snapshotRequested:!1,notifyUI:e=>this.trigger("notify-ui",e),lazyEvaluation:!("lazyEvaluation"in e)||e.lazyEvaluation}}setupCorePluginConfig(){return{getters:this.coreGetters,stateObserver:this.state,range:this.range,dispatch:this.dispatchFromCorePlugin,uuidGenerator:this.uuidGenerator,custom:this.config.custom,external:this.config.external}}setupUiPluginConfig(){return{getters:this.getters,stateObserver:this.state,dispatch:this.dispatch,selection:this.selection,moveClient:this.session.move.bind(this.session),custom:this.config.custom,uiActions:this.config,lazyEvaluation:this.config.lazyEvaluation}}checkDispatchAllowed(e){const t=this.handlers.map((t=>t.allowDispatch(e)));return new Ro(t.flat())}finalize(){this.status=3;for(const e of this.handlers)e.finalize();this.status=0}dispatchToHandlers(e,t){t=Ne(t);for(const i of e)i.beforeHandle(t);for(const i of e)i.handle(t)}drawGrid(e){for(let[t,i]of this.renderers)e.ctx.save(),t.drawGrid(e,i),e.ctx.restore()}exportData(){let e=Uf();for(let t of this.handlers)t instanceof Bf&&t.export(e);return e.revisionId=this.session.getRevisionId()||K,e=JSON.parse(JSON.stringify(e)),e}updateMode(e){"normal"!==e&&this.dispatch("STOP_EDITION",{cancel:!0}),this.config.mode=e,this.trigger("update")}exportXLSX(){this.dispatch("EVALUATE_CELLS");let e={...Uf(),sheets:[Vf(_f,"Sheet1")]};for(let t of this.handlers)t instanceof zf&&t.exportForExcel(e);return e=JSON.parse(JSON.stringify(e)),ZS(e)}garbageCollectExternalResources(){for(const e of this.corePlugins)e.garbageCollectExternalResources()}},e.Registry=Mn,e.Revision=ob,e.SPREADSHEET_DIMENSIONS=KS,e.Spreadsheet=Xb,e.UIPlugin=Ov,e.__info__=YS,e.addFunction=function(e,t){iu.add(e,t)},e.astToFormula=sv,e.compile=uv,e.components=tC,e.convertAstNodes=nv,e.coreTypes=xo,e.findCellInNewZone=Ki,e.functionCache=dv,e.helpers=JS,e.invalidateEvaluationCommands=Eo,e.links=eC,e.load=Ff,e.parse=iv,e.readonlyAllowedCommands=yo,e.registries=QS,e.setTranslationMethod=function(e){i=e},e.tokenize=uf,Object.defineProperty(e,"__esModule",{value:!0}),YS.version="16.2.0-alpha.0",YS.date="2023-02-28T08:16:17.842Z",YS.hash="2855f54"}(this.o_spreadsheet=this.o_spreadsheet||{},owl);
2410
+ `}var XS;!function(e){e[e.Ready=0]="Ready",e[e.Running=1]="Running",e[e.RunningCore=2]="RunningCore",e[e.Finalizing=3]="Finalizing"}(XS||(XS={}));const YS={},KS={MIN_ROW_HEIGHT:10,MIN_COL_WIDTH:5,HEADER_HEIGHT:O,HEADER_WIDTH:N,TOPBAR_HEIGHT:63,BOTTOMBAR_HEIGHT:36,DEFAULT_CELL_WIDTH:_,DEFAULT_CELL_HEIGHT:F,SCROLLBAR_WIDTH:D},QS={autofillModifiersRegistry:Lu,autofillRulesRegistry:Pu,cellMenuRegistry:Ps,colMenuRegistry:Us,linkMenuRegistry:Ku,functionRegistry:iu,featurePluginRegistry:Rb,statefulUIPluginRegistry:Tb,coreViewsPluginRegistry:Ab,corePluginRegistry:Ib,rowMenuRegistry:Vs,sidePanelRegistry:Lg,figureRegistry:og,chartSidePanelComponentRegistry:Tg,chartComponentRegistry:Nn,chartRegistry:On,topbarMenuRegistry:ag,topbarComponentRegistry:Pg,clickableCellRegistry:Mb,otRegistry:cg,inverseCommandRegistry:ng,urlRegistry:Eu,cellPopoverRegistry:eg},JS={arg:Zs,toBoolean:or,toJsDate:nr,toNumber:Qs,toString:er,toXC:Vt,toZone:_i,toCartesian:Ut,numberToLetters:Lt,UuidGenerator:Oi,formatValue:li,computeTextWidth:Le,createEmptyWorkbookData:Uf,createEmptySheet:Pf,createEmptyExcelSheet:Vf,getDefaultChartJsRuntime:on,chartFontColor:zo,ChartColors:Vo,EvaluationError:c,CellErrorLevel:l,getFillingMode:an,rgbaToHex:Et,colorToRGBA:wt,positionToZone:Ji,isDefined:et,lazy:nt},eC={isMarkdownLink:qe,parseMarkdownLink:Xe,markdownLink:je,openLink:Ru,urlRepresentation:Iu},tC={ChartPanel:Ag,ChartFigure:Xn,ChartJsComponent:oo,Grid:op,GridOverlay:Bg,ScorecardChart:go,LineConfigPanel:yg,LineBarPieDesignPanel:Sg,BarConfigPanel:gg,LineBarPieConfigPanel:ug,GaugeChartConfigPanel:Eg,GaugeChartDesignPanel:wg,ScorecardChartConfigPanel:Ig,ScorecardChartDesignPanel:Rg};e.AbstractChart=vo,e.CorePlugin=Bf,e.DATETIME_FORMAT=X,e.DispatchResult=Ro,e.EvaluationError=c,e.Model=class extends Yv{constructor(e={},i={},o=[],n=new Oi,s=!0){super(),this.corePlugins=[],this.featurePlugins=[],this.statefulUIPlugins=[],this.coreViewsPlugins=[],this.isReplayingCommand=!1,this.renderers=[],this.status=0,this.dispatch=(e,t)=>{const i={...t,type:e};let o=this.status;if(this.getters.isReadonly()&&(n=i,!yo.has(n.type)))return new Ro(67);var n;if(!this.session.canApplyOptimisticUpdate())return new Ro(64);switch(o){case 0:const t=this.checkDispatchAllowed(i);if(!t.isSuccessful)return t;this.status=1;const{changes:o,commands:n}=this.state.recordChanges((()=>{Io(i)&&this.state.addCommand(i),this.dispatchToHandlers(this.handlers,i),this.finalize()}));this.session.save(n,o),this.status=0,this.trigger("update");break;case 1:if(Io(i)){const e=this.checkDispatchAllowed(i);if(!e.isSuccessful)return e;this.state.addCommand(i)}this.dispatchToHandlers(this.handlers,i);break;case 3:throw new Error("Cannot dispatch commands in the finalize state");case 2:if(Io(i))throw new Error(`A UI plugin cannot dispatch ${e} while handling a core command`);this.dispatchToHandlers(this.handlers,i)}return Ro.Success},this.dispatchFromCorePlugin=(e,t)=>{const i={...t,type:e},o=this.status;this.status=2;const n=this.isReplayingCommand?[this.range,...this.corePlugins,...this.coreViewsPlugins]:this.handlers;return this.dispatchToHandlers(n,i),this.status=o,Ro.Success},o=kf(e,o);const r=Ff(e,s);this.state=new hS,this.uuidGenerator=n,this.config=this.setupConfig(i),this.session=this.setupSession(r.revisionId),this.history=new aS(this.dispatchFromCorePlugin,this.session),this.coreGetters={},this.range=new Av(this.coreGetters),this.coreGetters.getRangeString=this.range.getRangeString.bind(this.range),this.coreGetters.getRangeFromSheetXC=this.range.getRangeFromSheetXC.bind(this.range),this.coreGetters.createAdaptedRanges=this.range.createAdaptedRanges.bind(this.range),this.coreGetters.getRangeDataFromXc=this.range.getRangeDataFromXc.bind(this.range),this.coreGetters.getRangeDataFromZone=this.range.getRangeDataFromZone.bind(this.range),this.coreGetters.getRangeFromRangeData=this.range.getRangeFromRangeData.bind(this.range),this.coreGetters.getSelectionRangeString=this.range.getSelectionRangeString.bind(this.range),this.getters={isReadonly:()=>"readonly"===this.config.mode||"dashboard"===this.config.mode,isDashboard:()=>"dashboard"===this.config.mode,canUndo:this.history.canUndo.bind(this.history),canRedo:this.history.canRedo.bind(this.history),getClient:this.session.getClient.bind(this.session),getConnectedClients:this.session.getConnectedClients.bind(this.session),isFullySynchronized:this.session.isFullySynchronized.bind(this.session)},this.uuidGenerator.setIsFastStrategy(!0),this.selection=new cS(this.getters),this.corePluginConfig=this.setupCorePluginConfig(),this.uiPluginConfig=this.setupUiPluginConfig();for(let e of Ib.getAll())this.setupCorePlugin(e,r);Object.assign(this.getters,this.coreGetters);for(let e of Tb.getAll())this.statefulUIPlugins.push(this.setupUiPlugin(e));for(let e of Ab.getAll())this.coreViewsPlugins.push(this.setupUiPlugin(e));for(let e of Rb.getAll())this.featurePlugins.push(this.setupUiPlugin(e));this.uuidGenerator.setIsFastStrategy(!1),this.dispatch("START"),this.selection.observe(this,{handleEvent:()=>this.trigger("update")}),this.setupSessionEvents(),this.session.loadInitialMessages(o),this.joinSession(),i.snapshotRequested&&(this.session.snapshot(this.exportData()),this.garbageCollectExternalResources()),t.markRaw(this)}get handlers(){return[this.range,...this.corePlugins,...this.allUIPlugins,this.history]}get allUIPlugins(){return[...this.statefulUIPlugins,...this.coreViewsPlugins,...this.featurePlugins]}joinSession(){this.session.join(this.config.client)}leaveSession(){this.session.leave()}setupUiPlugin(e){const t=new e(this.uiPluginConfig);for(let i of e.getters){if(!(i in t))throw new Error(`Invalid getter name: ${i} for plugin ${t.constructor}`);if(i in this.getters)throw new Error(`Getter "${i}" is already defined.`);this.getters[i]=t[i].bind(t)}const i=e.layers.map((e=>[t,e]));return this.renderers.push(...i),this.renderers.sort(((e,t)=>e[1]-t[1])),t}setupCorePlugin(e,t){const i=new e(this.corePluginConfig);for(let t of e.getters){if(!(t in i))throw new Error(`Invalid getter name: ${t} for plugin ${i.constructor}`);if(t in this.coreGetters)throw new Error(`Getter "${t}" is already defined.`);this.coreGetters[t]=i[t].bind(i)}i.import(t),this.corePlugins.push(i)}onRemoteRevisionReceived({commands:e}){for(let t of e){const e=this.status;this.status=2,this.dispatchToHandlers(this.statefulUIPlugins,t),this.status=e}this.finalize()}setupSession(e){return new sb(sS(e,this.state.recordChanges.bind(this.state),(e=>{this.checkDispatchAllowed(e).isSuccessful&&(this.isReplayingCommand=!0,this.dispatchToHandlers([this.range,...this.corePlugins,...this.coreViewsPlugins],e),this.isReplayingCommand=!1)})),this.config.transportService,e)}setupSessionEvents(){this.session.on("remote-revision-received",this,this.onRemoteRevisionReceived),this.session.on("revision-redone",this,this.finalize),this.session.on("revision-undone",this,this.finalize),this.session.on("unexpected-revision-id",this,(()=>this.trigger("unexpected-revision-id"))),this.session.on("collaborative-event-received",this,(()=>{this.trigger("update")}))}setupConfig(e){const t=e.client||{id:this.uuidGenerator.uuidv4(),name:s("Anonymous").toString()},i=e.transportService||new Yb;return{...e,mode:e.mode||"normal",custom:e.custom||{},external:e.external||{},transportService:i,client:t,moveClient:()=>{},snapshotRequested:!1,notifyUI:e=>this.trigger("notify-ui",e),lazyEvaluation:!("lazyEvaluation"in e)||e.lazyEvaluation}}setupCorePluginConfig(){return{getters:this.coreGetters,stateObserver:this.state,range:this.range,dispatch:this.dispatchFromCorePlugin,uuidGenerator:this.uuidGenerator,custom:this.config.custom,external:this.config.external}}setupUiPluginConfig(){return{getters:this.getters,stateObserver:this.state,dispatch:this.dispatch,selection:this.selection,moveClient:this.session.move.bind(this.session),custom:this.config.custom,uiActions:this.config,lazyEvaluation:this.config.lazyEvaluation}}checkDispatchAllowed(e){const t=this.handlers.map((t=>t.allowDispatch(e)));return new Ro(t.flat())}finalize(){this.status=3;for(const e of this.handlers)e.finalize();this.status=0}dispatchToHandlers(e,t){t=Ne(t);for(const i of e)i.beforeHandle(t);for(const i of e)i.handle(t)}drawGrid(e){for(let[t,i]of this.renderers)e.ctx.save(),t.drawGrid(e,i),e.ctx.restore()}exportData(){let e=Uf();for(let t of this.handlers)t instanceof Bf&&t.export(e);return e.revisionId=this.session.getRevisionId()||K,e=JSON.parse(JSON.stringify(e)),e}updateMode(e){"normal"!==e&&this.dispatch("STOP_EDITION",{cancel:!0}),this.config.mode=e,this.trigger("update")}exportXLSX(){this.dispatch("EVALUATE_CELLS");let e={...Uf(),sheets:[Vf(_f,"Sheet1")]};for(let t of this.handlers)t instanceof zf&&t.exportForExcel(e);return e=JSON.parse(JSON.stringify(e)),ZS(e)}garbageCollectExternalResources(){for(const e of this.corePlugins)e.garbageCollectExternalResources()}},e.Registry=Mn,e.Revision=ob,e.SPREADSHEET_DIMENSIONS=KS,e.Spreadsheet=Xb,e.UIPlugin=Ov,e.__info__=YS,e.addFunction=function(e,t){iu.add(e,t)},e.astToFormula=sv,e.compile=uv,e.components=tC,e.convertAstNodes=nv,e.coreTypes=xo,e.findCellInNewZone=Ki,e.functionCache=dv,e.helpers=JS,e.invalidateEvaluationCommands=Eo,e.links=eC,e.load=Ff,e.parse=iv,e.readonlyAllowedCommands=yo,e.registries=QS,e.setTranslationMethod=function(e){i=e},e.tokenize=uf,Object.defineProperty(e,"__esModule",{value:!0}),YS.version="16.2.0-alpha.2",YS.date="2023-03-01T14:43:49.348Z",YS.hash="eb626ad"}(this.o_spreadsheet=this.o_spreadsheet||{},owl);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@odoo/o-spreadsheet",
3
- "version": "16.2.0-alpha.0",
3
+ "version": "16.2.0-alpha.2",
4
4
  "description": "A spreadsheet component",
5
5
  "main": "dist/o-spreadsheet.cjs.js",
6
6
  "browser": "dist/o-spreadsheet.iife.js",
@@ -11,20 +11,20 @@
11
11
  "dist/*.d.ts"
12
12
  ],
13
13
  "scripts": {
14
- "serve-static": "live-server --open=demo --watch=dist/o_spreadsheet.js,dist/o_spreadsheet.xml,demo",
14
+ "serve-static": "live-server --open=demo --watch=build/o_spreadsheet.js,build/o_spreadsheet.xml,demo",
15
15
  "dev": "npm-run-all build --parallel server serve-static watch:*",
16
16
  "server": "node tools/server/main.js",
17
17
  "build:js": "tsc --module es6 --incremental",
18
18
  "bundle:js": "rollup -c -m dev",
19
19
  "bundle:xml": "node tools/bundle_xml/main.js",
20
- "build": "npm-run-all build:js bundle:*",
20
+ "build": "npm-run-all build:js bundle:js 'bundle:xml -- --outDir build'",
21
21
  "doc": "typedoc",
22
22
  "precommit": "npm run prettier && npm run doc",
23
23
  "test": "jest",
24
24
  "test:watch": "jest --watch",
25
25
  "prettier": "prettier . --write",
26
26
  "check-formatting": "prettier . --check",
27
- "dist": "tsc --module es6 --declaration --declarationDir dist/types && rollup -c && npm run bundle:xml",
27
+ "dist": "tsc --module es6 --declaration --declarationDir dist/types && rollup -c && npm run bundle:xml -- --outDir dist",
28
28
  "prepare": "husky install",
29
29
  "watch:bundle": "npm run bundle:js -- --watch",
30
30
  "watch:ts": "npm run build:js -- --watch",
@@ -130,5 +130,8 @@
130
130
  },
131
131
  "lint-staged": {
132
132
  "*": "prettier --write"
133
+ },
134
+ "publishConfig": {
135
+ "tag": "alpha"
133
136
  }
134
137
  }