@odoo/o-spreadsheet 16.0.73 → 16.0.74

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.
@@ -41487,26 +41487,28 @@ class SelectionStreamProcessor {
41487
41487
  bottom: Math.min(this.getters.getNumberRows(sheetId) - 1, bottom),
41488
41488
  };
41489
41489
  };
41490
- const { col: refCol, row: refRow } = this.getReferencePosition();
41490
+ const { cell: refCell, zone: refZone } = this.getReferenceAnchor();
41491
+ const { col: refCol, row: refRow } = refCell;
41491
41492
  // check if we can shrink selection
41492
41493
  let n = 0;
41493
41494
  while (result !== null) {
41494
41495
  n++;
41495
41496
  if (deltaCol < 0) {
41496
41497
  const newRight = this.getNextAvailableCol(deltaCol, right - (n - 1), refRow);
41497
- result = refCol <= right - n ? expand({ top, left, bottom, right: newRight }) : null;
41498
+ result = refZone.right <= right - n ? expand({ top, left, bottom, right: newRight }) : null;
41498
41499
  }
41499
41500
  if (deltaCol > 0) {
41500
41501
  const newLeft = this.getNextAvailableCol(deltaCol, left + (n - 1), refRow);
41501
- result = left + n <= refCol ? expand({ top, left: newLeft, bottom, right }) : null;
41502
+ result = left + n <= refZone.left ? expand({ top, left: newLeft, bottom, right }) : null;
41502
41503
  }
41503
41504
  if (deltaRow < 0) {
41504
41505
  const newBottom = this.getNextAvailableRow(deltaRow, refCol, bottom - (n - 1));
41505
- result = refRow <= bottom - n ? expand({ top, left, bottom: newBottom, right }) : null;
41506
+ result =
41507
+ refZone.bottom <= bottom - n ? expand({ top, left, bottom: newBottom, right }) : null;
41506
41508
  }
41507
41509
  if (deltaRow > 0) {
41508
41510
  const newTop = this.getNextAvailableRow(deltaRow, refCol, top + (n - 1));
41509
- result = top + n <= refRow ? expand({ top: newTop, left, bottom, right }) : null;
41511
+ result = top + n <= refZone.top ? expand({ top: newTop, left, bottom, right }) : null;
41510
41512
  }
41511
41513
  result = result ? organizeZone(result) : result;
41512
41514
  if (result && !isEqual(result, anchor.zone)) {
@@ -41742,18 +41744,26 @@ class SelectionStreamProcessor {
41742
41744
  * If the anchor is hidden, browses from left to right and top to bottom to
41743
41745
  * find a visible cell.
41744
41746
  */
41745
- getReferencePosition() {
41747
+ getReferenceAnchor() {
41746
41748
  const sheetId = this.getters.getActiveSheetId();
41747
41749
  const anchor = this.anchor;
41748
41750
  const { left, right, top, bottom } = anchor.zone;
41749
41751
  const { col: anchorCol, row: anchorRow } = anchor.cell;
41752
+ const col = this.getters.isColHidden(sheetId, anchorCol)
41753
+ ? this.getters.findVisibleHeader(sheetId, "COL", left, right) || anchorCol
41754
+ : anchorCol;
41755
+ const row = this.getters.isRowHidden(sheetId, anchorRow)
41756
+ ? this.getters.findVisibleHeader(sheetId, "ROW", top, bottom) || anchorRow
41757
+ : anchorRow;
41758
+ const zone = this.getters.expandZone(sheetId, {
41759
+ left: col,
41760
+ right: col,
41761
+ top: row,
41762
+ bottom: row,
41763
+ });
41750
41764
  return {
41751
- col: this.getters.isColHidden(sheetId, anchorCol)
41752
- ? this.getters.findVisibleHeader(sheetId, "COL", left, right) || anchorCol
41753
- : anchorCol,
41754
- row: this.getters.isRowHidden(sheetId, anchorRow)
41755
- ? this.getters.findVisibleHeader(sheetId, "ROW", top, bottom) || anchorRow
41756
- : anchorRow,
41765
+ cell: { col, row },
41766
+ zone,
41757
41767
  };
41758
41768
  }
41759
41769
  deltaToTarget(position, direction, step) {
@@ -43880,6 +43890,6 @@ exports.setTranslationMethod = setTranslationMethod;
43880
43890
  exports.tokenize = tokenize;
43881
43891
 
43882
43892
 
43883
- __info__.version = '16.0.73';
43884
- __info__.date = '2025-06-19T18:25:17.838Z';
43885
- __info__.hash = '8bc0a8a';
43893
+ __info__.version = '16.0.74';
43894
+ __info__.date = '2025-06-27T09:02:46.788Z';
43895
+ __info__.hash = 'a1d6303';
@@ -522,7 +522,7 @@ declare class SelectionStreamProcessor implements SelectionProcessor, StatefulSt
522
522
  * If the anchor is hidden, browses from left to right and top to bottom to
523
523
  * find a visible cell.
524
524
  */
525
- private getReferencePosition;
525
+ private getReferenceAnchor;
526
526
  private deltaToTarget;
527
527
  private getStartingPosition;
528
528
  /**
@@ -41483,26 +41483,28 @@ class SelectionStreamProcessor {
41483
41483
  bottom: Math.min(this.getters.getNumberRows(sheetId) - 1, bottom),
41484
41484
  };
41485
41485
  };
41486
- const { col: refCol, row: refRow } = this.getReferencePosition();
41486
+ const { cell: refCell, zone: refZone } = this.getReferenceAnchor();
41487
+ const { col: refCol, row: refRow } = refCell;
41487
41488
  // check if we can shrink selection
41488
41489
  let n = 0;
41489
41490
  while (result !== null) {
41490
41491
  n++;
41491
41492
  if (deltaCol < 0) {
41492
41493
  const newRight = this.getNextAvailableCol(deltaCol, right - (n - 1), refRow);
41493
- result = refCol <= right - n ? expand({ top, left, bottom, right: newRight }) : null;
41494
+ result = refZone.right <= right - n ? expand({ top, left, bottom, right: newRight }) : null;
41494
41495
  }
41495
41496
  if (deltaCol > 0) {
41496
41497
  const newLeft = this.getNextAvailableCol(deltaCol, left + (n - 1), refRow);
41497
- result = left + n <= refCol ? expand({ top, left: newLeft, bottom, right }) : null;
41498
+ result = left + n <= refZone.left ? expand({ top, left: newLeft, bottom, right }) : null;
41498
41499
  }
41499
41500
  if (deltaRow < 0) {
41500
41501
  const newBottom = this.getNextAvailableRow(deltaRow, refCol, bottom - (n - 1));
41501
- result = refRow <= bottom - n ? expand({ top, left, bottom: newBottom, right }) : null;
41502
+ result =
41503
+ refZone.bottom <= bottom - n ? expand({ top, left, bottom: newBottom, right }) : null;
41502
41504
  }
41503
41505
  if (deltaRow > 0) {
41504
41506
  const newTop = this.getNextAvailableRow(deltaRow, refCol, top + (n - 1));
41505
- result = top + n <= refRow ? expand({ top: newTop, left, bottom, right }) : null;
41507
+ result = top + n <= refZone.top ? expand({ top: newTop, left, bottom, right }) : null;
41506
41508
  }
41507
41509
  result = result ? organizeZone(result) : result;
41508
41510
  if (result && !isEqual(result, anchor.zone)) {
@@ -41738,18 +41740,26 @@ class SelectionStreamProcessor {
41738
41740
  * If the anchor is hidden, browses from left to right and top to bottom to
41739
41741
  * find a visible cell.
41740
41742
  */
41741
- getReferencePosition() {
41743
+ getReferenceAnchor() {
41742
41744
  const sheetId = this.getters.getActiveSheetId();
41743
41745
  const anchor = this.anchor;
41744
41746
  const { left, right, top, bottom } = anchor.zone;
41745
41747
  const { col: anchorCol, row: anchorRow } = anchor.cell;
41748
+ const col = this.getters.isColHidden(sheetId, anchorCol)
41749
+ ? this.getters.findVisibleHeader(sheetId, "COL", left, right) || anchorCol
41750
+ : anchorCol;
41751
+ const row = this.getters.isRowHidden(sheetId, anchorRow)
41752
+ ? this.getters.findVisibleHeader(sheetId, "ROW", top, bottom) || anchorRow
41753
+ : anchorRow;
41754
+ const zone = this.getters.expandZone(sheetId, {
41755
+ left: col,
41756
+ right: col,
41757
+ top: row,
41758
+ bottom: row,
41759
+ });
41746
41760
  return {
41747
- col: this.getters.isColHidden(sheetId, anchorCol)
41748
- ? this.getters.findVisibleHeader(sheetId, "COL", left, right) || anchorCol
41749
- : anchorCol,
41750
- row: this.getters.isRowHidden(sheetId, anchorRow)
41751
- ? this.getters.findVisibleHeader(sheetId, "ROW", top, bottom) || anchorRow
41752
- : anchorRow,
41761
+ cell: { col, row },
41762
+ zone,
41753
41763
  };
41754
41764
  }
41755
41765
  deltaToTarget(position, direction, step) {
@@ -43848,6 +43858,6 @@ function addFunction(functionName, functionDescription) {
43848
43858
  export { AbstractChart, CommandResult, CorePlugin, DATETIME_FORMAT, DispatchResult, EvaluationError, Model, Registry, Revision, SPREADSHEET_DIMENSIONS, Spreadsheet, UIPlugin, __info__, addFunction, astToFormula, cellTypes, compile, components, convertAstNodes, coreTypes, findCellInNewZone, functionCache, helpers, invalidateEvaluationCommands, load, parse, readonlyAllowedCommands, registries, setTranslationMethod, tokenize };
43849
43859
 
43850
43860
 
43851
- __info__.version = '16.0.73';
43852
- __info__.date = '2025-06-19T18:25:17.838Z';
43853
- __info__.hash = '8bc0a8a';
43861
+ __info__.version = '16.0.74';
43862
+ __info__.date = '2025-06-27T09:02:46.788Z';
43863
+ __info__.hash = 'a1d6303';
@@ -41484,26 +41484,28 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
41484
41484
  bottom: Math.min(this.getters.getNumberRows(sheetId) - 1, bottom),
41485
41485
  };
41486
41486
  };
41487
- const { col: refCol, row: refRow } = this.getReferencePosition();
41487
+ const { cell: refCell, zone: refZone } = this.getReferenceAnchor();
41488
+ const { col: refCol, row: refRow } = refCell;
41488
41489
  // check if we can shrink selection
41489
41490
  let n = 0;
41490
41491
  while (result !== null) {
41491
41492
  n++;
41492
41493
  if (deltaCol < 0) {
41493
41494
  const newRight = this.getNextAvailableCol(deltaCol, right - (n - 1), refRow);
41494
- result = refCol <= right - n ? expand({ top, left, bottom, right: newRight }) : null;
41495
+ result = refZone.right <= right - n ? expand({ top, left, bottom, right: newRight }) : null;
41495
41496
  }
41496
41497
  if (deltaCol > 0) {
41497
41498
  const newLeft = this.getNextAvailableCol(deltaCol, left + (n - 1), refRow);
41498
- result = left + n <= refCol ? expand({ top, left: newLeft, bottom, right }) : null;
41499
+ result = left + n <= refZone.left ? expand({ top, left: newLeft, bottom, right }) : null;
41499
41500
  }
41500
41501
  if (deltaRow < 0) {
41501
41502
  const newBottom = this.getNextAvailableRow(deltaRow, refCol, bottom - (n - 1));
41502
- result = refRow <= bottom - n ? expand({ top, left, bottom: newBottom, right }) : null;
41503
+ result =
41504
+ refZone.bottom <= bottom - n ? expand({ top, left, bottom: newBottom, right }) : null;
41503
41505
  }
41504
41506
  if (deltaRow > 0) {
41505
41507
  const newTop = this.getNextAvailableRow(deltaRow, refCol, top + (n - 1));
41506
- result = top + n <= refRow ? expand({ top: newTop, left, bottom, right }) : null;
41508
+ result = top + n <= refZone.top ? expand({ top: newTop, left, bottom, right }) : null;
41507
41509
  }
41508
41510
  result = result ? organizeZone(result) : result;
41509
41511
  if (result && !isEqual(result, anchor.zone)) {
@@ -41739,18 +41741,26 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
41739
41741
  * If the anchor is hidden, browses from left to right and top to bottom to
41740
41742
  * find a visible cell.
41741
41743
  */
41742
- getReferencePosition() {
41744
+ getReferenceAnchor() {
41743
41745
  const sheetId = this.getters.getActiveSheetId();
41744
41746
  const anchor = this.anchor;
41745
41747
  const { left, right, top, bottom } = anchor.zone;
41746
41748
  const { col: anchorCol, row: anchorRow } = anchor.cell;
41749
+ const col = this.getters.isColHidden(sheetId, anchorCol)
41750
+ ? this.getters.findVisibleHeader(sheetId, "COL", left, right) || anchorCol
41751
+ : anchorCol;
41752
+ const row = this.getters.isRowHidden(sheetId, anchorRow)
41753
+ ? this.getters.findVisibleHeader(sheetId, "ROW", top, bottom) || anchorRow
41754
+ : anchorRow;
41755
+ const zone = this.getters.expandZone(sheetId, {
41756
+ left: col,
41757
+ right: col,
41758
+ top: row,
41759
+ bottom: row,
41760
+ });
41747
41761
  return {
41748
- col: this.getters.isColHidden(sheetId, anchorCol)
41749
- ? this.getters.findVisibleHeader(sheetId, "COL", left, right) || anchorCol
41750
- : anchorCol,
41751
- row: this.getters.isRowHidden(sheetId, anchorRow)
41752
- ? this.getters.findVisibleHeader(sheetId, "ROW", top, bottom) || anchorRow
41753
- : anchorRow,
41762
+ cell: { col, row },
41763
+ zone,
41754
41764
  };
41755
41765
  }
41756
41766
  deltaToTarget(position, direction, step) {
@@ -43879,9 +43889,9 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
43879
43889
  Object.defineProperty(exports, '__esModule', { value: true });
43880
43890
 
43881
43891
 
43882
- __info__.version = '16.0.73';
43883
- __info__.date = '2025-06-19T18:25:17.838Z';
43884
- __info__.hash = '8bc0a8a';
43892
+ __info__.version = '16.0.74';
43893
+ __info__.date = '2025-06-27T09:02:46.788Z';
43894
+ __info__.hash = 'a1d6303';
43885
43895
 
43886
43896
 
43887
43897
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);
@@ -1992,7 +1992,7 @@
1992
1992
  outline: none;
1993
1993
  }
1994
1994
  }
1995
- `;class Rb extends t.Component{constructor(){super(...arguments),this.isViewportTooSmall=!1}getStyle(){return this.env.isDashboard()?"grid-template-rows: auto;":"grid-template-rows: 63px auto 37px"}setup(){var e,i;null===(i=(e=this.props).exposeSpreadsheet)||void 0===i||i.call(e,this),this.model=this.props.model,this.sidePanel=t.useState({isOpen:!1,panelProps:{}}),this.composer=t.useState({topBarFocus:"inactive",gridFocusMode:"inactive"}),this.keyDownMapping={"CTRL+H":()=>this.toggleSidePanel("FindAndReplace",{}),"CTRL+F":()=>this.toggleSidePanel("FindAndReplace",{})},t.useSubEnv({model:this.model,isDashboard:()=>this.model.getters.isDashboard(),openSidePanel:this.openSidePanel.bind(this),toggleSidePanel:this.toggleSidePanel.bind(this),_t:Rb._t,clipboard:navigator.clipboard,focusableElement:new vb}),t.useExternalListener(window,"resize",(()=>this.render(!0))),t.useExternalListener(window,"beforeunload",this.unbindModelEvents.bind(this)),t.useExternalListener(document.body,"wheel",(()=>{})),this.bindModelEvents(),t.onMounted((()=>{this.checkViewportSize()})),t.onWillUnmount((()=>this.unbindModelEvents())),t.onPatched((()=>{this.checkViewportSize()}))}get focusTopBarComposer(){return"inactive"===this.model.getters.getEditionMode()?"inactive":this.composer.topBarFocus}get focusGridComposer(){return"inactive"===this.model.getters.getEditionMode()?"inactive":this.composer.gridFocusMode}bindModelEvents(){this.model.on("update",this,(()=>this.render(!0))),this.model.on("notify-ui",this,this.onNotifyUI)}unbindModelEvents(){this.model.off("update",this),this.model.off("notify-ui",this)}checkViewportSize(){const{xRatio:e,yRatio:t}=this.env.model.getters.getFrozenSheetViewRatio(this.env.model.getters.getActiveSheetId());if(t>.85||e>.85){if(this.isViewportTooSmall)return;this.env.notifyUser({text:s("The current window is too small to display this sheet properly. Consider resizing your browser window or adjusting frozen rows and columns."),tag:"viewportTooSmall"}),this.isViewportTooSmall=!0}else this.isViewportTooSmall=!1}onNotifyUI(e){if("ERROR"===e.type)this.env.raiseError(e.text)}openSidePanel(e,t){this.sidePanel.component=e,this.sidePanel.panelProps=t,this.sidePanel.isOpen=!0}closeSidePanel(){this.sidePanel.isOpen=!1,this.focusGrid()}toggleSidePanel(e,t){this.sidePanel.isOpen&&e===this.sidePanel.component?(this.sidePanel.isOpen=!1,this.focusGrid()):this.openSidePanel(e,t)}focusGrid(){if(!this._focusGrid)throw new Error("_focusGrid should be exposed by the grid component");this._focusGrid()}save(){var e,t;null===(t=(e=this.props).onContentSaved)||void 0===t||t.call(e,this.model.exportData())}onKeydown(e){let t="";zn(e)&&(t+="CTRL+"),t+=e.key.toUpperCase();let i=this.keyDownMapping[t];if(i)return e.preventDefault(),e.stopPropagation(),void i()}onTopBarComposerFocused(e){this.model.getters.isReadonly()||(this.model.dispatch("UNFOCUS_SELECTION_INPUT"),this.composer.topBarFocus="contentFocus",this.composer.gridFocusMode="inactive",this.setComposerContent({selection:e}))}onGridComposerContentFocused(e){this.model.getters.isReadonly()||(this.model.dispatch("UNFOCUS_SELECTION_INPUT"),this.composer.topBarFocus="inactive",this.composer.gridFocusMode="contentFocus",this.setComposerContent({selection:e}))}onGridComposerCellFocused(e,t){this.model.getters.isReadonly()||(this.model.dispatch("UNFOCUS_SELECTION_INPUT"),this.composer.topBarFocus="inactive",this.composer.gridFocusMode="cellFocus",this.setComposerContent({content:e,selection:t}||{}))}setComposerContent({content:e,selection:t}){"inactive"===this.model.getters.getEditionMode()?this.model.dispatch("START_EDITION",{text:e,selection:t}):e&&this.model.dispatch("SET_CURRENT_CONTENT",{content:e,selection:t})}get gridHeight(){const{height:e}=this.env.model.getters.getSheetViewDimension();return e}}Rb.template="o-spreadsheet-Spreadsheet",Rb.components={TopBar:xb,Grid:Mp,BottomBar:bb,SidePanel:Cb,SpreadsheetDashboard:Sb},Rb._t=e=>e;class Ib{constructor(){this.listeners=[]}sendMessage(e){for(const{callback:t}of this.listeners)t(e)}onNewMessage(e,t){this.listeners.push({id:e,callback:t})}leave(e){this.listeners=this.listeners.filter((t=>t.id!==e))}}function Tb(e){return so.get(e.type)(e)}function Ab(e){if("string"==typeof e)return{};if("number"==typeof e)return[];throw new Error("Cannot create new node")}class Nb{constructor(e,t=[]){this.buildTransformation=e,this.operations=t}getOperations(){return this.operations}getOperation(e){const t=this.operations.find((t=>t.id===e));if(!t)throw new Error(`Operation ${e} not found`);return t}getLastOperationId(){var e;return null===(e=this.operations[this.operations.length-1])||void 0===e?void 0:e.id}getFirstOperationAmong(e,t){for(const i of this.operations){if(i.id===e)return e;if(i.id===t)return t}throw new Error(`Operation ${e} and ${t} not found`)}contains(e){return!!this.operations.find((t=>t.id===e))}prepend(e){const t=this.buildTransformation.with(e.data);this.operations=[e,...this.operations.map((e=>e.transformed(t)))]}insert(e,t){const i=this.buildTransformation.with(e.data),{before:n,operation:o,after:s}=this.locateOperation(t);this.operations=[...n,o,e,...s.map((e=>e.transformed(i)))]}append(e){this.operations.push(e)}appendBranch(e){this.operations=this.operations.concat(e.operations)}fork(e){const{after:t}=this.locateOperation(e);return new Nb(this.buildTransformation,t)}transform(e){this.operations=this.operations.map((t=>t.transformed(e)))}cutBefore(e){this.operations=this.locateOperation(e).before}cutAfter(e){const{before:t,operation:i}=this.locateOperation(e);this.operations=t.concat([i])}locateOperation(e){const t=this.operations.findIndex((t=>t.id===e));if(-1===t)throw new Error(`Operation ${e} not found`);return{before:this.operations.slice(0,t),operation:this.operations[t],after:this.operations.slice(t+1)}}}class Ob{constructor(e,t){this.id=e,this.data=t}transformed(e){return new Mb(this.id,tt((()=>e(this.data))))}}class Mb{constructor(e,t){this.id=e,this.lazyData=t}get data(){return this.lazyData()}transformed(e){return new Mb(this.id,this.lazyData.map(e))}}class _b{constructor(e){this.operations=e}[Symbol.iterator](){return this.operations[Symbol.iterator]()}stopWith(e){return new _b(function*(e,t){for(const i of e)if(yield i,i.operation.id===t)return}(this.operations,e))}stopBefore(e){return new _b(function*(e,t){for(const i of e){if(i.operation.id===t)return;yield i}}(this.operations,e))}startAfter(e){return new _b(function*(e,t){let i=!0;for(const n of e)i||(yield n),n.operation.id===t&&(i=!1)}(this.operations,e))}}class Fb{constructor(e,t){this.buildTransformation=e,this.branchingOperationIds=new Map,this.branches=[t]}getLastBranch(){return this.branches[this.branches.length-1]}execution(e){return new _b(Pe(this._execution(e),this._execution(e)))}revertedExecution(e){return new _b(Pe(this._revertedExecution(e),this._revertedExecution(e)))}insertOperationLast(e,t){var i;const n=e.getLastOperationId()||(null===(i=this.previousBranch(e))||void 0===i?void 0:i.getLastOperationId());e.append(t),n&&this.insertPrevious(e,t,n)}insertOperationAfter(e,t,i){e.insert(t,i),this.updateNextWith(e,t,i),this.insertPrevious(e,t,i)}undo(e,t){const i=this.buildTransformation.without(t.data),n=this.branchingOperationIds.get(e);this.branchingOperationIds.set(e,t.id);const o=e.fork(t.id);n&&this.branchingOperationIds.set(o,n),this.insertBranchAfter(e,o),this.transform(o,i)}redo(e){const t=this.nextBranch(e);if(!t)return;const i=this.nextBranch(t);this.removeBranchFromTree(t);const n=this.branchingOperationIds.get(t);n?this.branchingOperationIds.set(e,n):this.branchingOperationIds.delete(e),i&&this.rebaseUp(i)}drop(e){for(const t of this.branches)t.contains(e)&&t.cutBefore(e)}findOperation(e,t){for(const i of this.revertedExecution(e))if(i.operation.id===t)return i;throw new Error(`Operation ${t} not found`)}rebaseUp(e){const{previousBranch:t,branchingOperation:i}=this.findPreviousBranchingOperation(e);if(!t||!i)return;const n=this.buildTransformation.without(i.data),o=t.fork(i.id);this.branchingOperationIds.set(o,this.branchingOperationIds.get(e)),this.removeBranchFromTree(e),this.insertBranchAfter(t,o),o.transform(n);const s=this.nextBranch(o);s&&this.rebaseUp(s)}removeBranchFromTree(e){const t=this.branches.findIndex((t=>t===e));this.branches.splice(t,1)}insertBranchAfter(e,t){const i=this.branches.findIndex((t=>t===e));this.branches.splice(i+1,0,t)}updateNextWith(e,t,i){const n=this.branchingOperationIds.get(e),o=this.nextBranch(e);if(n&&o)if(e.getFirstOperationAmong(i,n)===n){const s=this.addToNextBranch(e,o,n,t,i);this.updateNextWith(o,s,i)}else{const e=this.buildTransformation.with(t.data);this.transform(o,e)}}addToNextBranch(e,t,i,n,o){let s=n;return o===i?(s=this.getTransformedOperation(e,i,n),t.prepend(s)):t.contains(o)?(s=this.getTransformedOperation(e,i,n),t.insert(s,o)):t.append(n),s}getTransformedOperation(e,t,i){const n=e.getOperation(t),o=this.buildTransformation.without(n.data);return i.transformed(o)}shouldExecute(e,t){return t.id!==this.branchingOperationIds.get(e)}transform(e,t){e.transform(t);const i=this.nextBranch(e);i&&this.transform(i,t)}insertPrevious(e,t,i){const{previousBranch:n,branchingOperation:o}=this.findPreviousBranchingOperation(e);if(!n||!o)return;const s=this.buildTransformation.with(o.data),r=e.fork(i);r.transform(s),n.cutAfter(i),n.appendBranch(r);const a=t.transformed(s);this.insertPrevious(n,a,i)}findPreviousBranchingOperation(e){const t=this.previousBranch(e);if(!t)return{previousBranch:void 0,branchingOperation:void 0};const i=this.branchingOperationIds.get(t);return i?{previousBranch:t,branchingOperation:t.getOperation(i)}:{previousBranch:void 0,branchingOperation:void 0}}nextBranch(e){const t=this.branches.findIndex((t=>t===e));if(-1!==t)return this.branches[t+1]}previousBranch(e){const t=this.branches.findIndex((t=>t===e));if(-1!==t)return this.branches[t-1]}*_revertedExecution(e){const t=this.branchingOperationIds.get(e);let i=!!t;const n=e.getOperations();for(let o=n.length-1;o>=0;o--){const s=n[o];s.id===t&&(i=!1),i||(yield{operation:s,branch:e,isCancelled:!this.shouldExecute(e,s)})}const o=this.previousBranch(e);yield*o?this._revertedExecution(o):[]}*_execution(e){for(const t of e.getOperations())if(yield{operation:t,branch:e,isCancelled:!this.shouldExecute(e,t)},t.id===this.branchingOperationIds.get(e)){const t=this.nextBranch(e);return void(yield*t?this._execution(t):[])}if(!this.branchingOperationIds.get(e)){const t=this.nextBranch(e);yield*t?this._execution(t):[]}}}class Db{constructor(e,t,i,n,o){this.applyOperation=t,this.revertOperation=i,this.buildEmpty=n,this.buildTransformation=o,this.HEAD_BRANCH=new Nb(this.buildTransformation),this.tree=new Fb(o,this.HEAD_BRANCH);const s=new Ob(e,n(e));this.tree.insertOperationLast(this.HEAD_BRANCH,s),this.HEAD_OPERATION=s}get(e){return this.tree.findOperation(this.HEAD_BRANCH,e).operation.data}append(e,t){const i=new Ob(e,t),n=this.tree.getLastBranch();this.tree.insertOperationLast(n,i),this.HEAD_BRANCH=n,this.HEAD_OPERATION=i}insert(e,t,i){const n=new Ob(e,t);this.revertTo(i),this.tree.insertOperationAfter(this.HEAD_BRANCH,n,i),this.fastForward()}undo(e,t,i){const{branch:n,operation:o}=this.tree.findOperation(this.HEAD_BRANCH,e);this.revertBefore(e),this.tree.undo(n,o),this.fastForward(),this.insert(t,this.buildEmpty(t),i)}redo(e,t,i){const{branch:n}=this.tree.findOperation(this.HEAD_BRANCH,e);this.revertBefore(e),this.tree.redo(n),this.fastForward(),this.insert(t,this.buildEmpty(t),i)}rebase(e){const t=this.get(e),i=[...this.tree.execution(this.HEAD_BRANCH).startAfter(e)];this.revertBefore(e);const n=this.HEAD_OPERATION.id;this.tree.drop(e),this.insert(e,t,n);for(const{operation:e}of i)this.insert(e.id,e.data,this.HEAD_OPERATION.id)}revertBefore(e){const t=this.tree.revertedExecution(this.HEAD_BRANCH).stopWith(e);this.revert(t)}revertTo(e){const t=e?this.tree.revertedExecution(this.HEAD_BRANCH).stopBefore(e):this.tree.revertedExecution(this.HEAD_BRANCH);this.revert(t)}revert(e){for(const{next:t,operation:i,isCancelled:n}of e)n||this.revertOperation(i.data),t&&(this.HEAD_BRANCH=t.branch,this.HEAD_OPERATION=t.operation)}fastForward(){const e=this.HEAD_OPERATION?this.tree.execution(this.HEAD_BRANCH).startAfter(this.HEAD_OPERATION.id):this.tree.execution(this.HEAD_BRANCH);for(const{operation:t,branch:i,isCancelled:n}of e)n||this.applyOperation(t.data),this.HEAD_OPERATION=t,this.HEAD_BRANCH=i}}function kb(e,t,i){return new Db(e,(e=>{const n=e.commands.slice(),{changes:o}=t((()=>{for(const e of n)i(e)}));e.setChanges(o)}),(e=>function(e){for(const t of e.slice().reverse())for(let e=t.changes.length-1;e>=0;e--){$b(t.changes[e],"before")}}([e])),(e=>new ob(e,"empty",[],[])),{with:e=>t=>new ob(t.id,t.clientId,ib(t.commands,e.commands)),without:e=>t=>new ob(t.id,t.clientId,ib(t.commands,e.commands.map(Tb).flat()))})}function $b(e,t){let i=e.path[0];const n=e.path[e.path.length-1];for(let t=1;t<e.path.slice(0,-1).length;t++){const n=e.path[t];if(void 0===i[n]){const o=e.path[t+1];i[n]=Ab(o)}i=i[n]}void 0===e[t]?delete i[n]:i[n]=e[t]}class Lb extends t.EventBus{constructor(e,t){super(),this.dispatch=e,this.session=t,this.undoStack=[],this.redoStack=[],this.session.on("new-local-state-update",this,this.onNewLocalStateUpdate),this.session.on("revision-undone",this,(({commands:e})=>this.selectiveUndo(e))),this.session.on("revision-redone",this,(({commands:e})=>this.selectiveRedo(e))),this.session.on("snapshot",this,(()=>{this.undoStack=[],this.redoStack=[]}))}allowDispatch(e){switch(e.type){case"REQUEST_UNDO":if(!this.canUndo())return 6;break;case"REQUEST_REDO":if(!this.canRedo())return 7}return 0}beforeHandle(e){}handle(e){switch(e.type){case"REQUEST_UNDO":case"REQUEST_REDO":this.requestHistoryChange("REQUEST_UNDO"===e.type?"UNDO":"REDO")}}finalize(){}requestHistoryChange(e){const t="UNDO"===e?this.undoStack.pop():this.redoStack.pop();t&&("UNDO"===e?(this.session.undo(t),this.redoStack.push(t)):(this.session.redo(t),this.undoStack.push(t)))}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}onNewLocalStateUpdate({id:e}){this.undoStack.push(e),this.redoStack=[],this.undoStack.length>99&&this.undoStack.shift()}selectiveUndo(e){this.dispatch("UNDO",{commands:e})}selectiveRedo(e){this.dispatch("REDO",{commands:e})}}class Pb{constructor(e){this.providers=[],this.getters=e}allowDispatch(e){return"MOVE_RANGES"===e.type?1===e.target.length?0:26:0}beforeHandle(e){}handle(e){switch(e.type){case"REMOVE_COLUMNS_ROWS":{let t="COL"===e.dimension?"left":"top",i="COL"===e.dimension?"right":"bottom",n="COL"===e.dimension?"columns":"rows";const o=[...e.elements];o.sort(((e,t)=>t-e));const s=Le(o);this.executeOnAllRanges((o=>{if(o.sheetId!==e.sheetId)return{changeType:"NONE"};let r=o,a="NONE";for(let e of s){const s=ct(e),l=lt(e);if(o.zone[t]<=s&&s<=o.zone[i]){const e=Math.min(o.zone[i],l)-s+1;a="RESIZE",r=this.createAdaptedRange(r,n,a,-e)}else if(o.zone[t]>=s&&o.zone[i]<=l)a="REMOVE",r=o.clone({...this.getInvalidRange()});else if(o.zone[t]<=l&&o.zone[i]>=l){const e=l-o.zone[t]+1;a="RESIZE",r=this.createAdaptedRange(r,n,a,-e),r=this.createAdaptedRange(r,n,"MOVE",-(o.zone[t]-s))}else s<o.zone[t]&&(a="MOVE",r=this.createAdaptedRange(r,n,a,-(l-s+1)))}return"NONE"!==a?{changeType:a,range:r}:{changeType:"NONE"}}),e.sheetId);break}case"ADD_COLUMNS_ROWS":{let t="COL"===e.dimension?"left":"top",i="COL"===e.dimension?"right":"bottom",n="COL"===e.dimension?"columns":"rows";this.executeOnAllRanges((o=>{if(o.sheetId!==e.sheetId)return{changeType:"NONE"};if("after"===e.position){if(o.zone[t]<=e.base&&e.base<o.zone[i])return{changeType:"RESIZE",range:this.createAdaptedRange(o,n,"RESIZE",e.quantity)};if(e.base<o.zone[t])return{changeType:"MOVE",range:this.createAdaptedRange(o,n,"MOVE",e.quantity)}}else{if(o.zone[t]<e.base&&e.base<=o.zone[i])return{changeType:"RESIZE",range:this.createAdaptedRange(o,n,"RESIZE",e.quantity)};if(e.base<=o.zone[t])return{changeType:"MOVE",range:this.createAdaptedRange(o,n,"MOVE",e.quantity)}}return{changeType:"NONE"}}),e.sheetId);break}case"DELETE_SHEET":this.executeOnAllRanges((t=>{if(t.sheetId!==e.sheetId)return{changeType:"NONE"};const i=this.getters.getSheetName(e.sheetId);return{changeType:"REMOVE",range:t=t.clone({...this.getInvalidRange(),invalidSheetName:i})}}),e.sheetId);break;case"RENAME_SHEET":this.executeOnAllRanges((t=>{if(t.sheetId===e.sheetId)return{changeType:"CHANGE",range:t};if(Ai(t.invalidSheetName,e.name)){const i=void 0,n=e.sheetId;return{changeType:"CHANGE",range:t.clone({sheetId:n,invalidSheetName:i})}}return{changeType:"NONE"}}));break;case"MOVE_RANGES":{const t=e.target[0];this.executeOnAllRanges((i=>{if(i.sheetId!==e.sheetId||!Gi(i.zone,t))return{changeType:"NONE"};const n=e.targetSheetId,o=e.col-t.left,s=e.row-t.top,r=this.createAdaptedRange(i,"both","MOVE",[o,s]),a=e.sheetId!==n||r.prefixSheet;return{changeType:"MOVE",range:r.clone({sheetId:n,prefixSheet:a})}}));break}}}finalize(){}verifyRangeRemoved(e){return t=>{const i=e(t);return"NONE"===i.changeType||Di(i.range.zone)?i:{range:i.range,changeType:"REMOVE"}}}createAdaptedRange(e,t,i,n){const o=Ki(e.unboundedZone,t,i,n);return e.clone({zone:o})}executeOnAllRanges(e,t){const i=this.verifyRangeRemoved(e);for(const e of this.providers)e(i,t)}addRangeProvider(e){this.providers.push(e)}createAdaptedRanges(e,t,i,n){const o=e.map((e=>xi.fromRange(e,this.getters)));return o.map((e=>{if(!Di(e.zone))return e;const o=e.prefixSheet?e.sheetId:n,s={...e.unboundedZone,left:e.isFullRow&&!e.unboundedZone.hasHeader?e.unboundedZone.left:e.unboundedZone.left+(e.parts[0].colFixed?0:t),right:e.isFullRow?e.unboundedZone.right:e.unboundedZone.right+((e.parts[1]||e.parts[0]).colFixed?0:t),top:e.isFullCol&&!e.unboundedZone.hasHeader?e.unboundedZone.top:e.unboundedZone.top+(e.parts[0].rowFixed?0:i),bottom:e.isFullCol?e.unboundedZone.bottom:e.unboundedZone.bottom+((e.parts[1]||e.parts[0]).rowFixed?0:i)};return(e=e.clone({sheetId:o,zone:s})).orderZone(),e}))}getRangeFromSheetXC(e,t){if(!Ot.test(t)||!this.getters.tryGetSheet(e))return new xi({sheetId:"",zone:{left:-1,top:-1,right:-1,bottom:-1},parts:[],invalidXc:t,prefixSheet:!1},this.getters.getSheetSize);let i,n=t,o=!1;t.includes("!")&&(({xc:n,sheetName:i}=$t(t)),i&&(o=!0));const s=_i(n),r=xi.getRangeParts(n,s),a=i&&!this.getters.getSheetIdByName(i)?i:void 0,l=this.getters.getSheetIdByName(i)||e,c=new xi({prefixSheet:o,zone:s,sheetId:l,invalidSheetName:a,parts:r},this.getters.getSheetSize);return c.orderZone(),c}getSelectionRangeString(e,t){const i=xi.fromRange(e,this.getters),n=this.getters.expandZone(i.sheetId,i.zone),o=i.clone({zone:{...n,bottom:i.isFullCol?void 0:n.bottom,right:i.isFullRow?void 0:n.right}});return this.getRangeString(o,t)}getRangeString(e,t,i=!1){if(!e)return X;if(e.invalidXc)return e.invalidXc;if(!this.getters.tryGetSheet(e.sheetId))return X;if(e.zone.bottom-e.zone.top<0||e.zone.right-e.zone.left<0)return X;if(e.zone.left<0||e.zone.top<0)return X;const n=xi.fromRange(e,this.getters);let o=n.sheetId!==t||n.invalidSheetName||n.prefixSheet,s="";if(o&&(s=n.invalidSheetName?n.invalidSheetName:Oe(this.getters.getSheetName(n.sheetId))),o&&!s)return X;let r=this.getRangePartString(n,0,i);return n.parts&&2===n.parts.length&&(n.zone.top!==n.zone.bottom||n.zone.left!==n.zone.right||n.parts[0].rowFixed||n.parts[0].colFixed||n.parts[1].rowFixed||n.parts[1].colFixed)&&(r+=":",r+=this.getRangePartString(n,1,i)),`${o?s+"!":""}${r}`}getRangeDataFromXc(e,t){return this.getters.getRangeFromSheetXC(e,t).rangeData}getRangeDataFromZone(e,t){return{_sheetId:e,_zone:t}}getRangeFromRangeData(e){const t={prefixSheet:!1,zone:e._zone,sheetId:e._sheetId,invalidSheetName:void 0,parts:[{colFixed:!1,rowFixed:!1},{colFixed:!1,rowFixed:!1}]};return new xi(t,this.getters.getSheetSize)}getRangePartString(e,t,i=!1){var n,o;const s=e.parts&&(null===(n=e.parts[t])||void 0===n?void 0:n.colFixed)?"$":"",r=Lt(0===t?e.zone.left:e.zone.right),a=e.parts&&(null===(o=e.parts[t])||void 0===o?void 0:o.rowFixed)?"$":"",l=String(0===t?e.zone.top+1:e.zone.bottom+1);let c="";return c=e.isFullCol&&!i?0===t&&e.unboundedZone.hasHeader?s+r+a+l:s+r:e.isFullRow&&!i?0===t&&e.unboundedZone.hasHeader?s+r+a+l:a+l:s+r+a+l,c}getInvalidRange(){return{parts:[],prefixSheet:!1,zone:{left:-1,top:-1,right:-1,bottom:-1},sheetId:"",invalidXc:X}}}Pb.getters=["getRangeString","getSelectionRangeString","getRangeFromSheetXC","createAdaptedRanges","getRangeDataFromXc","getRangeDataFromZone","getRangeFromRangeData"];class Ub{constructor(){this.observers=[]}registerAsDefault(e,t){this.defaultSubscription={owner:e,callbacks:t},this.mainSubscription||(this.mainSubscription=this.defaultSubscription)}observe(e,t){this.observers.push({owner:e,callbacks:t})}capture(e,t){var i,n,o;if(this.observers.find((t=>t.owner===e)))throw new Error("You are already subscribed forever");(null===(i=this.mainSubscription)||void 0===i?void 0:i.owner)&&this.mainSubscription.owner!==e&&(null===(o=(n=this.mainSubscription.callbacks).release)||void 0===o||o.call(n)),this.mainSubscription={owner:e,callbacks:t}}release(e){var t;(null===(t=this.mainSubscription)||void 0===t?void 0:t.owner)!==e||this.observers.find((t=>t.owner===e))||(this.mainSubscription=this.defaultSubscription)}getBackToDefault(){var e,t,i;this.mainSubscription!==this.defaultSubscription&&(null===(i=null===(e=this.mainSubscription)||void 0===e?void 0:(t=e.callbacks).release)||void 0===i||i.call(t),this.mainSubscription=this.defaultSubscription)}isListening(e){var t;return(null===(t=this.mainSubscription)||void 0===t?void 0:t.owner)===e}send(e){var t;null===(t=this.mainSubscription)||void 0===t||t.callbacks.handleEvent(e),[...this.observers].forEach((t=>t.callbacks.handleEvent(e)))}}class Vb{constructor(e){this.getters=e,this.stream=new Ub,this.anchor={cell:{col:0,row:0},zone:en({col:0,row:0})},this.defaultAnchor=this.anchor}capture(e,t,i){this.stream.capture(e,i),this.anchor=t}registerAsDefault(e,t,i){this.checkAnchorZoneOrThrow(t),this.stream.registerAsDefault(e,i),this.defaultAnchor=t,this.capture(e,t,i)}resetDefaultAnchor(e,t){this.checkAnchorZoneOrThrow(t),this.stream.isListening(e)&&(this.anchor=t),this.defaultAnchor=t}resetAnchor(e,t){this.checkAnchorZoneOrThrow(t),this.stream.isListening(e)&&(this.anchor=t)}observe(e,t){this.stream.observe(e,t)}release(e){this.stream.isListening(e)&&(this.stream.release(e),this.anchor=this.defaultAnchor)}getBackToDefault(){this.stream.getBackToDefault()}selectZone(e){const t=this.getters.getActiveSheetId();return e={...e,zone:this.getters.expandZone(t,e.zone)},this.processEvent({type:"ZonesSelected",anchor:e,mode:"overrideSelection"})}selectCell(e,t){const i=en({col:e,row:t});return this.selectZone({zone:i,cell:{col:e,row:t}})}moveAnchorCell(e,t=1){if("end"!==t&&t<=0)return new fn(84);const{col:i,row:n}=this.getNextAvailablePosition(e,t);return this.selectCell(i,n)}setAnchorCorner(e,t){const i=this.getters.getActiveSheetId(),{col:n,row:o}=this.anchor.cell,s={left:Math.min(n,e),top:Math.min(o,t),right:Math.max(n,e),bottom:Math.max(o,t)},r={zone:this.getters.expandZone(i,s),cell:{col:n,row:o}};return this.processEvent({type:"AlterZoneCorner",mode:"updateAnchor",anchor:r})}addCellToSelection(e,t){const i=this.getters.getActiveSheetId();({col:e,row:t}=this.getters.getMainCellPosition(i,e,t));const n=this.getters.expandZone(i,en({col:e,row:t}));return this.processEvent({type:"ZonesSelected",anchor:{zone:n,cell:{col:e,row:t}},mode:"newAnchor"})}resizeAnchorZone(e,t=1){if("end"!==t&&t<=0)return new fn(84);const i=this.getters.getActiveSheetId(),n=this.anchor,{col:o,row:s}=n.cell,{left:r,right:a,top:l,bottom:c}=n.zone,h=this.getStartingPosition(e);let[d,u]=this.deltaToTarget(h,e,t);if(0===d&&0===u)return fn.Success;let g=n.zone;const p=e=>{e=Ji(e);const{left:t,right:n,top:o,bottom:s}=this.getters.expandZone(i,e);return{left:Math.max(0,t),right:Math.min(this.getters.getNumberCols(i)-1,n),top:Math.max(0,o),bottom:Math.min(this.getters.getNumberRows(i)-1,s)}},{col:m,row:f}=this.getReferencePosition();let v=0;for(;null!==g;){if(v++,d<0){const e=this.getNextAvailableCol(d,a-(v-1),f);g=m<=a-v?p({top:l,left:r,bottom:c,right:e}):null}if(d>0){const e=this.getNextAvailableCol(d,r+(v-1),f);g=r+v<=m?p({top:l,left:e,bottom:c,right:a}):null}if(u<0){const e=this.getNextAvailableRow(u,m,c-(v-1));g=f<=c-v?p({top:l,left:r,bottom:e,right:a}):null}if(u>0){const e=this.getNextAvailableRow(u,m,l+(v-1));g=l+v<=f?p({top:e,left:r,bottom:c,right:a}):null}if(g=g?Ji(g):g,g&&!Bi(g,n.zone))return this.processEvent({type:"ZonesSelected",mode:"updateAnchor",anchor:{zone:g,cell:{col:o,row:s}}})}g=p(Vi({top:s,bottom:s,left:o,right:o},Ji({top:this.getNextAvailableRow(u,m,l),left:this.getNextAvailableCol(d,r,f),bottom:this.getNextAvailableRow(u,m,c),right:this.getNextAvailableCol(d,a,f)})));const b={zone:g,cell:{col:o,row:s}};return this.processEvent({type:"ZonesSelected",anchor:b,mode:"updateAnchor"})}selectColumn(e,t){const i=this.getters.getActiveSheetId(),n=this.getters.getNumberRows(i)-1;let o={left:e,right:e,top:0,bottom:n};const s=this.getters.findFirstVisibleColRowIndex(i,"ROW");let r,a;switch(t){case"overrideSelection":case"newAnchor":r=e,a=s;break;case"updateAnchor":({col:r,row:a}=this.anchor.cell),o=Vi(o,{left:r,right:r,top:s,bottom:n})}return this.processEvent({type:"HeadersSelected",anchor:{zone:o,cell:{col:r,row:a}},mode:t})}selectRow(e,t){const i=this.getters.getActiveSheetId(),n=this.getters.getNumberCols(i)-1;let o={top:e,bottom:e,left:0,right:n};const s=this.getters.findFirstVisibleColRowIndex(i,"COL");let r,a;switch(t){case"overrideSelection":case"newAnchor":r=s,a=e;break;case"updateAnchor":({col:r,row:a}=this.anchor.cell),o=Vi(o,{left:s,right:n,top:a,bottom:a})}return this.processEvent({type:"HeadersSelected",anchor:{zone:o,cell:{col:r,row:a}},mode:t})}loopSelection(){const e=this.getters.getActiveSheetId(),t=this.anchor,i=e=>{for(const t of $e(e.left,e.right+1)){if(!this.isCellEmpty({col:t,row:e.top-1}))return{...e,top:e.top-1};if(!this.isCellEmpty({col:t,row:e.bottom+1}))return{...e,bottom:e.bottom+1}}for(const t of $e(e.top,e.bottom+1)){if(!this.isCellEmpty({col:e.left-1,row:t}))return{...e,left:e.left-1};if(!this.isCellEmpty({col:e.right+1,row:t}))return{...e,right:e.right+1}}return e};if(Bi(this.anchor.zone,this.getters.getSheetZone(e)))return this.selectZone({...t,zone:en(t.cell)});let n=!1,o=!1,s=t.zone;do{o=o||n,n=!1;const e=i(s);Bi(s,e)||(n=!0,s=e)}while(n);return o?this.selectZone({...t,zone:s}):this.selectAll()}selectAll(){const e=this.getters.getActiveSheetId(),t={left:0,top:0,bottom:this.getters.getNumberRows(e)-1,right:this.getters.getNumberCols(e)-1};return this.processEvent({type:"HeadersSelected",mode:"overrideSelection",anchor:{zone:t,cell:this.anchor.cell}})}isListening(e){return this.stream.isListening(e)}processEvent(e){const t={...e,previousAnchor:Ae(this.anchor)},i=this.checkEventAnchorZone(t);return 0!==i?new fn(i):(this.anchor=t.anchor,this.stream.send(t),fn.Success)}checkEventAnchorZone(e){return this.checkAnchorZone(e.anchor)}checkAnchorZone(e){const{cell:t,zone:i}=e;if(!Wi(t.col,t.row,i))return 16;const{left:n,right:o,top:s,bottom:r}=i,a=this.getters.getActiveSheetId(),l=this.getters.findVisibleHeader(a,"COL",n,o);return void 0===this.getters.findVisibleHeader(a,"ROW",s,r)||void 0===l?17:0}checkAnchorZoneOrThrow(e){if(16===this.checkAnchorZone(e))throw new Error(o("The provided anchor is invalid. The cell must be part of the zone."))}getNextAvailablePosition(e,t=1){const{col:i,row:n}=this.anchor.cell,o=this.deltaToTarget({col:i,row:n},e,t);return{col:this.getNextAvailableCol(o[0],i,n),row:this.getNextAvailableRow(o[1],i,n)}}getNextAvailableCol(e,t,i){const n=this.getters.getActiveSheetId(),o={col:t,row:i};return this.getNextAvailableHeader(e,"COL",t,o,(e=>this.getters.isInSameMerge(n,t,i,e,i)))}getNextAvailableRow(e,t,i){const n=this.getters.getActiveSheetId(),o={col:t,row:i};return this.getNextAvailableHeader(e,"ROW",i,o,(e=>this.getters.isInSameMerge(n,t,i,t,e)))}getNextAvailableHeader(e,t,i,n,o){const s=this.getters.getActiveSheetId();if(0===e)return i;const r=Math.sign(e);let a=i+e;for(;o(a);)a+=r;for(;this.getters.isHeaderHidden(s,t,a);)a+=r;return a<0||a>this.getters.getNumberHeaders(s,t)-1?this.getters.isHeaderHidden(s,t,i)?this.getNextAvailableHeader(-r,t,i,n,o):i:a}getReferencePosition(){const e=this.getters.getActiveSheetId(),t=this.anchor,{left:i,right:n,top:o,bottom:s}=t.zone,{col:r,row:a}=t.cell;return{col:this.getters.isColHidden(e,r)&&this.getters.findVisibleHeader(e,"COL",i,n)||r,row:this.getters.isRowHidden(e,a)&&this.getters.findVisibleHeader(e,"ROW",o,s)||a}}deltaToTarget(e,t,i){switch(t){case"up":return"end"!==i?[0,-i]:[0,this.getEndOfCluster(e,"rows",-1)-e.row];case"down":return"end"!==i?[0,i]:[0,this.getEndOfCluster(e,"rows",1)-e.row];case"left":return"end"!==i?[-i,0]:[this.getEndOfCluster(e,"cols",-1)-e.col,0];case"right":return"end"!==i?[i,0]:[this.getEndOfCluster(e,"cols",1)-e.col,0]}}getStartingPosition(e){let{col:t,row:i}=this.getPosition();const n=this.anchor.zone;switch(e){case"down":case"up":i=i===n.top?n.bottom:n.top;break;case"left":case"right":t=t===n.right?n.left:n.right}return{col:t,row:i}}getEndOfCluster(e,t,i){const n=this.getters.getActiveSheet();let o=e;const s=this.getNextCellPosition(e,t,i);let r=this.isCellEmpty(o,n.id)||this.isCellEmpty(s,n.id)?"nextCluster":"endOfCluster";for(;;){const e=this.getNextCellPosition(o,t,i);if(o.col===e.col&&o.row===e.row)break;const s=this.isCellEmpty(e,n.id);if("endOfCluster"===r&&s)break;if("nextCluster"===r&&!s){o=e;break}o=e}return"cols"===t?o.col:o.row}isCellEmpty({col:e,row:t},i=this.getters.getActiveSheetId()){const n=this.getters.getMainCellPosition(i,e,t),o=this.getters.getCell(i,n.col,n.row);return!o||o.isEmpty()}getNextCellPosition(e,t,i){const n="cols"===t?"col":"row",o={...e},s="cols"===t?this.getNextAvailableCol(i,o.col,o.row):this.getNextAvailableRow(i,o.col,o.row);return o[n]=s,{col:o.col,row:o.row}}getPosition(){return{...this.anchor.cell}}}class zb{constructor(){this.changes=[],this.commands=[]}recordChanges(e){return this.changes=[],this.commands=[],e(),{changes:this.changes,commands:this.commands}}addCommand(e){this.commands.push(e)}addChange(...e){const t=e.pop();let i=e[0],n=e[e.length-1];const o=e.length-2;for(let t=1;t<=o;t++){const n=e[t];if(void 0===i[n]){const o=e[t+1];i[n]=Ab(o)}i=i[n]}i[n]!==t&&(this.changes.push({path:e,before:i[n],after:t}),void 0===t?delete i[n]:i[n]=t)}}const Bb=17781237,Hb=88853993;function Wb(e,t,i){const n=[["xmlns:r",Jp],["xmlns:a",Yp],["xmlns:c",Xp]],o=Gb({backgroundColor:e.data.backgroundColor,line:{color:"000000"}});let s=kf``;e.data.title&&(s=kf`
1995
+ `;class Rb extends t.Component{constructor(){super(...arguments),this.isViewportTooSmall=!1}getStyle(){return this.env.isDashboard()?"grid-template-rows: auto;":"grid-template-rows: 63px auto 37px"}setup(){var e,i;null===(i=(e=this.props).exposeSpreadsheet)||void 0===i||i.call(e,this),this.model=this.props.model,this.sidePanel=t.useState({isOpen:!1,panelProps:{}}),this.composer=t.useState({topBarFocus:"inactive",gridFocusMode:"inactive"}),this.keyDownMapping={"CTRL+H":()=>this.toggleSidePanel("FindAndReplace",{}),"CTRL+F":()=>this.toggleSidePanel("FindAndReplace",{})},t.useSubEnv({model:this.model,isDashboard:()=>this.model.getters.isDashboard(),openSidePanel:this.openSidePanel.bind(this),toggleSidePanel:this.toggleSidePanel.bind(this),_t:Rb._t,clipboard:navigator.clipboard,focusableElement:new vb}),t.useExternalListener(window,"resize",(()=>this.render(!0))),t.useExternalListener(window,"beforeunload",this.unbindModelEvents.bind(this)),t.useExternalListener(document.body,"wheel",(()=>{})),this.bindModelEvents(),t.onMounted((()=>{this.checkViewportSize()})),t.onWillUnmount((()=>this.unbindModelEvents())),t.onPatched((()=>{this.checkViewportSize()}))}get focusTopBarComposer(){return"inactive"===this.model.getters.getEditionMode()?"inactive":this.composer.topBarFocus}get focusGridComposer(){return"inactive"===this.model.getters.getEditionMode()?"inactive":this.composer.gridFocusMode}bindModelEvents(){this.model.on("update",this,(()=>this.render(!0))),this.model.on("notify-ui",this,this.onNotifyUI)}unbindModelEvents(){this.model.off("update",this),this.model.off("notify-ui",this)}checkViewportSize(){const{xRatio:e,yRatio:t}=this.env.model.getters.getFrozenSheetViewRatio(this.env.model.getters.getActiveSheetId());if(t>.85||e>.85){if(this.isViewportTooSmall)return;this.env.notifyUser({text:s("The current window is too small to display this sheet properly. Consider resizing your browser window or adjusting frozen rows and columns."),tag:"viewportTooSmall"}),this.isViewportTooSmall=!0}else this.isViewportTooSmall=!1}onNotifyUI(e){if("ERROR"===e.type)this.env.raiseError(e.text)}openSidePanel(e,t){this.sidePanel.component=e,this.sidePanel.panelProps=t,this.sidePanel.isOpen=!0}closeSidePanel(){this.sidePanel.isOpen=!1,this.focusGrid()}toggleSidePanel(e,t){this.sidePanel.isOpen&&e===this.sidePanel.component?(this.sidePanel.isOpen=!1,this.focusGrid()):this.openSidePanel(e,t)}focusGrid(){if(!this._focusGrid)throw new Error("_focusGrid should be exposed by the grid component");this._focusGrid()}save(){var e,t;null===(t=(e=this.props).onContentSaved)||void 0===t||t.call(e,this.model.exportData())}onKeydown(e){let t="";zn(e)&&(t+="CTRL+"),t+=e.key.toUpperCase();let i=this.keyDownMapping[t];if(i)return e.preventDefault(),e.stopPropagation(),void i()}onTopBarComposerFocused(e){this.model.getters.isReadonly()||(this.model.dispatch("UNFOCUS_SELECTION_INPUT"),this.composer.topBarFocus="contentFocus",this.composer.gridFocusMode="inactive",this.setComposerContent({selection:e}))}onGridComposerContentFocused(e){this.model.getters.isReadonly()||(this.model.dispatch("UNFOCUS_SELECTION_INPUT"),this.composer.topBarFocus="inactive",this.composer.gridFocusMode="contentFocus",this.setComposerContent({selection:e}))}onGridComposerCellFocused(e,t){this.model.getters.isReadonly()||(this.model.dispatch("UNFOCUS_SELECTION_INPUT"),this.composer.topBarFocus="inactive",this.composer.gridFocusMode="cellFocus",this.setComposerContent({content:e,selection:t}||{}))}setComposerContent({content:e,selection:t}){"inactive"===this.model.getters.getEditionMode()?this.model.dispatch("START_EDITION",{text:e,selection:t}):e&&this.model.dispatch("SET_CURRENT_CONTENT",{content:e,selection:t})}get gridHeight(){const{height:e}=this.env.model.getters.getSheetViewDimension();return e}}Rb.template="o-spreadsheet-Spreadsheet",Rb.components={TopBar:xb,Grid:Mp,BottomBar:bb,SidePanel:Cb,SpreadsheetDashboard:Sb},Rb._t=e=>e;class Ib{constructor(){this.listeners=[]}sendMessage(e){for(const{callback:t}of this.listeners)t(e)}onNewMessage(e,t){this.listeners.push({id:e,callback:t})}leave(e){this.listeners=this.listeners.filter((t=>t.id!==e))}}function Tb(e){return so.get(e.type)(e)}function Ab(e){if("string"==typeof e)return{};if("number"==typeof e)return[];throw new Error("Cannot create new node")}class Nb{constructor(e,t=[]){this.buildTransformation=e,this.operations=t}getOperations(){return this.operations}getOperation(e){const t=this.operations.find((t=>t.id===e));if(!t)throw new Error(`Operation ${e} not found`);return t}getLastOperationId(){var e;return null===(e=this.operations[this.operations.length-1])||void 0===e?void 0:e.id}getFirstOperationAmong(e,t){for(const i of this.operations){if(i.id===e)return e;if(i.id===t)return t}throw new Error(`Operation ${e} and ${t} not found`)}contains(e){return!!this.operations.find((t=>t.id===e))}prepend(e){const t=this.buildTransformation.with(e.data);this.operations=[e,...this.operations.map((e=>e.transformed(t)))]}insert(e,t){const i=this.buildTransformation.with(e.data),{before:n,operation:o,after:s}=this.locateOperation(t);this.operations=[...n,o,e,...s.map((e=>e.transformed(i)))]}append(e){this.operations.push(e)}appendBranch(e){this.operations=this.operations.concat(e.operations)}fork(e){const{after:t}=this.locateOperation(e);return new Nb(this.buildTransformation,t)}transform(e){this.operations=this.operations.map((t=>t.transformed(e)))}cutBefore(e){this.operations=this.locateOperation(e).before}cutAfter(e){const{before:t,operation:i}=this.locateOperation(e);this.operations=t.concat([i])}locateOperation(e){const t=this.operations.findIndex((t=>t.id===e));if(-1===t)throw new Error(`Operation ${e} not found`);return{before:this.operations.slice(0,t),operation:this.operations[t],after:this.operations.slice(t+1)}}}class Ob{constructor(e,t){this.id=e,this.data=t}transformed(e){return new Mb(this.id,tt((()=>e(this.data))))}}class Mb{constructor(e,t){this.id=e,this.lazyData=t}get data(){return this.lazyData()}transformed(e){return new Mb(this.id,this.lazyData.map(e))}}class _b{constructor(e){this.operations=e}[Symbol.iterator](){return this.operations[Symbol.iterator]()}stopWith(e){return new _b(function*(e,t){for(const i of e)if(yield i,i.operation.id===t)return}(this.operations,e))}stopBefore(e){return new _b(function*(e,t){for(const i of e){if(i.operation.id===t)return;yield i}}(this.operations,e))}startAfter(e){return new _b(function*(e,t){let i=!0;for(const n of e)i||(yield n),n.operation.id===t&&(i=!1)}(this.operations,e))}}class Fb{constructor(e,t){this.buildTransformation=e,this.branchingOperationIds=new Map,this.branches=[t]}getLastBranch(){return this.branches[this.branches.length-1]}execution(e){return new _b(Pe(this._execution(e),this._execution(e)))}revertedExecution(e){return new _b(Pe(this._revertedExecution(e),this._revertedExecution(e)))}insertOperationLast(e,t){var i;const n=e.getLastOperationId()||(null===(i=this.previousBranch(e))||void 0===i?void 0:i.getLastOperationId());e.append(t),n&&this.insertPrevious(e,t,n)}insertOperationAfter(e,t,i){e.insert(t,i),this.updateNextWith(e,t,i),this.insertPrevious(e,t,i)}undo(e,t){const i=this.buildTransformation.without(t.data),n=this.branchingOperationIds.get(e);this.branchingOperationIds.set(e,t.id);const o=e.fork(t.id);n&&this.branchingOperationIds.set(o,n),this.insertBranchAfter(e,o),this.transform(o,i)}redo(e){const t=this.nextBranch(e);if(!t)return;const i=this.nextBranch(t);this.removeBranchFromTree(t);const n=this.branchingOperationIds.get(t);n?this.branchingOperationIds.set(e,n):this.branchingOperationIds.delete(e),i&&this.rebaseUp(i)}drop(e){for(const t of this.branches)t.contains(e)&&t.cutBefore(e)}findOperation(e,t){for(const i of this.revertedExecution(e))if(i.operation.id===t)return i;throw new Error(`Operation ${t} not found`)}rebaseUp(e){const{previousBranch:t,branchingOperation:i}=this.findPreviousBranchingOperation(e);if(!t||!i)return;const n=this.buildTransformation.without(i.data),o=t.fork(i.id);this.branchingOperationIds.set(o,this.branchingOperationIds.get(e)),this.removeBranchFromTree(e),this.insertBranchAfter(t,o),o.transform(n);const s=this.nextBranch(o);s&&this.rebaseUp(s)}removeBranchFromTree(e){const t=this.branches.findIndex((t=>t===e));this.branches.splice(t,1)}insertBranchAfter(e,t){const i=this.branches.findIndex((t=>t===e));this.branches.splice(i+1,0,t)}updateNextWith(e,t,i){const n=this.branchingOperationIds.get(e),o=this.nextBranch(e);if(n&&o)if(e.getFirstOperationAmong(i,n)===n){const s=this.addToNextBranch(e,o,n,t,i);this.updateNextWith(o,s,i)}else{const e=this.buildTransformation.with(t.data);this.transform(o,e)}}addToNextBranch(e,t,i,n,o){let s=n;return o===i?(s=this.getTransformedOperation(e,i,n),t.prepend(s)):t.contains(o)?(s=this.getTransformedOperation(e,i,n),t.insert(s,o)):t.append(n),s}getTransformedOperation(e,t,i){const n=e.getOperation(t),o=this.buildTransformation.without(n.data);return i.transformed(o)}shouldExecute(e,t){return t.id!==this.branchingOperationIds.get(e)}transform(e,t){e.transform(t);const i=this.nextBranch(e);i&&this.transform(i,t)}insertPrevious(e,t,i){const{previousBranch:n,branchingOperation:o}=this.findPreviousBranchingOperation(e);if(!n||!o)return;const s=this.buildTransformation.with(o.data),r=e.fork(i);r.transform(s),n.cutAfter(i),n.appendBranch(r);const a=t.transformed(s);this.insertPrevious(n,a,i)}findPreviousBranchingOperation(e){const t=this.previousBranch(e);if(!t)return{previousBranch:void 0,branchingOperation:void 0};const i=this.branchingOperationIds.get(t);return i?{previousBranch:t,branchingOperation:t.getOperation(i)}:{previousBranch:void 0,branchingOperation:void 0}}nextBranch(e){const t=this.branches.findIndex((t=>t===e));if(-1!==t)return this.branches[t+1]}previousBranch(e){const t=this.branches.findIndex((t=>t===e));if(-1!==t)return this.branches[t-1]}*_revertedExecution(e){const t=this.branchingOperationIds.get(e);let i=!!t;const n=e.getOperations();for(let o=n.length-1;o>=0;o--){const s=n[o];s.id===t&&(i=!1),i||(yield{operation:s,branch:e,isCancelled:!this.shouldExecute(e,s)})}const o=this.previousBranch(e);yield*o?this._revertedExecution(o):[]}*_execution(e){for(const t of e.getOperations())if(yield{operation:t,branch:e,isCancelled:!this.shouldExecute(e,t)},t.id===this.branchingOperationIds.get(e)){const t=this.nextBranch(e);return void(yield*t?this._execution(t):[])}if(!this.branchingOperationIds.get(e)){const t=this.nextBranch(e);yield*t?this._execution(t):[]}}}class Db{constructor(e,t,i,n,o){this.applyOperation=t,this.revertOperation=i,this.buildEmpty=n,this.buildTransformation=o,this.HEAD_BRANCH=new Nb(this.buildTransformation),this.tree=new Fb(o,this.HEAD_BRANCH);const s=new Ob(e,n(e));this.tree.insertOperationLast(this.HEAD_BRANCH,s),this.HEAD_OPERATION=s}get(e){return this.tree.findOperation(this.HEAD_BRANCH,e).operation.data}append(e,t){const i=new Ob(e,t),n=this.tree.getLastBranch();this.tree.insertOperationLast(n,i),this.HEAD_BRANCH=n,this.HEAD_OPERATION=i}insert(e,t,i){const n=new Ob(e,t);this.revertTo(i),this.tree.insertOperationAfter(this.HEAD_BRANCH,n,i),this.fastForward()}undo(e,t,i){const{branch:n,operation:o}=this.tree.findOperation(this.HEAD_BRANCH,e);this.revertBefore(e),this.tree.undo(n,o),this.fastForward(),this.insert(t,this.buildEmpty(t),i)}redo(e,t,i){const{branch:n}=this.tree.findOperation(this.HEAD_BRANCH,e);this.revertBefore(e),this.tree.redo(n),this.fastForward(),this.insert(t,this.buildEmpty(t),i)}rebase(e){const t=this.get(e),i=[...this.tree.execution(this.HEAD_BRANCH).startAfter(e)];this.revertBefore(e);const n=this.HEAD_OPERATION.id;this.tree.drop(e),this.insert(e,t,n);for(const{operation:e}of i)this.insert(e.id,e.data,this.HEAD_OPERATION.id)}revertBefore(e){const t=this.tree.revertedExecution(this.HEAD_BRANCH).stopWith(e);this.revert(t)}revertTo(e){const t=e?this.tree.revertedExecution(this.HEAD_BRANCH).stopBefore(e):this.tree.revertedExecution(this.HEAD_BRANCH);this.revert(t)}revert(e){for(const{next:t,operation:i,isCancelled:n}of e)n||this.revertOperation(i.data),t&&(this.HEAD_BRANCH=t.branch,this.HEAD_OPERATION=t.operation)}fastForward(){const e=this.HEAD_OPERATION?this.tree.execution(this.HEAD_BRANCH).startAfter(this.HEAD_OPERATION.id):this.tree.execution(this.HEAD_BRANCH);for(const{operation:t,branch:i,isCancelled:n}of e)n||this.applyOperation(t.data),this.HEAD_OPERATION=t,this.HEAD_BRANCH=i}}function kb(e,t,i){return new Db(e,(e=>{const n=e.commands.slice(),{changes:o}=t((()=>{for(const e of n)i(e)}));e.setChanges(o)}),(e=>function(e){for(const t of e.slice().reverse())for(let e=t.changes.length-1;e>=0;e--){$b(t.changes[e],"before")}}([e])),(e=>new ob(e,"empty",[],[])),{with:e=>t=>new ob(t.id,t.clientId,ib(t.commands,e.commands)),without:e=>t=>new ob(t.id,t.clientId,ib(t.commands,e.commands.map(Tb).flat()))})}function $b(e,t){let i=e.path[0];const n=e.path[e.path.length-1];for(let t=1;t<e.path.slice(0,-1).length;t++){const n=e.path[t];if(void 0===i[n]){const o=e.path[t+1];i[n]=Ab(o)}i=i[n]}void 0===e[t]?delete i[n]:i[n]=e[t]}class Lb extends t.EventBus{constructor(e,t){super(),this.dispatch=e,this.session=t,this.undoStack=[],this.redoStack=[],this.session.on("new-local-state-update",this,this.onNewLocalStateUpdate),this.session.on("revision-undone",this,(({commands:e})=>this.selectiveUndo(e))),this.session.on("revision-redone",this,(({commands:e})=>this.selectiveRedo(e))),this.session.on("snapshot",this,(()=>{this.undoStack=[],this.redoStack=[]}))}allowDispatch(e){switch(e.type){case"REQUEST_UNDO":if(!this.canUndo())return 6;break;case"REQUEST_REDO":if(!this.canRedo())return 7}return 0}beforeHandle(e){}handle(e){switch(e.type){case"REQUEST_UNDO":case"REQUEST_REDO":this.requestHistoryChange("REQUEST_UNDO"===e.type?"UNDO":"REDO")}}finalize(){}requestHistoryChange(e){const t="UNDO"===e?this.undoStack.pop():this.redoStack.pop();t&&("UNDO"===e?(this.session.undo(t),this.redoStack.push(t)):(this.session.redo(t),this.undoStack.push(t)))}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}onNewLocalStateUpdate({id:e}){this.undoStack.push(e),this.redoStack=[],this.undoStack.length>99&&this.undoStack.shift()}selectiveUndo(e){this.dispatch("UNDO",{commands:e})}selectiveRedo(e){this.dispatch("REDO",{commands:e})}}class Pb{constructor(e){this.providers=[],this.getters=e}allowDispatch(e){return"MOVE_RANGES"===e.type?1===e.target.length?0:26:0}beforeHandle(e){}handle(e){switch(e.type){case"REMOVE_COLUMNS_ROWS":{let t="COL"===e.dimension?"left":"top",i="COL"===e.dimension?"right":"bottom",n="COL"===e.dimension?"columns":"rows";const o=[...e.elements];o.sort(((e,t)=>t-e));const s=Le(o);this.executeOnAllRanges((o=>{if(o.sheetId!==e.sheetId)return{changeType:"NONE"};let r=o,a="NONE";for(let e of s){const s=ct(e),l=lt(e);if(o.zone[t]<=s&&s<=o.zone[i]){const e=Math.min(o.zone[i],l)-s+1;a="RESIZE",r=this.createAdaptedRange(r,n,a,-e)}else if(o.zone[t]>=s&&o.zone[i]<=l)a="REMOVE",r=o.clone({...this.getInvalidRange()});else if(o.zone[t]<=l&&o.zone[i]>=l){const e=l-o.zone[t]+1;a="RESIZE",r=this.createAdaptedRange(r,n,a,-e),r=this.createAdaptedRange(r,n,"MOVE",-(o.zone[t]-s))}else s<o.zone[t]&&(a="MOVE",r=this.createAdaptedRange(r,n,a,-(l-s+1)))}return"NONE"!==a?{changeType:a,range:r}:{changeType:"NONE"}}),e.sheetId);break}case"ADD_COLUMNS_ROWS":{let t="COL"===e.dimension?"left":"top",i="COL"===e.dimension?"right":"bottom",n="COL"===e.dimension?"columns":"rows";this.executeOnAllRanges((o=>{if(o.sheetId!==e.sheetId)return{changeType:"NONE"};if("after"===e.position){if(o.zone[t]<=e.base&&e.base<o.zone[i])return{changeType:"RESIZE",range:this.createAdaptedRange(o,n,"RESIZE",e.quantity)};if(e.base<o.zone[t])return{changeType:"MOVE",range:this.createAdaptedRange(o,n,"MOVE",e.quantity)}}else{if(o.zone[t]<e.base&&e.base<=o.zone[i])return{changeType:"RESIZE",range:this.createAdaptedRange(o,n,"RESIZE",e.quantity)};if(e.base<=o.zone[t])return{changeType:"MOVE",range:this.createAdaptedRange(o,n,"MOVE",e.quantity)}}return{changeType:"NONE"}}),e.sheetId);break}case"DELETE_SHEET":this.executeOnAllRanges((t=>{if(t.sheetId!==e.sheetId)return{changeType:"NONE"};const i=this.getters.getSheetName(e.sheetId);return{changeType:"REMOVE",range:t=t.clone({...this.getInvalidRange(),invalidSheetName:i})}}),e.sheetId);break;case"RENAME_SHEET":this.executeOnAllRanges((t=>{if(t.sheetId===e.sheetId)return{changeType:"CHANGE",range:t};if(Ai(t.invalidSheetName,e.name)){const i=void 0,n=e.sheetId;return{changeType:"CHANGE",range:t.clone({sheetId:n,invalidSheetName:i})}}return{changeType:"NONE"}}));break;case"MOVE_RANGES":{const t=e.target[0];this.executeOnAllRanges((i=>{if(i.sheetId!==e.sheetId||!Gi(i.zone,t))return{changeType:"NONE"};const n=e.targetSheetId,o=e.col-t.left,s=e.row-t.top,r=this.createAdaptedRange(i,"both","MOVE",[o,s]),a=e.sheetId!==n||r.prefixSheet;return{changeType:"MOVE",range:r.clone({sheetId:n,prefixSheet:a})}}));break}}}finalize(){}verifyRangeRemoved(e){return t=>{const i=e(t);return"NONE"===i.changeType||Di(i.range.zone)?i:{range:i.range,changeType:"REMOVE"}}}createAdaptedRange(e,t,i,n){const o=Ki(e.unboundedZone,t,i,n);return e.clone({zone:o})}executeOnAllRanges(e,t){const i=this.verifyRangeRemoved(e);for(const e of this.providers)e(i,t)}addRangeProvider(e){this.providers.push(e)}createAdaptedRanges(e,t,i,n){const o=e.map((e=>xi.fromRange(e,this.getters)));return o.map((e=>{if(!Di(e.zone))return e;const o=e.prefixSheet?e.sheetId:n,s={...e.unboundedZone,left:e.isFullRow&&!e.unboundedZone.hasHeader?e.unboundedZone.left:e.unboundedZone.left+(e.parts[0].colFixed?0:t),right:e.isFullRow?e.unboundedZone.right:e.unboundedZone.right+((e.parts[1]||e.parts[0]).colFixed?0:t),top:e.isFullCol&&!e.unboundedZone.hasHeader?e.unboundedZone.top:e.unboundedZone.top+(e.parts[0].rowFixed?0:i),bottom:e.isFullCol?e.unboundedZone.bottom:e.unboundedZone.bottom+((e.parts[1]||e.parts[0]).rowFixed?0:i)};return(e=e.clone({sheetId:o,zone:s})).orderZone(),e}))}getRangeFromSheetXC(e,t){if(!Ot.test(t)||!this.getters.tryGetSheet(e))return new xi({sheetId:"",zone:{left:-1,top:-1,right:-1,bottom:-1},parts:[],invalidXc:t,prefixSheet:!1},this.getters.getSheetSize);let i,n=t,o=!1;t.includes("!")&&(({xc:n,sheetName:i}=$t(t)),i&&(o=!0));const s=_i(n),r=xi.getRangeParts(n,s),a=i&&!this.getters.getSheetIdByName(i)?i:void 0,l=this.getters.getSheetIdByName(i)||e,c=new xi({prefixSheet:o,zone:s,sheetId:l,invalidSheetName:a,parts:r},this.getters.getSheetSize);return c.orderZone(),c}getSelectionRangeString(e,t){const i=xi.fromRange(e,this.getters),n=this.getters.expandZone(i.sheetId,i.zone),o=i.clone({zone:{...n,bottom:i.isFullCol?void 0:n.bottom,right:i.isFullRow?void 0:n.right}});return this.getRangeString(o,t)}getRangeString(e,t,i=!1){if(!e)return X;if(e.invalidXc)return e.invalidXc;if(!this.getters.tryGetSheet(e.sheetId))return X;if(e.zone.bottom-e.zone.top<0||e.zone.right-e.zone.left<0)return X;if(e.zone.left<0||e.zone.top<0)return X;const n=xi.fromRange(e,this.getters);let o=n.sheetId!==t||n.invalidSheetName||n.prefixSheet,s="";if(o&&(s=n.invalidSheetName?n.invalidSheetName:Oe(this.getters.getSheetName(n.sheetId))),o&&!s)return X;let r=this.getRangePartString(n,0,i);return n.parts&&2===n.parts.length&&(n.zone.top!==n.zone.bottom||n.zone.left!==n.zone.right||n.parts[0].rowFixed||n.parts[0].colFixed||n.parts[1].rowFixed||n.parts[1].colFixed)&&(r+=":",r+=this.getRangePartString(n,1,i)),`${o?s+"!":""}${r}`}getRangeDataFromXc(e,t){return this.getters.getRangeFromSheetXC(e,t).rangeData}getRangeDataFromZone(e,t){return{_sheetId:e,_zone:t}}getRangeFromRangeData(e){const t={prefixSheet:!1,zone:e._zone,sheetId:e._sheetId,invalidSheetName:void 0,parts:[{colFixed:!1,rowFixed:!1},{colFixed:!1,rowFixed:!1}]};return new xi(t,this.getters.getSheetSize)}getRangePartString(e,t,i=!1){var n,o;const s=e.parts&&(null===(n=e.parts[t])||void 0===n?void 0:n.colFixed)?"$":"",r=Lt(0===t?e.zone.left:e.zone.right),a=e.parts&&(null===(o=e.parts[t])||void 0===o?void 0:o.rowFixed)?"$":"",l=String(0===t?e.zone.top+1:e.zone.bottom+1);let c="";return c=e.isFullCol&&!i?0===t&&e.unboundedZone.hasHeader?s+r+a+l:s+r:e.isFullRow&&!i?0===t&&e.unboundedZone.hasHeader?s+r+a+l:a+l:s+r+a+l,c}getInvalidRange(){return{parts:[],prefixSheet:!1,zone:{left:-1,top:-1,right:-1,bottom:-1},sheetId:"",invalidXc:X}}}Pb.getters=["getRangeString","getSelectionRangeString","getRangeFromSheetXC","createAdaptedRanges","getRangeDataFromXc","getRangeDataFromZone","getRangeFromRangeData"];class Ub{constructor(){this.observers=[]}registerAsDefault(e,t){this.defaultSubscription={owner:e,callbacks:t},this.mainSubscription||(this.mainSubscription=this.defaultSubscription)}observe(e,t){this.observers.push({owner:e,callbacks:t})}capture(e,t){var i,n,o;if(this.observers.find((t=>t.owner===e)))throw new Error("You are already subscribed forever");(null===(i=this.mainSubscription)||void 0===i?void 0:i.owner)&&this.mainSubscription.owner!==e&&(null===(o=(n=this.mainSubscription.callbacks).release)||void 0===o||o.call(n)),this.mainSubscription={owner:e,callbacks:t}}release(e){var t;(null===(t=this.mainSubscription)||void 0===t?void 0:t.owner)!==e||this.observers.find((t=>t.owner===e))||(this.mainSubscription=this.defaultSubscription)}getBackToDefault(){var e,t,i;this.mainSubscription!==this.defaultSubscription&&(null===(i=null===(e=this.mainSubscription)||void 0===e?void 0:(t=e.callbacks).release)||void 0===i||i.call(t),this.mainSubscription=this.defaultSubscription)}isListening(e){var t;return(null===(t=this.mainSubscription)||void 0===t?void 0:t.owner)===e}send(e){var t;null===(t=this.mainSubscription)||void 0===t||t.callbacks.handleEvent(e),[...this.observers].forEach((t=>t.callbacks.handleEvent(e)))}}class Vb{constructor(e){this.getters=e,this.stream=new Ub,this.anchor={cell:{col:0,row:0},zone:en({col:0,row:0})},this.defaultAnchor=this.anchor}capture(e,t,i){this.stream.capture(e,i),this.anchor=t}registerAsDefault(e,t,i){this.checkAnchorZoneOrThrow(t),this.stream.registerAsDefault(e,i),this.defaultAnchor=t,this.capture(e,t,i)}resetDefaultAnchor(e,t){this.checkAnchorZoneOrThrow(t),this.stream.isListening(e)&&(this.anchor=t),this.defaultAnchor=t}resetAnchor(e,t){this.checkAnchorZoneOrThrow(t),this.stream.isListening(e)&&(this.anchor=t)}observe(e,t){this.stream.observe(e,t)}release(e){this.stream.isListening(e)&&(this.stream.release(e),this.anchor=this.defaultAnchor)}getBackToDefault(){this.stream.getBackToDefault()}selectZone(e){const t=this.getters.getActiveSheetId();return e={...e,zone:this.getters.expandZone(t,e.zone)},this.processEvent({type:"ZonesSelected",anchor:e,mode:"overrideSelection"})}selectCell(e,t){const i=en({col:e,row:t});return this.selectZone({zone:i,cell:{col:e,row:t}})}moveAnchorCell(e,t=1){if("end"!==t&&t<=0)return new fn(84);const{col:i,row:n}=this.getNextAvailablePosition(e,t);return this.selectCell(i,n)}setAnchorCorner(e,t){const i=this.getters.getActiveSheetId(),{col:n,row:o}=this.anchor.cell,s={left:Math.min(n,e),top:Math.min(o,t),right:Math.max(n,e),bottom:Math.max(o,t)},r={zone:this.getters.expandZone(i,s),cell:{col:n,row:o}};return this.processEvent({type:"AlterZoneCorner",mode:"updateAnchor",anchor:r})}addCellToSelection(e,t){const i=this.getters.getActiveSheetId();({col:e,row:t}=this.getters.getMainCellPosition(i,e,t));const n=this.getters.expandZone(i,en({col:e,row:t}));return this.processEvent({type:"ZonesSelected",anchor:{zone:n,cell:{col:e,row:t}},mode:"newAnchor"})}resizeAnchorZone(e,t=1){if("end"!==t&&t<=0)return new fn(84);const i=this.getters.getActiveSheetId(),n=this.anchor,{col:o,row:s}=n.cell,{left:r,right:a,top:l,bottom:c}=n.zone,h=this.getStartingPosition(e);let[d,u]=this.deltaToTarget(h,e,t);if(0===d&&0===u)return fn.Success;let g=n.zone;const p=e=>{e=Ji(e);const{left:t,right:n,top:o,bottom:s}=this.getters.expandZone(i,e);return{left:Math.max(0,t),right:Math.min(this.getters.getNumberCols(i)-1,n),top:Math.max(0,o),bottom:Math.min(this.getters.getNumberRows(i)-1,s)}},{cell:m,zone:f}=this.getReferenceAnchor(),{col:v,row:b}=m;let S=0;for(;null!==g;){if(S++,d<0){const e=this.getNextAvailableCol(d,a-(S-1),b);g=f.right<=a-S?p({top:l,left:r,bottom:c,right:e}):null}if(d>0){const e=this.getNextAvailableCol(d,r+(S-1),b);g=r+S<=f.left?p({top:l,left:e,bottom:c,right:a}):null}if(u<0){const e=this.getNextAvailableRow(u,v,c-(S-1));g=f.bottom<=c-S?p({top:l,left:r,bottom:e,right:a}):null}if(u>0){const e=this.getNextAvailableRow(u,v,l+(S-1));g=l+S<=f.top?p({top:e,left:r,bottom:c,right:a}):null}if(g=g?Ji(g):g,g&&!Bi(g,n.zone))return this.processEvent({type:"ZonesSelected",mode:"updateAnchor",anchor:{zone:g,cell:{col:o,row:s}}})}g=p(Vi({top:s,bottom:s,left:o,right:o},Ji({top:this.getNextAvailableRow(u,v,l),left:this.getNextAvailableCol(d,r,b),bottom:this.getNextAvailableRow(u,v,c),right:this.getNextAvailableCol(d,a,b)})));const C={zone:g,cell:{col:o,row:s}};return this.processEvent({type:"ZonesSelected",anchor:C,mode:"updateAnchor"})}selectColumn(e,t){const i=this.getters.getActiveSheetId(),n=this.getters.getNumberRows(i)-1;let o={left:e,right:e,top:0,bottom:n};const s=this.getters.findFirstVisibleColRowIndex(i,"ROW");let r,a;switch(t){case"overrideSelection":case"newAnchor":r=e,a=s;break;case"updateAnchor":({col:r,row:a}=this.anchor.cell),o=Vi(o,{left:r,right:r,top:s,bottom:n})}return this.processEvent({type:"HeadersSelected",anchor:{zone:o,cell:{col:r,row:a}},mode:t})}selectRow(e,t){const i=this.getters.getActiveSheetId(),n=this.getters.getNumberCols(i)-1;let o={top:e,bottom:e,left:0,right:n};const s=this.getters.findFirstVisibleColRowIndex(i,"COL");let r,a;switch(t){case"overrideSelection":case"newAnchor":r=s,a=e;break;case"updateAnchor":({col:r,row:a}=this.anchor.cell),o=Vi(o,{left:s,right:n,top:a,bottom:a})}return this.processEvent({type:"HeadersSelected",anchor:{zone:o,cell:{col:r,row:a}},mode:t})}loopSelection(){const e=this.getters.getActiveSheetId(),t=this.anchor,i=e=>{for(const t of $e(e.left,e.right+1)){if(!this.isCellEmpty({col:t,row:e.top-1}))return{...e,top:e.top-1};if(!this.isCellEmpty({col:t,row:e.bottom+1}))return{...e,bottom:e.bottom+1}}for(const t of $e(e.top,e.bottom+1)){if(!this.isCellEmpty({col:e.left-1,row:t}))return{...e,left:e.left-1};if(!this.isCellEmpty({col:e.right+1,row:t}))return{...e,right:e.right+1}}return e};if(Bi(this.anchor.zone,this.getters.getSheetZone(e)))return this.selectZone({...t,zone:en(t.cell)});let n=!1,o=!1,s=t.zone;do{o=o||n,n=!1;const e=i(s);Bi(s,e)||(n=!0,s=e)}while(n);return o?this.selectZone({...t,zone:s}):this.selectAll()}selectAll(){const e=this.getters.getActiveSheetId(),t={left:0,top:0,bottom:this.getters.getNumberRows(e)-1,right:this.getters.getNumberCols(e)-1};return this.processEvent({type:"HeadersSelected",mode:"overrideSelection",anchor:{zone:t,cell:this.anchor.cell}})}isListening(e){return this.stream.isListening(e)}processEvent(e){const t={...e,previousAnchor:Ae(this.anchor)},i=this.checkEventAnchorZone(t);return 0!==i?new fn(i):(this.anchor=t.anchor,this.stream.send(t),fn.Success)}checkEventAnchorZone(e){return this.checkAnchorZone(e.anchor)}checkAnchorZone(e){const{cell:t,zone:i}=e;if(!Wi(t.col,t.row,i))return 16;const{left:n,right:o,top:s,bottom:r}=i,a=this.getters.getActiveSheetId(),l=this.getters.findVisibleHeader(a,"COL",n,o);return void 0===this.getters.findVisibleHeader(a,"ROW",s,r)||void 0===l?17:0}checkAnchorZoneOrThrow(e){if(16===this.checkAnchorZone(e))throw new Error(o("The provided anchor is invalid. The cell must be part of the zone."))}getNextAvailablePosition(e,t=1){const{col:i,row:n}=this.anchor.cell,o=this.deltaToTarget({col:i,row:n},e,t);return{col:this.getNextAvailableCol(o[0],i,n),row:this.getNextAvailableRow(o[1],i,n)}}getNextAvailableCol(e,t,i){const n=this.getters.getActiveSheetId(),o={col:t,row:i};return this.getNextAvailableHeader(e,"COL",t,o,(e=>this.getters.isInSameMerge(n,t,i,e,i)))}getNextAvailableRow(e,t,i){const n=this.getters.getActiveSheetId(),o={col:t,row:i};return this.getNextAvailableHeader(e,"ROW",i,o,(e=>this.getters.isInSameMerge(n,t,i,t,e)))}getNextAvailableHeader(e,t,i,n,o){const s=this.getters.getActiveSheetId();if(0===e)return i;const r=Math.sign(e);let a=i+e;for(;o(a);)a+=r;for(;this.getters.isHeaderHidden(s,t,a);)a+=r;return a<0||a>this.getters.getNumberHeaders(s,t)-1?this.getters.isHeaderHidden(s,t,i)?this.getNextAvailableHeader(-r,t,i,n,o):i:a}getReferenceAnchor(){const e=this.getters.getActiveSheetId(),t=this.anchor,{left:i,right:n,top:o,bottom:s}=t.zone,{col:r,row:a}=t.cell,l=this.getters.isColHidden(e,r)&&this.getters.findVisibleHeader(e,"COL",i,n)||r,c=this.getters.isRowHidden(e,a)&&this.getters.findVisibleHeader(e,"ROW",o,s)||a;return{cell:{col:l,row:c},zone:this.getters.expandZone(e,{left:l,right:l,top:c,bottom:c})}}deltaToTarget(e,t,i){switch(t){case"up":return"end"!==i?[0,-i]:[0,this.getEndOfCluster(e,"rows",-1)-e.row];case"down":return"end"!==i?[0,i]:[0,this.getEndOfCluster(e,"rows",1)-e.row];case"left":return"end"!==i?[-i,0]:[this.getEndOfCluster(e,"cols",-1)-e.col,0];case"right":return"end"!==i?[i,0]:[this.getEndOfCluster(e,"cols",1)-e.col,0]}}getStartingPosition(e){let{col:t,row:i}=this.getPosition();const n=this.anchor.zone;switch(e){case"down":case"up":i=i===n.top?n.bottom:n.top;break;case"left":case"right":t=t===n.right?n.left:n.right}return{col:t,row:i}}getEndOfCluster(e,t,i){const n=this.getters.getActiveSheet();let o=e;const s=this.getNextCellPosition(e,t,i);let r=this.isCellEmpty(o,n.id)||this.isCellEmpty(s,n.id)?"nextCluster":"endOfCluster";for(;;){const e=this.getNextCellPosition(o,t,i);if(o.col===e.col&&o.row===e.row)break;const s=this.isCellEmpty(e,n.id);if("endOfCluster"===r&&s)break;if("nextCluster"===r&&!s){o=e;break}o=e}return"cols"===t?o.col:o.row}isCellEmpty({col:e,row:t},i=this.getters.getActiveSheetId()){const n=this.getters.getMainCellPosition(i,e,t),o=this.getters.getCell(i,n.col,n.row);return!o||o.isEmpty()}getNextCellPosition(e,t,i){const n="cols"===t?"col":"row",o={...e},s="cols"===t?this.getNextAvailableCol(i,o.col,o.row):this.getNextAvailableRow(i,o.col,o.row);return o[n]=s,{col:o.col,row:o.row}}getPosition(){return{...this.anchor.cell}}}class zb{constructor(){this.changes=[],this.commands=[]}recordChanges(e){return this.changes=[],this.commands=[],e(),{changes:this.changes,commands:this.commands}}addCommand(e){this.commands.push(e)}addChange(...e){const t=e.pop();let i=e[0],n=e[e.length-1];const o=e.length-2;for(let t=1;t<=o;t++){const n=e[t];if(void 0===i[n]){const o=e[t+1];i[n]=Ab(o)}i=i[n]}i[n]!==t&&(this.changes.push({path:e,before:i[n],after:t}),void 0===t?delete i[n]:i[n]=t)}}const Bb=17781237,Hb=88853993;function Wb(e,t,i){const n=[["xmlns:r",Jp],["xmlns:a",Yp],["xmlns:c",Xp]],o=Gb({backgroundColor:e.data.backgroundColor,line:{color:"000000"}});let s=kf``;e.data.title&&(s=kf`
1996
1996
  <c:title>
1997
1997
  ${Zb(e.data.title,e.data.fontColor)}
1998
1998
  <c:overlay val="0" />
@@ -2436,4 +2436,4 @@
2436
2436
  <tableParts count="${e.filterTables.length}">
2437
2437
  ${Df(a)}
2438
2438
  </tableParts>
2439
- `}var TS;!function(e){e[e.Ready=0]="Ready",e[e.Running=1]="Running",e[e.RunningCore=2]="RunningCore",e[e.Finalizing=3]="Finalizing"}(TS||(TS={}));const AS={},NS={MIN_ROW_HEIGHT:10,MIN_COL_WIDTH:5,HEADER_HEIGHT:O,HEADER_WIDTH:M,TOPBAR_HEIGHT:63,BOTTOMBAR_HEIGHT:36,DEFAULT_CELL_WIDTH:_,DEFAULT_CELL_HEIGHT:F,SCROLLBAR_WIDTH:D},OS={autofillModifiersRegistry:cn,autofillRulesRegistry:En,cellMenuRegistry:jo,colMenuRegistry:Yo,linkMenuRegistry:Qn,functionRegistry:Yu,uiPluginRegistry:mb,corePluginRegistry:pb,rowMenuRegistry:Xo,sidePanelRegistry:Rr,figureRegistry:oo,sheetMenuRegistry:Qo,chartSidePanelComponentRegistry:fr,chartComponentRegistry:an,chartRegistry:rn,topbarMenuRegistry:rs,topbarComponentRegistry:Ir,clickableCellRegistry:fb,otRegistry:as,inverseCommandRegistry:so,cellRegistry:io,cellPopoverRegistry:to},MS={LinkCell:Pp},_S={args:Ur,toBoolean:Kr,toJsDate:Qr,toNumber:Gr,toString:Zr,toXC:Vt,toZone:Fi,toCartesian:Ut,numberToLetters:Lt,createFullMenuItem:Yn,UuidGenerator:Mi,formatValue:Qt,computeTextWidth:_e,isMarkdownLink:He,parseMarkdownLink:Ge,markdownLink:We,createEmptyWorkbookData:rv,createEmptySheet:sv,createEmptyExcelSheet:av,getDefaultChartJsRuntime:Ds,chartFontColor:Rs,getMenuChildren:Fn,ChartColors:xs,EvaluationError:c,CellErrorLevel:l,getFillingMode:Ls,rgbaToHex:Ct,colorToRGBA:Et,positionToZone:en,deepEquals:ot},FS={ChartPanel:vr,ChartFigure:Mr,ChartJsComponent:ln,Grid:Mp,GridOverlay:mp,ScorecardChart:Ar,LineConfigPanel:ur,LineBarPieDesignPanel:lr,BarConfigPanel:ds,LineBarPieConfigPanel:hs,GaugeChartConfigPanel:hr,GaugeChartDesignPanel:dr,ScorecardChartConfigPanel:pr,ScorecardChartDesignPanel:mr};e.AbstractChart=us,e.CorePlugin=lv,e.DATETIME_FORMAT=Y,e.DispatchResult=fn,e.EvaluationError=c,e.Model=class extends Kv{constructor(e={},i={},n=[],o=new Mi,s=!0){super(),this.corePlugins=[],this.uiPlugins=[],this.isReplayingCommand=!1,this.renderers=[],this.status=0,this.handlers=[],this.coreHandlers=[],this.dispatch=(e,t)=>{const i={type:e,...t};let n=this.status;if(this.getters.isReadonly()&&(o=i,!gn.has(o.type)))return new fn(68);var o;if(!this.session.canApplyOptimisticUpdate())return new fn(65);switch(n){case 0:const t=this.checkDispatchAllowed(i);if(!t.isSuccessful)return t;this.status=1;const{changes:n,commands:o}=this.state.recordChanges((()=>{mn(i)&&this.state.addCommand(i),this.dispatchToHandlers(this.handlers,i),this.finalize()}));this.session.save(o,n),this.status=0,this.trigger("update");break;case 1:if(mn(i)){const e=this.checkDispatchAllowed(i);if(!e.isSuccessful)return e;this.state.addCommand(i),this.dispatchToHandlers(this.handlers,i)}else this.dispatchToHandlers(this.handlers,i);break;case 3:throw new Error("Cannot dispatch commands in the finalize state");case 2:if(mn(i))throw new Error(`A UI plugin cannot dispatch ${e} while handling a core command`);this.dispatchToHandlers(this.handlers,i)}return fn.Success},this.dispatchFromCorePlugin=(e,t)=>{const i={type:e,...t},n=this.status;this.status=2;const o=this.isReplayingCommand?this.coreHandlers:this.handlers;return this.dispatchToHandlers(o,i),this.status=n,fn.Success},n=nv(e,n);const r=tv(e,s);this.state=new zb,this.uuidGenerator=o,this.config=this.setupConfig(i),this.session=this.setupSession(r.revisionId),this.config.moveClient=this.session.move.bind(this.session),this.history=new Lb(this.dispatchFromCorePlugin,this.session),this.coreGetters={},this.range=new Pb(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 Vb(this.getters),this.coreHandlers.push(this.range),this.handlers.push(this.range);for(let e of pb.getAll())this.setupCorePlugin(e,r);Object.assign(this.getters,this.coreGetters);for(let e of mb.getAll())this.setupUiPlugin(e);this.uuidGenerator.setIsFastStrategy(!1),this.handlers.push(this.history),this.dispatch("START"),this.selection.observe(this,{handleEvent:()=>this.trigger("update")}),this.isLoading=!0,this.setupSessionEvents(),this.session.loadInitialMessages(n),this.joinSession(),i.snapshotRequested&&this.session.snapshot(this.exportData()),t.markRaw(this),this.isLoading=!1,this.finalize()}joinSession(){this.session.join(this.config.client)}leaveSession(){this.session.leave()}setupUiPlugin(e){const t=new e(this.getters,this.state,this.dispatch,this.config,this.selection);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)}this.uiPlugins.push(t),this.handlers.push(t);const i=e.layers.map((e=>[t,e]));this.renderers.push(...i),this.renderers.sort(((e,t)=>e[1]-t[1]))}setupCorePlugin(e,t){const i=new e(this.coreGetters,this.state,this.range,this.dispatchFromCorePlugin,this.config,this.uuidGenerator);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),this.coreHandlers.push(i),this.handlers.push(i)}onRemoteRevisionReceived({commands:e}){for(let t of e){const e=this.status;this.status=2,this.dispatchToHandlers(this.uiPlugins,t),this.status=e}this.finalize()}setupSession(e){return new rb(kb(e,this.state.recordChanges.bind(this.state),(e=>{this.checkDispatchAllowed(e).isSuccessful&&(this.isReplayingCommand=!0,this.dispatchToHandlers(this.coreHandlers,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.smallUuid(),name:s("Anonymous").toString()},i=e.transportService||new Ib;return{...e,mode:e.mode||"normal",evalContext:e.evalContext||{},transportService:i,client:t,moveClient:()=>{},snapshotRequested:!1,notifyUI:e=>this.trigger("notify-ui",e)}}checkDispatchAllowed(e){const t=this.handlers.map((t=>t.allowDispatch(e)));return t.some((e=>0!==e))?new fn(t.flat()):fn.Success}finalize(){if(!this.isLoading){this.status=3;for(const e of this.handlers)e.finalize();this.status=0}}dispatchToHandlers(e,t){t=Ae(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=rv();for(let t of this.handlers)t instanceof lv&&t.export(e);return e.revisionId=this.session.getRevisionId()||K,e=Ae(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={...rv(),sheets:[av(ev,"Sheet1")]};for(let t of this.handlers)t instanceof Wg&&t.exportForExcel(e);return e=Ae(e),RS(e)}},e.Registry=sn,e.Revision=ob,e.SPREADSHEET_DIMENSIONS=NS,e.Spreadsheet=Rb,e.UIPlugin=Gg,e.__info__=AS,e.addFunction=function(e,t){Yu.add(e,t)},e.astToFormula=Mg,e.cellTypes=MS,e.compile=Ug,e.components=FS,e.convertAstNodes=Og,e.coreTypes=pn,e.findCellInNewZone=Qi,e.functionCache=Pg,e.helpers=_S,e.invalidateEvaluationCommands=dn,e.load=tv,e.parse=Ag,e.readonlyAllowedCommands=gn,e.registries=OS,e.setTranslationMethod=function(e){i=e},e.tokenize=Ju,Object.defineProperty(e,"__esModule",{value:!0}),AS.version="16.0.73",AS.date="2025-06-19T18:25:17.838Z",AS.hash="8bc0a8a"}(this.o_spreadsheet=this.o_spreadsheet||{},owl);
2439
+ `}var TS;!function(e){e[e.Ready=0]="Ready",e[e.Running=1]="Running",e[e.RunningCore=2]="RunningCore",e[e.Finalizing=3]="Finalizing"}(TS||(TS={}));const AS={},NS={MIN_ROW_HEIGHT:10,MIN_COL_WIDTH:5,HEADER_HEIGHT:O,HEADER_WIDTH:M,TOPBAR_HEIGHT:63,BOTTOMBAR_HEIGHT:36,DEFAULT_CELL_WIDTH:_,DEFAULT_CELL_HEIGHT:F,SCROLLBAR_WIDTH:D},OS={autofillModifiersRegistry:cn,autofillRulesRegistry:En,cellMenuRegistry:jo,colMenuRegistry:Yo,linkMenuRegistry:Qn,functionRegistry:Yu,uiPluginRegistry:mb,corePluginRegistry:pb,rowMenuRegistry:Xo,sidePanelRegistry:Rr,figureRegistry:oo,sheetMenuRegistry:Qo,chartSidePanelComponentRegistry:fr,chartComponentRegistry:an,chartRegistry:rn,topbarMenuRegistry:rs,topbarComponentRegistry:Ir,clickableCellRegistry:fb,otRegistry:as,inverseCommandRegistry:so,cellRegistry:io,cellPopoverRegistry:to},MS={LinkCell:Pp},_S={args:Ur,toBoolean:Kr,toJsDate:Qr,toNumber:Gr,toString:Zr,toXC:Vt,toZone:Fi,toCartesian:Ut,numberToLetters:Lt,createFullMenuItem:Yn,UuidGenerator:Mi,formatValue:Qt,computeTextWidth:_e,isMarkdownLink:He,parseMarkdownLink:Ge,markdownLink:We,createEmptyWorkbookData:rv,createEmptySheet:sv,createEmptyExcelSheet:av,getDefaultChartJsRuntime:Ds,chartFontColor:Rs,getMenuChildren:Fn,ChartColors:xs,EvaluationError:c,CellErrorLevel:l,getFillingMode:Ls,rgbaToHex:Ct,colorToRGBA:Et,positionToZone:en,deepEquals:ot},FS={ChartPanel:vr,ChartFigure:Mr,ChartJsComponent:ln,Grid:Mp,GridOverlay:mp,ScorecardChart:Ar,LineConfigPanel:ur,LineBarPieDesignPanel:lr,BarConfigPanel:ds,LineBarPieConfigPanel:hs,GaugeChartConfigPanel:hr,GaugeChartDesignPanel:dr,ScorecardChartConfigPanel:pr,ScorecardChartDesignPanel:mr};e.AbstractChart=us,e.CorePlugin=lv,e.DATETIME_FORMAT=Y,e.DispatchResult=fn,e.EvaluationError=c,e.Model=class extends Kv{constructor(e={},i={},n=[],o=new Mi,s=!0){super(),this.corePlugins=[],this.uiPlugins=[],this.isReplayingCommand=!1,this.renderers=[],this.status=0,this.handlers=[],this.coreHandlers=[],this.dispatch=(e,t)=>{const i={type:e,...t};let n=this.status;if(this.getters.isReadonly()&&(o=i,!gn.has(o.type)))return new fn(68);var o;if(!this.session.canApplyOptimisticUpdate())return new fn(65);switch(n){case 0:const t=this.checkDispatchAllowed(i);if(!t.isSuccessful)return t;this.status=1;const{changes:n,commands:o}=this.state.recordChanges((()=>{mn(i)&&this.state.addCommand(i),this.dispatchToHandlers(this.handlers,i),this.finalize()}));this.session.save(o,n),this.status=0,this.trigger("update");break;case 1:if(mn(i)){const e=this.checkDispatchAllowed(i);if(!e.isSuccessful)return e;this.state.addCommand(i),this.dispatchToHandlers(this.handlers,i)}else this.dispatchToHandlers(this.handlers,i);break;case 3:throw new Error("Cannot dispatch commands in the finalize state");case 2:if(mn(i))throw new Error(`A UI plugin cannot dispatch ${e} while handling a core command`);this.dispatchToHandlers(this.handlers,i)}return fn.Success},this.dispatchFromCorePlugin=(e,t)=>{const i={type:e,...t},n=this.status;this.status=2;const o=this.isReplayingCommand?this.coreHandlers:this.handlers;return this.dispatchToHandlers(o,i),this.status=n,fn.Success},n=nv(e,n);const r=tv(e,s);this.state=new zb,this.uuidGenerator=o,this.config=this.setupConfig(i),this.session=this.setupSession(r.revisionId),this.config.moveClient=this.session.move.bind(this.session),this.history=new Lb(this.dispatchFromCorePlugin,this.session),this.coreGetters={},this.range=new Pb(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 Vb(this.getters),this.coreHandlers.push(this.range),this.handlers.push(this.range);for(let e of pb.getAll())this.setupCorePlugin(e,r);Object.assign(this.getters,this.coreGetters);for(let e of mb.getAll())this.setupUiPlugin(e);this.uuidGenerator.setIsFastStrategy(!1),this.handlers.push(this.history),this.dispatch("START"),this.selection.observe(this,{handleEvent:()=>this.trigger("update")}),this.isLoading=!0,this.setupSessionEvents(),this.session.loadInitialMessages(n),this.joinSession(),i.snapshotRequested&&this.session.snapshot(this.exportData()),t.markRaw(this),this.isLoading=!1,this.finalize()}joinSession(){this.session.join(this.config.client)}leaveSession(){this.session.leave()}setupUiPlugin(e){const t=new e(this.getters,this.state,this.dispatch,this.config,this.selection);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)}this.uiPlugins.push(t),this.handlers.push(t);const i=e.layers.map((e=>[t,e]));this.renderers.push(...i),this.renderers.sort(((e,t)=>e[1]-t[1]))}setupCorePlugin(e,t){const i=new e(this.coreGetters,this.state,this.range,this.dispatchFromCorePlugin,this.config,this.uuidGenerator);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),this.coreHandlers.push(i),this.handlers.push(i)}onRemoteRevisionReceived({commands:e}){for(let t of e){const e=this.status;this.status=2,this.dispatchToHandlers(this.uiPlugins,t),this.status=e}this.finalize()}setupSession(e){return new rb(kb(e,this.state.recordChanges.bind(this.state),(e=>{this.checkDispatchAllowed(e).isSuccessful&&(this.isReplayingCommand=!0,this.dispatchToHandlers(this.coreHandlers,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.smallUuid(),name:s("Anonymous").toString()},i=e.transportService||new Ib;return{...e,mode:e.mode||"normal",evalContext:e.evalContext||{},transportService:i,client:t,moveClient:()=>{},snapshotRequested:!1,notifyUI:e=>this.trigger("notify-ui",e)}}checkDispatchAllowed(e){const t=this.handlers.map((t=>t.allowDispatch(e)));return t.some((e=>0!==e))?new fn(t.flat()):fn.Success}finalize(){if(!this.isLoading){this.status=3;for(const e of this.handlers)e.finalize();this.status=0}}dispatchToHandlers(e,t){t=Ae(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=rv();for(let t of this.handlers)t instanceof lv&&t.export(e);return e.revisionId=this.session.getRevisionId()||K,e=Ae(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={...rv(),sheets:[av(ev,"Sheet1")]};for(let t of this.handlers)t instanceof Wg&&t.exportForExcel(e);return e=Ae(e),RS(e)}},e.Registry=sn,e.Revision=ob,e.SPREADSHEET_DIMENSIONS=NS,e.Spreadsheet=Rb,e.UIPlugin=Gg,e.__info__=AS,e.addFunction=function(e,t){Yu.add(e,t)},e.astToFormula=Mg,e.cellTypes=MS,e.compile=Ug,e.components=FS,e.convertAstNodes=Og,e.coreTypes=pn,e.findCellInNewZone=Qi,e.functionCache=Pg,e.helpers=_S,e.invalidateEvaluationCommands=dn,e.load=tv,e.parse=Ag,e.readonlyAllowedCommands=gn,e.registries=OS,e.setTranslationMethod=function(e){i=e},e.tokenize=Ju,Object.defineProperty(e,"__esModule",{value:!0}),AS.version="16.0.74",AS.date="2025-06-27T09:02:46.788Z",AS.hash="a1d6303"}(this.o_spreadsheet=this.o_spreadsheet||{},owl);
@@ -3258,7 +3258,7 @@ https://fontawesome.com/license -->
3258
3258
  </t>
3259
3259
  </odoo>
3260
3260
  <!--
3261
- __info__.version = '16.0.73';
3262
- __info__.date = '2025-06-19T18:25:40.525Z';
3263
- __info__.hash = '8bc0a8a';
3261
+ __info__.version = '16.0.74';
3262
+ __info__.date = '2025-06-27T09:03:07.613Z';
3263
+ __info__.hash = 'a1d6303';
3264
3264
  -->
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@odoo/o-spreadsheet",
3
- "version": "16.0.73",
3
+ "version": "16.0.74",
4
4
  "description": "A spreadsheet component",
5
5
  "main": "dist/o-spreadsheet.cjs.js",
6
6
  "browser": "dist/o-spreadsheet.iife.js",