@univerjs/sheets-ui 0.1.0-beta.1 → 0.1.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/lib/cjs/index.js +13 -10
  2. package/lib/es/index.js +9334 -7759
  3. package/lib/index.css +1 -1
  4. package/lib/types/commands/commands/auto-fill.command.d.ts +1 -11
  5. package/lib/types/commands/commands/set-scroll.command.d.ts +1 -1
  6. package/lib/types/commands/operations/activate-cell-edit.operation.d.ts +2 -2
  7. package/lib/types/common/keys.d.ts +1 -0
  8. package/lib/types/components/font-size/interface.d.ts +2 -0
  9. package/lib/types/components/menu-item-input/interface.d.ts +2 -0
  10. package/lib/types/controllers/auto-fill.controller.d.ts +13 -9
  11. package/lib/types/controllers/clipboard/clipboard.controller.d.ts +5 -1
  12. package/lib/types/controllers/clipboard/utils.d.ts +16 -14
  13. package/lib/types/controllers/editor/__tests__/create-test-bed.d.ts +25 -0
  14. package/lib/types/{commands/commands/set-selection-frozen.command.d.ts → controllers/editor/__tests__/end-edit.controller.spec.d.ts} +1 -2
  15. package/lib/types/controllers/editor/end-edit.controller.d.ts +3 -0
  16. package/lib/types/controllers/editor/formula-editor.controller.d.ts +1 -0
  17. package/lib/types/controllers/editor-bridge.controller.d.ts +2 -5
  18. package/lib/types/controllers/format-painter/format-painter.controller.d.ts +3 -3
  19. package/lib/types/controllers/freeze.controller.d.ts +11 -3
  20. package/lib/types/controllers/header-move.controller.d.ts +1 -1
  21. package/lib/types/controllers/menu/menu.d.ts +2 -2
  22. package/lib/types/controllers/scroll.controller.d.ts +2 -2
  23. package/lib/types/controllers/selection.controller.d.ts +4 -1
  24. package/lib/types/controllers/status-bar.controller.d.ts +5 -3
  25. package/lib/types/index.d.ts +1 -1
  26. package/lib/types/services/auto-fill/auto-fill.service.d.ts +33 -29
  27. package/lib/types/services/auto-fill/tools.d.ts +10 -2
  28. package/lib/types/services/auto-fill/type.d.ts +23 -9
  29. package/lib/types/services/clipboard/__tests__/clipboard-test-bed.d.ts +1 -0
  30. package/lib/types/services/clipboard/type.d.ts +16 -14
  31. package/lib/types/services/editor/formula-editor-manager.service.d.ts +4 -0
  32. package/lib/types/services/editor-bridge.service.d.ts +52 -13
  33. package/lib/types/services/mark-selection/mark-selection.service.d.ts +14 -2
  34. package/lib/types/services/selection/__test__/create-service-test-bed.d.ts +25 -0
  35. package/lib/types/services/selection/__test__/selection-render.test.d.ts +16 -0
  36. package/lib/types/services/selection/selection-render.service.d.ts +19 -3
  37. package/lib/types/services/selection/selection-shape-extension.d.ts +7 -2
  38. package/lib/types/services/selection/selection-shape.d.ts +1 -2
  39. package/lib/types/services/status-bar.service.d.ts +7 -4
  40. package/lib/types/views/header-menu-shape.d.ts +2 -2
  41. package/lib/types/views/header-resize-shape.d.ts +2 -2
  42. package/lib/types/views/header-unhide-shape.d.ts +2 -2
  43. package/lib/types/views/status-bar/CopyableStatisticItem.d.ts +2 -1
  44. package/lib/umd/index.js +13 -10
  45. package/package.json +22 -21
package/lib/cjs/index.js CHANGED
@@ -1,9 +1,12 @@
1
- "use strict";var yr=Object.defineProperty;var Or=(i,e,t)=>e in i?yr(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var v=(i,e,t)=>(Or(i,typeof e!="symbol"?e+"":e,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@univerjs/core"),f=require("@univerjs/sheets"),R=require("@univerjs/ui"),P=require("@wendellhu/redi"),k=require("rxjs"),w=require("@univerjs/engine-render"),L=require("react"),ie=require("@univerjs/design"),W=require("@wendellhu/redi/react-bindings"),K=require("@univerjs/docs"),po=require("rxjs/operators"),G=require("@univerjs/engine-formula"),Tt=require("clsx"),vo={InsertRow:!0,InsertColumn:!0,AddRowTop:!1,AddRowBottom:!1,AddColumnLeft:!1,AddColumnRight:!1,DeleteRow:!0,DeleteColumn:!0,HideRow:!1,ShowRow:!1,RowHeight:!1,HideColumn:!1,ShowColumn:!1,ColumnWidth:!1,DeleteCell:!0,ClearContent:!0,Matrix:!1},Co={undo:!0,redo:!0,paintFormat:!0,currencyFormat:!0,percentageFormat:!0,numberDecrease:!0,numberIncrease:!0,moreFormats:!0,font:!0,fontSize:!0,bold:!0,italic:!0,strikethrough:!0,underline:!0,textColor:!0,fillColor:!0,border:!0,horizontalAlignMode:!0,verticalAlignMode:!0,textWrapMode:!0,textRotateMode:!0,mergeCell:!0},Io={outerLeft:!1,outerRight:!1,header:!0,footer:!0,innerLeft:!1,innerRight:!1,frozenHeaderLT:!1,frozenHeaderRT:!1,frozenHeaderLM:!1,frozenContent:!1,infoBar:!0,toolbar:!0,formulaBar:!0,rightMenu:!0,countBar:!0,sheetBar:!0},xr={layout:{sheetContainerConfig:Io,rightMenuConfig:vo,toolbarConfig:Co}},Ro="SheetUI";function yn(i,e){if(i==null)return;const t=e.getRenderById(i);if(t==null)return;const{mainComponent:n,scene:o,engine:r}=t;return{document:n,scene:o,engine:r}}const Cn={type:a.CommandType.COMMAND,id:"sheet.command.auto-fill",handler:async(i,e)=>{var V,F;const t=i.get(a.ICommandService),n=i.get(a.IUniverInstanceService),o=i.get(a.IUndoRedoService),{applyRange:r,selectionRange:s,applyDatas:l,unitId:c=n.getCurrentUniverSheetInstance().getUnitId(),subUnitId:d=n.getCurrentUniverSheetInstance().getActiveSheet().getSheetId(),applyMergeRanges:u}=e||{};if(!r||!l||!s)return!1;const h=[],m=[];let S=!0;const g=[],_=(F=(V=n.getUniverSheetInstance(c))==null?void 0:V.getSheetBySheetId(d))==null?void 0:F.getMergeData();_&&_.forEach(j=>{a.Rectangle.intersects(j,r)&&g.push(j)});const I={unitId:c,subUnitId:d,ranges:g},C=f.RemoveMergeUndoMutationFactory(i,I);S=t.syncExecuteCommand(f.RemoveWorksheetMergeMutation.id,I),h.push({id:f.AddWorksheetMergeMutation.id,params:C}),m.push({id:f.RemoveWorksheetMergeMutation.id,params:I});const b=new a.ObjectMatrix,{startRow:M,startColumn:T,endRow:E,endColumn:y}=r;for(let j=0;j<=E-M;j++)for(let $=0;$<=y-T;$++)b.setValue(j+M,$+T,l[j][$]);const O={subUnitId:d,unitId:c,cellValue:b.getMatrix()},x=f.SetRangeValuesUndoMutationFactory(i,O),D=t.syncExecuteCommand(f.SetRangeValuesMutation.id,O);h.push({id:f.SetRangeValuesMutation.id,params:x}),m.push({id:f.SetRangeValuesMutation.id,params:O});const U=t.syncExecuteCommand(f.SetSelectionsOperation.id,{selections:[{primary:{...s,endColumn:s.startColumn,endRow:s.startRow},range:{...s,rangeType:a.RANGE_TYPE.NORMAL}}],unitId:c,subUnitId:d});h.push({id:f.SetRangeValuesMutation.id,params:x}),m.push({id:f.SetRangeValuesMutation.id,params:O});let N=!0;if(u!=null&&u.length){const j=f.getAddMergeMutationRangeByType(u),$={unitId:c,subUnitId:d,ranges:j},q=f.AddMergeUndoMutationFactory(i,$);N=t.syncExecuteCommand(f.AddWorksheetMergeMutation.id,$),h.push({id:f.RemoveWorksheetMergeMutation.id,params:q}),m.push({id:f.AddWorksheetMergeMutation.id,params:$})}const{undo:B,redo:A}=e==null?void 0:e.extendMutations,H=A.every(j=>t.syncExecuteCommand(j.id,j.params));return B.forEach(j=>{h.push(j)}),A.forEach(j=>{m.push(j)}),D&&S&&N&&U&&H&&o.pushUndoRedo({unitID:c,undoMutations:h,redoMutations:m}),!0}},zt={id:"sheet.command.auto-clear-content",type:a.CommandType.COMMAND,handler:async(i,e)=>{const t=i.get(a.IUniverInstanceService),n=i.get(a.ICommandService),o=i.get(a.IUndoRedoService),r=t.getCurrentUniverSheetInstance(),s=r.getUnitId(),c=r.getActiveSheet().getSheetId(),{clearRange:d,selectionRange:u}=e,h={subUnitId:c,unitId:s,cellValue:Ar([d])},m=f.SetRangeValuesUndoMutationFactory(i,h);return n.executeCommand(f.SetSelectionsOperation.id,{selections:[{primary:{...u},range:{...u}}],unitId:s,subUnitId:c}),n.syncExecuteCommand(f.SetRangeValuesMutation.id,h)?(o.pushUndoRedo({unitID:s,undoMutations:[{id:f.SetRangeValuesMutation.id,params:m}],redoMutations:[{id:f.SetRangeValuesMutation.id,params:h}],undo(){return n.syncExecuteCommand(f.SetRangeValuesMutation.id,m)},redo(){return n.syncExecuteCommand(f.SetRangeValuesMutation.id,h)}}),!0):!1}};function Ar(i){const e=new a.ObjectMatrix;return i.forEach(t=>{const{startRow:n,startColumn:o,endRow:r,endColumn:s}=t;for(let l=n;l<=r;l++)for(let c=o;c<=s;c++)e.setValue(l,c,{v:null,p:null,f:null,si:null})}),e.getData()}function Z(i){return i.getContextValue(a.FOCUSING_SHEET)&&!i.getContextValue(a.FOCUSING_EDITOR)}function bo(i){return i.getContextValue(a.FOCUSING_SHEET)&&i.getContextValue(a.FOCUSING_EDITOR)}function Hr(i){return i.getContextValue(a.FOCUSING_EDITOR_BUT_HIDDEN)&&!i.getContextValue(a.FOCUSING_EDITOR)}function Dr(i){return i.getContextValue(a.FOCUSING_EDITOR)&&i.getContextValue(a.FOCUSING_EDITOR_BUT_HIDDEN)}function Mo(i){return i.getContextValue(a.FOCUSING_FORMULA_EDITOR)}function Nr(i){return i.getContextValue(a.FOCUSING_SHEET)&&i.getContextValue(a.FOCUSING_EDITOR)&&i.getContextValue(a.FOCUSING_EDITOR_INPUT_FORMULA)}function In(i){return i.getContextValue(a.FOCUSING_SHEET)&&i.getContextValue(a.FOCUSING_EDITOR)&&!i.getContextValue(a.FOCUSING_EDITOR_INPUT_FORMULA)}class Pr{constructor(){v(this,"_startColumn",-1);v(this,"_startRow",-1);v(this,"_endColumn",-1);v(this,"_endRow",-1);v(this,"_startX",0);v(this,"_startY",0);v(this,"_endX",0);v(this,"_endY",0);v(this,"_currentCell");v(this,"_rangeType",a.RANGE_TYPE.NORMAL)}get startColumn(){return this._startColumn}get startRow(){return this._startRow}get endColumn(){return this._endColumn}get endRow(){return this._endRow}get startX(){return this._startX}get startY(){return this._startY}get endX(){return this._endX}get endY(){return this._endY}get currentCell(){return this._currentCell}get rangeType(){return this._rangeType}isEqual(e){const{startColumn:t,startRow:n,endColumn:o,endRow:r}=this,{startColumn:s,startRow:l,endColumn:c,endRow:d}=e;return t===s&&n===l&&o===c&&r===d}isInclude(e){const{startColumn:t,startRow:n,endColumn:o,endRow:r}=this,{startColumn:s,startRow:l,endColumn:c,endRow:d}=e;return!(c<t||s>o||l>r||d<n)}highlightToSelection(){return a.makeCellToSelection(this._currentCell)}getRange(){return{startColumn:this._startColumn,startRow:this._startRow,endColumn:this._endColumn,endRow:this._endRow,startX:this._startX,startY:this._startY,endX:this._endX,endY:this._endY,rangeType:this.rangeType}}getCell(){return this._currentCell}getRangeType(){return this._rangeType}getValue(){return{rangeWithCoord:{startColumn:this._startColumn,startRow:this._startRow,endColumn:this._endColumn,endRow:this._endRow,startX:this._startX,startY:this._startY,endX:this._endX,endY:this._endY,rangeType:this._rangeType},primaryWithCoord:this._currentCell}}setValue(e,t){const{startColumn:n,startRow:o,endColumn:r,endRow:s,startX:l,startY:c,endX:d,endY:u,rangeType:h}=e;this._startColumn=n,this._startRow=o,this._endColumn=r,this._endRow=s,this._startX=l,this._startY=c,this._endX=d,this._endY=u,h!=null&&(this._rangeType=h),this.setCurrentCell(t)}setCurrentCell(e){e&&(this._currentCell=e)}clearCurrentCell(){this._currentCell=null}}const Hi=.3;class Rn{constructor(e,t,n=!0,o){v(this,"_leftControl");v(this,"_rightControl");v(this,"_topControl");v(this,"_bottomControl");v(this,"_backgroundControlTop");v(this,"_backgroundControlBottom");v(this,"_backgroundControlMiddleLeft");v(this,"_backgroundControlMiddleRight");v(this,"_fillControl");v(this,"_selectionShape");v(this,"_rowHeaderBackground");v(this,"_rowHeaderBorder");v(this,"_rowHeaderGroup");v(this,"_rowHeaderHighlight");v(this,"_columnHeaderBackground");v(this,"_columnHeaderBorder");v(this,"_columnHeaderGroup");v(this,"_columnHeaderHighlight");v(this,"_topLeftWidget");v(this,"_topCenterWidget");v(this,"_topRightWidget");v(this,"_middleLeftWidget");v(this,"_middleRightWidget");v(this,"_bottomLeftWidget");v(this,"_bottomCenterWidget");v(this,"_bottomRightWidget");v(this,"_dashRect");v(this,"_selectionModel");v(this,"_selectionStyle");v(this,"_rowHeaderWidth",0);v(this,"_columnHeaderHeight",0);v(this,"_widgetRects",[]);v(this,"_dispose$",new k.BehaviorSubject(this));v(this,"dispose$",this._dispose$.asObservable());v(this,"selectionMoving$",new k.Subject);v(this,"selectionMoved$",new k.Subject);v(this,"selectionScaling$",new k.Subject);v(this,"selectionScaled$",new k.Subject);v(this,"selectionFilling$",new k.Subject);v(this,"_selectionFilled$",new k.Subject);v(this,"selectionFilled$",this._selectionFilled$.asObservable());v(this,"_defaultStyle");v(this,"_isHelperSelection",!0);this._scene=e,this._zIndex=t,this._isHeaderHighlight=n,this._themeService=o,this._initialize()}get zIndex(){return this._zIndex}get leftControl(){return this._leftControl}get rightControl(){return this._rightControl}get topControl(){return this._topControl}get bottomControl(){return this._bottomControl}get fillControl(){return this._fillControl}get backgroundControlTop(){return this._backgroundControlTop}get backgroundControlBottom(){return this._backgroundControlBottom}get backgroundControlMiddleLeft(){return this._backgroundControlMiddleLeft}get backgroundControlMiddleRight(){return this._backgroundControlMiddleRight}get selectionShape(){return this._selectionShape}get model(){return this._selectionModel}get topLeftWidget(){return this._topLeftWidget}get topCenterWidget(){return this._topCenterWidget}get topRightWidget(){return this._topRightWidget}get middleLeftWidget(){return this._middleLeftWidget}get middleRightWidget(){return this._middleRightWidget}get bottomLeftWidget(){return this._bottomLeftWidget}get bottomCenterWidget(){return this._bottomCenterWidget}get bottomRightWidget(){return this._bottomRightWidget}get selectionStyle(){return this._selectionStyle}get dashRect(){return this._dashRect}get isHelperSelection(){return this._isHelperSelection}enableHeaderHighlight(){this._isHelperSelection=!0}disableHeaderHighlight(){this._isHeaderHighlight=!1}refreshSelectionFilled(e){this._selectionFilled$.next(e)}updateStyle(e){this._updateControl(e,this._rowHeaderWidth,this._columnHeaderHeight)}update(e,t=0,n=0,o,r){this._selectionModel.setValue(e,r),o==null&&(o=this._selectionStyle),this._updateControl(o,t,n)}clearHighlight(){this._selectionModel.clearCurrentCell(),this._updateControl(this._selectionStyle,this._rowHeaderWidth,this._columnHeaderHeight)}getScene(){return this._scene}dispose(){var e,t,n,o,r,s,l,c,d,u,h,m,S,g,_,I,C,b,M,T,E,y,O,x,D;(e=this._leftControl)==null||e.dispose(),(t=this._rightControl)==null||t.dispose(),(n=this._topControl)==null||n.dispose(),(o=this._bottomControl)==null||o.dispose(),(r=this._backgroundControlTop)==null||r.dispose(),(s=this._backgroundControlMiddleLeft)==null||s.dispose(),(l=this._backgroundControlMiddleRight)==null||l.dispose(),(c=this._backgroundControlBottom)==null||c.dispose(),(d=this._fillControl)==null||d.dispose(),(u=this._selectionShape)==null||u.dispose(),(h=this._rowHeaderBackground)==null||h.dispose(),(m=this._rowHeaderBorder)==null||m.dispose(),(S=this._rowHeaderGroup)==null||S.dispose(),(g=this._rowHeaderBackground)==null||g.dispose(),(_=this._columnHeaderBackground)==null||_.dispose(),(I=this._columnHeaderBorder)==null||I.dispose(),(C=this._columnHeaderGroup)==null||C.dispose(),(b=this._topLeftWidget)==null||b.dispose(),(M=this._topCenterWidget)==null||M.dispose(),(T=this._topRightWidget)==null||T.dispose(),(E=this._middleLeftWidget)==null||E.dispose(),(y=this._middleRightWidget)==null||y.dispose(),(O=this._bottomLeftWidget)==null||O.dispose(),(x=this._bottomCenterWidget)==null||x.dispose(),(D=this._bottomRightWidget)==null||D.dispose(),this._dispose$.next(this),this._dispose$.complete()}getCurrentCellInfo(){const e=this.model.currentCell;if(e){let t;if(e.isMerged){const n=e.mergeInfo;t={startRow:n.startRow,endRow:n.endRow,startColumn:n.startColumn,endColumn:n.endColumn,startX:n.startX,endX:n.endX,startY:n.startY,endY:n.endY}}else{const{actualRow:n,actualColumn:o,startX:r,endX:s,startY:l,endY:c}=e;t={startRow:n,endRow:n,startColumn:o,endColumn:o,startX:r,endX:s,startY:l,endY:c}}return t}}getValue(){return{...this._selectionModel.getValue(),style:this._selectionStyle}}getRange(){return this._selectionModel.getValue().rangeWithCoord}enableHelperSelection(){this._isHelperSelection=!0}disableHelperSelection(){this._isHelperSelection=!1}updateStyleId(e){this._selectionStyle!=null&&(this._selectionStyle.id=e)}_updateControl(e,t,n){let{startX:o,startY:r,endX:s,endY:l}=this._selectionModel;const c=this._defaultStyle;e==null&&(e=c);const{stroke:d=c.stroke,widgets:u=c.widgets,hasAutoFill:h=c.hasAutoFill,AutofillStroke:m=c.AutofillStroke,strokeDash:S}=e;let{strokeWidth:g=c.strokeWidth,AutofillSize:_=c.AutofillSize,AutofillStrokeWidth:I=c.AutofillStrokeWidth}=e;const C=this._getScale();o=w.fixLineWidthByScale(o,C),r=w.fixLineWidthByScale(r,C),s=w.fixLineWidthByScale(s,C),l=w.fixLineWidthByScale(l,C);const b=(g+f.SELECTION_CONTROL_BORDER_BUFFER_WIDTH)/2/C;g/=this._getPureScale(),_/=C,I/=C;const M=f.SELECTION_CONTROL_BORDER_BUFFER_WIDTH/C,T=w.FIX_ONE_PIXEL_BLUR_OFFSET/C;this.leftControl.transformByState({height:l-r,left:-b+T,width:g,strokeWidth:M,top:-M/2+T}),this.leftControl.setProps({fill:d,stroke:f.SELECTION_CONTROL_BORDER_BUFFER_COLOR}),this.rightControl.transformByState({height:l-r,left:s-o-b+T,width:g,strokeWidth:M,top:-M/2+T}),this.rightControl.setProps({fill:d,stroke:f.SELECTION_CONTROL_BORDER_BUFFER_COLOR}),this.topControl.transformByState({width:s-o+g,top:-b+T,left:-b+T,height:g,strokeWidth:M}),this.topControl.setProps({fill:d,stroke:f.SELECTION_CONTROL_BORDER_BUFFER_COLOR}),this.bottomControl.transformByState({width:s-o+g,top:l-r-b+T,height:g,left:-b+T,strokeWidth:M}),this.bottomControl.setProps({fill:d,stroke:f.SELECTION_CONTROL_BORDER_BUFFER_COLOR}),S==null?this.dashRect.hide():(this.dashRect.transformByState({height:l-r-g/2,width:s-o-g/2,strokeWidth:g,left:g/2-1/C,top:g/2-1/C}),this.dashRect.setProps({strokeDashArray:[0,S]}),this.dashRect.show()),h===!0&&!this._hasWidgets(u)?(this.fillControl.setProps({fill:d,stroke:m}),this.fillControl.transformByState({width:_-I,height:_-I,left:s-o-_/2,top:l-r-_/2,strokeWidth:I}),this.fillControl.show()):this.fillControl.hide(),this._updateBackgroundControl(e),this._updateBackgroundTitle(e,w.fixLineWidthByScale(t,C),n),this._updateWidgets(e),this.selectionShape.show(),this.selectionShape.translate(o,r),this._selectionStyle=e,this._rowHeaderWidth=t||0,this._columnHeaderHeight=n||0,this.selectionShape.makeDirtyNoDebounce(!0)}_initialize(){this._defaultStyle=f.getNormalSelectionStyle(this._themeService),this._selectionModel=new Pr;const e=this._zIndex;this._leftControl=new w.Rect("__SpreadsheetSelectionShapeLeftControl__"+e,{zIndex:e}),this._rightControl=new w.Rect("__SpreadsheetSelectionShapeRightControl__"+e,{zIndex:e}),this._topControl=new w.Rect("__SpreadsheetSelectionTopControl__"+e,{zIndex:e}),this._bottomControl=new w.Rect("__SpreadsheetSelectionBottomControl__"+e,{zIndex:e}),this._backgroundControlTop=new w.Rect("__SpreadsheetSelectionBackgroundControlTop__"+e,{zIndex:e-1,evented:!1}),this._backgroundControlBottom=new w.Rect("__SpreadsheetSelectionBackgroundControlBottom__"+e,{zIndex:e-1,evented:!1}),this._backgroundControlMiddleLeft=new w.Rect("__SpreadsheetSelectionBackgroundControlMiddleLeft__"+e,{zIndex:e-1,evented:!1}),this._backgroundControlMiddleRight=new w.Rect("__SpreadsheetSelectionBackgroundControlMiddleRight__"+e,{zIndex:e-1,evented:!1}),this._fillControl=new w.Rect("__SpreadsheetSelectionFillControl__"+e,{zIndex:e+1}),this._dashRect=new w.Rect("__SpreadsheetDragDashControl__"+e,{zIndex:e+2,evented:!1,stroke:"#fff"});const t=[this._fillControl,this._leftControl,this._rightControl,this._topControl,this._bottomControl,this._backgroundControlTop,this._backgroundControlMiddleLeft,this._backgroundControlMiddleRight,this._backgroundControlBottom,this._dashRect];this._widgetRects=this._initialWidget(),this._selectionShape=new w.Group("__SpreadsheetSelectionShape__"+e,...t,...this._widgetRects),this._selectionShape.hide(),this._selectionShape.evented=!1,this._selectionShape.zIndex=e,this.getScene().addObject(this._selectionShape),this._initialTitle()}_initialTitle(){const e=this._zIndex;this._rowHeaderBackground=new w.Rect("__SpreadSheetSelectionRowHeaderBackground__"+e,{zIndex:e-1,evented:!1}),this._rowHeaderBorder=new w.Rect("__SpreadSheetSelectionRowHeaderBorder__"+e,{zIndex:e-1,evented:!1}),this._rowHeaderGroup=new w.Group("__SpreadSheetSelectionRowHeaderGroup__"+e,this._rowHeaderBackground,this._rowHeaderBorder),this._rowHeaderGroup.hide(),this._rowHeaderGroup.evented=!1,this._rowHeaderGroup.zIndex=e,this._columnHeaderBackground=new w.Rect("__SpreadSheetSelectionColumnHeaderBackground__"+e,{zIndex:e-1,evented:!1}),this._columnHeaderBorder=new w.Rect("__SpreadSheetSelectionColumnHeaderBorder__"+e,{zIndex:e-1,evented:!1}),this._columnHeaderGroup=new w.Group("__SpreadSheetSelectionColumnHeaderGroup__"+e,this._columnHeaderBackground,this._columnHeaderBorder),this._columnHeaderGroup.hide(),this._columnHeaderGroup.evented=!1,this._columnHeaderGroup.zIndex=e,this.getScene().addObjects([this._rowHeaderGroup,this._columnHeaderGroup],w.DEFAULT_SELECTION_LAYER_INDEX)}_initialWidget(){const e=this._zIndex;return this._topLeftWidget=new w.Rect("__SpreadSheetSelectionTopLeftWidget__"+e,{zIndex:e+1}),this._topCenterWidget=new w.Rect("__SpreadSheetSelectionTopCenterWidget__"+e,{zIndex:e+1}),this._topRightWidget=new w.Rect("__SpreadSheetSelectionTopRightWidget__"+e,{zIndex:e+1}),this._middleLeftWidget=new w.Rect("__SpreadSheetSelectionMiddleLeftWidget__"+e,{zIndex:e+1}),this._middleRightWidget=new w.Rect("__SpreadSheetSelectionMiddleRightWidget__"+e,{zIndex:e+1}),this._bottomLeftWidget=new w.Rect("__SpreadSheetSelectionBottomLeftWidget__"+e,{zIndex:e+1}),this._bottomCenterWidget=new w.Rect("__SpreadSheetSelectionBottomCenterWidget__"+e,{zIndex:e+1}),this._bottomRightWidget=new w.Rect("__SpreadSheetSelectionBottomRightWidget__"+e,{zIndex:e+1}),[this._topLeftWidget,this._topCenterWidget,this._topRightWidget,this._middleLeftWidget,this._middleRightWidget,this._bottomLeftWidget,this._bottomCenterWidget,this._bottomRightWidget]}_updateBackgroundTitle(e,t,n){const{startX:o,startY:r,endX:s,endY:l,rangeType:c}=this._selectionModel,d=this._defaultStyle;e==null&&(e=d);const u=this._getScale(),{stroke:h,hasRowHeader:m,rowHeaderFill:S=d.rowHeaderFill,rowHeaderStroke:g=d.rowHeaderStroke,hasColumnHeader:_,columnHeaderFill:I=d.columnHeaderFill,columnHeaderStroke:C=d.columnHeaderStroke}=e;let{rowHeaderStrokeWidth:b=d.rowHeaderStrokeWidth,columnHeaderStrokeWidth:M=d.columnHeaderStrokeWidth}=e;if(b/=u,M/=u,_===!0){let T=I;this._isHeaderHighlight&&c===a.RANGE_TYPE.COLUMN&&(T=new a.ColorKit(h).setAlpha(Hi).toString()),this._columnHeaderBackground.setProps({fill:T}),this._columnHeaderBackground.resize(s-o,n),this._columnHeaderBorder.setProps({fill:C}),this._columnHeaderBorder.transformByState({width:s-o,height:M,top:n-M+1/u}),this._columnHeaderGroup.show(),this._columnHeaderGroup.translate(o,0)}else this._columnHeaderGroup.hide();if(this._columnHeaderGroup.makeDirty(!0),m===!0){let T=S;this._isHeaderHighlight&&c===a.RANGE_TYPE.ROW&&(T=new a.ColorKit(h).setAlpha(Hi).toString()),this._rowHeaderBackground.setProps({fill:T}),this._rowHeaderBackground.resize(t,l-r),this._rowHeaderBorder.setProps({fill:g}),this._rowHeaderBorder.transformByState({width:b,height:l-r,left:t-b+1/u}),this._rowHeaderGroup.show(),this._rowHeaderGroup.translate(0,r)}else this._rowHeaderGroup.hide();this._rowHeaderGroup.makeDirty(!0)}_updateBackgroundControl(e){let{startX:t,startY:n,endX:o,endY:r}=this._selectionModel;const s=this._defaultStyle;e==null&&(e=s);const l=this._getScale(),{fill:c=s.fill}=e;let{strokeWidth:d=s.strokeWidth}=e;d/=l;const u=this._selectionModel.highlightToSelection();if(t=w.fixLineWidthByScale(t,l),n=w.fixLineWidthByScale(n,l),o=w.fixLineWidthByScale(o,l),r=w.fixLineWidthByScale(r,l),!u){this._backgroundControlTop.resize(o-t,r-n),this._backgroundControlTop.setProps({fill:c}),this._backgroundControlBottom.resize(0,0),this._backgroundControlMiddleLeft.resize(0,0),this._backgroundControlMiddleRight.resize(0,0);return}let{startX:h,startY:m,endX:S,endY:g}=u;h=w.fixLineWidthByScale(h,l),m=w.fixLineWidthByScale(m,l),S=w.fixLineWidthByScale(S,l),g=w.fixLineWidthByScale(g,l);const _=w.fixLineWidthByScale(d/2,l),I={left:-_,top:-_,width:o-t+_*2,height:m-n+_};I.height<0&&(I.width=0,I.height=0),this._backgroundControlTop.transformByState(I);const C={left:-_,top:m-n,width:h-t+_,height:g-m};C.width<0&&(C.width=0,C.height=0),this._backgroundControlMiddleLeft.transformByState(C);const b={left:S-t-_,top:m-n,width:o-S+_*2,height:g-m};b.width<0&&(b.width=0,b.height=0),this._backgroundControlMiddleRight.transformByState(b);const M={left:-_,top:g-n,width:o-t+_*2,height:r-g+_};M.height<0&&(M.width=0,M.height=0),this._backgroundControlBottom.transformByState(M),this._backgroundControlTop.setProps({fill:c}),this._backgroundControlMiddleLeft.setProps({fill:c}),this._backgroundControlMiddleRight.setProps({fill:c}),this._backgroundControlBottom.setProps({fill:c})}_updateWidgets(e){const{startX:t,startY:n,endX:o,endY:r}=this._selectionModel,s=this._defaultStyle;e==null&&(e=s);const{stroke:l=s.stroke,widgets:c=s.widgets,widgetStroke:d=s.widgetStroke}=e,u=this._getScale();let{widgetSize:h=s.widgetSize,widgetStrokeWidth:m=s.widgetStrokeWidth}=e;h/=u,m/=u;const S={left:-h/2,center:(o-t)/2-h/2,right:o-t-h/2,top:-h/2,middle:(r-n)/2-h/2,bottom:r-n-h/2},g=h-m;this._widgetRects.forEach(_=>{_.setProps({fill:l,stroke:d})}),c.tl===!0?(this._topLeftWidget.transformByState({height:g,width:g,left:S.left,top:S.top,strokeWidth:m}),this._topLeftWidget.show()):this._topLeftWidget.hide(),c.tc===!0?(this._topCenterWidget.transformByState({height:g,width:g,left:S.center,top:S.top,strokeWidth:m}),this._topCenterWidget.show()):this._topCenterWidget.hide(),c.tr===!0?(this._topRightWidget.transformByState({height:g,width:g,left:S.right,top:S.top,strokeWidth:m}),this._topRightWidget.show()):this._topRightWidget.hide(),c.ml===!0?(this._middleLeftWidget.transformByState({height:g,width:g,left:S.left,top:S.middle,strokeWidth:m}),this._middleLeftWidget.show()):this._middleLeftWidget.hide(),c.mr===!0?(this._middleRightWidget.transformByState({height:g,width:g,left:S.right,top:S.middle,strokeWidth:m}),this._middleRightWidget.show()):this._middleRightWidget.hide(),c.bl===!0?(this._bottomLeftWidget.transformByState({height:g,width:g,left:S.left,top:S.bottom,strokeWidth:m}),this._bottomLeftWidget.show()):this._bottomLeftWidget.hide(),c.bc===!0?(this._bottomCenterWidget.transformByState({height:g,width:g,left:S.center,top:S.bottom,strokeWidth:m}),this._bottomCenterWidget.show()):this._bottomCenterWidget.hide(),c.br===!0?(this._bottomRightWidget.transformByState({height:g,width:g,left:S.right,top:S.bottom,strokeWidth:m}),this._bottomRightWidget.show()):this._bottomRightWidget.hide()}_hasWidgets(e){if(e==null)return!1;const t=Object.keys(e);if(t.length===0)return!1;for(const n of t)if(e[n]===!0)return!0;return!0}_getScale(){const e=this._getPixelRatio(),{scaleX:t,scaleY:n}=this._scene.getAncestorScale();return Math.max(t*e,n*e)}_getPureScale(){const{scaleX:e,scaleY:t}=this._scene.getAncestorScale();return Math.max(e,t)}_getPixelRatio(){var e;return((e=this._scene.getEngine())==null?void 0:e.getPixelRatio())||1}}const Di="__SpreadsheetHelperSelectionTempRect",Lr=35;class Ni{constructor(e,t,n,o){v(this,"_startOffsetX",0);v(this,"_startOffsetY",0);v(this,"_relativeSelectionPositionRow",0);v(this,"_relativeSelectionPositionColumn",0);v(this,"_relativeSelectionRowLength",0);v(this,"_relativeSelectionColumnLength",0);v(this,"_moveObserver");v(this,"_upObserver");v(this,"_helperSelection");v(this,"_scrollTimer");v(this,"_targetSelection",{startY:0,endY:0,startX:0,endX:0,startRow:-1,endRow:-1,startColumn:-1,endColumn:-1});v(this,"_isInMergeState",!1);v(this,"_fillControlColors",[]);this._control=e,this._skeleton=t,this._scene=n,this._themeService=o,this._initialControl(),this._initialWidget(),this._initialFill(),this._control.dispose$.subscribe(()=>{this.dispose()})}get isHelperSelection(){return this._control.isHelperSelection}dispose(){var e,t;(e=this._scrollTimer)==null||e.dispose(),this._fillControlColors=[],this._clearObserverEvent(),(t=this._helperSelection)==null||t.dispose()}_clearObserverEvent(){this._scene.onPointerMoveObserver.remove(this._moveObserver),this._scene.onPointerUpObserver.remove(this._upObserver),this._moveObserver=null,this._upObserver=null}_initialControl(){const{leftControl:e,rightControl:t,topControl:n,bottomControl:o}=this._control;[e,t,n,o].forEach(r=>{r.onPointerEnterObserver.add(()=>{r.setCursor(w.CURSOR_TYPE.MOVE)}),r.onPointerLeaveObserver.add(()=>{r.resetCursor()}),r.onPointerDownObserver.add(this._controlEvent.bind(this))})}_controlMoving(e,t){var y;const n=this._scene,o=n.getScrollXYByRelativeCoords(w.Vector2.FromArray([this._startOffsetX,this._startOffsetY])),{scaleX:r,scaleY:s}=n.getAncestorScale(),l=this._skeleton.getCellPositionByOffset(e,t,r,s,o),{row:c,column:d}=l,u=this._skeleton.getRowCount()-1,h=this._skeleton.getColumnCount()-1;let m=c+this._relativeSelectionPositionRow;m<0&&(m=0);let S=m+this._relativeSelectionRowLength;S>u&&(S=u,S-m<this._relativeSelectionRowLength&&(m=S-this._relativeSelectionRowLength));let g=d+this._relativeSelectionPositionColumn;g<0&&(g=0);let _=g+this._relativeSelectionColumnLength;_>h&&(_=h,_-g<this._relativeSelectionColumnLength&&(g=_-this._relativeSelectionColumnLength));const I=this._skeleton.getNoMergeCellPositionByIndex(m,g,r,s),C=this._skeleton.getNoMergeCellPositionByIndex(S,_,r,s),b=(I==null?void 0:I.startY)||0,M=(C==null?void 0:C.endY)||0,T=(I==null?void 0:I.startX)||0,E=(C==null?void 0:C.endX)||0;(y=this._helperSelection)==null||y.transformByState({left:T,top:b,width:E-T,height:M-b}),this._targetSelection={startY:b,endY:M,startX:T,endX:E,startRow:m,endRow:S,startColumn:g,endColumn:_},this._control.selectionMoving$.next(this._targetSelection)}_controlEvent(e){const{offsetX:t,offsetY:n}=e,o=this._scene,r=o.getRelativeCoord(w.Vector2.FromArray([t,n])),{x:s,y:l}=r,c=o.getScrollXYByRelativeCoords(r),{scaleX:d,scaleY:u}=o.getAncestorScale(),h=this._skeleton.getCellPositionByOffset(s,l,d,u,c);this._startOffsetX=s,this._startOffsetY=l;const{row:m,column:S}=h,{startRow:g,startColumn:_,endRow:I,endColumn:C}=this._control.model;let b=0,M=0;m<g?b-=1:m>I&&(b+=1),S<_?M-=1:S>C&&(M+=1),this._relativeSelectionPositionRow=g-m+b,this._relativeSelectionPositionColumn=_-S+M,this._relativeSelectionRowLength=I-g,this._relativeSelectionColumnLength=C-_;const T=this._control.selectionStyle,E=this._getScale();this.isHelperSelection&&(this._helperSelection=new w.Rect(Di,{stroke:T.stroke,strokeWidth:T.strokeWidth/E}),o.addObject(this._helperSelection));const y=w.ScrollTimer.create(o);y.startScroll(s,l),this._scrollTimer=y,o.disableEvent(),this._moveObserver=o.onPointerMoveObserver.add(O=>{const{offsetX:x,offsetY:D}=O,{x:U,y:N}=o.getRelativeCoord(w.Vector2.FromArray([x,D]));this._controlMoving(U,N),o.setCursor(w.CURSOR_TYPE.MOVE),y.scrolling(U,N,()=>{this._controlMoving(U,N)})}),this._upObserver=o.onPointerUpObserver.add(()=>{var x,D;(x=this._helperSelection)==null||x.dispose();const O=this._scene;O.resetCursor(),this._clearObserverEvent(),O.enableEvent(),(D=this._scrollTimer)==null||D.dispose(),this._control.selectionMoved$.next(this._targetSelection)})}_initialWidget(){const{topLeftWidget:e,topCenterWidget:t,topRightWidget:n,middleLeftWidget:o,middleRightWidget:r,bottomLeftWidget:s,bottomCenterWidget:l,bottomRightWidget:c}=this._control,d=[w.CURSOR_TYPE.NORTH_WEST_RESIZE,w.CURSOR_TYPE.NORTH_RESIZE,w.CURSOR_TYPE.NORTH_EAST_RESIZE,w.CURSOR_TYPE.WEST_RESIZE,w.CURSOR_TYPE.EAST_RESIZE,w.CURSOR_TYPE.SOUTH_WEST_RESIZE,w.CURSOR_TYPE.SOUTH_RESIZE,w.CURSOR_TYPE.SOUTH_EAST_RESIZE];[e,t,n,o,r,s,l,c].forEach((u,h)=>{u.onPointerEnterObserver.add(()=>{u.setCursor(d[h])}),u.onPointerLeaveObserver.add(()=>{u.resetCursor()}),u.onPointerDownObserver.add(m=>{this._widgetEvent(m,d[h])})})}_widgetMoving(e,t,n){const o=this._scene,r=o.getScrollXYByRelativeCoords(w.Vector2.FromArray([this._startOffsetX,this._startOffsetY])),{scaleX:s,scaleY:l}=o.getAncestorScale(),c=this._skeleton.getCellPositionByOffset(e,t,s,l,r),{row:d,column:u}=c,{rowHeaderWidth:h,columnHeaderHeight:m}=this._skeleton;let S=this._relativeSelectionPositionRow,g=this._relativeSelectionPositionColumn,_=d,I=u;n===w.CURSOR_TYPE.NORTH_WEST_RESIZE?(S=d,g=u,_=this._relativeSelectionPositionRow,I=this._relativeSelectionPositionColumn):n===w.CURSOR_TYPE.NORTH_RESIZE?(S=d,g=this._relativeSelectionPositionColumn,_=this._relativeSelectionPositionRow,I=this._relativeSelectionPositionColumn+this._relativeSelectionColumnLength):n===w.CURSOR_TYPE.NORTH_EAST_RESIZE?(S=d,g=this._relativeSelectionPositionColumn,_=this._relativeSelectionPositionRow,I=u):n===w.CURSOR_TYPE.WEST_RESIZE?(S=this._relativeSelectionPositionRow,g=u,_=this._relativeSelectionPositionRow+this._relativeSelectionRowLength,I=this._relativeSelectionPositionColumn):n===w.CURSOR_TYPE.EAST_RESIZE?_=this._relativeSelectionPositionRow+this._relativeSelectionRowLength:n===w.CURSOR_TYPE.SOUTH_WEST_RESIZE?(S=this._relativeSelectionPositionRow,g=u,_=d,I=this._relativeSelectionPositionColumn):n===w.CURSOR_TYPE.SOUTH_RESIZE&&(S=this._relativeSelectionPositionRow,g=this._relativeSelectionPositionColumn,_=d,I=this._relativeSelectionPositionColumn+this._relativeSelectionColumnLength);const{startRow:C,startColumn:b,endRow:M,endColumn:T}=this._swapPositions(S,g,_,I),E=this._skeleton.getNoMergeCellPositionByIndex(C,b,s,l),y=this._skeleton.getNoMergeCellPositionByIndex(M,T,s,l),O=(E==null?void 0:E.startY)||0,x=(y==null?void 0:y.endY)||0,D=(E==null?void 0:E.startX)||0,U=(y==null?void 0:y.endX)||0;this._targetSelection={startY:O,endY:x,startX:D,endX:U,startRow:S,endRow:_,startColumn:g,endColumn:I},this._control.update(this._targetSelection,h,m,this._control.selectionStyle),this._control.clearHighlight(),this._control.selectionScaling$.next(this._targetSelection)}_widgetEvent(e,t){const{offsetX:n,offsetY:o}=e,r=this._scene,s=r.getRelativeCoord(w.Vector2.FromArray([n,o])),{x:l,y:c}=s;this._startOffsetX=n,this._startOffsetY=o;const{startRow:d,startColumn:u,endRow:h,endColumn:m}=this._control.model;this._relativeSelectionPositionRow=d,this._relativeSelectionPositionColumn=u,this._relativeSelectionRowLength=h-d,this._relativeSelectionColumnLength=m-u,t===w.CURSOR_TYPE.NORTH_WEST_RESIZE?(this._relativeSelectionPositionRow=h,this._relativeSelectionPositionColumn=m):t===w.CURSOR_TYPE.NORTH_RESIZE?this._relativeSelectionPositionRow=h:t===w.CURSOR_TYPE.NORTH_EAST_RESIZE?this._relativeSelectionPositionRow=h:t===w.CURSOR_TYPE.WEST_RESIZE?this._relativeSelectionPositionColumn=m:t===w.CURSOR_TYPE.SOUTH_WEST_RESIZE&&(this._relativeSelectionPositionColumn=m);const S=w.ScrollTimer.create(r);S.startScroll(l,c),this._scrollTimer=S,r.disableEvent(),this._moveObserver=r.onPointerMoveObserver.add(g=>{const{offsetX:_,offsetY:I}=g,{x:C,y:b}=r.getRelativeCoord(w.Vector2.FromArray([_,I]));this._widgetMoving(C,b,t),r.setCursor(t),S.scrolling(C,b,()=>{this._widgetMoving(C,b,t)})}),this._upObserver=r.onPointerUpObserver.add(()=>{var _;const g=this._scene;g.resetCursor(),this._clearObserverEvent(),g.enableEvent(),(_=this._scrollTimer)==null||_.dispose(),this._control.selectionScaled$.next(this._targetSelection)})}_initialFill(){const{fillControl:e}=this._control;e.onPointerEnterObserver.add(()=>{e.setCursor(w.CURSOR_TYPE.CROSSHAIR)}),e.onPointerLeaveObserver.add(()=>{e.resetCursor()}),e.onPointerDownObserver.add(this._fillEvent.bind(this))}_fillMoving(e,t){var U,N,B;const n=this._scene,o=n.getScrollXYByRelativeCoords(w.Vector2.FromArray([this._startOffsetX,this._startOffsetY])),{scaleX:r,scaleY:s}=n.getAncestorScale(),l=this._skeleton.getCellPositionByOffset(e,t,r,s,o),{row:c,column:d}=l,u=n.getRelativeCoord(w.Vector2.FromArray([e,t])),h=this._skeleton.getRowCount()-1,m=this._skeleton.getColumnCount()-1;let S=this._relativeSelectionPositionRow,g=this._relativeSelectionPositionColumn,_=this._relativeSelectionPositionRow+this._relativeSelectionRowLength,I=this._relativeSelectionPositionColumn+this._relativeSelectionColumnLength,C=!1,b=!0;if((d<g||d>I)&&c>=S&&c<=_){const A=this._fillRuler(d,g,I,this._relativeSelectionColumnLength,m);g=A.startRowOrColumn,I=A.endRowOrColumn,C=A.isLighten,b=!1}else if((c<S||c>_)&&d>=g&&d<=I){const A=this._fillRuler(c,S,_,this._relativeSelectionRowLength,h);S=A.startRowOrColumn,_=A.endRowOrColumn,C=A.isLighten}else if(Math.abs(this._startOffsetX-u.x-o.x)/2>Math.abs(this._startOffsetY-u.y-o.y)){const A=this._fillRuler(d,g,I,this._relativeSelectionColumnLength,m);g=A.startRowOrColumn,I=A.endRowOrColumn,C=A.isLighten,b=!1}else{const A=this._fillRuler(c,S,_,this._relativeSelectionRowLength,h);S=A.startRowOrColumn,_=A.endRowOrColumn,C=A.isLighten}const M=this._skeleton.getNoMergeCellPositionByIndex(S,g,r,s),T=this._skeleton.getNoMergeCellPositionByIndex(_,I,r,s),E=(M==null?void 0:M.startY)||0,y=(T==null?void 0:T.endY)||0,O=(M==null?void 0:M.startX)||0,x=(T==null?void 0:T.endX)||0;C?this._controlHandler((A,H)=>{const V=new a.ColorKit(this._fillControlColors[H]).lighten(Lr).toRgbString();A.setProps({fill:V})}):this._controlHandler((A,H)=>{A.setProps({fill:this._fillControlColors[H]})});const D=f.SELECTION_CONTROL_BORDER_BUFFER_WIDTH/this._getScale();S===_&&b===!0||g===I&&b===!1?(U=this._helperSelection)==null||U.hide():((N=this._helperSelection)==null||N.transformByState({left:O-D/2,top:E-D/2,width:x-O,height:y-E}),(B=this._helperSelection)==null||B.show()),this._targetSelection={startY:E,endY:y,startX:O,endX:x,startRow:S,endRow:_,startColumn:g,endColumn:I},this._control.selectionFilling$.next(this._targetSelection)}_fillEvent(e){const{offsetX:t,offsetY:n}=e,o=this._scene,r=o.getRelativeCoord(w.Vector2.FromArray([t,n])),{x:s,y:l}=r;this._startOffsetX=s,this._startOffsetY=l;const{startRow:c,startColumn:d,endRow:u,endColumn:h}=this._control.model;this._isInMergeState=this._hasMergeInRange(c,d,u,h),this._relativeSelectionPositionRow=c,this._relativeSelectionPositionColumn=d,this._relativeSelectionRowLength=u-c,this._relativeSelectionColumnLength=h-d;const m=this._control.selectionStyle;let S=m==null?void 0:m.stroke,g=m==null?void 0:m.strokeWidth;const _=f.getNormalSelectionStyle(this._themeService);S==null&&(S=_.stroke),g==null&&(g=_.strokeWidth);const I=this._getScale();g/=I;const C=f.SELECTION_CONTROL_BORDER_BUFFER_WIDTH/I,b=new a.ColorKit(S).darken(2).toRgbString();this.isHelperSelection&&(this._helperSelection=new w.Rect(Di,{stroke:b,strokeWidth:g+C/2}),o.addObject(this._helperSelection));const M=w.ScrollTimer.create(o);M.startScroll(s,l),this._scrollTimer=M,o.disableEvent(),this._controlHandler(T=>{this._fillControlColors.push(T.fill)}),this._moveObserver=o.onPointerMoveObserver.add(T=>{const{offsetX:E,offsetY:y}=T,{x:O,y:x}=o.getRelativeCoord(w.Vector2.FromArray([E,y]));this._fillMoving(O,x),o.setCursor(w.CURSOR_TYPE.CROSSHAIR),M.scrolling(O,x,()=>{this._fillMoving(O,x)})}),this._upObserver=o.onPointerUpObserver.add(()=>{var E,y;(E=this._helperSelection)==null||E.dispose();const T=this._scene;T.resetCursor(),this._clearObserverEvent(),T.enableEvent(),(y=this._scrollTimer)==null||y.dispose(),this._control.refreshSelectionFilled(this._targetSelection),this._isInMergeState=!1,this._controlHandler((O,x)=>{O.setProps({fill:this._fillControlColors[x]})}),this._fillControlColors=[]})}_hasMergeInRange(e,t,n,o){const r=this._skeleton.mergeData;if(!r)return!1;for(const s of r){const{startRow:l,startColumn:c,endRow:d,endColumn:u}=s,h={left:t,top:e,right:o,bottom:n},m={left:c,top:l,right:u,bottom:d};if(w.isRectIntersect(h,m))return!0}return!1}_swapPositions(e,t,n,o){const r=Math.min(e,n),s=Math.min(t,o),l=Math.max(e,n),c=Math.max(t,o);return{startRow:r,startColumn:s,endRow:l,endColumn:c}}_controlHandler(e){const{leftControl:t,rightControl:n,topControl:o,bottomControl:r,backgroundControlTop:s,backgroundControlMiddleLeft:l,backgroundControlMiddleRight:c,backgroundControlBottom:d,fillControl:u}=this._control,h=[t,n,o,r,s,l,c,d,u];for(let m=0,S=h.length;m<S;m++){const g=h[m];e(g,m)}}_fillRuler(e,t,n,o,r){let s=!1;if(e<t)if(this._isInMergeState&&e<t){const l=t-e,c=o+1,d=Math.ceil(l/c);let u=t-d*c;u<0&&(u=t-(d-1)*c),t=u}else t=e;else if(e>=t&&e<=n)s=!0,n=e;else if(this._isInMergeState&&e>n){const l=e-n,c=o+1,d=Math.ceil(l/c);let u=n+d*c;u>r&&(u=n+(d-1)*c),n=u}else n=e;return{rowOrColumn:e,startRowOrColumn:t,endRowOrColumn:n,isLighten:s}}_getScale(){const{scaleX:e,scaleY:t}=this._scene.getAncestorScale();return Math.max(e,t)}}var Ur=Object.defineProperty,kr=Object.getOwnPropertyDescriptor,Br=(i,e,t,n)=>{for(var o=n>1?void 0:n?kr(e,t):e,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(e,t,o):s(o))||o);return n&&o&&Ur(e,t,o),o},Pi=(i,e)=>(t,n)=>e(t,n,i);exports.SelectionRenderService=class{constructor(e,t){v(this,"hasSelection",!1);v(this,"_downObserver");v(this,"_moveObserver");v(this,"_upObserver");v(this,"_controlFillConfig$",new k.BehaviorSubject(null));v(this,"controlFillConfig$",this._controlFillConfig$.asObservable());v(this,"_selectionControls",[]);v(this,"_startSelectionRange",{startY:0,endY:0,startX:0,endX:0,startRow:-1,endRow:-1,startColumn:-1,endColumn:-1});v(this,"_startOffsetX",0);v(this,"_startOffsetY",0);v(this,"_scrollTimer");v(this,"_cancelDownObserver");v(this,"_cancelUpObserver");v(this,"_skeleton");v(this,"_scene");v(this,"_isHeaderHighlight",!0);v(this,"_isDetectMergedCell",!0);v(this,"_selectionStyle");v(this,"_isSelectionEnabled",!0);v(this,"_isShowPreviousEnable",0);v(this,"_isRemainLastEnable",!0);v(this,"_isSkipRemainLastEnable",!1);v(this,"_selectionMoveEnd$",new k.BehaviorSubject([]));v(this,"selectionMoveEnd$",this._selectionMoveEnd$.asObservable());v(this,"_selectionMoving$",new k.Subject);v(this,"selectionMoving$",this._selectionMoving$.asObservable());v(this,"_selectionMoveStart$",new k.Subject);v(this,"selectionMoveStart$",this._selectionMoveStart$.asObservable());v(this,"_activeViewport");this._themeService=e,this._shortcutService=t,this._selectionStyle=f.getNormalSelectionStyle(this._themeService)}enableHeaderHighlight(){this._isHeaderHighlight=!0}disableHeaderHighlight(){this._isHeaderHighlight=!1}enableDetectMergedCell(){this._isDetectMergedCell=!0}disableDetectMergedCell(){this._isDetectMergedCell=!1}setStyle(e){this._selectionStyle=e}resetStyle(){this.setStyle(f.getNormalSelectionStyle(this._themeService))}enableSelection(){this._isSelectionEnabled=!0}disableSelection(){this._isSelectionEnabled=!1}enableShowPrevious(){this._isShowPreviousEnable=!0}disableShowPrevious(){this._isShowPreviousEnable=!1}enableRemainLast(){this._isRemainLastEnable=!0}disableRemainLast(){this._isRemainLastEnable=!1}enableSkipRemainLast(){this._isSkipRemainLastEnable=!0}disableSkipRemainLast(){this._isSkipRemainLastEnable=!1}getViewPort(){return this._activeViewport}addControlToCurrentByRangeData(e){const t=this.getCurrentControls();if(!t)return;const{rangeWithCoord:n,primaryWithCoord:o}=e,r=this._skeleton;let s=e.style;s==null&&(s=f.getNormalSelectionStyle(this._themeService));const l=this._scene;if(l==null||r==null)return;const c=new Rn(l,t.length,this._isHeaderHighlight,this._themeService);new Ni(c,r,l,this._themeService);const{rowHeaderWidth:d,columnHeaderHeight:u}=r;c.update(n,d,u,s,o),this._isHeaderHighlight?c.enableHeaderHighlight():c.disableHeaderHighlight(),t.push(c)}changeRuntime(e,t,n){this._skeleton=e,this._scene=t,this._activeViewport=n||t.getViewports()[0]}getSelectionDataWithStyle(){return this._selectionControls.map(t=>t.getValue())}getCurrentControls(){return this._selectionControls}_clearSelectionControls(){const e=this.getCurrentControls();if(e.length>0){for(const t of e)t.dispose();e.length=0}}getActiveSelections(){const e=this.getCurrentControls();if(e&&e.length>0)return e==null?void 0:e.map(n=>{const o=n.model,r=o.currentCell;let s=null;return r&&(s={actualRow:r.actualRow,actualColumn:r.actualColumn,isMerged:r.isMerged,isMergedMainCell:r.isMergedMainCell,startRow:r.mergeInfo.startRow,startColumn:r.mergeInfo.startColumn,endRow:r.mergeInfo.endRow,endColumn:r.mergeInfo.endColumn}),{range:{startRow:o.startRow,startColumn:o.startColumn,endRow:o.endRow,endColumn:o.endColumn},primary:s}})}getActiveRange(){const e=this.getCurrentControls(),t=e&&e[e.length-1].model;return t&&{startRow:t.startRow,startColumn:t.startColumn,endRow:t.endRow,endColumn:t.endColumn}}getActiveSelection(){const e=this.getCurrentControls();return e&&e[e.length-1]}endSelection(){this._endSelection()}reset(){this._clearSelectionControls(),this._moveObserver=null,this._upObserver=null,this._downObserver=null}resetAndEndSelection(){this.endSelection(),this.reset()}eventTrigger(e,t=0,n=a.RANGE_TYPE.NORMAL,o,r=w.ScrollTimerType.ALL){if(this._isSelectionEnabled===!1)return;const s=this._skeleton,{offsetX:l,offsetY:c}=e,d=this._scene;if(d==null||s==null)return;o!=null&&(this._activeViewport=o);const u=d.getRelativeCoord(w.Vector2.FromArray([l,c]));let{x:h,y:m}=u;this._startOffsetX=h,this._startOffsetY=m;const S=d.getScrollXYByRelativeCoords(u),{scaleX:g,scaleY:_}=d.getAncestorScale();n===a.RANGE_TYPE.ROW?h=0:n===a.RANGE_TYPE.COLUMN&&(m=0);const I=this._getSelectedRangeWithMerge(h,m,g,_,S);if(!I)return!1;const{rangeWithCoord:C,primaryWithCoord:b}=I,{startRow:M,startColumn:T,endColumn:E,endRow:y,startY:O,endY:x,startX:D,endX:U}=C,{rowHeaderWidth:N,columnHeaderHeight:B}=s,A={startColumn:T,startRow:M,endColumn:E,endRow:y,startY:O,endY:x,startX:D,endX:U,rangeType:n};this._startSelectionRange=A;let H=this.getActiveSelection();const V=this.getCurrentControls();if(!V)return!1;for(const $ of V){if(e.button===2&&$.model.isInclude(A)){H=$;return}if($.model.isEqual(A)){H=$;break}e.shiftKey||$.clearHighlight()}if(V.length>0&&!e.ctrlKey&&!e.shiftKey&&!this._isShowPreviousEnable&&!this._isRemainLastEnable){for(const $ of V)$.dispose();V.length=0}const F=H&&H.model.currentCell;if(H&&e.shiftKey&&F){const{actualRow:$,actualColumn:q,mergeInfo:z}=F,Q=Math.min($,A.startRow,z.startRow),J=Math.max($,A.endRow,z.endRow),we=Math.min(q,A.startColumn,z.startColumn),re=Math.max(q,A.endColumn,z.endColumn),Se=s.getMergeBounding(Q,we,J,re),qe=s.getNoMergeCellPositionByIndex(Se.startRow,Se.startColumn,g,_),Be=s.getNoMergeCellPositionByIndex(Se.endRow,Se.endColumn,g,_),Te={startColumn:Se.startColumn,startRow:Se.startRow,endColumn:Se.endColumn,endRow:Se.endRow,startY:qe.startY,endY:Be.endY,startX:qe.startX,endX:Be.endX,rangeType:n},de=s.getCellByIndex($,q,g,_);this._startSelectionRange={startColumn:de.mergeInfo.startColumn,startRow:de.mergeInfo.startRow,endColumn:de.mergeInfo.endColumn,endRow:de.mergeInfo.endRow,startY:de.mergeInfo.startY||0,endY:de.mergeInfo.endY||0,startX:de.mergeInfo.startX||0,endX:de.mergeInfo.endX||0,rangeType:n},H.update(Te,N,B,this._selectionStyle,F)}else this._isRemainLastEnable&&H&&!e.ctrlKey&&!e.shiftKey&&!this._isSkipRemainLastEnable?H.update(A,N,B,this._selectionStyle,b):(H=new Rn(d,V.length+t,this._isHeaderHighlight,this._themeService),new Ni(H,s,d,this._themeService),H.update(A,N,B,this._selectionStyle,b),V.push(H));this._selectionMoveStart$.next(this.getSelectionDataWithStyle()),this.hasSelection=!0,this._endSelection(),d.disableEvent();const j=w.ScrollTimer.create(this._scene,r);j.startScroll(h,m,o),this._scrollTimer=j,this._addCancelObserver(),(n===a.RANGE_TYPE.ROW||n===a.RANGE_TYPE.COLUMN)&&this._moving(h,m,H,n),this._moveObserver=d.onPointerMoveObserver.add($=>{const{offsetX:q,offsetY:z}=$,{x:Q,y:J}=d.getRelativeCoord(w.Vector2.FromArray([q,z]));this._moving(Q,J,H,n),j.scrolling(Q,J,()=>{this._moving(Q,J,H,n)})}),this._upObserver=d.onPointerUpObserver.add($=>{this._endSelection(),this._selectionMoveEnd$.next(this.getSelectionDataWithStyle()),this._shortcutService.setDisable(!1)}),this._shortcutService.setDisable(!0)}convertSelectionRangeToData(e){const{range:t,primary:n,style:o}=e;let r=this.convertRangeDataToSelection(t);return r==null&&(r={startRow:-1,startColumn:-1,endRow:-1,endColumn:-1,startY:0,endY:0,startX:0,endX:0,rangeType:a.RANGE_TYPE.NORMAL}),{rangeWithCoord:r,primaryWithCoord:this.convertCellRangeToInfo(n),style:o}}convertRangeDataToSelection(e){const{startRow:t,startColumn:n,endRow:o,endColumn:r,rangeType:s}=e,l=this._scene,c=this._skeleton;if(l==null||c==null)return;const{scaleX:d,scaleY:u}=l.getAncestorScale(),h=c.getNoMergeCellPositionByIndex(t,n,d,u),m=c.getNoMergeCellPositionByIndex(o,r,d,u);return{startRow:t,startColumn:n,endRow:o,endColumn:r,rangeType:s,startY:(h==null?void 0:h.startY)||0,endY:(m==null?void 0:m.endY)||0,startX:(h==null?void 0:h.startX)||0,endX:(m==null?void 0:m.endX)||0}}convertCellRangeToInfo(e){if(e==null)return;const t=this._scene,n=this._skeleton;if(t==null||n==null)return;const{actualRow:o,actualColumn:r,isMerged:s,isMergedMainCell:l,startRow:c,startColumn:d,endRow:u,endColumn:h}=e,{scaleX:m,scaleY:S}=t.getAncestorScale(),g=n.getNoMergeCellPositionByIndex(o,r,m,S),_=n.getNoMergeCellPositionByIndex(c,d,m,S),I=n.getNoMergeCellPositionByIndex(u,h,m,S);return{actualRow:o,actualColumn:r,isMerged:s,isMergedMainCell:l,startX:g.startX,startY:g.startY,endX:g.endX,endY:g.endY,mergeInfo:{startRow:c,startColumn:d,endRow:u,endColumn:h,startY:(_==null?void 0:_.startY)||0,endY:(I==null?void 0:I.endY)||0,startX:(_==null?void 0:_.startX)||0,endX:(I==null?void 0:I.endX)||0}}}_moving(e,t,n,o){const r=this._skeleton,s=this._scene;if(s==null||r==null)return!1;const{startRow:l,startColumn:c,endRow:d,endColumn:u}=this._startSelectionRange,h=s.getScrollXYByRelativeCoords(w.Vector2.FromArray([this._startOffsetX,this._startOffsetY]),this._activeViewport),{scaleX:m,scaleY:S}=s.getAncestorScale(),{rowHeaderWidth:g,columnHeaderHeight:_}=r;o===a.RANGE_TYPE.ROW?e=1/0:o===a.RANGE_TYPE.COLUMN&&(t=1/0);const I=this._getSelectedRangeWithMerge(e,t,m,S,h);if(!I)return!1;const{rangeWithCoord:C,primaryWithCoord:b}=I,{startRow:M,startColumn:T,endColumn:E,endRow:y}=C,O=Math.min(M,l),x=Math.min(T,c),D=Math.max(y,d),U=Math.max(E,u);let N={startRow:O,startColumn:x,endRow:D,endColumn:U};if(this._isDetectMergedCell&&(N=r.getSelectionBounding(O,x,D,U)),!N)return!1;const{startRow:B,startColumn:A,endRow:H,endColumn:V}=N,F=r.getNoMergeCellPositionByIndex(B,A,m,S),j=r.getNoMergeCellPositionByIndex(H,V,m,S),$={startColumn:A,startRow:B,endColumn:V,endRow:H,startY:(F==null?void 0:F.startY)||0,endY:(j==null?void 0:j.endY)||0,startX:(F==null?void 0:F.startX)||0,endX:(j==null?void 0:j.endX)||0},{startRow:q,endRow:z,startColumn:Q,endColumn:J}=(n==null?void 0:n.model)||{startRow:-1,endRow:-1,startColumn:-1,endColumn:-1};(Q!==A||q!==B||J!==V||z!==H)&&n!=null&&(n.update($,g,_),this._selectionMoving$.next(this.getSelectionDataWithStyle()))}_endSelection(){var n,o;const e=this._scene;if(e==null)return;e.onPointerMoveObserver.remove(this._moveObserver),e.onPointerUpObserver.remove(this._upObserver),e.enableEvent(),(n=this._scrollTimer)==null||n.dispose();const t=(o=e.getEngine())==null?void 0:o.activeScene;t==null||t.onPointerDownObserver.remove(this._cancelDownObserver),t==null||t.onPointerUpObserver.remove(this._cancelUpObserver)}_addCancelObserver(){var n;const e=this._scene;if(e==null)return;const t=(n=e.getEngine())==null?void 0:n.activeScene;t==null||t===e||(t.onPointerDownObserver.remove(this._cancelDownObserver),t.onPointerUpObserver.remove(this._cancelUpObserver),this._cancelDownObserver=t.onPointerDownObserver.add(o=>{this._endSelection()}),this._cancelUpObserver=t.onPointerUpObserver.add(o=>{this._endSelection()}))}_getSelectedRangeWithMerge(e,t,n,o,r){var C;if(this._isDetectMergedCell){const b=(C=this._skeleton)==null?void 0:C.calculateCellIndexByPosition(e,t,n,o,r),M=a.makeCellToSelection(b);return M==null?void 0:{primaryWithCoord:b,rangeWithCoord:M}}const s=this._skeleton;if(s==null)return;const l=s.getCellPositionByOffset(e,t,n,o,r),{row:c,column:d}=l,u=s.getNoMergeCellPositionByIndex(c,d,n,o),{startX:h,startY:m,endX:S,endY:g}=u,_={startY:m,endY:g,startX:h,endX:S,startRow:c,endRow:c,startColumn:d,endColumn:d};return{primaryWithCoord:{actualRow:c,actualColumn:d,isMerged:!1,isMergedMainCell:!1,startY:m,endY:g,startX:h,endX:S,mergeInfo:_},rangeWithCoord:_}}};exports.SelectionRenderService=Br([Pi(0,P.Inject(a.ThemeService)),Pi(1,R.IShortcutService)],exports.SelectionRenderService);const ce=P.createIdentifier("deprecated.univer.sheet.selection-render-service");var Vr=Object.defineProperty,Fr=Object.getOwnPropertyDescriptor,jr=(i,e,t,n)=>{for(var o=n>1?void 0:n?Fr(e,t):e,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(e,t,o):s(o))||o);return n&&o&&Vr(e,t,o),o},Li=(i,e)=>(t,n)=>e(t,n,i);exports.SheetSkeletonManagerService=class{constructor(e,t){v(this,"_currentSkeleton",{unitId:"",sheetId:""});v(this,"_sheetSkeletonParam",[]);v(this,"_currentSkeleton$",new k.BehaviorSubject(null));v(this,"currentSkeleton$",this._currentSkeleton$.asObservable());v(this,"_currentSkeletonBefore$",new k.BehaviorSubject(null));v(this,"currentSkeletonBefore$",this._currentSkeletonBefore$.asObservable());this._currentUniverService=e,this._localeService=t}dispose(){this._currentSkeletonBefore$.complete(),this._currentSkeleton$.complete(),this._sheetSkeletonParam=[]}getCurrent(){return this._getCurrentBySearch(this._currentSkeleton)}setCurrent(e){const t=this._getCurrentBySearch(e);if(t!=null)this._reCalculate(t);else{const{unitId:o,sheetId:r}=e,s=this._currentUniverService.getUniverSheetInstance(e.unitId),l=s==null?void 0:s.getSheetBySheetId(e.sheetId);if(l==null||s==null)return;const c=this._buildSkeleton(l,s);this._sheetSkeletonParam.push({unitId:o,sheetId:r,skeleton:c,dirty:!1})}this._currentSkeleton=e;const n=this.getCurrent();return this._currentSkeletonBefore$.next(n),this._currentSkeleton$.next(n),this.getCurrent()}reCalculate(){const e=this.getCurrent();e!=null&&this._reCalculate(e)}_reCalculate(e){e.dirty&&(e.skeleton.makeDirty(!0),e.dirty=!1),e.skeleton.calculate()}makeDirtyCurrent(e=!0){this.makeDirty(this._currentSkeleton,e)}makeDirty(e,t=!0){const n=this._getCurrentBySearch(e);n!=null&&(n.dirty=t)}_getCurrentBySearch(e){const t=this._sheetSkeletonParam.find(n=>n.unitId===e.unitId&&n.sheetId===e.sheetId);return t!=null&&(t.commandId=e.commandId),t}_buildSkeleton(e,t){const n=e.getConfig();return w.SpreadsheetSkeleton.create(e,n,e.getCellMatrix(),t.getStyles(),this._localeService)}};exports.SheetSkeletonManagerService=jr([Li(0,a.IUniverInstanceService),Li(1,P.Inject(a.LocaleService))],exports.SheetSkeletonManagerService);var Wr=Object.defineProperty,$r=Object.getOwnPropertyDescriptor,zr=(i,e,t,n)=>{for(var o=n>1?void 0:n?$r(e,t):e,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(e,t,o):s(o))||o);return n&&o&&Wr(e,t,o),o},Ve=(i,e)=>(t,n)=>e(t,n,i);const Xr=1e4,At=P.createIdentifier("univer.mark-selection-service");exports.MarkSelectionService=class extends a.Disposable{constructor(t,n,o,r,s,l,c){super();v(this,"_shapeMap",new Map);this._currentService=t,this._renderManagerService=n,this._selectionRenderService=o,this._commandService=r,this._sheetSkeletonManagerService=s,this._themeService=l,this._selectionManagerService=c}addShape(t,n=Xr){const o=this._currentService.getCurrentUniverSheetInstance(),r=o.getActiveSheet().getSheetId(),s=a.Tools.generateRandomId();return this._shapeMap.set(s,{selection:t,subUnitId:r,unitId:o.getUnitId(),zIndex:n,control:null}),this.refreshShapes(),s}refreshShapes(){const t=this._currentService.getCurrentUniverSheetInstance().getUnitId(),n=this._currentService.getCurrentUniverSheetInstance().getActiveSheet().getSheetId();this._shapeMap.forEach(o=>{var b;const{unitId:r,subUnitId:s,selection:l,control:c,zIndex:d}=o;if(r!==t||s!==n){c&&c.dispose();return}const{style:u}=l,{scene:h}=this._renderManagerService.getRenderById(r)||{},{rangeWithCoord:m,primaryWithCoord:S}=this._selectionRenderService.convertSelectionRangeToData(l),g=(b=this._sheetSkeletonManagerService.getCurrent())==null?void 0:b.skeleton;if(!h||!g)return;const{rowHeaderWidth:_,columnHeaderHeight:I}=g,C=new Rn(h,d,!1,this._themeService);C.update(m,_,I,u,S),o.control=C})}removeShape(t){const n=this._shapeMap.get(t);if(!n)return;const{control:o}=n;o&&o.dispose(),this._shapeMap.delete(t)}removeAllShapes(){for(const t of this._shapeMap.values()){const{control:n}=t;n&&n.dispose()}this._shapeMap.clear()}};exports.MarkSelectionService=zr([Ve(0,a.IUniverInstanceService),Ve(1,w.IRenderManagerService),Ve(2,ce),Ve(3,a.ICommandService),Ve(4,P.Inject(exports.SheetSkeletonManagerService)),Ve(5,P.Inject(a.ThemeService)),Ve(6,P.Inject(f.SelectionManagerService))],exports.MarkSelectionService);const Yr=10,Zr=6;function Gr(){return a.Tools.generateRandomId(Zr)}function Kr(i){const e=i.match(/data-copy-id="([^\s]+)"/);return e&&e[1]?e[1]:null}class qr{constructor(){v(this,"_cache",new a.LRUMap(Yr))}set(e,t){this._cache.set(e,t)}get(e){return this._cache.get(e)}del(e){this._cache.delete(e)}clear(){this._cache.clear()}}const Ln=new qr;function Jr(i){const e=new DOMParser,t=`<x-univer id="univer-root">${i}</x-univer>`;return e.parseFromString(t,"text/html").querySelector("#univer-root")}function Qr(i){const e=i.style,t={};for(let n=0;n<e.length;n++){const o=e[n],r=e.getPropertyValue(o);switch(o){case"margin-top":{const s=parseInt(r);t.spaceAbove=/pt/.test(r)?qn(s):s;break}case"margin-bottom":{const s=parseInt(r);t.spaceBelow=/pt/.test(r)?qn(s):s;break}}}return Object.getOwnPropertyNames(t).length?t:null}function qn(i){return i/.75}function Ui(i,e){const t=[];for(let n=0,o=i.length;n<o;n++)i[n]===a.DataStreamTreeTokenType.PARAGRAPH&&t.push({startIndex:n});if(e)for(const n of t)e.bullet&&(n.bullet=a.Tools.deepClone(e.bullet)),e.paragraphStyle&&(n.paragraphStyle=a.Tools.deepClone(e.paragraphStyle));return t}function ci(i){const e=i.style,t={},n=i.tagName.toLowerCase();switch(n){case"b":case"em":case"strong":{t.bl=a.BooleanNumber.TRUE;break}case"s":{t.st={s:a.BooleanNumber.TRUE};break}case"u":{t.ul={s:a.BooleanNumber.TRUE};break}case"i":{t.it=a.BooleanNumber.TRUE;break}case"sub":case"sup":{t.va=n==="sup"?a.BaselineOffset.SUPERSCRIPT:a.BaselineOffset.SUBSCRIPT;break}}for(let o=0;o<e.length;o++){const r=e[o],s=e.getPropertyValue(r);switch(r){case"font-family":{t.ff=s;break}case"font-size":{const l=parseInt(s);Number.isNaN(l)||(t.fs=/pt$/.test(s)?qn(l):l);break}case"font-style":{s==="italic"&&(t.it=a.BooleanNumber.TRUE);break}case"font-weight":{Number(s)>400&&(t.bl=a.BooleanNumber.TRUE);break}case"text-decoration":{/underline/.test(s)?t.ul={s:a.BooleanNumber.TRUE}:/overline/.test(s)?t.ol={s:a.BooleanNumber.TRUE}:/line-through/.test(s)&&(t.st={s:a.BooleanNumber.TRUE});break}case"color":{const l=new a.ColorKit(s);l.isValid&&(t.cl={rgb:l.toRgbString()});break}case"background-color":{const l=new a.ColorKit(s);l.isValid&&(t.bg={rgb:l.toRgbString()});break}}}return t}function ki(i,e){const t=i.tagName.toLowerCase();return typeof e=="string"?t===e:Array.isArray(e)?e.some(n=>n===t):e(i)}const En=class En{constructor(e){v(this,"styleCache",new Map);v(this,"styleRules",[]);v(this,"afterProcessRules",[]);v(this,"getCurrentSkeleton");this.getCurrentSkeleton=e.getCurrentSkeleton}static use(e){if(this.pluginList.includes(e))throw new Error(`Univer paste plugin ${e.name} already added`);this.pluginList.push(e)}convert(e){const t=En.pluginList.find(m=>m.checkPasteType(e));t&&(this.styleRules=[...t.stylesRules],this.afterProcessRules=[...t.afterProcessRules]);const n=new a.ObjectMatrix,o=Jr(e),r={dataStream:"",textRuns:[]},s=[],l=e.match(/<table.*?>([\s\S]*?)<\/table>/gi),c=[];this.process(null,o==null?void 0:o.childNodes,r,c);const{paragraphs:d,dataStream:u,textRuns:h}=r;if(d){const m=d.map(S=>S.startIndex+1);m.unshift(0);for(let S=0;S<m.length;S++){let g;S===m.length-1?g=`${u.substring(m[S])}\r
2
- `:g=`${u.substring(m[S],m[S+1]-1)}\r
3
- `;const _=[];h==null||h.forEach(C=>{C.st>=m[S]&&C.ed<=m[S+1]&&_.push({st:C.st-m[S],ed:C.ed-m[S],ts:C.ts})});const I=this._generateDocumentDataModelSnapshot({body:{dataStream:g,textRuns:_,paragraphs:Ui(g)}});n.setValue(n.getLength(),0,{v:g,p:I}),s.push({}),l&&c.forEach(C=>{const b=n.getLength();if(C.index===S){const M=l.shift(),{cellMatrix:T,colProperties:E,rowProperties:y}=this._parseTable(M);T&&T.forValue((O,x,D)=>{n.setValue(b+O,x,D)}),s.push(...y)}})}}else{if(u){const m=`${u}\r
4
- `,S={dataStream:m,textRuns:h,paragraphs:Ui(m)},g=this._generateDocumentDataModelSnapshot({body:S});n.setValue(0,0,{v:u,p:g}),s.push({})}l&&l.forEach(m=>{const S=n.getLength(),{cellMatrix:g}=this._parseTable(m);g&&g.forValue((_,I,C)=>{n.setValue(S+_,I,C)}),s.push(...s)})}return{rowProperties:[],colProperties:[],cellMatrix:n}}_parseTable(e){const t=new a.ObjectMatrix;ns(e);const{rowProperties:n,rowCount:o,cellMatrix:r}=es(e);return r&&r.forValue((s,l,c)=>{var u;const d=R.handleStringToStyle(void 0,(u=c.properties)==null?void 0:u.style);t.setValue(s,l,{v:c.content,s:d,rowSpan:c.rowSpan,colSpan:c.colSpan})}),{rowProperties:[],colProperties:[],cellMatrix:t}}_generateDocumentDataModelSnapshot(e){var l;const t=this.getCurrentSkeleton();if(t==null)return null;const{skeleton:n}=t,o=(l=n.getBlankCellDocumentModel())==null?void 0:l.documentModel,s={...o==null?void 0:o.getSnapshot(),...e};return o==null||o.reset(s),o==null?void 0:o.getSnapshot()}process(e,t,n,o){var r,s;for(const l of t)if(l.nodeName.toLowerCase()==="table")o.push({index:((r=n==null?void 0:n.paragraphs)==null?void 0:r.length)||0});else if(l.nodeType===Node.TEXT_NODE){const c=(s=l.nodeValue)==null?void 0:s.replace(/[\r\n]/g,"");let d;e&&this.styleCache.has(e)&&(d=this.styleCache.get(e));const u={dataStream:"",textRuns:[]};n.dataStream+=c,u.dataStream+=c,d&&Object.getOwnPropertyNames(d).length&&(n.textRuns.push({st:n.dataStream.length-c.length,ed:n.dataStream.length,ts:d}),u.textRuns.push({st:n.dataStream.length-c.length,ed:n.dataStream.length,ts:d}))}else if(l.nodeType===Node.ELEMENT_NODE){const c=e?this.styleCache.get(e):{},d=this.styleRules.find(({filter:S})=>ki(l,S)),u=d?d.getStyle(l):ci(l);this.styleCache.set(l,{...c,...u});const{childNodes:h}=l;this.process(l,h,n,o);const m=this.afterProcessRules.find(({filter:S})=>ki(l,S));m&&m.handler(n,l)}}};v(En,"pluginList",[]);let Et=En;function es(i){const e=/<tr([\s\S]*?)>([\s\S]*?)<\/tr>/gi,t=i.matchAll(e);if(!t)return{rowProperties:[],rowCount:0,colCount:0,cellMatrix:null};const n=Array.from(t),o=n.map(l=>di(l[1])),{colCount:r,cellMatrix:s}=ts(n.map(l=>l[2]));return{rowProperties:o,rowCount:o.length,colCount:r,cellMatrix:s}}function ts(i){const e=new a.ObjectMatrix,t=new Map,n=/<td([\s\S]*?)>([\s\S]*?)<\/td>/gi;let o=0,r=0,s=0;return i.forEach((l,c)=>{const d=c===0,u=l.matchAll(n);r=0,Array.from(u).forEach(h=>{const m=di(h[1]),S=h[2].replace(/&nbsp;/g," "),g=m.rowspan?+m.rowspan:1,_=m.colspan?+m.colspan:1;if(!d){for(let C=r;C<o;C++)if(!(t.get(C)>=s)){r=C;break}}const I={content:S,properties:m};_>1&&(I.colSpan=+_),g>1&&(I.rowSpan=+g),d&&(o+=_);for(let C=r;C<r+_;C++)t.set(C,s+g-1);e.setValue(s,r,I),r+=_}),s+=1}),{colCount:o,cellMatrix:e}}function di(i){if(!i)return{};const e=/([\w-]+)="([^"]*)"/gi,t=i.matchAll(e),n={};return Array.from(t).forEach(o=>{const[r,s,l]=o;n[s]=l}),n}function ns(i){const e=/<colgroup([\s\S]*?)>(.*?)<\/colgroup>/,t=i.match(e);if(!t||!t[2])return null;const n=/<col([\s\S]*?)>/g,o=t[2].matchAll(n);return o?Array.from(o).map(r=>di(r[1])):null}const is={name:"univer-doc-paste-plugin-lark",checkPasteType(i){return/lark-record-clipboard/i.test(i)},stylesRules:[{filter:["s"],getStyle(i){const e=ci(i);return{st:{s:a.BooleanNumber.TRUE},...e}}}],afterProcessRules:[{filter(i){return i.tagName==="DIV"&&/ace-line/i.test(i.className)},handler(i){i.paragraphs==null&&(i.paragraphs=[]),i.paragraphs.push({startIndex:i.dataStream.length}),i.dataStream+="\r"}}]},os=is,rs={name:"univer-doc-paste-plugin-word",checkPasteType(i){return/word|mso/i.test(i)},stylesRules:[{filter:["b"],getStyle(i){const e=ci(i);return{bl:a.BooleanNumber.TRUE,...e}}}],afterProcessRules:[{filter(i){return i.tagName==="P"&&/mso/i.test(i.className)},handler(i,e){i.paragraphs==null&&(i.paragraphs=[]);const t={startIndex:i.dataStream.length},n=Qr(e);n&&(t.paragraphStyle=n),i.paragraphs.push(t),i.dataStream+="\r"}}]},ss=rs;var Xe=(i=>(i.COPY="COPY",i.CUT="CUT",i))(Xe||{});function ls(i,e,t,n){const o=t.map(c=>{var d;return(d=c.onCopyRow)==null?void 0:d.call(c,i)}).filter(c=>!!c),r=ui(o),s=hi(r),l=e.map(c=>as(i,c,t,n)).filter(c=>!!c).join("");return`<tr${s}>${l}</tr>`}function as(i,e,t,n){const o=n.getValue(i,e),r=t.map(d=>{var u;return(u=d.onCopyCellStyle)==null?void 0:u.call(d,i,e,o==null?void 0:o.rowSpan,o==null?void 0:o.colSpan)}).filter(d=>!!d),s=ui(r),l=hi(s),c=t.reduce((d,u)=>{var h;return d||((h=u.onCopyCellContent)==null?void 0:h.call(u,i,e))||""},"");return`<td${l}>${c}</td>`}function cs(i,e){return`<colgroup>${i.map(n=>{const o=e.map(l=>{var c;return(c=l.onCopyColumn)==null?void 0:c.call(l,n)}).filter(l=>!!l),r=ui(o);return`<col ${hi(r)}>`}).join("")}</colgroup>`}function ui(i){return i.reduce((e,t)=>(Object.keys(t).forEach(o=>{e[o]?e[o]+=`;${t[o]}`:e[o]=t[o]}),e),{})}function hi(i){return Object.keys(i).reduce((e,t)=>(e+=` ${t}="${i[t]}"`,e),"")}function ds(i,e){const t=[];for(let n=i;n<=e;n++)t.push(n);return t}class us{convert(e,t,n){const{startColumn:o,endColumn:r}=t,s=cs(ds(o,r),n),l=[];return e.forRow((d,u)=>{l.push(ls(d,u,n,e))}),`<google-sheets-html-origin><table xmlns="http://www.w3.org/1999/xhtml" cellspacing="0" cellpadding="0" dir="ltr" border="1" style="table-layout:fixed;font-size:10pt;font-family:Arial;width:0px;border-collapse:collapse;border:none">${s}
5
- <tbody>${l.join("")}</tbody></table>`}}var hs=Object.defineProperty,ms=Object.getOwnPropertyDescriptor,Ss=(i,e,t,n)=>{for(var o=n>1?void 0:n?ms(e,t):e,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(e,t,o):s(o))||o);return n&&o&&hs(e,t,o),o},He=(i,e)=>(t,n)=>e(t,n,i);const le={DEFAULT_COPY:"default-copy",DEFAULT_PASTE:"default-paste",SPECIAL_PASTE_VALUE:"special-paste-value",SPECIAL_PASTE_FORMAT:"special-paste-format",SPECIAL_PASTE_COL_WIDTH:"special-paste-col-width",SPECIAL_PASTE_BESIDES_BORDER:"special-paste-besides-border"};Et.use(ss);Et.use(os);const lt=P.createIdentifier("sheet.clipboard-service");exports.SheetClipboardService=class extends a.Disposable{constructor(t,n,o,r,s,l,c,d){super();v(this,"_clipboardHooks",[]);v(this,"_clipboardHooks$",new k.BehaviorSubject([]));v(this,"clipboardHooks$",this._clipboardHooks$.asObservable());v(this,"_htmlToUSM");v(this,"_usmToHtml");v(this,"_copyMarkId",null);v(this,"_pasteType",le.DEFAULT_PASTE);this._logService=t,this._currentUniverService=n,this._selectionManagerService=o,this._clipboardInterfaceService=r,this._undoRedoService=s,this._commandService=l,this._markSelectionService=c,this._sheetSkeletonManagerService=d,this._htmlToUSM=new Et({getCurrentSkeleton:()=>this._sheetSkeletonManagerService.getCurrent()}),this._usmToHtml=new us}async copy(t=Xe.COPY){const n=this._selectionManagerService.getLast();if(!n)return!1;const o=this._clipboardHooks;o.reduce((C,b)=>{var T;const M=(T=b.getFilteredOutRows)==null?void 0:T.call(b);return M==null||M.forEach(E=>C.add(E)),C},new Set);const{startColumn:r,startRow:s,endColumn:l,endRow:c}=n.range,d=this._currentUniverService.getCurrentUniverSheetInstance(),u=d.getActiveSheet(),h=u.getMatrixWithMergedCells(s,r,c,l),m=new a.ObjectMatrix;for(let C=s;C<=c;C++)for(let b=r;b<=l;b++){const M=h.getValue(C,b);M?m.setValue(C-s,b-r,{...Bi(),...a.Tools.deepClone(M)}):m.setValue(C-s,b-r,Bi())}o.forEach(C=>{var b;return(b=C.onBeforeCopy)==null?void 0:b.call(C,d.getUnitId(),u.getSheetId(),n.range)});let S=this._usmToHtml.convert(h,n.range,o);const g=_s(m),_=Gr();S=S.replace(/(<[a-z]+)/,(C,b)=>`${b} data-copy-id="${_}"`),Ln.set(_,{unitId:d.getUnitId(),subUnitId:u.getSheetId(),range:n.range,matrix:m,copyType:t}),await this._clipboardInterfaceService.write(g,S),this._markSelectionService.removeAllShapes();const I=this._selectionManagerService.createCopyPasteSelection();return this._copyMarkId=this._markSelectionService.addShape({...n,style:I}),o.forEach(C=>{var b;return(b=C.onAfterCopy)==null?void 0:b.call(C)}),!0}async cut(){return this.copy(Xe.CUT)}async paste(t,n=le.DEFAULT_PASTE){const o=t.types,r=o.indexOf(R.PLAIN_TEXT_CLIPBOARD_MIME_TYPE)!==-1?await t.getType(R.PLAIN_TEXT_CLIPBOARD_MIME_TYPE).then(l=>l&&l.text()):"",s=o.indexOf(R.HTML_CLIPBOARD_MIME_TYPE)!==-1?await t.getType(R.HTML_CLIPBOARD_MIME_TYPE).then(l=>l&&l.text()):"";return s?this._pasteHTML(s,n):r?this._pastePlainText(r):(this._logService.error("[SheetClipboardService]","No valid data on clipboard"),!1)}addClipboardHook(t){if(this._clipboardHooks.findIndex(o=>o.hookName===t.hookName)!==-1)return this._logService.error("[SheetClipboardService]","hook already exists",t.hookName),{dispose:()=>{}};const n=this._clipboardHooks.findIndex(o=>{const r=o.priority||0;return(t.priority||0)<r});return this._clipboardHooks.splice(n!==-1?n:this._clipboardHooks.length,0,t),this._notifyClipboardHook(),a.toDisposable(()=>{const o=this._clipboardHooks.indexOf(t);o>-1&&(this._clipboardHooks.splice(o,1),this._notifyClipboardHook())})}getClipboardHooks(){return this._clipboardHooks}_notifyClipboardHook(){this._clipboardHooks$.next(this._clipboardHooks)}async _pastePlainText(t){const n=this._getPastingTarget();if(!n.selection)return!1;const o=n.selection.range,r={[o.startRow]:{[o.endColumn]:{v:t}}},s={unitId:n.unitId,subUnitId:n.subUnitId,cellValue:r};return this._commandService.syncExecuteCommand(f.SetRangeValuesMutation.id,s)}async _pasteHTML(t,n){const o=Kr(t);return o?this._pasteInternal(o,n):this._pasteExternal(t,n)}async _pasteExternal(t,n){const o=this._getPastingTarget(),{selection:r,unitId:s,subUnitId:l}=o;if(!r)return!1;const{rowProperties:c,colProperties:d,cellMatrix:u}=this._htmlToUSM.convert(t),{startColumn:h,endColumn:m,startRow:S,endRow:g}=u.getDataRange(),_=g-S+1,I=m-h+1;if(!u)return!1;const C=this._transformPastedData(_,I,u,r.range);return C?this._pasteUSM({rowProperties:c,colProperties:d,cellMatrix:u},{unitId:s,subUnitId:l,pastedRange:C},n):!1}async _pasteInternal(t,n){var b;const o=this._getPastingTarget(),{selection:r,unitId:s,subUnitId:l}=o,c=a.Tools.deepClone(Ln.get(t)),{range:d,matrix:u}=c||{};if(!r||!u||!c||!d||!r||!u||!c)return!1;const h=(b=this._currentUniverService.getUniverSheetInstance(s))==null?void 0:b.getStyles();u.forValue((M,T,E)=>{if(typeof E.s=="string"){const y=a.Tools.deepClone(E);y.s=h==null?void 0:h.getStyleByCell(E),u.setValue(M,T,y)}});const{startColumn:m,endColumn:S,startRow:g,endRow:_}=d,I=this._transformPastedData(_-g+1,S-m+1,u,r.range);if(!I)return!1;const C=this._pasteUSM({cellMatrix:u},{unitId:s,subUnitId:l,pastedRange:I},n,{range:d,unitId:c.unitId,subUnitId:c.subUnitId,copyType:c.copyType,copyId:t});return c.copyType===Xe.CUT&&(Ln.del(t),this._copyMarkId&&this._markSelectionService.removeShape(this._copyMarkId),this._copyMarkId=null),C}_pasteUSM(t,n,o,r){const{rowProperties:s,colProperties:l,cellMatrix:c}=t,{unitId:d,subUnitId:u,pastedRange:h}=n,{startColumn:m,endColumn:S}=h,g=S-m+1,_=this._clipboardHooks,I=[];if(_.some(x=>{var D;return I.push(x)&&((D=x.onBeforePaste)==null?void 0:D.call(x,d,u,h))===!1}))return I.forEach(x=>{var D;return(D=x.onAfterPaste)==null?void 0:D.call(x,!1)}),!1;if(!c)return!1;const b=r?{copyRange:r.range,copyType:r.copyType,unitId:r.unitId,subUnitId:r.subUnitId}:{copyType:Xe.COPY},M=[],T=[];_.filter(x=>!x.specialPasteInfo&&x.hookName!==le.DEFAULT_PASTE||o===x.hookName).forEach(x=>{var N,B,A;if(s){const H=(N=x.onPasteRows)==null?void 0:N.call(x,h,s,o);H&&(M.push(...H.redos),T.push(...H.undos))}const D=(B=x.onPasteColumns)==null?void 0:B.call(x,h,l||new Array(g).map(()=>({})),o);D&&(M.push(...D.redos),T.push(...D.undos));const U=(A=x.onPasteCells)==null?void 0:A.call(x,h,c,o,b);U&&(M.push(...U.redos),T.push(...U.undos))});const y=this._getSetSelectionOperation(d,u,h,c);y&&M.push(y),this._logService.log("[SheetClipboardService]","pasting mutations",{undoMutationsInfo:T,redoMutationsInfo:M});const O=M.every(x=>this._commandService.executeCommand(x.id,x.params));return O&&this._undoRedoService.pushUndoRedo({unitID:d,undoMutations:T,redoMutations:M}),O}_getSetSelectionOperation(t,n,o,r){var _;const s=(_=this._currentUniverService.getUniverSheetInstance(t))==null?void 0:_.getSheetBySheetId(n);if(!s)return null;const{startRow:l,startColumn:c}=o,d={startRow:l,endRow:l,startColumn:c,endColumn:c},u=f.getPrimaryForRange(d,s),h=r.getValue(0,0),m=(h==null?void 0:h.rowSpan)||1,S=(h==null?void 0:h.colSpan)||1;if(m>1||S>1){const I={startRow:l,endRow:l+m-1,startColumn:c,endColumn:c+S-1};u.startRow=I.startRow,u.endRow=I.endRow,u.startColumn=I.startColumn,u.endColumn=I.endColumn,u.isMerged=!0,u.isMergedMainCell=!0}const g={unitId:t,subUnitId:n,pluginName:f.NORMAL_SELECTION_PLUGIN_NAME,selections:[{range:o,primary:u,style:null}]};return{id:f.SetSelectionsOperation.id,params:g}}_getPastingTarget(){const t=this._currentUniverService.getCurrentUniverSheetInstance(),n=t.getActiveSheet(),o=this._selectionManagerService.getLast();return{unitId:t.getUnitId(),subUnitId:n.getSheetId(),selection:o}}_transformPastedData(t,n,o,r){const{startRow:s,startColumn:l,endRow:c,endColumn:d}=r,u=c-s+1,h=d-l+1,_=this._currentUniverService.getCurrentUniverSheetInstance().getActiveSheet().getMergeData().filter(E=>a.Rectangle.intersects({startRow:s,startColumn:l,endRow:c,endColumn:d},E)),I=_[0];let C=0,b=0,M=0,T=0;if(I&&(C=I.startRow,b=I.startColumn,M=I.endRow,T=I.endColumn),u%t===0&&h%n===0)if(_.length>0&&(u!==t||h!==n))if(C===s&&b===l&&M===c&&T===d)if(Cs(o))for(let y=0;y<u;y++)for(let O=0;O<h;O++){const x=o.getValue(y%t,O%n);x&&o.setValue(y,O,x)}else o.forValue((y,O,x)=>{x.s=null,delete x.colSpan,delete x.rowSpan});else for(let E=0;E<u;E++)for(let y=0;y<h;y++){const O=o.getValue(E%t,y%n);O&&o.setValue(E,y,O)}else for(let E=0;E<u;E++)for(let y=0;y<h;y++){const O=o.getValue(E%t,y%n);O&&o.setValue(E,y,O)}else if(_.length>0)if(this._topLeftCellsMatch(t,n,r))r.endRow=s+t-1,r.endColumn=l+n-1;else{if(c>I.endRow||d>I.endColumn)return alert("We can't do that to a merged cell "),null;o.forValue((y,O,x)=>{x.s=null,delete x.colSpan,delete x.rowSpan})}else r.endRow=s+t-1,r.endColumn=l+n-1;return r}_topLeftCellsMatch(t,n,o){const s=this._currentUniverService.getCurrentUniverSheetInstance().getActiveSheet(),{startRow:l,startColumn:c,endRow:d,endColumn:u}=o,h=ps(l+t-1,c,c+t-1,s),m=vs(c+n-1,l,l+t-1,s);return!h&&!m}};exports.SheetClipboardService=Ss([He(0,a.ILogService),He(1,a.IUniverInstanceService),He(2,P.Inject(f.SelectionManagerService)),He(3,R.IClipboardInterfaceService),He(4,a.IUndoRedoService),He(5,a.ICommandService),He(6,At),He(7,P.Inject(exports.SheetSkeletonManagerService))],exports.SheetClipboardService);function _s(i){let e="";return i.forRow((t,n)=>{const o=[];n.forEach(r=>{const s=i.getValue(t,r);if(s){const l=gs(s);o.push(l)}}),e+=o.join(" "),t!==i.getLength()-1&&(e+=`
6
- `)}),e}function gs(i){const e=i.v;return fs((e==null?void 0:e.toString())||"")}const fs=i=>i.replace(/&/g,"&amp;").replace(/\ufeff/g,"").replace(/</g,"&lt;").replace(/>/g,"&gt;");function ps(i,e,t,n){return n.getMergeData().some(o=>o.startRow<=i&&i<o.endRow&&e<=o.startColumn&&o.startColumn<=t)}function vs(i,e,t,n){return n.getMergeData().some(o=>o.startColumn<=i&&i<o.endColumn&&e<=o.startRow&&o.startRow<=t)}function Cs(i){let e=0;return i.forValue((t,n,o)=>{if(o&&e++,e>1)return!1}),e>1}function Bi(){return{p:null,v:null,s:null,f:null,si:null,t:null}}const wo={id:R.CopyCommand.id,name:"sheet.command.copy",type:a.CommandType.COMMAND,multi:!0,priority:1e3,preconditions:Z,handler:async i=>i.get(lt).copy()},Is={id:R.CutCommand.id,name:"sheet.command.cut",type:a.CommandType.COMMAND,multi:!0,priority:1e3,preconditions:Z,handler:async i=>i.get(lt).cut()},at={id:R.PasteCommand.id,type:a.CommandType.COMMAND,multi:!0,name:"sheet.command.paste",priority:1e3,preconditions:Z,handler:async(i,e)=>{const t=i.get(a.ILogService);if(t.log("[SheetPasteCommand]","the focusing element is",document.activeElement),!document.execCommand("paste")){t.log("[SheetPasteCommand]","failed to execute paste command on the activeElement, trying to use clipboard API.");const r=await i.get(R.IClipboardInterfaceService).read(),s=i.get(lt);return r.length!==0?s.paste(r[0],e==null?void 0:e.value):!1}return!1}},To={id:"sheet.command.paste-value",type:a.CommandType.COMMAND,handler:async i=>i.get(a.ICommandService).executeCommand(at.id,{value:le.SPECIAL_PASTE_VALUE})},Eo={id:"sheet.command.paste-format",type:a.CommandType.COMMAND,handler:async i=>i.get(a.ICommandService).executeCommand(at.id,{value:le.SPECIAL_PASTE_FORMAT})},yo={id:"sheet.command.paste-col-width",type:a.CommandType.COMMAND,handler:async i=>i.get(a.ICommandService).executeCommand(at.id,{value:le.SPECIAL_PASTE_COL_WIDTH})},Oo={id:"sheet.command.paste-besides-border",type:a.CommandType.COMMAND,handler:async i=>i.get(a.ICommandService).executeCommand(at.id,{value:le.SPECIAL_PASTE_BESIDES_BORDER})};function Le(i,e,t,n,o=!0,r=1,s=!0){let l={...i};n==null&&(n={startRow:0,endRow:t.getRowCount()-1,startColumn:0,endColumn:t.getColumnCount()-1});let c;switch(e){case a.Direction.UP:for(c=i.startRow-r;c>-1&&!t.getRowVisible(c);)c-=1;c>=n.startRow?(l.startRow=c,l.endRow=c):s&&(l.startRow=n.endRow,l.endRow=n.endRow,o&&(l=Le(l,a.Direction.LEFT,t,n,!1)));break;case a.Direction.DOWN:for(c=i.endRow+r;c<t.getRowCount()&&!t.getRowVisible(c);)c+=1;c<=n.endRow?(l.startRow=c,l.endRow=c):s&&(l.startRow=n.startRow,l.endRow=n.startRow,o&&(l=Le(l,a.Direction.RIGHT,t,n,!1)));break;case a.Direction.LEFT:for(c=i.startColumn-r;c>-1&&!t.getColVisible(c);)c-=1;c>=n.startColumn?(l.startColumn=c,l.endColumn=c):s&&(l.startColumn=n.endColumn,l.endColumn=n.endColumn,o&&(l=Le(l,a.Direction.UP,t,n,!1)));break;case a.Direction.RIGHT:for(c=i.endColumn+r;c<t.getColumnCount()&&!t.getColVisible(c);)c+=1;c<=n.endColumn?(l.startColumn=c,l.endColumn=c):s&&(l.startColumn=n.startColumn,l.endColumn=n.startColumn,o&&(l=Le(l,a.Direction.DOWN,t,n,!1)));break}return l}function mi(i,e,t){const n={...i},{startRow:o,startColumn:r,endRow:s,endColumn:l}=yt(i,e,t);let c=St(t,o,r,s,l).hasValue,d=!0,u=!0;for(;u;){if(a.Direction.UP===e){let h=n.startRow-1;for(;h>-1&&!t.getRowVisible(h);)h-=1;if(h===-1){u=!1;break}const{hasValue:m,matrix:S}=St(t,h,n.startColumn,h,n.endColumn);if(c&&!m&&!d){u=!1;break}else{if(S.getLength()!==0){let g=h;S.forValue(_=>{g=Math.min(_,g)}),n.startRow=g}else n.startRow=h;if(n.endRow=n.startRow,!c&&m){u=!1;break}c=m,d=!1}}if(a.Direction.DOWN===e){let h=n.endRow+1;for(;h<t.getRowCount()&&!t.getRowVisible(h);)h+=1;if(h===t.getRowCount()){u=!1;break}const{hasValue:m,matrix:S}=St(t,h,n.startColumn,h,n.endColumn);if(c&&!m&&!d){u=!1;break}else{if(S.getLength()!==0){let g=h;S.forValue((_,I,C)=>{g=Math.max(_+(C.rowSpan||1)-1,g)}),n.endRow=g}else n.endRow=h;if(n.startRow=n.endRow,!c&&m){u=!1;break}c=m,d=!1}}if(a.Direction.LEFT===e){let h=n.startColumn-1;for(;h>-1&&!t.getColVisible(h);)h-=1;if(h===-1){u=!1;break}const{hasValue:m,matrix:S}=St(t,n.startRow,h,n.endRow,h);if(c&&!m&&!d){u=!1;break}else{if(S.getLength()!==0){let g=h;S.forValue((_,I)=>{g=Math.min(I,g)}),n.startColumn=g}else n.startColumn=h;if(n.endColumn=n.startColumn,!c&&m){u=!1;break}c=m,d=!1}}if(a.Direction.RIGHT===e){let h=n.endColumn+1;for(;h<t.getColumnCount()&&!t.getColVisible(h);)h+=1;if(h===t.getColumnCount()){u=!1;break}const{hasValue:m,matrix:S}=St(t,n.startRow,h,n.endRow,h);if(c&&!m&&!d){u=!1;break}else{if(S.getLength()!==0){let g=h;S.forValue((_,I,C)=>{g=Math.max(I+(C.colSpan||1)-1,g)}),n.endColumn=g}else n.endColumn=h;if(n.startColumn=n.endColumn,!c&&m){u=!1;break}c=m,d=!1}}}return f.alignToMergedCellsBorders(n,t,!0)}function xo(i,e,t){return Le(i,e,t,void 0,!1,1,!1)}function Rs(i,e,t){const n=mi(i,e,t);return f.alignToMergedCellsBorders(a.Rectangle.union(n,i),t,!0)}function bs(i,e,t){const n=xo(i,e,t),o={startRow:Math.min(i.startRow,n.startRow),startColumn:Math.min(i.startColumn,n.startColumn),endRow:Math.max(i.endRow,n.endRow),endColumn:Math.max(i.endColumn,n.endColumn)};return f.alignToMergedCellsBorders(a.Rectangle.union(i,o),t)}function Ms(i,e,t,n){const o=a.getReverseDirection(t),r=mi(yt(i,o,n),t,n);return t===a.Direction.UP&&r.startRow<=i.startRow?f.alignToMergedCellsBorders({...e,startColumn:i.startColumn,endColumn:i.endColumn},n,!0):t===a.Direction.DOWN&&r.endRow>=i.endRow?f.alignToMergedCellsBorders({...e,startColumn:i.startColumn,endColumn:i.endColumn},n,!0):t===a.Direction.LEFT&&r.startColumn<=i.startColumn?f.alignToMergedCellsBorders({...e,startRow:i.startRow,endRow:i.endRow},n,!0):t===a.Direction.RIGHT&&r.endColumn>=i.endColumn?f.alignToMergedCellsBorders({...e,startRow:i.startRow,endRow:i.endRow},n,!0):a.Rectangle.union(a.Rectangle.clone(e),r)}function ws(i,e,t){const n=a.getReverseDirection(e),o=yt(i,n,t),r=yt(i,e,t),s=xo(o,e,t);return f.alignToMergedCellsBorders(a.Rectangle.union(r,s),t,!1)}function Ts(i,e,t){const{left:n,right:o,up:r,down:s}=e,l=t.getMaxRows(),c=t.getMaxColumns();let d=!0;const u={...i};for(;d;){if(d=!1,r&&u.startRow!==0){const h=u.startRow-1;t.getMatrixWithMergedCells(h,u.startColumn,h,u.endColumn).forValue((S,g,_)=>{_.v&&(u.startRow=Math.min(S,u.startRow),u.startColumn=Math.min(g,u.startColumn),u.endColumn=Math.max(g,u.endColumn),d=!0)})}if(s&&u.endRow!==l-1){const h=u.endRow+1;t.getMatrixWithMergedCells(h,u.startColumn,h,u.endColumn).forValue((S,g,_)=>{_.v&&(u.endRow=Math.max(S+(_.rowSpan!==void 0?_.rowSpan-1:0),u.endRow),u.startColumn=Math.min(g,u.startColumn),u.endColumn=Math.max(g,u.endColumn),d=!0)})}if(n&&u.startColumn!==0){const h=u.startColumn-1;t.getMatrixWithMergedCells(u.startRow,h,u.endRow,h).forValue((S,g,_)=>{_.v&&(u.startColumn=Math.min(g,u.startColumn),u.startRow=Math.min(S,u.startRow),u.endRow=Math.max(S,u.endRow),d=!0)})}if(o&&u.endColumn!==c-1){const h=u.endColumn+1;t.getMatrixWithMergedCells(u.startRow,h,u.endRow,h).forValue((S,g,_)=>{_.v&&(u.endColumn=Math.max(g+(_.colSpan!==void 0?_.colSpan-1:0),u.endColumn),u.startRow=Math.min(S,u.startRow),u.endRow=Math.max(S,u.endRow),d=!0)})}}return u}function Vi(i){return{startRow:0,startColumn:0,endRow:i.getRowCount()-1,endColumn:i.getColumnCount()-1,rangeType:a.RANGE_TYPE.ALL}}function yt(i,e,t){let n;switch(e){case a.Direction.UP:n={startRow:i.startRow,startColumn:i.startColumn,endRow:i.startRow,endColumn:i.endColumn,rangeType:a.RANGE_TYPE.NORMAL};break;case a.Direction.DOWN:n={startRow:i.endRow,startColumn:i.startColumn,endRow:i.endRow,endColumn:i.endColumn,rangeType:a.RANGE_TYPE.NORMAL};break;case a.Direction.LEFT:n={startRow:i.startRow,startColumn:i.startColumn,endRow:i.endRow,endColumn:i.startColumn,rangeType:a.RANGE_TYPE.NORMAL};break;case a.Direction.RIGHT:n={startRow:i.startRow,startColumn:i.endColumn,endRow:i.endRow,endColumn:i.endColumn,rangeType:a.RANGE_TYPE.NORMAL};break;default:throw new Error("Invalid direction")}return f.alignToMergedCellsBorders(n,t,!1)}function St(i,e,t,n,o){let r=!1;const s=i.getMatrixWithMergedCells(e,t,n,o).forValue((l,c,d)=>{if(d.v)return r=!0,!1});return{hasValue:r,matrix:s}}function Jn(i,e,t){const n=a.Rectangle.clone(i);if(e==null)return n;switch(t){case a.Direction.UP:case a.Direction.DOWN:n.startColumn=n.endColumn=e.actualColumn;break;case a.Direction.LEFT:case a.Direction.RIGHT:n.startRow=n.endRow=e.actualRow;break}return n}function Es(i,e,t){const{primary:n,range:o}=i,r=a.Rectangle.clone(o);switch(e){case a.Direction.UP:case a.Direction.DOWN:r.startRow=n.startRow,r.endRow=n.endRow;break;case a.Direction.LEFT:case a.Direction.RIGHT:r.startColumn=n.startColumn,r.endColumn=n.endColumn;break}const s=yt(r,e,t);switch(e){case a.Direction.DOWN:return o.startRow<s.startRow;case a.Direction.UP:return o.endRow>s.endRow;case a.Direction.LEFT:return s.endColumn<o.endColumn;case a.Direction.RIGHT:return s.startColumn>o.startColumn}}var be=(i=>(i[i.moveStopeOne=0]="moveStopeOne",i[i.moveGap=1]="moveGap",i[i.moveStepPage=2]="moveStepPage",i[i.moveStepEnd=3]="moveStepEnd",i))(be||{});const me={id:"sheet.command.move-selection",type:a.CommandType.COMMAND,handler:async(i,e)=>{if(!e)return!1;const t=i.get(a.IUniverInstanceService).getCurrentUniverSheetInstance(),n=t.getActiveSheet(),o=i.get(f.SelectionManagerService).getLast();if(!o)return!1;const{direction:r,jumpOver:s}=e,{range:l,primary:c}=o,d=Jn(l,c,r),u=s===1?mi(d,r,n):Le(d,r,n),h=f.getCellAtRowCol(u.startRow,u.startColumn,n);return a.Rectangle.equals(h,d)?!1:(i.get(R.ShortcutExperienceService).remove({unitId:t.getUnitId(),sheetId:n.getSheetId(),keycode:R.KeyCode.TAB}),i.get(a.ICommandService).executeCommand(f.SetSelectionsOperation.id,{unitId:t.getUnitId(),sheetId:n.getSheetId(),pluginName:f.NORMAL_SELECTION_PLUGIN_NAME,selections:[{range:a.Rectangle.clone(h),primary:{startRow:h.startRow,startColumn:h.startColumn,endRow:h.endRow,endColumn:h.endColumn,actualRow:u.startRow,actualColumn:u.startColumn,isMerged:h.isMerged,isMergedMainCell:h.startRow===u.startRow&&h.startColumn===u.startColumn}}]}))}},Ke={id:"sheet.command.move-selection-enter-tab",type:a.CommandType.COMMAND,handler:async(i,e)=>{if(!e)return!1;const t=i.get(a.IUniverInstanceService).getCurrentUniverSheetInstance(),n=t.getActiveSheet(),o=i.get(f.SelectionManagerService).getLast(),r=t.getUnitId(),s=n.getSheetId();if(!o)return!1;const{direction:l,keycode:c}=e,{range:d,primary:u}=o;let h=Jn(d,u,l);const m=i.get(R.ShortcutExperienceService),S=m.getCurrentBySearch({unitId:r,sheetId:s,keycode:R.KeyCode.TAB});let g;const{startRow:_,endRow:I,startColumn:C,endColumn:b}=d;if(a.Rectangle.equals(d,u)){if(c===R.KeyCode.TAB)S==null&&m.addOrUpdate({unitId:r,sheetId:s,keycode:R.KeyCode.TAB,selection:o});else{const E=S==null?void 0:S.selection;if(E!=null){const{range:y,primary:O}=E;h=Jn(y,O,l)}m.remove({unitId:r,sheetId:s,keycode:R.KeyCode.TAB})}const M=Le(h,l,n),T=f.getCellAtRowCol(M.startRow,M.startColumn,n);if(a.Rectangle.equals(T,h))return!1;g={range:a.Rectangle.clone(T),primary:{startRow:T.startRow,startColumn:T.startColumn,endRow:T.endRow,endColumn:T.endColumn,actualRow:M.startRow,actualColumn:M.startColumn,isMerged:T.isMerged,isMergedMainCell:T.startRow===M.startRow&&T.startColumn===M.startColumn}}}else{m.remove({unitId:r,sheetId:s,keycode:R.KeyCode.TAB});const M=a.Tools.deepClone(u),T=Le({startRow:M.startRow,startColumn:M.startColumn,endRow:M.endRow,endColumn:M.endColumn},l,n,{startRow:_,endRow:I,startColumn:C,endColumn:b}),E=f.getCellAtRowCol(T.startRow,T.startColumn,n);g={range:a.Rectangle.clone(d),primary:{startRow:E.startRow,startColumn:E.startColumn,endRow:E.endRow,endColumn:E.endColumn,actualRow:T.startRow,actualColumn:T.startColumn,isMerged:E.isMerged,isMergedMainCell:E.startRow===T.startRow&&E.startColumn===T.startColumn}}}return i.get(a.ICommandService).executeCommand(f.SetSelectionsOperation.id,{unitId:r,sheetId:s,pluginName:f.NORMAL_SELECTION_PLUGIN_NAME,selections:[g]})}},Me={id:"sheet.command.expand-selection",type:a.CommandType.COMMAND,handler:async(i,e)=>{if(!e)return!1;const t=i.get(a.IUniverInstanceService).getCurrentUniverSheetInstance(),n=t.getActiveSheet(),o=i.get(f.SelectionManagerService).getLast();if(!o)return!1;const{range:r,primary:s}=o,{jumpOver:l,direction:c}=e,u=Es(o,c,n)?l===1?Ms(r,{...a.Rectangle.clone(s),rangeType:a.RANGE_TYPE.NORMAL},c,n):ws(r,c,n):l===1?Rs(r,c,n):bs(r,c,n);return a.Rectangle.equals(u,r)?!1:i.get(a.ICommandService).executeCommand(f.SetSelectionsOperation.id,{unitId:t.getUnitId(),sheetId:n.getSheetId(),pluginName:f.NORMAL_SELECTION_PLUGIN_NAME,selections:[{range:u,primary:s}]})}};let ve=[],Un="";const Ao={id:"sheet.command.select-all",type:a.CommandType.COMMAND,onDispose(){ve=[],Un=""},handler:async(i,e={expandToGapFirst:!0,loop:!1})=>{const t=i.get(f.SelectionManagerService).getLast(),n=i.get(a.IUniverInstanceService).getCurrentUniverSheetInstance(),o=n.getActiveSheet();if(!t||!o)return!1;const r=`${n.getUnitId()}|${o.getSheetId()}`;r!==Un&&(ve=[],Un=r);const s=o.getMaxRows(),l=o.getMaxColumns(),{expandToGapFirst:c,loop:d}=e,{range:u,primary:h}=t,m=u.endColumn===l-1&&u.endRow===s-1&&u.startRow===0&&u.startColumn===0;ve.some(g=>a.Rectangle.equals(g,u))||(ve=[],ve.push(u));let S;if(m)if(d){if(ve.findIndex(_=>a.Rectangle.equals(_,u))!==ve.length-1)return!1;S=ve[0]}else return!1;else c?(S=Ts(u,{left:!0,right:!0,up:!0,down:!0},o),a.Rectangle.equals(S,u)&&(S=Vi(o))):S=Vi(o);return ve.some(g=>a.Rectangle.equals(g,S))||ve.push(S),i.get(a.ICommandService).executeCommand(f.SetSelectionsOperation.id,{unitId:n.getUnitId(),sheetId:o.getSheetId(),pluginName:f.NORMAL_SELECTION_PLUGIN_NAME,selections:[{range:S,primary:h}]})}},ys=a.createInterceptorKey("BEFORE_CELL_EDIT"),Os=a.createInterceptorKey("AFTER_CELL_EDIT");class Ho extends a.Disposable{constructor(){super();v(this,"_state",null);v(this,"_isForceKeepVisible",!1);v(this,"_editorIsDirty",!1);v(this,"_visible",{visible:!1,eventType:w.DeviceInputEventType.Dblclick});v(this,"_state$",new k.BehaviorSubject(null));v(this,"state$",this._state$.asObservable());v(this,"_visible$",new k.BehaviorSubject(this._visible));v(this,"visible$",this._visible$.asObservable());v(this,"_afterVisible$",new k.BehaviorSubject(this._visible));v(this,"afterVisible$",this._afterVisible$.asObservable());v(this,"interceptor",new a.InterceptorManager({BEFORE_CELL_EDIT:ys,AFTER_CELL_EDIT:Os}));this.disposeWithMe(a.toDisposable(()=>{this._state$.complete(),this._state=null})),this.disposeWithMe(a.toDisposable(this.interceptor.intercept(this.interceptor.getInterceptPoints().AFTER_CELL_EDIT,{priority:-1,handler:t=>t}))),this.disposeWithMe(a.toDisposable(this.interceptor.intercept(this.interceptor.getInterceptPoints().BEFORE_CELL_EDIT,{priority:-1,handler:t=>t})))}setState(t){this._state=t,this._state$.next(t)}getState(){return this._state}getCurrentEditorId(){var t;return(t=this._state)==null?void 0:t.editorUnitId}changeVisible(t){this._visible=t,t.visible&&(this._editorIsDirty=!1),this._visible$.next(this._visible),this._afterVisible$.next(this._visible)}isVisible(){return this._visible}enableForceKeepVisible(){this._isForceKeepVisible=!0}disableForceKeepVisible(){this._isForceKeepVisible=!1}isForceKeepVisible(){return this._isForceKeepVisible}changeEditorDirty(t){this._editorIsDirty=t}getEditorDirty(){return this._editorIsDirty}}const pe=P.createIdentifier("univer.sheet-editor-bridge.service"),Re={id:"sheet.operation.set-cell-edit-visible",type:a.CommandType.OPERATION,handler:(i,e)=>{const t=i.get(pe);return e==null?!1:(t.changeVisible(e),!0)}},Ot={id:"sheet.operation.set-cell-edit-visible-arrow",type:a.CommandType.OPERATION,handler:()=>!0};class ke{constructor(){v(this,"_scrollInfo",new Map);v(this,"_currentScroll",null);v(this,"_scrollInfo$",new k.BehaviorSubject(null));v(this,"scrollInfo$",this._scrollInfo$.asObservable())}dispose(){this._scrollInfo$.complete()}setCurrentScroll(e){this._currentScroll=e,this._refresh(e)}getScrollByParam(e){return this._getCurrentScroll(e)}getCurrentScroll(){return this._getCurrentScroll(this._currentScroll)}addOrReplace(e){this._currentScroll!=null&&this._addByParam({...this._currentScroll,...e})}addOrReplaceNoRefresh(e){this._currentScroll!=null&&this._addByParam({...this._currentScroll,...e},!1)}addOrReplaceByParam(e){this._addByParam(e)}clear(){this._currentScroll!=null&&this._clearByParam(this._currentScroll)}_addByParam(e,t=!0){const{unitId:n,sheetId:o,sheetViewStartColumn:r,sheetViewStartRow:s,offsetX:l,offsetY:c}=e;this._scrollInfo.has(n)||this._scrollInfo.set(n,new Map),this._scrollInfo.get(n).set(o,{sheetViewStartRow:s,sheetViewStartColumn:r,offsetX:l,offsetY:c}),t===!0&&this._refresh({unitId:n,sheetId:o})}_clearByParam(e){this._addByParam({...e,sheetViewStartRow:0,sheetViewStartColumn:0,offsetX:0,offsetY:0}),this._refresh(e)}_getCurrentScroll(e){var o;if(e==null)return;const{unitId:t,sheetId:n}=e;return(o=this._scrollInfo.get(t))==null?void 0:o.get(n)}_refresh(e){this._scrollInfo$.next(this._getCurrentScroll(e))}}const ct={id:"sheet.operation.set-scroll",type:a.CommandType.OPERATION,handler:(i,e)=>{if(!e)return!1;const t=i.get(ke),r=i.get(a.IUniverInstanceService).getUniverSheetInstance(e.unitId).getSheetBySheetId(e.sheetId),{xSplit:s,ySplit:l}=r.getConfig().freeze;return t.addOrReplaceByParam({...e,sheetViewStartRow:e.sheetViewStartRow-l,sheetViewStartColumn:e.sheetViewStartColumn-s}),!0}},On={id:"sheet.operation.set-editor-resize",type:a.CommandType.OPERATION,handler:(i,e)=>!0},xe={id:"sheet.operation.set-zoom-ratio",type:a.CommandType.OPERATION,handler:(i,e)=>{const t=i.get(a.IUniverInstanceService).getUniverSheetInstance(e.unitId);if(!t)return!1;const n=t.getSheetBySheetId(e.subUnitId);return n?(n.getConfig().zoomRatio=e.zoomRatio,!0):!1}};var oe=(i=>(i.MAIN="__SpreadsheetRender__",i.ROW="__SpreadsheetRowHeader__",i.COLUMN="__SpreadsheetColumnHeader__",i.LEFT_TOP="__SpreadsheetLeftTopPlaceholder__",i))(oe||{}),Y=(i=>(i.VIEW_MAIN="viewMain",i.VIEW_MAIN_LEFT_TOP="viewMainLeftTop",i.VIEW_MAIN_TOP="viewMainTop",i.VIEW_MAIN_LEFT="viewMainLeft",i.VIEW_ROW_TOP="viewRowTop",i.VIEW_ROW_BOTTOM="viewRowBottom",i.VIEW_COLUMN_LEFT="viewColumnLeft",i.VIEW_COLUMN_RIGHT="viewColumnRight",i.VIEW_LEFT_TOP="viewLeftTop",i))(Y||{});const Fi=0,Ue=2,Qn=[10,400],ji=1001;var Do={exports:{}},xn={};/**
1
+ "use strict";var Ms=Object.defineProperty;var ws=(i,e,t)=>e in i?Ms(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var v=(i,e,t)=>(ws(i,typeof e!="symbol"?e+"":e,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("@univerjs/core"),p=require("@univerjs/sheets"),R=require("@univerjs/ui"),j=require("@wendellhu/redi"),J=require("rxjs"),y=require("@univerjs/engine-render"),X=require("react"),Ye=require("@univerjs/design"),me=require("@wendellhu/redi/react-bindings"),pe=require("@univerjs/docs"),uo=require("rxjs/operators"),Re=require("@univerjs/engine-formula"),bn=require("clsx"),ho={InsertRow:!0,InsertColumn:!0,AddRowTop:!1,AddRowBottom:!1,AddColumnLeft:!1,AddColumnRight:!1,DeleteRow:!0,DeleteColumn:!0,HideRow:!1,ShowRow:!1,RowHeight:!1,HideColumn:!1,ShowColumn:!1,ColumnWidth:!1,DeleteCell:!0,ClearContent:!0,Matrix:!1},mo={undo:!0,redo:!0,paintFormat:!0,currencyFormat:!0,percentageFormat:!0,numberDecrease:!0,numberIncrease:!0,moreFormats:!0,font:!0,fontSize:!0,bold:!0,italic:!0,strikethrough:!0,underline:!0,textColor:!0,fillColor:!0,border:!0,horizontalAlignMode:!0,verticalAlignMode:!0,textWrapMode:!0,textRotateMode:!0,mergeCell:!0},go={outerLeft:!1,outerRight:!1,header:!0,footer:!0,innerLeft:!1,innerRight:!1,frozenHeaderLT:!1,frozenHeaderRT:!1,frozenHeaderLM:!1,frozenContent:!1,infoBar:!0,toolbar:!0,formulaBar:!0,rightMenu:!0,countBar:!0,sheetBar:!0},Ts={layout:{sheetContainerConfig:go,rightMenuConfig:ho,toolbarConfig:mo}},_o="SheetUI";function wi(i,e){if(i==null)return;const t=e.getRenderById(i);if(t==null)return;const{mainComponent:n,scene:r,engine:o}=t;return{document:n,scene:r,engine:o}}const Zi={零:0,一:1,二:2,三:3,四:4,五:5,六:6,七:7,八:8,九:9},Si=["零","一","二","三","四","五","六","七","八","九"],Tr=["","万","亿","万亿","亿亿"],ys=["","十","百","千"],po={十:{value:10,secUnit:!1},百:{value:100,secUnit:!1},千:{value:1e3,secUnit:!1},万:{value:1e4,secUnit:!0},亿:{value:1e8,secUnit:!0}};function It(i){if(!i)return 0;let e=0,t=0,n=0,r=!1;const o=i.split("");for(let s=0;s<o.length;s++){const a=Zi[o[s]];if(typeof a<"u")n=a,s===o.length-1&&(t+=n);else{const c=po[o[s]],d=c.value;r=c.secUnit,r?(t=(t+n)*d,e+=t,t=0):t+=n*d,n=0}}return e+t}function Es(i){let e="",t="",n=0,r=!0;for(;i>0;){const o=i%10;o===0?r||(r=!0,t=Si[o]+t):(r=!1,e=Si[o],e+=ys[n],t=e+t),n++,i=Math.floor(i/10)}return t}function Os(i){let e=0,t="",n="",r=!1;if(i===0)return Si[0];for(;i>0;){const o=i%1e4;r&&(n=Si[0]+n),t=Es(o),t+=o!==0?Tr[e]:Tr[0],n=t+n,r=o<1e3&&o>0,i=Math.floor(i/1e4),e++}return n}function xs(i){if(!i)return!1;let e=!0;if(i)if(i.length===1)i==="日"||i in Zi?e=!0:e=!1;else{const t=i.split("");for(let n=0;n<t.length;n++)if(!(t[n]in Zi||t[n]in po)){e=!1;break}}return e}function Un(i){if(!i)return{isExtendNumber:!1};const e=/0|([1-9]+[0-9]*)/g,t=e.test(i);if(t){const n=i.match(e);if(n&&n.length>0){const r=n[n.length-1],o=i.lastIndexOf(r),s=i.substr(0,o),a=i.substr(o+r.length);return{isExtendNumber:!0,matchTxt:Number(r),beforeTxt:s,afterTxt:a}}return{isExtendNumber:!1}}return{isExtendNumber:t}}function As(i){let e;return i.length===2&&(i==="周一"||i==="周二"||i==="周三"||i==="周四"||i==="周五"||i==="周六"||i==="周日")?e=!0:e=!1,e}function Ns(i){let e;return i.length===3&&(i==="星期一"||i==="星期二"||i==="星期三"||i==="星期四"||i==="星期五"||i==="星期六"||i==="星期日")?e=!0:e=!1,e}function Ds(i,e){let t=0;for(let n=0;n<i.length&&i[n]<e;n++)t++;return t}function En(i){let e=!0;const t=i[1]-i[0];for(let n=1;n<i.length;n++)if(i[n]-i[n-1]!==t){e=!1;break}return e}function Ps(i,e,t){const n=[],r=Math.floor(e/i),o=e%i;let s=0;if(r>0){for(let a=0;a<r;a++)for(let c=0;c<t.length;c++)n[t[c]+a*i]=s,s++;for(let a=0;a<t.length&&t[a]<o;a++)n[t[a]+i*r]=s,s++}else for(let a=0;a<t.length&&t[a]<o;a++)n[t[a]]=s,s++;return n}function Bt(i,e){const t=[];for(let n=1;n<=e;n++){const r=(n-1)%i.length,o=l.Tools.deepClone(i[r]);t.push({v:null,s:null,p:null,f:null,si:null,t:null,...o})}return t}function Hs(i,e){var n;const t=[];for(let r=1;r<=e;r++){const o=(r-1)%i.length,s={s:(n=i[o])==null?void 0:n.s};t.push(s)}return t}function Ls(i){let e=!0;const t=i[1]/i[0];for(let n=1;n<i.length;n++)if(i[n]/i[n-1]!==t){e=!1;break}return e}function Us(i){const e=[];for(let t=1;t<=i;t++)e.push(t);return e}function yr(i,e,t){var o,s,a,c;const n=[],r=[];for(let d=0;d<i.length;d++)r.push(Number((o=i[d])==null?void 0:o.v));if(i.length>2&&Ls(r))for(let d=1;d<=e;d++){const u=(d-1)%i.length,h=l.Tools.deepClone(i[u]),m=Number((s=i[i.length-1])==null?void 0:s.v)*(Number((a=i[1])==null?void 0:a.v)/Number((c=i[0])==null?void 0:c.v))**d;h&&(h.v=m,n.push(h))}else{const d=Us(i.length);for(let u=1;u<=e;u++){const h=(u-1)%i.length,m=l.Tools.deepClone(i[h]),g=ks(i.length+u,r,d);m&&(m.v=g,n.push(m))}}return n}function ks(i,e,t){function n(u){let h=0;for(let m=0;m<u.length;m++)h+=u[m];return h/u.length}const r=n(t),o=n(e);let s=0,a=0;for(let u=0;u<t.length;u++)s+=(t[u]-r)*(e[u]-o),a+=(t[u]-r)*(t[u]-r);let c;a===0?c=1:c=s/a;const d=o-c*r;return Math.round((d+c*i)*1e5)/1e5}function Er(i,e,t){var o;const n=[],r=/0|([1-9]+[0-9]*)/g;for(let s=1;s<=e;s++){const a=(s-1)%i.length,c=l.Tools.deepClone(i[a]),d=`${(o=i[i.length-1])==null?void 0:o.v}`,u=d==null?void 0:d.match(r),h=u==null?void 0:u[u.length-1],m=Math.abs(Number(h)+t*s);if(!d||!h)continue;const g=d.lastIndexOf(h),_=d.substr(0,g)+m.toString()+d.substr(g+h.length);c&&(c.v=_,n.push(c))}return n}function en(i,e,t,n=0){var a,c;const r=[["日","一","二","三","四","五","六"],["周日","周一","周二","周三","周四","周五","周六"],["星期日","星期一","星期二","星期三","星期四","星期五","星期六"]];if(n>=r.length)return[];const o=r[n],s=[];for(let d=1;d<=e;d++){const u=(d-1)%i.length,h=l.Tools.deepClone(i[u]);let m=0;if(((a=i[i.length-1])==null?void 0:a.v)===o[0])m=7+t*d;else{const _=`${(c=i[i.length-1])==null?void 0:c.v}`;if(_){const f=_.substr(_.length-1,1);m=It(f)+t*d}}m<0&&(m=Math.ceil(Math.abs(m)/7)*7+m);const g=m%7;h&&(h.v=o[g],s.push(h))}return s}function Or(i,e,t){var r;const n=[];for(let o=1;o<=e;o++){const s=(o-1)%i.length,a=l.Tools.deepClone(i[s]),c=`${(r=i[i.length-1])==null?void 0:r.v}`,d=It(c)+t*o;let u;d<=0?u="零":u=Os(d),a&&(a.v=u,n.push(a))}return n}const In={enWeek1:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],enWeek2:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],enMonth1:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],enMonth2:["January","February","March","April","May","June","July","August","September","October","November","December"],chnMonth1:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"],chnMonth2:["正月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","腊月"],chHour1:["子","丑","寅","卯","辰","巳","午","未","申","酉","戌","亥"],chHour2:["子时","丑时","寅时","卯时","辰时","巳时","午时","未时","申时","酉时","戌时","亥时"],chYear1:["甲","乙","丙","丁","戊","己","庚","辛","壬","癸"],chSeason1:["春","夏","秋","冬"],chSeason2:["春季","夏季","秋季","冬季"]};function Vs(i){let e=!1;return Object.keys(In).forEach(t=>{In[t].includes(i)&&(e=!0)}),e}function Pi(i){let e="";const t=[];return Object.keys(In).forEach(n=>{In[n].includes(i)&&(e=n,t.push(...In[n]))}),{name:e,series:t}}function xr(i,e,t,n){var s;const r=n.length,o=[];for(let a=1;a<=e;a++){const c=(a-1)%i.length,d=l.Tools.deepClone(i[c]),u=`${(s=i[i.length-1])==null?void 0:s.v}`,m=(n.indexOf(u)+t*a)%r;d&&(d.v=n[m],o.push(d))}return o}function Fs(i,e){const t=[];let n;if(e.startRow<i.startRow)n=l.Direction.UP;else if(e.endRow>i.endRow)n=l.Direction.DOWN;else if(e.startColumn<i.startColumn)n=l.Direction.LEFT;else if(e.endColumn>i.endColumn)n=l.Direction.RIGHT;else return[];if(n===l.Direction.DOWN||n===l.Direction.UP){const r=i.endRow-i.startRow+1,o=e.endRow-e.startRow+1,s=o/r,a=o%r,c={startRow:0,startColumn:0,endRow:i.endRow-i.startRow,endColumn:i.endColumn-i.startColumn};if(n===l.Direction.DOWN){for(let d=0;d<s;d++)t.push({repeatStartCell:{row:i.startRow+(d+1)*r,col:i.startColumn},relativeRange:c});a>0&&t.push({repeatStartCell:{row:i.startRow+(s+1)*r,col:i.startColumn},relativeRange:{startRow:0,startColumn:0,endRow:a-1,endColumn:i.endColumn-i.startColumn}})}else{for(let d=0;d<s;d++)t.push({repeatStartCell:{row:i.startRow-(d+1)*r,col:i.startColumn},relativeRange:c});a>0&&t.push({repeatStartCell:{row:i.startRow-(s+1)*r,col:i.startColumn},relativeRange:{startRow:r-a,endRow:r-1,startColumn:0,endColumn:i.endColumn-i.startColumn}})}}if(n===l.Direction.RIGHT||n===l.Direction.LEFT){const r=i.endColumn-i.startColumn+1,o=e.endColumn-e.startColumn+1,s=o/r,a=o%r,c={startRow:0,startColumn:0,endRow:i.endRow-i.startRow,endColumn:i.endColumn-i.startColumn};if(n===l.Direction.RIGHT){for(let d=0;d<s;d++)t.push({repeatStartCell:{row:i.startRow,col:i.startColumn+(d+1)*r},relativeRange:c});a>0&&t.push({repeatStartCell:{row:i.startRow,col:i.startColumn+(s+1)*r},relativeRange:{startRow:0,startColumn:0,endRow:i.endRow-i.startRow,endColumn:a-1}})}else{for(let d=0;d<s;d++)t.push({repeatStartCell:{row:i.startRow,col:i.startColumn-(d+1)*r},relativeRange:c});a>0&&t.push({repeatStartCell:{row:i.startRow,col:i.startColumn-(s+1)*r},relativeRange:{startRow:0,startColumn:r-a,endRow:i.endRow-i.startRow,endColumn:r-1}})}}return t}function fo(i){const e=new l.ObjectMatrix;return i.forEach(t=>{const{startRow:n,startColumn:r,endRow:o,endColumn:s}=t;for(let a=n;a<=o;a++)for(let c=r;c<=s;c++)e.setValue(a,c,{v:null,p:null,f:null,si:null})}),e.getData()}const So={type:l.CommandType.COMMAND,id:"sheet.command.auto-fill",handler:async(i,e)=>!0},zn={id:"sheet.command.auto-clear-content",type:l.CommandType.COMMAND,handler:async(i,e)=>{const t=i.get(l.IUniverInstanceService),n=i.get(l.ICommandService),r=i.get(l.IUndoRedoService),o=t.getCurrentUniverSheetInstance(),s=o.getUnitId(),c=o.getActiveSheet().getSheetId(),{clearRange:d,selectionRange:u}=e,h={subUnitId:c,unitId:s,cellValue:fo([d])},m=p.SetRangeValuesUndoMutationFactory(i,h);return n.executeCommand(p.SetSelectionsOperation.id,{selections:[{primary:{...u},range:{...u}}],unitId:s,subUnitId:c}),n.syncExecuteCommand(p.SetRangeValuesMutation.id,h)?(r.pushUndoRedo({unitID:s,undoMutations:[{id:p.SetRangeValuesMutation.id,params:m}],redoMutations:[{id:p.SetRangeValuesMutation.id,params:h}],undo(){return n.syncExecuteCommand(p.SetRangeValuesMutation.id,m)},redo(){return n.syncExecuteCommand(p.SetRangeValuesMutation.id,h)}}),!0):!1}};function ye(i){return i.getContextValue(l.FOCUSING_SHEET)&&!i.getContextValue(l.FOCUSING_EDITOR)}function vo(i){return i.getContextValue(l.FOCUSING_SHEET)&&i.getContextValue(l.FOCUSING_EDITOR)}function Bs(i){return i.getContextValue(l.FOCUSING_EDITOR_BUT_HIDDEN)&&!i.getContextValue(l.FOCUSING_EDITOR)}function js(i){return i.getContextValue(l.FOCUSING_EDITOR)&&i.getContextValue(l.FOCUSING_EDITOR_BUT_HIDDEN)}function Co(i){return i.getContextValue(l.FOCUSING_FORMULA_EDITOR)}function Ws(i){return i.getContextValue(l.FOCUSING_SHEET)&&i.getContextValue(l.FOCUSING_EDITOR)&&i.getContextValue(l.FOCUSING_EDITOR_INPUT_FORMULA)}function vi(i){return i.getContextValue(l.FOCUSING_SHEET)&&i.getContextValue(l.FOCUSING_EDITOR)&&!i.getContextValue(l.FOCUSING_EDITOR_INPUT_FORMULA)}var Xe=(i=>(i.MAIN="__SpreadsheetRender__",i.ROW="__SpreadsheetRowHeader__",i.COLUMN="__SpreadsheetColumnHeader__",i.LEFT_TOP="__SpreadsheetLeftTopPlaceholder__",i))(Xe||{}),Q=(i=>(i.VIEW_MAIN="viewMain",i.VIEW_MAIN_LEFT_TOP="viewMainLeftTop",i.VIEW_MAIN_TOP="viewMainTop",i.VIEW_MAIN_LEFT="viewMainLeft",i.VIEW_ROW_TOP="viewRowTop",i.VIEW_ROW_BOTTOM="viewRowBottom",i.VIEW_COLUMN_LEFT="viewColumnLeft",i.VIEW_COLUMN_RIGHT="viewColumnRight",i.VIEW_LEFT_TOP="viewLeftTop",i))(Q||{});const Ar=0,At=2,zs=3,Gi=[10,400],Nr=1001;var $s=Object.defineProperty,Ys=Object.getOwnPropertyDescriptor,Xs=(i,e,t,n)=>{for(var r=n>1?void 0:n?Ys(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&$s(e,t,r),r},Dr=(i,e)=>(t,n)=>e(t,n,i);exports.SheetSkeletonManagerService=class{constructor(e,t){v(this,"_currentSkeleton",{unitId:"",sheetId:""});v(this,"_sheetSkeletonParam",[]);v(this,"_currentSkeleton$",new J.BehaviorSubject(null));v(this,"currentSkeleton$",this._currentSkeleton$.asObservable());v(this,"_currentSkeletonBefore$",new J.BehaviorSubject(null));v(this,"currentSkeletonBefore$",this._currentSkeletonBefore$.asObservable());this._currentUniverService=e,this._localeService=t}dispose(){this._currentSkeletonBefore$.complete(),this._currentSkeleton$.complete(),this._sheetSkeletonParam=[]}getCurrent(){return this._getCurrentBySearch(this._currentSkeleton)}setCurrent(e){const t=this._getCurrentBySearch(e);if(t!=null)this._reCalculate(t);else{const{unitId:r,sheetId:o}=e,s=this._currentUniverService.getUniverSheetInstance(e.unitId),a=s==null?void 0:s.getSheetBySheetId(e.sheetId);if(a==null||s==null)return;const c=this._buildSkeleton(a,s);this._sheetSkeletonParam.push({unitId:r,sheetId:o,skeleton:c,dirty:!1})}this._currentSkeleton=e;const n=this.getCurrent();return this._currentSkeletonBefore$.next(n),this._currentSkeleton$.next(n),this.getCurrent()}reCalculate(){const e=this.getCurrent();e!=null&&this._reCalculate(e)}_reCalculate(e){e.dirty&&(e.skeleton.makeDirty(!0),e.dirty=!1),e.skeleton.calculate()}makeDirtyCurrent(e=!0){this.makeDirty(this._currentSkeleton,e)}makeDirty(e,t=!0){const n=this._getCurrentBySearch(e);n!=null&&(n.dirty=t)}_getCurrentBySearch(e){const t=this._sheetSkeletonParam.find(n=>n.unitId===e.unitId&&n.sheetId===e.sheetId);return t!=null&&(t.commandId=e.commandId),t}_buildSkeleton(e,t){const n=e.getConfig();return y.SpreadsheetSkeleton.create(e,n,e.getCellMatrix(),t.getStyles(),this._localeService)}};exports.SheetSkeletonManagerService=Xs([Dr(0,l.IUniverInstanceService),Dr(1,j.Inject(l.LocaleService))],exports.SheetSkeletonManagerService);class Zs{constructor(){v(this,"_startColumn",-1);v(this,"_startRow",-1);v(this,"_endColumn",-1);v(this,"_endRow",-1);v(this,"_startX",0);v(this,"_startY",0);v(this,"_endX",0);v(this,"_endY",0);v(this,"_currentCell");v(this,"_rangeType",l.RANGE_TYPE.NORMAL)}get startColumn(){return this._startColumn}get startRow(){return this._startRow}get endColumn(){return this._endColumn}get endRow(){return this._endRow}get startX(){return this._startX}get startY(){return this._startY}get endX(){return this._endX}get endY(){return this._endY}get currentCell(){return this._currentCell}get rangeType(){return this._rangeType}isEqual(e){const{startColumn:t,startRow:n,endColumn:r,endRow:o}=this,{startColumn:s,startRow:a,endColumn:c,endRow:d}=e;return t===s&&n===a&&r===c&&o===d}isInclude(e){const{startColumn:t,startRow:n,endColumn:r,endRow:o}=this,{startColumn:s,startRow:a,endColumn:c,endRow:d}=e;return!(c<t||s>r||a>o||d<n)}highlightToSelection(){return l.makeCellToSelection(this._currentCell)}getRange(){return{startColumn:this._startColumn,startRow:this._startRow,endColumn:this._endColumn,endRow:this._endRow,startX:this._startX,startY:this._startY,endX:this._endX,endY:this._endY,rangeType:this.rangeType}}getCell(){return this._currentCell}getRangeType(){return this._rangeType}getValue(){return{rangeWithCoord:{startColumn:this._startColumn,startRow:this._startRow,endColumn:this._endColumn,endRow:this._endRow,startX:this._startX,startY:this._startY,endX:this._endX,endY:this._endY,rangeType:this._rangeType},primaryWithCoord:this._currentCell}}setValue(e,t){const{startColumn:n,startRow:r,endColumn:o,endRow:s,startX:a,startY:c,endX:d,endY:u,rangeType:h}=e;this._startColumn=n,this._startRow=r,this._endColumn=o,this._endRow=s,this._startX=a,this._startY=c,this._endX=d,this._endY=u,h!=null&&(this._rangeType=h),this.setCurrentCell(t)}setCurrentCell(e){e&&(this._currentCell=e)}clearCurrentCell(){this._currentCell=null}}const Pr=.3;class Ci{constructor(e,t,n=!0,r){v(this,"_leftControl");v(this,"_rightControl");v(this,"_topControl");v(this,"_bottomControl");v(this,"_backgroundControlTop");v(this,"_backgroundControlBottom");v(this,"_backgroundControlMiddleLeft");v(this,"_backgroundControlMiddleRight");v(this,"_fillControl");v(this,"_selectionShape");v(this,"_rowHeaderBackground");v(this,"_rowHeaderBorder");v(this,"_rowHeaderGroup");v(this,"_rowHeaderHighlight");v(this,"_columnHeaderBackground");v(this,"_columnHeaderBorder");v(this,"_columnHeaderGroup");v(this,"_columnHeaderHighlight");v(this,"_topLeftWidget");v(this,"_topCenterWidget");v(this,"_topRightWidget");v(this,"_middleLeftWidget");v(this,"_middleRightWidget");v(this,"_bottomLeftWidget");v(this,"_bottomCenterWidget");v(this,"_bottomRightWidget");v(this,"_dashRect");v(this,"_selectionModel");v(this,"_selectionStyle");v(this,"_rowHeaderWidth",0);v(this,"_columnHeaderHeight",0);v(this,"_widgetRects",[]);v(this,"_dispose$",new J.BehaviorSubject(this));v(this,"dispose$",this._dispose$.asObservable());v(this,"selectionMoving$",new J.Subject);v(this,"selectionMoved$",new J.Subject);v(this,"selectionScaling$",new J.Subject);v(this,"selectionScaled$",new J.Subject);v(this,"selectionFilling$",new J.Subject);v(this,"_selectionFilled$",new J.Subject);v(this,"selectionFilled$",this._selectionFilled$.asObservable());v(this,"_defaultStyle");v(this,"_isHelperSelection",!0);this._scene=e,this._zIndex=t,this._isHeaderHighlight=n,this._themeService=r,this._initialize()}get zIndex(){return this._zIndex}get leftControl(){return this._leftControl}get rightControl(){return this._rightControl}get topControl(){return this._topControl}get bottomControl(){return this._bottomControl}get fillControl(){return this._fillControl}get backgroundControlTop(){return this._backgroundControlTop}get backgroundControlBottom(){return this._backgroundControlBottom}get backgroundControlMiddleLeft(){return this._backgroundControlMiddleLeft}get backgroundControlMiddleRight(){return this._backgroundControlMiddleRight}get selectionShape(){return this._selectionShape}get model(){return this._selectionModel}get topLeftWidget(){return this._topLeftWidget}get topCenterWidget(){return this._topCenterWidget}get topRightWidget(){return this._topRightWidget}get middleLeftWidget(){return this._middleLeftWidget}get middleRightWidget(){return this._middleRightWidget}get bottomLeftWidget(){return this._bottomLeftWidget}get bottomCenterWidget(){return this._bottomCenterWidget}get bottomRightWidget(){return this._bottomRightWidget}get selectionStyle(){return this._selectionStyle}get dashRect(){return this._dashRect}get isHelperSelection(){return this._isHelperSelection}setEvent(e){this.leftControl.evented=e,this.rightControl.evented=e,this.topControl.evented=e,this.bottomControl.evented=e}enableHeaderHighlight(){this._isHelperSelection=!0}disableHeaderHighlight(){this._isHeaderHighlight=!1}refreshSelectionFilled(e){this._selectionFilled$.next(e)}updateStyle(e){this._updateControl(e,this._rowHeaderWidth,this._columnHeaderHeight)}update(e,t=0,n=0,r,o){this._selectionModel.setValue(e,o),r==null&&(r=this._selectionStyle),this._updateControl(r,t,n)}clearHighlight(){this._selectionModel.clearCurrentCell(),this._updateControl(this._selectionStyle,this._rowHeaderWidth,this._columnHeaderHeight)}getScene(){return this._scene}dispose(){var e,t,n,r,o,s,a,c,d,u,h,m,g,_,f,C,I,w,E,O,x,N,D,P,L;(e=this._leftControl)==null||e.dispose(),(t=this._rightControl)==null||t.dispose(),(n=this._topControl)==null||n.dispose(),(r=this._bottomControl)==null||r.dispose(),(o=this._backgroundControlTop)==null||o.dispose(),(s=this._backgroundControlMiddleLeft)==null||s.dispose(),(a=this._backgroundControlMiddleRight)==null||a.dispose(),(c=this._backgroundControlBottom)==null||c.dispose(),(d=this._fillControl)==null||d.dispose(),(u=this._selectionShape)==null||u.dispose(),(h=this._rowHeaderBackground)==null||h.dispose(),(m=this._rowHeaderBorder)==null||m.dispose(),(g=this._rowHeaderGroup)==null||g.dispose(),(_=this._rowHeaderBackground)==null||_.dispose(),(f=this._columnHeaderBackground)==null||f.dispose(),(C=this._columnHeaderBorder)==null||C.dispose(),(I=this._columnHeaderGroup)==null||I.dispose(),(w=this._topLeftWidget)==null||w.dispose(),(E=this._topCenterWidget)==null||E.dispose(),(O=this._topRightWidget)==null||O.dispose(),(x=this._middleLeftWidget)==null||x.dispose(),(N=this._middleRightWidget)==null||N.dispose(),(D=this._bottomLeftWidget)==null||D.dispose(),(P=this._bottomCenterWidget)==null||P.dispose(),(L=this._bottomRightWidget)==null||L.dispose(),this._dispose$.next(this),this._dispose$.complete()}getCurrentCellInfo(){const e=this.model.currentCell;if(e){let t;if(e.isMerged){const n=e.mergeInfo;t={startRow:n.startRow,endRow:n.endRow,startColumn:n.startColumn,endColumn:n.endColumn,startX:n.startX,endX:n.endX,startY:n.startY,endY:n.endY}}else{const{actualRow:n,actualColumn:r,startX:o,endX:s,startY:a,endY:c}=e;t={startRow:n,endRow:n,startColumn:r,endColumn:r,startX:o,endX:s,startY:a,endY:c}}return t}}getValue(){return{...this._selectionModel.getValue(),style:this._selectionStyle}}getRange(){return this._selectionModel.getValue().rangeWithCoord}enableHelperSelection(){this._isHelperSelection=!0}disableHelperSelection(){this._isHelperSelection=!1}updateStyleId(e){this._selectionStyle!=null&&(this._selectionStyle.id=e)}_updateControl(e,t,n){const{startX:r,startY:o,endX:s,endY:a}=this._selectionModel,c=this._defaultStyle;e==null&&(e=c);const{stroke:d=c.stroke,widgets:u=c.widgets,hasAutoFill:h=c.hasAutoFill,AutofillStroke:m=c.AutofillStroke,strokeDash:g}=e;let{strokeWidth:_=c.strokeWidth,AutofillSize:f=c.AutofillSize,AutofillStrokeWidth:C=c.AutofillStrokeWidth}=e;const I=this._getScale(),w=(_+p.SELECTION_CONTROL_BORDER_BUFFER_WIDTH)/2/I;_/=I,f/=I,C/=I<1?1:I;const E=p.SELECTION_CONTROL_BORDER_BUFFER_WIDTH/I,O=y.FIX_ONE_PIXEL_BLUR_OFFSET/I;this.leftControl.transformByState({height:a-o,left:-w+O,width:_,strokeWidth:E,top:-E/2+O}),this.leftControl.setProps({fill:d,stroke:p.SELECTION_CONTROL_BORDER_BUFFER_COLOR}),this.rightControl.transformByState({height:a-o,left:s-r-w+O,width:_,strokeWidth:E,top:-E/2+O}),this.rightControl.setProps({fill:d,stroke:p.SELECTION_CONTROL_BORDER_BUFFER_COLOR}),this.topControl.transformByState({width:s-r+_,top:-w+O,left:-w+O,height:_,strokeWidth:E}),this.topControl.setProps({fill:d,stroke:p.SELECTION_CONTROL_BORDER_BUFFER_COLOR}),this.bottomControl.transformByState({width:s-r+_,top:a-o-w+O,height:_,left:-w+O,strokeWidth:E}),this.bottomControl.setProps({fill:d,stroke:p.SELECTION_CONTROL_BORDER_BUFFER_COLOR}),g==null?this.dashRect.hide():(this.dashRect.transformByState({height:a-o-_/2,width:s-r-_/2,strokeWidth:_,left:_/2-1/I,top:_/2-1/I}),this.dashRect.setProps({strokeDashArray:[0,g]}),this.dashRect.show()),h===!0&&!this._hasWidgets(u)?(this.fillControl.setProps({fill:d,stroke:m,strokeScaleEnabled:!1}),this.fillControl.transformByState({width:f-C,height:f-C,left:s-r-f/2+C/2,top:a-o-f/2+C/2,strokeWidth:C}),this.fillControl.show()):this.fillControl.hide(),this._updateBackgroundControl(e),this._updateBackgroundTitle(e,t,n),this._updateWidgets(e),this.selectionShape.show(),this.selectionShape.translate(r,o),this._selectionStyle=e,this._rowHeaderWidth=t||0,this._columnHeaderHeight=n||0,this.selectionShape.makeDirtyNoDebounce(!0)}_initialize(){this._defaultStyle=p.getNormalSelectionStyle(this._themeService),this._selectionModel=new Zs;const e=this._zIndex;this._leftControl=new y.Rect("__SpreadsheetSelectionShapeLeftControl__"+e,{zIndex:e}),this._rightControl=new y.Rect("__SpreadsheetSelectionShapeRightControl__"+e,{zIndex:e}),this._topControl=new y.Rect("__SpreadsheetSelectionTopControl__"+e,{zIndex:e}),this._bottomControl=new y.Rect("__SpreadsheetSelectionBottomControl__"+e,{zIndex:e}),this._backgroundControlTop=new y.Rect("__SpreadsheetSelectionBackgroundControlTop__"+e,{zIndex:e-1,evented:!1}),this._backgroundControlBottom=new y.Rect("__SpreadsheetSelectionBackgroundControlBottom__"+e,{zIndex:e-1,evented:!1}),this._backgroundControlMiddleLeft=new y.Rect("__SpreadsheetSelectionBackgroundControlMiddleLeft__"+e,{zIndex:e-1,evented:!1}),this._backgroundControlMiddleRight=new y.Rect("__SpreadsheetSelectionBackgroundControlMiddleRight__"+e,{zIndex:e-1,evented:!1}),this._fillControl=new y.Rect("__SpreadsheetSelectionFillControl__"+e,{zIndex:e+1}),this._dashRect=new y.Rect("__SpreadsheetDragDashControl__"+e,{zIndex:e+2,evented:!1,stroke:"#fff"});const t=[this._fillControl,this._leftControl,this._rightControl,this._topControl,this._bottomControl,this._backgroundControlTop,this._backgroundControlMiddleLeft,this._backgroundControlMiddleRight,this._backgroundControlBottom,this._dashRect];this._widgetRects=this._initialWidget(),this._selectionShape=new y.Group("__SpreadsheetSelectionShape__"+e,...t,...this._widgetRects),this._selectionShape.hide(),this._selectionShape.evented=!1,this._selectionShape.zIndex=e,this.getScene().addObject(this._selectionShape,zs),this._initialTitle()}_initialTitle(){const e=this._zIndex;this._rowHeaderBackground=new y.Rect("__SpreadSheetSelectionRowHeaderBackground__"+e,{zIndex:e-1,evented:!1}),this._rowHeaderBorder=new y.Rect("__SpreadSheetSelectionRowHeaderBorder__"+e,{zIndex:e-1,evented:!1}),this._rowHeaderGroup=new y.Group("__SpreadSheetSelectionRowHeaderGroup__"+e,this._rowHeaderBackground,this._rowHeaderBorder),this._rowHeaderGroup.hide(),this._rowHeaderGroup.evented=!1,this._rowHeaderGroup.zIndex=e,this._columnHeaderBackground=new y.Rect("__SpreadSheetSelectionColumnHeaderBackground__"+e,{zIndex:e-1,evented:!1}),this._columnHeaderBorder=new y.Rect("__SpreadSheetSelectionColumnHeaderBorder__"+e,{zIndex:e-1,evented:!1}),this._columnHeaderGroup=new y.Group("__SpreadSheetSelectionColumnHeaderGroup__"+e,this._columnHeaderBackground,this._columnHeaderBorder),this._columnHeaderGroup.hide(),this._columnHeaderGroup.evented=!1,this._columnHeaderGroup.zIndex=e,this.getScene().addObjects([this._rowHeaderGroup,this._columnHeaderGroup],y.DEFAULT_SELECTION_LAYER_INDEX)}_initialWidget(){const e=this._zIndex;return this._topLeftWidget=new y.Rect("__SpreadSheetSelectionTopLeftWidget__"+e,{zIndex:e+1}),this._topCenterWidget=new y.Rect("__SpreadSheetSelectionTopCenterWidget__"+e,{zIndex:e+1}),this._topRightWidget=new y.Rect("__SpreadSheetSelectionTopRightWidget__"+e,{zIndex:e+1}),this._middleLeftWidget=new y.Rect("__SpreadSheetSelectionMiddleLeftWidget__"+e,{zIndex:e+1}),this._middleRightWidget=new y.Rect("__SpreadSheetSelectionMiddleRightWidget__"+e,{zIndex:e+1}),this._bottomLeftWidget=new y.Rect("__SpreadSheetSelectionBottomLeftWidget__"+e,{zIndex:e+1}),this._bottomCenterWidget=new y.Rect("__SpreadSheetSelectionBottomCenterWidget__"+e,{zIndex:e+1}),this._bottomRightWidget=new y.Rect("__SpreadSheetSelectionBottomRightWidget__"+e,{zIndex:e+1}),[this._topLeftWidget,this._topCenterWidget,this._topRightWidget,this._middleLeftWidget,this._middleRightWidget,this._bottomLeftWidget,this._bottomCenterWidget,this._bottomRightWidget]}_updateBackgroundTitle(e,t,n){const{startX:r,startY:o,endX:s,endY:a,rangeType:c}=this._selectionModel,d=this._defaultStyle;e==null&&(e=d);const u=this._getScale(),{stroke:h,hasRowHeader:m,rowHeaderFill:g=d.rowHeaderFill,rowHeaderStroke:_=d.rowHeaderStroke,hasColumnHeader:f,columnHeaderFill:C=d.columnHeaderFill,columnHeaderStroke:I=d.columnHeaderStroke}=e;let{rowHeaderStrokeWidth:w=d.rowHeaderStrokeWidth,columnHeaderStrokeWidth:E=d.columnHeaderStrokeWidth}=e;if(w/=u,E/=u,f===!0){let O=C;this._isHeaderHighlight&&c===l.RANGE_TYPE.COLUMN&&(O=new l.ColorKit(h).setAlpha(Pr).toString()),this._columnHeaderBackground.setProps({fill:O}),this._columnHeaderBackground.resize(s-r,n),this._columnHeaderBorder.setProps({fill:I}),this._columnHeaderBorder.transformByState({width:s-r,height:E,top:n-E+1/u}),this._columnHeaderGroup.show(),this._columnHeaderGroup.translate(r,0)}else this._columnHeaderGroup.hide();if(this._columnHeaderGroup.makeDirty(!0),m===!0){let O=g;this._isHeaderHighlight&&c===l.RANGE_TYPE.ROW&&(O=new l.ColorKit(h).setAlpha(Pr).toString()),this._rowHeaderBackground.setProps({fill:O}),this._rowHeaderBackground.resize(t,a-o),this._rowHeaderBorder.setProps({fill:_}),this._rowHeaderBorder.transformByState({width:w,height:a-o,left:t-w+1/u}),this._rowHeaderGroup.show(),this._rowHeaderGroup.translate(0,o)}else this._rowHeaderGroup.hide();this._rowHeaderGroup.makeDirty(!0)}_updateBackgroundControl(e){const{startX:t,startY:n,endX:r,endY:o}=this._selectionModel,s=this._defaultStyle;e==null&&(e=s);const a=this._getScale(),{fill:c=s.fill}=e;let{strokeWidth:d=s.strokeWidth}=e;d/=a;const u=this._selectionModel.highlightToSelection();if(!u){this._backgroundControlTop.resize(r-t,o-n),this._backgroundControlTop.setProps({fill:c}),this._backgroundControlBottom.resize(0,0),this._backgroundControlMiddleLeft.resize(0,0),this._backgroundControlMiddleRight.resize(0,0);return}const{startX:h,startY:m,endX:g,endY:_}=u,f=d/2,C={left:-f,top:-f,width:r-t+f*2,height:m-n+f};C.height<0&&(C.width=0,C.height=0),this._backgroundControlTop.transformByState(C);const I={left:-f,top:m-n,width:h-t+f,height:_-m};I.width<0&&(I.width=0,I.height=0),this._backgroundControlMiddleLeft.transformByState(I);const w={left:g-t-f,top:m-n,width:r-g+f*2,height:_-m};w.width<0&&(w.width=0,w.height=0),this._backgroundControlMiddleRight.transformByState(w);const E={left:-f,top:_-n,width:r-t+f*2,height:o-_+f};E.height<0&&(E.width=0,E.height=0),this._backgroundControlBottom.transformByState(E),this._backgroundControlTop.setProps({fill:c}),this._backgroundControlMiddleLeft.setProps({fill:c}),this._backgroundControlMiddleRight.setProps({fill:c}),this._backgroundControlBottom.setProps({fill:c})}_updateWidgets(e){const{startX:t,startY:n,endX:r,endY:o}=this._selectionModel,s=this._defaultStyle;e==null&&(e=s);const{stroke:a=s.stroke,widgets:c=s.widgets,widgetStroke:d=s.widgetStroke}=e,u=this._getScale();let{widgetSize:h=s.widgetSize,widgetStrokeWidth:m=s.widgetStrokeWidth}=e;h/=u,m/=u;const g={left:-h/2+m/2,center:(r-t)/2-h/2+m/2,right:r-t-h/2+m/2,top:-h/2,middle:(o-n)/2-h/2,bottom:o-n-h/2+m/2},_=h-m;this._widgetRects.forEach(f=>{f.setProps({fill:a,stroke:d})}),c.tl===!0?(this._topLeftWidget.transformByState({height:_,width:_,left:g.left,top:g.top,strokeWidth:m}),this._topLeftWidget.show()):this._topLeftWidget.hide(),c.tc===!0?(this._topCenterWidget.transformByState({height:_,width:_,left:g.center,top:g.top,strokeWidth:m}),this._topCenterWidget.show()):this._topCenterWidget.hide(),c.tr===!0?(this._topRightWidget.transformByState({height:_,width:_,left:g.right,top:g.top,strokeWidth:m}),this._topRightWidget.show()):this._topRightWidget.hide(),c.ml===!0?(this._middleLeftWidget.transformByState({height:_,width:_,left:g.left,top:g.middle,strokeWidth:m}),this._middleLeftWidget.show()):this._middleLeftWidget.hide(),c.mr===!0?(this._middleRightWidget.transformByState({height:_,width:_,left:g.right,top:g.middle,strokeWidth:m}),this._middleRightWidget.show()):this._middleRightWidget.hide(),c.bl===!0?(this._bottomLeftWidget.transformByState({height:_,width:_,left:g.left,top:g.bottom,strokeWidth:m}),this._bottomLeftWidget.show()):this._bottomLeftWidget.hide(),c.bc===!0?(this._bottomCenterWidget.transformByState({height:_,width:_,left:g.center,top:g.bottom,strokeWidth:m}),this._bottomCenterWidget.show()):this._bottomCenterWidget.hide(),c.br===!0?(this._bottomRightWidget.transformByState({height:_,width:_,left:g.right,top:g.bottom,strokeWidth:m}),this._bottomRightWidget.show()):this._bottomRightWidget.hide()}_hasWidgets(e){if(e==null)return!1;const t=Object.keys(e);if(t.length===0)return!1;for(const n of t)if(e[n]===!0)return!0;return!0}_getScale(){const{scaleX:e,scaleY:t}=this._scene.getAncestorScale();return Math.max(e,t)}}const Hr="__SpreadsheetHelperSelectionTempRect",Gs=35;class Lr{constructor(e,t,n,r,o){v(this,"_startOffsetX",0);v(this,"_startOffsetY",0);v(this,"_relativeSelectionPositionRow",0);v(this,"_relativeSelectionPositionColumn",0);v(this,"_relativeSelectionRowLength",0);v(this,"_relativeSelectionColumnLength",0);v(this,"_moveObserver");v(this,"_upObserver");v(this,"_helperSelection");v(this,"_scrollTimer");v(this,"_activeViewport");v(this,"_targetSelection",{startY:0,endY:0,startX:0,endX:0,startRow:-1,endRow:-1,startColumn:-1,endColumn:-1});v(this,"_isInMergeState",!1);v(this,"_fillControlColors",[]);this._control=e,this._skeleton=t,this._scene=n,this._themeService=r,this._injector=o,this._initialControl(),this._initialWidget(),this._initialFill(),this._control.dispose$.subscribe(()=>{this.dispose()})}get isHelperSelection(){return this._control.isHelperSelection}dispose(){var e,t;(e=this._scrollTimer)==null||e.dispose(),this._fillControlColors=[],this._clearObserverEvent(),(t=this._helperSelection)==null||t.dispose()}_getFreeze(){var t;return(t=this._injector.get(exports.SheetSkeletonManagerService).getCurrent())==null?void 0:t.skeleton.getWorksheetConfig().freeze}_isSelectionInViewport(e,t){const n=this._getFreeze()||{startRow:-1,startColumn:-1,xSplit:0,ySplit:0};switch(t.viewPortKey){case Q.VIEW_MAIN:return e.endRow>=n.startRow&&e.endColumn>=n.startColumn;case Q.VIEW_MAIN_TOP:case Q.VIEW_COLUMN_RIGHT:return e.endColumn>=n.startColumn&&e.startRow<n.startRow;case Q.VIEW_MAIN_LEFT:case Q.VIEW_ROW_BOTTOM:return e.endRow>=n.startRow&&e.startColumn<n.startColumn;case Q.VIEW_MAIN_LEFT_TOP:case Q.VIEW_COLUMN_LEFT:case Q.VIEW_ROW_TOP:case Q.VIEW_LEFT_TOP:return e.startRow<n.startRow&&e.startColumn<n.startColumn}}_clearObserverEvent(){this._scene.onPointerMoveObserver.remove(this._moveObserver),this._scene.onPointerUpObserver.remove(this._upObserver),this._moveObserver=null,this._upObserver=null}_initialControl(){const{leftControl:e,rightControl:t,topControl:n,bottomControl:r}=this._control;[e,t,n,r].forEach(o=>{o.onPointerEnterObserver.add(()=>{o.setCursor(y.CURSOR_TYPE.MOVE)}),o.onPointerLeaveObserver.add(()=>{o.resetCursor()}),o.onPointerDownObserver.add(this._controlEvent.bind(this))})}_controlMoving(e,t){var N;const n=this._scene,r=n.getScrollXYByRelativeCoords(y.Vector2.FromArray([e,t])),{scaleX:o,scaleY:s}=n.getAncestorScale(),a=this._skeleton.getCellPositionByOffset(e,t,o,s,r),{row:c,column:d}=a,u=this._skeleton.getRowCount()-1,h=this._skeleton.getColumnCount()-1;let m=c+this._relativeSelectionPositionRow;m<0&&(m=0);let g=m+this._relativeSelectionRowLength;g>u&&(g=u,g-m<this._relativeSelectionRowLength&&(m=g-this._relativeSelectionRowLength));let _=d+this._relativeSelectionPositionColumn;_<0&&(_=0);let f=_+this._relativeSelectionColumnLength;f>h&&(f=h,f-_<this._relativeSelectionColumnLength&&(_=f-this._relativeSelectionColumnLength));const C=this._skeleton.getNoMergeCellPositionByIndex(m,_),I=this._skeleton.getNoMergeCellPositionByIndex(g,f),w=(C==null?void 0:C.startY)||0,E=(I==null?void 0:I.endY)||0,O=(C==null?void 0:C.startX)||0,x=(I==null?void 0:I.endX)||0;(N=this._helperSelection)==null||N.transformByState({left:O,top:w,width:x-O,height:E-w}),this._targetSelection={startY:w,endY:E,startX:O,endX:x,startRow:m,endRow:g,startColumn:_,endColumn:f},this._control.selectionMoving$.next(this._targetSelection)}_controlEvent(e){const{offsetX:t,offsetY:n}=e,r=this._scene,o=r.getRelativeCoord(y.Vector2.FromArray([t,n])),{x:s,y:a}=o,c=r.getScrollXYByRelativeCoords(o),{scaleX:d,scaleY:u}=r.getAncestorScale(),h=this._skeleton.getCellPositionByOffset(s,a,d,u,c);this._startOffsetX=s,this._startOffsetY=a;const{row:m,column:g}=h,{startRow:_,startColumn:f,endRow:C,endColumn:I}=this._control.model;let w=0,E=0;m<_?w-=1:m>C&&(w+=1),g<f?E-=1:g>I&&(E+=1),this._relativeSelectionPositionRow=_-m+w,this._relativeSelectionPositionColumn=f-g+E,this._relativeSelectionRowLength=C-_,this._relativeSelectionColumnLength=I-f;const O=this._control.selectionStyle,x=this._getScale();this.isHelperSelection&&(this._helperSelection=new y.Rect(Hr,{stroke:O.stroke,strokeWidth:O.strokeWidth/x}),r.addObject(this._helperSelection));const N=r.getViewport(Q.VIEW_MAIN),D=y.ScrollTimer.create(r);D.startScroll(s,a,N),this._scrollTimer=D,r.disableEvent(),this._moveObserver=r.onPointerMoveObserver.add(P=>{const{offsetX:L,offsetY:G}=P,{x:k,y:ee}=r.getRelativeCoord(y.Vector2.FromArray([L,G]));this._controlMoving(k,ee),r.setCursor(y.CURSOR_TYPE.MOVE),D.scrolling(k,ee,()=>{this._controlMoving(k,ee)})}),this._upObserver=r.onPointerUpObserver.add(()=>{var L,G;(L=this._helperSelection)==null||L.dispose();const P=this._scene;P.resetCursor(),this._clearObserverEvent(),P.enableEvent(),(G=this._scrollTimer)==null||G.dispose(),this._control.selectionMoved$.next(this._targetSelection)})}_initialWidget(){const{topLeftWidget:e,topCenterWidget:t,topRightWidget:n,middleLeftWidget:r,middleRightWidget:o,bottomLeftWidget:s,bottomCenterWidget:a,bottomRightWidget:c}=this._control,d=[y.CURSOR_TYPE.NORTH_WEST_RESIZE,y.CURSOR_TYPE.NORTH_RESIZE,y.CURSOR_TYPE.NORTH_EAST_RESIZE,y.CURSOR_TYPE.WEST_RESIZE,y.CURSOR_TYPE.EAST_RESIZE,y.CURSOR_TYPE.SOUTH_WEST_RESIZE,y.CURSOR_TYPE.SOUTH_RESIZE,y.CURSOR_TYPE.SOUTH_EAST_RESIZE];[e,t,n,r,o,s,a,c].forEach((u,h)=>{u.onPointerEnterObserver.add(()=>{u.setCursor(d[h])}),u.onPointerLeaveObserver.add(()=>{u.resetCursor()}),u.onPointerDownObserver.add(m=>{this._widgetEvent(m,d[h])})})}_widgetMoving(e,t,n){const r=this._scene,o=r.getScrollXYByRelativeCoords(y.Vector2.FromArray([this._startOffsetX,this._startOffsetY])),{scaleX:s,scaleY:a}=r.getAncestorScale(),c=this._skeleton.getCellPositionByOffset(e,t,s,a,o),{row:d,column:u}=c,{rowHeaderWidth:h,columnHeaderHeight:m}=this._skeleton;let g=this._relativeSelectionPositionRow,_=this._relativeSelectionPositionColumn,f=d,C=u;n===y.CURSOR_TYPE.NORTH_WEST_RESIZE?(g=d,_=u,f=this._relativeSelectionPositionRow,C=this._relativeSelectionPositionColumn):n===y.CURSOR_TYPE.NORTH_RESIZE?(g=d,_=this._relativeSelectionPositionColumn,f=this._relativeSelectionPositionRow,C=this._relativeSelectionPositionColumn+this._relativeSelectionColumnLength):n===y.CURSOR_TYPE.NORTH_EAST_RESIZE?(g=d,_=this._relativeSelectionPositionColumn,f=this._relativeSelectionPositionRow,C=u):n===y.CURSOR_TYPE.WEST_RESIZE?(g=this._relativeSelectionPositionRow,_=u,f=this._relativeSelectionPositionRow+this._relativeSelectionRowLength,C=this._relativeSelectionPositionColumn):n===y.CURSOR_TYPE.EAST_RESIZE?f=this._relativeSelectionPositionRow+this._relativeSelectionRowLength:n===y.CURSOR_TYPE.SOUTH_WEST_RESIZE?(g=this._relativeSelectionPositionRow,_=u,f=d,C=this._relativeSelectionPositionColumn):n===y.CURSOR_TYPE.SOUTH_RESIZE&&(g=this._relativeSelectionPositionRow,_=this._relativeSelectionPositionColumn,f=d,C=this._relativeSelectionPositionColumn+this._relativeSelectionColumnLength);const{startRow:I,startColumn:w,endRow:E,endColumn:O}=this._swapPositions(g,_,f,C),x=this._skeleton.getNoMergeCellPositionByIndex(I,w),N=this._skeleton.getNoMergeCellPositionByIndex(E,O),D=(x==null?void 0:x.startY)||0,P=(N==null?void 0:N.endY)||0,L=(x==null?void 0:x.startX)||0,G=(N==null?void 0:N.endX)||0;this._targetSelection={startY:D,endY:P,startX:L,endX:G,startRow:g,endRow:f,startColumn:_,endColumn:C},this._control.update(this._targetSelection,h,m,this._control.selectionStyle),this._control.clearHighlight(),this._control.selectionScaling$.next(this._targetSelection)}_widgetEvent(e,t){const{offsetX:n,offsetY:r}=e,o=this._scene,s=o.getRelativeCoord(y.Vector2.FromArray([n,r])),{x:a,y:c}=s;this._startOffsetX=n,this._startOffsetY=r;const{startRow:d,startColumn:u,endRow:h,endColumn:m}=this._control.model;this._relativeSelectionPositionRow=d,this._relativeSelectionPositionColumn=u,this._relativeSelectionRowLength=h-d,this._relativeSelectionColumnLength=m-u,t===y.CURSOR_TYPE.NORTH_WEST_RESIZE?(this._relativeSelectionPositionRow=h,this._relativeSelectionPositionColumn=m):t===y.CURSOR_TYPE.NORTH_RESIZE?this._relativeSelectionPositionRow=h:t===y.CURSOR_TYPE.NORTH_EAST_RESIZE?this._relativeSelectionPositionRow=h:t===y.CURSOR_TYPE.WEST_RESIZE?this._relativeSelectionPositionColumn=m:t===y.CURSOR_TYPE.SOUTH_WEST_RESIZE&&(this._relativeSelectionPositionColumn=m);const g=y.ScrollTimer.create(o);g.startScroll(a,c),this._scrollTimer=g,o.disableEvent(),this._moveObserver=o.onPointerMoveObserver.add(_=>{const{offsetX:f,offsetY:C}=_,{x:I,y:w}=o.getRelativeCoord(y.Vector2.FromArray([f,C]));this._widgetMoving(I,w,t),o.setCursor(t),g.scrolling(I,w,()=>{this._widgetMoving(I,w,t)})}),this._upObserver=o.onPointerUpObserver.add(()=>{var f;const _=this._scene;_.resetCursor(),this._clearObserverEvent(),_.enableEvent(),(f=this._scrollTimer)==null||f.dispose(),this._control.selectionScaled$.next(this._targetSelection)})}_initialFill(){const{fillControl:e}=this._control;e.onPointerEnterObserver.add(()=>{e.setCursor(y.CURSOR_TYPE.CROSSHAIR)}),e.onPointerLeaveObserver.add(()=>{e.resetCursor()}),e.onPointerDownObserver.add(this._fillEvent.bind(this))}_fillMoving(e,t){var G,k,ee;const n=this._scene,r=n.getScrollXY(this._activeViewport),{scaleX:o,scaleY:s}=n.getAncestorScale(),a=this._skeleton.getCellPositionByOffset(e,t,o,s,r),{row:c,column:d}=a,u=n.getRelativeCoord(y.Vector2.FromArray([e,t])),h=this._skeleton.getRowCount()-1,m=this._skeleton.getColumnCount()-1;let g=this._relativeSelectionPositionRow,_=this._relativeSelectionPositionColumn,f=this._relativeSelectionPositionRow+this._relativeSelectionRowLength,C=this._relativeSelectionPositionColumn+this._relativeSelectionColumnLength,I=!1,w=!0;if((d<_||d>C)&&c>=g&&c<=f){const te=this._fillRuler(d,_,C,this._relativeSelectionColumnLength,m);_=te.startRowOrColumn,C=te.endRowOrColumn,I=te.isLighten,w=!1}else if((c<g||c>f)&&d>=_&&d<=C){const te=this._fillRuler(c,g,f,this._relativeSelectionRowLength,h);g=te.startRowOrColumn,f=te.endRowOrColumn,I=te.isLighten}else if(Math.abs(this._startOffsetX-u.x-r.x)/2>Math.abs(this._startOffsetY-u.y-r.y)){const te=this._fillRuler(d,_,C,this._relativeSelectionColumnLength,m);_=te.startRowOrColumn,C=te.endRowOrColumn,I=te.isLighten,w=!1}else{const te=this._fillRuler(c,g,f,this._relativeSelectionRowLength,h);g=te.startRowOrColumn,f=te.endRowOrColumn,I=te.isLighten}const E=this._skeleton.getNoMergeCellPositionByIndex(g,_),O=this._skeleton.getNoMergeCellPositionByIndex(f,C),x=(E==null?void 0:E.startY)||0,N=(O==null?void 0:O.endY)||0,D=(E==null?void 0:E.startX)||0,P=(O==null?void 0:O.endX)||0;I?this._controlHandler((te,W)=>{const V=new l.ColorKit(this._fillControlColors[W]).lighten(Gs).toRgbString();te.setProps({fill:V})}):this._controlHandler((te,W)=>{te.setProps({fill:this._fillControlColors[W]})});const L=p.SELECTION_CONTROL_BORDER_BUFFER_WIDTH/this._getScale();g===f&&w===!0||_===C&&w===!1?(G=this._helperSelection)==null||G.hide():((k=this._helperSelection)==null||k.transformByState({left:D-L/2,top:x-L/2,width:P-D,height:N-x}),(ee=this._helperSelection)==null||ee.show()),this._targetSelection={startY:x,endY:N,startX:D,endX:P,startRow:g,endRow:f,startColumn:_,endColumn:C},this._control.selectionFilling$.next(this._targetSelection)}_fillEvent(e){const{offsetX:t,offsetY:n}=e,r=this._scene,o=r.getRelativeCoord(y.Vector2.FromArray([t,n])),{x:s,y:a}=o;this._startOffsetX=s,this._startOffsetY=a;const{startRow:c,startColumn:d,endRow:u,endColumn:h}=this._control.model;this._isInMergeState=this._hasMergeInRange(c,d,u,h),this._relativeSelectionPositionRow=c,this._relativeSelectionPositionColumn=d,this._relativeSelectionRowLength=u-c,this._relativeSelectionColumnLength=h-d;const m=this._control.selectionStyle;let g=m==null?void 0:m.stroke,_=m==null?void 0:m.strokeWidth;const f=p.getNormalSelectionStyle(this._themeService);g==null&&(g=f.stroke),_==null&&(_=f.strokeWidth);const C=this._getScale();_/=C;const I=p.SELECTION_CONTROL_BORDER_BUFFER_WIDTH/C,w=new l.ColorKit(g).darken(2).toRgbString();this.isHelperSelection&&(this._helperSelection=new y.Rect(Hr,{stroke:w,strokeWidth:_+I/2}),r.addObject(this._helperSelection)),this._activeViewport=r.getActiveViewportByCoord(y.Vector2.FromArray([t,n]));const E=r.getViewport(Q.VIEW_MAIN),O=y.ScrollTimer.create(r,this._activeViewport.viewPortKey===Q.VIEW_MAIN?y.ScrollTimerType.ALL:y.ScrollTimerType.NONE);O.startScroll(s,a,E),this._scrollTimer=O,r.disableEvent(),this._controlHandler(x=>{this._fillControlColors.push(x.fill)}),this._moveObserver=r.onPointerMoveObserver.add(x=>{var ee;const{offsetX:N,offsetY:D}=x,P=r.getActiveViewportByCoord(y.Vector2.FromArray([N,D])),{x:L,y:G}=r.getRelativeCoord(y.Vector2.FromArray([N,D]));this._fillMoving(L,G),r.setCursor(y.CURSOR_TYPE.CROSSHAIR);const k=this._targetSelection;if(E&&P&&((ee=this._activeViewport)==null?void 0:ee.viewPortKey)!==(P==null?void 0:P.viewPortKey)){let te;k.startRow!==c?(O.scrollTimerType=y.ScrollTimerType.Y,te={...k,endRow:k.startRow}):k.endRow!==u?(O.scrollTimerType=y.ScrollTimerType.Y,te={...k,startRow:k.endRow}):k.startColumn!==d?(O.scrollTimerType=y.ScrollTimerType.X,te={...k,endColumn:k.startColumn}):(O.scrollTimerType=y.ScrollTimerType.X,te={...k,startColumn:k.endColumn}),this._isSelectionInViewport(te,P)&&(E.scrollTo({x:O.scrollTimerType===y.ScrollTimerType.X?0:void 0,y:O.scrollTimerType===y.ScrollTimerType.Y?0:void 0}),this._activeViewport=P)}O.scrolling(L,G,()=>{this._fillMoving(L,G)})}),this._upObserver=r.onPointerUpObserver.add(()=>{var N,D;(N=this._helperSelection)==null||N.dispose();const x=this._scene;x.resetCursor(),this._clearObserverEvent(),x.enableEvent(),(D=this._scrollTimer)==null||D.dispose(),this._control.refreshSelectionFilled(this._targetSelection),this._isInMergeState=!1,this._controlHandler((P,L)=>{P.setProps({fill:this._fillControlColors[L]})}),this._fillControlColors=[]})}_hasMergeInRange(e,t,n,r){const o=this._skeleton.mergeData;if(!o)return!1;for(const s of o){const{startRow:a,startColumn:c,endRow:d,endColumn:u}=s,h={left:t,top:e,right:r,bottom:n},m={left:c,top:a,right:u,bottom:d};if(y.isRectIntersect(h,m))return!0}return!1}_swapPositions(e,t,n,r){const o=Math.min(e,n),s=Math.min(t,r),a=Math.max(e,n),c=Math.max(t,r);return{startRow:o,startColumn:s,endRow:a,endColumn:c}}_controlHandler(e){const{leftControl:t,rightControl:n,topControl:r,bottomControl:o,backgroundControlTop:s,backgroundControlMiddleLeft:a,backgroundControlMiddleRight:c,backgroundControlBottom:d,fillControl:u}=this._control,h=[t,n,r,o,s,a,c,d,u];for(let m=0,g=h.length;m<g;m++){const _=h[m];e(_,m)}}_fillRuler(e,t,n,r,o){let s=!1;if(e<t)if(this._isInMergeState&&e<t){const a=t-e,c=r+1,d=Math.ceil(a/c);let u=t-d*c;u<0&&(u=t-(d-1)*c),t=u}else t=e;else if(e>=t&&e<=n)s=!0,n=e;else if(this._isInMergeState&&e>n){const a=e-n,c=r+1,d=Math.ceil(a/c);let u=n+d*c;u>o&&(u=n+(d-1)*c),n=u}else n=e;return{rowOrColumn:e,startRowOrColumn:t,endRowOrColumn:n,isLighten:s}}_getScale(){const{scaleX:e,scaleY:t}=this._scene.getAncestorScale();return Math.max(e,t)}}var Ks=Object.defineProperty,qs=Object.getOwnPropertyDescriptor,Js=(i,e,t,n)=>{for(var r=n>1?void 0:n?qs(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&Ks(e,t,r),r},kn=(i,e)=>(t,n)=>e(t,n,i);exports.SelectionRenderService=class{constructor(e,t,n,r){v(this,"hasSelection",!1);v(this,"_downObserver");v(this,"_moveObserver");v(this,"_upObserver");v(this,"_controlFillConfig$",new J.BehaviorSubject(null));v(this,"controlFillConfig$",this._controlFillConfig$.asObservable());v(this,"_selectionControls",[]);v(this,"_startSelectionRange",{startY:0,endY:0,startX:0,endX:0,startRow:-1,endRow:-1,startColumn:-1,endColumn:-1});v(this,"_startOffsetX",0);v(this,"_startOffsetY",0);v(this,"_scrollTimer");v(this,"_cancelDownObserver");v(this,"_cancelUpObserver");v(this,"_skeleton");v(this,"_scene");v(this,"_isHeaderHighlight",!0);v(this,"_isDetectMergedCell",!0);v(this,"_selectionStyle");v(this,"_isSelectionEnabled",!0);v(this,"_isShowPreviousEnable",0);v(this,"_isRemainLastEnable",!0);v(this,"_isSkipRemainLastEnable",!1);v(this,"_selectionMoveEnd$",new J.BehaviorSubject([]));v(this,"selectionMoveEnd$",this._selectionMoveEnd$.asObservable());v(this,"_selectionMoving$",new J.Subject);v(this,"selectionMoving$",this._selectionMoving$.asObservable());v(this,"_selectionMoveStart$",new J.Subject);v(this,"selectionMoveStart$",this._selectionMoveStart$.asObservable());v(this,"_activeViewport");this._themeService=e,this._shortcutService=t,this._sheetSkeletonManagerService=n,this._injector=r,this._selectionStyle=p.getNormalSelectionStyle(this._themeService)}enableHeaderHighlight(){this._isHeaderHighlight=!0}disableHeaderHighlight(){this._isHeaderHighlight=!1}enableDetectMergedCell(){this._isDetectMergedCell=!0}disableDetectMergedCell(){this._isDetectMergedCell=!1}setStyle(e){this._selectionStyle=e}resetStyle(){this.setStyle(p.getNormalSelectionStyle(this._themeService))}enableSelection(){this._isSelectionEnabled=!0}disableSelection(){this._isSelectionEnabled=!1}enableShowPrevious(){this._isShowPreviousEnable=!0}disableShowPrevious(){this._isShowPreviousEnable=!1}enableRemainLast(){this._isRemainLastEnable=!0}disableRemainLast(){this._isRemainLastEnable=!1}enableSkipRemainLast(){this._isSkipRemainLastEnable=!0}disableSkipRemainLast(){this._isSkipRemainLastEnable=!1}getViewPort(){return this._activeViewport}addControlToCurrentByRangeData(e){const t=this.getCurrentControls();if(!t)return;const{rangeWithCoord:n,primaryWithCoord:r}=e,o=this._skeleton;let s=e.style;s==null&&(s=p.getNormalSelectionStyle(this._themeService));const a=this._scene;if(a==null||o==null)return;const c=new Ci(a,t.length,this._isHeaderHighlight,this._themeService);new Lr(c,o,a,this._themeService,this._injector);const{rowHeaderWidth:d,columnHeaderHeight:u}=o;c.update(n,d,u,s,r),this._isHeaderHighlight?c.enableHeaderHighlight():c.disableHeaderHighlight(),t.push(c)}updateControlForCurrentByRangeData(e){const t=this.getCurrentControls();if(!t)return;const n=this._skeleton;if(n==null)return;const{rowHeaderWidth:r,columnHeaderHeight:o}=n;for(let s=0,a=e.length;s<a;s++){const{rangeWithCoord:c,primaryWithCoord:d,style:u}=e[s];t[s].update(c,r,o,u,d)}}refreshSelectionMoveStart(){this._selectionMoveStart$.next(this.getSelectionDataWithStyle())}changeRuntime(e,t,n){this._skeleton=e,this._scene=t,this._activeViewport=n||t.getViewports()[0]}getSelectionDataWithStyle(){return this._selectionControls.map(t=>t.getValue())}getCurrentControls(){return this._selectionControls}_clearSelectionControls(){const e=this.getCurrentControls();if(e.length>0){for(const t of e)t.dispose();e.length=0}}_getFreeze(){var t;return(t=this._sheetSkeletonManagerService.getCurrent())==null?void 0:t.skeleton.getWorksheetConfig().freeze}_getViewportByCell(e,t){if(!this._scene||e===void 0||t===void 0)return null;const n=this._getFreeze();if(!n||n.startRow<=0&&n.startColumn<=0)return this._scene.getViewport(Q.VIEW_MAIN);if(e>n.startRow&&t>n.startColumn)return this._scene.getViewport(Q.VIEW_MAIN);if(e<=n.startRow&&t<=n.startColumn)return this._scene.getViewport(Q.VIEW_MAIN_LEFT_TOP);if(e<=n.startRow&&t>n.startColumn)return this._scene.getViewport(Q.VIEW_MAIN_TOP);if(e>n.startRow&&t<=n.startColumn)return this._scene.getViewport(Q.VIEW_MAIN_LEFT)}getActiveSelections(){const e=this.getCurrentControls();if(e&&e.length>0)return e==null?void 0:e.map(n=>{const r=n.model,o=r.currentCell;let s=null;return o&&(s={actualRow:o.actualRow,actualColumn:o.actualColumn,isMerged:o.isMerged,isMergedMainCell:o.isMergedMainCell,startRow:o.mergeInfo.startRow,startColumn:o.mergeInfo.startColumn,endRow:o.mergeInfo.endRow,endColumn:o.mergeInfo.endColumn}),{range:{startRow:r.startRow,startColumn:r.startColumn,endRow:r.endRow,endColumn:r.endColumn},primary:s}})}getActiveRange(){const e=this.getCurrentControls(),t=e&&e[e.length-1].model;return t&&{startRow:t.startRow,startColumn:t.startColumn,endRow:t.endRow,endColumn:t.endColumn}}getActiveSelection(){const e=this.getCurrentControls();return e&&e[e.length-1]}endSelection(){this._endSelection()}reset(){this._clearSelectionControls(),this._moveObserver=null,this._upObserver=null,this._downObserver=null}resetAndEndSelection(){this.endSelection(),this.reset()}eventTrigger(e,t=0,n=l.RANGE_TYPE.NORMAL,r,o=y.ScrollTimerType.ALL){if(this._isSelectionEnabled===!1)return;const s=this._skeleton,{offsetX:a,offsetY:c}=e,d=this._scene;if(d==null||s==null)return;r!=null&&(this._activeViewport=r);const u=d.getViewport(Q.VIEW_MAIN),h=d.getRelativeCoord(y.Vector2.FromArray([a,c]));let{x:m,y:g}=h;this._startOffsetX=m,this._startOffsetY=g;const _=d.getScrollXYByRelativeCoords(h),{scaleX:f,scaleY:C}=d.getAncestorScale();n===l.RANGE_TYPE.ROW?m=0:n===l.RANGE_TYPE.COLUMN&&(g=0);const I=this._getSelectedRangeWithMerge(m,g,f,C,_);if(!I)return!1;const{rangeWithCoord:w,primaryWithCoord:E}=I,{startRow:O,startColumn:x,endColumn:N,endRow:D,startY:P,endY:L,startX:G,endX:k}=w,{rowHeaderWidth:ee,columnHeaderHeight:te}=s,W={startColumn:x,startRow:O,endColumn:N,endRow:D,startY:P,endY:L,startX:G,endX:k,rangeType:n};this._startSelectionRange=W;let V=this.getActiveSelection();const re=this.getCurrentControls();if(!re)return!1;for(const Oe of re){if(e.button===2&&Oe.model.isInclude(W)){V=Oe;return}if(Oe.model.isEqual(W)){V=Oe;break}e.shiftKey||Oe.clearHighlight()}if(re.length>0&&!e.ctrlKey&&!e.shiftKey&&!this._isShowPreviousEnable&&!this._isRemainLastEnable){for(const Oe of re)Oe.dispose();re.length=0}const q=V&&V.model.currentCell;if(V&&e.shiftKey&&q){const{actualRow:Oe,actualColumn:Le,mergeInfo:Se}=q,he=Math.min(Oe,W.startRow,Se.startRow),ge=Math.max(Oe,W.endRow,Se.endRow),Ae=Math.min(Le,W.startColumn,Se.startColumn),we=Math.max(Le,W.endColumn,Se.endColumn),Pe=s.getMergeBounding(he,Ae,ge,we),Ue=s.getNoMergeCellPositionByIndex(Pe.startRow,Pe.startColumn),Ne=s.getNoMergeCellPositionByIndex(Pe.endRow,Pe.endColumn),it={startColumn:Pe.startColumn,startRow:Pe.startRow,endColumn:Pe.endColumn,endRow:Pe.endRow,startY:Ue.startY,endY:Ne.endY,startX:Ue.startX,endX:Ne.endX,rangeType:n},Fe=s.getCellByIndex(Oe,Le);this._startSelectionRange={startColumn:Fe.mergeInfo.startColumn,startRow:Fe.mergeInfo.startRow,endColumn:Fe.mergeInfo.endColumn,endRow:Fe.mergeInfo.endRow,startY:Fe.mergeInfo.startY||0,endY:Fe.mergeInfo.endY||0,startX:Fe.mergeInfo.startX||0,endX:Fe.mergeInfo.endX||0,rangeType:n},V.update(it,ee,te,this._selectionStyle,q)}else this._isRemainLastEnable&&V&&!e.ctrlKey&&!e.shiftKey&&!this._isSkipRemainLastEnable?V.update(W,ee,te,this._selectionStyle,E):(V=new Ci(d,re.length+t,this._isHeaderHighlight,this._themeService),new Lr(V,s,d,this._themeService,this._injector),V.update(W,ee,te,this._selectionStyle,E),re.push(V));this._selectionMoveStart$.next(this.getSelectionDataWithStyle()),this.hasSelection=!0,this._endSelection(),d.disableEvent();const ae=d.getActiveViewportByCoord(y.Vector2.FromArray([m,g])),Ie=y.ScrollTimer.create(this._scene,o);Ie.startScroll((u==null?void 0:u.left)??0,(u==null?void 0:u.top)??0,u),this._scrollTimer=Ie,this._addCancelObserver(),(n===l.RANGE_TYPE.ROW||n===l.RANGE_TYPE.COLUMN)&&this._moving(m,g,V,n);let de=0,Ee=0,be=m,De=g;this._moveObserver=d.onPointerMoveObserver.add(Oe=>{var Fe;const{offsetX:Le,offsetY:Se}=Oe,{x:he,y:ge}=d.getRelativeCoord(y.Vector2.FromArray([Le,Se]));this._moving(he,ge,V,n);let Ae=he,we=ge;const Pe=this.getActiveSelection(),Ue=(Fe=this._sheetSkeletonManagerService.getCurrent())==null?void 0:Fe.skeleton.getWorksheetConfig().freeze,Ne=Pe==null?void 0:Pe.model,it=d.getActiveViewportByCoord(y.Vector2.FromArray([Le,Se]))??this._getViewportByCell(Ne==null?void 0:Ne.endRow,Ne==null?void 0:Ne.endColumn);if(ae&&it&&u){const pt=be<u.left&&he>u.left||be>u.left&&he<u.left,ft=De<u.top&&ge>u.top||De>u.top&&ge<u.top;pt&&(de+=1),ft&&(Ee+=1);const $e=ae.viewPortKey,Ve=it.viewPortKey;if($e===Q.VIEW_ROW_TOP)Se<u.top&&((Ne==null?void 0:Ne.endRow)??0)<((Ue==null?void 0:Ue.startRow)??0)?we=u.top:ft&&Ee%2===1&&u.scrollTo({y:0});else if($e===Q.VIEW_COLUMN_LEFT)Le<u.left&&((Ne==null?void 0:Ne.endColumn)??0)<((Ue==null?void 0:Ue.startColumn)??0)?Ae=u.left:pt&&de%2===1&&u.scrollTo({x:0});else if($e===Ve){let He=!1,Qe=!1;$e===Q.VIEW_MAIN_LEFT_TOP?(He=!0,Qe=!0):$e===Q.VIEW_MAIN_TOP?Qe=!0:$e===Q.VIEW_MAIN_LEFT&&(He=!0),((Ne==null?void 0:Ne.endRow)??0)>((Ue==null?void 0:Ue.startRow)??0)&&(Qe=!1),((Ne==null?void 0:Ne.endColumn)??0)>((Ue==null?void 0:Ue.startColumn)??0)&&(He=!1),He&&(Ae=u.left),Qe&&(we=u.top)}else{const He={x:ae.scrollX,y:ae.scrollY},Qe={x:it.scrollX,y:it.scrollY},dn=He.x!==Qe.x&&pt&&de%2===1,un=He.y!==Qe.y&&ft&&Ee%2===1;(dn||un)&&(u.scrollTo({x:dn?He.x:void 0,y:un?He.y:void 0}),dn||(Ae=u.left),un||(we=u.top)),($e===Q.VIEW_MAIN_LEFT_TOP&&Ve===Q.VIEW_MAIN_LEFT||Ve===Q.VIEW_MAIN_LEFT_TOP&&$e===Q.VIEW_MAIN_LEFT)&&(Ae=u.left),($e===Q.VIEW_MAIN_LEFT_TOP&&Ve===Q.VIEW_MAIN_TOP||Ve===Q.VIEW_MAIN_LEFT_TOP&&$e===Q.VIEW_MAIN_TOP)&&(we=u.top)}be=he,De=ge}Ie.scrolling(Ae,we,()=>{this._moving(he,ge,V,n)})}),this._upObserver=d.onPointerUpObserver.add(Oe=>{this._endSelection(),this._selectionMoveEnd$.next(this.getSelectionDataWithStyle()),this._shortcutService.setDisable(!1)}),this._shortcutService.setDisable(!0)}convertSelectionRangeToData(e){const{range:t,primary:n,style:r}=e;let o=this.convertRangeDataToSelection(t);return o==null&&(o={startRow:-1,startColumn:-1,endRow:-1,endColumn:-1,startY:0,endY:0,startX:0,endX:0,rangeType:l.RANGE_TYPE.NORMAL}),{rangeWithCoord:o,primaryWithCoord:this.convertCellRangeToInfo(n),style:r}}convertRangeDataToSelection(e){const{startRow:t,startColumn:n,endRow:r,endColumn:o,rangeType:s}=e,a=this._scene,c=this._skeleton;if(a==null||c==null)return;a.getAncestorScale();const d=c.getNoMergeCellPositionByIndex(t,n),u=c.getNoMergeCellPositionByIndex(r,o);return{startRow:t,startColumn:n,endRow:r,endColumn:o,rangeType:s,startY:(d==null?void 0:d.startY)||0,endY:(u==null?void 0:u.endY)||0,startX:(d==null?void 0:d.startX)||0,endX:(u==null?void 0:u.endX)||0}}convertCellRangeToInfo(e){if(e==null)return;const t=this._scene,n=this._skeleton;if(t==null||n==null)return;const{actualRow:r,actualColumn:o,isMerged:s,isMergedMainCell:a,startRow:c,startColumn:d,endRow:u,endColumn:h}=e,m=n.getNoMergeCellPositionByIndex(r,o),g=n.getNoMergeCellPositionByIndex(c,d),_=n.getNoMergeCellPositionByIndex(u,h);return{actualRow:r,actualColumn:o,isMerged:s,isMergedMainCell:a,startX:m.startX,startY:m.startY,endX:m.endX,endY:m.endY,mergeInfo:{startRow:c,startColumn:d,endRow:u,endColumn:h,startY:(g==null?void 0:g.startY)||0,endY:(_==null?void 0:_.endY)||0,startX:(g==null?void 0:g.startX)||0,endX:(_==null?void 0:_.endX)||0}}}_moving(e,t,n,r){const o=this._skeleton,s=this._scene;if(s==null||o==null)return!1;const{startRow:a,startColumn:c,endRow:d,endColumn:u}=this._startSelectionRange,{startRow:h,endRow:m,startColumn:g,endColumn:_}=(n==null?void 0:n.model)||{startRow:-1,endRow:-1,startColumn:-1,endColumn:-1},f=s.getViewport(Q.VIEW_MAIN),C=this._getViewportByCell(m,_)??f,I=s.getScrollXYByRelativeCoords(y.Vector2.FromArray([this._startOffsetX,this._startOffsetY]),C),{scaleX:w,scaleY:E}=s.getAncestorScale(),{rowHeaderWidth:O,columnHeaderHeight:x}=o;r===l.RANGE_TYPE.ROW?e=1/0:r===l.RANGE_TYPE.COLUMN&&(t=1/0);const N=this._getSelectedRangeWithMerge(e,t,w,E,I);if(!N)return!1;const{rangeWithCoord:D,primaryWithCoord:P}=N,{startRow:L,startColumn:G,endColumn:k,endRow:ee}=D,te=Math.min(L,a),W=Math.min(G,c),V=Math.max(ee,d),re=Math.max(k,u);let q={startRow:te,startColumn:W,endRow:V,endColumn:re};if(this._isDetectMergedCell&&(q=o.getSelectionBounding(te,W,V,re)),!q)return!1;const{startRow:ae,startColumn:Ie,endRow:de,endColumn:Ee}=q,be=o.getNoMergeCellPositionByIndex(ae,Ie),De=o.getNoMergeCellPositionByIndex(de,Ee),Oe={startColumn:Ie,startRow:ae,endColumn:Ee,endRow:de,startY:(be==null?void 0:be.startY)||0,endY:(De==null?void 0:De.endY)||0,startX:(be==null?void 0:be.startX)||0,endX:(De==null?void 0:De.endX)||0};(g!==Ie||h!==ae||_!==Ee||m!==de)&&n!=null&&(n.update(Oe,O,x),this._selectionMoving$.next(this.getSelectionDataWithStyle()))}_endSelection(){var n,r;const e=this._scene;if(e==null)return;e.onPointerMoveObserver.remove(this._moveObserver),e.onPointerUpObserver.remove(this._upObserver),e.enableEvent(),(n=this._scrollTimer)==null||n.dispose();const t=(r=e.getEngine())==null?void 0:r.activeScene;t==null||t.onPointerDownObserver.remove(this._cancelDownObserver),t==null||t.onPointerUpObserver.remove(this._cancelUpObserver)}_addCancelObserver(){var n;const e=this._scene;if(e==null)return;const t=(n=e.getEngine())==null?void 0:n.activeScene;t==null||t===e||(t.onPointerDownObserver.remove(this._cancelDownObserver),t.onPointerUpObserver.remove(this._cancelUpObserver),this._cancelDownObserver=t.onPointerDownObserver.add(r=>{this._endSelection()}),this._cancelUpObserver=t.onPointerUpObserver.add(r=>{this._endSelection()}))}_getSelectedRangeWithMerge(e,t,n,r,o){var I;if(this._isDetectMergedCell){const w=(I=this._skeleton)==null?void 0:I.calculateCellIndexByPosition(e,t,n,r,o),E=l.makeCellToSelection(w);return E==null?void 0:{primaryWithCoord:w,rangeWithCoord:E}}const s=this._skeleton;if(s==null)return;const a=s.getCellPositionByOffset(e,t,n,r,o),{row:c,column:d}=a,u=s.getNoMergeCellPositionByIndex(c,d),{startX:h,startY:m,endX:g,endY:_}=u,f={startY:m,endY:_,startX:h,endX:g,startRow:c,endRow:c,startColumn:d,endColumn:d};return{primaryWithCoord:{actualRow:c,actualColumn:d,isMerged:!1,isMergedMainCell:!1,startY:m,endY:_,startX:h,endX:g,mergeInfo:f},rangeWithCoord:f}}};exports.SelectionRenderService=Js([kn(0,j.Inject(l.ThemeService)),kn(1,R.IShortcutService),kn(2,j.Inject(exports.SheetSkeletonManagerService)),kn(3,j.Inject(j.Injector))],exports.SelectionRenderService);const Ze=j.createIdentifier("deprecated.univer.sheet.selection-render-service");var Qs=Object.defineProperty,ea=Object.getOwnPropertyDescriptor,ta=(i,e,t,n)=>{for(var r=n>1?void 0:n?ea(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&Qs(e,t,r),r},Pt=(i,e)=>(t,n)=>e(t,n,i);const na=1e4,On=j.createIdentifier("univer.mark-selection-service");exports.MarkSelectionService=class extends l.Disposable{constructor(t,n,r,o,s,a,c){super();v(this,"_shapeMap",new Map);this._currentService=t,this._renderManagerService=n,this._selectionRenderService=r,this._commandService=o,this._sheetSkeletonManagerService=s,this._themeService=a,this._selectionManagerService=c}addShape(t,n=[],r=na){const o=this._currentService.getCurrentUniverSheetInstance(),s=o.getActiveSheet().getSheetId(),a=l.Tools.generateRandomId();return this._shapeMap.set(a,{selection:t,subUnitId:s,unitId:o.getUnitId(),zIndex:r,control:null,exits:n}),this.refreshShapes(),a}refreshShapes(){const t=this._currentService.getCurrentUniverSheetInstance().getUnitId(),n=this._currentService.getCurrentUniverSheetInstance().getActiveSheet().getSheetId();this._shapeMap.forEach(r=>{var w;const{unitId:o,subUnitId:s,selection:a,control:c,zIndex:d}=r;if(c&&c.dispose(),o!==t||s!==n)return;const{style:u}=a,{scene:h}=this._renderManagerService.getRenderById(o)||{},{rangeWithCoord:m,primaryWithCoord:g}=this._selectionRenderService.convertSelectionRangeToData(a),_=(w=this._sheetSkeletonManagerService.getCurrent())==null?void 0:w.skeleton;if(!h||!_)return;const{rowHeaderWidth:f,columnHeaderHeight:C}=_,I=new Ci(h,d,!1,this._themeService);I.update(m,f,C,u,g),r.control=I})}getShapeMap(){return this._shapeMap}removeShape(t){const n=this._shapeMap.get(t);if(!n)return;const{control:r}=n;r&&r.dispose(),this._shapeMap.delete(t)}removeAllShapes(){for(const t of this._shapeMap.values()){const{control:n}=t;n&&n.dispose()}this._shapeMap.clear()}};exports.MarkSelectionService=ta([Pt(0,l.IUniverInstanceService),Pt(1,y.IRenderManagerService),Pt(2,Ze),Pt(3,l.ICommandService),Pt(4,j.Inject(exports.SheetSkeletonManagerService)),Pt(5,j.Inject(l.ThemeService)),Pt(6,j.Inject(p.SelectionManagerService))],exports.MarkSelectionService);const ia=10,ra=6;function oa(){return l.Tools.generateRandomId(ra)}function sa(i){const e=i.match(/data-copy-id="([^\s]+)"/);return e&&e[1]?e[1]:null}class aa{constructor(){v(this,"_cache",new l.LRUMap(ia))}set(e,t){this._cache.set(e,t)}get(e){return this._cache.get(e)}del(e){this._cache.delete(e)}clear(){this._cache.clear()}}const Vn=new aa;var Vt=(i=>(i.COPY="COPY",i.CUT="CUT",i))(Vt||{});function la(i,e,t,n,r){const o=[],s=[];if(n.copyType===Vt.CUT){const{undos:a,redos:c}=ca(i,e,r);o.push(...c),s.push(...a)}else{const{undos:a,redos:c}=bo(e,t,r);o.push(...c),s.push(...a);const{undos:d,redos:u}=Ro(e,t,r);o.push(...u),s.push(...d);const{undos:h,redos:m}=Io(e,t,r);o.push(...m),s.push(...h);const{undos:g,redos:_}=Ki(e,t,r);o.push(..._),s.push(...g)}return{undos:s,redos:o}}function ca(i,e,t){let n=[],r=[];const{range:o,subUnitId:s,unitId:a}=i,{range:c,subUnitId:d}=e;if(o&&c){const u=t.get(l.IUniverInstanceService),h=t.get(p.SheetInterceptorService),m=u.getUniverSheetInstance(a),g=m==null?void 0:m.getSheetBySheetId(s),_=m==null?void 0:m.getSheetBySheetId(d);if(g&&_){const f=new l.ObjectMatrix,C=new l.ObjectMatrix,I=(q,ae)=>({startRow:q,endRow:q,startColumn:ae,endColumn:ae}),w=g.getCellMatrix(),E=_.getCellMatrix();l.Range.foreach(o,(q,ae)=>{f.setValue(q,ae,w.getValue(q,ae)),C.setValue(q,ae,null)});const O=new l.ObjectMatrix;l.Range.foreach(c,(q,ae)=>{O.setValue(q,ae,E.getValue(q,ae))});const x=new l.ObjectMatrix;l.Range.foreach(o,(q,ae)=>{const Ie=I(q,ae),de=l.Rectangle.getRelativeRange(Ie,o),Ee=l.Rectangle.getPositionRange(de,c);x.setValue(Ee.startRow,Ee.startColumn,w.getValue(q,ae))});const N={from:{value:C.getMatrix(),subUnitId:s},to:{value:x.getMatrix(),subUnitId:d},unitId:a},D={from:{value:f.getMatrix(),subUnitId:s},to:{value:O.getMatrix(),subUnitId:d},unitId:a},P=h.onCommandExecute({id:p.MoveRangeCommand.id,params:{toRange:c,fromRange:o}}),L=g.getMergeData(),G=_.getMergeData(),k=L.filter(q=>l.Rectangle.intersects(q,o)),ee=G.filter(q=>l.Rectangle.intersects(q,c)),te=k.map(q=>l.Rectangle.getRelativeRange(q,o)).map(q=>l.Rectangle.getPositionRange(q,c)),W=p.getAddMergeMutationRangeByType(te).filter(q=>!G.some(ae=>l.Rectangle.equals(q,ae))),V=[{id:p.RemoveWorksheetMergeMutation.id,params:{unitId:a,subUnitId:s,ranges:k}},{id:p.RemoveWorksheetMergeMutation.id,params:{unitId:a,subUnitId:s,ranges:ee}},{id:p.AddWorksheetMergeMutation.id,params:{unitId:a,subUnitId:d,ranges:W}}],re=[{id:p.RemoveWorksheetMergeMutation.id,params:{unitId:a,subUnitId:d,ranges:W}},{id:p.AddWorksheetMergeMutation.id,params:{unitId:a,subUnitId:d,ranges:ee}},{id:p.AddWorksheetMergeMutation.id,params:{unitId:a,subUnitId:s,ranges:k}}];n=[{id:p.MoveRangeMutation.id,params:N},...P.redos,...V,{id:p.SetSelectionsOperation.id,params:{unitId:a,sheetId:d,pluginName:p.NORMAL_SELECTION_PLUGIN_NAME,selections:[{range:c}]}}],r=[{id:p.SetSelectionsOperation.id,params:{unitId:a,sheetId:s,pluginName:p.NORMAL_SELECTION_PLUGIN_NAME,selections:[{range:o}]}},...P.undos,...re,{id:p.MoveRangeMutation.id,params:D}]}}return{undos:r,redos:n}}function Ro(i,e,t){const{unitId:n,subUnitId:r,range:o}=i,s=[],a=[],{startColumn:c,startRow:d}=o,u=new l.ObjectMatrix;e.forValue((g,_,f)=>{u.setValue(g+d,_+c,{v:f.v})});const h={unitId:n,subUnitId:r,cellValue:u.getData()};s.push({id:p.SetRangeValuesMutation.id,params:h});const m=p.SetRangeValuesUndoMutationFactory(t,h);return a.push({id:p.SetRangeValuesMutation.id,params:m}),{undos:a,redos:s}}function Io(i,e,t){const n=[],r=[],{unitId:o,subUnitId:s,range:a}=i,{startColumn:c,startRow:d}=a,u=new l.ObjectMatrix;e.forValue((g,_,f)=>{var I;const C={s:f.s};(I=f.p)!=null&&I.body&&(C.p=f.p),u.setValue(g+d,_+c,C)});const h={unitId:o,subUnitId:s,cellValue:u.getData()};n.push({id:p.SetRangeValuesMutation.id,params:h});const m=p.SetRangeValuesUndoMutationFactory(t,h);return r.push({id:p.SetRangeValuesMutation.id,params:m}),{undos:r,redos:n}}function bo(i,e,t){const n=[],r=[],o=new l.ObjectMatrix,{unitId:s,subUnitId:a,range:c}=i,{startColumn:d,startRow:u}=c;if(e.forValue((h,m,g)=>{g.s&&o.setValue(h+u,m+d,{s:null})}),o.getLength()>0){const h={subUnitId:a,unitId:s,cellValue:o.getData()};n.push({id:p.SetRangeValuesMutation.id,params:h});const m=p.SetRangeValuesUndoMutationFactory(t,h);r.push({id:p.SetRangeValuesMutation.id,params:m})}return{undos:r,redos:n}}function Ki(i,e,t){const n=[],r=[],{unitId:o,subUnitId:s,range:a}=i,{startColumn:c,startRow:d,endColumn:u,endRow:h}=a;let m=!1;const g=[];if(e.forValue((C,I,w)=>{if(w.rowSpan){const E=w.colSpan||1,O={startRow:d+C,endRow:d+C+w.rowSpan-1,startColumn:c+I,endColumn:c+I+E-1};g.push(O),m=!0}else if(w.colSpan){const E=w.rowSpan||1,O={startRow:d+C,endRow:d+C+E-1,startColumn:c+I,endColumn:c+I+w.colSpan-1};g.push(O),m=!0}}),m){const I=t.get(l.IUniverInstanceService).getUniverSheetInstance(o),w=I==null?void 0:I.getSheetBySheetId(s);if(I&&w){const O=w.getMergeData().filter(D=>l.Rectangle.intersects({startRow:d,startColumn:c,endRow:h,endColumn:u},D)),x={unitId:o,subUnitId:s,ranges:O};n.push({id:p.RemoveWorksheetMergeMutation.id,params:x});const N=p.RemoveMergeUndoMutationFactory(t,x);r.push({id:p.AddWorksheetMergeMutation.id,params:N})}}const _={unitId:o,subUnitId:s,ranges:g};n.push({id:p.AddWorksheetMergeMutation.id,params:_});const f=p.AddMergeUndoMutationFactory(t,_);return r.push({id:p.RemoveWorksheetMergeMutation.id,params:f}),{undos:r,redos:n}}function Mo(i){let e=i.replace(/(\r\n|\n)/g,"\r");e.endsWith(`\r
2
+ `)||(e+=`\r
3
+ `);const t=[];for(let n=0;n<e.length;n++)e[n]==="\r"&&t.push({startIndex:n});return{dataStream:e,paragraphs:t,sectionBreaks:[{startIndex:e.indexOf(`
4
+ `)}]}}function da(i){const e=new DOMParser,t=`<x-univer id="univer-root">${i}</x-univer>`;return e.parseFromString(t,"text/html").querySelector("#univer-root")}function ua(i){const e=i.style,t={};for(let n=0;n<e.length;n++){const r=e[n],o=e.getPropertyValue(r);switch(r){case"margin-top":{const s=parseInt(o);t.spaceAbove=/pt/.test(o)?qi(s):s;break}case"margin-bottom":{const s=parseInt(o);t.spaceBelow=/pt/.test(o)?qi(s):s;break}}}return Object.getOwnPropertyNames(t).length?t:null}function qi(i){return i/.75}function Ur(i,e){const t=[];for(let n=0,r=i.length;n<r;n++)i[n]===l.DataStreamTreeTokenType.PARAGRAPH&&t.push({startIndex:n});if(e)for(const n of t)e.bullet&&(n.bullet=l.Tools.deepClone(e.bullet)),e.paragraphStyle&&(n.paragraphStyle=l.Tools.deepClone(e.paragraphStyle));return t}function sr(i){const e=i.style,t={},n=i.tagName.toLowerCase();switch(n){case"b":case"em":case"strong":{t.bl=l.BooleanNumber.TRUE;break}case"s":{t.st={s:l.BooleanNumber.TRUE};break}case"u":{t.ul={s:l.BooleanNumber.TRUE};break}case"i":{t.it=l.BooleanNumber.TRUE;break}case"sub":case"sup":{t.va=n==="sup"?l.BaselineOffset.SUPERSCRIPT:l.BaselineOffset.SUBSCRIPT;break}}for(let r=0;r<e.length;r++){const o=e[r],s=e.getPropertyValue(o);switch(o){case"font-family":{t.ff=s;break}case"font-size":{const a=parseInt(s);Number.isNaN(a)||(t.fs=/pt$/.test(s)?qi(a):a);break}case"font-style":{s==="italic"&&(t.it=l.BooleanNumber.TRUE);break}case"font-weight":{Number(s)>400&&(t.bl=l.BooleanNumber.TRUE);break}case"text-decoration":{/underline/.test(s)?t.ul={s:l.BooleanNumber.TRUE}:/overline/.test(s)?t.ol={s:l.BooleanNumber.TRUE}:/line-through/.test(s)&&(t.st={s:l.BooleanNumber.TRUE});break}case"color":{const a=new l.ColorKit(s);a.isValid&&(t.cl={rgb:a.toRgbString()});break}case"background-color":{const a=new l.ColorKit(s);a.isValid&&(t.bg={rgb:a.toRgbString()});break}}}return t}function kr(i,e){const t=i.tagName.toLowerCase();return typeof e=="string"?t===e:Array.isArray(e)?e.some(n=>n===t):e(i)}const Mi=class Mi{constructor(e){v(this,"styleCache",new Map);v(this,"styleRules",[]);v(this,"afterProcessRules",[]);v(this,"getCurrentSkeleton");this.getCurrentSkeleton=e.getCurrentSkeleton}static use(e){if(this.pluginList.includes(e))throw new Error(`Univer paste plugin ${e.name} already added`);this.pluginList.push(e)}convert(e){const t=Mi.pluginList.find(m=>m.checkPasteType(e));t&&(this.styleRules=[...t.stylesRules],this.afterProcessRules=[...t.afterProcessRules]);const n=new l.ObjectMatrix,r=da(e),o={dataStream:"",textRuns:[]},s=[],a=e.match(/<table\b[^>]*>([\s\S]*?)<\/table>/gi),c=[];this.process(null,r==null?void 0:r.childNodes,o,c);const{paragraphs:d,dataStream:u,textRuns:h}=o;if(d){const m=d.map(g=>g.startIndex+1);m.unshift(0);for(let g=0;g<m.length;g++){let _;g===m.length-1?_=`${u.substring(m[g])}\r
5
+ `:_=`${u.substring(m[g],m[g+1]-1)}\r
6
+ `;const f=[];h==null||h.forEach(I=>{I.st>=m[g]&&I.ed<=m[g+1]&&f.push({st:I.st-m[g],ed:I.ed-m[g],ts:I.ts})});const C=this._generateDocumentDataModelSnapshot({body:{dataStream:_,textRuns:f,paragraphs:Ur(_)}});n.setValue(n.getLength(),0,{v:_,p:C}),s.push({}),a&&c.forEach(I=>{const w=n.getDataRange().endRow+1;if(I.index===g){const E=a.shift(),{cellMatrix:O,colProperties:x,rowProperties:N}=this._parseTable(E);O&&O.forValue((D,P,L)=>{n.setValue(w+D,P,L)}),s.push(...N)}})}}else{if(u){const m=`${u}\r
7
+ `,g={dataStream:m,textRuns:h,paragraphs:Ur(m)},_=this._generateDocumentDataModelSnapshot({body:g});n.setValue(0,0,{v:u,p:_}),s.push({})}a&&a.forEach(m=>{const g=n.getDataRange().endRow+1,{cellMatrix:_}=this._parseTable(m);_&&_.forValue((f,C,I)=>{const{rowSpan:w=1,colSpan:E=1}=I;for(let O=0;O<w;O++)for(let x=0;x<E;x++)n.setValue(g+f+O,C+x,{v:""});n.setValue(g+f,C,I)}),s.push(...s)})}return{rowProperties:[],colProperties:[],cellMatrix:n}}_parseTable(e){const t=new l.ObjectMatrix;ga(e);const{rowProperties:n,rowCount:r,cellMatrix:o}=ha(e);return o&&o.forValue((s,a,c)=>{var u;const d=R.handleStringToStyle(void 0,(u=c.properties)==null?void 0:u.style);if(/\r|\n/.test(c.content)){const h=Mo(c.content),m=this._generateDocumentDataModelSnapshot({body:h});t.setValue(s,a,{v:c.content,p:m,s:d,rowSpan:c.rowSpan,colSpan:c.colSpan})}else t.setValue(s,a,{v:c.content,s:d,rowSpan:c.rowSpan,colSpan:c.colSpan})}),{rowProperties:[],colProperties:[],cellMatrix:t}}_generateDocumentDataModelSnapshot(e){var a;const t=this.getCurrentSkeleton();if(t==null)return null;const{skeleton:n}=t,r=(a=n.getBlankCellDocumentModel())==null?void 0:a.documentModel,s={...r==null?void 0:r.getSnapshot(),...e};return r==null||r.reset(s),r==null?void 0:r.getSnapshot()}process(e,t,n,r){var o,s;for(const a of t)if(a.nodeName.toLowerCase()==="table")r.push({index:((o=n==null?void 0:n.paragraphs)==null?void 0:o.length)||0});else if(a.nodeType===Node.TEXT_NODE){const c=(s=a.nodeValue)==null?void 0:s.replace(/[\r\n]/g,"");let d;e&&this.styleCache.has(e)&&(d=this.styleCache.get(e));const u={dataStream:"",textRuns:[]};n.dataStream+=c,u.dataStream+=c,d&&Object.getOwnPropertyNames(d).length&&(n.textRuns.push({st:n.dataStream.length-c.length,ed:n.dataStream.length,ts:d}),u.textRuns.push({st:n.dataStream.length-c.length,ed:n.dataStream.length,ts:d}))}else if(a.nodeType===Node.ELEMENT_NODE){const c=e?this.styleCache.get(e):{},d=this.styleRules.find(({filter:g})=>kr(a,g)),u=d?d.getStyle(a):sr(a);this.styleCache.set(a,{...c,...u});const{childNodes:h}=a;this.process(a,h,n,r);const m=this.afterProcessRules.find(({filter:g})=>kr(a,g));m&&m.handler(n,a)}}};v(Mi,"pluginList",[]);let Mn=Mi;function ha(i){const e=/<tr([\s\S]*?)>([\s\S]*?)<\/tr>/gi,t=i.matchAll(e);if(!t)return{rowProperties:[],rowCount:0,colCount:0,cellMatrix:null};const n=Array.from(t),r=n.map(a=>ar(a[1])),{colCount:o,cellMatrix:s}=ma(n.map(a=>a[2]));return{rowProperties:r,rowCount:r.length,colCount:o,cellMatrix:s}}function ma(i){const e=new l.ObjectMatrix,t=new Map,n=/<td([\s\S]*?)>([\s\S]*?)<\/td>/gi;let r=0,o=0,s=0;return i.forEach((a,c)=>{const d=c===0,u=a.matchAll(n);o=0,Array.from(u).forEach(h=>{const m=ar(h[1]),g=_a(h[2].replace("<br>","\r").replace(/<\/?[^>]*>/g,"")),_=m.rowspan?+m.rowspan:1,f=m.colspan?+m.colspan:1;if(!d){for(let I=o;I<r;I++)if(!(t.get(I)>=s)){o=I;break}}const C={content:g,properties:m};f>1&&(C.colSpan=+f),_>1&&(C.rowSpan=+_),d&&(r+=f);for(let I=o;I<o+f;I++)t.set(I,s+_-1);e.setValue(s,o,C),o+=f}),s+=1}),{colCount:r,cellMatrix:e}}function ar(i){if(!i)return{};const e=/([\w-]+)="([^"]*)"/gi,t=i.matchAll(e),n={};return Array.from(t).forEach(r=>{const[o,s,a]=r;n[s]=a}),n}function ga(i){const e=/<colgroup([\s\S]*?)>(.*?)<\/colgroup>/,t=i.match(e);if(!t||!t[2])return null;const n=/<col([\s\S]*?)>/g,r=t[2].matchAll(n);return r?Array.from(r).map(o=>ar(o[1])):null}function _a(i){const e={"&lt;":"<","&gt;":">","&amp;":"&","&quot;":'"',"&#39;":"'","&nbsp;":" "};return i.replace(/&lt;|&gt;|&amp;|&quot;|&#39;|&nbsp;|<br>/g,t=>e[t])}const pa={name:"univer-doc-paste-plugin-lark",checkPasteType(i){return/lark-record-clipboard/i.test(i)},stylesRules:[{filter:["s"],getStyle(i){const e=sr(i);return{st:{s:l.BooleanNumber.TRUE},...e}}}],afterProcessRules:[{filter(i){return i.tagName==="DIV"&&/ace-line/i.test(i.className)},handler(i){i.paragraphs==null&&(i.paragraphs=[]),i.paragraphs.push({startIndex:i.dataStream.length}),i.dataStream+="\r"}}]},fa=pa,Sa={name:"univer-doc-paste-plugin-word",checkPasteType(i){return/word|mso/i.test(i)},stylesRules:[{filter:["b"],getStyle(i){const e=sr(i);return{bl:l.BooleanNumber.TRUE,...e}}}],afterProcessRules:[{filter(i){return i.tagName==="P"&&/mso/i.test(i.className)},handler(i,e){i.paragraphs==null&&(i.paragraphs=[]);const t={startIndex:i.dataStream.length},n=ua(e);n&&(t.paragraphStyle=n),i.paragraphs.push(t),i.dataStream+="\r"}}]},va=Sa;function Ca(i,e,t,n){const r=t.map(c=>{var d;return(d=c.onCopyRow)==null?void 0:d.call(c,i)}).filter(c=>!!c),o=lr(r),s=cr(o),a=e.map(c=>Ra(i,c,t,n)).filter(c=>!!c).join("");return`<tr${s}>${a}</tr>`}function Ra(i,e,t,n){const r=n.getValue(i,e),o=t.map(d=>{var u;return(u=d.onCopyCellStyle)==null?void 0:u.call(d,i,e,r==null?void 0:r.rowSpan,r==null?void 0:r.colSpan)}).filter(d=>!!d),s=lr(o),a=cr(s),c=t.reduce((d,u)=>{var h;return d||((h=u.onCopyCellContent)==null?void 0:h.call(u,i,e))||""},"");return`<td${a}>${c}</td>`}function Ia(i,e){return`<colgroup>${i.map(n=>{const r=e.map(a=>{var c;return(c=a.onCopyColumn)==null?void 0:c.call(a,n)}).filter(a=>!!a),o=lr(r);return`<col ${cr(o)}>`}).join("")}</colgroup>`}function lr(i){return i.reduce((e,t)=>(Object.keys(t).forEach(r=>{e[r]?e[r]+=`;${t[r]}`:e[r]=t[r]}),e),{})}function cr(i){return Object.keys(i).reduce((e,t)=>(e+=` ${t}="${i[t]}"`,e),"")}function ba(i,e){const t=[];for(let n=i;n<=e;n++)t.push(n);return t}class Ma{convert(e,t,n){const{startColumn:r,endColumn:o}=t,s=Ia(ba(r,o),n),a=[],{startRow:c,endRow:d,startColumn:u,endColumn:h}=e.getDataRange();for(let g=c;g<=d;g++){const _=Array.from({length:h-u+1},(f,C)=>u+C);a.push(Ca(g,_,n,e))}return`<google-sheets-html-origin><table xmlns="http://www.w3.org/1999/xhtml" cellspacing="0" cellpadding="0" dir="ltr" border="1" style="table-layout:fixed;font-size:10pt;font-family:Arial;width:0px;border-collapse:collapse;border:none">${s}
8
+ <tbody>${a.join("")}</tbody></table>`}}var wa=Object.defineProperty,Ta=Object.getOwnPropertyDescriptor,ya=(i,e,t,n)=>{for(var r=n>1?void 0:n?Ta(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&wa(e,t,r),r},Tt=(i,e)=>(t,n)=>e(t,n,i);const Ke={DEFAULT_COPY:"default-copy",DEFAULT_PASTE:"default-paste",SPECIAL_PASTE_VALUE:"special-paste-value",SPECIAL_PASTE_FORMAT:"special-paste-format",SPECIAL_PASTE_COL_WIDTH:"special-paste-col-width",SPECIAL_PASTE_BESIDES_BORDER:"special-paste-besides-border"};Mn.use(va);Mn.use(fa);const nn=j.createIdentifier("sheet.clipboard-service");exports.SheetClipboardService=class extends l.Disposable{constructor(t,n,r,o,s,a,c,d){super();v(this,"_clipboardHooks",[]);v(this,"_clipboardHooks$",new J.BehaviorSubject([]));v(this,"clipboardHooks$",this._clipboardHooks$.asObservable());v(this,"_htmlToUSM");v(this,"_usmToHtml");v(this,"_copyMarkId",null);v(this,"_pasteType",Ke.DEFAULT_PASTE);this._logService=t,this._currentUniverService=n,this._selectionManagerService=r,this._clipboardInterfaceService=o,this._undoRedoService=s,this._commandService=a,this._markSelectionService=c,this._sheetSkeletonManagerService=d,this._htmlToUSM=new Mn({getCurrentSkeleton:()=>this._sheetSkeletonManagerService.getCurrent()}),this._usmToHtml=new Ma}async copy(t=Vt.COPY){const n=this._selectionManagerService.getLast();if(!n)return!1;const r=this._clipboardHooks;r.reduce((I,w)=>{var O;const E=(O=w.getFilteredOutRows)==null?void 0:O.call(w);return E==null||E.forEach(x=>I.add(x)),I},new Set);const{startColumn:o,startRow:s,endColumn:a,endRow:c}=n.range,d=this._currentUniverService.getCurrentUniverSheetInstance(),u=d.getActiveSheet(),h=u.getMatrixWithMergedCells(s,o,c,a),m=new l.ObjectMatrix;for(let I=s;I<=c;I++)for(let w=o;w<=a;w++){const E=h.getValue(I,w);E?m.setValue(I-s,w-o,{...Vr(),...l.Tools.deepClone(E)}):m.setValue(I-s,w-o,Vr())}r.forEach(I=>{var w;return(w=I.onBeforeCopy)==null?void 0:w.call(I,d.getUnitId(),u.getSheetId(),n.range)});let g=this._usmToHtml.convert(h,n.range,r);const _=Ea(m),f=oa();g=g.replace(/(<[a-z]+)/,(I,w)=>`${w} data-copy-id="${f}"`),Vn.set(f,{unitId:d.getUnitId(),subUnitId:u.getSheetId(),range:n.range,matrix:m,copyType:t}),await this._clipboardInterfaceService.write(_,g),this._markSelectionService.removeAllShapes();const C=this._selectionManagerService.createCopyPasteSelection();return this._copyMarkId=this._markSelectionService.addShape({...n,style:C}),r.forEach(I=>{var w;return(w=I.onAfterCopy)==null?void 0:w.call(I)}),!0}async cut(){return this.copy(Vt.CUT)}async paste(t,n=Ke.DEFAULT_PASTE){const r=t.types,o=r.indexOf(R.PLAIN_TEXT_CLIPBOARD_MIME_TYPE)!==-1?await t.getType(R.PLAIN_TEXT_CLIPBOARD_MIME_TYPE).then(a=>a&&a.text()):"",s=r.indexOf(R.HTML_CLIPBOARD_MIME_TYPE)!==-1?await t.getType(R.HTML_CLIPBOARD_MIME_TYPE).then(a=>a&&a.text()):"";return s?this._pasteHTML(s,n):o?this._pastePlainText(o,n):(this._logService.error("[SheetClipboardService]","No valid data on clipboard"),!1)}addClipboardHook(t){if(this._clipboardHooks.findIndex(r=>r.id===t.id)!==-1)return this._logService.error("[SheetClipboardService]","hook already exists",t.id),{dispose:()=>{}};const n=this._clipboardHooks.findIndex(r=>{const o=r.priority||0;return(t.priority||0)<o});return this._clipboardHooks.splice(n!==-1?n:this._clipboardHooks.length,0,t),this._notifyClipboardHook(),l.toDisposable(()=>{const r=this._clipboardHooks.indexOf(t);r>-1&&(this._clipboardHooks.splice(r,1),this._notifyClipboardHook())})}getClipboardHooks(){return this._clipboardHooks}_notifyClipboardHook(){this._clipboardHooks$.next(this._clipboardHooks)}async _pastePlainText(t,n){const r=this._getPastingTarget();if(!r.selection)return!1;const o=r.selection.range,{unitId:s,subUnitId:a}=r,c=this._clipboardHooks,d=[];if(c.some(_=>{var f;return d.push(_)&&((f=_.onBeforePaste)==null?void 0:f.call(_,{unitId:s,subUnitId:a,range:o}))===!1}))return d.forEach(_=>{var f;return(f=_.onAfterPaste)==null?void 0:f.call(_,!1)}),!1;const h=[],m=[];d.forEach(_=>{var C;const f=(C=_.onPastePlainText)==null?void 0:C.call(_,{unitId:s,subUnitId:a,range:o},t,{pasteType:n});f&&(h.push(...f.redos),m.push(...f.undos))});const g=h.every(_=>this._commandService.executeCommand(_.id,_.params));return g&&this._undoRedoService.pushUndoRedo({unitID:this._currentUniverService.getCurrentUniverSheetInstance().getUnitId(),undoMutations:m,redoMutations:h}),g}async _pasteHTML(t,n){const r=sa(t);return r&&Vn.get(r)?this._pasteInternal(r,n):this._pasteExternal(t,n)}async _pasteExternal(t,n){const r=this._getPastingTarget(),{selection:o,unitId:s,subUnitId:a}=r;if(!o)return!1;const{rowProperties:c,colProperties:d,cellMatrix:u}=this._htmlToUSM.convert(t),{startColumn:h,endColumn:m,startRow:g,endRow:_}=u.getDataRange(),f=_-g+1,C=m-h+1;if(!u||m<h||_<g)return!1;const I=this._transformPastedData(f,C,u,o.range);return I?this._pasteUSM({rowProperties:c,colProperties:d,cellMatrix:u},{unitId:s,subUnitId:a,pastedRange:I},n):!1}async _pasteInternal(t,n){var P,L;const r=this._getPastingTarget(),{selection:o,unitId:s,subUnitId:a}=r,c=l.Tools.deepClone(Vn.get(t)),{range:d,matrix:u,unitId:h,subUnitId:m}=c||{};if(!o||!u||!c||!d||!h||!m||!o||!u||!c)return!1;const g=(P=this._currentUniverService.getUniverSheetInstance(h))==null?void 0:P.getStyles();u.forValue((G,k,ee)=>{if(typeof ee.s=="string"){const te=l.Tools.deepClone(ee);te.s=g==null?void 0:g.getStyleByCell(ee),u.setValue(G,k,te)}});const{startColumn:_,endColumn:f,startRow:C,endRow:I}=d,w=this._transformPastedData(I-C+1,f-_+1,u,o.range);if(!w)return!1;const E=(L=this._currentUniverService.getUniverSheetInstance(h))==null?void 0:L.getSheetBySheetId(m);if(!E)return!1;const O=E.getColumnManager(),x=E.getConfig().defaultColumnWidth,N=[];for(let G=_;G<=f;G++){const k=O.getColumnOrCreate(G);N.push({width:`${k.w||x}`})}const D=this._pasteUSM({cellMatrix:u,colProperties:N},{unitId:s,subUnitId:a,pastedRange:w},n,{range:d,unitId:c.unitId,subUnitId:c.subUnitId,copyType:c.copyType,copyId:t});return c.copyType===Vt.CUT&&(Vn.del(t),this._copyMarkId&&this._markSelectionService.removeShape(this._copyMarkId),this._copyMarkId=null),D}_pasteUSM(t,n,r,o){const{rowProperties:s,colProperties:a,cellMatrix:c}=t,{unitId:d,subUnitId:u,pastedRange:h}=n,{startColumn:m,endColumn:g}=h,_=g-m+1,f=this._clipboardHooks,C=[];if(f.some(L=>{var G;return C.push(L)&&((G=L.onBeforePaste)==null?void 0:G.call(L,{unitId:d,subUnitId:u,range:h}))===!1}))return C.forEach(L=>{var G;return(G=L.onAfterPaste)==null?void 0:G.call(L,!1)}),!1;if(!c)return!1;const w=o?{unitId:o.unitId,subUnitId:o.subUnitId,range:o.range}:null,E={copyType:(o==null?void 0:o.copyType)||Vt.COPY,copyId:o==null?void 0:o.copyId,pasteType:r},O=[],x=[];C.filter(L=>!L.specialPasteInfo&&L.id!==Ke.DEFAULT_PASTE||r===L.id).forEach(L=>{var ee,te,W;if(s){const V=(ee=L.onPasteRows)==null?void 0:ee.call(L,{range:h,unitId:d,subUnitId:u},s,{pasteType:r});V&&(O.push(...V.redos),x.push(...V.undos))}const G=(te=L.onPasteColumns)==null?void 0:te.call(L,{range:h,unitId:d,subUnitId:u},a||new Array(_).map(()=>({})),{pasteType:r});G&&(O.push(...G.redos),x.push(...G.undos));const k=(W=L.onPasteCells)==null?void 0:W.call(L,w,{range:h,unitId:d,subUnitId:u},c,E);k&&(O.push(...k.redos),x.push(...k.undos))});const D=this._getSetSelectionOperation(d,u,h,c);D&&O.push(D),this._logService.log("[SheetClipboardService]","pasting mutations",{undoMutationsInfo:x,redoMutationsInfo:O});const P=O.every(L=>this._commandService.executeCommand(L.id,L.params));return P&&this._undoRedoService.pushUndoRedo({unitID:d,undoMutations:x,redoMutations:O}),P}_getSetSelectionOperation(t,n,r,o){var f;const s=(f=this._currentUniverService.getUniverSheetInstance(t))==null?void 0:f.getSheetBySheetId(n);if(!s)return null;const{startRow:a,startColumn:c}=r,d={startRow:a,endRow:a,startColumn:c,endColumn:c},u=p.getPrimaryForRange(d,s),h=o.getValue(0,0),m=(h==null?void 0:h.rowSpan)||1,g=(h==null?void 0:h.colSpan)||1;if(m>1||g>1){const C={startRow:a,endRow:a+m-1,startColumn:c,endColumn:c+g-1};u.startRow=C.startRow,u.endRow=C.endRow,u.startColumn=C.startColumn,u.endColumn=C.endColumn,u.isMerged=!0,u.isMergedMainCell=!0}const _={unitId:t,subUnitId:n,pluginName:p.NORMAL_SELECTION_PLUGIN_NAME,selections:[{range:r,primary:u,style:null}]};return{id:p.SetSelectionsOperation.id,params:_}}_getPastingTarget(){const t=this._currentUniverService.getCurrentUniverSheetInstance(),n=t.getActiveSheet(),r=this._selectionManagerService.getLast();return{unitId:t.getUnitId(),subUnitId:n.getSheetId(),selection:r}}_transformPastedData(t,n,r,o){const{startRow:s,startColumn:a,endRow:c,endColumn:d}=o,u=c-s+1,h=d-a+1,f=this._currentUniverService.getCurrentUniverSheetInstance().getActiveSheet().getMergeData().filter(x=>l.Rectangle.intersects({startRow:s,startColumn:a,endRow:c,endColumn:d},x)),C=f[0];let I=0,w=0,E=0,O=0;if(C&&(I=C.startRow,w=C.startColumn,E=C.endRow,O=C.endColumn),u%t===0&&h%n===0)if(f.length>0&&(u!==t||h!==n))if(I===s&&w===a&&E===c&&O===d)if(Da(r))for(let N=0;N<u;N++)for(let D=0;D<h;D++){const P=r.getValue(N%t,D%n);P&&r.setValue(N,D,P)}else r.forValue((N,D,P)=>{P.s=null,delete P.colSpan,delete P.rowSpan});else for(let x=0;x<u;x++)for(let N=0;N<h;N++){const D=r.getValue(x%t,N%n);D&&r.setValue(x,N,D)}else for(let x=0;x<u;x++)for(let N=0;N<h;N++){const D=r.getValue(x%t,N%n);D&&r.setValue(x,N,D)}else if(f.length>0)if(this._topLeftCellsMatch(t,n,o))o.endRow=s+t-1,o.endColumn=a+n-1;else{if(c>C.endRow||d>C.endColumn)return null;r.forValue((N,D,P)=>{P.s=null,delete P.colSpan,delete P.rowSpan})}else o.endRow=s+t-1,o.endColumn=a+n-1;return o}_topLeftCellsMatch(t,n,r){const s=this._currentUniverService.getCurrentUniverSheetInstance().getActiveSheet(),{startRow:a,startColumn:c,endRow:d,endColumn:u}=r,h=Aa(a+t-1,c,c+t-1,s),m=Na(c+n-1,a,a+t-1,s);return!h&&!m}};exports.SheetClipboardService=ya([Tt(0,l.ILogService),Tt(1,l.IUniverInstanceService),Tt(2,j.Inject(p.SelectionManagerService)),Tt(3,R.IClipboardInterfaceService),Tt(4,l.IUndoRedoService),Tt(5,l.ICommandService),Tt(6,On),Tt(7,j.Inject(exports.SheetSkeletonManagerService))],exports.SheetClipboardService);function Ea(i){let e="";return i.forRow((t,n)=>{const r=[];n.forEach(o=>{const s=i.getValue(t,o);if(s){const a=Oa(s);r.push(a)}}),e+=r.join(" "),t!==i.getLength()-1&&(e+=`
9
+ `)}),e}function Oa(i){const e=i.v;return xa((e==null?void 0:e.toString())||"")}const xa=i=>i.replace(/&/g,"&amp;").replace(/\ufeff/g,"").replace(/</g,"&lt;").replace(/>/g,"&gt;");function Aa(i,e,t,n){return n.getMergeData().some(r=>r.startRow<=i&&i<r.endRow&&e<=r.startColumn&&r.startColumn<=t)}function Na(i,e,t,n){return n.getMergeData().some(r=>r.startColumn<=i&&i<r.endColumn&&e<=r.startRow&&r.startRow<=t)}function Da(i){let e=0;return i.forValue((t,n,r)=>{if(r&&e++,e>1)return!1}),e>1}function Vr(){return{p:null,v:null,s:null,f:null,si:null,t:null}}const wo={id:R.CopyCommand.id,name:"sheet.command.copy",type:l.CommandType.COMMAND,multi:!0,priority:1e3,preconditions:ye,handler:async i=>i.get(nn).copy()},Pa={id:R.CutCommand.id,name:"sheet.command.cut",type:l.CommandType.COMMAND,multi:!0,priority:1e3,preconditions:ye,handler:async i=>i.get(nn).cut()},rn={id:R.PasteCommand.id,type:l.CommandType.COMMAND,multi:!0,name:"sheet.command.paste",priority:1e3,preconditions:ye,handler:async(i,e)=>{const t=i.get(l.ILogService);if(t.log("[SheetPasteCommand]","the focusing element is",document.activeElement),!document.execCommand("paste")){t.log("[SheetPasteCommand]","failed to execute paste command on the activeElement, trying to use clipboard API.");const o=await i.get(R.IClipboardInterfaceService).read(),s=i.get(nn);return o.length!==0?s.paste(o[0],e==null?void 0:e.value):!1}return!1}},To={id:"sheet.command.paste-value",type:l.CommandType.COMMAND,handler:async i=>i.get(l.ICommandService).executeCommand(rn.id,{value:Ke.SPECIAL_PASTE_VALUE})},yo={id:"sheet.command.paste-format",type:l.CommandType.COMMAND,handler:async i=>i.get(l.ICommandService).executeCommand(rn.id,{value:Ke.SPECIAL_PASTE_FORMAT})},Eo={id:"sheet.command.paste-col-width",type:l.CommandType.COMMAND,handler:async i=>i.get(l.ICommandService).executeCommand(rn.id,{value:Ke.SPECIAL_PASTE_COL_WIDTH})},Oo={id:"sheet.command.paste-besides-border",type:l.CommandType.COMMAND,handler:async i=>i.get(l.ICommandService).executeCommand(rn.id,{value:Ke.SPECIAL_PASTE_BESIDES_BORDER})};function xt(i,e,t,n,r=!0,o=1,s=!0){let a={...i};n==null&&(n={startRow:0,endRow:t.getRowCount()-1,startColumn:0,endColumn:t.getColumnCount()-1});let c;switch(e){case l.Direction.UP:for(c=i.startRow-o;c>-1&&!t.getRowVisible(c);)c-=1;c>=n.startRow?(a.startRow=c,a.endRow=c):s&&(a.startRow=n.endRow,a.endRow=n.endRow,r&&(a=xt(a,l.Direction.LEFT,t,n,!1)));break;case l.Direction.DOWN:for(c=i.endRow+o;c<t.getRowCount()&&!t.getRowVisible(c);)c+=1;c<=n.endRow?(a.startRow=c,a.endRow=c):s&&(a.startRow=n.startRow,a.endRow=n.startRow,r&&(a=xt(a,l.Direction.RIGHT,t,n,!1)));break;case l.Direction.LEFT:for(c=i.startColumn-o;c>-1&&!t.getColVisible(c);)c-=1;c>=n.startColumn?(a.startColumn=c,a.endColumn=c):s&&(a.startColumn=n.endColumn,a.endColumn=n.endColumn,r&&(a=xt(a,l.Direction.UP,t,n,!1)));break;case l.Direction.RIGHT:for(c=i.endColumn+o;c<t.getColumnCount()&&!t.getColVisible(c);)c+=1;c<=n.endColumn?(a.startColumn=c,a.endColumn=c):s&&(a.startColumn=n.startColumn,a.endColumn=n.startColumn,r&&(a=xt(a,l.Direction.DOWN,t,n,!1)));break}return a}function dr(i,e,t){const n={...i},{startRow:r,startColumn:o,endRow:s,endColumn:a}=wn(i,e,t);let c=mn(t,r,o,s,a).hasValue,d=!0,u=!0;for(;u;){if(l.Direction.UP===e){let h=n.startRow-1;for(;h>-1&&!t.getRowVisible(h);)h-=1;if(h===-1){u=!1;break}const{hasValue:m,matrix:g}=mn(t,h,n.startColumn,h,n.endColumn);if(c&&!m&&!d){u=!1;break}else{if(g.getLength()!==0){let _=h;g.forValue(f=>{_=Math.min(f,_)}),n.startRow=_}else n.startRow=h;if(n.endRow=n.startRow,!c&&m){u=!1;break}c=m,d=!1}}if(l.Direction.DOWN===e){let h=n.endRow+1;for(;h<t.getRowCount()&&!t.getRowVisible(h);)h+=1;if(h===t.getRowCount()){u=!1;break}const{hasValue:m,matrix:g}=mn(t,h,n.startColumn,h,n.endColumn);if(c&&!m&&!d){u=!1;break}else{if(g.getLength()!==0){let _=h;g.forValue((f,C,I)=>{_=Math.max(f+(I.rowSpan||1)-1,_)}),n.endRow=_}else n.endRow=h;if(n.startRow=n.endRow,!c&&m){u=!1;break}c=m,d=!1}}if(l.Direction.LEFT===e){let h=n.startColumn-1;for(;h>-1&&!t.getColVisible(h);)h-=1;if(h===-1){u=!1;break}const{hasValue:m,matrix:g}=mn(t,n.startRow,h,n.endRow,h);if(c&&!m&&!d){u=!1;break}else{if(g.getLength()!==0){let _=h;g.forValue((f,C)=>{_=Math.min(C,_)}),n.startColumn=_}else n.startColumn=h;if(n.endColumn=n.startColumn,!c&&m){u=!1;break}c=m,d=!1}}if(l.Direction.RIGHT===e){let h=n.endColumn+1;for(;h<t.getColumnCount()&&!t.getColVisible(h);)h+=1;if(h===t.getColumnCount()){u=!1;break}const{hasValue:m,matrix:g}=mn(t,n.startRow,h,n.endRow,h);if(c&&!m&&!d){u=!1;break}else{if(g.getLength()!==0){let _=h;g.forValue((f,C,I)=>{_=Math.max(C+(I.colSpan||1)-1,_)}),n.endColumn=_}else n.endColumn=h;if(n.startColumn=n.endColumn,!c&&m){u=!1;break}c=m,d=!1}}}return p.alignToMergedCellsBorders(n,t,!0)}function xo(i,e,t){return xt(i,e,t,void 0,!1,1,!1)}function Ha(i,e,t){const n=dr(i,e,t);return p.alignToMergedCellsBorders(l.Rectangle.union(n,i),t,!0)}function La(i,e,t){const n=xo(i,e,t),r={startRow:Math.min(i.startRow,n.startRow),startColumn:Math.min(i.startColumn,n.startColumn),endRow:Math.max(i.endRow,n.endRow),endColumn:Math.max(i.endColumn,n.endColumn)};return p.alignToMergedCellsBorders(l.Rectangle.union(i,r),t)}function Ua(i,e,t,n){const r=l.getReverseDirection(t),o=dr(wn(i,r,n),t,n);return t===l.Direction.UP&&o.startRow<=i.startRow?p.alignToMergedCellsBorders({...e,startColumn:i.startColumn,endColumn:i.endColumn},n,!0):t===l.Direction.DOWN&&o.endRow>=i.endRow?p.alignToMergedCellsBorders({...e,startColumn:i.startColumn,endColumn:i.endColumn},n,!0):t===l.Direction.LEFT&&o.startColumn<=i.startColumn?p.alignToMergedCellsBorders({...e,startRow:i.startRow,endRow:i.endRow},n,!0):t===l.Direction.RIGHT&&o.endColumn>=i.endColumn?p.alignToMergedCellsBorders({...e,startRow:i.startRow,endRow:i.endRow},n,!0):l.Rectangle.union(l.Rectangle.clone(e),o)}function ka(i,e,t){const n=l.getReverseDirection(e),r=wn(i,n,t),o=wn(i,e,t),s=xo(r,e,t);return p.alignToMergedCellsBorders(l.Rectangle.union(o,s),t,!1)}function Va(i,e,t){const{left:n,right:r,up:o,down:s}=e,a=t.getMaxRows(),c=t.getMaxColumns();let d=!0;const u={...i};for(;d;){if(d=!1,o&&u.startRow!==0){const h=u.startRow-1;t.getMatrixWithMergedCells(h,u.startColumn,h,u.endColumn).forValue((g,_,f)=>{f.v&&(u.startRow=Math.min(g,u.startRow),u.startColumn=Math.min(_,u.startColumn),u.endColumn=Math.max(_,u.endColumn),d=!0)})}if(s&&u.endRow!==a-1){const h=u.endRow+1;t.getMatrixWithMergedCells(h,u.startColumn,h,u.endColumn).forValue((g,_,f)=>{f.v&&(u.endRow=Math.max(g+(f.rowSpan!==void 0?f.rowSpan-1:0),u.endRow),u.startColumn=Math.min(_,u.startColumn),u.endColumn=Math.max(_,u.endColumn),d=!0)})}if(n&&u.startColumn!==0){const h=u.startColumn-1;t.getMatrixWithMergedCells(u.startRow,h,u.endRow,h).forValue((g,_,f)=>{f.v&&(u.startColumn=Math.min(_,u.startColumn),u.startRow=Math.min(g,u.startRow),u.endRow=Math.max(g,u.endRow),d=!0)})}if(r&&u.endColumn!==c-1){const h=u.endColumn+1;t.getMatrixWithMergedCells(u.startRow,h,u.endRow,h).forValue((g,_,f)=>{f.v&&(u.endColumn=Math.max(_+(f.colSpan!==void 0?f.colSpan-1:0),u.endColumn),u.startRow=Math.min(g,u.startRow),u.endRow=Math.max(g,u.endRow),d=!0)})}}return u}function Fr(i){return{startRow:0,startColumn:0,endRow:i.getRowCount()-1,endColumn:i.getColumnCount()-1,rangeType:l.RANGE_TYPE.ALL}}function wn(i,e,t){let n;switch(e){case l.Direction.UP:n={startRow:i.startRow,startColumn:i.startColumn,endRow:i.startRow,endColumn:i.endColumn,rangeType:l.RANGE_TYPE.NORMAL};break;case l.Direction.DOWN:n={startRow:i.endRow,startColumn:i.startColumn,endRow:i.endRow,endColumn:i.endColumn,rangeType:l.RANGE_TYPE.NORMAL};break;case l.Direction.LEFT:n={startRow:i.startRow,startColumn:i.startColumn,endRow:i.endRow,endColumn:i.startColumn,rangeType:l.RANGE_TYPE.NORMAL};break;case l.Direction.RIGHT:n={startRow:i.startRow,startColumn:i.endColumn,endRow:i.endRow,endColumn:i.endColumn,rangeType:l.RANGE_TYPE.NORMAL};break;default:throw new Error("Invalid direction")}return p.alignToMergedCellsBorders(n,t,!1)}function mn(i,e,t,n,r){let o=!1;const s=i.getMatrixWithMergedCells(e,t,n,r).forValue((a,c,d)=>{if(d.v)return o=!0,!1});return{hasValue:o,matrix:s}}function Ji(i,e,t){const n=l.Rectangle.clone(i);if(e==null)return n;switch(t){case l.Direction.UP:case l.Direction.DOWN:n.startColumn=n.endColumn=e.actualColumn;break;case l.Direction.LEFT:case l.Direction.RIGHT:n.startRow=n.endRow=e.actualRow;break}return n}function Fa(i,e,t){const{primary:n,range:r}=i,o=l.Rectangle.clone(r);switch(e){case l.Direction.UP:case l.Direction.DOWN:o.startRow=n.startRow,o.endRow=n.endRow;break;case l.Direction.LEFT:case l.Direction.RIGHT:o.startColumn=n.startColumn,o.endColumn=n.endColumn;break}const s=wn(o,e,t);switch(e){case l.Direction.DOWN:return r.startRow<s.startRow;case l.Direction.UP:return r.endRow>s.endRow;case l.Direction.LEFT:return s.endColumn<r.endColumn;case l.Direction.RIGHT:return s.startColumn>r.startColumn}}var gt=(i=>(i[i.moveStopeOne=0]="moveStopeOne",i[i.moveGap=1]="moveGap",i[i.moveStepPage=2]="moveStepPage",i[i.moveStepEnd=3]="moveStepEnd",i))(gt||{});const nt={id:"sheet.command.move-selection",type:l.CommandType.COMMAND,handler:async(i,e)=>{if(!e)return!1;const t=i.get(l.IUniverInstanceService).getCurrentUniverSheetInstance(),n=t.getActiveSheet(),r=i.get(p.SelectionManagerService).getLast();if(!r)return!1;const{direction:o,jumpOver:s}=e,{range:a,primary:c}=r,d=Ji(a,c,o),u=s===1?dr(d,o,n):xt(d,o,n),h=p.getCellAtRowCol(u.startRow,u.startColumn,n);return l.Rectangle.equals(h,d)?!1:(i.get(R.ShortcutExperienceService).remove({unitId:t.getUnitId(),sheetId:n.getSheetId(),keycode:R.KeyCode.TAB}),i.get(l.ICommandService).executeCommand(p.SetSelectionsOperation.id,{unitId:t.getUnitId(),subUnitId:n.getSheetId(),pluginName:p.NORMAL_SELECTION_PLUGIN_NAME,selections:[{range:l.Rectangle.clone(h),primary:{startRow:h.startRow,startColumn:h.startColumn,endRow:h.endRow,endColumn:h.endColumn,actualRow:u.startRow,actualColumn:u.startColumn,isMerged:h.isMerged,isMergedMainCell:h.startRow===u.startRow&&h.startColumn===u.startColumn}}]}))}},jt={id:"sheet.command.move-selection-enter-tab",type:l.CommandType.COMMAND,handler:async(i,e)=>{if(!e)return!1;const t=i.get(l.IUniverInstanceService).getCurrentUniverSheetInstance(),n=t.getActiveSheet(),r=i.get(p.SelectionManagerService).getLast(),o=t.getUnitId(),s=n.getSheetId();if(!r)return!1;const{direction:a,keycode:c}=e,{range:d,primary:u}=r;let h=Ji(d,u,a);const m=i.get(R.ShortcutExperienceService),g=m.getCurrentBySearch({unitId:o,sheetId:s,keycode:R.KeyCode.TAB});let _;const{startRow:f,endRow:C,startColumn:I,endColumn:w}=d;if(l.Rectangle.equals(d,u)){if(c===R.KeyCode.TAB)g==null&&m.addOrUpdate({unitId:o,sheetId:s,keycode:R.KeyCode.TAB,selection:r});else{const x=g==null?void 0:g.selection;if(x!=null){const{range:N,primary:D}=x;h=Ji(N,D,a)}m.remove({unitId:o,sheetId:s,keycode:R.KeyCode.TAB})}const E=xt(h,a,n),O=p.getCellAtRowCol(E.startRow,E.startColumn,n);if(l.Rectangle.equals(O,h))return!1;_={range:l.Rectangle.clone(O),primary:{startRow:O.startRow,startColumn:O.startColumn,endRow:O.endRow,endColumn:O.endColumn,actualRow:E.startRow,actualColumn:E.startColumn,isMerged:O.isMerged,isMergedMainCell:O.startRow===E.startRow&&O.startColumn===E.startColumn}}}else{m.remove({unitId:o,sheetId:s,keycode:R.KeyCode.TAB});const E=l.Tools.deepClone(u),O=xt({startRow:E.startRow,startColumn:E.startColumn,endRow:E.endRow,endColumn:E.endColumn},a,n,{startRow:f,endRow:C,startColumn:I,endColumn:w}),x=p.getCellAtRowCol(O.startRow,O.startColumn,n);_={range:l.Rectangle.clone(d),primary:{startRow:x.startRow,startColumn:x.startColumn,endRow:x.endRow,endColumn:x.endColumn,actualRow:O.startRow,actualColumn:O.startColumn,isMerged:x.isMerged,isMergedMainCell:x.startRow===O.startRow&&x.startColumn===O.startColumn}}}return i.get(l.ICommandService).executeCommand(p.SetSelectionsOperation.id,{unitId:o,subUnitId:s,pluginName:p.NORMAL_SELECTION_PLUGIN_NAME,selections:[_]})}},_t={id:"sheet.command.expand-selection",type:l.CommandType.COMMAND,handler:async(i,e)=>{if(!e)return!1;const t=i.get(l.IUniverInstanceService).getCurrentUniverSheetInstance(),n=t.getActiveSheet(),r=i.get(p.SelectionManagerService).getLast();if(!r)return!1;const{range:o,primary:s}=r,{jumpOver:a,direction:c}=e,u=Fa(r,c,n)?a===1?Ua(o,{...l.Rectangle.clone(s),rangeType:l.RANGE_TYPE.NORMAL},c,n):ka(o,c,n):a===1?Ha(o,c,n):La(o,c,n);return l.Rectangle.equals(u,o)?!1:i.get(l.ICommandService).executeCommand(p.SetSelectionsOperation.id,{unitId:t.getUnitId(),subUnitId:n.getSheetId(),pluginName:p.NORMAL_SELECTION_PLUGIN_NAME,selections:[{range:u,primary:s}]})}};let ct=[],Hi="";const Ao={id:"sheet.command.select-all",type:l.CommandType.COMMAND,onDispose(){ct=[],Hi=""},handler:async(i,e={expandToGapFirst:!0,loop:!1})=>{const t=i.get(p.SelectionManagerService).getLast(),n=i.get(l.IUniverInstanceService).getCurrentUniverSheetInstance(),r=n.getActiveSheet();if(!t||!r)return!1;const o=`${n.getUnitId()}|${r.getSheetId()}`;o!==Hi&&(ct=[],Hi=o);const s=r.getMaxRows(),a=r.getMaxColumns(),{expandToGapFirst:c,loop:d}=e,{range:u,primary:h}=t,m=u.endColumn===a-1&&u.endRow===s-1&&u.startRow===0&&u.startColumn===0;ct.some(_=>l.Rectangle.equals(_,u))||(ct=[],ct.push(u));let g;if(m)if(d){if(ct.findIndex(f=>l.Rectangle.equals(f,u))!==ct.length-1)return!1;g=ct[0]}else return!1;else c?(g=Va(u,{left:!0,right:!0,up:!0,down:!0},r),l.Rectangle.equals(g,u)&&(g=Fr(r))):g=Fr(r);return ct.some(_=>l.Rectangle.equals(_,g))||ct.push(g),i.get(l.ICommandService).executeCommand(p.SetSelectionsOperation.id,{unitId:n.getUnitId(),subUnitId:r.getSheetId(),pluginName:p.NORMAL_SELECTION_PLUGIN_NAME,selections:[{range:g,primary:h}]})}};var Ba=Object.defineProperty,ja=Object.getOwnPropertyDescriptor,Wa=(i,e,t,n)=>{for(var r=n>1?void 0:n?ja(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&Ba(e,t,r),r},Fn=(i,e)=>(t,n)=>e(t,n,i);const za=l.createInterceptorKey("BEFORE_CELL_EDIT"),$a=l.createInterceptorKey("AFTER_CELL_EDIT");exports.EditorBridgeService=class extends l.Disposable{constructor(t,n,r,o){super();v(this,"_editorUnitId",l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY);v(this,"_isForceKeepVisible",!1);v(this,"_editorIsDirty",!1);v(this,"_visible",{visible:!1,eventType:y.DeviceInputEventType.Dblclick});v(this,"_currentEditCell",null);v(this,"_currentEditCellState",null);v(this,"_currentEditCellState$",new J.BehaviorSubject(null));v(this,"currentEditCellState$",this._currentEditCellState$.asObservable());v(this,"_visible$",new J.BehaviorSubject(this._visible));v(this,"visible$",this._visible$.asObservable());v(this,"_afterVisible$",new J.BehaviorSubject(this._visible));v(this,"afterVisible$",this._afterVisible$.asObservable());v(this,"interceptor",new l.InterceptorManager({BEFORE_CELL_EDIT:za,AFTER_CELL_EDIT:$a}));this._sheetSkeletonManagerService=t,this._selectionRenderService=n,this._themeService=r,this._currentUniverService=o,this.disposeWithMe(l.toDisposable(()=>{this._currentEditCellState$.complete(),this._currentEditCell=null})),this.disposeWithMe(l.toDisposable(this.interceptor.intercept(this.interceptor.getInterceptPoints().AFTER_CELL_EDIT,{priority:-1,handler:s=>s}))),this.disposeWithMe(l.toDisposable(this.interceptor.intercept(this.interceptor.getInterceptPoints().BEFORE_CELL_EDIT,{priority:-1,handler:s=>s})))}refreshEditCellState(){const t=this.getLatestEditCellState();this._currentEditCellState=t,this._currentEditCellState$.next(t)}setEditCell(t){this._currentEditCell=t;const n=this.getLatestEditCellState();this._currentEditCellState=n,this._currentEditCellState$.next(n)}getEditCellState(){return this._currentEditCellState}getLatestEditCellState(){var te,W;const t=this._currentEditCell;if(t==null)return;const n=this._sheetSkeletonManagerService.getCurrent();if(n==null)return;const{skeleton:r}=n,{primary:o,unitId:s,sheetId:a,scene:c,engine:d}=t,{startRow:u,startColumn:h}=o,m=this._selectionRenderService.convertCellRangeToInfo(o);if(m==null)return;const g=l.makeCellToSelection(m);if(g==null)return;const _=y.getCanvasOffsetByEngine(d);let{startX:f,startY:C,endX:I,endY:w}=g;const{scaleX:E,scaleY:O}=c.getAncestorScale(),{scaleX:x,scaleY:N}=c.getPrecisionScale(),D=c.getScrollXY(this._selectionRenderService.getViewPort());f=y.fixLineWidthByScale(r.convertTransformToOffsetX(f,E,D),x),C=y.fixLineWidthByScale(r.convertTransformToOffsetY(C,O,D),N),I=y.fixLineWidthByScale(r.convertTransformToOffsetX(I,E,D),x),w=y.fixLineWidthByScale(r.convertTransformToOffsetY(w,O,D),N);const P=this._currentUniverService.getCurrentUniverSheetInstance(),L=P.getActiveSheet(),G={workbook:P,worksheet:L,unitId:P.getUnitId(),subUnitId:L.getSheetId(),row:u,col:h},k=this.interceptor.fetchThroughInterceptors(this.interceptor.getInterceptPoints().BEFORE_CELL_EDIT)(L.getCell(u,h),G);let ee=k&&r.getCellDocumentModelWithFormula(k);if((!ee||ee.documentModel==null)&&(ee=r.getBlankCellDocumentModel(k)),(te=ee.documentModel)==null||te.setZoomRatio(Math.max(E,O)),(k==null?void 0:k.isInArrayFormulaRange)===!0){const V=(W=ee.documentModel)==null?void 0:W.getBody();V&&(V.textRuns=[{st:0,ed:V.dataStream.length-2,ts:{cl:{rgb:this._themeService.getCurrentTheme().textColorSecondary}}}])}return{position:{startX:f,startY:C,endX:I,endY:w},scaleX:E,scaleY:O,canvasOffset:_,row:u,column:h,unitId:s,sheetId:a,documentLayoutObject:ee,editorUnitId:this._editorUnitId,isInArrayFormulaRange:k==null?void 0:k.isInArrayFormulaRange}}getCurrentEditorId(){return this._editorUnitId}changeVisible(t){this._visible=t,t.visible&&(this._editorIsDirty=!1),this._visible$.next(this._visible),this._afterVisible$.next(this._visible)}isVisible(){return this._visible}enableForceKeepVisible(){this._isForceKeepVisible=!0}disableForceKeepVisible(){this._isForceKeepVisible=!1}isForceKeepVisible(){return this._isForceKeepVisible}changeEditorDirty(t){this._editorIsDirty=t}getEditorDirty(){return this._editorIsDirty}};exports.EditorBridgeService=Wa([Fn(0,j.Inject(exports.SheetSkeletonManagerService)),Fn(1,Ze),Fn(2,j.Inject(l.ThemeService)),Fn(3,l.IUniverInstanceService)],exports.EditorBridgeService);const at=j.createIdentifier("univer.sheet-editor-bridge.service"),mt={id:"sheet.operation.set-cell-edit-visible",type:l.CommandType.OPERATION,handler:(i,e)=>{const t=i.get(at);return e==null?!1:(t.changeVisible(e),!0)}},Tn={id:"sheet.operation.set-cell-edit-visible-arrow",type:l.CommandType.OPERATION,handler:()=>!0};class Nt{constructor(){v(this,"_scrollInfo",new Map);v(this,"_currentScroll",null);v(this,"_scrollInfo$",new J.BehaviorSubject(null));v(this,"scrollInfo$",this._scrollInfo$.asObservable())}dispose(){this._scrollInfo$.complete()}setCurrentScroll(e){this._currentScroll=e,this._refresh(e)}getScrollByParam(e){return this._getCurrentScroll(e)}getCurrentScroll(){return this._getCurrentScroll(this._currentScroll)}addOrReplace(e){this._currentScroll!=null&&this._addByParam({...this._currentScroll,...e})}addOrReplaceNoRefresh(e){this._currentScroll!=null&&this._addByParam({...this._currentScroll,...e},!1)}addOrReplaceByParam(e){this._addByParam(e)}clear(){this._currentScroll!=null&&this._clearByParam(this._currentScroll)}_addByParam(e,t=!0){const{unitId:n,sheetId:r,sheetViewStartColumn:o,sheetViewStartRow:s,offsetX:a,offsetY:c}=e;this._scrollInfo.has(n)||this._scrollInfo.set(n,new Map),this._scrollInfo.get(n).set(r,{sheetViewStartRow:s,sheetViewStartColumn:o,offsetX:a,offsetY:c}),t===!0&&this._refresh({unitId:n,sheetId:r})}_clearByParam(e){this._addByParam({...e,sheetViewStartRow:0,sheetViewStartColumn:0,offsetX:0,offsetY:0}),this._refresh(e)}_getCurrentScroll(e){var r;if(e==null)return;const{unitId:t,sheetId:n}=e;return(r=this._scrollInfo.get(t))==null?void 0:r.get(n)}_refresh(e){this._scrollInfo$.next(this._getCurrentScroll(e))}}const on={id:"sheet.operation.set-scroll",type:l.CommandType.OPERATION,handler:(i,e)=>{if(e==null)return!1;const t=i.get(Nt),o=i.get(l.IUniverInstanceService).getUniverSheetInstance(e.unitId).getSheetBySheetId(e.sheetId),{xSplit:s,ySplit:a}=o.getConfig().freeze;return t.addOrReplaceByParam({...e,sheetViewStartRow:e.sheetViewStartRow-a,sheetViewStartColumn:e.sheetViewStartColumn-s}),!0}},Ti={id:"sheet.operation.set-editor-resize",type:l.CommandType.OPERATION,handler:(i,e)=>!0},bt={id:"sheet.operation.set-zoom-ratio",type:l.CommandType.OPERATION,handler:(i,e)=>{const t=i.get(l.IUniverInstanceService).getUniverSheetInstance(e.unitId);if(!t)return!1;const n=t.getSheetBySheetId(e.subUnitId);return n?(n.getConfig().zoomRatio=e.zoomRatio,!0):!1}};var Ya=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Xa(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var No={exports:{}},yi={};/**
7
10
  * @license React
8
11
  * react-jsx-runtime.production.min.js
9
12
  *
@@ -11,7 +14,7 @@
11
14
  *
12
15
  * This source code is licensed under the MIT license found in the
13
16
  * LICENSE file in the root directory of this source tree.
14
- */var xs=L,As=Symbol.for("react.element"),Hs=Symbol.for("react.fragment"),Ds=Object.prototype.hasOwnProperty,Ns=xs.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,Ps={key:!0,ref:!0,__self:!0,__source:!0};function No(i,e,t){var n,o={},r=null,s=null;t!==void 0&&(r=""+t),e.key!==void 0&&(r=""+e.key),e.ref!==void 0&&(s=e.ref);for(n in e)Ds.call(e,n)&&!Ps.hasOwnProperty(n)&&(o[n]=e[n]);if(i&&i.defaultProps)for(n in e=i.defaultProps,e)o[n]===void 0&&(o[n]=e[n]);return{$$typeof:As,type:i,key:r,ref:s,props:o,_owner:Ns.current}}xn.Fragment=Hs;xn.jsx=No;xn.jsxs=No;Do.exports=xn;var p=Do.exports,he=function(){return he=Object.assign||function(i){for(var e,t=1,n=arguments.length;t<n;t++){e=arguments[t];for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(i[o]=e[o])}return i},he.apply(this,arguments)},Ls=function(i,e){var t={};for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&e.indexOf(n)<0&&(t[n]=i[n]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,n=Object.getOwnPropertySymbols(i);o<n.length;o++)e.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(i,n[o])&&(t[n[o]]=i[n[o]]);return t},ue=L.forwardRef(function(i,e){var t=i.icon,n=i.id,o=i.className,r=i.extend,s=Ls(i,["icon","id","className","extend"]),l="univerjs-icon univerjs-icon-".concat(n," ").concat(o||"").trim(),c=L.useRef("_".concat(Bs()));return Po(t,"".concat(n),{defIds:t.defIds,idSuffix:c.current},he({ref:e,className:l},s),r)});function Po(i,e,t,n,o){return L.createElement(i.tag,he(he({key:e},Us(i,t,o)),n),(ks(i,t).children||[]).map(function(r,s){return Po(r,"".concat(e,"-").concat(i.tag,"-").concat(s),t,void 0,o)}))}function Us(i,e,t){var n=he({},i.attrs);t!=null&&t.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=t.colorChannel1);var o=e.defIds;return!o||o.length===0||(i.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+e.idSuffix),Object.entries(n).forEach(function(r){var s=r[0],l=r[1];typeof l=="string"&&(n[s]=l.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),n}function ks(i,e){var t,n=e.defIds;return!n||n.length===0?i:i.tag==="defs"&&(!((t=i.children)===null||t===void 0)&&t.length)?he(he({},i),{children:i.children.map(function(o){return typeof o.attrs.id=="string"&&n&&n.indexOf(o.attrs.id)>-1?he(he({},o),{attrs:he(he({},o.attrs),{id:o.attrs.id+e.idSuffix})}):o})}):i}function Bs(){return Math.random().toString(36).substring(2,8)}ue.displayName="UniverIcon";var Vs={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"colorChannel1",d:"M11.5261 12.834V14.634C11.5261 14.9654 11.7948 15.234 12.1261 15.234V15.234C12.4575 15.234 12.7261 14.9654 12.7261 14.634V12.834H14.5262C14.8576 12.834 15.1262 12.5654 15.1262 12.234V12.234C15.1262 11.9027 14.8576 11.634 14.5262 11.634H12.7261V9.83401C12.7261 9.50264 12.4575 9.23401 12.1261 9.23401V9.23401C11.7948 9.23401 11.5261 9.50264 11.5261 9.83401V11.634H9.72622C9.39485 11.634 9.12622 11.9027 9.12622 12.234V12.234C9.12622 12.5654 9.39485 12.834 9.72622 12.834H11.5261Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M3.05352 1.9613C2.39077 1.9613 1.85352 2.49856 1.85352 3.1613V6.7613C1.85352 7.42405 2.39077 7.9613 3.05352 7.9613H6.65352C7.31626 7.9613 7.85352 7.42405 7.85352 6.7613V3.1613C7.85352 2.49856 7.31626 1.9613 6.65352 1.9613H3.05352zM6.65352 3.1613H3.05352L3.05352 6.7613H6.65352V3.1613zM3.05352 9.23401C2.39077 9.23401 1.85352 9.77127 1.85352 10.434V14.034C1.85352 14.6968 2.39077 15.234 3.05352 15.234H6.65352C7.31626 15.234 7.85352 14.6968 7.85352 14.034V10.434C7.85352 9.77127 7.31626 9.23401 6.65352 9.23401H3.05352zM6.65352 10.434H3.05352L3.05352 14.034H6.65352V10.434zM10.3262 7.9613C9.66348 7.9613 9.12622 7.42405 9.12622 6.7613V3.1613C9.12622 2.49856 9.66348 1.9613 10.3262 1.9613H13.9262C14.589 1.9613 15.1262 2.49856 15.1262 3.1613V6.7613C15.1262 7.42405 14.589 7.9613 13.9262 7.9613H10.3262zM10.3262 6.7613V3.1613L13.9262 3.1613V6.7613H10.3262z",fillRule:"evenodd",clipRule:"evenodd"}}]},Lo=L.forwardRef(function(i,e){return L.createElement(ue,Object.assign({},i,{id:"autofill",ref:e,icon:Vs}))});Lo.displayName="Autofill";const Fs=Lo;var js={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M14.6152 4.52067C14.8732 4.77869 14.8732 5.19703 14.6152 5.45505L6.61862 13.4514C6.46241 13.6077 6.20915 13.6077 6.05294 13.4514L1.73512 9.13354C1.4771 8.87551 1.4771 8.45718 1.73513 8.19915C1.99315 7.94113 2.41149 7.94114 2.66951 8.19916L6.19436 11.7241C6.27247 11.8022 6.3991 11.8022 6.47721 11.7241L13.6808 4.52067C13.9388 4.26264 14.3571 4.26264 14.6152 4.52067Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Uo=L.forwardRef(function(i,e){return L.createElement(ue,Object.assign({},i,{id:"check-mark-single",ref:e,icon:js}))});Uo.displayName="CheckMarkSingle";const bn=Uo;var Ws={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.48712 4.59907C5.23328 4.34523 4.82172 4.34523 4.56788 4.59907C4.31404 4.85291 4.31404 5.26447 4.56788 5.51831L7.9973 8.94773L4.56773 12.3773C4.31389 12.6311 4.31389 13.0427 4.56773 13.2965C4.82157 13.5504 5.23313 13.5504 5.48697 13.2965L8.91654 9.86697L12.3461 13.2965C12.5999 13.5503 13.0114 13.5503 13.2653 13.2965C13.5191 13.0426 13.5191 12.6311 13.2653 12.3772L9.83577 8.94773L13.2651 5.51836C13.519 5.26452 13.519 4.85296 13.2651 4.59912C13.0113 4.34528 12.5997 4.34528 12.3459 4.59912L8.91654 8.02849L5.48712 4.59907Z"}}]},ko=L.forwardRef(function(i,e){return L.createElement(ue,Object.assign({},i,{id:"close-single",ref:e,icon:Ws}))});ko.displayName="CloseSingle";const $s=ko;var zs={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_102_1213",style:{maskType:"alpha"},width:17,height:17,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#DCDCDC",d:"M0.54 0.32H16.54V16.32H0.54z"}}]},{tag:"g",attrs:{fill:"currentColor",mask:"url(#mask0_102_1213)"},children:[{tag:"path",attrs:{d:"M1.76539 1.27148C1.89532 1.2465 2.05784 1.23193 2.25712 1.23193H7.39957C7.59852 1.23193 7.76228 1.24644 7.89394 1.27682 8.02979 1.30817 8.13912 1.36697 8.22237 1.45577 8.30591 1.54488 8.35813 1.6636 8.38857 1.80057L8.38913 1.80311C8.41406 1.93772 8.42854 2.10966 8.42854 2.31825V7.47982C8.42854 7.67924 8.41396 7.84153 8.38908 7.97584 8.36281 8.11247 8.3041 8.22717 8.22073 8.31054 8.13704 8.39424 8.02807 8.4472 7.89934 8.4781 7.77208 8.50864 7.60803 8.52313 7.41869 8.52313H2.25712C2.06419 8.52313 1.90591 8.51354 1.77494 8.48836 1.64209 8.46281 1.53156 8.41527 1.4464 8.33054 1.3606 8.24999 1.30815 8.13434 1.27781 8.00286 1.2476 7.87192 1.22815 7.69892 1.22815 7.47982V2.27524C1.22815 2.07123 1.24271 1.90413 1.26761 1.76966 1.29388 1.63303 1.35259 1.51833 1.43596 1.43496 1.52104 1.34988 1.63137 1.30236 1.76275 1.27204L1.76539 1.27148zM2.56975 2.39137C2.49306 2.39568 2.45433 2.41469 2.43395 2.43562 2.41191 2.46884 2.39718 2.51452 2.39715 2.57614L2.40631 4.24285H4.26296V2.39137H2.56975zM5.44152 2.39615V4.24285H7.24998V2.51898C7.24998 2.47398 7.24652 2.44245 7.24141 2.42201 7.23917 2.41305 7.23709 2.40806 7.23591 2.40567 7.22586 2.40059 7.20631 2.39615 7.16061 2.39615H5.44152zM2.40708 5.39751L2.41626 7.22616C2.41626 7.26829 2.41965 7.29933 2.42492 7.32085 2.42882 7.33675 2.43309 7.34502 2.43572 7.34893 2.43572 7.34893 2.43928 7.35079 2.44202 7.35193 2.44831 7.35455 2.45718 7.35739 2.46908 7.35996 2.49304 7.36512 2.52583 7.36847 2.56777 7.36847H4.26774V5.39751H2.40708zM5.44152 5.39751V7.36847H7.09848C7.1739 7.36847 7.21416 7.35941 7.23151 7.35088 7.23281 7.34891 7.23591 7.34357 7.23933 7.33216 7.24553 7.3115 7.24998 7.27978 7.24998 7.23608V5.39751H5.44152zM9.19356 8.15082C9.3235 8.12583 9.48601 8.11127 9.6853 8.11127H14.8277C15.0267 8.11127 15.1905 8.12577 15.3221 8.15616 15.458 8.18751 15.5673 8.2463 15.6506 8.33511 15.7341 8.42421 15.7863 8.54294 15.8167 8.67991L15.8173 8.68245C15.8422 8.81705 15.8567 8.98899 15.8567 9.19759V14.3592C15.8567 14.5586 15.8421 14.7209 15.8173 14.8552 15.791 14.9918 15.7323 15.1065 15.6489 15.1899 15.5652 15.2736 15.4562 15.3265 15.3275 15.3574 15.2003 15.388 15.0362 15.4025 14.8469 15.4025H9.6853C9.49237 15.4025 9.33408 15.3929 9.20312 15.3677 9.07027 15.3421 8.95974 15.2946 8.87458 15.2099 8.78878 15.1293 8.73633 15.0137 8.70599 14.8822 8.67578 14.7513 8.65633 14.5783 8.65633 14.3592V9.15457C8.65633 8.95057 8.67088 8.78346 8.69579 8.649 8.72206 8.51237 8.78077 8.39767 8.86414 8.3143 8.94922 8.22922 9.05955 8.1817 9.19093 8.15138L9.19356 8.15082zM9.99793 9.27071C9.92124 9.27501 9.88251 9.29403 9.86212 9.31496 9.84009 9.34817 9.82536 9.39386 9.82533 9.45548L9.83448 11.1222H11.6911V9.27071H9.99793zM12.8697 9.27549V11.1222H14.6782V9.39831C14.6782 9.35332 14.6747 9.32178 14.6696 9.30135 14.6673 9.29238 14.6653 9.2874 14.6641 9.285 14.654 9.27992 14.6345 9.27549 14.5888 9.27549H12.8697zM9.83525 12.2768L9.84444 14.1055C9.84444 14.1476 9.84783 14.1787 9.8531 14.2002 9.85699 14.2161 9.86127 14.2244 9.86389 14.2283L9.86689 14.2298 9.87019 14.2313C9.87648 14.2339 9.88535 14.2367 9.89726 14.2393 9.92122 14.2445 9.95401 14.2478 9.99594 14.2478H11.6959V12.2768H9.83525zM12.8697 12.2768V14.2478H14.5267C14.6021 14.2478 14.6423 14.2387 14.6597 14.2302 14.661 14.2282 14.6641 14.2229 14.6675 14.2115 14.6737 14.1908 14.6782 14.1591 14.6782 14.1154V12.2768H12.8697z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{d:"M10.0049 2.46747C10.0049 2.06363 10.3323 1.73625 10.7361 1.73625H12.9298C14.1413 1.73625 15.1234 2.71838 15.1234 3.9299V6.12354C15.1234 6.52738 14.796 6.85476 14.3922 6.85476 13.9883 6.85476 13.661 6.52738 13.661 6.12354V3.9299C13.661 3.52606 13.3336 3.19868 12.9298 3.19868H10.7361C10.3323 3.19868 10.0049 2.87131 10.0049 2.46747zM3.42396 10.5108C3.42396 10.107 3.09658 9.77962 2.69274 9.77962 2.2889 9.77962 1.96152 10.107 1.96152 10.5108V12.7045C1.96152 13.916 2.94365 14.8981 4.15517 14.8981H6.34882C6.75266 14.8981 7.08003 14.5707 7.08003 14.1669 7.08003 13.7631 6.75266 13.4357 6.34882 13.4357H4.15517C3.75134 13.4357 3.42396 13.1083 3.42396 12.7045V10.5108z"}}]}]},Bo=L.forwardRef(function(i,e){return L.createElement(ue,Object.assign({},i,{id:"convert-single",ref:e,icon:zs}))});Bo.displayName="ConvertSingle";const Xs=Bo;var Ys={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_371_77",style:{maskType:"alpha"},width:17,height:17,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#DCDCDC",d:"M0.87 0.63H16.87V16.63H0.87z"}}]},{tag:"g",attrs:{mask:"url(#mask0_371_77)"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M9.72636 13.5549C9.25212 14.1041 8.48323 14.1041 8.00899 13.5549L1.22579 5.70056C0.46078 4.81474 1.00259 3.30013 2.08448 3.30013L15.6509 3.30013C16.7328 3.30013 17.2746 4.81474 16.5096 5.70056L9.72636 13.5549Z"}}]}]},Vo=L.forwardRef(function(i,e){return L.createElement(ue,Object.assign({},i,{id:"dropdown-single",ref:e,icon:Ys}))});Vo.displayName="DropdownSingle";const Wi=Vo;var Zs={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M1.90535 4.99197C2.23194 4.82196 2.63451 4.94889 2.80452 5.27548C2.96702 5.58764 3.22397 5.8971 3.57667 6.18615C4.57587 7.00507 6.2535 7.58331 8.21318 7.58331C10.1728 7.58331 11.8505 7.00508 12.8497 6.18616C13.2024 5.8971 13.4593 5.58763 13.6218 5.27549C13.7918 4.94889 14.1944 4.82196 14.521 4.99196C14.8476 5.16197 14.9745 5.56454 14.8045 5.89113C14.5439 6.39185 14.1596 6.83646 13.6948 7.2174C13.6514 7.25301 13.6071 7.28815 13.5621 7.3228L15.0214 8.78205C15.2817 9.0424 15.2817 9.46451 15.0214 9.72486C14.761 9.98521 14.3389 9.98521 14.0785 9.72486L12.3889 8.03522C11.8643 8.28584 11.2846 8.48827 10.6659 8.63563L11.2065 10.6532C11.3018 11.0088 11.0907 11.3744 10.7351 11.4697C10.3794 11.565 10.0139 11.3539 9.91857 10.9983L9.34529 8.85869C8.97555 8.89693 8.59724 8.91664 8.21318 8.91664C7.82639 8.91664 7.44544 8.89665 7.07321 8.85788L6.49971 10.9983C6.40441 11.354 6.03886 11.565 5.68321 11.4697C5.32757 11.3744 5.11651 11.0089 5.2118 10.6532L5.75288 8.63382C5.13793 8.48682 4.5615 8.28539 4.03968 8.03629L2.35121 9.72477C2.09086 9.98512 1.66875 9.98512 1.4084 9.72477C1.14805 9.46442 1.14805 9.04231 1.4084 8.78196L2.86611 7.32424C2.82044 7.28912 2.77557 7.2535 2.73152 7.2174C2.26668 6.83645 1.88248 6.39184 1.62183 5.89114C1.45182 5.56455 1.57876 5.16198 1.90535 4.99197Z"}}]},Fo=L.forwardRef(function(i,e){return L.createElement(ue,Object.assign({},i,{id:"eyelash-single",ref:e,icon:Zs}))});Fo.displayName="EyelashSingle";const Gs=Fo;var Ks={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_367_60",style:{maskType:"alpha"},width:17,height:17,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#D9D9D9",d:"M0.06 0.78H16.06V16.78H0.06z"}}]},{tag:"g",attrs:{fill:"currentColor",mask:"url(#mask0_367_60)"},children:[{tag:"path",attrs:{d:"M5.54303 5.67809C5.41486 5.67809 5.31977 5.55923 5.34791 5.43419L5.43336 5.05446C5.53338 4.62534 5.71701 4.25903 5.99076 3.96308 6.28977 3.63984 6.73293 3.49761 7.27633 3.49761 7.47741 3.49761 7.69254 3.52131 7.92082 3.56601 7.93983 3.56973 7.95869 3.57361 7.9774 3.57766 8.18885 3.62335 8.41593 3.52833 8.49925 3.32869L8.72661 2.78395C8.81351 2.57574 8.71072 2.3376 8.49476 2.27229 8.46253 2.26255 8.42923 2.25268 8.39485 2.24269 8.10639 2.15986 7.76287 2.11572 7.35969 2.11572 6.29909 2.11572 5.50608 2.38292 4.95354 2.88796 4.38882 3.40424 3.98783 4.14273 3.76308 5.11976L2.31598 11.3345C2.2402 11.6722 2.14495 12.0353 2.02739 12.4247 1.90869 12.8169 1.76625 13.2031 1.60116 13.5809 1.43472 13.9595 1.24707 14.3197 1.0385 14.6607.972389 14.7687.904093 14.8718.833608 14.9698.744025 15.0945.813644 15.2766.965497 15.2989 1.6153 15.3945 2.29684 15.2198 2.66091 14.6732 2.80556 14.456 2.94673 14.2082 3.08403 13.9287 3.44529 13.1932 3.78416 12.1538 4.09761 10.801L4.94794 7.15889C4.96907 7.06839 5.04977 7.00436 5.14271 7.00436H7.10372C7.28864 7.00436 7.44946 6.87761 7.49265 6.6978L7.61908 6.17153C7.67951 5.91998 7.48886 5.67809 7.23015 5.67809H5.54303zM13.8 5.86392L11.9914 8.11319 10.8878 5.92109C10.8211 5.77368 10.6743 5.67896 10.5125 5.67896H9.79183C9.48739 5.67896 9.28816 5.99784 9.42165 6.27145L10.8878 9.19857 8.27677 12.2928C8.04481 12.5594 8.23414 12.9751 8.58749 12.9751H9.16501C9.28566 12.9751 9.43944 12.9258 9.5177 12.834L11.5897 10.4084 12.5966 12.7046C12.6575 12.8666 12.8119 12.9751 12.9851 12.9751H13.779C14.062 12.9751 14.2207 12.7611 14.1216 12.4959L12.6517 9.42983C12.6517 9.42983 14.8799 6.59898 15.0802 6.32247 15.2756 6.05285 15.0812 5.67896 14.7482 5.67896H14.145C14.0064 5.67896 13.9122 5.73242 13.8 5.86392z"}}]}]},jo=L.forwardRef(function(i,e){return L.createElement(ue,Object.assign({},i,{id:"fx-single",ref:e,icon:Ks}))});jo.displayName="FxSingle";const qs=jo;var Js={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_102_249",style:{maskType:"alpha"},width:17,height:17,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#D9D9D9",d:"M0.37 0.77H16.37V16.77H0.37z"}}]},{tag:"g",attrs:{mask:"url(#mask0_102_249)"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M9.12107 2.86418C9.12107 2.45648 8.78669 2.12598 8.37422 2.12598C7.96175 2.12598 7.62737 2.45648 7.62737 2.86418V8.03164H2.39931C1.98684 8.03164 1.65247 8.36214 1.65247 8.76984C1.65247 9.17754 1.98684 9.50805 2.39931 9.50805H7.62737V14.6754C7.62737 15.0831 7.96175 15.4136 8.37422 15.4136C8.78669 15.4136 9.12107 15.0831 9.12107 14.6754V9.50805H14.3489C14.7613 9.50805 15.0957 9.17754 15.0957 8.76984C15.0957 8.36214 14.7613 8.03164 14.3489 8.03164H9.12107V2.86418Z"}}]}]},Wo=L.forwardRef(function(i,e){return L.createElement(ue,Object.assign({},i,{id:"increase-single",ref:e,icon:Js}))});Wo.displayName="IncreaseSingle";const Qs=Wo;var el={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_102_556",style:{maskType:"alpha"},width:17,height:17,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#D9D9D9",d:"M0.56 0.77H16.56V16.77H0.56z"}}]},{tag:"g",attrs:{mask:"url(#mask0_102_556)"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M1.19318 4.76988C1.70089 4.26222 2.524 4.26226 3.03166 4.76997L8.13929 9.87808C8.3736 10.1124 8.75352 10.1124 8.98784 9.8781L14.0959 4.77C14.6036 4.26232 15.4267 4.26232 15.9344 4.77C16.4421 5.27768 16.4421 6.1008 15.9344 6.60848L9.97775 12.5651C9.19667 13.3462 7.93029 13.3462 7.14925 12.5651L1.1931 6.60836C0.685438 6.10065 0.685477 5.27753 1.19318 4.76988Z",fillRule:"evenodd",clipRule:"evenodd"}}]}]},$o=L.forwardRef(function(i,e){return L.createElement(ue,Object.assign({},i,{id:"more-down-single",ref:e,icon:el}))});$o.displayName="MoreDownSingle";const ei=$o;var tl={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.52628 3.57095C5.81918 3.26411 6.29405 3.26411 6.58695 3.57095L11.0869 8.28525C11.3798 8.59209 11.3798 9.08958 11.0869 9.39642L6.51623 14.04C6.22334 14.3468 5.74846 14.3468 5.45557 14.04C5.16268 13.7331 5.16268 13.2357 5.45557 12.9288L9.35939 8.979C9.43544 8.90205 9.43652 8.77857 9.36182 8.70031L5.52628 4.68212C5.23339 4.37528 5.23339 3.87779 5.52628 3.57095Z",fillRule:"evenodd",clipRule:"evenodd"}}]},zo=L.forwardRef(function(i,e){return L.createElement(ue,Object.assign({},i,{id:"more-single",ref:e,icon:tl}))});zo.displayName="MoreSingle";const $i=zo;var nl={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_102_1204",style:{maskType:"alpha"},width:17,height:17,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#DCDCDC",d:"M0.25 0.41H16.25V16.41H0.25z"}}]},{tag:"g",attrs:{mask:"url(#mask0_102_1204)"},children:[{tag:"rect",attrs:{width:12.62,height:2.79,x:1.94,y:12.66,fill:"colorChannel1",rx:1.4}},{tag:"path",attrs:{fill:"currentColor",d:"M7.99664 2.57069C7.59302 2.05771 7.10966 1.68854 6.63466 1.50243C6.11882 1.30028 5.40184 1.25862 4.95066 1.83566C4.5486 2.34994 4.581 3.10899 4.82709 3.91045C4.93826 4.27259 5.11865 4.62903 5.37541 4.97266C5.38713 4.98834 5.39945 5.00329 5.41229 5.01752C5.4217 5.02789 5.4314 5.03788 5.44133 5.04746C5.45477 5.06043 5.46874 5.07267 5.48315 5.08419L3.75659 6.81071C3.51774 7.04955 3.51774 7.43683 3.75659 7.67569L7.48775 11.4068C7.72666 11.6457 8.11394 11.6457 8.35278 11.4068L13.0831 6.67651C13.3219 6.43766 13.3219 6.05039 13.0831 5.81155L9.35191 2.08037C9.11306 1.84153 8.72579 1.84153 8.48695 2.08037L7.99664 2.57069ZM7.71181 4.91288C7.72271 4.98224 7.73182 5.05302 7.73898 5.12518C7.77251 5.46131 8.07213 5.70663 8.40825 5.6731C8.74438 5.6396 8.98972 5.33994 8.9562 5.00382C8.90804 4.52113 8.79269 4.0731 8.6291 3.66819L8.91946 3.37784L11.7856 6.24403L10.8608 7.16886H5.12843L7.6582 4.63909C7.67903 4.72777 7.69702 4.81905 7.71181 4.91288ZM7.12302 3.44433C6.8246 3.02658 6.47279 2.75283 6.18833 2.64136C6.05252 2.58814 5.96546 2.58477 5.92656 2.58984C5.92268 2.59037 5.91947 2.59093 5.91678 2.59147L5.91208 2.59257C5.89185 2.62604 5.78612 2.86628 5.99645 3.5514C6.0626 3.76685 6.1728 3.99252 6.34325 4.2241L7.12302 3.44433Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M12.4434 11.9528C12.8956 11.9528 13.2622 11.5862 13.2622 11.134C13.2622 10.854 12.9483 10.3347 12.7092 9.9798C12.5801 9.78823 12.3066 9.78823 12.1776 9.97981C11.9385 10.3347 11.6246 10.854 11.6246 11.134C11.6246 11.5862 11.9912 11.9528 12.4434 11.9528Z"}}]}]},Xo=L.forwardRef(function(i,e){return L.createElement(ue,Object.assign({},i,{id:"paint-bucket",ref:e,icon:nl}))});Xo.displayName="PaintBucket";const il=Xo;var ol={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M2.80805 1.53809C2.10674 1.53809 1.53821 2.10661 1.53821 2.80793V13.6016C1.53821 14.3029 2.10674 14.8714 2.80805 14.8714H9.74456C10.2968 14.8714 10.7446 14.4237 10.7446 13.8714V13.6016V11.128C10.7446 10.9623 10.8789 10.828 11.0446 10.828H13.6017H13.8715C14.4238 10.828 14.8715 10.3803 14.8715 9.82802V2.80793C14.8715 2.10661 14.303 1.53809 13.6017 1.53809H2.80805ZM9.17472 13.6016C9.3404 13.6016 9.47472 13.4673 9.47472 13.3016V11.128C9.47472 10.9623 9.3404 10.828 9.17472 10.828H6.91757C6.75189 10.828 6.61757 10.9623 6.61757 11.128V13.3016C6.61757 13.4673 6.75189 13.6016 6.91757 13.6016H9.17472ZM13.6017 9.25817C13.6017 9.42386 13.4674 9.55818 13.3017 9.55818H11.0446C10.8789 9.55818 10.7446 9.42386 10.7446 9.25818V7.17177C10.7446 7.00608 10.8789 6.87177 11.0446 6.87177H13.3017C13.4674 6.87177 13.6017 7.00608 13.6017 7.17177V9.25817ZM9.17472 9.55818C9.3404 9.55818 9.47472 9.42386 9.47472 9.25818V7.17177C9.47472 7.00608 9.3404 6.87177 9.17472 6.87177H6.91757C6.75189 6.87177 6.61757 7.00608 6.61757 7.17177V9.25817C6.61757 9.42386 6.75189 9.55818 6.91757 9.55818H9.17472ZM13.6017 5.30193C13.6017 5.46761 13.4674 5.60193 13.3017 5.60193H11.0446C10.8789 5.60193 10.7446 5.46761 10.7446 5.30193V3.10793C10.7446 2.94224 10.8789 2.80793 11.0446 2.80793H13.3017C13.4674 2.80793 13.6017 2.94224 13.6017 3.10793V5.30193ZM9.17472 5.60193C9.3404 5.60193 9.47472 5.46761 9.47472 5.30193V3.10793C9.47472 2.94224 9.3404 2.80793 9.17472 2.80793H6.91757C6.75189 2.80793 6.61757 2.94224 6.61757 3.10793V5.30193C6.61757 5.46761 6.75189 5.60193 6.91757 5.60193H9.17472ZM5.34773 3.10793C5.34773 2.94224 5.21342 2.80793 5.04773 2.80793H3.10805C2.94236 2.80793 2.80805 2.94224 2.80805 3.10793V5.30193C2.80805 5.46761 2.94236 5.60193 3.10805 5.60193H5.04773C5.21342 5.60193 5.34773 5.46761 5.34773 5.30193V3.10793ZM5.34773 7.17177C5.34773 7.00608 5.21342 6.87177 5.04773 6.87177H3.10805C2.94236 6.87177 2.80805 7.00608 2.80805 7.17177V9.25817C2.80805 9.42386 2.94236 9.55818 3.10805 9.55818H5.04773C5.21342 9.55818 5.34773 9.42386 5.34773 9.25818V7.17177ZM5.34773 11.128C5.34773 10.9623 5.21342 10.828 5.04773 10.828H3.10805C2.94236 10.828 2.80805 10.9623 2.80805 11.128V13.3016C2.80805 13.4673 2.94236 13.6016 3.10805 13.6016H5.04773C5.21342 13.6016 5.34773 13.4673 5.34773 13.3016V11.128Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M12.3869 12.1183C12.361 11.9546 12.5342 11.8323 12.6798 11.9114L14.9901 13.1655C15.1577 13.2565 15.1137 13.5049 14.932 13.5378C14.9212 13.5398 14.9102 13.5417 14.8996 13.5446L13.8966 13.8224L13.1603 14.7467C13.0651 14.9084 12.8197 14.8618 12.7904 14.6764L12.3869 12.1183Z"}}]},Yo=L.forwardRef(function(i,e){return L.createElement(ue,Object.assign({},i,{id:"select-range-single",ref:e,icon:ol}))});Yo.displayName="SelectRangeSingle";const rl=Yo,sl="univer-range-selector",ll="univer-range-selector-editor",al="univer-range-selector-icon",cl="univer-range-selector-active",Fe={rangeSelector:sl,rangeSelectorEditor:ll,rangeSelectorIcon:al,rangeSelectorActive:cl};function dl(i){const{onChange:e,onActive:t}=i,[n,o]=L.useState(!1),r=L.useRef(null),s=W.useDependency(a.LocaleService),l=W.useDependency(f.SelectionManagerService);L.useEffect(()=>{var m;if(n){t(n);const S=l.selectionMoveEnd$.subscribe(g=>{const _=["A1","B2:C3","Sheet2!A1:B2","D10:E11,F1:G2,H3:I4"],I=Math.floor(Math.random()*_.length),C=_[I];r.current&&(r.current.innerHTML=C)});return document.addEventListener("click",c),()=>{document.removeEventListener("click",c),S.unsubscribe()}}e(((m=r.current)==null?void 0:m.innerHTML)||"")},[n]);function c(m){var I,C,b;if(((I=m.target)==null?void 0:I.closest('[data-range-selector="true"]'))||m.target===r.current)return;const g=(C=m.target)==null?void 0:C.closest(`.${Fe.rangeSelector}`);(g==null?void 0:g.querySelector(`.${Fe.rangeSelectorEditor}`))!==r.current&&(o(!1),(b=r.current)==null||b.blur())}function d(m){m.stopPropagation(),m.key==="Enter"&&(m.preventDefault(),m.currentTarget.blur(),o(!1))}function u(){o(!0)}function h(){var m;if(!n){(m=r.current)==null||m.focus();return}o(!n)}return p.jsxs("div",{className:n?`${Fe.rangeSelector} ${Fe.rangeSelectorActive}`:Fe.rangeSelector,children:[p.jsx("div",{ref:r,className:Fe.rangeSelectorEditor,contentEditable:!0,"data-placeholder":s.t("rangeSelector.placeholder"),onKeyDown:d,onFocus:u}),p.jsx(ie.Tooltip,{title:s.t("rangeSelector.tooltip"),placement:"bottom",children:p.jsx("button",{className:Fe.rangeSelectorIcon,onClick:h,children:p.jsx(rl,{})})})]})}const ti={零:0,一:1,二:2,三:3,四:4,五:5,六:6,七:7,八:8,九:9},Mn=["零","一","二","三","四","五","六","七","八","九"],zi=["","万","亿","万亿","亿亿"],ul=["","十","百","千"],Zo={十:{value:10,secUnit:!1},百:{value:100,secUnit:!1},千:{value:1e3,secUnit:!1},万:{value:1e4,secUnit:!0},亿:{value:1e8,secUnit:!0}};function Oe(i){if(!i)return 0;let e=0,t=0,n=0,o=!1;const r=i.split("");for(let s=0;s<r.length;s++){const l=ti[r[s]];if(typeof l<"u")n=l,s===r.length-1&&(t+=n);else{const c=Zo[r[s]],d=c.value;o=c.secUnit,o?(t=(t+n)*d,e+=t,t=0):t+=n*d,n=0}}return e+t}function hl(i){let e="",t="",n=0,o=!0;for(;i>0;){const r=i%10;r===0?o||(o=!0,t=Mn[r]+t):(o=!1,e=Mn[r],e+=ul[n],t=e+t),n++,i=Math.floor(i/10)}return t}function ml(i){let e=0,t="",n="",o=!1;if(i===0)return Mn[0];for(;i>0;){const r=i%1e4;o&&(n=Mn[0]+n),t=hl(r),t+=r!==0?zi[e]:zi[0],n=t+n,o=r<1e3&&r>0,i=Math.floor(i/1e4),e++}return n}function Sl(i){if(!i)return!1;let e=!0;if(i)if(i.length===1)i==="日"||i in ti?e=!0:e=!1;else{const t=i.split("");for(let n=0;n<t.length;n++)if(!(t[n]in ti||t[n]in Zo)){e=!1;break}}return e}function Ft(i){if(!i)return{isExtendNumber:!1};const e=/0|([1-9]+[0-9]*)/g,t=e.test(i);if(t){const n=i.match(e);if(n&&n.length>0){const o=n[n.length-1],r=i.lastIndexOf(o),s=i.substr(0,r),l=i.substr(r+o.length);return{isExtendNumber:!0,matchTxt:Number(o),beforeTxt:s,afterTxt:l}}return{isExtendNumber:!1}}return{isExtendNumber:t}}function _l(i){let e;return i.length===2&&(i==="周一"||i==="周二"||i==="周三"||i==="周四"||i==="周五"||i==="周六"||i==="周日")?e=!0:e=!1,e}function gl(i){let e;return i.length===3&&(i==="星期一"||i==="星期二"||i==="星期三"||i==="星期四"||i==="星期五"||i==="星期六"||i==="星期日")?e=!0:e=!1,e}function fl(i,e){let t=0;for(let n=0;n<i.length&&i[n]<e;n++)t++;return t}function Ht(i){let e=!0;const t=i[1]-i[0];for(let n=1;n<i.length;n++)if(i[n]-i[n-1]!==t){e=!1;break}return e}function pl(i,e,t){const n=[],o=Math.floor(e/i),r=e%i;let s=0;if(o>0){for(let l=0;l<o;l++)for(let c=0;c<t.length;c++)n[t[c]+l*i]=s,s++;for(let l=0;l<t.length&&t[l]<r;l++)n[t[l]+i*o]=s,s++}else for(let l=0;l<t.length&&t[l]<r;l++)n[t[l]]=s,s++;return n}function Ge(i,e){const t=[];for(let n=1;n<=e;n++){const o=(n-1)%i.length,r=a.Tools.deepClone(i[o]);t.push(r)}return t}function vl(i,e){var n;const t=[];for(let o=1;o<=e;o++){const r=(o-1)%i.length,s={s:(n=i[r])==null?void 0:n.s};t.push(s)}return t}function Cl(i){let e=!0;const t=i[1]/i[0];for(let n=1;n<i.length;n++)if(i[n]/i[n-1]!==t){e=!1;break}return e}function Il(i){const e=[];for(let t=1;t<=i;t++)e.push(t);return e}function Rl(i,e,t){var r,s,l,c,d,u,h;const n=[],o=[];for(let m=0;m<i.length;m++)o.push(Number((r=i[m])==null?void 0:r.v));if(i.length>2&&Cl(o))for(let m=1;m<=e;m++){const S=(m-1)%i.length,g=a.Tools.deepClone(i[S]);let _;t===a.Direction.DOWN||t===a.Direction.RIGHT?_=Number((s=i[i.length-1])==null?void 0:s.v)*(Number((l=i[1])==null?void 0:l.v)/Number((c=i[0])==null?void 0:c.v))**m:(t===a.Direction.UP||t===a.Direction.LEFT)&&(_=Number((d=i[0])==null?void 0:d.v)/(Number((u=i[1])==null?void 0:u.v)/Number((h=i[0])==null?void 0:h.v))**m),g&&(g.v=_,n.push(g))}else{const m=Il(i.length);for(let S=1;S<=e;S++){const g=(S-1)%i.length,_=a.Tools.deepClone(i[g]);let I;t===a.Direction.DOWN||t===a.Direction.RIGHT?I=Xi(i.length+S,o,m):I=Xi(1-S,o,m),_&&(_.v=I,n.push(_))}}return n}function Xi(i,e,t){function n(u){let h=0;for(let m=0;m<u.length;m++)h+=u[m];return h/u.length}const o=n(t),r=n(e);let s=0,l=0;for(let u=0;u<t.length;u++)s+=(t[u]-o)*(e[u]-r),l+=(t[u]-o)*(t[u]-o);let c;l===0?c=1:c=s/l;const d=r-c*o;return Math.round((d+c*i)*1e5)/1e5}function Yi(i,e,t){var r;const n=[],o=/0|([1-9]+[0-9]*)/g;for(let s=1;s<=e;s++){const l=(s-1)%i.length,c=a.Tools.deepClone(i[l]),d=`${(r=i[i.length-1])==null?void 0:r.v}`,u=d==null?void 0:d.match(o),h=u==null?void 0:u[u.length-1],m=Math.abs(Number(h)+t*s);if(!d||!h)continue;const S=d.lastIndexOf(h),g=d.substr(0,S)+m.toString()+d.substr(S+h.length);c&&(c.v=g,n.push(c))}return n}function rt(i,e,t,n=0){var l,c;const o=[["日","一","二","三","四","五","六"],["周日","周一","周二","周三","周四","周五","周六"],["星期日","星期一","星期二","星期三","星期四","星期五","星期六"]];if(n>=o.length)return[];const r=o[n],s=[];for(let d=1;d<=e;d++){const u=(d-1)%i.length,h=a.Tools.deepClone(i[u]);let m=0;if(((l=i[i.length-1])==null?void 0:l.v)===r[0])m=7+t*d;else{const g=`${(c=i[i.length-1])==null?void 0:c.v}`;if(g){const _=g.substr(g.length-1,1);m=Oe(_)+t*d}}m<0&&(m=Math.ceil(Math.abs(m)/7)*7+m);const S=m%7;h&&(h.v=r[S],s.push(h))}return s}function Zi(i,e,t){var o;const n=[];for(let r=1;r<=e;r++){const s=(r-1)%i.length,l=a.Tools.deepClone(i[s]),c=`${(o=i[i.length-1])==null?void 0:o.v}`,d=Oe(c)+t*r;let u;d<=0?u="零":u=ml(d),l&&(l.v=u,n.push(l))}return n}const Mt={enWeek1:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],enWeek2:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],enMonth1:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],enMonth2:["January","February","March","April","May","June","July","August","September","October","November","December"],chnMonth1:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"],chnMonth2:["正月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","腊月"],chHour1:["子","丑","寅","卯","辰","巳","午","未","申","酉","戌","亥"],chHour2:["子时","丑时","寅时","卯时","辰时","巳时","午时","未时","申时","酉时","戌时","亥时"],chYear1:["甲","乙","丙","丁","戊","己","庚","辛","壬","癸"],chSeason1:["春","夏","秋","冬"],chSeason2:["春季","夏季","秋季","冬季"]};function bl(i){let e=!1;return Object.keys(Mt).forEach(t=>{Mt[t].includes(i)&&(e=!0)}),e}function kn(i){let e="";const t=[];return Object.keys(Mt).forEach(n=>{Mt[n].includes(i)&&(e=n,t.push(...Mt[n]))}),{name:e,series:t}}function Gi(i,e,t,n){var s;const o=n.length,r=[];for(let l=1;l<=e;l++){const c=(l-1)%i.length,d=a.Tools.deepClone(i[c]),u=`${(s=i[i.length-1])==null?void 0:s.v}`,m=(n.indexOf(u)+t*l)%o;d&&(d.v=n[m],r.push(d))}return r}function Ml(i,e){const t=[];let n;if(e.startRow<i.startRow)n=a.Direction.UP;else if(e.endRow>i.endRow)n=a.Direction.DOWN;else if(e.startColumn<i.startColumn)n=a.Direction.LEFT;else if(e.endColumn>i.endColumn)n=a.Direction.RIGHT;else return[];if(n===a.Direction.DOWN||n===a.Direction.UP){const o=i.endRow-i.startRow+1,r=e.endRow-e.startRow+1,s=r/o,l=r%o,c={startRow:0,startColumn:0,endRow:i.endRow-i.startRow,endColumn:i.endColumn-i.startColumn};if(n===a.Direction.DOWN){for(let d=0;d<s;d++)t.push({repeatStartCell:{row:i.startRow+(d+1)*o,col:i.startColumn},relativeRange:c});l>0&&t.push({repeatStartCell:{row:i.startRow+(s+1)*o,col:i.startColumn},relativeRange:{startRow:0,startColumn:0,endRow:l-1,endColumn:i.endColumn-i.startColumn}})}else{for(let d=0;d<s;d++)t.push({repeatStartCell:{row:i.startRow-(d+1)*o,col:i.startColumn},relativeRange:c});l>0&&t.push({repeatStartCell:{row:i.startRow-(s+1)*o,col:i.startColumn},relativeRange:{startRow:o-l,endRow:o-1,startColumn:0,endColumn:i.endColumn-i.startColumn}})}}if(n===a.Direction.RIGHT||n===a.Direction.LEFT){const o=i.endColumn-i.startColumn+1,r=e.endColumn-e.startColumn+1,s=r/o,l=r%o,c={startRow:0,startColumn:0,endRow:i.endRow-i.startRow,endColumn:i.endColumn-i.startColumn};if(n===a.Direction.RIGHT){for(let d=0;d<s;d++)t.push({repeatStartCell:{row:i.startRow,col:i.startColumn+(d+1)*o},relativeRange:c});l>0&&t.push({repeatStartCell:{row:i.startRow,col:i.startColumn+(s+1)*o},relativeRange:{startRow:0,startColumn:0,endRow:i.endRow-i.startRow,endColumn:l-1}})}else{for(let d=0;d<s;d++)t.push({repeatStartCell:{row:i.startRow,col:i.startColumn-(d+1)*o},relativeRange:c});l>0&&t.push({repeatStartCell:{row:i.startRow,col:i.startColumn-(s+1)*o},relativeRange:{startRow:0,startColumn:o-l,endRow:i.endRow-i.startRow,endColumn:o-1}})}}return t}var te=(i=>(i.NUMBER="number",i.DATE="date",i.EXTEND_NUMBER="extendNumber",i.CHN_NUMBER="chnNumber",i.CHN_WEEK2="chnWeek2",i.CHN_WEEK3="chnWeek3",i.LOOP_SERIES="loopSeries",i.FORMULA="formula",i.OTHER="other",i))(te||{}),X=(i=>(i.COPY="0",i.SERIES="1",i.ONLY_FORMAT="2",i.NO_FORMAT="3",i))(X||{});const wl={type:te.NUMBER,priority:1e3,match:i=>typeof(i==null?void 0:i.v)=="number"||!isNaN(Number(i==null?void 0:i.v)),isContinue:(i,e)=>i.type===te.NUMBER,applyFunctions:{[X.SERIES]:(i,e,t)=>{const{data:n}=i;return(t===a.Direction.LEFT||t===a.Direction.UP)&&n.reverse(),Rl(n,e,t)}}},Go={type:te.OTHER,priority:0,match:()=>!0,isContinue:(i,e)=>i.type===te.OTHER},Tl={type:te.EXTEND_NUMBER,priority:900,match:i=>Ft(`${i==null?void 0:i.v}`||"").isExtendNumber,isContinue:(i,e)=>{var t;if(i.type===te.EXTEND_NUMBER){const{beforeTxt:n,afterTxt:o}=Ft(`${(t=i.cellData)==null?void 0:t.v}`||""),{beforeTxt:r,afterTxt:s}=Ft(`${e==null?void 0:e.v}`||"");if(n===r&&o===s)return!0}return!1},applyFunctions:{[X.SERIES]:(i,e,t)=>{var s;const{data:n}=i;let o;if(n.length===1)return o=t===a.Direction.DOWN||t===a.Direction.RIGHT?1:-1,Yi(n,e,o);const r=[];for(let l=0;l<n.length;l++){const c=`${(s=n[l])==null?void 0:s.v}`;c&&r.push(Number(Ft(c).matchTxt))}return(t===a.Direction.UP||t===a.Direction.LEFT)&&(n.reverse(),r.reverse()),Ht(r)?(o=r[1]-r[0],Yi(n,e,o)):Ge(n,e)}}},El={type:te.CHN_NUMBER,priority:830,match:i=>!!Sl(`${i==null?void 0:i.v}`||""),isContinue:(i,e)=>i.type===te.CHN_NUMBER,applyFunctions:{[X.SERIES]:(i,e,t)=>{var c,d,u;const{data:n}=i,o=t===a.Direction.LEFT||t===a.Direction.UP;if(n.length===1){const h=`${(c=n[0])==null?void 0:c.v}`;let m;return o?m=-1:m=1,h&&(h==="日"||Oe(h)<7)?rt(n,e,m):Zi(n,e,m)}let r=!1;for(let h=0;h<n.length;h++)if(((d=n[h])==null?void 0:d.v)==="日"){r=!0;break}const s=[];let l=0;for(let h=0;h<n.length;h++){const m=`${(u=n[h])==null?void 0:u.v}`;m==="日"?h===0?s.push(0):(l++,s.push(l*7)):r&&Oe(m)>0&&Oe(m)<7?s.push(Oe(m)+l*7):s.push(Oe(m))}if(o&&(n.reverse(),s.reverse()),Ht(s)){if(r||s[s.length-1]<6&&s[0]>0||s[0]<6&&s[s.length-1]>0){const m=s[1]-s[0];return rt(n,e,m)}const h=s[1]-s[0];return Zi(n,e,h)}return Ge(n,e)}}},yl={type:te.CHN_WEEK2,priority:820,match:i=>!!_l(`${i==null?void 0:i.v}`||""),isContinue:(i,e)=>i.type===te.CHN_WEEK2,applyFunctions:{[X.SERIES]:(i,e,t)=>{var l;const{data:n}=i,o=t===a.Direction.LEFT||t===a.Direction.UP;if(n.length===1){let c;return o?c=-1:c=1,rt(n,e,c,1)}const r=[];let s=0;for(let c=0;c<n.length;c++){const d=`${(l=n[c])==null?void 0:l.v}`,u=d==null?void 0:d.substr(d.length-1,1);d==="周日"?c===0?r.push(0):(s++,r.push(s*7)):r.push(Oe(u)+s*7)}if(o&&(n.reverse(),r.reverse()),Ht(r)){const c=r[1]-r[0];return rt(n,e,c,1)}return Ge(n,e)}}},Ol={type:te.CHN_WEEK3,priority:810,match:i=>gl(`${i==null?void 0:i.v}`||""),isContinue:(i,e)=>i.type===te.CHN_WEEK3,applyFunctions:{[X.SERIES]:(i,e,t)=>{var l;const{data:n}=i,o=t===a.Direction.LEFT||t===a.Direction.UP;if(n.length===1){let c;return o?c=-1:c=1,rt(n,e,c,2)}const r=[];let s=0;for(let c=0;c<n.length;c++){const d=`${(l=n[c])==null?void 0:l.v}`;if(d){const u=d.substr(d.length-1,1);d==="星期日"?c===0?r.push(0):(s++,r.push(s*7)):r.push(Oe(u)+s*7)}}if(o&&(n.reverse(),r.reverse()),Ht(r)){const c=r[1]-r[0];return rt(n,e,c,2)}return Ge(n,e)}}},xl={type:te.LOOP_SERIES,priority:800,match:i=>bl(`${i==null?void 0:i.v}`||""),isContinue:(i,e)=>{var t;return i.type===te.LOOP_SERIES?kn(`${(t=i.cellData)==null?void 0:t.v}`||"").name===kn(`${e==null?void 0:e.v}`||"").name:!1},applyFunctions:{[X.SERIES]:(i,e,t)=>{var c,d;const{data:n}=i,o=t===a.Direction.LEFT||t===a.Direction.UP,{series:r}=kn(`${(c=n[0])==null?void 0:c.v}`||"");if(n.length===1){let u;return o?u=-1:u=1,Gi(n,e,u,r)}const s=[];let l=0;for(let u=0;u<n.length;u++){const h=`${(d=n[u])==null?void 0:d.v}`;h&&(h===r[0]?u===0?s.push(0):(l++,s.push(l*r.length)):s.push(r.indexOf(h)+l*7))}if(o&&(n.reverse(),s.reverse()),Ht(s)){const u=s[1]-s[0];return Gi(n,e,u,r)}return Ge(n,e)}}};var Al=Object.defineProperty,Hl=Object.getOwnPropertyDescriptor,Dl=(i,e,t,n)=>{for(var o=n>1?void 0:n?Hl(e,t):e,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(e,t,o):s(o))||o);return n&&o&&Al(e,t,o),o},Bn=(i,e)=>(t,n)=>e(t,n,i);exports.AutoFillService=class extends a.Disposable{constructor(t,n,o){super();v(this,"_rules",[]);v(this,"_hooks",[]);v(this,"_applyType$",new k.BehaviorSubject(X.SERIES));v(this,"_isFillingStyle",!0);v(this,"_sourceRange",null);v(this,"_destRange",null);v(this,"_applyRange",null);v(this,"applyType$",this._applyType$.asObservable());v(this,"_menu$",new k.BehaviorSubject([{label:"autoFill.copy",value:X.COPY,disable:!1},{label:"autoFill.series",value:X.SERIES,disable:!1},{label:"autoFill.formatOnly",value:X.ONLY_FORMAT,disable:!1},{label:"autoFill.noFormat",value:X.NO_FORMAT,disable:!1}]));v(this,"menu$",this._menu$.asObservable());this._sheetInterceptorService=t,this._univerInstanceService=n,this._selectionManagerService=o,this._init()}_init(){this._rules=[wl,Tl,El,yl,Ol,xl,Go].sort((t,n)=>n.priority-t.priority),this._isFillingStyle=!0}addHook(t){if(this._hooks.find(n=>n.hookName===t.hookName))throw new Error(`Add hook failed, hook name '${t.hookName}' already exist!`);return this._hooks.push(t),a.toDisposable(()=>{const n=this._hooks.findIndex(o=>o===t);n>-1&&this._hooks.splice(n,1)})}registerRule(t){if(this._rules.find(o=>o.type===t.type))throw new Error(`Registry rule failed, type '${t.type}' already exist!`);const n=this._rules.findIndex(o=>o.priority<t.priority);this._rules.splice(n===-1?this._rules.length:n,0,t)}getRules(){return this._rules}getHooks(){return this._hooks}getApplyType(){return this._applyType$.getValue()}setApplyType(t){this._applyType$.next(t)}isFillingStyle(){return this._isFillingStyle}setFillingStyle(t){this._isFillingStyle=t}setRanges(t,n,o){this._sourceRange=n,this._destRange=t,this._applyRange=o}getRanges(){return{sourceRange:this._sourceRange,destRange:this._destRange,applyRange:this._applyRange}}setDisableApplyType(t,n){this._menu$.next(this._menu$.getValue().map(o=>o.value===t?{...o,disable:n}:o))}};exports.AutoFillService=Dl([a.OnLifecycle(a.LifecycleStages.Rendered,exports.AutoFillService),Bn(0,P.Inject(f.SheetInterceptorService)),Bn(1,P.Inject(a.IUniverInstanceService)),Bn(2,P.Inject(f.SelectionManagerService))],exports.AutoFillService);const Dt=P.createIdentifier("univer.auto-fill-service");var Nl=Object.defineProperty,Pl=Object.getOwnPropertyDescriptor,Ll=(i,e,t,n)=>{for(var o=n>1?void 0:n?Pl(e,t):e,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(e,t,o):s(o))||o);return n&&o&&Nl(e,t,o),o},Je=(i,e)=>(t,n)=>e(t,n,i);exports.AutoFillController=class extends a.Disposable{constructor(t,n,o,r,s,l){super();v(this,"_direction",null);v(this,"_beforeApplyData",[]);v(this,"_applyType",X.SERIES);v(this,"_hasFillingStyle",!0);v(this,"_copyData",[]);this._univerInstanceService=t,this._selectionRenderService=n,this._commandService=o,this._autoFillService=r,this._editorBridgeService=s,this._selectionManagerService=l,this._init()}_init(){this._onSelectionControlFillChanged(),this._onApplyTypeChanged(),[Cn,zt].forEach(t=>{this.disposeWithMe(this._commandService.registerCommand(t))})}_handleDbClickFill(t){const n=this._detectFillRange(t);n.endRow<=t.endRow||this._handleFill(t,n)}_detectFillRange(t){var m,S,g,_,I,C;const{startRow:n,endRow:o,startColumn:r,endColumn:s}=t,l=(m=this._univerInstanceService.getCurrentUniverSheetInstance())==null?void 0:m.getActiveSheet();if(!l)return t;const c=l.getCellMatrix(),d=l.getMaxRows()-1,u=l.getMaxColumns()-1;let h=o;if(r>0&&((S=c.getValue(n,r-1))==null?void 0:S.v)!=null){let b=n;for(;((g=c.getValue(b,r-1))==null?void 0:g.v)!=null&&b<d;)b+=1;h=b}else if(s<u&&((_=c.getValue(o,s+1))==null?void 0:_.v)!=null){let b=n;for(;((I=c.getValue(b,s+1))==null?void 0:I.v)!=null&&b<d;)b++;h=b}for(let b=o+1;b<=h;b++)for(let M=r;M<=s;M++)if(((C=c.getValue(b,M))==null?void 0:C.v)!=null){h=b-1;break}return{startColumn:r,endColumn:s,startRow:n,endRow:h}}_handleFill(t,n){if(!(t.startColumn===n.startColumn&&t.startRow===n.startRow&&t.endColumn===n.endColumn&&t.endRow===n.endRow)){if(n.endColumn<t.endColumn&&n.endColumn>t.startColumn){this._commandService.executeCommand(zt.id,{clearRange:{startRow:n.startRow,endRow:n.endRow,startColumn:n.endColumn+1,endColumn:t.endColumn},selectionRange:n});return}if(n.endRow<t.endRow&&n.endRow>t.startRow){this._commandService.executeCommand(zt.id,{clearRange:{startRow:n.endRow+1,endRow:t.endRow,startColumn:n.startColumn,endColumn:n.endColumn},selectionRange:n});return}this._presetAndCacheData(t,n)}}_onSelectionControlFillChanged(){const t=new a.DisposableCollection;this.disposeWithMe(a.toDisposable(this._selectionManagerService.selectionMoveEnd$.subscribe(()=>{t.dispose();const n=this._selectionManagerService.getCurrent();if((n==null?void 0:n.pluginName)!==f.NORMAL_SELECTION_PLUGIN_NAME)return;this._selectionRenderService.getCurrentControls().forEach(r=>{t.add(a.toDisposable(r.selectionFilled$.subscribe(s=>{if(s==null)return;const l={startColumn:r.model.startColumn,endColumn:r.model.endColumn,startRow:r.model.startRow,endRow:r.model.endRow},c={startColumn:s.startColumn,endColumn:s.endColumn,startRow:s.startRow,endRow:s.endRow};this._handleFill(l,c)}))),t.add(a.toDisposable(r.fillControl.onDblclickObserver.add(()=>{const s={startColumn:r.model.startColumn,endColumn:r.model.endColumn,startRow:r.model.startRow,endRow:r.model.endRow};this._handleDbClickFill(s)}))),t.add(a.toDisposable(r.fillControl.onPointerDownObserver.add(()=>{this._editorBridgeService.isVisible().visible&&this._editorBridgeService.changeVisible({visible:!1,eventType:w.DeviceInputEventType.PointerDown})})))})})))}_onApplyTypeChanged(){this.disposeWithMe(a.toDisposable(this._autoFillService.applyType$.subscribe(t=>{t===X.NO_FORMAT?(this._applyType=X.SERIES,this._hasFillingStyle=!1):(this._applyType=t||X.SERIES,this._hasFillingStyle=!0),this._fillData()})))}_getApplyData(t,n,o,r,s,l=!0){const c=[],d=Math.floor(o/n),u=o%n,h=this._autoFillService.getRules();if(!l&&s===X.ONLY_FORMAT)return console.error("ERROR: only format can not be applied when hasStyle is false"),[];const m={};h.forEach(S=>{m[S.type]=[]}),h.forEach(S=>{const{type:g,applyFunctions:_={}}=S,I=t[g];I&&I.forEach(C=>{const b=fl(C.index,u),M=C.index.length*d+b,T=this._applyFunctions(C,M,r,s,_,t),E=pl(n,o,C.index);m[g].push({data:T,index:E})})});for(let S=0;S<o;S++)h.forEach(g=>{const{type:_}=g,I=m[_];for(let C=0;C<I.length;C++)S in I[C].index&&c.push(I[C].data[I[C].index[S]])});return c}_applyFunctions(t,n,o,r,s,l){const{data:c}=t,d=o===a.Direction.UP||o===a.Direction.LEFT;if(r===X.COPY){const u=s==null?void 0:s[X.COPY];return u?u(t,n,o,l):(d&&c.reverse(),Ge(c,n))}if(r===X.SERIES){const u=s==null?void 0:s[X.SERIES];return u?u(t,n,o,l):(d&&c.reverse(),s!=null&&s[X.COPY]?s[X.COPY](t,n,o,l):Ge(c,n))}if(r===X.ONLY_FORMAT){const u=s==null?void 0:s[X.ONLY_FORMAT];return u?u(t,n,o,l):vl(c,n)}}_getCopyData(t,n){const{startRow:o,startColumn:r,endRow:s,endColumn:l}=t,c=this._univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getCellMatrix(),d=this._autoFillService.getRules(),u=[],h=n===a.Direction.DOWN||n===a.Direction.UP;let m,S,g,_;h?(m=r,S=l,g=o,_=s):(m=o,S=s,g=r,_=l);for(let I=m;I<=S;I++){const C=this._getEmptyCopyDataPiece(),b={type:void 0,cellData:void 0};for(let M=g;M<=_;M++){let T;h?T=c.getValue(M,I):T=c.getValue(I,M);const{type:E,isContinue:y}=d.find(O=>O.match(T))||Go;if(y(b,T)){const O=C[E],x=O[O.length-1];x.data.push(T),x.index.push(M-g)}else{const O=C[E];O?O.push({data:[T],index:[M-g]}):C[E]=[{data:[T],index:[M-g]}]}b.type=E,b.cellData=T}u.push(C)}return u}_getEmptyCopyDataPiece(){const t={};return this._autoFillService.getRules().forEach(n=>{t[n.type]=[]}),t}_getMergeApplyData(t,n,o,r){const s=this._univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getMergeData(),l=[];for(let c=t.startRow;c<=t.endRow;c++)for(let d=t.startColumn;d<=t.endColumn;d++){const{isMergedMainCell:u,startRow:h,startColumn:m,endRow:S,endColumn:g}=w.getCellInfoInMergeData(c,d,s);if(u){if(o===a.Direction.DOWN){let _=h+r,I=S+r;for(;I<=n.endRow;)l.push({startRow:_,startColumn:m,endRow:I,endColumn:g}),_+=r,I+=r}else if(o===a.Direction.UP){let _=h-r,I=S-r;for(;_>=n.startRow;)l.push({startRow:_,startColumn:m,endRow:I,endColumn:g}),_-=r,I-=r}else if(o===a.Direction.RIGHT){let _=m+r,I=g+r;for(;I<=n.endColumn;)l.push({startRow:h,startColumn:_,endRow:S,endColumn:I}),_+=r,I+=r}else if(o===a.Direction.LEFT){const _=m-r,I=g-r;for(;_>=n.startColumn;)l.push({startRow:h,startColumn:_,endRow:S,endColumn:I})}}}return l}_presetAndCacheData(t,n){const o={startRow:n.startRow,endRow:n.endRow,startColumn:n.startColumn,endColumn:n.endColumn};let r=null;if(n.startRow<t.startRow)r=a.Direction.UP,o.endRow=t.startRow-1;else if(n.endRow>t.endRow)r=a.Direction.DOWN,o.startRow=t.endRow+1;else if(n.startColumn<t.startColumn)r=a.Direction.LEFT,o.endColumn=t.startColumn-1;else if(n.endColumn>t.endColumn)r=a.Direction.RIGHT,o.startColumn=t.endColumn+1;else return;this._direction=r;const s=this._univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getCellMatrix(),l=[];for(let c=o.startRow;c<=o.endRow;c++){const d=[];for(let u=o.startColumn;u<=o.endColumn;u++)d.push(a.Tools.deepClone(s.getValue(c,u)));l.push(d)}this._beforeApplyData=l,this._autoFillService.setRanges(n,t,o),this._copyData=this._getCopyData(t,r),this._hasSeries(this._copyData)?(this._autoFillService.setDisableApplyType(X.SERIES,!1),this._autoFillService.setApplyType(X.SERIES)):(this._autoFillService.setDisableApplyType(X.SERIES,!0),this._autoFillService.setApplyType(X.COPY))}_fillData(){const{destRange:t,sourceRange:n,applyRange:o}=this._autoFillService.getRanges(),r=this._applyType,s=this._hasFillingStyle,l=this._direction;if(!t||!n||!o||l==null)return;const{startRow:c,startColumn:d,endRow:u,endColumn:h}=n,{startRow:m,startColumn:S,endRow:g,endColumn:_}=o,I=this._copyData;let C;l===a.Direction.DOWN||l===a.Direction.UP?C=u-c+1:C=h-d+1;const b=[];if(l===a.Direction.DOWN||l===a.Direction.UP){const D=g-m+1,U=[];for(let N=S;N<=_;N++){const B=I[N-S],A=this._getApplyData(B,C,D,l,r,s);U.push(A)}for(let N=0;N<U[0].length;N++){const B=[];for(let A=0;A<U.length;A++)B.push({v:null,s:null,...this._beforeApplyData[N][A],...U[A][N]});b.push(B)}}else{const D=_-S+1;for(let U=m;U<=g;U++){const N=I[U-m],B=this._getApplyData(N,C,D,l,r,s),A=[];for(let H=0;H<B.length;H++)A.push({v:null,s:null,...this._beforeApplyData[U-m][H],...B[H]});b.push(A)}}let M;const T=this._univerInstanceService.getCurrentUniverSheetInstance().getStyles();s?(M=this._getMergeApplyData(n,t,l,C),b.forEach(D=>{D.forEach(U=>{U&&T&&T&&(U.s=T.getStyleByCell(U))})})):b.forEach((D,U)=>{D.forEach((N,B)=>{N&&T&&(N.s=T.getStyleByCell(this._beforeApplyData[U][B])||null)})});const E=this._autoFillService.getHooks(),y=[],O=[],x=this._hasFillingStyle?r:X.NO_FORMAT;E.forEach(D=>{const{hook:U}=D,{redos:N,undos:B}=U==null?void 0:U[x](n,o);y.push(...N),O.push(...B)}),this._commandService.executeCommand(Cn.id,{selectionRange:t,applyRange:o,applyDatas:b,unitId:this._univerInstanceService.getCurrentUniverSheetInstance().getUnitId(),subUnitId:this._univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getSheetId(),extendMutations:{undo:O,redo:y},applyMergeRanges:M})}_hasSeries(t){return t.some(n=>Object.keys(n).some(r=>{var s;return!!((s=n[r])!=null&&s.length&&![te.OTHER,te.FORMULA].includes(r))}))}};exports.AutoFillController=Ll([a.OnLifecycle(a.LifecycleStages.Steady,exports.AutoFillController),Je(0,a.IUniverInstanceService),Je(1,ce),Je(2,a.ICommandService),Je(3,Dt),Je(4,pe),Je(5,P.Inject(f.SelectionManagerService))],exports.AutoFillController);const Si={type:a.CommandType.COMMAND,id:"sheet.command.set-range-bold",handler:async i=>{const e=i.get(a.ICommandService);return i.get(a.IContextService).getContextValue(a.FOCUSING_EDITOR)?e.executeCommand(K.SetInlineFormatBoldCommand.id):e.executeCommand(f.SetBoldCommand.id)}},_i={type:a.CommandType.COMMAND,id:"sheet.command.set-range-italic",handler:async i=>{const e=i.get(a.ICommandService);return i.get(a.IContextService).getContextValue(a.FOCUSING_EDITOR)?e.executeCommand(K.SetInlineFormatItalicCommand.id):e.executeCommand(f.SetItalicCommand.id)}},gi={type:a.CommandType.COMMAND,id:"sheet.command.set-range-underline",handler:async i=>{const e=i.get(a.ICommandService);return i.get(a.IContextService).getContextValue(a.FOCUSING_EDITOR)?e.executeCommand(K.SetInlineFormatUnderlineCommand.id):e.executeCommand(f.SetUnderlineCommand.id)}},fi={type:a.CommandType.COMMAND,id:"sheet.command.set-range-stroke",handler:async i=>{const e=i.get(a.ICommandService);return i.get(a.IContextService).getContextValue(a.FOCUSING_EDITOR)?e.executeCommand(K.SetInlineFormatStrikethroughCommand.id):e.executeCommand(f.SetStrikeThroughCommand.id)}},Ul={type:a.CommandType.COMMAND,id:"sheet.command.set-range-subscript",handler:async i=>{const e=i.get(a.ICommandService);return i.get(a.IContextService).getContextValue(a.FOCUSING_EDITOR)?e.executeCommand(K.SetInlineFormatSubscriptCommand.id):!1}},kl={type:a.CommandType.COMMAND,id:"sheet.command.set-range-superscript",handler:async i=>{const e=i.get(a.ICommandService);return i.get(a.IContextService).getContextValue(a.FOCUSING_EDITOR)?e.executeCommand(K.SetInlineFormatSuperscriptCommand.id):!1}},Ko={type:a.CommandType.COMMAND,id:"sheet.command.set-range-fontsize",handler:async(i,e)=>{const t=i.get(a.ICommandService);return i.get(a.IContextService).getContextValue(a.FOCUSING_EDITOR)?t.executeCommand(K.SetInlineFormatFontSizeCommand.id,e):t.executeCommand(f.SetFontSizeCommand.id,e)}},qo={type:a.CommandType.COMMAND,id:"sheet.command.set-range-font-family",handler:async(i,e)=>{const t=i.get(a.ICommandService);return i.get(a.IContextService).getContextValue(a.FOCUSING_EDITOR)?t.executeCommand(K.SetInlineFormatFontFamilyCommand.id,e):t.executeCommand(f.SetFontFamilyCommand.id,e)}},wn={type:a.CommandType.COMMAND,id:"sheet.command.set-range-text-color",handler:async(i,e)=>{const t=i.get(a.ICommandService);return i.get(a.IContextService).getContextValue(a.FOCUSING_EDITOR)?t.executeCommand(K.SetInlineFormatTextColorCommand.id,e):t.executeCommand(f.SetTextColorCommand.id,e)}};function Jo(i,e){return e.some(t=>Bl(i,t))}function Bl(i,e){const{startRow:t,startColumn:n,endColumn:o,endRow:r}=e,s=i.getMatrixWithMergedCells(t,n,r,o);let l=!1;return s.forValue((c,d,u)=>{if(u&&(c!==t||d!==n)&&i.cellHasValue(u))return l=!0,!1}),l}function Qo(i,e,t,n){const o=[],r=[],s=t.getSheetId();return n.forEach(l=>{const c=Vl(t,l),d={unitId:e,subUnitId:s,cellValue:c.getData()},u=f.SetRangeValuesUndoMutationFactory(i,d);o.push({id:f.SetRangeValuesMutation.id,params:u}),r.push({id:f.SetRangeValuesMutation.id,params:d})}),{undos:o,redos:r}}function Vl(i,e){const{startRow:t,startColumn:n,endColumn:o,endRow:r}=e,s=i.getMatrixWithMergedCells(t,n,r,o),l=new a.ObjectMatrix;return s.forValue((c,d,u)=>{u&&(c!==t||d!==n)&&l.setValue(c,d,null)}),l}var Fl=Object.defineProperty,jl=Object.getOwnPropertyDescriptor,Wl=(i,e,t,n)=>{for(var o=n>1?void 0:n?jl(e,t):e,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(e,t,o):s(o))||o);return n&&o&&Fl(e,t,o),o},Vn=(i,e)=>(t,n)=>e(t,n,i),fe=(i=>(i[i.OFF=0]="OFF",i[i.ONCE=1]="ONCE",i[i.INFINITE=2]="INFINITE",i))(fe||{});const dt=P.createIdentifier("univer.format-painter-service");let ni=class extends a.Disposable{constructor(e,t,n){super();v(this,"status$");v(this,"_selectionFormat");v(this,"_markId",null);v(this,"_status$");this._selectionManagerService=e,this._univerInstanceService=t,this._markSelectionService=n,this._status$=new k.BehaviorSubject(0),this.status$=this._status$.asObservable(),this._selectionFormat={styles:new a.ObjectMatrix,merges:[]}}setStatus(e){e!==0&&this._getSelectionRangeFormat(),this._updateRangeMark(e),this._status$.next(e)}getStatus(){return this._status$.getValue()}_updateRangeMark(e){if(this._markSelectionService.removeAllShapes(),this._markId=null,e!==0){const t=this._selectionManagerService.getLast();if(t){const n=this._selectionManagerService.createCopyPasteSelection();this._markId=this._markSelectionService.addShape({...t,style:n})}}}_getSelectionRangeFormat(){const e=this._selectionManagerService.getLast(),t=e==null?void 0:e.range;if(!t)return;const{startRow:n,endRow:o,startColumn:r,endColumn:s}=t,l=this._univerInstanceService.getCurrentUniverSheetInstance(),d=(l==null?void 0:l.getActiveSheet()).getCellMatrix(),u=this._univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getMergeData(),h=l.getStyles(),m=new a.ObjectMatrix;for(let S=n;S<=o;S++)for(let g=r;g<=s;g++){const _=d.getValue(S,g);m.setValue(S,g,h.getStyleByCell(_)||{});const{isMergedMainCell:I,...C}=w.getCellInfoInMergeData(S,g,u);I&&this._selectionFormat.merges.push({startRow:C.startRow,startColumn:C.startColumn,endRow:C.endRow,endColumn:C.endColumn})}this._selectionFormat.styles=m}getSelectionFormat(){return this._selectionFormat}};ni=Wl([Vn(0,P.Inject(f.SelectionManagerService)),Vn(1,a.IUniverInstanceService),Vn(2,At)],ni);const pi={id:"sheet.operation.set-format-painter",type:a.CommandType.OPERATION,handler:(i,e)=>e?(i.get(dt).setStatus(e.status),!0):!1},er={type:a.CommandType.COMMAND,id:"sheet.command.set-infinite-format-painter",handler:async i=>{const t=i.get(dt).getStatus();let n;return t!==fe.OFF?n=fe.OFF:n=fe.INFINITE,i.get(a.ICommandService).executeCommand(pi.id,{status:n})}},vi={type:a.CommandType.COMMAND,id:"sheet.command.set-once-format-painter",handler:async i=>{const t=i.get(dt).getStatus();let n;return t!==fe.OFF?n=fe.OFF:n=fe.ONCE,i.get(a.ICommandService).executeCommand(pi.id,{status:n})}},tr={type:a.CommandType.COMMAND,id:"sheet.command.apply-format-painter",handler:async(i,e)=>{const t=i.get(a.ICommandService),n=i.get(a.IUndoRedoService),o=i.get(a.IUniverInstanceService),r=i.get(f.SelectionManagerService),s=i.get(f.SheetInterceptorService),{styleValues:l,styleRange:c,mergeRanges:d,unitId:u=o.getCurrentUniverSheetInstance().getUnitId(),subUnitId:h=o.getCurrentUniverSheetInstance().getActiveSheet().getSheetId()}=e,m=c?[c]:r.getSelectionRanges();if(!m||!m.length)return!1;const S=new a.ObjectMatrix;let g;if(a.Tools.isArray(l))for(let H=0;H<m.length;H++){const{startRow:V,startColumn:F,endRow:j,endColumn:$}=m[H];for(let q=0;q<=j-V;q++)for(let z=0;z<=$-F;z++)S.setValue(q+V,z+F,l[q][z])}else if(a.isICellData(l))for(let H=0;H<m.length;H++){const{startRow:V,startColumn:F}=m[H];S.setValue(V,F,l)}else g=l;const _={subUnitId:h,unitId:u,cellValue:g??S.getMatrix()},I=f.SetRangeValuesUndoMutationFactory(i,_);if(!s.fetchThroughInterceptors(f.INTERCEPTOR_POINT.PERMISSION)(null,{id:f.SetRangeValuesCommand.id,params:_}))return!1;const C=t.syncExecuteCommand(f.SetRangeValuesMutation.id,_),{undos:b,redos:M}=s.onCommandExecute({id:f.SetRangeValuesCommand.id,params:{..._,range:m}}),T=f.getAddMergeMutationRangeByType(d),E=o.getUniverSheetInstance(u).getSheetBySheetId(h),y=[],O=[],x=Jo(E,T),D={unitId:u,subUnitId:h,ranges:T},U={unitId:u,subUnitId:h,ranges:T};y.push({id:f.RemoveWorksheetMergeMutation.id,params:D}),y.push({id:f.AddWorksheetMergeMutation.id,params:U});const N=f.RemoveMergeUndoMutationFactory(i,D),B=f.AddMergeUndoMutationFactory(i,U);if(O.push({id:f.RemoveWorksheetMergeMutation.id,params:B}),O.push({id:f.AddWorksheetMergeMutation.id,params:N}),x){const H=Qo(i,u,E,T);y.unshift(...H.redos),O.push(...H.undos)}const A=await a.sequenceExecute([...M,...y],t);return C&&A.result?(n.pushUndoRedo({unitID:u,undoMutations:[{id:f.SetRangeValuesMutation.id,params:I},...b,...O],redoMutations:[{id:f.SetRangeValuesMutation.id,params:_},...M,...y]}),!0):!1}},An={type:a.CommandType.COMMAND,id:"sheet.command.set-selection-frozen",handler:async(i,e)=>{const{type:t}=e||{},n=i.get(a.IUniverInstanceService),o=i.get(a.IUndoRedoService),r=n.getCurrentUniverSheetInstance().getUnitId(),s=n.getCurrentUniverSheetInstance().getActiveSheet().getSheetId(),l=i.get(a.ICommandService),d=i.get(f.SelectionManagerService).getSelections();if(!d)return!1;const u=d[(d==null?void 0:d.length)-1],{range:h}=u,m=i.get(ke),{sheetViewStartRow:S=0,sheetViewStartColumn:g=0}=m.getCurrentScroll()||{};let _,I,C,b;const{startRow:M,startColumn:T,rangeType:E}=h;if(E===a.RANGE_TYPE.ROW||t===1)_=M,C=M-S,I=-1,b=0;else if(E===a.RANGE_TYPE.COLUMN||t===2)_=-1,C=0,I=T,b=T-g;else if(E===a.RANGE_TYPE.NORMAL)_=M,C=M-S,I=T,b=T-g;else return!1;const y={unitId:r,subUnitId:s,startRow:_,startColumn:I,xSplit:b,ySplit:C},O=f.SetFrozenMutationFactory(i,y);return l.syncExecuteCommand(f.SetFrozenMutation.id,y)&&o.pushUndoRedo({unitID:r,undoMutations:[{id:f.SetFrozenMutation.id,params:O}],redoMutations:[{id:f.SetFrozenMutation.id,params:y}]}),!0}},nr={type:a.CommandType.COMMAND,id:"sheet.command.set-row-frozen",handler:async i=>(i.get(a.ICommandService).executeCommand(An.id,{type:1}),!0)},ir={type:a.CommandType.COMMAND,id:"sheet.command.set-col-frozen",handler:async i=>(i.get(a.ICommandService).executeCommand(An.id,{type:2}),!0)},or={type:a.CommandType.COMMAND,id:"sheet.command.cancel-frozen",handler:async i=>{const e=i.get(a.ICommandService),t=i.get(a.IUniverInstanceService),n=i.get(a.IUndoRedoService),o=t.getCurrentUniverSheetInstance().getUnitId(),r=t.getCurrentUniverSheetInstance().getActiveSheet().getSheetId(),s={unitId:o,subUnitId:r,startRow:-1,startColumn:-1,xSplit:0,ySplit:0},l=f.SetFrozenMutationFactory(i,s);return e.syncExecuteCommand(f.SetFrozenMutation.id,s)&&n.pushUndoRedo({unitID:o,undoMutations:[{id:f.SetFrozenMutation.id,params:l}],redoMutations:[{id:f.SetFrozenMutation.id,params:s}]}),!0}},ut="UI_PLUGIN_SHEETS",Hn=`${ut}_COLOR_PICKER_COMPONENT`,$l="univer-ui-plugin-sheets-font-family",zl="univer-ui-plugin-sheets-font-family-item",rr={uiPluginSheetsFontFamily:$l,uiPluginSheetsFontFamilyItem:zl},Xl=i=>{const{value:e}=i,t=W.useDependency(a.LocaleService);return p.jsx("div",{className:rr.uiPluginSheetsFontFamily,style:{fontFamily:e},children:t.t(`fontFamily.${(`${e}`??"").replace(/\s/g,"")}`)})},Yl=i=>{const{value:e}=i,t=W.useDependency(a.LocaleService);return p.jsx("span",{className:rr.uiPluginSheetsFontFamilyItem,style:{fontFamily:e},children:t.t(`fontFamily.${(`${e}`??"").replace(/\s/g,"")}`)})},sr=`${ut}_FONT_FAMILY_COMPONENT`,se=`${ut}_FONT_FAMILY_ITEM_COMPONENT`,Zl="univer-ui-plugin-sheets-font-size",Gl="univer-ui-plugin-sheets-font-size-input",Ki={uiPluginSheetsFontSize:Zl,uiPluginSheetsFontSizeInput:Gl},Kl=i=>{const{value:e,min:t,max:n,onChange:o}=i,[r,s]=L.useState(Number(e??0)),l=L.useMemo(()=>Number(e??r),[e]);function c(u){u!==null&&s(u)}function d(u){u.stopPropagation(),u.code==="Enter"&&o(r.toString())}return p.jsx("div",{className:Ki.uiPluginSheetsFontSize,children:p.jsx(ie.InputNumber,{className:Ki.uiPluginSheetsFontSizeInput,value:l,controls:!1,min:t,max:n,onKeyDown:d,onChange:c})})},lr=`${ut}_FONT_SIZE_COMPONENT`,Ci=`${ut}_MENU_ITEM_INPUT_COMPONENT`,ql="univer-sheets-ui-context-menu-input",Jl="univer-sheets-ui-context-menu-input-container",Ql="univer-sheets-ui-context-menu-input-number",Fn={sheetsUiContextMenuInput:ql,sheetsUiContextMenuInputContainer:Jl,sheetsUiContextMenuInputNumber:Ql},ea=i=>{const{prefix:e,suffix:t,value:n,onChange:o}=i,r=W.useDependency(a.LocaleService),[s,l]=L.useState(),c=u=>{l(u==null?void 0:u.toString()),o((u==null?void 0:u.toString())??"")};L.useEffect(()=>{l(n)},[n]);function d(u){u.key==="Backspace"&&u.stopPropagation()}return p.jsxs("div",{className:Fn.sheetsUiContextMenuInput,children:[r.t(e),p.jsx("span",{className:Fn.sheetsUiContextMenuInputContainer,onClick:u=>u.stopPropagation(),children:p.jsx(ie.InputNumber,{className:Fn.sheetsUiContextMenuInputNumber,value:Number(s),precision:0,onKeyDown:d,onChange:c})}),r.t(t)]})};var ee=(i=>(i.ROW_HEADER_CONTEXT_MENU="rowHeaderContextMenu",i.COL_HEADER_CONTEXT_MENU="colHeaderContextMenu",i.SHEET_BAR="sheetBar",i))(ee||{});function ta(i){const e=i.get(dt);return i.get(a.IUniverInstanceService),{id:vi.id,subId:er.id,group:R.MenuGroup.TOOLBAR_FORMAT,type:R.MenuItemType.BUTTON,icon:"BrushSingle",title:"Format Painter",tooltip:"toolbar.formatPainter",positions:[R.MenuPosition.TOOLBAR_START],activated$:new k.Observable(t=>{let n=!1;const o=e.status$.subscribe(r=>{n=r!==fe.OFF,t.next(n)});return t.next(n),()=>{o.unsubscribe()}}),hidden$:R.getMenuHiddenObservable(i,a.UniverInstanceType.SHEET)}}function na(i){const e=i.get(a.ICommandService),t=i.get(f.SheetPermissionService),n=i.get(a.IUniverInstanceService),o=i.get(f.SelectionManagerService),r=n.getCurrentUniverSheetInstance().getUnitId(),s=n.getCurrentUniverSheetInstance().getActiveSheet().getSheetId();return{id:Si.id,group:R.MenuGroup.TOOLBAR_FORMAT,type:R.MenuItemType.BUTTON,icon:"BoldSingle",title:"Set bold",tooltip:"toolbar.bold",positions:[R.MenuPosition.TOOLBAR_START],disabled$:new k.Observable(l=>{var d;const c=(d=t.getEditable$(r,s))==null?void 0:d.subscribe(u=>{l.next(!u.value)});return()=>{c==null||c.unsubscribe()}}),activated$:new k.Observable(l=>{const c=e.onCommandExecuted(d=>{var g;const u=d.id;if(u!==f.SetRangeValuesMutation.id&&u!==f.SetSelectionsOperation.id)return;const h=(g=o.getLast())==null?void 0:g.primary,m=n.getCurrentUniverSheetInstance().getActiveSheet();let S=a.FontWeight.NORMAL;if(h!=null){const _=m.getRange(h.startRow,h.startColumn);S=_==null?void 0:_.getFontWeight()}l.next(S===a.FontWeight.BOLD)});return l.next(!1),c.dispose}),hidden$:R.getMenuHiddenObservable(i,a.UniverInstanceType.SHEET)}}function ia(i){const e=i.get(a.ICommandService),t=i.get(a.IUniverInstanceService),n=i.get(f.SelectionManagerService),o=i.get(f.SheetPermissionService),r=t.getCurrentUniverSheetInstance().getUnitId(),s=t.getCurrentUniverSheetInstance().getActiveSheet().getSheetId();return{id:_i.id,group:R.MenuGroup.TOOLBAR_FORMAT,type:R.MenuItemType.BUTTON,icon:"ItalicSingle",title:"Set italic",tooltip:"toolbar.italic",positions:[R.MenuPosition.TOOLBAR_START],disabled$:new k.Observable(l=>{var d;const c=(d=o.getEditable$(r,s))==null?void 0:d.subscribe(u=>{l.next(!u.value)});return()=>{c==null||c.unsubscribe()}}),activated$:new k.Observable(l=>{const c=e.onCommandExecuted(d=>{var g;const u=d.id;if(u!==f.SetRangeValuesMutation.id&&u!==f.SetSelectionsOperation.id)return;const h=(g=n.getLast())==null?void 0:g.primary,m=t.getCurrentUniverSheetInstance().getActiveSheet();let S=a.FontItalic.NORMAL;if(h!=null){const _=m.getRange(h.startRow,h.startColumn);S=_==null?void 0:_.getFontStyle()}l.next(S===a.FontItalic.ITALIC)});return l.next(!1),c.dispose}),hidden$:R.getMenuHiddenObservable(i,a.UniverInstanceType.SHEET)}}function oa(i){const e=i.get(a.ICommandService),t=i.get(a.IUniverInstanceService),n=i.get(f.SelectionManagerService),o=i.get(f.SheetPermissionService),r=t.getCurrentUniverSheetInstance().getUnitId(),s=t.getCurrentUniverSheetInstance().getActiveSheet().getSheetId();return{id:gi.id,group:R.MenuGroup.TOOLBAR_FORMAT,type:R.MenuItemType.BUTTON,icon:"UnderlineSingle",title:"Set underline",tooltip:"toolbar.underline",positions:[R.MenuPosition.TOOLBAR_START],disabled$:new k.Observable(l=>{var d;const c=(d=o.getEditable$(r,s))==null?void 0:d.subscribe(u=>{l.next(!u.value)});return()=>{c==null||c.unsubscribe()}}),activated$:new k.Observable(l=>{const c=e.onCommandExecuted(d=>{var g;const u=d.id;if(u!==f.SetRangeValuesMutation.id&&u!==f.SetSelectionsOperation.id)return;const h=(g=n.getLast())==null?void 0:g.primary,m=t.getCurrentUniverSheetInstance().getActiveSheet();let S;if(h!=null){const _=m.getRange(h.startRow,h.startColumn);S=_==null?void 0:_.getUnderline()}l.next(!!(S&&S.s))});return l.next(!1),c.dispose}),hidden$:R.getMenuHiddenObservable(i,a.UniverInstanceType.SHEET)}}function ra(i){const e=i.get(a.ICommandService),t=i.get(a.IUniverInstanceService),n=i.get(f.SelectionManagerService),o=i.get(f.SheetPermissionService),r=t.getCurrentUniverSheetInstance().getUnitId(),s=t.getCurrentUniverSheetInstance().getActiveSheet().getSheetId();return{id:fi.id,group:R.MenuGroup.TOOLBAR_FORMAT,type:R.MenuItemType.BUTTON,icon:"StrikethroughSingle",title:"Set strike through",tooltip:"toolbar.strikethrough",positions:[R.MenuPosition.TOOLBAR_START],disabled$:new k.Observable(l=>{var d;const c=(d=o.getEditable$(r,s))==null?void 0:d.subscribe(u=>{l.next(!u.value)});return()=>{c==null||c.unsubscribe()}}),activated$:new k.Observable(l=>{const c=e.onCommandExecuted(d=>{var g;const u=d.id;if(u!==f.SetRangeValuesMutation.id&&u!==f.SetSelectionsOperation.id)return;const h=(g=n.getLast())==null?void 0:g.primary,m=t.getCurrentUniverSheetInstance().getActiveSheet();let S;if(h!=null){const _=m.getRange(h.startRow,h.startColumn);S=_==null?void 0:_.getStrikeThrough()}l.next(!!(S&&S.s))});return l.next(!1),c.dispose}),hidden$:R.getMenuHiddenObservable(i,a.UniverInstanceType.SHEET)}}const sa=[{label:"9",value:9},{label:"10",value:10},{label:"11",value:11},{label:"12",value:12},{label:"14",value:14},{label:"16",value:16},{label:"18",value:18},{label:"20",value:20},{label:"22",value:22},{label:"24",value:24},{label:"26",value:26},{label:"28",value:28},{label:"36",value:36},{label:"48",value:48},{label:"72",value:72}],qi=[{label:se,value:"Times New Roman"},{label:se,value:"Arial"},{label:se,value:"Tahoma"},{label:se,value:"Verdana"},{label:se,value:"Microsoft YaHei"},{label:se,value:"SimSun"},{label:se,value:"SimHei"},{label:se,value:"Kaiti"},{label:se,value:"FangSong"},{label:se,value:"NSimSun"},{label:se,value:"STXinwei"},{label:se,value:"STXingkai"},{label:se,value:"STLiti"}];function la(i){const e=i.get(a.ICommandService),t=i.get(a.IUniverInstanceService),n=i.get(f.SelectionManagerService),o=i.get(f.SheetPermissionService),r=t.getCurrentUniverSheetInstance().getUnitId(),s=t.getCurrentUniverSheetInstance().getActiveSheet().getSheetId();return{id:qo.id,tooltip:"toolbar.font",group:R.MenuGroup.TOOLBAR_FORMAT,type:R.MenuItemType.SELECTOR,label:sr,positions:[R.MenuPosition.TOOLBAR_START],selections:qi,disabled$:new k.Observable(l=>{var d;const c=(d=o.getEditable$(r,s))==null?void 0:d.subscribe(u=>{l.next(!u.value)});return()=>{c==null||c.unsubscribe()}}),value$:new k.Observable(l=>{const c=qi[0].value,d=e.onCommandExecuted(u=>{var _;const h=u.id;if(h!==f.SetRangeValuesMutation.id&&h!==f.SetSelectionsOperation.id)return;const m=(_=n.getLast())==null?void 0:_.primary,S=t.getCurrentUniverSheetInstance().getActiveSheet();let g;if(m!=null){const I=S.getRange(m.startRow,m.startColumn);g=I==null?void 0:I.getFontFamily()}l.next(g??c)});return l.next(c),d.dispose}),hidden$:R.getMenuHiddenObservable(i,a.UniverInstanceType.SHEET)}}function aa(i){const e=i.get(a.ICommandService),t=i.get(a.IUniverInstanceService),n=i.get(f.SelectionManagerService),o=i.get(f.SheetPermissionService),r=t.getCurrentUniverSheetInstance().getUnitId(),s=t.getCurrentUniverSheetInstance().getActiveSheet().getSheetId();return{id:Ko.id,group:R.MenuGroup.TOOLBAR_FORMAT,type:R.MenuItemType.SELECTOR,tooltip:"toolbar.fontSize",label:{name:lr,props:{min:1,max:400}},positions:[R.MenuPosition.TOOLBAR_START],selections:sa,disabled$:new k.Observable(l=>{var d;const c=(d=o.getEditable$(r,s))==null?void 0:d.subscribe(u=>{l.next(!u.value)});return()=>{c==null||c.unsubscribe()}}),value$:new k.Observable(l=>{const d=e.onCommandExecuted(u=>{var _;const h=u.id;if(h!==f.SetRangeValuesMutation.id&&h!==f.SetSelectionsOperation.id)return;const m=(_=n.getLast())==null?void 0:_.primary,S=t.getCurrentUniverSheetInstance().getActiveSheet();let g;if(m!=null){const I=S.getRange(m.startRow,m.startColumn);g=I==null?void 0:I.getFontSize()}l.next(g??14)});return l.next(14),d.dispose}),hidden$:R.getMenuHiddenObservable(i,a.UniverInstanceType.SHEET)}}function ca(){return{id:f.ResetTextColorCommand.id,type:R.MenuItemType.BUTTON,title:"toolbar.resetColor",icon:"NoColor",positions:wn.id}}function da(i){const e=i.get(a.ICommandService),t=i.get(a.ThemeService);return i.get(a.IUniverInstanceService),{id:wn.id,icon:"FontColor",tooltip:"toolbar.textColor.main",group:R.MenuGroup.TOOLBAR_FORMAT,type:R.MenuItemType.BUTTON_SELECTOR,positions:[R.MenuPosition.TOOLBAR_START],selections:[{label:{name:Hn,hoverable:!1}}],value$:new k.Observable(n=>{const o=t.getCurrentTheme().textColor,r=e.onCommandExecuted(s=>{if(s.id===wn.id){const l=s.params.value;n.next(l??o)}});return n.next(o),r.dispose}),hidden$:R.getMenuHiddenObservable(i,a.UniverInstanceType.SHEET)}}function ua(){return{id:f.ResetBackgroundColorCommand.id,type:R.MenuItemType.BUTTON,title:"toolbar.resetColor",icon:"NoColor",positions:f.SetBackgroundColorCommand.id}}function ha(i){const e=i.get(a.ICommandService),t=i.get(a.ThemeService);return i.get(a.IUniverInstanceService),{id:f.SetBackgroundColorCommand.id,tooltip:"toolbar.fillColor.main",group:R.MenuGroup.TOOLBAR_FORMAT,type:R.MenuItemType.BUTTON_SELECTOR,positions:[R.MenuPosition.TOOLBAR_START],icon:"PaintBucket",selections:[{label:{name:Hn,hoverable:!1}}],value$:new k.Observable(n=>{const o=t.getCurrentTheme().primaryColor,r=e.onCommandExecuted(s=>{if(s.id===f.SetBackgroundColorCommand.id){const l=s.params.value;n.next(l??o)}});return n.next(o),r.dispose}),hidden$:R.getMenuHiddenObservable(i,a.UniverInstanceType.SHEET)}}const Ji=[{label:"align.left",icon:"LeftJustifyingSingle",value:a.HorizontalAlign.LEFT},{label:"align.center",icon:"HorizontallySingle",value:a.HorizontalAlign.CENTER},{label:"align.right",icon:"RightJustifyingSingle",value:a.HorizontalAlign.RIGHT}];function ma(i){const e=i.get(a.IUniverInstanceService),t=i.get(f.SelectionManagerService);return{id:f.SetHorizontalTextAlignCommand.id,icon:Ji[0].icon,positions:[R.MenuPosition.TOOLBAR_START],tooltip:"toolbar.horizontalAlignMode.main",group:R.MenuGroup.TOOLBAR_LAYOUT,type:R.MenuItemType.SELECTOR,selections:Ji,value$:new k.Observable(n=>{const o=i.get(a.ICommandService).onCommandExecuted(r=>{var u;const s=r.id;if(s!==f.SetHorizontalTextAlignCommand.id&&s!==f.SetSelectionsOperation.id)return;const l=(u=t.getLast())==null?void 0:u.primary,c=e.getCurrentUniverSheetInstance().getActiveSheet();let d;if(l!=null){const h=c.getRange(l.startRow,l.startColumn);d=h==null?void 0:h.getHorizontalAlignment()}n.next(d??a.HorizontalAlign.LEFT)});return n.next(a.HorizontalAlign.LEFT),o.dispose}),hidden$:R.getMenuHiddenObservable(i,a.UniverInstanceType.SHEET)}}const Qi=[{label:"align.top",icon:"AlignTopSingle",value:a.VerticalAlign.TOP},{label:"align.middle",icon:"VerticalCenterSingle",value:a.VerticalAlign.MIDDLE},{label:"align.bottom",icon:"AlignBottomSingle",value:a.VerticalAlign.BOTTOM}];function Sa(i){const e=i.get(a.IUniverInstanceService),t=i.get(f.SelectionManagerService);return{id:f.SetVerticalTextAlignCommand.id,icon:Qi[0].icon,tooltip:"toolbar.verticalAlignMode.main",group:R.MenuGroup.TOOLBAR_LAYOUT,type:R.MenuItemType.SELECTOR,positions:[R.MenuPosition.TOOLBAR_START],selections:Qi,value$:new k.Observable(n=>{const o=i.get(a.ICommandService).onCommandExecuted(r=>{var u;const s=r.id;if(s!==f.SetVerticalTextAlignCommand.id&&s!==f.SetSelectionsOperation.id)return;const l=(u=t.getLast())==null?void 0:u.primary,c=e.getCurrentUniverSheetInstance().getActiveSheet();let d;if(l!=null){const h=c.getRange(l.startRow,l.startColumn);d=h==null?void 0:h.getVerticalAlignment()}n.next(d??a.VerticalAlign.TOP)});return n.next(a.VerticalAlign.TOP),o.dispose}),hidden$:R.getMenuHiddenObservable(i,a.UniverInstanceType.SHEET)}}const eo=[{label:"textWrap.overflow",icon:"OverflowSingle",value:a.WrapStrategy.OVERFLOW},{label:"textWrap.wrap",icon:"AutowrapSingle",value:a.WrapStrategy.WRAP},{label:"textWrap.clip",icon:"TruncationSingle",value:a.WrapStrategy.CLIP}];function _a(i){const e=i.get(a.IUniverInstanceService),t=i.get(f.SelectionManagerService);return{id:f.SetTextWrapCommand.id,tooltip:"toolbar.textWrapMode.main",icon:eo[0].icon,group:R.MenuGroup.TOOLBAR_LAYOUT,type:R.MenuItemType.SELECTOR,positions:[R.MenuPosition.TOOLBAR_START],selections:eo,value$:new k.Observable(n=>{const o=i.get(a.ICommandService).onCommandExecuted(r=>{var u;const s=r.id;if(s!==f.SetTextWrapCommand.id&&s!==f.SetSelectionsOperation.id)return;const l=(u=t.getLast())==null?void 0:u.primary,c=e.getCurrentUniverSheetInstance().getActiveSheet();let d;if(l!=null){const h=c.getRange(l.startRow,l.startColumn);d=h==null?void 0:h.getWrapStrategy()}n.next(d??a.WrapStrategy.OVERFLOW)});return n.next(a.WrapStrategy.OVERFLOW),o.dispose}),hidden$:R.getMenuHiddenObservable(i,a.UniverInstanceType.SHEET)}}const to=[{label:"textRotate.none",icon:"NoRotationSingle",value:0},{label:"textRotate.angleUp",icon:"LeftRotationFortyFiveDegreesSingle",value:-45},{label:"textRotate.angleDown",icon:"RightRotationFortyFiveDegreesSingle",value:45},{label:"textRotate.vertical",icon:"VerticalTextSingle",value:"v"},{label:"textRotate.rotationUp",icon:"LeftRotationNinetyDegreesSingle",value:-90},{label:"textRotate.rotationDown",icon:"RightRotationNinetyDegreesSingle",value:90}];function ga(i){const e=i.get(a.IUniverInstanceService),t=i.get(f.SelectionManagerService);return{id:f.SetTextRotationCommand.id,tooltip:"toolbar.textRotateMode.main",icon:to[0].icon,group:R.MenuGroup.TOOLBAR_LAYOUT,type:R.MenuItemType.SELECTOR,selections:to,positions:[R.MenuPosition.TOOLBAR_START],value$:new k.Observable(n=>{const o=i.get(a.ICommandService).onCommandExecuted(r=>{var u;const s=r.id;if(s!==f.SetTextRotationCommand.id&&s!==f.SetSelectionsOperation.id)return;const l=(u=t.getLast())==null?void 0:u.primary,c=e.getCurrentUniverSheetInstance().getActiveSheet();let d;if(l!=null){const h=c.getRange(l.startRow,l.startColumn);d=h==null?void 0:h.getTextRotation()}(d==null?void 0:d.v)===a.BooleanNumber.TRUE?n.next("v"):n.next((d&&d.a)??0)});return n.next(0),o.dispose}),hidden$:R.getMenuHiddenObservable(i,a.UniverInstanceType.SHEET)}}function fa(){return{id:R.CopyCommand.id,group:R.MenuGroup.CONTEXT_MENU_FORMAT,type:R.MenuItemType.BUTTON,title:"rightClick.copy",icon:"Copy",positions:[R.MenuPosition.CONTEXT_MENU,"colHeaderContextMenu","rowHeaderContextMenu"]}}function pa(){return{id:R.PasteCommand.id,group:R.MenuGroup.CONTEXT_MENU_FORMAT,type:R.MenuItemType.BUTTON,title:"rightClick.paste",icon:"PasteSpecial",positions:[R.MenuPosition.CONTEXT_MENU,"colHeaderContextMenu","rowHeaderContextMenu"]}}const ht="sheet.menu.paste-special";function va(){return{id:ht,group:R.MenuGroup.CONTEXT_MENU_FORMAT,type:R.MenuItemType.SUBITEMS,icon:"PasteSpecial",title:"rightClick.pasteSpecial",positions:[R.MenuPosition.CONTEXT_MENU,"colHeaderContextMenu","rowHeaderContextMenu"]}}function Ca(){return{id:To.id,type:R.MenuItemType.BUTTON,title:"rightClick.pasteValue",positions:[ht]}}function Ia(){return{id:Eo.id,type:R.MenuItemType.BUTTON,title:"rightClick.pasteFormat",positions:[ht]}}function Ra(){return{id:yo.id,type:R.MenuItemType.BUTTON,title:"rightClick.pasteColWidth",positions:[ht]}}function ba(){return{id:Oo.id,type:R.MenuItemType.BUTTON,title:"rightClick.pasteBesidesBorder",positions:[ht]}}function Ma(){return{id:f.SetWorksheetRowIsAutoHeightCommand.id,group:R.MenuGroup.CONTEXT_MENU_LAYOUT,type:R.MenuItemType.BUTTON,positions:["rowHeaderContextMenu"],icon:"AutoHeight",title:"rightClick.fitContent"}}const Nt="sheet.menu.sheet-frozen";function wa(){return{id:Nt,group:R.MenuGroup.CONTEXT_MENU_LAYOUT,type:R.MenuItemType.SUBITEMS,title:"rightClick.freeze",icon:"FreezeToSelectedSingle",positions:[R.MenuPosition.CONTEXT_MENU]}}const Ii="sheet.header-menu.sheet-frozen";function Ta(){return{id:Ii,group:R.MenuGroup.CONTEXT_MENU_LAYOUT,type:R.MenuItemType.SUBITEMS,title:"rightClick.freeze",icon:"FreezeToSelectedSingle",positions:["rowHeaderContextMenu","colHeaderContextMenu"]}}function Ea(){return{id:An.id,type:R.MenuItemType.BUTTON,positions:[Nt,Ii],title:"rightClick.freeze",icon:"FreezeToSelectedSingle"}}function ya(){return{id:nr.id,type:R.MenuItemType.BUTTON,positions:[Nt],title:"rightClick.freezeRow",icon:"FreezeRowSingle"}}function Oa(){return{id:ir.id,type:R.MenuItemType.BUTTON,positions:[Nt],title:"rightClick.freezeCol",icon:"FreezeColumnSingle"}}function xa(){return{id:or.id,type:R.MenuItemType.BUTTON,positions:[Nt,Ii],title:"rightClick.cancelFreeze",icon:"CancelFreezeSingle"}}function Aa(){return{id:f.SetRowHiddenCommand.id,group:R.MenuGroup.CONTEXT_MENU_LAYOUT,type:R.MenuItemType.BUTTON,positions:["rowHeaderContextMenu"],icon:"Hide",title:"rightClick.hideSelectedRow"}}function Ha(){return{id:f.SetColHiddenCommand.id,group:R.MenuGroup.CONTEXT_MENU_LAYOUT,type:R.MenuItemType.BUTTON,positions:["colHeaderContextMenu"],icon:"Hide",title:"rightClick.hideSelectedColumn"}}function Da(i){const e=i.get(a.IUniverInstanceService),t=i.get(f.SelectionManagerService);function n(){var l;const r=e.getCurrentUniverSheetInstance().getActiveSheet(),s=(l=t.getSelections())==null?void 0:l.map(c=>c.range).filter(c=>c.rangeType===a.RANGE_TYPE.ROW);return!!(s!=null&&s.some(c=>{for(let d=c.startRow;d<=c.endRow;d++)if(!r.getRowVisible(d))return!0;return!1}))}const o=i.get(a.ICommandService);return{id:f.SetSelectedRowsVisibleCommand.id,group:R.MenuGroup.CONTEXT_MENU_LAYOUT,type:R.MenuItemType.BUTTON,positions:["rowHeaderContextMenu"],title:"rightClick.showHideRow",hidden$:new k.Observable(r=>{const s=o.onCommandExecuted(l=>{(l.id===f.SetSelectionsOperation.id||l.id===f.SetRowHiddenMutation.id||l.id===f.SetRowVisibleMutation.id)&&r.next(!n())});return r.next(!n()),()=>s.dispose()})}}function Na(i){const e=i.get(a.IUniverInstanceService),t=i.get(f.SelectionManagerService);function n(){var l;const r=e.getCurrentUniverSheetInstance().getActiveSheet(),s=(l=t.getSelections())==null?void 0:l.map(c=>c.range).filter(c=>c.rangeType===a.RANGE_TYPE.COLUMN);return!!(s!=null&&s.some(c=>{for(let d=c.startRow;d<=c.endRow;d++)if(!r.getColVisible(d))return!0;return!1}))}const o=i.get(a.ICommandService);return{id:f.SetSelectedColsVisibleCommand.id,group:R.MenuGroup.CONTEXT_MENU_LAYOUT,type:R.MenuItemType.BUTTON,positions:["colHeaderContextMenu"],title:"rightClick.showHideColumn",hidden$:new k.Observable(r=>{const s=o.onCommandExecuted(l=>{(l.id===f.SetSelectionsOperation.id||l.id===f.SetColHiddenMutation.id||l.id===f.SetColVisibleMutation.id)&&r.next(!n())});return r.next(!n()),()=>s.dispose()})}}function Pa(i){const e=i.get(a.ICommandService),t=i.get(a.IUniverInstanceService),n=i.get(f.SelectionManagerService);return{id:f.SetRowHeightCommand.id,group:R.MenuGroup.CONTEXT_MENU_LAYOUT,type:R.MenuItemType.BUTTON,icon:"AdjustHeight",positions:["rowHeaderContextMenu"],label:{name:Ci,props:{prefix:"rightClick.rowHeight",suffix:"px"}},value$:new k.Observable(o=>{function r(){var u;const l=(u=n.getLast())==null?void 0:u.primary,c=t.getCurrentUniverSheetInstance().getActiveSheet();let d;l!=null&&(d=c.getRowHeight(l.startRow)),o.next(d??0)}const s=e.onCommandExecuted(l=>{const c=l.id;if(c===f.SetRangeValuesMutation.id||c===f.SetSelectionsOperation.id)return r()});return r(),s.dispose})}}function La(i){const e=i.get(a.ICommandService),t=i.get(a.IUniverInstanceService),n=i.get(f.SelectionManagerService);return{id:f.SetColWidthCommand.id,group:R.MenuGroup.CONTEXT_MENU_LAYOUT,type:R.MenuItemType.BUTTON,icon:"AdjustWidth",positions:["colHeaderContextMenu"],label:{name:Ci,props:{prefix:"rightClick.columnWidth",suffix:"px"}},value$:new k.Observable(o=>{function r(){var u;const l=(u=n.getLast())==null?void 0:u.primary,c=t.getCurrentUniverSheetInstance().getActiveSheet();let d=0;l!=null&&(d=c.getColumnWidth(l.startColumn)),o.next(d)}const s=e.onCommandExecuted(l=>{const c=l.id;if(c===f.SetRangeValuesMutation.id||c===f.SetSelectionsOperation.id)return r()});return r(),s.dispose})}}function ae(i,e){const n=i.getCurrentUniverSheetInstance().getUnitId(),o=e.getRenderById(n);if(o==null)return;const{components:r,mainComponent:s,scene:l,engine:c}=o,d=s,u=r.get(oe.ROW),h=r.get(oe.COLUMN),m=r.get(oe.LEFT_TOP);return{spreadsheet:d,spreadsheetRowHeader:u,spreadsheetColumnHeader:h,spreadsheetLeftTopPlaceholder:m,scene:l,engine:c}}function ii(i,e,t,n){const{scaleX:o,scaleY:r}=t.getAncestorScale(),{startX:s,startY:l,endX:c,endY:d}=n.getCellByIndex(i,e,o,r);return{startX:s,startY:l,endX:c,endY:d}}function st(i,e,t,n,o){const r=t.getRelativeCoord(w.Vector2.FromArray([i,e])),{x:s,y:l}=r,c=t.getScrollXYByRelativeCoords(r,o),{scaleX:d,scaleY:u}=t.getAncestorScale(),h=n.getCellPositionByOffset(s,l,d,u,c),{row:m,column:S}=h,g=n.getNoMergeCellPositionByIndex(m,S,d,u),{startX:_,startY:I,endX:C,endY:b}=g;return{startX:_,startY:I,endX:C,endY:b,row:m,column:S}}function Xt(i,e,t,n){const o=t.getRelativeCoord(w.Vector2.FromArray([i,e])),r=t.getViewport(Y.VIEW_MAIN),s=t.getScrollXYByRelativeCoords(o,r),{scaleX:l,scaleY:c}=t.getAncestorScale(),{x:d,y:u}=s,h=i/l+d,m=e/c+u;return{x:h,y:m}}const Ua={spreadsheetLabel:"Spreadsheet",spreadsheetRightLabel:"more Sheets",toolbar:{undo:"Undo",redo:"Redo",formatPainter:"Paint format",currencyFormat:"Format as currency",percentageFormat:"Format as percent",numberDecrease:"Decrease decimal places",numberIncrease:"Increase decimal places",moreFormats:"More formats",font:"Font",fontSize:"Font size",bold:"Bold",italic:"Italic",strikethrough:"Strikethrough",subscript:"Subscript",superscript:"Superscript",underline:"Underline",textColor:{main:"Text color",right:"Choose color"},resetColor:"Reset",customColor:"CUSTOM",alternatingColors:"Alternating colors",confirmColor:"OK",cancelColor:"Cancel",collapse:"Collapse",fillColor:{main:"Fill color",right:"Choose color"},border:{main:"Border",right:"Border style"},mergeCell:{main:"Merge cells",right:"Choose merge type"},horizontalAlignMode:{main:"Horizontal align",right:"Alignment"},verticalAlignMode:{main:"Vertical align",right:"Alignment"},textWrapMode:{main:"Text wrap",right:"Text wrap mode"},textRotateMode:{main:"Text rotate",right:"Text rotate mode"},freezeTopRow:"Freeze top row",sortAndFilter:"Sort and filter",findAndReplace:"Find and replace",sum:"SUM",autoSum:"Auto SUM",moreFunction:"More functions",conditionalFormat:"Conditional format",comment:"Comment",pivotTable:"Pivot Table",chart:"Chart",screenshot:"Screenshot",splitColumn:"Split text",insertImage:"Insert image",insertLink:"Insert link",dataValidation:"Data validation",protection:"Protect the sheet",clearText:"Clear color",noColorSelectedText:"No color is selected",toolMore:"More",toolLess:"Less",toolClose:"Close",toolMoreTip:"More features",moreOptions:"More options",cellFormat:"Cell format config",print:"Print",borderMethod:{top:"Upper frame line",bottom:"Lower frame line",left:"Left frame line",right:"Right frame line"},more:"More"},defaultFmt:{Automatic:{text:"Automatic",value:"General",example:""},Number:{text:"Number",value:"##0.00",example:"1000.12"},Percent:{text:"Percent",value:"#0.00%",example:"12.21%"},PlainText:{text:"Plain text",value:"@",example:""},Scientific:{text:"Scientific",value:"0.00E+00",example:"1.01E+5"},Accounting:{text:"Accounting",value:"¥(0.00)",example:"¥(1200.09)"},Thousand:{text:"Ten Thousand",value:"w",example:"1亿2000万2500"},Currency:{text:"Currency",value:"¥0.00",example:"¥1200.09"},Digit:{text:"万元2位小数",value:"w0.00",example:"2万2500.55"},Date:{text:"Date",value:"yyyy-MM-dd",example:"2017-11-29"},Time:{text:"Time",value:"hh:mm AM/PM",example:"3:00 PM"},Time24H:{text:"Time 24H",value:"hh:mm",example:"15:00"},DateTime:{text:"Date time",value:"yyyy-MM-dd hh:mm AM/PM",example:"2017-11-29 3:00 PM"},DateTime24H:{text:"Date time 24H",value:"yyyy-MM-dd hh:mm",example:"2017-11-29 15:00"},CustomFormats:{text:"Custom Formats",value:"fmtOtherSelf",example:""}},format:{moreCurrency:"More currency formats",moreDateTime:"More date and time formats",moreNumber:"More number formats",titleCurrency:"Currency formats",decimalPlaces:"Decimal places",titleDateTime:"Date and time formats",titleNumber:"Number formats"},fontFamily:{TimesNewRoman:"Times New Roman",Arial:"Arial",Tahoma:"Tahoma",Verdana:"Verdana",MicrosoftYaHei:"Microsoft YaHei",SimSun:"SimSun",SimHei:"SimHei",Kaiti:"Kaiti",FangSong:"FangSong",NSimSun:"NSimSun",STXinwei:"STXinwei",STXingkai:"STXingkai",STLiti:"STLiti",HanaleiFill:"HanaleiFill",Anton:"Anton",Pacifico:"Pacifico"},print:{normalBtn:"Normal",layoutBtn:"Page Layout",pageBtn:"Page break preview",menuItemPrint:"Print (Ctrl+P)",menuItemAreas:"Print areas",menuItemRows:"Print title rows",menuItemColumns:"Print title columns"},align:{left:"left",center:"center",right:"right",top:"top",middle:"middle",bottom:"bottom"},dateFmtList:[{name:"1930-08-05",value:"yyyy-MM-dd"},{name:"1930/8/5",value:"yyyy/MM/dd"},{name:"08-05",value:"MM-dd"},{name:"8-5",value:"M-d"},{name:"13:30:30",value:"h:mm:ss"},{name:"13:30",value:"h:mm"},{name:"PM 01:30",value:"AM/PM hh:mm"},{name:"PM 1:30",value:"AM/PM h:mm"},{name:"PM 1:30:30",value:"AM/PM h:mm:ss"},{name:"08-05 PM 01:30",value:"MM-dd AM/PM hh:mm"}],numFmtList:[{name:"1235",value:"0"},{name:"1234.56",value:"0.00"},{name:"1,235",value:"#,##0"},{name:"1,234.56",value:"#,##0.00"},{name:"1,235",value:"#,##0_);(#,##0)"},{name:"1,235",value:"#,##0_);[Red](#,##0)"},{name:"1,234.56",value:"#,##0.00_);(#,##0.00)"},{name:"1,234.56",value:"#,##0.00_);[Red](#,##0.00)"},{name:"$1,235",value:"$#,##0_);($#,##0)"},{name:"$1,235",value:"$#,##0_);[Red]($#,##0)"},{name:"$1,234.56",value:"$#,##0.00_);($#,##0.00)"},{name:"$1,234.56",value:"$#,##0.00_);[Red]($#,##0.00)"},{name:"1234.56",value:"@"},{name:"123456%",value:"0%"},{name:"123456.00%",value:"0.00%"},{name:"1.23E+03",value:"0.00E+00"},{name:"1.2E+3",value:"##0.0E+0"},{name:"1234 5/9",value:"# ?/?"},{name:"1234 14/25",value:"# ??/??"},{name:"$ 1,235",value:'_($* #,##0_);_(...($* "-"_);_(@_)'},{name:"1,235",value:'_(* #,##0_);_(*..._(* "-"_);_(@_)'},{name:"$ 1,234.56",value:'_($* #,##0.00_);_(...($* "-"_);_(@_)'},{name:"1,234.56",value:'_(* #,##0.00_);...* "-"??_);_(@_)'}],button:{confirm:"OK",cancel:"Cancel",close:"Close",update:"Update",delete:"Delete",insert:"Insert",prevPage:"Previous",nextPage:"Next",total:"total:"},punctuation:{tab:"Tab",semicolon:"semicolond",comma:"comma",space:"space"},colorPicker:{collapse:"Collapse",customColor:"CUSTOM",change:"Change",confirmColor:"OK",cancelColor:"Cancel"},borderLine:{borderTop:"borderTop",borderBottom:"borderBottom",borderLeft:"borderLeft",borderRight:"borderRight",borderNone:"borderNone",borderAll:"borderAll",borderOutside:"borderOutside",borderInside:"borderInside",borderHorizontal:"borderHorizontal",borderVertical:"borderVertical",borderColor:"borderColor",borderSize:"borderSize",borderType:"borderType"},merge:{all:"Merge all",vertical:"Vertical merge",horizontal:"Horizontal merge",cancel:"Cancel merge",overlappingError:"Cannot merge overlapping areas",partiallyError:"Cannot perform this operation on partially merged cells",confirm:{title:"Continue merging would only keep the upper-left cell value, discard other values. Are you sure to continue?",cancel:"Cancel merging",confirm:"Continue merging"}},textWrap:{overflow:"Overflow",wrap:"Wrap",clip:"Clip"},textRotate:{none:"None",angleUp:"Tilt Up",angleDown:"Tilt Down",vertical:"Stack Vertically",rotationUp:"Rotate Up",rotationDown:"Rotate Down"},sheetConfig:{delete:"Delete",copy:"Copy",rename:"Rename",changeColor:"Change color",hide:"Hide",unhide:"Unhide",moveLeft:"Move left",moveRight:"Move right",resetColor:"Reset color",cancelText:"Cancel",chooseText:"Confirm color",tipNameRepeat:"The name of the tab page cannot be repeated! Please revise",noMoreSheet:"The workbook contains at least one visual worksheet. To delete the selected worksheet, please insert a new worksheet or show a hidden worksheet.",confirmDelete:"Are you sure to delete",redoDelete:"Can be undo by Ctrl+Z",noHide:"Can't hide, at least keep one sheet tag",chartEditNoOpt:"This operation is not allowed in chart editing mode!",sheetNameErrorTitle:"There was a problem",sheetNameSpecCharError:`The name cannot contain:[ ] : ? * / ' "`,sheetNameCannotIsEmptyError:"The sheet name cannot be empty.",sheetNameAlreadyExistsError:"The sheet name already exists. Please enter another name.",deleteSheet:"Delete worksheet",deleteSheetContent:"Confirm to delete this worksheet. It will not be retrieved after deletion. Are you sure you want to delete it?"},rightClick:{copy:"Copy",copyAs:"Copy as",cut:"Cut",paste:"Paste",pasteSpecial:"Paste Special",pasteValue:"Paste Value",pasteFormat:"Paste Format",pasteColWidth:"Paste Column Width",pasteBesidesBorder:"Paste Besides Border Styles",insert:"Insert",insertRow:"Insert Row",insertRowBefore:"Insert Row Before",insertColumn:"Insert Column",insertColumnBefore:"Insert Column Before",delete:"Delete",deleteCell:"Delete Cell",insertCell:"Insert Cell",deleteSelected:"Delete Selected ",hide:"Hide",hideSelected:"Hide Selected ",showHide:"Show Hidden",toTopAdd:"Towards Top Add",toBottomAdd:"Towards Bottom Add",toLeftAdd:"Towards Left Add",toRightAdd:"Towards Right Add",deleteSelectedRow:"Delete Selected row",deleteSelectedColumn:"Delete Selected column",hideSelectedRow:"Hide Selected Row",showHideRow:"Show Selected Row",rowHeight:"Row Height",hideSelectedColumn:"Hide Selected Column",showHideColumn:"Show Hide Column",columnWidth:"Column Width",to:"Towards",left:"Left",right:"Right",top:"Top",bottom:"Bottom",moveLeft:"Move Left",moveUp:"Move up",moveRight:"Move Right",moveDown:"Move Down",add:"Add",row:"Row",column:"Column",width:"Width",height:"Height",number:"Number",confirm:"Confirm",orderAZ:"A-Z order",orderZA:"Z-A order",clearSelection:"Clear",clearContent:"Clear Contents",clearFormat:"Clear Formats",clearAll:"Clear All",matrix:"Matrix operation",sortSelection:"Sort",filterSelection:"Filter",chartGeneration:"Create Chart",firstLineTitle:"First Line Title",untitled:"Untitled",array1:"One-dimensional array",array2:"Two-dimensional array",array3:"Multidimensional Arrays",diagonal:"Diagonal",antiDiagonal:"Anti-diagonal",diagonalOffset:"Diagonal offset",offset:"Offset",boolean:"Boolean",flip:"Flip",upAndDown:"Up and down",leftAndRight:"Left and right",clockwise:"Clockwise",counterclockwise:"Counterclockwise",transpose:"Transpose",matrixCalculation:"Matrix Calculation",plus:"Plus",minus:"Minus",multiply:"Multiply",divided:"Divided",power:"Power",root:"Root",log:"Log",delete0:"Delete 0 values at both ends",removeDuplicate:"Remove duplicate values",byRow:"By row",byCol:"By column",generateNewMatrix:"Generate new matrix",fitContent:"Fit for data",freeze:"Freeze",freezeCol:"Freeze to this column",freezeRow:"Freeze to this row",cancelFreeze:"Cancel freeze",zenEditor:"Full Screen Editor"},info:{tooltip:"Tooltip",notChangeMerge:"You cannot make partial changes to the merged cells",detailUpdate:"New opened",detailSave:"Local cache restored",row:"",column:"",loading:"Loading...",copy:"Copy",return:"Exit",rename:"Rename",tips:"Rename",noName:"Untitled spreadsheet",wait:"waiting for update",add:"Add",addLast:"more rows at bottom",backTop:"Back to the top",pageInfo:"Total ${total},${totalPage} page,current ${currentPage}",nextPage:"Next",tipInputNumber:"Please enter the number",tipInputNumberLimit:"The increase range is limited to 1-100",tipRowHeightLimit:"Row height must be between 0 ~ 545",tipColumnWidthLimit:"The column width must be between 0 ~ 2038",pageInfoFull:"Total ${total},${totalPage} page,All data displayed"},clipboard:{paste:{exceedMaxCells:"The number of cells pasted exceeds the maximum number of cells"}},statusbar:{sum:"Sum",average:"Average",min:"Min",max:"Max",count:"Numerical Count",countA:"Count",clickToCopy:"Click to Copy",copied:"Copied"},autoFill:{copy:"Copy Cell",series:"Fill Series",formatOnly:"Format Only",noFormat:"No Format"},rangeSelector:{placeholder:"Select range or input value",tooltip:"Select range"},shortcut:{sheet:{"zoom-in":"Zoom in","zoom-out":"Zoom out","reset-zoom":"Reset zoom level","select-below-cell":"Select the cell below","select-up-cell":"Select the cell above","select-left-cell":"Select the left cell","select-right-cell":"Select the right cell","select-next-cell":"Select the next cell","select-previous-cell":"Select the previous cell","select-up-value-cell":"Select the cell above that has value","select-below-value-cell":"Select the cell below that has value","select-left-value-cell":"Select the cell left that has value","select-right-value-cell":"Select the cell right that has value","expand-selection-down":"Expand selection down","expand-selection-up":"Expand selection up","expand-selection-left":"Expand selection left","expand-selection-right":"Expand selection right","expand-selection-to-left-gap":"Expand selection to the left gap","expand-selection-to-below-gap":"Expand selection to the below gap","expand-selection-to-right-gap":"Expand selection to the right gap","expand-selection-to-up-gap":"Expand selection to the up gap","select-all":"Select all","toggle-editing":"Toggle editing","delete-and-start-editing":"Clear and start editing","abort-editing":"Abort editing","break-line":"Break line","set-bold":"Toggle bold","set-italic":"Toggle italic","set-underline":"Toggle underline","set-strike-through":"Toggle strike through"}},"sheet-view":"Sheet View","sheet-edit":"Sheet Edit"},ar={spreadsheetLabel:"插件",spreadsheetRightLabel:"更多 Sheets",toolbar:{undo:"撤销",redo:"重做",formatPainter:"格式刷",currencyFormat:"货币格式",percentageFormat:"百分比格式",numberDecrease:"减少小数位数",numberIncrease:"增加小数位数",moreFormats:"更多格式",font:"字体",fontSize:"字号",bold:"粗体",italic:"斜体",strikethrough:"删除线",subscript:"下标",superscript:"上标",underline:"下划线",textColor:{main:"文本颜色",right:"颜色选择"},resetColor:"重置颜色",customColor:"自定义",alternatingColors:"交替颜色",confirmColor:"确定颜色",cancelColor:"取消",collapse:"收起",fillColor:{main:"单元格颜色",right:"颜色选择"},border:{main:"边框",right:"边框类型"},mergeCell:{main:"合并单元格",right:"选择合并类型"},horizontalAlignMode:{main:"水平对齐",right:"对齐方式"},verticalAlignMode:{main:"垂直对齐",right:"对齐方式"},textWrapMode:{main:"文本换行",right:"换行方式"},textRotateMode:{main:"文本旋转",right:"旋转方式"},freezeTopRow:"冻结首行",sortAndFilter:"排序和筛选",findAndReplace:"查找替换",sum:"求和",autoSum:"自动求和",moreFunction:"更多函数",conditionalalFormat:"条件格式",comment:"批注",pivotTable:"数据透视表",chart:"图表",screenshot:"截图",splitColumn:"分列",insertImage:"插入图片",insertLink:"插入链接",dataValidation:"数据验证",protection:"保护工作表内容",clearText:"清除颜色选择",noColorSelectedText:"没有颜色被选择",toolMore:"更多",toolLess:"少于",toolClose:"收起",toolMoreTip:"更多功能",moreOptions:"更多选项",cellFormat:"设置单元格格式",print:"打印",borderMethod:{top:"上框线",bottom:"下框线",left:"左框线",right:"右框线"},more:"更多"},defaultFmt:{Automatic:{text:"自动",value:"General",example:""},Number:{text:"数字",value:"##0.00",example:"1000.12"},Percent:{text:"百分比",value:"#0.00%",example:"12.21%"},PlainText:{text:"纯文本",value:"@",example:""},Scientific:{text:"科学计数",value:"0.00E+00",example:"1.01E+5"},Accounting:{text:"会计",value:"¥(0.00)",example:"¥(1200.09)"},Thousand:{text:"万元",value:"w",example:"1亿2000万2500"},Currency:{text:"货币",value:"¥0.00",example:"¥1200.09"},Digit:{text:"万元2位小数",value:"w0.00",example:"2万2500.55"},Date:{text:"日期",value:"yyyy-MM-dd",example:"2017-11-29"},Time:{text:"时间",value:"hh:mm AM/PM",example:"3:00 PM"},Time24H:{text:"时间24H",value:"hh:mm",example:"15:00"},DateTime:{text:"日期时间",value:"yyyy-MM-dd hh:mm AM/PM",example:"2017-11-29 3:00 PM"},DateTime24H:{text:"日期时间24H",value:"yyyy-MM-dd hh:mm",example:"2017-11-29 15:00"},CustomFormats:{text:"自定义格式",value:"fmtOtherSelf",example:""}},format:{moreCurrency:"更多货币格式",moreDateTime:"更多日期与时间格式",moreNumber:"更多数字格式",titleCurrency:"货币格式",decimalPlaces:"小数位数",titleDateTime:"日期与时间格式",titleNumber:"数字格式"},fontFamily:{TimesNewRoman:"Times New Roman",Arial:"Arial",Tahoma:"Tahoma",Verdana:"Verdana",MicrosoftYaHei:"微软雅黑",SimSun:"宋体",SimHei:"黑体",Kaiti:"楷体",FangSong:"仿宋",NSimSun:"新宋体",STXinwei:"华文新魏",STXingkai:"华文行楷",STLiti:"华文隶书",HanaleiFill:"HanaleiFill",Anton:"Anton",Pacifico:"Pacifico"},print:{normalBtn:"常规视图",layoutBtn:"页面布局",pageBtn:"分页预览",menuItemPrint:"打印(Ctrl+P)",menuItemAreas:"打印区域",menuItemRows:"打印标题行",menuItemColumns:"打印标题列"},align:{left:"左对齐",center:"中间对齐",right:"右对齐",top:"顶部对齐",middle:"居中对齐",bottom:"底部对齐"},button:{confirm:"确定",cancel:"取消",close:"关闭",update:"Update",delete:"Delete",insert:"新建",prevPage:"上一页",nextPage:"下一页",total:"总共:"},punctuation:{tab:"Tab 键",semicolon:"分号",comma:"逗号",space:"空格"},colorPicker:{collapse:"收起",customColor:"自定义",change:"切换",confirmColor:"确定",cancelColor:"取消"},borderLine:{borderTop:"上框线",borderBottom:"下框线",borderLeft:"左框线",borderRight:"右框线",borderNone:"无",borderAll:"所有",borderOutside:"外侧",borderInside:"内侧",borderHorizontal:"内侧横线",borderVertical:"内侧竖线",borderColor:"边框颜色",borderSize:"边框粗细",borderType:"边框线类型"},merge:{all:"全部合并",vertical:"垂直合并",horizontal:"水平合并",cancel:"取消合并",overlappingError:"不能合并重叠区域",partiallyError:"无法对部分合并单元格执行此操作",confirm:{title:"合并单元格仅保存左上角单元格的值,是否继续?",cancel:"取消合并",confirm:"继续合并"}},textWrap:{overflow:"溢出",wrap:"自动换行",clip:"截断"},textRotate:{none:"无旋转",angleUp:"向上倾斜",angleDown:"向下倾斜",vertical:"竖排文字",rotationUp:"向上90°",rotationDown:"向下90°"},sheetConfig:{delete:"删除",copy:"复制",rename:"重命名",changeColor:"更改颜色",hide:"隐藏",unhide:"取消隐藏",moveLeft:"向左移",moveRight:"向右移",resetColor:"重置颜色",cancelText:"取消",chooseText:"确定颜色",tipNameRepeat:"标签页的名称不能重复!请重新修改",noMoreSheet:"工作薄内至少含有一张可视工作表。若需删除选定的工作表,请先插入一张新工作表或显示一张隐藏的工作表。",confirmDelete:"是否删除",redoDelete:"可以通过Ctrl+Z撤销删除",noHide:"不能隐藏, 至少保留一个sheet标签",chartEditNoOpt:"图表编辑模式下不允许该操作!",sheetNameErrorTitle:"错误",sheetNameSpecCharError:`名称不能超过31个字符,首尾不能是' 且名称不能包含:\r
15
- [ ] : \\ ? * /`,sheetNameCannotIsEmptyError:"名称不能为空。",sheetNameAlreadyExistsError:"工作表已存在,请输入其它名称。",deleteSheet:"删除工作表",deleteSheetContent:"确认删除此工作表,删除后将不可找回,确定要删除吗?"},rightClick:{copy:"复制",copyAs:"复制为",cut:"剪切",paste:"粘贴",pasteSpecial:"选择性粘贴",pasteValue:"仅粘贴值",pasteFormat:"仅粘贴格式",pasteColWidth:"仅粘贴列宽",pasteBesidesBorder:"仅粘贴边框以外内容",insert:"插入",delete:"删除",insertRow:"插入行",insertRowBefore:"在上方插入行",insertColumn:"插入列",insertColumnBefore:"在左侧插入列",deleteCell:"删除单元格",insertCell:"插入单元格",deleteSelected:"删除选中",hide:"隐藏",hideSelected:"隐藏选中",showHide:"显示隐藏",toTopAdd:"向上增加",toBottomAdd:"向下增加",toLeftAdd:"向左增加",toRightAdd:"向右增加",deleteSelectedRow:"删除选中行",deleteSelectedColumn:"删除选中列",hideSelectedRow:"隐藏选中行",showHideRow:"显示隐藏行",rowHeight:"行高",hideSelectedColumn:"隐藏选中列",showHideColumn:"显示隐藏列",columnWidth:"列宽",to:"向",left:"左",right:"右",top:"上",bottom:"下",moveLeft:"左移",moveUp:"上移",moveRight:"右移",moveDown:"下移",add:"增加",row:"行",column:"列",width:"宽",height:"高",number:"数字",confirm:"确认",orderAZ:"A-Z顺序排列",orderZA:"Z-A降序排列",clearSelection:"清除",clearContent:"清除内容",clearFormat:"清除格式",clearAll:"清除全部",matrix:"矩阵操作选区",sortSelection:"排序选区",filterSelection:"筛选选区",chartGeneration:"图表生成",firstLineTitle:"首行为标题",untitled:"无标题",array1:"一维数组",array2:"二维数组",array3:"多维数组",diagonal:"对角线",antiDiagonal:"反对角线",diagonalOffset:"对角偏移",offset:"偏移量",boolean:"布尔值",flip:"翻转",upAndDown:"上下",leftAndRight:"左右",clockwise:"顺时针",counterclockwise:"逆时针",transpose:"转置",matrixCalculation:"矩阵计算",plus:"加",minus:"减",multiply:"乘",divided:"除",power:"次方",root:"次方根",log:"log",delete0:"删除两端0值",removeDuplicate:"删除重复值",byRow:"按行",byCol:"按列",generateNewMatrix:"生成新矩阵",fitContent:"适合数据",freeze:"冻结",freezeCol:"冻结列",freezeRow:"冻结行",cancelFreeze:"取消冻结",zenEditor:"禅模式编辑"},info:{tooltip:"提示",notChangeMerge:"不能对合并单元格做部分更改",detailUpdate:"新打开",detailSave:"已恢复本地缓存",row:"行",column:"列",loading:"渲染中···",copy:"副本",return:"返回",rename:"重命名",tips:"重命名",noName:"无标题的电子表格",wait:"待更新",add:"添加",addLast:"在底部添加",backTop:"回到顶部",pageInfo:"共${total}条,${totalPage}页,当前已显示${currentPage}页",nextPage:"下一页",tipInputNumber:"请输入数字",tipInputNumberLimit:"增加范围限制在1-100",tipRowHeightLimit:"行高必须在0 ~ 545之间",tipColumnWidthLimit:"列宽必须在0 ~ 2038之间",pageInfoFull:"共${total}条,${totalPage}页,已显示全部数据"},clipboard:{paste:{exceedMaxCells:"粘贴区域超出最大单元格数"}},statusbar:{sum:"求和",average:"平均值",min:"最小值",max:"最大值",count:"数值计数",countA:"计数",clickToCopy:"点击复制数值",copied:"已复制"},autoFill:{copy:"复制单元格",series:"填充序列",formatOnly:"仅填充格式",noFormat:"不带格式填充"},rangeSelector:{placeholder:"选择范围或输入值",tooltip:"选择范围"},shortcut:{sheet:{"zoom-in":"放大","zoom-out":"缩小","reset-zoom":"恢复缩放","select-below-cell":"选择下方单元格","select-up-cell":"选择上方单元格","select-left-cell":"选择左侧单元格","select-right-cell":"选择右侧单元格","select-next-cell":"选择后一个单元格","select-previous-cell":"选择前一个单元格","select-up-value-cell":"选择上方有值的单元格","select-below-value-cell":"选择下方有值的单元格","select-left-value-cell":"选择左侧有值的单元格","select-right-value-cell":"选择右侧有值的单元格","expand-selection-down":"向下扩展选区","expand-selection-up":"向上扩展选区","expand-selection-left":"向左扩展选区","expand-selection-right":"向右扩展选区","expand-selection-to-left-gap":"向左扩展选区到下一个边界","expand-selection-to-below-gap":"向下扩展选区到下一个边界","expand-selection-to-right-gap":"向右扩展选区到下一个边界","expand-selection-to-up-gap":"向上扩展选区到下一个边界","select-all":"全选","toggle-editing":"开始 / 结束编辑","delete-and-start-editing":"清空并开始编辑","abort-editing":"放弃编辑","break-line":"换行","set-bold":"切换粗体","set-italic":"切换斜体","set-underline":"切换下划线","set-strike-through":"切换删除线"}},"sheet-view":"浏览表格","sheet-edit":"编辑表格"},ka=(i,e,t=!1)=>{const n=h=>h.endRow-h.startRow+1,o=h=>h.endColumn-h.startColumn+1,r=n(e)%n(i),s=o(e)%o(i),l={startRow:0,endRow:n(i)-1,startColumn:0,endColumn:o(i)-1},c=Math.floor(n(e)/n(i)),d=Math.floor(o(e)/o(i)),u=[];if(!r&&!s)for(let h=1;h<=c;h++)for(let m=1;m<=d;m++){const S=n(i)*(h-1),g=o(i)*(m-1),_={startRow:S+e.startRow,endRow:S+e.startRow,startColumn:g+e.startColumn,endColumn:g+e.startColumn};u.push({repeatRelativeRange:l,startRange:_})}else if(!r&&s&&!t)for(let h=1;h<=c;h++){const m=n(i)*(h-1),S=0,g={startRow:m+e.startRow,endRow:m+e.startRow,startColumn:S+e.startColumn,endColumn:S+e.startColumn};u.push({repeatRelativeRange:l,startRange:g})}else if(r&&!s&&!t)for(let h=1;h<=d;h++){const S=o(i)*(h-1),g={startRow:0+e.startRow,endRow:0+e.startRow,startColumn:S+e.startColumn,endColumn:S+e.startColumn};u.push({repeatRelativeRange:l,startRange:g})}else{const h={startRow:e.startRow,endRow:e.startRow,startColumn:e.startColumn,endColumn:e.startColumn};u.push({startRange:h,repeatRelativeRange:l})}return u};class cr{constructor(){v(this,"_state",null);v(this,"_rect",null);v(this,"_focus",!1);v(this,"_state$",new k.BehaviorSubject(null));v(this,"state$",this._state$.asObservable());v(this,"_rect$",new k.BehaviorSubject(null));v(this,"rect$",this._rect$.asObservable());v(this,"_focus$",new k.BehaviorSubject(this._focus));v(this,"focus$",this._focus$.asObservable())}dispose(){this._state$.complete(),this._state=null,this._rect$.complete(),this._rect=null}setState(e){this._state=e,this._refresh(e)}getRect(){return this._rect}setRect(e){this._rect=e,this._rect$.next(e)}getState(){return this._state}setFocus(e=!1){this._focus=e,this._focus$.next(e)}_refresh(e){this._state$.next(e)}}const Pt=P.createIdentifier("univer.sheet-cell-editor-manager.service");class Ba{constructor(){v(this,"_position",null);v(this,"_position$",new k.BehaviorSubject(null));v(this,"position$",this._position$.asObservable());v(this,"_focus",!1);v(this,"_focus$",new k.BehaviorSubject(this._focus));v(this,"focus$",this._focus$.asObservable());v(this,"_fxBtnClick$",new k.BehaviorSubject(!1));v(this,"fxBtnClick$",this._fxBtnClick$.asObservable())}dispose(){this._position$.complete(),this._focus$.complete(),this._position=null,this._focus=!1}setPosition(e){this._position=e,this._refresh(e)}getPosition(){return this._position}setFocus(e=!1){this._focus=e,this._focus$.next(e)}handleFxBtnClick(e){this._fxBtnClick$.next(e)}_refresh(e){this._position$.next(e)}}const Dn=P.createIdentifier("univer.sheet-formula-editor-manager.service");var Va=Object.defineProperty,Fa=Object.getOwnPropertyDescriptor,ja=(i,e,t,n)=>{for(var o=n>1?void 0:n?Fa(e,t):e,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(e,t,o):s(o))||o);return n&&o&&Va(e,t,o),o},no=(i,e)=>(t,n)=>e(t,n,i);let Yt=class extends a.Disposable{constructor(e,t){super();v(this,"_previousSheetIndex",-1);this._commandService=e,this._univerInstanceService=t,this.disposeWithMe(this._commandService.beforeCommandExecuted((n,o)=>{if(n.id===f.RemoveSheetMutation.id)return this._beforeAdjustActiveSheetOnRemoveSheet(n)})),this.disposeWithMe(this._commandService.onCommandExecuted((n,o)=>{if(n.id===f.RemoveSheetMutation.id)return this._adjustActiveSheetOnRemoveSheet(n);if(n.id===f.SetWorksheetHideMutation.id&&n.params.hidden)return this._adjustActiveSheetOnHideSheet(n);if(!(o!=null&&o.fromCollab)){if(n.id===f.InsertSheetMutation.id)return this._adjustActiveSheetOnInsertSheet(n);if(n.id===f.SetWorksheetHideMutation.id&&!n.params.hidden)return this._adjustActiveSheetOnShowSheet(n)}}))}_adjustActiveSheetOnHideSheet(e){const{unitId:t,subUnitId:n}=e.params,o=this._univerInstanceService.getUniverSheetInstance(t);if(!o||(o==null?void 0:o.getRawActiveSheet())!==n)return;const s=o.getActiveSheetIndex(),l=Wa(o,s);this._switchToNextSheet(t,l)}_beforeAdjustActiveSheetOnRemoveSheet(e){const{unitId:t,subUnitId:n}=e.params,o=this._univerInstanceService.getUniverSheetInstance(t);if(!o)return;const r=o.getSheetBySheetId(n);r&&(this._previousSheetIndex=o.getSheetIndex(r))}_adjustActiveSheetOnRemoveSheet(e){if(this._previousSheetIndex===-1)return;const{unitId:t}=e.params,n=this._univerInstanceService.getUniverSheetInstance(t);if(!n||n.getRawActiveSheet())return;const r=this._previousSheetIndex,s=r>=1?r-1:0,l=n.getSheetByIndex(s);if(!l)throw new Error("[ActiveWorksheetController]: cannot find the next sheet!");this._switchToNextSheet(t,l.getSheetId())}_adjustActiveSheetOnInsertSheet(e){const{unitId:t,sheet:n}=e.params;this._switchToNextSheet(t,n.id)}_adjustActiveSheetOnShowSheet(e){const{unitId:t,subUnitId:n}=e.params;this._switchToNextSheet(t,n)}_switchToNextSheet(e,t){this._commandService.executeCommand(f.SetWorksheetActiveOperation.id,{unitId:e,subUnitId:t})}};Yt=ja([a.OnLifecycle(a.LifecycleStages.Ready,Yt),no(0,a.ICommandService),no(1,a.IUniverInstanceService)],Yt);function Wa(i,e){const t=i.getSheetSize();for(let n=e;n>-1;n--){const o=i.getSheetByIndex(n);if(!o.getConfig().hidden)return o.getSheetId()}for(let n=e;n<t;n++){const o=i.getSheetByIndex(n);if(!o.getConfig().hidden)return o.getSheetId()}throw new Error("[ActiveWorksheetController]: could not find the next unhidden sheet! Collaboration error perhaps.")}var $a=Object.defineProperty,za=Object.getOwnPropertyDescriptor,Xa=(i,e,t,n)=>{for(var o=n>1?void 0:n?za(e,t):e,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(e,t,o):s(o))||o);return n&&o&&$a(e,t,o),o},_t=(i,e)=>(t,n)=>e(t,n,i);let Zt=class{constructor(i,e,t,n,o){this._injector=i,this._sheetInterceptorService=e,this._selectionManagerService=t,this._univerInstanceService=n,this._sheetSkeletonManagerService=o,this._initialize()}_getUndoRedoParamsOfAutoHeight(i){const{_univerInstanceService:e,_sheetSkeletonManagerService:t,_injector:n}=this,{skeleton:o}=t.getCurrent(),r=o.calculateAutoHeightInRange(i),s=e.getCurrentUniverSheetInstance(),l=s.getUnitId(),d={subUnitId:s.getActiveSheet().getSheetId(),unitId:l,rowsAutoHeightInfo:r},u=f.SetWorksheetRowAutoHeightMutationFactory(n,d);return{undos:[{id:f.SetWorksheetRowAutoHeightMutation.id,params:u}],redos:[{id:f.SetWorksheetRowAutoHeightMutation.id,params:d}]}}_initialize(){const{_sheetInterceptorService:i,_selectionManagerService:e}=this;i.interceptCommand({getMutations:t=>t.id!==f.SetRangeValuesCommand.id?{redos:[],undos:[]}:this._getUndoRedoParamsOfAutoHeight(t.params.range)}),i.interceptCommand({getMutations:t=>t.id!==f.SetWorksheetRowIsAutoHeightCommand.id?{redos:[],undos:[]}:this._getUndoRedoParamsOfAutoHeight(t.params.ranges)}),i.interceptCommand({getMutations:t=>{var r;if(t.id!==f.SetStyleCommand.id)return{redos:[],undos:[]};if(!["ff","fs","tr","tb"].includes((r=t.params)==null?void 0:r.style.type))return{redos:[],undos:[]};const o=e.getSelectionRanges();return o!=null&&o.length?this._getUndoRedoParamsOfAutoHeight(o):{redos:[],undos:[]}}})}};Zt=Xa([a.OnLifecycle(a.LifecycleStages.Ready,Zt),_t(0,P.Inject(P.Injector)),_t(1,P.Inject(f.SheetInterceptorService)),_t(2,P.Inject(f.SelectionManagerService)),_t(3,P.Inject(a.IUniverInstanceService)),_t(4,P.Inject(exports.SheetSkeletonManagerService))],Zt);function Ya(i,e,t,n,o,r){const s=[],l=[];if(o.copyType===Xe.CUT){const{undos:c,redos:d}=Za(i,t,n,o,r);s.push(...d),l.push(...c)}else{const{undos:c,redos:d}=hr(t,n,i,e,r);s.push(...d),l.push(...c);const{undos:u,redos:h}=dr(t,n,i,e,r);s.push(...h),l.push(...u);const{undos:m,redos:S}=ur(t,n,i,e,r);s.push(...S),l.push(...m);const{undos:g,redos:_}=oi(t,n,i,e,r);s.push(..._),l.push(...g)}return{undos:l,redos:s}}function Za(i,e,t,n,o){let r=[],s=[];const{copyRange:l}=n;if(l){const c=o.get(a.IUniverInstanceService),d=o.get(f.SheetInterceptorService),u=c.getUniverSheetInstance(e),h=u==null?void 0:u.getSheetBySheetId(t);if(h){const m=h.getRange(l).getValues(),S=m.reduce((T,E,y)=>(E.forEach((O,x)=>{T.setValue(l.startRow+y,l.startColumn+x,null)}),T),new a.ObjectMatrix),g=m.reduce((T,E,y)=>(E.forEach((O,x)=>{T.setValue(l.startRow+y,l.startColumn+x,O)}),T),new a.ObjectMatrix),_=m.reduce((T,E,y)=>(E.forEach((O,x)=>{T.setValue(i.startRow+y,i.startColumn+x,O)}),T),new a.ObjectMatrix),I=h.getRange(i).getValues().reduce((T,E,y)=>(E.forEach((O,x)=>{T.setValue(i.startRow+y,i.startColumn+x,O)}),T),new a.ObjectMatrix),C={from:S.getMatrix(),to:_.getMatrix(),unitId:e,subUnitId:t},b={from:g.getMatrix(),to:I.getMatrix(),unitId:e,subUnitId:t},M=d.onCommandExecute({id:f.MoveRangeCommand.id,params:{toRange:i,fromRange:l}});r=[{id:f.MoveRangeMutation.id,params:C},...M.redos,{id:f.SetSelectionsOperation.id,params:{unitId:e,sheetId:t,pluginName:f.NORMAL_SELECTION_PLUGIN_NAME,selections:[{range:i}]}}],s=[{id:f.SetSelectionsOperation.id,params:{unitId:e,sheetId:t,pluginName:f.NORMAL_SELECTION_PLUGIN_NAME,selections:[{range:l}]}},...M.undos,{id:f.MoveRangeMutation.id,params:b}]}}return{undos:s,redos:r}}function dr(i,e,t,n,o){const r=[],s=[],{startColumn:l,startRow:c}=t,d=new a.ObjectMatrix;n.forValue((m,S,g)=>{d.setValue(m+c,S+l,{v:g.v})});const u={unitId:i,subUnitId:e,cellValue:d.getData()};r.push({id:f.SetRangeValuesMutation.id,params:u});const h=f.SetRangeValuesUndoMutationFactory(o,u);return s.push({id:f.SetRangeValuesMutation.id,params:h}),{undos:s,redos:r}}function ur(i,e,t,n,o){const r=[],s=[],{startColumn:l,startRow:c}=t,d=new a.ObjectMatrix;n.forValue((m,S,g)=>{var _;d.setValue(m+c,S+l,{s:g.s}),(_=g.p)!=null&&_.body&&d.setValue(m+c,S+l,{p:g.p})});const u={unitId:i,subUnitId:e,cellValue:d.getData()};r.push({id:f.SetRangeValuesMutation.id,params:u});const h=f.SetRangeValuesUndoMutationFactory(o,u);return s.push({id:f.SetRangeValuesMutation.id,params:h}),{undos:s,redos:r}}function hr(i,e,t,n,o){const r=[],s=[],l=new a.ObjectMatrix,{startColumn:c,startRow:d}=t;if(n.forValue((u,h,m)=>{m.s&&l.setValue(u+d,h+c,{s:null})}),l.getLength()>0){const u={subUnitId:e,unitId:i,cellValue:l.getData()};r.push({id:f.SetRangeValuesMutation.id,params:u});const h=f.SetRangeValuesUndoMutationFactory(o,u);s.push({id:f.SetRangeValuesMutation.id,params:h})}return{undos:s,redos:r}}function oi(i,e,t,n,o){const r=[],s=[],{startColumn:l,startRow:c,endColumn:d,endRow:u}=t;let h=!1;const m=[];if(n.forValue((_,I,C)=>{if(C.rowSpan){const b=C.colSpan||1,M={startRow:c+_,endRow:c+_+C.rowSpan-1,startColumn:l+I,endColumn:l+I+b-1};m.push(M),h=!0}else if(C.colSpan){const b=C.rowSpan||1,M={startRow:c+_,endRow:c+_+b-1,startColumn:l+I,endColumn:l+I+C.colSpan-1};m.push(M),h=!0}}),h){const I=o.get(a.IUniverInstanceService).getUniverSheetInstance(i),C=I==null?void 0:I.getSheetBySheetId(e);if(I&&C){const M=C.getMergeData().filter(y=>a.Rectangle.intersects({startRow:c,startColumn:l,endRow:u,endColumn:d},y)),T={unitId:i,subUnitId:e,ranges:M};r.push({id:f.RemoveWorksheetMergeMutation.id,params:T});const E=f.RemoveMergeUndoMutationFactory(o,T);s.push({id:f.AddWorksheetMergeMutation.id,params:E})}}const S={unitId:i,subUnitId:e,ranges:m};r.push({id:f.AddWorksheetMergeMutation.id,params:S});const g=f.AddMergeUndoMutationFactory(o,S);return s.push({id:f.RemoveWorksheetMergeMutation.id,params:g}),{undos:s,redos:r}}var Ga=Object.defineProperty,Ka=Object.getOwnPropertyDescriptor,qa=(i,e,t,n)=>{for(var o=n>1?void 0:n?Ka(e,t):e,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(e,t,o):s(o))||o);return n&&o&&Ga(e,t,o),o},je=(i,e)=>(t,n)=>e(t,n,i);let Gt=class extends a.Disposable{constructor(i,e,t,n,o,r,s){super(),this._currentUniverSheet=i,this._commandService=e,this._configService=t,this._sheetClipboardService=n,this._messageService=o,this._injector=r,this._localService=s,this._init()}_init(){[wo,Is,at].forEach(e=>this.disposeWithMe(this._commandService.registerAsMultipleCommand(e))),[To,Eo,yo,Oo].forEach(e=>this.disposeWithMe(this._commandService.registerCommand(e))),this.disposeWithMe(this._sheetClipboardService.addClipboardHook(this._initCopyingHooks())),this.disposeWithMe(this._sheetClipboardService.addClipboardHook(this._initPastingHook()));const i=this._initSpecialPasteHooks().map(e=>this._sheetClipboardService.addClipboardHook(e));this.disposeWithMe({dispose:()=>i.forEach(e=>e.dispose())})}_initCopyingHooks(){const i=this;let e=null;return{hookName:le.DEFAULT_COPY,isDefaultHook:!0,onBeforeCopy(t,n){e=i._getWorksheet(t,n)},onCopyCellContent(t,n){const o=e.getCell(t,n);return`${o==null?void 0:o.v}`||""},onCopyCellStyle:(t,n,o,r)=>{const s={};(o||r)&&(s.rowspan=`${o||1}`,s.colspan=`${r||1}`);const c=e.getRange(t,n).getTextStyle();let d="";return c&&(d=a.handleStyleToString(c)),d&&(s.style=d),s},onCopyColumn(t){return{width:`${e.getColumnWidth(t)}`}},onCopyRow(t){return{style:`height: ${e.getRowHeight(t)}px;`}},onAfterCopy(){e=null}}}_initPastingHook(){const i=this;let e=null,t=null,n=null;return{hookName:le.DEFAULT_PASTE,isDefaultHook:!0,onBeforePaste(o,r,s){n=i._getWorksheet(o,r),e=o,t=r;const l=i._configService.getConfig(f.MAX_CELL_PER_SHEET_KEY),{endRow:c,endColumn:d}=s;return l&&c*d>l?(i._messageService.show({type:ie.MessageType.Error,content:i._localService.t("clipboard.paste.exceedMaxCells")}),!1):!0},onPasteRows(o,r){const s=[],l=n.getMaxRows(),c=o.endRow-l,d=r.length-c;if(c>0){const m={};r.slice(d).forEach((g,_)=>{const I=g==null?void 0:g.style;if(!I)return;const C=I.split(";");let b=a.DEFAULT_WORKSHEET_ROW_HEIGHT;C.find(M=>{M=M.toLowerCase();const T=R.textTrim(M.substr(0,M.indexOf(":"))),E=R.textTrim(M.substr(M.indexOf(":")+1));return T==="height"?(b=parseFloat(E),!0):!1}),m[_]={h:b,hd:a.BooleanNumber.FALSE}});const S={unitId:e,subUnitId:t,range:{...o,startRow:l},rowInfo:m};s.push({id:f.InsertRowMutation.id,params:S})}const u={};r.slice(0,d).forEach((m,S)=>{const g=m.style;if(!g)return;const _=g.split(";");let I=a.DEFAULT_WORKSHEET_ROW_HEIGHT;_.find(C=>{C=C.toLowerCase();const b=R.textTrim(C.substr(0,C.indexOf(":"))),M=R.textTrim(C.substr(C.indexOf(":")+1));return b==="height"?(I=parseFloat(M),!0):!1}),u[S]=I});const h={unitId:e,subUnitId:t,ranges:[{...o,endRow:Math.min(o.endRow,l)}],rowHeight:u};return s.push({id:f.SetWorksheetRowHeightMutation.id,params:h}),{redos:s,undos:[]}},onPasteColumns(o,r,s){const l=[],c=n.getMaxColumns(),d=o.endColumn-c,u=r.length-d;if(d>0){const m={unitId:e,subUnitId:t,range:{...o,startColumn:c},colInfo:r.slice(u).map(S=>({w:S.width?+S.width:a.DEFAULT_WORKSHEET_COLUMN_WIDTH,hd:a.BooleanNumber.FALSE}))};l.push({id:f.InsertColMutation.id,params:m})}const h={unitId:e,subUnitId:t,ranges:[{...o,endRow:Math.min(o.endColumn,c)}],colWidth:r.slice(0,u).map(m=>m.width?+m.width:a.DEFAULT_WORKSHEET_COLUMN_WIDTH)};return l.push({id:f.SetWorksheetColWidthMutation.id,params:h}),{redos:l,undos:[]}},onPasteCells(o,r,s,l){return i._onPasteCells(o,r,e,t,s,l)},onAfterPaste(o){n=null}}}_onPasteCells(i,e,t,n,o,r){const s={get:this._injector.get.bind(this._injector)};return Ya(i,e,t,n,r,s)}_initSpecialPasteHooks(){const i={get:this._injector.get.bind(this._injector)},e=this,t={hookName:le.SPECIAL_PASTE_VALUE,specialPasteInfo:{label:"specialPaste.value"},onPasteCells:(s,l,c,d)=>{const u=e._currentUniverSheet.getCurrentUniverSheetInstance(),h=u.getUnitId(),m=u.getActiveSheet().getSheetId();return dr(h,m,s,l,i)}},n={hookName:le.SPECIAL_PASTE_FORMAT,specialPasteInfo:{label:"specialPaste.format"},onPasteCells(s,l,c,d){const u=e._currentUniverSheet.getCurrentUniverSheetInstance(),h=u.getUnitId(),m=u.getActiveSheet().getSheetId(),S=[],g=[],{undos:_,redos:I}=hr(h,m,s,l,i);S.push(...I),g.push(..._);const{undos:C,redos:b}=oi(h,m,s,l,i);S.push(...b),g.push(...C);const{undos:M,redos:T}=ur(h,m,s,l,i);return S.push(...T),g.push(...M),{undos:g,redos:S}}},o={hookName:le.SPECIAL_PASTE_COL_WIDTH,specialPasteInfo:{label:"specialPaste.colWidth"},onPasteCells(){return{undos:[],redos:[]}},onPasteColumns(s,l,c){const d=e._currentUniverSheet.getCurrentUniverSheetInstance(),u=d.getUnitId(),h=d.getActiveSheet().getSheetId(),m=[],g=e._getWorksheet(u,h).getMaxColumns(),_=s.endColumn-g,I=l.length-_,C={unitId:u,subUnitId:h,ranges:[{...s,endRow:Math.min(s.endColumn,g)}],colWidth:l.slice(0,I).map(b=>b.width?+b.width:a.DEFAULT_WORKSHEET_COLUMN_WIDTH)};return m.push({id:f.SetWorksheetColWidthMutation.id,params:C}),m.push({id:f.SetWorksheetColWidthMutation.id,params:C}),{redos:m,undos:[]}}},r={hookName:le.SPECIAL_PASTE_BESIDES_BORDER,specialPasteInfo:{label:"specialPaste.besidesBorder"},onPasteCells(s,l,c,d){const u=e._currentUniverSheet.getCurrentUniverSheetInstance(),h=u.getUnitId(),m=u.getActiveSheet().getSheetId(),S=[],g=[],{startColumn:_,startRow:I,endColumn:C,endRow:b}=s,M=new a.ObjectMatrix;l.forValue((x,D,U)=>{const N=U.s;typeof N=="object"&&M.setValue(x+I,D+_,{s:{...N,bd:void 0},v:U.v})});const T={unitId:h,subUnitId:m,cellValue:M.getData()};S.push({id:f.SetRangeValuesMutation.id,params:T});const E=f.SetRangeValuesUndoMutationFactory(i,T);g.push({id:f.SetRangeValuesMutation.id,params:E});const{undos:y,redos:O}=oi(h,m,s,l,i);return g.push(...y),S.push(...O),{redos:S,undos:g}}};return[t,n,o,r]}_getWorksheet(i,e){var n;const t=(n=this._currentUniverSheet.getUniverSheetInstance(i))==null?void 0:n.getSheetBySheetId(e);if(!t)throw new Error(`[SheetClipboardController]: cannot find a worksheet with unitId ${i} and subUnitId ${e}.`);return t}};Gt=qa([a.OnLifecycle(a.LifecycleStages.Rendered,Gt),je(0,a.IUniverInstanceService),je(1,a.ICommandService),je(2,a.IConfigService),je(3,lt),je(4,R.IMessageService),je(5,P.Inject(P.Injector)),je(6,P.Inject(a.LocaleService))],Gt);var Ja=Object.defineProperty,Qa=Object.getOwnPropertyDescriptor,ec=(i,e,t,n)=>{for(var o=n>1?void 0:n?Qa(e,t):e,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(e,t,o):s(o))||o);return n&&o&&Ja(e,t,o),o},gt=(i,e)=>(t,n)=>e(t,n,i);let Kt=class extends a.Disposable{constructor(i,e,t,n,o){super(),this._currentUniverService=i,this._contextMenuService=e,this._renderManagerService=t,this._selectionManagerService=n,this._selectionRenderService=o,this._currentUniverService.currentSheet$.subscribe(r=>{if(r==null)throw new Error("workbook is null");this._addListeners()})}_addListeners(){const i=ae(this._currentUniverService,this._renderManagerService);if(!i)return;const e=i.spreadsheet.onPointerDownObserver,t=e.add(l=>{if(l.button===2){const c=this._selectionManagerService.getSelections(),d=c==null?void 0:c[0];if(!d)return;const u=d.range.rangeType,h=this._selectionRenderService.convertSelectionRangeToData(d).rangeWithCoord,m=()=>{if(!h)return!1;const g=l.offsetX,_=l.offsetY;switch(u){case a.RANGE_TYPE.ROW:return h.startY<=_&&h.endY>=_;case a.RANGE_TYPE.COLUMN:return h.startX<=g&&h.endX>=g;default:return h.startX<=g&&h.endX>=g&&h.startY<=_&&h.endY>=_}},S=g=>{this._contextMenuService.triggerContextMenu(l,g)};m()?u===a.RANGE_TYPE.COLUMN?S(ee.COL_HEADER_CONTEXT_MENU):u===a.RANGE_TYPE.ROW?S(ee.ROW_HEADER_CONTEXT_MENU):S(R.MenuPosition.CONTEXT_MENU):S(R.MenuPosition.CONTEXT_MENU)}});this.disposeWithMe(a.toDisposable(()=>e.remove(t)));const o=i.spreadsheetRowHeader.onPointerDownObserver.add(l=>{l.button===2&&this._contextMenuService.triggerContextMenu(l,ee.ROW_HEADER_CONTEXT_MENU)});this.disposeWithMe(a.toDisposable(()=>e.remove(o)));const s=i.spreadsheetColumnHeader.onPointerDownObserver.add(l=>{l.button===2&&this._contextMenuService.triggerContextMenu(l,ee.COL_HEADER_CONTEXT_MENU)});this.disposeWithMe(a.toDisposable(()=>e.remove(s)))}};Kt=ec([a.OnLifecycle(a.LifecycleStages.Rendered,Kt),gt(0,a.IUniverInstanceService),gt(1,R.IContextMenuService),gt(2,w.IRenderManagerService),gt(3,P.Inject(f.SelectionManagerService)),gt(4,ce)],Kt);var tc=Object.defineProperty,nc=Object.getOwnPropertyDescriptor,ic=(i,e,t,n)=>{for(var o=n>1?void 0:n?nc(e,t):e,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(e,t,o):s(o))||o);return n&&o&&tc(e,t,o),o},jn=(i,e)=>(t,n)=>e(t,n,i);let qt=class extends a.RxDisposable{constructor(i,e,t){super(),this._currentUniverService=i,this._renderManagerService=e,this._undoRedoService=t,this._initialize(),this._commandExecutedListener()}_initialize(){this._initialNormalInput(),this._listenEditorBlur()}_listenEditorBlur(){this._currentUniverService.currentDoc$.pipe(k.takeUntil(this.dispose$)).subscribe(i=>{if(i==null)return;i.getUnitId()!==a.DOCS_NORMAL_EDITOR_UNIT_ID_KEY&&this._undoRedoService.clearUndoRedo(a.DOCS_NORMAL_EDITOR_UNIT_ID_KEY)})}_initialNormalInput(){const i={};this._currentUniverService.getCurrentUniverSheetInstance().getSheets().forEach(e=>{const t=e.getConfig();i[e.getSheetId()]={cellData:new a.ObjectMatrix(t.cellData),rowCount:t.rowCount,columnCount:t.columnCount}})}_commandExecutedListener(){}_getDocObject(){return K.getDocObject(this._currentUniverService,this._renderManagerService)}};qt=ic([a.OnLifecycle(a.LifecycleStages.Steady,qt),jn(0,a.IUniverInstanceService),jn(1,w.IRenderManagerService),jn(2,P.Inject(a.IUndoRedoService))],qt);const mr=[R.KeyCode.ARROW_DOWN,R.KeyCode.ARROW_UP,R.KeyCode.ARROW_LEFT,R.KeyCode.ARROW_RIGHT],oc=[R.KeyCode.ENTER,R.KeyCode.TAB,...mr];function rc(){const i=[];for(const e of mr)i.push({id:Ot.id,binding:e,preconditions:t=>In(t),staticParameters:{visible:!1,eventType:w.DeviceInputEventType.Keyboard,keycode:e,isShift:!1}}),i.push({id:Ot.id,binding:e|R.MetaKeys.SHIFT,preconditions:t=>In(t),staticParameters:{visible:!1,eventType:w.DeviceInputEventType.Keyboard,keycode:e,isShift:!0}});return i}const sc={id:Re.id,binding:R.KeyCode.ENTER,description:"shortcut.sheet.toggle-editing",group:"4_sheet-edit",preconditions:i=>In(i),staticParameters:{visible:!1,eventType:w.DeviceInputEventType.Keyboard,keycode:R.KeyCode.ENTER}},lc={id:Re.id,binding:R.KeyCode.TAB,preconditions:i=>In(i),staticParameters:{visible:!1,eventType:w.DeviceInputEventType.Keyboard,keycode:R.KeyCode.TAB}},ac={id:Re.id,binding:R.KeyCode.ESC,description:"shortcut.sheet.abort-editing",group:"4_sheet-edit",preconditions:i=>bo(i),staticParameters:{visible:!1,eventType:w.DeviceInputEventType.Keyboard,keycode:R.KeyCode.ESC}},cc={id:K.BreakLineCommand.id,description:"shortcut.sheet.break-line",group:"4_sheet-edit",preconditions:i=>bo(i),binding:R.KeyCode.ENTER|R.MetaKeys.ALT},dc={id:K.DeleteLeftCommand.id,preconditions:i=>Dr(i)||Mo(i),binding:R.KeyCode.BACKSPACE},uc={id:Re.id,description:"shortcut.sheet.delete-and-start-editing",group:"4_sheet-edit",preconditions:i=>Hr(i)&&!Mo(i),binding:R.KeyCode.BACKSPACE,staticParameters:{visible:!0,eventType:w.DeviceInputEventType.Keyboard,keycode:R.KeyCode.BACKSPACE}};var hc=Object.defineProperty,mc=Object.getOwnPropertyDescriptor,Sc=(i,e,t,n)=>{for(var o=n>1?void 0:n?mc(e,t):e,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(e,t,o):s(o))||o);return n&&o&&hc(e,t,o),o},Ce=(i,e)=>(t,n)=>e(t,n,i);function _c(i){const{textRuns:e=[],paragraphs:t=[]}=i;return e.some(n=>n.ts&&!a.Tools.isEmptyObject(n.ts))||t.some(n=>n.bullet)}let Jt=class extends a.Disposable{constructor(e,t,n,o,r,s,l,c,d,u){super();v(this,"_onInputSubscription");v(this,"_cursorChangeObservers");v(this,"_editorVisiblePrevious",!1);v(this,"_isCursorChange",0);this._currentUniverService=e,this._renderManagerService=t,this._commandService=n,this._editorBridgeService=o,this._contextService=r,this._cellEditorManagerService=s,this._lexerTreeBuilder=l,this._undoRedoService=c,this._sheetInterceptorService=d,this._selectionManagerService=u,this._initialize(),this._commandExecutedListener()}dispose(){var n;(n=this._onInputSubscription)==null||n.unsubscribe();const e=this._getEditorObject();if(e==null)return;const{document:t}=e;t.onPointerDownObserver.remove(this._cursorChangeObservers)}_initialize(){this._initialExitInput(),this._cursorStateListener()}_initialExitInput(){this._onInputSubscription=this._editorBridgeService.visible$.subscribe(e=>{const{visible:t,keycode:n,eventType:o}=e;if(t===this._editorVisiblePrevious)return;if(this._editorVisiblePrevious=t,t===!0){this._isCursorChange=o===w.DeviceInputEventType.PointerDown?2:1;return}this._isCursorChange=0;const r=this._selectionManagerService.getSelections(),s=this._selectionManagerService.getCurrent();if(s==null)return;const{unitId:l,sheetId:c,pluginName:d}=s;if(this._exitInput(e),n===R.KeyCode.ESC){this._commandService.syncExecuteCommand(f.SetSelectionsOperation.id,{unitId:l,subUnitId:c,pluginName:d,selections:r});return}const u=this._editorBridgeService.getState();if(u==null)return;const{unitId:h,sheetId:m,row:S,column:g,documentLayoutObject:_}=u;if(_==null||(this._moveCursor(n),this._editorBridgeService.getEditorDirty()===!1))return;const C=this._currentUniverService.getUniverSheetInstance(h),b=C==null?void 0:C.getSheetBySheetId(m);if(b==null)return;const M=a.Tools.deepClone(b.getCellRaw(S,g)||{}),E=_.documentModel.getSnapshot(),y=E.body;if(y==null)return;const O=y.dataStream;let D=O.substring(O.length-2,O.length)===a.DEFAULT_EMPTY_DOCUMENT_VALUE?O.substring(0,O.length-2):O;if(a.isFormulaString(D)){if(M.f===D)return;const B=this._lexerTreeBuilder.checkIfAddBracket(D);for(let A=0;A<B;A++)D+=G.matchToken.CLOSE_BRACKET;M.f=D,M.v=null,M.p=null}else if(_c(y))y.dataStream===`\r
16
- `?(M.v="",M.f=null,M.p=null):(M.p=E,M.v=null,M.f=null);else{if(D==M.v||D==""&&M.v==null)return;M.v=D,M.f=null,M.p=null}const U={subUnitId:m,unitId:h,workbook:C,worksheet:b,row:S,col:g},N=this._editorBridgeService.interceptor.fetchThroughInterceptors(this._editorBridgeService.interceptor.getInterceptPoints().AFTER_CELL_EDIT)(M,U);this._commandService.executeCommand(f.SetRangeValuesCommand.id,{subUnitId:m,unitId:h,range:{startRow:S,startColumn:g,endRow:S,endColumn:g},value:N}),l===h&&m!==c&&this._commandService.executeCommand(f.SetWorksheetActivateCommand.id,{subUnitId:m,unitId:h})})}_exitInput(e){this._contextService.setContextValue(a.FOCUSING_EDITOR_INPUT_FORMULA,!1),this._contextService.setContextValue(a.FOCUSING_EDITOR,!1),this._contextService.setContextValue(a.FOCUSING_EDITOR_BUT_HIDDEN,!1),this._contextService.setContextValue(a.FOCUSING_FORMULA_EDITOR,!1),this._cellEditorManagerService.setState({show:e.visible});const t=this._editorBridgeService.getCurrentEditorId();t!=null&&(this._undoRedoService.clearUndoRedo(t),this._undoRedoService.clearUndoRedo(a.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY))}_moveCursor(e){if(e==null||!oc.includes(e))return;let t=a.Direction.LEFT;switch(e){case R.KeyCode.ENTER:t=a.Direction.DOWN;break;case R.KeyCode.TAB:t=a.Direction.RIGHT;break;case R.KeyCode.ARROW_DOWN:t=a.Direction.DOWN;break;case R.KeyCode.ARROW_UP:t=a.Direction.UP;break;case R.KeyCode.ARROW_LEFT:t=a.Direction.LEFT;break;case R.KeyCode.ARROW_RIGHT:t=a.Direction.RIGHT;break}e===R.KeyCode.ENTER||e===R.KeyCode.TAB?this._commandService.executeCommand(Ke.id,{keycode:e,direction:t}):this._commandService.executeCommand(me.id,{direction:t})}_cursorStateListener(){const e=this._getEditorObject();if(e==null)return;const{document:t}=e;this._cursorChangeObservers=t.onPointerDownObserver.add(()=>{this._isCursorChange===1&&(this._isCursorChange=2)})}_commandExecutedListener(){const e=[Ot.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(e.includes(t.id)){const n=t.params,{keycode:o,isShift:r}=n;if(o!=null&&this._isCursorChange===2){this._moveInEditor(o,r);return}this._editorBridgeService.changeVisible(n)}}))}_moveInEditor(e,t){let n=a.Direction.LEFT;e===R.KeyCode.ARROW_DOWN?n=a.Direction.DOWN:e===R.KeyCode.ARROW_UP?n=a.Direction.UP:e===R.KeyCode.ARROW_RIGHT&&(n=a.Direction.RIGHT),t?this._commandService.executeCommand(K.MoveSelectionOperation.id,{direction:n}):this._commandService.executeCommand(K.MoveCursorOperation.id,{direction:n})}_getEditorObject(){return yn(this._editorBridgeService.getCurrentEditorId(),this._renderManagerService)}};Jt=Sc([a.OnLifecycle(a.LifecycleStages.Steady,Jt),Ce(0,a.IUniverInstanceService),Ce(1,w.IRenderManagerService),Ce(2,a.ICommandService),Ce(3,pe),Ce(4,a.IContextService),Ce(5,Pt),Ce(6,P.Inject(G.LexerTreeBuilder)),Ce(7,a.IUndoRedoService),Ce(8,P.Inject(f.SheetInterceptorService)),Ce(9,P.Inject(f.SelectionManagerService))],Jt);var gc=Object.defineProperty,fc=Object.getOwnPropertyDescriptor,pc=(i,e,t,n)=>{for(var o=n>1?void 0:n?fc(e,t):e,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(e,t,o):s(o))||o);return n&&o&&gc(e,t,o),o},Ie=(i,e)=>(t,n)=>e(t,n,i);let Qt=class extends a.RxDisposable{constructor(e,t,n,o,r,s,l,c,d,u){super();v(this,"_loadedMap",new Set);this._univerInstanceService=e,this._renderManagerService=t,this._editorBridgeService=n,this._docSkeletonManagerService=o,this._docViewModelManagerService=r,this._commandService=s,this._contextService=l,this._formulaEditorManagerService=c,this._undoRedoService=d,this._textSelectionManagerService=u,this._initialize()}_initialize(){this._syncFormulaEditorContent(),this._commandExecutedListener(),this._syncEditorSize(),this._listenFxBtnClick(),this._renderManagerService.currentRender$.pipe(k.takeUntil(this.dispose$)).subscribe(e=>{e===a.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY&&(this._loadedMap.has(e)||(this._initialMain(e),this._loadedMap.add(e)))}),this._textSelectionManagerService.textSelection$.pipe(k.takeUntil(this.dispose$)).subscribe(e=>{if(e==null)return;const{unitId:t}=e;t!==a.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY&&(this._contextService.setContextValue(a.FOCUSING_FORMULA_EDITOR,!1),this._undoRedoService.clearUndoRedo(a.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY))})}_listenFxBtnClick(){this._formulaEditorManagerService.fxBtnClick$.pipe(k.takeUntil(this.dispose$)).subscribe(()=>{var t;if(this._contextService.getContextValue(a.FOCUSING_EDITOR_BUT_HIDDEN)&&!this._contextService.getContextValue(a.FOCUSING_EDITOR)){this._univerInstanceService.setCurrentUniverDocInstance(a.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY),this._contextService.setContextValue(a.FOCUSING_FORMULA_EDITOR,!0);const n=this._univerInstanceService.getUniverDocInstance(a.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY);this._editorBridgeService.isVisible().visible===!1&&this._editorBridgeService.changeVisible({visible:!0,eventType:w.DeviceInputEventType.PointerDown});const r=(t=n==null?void 0:n.getBody())==null?void 0:t.dataStream;if(r==null)return;let s=r.startsWith("=")?r:`=${r}`;s=s.replace(/\r\n$/,"");const l=[{startOffset:s.length,endOffset:s.length}],c={unitId:a.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,body:{dataStream:s},segmentId:""};this._commandService.executeCommand(K.CoverContentCommand.id,c),this._textSelectionManagerService.replaceTextRanges(l)}})}_initialMain(e){const t=this._renderManagerService.getRenderById(e);if(t==null)return;const{mainComponent:n}=t;n!=null&&this.disposeWithMe(a.toDisposable(n.onPointerDownObserver.add(()=>{this._contextService.setContextValue(a.FOCUSING_FORMULA_EDITOR,!0),this._undoRedoService.clearUndoRedo(a.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY),this._editorBridgeService.isVisible().visible===!1&&this._editorBridgeService.changeVisible({visible:!0,eventType:w.DeviceInputEventType.PointerDown})})))}_syncEditorSize(){this._formulaEditorManagerService.position$.pipe(k.takeUntil(this.dispose$)).subscribe(e=>{if(e==null)return;const t=yn(a.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,this._renderManagerService),n=this._univerInstanceService.getUniverDocInstance(a.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY);if(t==null||n==null)return;const{width:o,height:r}=e,{engine:s}=t;n.updateDocumentDataPageSize(o),this._autoScroll(),requestIdleCallback(()=>{s.resizeBySize(o,r)})})}_syncFormulaEditorContent(){this._editorBridgeService.state$.pipe(k.takeUntil(this.dispose$)).subscribe(e=>{e==null||this._editorBridgeService.isForceKeepVisible()||this._editorSyncHandler(e)}),this._editorBridgeService.visible$.pipe(k.takeUntil(this.dispose$)).subscribe(e=>{if(e==null||e.visible===!1||this._editorBridgeService.isForceKeepVisible())return;const t=this._editorBridgeService.getState();t!=null&&this._editorSyncHandler(t)})}_editorSyncHandler(e){var s;const t=(s=e.documentLayoutObject.documentModel)==null?void 0:s.getBody();let n=t==null?void 0:t.dataStream,o=t==null?void 0:t.paragraphs,r=[];n==null||o==null||(e.isInArrayFormulaRange===!0&&this._editorBridgeService.isVisible().eventType===w.DeviceInputEventType.Dblclick?(n=`\r
17
- `,o=[{startIndex:0}]):e.isInArrayFormulaRange===!0&&(r=(t==null?void 0:t.textRuns)||[]),this._syncContentAndRender(a.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,n,o,r),this._autoScroll())}_commandExecutedListener(){const e=[K.RichTextEditingMutation.id,On.id],t=[a.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,a.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY];this.disposeWithMe(this._commandService.onCommandExecuted(n=>{var o,r;if(e.includes(n.id)){const s=n.params,{unitId:l}=s;if(t.includes(l)){const c=this._univerInstanceService.getUniverDocInstance(l),d=(o=c==null?void 0:c.getBody())==null?void 0:o.dataStream,u=(r=c==null?void 0:c.getBody())==null?void 0:r.paragraphs,h=l===a.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY?a.DOCS_NORMAL_EDITOR_UNIT_ID_KEY:a.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY;if(d==null||u==null)return;this._syncContentAndRender(h,d,u),this._autoScroll()}}}))}_syncContentAndRender(e,t,n,o=[]){var h;const r=[a.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,a.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY],s=this._docSkeletonManagerService.getSkeletonByUnitId(e),l=this._univerInstanceService.getUniverDocInstance(e),c=this._docViewModelManagerService.getViewModel(e);if(l==null||c==null||s==null)return;l.getBody().dataStream=t,l.getBody().paragraphs=this._clearParagraph(n),e===a.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY&&(l.getBody().textRuns=[]),o.length>0&&(l.getBody().textRuns=o),c.reset(l);const{skeleton:d}=s,u=this._renderManagerService.getRenderById(e);u!=null&&(d.calculate(),r.includes(e)&&((h=u.mainComponent)==null||h.makeDirty()))}_clearParagraph(e){const t=a.Tools.deepClone(e);for(const n of t)n.paragraphStyle&&(n.paragraphStyle.horizontalAlign=a.HorizontalAlign.UNSPECIFIED);return t}_autoScroll(){var g,_;const e=(g=this._docSkeletonManagerService.getSkeletonByUnitId(a.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY))==null?void 0:g.skeleton,t=this._formulaEditorManagerService.getPosition(),n=this._renderManagerService.getRenderById(a.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY),o=this._univerInstanceService.getUniverDocInstance(a.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY);if(e==null||t==null||n==null||o==null)return;const{marginTop:r=0,marginBottom:s=0}=o.getSnapshot().documentStyle,{scene:l,mainComponent:c}=n;let{actualHeight:d}=e.getActualSize();d+=r+s;const{width:u,height:h}=t,m=l.getViewport(K.VIEWPORT_KEY.VIEW_MAIN);let S=m==null?void 0:m.getScrollBar();d>h?S==null?m&&new w.ScrollBar(m,{enableHorizontal:!1}):m==null||m.resetSizeAndScrollBar():(S=null,m==null||m.scrollTo({x:0,y:0}),(_=m==null?void 0:m.getScrollBar())==null||_.dispose()),l.transformByState({width:u,height:d}),c==null||c.resize(u,d)}};Qt=pc([a.OnLifecycle(a.LifecycleStages.Steady,Qt),Ie(0,a.IUniverInstanceService),Ie(1,w.IRenderManagerService),Ie(2,pe),Ie(3,P.Inject(K.DocSkeletonManagerService)),Ie(4,P.Inject(K.DocViewModelManagerService)),Ie(5,a.ICommandService),Ie(6,a.IContextService),Ie(7,Dn),Ie(8,a.IUndoRedoService),Ie(9,P.Inject(K.TextSelectionManagerService))],Qt);var vc=Object.defineProperty,Cc=Object.getOwnPropertyDescriptor,Ic=(i,e,t,n)=>{for(var o=n>1?void 0:n?Cc(e,t):e,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(e,t,o):s(o))||o);return n&&o&&vc(e,t,o),o},Rc=(i,e)=>(t,n)=>e(t,n,i);let en=class extends a.Disposable{constructor(i){super(),this._currentUniverService=i,setTimeout(()=>{this._initialize()},0)}_initialize(){this._currentUniverService.createDoc({id:a.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,body:{dataStream:`${a.DEFAULT_EMPTY_DOCUMENT_VALUE}`,textRuns:[],paragraphs:[{startIndex:0}]},documentStyle:{}});const i={id:a.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,body:{dataStream:`${a.DEFAULT_EMPTY_DOCUMENT_VALUE}`,textRuns:[],paragraphs:[{startIndex:0}]},documentStyle:{pageSize:{width:1/0,height:1/0},marginTop:5,marginBottom:5,marginRight:0,marginLeft:0,paragraphLineGapDefault:0,renderConfig:{horizontalAlign:a.HorizontalAlign.UNSPECIFIED,verticalAlign:a.VerticalAlign.UNSPECIFIED,centerAngle:0,vertexAngle:0,wrapStrategy:a.WrapStrategy.WRAP}}};this._currentUniverService.createDoc(i)}};en=Ic([a.OnLifecycle(a.LifecycleStages.Rendered,en),Rc(0,a.IUniverInstanceService)],en);const bc="36",Mc="univer-sheet-container",Sr={sheetFooterBarHeight:bc,sheetContainer:Mc};var wc=Object.defineProperty,Tc=Object.getOwnPropertyDescriptor,Ec=(i,e,t,n)=>{for(var o=n>1?void 0:n?Tc(e,t):e,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(e,t,o):s(o))||o);return n&&o&&wc(e,t,o),o},_e=(i,e)=>(t,n)=>e(t,n,i);const io=-1e3,oo=5,yc=2;let tn=class extends a.Disposable{constructor(e,t,n,o,r,s,l,c,d,u,h){super();v(this,"_onInputSubscription");v(this,"_onInputActivateSubscription");v(this,"_editorVisiblePrevious",!1);this._docSkeletonManagerService=e,this._docViewModelManagerService=t,this._contextService=n,this._currentUniverService=o,this._renderManagerService=r,this._editorBridgeService=s,this._cellEditorManagerService=l,this._textSelectionRenderManager=c,this._textSelectionManagerService=d,this._commandService=u,this._localService=h,this._initialize(),this._commandExecutedListener()}dispose(){var e,t;(e=this._onInputSubscription)==null||e.unsubscribe(),(t=this._onInputActivateSubscription)==null||t.unsubscribe()}_initialize(){this._initialEditFocusListener(),this._initialStartEdit(),this._initialKeyboardListener(),this._initialCursorSync(),this._listenEditorFocus()}_listenEditorFocus(){const e=this._getEditorObject();e!=null&&this.disposeWithMe(a.toDisposable(e.document.onPointerDownObserver.add(()=>{var t;if(this._editorBridgeService.isVisible()){const n=this._editorBridgeService.getState(),o=this._editorBridgeService.getCurrentEditorId();if(n==null||o==null)return;const r=(t=this._docSkeletonManagerService.getSkeletonByUnitId(o))==null?void 0:t.skeleton;if(r==null)return;const{position:s,documentLayoutObject:l,canvasOffset:c,scaleX:d,scaleY:u}=n;this._fitTextSize(s,c,r,l,d,u)}})))}_initialCursorSync(){this._cellEditorManagerService.focus$.subscribe(()=>{this._textSelectionRenderManager.sync()})}_initialEditFocusListener(){this._onInputSubscription=this._editorBridgeService.state$.subscribe(e=>{if(e==null||this._editorBridgeService.isForceKeepVisible())return;const{position:t,documentLayoutObject:n,scaleX:o,editorUnitId:r}=e;if(this._getEditorObject()==null)return;const{startX:l,endX:c}=t,{textRotation:d,wrapStrategy:u,documentModel:h}=n,{a:m}=d;h.updateDocumentId(r),u===a.WrapStrategy.WRAP&&m===0&&h.updateDocumentDataPageSize((c-l)/o),this._currentUniverService.changeDoc(r,h),this._contextService.setContextValue(a.FOCUSING_EDITOR_BUT_HIDDEN,!0),this._textSelectionManagerService.replaceTextRanges([{startOffset:0,endOffset:0}]),this._textSelectionRenderManager.activate(io,io)})}_fitTextSize(e,t,n,o,r=1,s=1){const{startX:l,startY:c,endX:d,endY:u}=e,h=o.documentModel;if(h==null)return;const{actualWidth:m,actualHeight:S}=this._predictingSize(e,t,n,o,r,s),{verticalAlign:g,paddingData:_,fill:I}=o;let C=d-l,b=u-c;if(C<m&&(C=m),b<S)b=S,h.updateDocumentDataMargin(_);else{let M=_.t||0;g===a.VerticalAlign.MIDDLE?M=(b-S)/2:g===a.VerticalAlign.BOTTOM&&(M=b-S),M/=s,M=M<(_.t||0)?_.t||0:M,h.updateDocumentDataMargin({t:M})}n.calculate(),this._editAreaProcessing(C,b,e,t,I,r,s)}_predictingSize(e,t,n,o,r=1,s=1){const{startX:l,endX:c}=e,{textRotation:d,wrapStrategy:u}=o,h=o.documentModel,{a:m}=d,S=document.body.clientWidth;if(u===a.WrapStrategy.WRAP&&m===0){const{actualWidth:I,actualHeight:C}=n.getActualSize();return{actualWidth:I*r,actualHeight:C*s}}h==null||h.updateDocumentDataPageSize((S-l-t.left)/r),n.calculate();const g=n.getActualSize();let _=c-l;return _<g.actualWidth*r+oo*r&&(_=g.actualWidth*r+oo),h==null||h.updateDocumentDataPageSize(_/r),h==null||h.updateDocumentRenderConfig({horizontalAlign:a.HorizontalAlign.UNSPECIFIED}),{actualWidth:_,actualHeight:g.actualHeight*s}}_editAreaProcessing(e,t,n,o,r,s=1,l=1){var y;const c=this._getEditorObject();if(c==null)return;let{startX:d,startY:u}=n;const{document:h,scene:m,engine:S}=c,g=m.getViewport(K.VIEWPORT_KEY.VIEW_MAIN),_=document.body.clientHeight-u-parseFloat(Sr.sheetFooterBarHeight)-o.top-yc*2,I=document.body.clientWidth-d-o.left;let C=t,b=g==null?void 0:g.getScrollBar();C>_?(C=_,b==null?g&&new w.ScrollBar(g,{enableHorizontal:!1}):g==null||g.resetSizeAndScrollBar()):(b=null,(y=g==null?void 0:g.getScrollBar())==null||y.dispose()),e+=(b==null?void 0:b.barSize)||0,e>I&&(e=I);const M=S.getPixelRatio(),T=s*M,E=l*M;d=w.fixLineWidthByScale(d-w.FIX_ONE_PIXEL_BLUR_OFFSET,T),u=w.fixLineWidthByScale(u-w.FIX_ONE_PIXEL_BLUR_OFFSET,E),e=w.fixLineWidthByScale(e,T),t=w.fixLineWidthByScale(t,E),C=w.fixLineWidthByScale(t,E),this._addBackground(m,e/s,t/l,r),this._addBackground(m,e/s,t/l,r),m.transformByState({width:e,height:t}),h.resize(e,t),setTimeout(()=>{S.resizeBySize(e,C)},0),this._cellEditorManagerService.setState({startX:d,startY:u,endX:e+d,endY:C+u,show:!0})}_addBackground(e,t,n,o){const r="_backgroundRectHelperColor_",s=e.getObject(r);s==null&&o==null||(s==null?e.addObjects([new w.Rect(r,{width:t,height:n,fill:o,evented:!1})],K.DOCS_COMPONENT_MAIN_LAYER_INDEX):o==null?s.dispose():(s.setProps({fill:o}),s.transformByState({width:t,height:n})))}_initialStartEdit(){this._onInputActivateSubscription=this._editorBridgeService.visible$.subscribe(e=>{var T,E,y;const{visible:t,eventType:n,keycode:o}=e;if(t===this._editorVisiblePrevious||(this._editorVisiblePrevious=t,t===!1))return;const r=this._editorBridgeService.getState();if(r==null)return;const{position:s,documentLayoutObject:l,canvasOffset:c,scaleX:d,scaleY:u,editorUnitId:h,unitId:m,isInArrayFormulaRange:S=!1}=r,g=this._getEditorObject();if(g==null)return;const{document:_,scene:I}=g;this._contextService.setContextValue(a.FOCUSING_EDITOR,!0);const{documentModel:C}=l,b=this._docSkeletonManagerService.getSkeletonByUnitId(h);if(b==null||C==null)return;const{skeleton:M}=b;if(this._fitTextSize(s,c,M,l,d,u),n===w.DeviceInputEventType.Keyboard||n===w.DeviceInputEventType.Dblclick&&S){const O=a.Tools.deepClone(C.snapshot),x=(T=this._docViewModelManagerService.getCurrent())==null?void 0:T.docViewModel;this._resetBodyStyle(O.body),C.reset(O),x.reset(C),_.makeDirty(),(o===R.KeyCode.BACKSPACE||n===w.DeviceInputEventType.Dblclick)&&(M.calculate(),this._editorBridgeService.changeEditorDirty(!0)),this._textSelectionManagerService.replaceTextRanges([{startOffset:0,endOffset:0}])}else if(n===w.DeviceInputEventType.Dblclick){const O=C.getBody().dataStream.length-2||0;(E=I.getViewport(K.VIEWPORT_KEY.VIEW_MAIN))==null||E.scrollTo({y:1/0}),this._textSelectionManagerService.replaceTextRanges([{startOffset:O,endOffset:O}])}(y=this._renderManagerService.getRenderById(m))==null||y.scene.resetCursor()})}_resetBodyStyle(e){e.dataStream=a.DEFAULT_EMPTY_DOCUMENT_VALUE,e.textRuns!=null&&(e.textRuns.length===1?(e.textRuns[0].st=0,e.textRuns[0].ed=1):e.textRuns=void 0),e.paragraphs!=null&&(e.paragraphs.length===1?e.paragraphs[0].startIndex=0:e.paragraphs=[{startIndex:0}]),e.sectionBreaks!=null&&(e.sectionBreaks=void 0),e.tables!=null&&(e.tables=void 0),e.customRanges!=null&&(e.customRanges=void 0),e.customBlocks!=null&&(e.customBlocks=void 0)}_initialKeyboardListener(){this._textSelectionRenderManager.onInputBefore$.subscribe(e=>{const t=this._contextService.getContextValue(a.FOCUSING_FORMULA_EDITOR);this._contextService.getContextValue(a.FOCUSING_SHEET)&&!t&&this._showEditorByKeyboard(e)})}_showEditorByKeyboard(e){if(e==null)return;const t=e.event;this._commandService.executeCommand(Re.id,{visible:!0,eventType:w.DeviceInputEventType.Keyboard,keycode:t.which})}_commandExecutedListener(){const e=[K.RichTextEditingMutation.id,On.id],t=[a.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,a.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY];this.disposeWithMe(this._commandService.onCommandExecuted(n=>{var o;if(e.includes(n.id)){const r=n.params,{unitId:s}=r,l=this._editorBridgeService.getCurrentEditorId();if(l==null)return;this._editorBridgeService.changeEditorDirty(!0);const c=(o=this._docSkeletonManagerService.getSkeletonByUnitId(l))==null?void 0:o.skeleton;if(c==null||!t.includes(s))return;const d=this._editorBridgeService.getState();if(d==null)return;const{position:u,documentLayoutObject:h,canvasOffset:m,scaleX:S,scaleY:g}=d;this._fitTextSize(u,m,c,h,S,g)}}))}_getEditorObject(){return yn(this._editorBridgeService.getCurrentEditorId(),this._renderManagerService)}};tn=Ec([a.OnLifecycle(a.LifecycleStages.Steady,tn),_e(0,P.Inject(K.DocSkeletonManagerService)),_e(1,P.Inject(K.DocViewModelManagerService)),_e(2,a.IContextService),_e(3,a.IUniverInstanceService),_e(4,w.IRenderManagerService),_e(5,pe),_e(6,Pt),_e(7,w.ITextSelectionRenderManager),_e(8,P.Inject(K.TextSelectionManagerService)),_e(9,a.ICommandService),_e(10,P.Inject(a.LocaleService))],tn);const _r={id:"sheet.operation.set-activate-cell-edit",type:a.CommandType.OPERATION,handler:(i,e)=>(i.get(pe).setState(e),!0)};var Oc=Object.defineProperty,xc=Object.getOwnPropertyDescriptor,Ac=(i,e,t,n)=>{for(var o=n>1?void 0:n?xc(e,t):e,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(e,t,o):s(o))||o);return n&&o&&Oc(e,t,o),o},De=(i,e)=>(t,n)=>e(t,n,i);let nn=class extends a.RxDisposable{constructor(i,e,t,n,o,r,s,l){super(),this._sheetSkeletonManagerService=i,this._currentUniverService=e,this._commandService=t,this._renderManagerService=n,this._editorBridgeService=o,this._selectionManagerService=r,this._selectionRenderService=s,this._themeService=l,this._initialize(),this._commandExecutedListener()}dispose(){}_initialize(){this._initSelectionChangeListener(),this._initialEventListener()}_initSelectionChangeListener(){k.merge(this._selectionManagerService.selectionMoveEnd$,this._selectionManagerService.selectionMoveStart$).pipe(k.takeUntil(this.dispose$)).subscribe(i=>this._handleSelectionListener(i))}_handleSelectionListener(i){var N,B;const e=this._selectionManagerService.getCurrent();if((e==null?void 0:e.pluginName)!==f.NORMAL_SELECTION_PLUGIN_NAME||this._editorBridgeService.isVisible().visible===!0)return;const t=this._sheetSkeletonManagerService.getCurrent(),n=this._getSheetObject();if(t==null||n==null)return;const{skeleton:o,unitId:r,sheetId:s}=t,{scene:l,engine:c}=n;if(i==null||i.length===0||o==null||i[i.length-1]==null)return;const{primary:d}=i[i.length-1];if(d==null)return;const{startRow:u,startColumn:h}=d,m=this._selectionRenderService.convertCellRangeToInfo(d);if(m==null)return;const S=a.makeCellToSelection(m);if(S==null)return;const g=w.getCanvasOffsetByEngine(c);let{startX:_,startY:I,endX:C,endY:b}=S;const{scaleX:M,scaleY:T}=l.getAncestorScale(),E=l.getScrollXY(this._selectionRenderService.getViewPort());_=o.convertTransformToOffsetX(_,M,E),I=o.convertTransformToOffsetY(I,T,E),C=o.convertTransformToOffsetX(C,M,E),b=o.convertTransformToOffsetY(b,T,E);const y=this._currentUniverService.getCurrentUniverSheetInstance(),O=y.getActiveSheet(),x={workbook:y,worksheet:O,unitId:y.getUnitId(),subUnitId:O.getSheetId(),row:u,col:h},D=this._editorBridgeService.interceptor.fetchThroughInterceptors(this._editorBridgeService.interceptor.getInterceptPoints().BEFORE_CELL_EDIT)(O.getCell(u,h),x);let U=D&&o.getCellDocumentModelWithFormula(D);if((!U||U.documentModel==null)&&(U=o.getBlankCellDocumentModel(D)),(N=U.documentModel)==null||N.setZoomRatio(Math.max(M,T)),(D==null?void 0:D.isInArrayFormulaRange)===!0){const A=(B=U.documentModel)==null?void 0:B.getBody();A&&(A.textRuns=[{st:0,ed:A.dataStream.length-2,ts:{cl:{rgb:this._themeService.getCurrentTheme().textColorSecondary}}}])}this._commandService.executeCommand(_r.id,{position:{startX:_,startY:I,endX:C,endY:b},scaleX:M,scaleY:T,canvasOffset:g,row:u,column:h,unitId:r,sheetId:s,documentLayoutObject:U,editorUnitId:a.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,isInArrayFormulaRange:D==null?void 0:D.isInArrayFormulaRange})}_initialEventListener(){const i=this._getSheetObject();if(i==null)return;const{spreadsheet:e,spreadsheetColumnHeader:t,spreadsheetLeftTopPlaceholder:n,spreadsheetRowHeader:o}=i;e.onDblclickObserver.add(r=>{r.button!==2&&this._commandService.executeCommand(Re.id,{visible:!0,eventType:w.DeviceInputEventType.Dblclick})}),e.onPointerDownObserver.add(this._keepVisibleHideEditor.bind(this)),t.onPointerDownObserver.add(this._keepVisibleHideEditor.bind(this)),n.onPointerDownObserver.add(this._keepVisibleHideEditor.bind(this)),o.onPointerDownObserver.add(this._keepVisibleHideEditor.bind(this))}_keepVisibleHideEditor(){this._editorBridgeService.isForceKeepVisible()||this._hideEditor()}_hideEditor(){this._editorBridgeService.isVisible().visible===!0&&(this._selectionManagerService.makeDirty(!1),this._commandService.executeCommand(Re.id,{visible:!1,eventType:w.DeviceInputEventType.PointerDown}),setTimeout(()=>{this._selectionManagerService.makeDirty(!0)},0))}_getSheetObject(){return ae(this._currentUniverService,this._renderManagerService)}_commandExecutedListener(){const i=f.COMMAND_LISTENER_SKELETON_CHANGE;this.disposeWithMe(this._commandService.onCommandExecuted((e,t)=>{t!=null&&t.fromCollab||(e.id===f.SetWorksheetActiveOperation.id?this._keepVisibleHideEditor():i.includes(e.id)&&this._hideEditor())}))}};nn=Ac([a.OnLifecycle(a.LifecycleStages.Rendered,nn),De(0,P.Inject(exports.SheetSkeletonManagerService)),De(1,a.IUniverInstanceService),De(2,a.ICommandService),De(3,w.IRenderManagerService),De(4,pe),De(5,P.Inject(f.SelectionManagerService)),De(6,ce),De(7,P.Inject(a.ThemeService))],nn);var Hc=Object.defineProperty,Dc=Object.getOwnPropertyDescriptor,Nc=(i,e,t,n)=>{for(var o=n>1?void 0:n?Dc(e,t):e,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(e,t,o):s(o))||o);return n&&o&&Hc(e,t,o),o},ft=(i,e)=>(t,n)=>e(t,n,i);let on=class extends a.Disposable{constructor(i,e,t,n,o){super(),this._commandService=i,this._formatPainterService=e,this._currentUniverService=t,this._renderManagerService=n,this._selectionManagerService=o,this._initialize()}_initialize(){this._commandExecutedListener(),this._bindFormatPainterStatus()}_bindFormatPainterStatus(){this._formatPainterService.status$.subscribe(i=>{const{scene:e}=this._getSheetObject()||{};e&&(i!==fe.OFF?e.setDefaultCursor(w.CURSOR_TYPE.CELL):e.setDefaultCursor(w.CURSOR_TYPE.DEFAULT))})}_commandExecutedListener(){this.disposeWithMe(this._commandService.onCommandExecuted(i=>{if(i.id===f.SetSelectionsOperation.id&&this._formatPainterService.getStatus()!==fe.OFF){const{selections:e}=i.params,{range:t}=e[e.length-1];this._applyFormatPainter(t),this._formatPainterService.getStatus()===fe.ONCE&&this._commandService.executeCommand(vi.id)}}))}async _applyFormatPainter(i){const{styles:e,merges:t}=this._formatPainterService.getSelectionFormat(),n=this._currentUniverService.getCurrentUniverSheetInstance().getUnitId(),o=this._currentUniverService.getCurrentUniverSheetInstance().getActiveSheet().getSheetId();if(!e)return;const{startRow:r,startColumn:s,endRow:l,endColumn:c}=e.getDataRange(),d=l-r+1,u=c-s+1,h=Array.from({length:i.endRow-i.startRow+1},()=>Array.from({length:i.endColumn-i.startColumn+1},()=>({}))),m=[];h.forEach((g,_)=>{g.forEach((I,C)=>{const b=_%d+r,M=C%u+s,T=e.getValue(b,M);T&&(h[_][C].s=T)})}),t.forEach(g=>{const _={startRow:g.startRow-r,startColumn:g.startColumn-s,endRow:g.endRow-r,endColumn:g.endColumn-s},I=Math.floor((i.endRow-i.startRow+1)/d),C=Math.floor((i.endColumn-i.startColumn+1)/u);for(let b=0;b<I;b++)for(let M=0;M<C;M++)m.push({startRow:_.startRow+b*d+i.startRow,startColumn:_.startColumn+M*u+i.startColumn,endRow:_.endRow+b*d+i.startRow,endColumn:_.endColumn+M*u+i.startColumn})});const S={subUnitId:o,unitId:n,styleRange:i,styleValues:h,mergeRanges:m};await this._commandService.executeCommand(tr.id,S)}_getSheetObject(){return ae(this._currentUniverService,this._renderManagerService)}};on=Nc([a.OnLifecycle(a.LifecycleStages.Rendered,on),ft(0,a.ICommandService),ft(1,dt),ft(2,a.IUniverInstanceService),ft(3,w.IRenderManagerService),ft(4,P.Inject(f.SelectionManagerService))],on);const rn={id:"sheet.command.set-scroll-relative",type:a.CommandType.COMMAND,handler:async(i,e={offsetX:0,offsetY:0})=>{const t=i.get(a.ICommandService),n=i.get(ke),r=i.get(a.IUniverInstanceService).getCurrentUniverSheetInstance(),s=r.getActiveSheet(),{xSplit:l,ySplit:c}=s.getConfig().freeze,d=n.getCurrentScroll(),{offsetX:u=0,offsetY:h=0}=e||{},{sheetViewStartRow:m=0,sheetViewStartColumn:S=0,offsetX:g=0,offsetY:_=0}=d||{};return t.executeCommand(ct.id,{unitId:r.getUnitId(),sheetId:s.getSheetId(),sheetViewStartRow:m+c,sheetViewStartColumn:S+l,offsetX:g+u,offsetY:_+h})}},Ye={id:"sheet.command.scroll-view",type:a.CommandType.COMMAND,handler:async(i,e)=>{if(!e)return!1;const n=i.get(a.IUniverInstanceService).getCurrentUniverSheetInstance(),o=n.getActiveSheet(),s=i.get(ke).getCurrentScroll();if(!o)return!1;const l=i.get(a.ICommandService),{sheetViewStartRow:c,sheetViewStartColumn:d,offsetX:u,offsetY:h}=e,{sheetViewStartColumn:m,sheetViewStartRow:S,offsetX:g,offsetY:_}=s||{};return l.executeCommand(ct.id,{unitId:n.getUnitId(),sheetId:o.getSheetId(),sheetViewStartRow:c??m,sheetViewStartColumn:d??S,offsetX:u??g,offsetY:h??_})}};a.CommandType.COMMAND;var Pc=Object.defineProperty,Lc=Object.getOwnPropertyDescriptor,Uc=(i,e,t,n)=>{for(var o=n>1?void 0:n?Lc(e,t):e,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(e,t,o):s(o))||o);return n&&o&&Pc(e,t,o),o},Ne=(i,e)=>(t,n)=>e(t,n,i);const kc="__SpreadsheetFreezeRowMainName__",Bc="__SpreadsheetFreezeRowHeaderName__",Vc="__SpreadsheetFreezeColumnMainName__",Fc="__SpreadsheetFreezeColumnHeaderName__",Wn=4,jc=.01;let sn=class extends a.Disposable{constructor(e,t,n,o,r,s,l,c){super();v(this,"_rowFreezeHeaderRect");v(this,"_rowFreezeMainRect");v(this,"_columnFreezeHeaderRect");v(this,"_columnFreezeMainRect");v(this,"_freezeDownObservers",[]);v(this,"_freezeMoveObservers",[]);v(this,"_freezeLeaveObservers",[]);v(this,"_moveObserver");v(this,"_upObserver");v(this,"_viewportObservers",[]);v(this,"_changeToRow",-1);v(this,"_changeToColumn",-1);v(this,"_changeToOffsetX",0);v(this,"_changeToOffsetY",0);v(this,"_freezeNormalHeaderColor","");v(this,"_freezeNormalMainColor","");v(this,"_freezeActiveColor","");v(this,"_freezeHoverColor","");this._sheetSkeletonManagerService=e,this._currentUniverService=t,this._commandService=n,this._renderManagerService=o,this._selectionRenderService=r,this._selectionManagerService=s,this._scrollManagerService=l,this._themeService=c,this._initialize()}dispose(){super.dispose()}_initialize(){this._skeletonListener(),this._commandExecutedListener(),this._themeChangeListener()}_createFreeze(e=0){var y;const t=this._getFreeze();if(t==null)return;const n=(y=this._sheetSkeletonManagerService.getCurrent())==null?void 0:y.skeleton;if(n==null)return;const{startRow:o,startColumn:r}=t,s=this._getPositionByIndex(o,r);if(s==null)return;const l=this._getSheetObject();if(l==null)return;const c=l.engine,d=(c==null?void 0:c.width)||0,u=(c==null?void 0:c.height)||0,h=l.scene,{startX:m,startY:S}=s,{rowTotalHeight:g,columnTotalWidth:_,rowHeaderWidthAndMarginLeft:I,columnHeaderHeightAndMarginTop:C}=n,b=d>_+I?d:_+C,M=u>g+C?u:g+C;this._changeToRow=o,this._changeToColumn=r,this._changeToOffsetX=m,this._changeToOffsetY=S;const T=Math.max(h.scaleX,h.scaleY),E=Wn/(T<1?1:T);if(e===0){this._rowFreezeHeaderRect=new w.Rect(Bc,{fill:this._freezeNormalHeaderColor,width:I,height:E,left:0,top:S-E,zIndex:3});let O=this._freezeNormalHeaderColor;(o===-1||o===0)&&(O=this._freezeNormalMainColor),this._rowFreezeMainRect=new w.Rect(kc,{fill:O,width:b*2,height:E,left:I,top:S-E,zIndex:3}),h.addObjects([this._rowFreezeHeaderRect,this._rowFreezeMainRect],Ue)}else{this._columnFreezeHeaderRect=new w.Rect(Fc,{fill:this._freezeNormalHeaderColor,width:E,height:C,left:m-E,top:0,zIndex:3});let O=this._freezeNormalHeaderColor;(r===-1||r===0)&&(O=this._freezeNormalMainColor),this._columnFreezeMainRect=new w.Rect(Vc,{fill:O,width:E,height:M*2,left:m-E,top:C,zIndex:3}),h.addObjects([this._columnFreezeHeaderRect,this._columnFreezeMainRect],Ue)}this._eventBinding(e)}_eventBinding(e=0){let t=this._rowFreezeHeaderRect,n=this._rowFreezeMainRect;e===1&&(t=this._columnFreezeHeaderRect,n=this._columnFreezeMainRect);const o=this._getSheetObject();if(o==null)return;const{scene:r}=o;this._freezeMoveObservers.push(t==null?void 0:t.onPointerEnterObserver.add(()=>{t==null||t.setProps({fill:this._freezeHoverColor,zIndex:4}),r.setCursor(w.CURSOR_TYPE.GRAB)})),this._freezeMoveObservers.push(n==null?void 0:n.onPointerEnterObserver.add(()=>{t==null||t.setProps({fill:this._freezeHoverColor,zIndex:4}),r.setCursor(w.CURSOR_TYPE.GRAB)})),this._freezeLeaveObservers.push(t==null?void 0:t.onPointerLeaveObserver.add(()=>{t==null||t.setProps({fill:this._freezeNormalHeaderColor,zIndex:3}),r.resetCursor()})),this._freezeLeaveObservers.push(n==null?void 0:n.onPointerLeaveObserver.add(()=>{t==null||t.setProps({fill:this._freezeNormalHeaderColor,zIndex:3}),r.resetCursor()})),this._freezeDownObservers.push(t==null?void 0:t.onPointerDownObserver.add(s=>{this._freezeDown(s,t,n,e)})),this._freezeDownObservers.push(n==null?void 0:n.onPointerDownObserver.add(s=>{this._freezeDown(s,t,n,e)}))}_getCurrentLastVisibleRow(){var u;const e=this._getSheetObject();if(e==null)return;const t=(u=this._sheetSkeletonManagerService.getCurrent())==null?void 0:u.skeleton;if(t==null)return;const n=e.scene,o=Math.max(n.scaleX,n.scaleY),r=this._scrollManagerService.getCurrentScroll(),s=(e.engine.height-t.columnHeaderHeight)/o,l=(r==null?void 0:r.sheetViewStartRow)??0,c=l===0?-((r==null?void 0:r.offsetY)??0):t.rowHeightAccumulation[l-1]-((r==null?void 0:r.offsetY)??0);let d=0;for(let h=l,m=t.rowHeightAccumulation.length;h<m;h++)if(t.rowHeightAccumulation[h]-c>s){d=h;break}return d}_freezeDown(e,t,n,o=0){var h;const r=(h=this._sheetSkeletonManagerService.getCurrent())==null?void 0:h.skeleton;if(r==null)return;const s=this._getSheetObject();if(s==null)return;const{scene:l}=s;l.setCursor(w.CURSOR_TYPE.GRABBING),l.disableEvent();const c=this._getCurrentLastVisibleRow(),d=c===void 0?1/0:r.rowHeightAccumulation[c],u=l.getViewport(Y.VIEW_MAIN);this._moveObserver=l.onPointerMoveObserver.add(m=>{var b,M,T,E;const{startX:S,startY:g,row:_,column:I}=st(m.offsetX,m.offsetY,l,r,u);l.setCursor(w.CURSOR_TYPE.GRABBING);const C=Wn/Math.max(l.scaleX,l.scaleY);o===0?((b=t.transformByState({top:Math.min(g,d)-C/2}))==null||b.setProps({fill:this._freezeActiveColor}),(M=n.transformByState({top:Math.min(g,d)-C/2}))==null||M.setProps({fill:this._freezeNormalHeaderColor}),this._changeToRow=c===void 0?_:Math.min(_,c),this._changeToOffsetY=Math.min(g,d)):((T=t.transformByState({left:S-C/2}))==null||T.setProps({fill:this._freezeActiveColor}),(E=n.transformByState({left:S-C/2}))==null||E.setProps({fill:this._freezeNormalHeaderColor}),this._changeToColumn=I,this._changeToOffsetX=S)}),this._upObserver=l.onPointerUpObserver.add(()=>{var O;l.resetCursor(),l.enableEvent(),this._clearObserverEvent();const{rowHeaderWidthAndMarginLeft:m,columnHeaderHeightAndMarginTop:S}=r;o===0&&(this._changeToRow===0||this._changeToRow===-1)||o===1&&(this._changeToColumn===0||this._changeToColumn===-1)?(t.setProps({fill:this._freezeNormalHeaderColor}),n.setProps({fill:this._freezeNormalMainColor})):(t==null||t.setProps({fill:this._freezeNormalHeaderColor}),n==null||n.setProps({fill:this._freezeNormalHeaderColor}));const g=Wn/Math.max(l.scaleX,l.scaleY);o===0?(this._changeToRow===0||this._changeToRow===-1)&&(t.transformByState({top:S-g}),n.transformByState({top:S-g})):(this._changeToColumn===0||this._changeToColumn===-1)&&(t.transformByState({left:m-g}),n.transformByState({left:m-g}));const _=this._scrollManagerService.getCurrentScroll()||{sheetViewStartRow:0,sheetViewStartColumn:0},{sheetViewStartRow:I,sheetViewStartColumn:C}=_;if(C==null||I==null)return;const b=this._currentUniverService.getCurrentUniverSheetInstance(),M=b.getActiveSheet(),T=(O=M.getConfig())==null?void 0:O.freeze;let E=(T==null?void 0:T.xSplit)||0,y=(T==null?void 0:T.ySplit)||0;o===0&&(y=this._changeToRow-I,y=y<0?0:y),o===1&&(E=this._changeToColumn-C,E=E<0?0:E),this._commandService.executeCommand(f.SetFrozenCommand.id,{startRow:this._changeToRow,startColumn:this._changeToColumn,ySplit:y,xSplit:E,unitId:b.getUnitId(),subUnitId:M.getSheetId()})})}_updateViewport(e=-1,t=-1,n=0,o=0){var U;const r=this._getSheetObject();if(r==null)return;const{scene:s}=r,l=(U=this._sheetSkeletonManagerService.getCurrent())==null?void 0:U.skeleton;if(l==null)return;const{rowHeaderWidthAndMarginLeft:c,columnHeaderHeightAndMarginTop:d}=l,u=s.getViewport(Y.VIEW_COLUMN_LEFT),h=s.getViewport(Y.VIEW_COLUMN_RIGHT),m=s.getViewport(Y.VIEW_ROW_TOP),S=s.getViewport(Y.VIEW_ROW_BOTTOM),g=s.getViewport(Y.VIEW_LEFT_TOP),_=s.getViewport(Y.VIEW_MAIN),I=s.getViewport(Y.VIEW_MAIN_LEFT_TOP),C=s.getViewport(Y.VIEW_MAIN_LEFT),b=s.getViewport(Y.VIEW_MAIN_TOP);if(u==null||h==null||m==null||S==null||g==null||_==null||I==null||C==null||b==null)return;const{scaleX:M,scaleY:T}=s.getAncestorScale();this._viewportObservers.forEach(N=>{_.onScrollAfterObserver.remove(N)}),h.resize({left:c,top:0,height:d,right:0}),S.resize({left:0,top:d,bottom:0,width:c}),g.resize({left:0,top:0,width:c,height:d}),this._viewportObservers.push(_.onScrollAfterObserver.add(N=>{const{scrollX:B,scrollY:A,actualScrollX:H,actualScrollY:V}=N;h.updateScroll({scrollX:B,actualScrollX:H}).makeDirty(!0),S.updateScroll({scrollY:A,actualScrollY:V}).makeDirty(!0)}));let E=!0,y=!0;I.enable(),(e===-1||e===0)&&(E=!1),(t===-1||t===0)&&(y=!1);const O=l.getNoMergeCellPositionByIndexWithNoHeader(e-n,t-o,M,T),x=l.getNoMergeCellPositionByIndexWithNoHeader(e,t,M,T);I.disable(),b.disable(),C.disable(),m.disable(),u.disable(),I.resetPadding(),b.resetPadding(),C.resetPadding(),m.resetPadding(),u.resetPadding();const D=this._scrollManagerService.getCurrentScroll();if(E===!1&&y===!1)_.resize({left:c,top:d,bottom:0,right:0}),_.resetPadding(),this._commandService.executeCommand(Ye.id,D??{sheetViewStartRow:0,sheetViewStartColumn:0,offsetX:0,offsetY:0});else if(E===!0&&y===!1){const N=x.startY-O.startY;_.resize({left:c,top:d+N,bottom:0,right:0}),_.setPadding({startY:O.startY,endY:x.startY,startX:0,endX:0}),this._commandService.executeCommand(Ye.id,D??{sheetViewStartRow:0,offsetY:0}),b.resize({left:c,top:d,height:N,right:0}),b.updateScroll({actualScrollY:O.startY,x:_.scrollX,actualScrollX:_.actualScrollX}).makeDirty(!0),m.resize({left:0,top:d,width:c,height:N}),m.updateScroll({actualScrollY:O.startY}).makeDirty(!0),S.resize({left:0,top:d+N,bottom:0,width:c}),this._viewportObservers.push(_.onScrollAfterObserver.add(B=>{const{scrollX:A,actualScrollX:H}=B;b.updateScroll({scrollX:A,actualScrollX:H}).makeDirty(!0)})),b.enable(),m.enable()}else if(E===!1&&y===!0){const N=x.startX-O.startX;_.resize({left:c+N,top:d,bottom:0,right:0}),_.setPadding({startX:O.startX,endX:x.startX,startY:0,endY:0}),this._commandService.executeCommand(Ye.id,D??{sheetViewStartColumn:0,offsetX:0}),C.resize({left:c,top:d,width:N,bottom:0,right:0}),C.updateScroll({actualScrollX:O.startX,y:_.scrollY,actualScrollY:_.actualScrollY}).makeDirty(!0),u.resize({left:c,top:0,width:N,height:d}),u.updateScroll({actualScrollX:O.startX}).makeDirty(!0),h.resize({left:c+N,top:0,height:d,right:0}),this._viewportObservers.push(_.onScrollAfterObserver.add(B=>{const{scrollY:A,actualScrollY:H}=B;C.updateScroll({scrollY:A,actualScrollY:H}).makeDirty(!0)})),C.enable(),u.enable()}else{const N=x.startX-O.startX,B=x.startY-O.startY;_.resize({left:c+N,top:d+B,bottom:0,right:0}),_.setPadding({startY:O.startY,endY:x.startY,startX:O.startX,endX:x.startX}),this._commandService.executeCommand(Ye.id,{sheetViewStartRow:0,sheetViewStartColumn:0,offsetX:0,offsetY:0}),C.resize({left:c,top:d+B,width:N,bottom:0}),C.updateScroll({actualScrollX:O.startX,y:_.scrollY,actualScrollY:_.actualScrollY}).makeDirty(!0),b.resize({left:c+N,top:d,height:B,right:0}),b.updateScroll({actualScrollY:O.startY,x:_.scrollX,actualScrollX:_.actualScrollX}).makeDirty(!0),I.resize({left:c,top:d,width:N,height:B}),I.updateScroll({actualScrollX:O.startX,actualScrollY:O.startY}).makeDirty(!0),m.resize({left:0,top:d,width:c,height:B}),m.updateScroll({actualScrollY:O.startY}).makeDirty(!0),S.resize({left:0,top:d+B,bottom:0,width:c}),u.resize({left:c,top:0,width:N,height:d}),u.updateScroll({actualScrollX:O.startX}).makeDirty(!0),h.resize({left:c+N,top:0,height:d,right:0}),this._viewportObservers.forEach(A=>{_.onScrollAfterObserver.remove(A)}),this._viewportObservers.push(_.onScrollAfterObserver.add(A=>{const{scrollX:H,scrollY:V,actualScrollX:F,actualScrollY:j}=A;S.updateScroll({scrollY:V,actualScrollY:j}).makeDirty(!0),h.updateScroll({scrollX:H,actualScrollX:F}).makeDirty(!0),C.updateScroll({scrollY:V,actualScrollY:j}).makeDirty(!0),b.updateScroll({scrollX:H,actualScrollX:F}).makeDirty(!0)})),I.enable(),b.enable(),C.enable(),m.enable(),u.enable()}}_skeletonListener(){this.disposeWithMe(a.toDisposable(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(e=>{[f.SetWorksheetActiveOperation.id].includes((e==null?void 0:e.commandId)||"")&&this._refreshCurrent()})))}_refreshCurrent(){const n=this._currentUniverService.getCurrentUniverSheetInstance().getActiveSheet().getConfig().freeze,{startRow:o=-1,startColumn:r=-1,ySplit:s=0,xSplit:l=0}=n;this._refreshFreeze(o,r,s,l)}_themeChangeListener(){this._themeChange(this._themeService.getCurrentTheme()),this.disposeWithMe(a.toDisposable(this._themeService.currentTheme$.subscribe(e=>{this._clearFreeze(),this._themeChange(e),this._refreshCurrent()})))}_themeChange(e){this._freezeNormalHeaderColor=e.grey400,this._freezeNormalMainColor=new a.ColorKit(e.grey400).setAlpha(jc).toRgbString(),this._freezeActiveColor=e.primaryColor,this._freezeHoverColor=e.grey500}_commandExecutedListener(){const e=[f.SetFrozenMutation.id,xe.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(e.includes(t.id)){const n=this._currentUniverService.getCurrentUniverSheetInstance(),o=n.getActiveSheet(),r=t.params,{unitId:s,subUnitId:l}=r;if(!(s===n.getUnitId()&&l===o.getSheetId())||o.getConfig().freeze==null)return;const{startRow:d=-1,startColumn:u=-1,ySplit:h=0,xSplit:m=0}=o.getConfig().freeze;this._refreshFreeze(d,u,h,m)}else if(t.id===f.DeltaRowHeightCommand.id){const n=this._getFreeze();t.params&&n&&t.params.anchorRow<n.startRow&&this._refreshCurrent()}else if(t.id===f.DeltaColumnWidthCommand.id){const n=this._getFreeze();t.params&&n&&t.params.anchorCol<n.startColumn&&this._refreshCurrent()}else if(t.id===f.SetWorksheetRowAutoHeightMutation.id){const n=t.params,o=this._getFreeze();if(o&&o.startRow>-1&&n.rowsAutoHeightInfo.some(r=>r.row<o.startRow)){const r=this._sheetSkeletonManagerService.currentSkeleton$.subscribe(()=>{this._refreshCurrent(),setTimeout(()=>{r.unsubscribe()})})}}}))}_clearObserverEvent(){const e=this._getSheetObject();if(e==null)return;const{scene:t}=e;t.onPointerMoveObserver.remove(this._moveObserver),t.onPointerUpObserver.remove(this._upObserver),this._moveObserver=null,this._upObserver=null}_clearFreeze(){var n,o,r,s;(n=this._rowFreezeHeaderRect)==null||n.dispose(),(o=this._rowFreezeMainRect)==null||o.dispose(),(r=this._columnFreezeHeaderRect)==null||r.dispose(),(s=this._columnFreezeMainRect)==null||s.dispose();const e=this._getSheetObject();if(e==null)return;const{scene:t}=e;[...this._freezeDownObservers,...this._freezeMoveObservers,...this._freezeLeaveObservers].forEach(l=>{t.onPointerDownObserver.remove(l),t.onPointerMoveObserver.remove(l),t.onPointerLeaveObserver.remove(l)}),t.onPointerEnterObserver.remove(this._moveObserver),t.onPointerMoveObserver.remove(this._upObserver)}_getPositionByIndex(e,t){var u;const n=this._getSheetObject();if(n==null)return;const{scaleX:o,scaleY:r}=n.scene.getAncestorScale(),s=(u=this._sheetSkeletonManagerService.getCurrent())==null?void 0:u.skeleton,l=s==null?void 0:s.getNoMergeCellPositionByIndex(e,t,o,r);if(s==null)return;if(l!=null&&(!isNaN(l.endX)||!isNaN(l.endY)))return l;const{rowHeaderWidthAndMarginLeft:c,columnHeaderHeightAndMarginTop:d}=s;return{startX:c,endX:c,startY:d,endY:d}}_getFreeze(){var t;const e=(t=this._sheetSkeletonManagerService.getCurrent())==null?void 0:t.skeleton.getWorksheetConfig();if(e!=null)return e.freeze}_getSheetObject(){return ae(this._currentUniverService,this._renderManagerService)}_refreshFreeze(e,t,n,o){var r;this._clearFreeze(),this._createFreeze(0),this._createFreeze(1),this._updateViewport(e,t,n,o),(r=this._getSheetObject())==null||r.spreadsheet.makeForceDirty()}};sn=Uc([a.OnLifecycle(a.LifecycleStages.Rendered,sn),Ne(0,P.Inject(exports.SheetSkeletonManagerService)),Ne(1,a.IUniverInstanceService),Ne(2,a.ICommandService),Ne(3,w.IRenderManagerService),Ne(4,ce),Ne(5,P.Inject(f.SelectionManagerService)),Ne(6,P.Inject(ke)),Ne(7,P.Inject(a.ThemeService))],sn);var ri=(i=>(i[i.NORMAL=0]="NORMAL",i[i.HIGHLIGHT=1]="HIGHLIGHT",i))(ri||{});const Wc="rgba(0, 0, 0, 0.15)",ye="rgb(0, 0, 0)",jt="rgb(255, 255, 255, 1)";class $c extends w.Shape{constructor(t,n){super(t,n);v(this,"_size",12);v(this,"_iconRatio",.4);v(this,"_mode",0);this.setShapeProps(n)}setShapeProps(t){t!=null&&t.size&&(this._size=t.size),t!=null&&t.mode&&(this._mode=t.mode),this.transformByState({width:this._size,height:this._size})}_draw(t){this._mode===1&&w.Rect.drawWith(t,{width:this._size,height:this._size,radius:this._size,fill:Wc});const n=this._size*.5*this._iconRatio,o=Math.PI/180*60,r=n*Math.sin(o),s=n*Math.cos(o);w.RegularPolygon.drawWith(t,{pointsGroup:[[{x:-r+this._size/2,y:-s+this._size/2},{x:r+this._size/2,y:-s+this._size/2},{x:this._size/2,y:n+this._size/2}]],fill:ye})}}var zc=Object.defineProperty,Xc=Object.getOwnPropertyDescriptor,Yc=(i,e,t,n)=>{for(var o=n>1?void 0:n?Xc(e,t):e,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(e,t,o):s(o))||o);return n&&o&&zc(e,t,o),o},pt=(i,e)=>(t,n)=>e(t,n,i);const Zc="__SpreadsheetHeaderMenuSHAPEControllerShape__",Gc="__SpreadsheetHeaderMenuMAINControllerShape__",Kc="rgba(0, 0, 0, 0.1)";let ln=class extends a.Disposable{constructor(e,t,n,o,r){super();v(this,"_hoverRect");v(this,"_hoverMenu");v(this,"_currentColumn",1/0);v(this,"_observers",[]);this._sheetSkeletonManagerService=e,this._currentUniverService=t,this._renderManagerService=n,this._contextMenuService=o,this._selectionManagerService=r,this._initialize()}dispose(){var o,r;(o=this._hoverRect)==null||o.dispose(),(r=this._hoverMenu)==null||r.dispose();const e=this._getSheetObject();if(e==null)return;const{spreadsheetRowHeader:t,spreadsheetColumnHeader:n}=e;this._observers.forEach(s=>{t.onPointerEnterObserver.remove(s),t.onPointerMoveObserver.remove(s),t.onPointerLeaveObserver.remove(s),n.onPointerEnterObserver.remove(s),n.onPointerMoveObserver.remove(s),n.onPointerLeaveObserver.remove(s)})}_initialize(){const e=this._getSheetObject();if(e==null)return;const{scene:t}=e;this._hoverRect=new w.Rect(Zc,{fill:Kc,evented:!1}),this._hoverMenu=new $c(Gc,{zIndex:100,visible:!1}),t.addObjects([this._hoverRect,this._hoverMenu],Ue),this._initialHover(0),this._initialHover(1),this._initialHoverMenu()}_initialHover(e=0){const t=this._getSheetObject();if(t==null)return;const{spreadsheetColumnHeader:n,spreadsheetRowHeader:o}=t,r=e===0?o:n;this._observers.push(r==null?void 0:r.onPointerEnterObserver.add(()=>{var s;(s=this._hoverRect)==null||s.show()})),this._observers.push(r==null?void 0:r.onPointerMoveObserver.add(s=>{var I,C,b;const l=(I=this._sheetSkeletonManagerService.getCurrent())==null?void 0:I.skeleton;if(l==null)return;const c=this._getSheetObject();if(c==null)return;const{rowHeaderWidth:d,columnHeaderHeight:u}=l,{startX:h,startY:m,endX:S,endY:g,column:_}=st(s.offsetX,s.offsetY,c.scene,l);if(e===0)(C=this._hoverRect)==null||C.transformByState({width:d,height:g-m,left:0,top:m});else{if(this._currentColumn=_,(b=this._hoverRect)==null||b.transformByState({width:S-h,height:u,left:h,top:0}),this._hoverMenu==null)return;if(S-h<u*2){this._hoverMenu.hide();return}const M=u*.8;this._hoverMenu.transformByState({left:S-u,top:u/2-M/2}),this._hoverMenu.setShapeProps({size:M}),this._hoverMenu.show()}})),this._observers.push(r==null?void 0:r.onPointerLeaveObserver.add(()=>{var s,l;(s=this._hoverRect)==null||s.hide(),(l=this._hoverMenu)==null||l.hide()}))}_initialHoverMenu(){this._hoverMenu!=null&&(this._hoverMenu.onPointerEnterObserver.add(()=>{if(this._hoverMenu==null)return;const e=this._getSheetObject();e!=null&&(this._hoverMenu.setProps({mode:ri.HIGHLIGHT,visible:!0}),e.scene.setCursor(w.CURSOR_TYPE.POINTER))}),this._hoverMenu.onPointerLeaveObserver.add(()=>{if(this._hoverMenu==null)return;const e=this._getSheetObject();e!=null&&(this._hoverMenu.setProps({mode:ri.NORMAL,visible:!1}),e.scene.resetCursor())}),this._hoverMenu.onPointerDownObserver.add(e=>{const t=this._getSheetObject();if(t==null)return;const n=this._currentColumn,o=this._selectionManagerService.getSelectionRanges();(o==null?void 0:o.find(s=>{const{startColumn:l,endColumn:c}=s;return n>=l&&l<=c}))==null?t.spreadsheetColumnHeader.onPointerDownObserver.notifyObservers(e):(e.stopPropagation(),e.preventDefault(),this._contextMenuService.triggerContextMenu(e,ee.COL_HEADER_CONTEXT_MENU))}))}_getSheetObject(){return ae(this._currentUniverService,this._renderManagerService)}};ln=Yc([a.OnLifecycle(a.LifecycleStages.Rendered,ln),pt(0,P.Inject(exports.SheetSkeletonManagerService)),pt(1,a.IUniverInstanceService),pt(2,w.IRenderManagerService),pt(3,R.IContextMenuService),pt(4,P.Inject(f.SelectionManagerService))],ln);var qc=Object.defineProperty,Jc=Object.getOwnPropertyDescriptor,Qc=(i,e,t,n)=>{for(var o=n>1?void 0:n?Jc(e,t):e,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(e,t,o):s(o))||o);return n&&o&&qc(e,t,o),o},Qe=(i,e)=>(t,n)=>e(t,n,i);const ed="__SpreadsheetHeaderMoveControllerBackground__",td="__SpreadsheetHeaderMoveControllerShapeLine__",nd="rgba(0, 0, 0, 0.1)",id="rgb(119, 119, 119)",od=4;let an=class extends a.Disposable{constructor(e,t,n,o,r,s){super();v(this,"_startOffsetX",-1/0);v(this,"_startOffsetY",-1/0);v(this,"_moveHelperBackgroundShape");v(this,"_moveHelperLineShape");v(this,"_sheetObject");v(this,"_rowOrColumnDownObservers",[]);v(this,"_rowOrColumnMoveObservers",[]);v(this,"_rowOrColumnLeaveObservers",[]);v(this,"_moveObserver");v(this,"_upObserver");v(this,"_scrollTimer");v(this,"_changeFromColumn",-1);v(this,"_changeFromRow",-1);v(this,"_changeToColumn",-1);v(this,"_changeToRow",-1);this._sheetSkeletonManagerService=e,this._currentUniverService=t,this._renderManagerService=n,this._commandService=o,this._selectionRenderService=r,this._selectionManagerService=s,this._initialize()}dispose(){var r,s;(r=this._moveHelperBackgroundShape)==null||r.dispose(),(s=this._moveHelperLineShape)==null||s.dispose();const e=this._getSheetObject();if(e==null)return;const{spreadsheetRowHeader:t,spreadsheetColumnHeader:n,scene:o}=e;[...this._rowOrColumnDownObservers,...this._rowOrColumnMoveObservers,...this._rowOrColumnLeaveObservers].forEach(l=>{t.onPointerDownObserver.remove(l),n.onPointerDownObserver.remove(l)}),o.onPointerMoveObserver.remove(this._moveObserver),o.onPointerUpObserver.remove(this._upObserver),this._scrollTimer.dispose()}_initialize(){const e=this._getSheetObject();e!=null&&(this._sheetObject=e,this._initialRowOrColumn(0),this._initialRowOrColumn(1))}_initialRowOrColumn(e=0){const{spreadsheetColumnHeader:t,spreadsheetRowHeader:n,scene:o}=this._sheetObject,r=e===0?n:t;this._rowOrColumnMoveObservers.push(r==null?void 0:r.onPointerMoveObserver.add(s=>{var h;const l=(h=this._sheetSkeletonManagerService.getCurrent())==null?void 0:h.skeleton;if(l==null)return;const{row:c,column:d}=st(s.offsetX,s.offsetY,o,l);if(this._checkInHeaderRange(e===0?c:d,e)===!1){o.resetCursor(),this._selectionRenderService.enableSelection();return}o.setCursor(w.CURSOR_TYPE.GRAB),this._selectionRenderService.disableSelection()})),this._rowOrColumnLeaveObservers.push(r==null?void 0:r.onPointerLeaveObserver.add(()=>{var s,l;(s=this._moveHelperBackgroundShape)==null||s.hide(),(l=this._moveHelperLineShape)==null||l.hide(),o.resetCursor(),this._selectionRenderService.enableSelection()})),this._rowOrColumnDownObservers.push(r==null?void 0:r.onPointerDownObserver.add(s=>{var b;const l=(b=this._sheetSkeletonManagerService.getCurrent())==null?void 0:b.skeleton;if(l==null)return;const{offsetX:c,offsetY:d}=s,u=o.getRelativeCoord(w.Vector2.FromArray([c,d])),{x:h,y:m}=u;this._startOffsetX=h,this._startOffsetY=m;const{row:S,column:g}=st(s.offsetX,s.offsetY,o,l);e===0?this._changeFromRow=S:this._changeFromColumn=g;const _=this._checkInHeaderRange(e===0?S:g,e);if(_===!1)return;this._newBackgroundAndLine(),o.setCursor(w.CURSOR_TYPE.GRABBING),o.disableEvent();const I=w.ScrollTimer.create(o),C=o.getViewport(Y.VIEW_MAIN);I.startScroll(h,m,C),this._scrollTimer=I,this._moveObserver=o.onPointerMoveObserver.add(M=>{const{offsetX:T,offsetY:E}=M,{x:y,y:O}=o.getRelativeCoord(w.Vector2.FromArray([T,E]));o.setCursor(w.CURSOR_TYPE.GRABBING),this._columnMoving(y,O,_,e),I.scrolling(y,O,()=>{this._columnMoving(y,O,_,e)})}),this._upObserver=o.onPointerUpObserver.add(()=>{var M;this._disposeBackgroundAndLine(),o.resetCursor(),o.enableEvent(),this._clearObserverEvent(),(M=this._scrollTimer)==null||M.dispose(),e===0?(this._changeFromRow!==this._changeToRow&&this._changeToRow!==-1&&this._commandService.executeCommand(f.MoveRowsCommand.id,{fromRow:this._changeFromRow,toRow:this._changeToRow}),this._changeToRow=this._changeFromRow=-1):(this._changeFromColumn!==this._changeToColumn&&this._changeToColumn!==-1&&this._commandService.executeCommand(f.MoveColsCommand.id,{fromCol:this._changeFromColumn,toCol:this._changeToColumn}),this._changeToColumn=this._changeFromColumn=-1)})}))}_columnMoving(e,t,n,o){var j,$,q,z,Q,J,we;const{scene:r}=this._sheetObject,s=(j=this._sheetSkeletonManagerService.getCurrent())==null?void 0:j.skeleton;if(s==null)return;const{rowHeaderWidth:l,columnHeaderHeight:c,rowTotalHeight:d,columnTotalWidth:u}=s,h=r.getScrollXYByRelativeCoords(w.Vector2.FromArray([this._startOffsetX,this._startOffsetY])),{scaleX:m,scaleY:S}=r.getAncestorScale(),g=s.getCellPositionByOffset(e,t,m,S,h),{row:_,column:I}=g,C=s.getNoMergeCellPositionByIndex(_,I,m,S),{startX:b,startY:M,endX:T,endY:E}=C,y=this._selectionRenderService.convertRangeDataToSelection(n.range);if(y==null)return;const O=Math.max(m,m),{startX:x,endX:D,startY:U,endY:N,startRow:B,startColumn:A,endRow:H,endColumn:V}=y;o===0?($=this._moveHelperBackgroundShape)==null||$.transformByState({height:N-U,width:u+l,left:0,top:U+(t-this._startOffsetY)/O}):(q=this._moveHelperBackgroundShape)==null||q.transformByState({height:d+c,width:D-x,left:x+(e-this._startOffsetX)/O,top:0}),(z=this._moveHelperBackgroundShape)==null||z.show();const F=od/O;if(o===0){let re=0;if(_<=B)re=M-F/2,this._changeToRow=_;else if(_>H)re=E-F/2,this._changeToRow=_+1;else return;(Q=this._moveHelperLineShape)==null||Q.transformByState({height:F,width:u,left:l,top:re})}else{let re=0;if(I<=A)re=b-F/2,this._changeToColumn=I;else if(I>V)re=T-F/2,this._changeToColumn=I+1;else return;(J=this._moveHelperLineShape)==null||J.transformByState({height:d,width:F,left:re,top:c})}(we=this._moveHelperLineShape)==null||we.show()}_checkInHeaderRange(e,t=0){const n=this._selectionManagerService.getSelections(),o=n==null?void 0:n.find(s=>{const l=s.range,{startRow:c,endRow:d,startColumn:u,endColumn:h}=l;return t===1?e>=u&&e<=h:e>=c&&e<=d}),r=o==null?void 0:o.range;return o==null||r==null||r.rangeType===a.RANGE_TYPE.ALL||r.rangeType===a.RANGE_TYPE.NORMAL||r.rangeType===a.RANGE_TYPE.ROW&&t!==0||r.rangeType===a.RANGE_TYPE.COLUMN&&t!==1?!1:o}_clearObserverEvent(){const{scene:e}=this._sheetObject;e.onPointerMoveObserver.remove(this._moveObserver),e.onPointerUpObserver.remove(this._upObserver),this._moveObserver=null,this._upObserver=null}_newBackgroundAndLine(){const{scene:e}=this._sheetObject;this._moveHelperBackgroundShape=new w.Rect(ed,{fill:nd,evented:!1,zIndex:100}),this._moveHelperLineShape=new w.Rect(td,{fill:id,evented:!1,zIndex:100}),e.addObjects([this._moveHelperBackgroundShape,this._moveHelperLineShape],Ue)}_disposeBackgroundAndLine(){var e,t;(e=this._moveHelperBackgroundShape)==null||e.dispose(),(t=this._moveHelperLineShape)==null||t.dispose()}_getSheetObject(){return ae(this._currentUniverService,this._renderManagerService)}};an=Qc([a.OnLifecycle(a.LifecycleStages.Rendered,an),Qe(0,P.Inject(exports.SheetSkeletonManagerService)),Qe(1,a.IUniverInstanceService),Qe(2,w.IRenderManagerService),Qe(3,a.ICommandService),Qe(4,ce),Qe(5,P.Inject(f.SelectionManagerService))],an);var si=(i=>(i[i.VERTICAL=0]="VERTICAL",i[i.HORIZONTAL=1]="HORIZONTAL",i))(si||{});const rd="rgba(120, 120, 120, 0.01)",$n="rgb(68, 71, 70)",Rt=12,li=4;class ro extends w.Shape{constructor(t,n){super(t,n);v(this,"_size",Rt);v(this,"_color",$n);v(this,"_mode",0);this.setShapeProps(n)}get size(){return this._size}get mode(){return this._mode}get color(){return this._color}_draw(t){let{width:n,height:o}=this,r=0,s=0;const l=this.getScene(),{scaleX:c,scaleY:d}=l.getAncestorScale(),u=Math.max(c,d),h=Rt/u,m=li/u;this.mode===0?(n=m,r=h-m):(o=m,s=h-m),w.Rect.drawWith(t,{width:this.width,height:this.height,left:0,top:0,fill:rd}),w.Rect.drawWith(t,{width:n,height:o,fill:$n,radius:m}),t.save(),t.transform(1,0,0,1,r,s),w.Rect.drawWith(t,{width:n,height:o,fill:$n,radius:m}),t.restore()}setShapeProps(t){return t!=null&&t.size&&(this._size=t.size),t!=null&&t.mode&&(this._mode=t.mode),t!=null&&t.color&&(this._color=t.color),this.mode===0?this.transformByState({width:Rt,height:this.size}):this.transformByState({width:this.size,height:Rt}),this}}var sd=Object.defineProperty,ld=Object.getOwnPropertyDescriptor,ad=(i,e,t,n)=>{for(var o=n>1?void 0:n?ld(e,t):e,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(e,t,o):s(o))||o);return n&&o&&sd(e,t,o),o},vt=(i,e)=>(t,n)=>e(t,n,i);const cd="__SpreadsheetHeaderResizeControllerShapeRow__",dd="__SpreadsheetHeaderResizeControllerShapeColumn__",so="__SpreadsheetHeaderResizeControllerShapeHelper__",lo="rgb(199, 199, 199)",ud=2;let cn=class extends a.Disposable{constructor(e,t,n,o,r){super();v(this,"_currentRow",0);v(this,"_currentColumn",0);v(this,"_rowResizeRect");v(this,"_columnResizeRect");v(this,"_observers",[]);v(this,"_moveObserver");v(this,"_upObserver");v(this,"_resizeHelperShape");v(this,"_startOffsetX",1/0);v(this,"_startOffsetY",1/0);this._sheetSkeletonManagerService=e,this._currentUniverService=t,this._commandService=n,this._renderManagerService=o,this._editorBridgeService=r,this._initialize()}dispose(){var o,r;(o=this._rowResizeRect)==null||o.dispose(),this._rowResizeRect=null,(r=this._columnResizeRect)==null||r.dispose(),this._columnResizeRect=null;const e=this._getSheetObject();if(e==null)throw new Error("sheetObject is null");const{spreadsheetRowHeader:t,spreadsheetColumnHeader:n}=e;this._observers.forEach(s=>{t.onPointerMoveObserver.remove(s),t.onPointerLeaveObserver.remove(s),n.onPointerMoveObserver.remove(s),n.onPointerLeaveObserver.remove(s)}),this._observers=[]}_initialize(){const e=this._getSheetObject();if(e==null)return;const{scene:t}=e;this._rowResizeRect=new ro(cd,{visible:!1,mode:si.HORIZONTAL,zIndex:100}),this._columnResizeRect=new ro(dd,{visible:!1,mode:si.VERTICAL,zIndex:100}),t.addObjects([this._rowResizeRect,this._columnResizeRect],Ue),this._initialHover(0),this._initialHover(1),this._initialHoverResize(0),this._initialHoverResize(1)}_initialHover(e=0){const t=this._getSheetObject();if(t==null)return;const{spreadsheetRowHeader:n,spreadsheetColumnHeader:o,scene:r}=t,s=e===0?n:o;this._observers.push(s==null?void 0:s.onPointerMoveObserver.add((l,c)=>{var O;const d=(O=this._sheetSkeletonManagerService.getCurrent())==null?void 0:O.skeleton;if(d==null||this._rowResizeRect==null||this._columnResizeRect==null)return;const{rowHeaderWidth:u,columnHeaderHeight:h}=d,{startX:m,startY:S,endX:g,endY:_,row:I,column:C}=st(l.offsetX,l.offsetY,r,d),b=Xt(l.offsetX,l.offsetY,r),{scaleX:M,scaleY:T}=r.getAncestorScale(),E=Math.max(M,T),y=Rt/E;if(e===0){let x=S-y/2;if(b.y<=S+y/2&&b.y>=S)this._currentRow=I-1;else if(b.y>=_-y/2&&b.y<=_)this._currentRow=I,x=_-y/2;else{this._rowResizeRect.hide();return}if(this._currentRow===-1)return;const D=u/3;this._rowResizeRect.transformByState({left:u/2-D/2,top:x}),this._rowResizeRect.setShapeProps({size:D}),this._rowResizeRect.show()}else{let x=m-y/2;if(b.x<=m+y/2&&b.x>=m)this._currentColumn=C-1;else if(b.x>=g-y/2&&b.x<=g)this._currentColumn=C,x=g-y/2;else{this._columnResizeRect.hide();return}if(this._currentColumn===-1)return;const D=h*.7;this._columnResizeRect.transformByState({left:x,top:h/2-D/2}),this._columnResizeRect.setShapeProps({size:D}),this._columnResizeRect.show()}})),this._observers.push(s==null?void 0:s.onPointerLeaveObserver.add((l,c)=>{var d,u;(d=this._rowResizeRect)==null||d.hide(),(u=this._columnResizeRect)==null||u.hide()}))}_initialHoverResize(e=0){const t=this._getSheetObject();if(t==null)return;const{scene:n}=t,o=e===0?this._rowResizeRect:this._columnResizeRect;if(o==null)return;const r=n.getEngine(),s=(r==null?void 0:r.width)||0,l=(r==null?void 0:r.height)||0;this.disposeWithMe(a.toDisposable(o.onPointerEnterObserver.add(()=>{o!=null&&(o.show(),n.setCursor(e===0?w.CURSOR_TYPE.ROW_RESIZE:w.CURSOR_TYPE.COLUMN_RESIZE))}))),this.disposeWithMe(a.toDisposable(o.onPointerLeaveObserver.add(()=>{o!=null&&(o.hide(),n.resetCursor())}))),this.disposeWithMe(a.toDisposable(o.onPointerDownObserver.add((c,d)=>{var q,z,Q,J,we,re,Se;const u=(q=this._sheetSkeletonManagerService.getCurrent())==null?void 0:q.skeleton;if(u==null)return;const h=this._getSheetObject();if(h==null)return;const{scene:m}=h,S=m.getViewport(Y.VIEW_MAIN),g=(((Q=(z=S==null?void 0:S.getScrollBar())==null?void 0:z.horizonBarRect)==null?void 0:Q.height)||0)+10,_=(((we=(J=S==null?void 0:S.getScrollBar())==null?void 0:J.verticalBarRect)==null?void 0:we.width)||0)+10,I=Xt(c.offsetX,c.offsetY,m),{scaleX:C,scaleY:b}=m.getAncestorScale();this._startOffsetX=I.x,this._startOffsetY=I.y;const M=u.getOffsetByPositionX(this._currentColumn),T=u.getOffsetByPositionY(this._currentRow),E=u.getNoMergeCellPositionByIndex(this._currentRow,this._currentColumn,C,b);let y=!1,O=0,x=0;const{columnTotalWidth:D,rowHeaderWidth:U,rowTotalHeight:N,columnHeaderHeight:B}=u,A=s>D+U?s:D+U,H=l>N+B?l:N+B,V=Math.max(C,b),F=li/V;e===0?this._resizeHelperShape=new w.Rect(so,{width:A,height:F,fill:lo,left:0,top:T-F/2}):this._resizeHelperShape=new w.Rect(so,{width:F,height:H,fill:lo,left:M-F/2,top:0});const j=((re=this._columnResizeRect)==null?void 0:re.left)||0,$=((Se=this._rowResizeRect)==null?void 0:Se.top)||0;m.addObject(this._resizeHelperShape,Ue),m.disableEvent(),this._editorBridgeService.changeVisible({visible:!1,eventType:w.DeviceInputEventType.PointerDown}),this._moveObserver=m.onPointerMoveObserver.add(qe=>{var Ti,Ei,yi,Oi,xi,Ai;const Be=m.getRelativeCoord(w.Vector2.FromArray([this._startOffsetX,this._startOffsetY])),Te=m.getScrollXYByRelativeCoords(Be,S),de=Xt(qe.offsetX,qe.offsetY,m),{x:kt,y:Bt}=de,{scaleX:wr,scaleY:Tr}=m.getAncestorScale(),Er=Math.max(wr,Tr),Vt=li/Er;O=kt-this._startOffsetX-Vt/2,x=Bt-this._startOffsetY-Vt/2,Math.abs(e===0?x:O)>=ud&&(y=!0),e===0?(x<-(E.endY-E.startY)+2&&(x=-(E.endY-E.startY)+2),x>l-g+Te.y-E.startY&&(x=l-g+Te.y-E.startY),y&&((Ti=this._resizeHelperShape)==null||Ti.transformByState({top:T+x}),(Ei=this._rowResizeRect)==null||Ei.transformByState({top:$+x+Vt/2}),(yi=this._rowResizeRect)==null||yi.show(),m.setCursor(w.CURSOR_TYPE.ROW_RESIZE))):(O<-(E.endX-E.startX)+2&&(O=-(E.endX-E.startX)+2),O>s-_+Te.x-E.startX&&(O=s-_+Te.x-E.startX),y&&((Oi=this._resizeHelperShape)==null||Oi.transformByState({left:M+O}),(xi=this._columnResizeRect)==null||xi.transformByState({left:j+O+Vt/2}),(Ai=this._columnResizeRect)==null||Ai.show(),m.setCursor(w.CURSOR_TYPE.COLUMN_RESIZE)))}),this._upObserver=m.onPointerUpObserver.add(qe=>{var de,kt,Bt;const Be=ae(this._currentUniverService,this._renderManagerService);if(Be==null)return;this._clearObserverEvent(),(de=this._resizeHelperShape)==null||de.dispose(),this._resizeHelperShape=null;const{scene:Te}=Be;Te.enableEvent(),y&&(Te.resetCursor(),(kt=this._rowResizeRect)==null||kt.hide(),(Bt=this._columnResizeRect)==null||Bt.hide(),e===0?this._commandService.executeCommand(f.DeltaRowHeightCommand.id,{deltaY:x,anchorRow:this._currentRow}):this._commandService.executeCommand(f.DeltaColumnWidthCommand.id,{deltaX:O,anchorCol:this._currentColumn}))})}))),this.disposeWithMe(a.toDisposable(o.onDblclickObserver.add(()=>{var c;if(e===0){const d=this._getSheetObject();if(d==null)return;const{scene:u}=d;u.resetCursor(),this._commandService.executeCommand(f.SetWorksheetRowIsAutoHeightCommand.id,{anchorRow:this._currentRow}),(c=this._rowResizeRect)==null||c.hide()}})))}_clearObserverEvent(){const e=this._getSheetObject();if(e==null)return;const{scene:t}=e;t.onPointerMoveObserver.remove(this._moveObserver),t.onPointerUpObserver.remove(this._upObserver),this._moveObserver=null,this._upObserver=null}_getSheetObject(){return ae(this._currentUniverService,this._renderManagerService)}};cn=ad([a.OnLifecycle(a.LifecycleStages.Rendered,cn),vt(0,P.Inject(exports.SheetSkeletonManagerService)),vt(1,a.IUniverInstanceService),vt(2,a.ICommandService),vt(3,w.IRenderManagerService),vt(4,pe)],cn);var ai=(i=>(i[i.ROW=0]="ROW",i[i.COLUMN=1]="COLUMN",i))(ai||{});const bt=12,hd=.4;class ao extends w.Shape{constructor(t,n,o){super(t,n);v(this,"_size",bt);v(this,"_iconRatio",hd);v(this,"_hovered",!0);v(this,"_hasPrevious",!0);v(this,"_hasNext",!0);v(this,"_unhideType");n&&this.setShapeProps(n),this.onPointerEnterObserver.add(()=>this.setShapeProps({hovered:!0})),this.onPointerLeaveObserver.add(()=>this.setShapeProps({hovered:!1})),this.onPointerDownObserver.add(()=>o==null?void 0:o())}setShapeProps(t){t.type!==void 0&&(this._unhideType=t.type),t.hovered!==void 0&&(this._hovered=t.hovered),t.hasPrevious!==void 0&&(this._hasPrevious=t.hasPrevious),t.hasNext!==void 0&&(this._hasNext=t.hasNext),this.transformByState({width:this._size*(this._unhideType===1?2:1),height:this._size*(this._unhideType===0?2:1)})}_draw(t){this._unhideType===0?this._drawOnRow(t):this._drawOnCol(t)}_drawOnRow(t){this._hovered&&(!this._hasNext||!this._hasPrevious?w.Rect.drawWith(t,{width:this._size,height:this._size,stroke:ye,fill:jt}):w.Rect.drawWith(t,{width:this._size,height:2*this._size,stroke:ye,fill:jt}));const n=this._size*.5*this._iconRatio,o=Math.PI/3,r=n*Math.cos(o),s=n*Math.sin(o);if(this._hasPrevious&&w.RegularPolygon.drawWith(t,{pointsGroup:[[{x:this._size/2,y:this._size/2-s},{x:this._size/2-s,y:this._size/2+r},{x:this._size/2+s,y:this._size/2+r}]],fill:ye}),this._hasNext){const l=this._hasPrevious?3:1;w.RegularPolygon.drawWith(t,{pointsGroup:[[{x:this._size/2,y:this._size*l/2+s},{x:this._size/2-s,y:this._size*l/2-r},{x:this._size/2+s,y:this._size*l/2-r}]],fill:ye})}}_drawOnCol(t){this._hovered&&(!this._hasNext||!this._hasPrevious?w.Rect.drawWith(t,{width:this._size,height:this._size,stroke:ye,fill:jt}):w.Rect.drawWith(t,{width:2*this._size,height:this._size,stroke:ye,fill:jt}));const n=this._size*.5*this._iconRatio,o=Math.PI/3,r=n*Math.cos(o),s=n*Math.sin(o);if(this._hasPrevious&&w.RegularPolygon.drawWith(t,{pointsGroup:[[{x:-r+this._size/2,y:this._size/2},{x:this._size/2+s,y:this._size/2-s},{x:this._size/2+s,y:this._size/2+s}]],fill:ye}),this._hasNext){const l=this._hasPrevious?3:1;w.RegularPolygon.drawWith(t,{pointsGroup:[[{x:r+this._size*l/2,y:this._size/2},{x:-s+this._size*l/2,y:this._size/2-s},{x:-s+this._size*l/2,y:this._size/2+s}]],fill:ye})}}}var md=Object.defineProperty,Sd=Object.getOwnPropertyDescriptor,_d=(i,e,t,n)=>{for(var o=n>1?void 0:n?Sd(e,t):e,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(e,t,o):s(o))||o);return n&&o&&md(e,t,o),o},Wt=(i,e)=>(t,n)=>e(t,n,i);const co="__SpreadsheetHeaderUnhideSHAPEControllerShape__",gd=[f.SetRowHiddenMutation.id,f.SetRowVisibleMutation.id,f.SetColHiddenMutation.id,f.SetColVisibleMutation.id];let dn=class extends a.RxDisposable{constructor(e,t,n,o){super();v(this,"_shapes",new Map);this._sheetSkeletonManagerService=e,this._cmdSrv=t,this._univerInstanceService=n,this._rendererManagerService=o,this._init()}dispose(){super.dispose()}_init(){if(!this._getSheetObject())return;const t=this._univerInstanceService.getCurrentUniverSheetInstance(),n=t.getActiveSheet();n&&this._initForWorksheet(t,n),this._sheetSkeletonManagerService.currentSkeleton$.pipe(k.takeUntil(this.dispose$)).subscribe(o=>{if(o){const r=this._univerInstanceService.getUniverSheetInstance(o.unitId),s=r.getSheetBySheetId(o.sheetId);this._updateWorksheet(r,s)}}),this.disposeWithMe(this._cmdSrv.onCommandExecuted(o=>{if(!gd.includes(o.id)||!o.params||!o.params.unitId||!o.params.subUnitId)return;const r=this._univerInstanceService.getUniverSheetInstance(o.params.unitId),s=r==null?void 0:r.getSheetBySheetId(o.params.subUnitId);s&&this._updateWorksheet(r,s)}))}_initForWorksheet(e,t){var m;const n=(m=this._sheetSkeletonManagerService.getCurrent())==null?void 0:m.skeleton;if(!n)return;const o=t.getHiddenRows(),r=t.getHiddenCols(),s=this._getSheetObject();if(!s)return;const{scene:l}=s,c=t.getRowCount(),d=o.map(S=>{const{startRow:g,endRow:_}=S,I=ii(g,0,l,n),C=g!==0,b=_!==c-1;return new ao(co,{type:ai.ROW,hovered:!1,hasPrevious:C,hasNext:b,top:I.startY-(C?bt:0),left:I.startX-bt},()=>this._cmdSrv.executeCommand(f.SetSpecificRowsVisibleCommand.id,{unitId:e.getUnitId(),subUnitId:t.getSheetId(),ranges:[S]}))}),u=t.getColumnCount(),h=r.map(S=>{const{startColumn:g,endColumn:_}=S,I=ii(0,g,l,n),C=g!==0,b=_!==u-1;return new ao(co,{type:ai.COLUMN,hovered:!1,hasPrevious:C,hasNext:b,left:I.startX-(C?bt:0),top:20-bt},()=>this._cmdSrv.executeCommand(f.SetSpecificColsVisibleCommand.id,{unitId:e.getUnitId(),subUnitId:t.getSheetId(),ranges:[S]}))});l.addObjects(h,ji),l.addObjects(d,ji),this._shapes.set(a.getWorksheetUID(e,t),{cols:h,rows:d})}_updateWorksheet(e,t){const n=this._shapes.get(a.getWorksheetUID(e,t));n==null||n.cols.forEach(o=>o.dispose()),n==null||n.rows.forEach(o=>o.dispose()),this._initForWorksheet(e,t)}_getSheetObject(){return ae(this._univerInstanceService,this._rendererManagerService)}};dn=_d([a.OnLifecycle(a.LifecycleStages.Rendered,dn),Wt(0,P.Inject(exports.SheetSkeletonManagerService)),Wt(1,a.ICommandService),Wt(2,a.IUniverInstanceService),Wt(3,w.IRenderManagerService)],dn);var fd=Object.defineProperty,pd=Object.getOwnPropertyDescriptor,vd=(i,e,t,n)=>{for(var o=n>1?void 0:n?pd(e,t):e,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(e,t,o):s(o))||o);return n&&o&&fd(e,t,o),o},zn=(i,e)=>(t,n)=>e(t,n,i);let un=class extends a.Disposable{constructor(i,e,t){super(),this._markSelectionService=i,this._commandService=e,this._sheetSkeletonManagerService=t,this._initListeners()}_initListeners(){this._addRemoveListener(),this._addRefreshListener()}_addRemoveListener(){const i=[Re.id,f.SetRangeValuesMutation.id];this.disposeWithMe(this._commandService.onCommandExecuted(e=>{i.includes(e.id)&&this._markSelectionService.removeAllShapes()}))}_addRefreshListener(){this.disposeWithMe(a.toDisposable(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(i=>{i&&this._markSelectionService.refreshShapes()})))}};un=vd([a.OnLifecycle(a.LifecycleStages.Steady,un),zn(0,P.Inject(At)),zn(1,a.ICommandService),zn(2,P.Inject(exports.SheetSkeletonManagerService))],un);var Cd=Object.defineProperty,Id=Object.getOwnPropertyDescriptor,Rd=(i,e,t,n)=>{for(var o=n>1?void 0:n?Id(e,t):e,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(e,t,o):s(o))||o);return n&&o&&Cd(e,t,o),o},Xn=(i,e)=>(t,n)=>e(t,n,i);let hn=class extends a.Disposable{constructor(e,t,n){super();v(this,"_initialize",()=>{const e=new a.DisposableCollection;this.disposeWithMe(a.toDisposable(this._selectionManagerService.selectionMoveEnd$.subscribe(()=>{e.dispose();const t=this._selectionManagerService.getCurrent();if((t==null?void 0:t.pluginName)!==f.NORMAL_SELECTION_PLUGIN_NAME)return;this._selectionRenderService.getCurrentControls().forEach(o=>{e.add(a.toDisposable(o.selectionMoved$.subscribe(r=>{if(!r)return;const s=o.model.getRange(),l={startRow:s.startRow,startColumn:s.startColumn,endRow:s.endRow,endColumn:s.endColumn,rangeType:s.rangeType},c={startRow:r.startRow,startColumn:r.startColumn,endRow:r.endRow,endColumn:r.endColumn,rangeType:s.rangeType};if(l.startRow===c.startRow&&l.startColumn===c.startColumn||c.startRow<0||c.startColumn<0)return;const d={fromRange:l,toRange:c};this._commandService.executeCommand(f.MoveRangeCommand.id,d)})))})})))});this._selectionRenderService=e,this._selectionManagerService=t,this._commandService=n,this._initialize()}};hn=Rd([a.OnLifecycle(a.LifecycleStages.Steady,hn),Xn(0,P.Inject(ce)),Xn(1,P.Inject(f.SelectionManagerService)),Xn(2,P.Inject(a.ICommandService))],hn);var bd=Object.defineProperty,Md=Object.getOwnPropertyDescriptor,wd=(i,e,t,n)=>{for(var o=n>1?void 0:n?Md(e,t):e,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(e,t,o):s(o))||o);return n&&o&&bd(e,t,o),o},et=(i,e)=>(t,n)=>e(t,n,i);let wt=class extends a.Disposable{constructor(i,e,t,n,o,r){super(),this._sheetSkeletonManagerService=i,this._currentUniverService=e,this._commandService=t,this._renderManagerService=n,this._selectionManagerService=o,this._scrollManagerService=r,this._initialize()}dispose(){super.dispose()}_initialize(){this._scrollEventBinding(),this._scrollSubscribeBinding(),this._skeletonListener()}_scrollEventBinding(){var t;const i=(t=this._getSheetObject())==null?void 0:t.scene;if(i==null)return;const e=i.getViewport(Y.VIEW_MAIN);this.disposeWithMe(a.toDisposable(e==null?void 0:e.onScrollAfterObserver.add(n=>{var m;const o=(m=this._sheetSkeletonManagerService.getCurrent())==null?void 0:m.skeleton;if(o==null||n.isTrigger===!1)return;const r=this._getSheetObject();if(o==null||r==null)return;const{actualScrollX:s=0,actualScrollY:l=0}=n,{row:c,column:d,rowOffset:u,columnOffset:h}=o.getDecomposedOffset(s,l);this._scrollManagerService.addOrReplaceNoRefresh({sheetViewStartRow:c,sheetViewStartColumn:d,offsetX:h,offsetY:u})}))),this.disposeWithMe(a.toDisposable(e==null?void 0:e.onScrollByBarObserver.add(n=>{var m;const o=(m=this._sheetSkeletonManagerService.getCurrent())==null?void 0:m.skeleton;if(o==null||n.isTrigger===!1)return;const r=this._getSheetObject();if(o==null||r==null)return;const{actualScrollX:s=0,actualScrollY:l=0}=n,{row:c,column:d,rowOffset:u,columnOffset:h}=o.getDecomposedOffset(s,l);this._commandService.executeCommand(Ye.id,{sheetViewStartRow:c,sheetViewStartColumn:d,offsetX:h,offsetY:u})})))}scrollToVisible(i){var U,N,B;let e,t;const n=this._selectionManagerService.getLast();if(n==null)return;const{actualRow:o,actualColumn:r}=n.primary,{rowHeightAccumulation:s,columnWidthAccumulation:l}=((U=this._sheetSkeletonManagerService.getCurrent())==null?void 0:U.skeleton)??{};if(s==null||l==null)return;const c=(N=this._getSheetObject())==null?void 0:N.scene;if(c==null)return;const d=c.getViewport(Y.VIEW_MAIN);if(d==null||this._getSheetObject()==null)return;const h=this._currentUniverService.getCurrentUniverSheetInstance().getActiveSheet(),{startColumn:m,startRow:S,ySplit:g,xSplit:_}=h.getFreeze(),I=d.getBounding(),C=(B=this._sheetSkeletonManagerService.getCurrent())==null?void 0:B.skeleton;if(C==null)return;const{startRow:b,startColumn:M,endRow:T,endColumn:E}=C.getRowColumnSegment(I);if(o>=S&&r>=m-_&&(o<=b&&(e=o),o>=T)){const A=s[o]-d.height;for(let H=b;H<=o;H++)if(s[H]>=A){e=H+1;break}}if(r>=m&&o>=S-g&&(r<=M&&(t=r),r>=E)){const A=l[r]-d.width;for(let H=M;H<=r;H++)if(l[H]>=A){t=H+1;break}}if(e===void 0&&t===void 0)return;const{sheetViewStartColumn:y,sheetViewStartRow:O,offsetX:x,offsetY:D}=this._scrollManagerService.getCurrentScroll()||{};this._commandService.executeCommand(Ye.id,{sheetViewStartRow:e??O,sheetViewStartColumn:t??y,offsetX:t===void 0?x:0,offsetY:e===void 0?D:0})}_scrollSubscribeBinding(){this.disposeWithMe(a.toDisposable(this._scrollManagerService.scrollInfo$.subscribe(i=>{var I;const e=(I=this._sheetSkeletonManagerService.getCurrent())==null?void 0:I.skeleton,t=this._getSheetObject();if(e==null||t==null)return;const n=t.scene,{scaleX:o,scaleY:r}=t.scene.getAncestorScale(),s=n.getViewport(Y.VIEW_MAIN);if(s==null)return;if(i==null){s.scrollTo({x:0,y:0});return}const{sheetViewStartRow:l,sheetViewStartColumn:c,offsetX:d,offsetY:u}=i,{startX:h,startY:m}=e.getCellByIndexWithNoHeader(l,c,o,r),S=h+d,g=m+u,_=s.getBarScroll(S,g);s.scrollTo(_)})))}_skeletonListener(){this.disposeWithMe(a.toDisposable(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(i=>{if(i==null)return;const{unitId:e,sheetId:t}=i;this._renderManagerService.getRenderById(e)!=null&&(this._updateSceneSize(i),this._scrollManagerService.setCurrentScroll({unitId:e,sheetId:t}))})))}_updateSceneSize(i){var c;if(i==null)return;const{skeleton:e,unitId:t}=i,n=(c=this._renderManagerService.getRenderById(t))==null?void 0:c.scene;if(e==null||n==null)return;const{rowTotalHeight:o,columnTotalWidth:r,rowHeaderWidthAndMarginLeft:s,columnHeaderHeightAndMarginTop:l}=e;n==null||n.transformByState({width:s+r,height:l+o})}_getSheetObject(){return ae(this._currentUniverService,this._renderManagerService)}};wt=wd([a.OnLifecycle(a.LifecycleStages.Rendered,wt),et(0,P.Inject(exports.SheetSkeletonManagerService)),et(1,a.IUniverInstanceService),et(2,a.ICommandService),et(3,w.IRenderManagerService),et(4,P.Inject(f.SelectionManagerService)),et(5,P.Inject(ke))],wt);var Td=Object.defineProperty,Ed=Object.getOwnPropertyDescriptor,yd=(i,e,t,n)=>{for(var o=n>1?void 0:n?Ed(e,t):e,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(e,t,o):s(o))||o);return n&&o&&Td(e,t,o),o},uo=(i,e)=>(t,n)=>e(t,n,i);const Od=[me.id,Ke.id];let mn=class extends a.Disposable{constructor(i,e){super(),this._commandService=i,this._scrollController=e,this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(Od.includes(t.id)){const n=t.params;this._scrollController.scrollToVisible(n.direction)}}))}};mn=yd([a.OnLifecycle(a.LifecycleStages.Rendered,mn),uo(0,a.ICommandService),uo(1,P.Inject(wt))],mn);var xd=Object.defineProperty,Ad=Object.getOwnPropertyDescriptor,Hd=(i,e,t,n)=>{for(var o=n>1?void 0:n?Ad(e,t):e,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(e,t,o):s(o))||o);return n&&o&&xd(e,t,o),o},We=(i,e)=>(t,n)=>e(t,n,i);let Sn=class extends a.Disposable{constructor(i,e,t,n,o,r,s){super(),this._sheetSkeletonManagerService=i,this._currentUniverService=e,this._commandService=t,this._renderManagerService=n,this._selectionRenderService=o,this._selectionManagerService=r,this._themeService=s,this._initialize()}_initialize(){const i=this._currentUniverService.getCurrentUniverSheetInstance(),e=i.getActiveSheet(),t=this._getSheetObject();if(t==null)return;this._initViewMainListener(t),this._initRowHeader(t),this._initColumnHeader(t),this._initLeftTop(t),this._initSelectionChangeListener(),this._initThemeChangeListener(),this._initSkeletonChangeListener(),this._initCommandListener(),this._initUserActionSyncListener();const n=i.getUnitId(),o=e.getSheetId();this._selectionManagerService.setCurrentSelection({pluginName:f.NORMAL_SELECTION_PLUGIN_NAME,unitId:n,sheetId:o})}_initViewMainListener(i){const{spreadsheet:e,scene:t}=i,n=t.getViewport(Y.VIEW_MAIN);this.disposeWithMe(a.toDisposable(e==null?void 0:e.onPointerDownObserver.add((o,r)=>{this._selectionRenderService.enableDetectMergedCell(),this._selectionRenderService.eventTrigger(o,e.zIndex+1,a.RANGE_TYPE.NORMAL,n),o.button!==2&&r.stopPropagation()})))}_initThemeChangeListener(){this.disposeWithMe(a.toDisposable(this._themeService.currentTheme$.subscribe(()=>{this._selectionRenderService.resetStyle();const i=this._selectionManagerService.getSelections(),e=this._selectionManagerService.getCurrent();i==null||(e==null?void 0:e.pluginName)!==f.NORMAL_SELECTION_PLUGIN_NAME||this._refreshSelection(i)})))}_refreshSelection(i){this._selectionRenderService.reset();for(const e of i){if(e==null)continue;const t=this._selectionRenderService.convertSelectionRangeToData(e);t.style=f.getNormalSelectionStyle(this._themeService),this._selectionRenderService.addControlToCurrentByRangeData(t)}}_initRowHeader(i){const{spreadsheetRowHeader:e,spreadsheet:t,scene:n}=i,o=n.getViewport(Y.VIEW_MAIN);this.disposeWithMe(a.toDisposable(e==null?void 0:e.onPointerDownObserver.add((r,s)=>{this._selectionRenderService.disableDetectMergedCell(),this._selectionRenderService.eventTrigger(r,((t==null?void 0:t.zIndex)||1)+1,a.RANGE_TYPE.ROW,o,w.ScrollTimerType.Y),r.button!==2&&s.stopPropagation()})))}_initColumnHeader(i){const{spreadsheetColumnHeader:e,spreadsheet:t,scene:n}=i,o=n.getViewport(Y.VIEW_MAIN);this.disposeWithMe(a.toDisposable(e==null?void 0:e.onPointerDownObserver.add((r,s)=>{this._selectionRenderService.disableDetectMergedCell(),this._selectionRenderService.eventTrigger(r,((t==null?void 0:t.zIndex)||1)+1,a.RANGE_TYPE.COLUMN,o,w.ScrollTimerType.X),r.button!==2&&s.stopPropagation()})))}_initLeftTop(i){const{spreadsheetLeftTopPlaceholder:e}=i;this.disposeWithMe(a.toDisposable(e==null?void 0:e.onPointerDownObserver.add((t,n)=>{var r;const o=(r=this._sheetSkeletonManagerService.getCurrent())==null?void 0:r.skeleton;o!=null&&(this._selectionManagerService.replace([this._getAllRange(o)]),t.button!==2&&n.stopPropagation())})))}_initSelectionChangeListener(){this.disposeWithMe(a.toDisposable(this._selectionManagerService.selectionMoveEnd$.subscribe(i=>{if(this._selectionRenderService.reset(),i!=null)for(const e of i){if(e==null)continue;const t=this._selectionRenderService.convertSelectionRangeToData(e);this._selectionRenderService.addControlToCurrentByRangeData(t)}})))}_initUserActionSyncListener(){this._selectionRenderService.selectionMoveStart$.subscribe(i=>{this._move(i,f.SelectionMoveType.MOVE_START)}),this._selectionRenderService.selectionMoving$.subscribe(i=>{this._move(i,f.SelectionMoveType.MOVING)}),this._selectionRenderService.selectionMoveEnd$.subscribe(i=>{this._move(i,f.SelectionMoveType.MOVE_END)})}_move(i,e){const t=this._currentUniverService.getCurrentUniverSheetInstance(),n=t.getUnitId(),o=t.getActiveSheet().getSheetId(),r=this._selectionManagerService.getCurrent();i==null||i.length===0||this._commandService.executeCommand(f.SetSelectionsOperation.id,{unitId:n,subUnitId:o,type:e,pluginName:(r==null?void 0:r.pluginName)||f.NORMAL_SELECTION_PLUGIN_NAME,selections:i.map(s=>f.convertSelectionDataToRange(s))})}_getSheetObject(){return ae(this._currentUniverService,this._renderManagerService)}_initCommandListener(){const i=[xe.id];this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(i.includes(e.id)){const t=this._currentUniverService.getCurrentUniverSheetInstance(),n=t.getActiveSheet(),o=e.params,{unitId:r,subUnitId:s}=o;if(!(r===t.getUnitId()&&s===n.getSheetId()))return;this._selectionManagerService.refreshSelection()}}))}_initSkeletonChangeListener(){this._sheetSkeletonManagerService.currentSkeleton$.subscribe(i=>{if(i==null)return;const{unitId:e,sheetId:t,skeleton:n}=i,o=this._renderManagerService.getRenderById(e);if(o==null)return;const{scene:r}=o,s=r.getViewport(Y.VIEW_MAIN);this._selectionRenderService.changeRuntime(n,r,s);const l=this._selectionManagerService.getCurrent(),c=(l==null?void 0:l.pluginName)||f.NORMAL_SELECTION_PLUGIN_NAME;if((l==null?void 0:l.unitId)===e&&l.sheetId===t){const d=this._selectionManagerService.getSelections();d!=null&&this._refreshSelection(d)}else this._selectionManagerService.setCurrentSelection({pluginName:c,unitId:e,sheetId:t});c===f.NORMAL_SELECTION_PLUGIN_NAME&&this._selectionManagerService.getLast()==null&&this._selectionManagerService.add([this._getZeroRange(n)])})}_getAllRange(i){return{range:{startRow:0,startColumn:0,endRow:i.getRowCount()-1,endColumn:i.getColumnCount()-1,rangeType:a.RANGE_TYPE.ALL},primary:this._getZeroRange(i).primary,style:null}}_getZeroRange(i){const e=i.mergeData;return f.transformCellDataToSelectionData(0,0,e)||{range:{startRow:0,startColumn:0,endRow:0,endColumn:0},primary:{actualRow:0,actualColumn:0,startRow:0,startColumn:0,endRow:0,endColumn:0,isMerged:!1,isMergedMainCell:!1},style:null}}};Sn=Hd([a.OnLifecycle(a.LifecycleStages.Rendered,Sn),We(0,P.Inject(exports.SheetSkeletonManagerService)),We(1,a.IUniverInstanceService),We(2,a.ICommandService),We(3,w.IRenderManagerService),We(4,ce),We(5,P.Inject(f.SelectionManagerService)),We(6,P.Inject(a.ThemeService))],Sn);var Dd=Object.defineProperty,Nd=Object.getOwnPropertyDescriptor,Pd=(i,e,t,n)=>{for(var o=n>1?void 0:n?Nd(e,t):e,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(e,t,o):s(o))||o);return n&&o&&Dd(e,t,o),o},tt=(i,e)=>(t,n)=>e(t,n,i);let _n=class extends a.Disposable{constructor(i,e,t,n,o,r){super(),this._sheetSkeletonManagerService=i,this._currentUniverService=e,this._renderManagerService=t,this._commandService=n,this._selectionRenderService=o,this._selectionManagerService=r,this._initialize(),this._commandExecutedListener()}dispose(){super.dispose()}_initialize(){this._initialRenderRefresh()}_initialRenderRefresh(){this.disposeWithMe(a.toDisposable(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(i=>{if(i==null)return;const{skeleton:e,unitId:t,sheetId:n}=i,o=this._currentUniverService.getUniverSheetInstance(t),r=o==null?void 0:o.getSheetBySheetId(n);if(o==null||r==null)return;const s=this._renderManagerService.getRenderById(t);if(s==null)return;const{mainComponent:l,components:c,scene:d}=s,u=l,h=c.get(oe.ROW),m=c.get(oe.COLUMN),S=c.get(oe.LEFT_TOP),{rowHeaderWidth:g,columnHeaderHeight:_}=e;u==null||u.updateSkeleton(e),h==null||h.updateSkeleton(e),m==null||m.updateSkeleton(e),S==null||S.transformByState({width:g,height:_})})))}_commandExecutedListener(){this.disposeWithMe(this._commandService.onCommandExecuted((i,e)=>{var o,r;const t=this._currentUniverService.getCurrentUniverSheetInstance(),n=t.getUnitId();if(f.COMMAND_LISTENER_SKELETON_CHANGE.includes(i.id)){const s=t.getActiveSheet(),l=s.getSheetId(),c=i.params,{unitId:d,subUnitId:u}=c;if(!(d===t.getUnitId()&&u===s.getSheetId()))return;i.id!==f.SetWorksheetActiveOperation.id&&this._sheetSkeletonManagerService.makeDirty({unitId:d,sheetId:l,commandId:i.id},!0),this._sheetSkeletonManagerService.setCurrent({unitId:d,sheetId:l,commandId:i.id})}else f.COMMAND_LISTENER_VALUE_CHANGE.includes(i.id)&&this._sheetSkeletonManagerService.reCalculate();i.type===a.CommandType.MUTATION&&((r=(o=this._renderManagerService.getRenderById(n))==null?void 0:o.mainComponent)==null||r.makeDirty())}))}};_n=Pd([a.OnLifecycle(a.LifecycleStages.Ready,_n),tt(0,P.Inject(exports.SheetSkeletonManagerService)),tt(1,a.IUniverInstanceService),tt(2,w.IRenderManagerService),tt(3,a.ICommandService),tt(4,ce),tt(5,P.Inject(f.SelectionManagerService))],_n);const Ae={type:a.CommandType.COMMAND,id:"sheet.command.add-worksheet-merge",handler:async(i,e)=>{const t=i.get(a.ICommandService),n=i.get(a.IUndoRedoService),o=i.get(a.IUniverInstanceService),r=i.get(R.IConfirmService),s=i.get(a.LocaleService),l=e.unitId,c=e.subUnitId,d=e.selections,u=f.getAddMergeMutationRangeByType(d,e.value),h=o.getUniverSheetInstance(l).getSheetBySheetId(c),m=[],S=[],g=Jo(h,u);if(g&&!await r.confirm({id:"merge.confirm.add-worksheet-merge",title:{title:"merge.confirm.title"},cancelText:s.t("merge.confirm.cancel"),confirmText:s.t("merge.confirm.confirm")}))return!1;const _={unitId:l,subUnitId:c,ranges:u},I={unitId:l,subUnitId:c,ranges:u};m.push({id:f.RemoveWorksheetMergeMutation.id,params:_}),m.push({id:f.AddWorksheetMergeMutation.id,params:I});const C=f.RemoveMergeUndoMutationFactory(i,_),b=f.AddMergeUndoMutationFactory(i,I);if(S.push({id:f.RemoveWorksheetMergeMutation.id,params:b}),S.push({id:f.AddWorksheetMergeMutation.id,params:C}),g){const T=Qo(i,l,h,u);m.unshift(...T.redos),S.push(...T.undos)}return a.sequenceExecute(m,t).result?(n.pushUndoRedo({unitID:l,undoMutations:S,redoMutations:m}),!0):!1}},gr={type:a.CommandType.COMMAND,id:"sheet.command.add-worksheet-merge-all",handler:async i=>{const e=i.get(a.ICommandService),n=i.get(f.SelectionManagerService).getSelectionRanges();if(!(n!=null&&n.length))return!1;const r=i.get(a.IUniverInstanceService).getCurrentUniverSheetInstance();if(!r)return!1;const s=r.getActiveSheet();if(!s)return!1;const l=r.getUnitId(),c=s.getSheetId();return e.executeCommand(Ae.id,{selections:n,unitId:l,subUnitId:c})}},fr={type:a.CommandType.COMMAND,id:"sheet.command.add-worksheet-merge-vertical",handler:async i=>{const e=i.get(a.ICommandService),n=i.get(f.SelectionManagerService).getSelectionRanges();if(!(n!=null&&n.length))return!1;const r=i.get(a.IUniverInstanceService).getCurrentUniverSheetInstance();if(!r)return!1;const s=r.getActiveSheet();if(!s)return!1;const l=r.getUnitId(),c=s.getSheetId();return e.executeCommand(Ae.id,{value:a.Dimension.COLUMNS,selections:n,unitId:l,subUnitId:c})}},pr={type:a.CommandType.COMMAND,id:"sheet.command.add-worksheet-merge-horizontal",handler:async i=>{const e=i.get(a.ICommandService),n=i.get(f.SelectionManagerService).getSelectionRanges();if(!(n!=null&&n.length))return!1;const r=i.get(a.IUniverInstanceService).getCurrentUniverSheetInstance();if(!r)return!1;const s=r.getActiveSheet();if(!s)return!1;const l=r.getUnitId(),c=s.getSheetId();return e.executeCommand(Ae.id,{value:a.Dimension.ROWS,selections:n,unitId:l,subUnitId:c})}},vr={id:"sheet.command.refill",type:a.CommandType.COMMAND,handler:async(i,e)=>(i.get(Dt).setApplyType(e.type),!0)},Cr={id:"sheet.command.remove-sheet-confirm",type:a.CommandType.COMMAND,handler:async(i,e)=>{const{subUnitId:t}=e,n=i.get(R.IConfirmService),o=i.get(a.ICommandService),r=i.get(a.LocaleService);return await n.confirm({id:"merge.confirm.add-worksheet-merge",title:{title:r.t("sheetConfig.deleteSheet")},children:{title:r.t("sheetConfig.deleteSheetContent")},cancelText:r.t("button.cancel"),confirmText:r.t("button.confirm")})?(await o.executeCommand(f.RemoveSheetCommand.id,{subUnitId:t}),!0):!1}},Nn={id:"sheet.command.change-zoom-ratio",type:a.CommandType.COMMAND,handler:async(i,e)=>{if(!e)return!1;const{delta:t,reset:n}=e,o=i.get(a.IUniverInstanceService).getCurrentUniverSheetInstance(),r=o.getActiveSheet(),s=o.getUnitId(),l=r.getSheetId();let c=n?100:Math.round((r.getConfig().zoomRatio+t)*100);c=Math.max(Qn[0],c),c=Math.min(Qn[1],c);const d=c/100;return i.get(a.ICommandService).executeCommand(xe.id,{unitId:s,subUnitId:l,zoomRatio:d})}},Ri={id:"sheet.command.set-zoom-ratio",type:a.CommandType.COMMAND,handler:async(i,e)=>{if(!e)return!1;const{unitId:t,subUnitId:n,zoomRatio:o}=e;return i.get(a.ICommandService).executeCommand(xe.id,{unitId:t,subUnitId:n,zoomRatio:o})}},mt=P.createIdentifier("univer.sheetbar-service");class Ld extends a.Disposable{constructor(){super();v(this,"renameId$");v(this,"removeId$");v(this,"scroll$");v(this,"scrollX$");v(this,"addSheet$");v(this,"_renameId$");v(this,"_removeId$");v(this,"_scroll$");v(this,"_scrollX$");v(this,"_addSheet$");v(this,"_currentHandler",null);this._renameId$=new k.Subject,this.renameId$=this._renameId$.asObservable(),this._removeId$=new k.Subject,this.removeId$=this._removeId$.asObservable(),this._scroll$=new k.Subject,this.scroll$=this._scroll$.asObservable(),this._scrollX$=new k.Subject,this.scrollX$=this._scrollX$.asObservable(),this._addSheet$=new k.Subject,this.addSheet$=this._addSheet$.asObservable()}setRenameId(t){this._renameId$.next(t)}setRemoveId(t){this._removeId$.next(t)}setScroll(t){this._scroll$.next(t)}setScrollX(t){this._scrollX$.next(t)}setAddSheet(t){this._addSheet$.next(t)}triggerSheetBarMenu(){var t;(t=this._currentHandler)==null||t.handleSheetBarMenu()}registerSheetBarMenuHandler(t){if(this._currentHandler)throw new Error("There is already a context menu handler!");return this._currentHandler=t,a.toDisposable(()=>{this._currentHandler=null})}}const Ir={id:"ui-sheet.command.show-menu-list",type:a.CommandType.OPERATION,handler:async i=>(i.get(mt).triggerSheetBarMenu(),!0)},Rr={id:"sheet.operation.rename-sheet",type:a.CommandType.OPERATION,handler:async(i,e)=>{const t=i.get(mt);return e&&t.setRenameId(e.subUnitId),!0}},Ud=()=>p.jsxs("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[p.jsx("path",{d:"M0.98999 1.08218H-0.0100098V0.0821838H0.98999V1.08218Z",fill:"black"}),p.jsx("path",{d:"M5.78992 1.08218H2.78992V0.0821838H5.78992V1.08218Z",fill:"black"}),p.jsx("path",{d:"M7.58984 1.08218H8.58984V0.0821838H7.58984V1.08218Z",fill:"black"}),p.jsx("path",{d:"M14.9152 1.08218H13.9152V0.0821838H14.9152V1.08218Z",fill:"black"}),p.jsx("path",{d:"M16.7151 1.08218H19.7151V0.0821838H16.7151V1.08218Z",fill:"black"}),p.jsx("path",{d:"M22.515 1.08218H21.515V0.0821838H22.515V1.08218Z",fill:"black"}),p.jsx("path",{d:"M27.8405 1.08218H28.8405V0.0821838H27.8405V1.08218Z",fill:"black"}),p.jsx("path",{d:"M33.6404 1.08218H30.6404V0.0821838H33.6404V1.08218Z",fill:"black"}),p.jsx("path",{d:"M35.4403 1.08218H36.4403V0.0821838H35.4403V1.08218Z",fill:"black"}),p.jsx("path",{d:"M42.7657 1.08218H41.7657V0.0821838H42.7657V1.08218Z",fill:"black"}),p.jsx("path",{d:"M44.5657 1.08218H47.5657V0.0821838H44.5657V1.08218Z",fill:"black"}),p.jsx("path",{d:"M50.3656 1.08218H49.3656V0.0821838H50.3656V1.08218Z",fill:"black"}),p.jsx("path",{d:"M55.691 1.08218H56.691V0.0821838H55.691V1.08218Z",fill:"black"}),p.jsx("path",{d:"M61.491 1.08218H58.491V0.0821838H61.491V1.08218Z",fill:"black"}),p.jsx("path",{d:"M63.2909 1.08218H64.2909V0.0821838H63.2909V1.08218Z",fill:"black"}),p.jsx("path",{d:"M70.6163 1.08218H69.6163V0.0821838H70.6163V1.08218Z",fill:"black"}),p.jsx("path",{d:"M72.4163 1.08218H75.4163V0.0821838H72.4163V1.08218Z",fill:"black"}),p.jsx("path",{d:"M78.2162 1.08218H77.2162V0.0821838H78.2162V1.08218Z",fill:"black"}),p.jsx("path",{d:"M83.5416 1.08218H84.5416V0.0821838H83.5416V1.08218Z",fill:"black"}),p.jsx("path",{d:"M89.3416 1.08218H86.3416V0.0821838H89.3416V1.08218Z",fill:"black"}),p.jsx("path",{d:"M91.1415 1.08218H92.1415V0.0821838H91.1415V1.08218Z",fill:"black"}),p.jsx("path",{d:"M98.4669 1.08218H97.4669V0.0821838H98.4669V1.08218Z",fill:"black"}),p.jsx("path",{d:"M100.267 1.08218H103.267V0.0821838H100.267V1.08218Z",fill:"black"}),p.jsx("path",{d:"M106.067 1.08218H105.067V0.0821838H106.067V1.08218Z",fill:"black"}),p.jsx("path",{d:"M111.392 1.08218H112.392V0.0821838H111.392V1.08218Z",fill:"black"}),p.jsx("path",{d:"M117.192 1.08218H114.192V0.0821838H117.192V1.08218Z",fill:"black"}),p.jsx("path",{d:"M118.992 1.08218H119.992V0.0821838H118.992V1.08218Z",fill:"black"})]}),kd=()=>p.jsxs("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[p.jsx("path",{d:"M-0.0100098 1.15771H0.98999V0.157715H-0.0100098V1.15771Z",fill:"black"}),p.jsx("path",{d:"M2.78992 1.15771H5.78992V0.157715H2.78992V1.15771Z",fill:"black"}),p.jsx("path",{d:"M8.58984 1.15771H7.58984V0.157715H8.58984V1.15771Z",fill:"black"}),p.jsx("path",{d:"M10.3899 1.15771H11.3899V0.157715H10.3899V1.15771Z",fill:"black"}),p.jsx("path",{d:"M19.0903 1.15771H18.0903V0.157715H19.0903V1.15771Z",fill:"black"}),p.jsx("path",{d:"M20.8903 1.15771H23.8903V0.157715H20.8903V1.15771Z",fill:"black"}),p.jsx("path",{d:"M26.6902 1.15771H25.6902V0.157715H26.6902V1.15771Z",fill:"black"}),p.jsx("path",{d:"M28.4902 1.15771H29.4902V0.157715H28.4902V1.15771Z",fill:"black"}),p.jsx("path",{d:"M37.1907 1.15771H36.1907V0.157715H37.1907V1.15771Z",fill:"black"}),p.jsx("path",{d:"M38.9906 1.15771H41.9906V0.157715H38.9906V1.15771Z",fill:"black"}),p.jsx("path",{d:"M44.7905 1.15771H43.7905V0.157715H44.7905V1.15771Z",fill:"black"}),p.jsx("path",{d:"M46.5906 1.15771H47.5906V0.157715H46.5906V1.15771Z",fill:"black"}),p.jsx("path",{d:"M55.291 1.15771H54.291V0.157715H55.291V1.15771Z",fill:"black"}),p.jsx("path",{d:"M57.0909 1.15771H60.0909V0.157715H57.0909V1.15771Z",fill:"black"}),p.jsx("path",{d:"M62.8909 1.15771H61.8909V0.157715H62.8909V1.15771Z",fill:"black"}),p.jsx("path",{d:"M64.6909 1.15771H65.6909V0.157715H64.6909V1.15771Z",fill:"black"}),p.jsx("path",{d:"M73.3914 1.15771H72.3914V0.157715H73.3914V1.15771Z",fill:"black"}),p.jsx("path",{d:"M75.1913 1.15771H78.1913V0.157715H75.1913V1.15771Z",fill:"black"}),p.jsx("path",{d:"M80.9912 1.15771H79.9912V0.157715H80.9912V1.15771Z",fill:"black"}),p.jsx("path",{d:"M82.7913 1.15771H83.7913V0.157715H82.7913V1.15771Z",fill:"black"}),p.jsx("path",{d:"M91.4917 1.15771H90.4917V0.157715H91.4917V1.15771Z",fill:"black"}),p.jsx("path",{d:"M93.2916 1.15771H96.2916V0.157715H93.2916V1.15771Z",fill:"black"}),p.jsx("path",{d:"M99.0916 1.15771H98.0916V0.157715H99.0916V1.15771Z",fill:"black"}),p.jsx("path",{d:"M100.892 1.15771H101.892V0.157715H100.892V1.15771Z",fill:"black"}),p.jsx("path",{d:"M109.592 1.15771H108.592V0.157715H109.592V1.15771Z",fill:"black"}),p.jsx("path",{d:"M111.392 1.15771H114.392V0.157715H111.392V1.15771Z",fill:"black"}),p.jsx("path",{d:"M117.192 1.15771H116.192V0.157715H117.192V1.15771Z",fill:"black"}),p.jsx("path",{d:"M118.992 1.15771H119.992V0.157715H118.992V1.15771Z",fill:"black"})]}),Bd=()=>p.jsxs("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[p.jsx("path",{d:"M-0.00842285 1.22449H2.99158V0.224487H-0.00842285V1.22449Z",fill:"black"}),p.jsx("path",{d:"M6.14941 1.22449H9.14941V0.224487H6.14941V1.22449Z",fill:"black"}),p.jsx("path",{d:"M15.3073 1.22449H12.3073V0.224487H15.3073V1.22449Z",fill:"black"}),p.jsx("path",{d:"M18.4651 1.22449H21.4651V0.224487H18.4651V1.22449Z",fill:"black"}),p.jsx("path",{d:"M27.6229 1.22449H24.6229V0.224487H27.6229V1.22449Z",fill:"black"}),p.jsx("path",{d:"M30.7808 1.22449H33.7808V0.224487H30.7808V1.22449Z",fill:"black"}),p.jsx("path",{d:"M39.9386 1.22449H36.9386V0.224487H39.9386V1.22449Z",fill:"black"}),p.jsx("path",{d:"M43.0964 1.22449H46.0964V0.224487H43.0964V1.22449Z",fill:"black"}),p.jsx("path",{d:"M52.2543 1.22449H49.2543V0.224487H52.2543V1.22449Z",fill:"black"}),p.jsx("path",{d:"M55.4121 1.22449H58.4121V0.224487H55.4121V1.22449Z",fill:"black"}),p.jsx("path",{d:"M64.5699 1.22449H61.5699V0.224487H64.5699V1.22449Z",fill:"black"}),p.jsx("path",{d:"M67.7278 1.22449H70.7278V0.224487H67.7278V1.22449Z",fill:"black"}),p.jsx("path",{d:"M76.8856 1.22449H73.8856V0.224487H76.8856V1.22449Z",fill:"black"}),p.jsx("path",{d:"M80.0435 1.22449H83.0435V0.224487H80.0435V1.22449Z",fill:"black"}),p.jsx("path",{d:"M89.2013 1.22449H86.2013V0.224487H89.2013V1.22449Z",fill:"black"}),p.jsx("path",{d:"M92.3591 1.22449H95.3591V0.224487H92.3591V1.22449Z",fill:"black"}),p.jsx("path",{d:"M101.517 1.22449H98.517V0.224487H101.517V1.22449Z",fill:"black"}),p.jsx("path",{d:"M104.675 1.22449H107.675V0.224487H104.675V1.22449Z",fill:"black"}),p.jsx("path",{d:"M113.833 1.22449H110.833V0.224487H113.833V1.22449Z",fill:"black"}),p.jsx("path",{d:"M116.99 1.22449H119.99V0.224487H116.99V1.22449Z",fill:"black"})]}),Vd=()=>p.jsxs("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[p.jsx("path",{d:"M-0.00976562 1.65707H0.990234V0.657074H-0.00976562V1.65707Z",fill:"black"}),p.jsx("path",{d:"M2.32361 1.65707H3.32361V0.657074H2.32361V1.65707Z",fill:"black"}),p.jsx("path",{d:"M5.65698 1.65707H4.65698V0.657074H5.65698V1.65707Z",fill:"black"}),p.jsx("path",{d:"M6.99036 1.65707H7.99036V0.657074H6.99036V1.65707Z",fill:"black"}),p.jsx("path",{d:"M10.3237 1.65707H9.32373V0.657074H10.3237V1.65707Z",fill:"black"}),p.jsx("path",{d:"M11.6571 1.65707H12.6571V0.657074H11.6571V1.65707Z",fill:"black"}),p.jsx("path",{d:"M14.9905 1.65707H13.9905V0.657074H14.9905V1.65707Z",fill:"black"}),p.jsx("path",{d:"M16.3239 1.65707H17.3239V0.657074H16.3239V1.65707Z",fill:"black"}),p.jsx("path",{d:"M19.6572 1.65707H18.6572V0.657074H19.6572V1.65707Z",fill:"black"}),p.jsx("path",{d:"M20.9906 1.65707H21.9906V0.657074H20.9906V1.65707Z",fill:"black"}),p.jsx("path",{d:"M24.324 1.65707H23.324V0.657074H24.324V1.65707Z",fill:"black"}),p.jsx("path",{d:"M25.6573 1.65707H26.6573V0.657074H25.6573V1.65707Z",fill:"black"}),p.jsx("path",{d:"M28.9907 1.65707H27.9907V0.657074H28.9907V1.65707Z",fill:"black"}),p.jsx("path",{d:"M30.3241 1.65707H31.3241V0.657074H30.3241V1.65707Z",fill:"black"}),p.jsx("path",{d:"M33.6575 1.65707H32.6575V0.657074H33.6575V1.65707Z",fill:"black"}),p.jsx("path",{d:"M34.9908 1.65707H35.9908V0.657074H34.9908V1.65707Z",fill:"black"}),p.jsx("path",{d:"M38.3242 1.65707H37.3242V0.657074H38.3242V1.65707Z",fill:"black"}),p.jsx("path",{d:"M39.6576 1.65707H40.6576V0.657074H39.6576V1.65707Z",fill:"black"}),p.jsx("path",{d:"M42.991 1.65707H41.991V0.657074H42.991V1.65707Z",fill:"black"}),p.jsx("path",{d:"M44.3243 1.65707H45.3243V0.657074H44.3243V1.65707Z",fill:"black"}),p.jsx("path",{d:"M47.6577 1.65707H46.6577V0.657074H47.6577V1.65707Z",fill:"black"}),p.jsx("path",{d:"M48.9911 1.65707H49.9911V0.657074H48.9911V1.65707Z",fill:"black"}),p.jsx("path",{d:"M52.3245 1.65707H51.3245V0.657074H52.3245V1.65707Z",fill:"black"}),p.jsx("path",{d:"M53.6578 1.65707H54.6578V0.657074H53.6578V1.65707Z",fill:"black"}),p.jsx("path",{d:"M56.9912 1.65707H55.9912V0.657074H56.9912V1.65707Z",fill:"black"}),p.jsx("path",{d:"M58.3246 1.65707H59.3246V0.657074H58.3246V1.65707Z",fill:"black"}),p.jsx("path",{d:"M61.658 1.65707H60.658V0.657074H61.658V1.65707Z",fill:"black"}),p.jsx("path",{d:"M62.9913 1.65707H63.9913V0.657074H62.9913V1.65707Z",fill:"black"}),p.jsx("path",{d:"M66.3247 1.65707H65.3247V0.657074H66.3247V1.65707Z",fill:"black"}),p.jsx("path",{d:"M67.6581 1.65707H68.6581V0.657074H67.6581V1.65707Z",fill:"black"}),p.jsx("path",{d:"M70.9915 1.65707H69.9915V0.657074H70.9915V1.65707Z",fill:"black"}),p.jsx("path",{d:"M72.3248 1.65707H73.3248V0.657074H72.3248V1.65707Z",fill:"black"}),p.jsx("path",{d:"M75.6582 1.65707H74.6582V0.657074H75.6582V1.65707Z",fill:"black"}),p.jsx("path",{d:"M76.9916 1.65707H77.9916V0.657074H76.9916V1.65707Z",fill:"black"}),p.jsx("path",{d:"M80.325 1.65707H79.325V0.657074H80.325V1.65707Z",fill:"black"}),p.jsx("path",{d:"M81.6583 1.65707H82.6583V0.657074H81.6583V1.65707Z",fill:"black"}),p.jsx("path",{d:"M84.9917 1.65707H83.9917V0.657074H84.9917V1.65707Z",fill:"black"}),p.jsx("path",{d:"M86.3251 1.65707H87.3251V0.657074H86.3251V1.65707Z",fill:"black"}),p.jsx("path",{d:"M89.6584 1.65707H88.6584V0.657074H89.6584V1.65707Z",fill:"black"}),p.jsx("path",{d:"M90.9918 1.65707H91.9918V0.657074H90.9918V1.65707Z",fill:"black"}),p.jsx("path",{d:"M94.3252 1.65707H93.3252V0.657074H94.3252V1.65707Z",fill:"black"}),p.jsx("path",{d:"M95.6586 1.65707H96.6586V0.657074H95.6586V1.65707Z",fill:"black"}),p.jsx("path",{d:"M98.9919 1.65707H97.9919V0.657074H98.9919V1.65707Z",fill:"black"}),p.jsx("path",{d:"M100.325 1.65707H101.325V0.657074H100.325V1.65707Z",fill:"black"}),p.jsx("path",{d:"M103.659 1.65707H102.659V0.657074H103.659V1.65707Z",fill:"black"}),p.jsx("path",{d:"M104.992 1.65707H105.992V0.657074H104.992V1.65707Z",fill:"black"}),p.jsx("path",{d:"M108.325 1.65707H107.325V0.657074H108.325V1.65707Z",fill:"black"}),p.jsx("path",{d:"M109.659 1.65707H110.659V0.657074H109.659V1.65707Z",fill:"black"}),p.jsx("path",{d:"M112.992 1.65707H111.992V0.657074H112.992V1.65707Z",fill:"black"}),p.jsx("path",{d:"M114.325 1.65707H115.325V0.657074H114.325V1.65707Z",fill:"black"}),p.jsx("path",{d:"M117.659 1.65707H116.659V0.657074H117.659V1.65707Z",fill:"black"}),p.jsx("path",{d:"M118.992 1.65707H119.992V0.657074H118.992V1.65707Z",fill:"black"})]}),Fd=()=>p.jsx("svg",{width:"120",height:"3",viewBox:"0 0 120 3",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:p.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M119.991 2.42035H-0.0090332V0.420349H119.991V2.42035Z",fill:"black"})}),jd=()=>p.jsxs("svg",{width:"120",height:"3",viewBox:"0 0 120 3",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[p.jsx("path",{d:"M-0.0100098 2.47614H1.98999V0.476135H-0.0100098V2.47614Z",fill:"black"}),p.jsx("path",{d:"M3.99014 2.47614H9.99014V0.476135H3.99014V2.47614Z",fill:"black"}),p.jsx("path",{d:"M13.9901 2.47614H11.9901V0.476135H13.9901V2.47614Z",fill:"black"}),p.jsx("path",{d:"M21.1904 2.47614H23.1904V0.476135H21.1904V2.47614Z",fill:"black"}),p.jsx("path",{d:"M31.1906 2.47614H25.1906V0.476135H31.1906V2.47614Z",fill:"black"}),p.jsx("path",{d:"M33.1906 2.47614H35.1906V0.476135H33.1906V2.47614Z",fill:"black"}),p.jsx("path",{d:"M44.3909 2.47614H42.3909V0.476135H44.3909V2.47614Z",fill:"black"}),p.jsx("path",{d:"M46.391 2.47614H52.391V0.476135H46.391V2.47614Z",fill:"black"}),p.jsx("path",{d:"M56.391 2.47614H54.391V0.476135H56.391V2.47614Z",fill:"black"}),p.jsx("path",{d:"M63.5913 2.47614H65.5913V0.476135H63.5913V2.47614Z",fill:"black"}),p.jsx("path",{d:"M73.5915 2.47614H67.5915V0.476135H73.5915V2.47614Z",fill:"black"}),p.jsx("path",{d:"M75.5915 2.47614H77.5915V0.476135H75.5915V2.47614Z",fill:"black"}),p.jsx("path",{d:"M86.7917 2.47614H84.7917V0.476135H86.7917V2.47614Z",fill:"black"}),p.jsx("path",{d:"M88.7919 2.47614H94.7919V0.476135H88.7919V2.47614Z",fill:"black"}),p.jsx("path",{d:"M98.7919 2.47614H96.7919V0.476135H98.7919V2.47614Z",fill:"black"}),p.jsx("path",{d:"M105.992 2.47614H107.992V0.476135H105.992V2.47614Z",fill:"black"}),p.jsx("path",{d:"M115.992 2.47614H109.992V0.476135H115.992V2.47614Z",fill:"black"}),p.jsx("path",{d:"M117.992 2.47614H119.992V0.476135H117.992V2.47614Z",fill:"black"})]}),Wd=()=>p.jsxs("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[p.jsx("path",{d:"M-0.0100098 2.00415H1.98999V0.00415039H-0.0100098V2.00415Z",fill:"black"}),p.jsx("path",{d:"M3.99014 2.00415H9.99014V0.00415039H3.99014V2.00415Z",fill:"black"}),p.jsx("path",{d:"M13.9901 2.00415H11.9901V0.00415039H13.9901V2.00415Z",fill:"black"}),p.jsx("path",{d:"M15.9901 2.00415H17.9901V0.00415039H15.9901V2.00415Z",fill:"black"}),p.jsx("path",{d:"M27.4905 2.00415H25.4905V0.00415039H27.4905V2.00415Z",fill:"black"}),p.jsx("path",{d:"M29.4906 2.00415H35.4906V0.00415039H29.4906V2.00415Z",fill:"black"}),p.jsx("path",{d:"M39.4906 2.00415H37.4906V0.00415039H39.4906V2.00415Z",fill:"black"}),p.jsx("path",{d:"M41.4906 2.00415H43.4906V0.00415039H41.4906V2.00415Z",fill:"black"}),p.jsx("path",{d:"M52.991 2.00415H50.991V0.00415039H52.991V2.00415Z",fill:"black"}),p.jsx("path",{d:"M54.9911 2.00415H60.9911V0.00415039H54.9911V2.00415Z",fill:"black"}),p.jsx("path",{d:"M64.9911 2.00415H62.9911V0.00415039H64.9911V2.00415Z",fill:"black"}),p.jsx("path",{d:"M66.9911 2.00415H68.9911V0.00415039H66.9911V2.00415Z",fill:"black"}),p.jsx("path",{d:"M78.4915 2.00415H76.4915V0.00415039H78.4915V2.00415Z",fill:"black"}),p.jsx("path",{d:"M80.4916 2.00415H86.4916V0.00415039H80.4916V2.00415Z",fill:"black"}),p.jsx("path",{d:"M90.4916 2.00415H88.4916V0.00415039H90.4916V2.00415Z",fill:"black"}),p.jsx("path",{d:"M92.4916 2.00415H94.4916V0.00415039H92.4916V2.00415Z",fill:"black"}),p.jsx("path",{d:"M103.992 2.00415H101.992V0.00415039H103.992V2.00415Z",fill:"black"}),p.jsx("path",{d:"M105.992 2.00415H111.992V0.00415039H105.992V2.00415Z",fill:"black"}),p.jsx("path",{d:"M115.992 2.00415H113.992V0.00415039H115.992V2.00415Z",fill:"black"}),p.jsx("path",{d:"M117.992 2.00415H119.992V0.00415039H117.992V2.00415Z",fill:"black"})]}),$d=()=>p.jsxs("svg",{width:"118",height:"3",viewBox:"0 0 118 3",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[p.jsx("path",{d:"M-0.00854492 2.94815H1.99146V0.948151H-0.00854492V2.94815Z",fill:"black"}),p.jsx("path",{d:"M6.09668 2.94815H8.09668V0.948151H6.09668V2.94815Z",fill:"black"}),p.jsx("path",{d:"M14.2019 2.94815H12.2019V0.948151H14.2019V2.94815Z",fill:"black"}),p.jsx("path",{d:"M18.3071 2.94815H20.3071V0.948151H18.3071V2.94815Z",fill:"black"}),p.jsx("path",{d:"M26.4124 2.94815H24.4124V0.948151H26.4124V2.94815Z",fill:"black"}),p.jsx("path",{d:"M30.5176 2.94815H32.5176V0.948151H30.5176V2.94815Z",fill:"black"}),p.jsx("path",{d:"M38.6228 2.94815H36.6228V0.948151H38.6228V2.94815Z",fill:"black"}),p.jsx("path",{d:"M42.728 2.94815H44.728V0.948151H42.728V2.94815Z",fill:"black"}),p.jsx("path",{d:"M50.8333 2.94815H48.8333V0.948151H50.8333V2.94815Z",fill:"black"}),p.jsx("path",{d:"M54.9385 2.94815H56.9385V0.948151H54.9385V2.94815Z",fill:"black"}),p.jsx("path",{d:"M63.0437 2.94815H61.0437V0.948151H63.0437V2.94815Z",fill:"black"}),p.jsx("path",{d:"M67.1489 2.94815H69.1489V0.948151H67.1489V2.94815Z",fill:"black"}),p.jsx("path",{d:"M75.2542 2.94815H73.2542V0.948151H75.2542V2.94815Z",fill:"black"}),p.jsx("path",{d:"M79.3594 2.94815H81.3594V0.948151H79.3594V2.94815Z",fill:"black"}),p.jsx("path",{d:"M87.4645 2.94815H85.4645V0.948151H87.4645V2.94815Z",fill:"black"}),p.jsx("path",{d:"M91.5697 2.94815H93.5697V0.948151H91.5697V2.94815Z",fill:"black"}),p.jsx("path",{d:"M99.6749 2.94815H97.6749V0.948151H99.6749V2.94815Z",fill:"black"}),p.jsx("path",{d:"M103.78 2.94815H105.78V0.948151H103.78V2.94815Z",fill:"black"}),p.jsx("path",{d:"M111.885 2.94815H109.885V0.948151H111.885V2.94815Z",fill:"black"}),p.jsx("path",{d:"M115.991 2.94815H117.991V0.948151H115.991V2.94815Z",fill:"black"})]}),zd=()=>p.jsx("svg",{width:"120",height:"4",viewBox:"0 0 120 4",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:p.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M119.991 3.86215H-0.0090332V0.862152H119.991V3.86215Z",fill:"black"})}),ho=()=>p.jsx("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:p.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M119.991 1.15668H-0.0090332V0.156677H119.991V1.15668Z",fill:"black"})});function mo(i){const{type:e=a.BorderStyleTypes.THIN}=i;switch(e){case a.BorderStyleTypes.DASH_DOT:return p.jsx(Ud,{});case a.BorderStyleTypes.DASH_DOT_DOT:return p.jsx(kd,{});case a.BorderStyleTypes.DASHED:return p.jsx(Bd,{});case a.BorderStyleTypes.HAIR:return p.jsx(Vd,{});case a.BorderStyleTypes.MEDIUM:return p.jsx(Fd,{});case a.BorderStyleTypes.MEDIUM_DASH_DOT:return p.jsx(jd,{});case a.BorderStyleTypes.MEDIUM_DASH_DOT_DOT:return p.jsx(Wd,{});case a.BorderStyleTypes.MEDIUM_DASHED:return p.jsx($d,{});case a.BorderStyleTypes.THICK:return p.jsx(zd,{});case a.BorderStyleTypes.THIN:return p.jsx(ho,{});default:return p.jsx(ho,{})}}const Xd="univer-ui-plugin-sheets-border-panel",Yd="univer-ui-plugin-sheets-border-panel-position",Zd="univer-ui-plugin-sheets-border-panel-position-item",Gd="univer-ui-plugin-sheets-border-panel-styles",Kd="univer-ui-plugin-sheets-border-panel-board",qd="univer-ui-plugin-sheets-border-panel-button",Jd="univer-ui-plugin-sheets-border-panel-more-icon",Ee={uiPluginSheetsBorderPanel:Xd,uiPluginSheetsBorderPanelPosition:Yd,uiPluginSheetsBorderPanelPositionItem:Zd,uiPluginSheetsBorderPanelStyles:Gd,uiPluginSheetsBorderPanelBoard:Kd,uiPluginSheetsBorderPanelButton:qd,uiPluginSheetsBorderPanelMoreIcon:Jd},br=`${ut}_BORDER_PANEL_COMPONENT`,Mr=[{label:"borderLine.borderTop",icon:"UpBorder",value:"top"},{label:"borderLine.borderBottom",icon:"DownBorder",value:"bottom"},{label:"borderLine.borderLeft",icon:"LeftBorder",value:"left"},{label:"borderLine.borderRight",icon:"RightBorder",value:"right"},{label:"borderLine.borderNone",icon:"NoBorderSingle",value:"none"},{label:"borderLine.borderAll",icon:"AllBorderSingle",value:"all"},{label:"borderLine.borderOutside",icon:"OuterBorder",value:"outside"},{label:"borderLine.borderInside",icon:"InnerBorder",value:"inside"},{label:"borderLine.borderHorizontal",icon:"InnerBorder",value:"horizontal"},{label:"borderLine.borderVertical",icon:"InnerBorder",value:"vertical"},{label:"borderLine.borderTlbr",icon:"BackSlashSingle",value:"tlbr"},{label:"borderLine.borderTlbcTlmr",icon:"LeftDoubleDiagonalSingle",value:"tlbc_tlmr"},{label:"borderLine.borderTlbrTlbcTlmr",icon:"LeftTridiagonalSingle",value:"tlbr_tlbc_tlmr"},{label:"borderLine.borderBlTr",icon:"SlashSingle",value:"bltr"},{label:"borderLine.borderMltrBctr",icon:"RightDoubleDiagonalSingle",value:"mltr_bctr"}],Qd=[{label:a.BorderStyleTypes.THIN,value:a.BorderStyleTypes.THIN},{label:a.BorderStyleTypes.HAIR,value:a.BorderStyleTypes.HAIR},{label:a.BorderStyleTypes.DOTTED,value:a.BorderStyleTypes.DOTTED},{label:a.BorderStyleTypes.DASHED,value:a.BorderStyleTypes.DASHED},{label:a.BorderStyleTypes.DASH_DOT,value:a.BorderStyleTypes.DASH_DOT},{label:a.BorderStyleTypes.DASH_DOT_DOT,value:a.BorderStyleTypes.DASH_DOT_DOT},{label:a.BorderStyleTypes.MEDIUM,value:a.BorderStyleTypes.MEDIUM},{label:a.BorderStyleTypes.MEDIUM_DASHED,value:a.BorderStyleTypes.MEDIUM_DASHED},{label:a.BorderStyleTypes.MEDIUM_DASH_DOT,value:a.BorderStyleTypes.MEDIUM_DASH_DOT},{label:a.BorderStyleTypes.MEDIUM_DASH_DOT_DOT,value:a.BorderStyleTypes.MEDIUM_DASH_DOT_DOT},{label:a.BorderStyleTypes.THICK,value:a.BorderStyleTypes.THICK}];function eu(i){const e=W.useDependency(R.ComponentManager),{onChange:t,value:n}=i;function o(l,c){t==null||t({...n,[c]:l})}function r(l){const c=e.get(l);return c&&p.jsx(c,{extend:{colorChannel1:"rgb(var(--primary-color))"}})}function s(l){l.stopPropagation()}return p.jsxs("section",{className:Ee.uiPluginSheetsBorderPanel,children:[p.jsx("div",{className:Ee.uiPluginSheetsBorderPanelPosition,children:Mr.map(l=>p.jsx("div",{className:Ee.uiPluginSheetsBorderPanelPositionItem,onClick:()=>o(l.value,"type"),children:r(l.icon)},l.value))}),p.jsxs("div",{className:Ee.uiPluginSheetsBorderPanelStyles,children:[p.jsx("div",{children:p.jsx(ie.Dropdown,{align:{offset:[0,18]},overlay:p.jsx("section",{className:Ee.uiPluginSheetsBorderPanelBoard,onClick:s,children:p.jsx(ie.ColorPicker,{onChange:l=>o(l,"color")})}),children:p.jsxs("a",{className:Ee.uiPluginSheetsBorderPanelButton,onClick:s,children:[p.jsx(il,{extend:{colorChannel1:n.color??"rgb(var(--primary-color))"}}),p.jsx("span",{className:Ee.uiPluginSheetsBorderPanelMoreIcon,children:p.jsx(ei,{})})]})})}),p.jsx("div",{children:p.jsx(ie.Dropdown,{align:{offset:[0,18]},overlay:p.jsx("section",{onClick:s,children:p.jsx(ie.Menu,{children:Qd.map(l=>p.jsx(ie.MenuItem,{eventKey:l.value.toString(),onClick:()=>o(l.value,"style"),children:p.jsx(mo,{type:l.value})},l.value))})}),children:p.jsxs("a",{className:Ee.uiPluginSheetsBorderPanelButton,onClick:s,children:[p.jsx(mo,{type:a.BorderStyleTypes.THIN}),p.jsx("span",{className:Ee.uiPluginSheetsBorderPanelMoreIcon,children:p.jsx(ei,{})})]})})})]})]})}const tu="univer-count-bar",nu={countBar:tu},iu=[50,80,100,130,150,170,200,400];function ou(){const i=W.useDependency(a.ICommandService),e=W.useDependency(a.IUniverInstanceService),t=r(),[n,o]=L.useState(t);L.useEffect(()=>i.onCommandExecuted(c=>{if(c.id===xe.id||c.id===f.SetWorksheetActivateCommand.id){const d=r();o(d)}}).dispose,[i]);function r(){const l=e.getCurrentUniverSheetInstance().getActiveSheet().getZoomRatio()*100||100;return Math.round(l)}function s(l){o(l);const c=e.getCurrentUniverSheetInstance();if(!c)return;const d=c.getActiveSheet();if(!d)return;const u=l/100;i.executeCommand(Ri.id,{unitId:c.getUnitId(),subUnitId:d.getSheetId(),zoomRatio:u})}return p.jsx(ie.Slider,{min:Qn[0],value:n,shortcuts:iu,onChange:s})}function ru(i){return p.jsx("section",{className:nu.countBar,children:p.jsx(ou,{})})}const su="univer-editor-container",lu="univer-editor-input",So={editorContainer:su,editorInput:lu},Tn=-1e3,_o={width:0,height:0,top:Tn,left:Tn},au=()=>{const[i,e]=L.useState({..._o}),t=L.useRef(null),n=W.useDependency(w.IRenderManagerService),o=W.useDependency(Pt);return L.useEffect(()=>{const r=t.current;if(!r)return;const s=n.currentRender$.pipe(po.switchMap(()=>{var c;const l=(c=n.getRenderById(a.DOCS_NORMAL_EDITOR_UNIT_ID_KEY))==null?void 0:c.engine;return l==null||l.setContainer(r),o.state$})).subscribe(l=>{if(l==null)return;const{startX:c=Tn,startY:d=Tn,endX:u=0,endY:h=0,show:m=!1}=l;if(!m)e({..._o});else{e({width:u-c,height:h-d,left:c,top:d});const S=t.current;if(!S)return;const{left:g,top:_,width:I,height:C}=S.getBoundingClientRect();o.setRect({left:g,top:_,width:I,height:C})}});return()=>{s.unsubscribe()}},[]),L.useEffect(()=>{o.setFocus(!0)},[i]),p.jsx("div",{className:So.editorContainer,style:{left:i.left,top:i.top,width:i.width,height:i.height},children:p.jsx("div",{className:So.editorInput,ref:t})})},cu="univer-formula-box",du="univer-name-ranges",uu="univer-name-ranges-input",hu="univer-formula-bar",mu="univer-formula-icon",Su="univer-formula-icon-wrapper",_u="univer-icon-container",gu="univer-icon-container-success",fu="univer-formula-active",pu="univer-icon-container-error",vu="univer-formula-input",Cu="univer-formula-content",Iu="univer-arrow-container",ne={formulaBox:cu,nameRanges:du,nameRangesInput:uu,formulaBar:hu,formulaIcon:mu,formulaIconWrapper:Su,iconContainer:_u,iconContainerSuccess:gu,formulaActive:fu,iconContainerError:pu,formulaInput:vu,formulaContent:Cu,arrowContainer:Iu};function Ru(){const[i,e]=L.useState(ne.formulaGrey),[t,n]=L.useState(0),o=L.useRef(null),r=W.useDependency(w.IRenderManagerService),s=W.useDependency(Dn),l=W.useDependency(pe);L.useEffect(()=>{const m=o.current;if(!m)return;const S=r.currentRender$.subscribe(_=>{var C;if(_!==a.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY)return;const I=(C=r.getRenderById(a.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY))==null?void 0:C.engine;I==null||I.setContainer(m)}),g=new ResizeObserver(()=>{const _=m.getBoundingClientRect();s.setPosition(_)});return g.observe(m),l.visible$.subscribe(_=>{e(_.visible?ne.formulaActive:ne.formulaGrey)}),()=>{g.unobserve(m),S.unsubscribe()}},[]);function c(){n(t===0?1:0)}function d(){l.isVisible().visible&&l.changeVisible({visible:!1,eventType:w.DeviceInputEventType.Keyboard,keycode:R.KeyCode.ESC})}function u(){l.isVisible().visible&&l.changeVisible({visible:!1,eventType:w.DeviceInputEventType.PointerDown})}function h(){s.handleFxBtnClick(!0)}return p.jsxs("div",{className:ne.formulaBox,style:{height:t===0?"28px":"82px"},children:[p.jsx("div",{className:ne.nameRanges,children:p.jsx("div",{className:ne.nameRangesInput})}),p.jsxs("div",{className:ne.formulaBar,children:[p.jsx("div",{className:ne.formulaIcon,children:p.jsxs("div",{className:ne.formulaIconWrapper,children:[p.jsx("span",{className:Tt(ne.iconContainer,ne.iconContainerError,i),onClick:d,children:p.jsx($s,{})}),p.jsx("span",{className:Tt(ne.iconContainer,ne.iconContainerSuccess,i),onClick:u,children:p.jsx(bn,{})}),p.jsx("span",{className:ne.iconContainer,onClick:h,children:p.jsx(qs,{})})]})}),p.jsxs("div",{className:ne.formulaInput,children:[p.jsx("div",{onContextMenu:m=>m.preventDefault(),className:ne.formulaContent,ref:o}),p.jsx("div",{className:ne.arrowContainer,onClick:c,children:t===0?p.jsx(Wi,{}):p.jsx(Wi,{style:{transform:"rotateZ(180deg)"}})})]})]})]})}const bu="univer-operate-container",Mu="univer-auto-fill-popup-menu",wu="univer-auto-fill-popup-menu-item",Tu="univer-auto-fill-popup-menu-item-icon",Eu="univer-auto-fill-popup-menu-item-title",yu="univer-auto-fill-popup-menu-item-hide",Ou="univer-btn-container",xu="univer-btn-container-expand",ze={operateContainer:bu,autoFillPopupMenu:Mu,autoFillPopupMenuItem:wu,autoFillPopupMenuItemIcon:Tu,autoFillPopupMenuItemTitle:Eu,autoFillPopupMenuItemHide:yu,btnContainer:Ou,btnContainerExpand:xu},Au=()=>{const[,i]=L.useState({});return L.useCallback(()=>i({}),[])},Hu=()=>{var q;const i=W.useDependency(a.ICommandService),e=W.useDependency(exports.SheetSkeletonManagerService),t=W.useDependency(a.IUniverInstanceService),n=W.useDependency(w.IRenderManagerService),o=W.useDependency(ce),r=W.useDependency(Dt),s=W.useDependency(a.LocaleService),[l,c]=L.useState([]),[d,u]=L.useState(!1),[h,m]=L.useState({row:-1,col:-1}),[S,g]=L.useState(X.SERIES),[_,I]=L.useState(!1),C=()=>{I(!0)},b=()=>{I(!1)},M=Au(),T=ae(t,n);if(T==null)return null;const{scene:E}=T;if(L.useEffect(()=>{const z=[Re.id,zt.id,xe.id,f.SetRangeValuesMutation.id];return i.onCommandExecuted(J=>{if(J.id===Cn.id){const{endColumn:we,endRow:re}=(J==null?void 0:J.params).selectionRange;m({row:re,col:we})}J.id===ct.id&&M(),z.includes(J.id)&&m({row:-1,col:-1})}).dispose},[M,i]),L.useEffect(()=>a.toDisposable(r.menu$.subscribe(Q=>{c(Q.map(J=>({...J,index:Q.indexOf(J)})))})).dispose,[r]),L.useEffect(()=>a.toDisposable(r.applyType$.subscribe(Q=>{g(Q)})).dispose,[r]),L.useEffect(()=>{function z(){u(!1)}return document.addEventListener("wheel",z),()=>{document.removeEventListener("wheel",z)}},[d]),h.col<0||h.row<0)return null;const y=(q=e.getCurrent())==null?void 0:q.skeleton,O=o.getViewPort(),x=E==null?void 0:E.scaleX,D=E==null?void 0:E.scaleY,U=E==null?void 0:E.getScrollXY(O);if(!x||!E||!x||!D||!U)return null;const N=(y==null?void 0:y.getNoMergeCellPositionByIndex(h.row,h.col,x,D).endX)||0,B=(y==null?void 0:y.getNoMergeCellPositionByIndex(h.row,h.col,x,D).endY)||0,A=y==null?void 0:y.convertTransformToOffsetX(N,x,U),H=y==null?void 0:y.convertTransformToOffsetY(B,D,U);if(A==null||H==null)return null;const V=z=>{u(z)},F=z=>{i.executeCommand(vr.id,{type:z.value})},j=d||_,$=l.filter(z=>!z.disable);return p.jsx("div",{onMouseEnter:C,onMouseLeave:b,style:{left:`${A+2}px`,top:`${H+2}px`,position:"absolute"},children:p.jsx(ie.Dropdown,{placement:"bottomLeft",trigger:["click"],overlay:p.jsx("ul",{className:ze.autoFillPopupMenu,children:$.map(z=>p.jsxs("li",{onClick:()=>F(z),className:ze.autoFillPopupMenuItem,children:[p.jsx("span",{className:ze.autoFillPopupMenuItemIcon,children:z.value===S&&p.jsx(bn,{style:{color:"rgb(var(--green-700, #409f11))"}})}),p.jsx("span",{className:ze.autoFillPopupMenuItemTitle,children:s.t(z.label)})]},z.index))}),visible:d,onVisibleChange:V,children:p.jsxs("div",{className:Tt(ze.btnContainer,{[ze.btnContainerExpand]:d}),children:[p.jsx(Fs,{style:{color:"#35322B"},extend:{colorChannel1:"rgb(var(--green-700, #409f11))"}}),j&&p.jsx(ei,{style:{color:"#CCCCCC",fontSize:"8px",marginLeft:"8px"}})]})})})},Du=()=>p.jsx("div",{className:ze.operateContainer,children:p.jsx(Hu,{})}),Nu="univer-sheet-bar",Pu="univer-sheet-bar-options",Lu="univer-sheet-bar-options-divider",$t={sheetBar:Nu,sheetBarOptions:Pu,sheetBarOptionsDivider:Lu},Uu="univer-sheet-bar-btn",ku={sheetBarBtn:Uu};function gn(i){const{children:e,className:t,style:n,disabled:o=!1,onClick:r,...s}=i,l=c=>{if(o){c.preventDefault();return}r&&r(c)};return p.jsx("button",{className:ku.sheetBarBtn,style:n,disabled:o,onClick:l,...s,children:e})}const Bu="univer-sheet-bar-menu",Vu="univer-sheet-bar-menu-item",Fu="univer-sheet-bar-menu-item-icon",ju="univer-sheet-bar-menu-item-hide",Wu="univer-sheet-bar-menu-item-select",$u="univer-sheet-bar-menu-item-label",Pe={sheetBarMenu:Bu,sheetBarMenuItem:Vu,sheetBarMenuItemIcon:Fu,sheetBarMenuItemHide:ju,sheetBarMenuItemSelect:Wu,sheetBarMenuItemLabel:$u};function zu(i){const{style:e}=i,[t,n]=L.useState([]),[o,r]=L.useState(!1),s=W.useDependency(a.IUniverInstanceService),l=W.useDependency(a.ICommandService),c=W.useDependency(mt),d=s.getCurrentUniverSheetInstance(),u=_=>{const{sheetId:I}=_;I&&(_.hidden?l.executeCommand(f.SetWorksheetShowCommand.id,{value:I}):_.selected||l.executeCommand(f.SetWorksheetActivateCommand.id,{unitId:d.getUnitId(),subUnitId:I}),r(!1))};L.useEffect(()=>{m();const _=new a.DisposableCollection;return _.add(h()),_.add(c.registerSheetBarMenuHandler({handleSheetBarMenu:S})),()=>{_.dispose()}},[]);const h=()=>l.onCommandExecuted(_=>{switch(_.id){case f.SetWorksheetHideMutation.id:case f.RemoveSheetMutation.id:case f.SetWorksheetNameMutation.id:case f.InsertSheetMutation.id:case f.SetWorksheetOrderMutation.id:case f.SetWorksheetActiveOperation.id:m();break}}),m=()=>{const I=d.getSheets().map((C,b)=>({label:C.getName(),index:`${b}`,sheetId:C.getSheetId(),hidden:C.isSheetHidden()===a.BooleanNumber.TRUE,selected:C.getStatus()===a.BooleanNumber.TRUE}));n(I)};function S(){r(!0)}const g=_=>{r(_)};return p.jsx(ie.Dropdown,{placement:"topLeft",trigger:["click"],overlay:p.jsx("ul",{className:Pe.sheetBarMenu,style:{...e},children:t.map(_=>p.jsxs("li",{onClick:()=>u(_),className:_.selected?`${Pe.sheetBarMenuItem} ${Pe.sheetBarMenuItemSelect}`:_.hidden?`${Pe.sheetBarMenuItem} ${Pe.sheetBarMenuItemHide}`:Pe.sheetBarMenuItem,children:[p.jsx("span",{className:Pe.sheetBarMenuItemIcon,children:_.selected?p.jsx(bn,{}):_.hidden?p.jsx(Gs,{}):p.jsx(bn,{})}),p.jsx("span",{className:Pe.sheetBarMenuItemLabel,children:_.label})]},_.index))}),visible:o,onVisibleChange:g,children:p.jsx(gn,{children:p.jsx(Xs,{})})})}const Xu="univer-slide-tab-bar-container",Yu="univer-slide-tab-bar",Zu="univer-slide-tab-item",Gu="univer-slide-tab-active",Ku="univer-slide-tab-span",qu="univer-slide-tab-span-edit",ge={slideTabBarContainer:Xu,slideTabBar:Yu,slideTabItem:Zu,slideTabActive:Gu,slideTabSpan:Ku,slideTabSpanEdit:qu};function Ju(i){const{sheetId:e,label:t,color:n,selected:o}=i,[r,s]=L.useState(!1),[l,c]=L.useState(o),d=W.useDependency(a.ICommandService),u=W.useDependency(a.ThemeService);L.useEffect(()=>{c(o)},[o]);const h=S=>{s(S)},m=S=>{const g=u.getCurrentTheme(),_=g.textColor,I=g.colorWhite;return new a.ColorKit(S).isDark()?I:_};return p.jsx(ie.Dropdown,{visible:r,trigger:["contextMenu"],overlay:p.jsx(R.Menu,{menuType:ee.SHEET_BAR,onOptionSelect:S=>{const{label:g,value:_}=S;d.executeCommand(g,{value:_,subUnitId:e}),s(!1)}}),onVisibleChange:h,children:p.jsx("div",{"data-id":e,className:l?`${ge.slideTabActive} ${ge.slideTabItem}`:ge.slideTabItem,style:{backgroundColor:!l&&n?n:"",color:!l&&n?m(n):"",boxShadow:l&&n?`0px 0px 12px rgba(0, 0, 0, 0.2), inset 0px -2px 0px 0px ${n}`:""},children:p.jsx("span",{className:ge.slideTabSpan,children:t})},e)})}const Qu={easeOutStrong(i,e,t,n){return-t*((i=i/n-1)*i*i*i-1)+e},backOut(i,e,t,n,o){return typeof o>"u"&&(o=.7),t*((i=i/n-1)*i*((o+1)*i+o)+1)+e}},eh={loop:!1,begin:0,end:0,duration:300,delay:0,type:"easeOutStrong",receive(i){},success(i){},cancel(i){},complete(i){}};class th{constructor(e){v(this,"_config");v(this,"_status",0);v(this,"_start",0);v(this,"_handle",0);v(this,"_delayHandle",null);this._config={...eh,...e},this._config.loop&&(this._config.complete=()=>{},this._config.success=()=>{this.request()})}static success(...e){let t=0;return new Promise(n=>{for(let o=0;o<e.length;o++){const r=e[o],s=r._config,l=s.success;s.loop||(s.success=d=>{t++,l&&l.call(r,d),t===e.length&&n()})}})}request(){this._config.delay===0?(this._status=0,this._start=Date.now(),this._fakeHandle()):(this._delayHandle&&clearTimeout(this._delayHandle),this._delayHandle=setTimeout(()=>{this._status=0,this._start=Date.now(),this._fakeHandle()},this._config.delay))}cancel(){this._status=1,this._delayHandle&&clearTimeout(this._delayHandle),cancelAnimationFrame(this._handle)}_fakeHandle(){let e=Date.now()-this._start;e=e>=this._config.duration?this._config.duration:e;const n=Qu[this._config.type](e,this._config.begin,this._config.end-this._config.begin,this._config.duration,.7).toFixed(2);if(this._config.receive(n),this._status===1){this._config.cancel(n),this._config.complete(n);return}if(e===this._config.duration){this._config.success(n),this._config.complete(n);return}this._handle=requestAnimationFrame(()=>{this._fakeHandle()})}}class Ze{constructor(e,t){v(this,"_slideTabItem");v(this,"_animate");v(this,"_midline",0);v(this,"_translateX");v(this,"_scrollbar");v(this,"_slideTabBar");v(this,"_editMode");v(this,"_placeholder");this._slideTabItem=e,this._animate=null,this._translateX=0,this._editMode=!1,this._slideTabBar=t,this._placeholder=null,this._scrollbar=t.getScrollbar(),this.update()}static midline(e){return e.getBoundingRect().x+e.getBoundingRect().width/2}static leftLine(e){return e.getBoundingRect().x}static rightLine(e){return e.getBoundingRect().x+e.getBoundingRect().width}static make(e,t){const n=[];return e.forEach(o=>n.push(new Ze(o,t))),n}getSlideTabItem(){return this._slideTabItem}getEditor(){return this._slideTabItem.querySelector("span")}isEditMode(){return this._editMode}classList(){return this._slideTabItem.classList}translateX(e){return this._translateX=e,this._slideTabItem.style.transform=`translateX(${e}px)`,this.getTranslateXDirection()}setEditor(e){let t=!0;if(this._editMode===!1){const n=this._slideTabItem.querySelector("span"),o=d=>{if(!this.nameCheck()){if(this._editMode=!1,n&&(n.removeAttribute("contentEditable"),n.removeEventListener("blur",o),n.removeEventListener("compositionstart",s),n.removeEventListener("compositionend",l),n.removeEventListener("input",c),n.removeEventListener("keydown",r),n.classList.remove(this._slideTabBar.getConfig().slideTabBarSpanEditClassName)),this._slideTabBar.removeListener(),this._slideTabBar.updateItems(),this._slideTabBar.getConfig().onChangeName){const u=(n==null?void 0:n.innerText)||"",h=this.getId();this._slideTabBar.getConfig().onChangeName(h,u)}e&&e(d)}};let r=d=>{n&&(d.stopPropagation(),d.key==="Enter"&&n.blur())};const s=d=>{t=!1},l=d=>{t=!0},c=d=>{if(!n)return;const u=50;setTimeout(()=>{if(t){const h=n.innerText;h.length>u&&(n.innerText=h.substring(0,u),xt.keepLastIndex(n))}},0)};n&&(n.setAttribute("contentEditable","true"),n.addEventListener("blur",o),n.addEventListener("compositionstart",s),n.addEventListener("compositionend",l),n.addEventListener("input",c),n.addEventListener("keydown",r),n.classList.add(this._slideTabBar.getConfig().slideTabBarSpanEditClassName),this._editMode=!0,xt.keepSelectAll(n))}}nameCheck(){const e=this._slideTabItem.querySelector("span");if(!e)return!1;const t=e.innerText;return this._slideTabBar.getConfig().onNameCheckAlert(t)}animate(){return{translateX:e=>{this._translateX!==e&&(this._animate&&(this._animate.cancel(),this._animate=null),this._animate=new th({begin:this._translateX,end:e,receive:t=>{this._slideTabItem.style.transform=`translateX(${t}px)`}}),this._translateX=e,this._animate.request())},cancel:()=>{this._animate&&(this._animate.cancel(),this._animate=null)}}}after(e){this._slideTabItem.after(e._slideTabItem||e)}update(){this._midline=Ze.midline(this)}disableFixed(){if(this._placeholder){const e=this._slideTabBar.primeval();this._slideTabItem.style.removeProperty("position"),this._slideTabItem.style.removeProperty("left"),this._slideTabItem.style.removeProperty("top"),this._slideTabItem.style.removeProperty("width"),this._slideTabItem.style.removeProperty("height"),this._slideTabItem.style.removeProperty("background"),this._slideTabItem.style.removeProperty("padding"),this._slideTabItem.style.removeProperty("box-sizing"),this._slideTabItem.style.removeProperty("font-size"),this._slideTabItem.style.removeProperty("font-family"),this._slideTabItem.style.removeProperty("font-weight"),this._slideTabItem.style.removeProperty("color"),this._slideTabItem.style.removeProperty("border-radius"),this._placeholder.after(this._slideTabItem),e.removeChild(this._placeholder),this._placeholder=null}}enableFixed(){const e=document.createElement("div"),t=this.getBoundingRect(),n=getComputedStyle(this._slideTabItem),o=this._slideTabItem.querySelector("span");if(this._placeholder=e,this._placeholder.style.width=`${t.width}px`,this._placeholder.style.height=`${t.height}px`,this._placeholder.style.flexShrink="0",this._placeholder.style.margin=n.margin,this._slideTabItem.style.background=n.background,o){const r=getComputedStyle(o).padding;this._slideTabItem.style.padding=r}this._slideTabItem.style.boxSizing=n.boxSizing,this._slideTabItem.style.fontSize=n.fontSize,this._slideTabItem.style.fontFamily=n.fontFamily,this._slideTabItem.style.fontWeight=n.fontWeight,this._slideTabItem.style.color=n.color,this._slideTabItem.style.borderRadius=n.borderRadius,this._slideTabItem.style.left=`${t.x-this.getScrollbar().getScrollX()}px`,this._slideTabItem.style.top=`${t.y}px`,this._slideTabItem.style.width=`${t.width}px`,this._slideTabItem.style.height=`${t.height}px`,this._slideTabItem.style.position="fixed",this._slideTabItem.after(e),document.body.appendChild(this._slideTabItem)}addEventListener(e,t,n){this._slideTabItem.addEventListener(e,t,n)}removeEventListener(e,t,n){this._slideTabItem.removeEventListener(e,t,n)}getScrollbar(){return this._scrollbar}getMidLine(){return this._midline}getBoundingRect(){const e=this._slideTabItem.getBoundingClientRect();return e.x+=this._scrollbar.getScrollX(),e}getWidth(){return this.getBoundingRect().width}getTranslateXDirection(){const e=Ze.midline(this);return e>this._midline?1:e<this._midline?-1:0}equals(e){return e&&e._slideTabItem===this._slideTabItem}getId(){return this._slideTabItem.dataset.id||""}}class nh{constructor(e){v(this,"_slideTabBar");v(this,"_scrollX");const t=e.primeval();this._scrollX=t.scrollLeft,this._slideTabBar=e}scrollX(e){const t=this._slideTabBar.primeval();t.scrollLeft=e,this._scrollX=t.scrollLeft}scrollRight(){const e=this._slideTabBar.primeval();e.scrollLeft=e.scrollWidth,this._scrollX=e.scrollLeft}getScrollX(){return this._scrollX}}const ot=class ot{constructor(e){v(this,"_activeTabItemIndex",0);v(this,"_slideTabBar");v(this,"_slideTabItems",[]);v(this,"_config");v(this,"_downActionX",0);v(this,"_moveActionX",0);v(this,"_compareIndex",0);v(this,"_activeTabItem",null);v(this,"_moveAction");v(this,"_upAction");v(this,"_downAction");v(this,"_wheelAction");v(this,"_scrollIncremental",0);v(this,"_compareDirection",0);v(this,"_autoScrollTime",null);v(this,"_slideScrollbar");v(this,"_longPressTimer",null);v(this,"_leftBoundingLine",0);v(this,"_rightBoundingLine",0);v(this,"_leftMoveX",0);v(this,"_rightMoveX",0);if(e.slideTabBarContainer==null)throw new Error("not found slide-tab-bar root element");const t=e.slideTabBarContainer.querySelector(`.${e.slideTabBarClassName??"slide-tab-bar"}`);if(t==null)throw new Error("not found slide-tab-bar");this._slideTabBar=t,this._slideScrollbar=new nh(this),this._config=e,this._initConfig();let n=0,o=0,r=0;this._downAction=s=>{var E,y,O,x,D,U;if((E=this._activeTabItem)!=null&&E.isEditMode())return;const l=(O=(y=s.target)==null?void 0:y.closest(`.${e.slideTabBarItemClassName}`))==null?void 0:O.getAttribute("data-id"),c=this._slideTabItems.findIndex(N=>N.getId()===l);if(l==null||c===-1)return;if(this._activeTabItemIndex!==c){(x=this._activeTabItem)==null||x.removeEventListener("pointermove",this._moveAction),(D=this._activeTabItem)==null||D.removeEventListener("pointerup",this._upAction),this.removeListener(),this._config.onChangeTab(s,l);return}if(this._compareIndex=c,this._downActionX=s.pageX,this._moveActionX=0,this._scrollIncremental=0,this._activeTabItem=this._slideTabItems[c],!this._activeTabItem){console.error("Not found active slide-tab-item in sheet bar");return}const d=this._activeTabItem.getSlideTabItem();d==null||d.setPointerCapture(s.pointerId),(U=this._activeTabItem)==null||U.addEventListener("pointerup",this._upAction);const{x:u,width:h}=this._activeTabItem.getBoundingRect(),{x:m,width:S}=this.getBoundingRect(),g=this._slideScrollbar.getScrollX();if(this._leftBoundingLine=this._downActionX-(u-g),this._rightBoundingLine=u-g+h-this._downActionX,this._leftMoveX=u-m-g,this._rightMoveX=m+S-(u+h)+g,s.button===2||this._hasEditItem())return;const{pageX:_,pageY:I}=s,C=Date.now(),b=C-r<=ot.DoubleClickDelay,M=Math.abs(_-n)<10,T=Math.abs(I-o)<10;b&&M&&T&&this._activeTabItem.setEditor(),n=_,o=I,r=C,this._longPressTimer=setTimeout(()=>{var N,B;(N=this._activeTabItem)==null||N.enableFixed(),this._startAutoScroll(),d&&(d.setPointerCapture(s.pointerId),d.style.cursor="move",(B=this._activeTabItem)==null||B.addEventListener("pointermove",this._moveAction))},ot.LongPressDelay)},this._upAction=s=>{var c,d,u;if(this._longPressTimer&&(clearTimeout(this._longPressTimer),this._longPressTimer=null),!this._activeTabItem)return;this._closeAutoScroll(),this._activeTabItem.disableFixed(),this.updateItems();const l=(c=this._activeTabItem)==null?void 0:c.getSlideTabItem();l&&(l.style.cursor="",l.releasePointerCapture(s.pointerId),(d=this._activeTabItem)==null||d.removeEventListener("pointermove",this._moveAction),(u=this._activeTabItem)==null||u.removeEventListener("pointerup",this._upAction),this._config.onSlideEnd&&this._activeTabItemIndex!==this._compareIndex&&(this.removeListener(),this._config.onSlideEnd(s,this._compareIndex||0)),this._scrollIncremental=0,this._downActionX=0,this._moveActionX=0,this._compareIndex=0)},this._moveAction=s=>{this._activeTabItem&&(this._moveActionX=s.pageX-this._downActionX,this._moveActionX<=-this._leftMoveX?this._moveActionX=-this._leftMoveX:this._moveActionX>=this._rightMoveX&&(this._moveActionX=this._rightMoveX),this._scrollIncremental=0,this._scrollLeft(s),this._scrollRight(s))},this._wheelAction=s=>{this.setScroll(s.deltaY)},this.addListener()}static checkedSkipSlide(e){let t=e.target;for(;t!=null&&t!==document.body;){if(t.getAttribute("data-slide-skip"))return!0;t=t.parentElement}return!1}static keepLastIndex(e){setTimeout(()=>{const t=window.getSelection();t&&(t.selectAllChildren(e),t.collapseToEnd())})}static keepSelectAll(e){setTimeout(()=>{const t=window.getSelection();if(!t)return;const n=document.createRange();n.selectNodeContents(e),t.removeAllRanges(),t.addRange(n)})}update(e){this._config.currentIndex=e,this._initConfig(),this.removeListener(),this.addListener()}primeval(){return this._slideTabBar}updateItems(){for(let e=0;e<this._slideTabItems.length;e++)this._slideTabItems[e].animate().cancel(),this._slideTabItems[e].translateX(0),this._slideTabItems[e].update()}getScrollbar(){return this._slideScrollbar}getConfig(){return this._config}getBoundingRect(){return this._slideTabBar.getBoundingClientRect()}getSlideTabItems(){return this._slideTabItems}getActiveItem(){return this._activeTabItem}isLeftEnd(){return this._slideTabBar.scrollLeft===0}isRightEnd(){const e=this._slideTabBar.parentElement;return e?this._slideTabBar.scrollWidth-e.clientWidth===this._slideTabBar.scrollLeft:!1}addListener(){this._slideTabBar.addEventListener("wheel",this._wheelAction),this._slideTabItems.forEach(e=>{e.addEventListener("pointerdown",this._downAction)})}removeListener(){this._slideTabBar.removeEventListener("wheel",this._wheelAction),this._slideTabItems.forEach(e=>{e.removeEventListener("pointerdown",this._downAction)})}setScroll(e){if(this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+e),e>0){const t=this.calculateLeftScrollX();this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+t)}else if(e<0){const t=this.calculateRightScrollX();this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+t)}this._config.onScroll({leftEnd:this.isLeftEnd(),rightEnd:this.isRightEnd()})}flipPage(e){if(e>0){const t=this.calculateLeftScrollX(!0);this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+t)}else if(e<0){const t=this.calculateRightScrollX(!0);this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+t)}this._config.onScroll({leftEnd:this.isLeftEnd(),rightEnd:this.isRightEnd()})}calculateLeftScrollX(e){let t=0;const n=4;return this._slideTabItems.some(o=>{const r=this._slideTabBar.getBoundingClientRect(),s=r.left+r.width,l=o.getSlideTabItem().getBoundingClientRect(),c=l.left,d=l.width;return c<s&&c+d+n*2>s?(t=e?c-r.left-n:c+d-s+n,!0):!1}),t}calculateRightScrollX(e){let t=0;const n=4;return this._slideTabItems.some(o=>{const r=this._slideTabBar.getBoundingClientRect(),s=r.left,l=o.getSlideTabItem().getBoundingClientRect(),c=l.left,d=l.width;return c-n*2<s&&c+d>s?(t=e?c+d-r.left-r.width+n:c-s-n,!0):!1}),t}destroy(){this._downActionX=0,this._moveActionX=0,this._compareDirection=0,this._compareIndex=0,this._slideTabItems=[],this._activeTabItem=null,this.removeListener()}_hasEditItem(){for(let e=0;e<this._slideTabItems.length;e++)if(this._slideTabItems[e].isEditMode())return!0;return!1}_autoScrollFrame(){if(this._activeTabItem)switch(this._compareDirection=this._activeTabItem.translateX(this._moveActionX),this._compareDirection){case 1:{this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+this._scrollIncremental),this._compareRight();break}case 0:{this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+this._scrollIncremental),this._compareIndex=this._activeTabItemIndex;break}case-1:{this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+this._scrollIncremental),this._compareLeft();break}}this._autoScrollTime=requestAnimationFrame(()=>{this._autoScrollFrame()})}_startAutoScroll(){this._autoScrollTime==null&&this._autoScrollFrame()}_closeAutoScroll(){this._autoScrollTime&&cancelAnimationFrame(this._autoScrollTime),this._autoScrollTime=null}_scrollLeft(e){const t=this.getBoundingRect(),n=e.pageX-t.x;n<this._leftBoundingLine&&(this._scrollIncremental=-Math.min(Math.abs(n-this._leftBoundingLine)*.1,50))}_scrollRight(e){const t=this.getBoundingRect(),n=e.pageX-t.x;n>t.width-this._rightBoundingLine&&(this._scrollIncremental=Math.min(Math.abs(n-(t.width-this._rightBoundingLine))*.1,50))}_sortedItems(){if(this._activeTabItem!=null&&this._activeTabItemIndex!=null&&this._compareIndex!=null&&(this._slideTabItems.splice(this._activeTabItemIndex,1),this._slideTabItems.splice(this._compareIndex,0,this._activeTabItem),this._config.slideTabBarItemAutoSort))for(let e=0;e<this._slideTabItems.length;e++){const t=this._slideTabItems[e],n=this._slideTabItems[e+1];n&&t.after(n)}}_compareLeft(){if(this._activeTabItem&&this._activeTabItemIndex){const e=this._slideTabItems.findIndex(r=>r.equals(this._activeTabItem)),t=this._slideTabItems.length,n=[];for(let r=0;r<e&&!(r>=e);r++)n.push(this._slideTabItems[r]);for(let r=e+1;r<t;r++)this._slideTabItems[r].animate().translateX(0);let o=!0;for(let r=n.length-1;r>=0;r--){const s=n[r];Ze.leftLine(this._activeTabItem)<s.getMidLine()?(s.animate().translateX(this._activeTabItem.getWidth()),this._compareIndex=r,o=!1):(s.animate().translateX(0),o&&(this._compareIndex=this._activeTabItemIndex))}}}_compareRight(){if(this._activeTabItem){const e=this._slideTabItems.findIndex(r=>r.equals(this._activeTabItem)),t=this._slideTabItems.length,n=[];for(let r=e+1;r<t;r++)n.push(this._slideTabItems[r]);for(let r=0;r<e;r++)this._slideTabItems[r].animate().translateX(0);let o=!0;for(let r=0;r<n.length;r++){const s=n[r];Ze.rightLine(this._activeTabItem)>s.getMidLine()?(s.animate().translateX(-this._activeTabItem.getWidth()),this._compareIndex=e+r+1,o=!1):(s.animate().translateX(0),o&&(this._compareIndex=this._activeTabItemIndex))}}}_initConfig(){const e=this._slideTabBar.querySelectorAll(`.${this._config.slideTabBarItemClassName??"slide-tab-item"}`);this._downActionX=0,this._moveActionX=0,this._compareDirection=0,this._compareIndex=0,this._slideTabItems=Ze.make(e,this),this._activeTabItemIndex=this._config.currentIndex,this._activeTabItem=this._slideTabItems[this._activeTabItemIndex]}};v(ot,"LongPressDelay",500),v(ot,"DoubleClickDelay",300);let xt=ot;function ih(){const[i,e]=L.useState([]),[t,n]=L.useState(""),[o,r]=L.useState(""),s=L.useRef({slideTabBar:null}),l=L.useRef(null),c=W.useDependency(a.IUniverInstanceService),d=W.useDependency(a.ICommandService),u=W.useDependency(mt),h=W.useDependency(a.LocaleService),m=W.useDependency(R.IConfirmService),S=c.getCurrentUniverSheetInstance();L.useEffect(()=>{E();const A=g(),H=T(),V=[y(),O(),x(),D()];return()=>{H.dispose(),A.destroy(),V.forEach(F=>F.unsubscribe())}},[]),L.useEffect(()=>{i.length>0&&M()},[i]);const g=()=>{const A=new xt({slideTabBarClassName:ge.slideTabBar,slideTabBarItemActiveClassName:ge.slideTabActive,slideTabBarItemClassName:ge.slideTabItem,slideTabBarSpanEditClassName:ge.slideTabSpanEdit,slideTabBarItemAutoSort:!0,slideTabBarContainer:l.current,currentIndex:0,onChangeName:(H,V)=>{d.executeCommand(f.SetWorksheetNameCommand.id,{subUnitId:H,name:V})},onSlideEnd:(H,V)=>{d.executeCommand(f.SetWorksheetOrderCommand.id,{order:V})},onChangeTab:(H,V)=>{d.executeCommand(f.SetWorksheetActivateCommand.id,{subUnitId:V,unitId:S.getUnitId()})},onScroll:H=>{u.setScroll(H)},onNameCheckAlert:H=>_(H)||I(H)});return s.current.slideTabBar=A,B(A),A},_=A=>{if(A.trim()===""){const H="sheetNameEmptyAlert";return m.open({id:H,title:{title:h.t("sheetConfig.sheetNameErrorTitle")},children:{title:h.t("sheetConfig.sheetNameCannotIsEmptyError")},cancelText:h.t("button.cancel"),confirmText:h.t("button.confirm"),onClose(){m.close(H),C()},onConfirm(){m.close(H),C()}}),!0}return!1},I=A=>{const H=c.getCurrentUniverSheetInstance();if(H.getActiveSheet().getName()===A)return!1;const j=H.checkSheetName(A);if(j){const $="sheetNameRepeatAlert";m.open({id:$,title:{title:h.t("sheetConfig.sheetNameErrorTitle")},children:{title:h.t("sheetConfig.sheetNameAlreadyExistsError")},cancelText:h.t("button.cancel"),confirmText:h.t("button.confirm"),onClose(){m.close($),b()},onConfirm(){m.close($),b()}})}return j},C=()=>{var H,V;const A=(V=(H=s.current.slideTabBar)==null?void 0:H.getActiveItem())==null?void 0:V.getEditor();A&&A.focus()},b=()=>{var A,H;(H=(A=s.current.slideTabBar)==null?void 0:A.getActiveItem())==null||H.setEditor()},M=()=>{var H;const A=i.findIndex(V=>V.selected);(H=s.current.slideTabBar)==null||H.update(A)},T=()=>d.onCommandExecuted(A=>{switch(A.id){case f.SetTabColorMutation.id:case f.SetWorksheetHideMutation.id:case f.RemoveSheetMutation.id:case f.SetWorksheetNameMutation.id:case f.InsertSheetMutation.id:case f.SetWorksheetOrderMutation.id:case f.SetWorksheetActiveOperation.id:E();break}}),E=()=>{const A=S.getActiveSheet().getSheetId();n(A);const V=S.getSheets().filter(F=>!F.isSheetHidden()).map((F,j)=>({sheetId:F.getSheetId(),label:F.getName(),index:j,selected:F.getStatus()===a.BooleanNumber.TRUE,color:F.getTabColor()??void 0}));e(V)},y=()=>u.scroll$.subscribe(A=>{U(A)}),O=()=>u.scrollX$.subscribe(A=>{var H;(H=s.current.slideTabBar)==null||H.flipPage(A)}),x=()=>u.renameId$.subscribe(()=>{b()}),D=()=>u.addSheet$.subscribe(()=>{var A;(A=s.current.slideTabBar)==null||A.getScrollbar().scrollRight()}),U=A=>{const{leftEnd:H,rightEnd:V}=A;let F="";H&&V?F="":H&&!V?F="inset -10px 0px 10px -10px rgba(0, 0, 0, 0.2)":!H&&V?F="inset 10px 0px 10px -10px rgba(0, 0, 0, 0.2)":!H&&!V&&(F="inset 10px 0px 10px -10px rgba(0, 0, 0, 0.2), inset -10px 0px 10px -10px rgba(0, 0, 0, 0.2)"),r(F)},N=A=>{u.setScroll({leftEnd:A.isLeftEnd(),rightEnd:A.isRightEnd()})},B=A=>{var F;const H=(F=l.current)==null?void 0:F.querySelector(`.${ge.slideTabBar}`);if(!H)return;new ResizeObserver(()=>{N(A)}).observe(H)};return p.jsx("div",{className:ge.slideTabBarContainer,ref:l,children:p.jsx("div",{className:ge.slideTabBar,style:{boxShadow:o},children:i.map(A=>L.createElement(Ju,{...A,key:A.sheetId,selected:t===A.sheetId}))})})}const go=100,oh=()=>{const[i,e]=L.useState(!0),[t,n]=L.useState(!0),o=W.useDependency(a.ICommandService),r=W.useDependency(mt);L.useEffect(()=>{const u=r.scroll$.subscribe(h=>{s(h)});return()=>{u.unsubscribe()}},[]);const s=u=>{const{leftEnd:h,rightEnd:m}=u;e(h),n(m)},l=()=>{o.executeCommand(f.InsertSheetCommand.id),setTimeout(()=>{r.setAddSheet(0)},0)},c=()=>{r.setScrollX(-go)},d=()=>{r.setScrollX(go)};return p.jsxs("div",{className:$t.sheetBar,children:[p.jsxs("div",{className:$t.sheetBarOptions,children:[p.jsx(gn,{onClick:l,children:p.jsx(Qs,{})}),p.jsx(zu,{})]}),p.jsx(ih,{}),(!i||!t)&&p.jsxs("div",{className:`${$t.sheetBarOptions} ${$t.sheetBarOptionsDivider}`,children:[p.jsx(gn,{disabled:i,onClick:c,children:p.jsx($i,{style:{transform:"rotateZ(180deg)"}})}),p.jsx(gn,{disabled:t,onClick:d,children:p.jsx($i,{})})]})]})};class rh{constructor(){v(this,"_functions",[{func:G.FUNCTION_NAMES_STATISTICAL.MAX,filter:e=>{var t,n;return(((t=e.find(o=>o.func===G.FUNCTION_NAMES_STATISTICAL.COUNTA))==null?void 0:t.value)??0)>1&&(((n=e.find(o=>o.func===G.FUNCTION_NAMES_STATISTICAL.COUNT))==null?void 0:n.value)??0)>0}},{func:G.FUNCTION_NAMES_STATISTICAL.MIN,filter:e=>{var t,n;return(((t=e.find(o=>o.func===G.FUNCTION_NAMES_STATISTICAL.COUNTA))==null?void 0:t.value)??0)>1&&(((n=e.find(o=>o.func===G.FUNCTION_NAMES_STATISTICAL.COUNT))==null?void 0:n.value)??0)>0}},{func:G.FUNCTION_NAMES_MATH.SUM,filter:e=>{var t,n;return(((t=e.find(o=>o.func===G.FUNCTION_NAMES_STATISTICAL.COUNTA))==null?void 0:t.value)??0)>1&&(((n=e.find(o=>o.func===G.FUNCTION_NAMES_STATISTICAL.COUNT))==null?void 0:n.value)??0)>0}},{func:G.FUNCTION_NAMES_STATISTICAL.COUNTA,filter:e=>{var t;return(((t=e.find(n=>n.func===G.FUNCTION_NAMES_STATISTICAL.COUNTA))==null?void 0:t.value)??0)>1}},{func:G.FUNCTION_NAMES_STATISTICAL.COUNT,filter:e=>{var t,n;return(((t=e.find(o=>o.func===G.FUNCTION_NAMES_STATISTICAL.COUNTA))==null?void 0:t.value)??0)>1&&(((n=e.find(o=>o.func===G.FUNCTION_NAMES_STATISTICAL.COUNT))==null?void 0:n.value)??0)>0}},{func:G.FUNCTION_NAMES_STATISTICAL.AVERAGE,filter:e=>{var t,n;return(((t=e.find(o=>o.func===G.FUNCTION_NAMES_STATISTICAL.COUNTA))==null?void 0:t.value)??0)>1&&(((n=e.find(o=>o.func===G.FUNCTION_NAMES_STATISTICAL.COUNT))==null?void 0:n.value)??0)>0}}]);v(this,"_state$",new k.BehaviorSubject(null));v(this,"state$",this._state$.asObservable())}dispose(){this._state$.complete()}setState(e){const t=[];e==null||e.forEach(n=>{const o=this._functions.find(r=>r.func===n.func);o&&(o.filter===void 0||o.filter(e))&&t.push(n)}),this._state$.next(t)}getState(){return this._state$.getValue()}getFunctions(){return this._functions}addFunctions(e){this._functions.push(...e)}}const bi=P.createIdentifier("univer.sheet-status-bar.service"),sh="univer-status-bar",lh="univer-single-mode",ah="univer-status-bar-div",ch="univer-statistic-list",dh="univer-statistic-list-column",uh="univer-statistic-item",hh="univer-statistic-picker",mh="univer-statistic-picker-item",Sh="univer-statistic-more",it={statusBar:sh,singleMode:lh,statusBarDiv:ah,statisticList:ch,statisticListColumn:dh,statisticItem:uh,statisticPicker:hh,statisticPickerItem:mh,statisticMore:Sh},Yn={[G.FUNCTION_NAMES_MATH.SUM]:"statusbar.sum",[G.FUNCTION_NAMES_STATISTICAL.AVERAGE]:"statusbar.average",[G.FUNCTION_NAMES_STATISTICAL.MIN]:"statusbar.min",[G.FUNCTION_NAMES_STATISTICAL.MAX]:"statusbar.max",[G.FUNCTION_NAMES_STATISTICAL.COUNT]:"statusbar.count",[G.FUNCTION_NAMES_STATISTICAL.COUNTA]:"statusbar.countA",[G.FUNCTION_NAMES_COMPATIBILITY.CONCATENATE]:"concatenate"},Zn=i=>{const e=W.useDependency(a.LocaleService),t=W.useDependency(R.IMessageService),n=W.useDependency(R.IClipboardInterfaceService),o=_h(i.value),r=async()=>{await n.writeText(i.value.toString()),t.show({type:ie.MessageType.Success,content:e.t("statusbar.copied")})};return p.jsx(ie.Tooltip,{title:e.t("statusbar.clickToCopy"),placement:"top",children:p.jsx("div",{className:it.statisticItem,onClick:r,children:p.jsx("span",{children:`${e.t((Yn==null?void 0:Yn[i.name])||i.name)}: ${o}`})},i.name)})};function _h(i){return typeof i!="number"?"Invalid input":i>=1e8?i.toExponential(2):i.toLocaleString()}const fo=800,gh=3,fh=()=>{const[i,e]=L.useState(window.innerWidth<fo),[t,n]=L.useState(!0),o=W.useDependency(bi),r=o.getFunctions().map((m,S)=>({name:m.func,value:0,show:!0,disable:!1})),[s,l]=L.useState(r),c=s.find(m=>m.show&&!m.disable),d=i&&c?[c]:s.filter(m=>m.show&&!m.disable);L.useEffect(()=>{const m=o.state$.subscribe(S=>{if(!S||S.length===0)n(!1);else{n(!0);const g=s.map(_=>{const I=S.find(C=>C.func===_.name);return I?(_.value=I.value,_.disable=!1):_.disable=!0,_});l(g)}});return()=>{m.unsubscribe()}},[o]);const u=ph(()=>{const m=window.innerWidth<fo;i!==m&&e(m)},100);L.useEffect(()=>(window.addEventListener("resize",u),()=>{window.removeEventListener("resize",u)}),[i]);let h=null;if(d.length>gh){const m=[];d.forEach((S,g)=>{g%2===0&&m.push(d.slice(g,g+2))}),h=p.jsxs(p.Fragment,{children:[" ",m.map((S,g)=>p.jsxs("div",{className:it.statisticListColumn,children:[(S==null?void 0:S[0])&&p.jsx(Zn,{...S==null?void 0:S[0]},S==null?void 0:S[0].name),(S==null?void 0:S[1])&&p.jsx(Zn,{...S==null?void 0:S[1]},S==null?void 0:S[1].name)]},`stat-col-${g}`))," "]})}else h=p.jsx(p.Fragment,{children:d.map(m=>p.jsx(Zn,{...m},m.name))});return t&&p.jsxs("div",{className:Tt(it.statusBar,{[it.singleMode]:i}),children:[p.jsx("div",{className:Tt(it.statisticList),children:h}),p.jsx("div",{className:it.statusBarDiv})]})};function ph(i,e){let t;return function(...n){const o=this,r=function(){t=null,i.apply(o,n)};clearTimeout(t),t=setTimeout(r,e)}}function vh(){return p.jsxs("section",{className:Sr.sheetContainer,"data-range-selector":!0,children:[p.jsx(oh,{}),p.jsx(fh,{}),p.jsx(ru,{})]})}function Ch(){return p.jsx(p.Fragment,{children:p.jsx(Ru,{})})}function Ih(){return p.jsxs(p.Fragment,{children:[p.jsx(au,{}),p.jsx(Du,{})]})}function Rh(i){const e=i.get(f.BorderStyleManagerService);return{id:f.SetBorderBasicCommand.id,icon:new k.Observable(t=>{const n="AllBorderSingle",o=i.get(f.BorderStyleManagerService),r=i.get(a.ICommandService).onCommandExecuted(s=>{if(s.id!==f.SetBorderBasicCommand.id)return;const{type:c}=o.getBorderInfo(),d=Mr.find(h=>h.value===c),u=(d==null?void 0:d.icon)??n;t.next(u)});return t.next(n),r.dispose}),group:R.MenuGroup.TOOLBAR_FORMAT,tooltip:"toolbar.border.main",positions:[R.MenuPosition.TOOLBAR_START],type:R.MenuItemType.BUTTON_SELECTOR,selections:[{label:{name:br,hoverable:!1},value$:e.borderInfo$}],value$:e.borderInfo$,hidden$:R.getMenuHiddenObservable(i,a.UniverInstanceType.SHEET)}}const Pn="sheet.menu.clear-selection";function bh(){return{id:Pn,group:R.MenuGroup.CONTEXT_MENU_FORMAT,type:R.MenuItemType.SUBITEMS,icon:"ClearFormat",title:"rightClick.clearSelection",positions:[R.MenuPosition.CONTEXT_MENU,ee.COL_HEADER_CONTEXT_MENU,ee.ROW_HEADER_CONTEXT_MENU]}}function Mh(){return{id:f.ClearSelectionContentCommand.id,type:R.MenuItemType.BUTTON,title:"rightClick.clearContent",positions:[Pn]}}function wh(){return{id:f.ClearSelectionFormatCommand.id,type:R.MenuItemType.BUTTON,title:"rightClick.clearFormat",positions:[Pn]}}function Th(){return{id:f.ClearSelectionAllCommand.id,type:R.MenuItemType.BUTTON,title:"rightClick.clearAll",positions:[Pn]}}const Lt="sheet.menu.delete";function Eh(){return{id:Lt,group:R.MenuGroup.CONTEXT_MENU_LAYOUT,type:R.MenuItemType.SUBITEMS,title:"rightClick.delete",icon:"Reduce",positions:[R.MenuPosition.CONTEXT_MENU]}}function yh(){return{id:f.RemoveColCommand.id,group:R.MenuGroup.CONTEXT_MENU_LAYOUT,type:R.MenuItemType.BUTTON,icon:"DeleteColumn",positions:[Lt,ee.COL_HEADER_CONTEXT_MENU],title:"rightClick.deleteSelectedColumn"}}function Oh(){return{id:f.RemoveRowCommand.id,group:R.MenuGroup.CONTEXT_MENU_LAYOUT,type:R.MenuItemType.BUTTON,icon:"DeleteRow",positions:[Lt,ee.ROW_HEADER_CONTEXT_MENU],title:"rightClick.deleteSelectedRow"}}function xh(){return{id:f.DeleteRangeMoveLeftCommand.id,group:R.MenuGroup.CONTEXT_MENU_LAYOUT,type:R.MenuItemType.BUTTON,title:"rightClick.moveLeft",icon:"DeleteCellShiftLeft",positions:[Lt]}}function Ah(){return{id:f.DeleteRangeMoveUpCommand.id,group:R.MenuGroup.CONTEXT_MENU_LAYOUT,type:R.MenuItemType.BUTTON,title:"rightClick.moveUp",icon:"DeleteCellShiftUp",positions:[Lt]}}const Mi="sheet.menu.col-insert";function Hh(){return{id:Mi,group:R.MenuGroup.CONTEXT_MENU_LAYOUT,type:R.MenuItemType.SUBITEMS,title:"rightClick.insert",icon:"Insert",positions:[ee.COL_HEADER_CONTEXT_MENU]}}const wi="sheet.menu.row-insert";function Dh(){return{id:wi,group:R.MenuGroup.CONTEXT_MENU_LAYOUT,type:R.MenuItemType.SUBITEMS,title:"rightClick.insert",icon:"Insert",positions:[ee.ROW_HEADER_CONTEXT_MENU]}}const Ut="sheet.menu.cell-insert";function Nh(){return{id:Ut,group:R.MenuGroup.CONTEXT_MENU_LAYOUT,type:R.MenuItemType.SUBITEMS,title:"rightClick.insert",icon:"Insert",positions:[R.MenuPosition.CONTEXT_MENU]}}function Ph(i){const e=i.get(f.SelectionManagerService);return{id:f.InsertRowBeforeCommand.id,type:R.MenuItemType.BUTTON,title:"rightClick.insertRowBefore",icon:"InsertRowAbove",positions:[wi,Ut],hidden$:new k.Observable(t=>{const n=e.getSelections();t.next((n==null?void 0:n.length)!==1)})}}function Lh(i){const e=i.get(f.SelectionManagerService);return{id:f.InsertRowAfterCommand.id,type:R.MenuItemType.BUTTON,positions:[wi],title:"rightClick.insertRow",icon:"InsertRowBelow",hidden$:new k.Observable(t=>{const n=e.getSelections();t.next((n==null?void 0:n.length)!==1)})}}function Uh(i){const e=i.get(f.SelectionManagerService);return{id:f.InsertColBeforeCommand.id,type:R.MenuItemType.BUTTON,positions:[Mi,Ut],title:"rightClick.insertColumnBefore",icon:"LeftInsertColumn",hidden$:new k.Observable(t=>{const n=e.getSelections();t.next((n==null?void 0:n.length)!==1)})}}function kh(i){const e=i.get(f.SelectionManagerService);return{id:f.InsertColAfterCommand.id,type:R.MenuItemType.BUTTON,positions:[Mi],title:"rightClick.insertColumn",icon:"RightInsertColumn",hidden$:new k.Observable(t=>{const n=e.getSelections();t.next((n==null?void 0:n.length)!==1)})}}function Bh(){return{id:f.InsertRangeMoveRightCommand.id,type:R.MenuItemType.BUTTON,title:"rightClick.moveRight",icon:"InsertCellShiftRight",positions:[Ut]}}function Vh(){return{id:f.InsertRangeMoveDownCommand.id,type:R.MenuItemType.BUTTON,title:"rightClick.moveDown",icon:"InsertCellDown",positions:[Ut]}}function Fh(i){return{id:Ae.id,icon:"MergeAllSingle",tooltip:"toolbar.mergeCell.main",positions:[R.MenuPosition.TOOLBAR_START],group:R.MenuGroup.TOOLBAR_LAYOUT,type:R.MenuItemType.SUBITEMS,hidden$:R.getMenuHiddenObservable(i,a.UniverInstanceType.SHEET)}}function jh(i){return{id:gr.id,type:R.MenuItemType.BUTTON,title:"merge.all",icon:"MergeAllSingle",positions:[Ae.id]}}function Wh(i){return{id:fr.id,type:R.MenuItemType.BUTTON,title:"merge.vertical",icon:"VerticalIntegrationSingle",positions:[Ae.id]}}function $h(i){return{id:pr.id,type:R.MenuItemType.BUTTON,title:"merge.horizontal",icon:"HorizontalMergeSingle",positions:[Ae.id]}}function zh(i){return{id:f.RemoveWorksheetMergeCommand.id,type:R.MenuItemType.BUTTON,title:"merge.cancel",icon:"CancelMergeSingle",positions:[Ae.id]}}function Xh(){return{id:Cr.id,type:R.MenuItemType.BUTTON,positions:[ee.SHEET_BAR],title:"sheetConfig.delete"}}function Yh(){return{id:f.CopySheetCommand.id,type:R.MenuItemType.BUTTON,positions:[ee.SHEET_BAR],title:"sheetConfig.copy"}}function Zh(){return{id:Rr.id,type:R.MenuItemType.BUTTON,positions:[ee.SHEET_BAR],title:"sheetConfig.rename"}}function Gh(){return{id:f.SetTabColorCommand.id,title:"sheetConfig.changeColor",positions:[ee.SHEET_BAR],type:R.MenuItemType.SELECTOR,selections:[{label:{name:Hn,hoverable:!1}}]}}function Kh(){return{id:f.SetWorksheetHideCommand.id,type:R.MenuItemType.BUTTON,positions:[ee.SHEET_BAR],title:"sheetConfig.hide"}}function qh(){return{id:Ir.id,type:R.MenuItemType.BUTTON,positions:[ee.SHEET_BAR],title:"sheetConfig.unhide"}}const Jh={id:f.SetRowHiddenCommand.id,preconditions:i=>Z(i),binding:R.KeyCode.Digit9|R.MetaKeys.CTRL_COMMAND},Qh={id:f.SetColHiddenCommand.id,preconditions:i=>Z(i),binding:R.KeyCode.Digit0|R.MetaKeys.CTRL_COMMAND|R.MetaKeys.SHIFT},em={id:me.id,description:"shortcut.sheet.select-below-cell",group:"3_sheet-view",binding:R.KeyCode.ARROW_DOWN,priority:100,preconditions:Z,staticParameters:{direction:a.Direction.DOWN}},tm={id:me.id,description:"shortcut.sheet.select-up-cell",group:"3_sheet-view",binding:R.KeyCode.ARROW_UP,priority:100,preconditions:Z,staticParameters:{direction:a.Direction.UP}},nm={id:me.id,description:"shortcut.sheet.select-left-cell",group:"3_sheet-view",binding:R.KeyCode.ARROW_LEFT,priority:100,preconditions:Z,staticParameters:{direction:a.Direction.LEFT}},im={id:me.id,description:"shortcut.sheet.select-right-cell",group:"3_sheet-view",binding:R.KeyCode.ARROW_RIGHT,priority:100,preconditions:Z,staticParameters:{direction:a.Direction.RIGHT}},om={id:Ke.id,description:"shortcut.sheet.select-next-cell",group:"3_sheet-view",binding:R.KeyCode.TAB,priority:100,preconditions:Z,staticParameters:{direction:a.Direction.RIGHT,keycode:R.KeyCode.TAB}},rm={id:Ke.id,description:"shortcut.sheet.select-previous-cell",group:"3_sheet-view",binding:R.KeyCode.TAB|R.MetaKeys.SHIFT,priority:100,preconditions:Z,staticParameters:{direction:a.Direction.LEFT,keycode:R.KeyCode.TAB}},sm={id:Ke.id,description:"shortcut.sheet.select-below-cell",group:"3_sheet-view",binding:R.KeyCode.ENTER,priority:100,preconditions:Z,staticParameters:{direction:a.Direction.DOWN,keycode:R.KeyCode.ENTER}},lm={id:Ke.id,description:"shortcut.sheet.select-up-cell",group:"3_sheet-view",binding:R.KeyCode.ENTER|R.MetaKeys.SHIFT,priority:100,preconditions:Z,staticParameters:{direction:a.Direction.UP,keycode:R.KeyCode.ENTER}},am={id:me.id,description:"shortcut.sheet.select-below-value-cell",group:"3_sheet-view",binding:R.KeyCode.ARROW_DOWN|R.MetaKeys.CTRL_COMMAND,preconditions:Z,staticParameters:{direction:a.Direction.DOWN,jumpOver:be.moveGap}},cm={id:me.id,description:"shortcut.sheet.select-up-value-cell",group:"3_sheet-view",binding:R.KeyCode.ARROW_UP|R.MetaKeys.CTRL_COMMAND,preconditions:Z,staticParameters:{direction:a.Direction.UP,jumpOver:be.moveGap}},dm={id:me.id,description:"shortcut.sheet.select-left-value-cell",group:"3_sheet-view",binding:R.KeyCode.ARROW_LEFT|R.MetaKeys.CTRL_COMMAND,preconditions:Z,staticParameters:{direction:a.Direction.LEFT,jumpOver:be.moveGap}},um={id:me.id,description:"shortcut.sheet.select-right-value-cell",group:"3_sheet-view",binding:R.KeyCode.ARROW_RIGHT|R.MetaKeys.CTRL_COMMAND,preconditions:Z,staticParameters:{direction:a.Direction.RIGHT,jumpOver:be.moveGap}},hm={id:Me.id,description:"shortcut.sheet.expand-selection-down",group:"3_sheet-view",binding:R.KeyCode.ARROW_DOWN|R.MetaKeys.SHIFT,preconditions:Z,staticParameters:{direction:a.Direction.DOWN}},mm={id:Me.id,description:"shortcut.sheet.expand-selection-up",group:"3_sheet-view",binding:R.KeyCode.ARROW_UP|R.MetaKeys.SHIFT,preconditions:Z,staticParameters:{direction:a.Direction.UP}},Sm={id:Me.id,description:"shortcut.sheet.expand-selection-left",group:"3_sheet-view",binding:R.KeyCode.ARROW_LEFT|R.MetaKeys.SHIFT,preconditions:Z,staticParameters:{direction:a.Direction.LEFT}},_m={id:Me.id,description:"shortcut.sheet.expand-selection-right",group:"3_sheet-view",binding:R.KeyCode.ARROW_RIGHT|R.MetaKeys.SHIFT,preconditions:Z,staticParameters:{direction:a.Direction.RIGHT}},gm={id:Me.id,description:"shortcut.sheet.expand-selection-to-below-gap",group:"3_sheet-view",binding:R.KeyCode.ARROW_DOWN|R.MetaKeys.SHIFT|R.MetaKeys.CTRL_COMMAND,preconditions:Z,staticParameters:{direction:a.Direction.DOWN,jumpOver:be.moveGap}},fm={id:Me.id,description:"shortcut.sheet.expand-selection-to-up-gap",group:"3_sheet-view",binding:R.KeyCode.ARROW_UP|R.MetaKeys.SHIFT|R.MetaKeys.CTRL_COMMAND,preconditions:Z,staticParameters:{direction:a.Direction.UP,jumpOver:be.moveGap}},pm={id:Me.id,description:"shortcut.sheet.expand-selection-to-left-gap",group:"3_sheet-view",binding:R.KeyCode.ARROW_LEFT|R.MetaKeys.SHIFT|R.MetaKeys.CTRL_COMMAND,preconditions:Z,staticParameters:{direction:a.Direction.LEFT,jumpOver:be.moveGap}},vm={id:Me.id,description:"shortcut.sheet.expand-selection-to-right-gap",group:"3_sheet-view",binding:R.KeyCode.ARROW_RIGHT|R.MetaKeys.SHIFT|R.MetaKeys.CTRL_COMMAND,preconditions:Z,staticParameters:{direction:a.Direction.RIGHT,jumpOver:be.moveGap}},Cm={id:Ao.id,description:"shortcut.sheet.select-all",group:"3_sheet-view",binding:R.KeyCode.A|R.MetaKeys.CTRL_COMMAND,preconditions:Z,staticParameters:{expandToGapFirst:!0,loop:!0}},Im={id:Si.id,description:"shortcut.sheet.set-bold",group:"4_sheet-edit",preconditions:i=>Z(i),binding:R.KeyCode.B|R.MetaKeys.CTRL_COMMAND},Rm={id:_i.id,description:"shortcut.sheet.set-italic",group:"4_sheet-edit",preconditions:i=>Z(i),binding:R.KeyCode.I|R.MetaKeys.CTRL_COMMAND},bm={id:gi.id,description:"shortcut.sheet.set-underline",group:"4_sheet-edit",preconditions:i=>Z(i),binding:R.KeyCode.U|R.MetaKeys.CTRL_COMMAND},Mm={id:fi.id,description:"shortcut.sheet.set-strike-through",group:"4_sheet-edit",preconditions:i=>Z(i),binding:R.KeyCode.X|R.MetaKeys.SHIFT|R.MetaKeys.CTRL_COMMAND},wm={id:f.ClearSelectionContentCommand.id,preconditions:i=>Z(i),binding:R.KeyCode.DELETE,mac:R.KeyCode.BACKSPACE},Tm={id:Nn.id,description:"shortcut.sheet.zoom-in",binding:R.KeyCode.EQUAL|R.MetaKeys.CTRL_COMMAND,group:"3_sheet-view",staticParameters:{delta:.2}},Em={id:Nn.id,description:"shortcut.sheet.zoom-out",binding:R.KeyCode.MINUS|R.MetaKeys.CTRL_COMMAND,group:"3_sheet-view",staticParameters:{delta:-.2}},ym={id:Nn.id,description:"shortcut.sheet.reset-zoom",binding:R.KeyCode.Digit0|R.MetaKeys.CTRL_COMMAND,group:"3_sheet-view",staticParameters:{reset:!0}};var Om=Object.defineProperty,xm=Object.getOwnPropertyDescriptor,Am=(i,e,t,n)=>{for(var o=n>1?void 0:n?xm(e,t):e,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(e,t,o):s(o))||o);return n&&o&&Om(e,t,o),o},nt=(i,e)=>(t,n)=>e(t,n,i);let fn=class extends a.Disposable{constructor(i,e,t,n,o,r){super(),this._injector=i,this._componentManager=e,this._commandService=t,this._shortcutService=n,this._menuService=o,this._uiController=r,this._init()}_initCustomComponents(){const i=this._componentManager;this.disposeWithMe(i.register(Ci,ea)),this.disposeWithMe(i.register(br,eu)),this.disposeWithMe(i.register(Hn,ie.ColorPicker)),this.disposeWithMe(i.register(sr,Xl)),this.disposeWithMe(i.register(se,Yl)),this.disposeWithMe(i.register(lr,Kl))}_initCommands(){[gr,Ae,pr,fr,Nn,Me,me,Ke,Rr,Cr,Ye,Ao,_r,On,f.SetBoldCommand,Ot,Re,Si,_i,gi,fi,Ul,kl,Ko,qo,wn,f.SetItalicCommand,f.SetStrikeThroughCommand,f.SetFontFamilyCommand,f.SetFontSizeCommand,pi,er,vi,tr,ct,rn,An,nr,ir,or,f.SetUnderlineCommand,Ri,xe,Ir,vr].forEach(i=>{this.disposeWithMe(this._commandService.registerCommand(i))})}_initMenus(){[fa,pa,va,Ca,Ia,Ra,ba,Mh,wh,Th,bh,Hh,Dh,Nh,Ph,Lh,Uh,kh,Oh,Aa,Da,Ha,Na,yh,Pa,Ma,La,Eh,xh,Ah,Bh,Vh,Ea,ya,Oa,xa,wa,Ta,ta,na,ia,oa,ra,la,aa,ca,da,ua,ha,Rh,Fh,jh,Wh,$h,zh,ma,Sa,_a,ga,Xh,Yh,Zh,Gh,Kh,qh].forEach(i=>{this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(i)))})}_initShortcuts(){[em,tm,nm,im,om,rm,sm,lm,am,cm,dm,um,hm,mm,Sm,_m,gm,fm,pm,vm,Cm,Tm,Em,ym,Im,Rm,bm,Mm,wm,...rc(),sc,lc,cc,dc,uc,ac,Jh,Qh].forEach(i=>{this.disposeWithMe(this._shortcutService.registerShortcut(i))})}_initWorkbenchParts(){this.disposeWithMe(this._uiController.registerHeaderComponent(()=>W.connectInjector(Ch,this._injector))),this.disposeWithMe(this._uiController.registerFooterComponent(()=>W.connectInjector(vh,this._injector))),this.disposeWithMe(this._uiController.registerContentComponent(()=>W.connectInjector(Ih,this._injector)))}_init(){this._initCustomComponents(),this._initCommands(),this._initMenus(),this._initShortcuts(),this._initWorkbenchParts()}};fn=Am([a.OnLifecycle(a.LifecycleStages.Ready,fn),nt(0,P.Inject(P.Injector)),nt(1,P.Inject(R.ComponentManager)),nt(2,a.ICommandService),nt(3,R.IShortcutService),nt(4,R.IMenuService),nt(5,R.IUIController)],fn);var Hm=Object.defineProperty,Dm=Object.getOwnPropertyDescriptor,Nm=(i,e,t,n)=>{for(var o=n>1?void 0:n?Dm(e,t):e,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(e,t,o):s(o))||o);return n&&o&&Hm(e,t,o),o},Ct=(i,e)=>(t,n)=>e(t,n,i);let pn=class extends a.Disposable{constructor(e,t,n,o,r){super();v(this,"_calculateTimeout",-1);this._univerInstanceService=e,this._selectionManagerService=t,this._functionService=n,this._statusBarService=o,this._formulaDataModel=r,this._init()}_init(){this._registerSelectionListener()}_registerSelectionListener(){this.disposeWithMe(a.toDisposable(this._selectionManagerService.selectionMoving$.subscribe(e=>{e&&(clearTimeout(this._calculateTimeout),this._calculateTimeout=setTimeout(()=>{this._calculateSelection(e.map(t=>t.range))},100))}))),this.disposeWithMe(a.toDisposable(this._selectionManagerService.selectionMoveEnd$.subscribe(e=>{e&&this._calculateSelection(e.map(t=>t.range))})))}_calculateSelection(e){const t=this._univerInstanceService.getCurrentUniverSheetInstance(),n=t.getUnitId(),o=t.getActiveSheet().getSheetId(),r={},s=this._formulaDataModel.getArrayFormulaCellData();if(this._univerInstanceService.getCurrentUniverSheetInstance().getSheets().forEach(l=>{const c=l.getConfig();r[l.getSheetId()]={cellData:new a.ObjectMatrix(c.cellData),rowCount:c.rowCount,columnCount:c.columnCount}}),e!=null&&e.length){const l=e.map(h=>new G.RangeReferenceObject(h,o,n));l.forEach(h=>{h.setUnitData({[n]:r}),s&&h.setArrayFormulaCellData(G.convertUnitDataToRuntime(s))});const d=this._statusBarService.getFunctions().map(h=>{const m=this._functionService.getExecutor(h.func);if(!m)return;const S=l.map(_=>_.toArrayValueObject());if((m==null?void 0:m.calculate(...S)).getValue)return{func:h.func,value:(m==null?void 0:m.calculate(...S)).getValue()}});if(d.every(h=>h===void 0))return;const u=d.filter(h=>h!==void 0);this._statusBarService.setState(u)}else this._statusBarService.setState(null)}_isSingleCell(e){return e.startRow===e.endRow&&e.startColumn===e.endColumn}};pn=Nm([a.OnLifecycle(a.LifecycleStages.Ready,pn),Ct(0,a.IUniverInstanceService),Ct(1,P.Inject(f.SelectionManagerService)),Ct(2,G.IFunctionService),Ct(3,bi),Ct(4,P.Inject(G.FormulaDataModel))],pn);var Pm=Object.defineProperty,Lm=Object.getOwnPropertyDescriptor,Um=(i,e,t,n)=>{for(var o=n>1?void 0:n?Lm(e,t):e,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(e,t,o):s(o))||o);return n&&o&&Pm(e,t,o),o},$e=(i,e)=>(t,n)=>e(t,n,i);let vn=class extends a.Disposable{constructor(i,e,t,n,o,r,s){super(),this._sheetSkeletonManagerService=i,this._currentUniverService=e,this._commandService=t,this._renderManagerService=n,this._selectionRenderService=o,this._selectionManagerService=r,this._scrollManagerService=s,this._initialize()}dispose(){super.dispose()}_initialize(){this._skeletonListener(),this._commandExecutedListener(),this._zoomEventBinding()}_zoomEventBinding(){var e;const i=(e=this._getSheetObject())==null?void 0:e.scene;i!=null&&(i.getViewport(Y.VIEW_MAIN),this.disposeWithMe(a.toDisposable(i.onMouseWheelObserver.add((t,n)=>{if(!t.ctrlKey)return;const o=Math.abs(t.deltaX);let r=o<40?.2:o<80?.4:.2;r*=t.deltaY>0?-1:1,i.scaleX<1&&(r/=2);const s=this._currentUniverService.getCurrentUniverSheetInstance(),l=s.getActiveSheet(),c=l.getZoomRatio();let d=+parseFloat(`${c+r}`).toFixed(1);d=d>=4?4:d<=.1?.1:d,this._commandService.executeCommand(Ri.id,{zoomRatio:Math.round(d*10)/10,unitId:s.getUnitId(),subUnitId:l.getSheetId()}),t.preventDefault()}))))}_skeletonListener(){this.disposeWithMe(a.toDisposable(this._sheetSkeletonManagerService.currentSkeletonBefore$.subscribe(i=>{if(i==null)return;const n=this._currentUniverService.getCurrentUniverSheetInstance().getActiveSheet().getZoomRatio()||1;this._updateViewZoom(n)})))}_commandExecutedListener(){const i=[xe.id];this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(i.includes(e.id)){const t=this._currentUniverService.getCurrentUniverSheetInstance(),n=t.getActiveSheet(),o=e.params,{unitId:r,subUnitId:s}=o;if(!(r===t.getUnitId()&&s===n.getSheetId()))return;const l=n.getConfig().zoomRatio||1;this._updateViewZoom(l)}}))}_updateViewZoom(i){const e=this._getSheetObject();e==null||e.scene.scale(i,i),e==null||e.spreadsheet.makeForceDirty()}_getSheetObject(){return ae(this._currentUniverService,this._renderManagerService)}};vn=Um([a.OnLifecycle(a.LifecycleStages.Rendered,vn),$e(0,P.Inject(exports.SheetSkeletonManagerService)),$e(1,a.IUniverInstanceService),$e(2,a.ICommandService),$e(3,w.IRenderManagerService),$e(4,ce),$e(5,P.Inject(f.SelectionManagerService)),$e(6,P.Inject(ke))],vn);var km=Object.defineProperty,Bm=Object.getOwnPropertyDescriptor,Vm=(i,e,t,n)=>{for(var o=n>1?void 0:n?Bm(e,t):e,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(e,t,o):s(o))||o);return n&&o&&km(e,t,o),o},It=(i,e)=>(t,n)=>e(t,n,i);exports.SheetCanvasView=class extends a.RxDisposable{constructor(t,n,o,r,s){super();v(this,"_scene");v(this,"_currentWorkbook");v(this,"_loadedMap",new Set);v(this,"_isLoadedEditor",!1);v(this,"_fps$",new k.BehaviorSubject(""));v(this,"fps$",this._fps$.asObservable());this._currentUniverService=t,this._commandService=n,this._renderManagerService=o,this._selectionRenderService=r,this._sheetSkeletonManagerService=s,this._currentUniverService.currentSheet$.subscribe(l=>{if(l==null)return;const c=l.getUnitId();this._loadedMap.has(c)||(this._currentWorkbook=l,this._addNewRender(),this._loadedMap.add(c))})}dispose(){this._fps$.complete()}_addNewRender(){const t=this._currentWorkbook,n=t.getUnitId(),o=t.getContainer(),r=t.getParentRenderUnitId();if(o!=null&&r!=null)throw new Error("container or parentRenderUnitId can only exist one");const s=o==null&&r!=null;s?this._renderManagerService.createRenderWithParent(n,r):this._renderManagerService.createRender(n);const l=this._renderManagerService.getRenderById(n);if(l==null)return;const{scene:c,engine:d}=l;c.openTransformer(),this._scene=c,c.addLayer(new w.Layer(c,[],0),new w.Layer(c,[],2)),l!=null&&this._addComponent(l),t.getShouldRenderLoopImmediately()&&!s&&d.runRenderLoop(()=>{c.render(),this._fps$.next(Math.round(d.getFps()).toString())}),this._renderManagerService.setCurrent(n)}_addComponent(t){const n=this._scene,o=this._currentWorkbook,r=o.getActiveSheet(),s=o.getUnitId(),l=r.getSheetId();this._addViewport(r);const c=new w.Spreadsheet(oe.MAIN),d=new w.SpreadsheetRowHeader(oe.ROW),u=new w.SpreadsheetColumnHeader(oe.COLUMN),h=new w.Rect(oe.LEFT_TOP,{zIndex:2,left:-1,top:-1,fill:"rgb(248, 249, 250)",stroke:"rgb(217, 217, 217)",strokeWidth:1});t.mainComponent=c,t.components.set(oe.MAIN,c),t.components.set(oe.ROW,d),t.components.set(oe.COLUMN,u),t.components.set(oe.LEFT_TOP,h),n.addObjects([c],Fi),n.addObjects([d,u,h],Ue),n.enableLayerCache(Fi,Ue),this._sheetSkeletonManagerService.setCurrent({sheetId:l,unitId:s})}_addViewport(t){const n=this._scene;if(n==null)return;const{rowHeader:o,columnHeader:r}=t.getConfig(),s=new w.Viewport(Y.VIEW_MAIN,n,{left:o.width,top:r.height,bottom:0,right:0,isWheelPreventDefaultX:!0}),l=new w.Viewport(Y.VIEW_ROW_TOP,n,{active:!1,isWheelPreventDefaultX:!0}),c=new w.Viewport(Y.VIEW_ROW_BOTTOM,n,{left:0,top:r.height,bottom:0,width:o.width,isWheelPreventDefaultX:!0}),d=new w.Viewport(Y.VIEW_COLUMN_LEFT,n,{active:!1,isWheelPreventDefaultX:!0}),u=new w.Viewport(Y.VIEW_COLUMN_RIGHT,n,{left:o.width,top:0,height:r.height,right:0,isWheelPreventDefaultX:!0}),h=new w.Viewport(Y.VIEW_LEFT_TOP,n,{left:0,top:0,width:o.width,height:r.height,isWheelPreventDefaultX:!0}),m=new w.Viewport(Y.VIEW_MAIN_LEFT_TOP,n,{isWheelPreventDefaultX:!0,active:!1}),S=new w.Viewport(Y.VIEW_MAIN_LEFT,n,{isWheelPreventDefaultX:!0,active:!1}),g=new w.Viewport(Y.VIEW_MAIN_TOP,n,{isWheelPreventDefaultX:!0,active:!1});return n.onMouseWheelObserver.add((_,I)=>{if(_.ctrlKey)return;let C=0,b=0;const M=s.limitedScroll();if(_.inputIndex===w.PointerInput.MouseWheelX){const E=Math.abs(_.deltaX);_.deltaX>0?C=E:C=-E,this._commandService.executeCommand(rn.id,{offsetX:C}),n.getParent().classType===w.RENDER_CLASS_TYPE.SCENE_VIEWER?M!=null&&M.isLimitedX||I.stopPropagation():s.isWheelPreventDefaultX?_.preventDefault():M!=null&&M.isLimitedX||_.preventDefault()}if(_.inputIndex===w.PointerInput.MouseWheelY){let E=Math.abs(_.deltaY);_.shiftKey?(E*=3,_.deltaY>0?C=E:C=-E,this._commandService.executeCommand(rn.id,{offsetX:C}),n.getParent().classType===w.RENDER_CLASS_TYPE.SCENE_VIEWER?M!=null&&M.isLimitedX||I.stopPropagation():s.isWheelPreventDefaultX?_.preventDefault():M!=null&&M.isLimitedX||_.preventDefault()):(_.deltaY>0?b=E:b=-E,this._commandService.executeCommand(rn.id,{offsetY:b}),n.getParent().classType===w.RENDER_CLASS_TYPE.SCENE_VIEWER?M!=null&&M.isLimitedY||I.stopPropagation():s.isWheelPreventDefaultY?_.preventDefault():M!=null&&M.isLimitedY||_.preventDefault())}_.inputIndex,w.PointerInput.MouseWheelZ,this._scene.makeDirty(!0)}),new w.ScrollBar(s),n.addViewport(s,d,u,l,c,h,m,S,g).attachControl(),s}};exports.SheetCanvasView=Vm([a.OnLifecycle(a.LifecycleStages.Ready,exports.SheetCanvasView),It(0,a.IUniverInstanceService),It(1,a.ICommandService),It(2,w.IRenderManagerService),It(3,ce),It(4,P.Inject(exports.SheetSkeletonManagerService))],exports.SheetCanvasView);var Fm=Object.defineProperty,jm=Object.getOwnPropertyDescriptor,Wm=(i,e,t,n)=>{for(var o=n>1?void 0:n?jm(e,t):e,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(e,t,o):s(o))||o);return n&&o&&Fm(e,t,o),o},Gn=(i,e)=>(t,n)=>e(t,n,i),Kn;exports.UniverSheetsUIPlugin=(Kn=class extends a.Plugin{constructor(e,t,n,o){super(Ro),this._injector=t,this._localeService=n,this._currentUniverService=o,this._localeService.load({zhCN:ar})}onStarting(e){[[exports.SheetCanvasView],[pe,{useClass:Ho}],[lt,{useClass:exports.SheetClipboardService}],[mt,{useClass:Ld}],[dt,{useClass:ni}],[Pt,{useClass:cr}],[Dn,{useClass:Ba}],[Dt,{useClass:exports.AutoFillService}],[ke],[exports.SheetSkeletonManagerService],[ce,{useClass:exports.SelectionRenderService}],[bi,{useClass:rh}],[At,{useClass:exports.MarkSelectionService}],[Yt],[Zt],[nn],[Jt],[Qt],[on],[sn],[ln],[an],[cn],[dn],[en],[hn],[wt],[Sn],[Gt],[Kt],[mn],[_n],[fn],[tn],[vn],[exports.AutoFillController],[pn],[qt],[un]].forEach(t=>e.add(t))}onReady(){this._markSheetAsFocused()}_markSheetAsFocused(){const e=this._currentUniverService;e.currentSheet$.pipe(po.filter(t=>!!t)).subscribe(t=>{e.focusUniverInstance(t.getUnitId())})}},v(Kn,"type",a.PluginType.Sheet),Kn);exports.UniverSheetsUIPlugin=Wm([Gn(1,P.Inject(P.Injector)),Gn(2,P.Inject(a.LocaleService)),Gn(3,a.IUniverInstanceService)],exports.UniverSheetsUIPlugin);exports.APPLY_TYPE=X;exports.AutoFillCommand=Cn;exports.COPY_TYPE=Xe;exports.CellEditorManagerService=cr;exports.DATA_TYPE=te;exports.DefaultRightMenuConfig=vo;exports.DefaultSheetContainerConfig=Io;exports.DefaultSheetUIConfig=xr;exports.DefaultToolbarConfig=Co;exports.EditorBridgeService=Ho;exports.ExpandSelectionCommand=Me;exports.IAutoFillService=Dt;exports.ICellEditorManagerService=Pt;exports.IEditorBridgeService=pe;exports.IFormulaEditorManagerService=Dn;exports.IMarkSelectionService=At;exports.ISelectionRenderService=ce;exports.ISheetClipboardService=lt;exports.JumpOver=be;exports.MoveSelectionCommand=me;exports.PASTE_SPECIAL_MENU_ID=ht;exports.PREDEFINED_HOOK_NAME=le;exports.RangeSelector=dl;exports.SHEET_UI_PLUGIN_NAME=Ro;exports.SelectionShape=Rn;exports.SetCellEditVisibleArrowOperation=Ot;exports.SetEditorResizeOperation=On;exports.SetScrollOperation=ct;exports.SetZoomRatioOperation=xe;exports.SheetCopyCommand=wo;exports.SheetPasteCommand=at;exports.VIEWPORT_KEY=Y;exports.enUS=Ua;exports.getAutoFillRepeatRange=Ml;exports.getCoordByCell=ii;exports.getCoordByOffset=st;exports.getEditorObject=yn;exports.getRepeatRange=ka;exports.getSheetObject=ae;exports.getTransformCoord=Xt;exports.whenEditorInputFormulaActivated=Nr;exports.zhCN=ar;
17
+ */var Za=X,Ga=Symbol.for("react.element"),Ka=Symbol.for("react.fragment"),qa=Object.prototype.hasOwnProperty,Ja=Za.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,Qa={key:!0,ref:!0,__self:!0,__source:!0};function Do(i,e,t){var n,r={},o=null,s=null;t!==void 0&&(o=""+t),e.key!==void 0&&(o=""+e.key),e.ref!==void 0&&(s=e.ref);for(n in e)qa.call(e,n)&&!Qa.hasOwnProperty(n)&&(r[n]=e[n]);if(i&&i.defaultProps)for(n in e=i.defaultProps,e)r[n]===void 0&&(r[n]=e[n]);return{$$typeof:Ga,type:i,key:o,ref:s,props:r,_owner:Ja.current}}yi.Fragment=Ka;yi.jsx=Do;yi.jsxs=Do;No.exports=yi;var S=No.exports,tt=function(){return tt=Object.assign||function(i){for(var e,t=1,n=arguments.length;t<n;t++){e=arguments[t];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(i[r]=e[r])}return i},tt.apply(this,arguments)},el=function(i,e){var t={};for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&e.indexOf(n)<0&&(t[n]=i[n]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,n=Object.getOwnPropertySymbols(i);r<n.length;r++)e.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(i,n[r])&&(t[n[r]]=i[n[r]]);return t},Je=X.forwardRef(function(i,e){var t=i.icon,n=i.id,r=i.className,o=i.extend,s=el(i,["icon","id","className","extend"]),a="univerjs-icon univerjs-icon-".concat(n," ").concat(r||"").trim(),c=X.useRef("_".concat(il()));return Po(t,"".concat(n),{defIds:t.defIds,idSuffix:c.current},tt({ref:e,className:a},s),o)});function Po(i,e,t,n,r){return X.createElement(i.tag,tt(tt({key:e},tl(i,t,r)),n),(nl(i,t).children||[]).map(function(o,s){return Po(o,"".concat(e,"-").concat(i.tag,"-").concat(s),t,void 0,r)}))}function tl(i,e,t){var n=tt({},i.attrs);t!=null&&t.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=t.colorChannel1);var r=e.defIds;return!r||r.length===0||(i.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+e.idSuffix),Object.entries(n).forEach(function(o){var s=o[0],a=o[1];typeof a=="string"&&(n[s]=a.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),n}function nl(i,e){var t,n=e.defIds;return!n||n.length===0?i:i.tag==="defs"&&(!((t=i.children)===null||t===void 0)&&t.length)?tt(tt({},i),{children:i.children.map(function(r){return typeof r.attrs.id=="string"&&n&&n.indexOf(r.attrs.id)>-1?tt(tt({},r),{attrs:tt(tt({},r.attrs),{id:r.attrs.id+e.idSuffix})}):r})}):i}function il(){return Math.random().toString(36).substring(2,8)}Je.displayName="UniverIcon";var rl={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"colorChannel1",d:"M11.5261 12.834V14.634C11.5261 14.9654 11.7948 15.234 12.1261 15.234V15.234C12.4575 15.234 12.7261 14.9654 12.7261 14.634V12.834H14.5262C14.8576 12.834 15.1262 12.5654 15.1262 12.234V12.234C15.1262 11.9027 14.8576 11.634 14.5262 11.634H12.7261V9.83401C12.7261 9.50264 12.4575 9.23401 12.1261 9.23401V9.23401C11.7948 9.23401 11.5261 9.50264 11.5261 9.83401V11.634H9.72622C9.39485 11.634 9.12622 11.9027 9.12622 12.234V12.234C9.12622 12.5654 9.39485 12.834 9.72622 12.834H11.5261Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M3.05352 1.9613C2.39077 1.9613 1.85352 2.49856 1.85352 3.1613V6.7613C1.85352 7.42405 2.39077 7.9613 3.05352 7.9613H6.65352C7.31626 7.9613 7.85352 7.42405 7.85352 6.7613V3.1613C7.85352 2.49856 7.31626 1.9613 6.65352 1.9613H3.05352zM6.65352 3.1613H3.05352L3.05352 6.7613H6.65352V3.1613zM3.05352 9.23401C2.39077 9.23401 1.85352 9.77127 1.85352 10.434V14.034C1.85352 14.6968 2.39077 15.234 3.05352 15.234H6.65352C7.31626 15.234 7.85352 14.6968 7.85352 14.034V10.434C7.85352 9.77127 7.31626 9.23401 6.65352 9.23401H3.05352zM6.65352 10.434H3.05352L3.05352 14.034H6.65352V10.434zM10.3262 7.9613C9.66348 7.9613 9.12622 7.42405 9.12622 6.7613V3.1613C9.12622 2.49856 9.66348 1.9613 10.3262 1.9613H13.9262C14.589 1.9613 15.1262 2.49856 15.1262 3.1613V6.7613C15.1262 7.42405 14.589 7.9613 13.9262 7.9613H10.3262zM10.3262 6.7613V3.1613L13.9262 3.1613V6.7613H10.3262z",fillRule:"evenodd",clipRule:"evenodd"}}]},Ho=X.forwardRef(function(i,e){return X.createElement(Je,Object.assign({},i,{id:"autofill",ref:e,icon:rl}))});Ho.displayName="Autofill";const ol=Ho;var sl={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M14.6152 4.52067C14.8732 4.77869 14.8732 5.19703 14.6152 5.45505L6.61862 13.4514C6.46241 13.6077 6.20915 13.6077 6.05294 13.4514L1.73512 9.13354C1.4771 8.87551 1.4771 8.45718 1.73513 8.19915C1.99315 7.94113 2.41149 7.94114 2.66951 8.19916L6.19436 11.7241C6.27247 11.8022 6.3991 11.8022 6.47721 11.7241L13.6808 4.52067C13.9388 4.26264 14.3571 4.26264 14.6152 4.52067Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Lo=X.forwardRef(function(i,e){return X.createElement(Je,Object.assign({},i,{id:"check-mark-single",ref:e,icon:sl}))});Lo.displayName="CheckMarkSingle";const Ri=Lo;var al={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.48712 4.59907C5.23328 4.34523 4.82172 4.34523 4.56788 4.59907C4.31404 4.85291 4.31404 5.26447 4.56788 5.51831L7.9973 8.94773L4.56773 12.3773C4.31389 12.6311 4.31389 13.0427 4.56773 13.2965C4.82157 13.5504 5.23313 13.5504 5.48697 13.2965L8.91654 9.86697L12.3461 13.2965C12.5999 13.5503 13.0114 13.5503 13.2653 13.2965C13.5191 13.0426 13.5191 12.6311 13.2653 12.3772L9.83577 8.94773L13.2651 5.51836C13.519 5.26452 13.519 4.85296 13.2651 4.59912C13.0113 4.34528 12.5997 4.34528 12.3459 4.59912L8.91654 8.02849L5.48712 4.59907Z"}}]},Uo=X.forwardRef(function(i,e){return X.createElement(Je,Object.assign({},i,{id:"close-single",ref:e,icon:al}))});Uo.displayName="CloseSingle";const ll=Uo;var cl={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_102_1213",style:{maskType:"alpha"},width:17,height:17,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#DCDCDC",d:"M0.54 0.32H16.54V16.32H0.54z"}}]},{tag:"g",attrs:{fill:"currentColor",mask:"url(#mask0_102_1213)"},children:[{tag:"path",attrs:{d:"M1.76539 1.27148C1.89532 1.2465 2.05784 1.23193 2.25712 1.23193H7.39957C7.59852 1.23193 7.76228 1.24644 7.89394 1.27682 8.02979 1.30817 8.13912 1.36697 8.22237 1.45577 8.30591 1.54488 8.35813 1.6636 8.38857 1.80057L8.38913 1.80311C8.41406 1.93772 8.42854 2.10966 8.42854 2.31825V7.47982C8.42854 7.67924 8.41396 7.84153 8.38908 7.97584 8.36281 8.11247 8.3041 8.22717 8.22073 8.31054 8.13704 8.39424 8.02807 8.4472 7.89934 8.4781 7.77208 8.50864 7.60803 8.52313 7.41869 8.52313H2.25712C2.06419 8.52313 1.90591 8.51354 1.77494 8.48836 1.64209 8.46281 1.53156 8.41527 1.4464 8.33054 1.3606 8.24999 1.30815 8.13434 1.27781 8.00286 1.2476 7.87192 1.22815 7.69892 1.22815 7.47982V2.27524C1.22815 2.07123 1.24271 1.90413 1.26761 1.76966 1.29388 1.63303 1.35259 1.51833 1.43596 1.43496 1.52104 1.34988 1.63137 1.30236 1.76275 1.27204L1.76539 1.27148zM2.56975 2.39137C2.49306 2.39568 2.45433 2.41469 2.43395 2.43562 2.41191 2.46884 2.39718 2.51452 2.39715 2.57614L2.40631 4.24285H4.26296V2.39137H2.56975zM5.44152 2.39615V4.24285H7.24998V2.51898C7.24998 2.47398 7.24652 2.44245 7.24141 2.42201 7.23917 2.41305 7.23709 2.40806 7.23591 2.40567 7.22586 2.40059 7.20631 2.39615 7.16061 2.39615H5.44152zM2.40708 5.39751L2.41626 7.22616C2.41626 7.26829 2.41965 7.29933 2.42492 7.32085 2.42882 7.33675 2.43309 7.34502 2.43572 7.34893 2.43572 7.34893 2.43928 7.35079 2.44202 7.35193 2.44831 7.35455 2.45718 7.35739 2.46908 7.35996 2.49304 7.36512 2.52583 7.36847 2.56777 7.36847H4.26774V5.39751H2.40708zM5.44152 5.39751V7.36847H7.09848C7.1739 7.36847 7.21416 7.35941 7.23151 7.35088 7.23281 7.34891 7.23591 7.34357 7.23933 7.33216 7.24553 7.3115 7.24998 7.27978 7.24998 7.23608V5.39751H5.44152zM9.19356 8.15082C9.3235 8.12583 9.48601 8.11127 9.6853 8.11127H14.8277C15.0267 8.11127 15.1905 8.12577 15.3221 8.15616 15.458 8.18751 15.5673 8.2463 15.6506 8.33511 15.7341 8.42421 15.7863 8.54294 15.8167 8.67991L15.8173 8.68245C15.8422 8.81705 15.8567 8.98899 15.8567 9.19759V14.3592C15.8567 14.5586 15.8421 14.7209 15.8173 14.8552 15.791 14.9918 15.7323 15.1065 15.6489 15.1899 15.5652 15.2736 15.4562 15.3265 15.3275 15.3574 15.2003 15.388 15.0362 15.4025 14.8469 15.4025H9.6853C9.49237 15.4025 9.33408 15.3929 9.20312 15.3677 9.07027 15.3421 8.95974 15.2946 8.87458 15.2099 8.78878 15.1293 8.73633 15.0137 8.70599 14.8822 8.67578 14.7513 8.65633 14.5783 8.65633 14.3592V9.15457C8.65633 8.95057 8.67088 8.78346 8.69579 8.649 8.72206 8.51237 8.78077 8.39767 8.86414 8.3143 8.94922 8.22922 9.05955 8.1817 9.19093 8.15138L9.19356 8.15082zM9.99793 9.27071C9.92124 9.27501 9.88251 9.29403 9.86212 9.31496 9.84009 9.34817 9.82536 9.39386 9.82533 9.45548L9.83448 11.1222H11.6911V9.27071H9.99793zM12.8697 9.27549V11.1222H14.6782V9.39831C14.6782 9.35332 14.6747 9.32178 14.6696 9.30135 14.6673 9.29238 14.6653 9.2874 14.6641 9.285 14.654 9.27992 14.6345 9.27549 14.5888 9.27549H12.8697zM9.83525 12.2768L9.84444 14.1055C9.84444 14.1476 9.84783 14.1787 9.8531 14.2002 9.85699 14.2161 9.86127 14.2244 9.86389 14.2283L9.86689 14.2298 9.87019 14.2313C9.87648 14.2339 9.88535 14.2367 9.89726 14.2393 9.92122 14.2445 9.95401 14.2478 9.99594 14.2478H11.6959V12.2768H9.83525zM12.8697 12.2768V14.2478H14.5267C14.6021 14.2478 14.6423 14.2387 14.6597 14.2302 14.661 14.2282 14.6641 14.2229 14.6675 14.2115 14.6737 14.1908 14.6782 14.1591 14.6782 14.1154V12.2768H12.8697z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{d:"M10.0049 2.46747C10.0049 2.06363 10.3323 1.73625 10.7361 1.73625H12.9298C14.1413 1.73625 15.1234 2.71838 15.1234 3.9299V6.12354C15.1234 6.52738 14.796 6.85476 14.3922 6.85476 13.9883 6.85476 13.661 6.52738 13.661 6.12354V3.9299C13.661 3.52606 13.3336 3.19868 12.9298 3.19868H10.7361C10.3323 3.19868 10.0049 2.87131 10.0049 2.46747zM3.42396 10.5108C3.42396 10.107 3.09658 9.77962 2.69274 9.77962 2.2889 9.77962 1.96152 10.107 1.96152 10.5108V12.7045C1.96152 13.916 2.94365 14.8981 4.15517 14.8981H6.34882C6.75266 14.8981 7.08003 14.5707 7.08003 14.1669 7.08003 13.7631 6.75266 13.4357 6.34882 13.4357H4.15517C3.75134 13.4357 3.42396 13.1083 3.42396 12.7045V10.5108z"}}]}]},ko=X.forwardRef(function(i,e){return X.createElement(Je,Object.assign({},i,{id:"convert-single",ref:e,icon:cl}))});ko.displayName="ConvertSingle";const dl=ko;var ul={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_371_77",style:{maskType:"alpha"},width:17,height:17,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#DCDCDC",d:"M0.87 0.63H16.87V16.63H0.87z"}}]},{tag:"g",attrs:{mask:"url(#mask0_371_77)"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M9.72636 13.5549C9.25212 14.1041 8.48323 14.1041 8.00899 13.5549L1.22579 5.70056C0.46078 4.81474 1.00259 3.30013 2.08448 3.30013L15.6509 3.30013C16.7328 3.30013 17.2746 4.81474 16.5096 5.70056L9.72636 13.5549Z"}}]}]},Vo=X.forwardRef(function(i,e){return X.createElement(Je,Object.assign({},i,{id:"dropdown-single",ref:e,icon:ul}))});Vo.displayName="DropdownSingle";const Br=Vo;var hl={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M1.90535 4.99197C2.23194 4.82196 2.63451 4.94889 2.80452 5.27548C2.96702 5.58764 3.22397 5.8971 3.57667 6.18615C4.57587 7.00507 6.2535 7.58331 8.21318 7.58331C10.1728 7.58331 11.8505 7.00508 12.8497 6.18616C13.2024 5.8971 13.4593 5.58763 13.6218 5.27549C13.7918 4.94889 14.1944 4.82196 14.521 4.99196C14.8476 5.16197 14.9745 5.56454 14.8045 5.89113C14.5439 6.39185 14.1596 6.83646 13.6948 7.2174C13.6514 7.25301 13.6071 7.28815 13.5621 7.3228L15.0214 8.78205C15.2817 9.0424 15.2817 9.46451 15.0214 9.72486C14.761 9.98521 14.3389 9.98521 14.0785 9.72486L12.3889 8.03522C11.8643 8.28584 11.2846 8.48827 10.6659 8.63563L11.2065 10.6532C11.3018 11.0088 11.0907 11.3744 10.7351 11.4697C10.3794 11.565 10.0139 11.3539 9.91857 10.9983L9.34529 8.85869C8.97555 8.89693 8.59724 8.91664 8.21318 8.91664C7.82639 8.91664 7.44544 8.89665 7.07321 8.85788L6.49971 10.9983C6.40441 11.354 6.03886 11.565 5.68321 11.4697C5.32757 11.3744 5.11651 11.0089 5.2118 10.6532L5.75288 8.63382C5.13793 8.48682 4.5615 8.28539 4.03968 8.03629L2.35121 9.72477C2.09086 9.98512 1.66875 9.98512 1.4084 9.72477C1.14805 9.46442 1.14805 9.04231 1.4084 8.78196L2.86611 7.32424C2.82044 7.28912 2.77557 7.2535 2.73152 7.2174C2.26668 6.83645 1.88248 6.39184 1.62183 5.89114C1.45182 5.56455 1.57876 5.16198 1.90535 4.99197Z"}}]},Fo=X.forwardRef(function(i,e){return X.createElement(Je,Object.assign({},i,{id:"eyelash-single",ref:e,icon:hl}))});Fo.displayName="EyelashSingle";const ml=Fo;var gl={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_367_60",style:{maskType:"alpha"},width:17,height:17,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#D9D9D9",d:"M0.06 0.78H16.06V16.78H0.06z"}}]},{tag:"g",attrs:{fill:"currentColor",mask:"url(#mask0_367_60)"},children:[{tag:"path",attrs:{d:"M5.54303 5.67809C5.41486 5.67809 5.31977 5.55923 5.34791 5.43419L5.43336 5.05446C5.53338 4.62534 5.71701 4.25903 5.99076 3.96308 6.28977 3.63984 6.73293 3.49761 7.27633 3.49761 7.47741 3.49761 7.69254 3.52131 7.92082 3.56601 7.93983 3.56973 7.95869 3.57361 7.9774 3.57766 8.18885 3.62335 8.41593 3.52833 8.49925 3.32869L8.72661 2.78395C8.81351 2.57574 8.71072 2.3376 8.49476 2.27229 8.46253 2.26255 8.42923 2.25268 8.39485 2.24269 8.10639 2.15986 7.76287 2.11572 7.35969 2.11572 6.29909 2.11572 5.50608 2.38292 4.95354 2.88796 4.38882 3.40424 3.98783 4.14273 3.76308 5.11976L2.31598 11.3345C2.2402 11.6722 2.14495 12.0353 2.02739 12.4247 1.90869 12.8169 1.76625 13.2031 1.60116 13.5809 1.43472 13.9595 1.24707 14.3197 1.0385 14.6607.972389 14.7687.904093 14.8718.833608 14.9698.744025 15.0945.813644 15.2766.965497 15.2989 1.6153 15.3945 2.29684 15.2198 2.66091 14.6732 2.80556 14.456 2.94673 14.2082 3.08403 13.9287 3.44529 13.1932 3.78416 12.1538 4.09761 10.801L4.94794 7.15889C4.96907 7.06839 5.04977 7.00436 5.14271 7.00436H7.10372C7.28864 7.00436 7.44946 6.87761 7.49265 6.6978L7.61908 6.17153C7.67951 5.91998 7.48886 5.67809 7.23015 5.67809H5.54303zM13.8 5.86392L11.9914 8.11319 10.8878 5.92109C10.8211 5.77368 10.6743 5.67896 10.5125 5.67896H9.79183C9.48739 5.67896 9.28816 5.99784 9.42165 6.27145L10.8878 9.19857 8.27677 12.2928C8.04481 12.5594 8.23414 12.9751 8.58749 12.9751H9.16501C9.28566 12.9751 9.43944 12.9258 9.5177 12.834L11.5897 10.4084 12.5966 12.7046C12.6575 12.8666 12.8119 12.9751 12.9851 12.9751H13.779C14.062 12.9751 14.2207 12.7611 14.1216 12.4959L12.6517 9.42983C12.6517 9.42983 14.8799 6.59898 15.0802 6.32247 15.2756 6.05285 15.0812 5.67896 14.7482 5.67896H14.145C14.0064 5.67896 13.9122 5.73242 13.8 5.86392z"}}]}]},Bo=X.forwardRef(function(i,e){return X.createElement(Je,Object.assign({},i,{id:"fx-single",ref:e,icon:gl}))});Bo.displayName="FxSingle";const _l=Bo;var pl={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_102_249",style:{maskType:"alpha"},width:17,height:17,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#D9D9D9",d:"M0.37 0.77H16.37V16.77H0.37z"}}]},{tag:"g",attrs:{mask:"url(#mask0_102_249)"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M9.12107 2.86418C9.12107 2.45648 8.78669 2.12598 8.37422 2.12598C7.96175 2.12598 7.62737 2.45648 7.62737 2.86418V8.03164H2.39931C1.98684 8.03164 1.65247 8.36214 1.65247 8.76984C1.65247 9.17754 1.98684 9.50805 2.39931 9.50805H7.62737V14.6754C7.62737 15.0831 7.96175 15.4136 8.37422 15.4136C8.78669 15.4136 9.12107 15.0831 9.12107 14.6754V9.50805H14.3489C14.7613 9.50805 15.0957 9.17754 15.0957 8.76984C15.0957 8.36214 14.7613 8.03164 14.3489 8.03164H9.12107V2.86418Z"}}]}]},jo=X.forwardRef(function(i,e){return X.createElement(Je,Object.assign({},i,{id:"increase-single",ref:e,icon:pl}))});jo.displayName="IncreaseSingle";const fl=jo;var Sl={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_102_556",style:{maskType:"alpha"},width:17,height:17,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#D9D9D9",d:"M0.56 0.77H16.56V16.77H0.56z"}}]},{tag:"g",attrs:{mask:"url(#mask0_102_556)"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M1.19318 4.76988C1.70089 4.26222 2.524 4.26226 3.03166 4.76997L8.13929 9.87808C8.3736 10.1124 8.75352 10.1124 8.98784 9.8781L14.0959 4.77C14.6036 4.26232 15.4267 4.26232 15.9344 4.77C16.4421 5.27768 16.4421 6.1008 15.9344 6.60848L9.97775 12.5651C9.19667 13.3462 7.93029 13.3462 7.14925 12.5651L1.1931 6.60836C0.685438 6.10065 0.685477 5.27753 1.19318 4.76988Z",fillRule:"evenodd",clipRule:"evenodd"}}]}]},Wo=X.forwardRef(function(i,e){return X.createElement(Je,Object.assign({},i,{id:"more-down-single",ref:e,icon:Sl}))});Wo.displayName="MoreDownSingle";const Qi=Wo;var vl={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.52628 3.57095C5.81918 3.26411 6.29405 3.26411 6.58695 3.57095L11.0869 8.28525C11.3798 8.59209 11.3798 9.08958 11.0869 9.39642L6.51623 14.04C6.22334 14.3468 5.74846 14.3468 5.45557 14.04C5.16268 13.7331 5.16268 13.2357 5.45557 12.9288L9.35939 8.979C9.43544 8.90205 9.43652 8.77857 9.36182 8.70031L5.52628 4.68212C5.23339 4.37528 5.23339 3.87779 5.52628 3.57095Z",fillRule:"evenodd",clipRule:"evenodd"}}]},zo=X.forwardRef(function(i,e){return X.createElement(Je,Object.assign({},i,{id:"more-single",ref:e,icon:vl}))});zo.displayName="MoreSingle";const jr=zo;var Cl={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_102_1204",style:{maskType:"alpha"},width:17,height:17,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#DCDCDC",d:"M0.25 0.41H16.25V16.41H0.25z"}}]},{tag:"g",attrs:{mask:"url(#mask0_102_1204)"},children:[{tag:"rect",attrs:{width:12.62,height:2.79,x:1.94,y:12.66,fill:"colorChannel1",rx:1.4}},{tag:"path",attrs:{fill:"currentColor",d:"M7.99664 2.57069C7.59302 2.05771 7.10966 1.68854 6.63466 1.50243C6.11882 1.30028 5.40184 1.25862 4.95066 1.83566C4.5486 2.34994 4.581 3.10899 4.82709 3.91045C4.93826 4.27259 5.11865 4.62903 5.37541 4.97266C5.38713 4.98834 5.39945 5.00329 5.41229 5.01752C5.4217 5.02789 5.4314 5.03788 5.44133 5.04746C5.45477 5.06043 5.46874 5.07267 5.48315 5.08419L3.75659 6.81071C3.51774 7.04955 3.51774 7.43683 3.75659 7.67569L7.48775 11.4068C7.72666 11.6457 8.11394 11.6457 8.35278 11.4068L13.0831 6.67651C13.3219 6.43766 13.3219 6.05039 13.0831 5.81155L9.35191 2.08037C9.11306 1.84153 8.72579 1.84153 8.48695 2.08037L7.99664 2.57069ZM7.71181 4.91288C7.72271 4.98224 7.73182 5.05302 7.73898 5.12518C7.77251 5.46131 8.07213 5.70663 8.40825 5.6731C8.74438 5.6396 8.98972 5.33994 8.9562 5.00382C8.90804 4.52113 8.79269 4.0731 8.6291 3.66819L8.91946 3.37784L11.7856 6.24403L10.8608 7.16886H5.12843L7.6582 4.63909C7.67903 4.72777 7.69702 4.81905 7.71181 4.91288ZM7.12302 3.44433C6.8246 3.02658 6.47279 2.75283 6.18833 2.64136C6.05252 2.58814 5.96546 2.58477 5.92656 2.58984C5.92268 2.59037 5.91947 2.59093 5.91678 2.59147L5.91208 2.59257C5.89185 2.62604 5.78612 2.86628 5.99645 3.5514C6.0626 3.76685 6.1728 3.99252 6.34325 4.2241L7.12302 3.44433Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M12.4434 11.9528C12.8956 11.9528 13.2622 11.5862 13.2622 11.134C13.2622 10.854 12.9483 10.3347 12.7092 9.9798C12.5801 9.78823 12.3066 9.78823 12.1776 9.97981C11.9385 10.3347 11.6246 10.854 11.6246 11.134C11.6246 11.5862 11.9912 11.9528 12.4434 11.9528Z"}}]}]},$o=X.forwardRef(function(i,e){return X.createElement(Je,Object.assign({},i,{id:"paint-bucket",ref:e,icon:Cl}))});$o.displayName="PaintBucket";const Rl=$o;var Il={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M2.80805 1.53809C2.10674 1.53809 1.53821 2.10661 1.53821 2.80793V13.6016C1.53821 14.3029 2.10674 14.8714 2.80805 14.8714H9.74456C10.2968 14.8714 10.7446 14.4237 10.7446 13.8714V13.6016V11.128C10.7446 10.9623 10.8789 10.828 11.0446 10.828H13.6017H13.8715C14.4238 10.828 14.8715 10.3803 14.8715 9.82802V2.80793C14.8715 2.10661 14.303 1.53809 13.6017 1.53809H2.80805ZM9.17472 13.6016C9.3404 13.6016 9.47472 13.4673 9.47472 13.3016V11.128C9.47472 10.9623 9.3404 10.828 9.17472 10.828H6.91757C6.75189 10.828 6.61757 10.9623 6.61757 11.128V13.3016C6.61757 13.4673 6.75189 13.6016 6.91757 13.6016H9.17472ZM13.6017 9.25817C13.6017 9.42386 13.4674 9.55818 13.3017 9.55818H11.0446C10.8789 9.55818 10.7446 9.42386 10.7446 9.25818V7.17177C10.7446 7.00608 10.8789 6.87177 11.0446 6.87177H13.3017C13.4674 6.87177 13.6017 7.00608 13.6017 7.17177V9.25817ZM9.17472 9.55818C9.3404 9.55818 9.47472 9.42386 9.47472 9.25818V7.17177C9.47472 7.00608 9.3404 6.87177 9.17472 6.87177H6.91757C6.75189 6.87177 6.61757 7.00608 6.61757 7.17177V9.25817C6.61757 9.42386 6.75189 9.55818 6.91757 9.55818H9.17472ZM13.6017 5.30193C13.6017 5.46761 13.4674 5.60193 13.3017 5.60193H11.0446C10.8789 5.60193 10.7446 5.46761 10.7446 5.30193V3.10793C10.7446 2.94224 10.8789 2.80793 11.0446 2.80793H13.3017C13.4674 2.80793 13.6017 2.94224 13.6017 3.10793V5.30193ZM9.17472 5.60193C9.3404 5.60193 9.47472 5.46761 9.47472 5.30193V3.10793C9.47472 2.94224 9.3404 2.80793 9.17472 2.80793H6.91757C6.75189 2.80793 6.61757 2.94224 6.61757 3.10793V5.30193C6.61757 5.46761 6.75189 5.60193 6.91757 5.60193H9.17472ZM5.34773 3.10793C5.34773 2.94224 5.21342 2.80793 5.04773 2.80793H3.10805C2.94236 2.80793 2.80805 2.94224 2.80805 3.10793V5.30193C2.80805 5.46761 2.94236 5.60193 3.10805 5.60193H5.04773C5.21342 5.60193 5.34773 5.46761 5.34773 5.30193V3.10793ZM5.34773 7.17177C5.34773 7.00608 5.21342 6.87177 5.04773 6.87177H3.10805C2.94236 6.87177 2.80805 7.00608 2.80805 7.17177V9.25817C2.80805 9.42386 2.94236 9.55818 3.10805 9.55818H5.04773C5.21342 9.55818 5.34773 9.42386 5.34773 9.25818V7.17177ZM5.34773 11.128C5.34773 10.9623 5.21342 10.828 5.04773 10.828H3.10805C2.94236 10.828 2.80805 10.9623 2.80805 11.128V13.3016C2.80805 13.4673 2.94236 13.6016 3.10805 13.6016H5.04773C5.21342 13.6016 5.34773 13.4673 5.34773 13.3016V11.128Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M12.3869 12.1183C12.361 11.9546 12.5342 11.8323 12.6798 11.9114L14.9901 13.1655C15.1577 13.2565 15.1137 13.5049 14.932 13.5378C14.9212 13.5398 14.9102 13.5417 14.8996 13.5446L13.8966 13.8224L13.1603 14.7467C13.0651 14.9084 12.8197 14.8618 12.7904 14.6764L12.3869 12.1183Z"}}]},Yo=X.forwardRef(function(i,e){return X.createElement(Je,Object.assign({},i,{id:"select-range-single",ref:e,icon:Il}))});Yo.displayName="SelectRangeSingle";const bl=Yo,Ml="univer-range-selector",wl="univer-range-selector-editor",Tl="univer-range-selector-icon",yl="univer-range-selector-active",Ht={rangeSelector:Ml,rangeSelectorEditor:wl,rangeSelectorIcon:Tl,rangeSelectorActive:yl};function El(i){const{onChange:e,onActive:t}=i,[n,r]=X.useState(!1),o=X.useRef(null),s=me.useDependency(l.LocaleService),a=me.useDependency(p.SelectionManagerService);X.useEffect(()=>{var m;if(n){t(n);const g=a.selectionMoveEnd$.subscribe(_=>{const f=["A1","B2:C3","Sheet2!A1:B2","D10:E11,F1:G2,H3:I4"],C=Math.floor(Math.random()*f.length),I=f[C];o.current&&(o.current.innerHTML=I)});return document.addEventListener("click",c),()=>{document.removeEventListener("click",c),g.unsubscribe()}}e(((m=o.current)==null?void 0:m.innerHTML)||"")},[n]);function c(m){var C,I,w;if(((C=m.target)==null?void 0:C.closest('[data-range-selector="true"]'))||m.target===o.current)return;const _=(I=m.target)==null?void 0:I.closest(`.${Ht.rangeSelector}`);(_==null?void 0:_.querySelector(`.${Ht.rangeSelectorEditor}`))!==o.current&&(r(!1),(w=o.current)==null||w.blur())}function d(m){m.stopPropagation(),m.key==="Enter"&&(m.preventDefault(),m.currentTarget.blur(),r(!1))}function u(){r(!0)}function h(){var m;if(!n){(m=o.current)==null||m.focus();return}r(!n)}return S.jsxs("div",{className:n?`${Ht.rangeSelector} ${Ht.rangeSelectorActive}`:Ht.rangeSelector,children:[S.jsx("div",{ref:o,className:Ht.rangeSelectorEditor,contentEditable:!0,"data-placeholder":s.t("rangeSelector.placeholder"),onKeyDown:d,onFocus:u}),S.jsx(Ye.Tooltip,{title:s.t("rangeSelector.tooltip"),placement:"bottom",children:S.jsx("button",{className:Ht.rangeSelectorIcon,onClick:h,children:S.jsx(bl,{})})})]})}var Kt=(i=>(i.Append="APPEND",i.Default="DEFAULT",i.Only="ONLY",i))(Kt||{}),We=(i=>(i.NUMBER="number",i.DATE="date",i.EXTEND_NUMBER="extendNumber",i.CHN_NUMBER="chnNumber",i.CHN_WEEK2="chnWeek2",i.CHN_WEEK3="chnWeek3",i.LOOP_SERIES="loopSeries",i.FORMULA="formula",i.OTHER="other",i))(We||{}),Te=(i=>(i.COPY="0",i.SERIES="1",i.ONLY_FORMAT="2",i.NO_FORMAT="3",i))(Te||{});const Ol={type:We.NUMBER,priority:1e3,match:i=>typeof(i==null?void 0:i.v)=="number"||!isNaN(Number(i==null?void 0:i.v)),isContinue:(i,e)=>i.type===We.NUMBER,applyFunctions:{[Te.SERIES]:(i,e,t)=>{const{data:n}=i;return t===l.Direction.LEFT||t===l.Direction.UP?(n.reverse(),yr(n,e).reverse()):yr(n,e)}}},Xo={type:We.OTHER,priority:0,match:()=>!0,isContinue:(i,e)=>i.type===We.OTHER},xl={type:We.EXTEND_NUMBER,priority:900,match:i=>Un(`${i==null?void 0:i.v}`||"").isExtendNumber,isContinue:(i,e)=>{var t;if(i.type===We.EXTEND_NUMBER){const{beforeTxt:n,afterTxt:r}=Un(`${(t=i.cellData)==null?void 0:t.v}`||""),{beforeTxt:o,afterTxt:s}=Un(`${e==null?void 0:e.v}`||"");if(n===o&&r===s)return!0}return!1},applyFunctions:{[Te.SERIES]:(i,e,t)=>{var s;const{data:n}=i;let r;if(n.length===1)return r=t===l.Direction.DOWN||t===l.Direction.RIGHT?1:-1,Er(n,e,r);const o=[];for(let a=0;a<n.length;a++){const c=`${(s=n[a])==null?void 0:s.v}`;c&&o.push(Number(Un(c).matchTxt))}return(t===l.Direction.UP||t===l.Direction.LEFT)&&(n.reverse(),o.reverse()),En(o)?(r=o[1]-o[0],Er(n,e,r)):Bt(n,e)}}},Al={type:We.CHN_NUMBER,priority:830,match:i=>!!xs(`${i==null?void 0:i.v}`||""),isContinue:(i,e)=>i.type===We.CHN_NUMBER,applyFunctions:{[Te.SERIES]:(i,e,t)=>{var c,d,u;const{data:n}=i,r=t===l.Direction.LEFT||t===l.Direction.UP;if(n.length===1){const h=`${(c=n[0])==null?void 0:c.v}`;let m;return r?m=-1:m=1,h&&(h==="日"||It(h)<7)?en(n,e,m):Or(n,e,m)}let o=!1;for(let h=0;h<n.length;h++)if(((d=n[h])==null?void 0:d.v)==="日"){o=!0;break}const s=[];let a=0;for(let h=0;h<n.length;h++){const m=`${(u=n[h])==null?void 0:u.v}`;m==="日"?h===0?s.push(0):(a++,s.push(a*7)):o&&It(m)>0&&It(m)<7?s.push(It(m)+a*7):s.push(It(m))}if(r&&(n.reverse(),s.reverse()),En(s)){if(o||s[s.length-1]<6&&s[0]>0||s[0]<6&&s[s.length-1]>0){const m=s[1]-s[0];return en(n,e,m)}const h=s[1]-s[0];return Or(n,e,h)}return Bt(n,e)}}},Nl={type:We.CHN_WEEK2,priority:820,match:i=>!!As(`${i==null?void 0:i.v}`||""),isContinue:(i,e)=>i.type===We.CHN_WEEK2,applyFunctions:{[Te.SERIES]:(i,e,t)=>{var a;const{data:n}=i,r=t===l.Direction.LEFT||t===l.Direction.UP;if(n.length===1){let c;return r?c=-1:c=1,en(n,e,c,1)}const o=[];let s=0;for(let c=0;c<n.length;c++){const d=`${(a=n[c])==null?void 0:a.v}`,u=d==null?void 0:d.substr(d.length-1,1);d==="周日"?c===0?o.push(0):(s++,o.push(s*7)):o.push(It(u)+s*7)}if(r&&(n.reverse(),o.reverse()),En(o)){const c=o[1]-o[0];return en(n,e,c,1)}return Bt(n,e)}}},Dl={type:We.CHN_WEEK3,priority:810,match:i=>Ns(`${i==null?void 0:i.v}`||""),isContinue:(i,e)=>i.type===We.CHN_WEEK3,applyFunctions:{[Te.SERIES]:(i,e,t)=>{var a;const{data:n}=i,r=t===l.Direction.LEFT||t===l.Direction.UP;if(n.length===1){let c;return r?c=-1:c=1,en(n,e,c,2)}const o=[];let s=0;for(let c=0;c<n.length;c++){const d=`${(a=n[c])==null?void 0:a.v}`;if(d){const u=d.substr(d.length-1,1);d==="星期日"?c===0?o.push(0):(s++,o.push(s*7)):o.push(It(u)+s*7)}}if(r&&(n.reverse(),o.reverse()),En(o)){const c=o[1]-o[0];return en(n,e,c,2)}return Bt(n,e)}}},Pl={type:We.LOOP_SERIES,priority:800,match:i=>Vs(`${i==null?void 0:i.v}`||""),isContinue:(i,e)=>{var t;return i.type===We.LOOP_SERIES?Pi(`${(t=i.cellData)==null?void 0:t.v}`||"").name===Pi(`${e==null?void 0:e.v}`||"").name:!1},applyFunctions:{[Te.SERIES]:(i,e,t)=>{var c,d;const{data:n}=i,r=t===l.Direction.LEFT||t===l.Direction.UP,{series:o}=Pi(`${(c=n[0])==null?void 0:c.v}`||"");if(n.length===1){let u;return r?u=-1:u=1,xr(n,e,u,o)}const s=[];let a=0;for(let u=0;u<n.length;u++){const h=`${(d=n[u])==null?void 0:d.v}`;h&&(h===o[0]?u===0?s.push(0):(a++,s.push(a*o.length)):s.push(o.indexOf(h)+a*7))}if(r&&(n.reverse(),s.reverse()),En(s)){const u=s[1]-s[0];return xr(n,e,u,o)}return Bt(n,e)}}};var Hl=Object.defineProperty,Ll=Object.getOwnPropertyDescriptor,Ul=(i,e,t,n)=>{for(var r=n>1?void 0:n?Ll(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&Hl(e,t,r),r},Li=(i,e)=>(t,n)=>e(t,n,i);exports.AutoFillService=class extends l.Disposable{constructor(t,n,r){super();v(this,"_rules",[]);v(this,"_hooks",[]);v(this,"_applyType$",new J.BehaviorSubject(Te.SERIES));v(this,"_isFillingStyle",!0);v(this,"_autoFillLocation$",new J.BehaviorSubject(null));v(this,"autoFillLocation$",this._autoFillLocation$.asObservable());v(this,"_showMenu$",new J.BehaviorSubject(!1));v(this,"showMenu$",this._showMenu$.asObservable());v(this,"_direction",l.Direction.DOWN);v(this,"applyType$",this._applyType$.asObservable());v(this,"_menu$",new J.BehaviorSubject([{label:"autoFill.copy",value:Te.COPY,disable:!1},{label:"autoFill.series",value:Te.SERIES,disable:!1},{label:"autoFill.formatOnly",value:Te.ONLY_FORMAT,disable:!1},{label:"autoFill.noFormat",value:Te.NO_FORMAT,disable:!1}]));v(this,"menu$",this._menu$.asObservable());this._sheetInterceptorService=t,this._univerInstanceService=n,this._selectionManagerService=r,this._init()}_init(){this._rules=[Ol,xl,Al,Nl,Dl,Pl,Xo].sort((t,n)=>n.priority-t.priority),this._isFillingStyle=!0}getOneByPriority(t){return t.length<=0?[]:[t.reduce((r,o)=>(o.priority||0)>(r.priority||0)?o:r,t[0])]}addHook(t){if(this._hooks.find(n=>n.id===t.id))throw new Error(`Add hook failed, hook id '${t.id}' already exist!`);return t.priority===void 0&&(t.priority=0),t.type===void 0&&(t.type=Kt.Append),this._hooks.push(t),l.toDisposable(()=>{const n=this._hooks.findIndex(r=>r===t);n>-1&&this._hooks.splice(n,1)})}registerRule(t){if(this._rules.find(r=>r.type===t.type))throw new Error(`Registry rule failed, type '${t.type}' already exist!`);const n=this._rules.findIndex(r=>r.priority<t.priority);this._rules.splice(n===-1?this._rules.length:n,0,t)}getRules(){return this._rules}getAllHooks(){return this._hooks}getActiveHooks(){const{source:t,target:n,unitId:r,subUnitId:o}=this.autoFillLocation||{};if(!t||!n||!r||!o)return[];const s=this._hooks.filter(u=>{var h;return!((h=u.disable)!=null&&h.call(u,{source:t,target:n,unitId:r,subUnitId:o},this._direction,this.applyType))}),a=s.filter(u=>u.type===Kt.Only);if(a.length>0)return this.getOneByPriority(a);const c=this.getOneByPriority(s.filter(u=>u.type===Kt.Default)),d=s.filter(u=>u.type===Kt.Append)||[];return[...c,...d]}get applyType(){return this._applyType$.getValue()}set applyType(t){this._applyType$.next(t)}get menu(){return this._menu$.getValue()}get direction(){return this._direction}set direction(t){this._direction=t}isFillingStyle(){return this._isFillingStyle}setFillingStyle(t){this._isFillingStyle=t}get autoFillLocation(){return this._autoFillLocation$.getValue()}set autoFillLocation(t){this._autoFillLocation$.next(t)}setDisableApplyType(t,n){this._menu$.next(this._menu$.getValue().map(r=>r.value===t?{...r,disable:n}:r))}setShowMenu(t){this._showMenu$.next(t)}};exports.AutoFillService=Ul([l.OnLifecycle(l.LifecycleStages.Rendered,exports.AutoFillService),Li(0,j.Inject(p.SheetInterceptorService)),Li(1,j.Inject(l.IUniverInstanceService)),Li(2,j.Inject(p.SelectionManagerService))],exports.AutoFillService);const xn=j.createIdentifier("univer.auto-fill-service");var kl=Object.defineProperty,Vl=Object.getOwnPropertyDescriptor,Fl=(i,e,t,n)=>{for(var r=n>1?void 0:n?Vl(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&kl(e,t,r),r},vt=(i,e)=>(t,n)=>e(t,n,i);exports.AutoFillController=class extends l.Disposable{constructor(t,n,r,o,s,a,c,d,u){super();v(this,"_beforeApplyData",[]);v(this,"_copyData",[]);v(this,"_defaultHook");this._univerInstanceService=t,this._selectionRenderService=n,this._commandService=r,this._undoRedoService=o,this._autoFillService=s,this._editorBridgeService=a,this._sheetInterceptorService=c,this._selectionManagerService=d,this._injector=u,this._defaultHook={id:"default",type:Kt.Default,priority:0,onBeforeFillData:(h,m)=>{this._presetAndCacheData(h,m)},onFillData:(h,m,g)=>this._fillData(h,m,g)},this._init()}_init(){this._initDefaultHook(),this._onSelectionControlFillChanged(),this._onApplyTypeChanged(),[So,zn].forEach(t=>{this.disposeWithMe(this._commandService.registerCommand(t))})}_initDefaultHook(){this._autoFillService.addHook(this._defaultHook)}_onSelectionControlFillChanged(){const t=new l.DisposableCollection;this.disposeWithMe(this._commandService.onCommandExecuted(n=>{if(n.id!==p.SetSelectionsOperation.id)return;const r=this._selectionManagerService.getCurrent();if((r==null?void 0:r.pluginName)!==p.NORMAL_SELECTION_PLUGIN_NAME)return;t.dispose(),this._selectionRenderService.getCurrentControls().forEach(s=>{t.add(l.toDisposable(s.selectionFilled$.subscribe(a=>{if(a==null||a.startColumn===-1||a.startRow===-1||a.endColumn===-1||a.endRow===-1)return;const c={startColumn:s.model.startColumn,endColumn:s.model.endColumn,startRow:s.model.startRow,endRow:s.model.endRow},d={startColumn:a.startColumn,endColumn:a.endColumn,startRow:a.startRow,endRow:a.endRow};this._triggerAutoFill(c,d)}))),t.add(l.toDisposable(s.fillControl.onDblclickObserver.add(()=>{const a={startColumn:s.model.startColumn,endColumn:s.model.endColumn,startRow:s.model.startRow,endRow:s.model.endRow};this._handleDbClickFill(a)}))),t.add(l.toDisposable(s.fillControl.onPointerDownObserver.add(()=>{this._editorBridgeService.isVisible().visible&&this._editorBridgeService.changeVisible({visible:!1,eventType:y.DeviceInputEventType.PointerDown})})))})}))}_onApplyTypeChanged(){this.disposeWithMe(l.toDisposable(this._autoFillService.applyType$.subscribe(()=>{this._handleFillData()})))}_triggerAutoFill(t,n){var d;if(t.startColumn===n.startColumn&&t.startRow===n.startRow&&t.endColumn===n.endColumn&&t.endRow===n.endRow)return;if(n.endColumn<t.endColumn&&n.endColumn>t.startColumn){this._commandService.executeCommand(zn.id,{clearRange:{startRow:n.startRow,endRow:n.endRow,startColumn:n.endColumn+1,endColumn:t.endColumn},selectionRange:n});return}if(n.endRow<t.endRow&&n.endRow>t.startRow){this._commandService.executeCommand(zn.id,{clearRange:{startRow:n.endRow+1,endRow:t.endRow,startColumn:n.startColumn,endColumn:n.endColumn},selectionRange:n});return}const r={startRow:n.startRow,endRow:n.endRow,startColumn:n.startColumn,endColumn:n.endColumn};let o=null;if(n.startRow<t.startRow)o=l.Direction.UP,r.endRow=t.startRow-1;else if(n.endRow>t.endRow)o=l.Direction.DOWN,r.startRow=t.endRow+1;else if(n.startColumn<t.startColumn)o=l.Direction.LEFT,r.endColumn=t.startColumn-1;else if(n.endColumn>t.endColumn)o=l.Direction.RIGHT,r.startColumn=t.endColumn+1;else return;const s=this._univerInstanceService.getCurrentUniverSheetInstance().getUnitId(),a=this._univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getSheetId();this._autoFillService.direction=o,this._autoFillService.autoFillLocation={source:t,target:r,unitId:s,subUnitId:a},this._autoFillService.getActiveHooks().forEach(u=>{var h;(h=u==null?void 0:u.onBeforeFillData)==null||h.call(u,{source:t,target:r,unitId:s,subUnitId:a},o)}),(d=this._autoFillService.menu.find(u=>u.value===Te.SERIES))!=null&&d.disable?this._autoFillService.applyType=Te.COPY:this._autoFillService.applyType=Te.SERIES}_handleDbClickFill(t){const n=this._detectFillRange(t);n.endRow<=t.endRow||this._triggerAutoFill(t,n)}_detectFillRange(t){var m,g,_,f,C,I;const{startRow:n,endRow:r,startColumn:o,endColumn:s}=t,a=(m=this._univerInstanceService.getCurrentUniverSheetInstance())==null?void 0:m.getActiveSheet();if(!a)return t;const c=a.getCellMatrix(),d=a.getMaxRows()-1,u=a.getMaxColumns()-1;let h=r;if(o>0&&((g=c.getValue(n,o-1))==null?void 0:g.v)!=null){let w=n;for(;((_=c.getValue(w,o-1))==null?void 0:_.v)!=null&&w<d;)w+=1;h=w-1}else if(s<u&&((f=c.getValue(r,s+1))==null?void 0:f.v)!=null){let w=n;for(;((C=c.getValue(w,s+1))==null?void 0:C.v)!=null&&w<d;)w+=1;h=w-1}for(let w=r+1;w<=h;w++)for(let E=o;E<=s;E++)if(((I=c.getValue(w,E))==null?void 0:I.v)!=null){h=w-1;break}return{startColumn:o,endColumn:s,startRow:n,endRow:h}}_handleFillData(){const{source:t,target:n,unitId:r=this._univerInstanceService.getCurrentUniverSheetInstance().getUnitId(),subUnitId:o=this._univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getSheetId()}=this._autoFillService.autoFillLocation||{},s=this._autoFillService.direction;if(!t||!n)return;const a=l.Rectangle.union(t,n),c=this._autoFillService.applyType,d=this._autoFillService.getActiveHooks();this._commandService.syncExecuteCommand(p.SetSelectionsOperation.id,{selections:[{primary:{...a,actualRow:a.startRow,actualColumn:a.startColumn,endColumn:a.startColumn,endRow:a.startRow},range:{...a,rangeType:l.RANGE_TYPE.NORMAL}}],unitId:r,subUnitId:o});const u=[],h=[];d.forEach(g=>{var C;const{undos:_,redos:f}=((C=g.onFillData)==null?void 0:C.call(g,{source:t,target:n,unitId:r,subUnitId:o},s,c))||{};_&&u.push(..._),f&&h.push(...f)}),h.every(g=>this._commandService.syncExecuteCommand(g.id,g.params))&&this._undoRedoService.pushUndoRedo({unitID:r,undoMutations:u,redoMutations:h}),d.forEach(g=>{var _;(_=g.onAfterFillData)==null||_.call(g,{source:t,target:n,unitId:r,subUnitId:o},s,c)}),this._autoFillService.setShowMenu(!0)}_getApplyData(t,n,r,o,s,a=!0){const c=[],d=Math.floor(r/n),u=r%n,h=this._autoFillService.getRules();if(!a&&s===Te.ONLY_FORMAT)return console.error("ERROR: only format can not be applied when hasStyle is false"),[];const m={};h.forEach(g=>{m[g.type]=[]}),h.forEach(g=>{const{type:_,applyFunctions:f={}}=g,C=t[_];C&&C.forEach(I=>{const w=Ds(I.index,u),E=I.index.length*d+w,O=this._applyFunctions(I,E,o,s,f,t),x=Ps(n,r,I.index);m[_].push({data:O,index:x})})});for(let g=0;g<r;g++)h.forEach(_=>{const{type:f}=_,C=m[f];for(let I=0;I<C.length;I++)g in C[I].index&&c.push(C[I].data[C[I].index[g]])});return c}_applyFunctions(t,n,r,o,s,a){const{data:c}=t,d=r===l.Direction.UP||r===l.Direction.LEFT;if(o===Te.COPY){const u=s==null?void 0:s[Te.COPY];return u?u(t,n,r,a):(d&&c.reverse(),Bt(c,n))}if(o===Te.SERIES){const u=s==null?void 0:s[Te.SERIES];return u?u(t,n,r,a):(d&&c.reverse(),s!=null&&s[Te.COPY]?s[Te.COPY](t,n,r,a):Bt(c,n))}if(o===Te.ONLY_FORMAT){const u=s==null?void 0:s[Te.ONLY_FORMAT];return u?u(t,n,r,a):Hs(c,n)}}_getCopyData(t,n){const{startRow:r,startColumn:o,endRow:s,endColumn:a}=t,c=this._univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getCellMatrix(),d=this._autoFillService.getRules(),u=[],h=n===l.Direction.DOWN||n===l.Direction.UP;let m,g,_,f;h?(m=o,g=a,_=r,f=s):(m=r,g=s,_=o,f=a);for(let C=m;C<=g;C++){const I=this._getEmptyCopyDataPiece(),w={type:void 0,cellData:void 0};for(let E=_;E<=f;E++){let O;h?O=c.getValue(E,C):O=c.getValue(C,E);const{type:x,isContinue:N}=d.find(D=>D.match(O))||Xo;if(N(w,O)){const D=I[x],P=D[D.length-1];P.data.push(O),P.index.push(E-_)}else{const D=I[x];D?D.push({data:[O],index:[E-_]}):I[x]=[{data:[O],index:[E-_]}]}w.type=x,w.cellData=O}u.push(I)}return u}_getEmptyCopyDataPiece(){const t={};return this._autoFillService.getRules().forEach(n=>{t[n.type]=[]}),t}_getMergeApplyData(t,n,r,o){const s=this._univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getMergeData(),a=[];for(let c=t.startRow;c<=t.endRow;c++)for(let d=t.startColumn;d<=t.endColumn;d++){const{isMergedMainCell:u,startRow:h,startColumn:m,endRow:g,endColumn:_}=y.getCellInfoInMergeData(c,d,s);if(u){if(r===l.Direction.DOWN){let f=h+o,C=g+o;for(;C<=n.endRow;)a.push({startRow:f,startColumn:m,endRow:C,endColumn:_}),f+=o,C+=o}else if(r===l.Direction.UP){let f=h-o,C=g-o;for(;f>=n.startRow;)a.push({startRow:f,startColumn:m,endRow:C,endColumn:_}),f-=o,C-=o}else if(r===l.Direction.RIGHT){let f=m+o,C=_+o;for(;C<=n.endColumn;)a.push({startRow:h,startColumn:f,endRow:g,endColumn:C}),f+=o,C+=o}else if(r===l.Direction.LEFT){let f=m-o,C=_-o;for(;f>=n.startColumn;)a.push({startRow:h,startColumn:f,endRow:g,endColumn:C}),f-=o,C-=o}}}return a}_presetAndCacheData(t,n){const{source:r,target:o}=t,s=this._univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getCellMatrix(),a=[];for(let c=o.startRow;c<=o.endRow;c++){const d=[];for(let u=o.startColumn;u<=o.endColumn;u++)d.push(l.Tools.deepClone(s.getValue(c,u)));a.push(d)}this._beforeApplyData=a,this._copyData=this._getCopyData(r,n),this._hasSeries(this._copyData)?this._autoFillService.setDisableApplyType(Te.SERIES,!1):this._autoFillService.setDisableApplyType(Te.SERIES,!0)}_fillData(t,n,r){var Oe,Le;const o=[],s=[];let a=!0;r===Te.NO_FORMAT&&(a=!1,r=Te.SERIES);const{source:c,target:d,unitId:u,subUnitId:h}=t;if(!c||!d||n==null)return{undos:o,redos:s};const{startRow:m,startColumn:g,endRow:_,endColumn:f}=c,{startRow:C,startColumn:I,endRow:w,endColumn:E}=d,O=this._copyData;let x;n===l.Direction.DOWN||n===l.Direction.UP?x=_-m+1:x=f-g+1;const N=[];if(n===l.Direction.DOWN||n===l.Direction.UP){const Se=w-C+1,he=[];for(let ge=I;ge<=E;ge++){const Ae=O[ge-I],we=this._getApplyData(Ae,x,Se,n,r,a);he.push(we)}for(let ge=0;ge<he[0].length;ge++){const Ae=[];for(let we=0;we<he.length;we++)Ae.push({s:null,...he[we][ge]});N.push(Ae)}}else{const Se=E-I+1;for(let he=C;he<=w;he++){const ge=O[he-C],Ae=this._getApplyData(ge,x,Se,n,r,a),we=[];for(let Pe=0;Pe<Ae.length;Pe++)we.push({s:null,...Ae[Pe]});N.push(we)}}let D=[];const P=this._univerInstanceService.getCurrentUniverSheetInstance().getStyles();a?(D=this._getMergeApplyData(c,d,n,x),N.forEach(Se=>{Se.forEach(he=>{he&&P&&P&&(he.s=P.getStyleByCell(he))})})):N.forEach((Se,he)=>{Se.forEach((ge,Ae)=>{ge&&P&&(ge.s=P.getStyleByCell(this._beforeApplyData[he][Ae])||null)})}),r===Te.ONLY_FORMAT&&N.forEach((Se,he)=>{Se.forEach((ge,Ae)=>{if(ge){const we=this._beforeApplyData[he][Ae]||{};ge.f=we.f,ge.si=we.si,ge.t=we.t,ge.v=we.v}})});const L={get:this._injector.get.bind(this._injector)},G=[],k=(Le=(Oe=this._univerInstanceService.getUniverSheetInstance(u))==null?void 0:Oe.getSheetBySheetId(h))==null?void 0:Le.getMergeData();k&&k.forEach(Se=>{l.Rectangle.intersects(Se,d)&&G.push(Se)});const ee={unitId:u,subUnitId:h,ranges:G},te=p.RemoveMergeUndoMutationFactory(L,ee);s.push({id:p.RemoveWorksheetMergeMutation.id,params:ee}),o.push({id:p.AddWorksheetMergeMutation.id,params:te});const W={subUnitId:h,unitId:u,cellValue:fo([d])},V=p.SetRangeValuesUndoMutationFactory(L,W),re=this._sheetInterceptorService.onCommandExecute({id:p.ClearSelectionContentCommand.id});s.push({id:p.SetRangeValuesMutation.id,params:W},...re.redos),o.push(...re.undos,{id:p.SetRangeValuesMutation.id,params:V});const q=new l.ObjectMatrix,{startRow:ae,startColumn:Ie,endRow:de,endColumn:Ee}=d;for(let Se=0;Se<=de-ae;Se++)for(let he=0;he<=Ee-Ie;he++)N[Se][he]&&q.setValue(Se+ae,he+Ie,N[Se][he]);const be={subUnitId:h,unitId:u,cellValue:q.getMatrix()},De=p.SetRangeValuesUndoMutationFactory(L,be);if(o.push({id:p.SetRangeValuesMutation.id,params:De}),s.push({id:p.SetRangeValuesMutation.id,params:be}),D!=null&&D.length){const Se=p.getAddMergeMutationRangeByType(D),he={unitId:u,subUnitId:h,ranges:Se},ge=p.AddMergeUndoMutationFactory(L,he);o.push({id:p.RemoveWorksheetMergeMutation.id,params:ge}),s.push({id:p.AddWorksheetMergeMutation.id,params:he})}return{undos:o,redos:s}}_hasSeries(t){return t.some(n=>Object.keys(n).some(o=>{var s;return!!((s=n[o])!=null&&s.length&&![We.OTHER,We.FORMULA].includes(o))}))}};exports.AutoFillController=Fl([l.OnLifecycle(l.LifecycleStages.Steady,exports.AutoFillController),vt(0,l.IUniverInstanceService),vt(1,Ze),vt(2,l.ICommandService),vt(3,l.IUndoRedoService),vt(4,xn),vt(5,at),vt(6,j.Inject(p.SheetInterceptorService)),vt(7,j.Inject(p.SelectionManagerService)),vt(8,j.Inject(j.Injector))],exports.AutoFillController);const ur={type:l.CommandType.COMMAND,id:"sheet.command.set-range-bold",handler:async i=>{const e=i.get(l.ICommandService);return i.get(l.IContextService).getContextValue(l.FOCUSING_EDITOR)?e.executeCommand(pe.SetInlineFormatBoldCommand.id):e.executeCommand(p.SetBoldCommand.id)}},hr={type:l.CommandType.COMMAND,id:"sheet.command.set-range-italic",handler:async i=>{const e=i.get(l.ICommandService);return i.get(l.IContextService).getContextValue(l.FOCUSING_EDITOR)?e.executeCommand(pe.SetInlineFormatItalicCommand.id):e.executeCommand(p.SetItalicCommand.id)}},mr={type:l.CommandType.COMMAND,id:"sheet.command.set-range-underline",handler:async i=>{const e=i.get(l.ICommandService);return i.get(l.IContextService).getContextValue(l.FOCUSING_EDITOR)?e.executeCommand(pe.SetInlineFormatUnderlineCommand.id):e.executeCommand(p.SetUnderlineCommand.id)}},gr={type:l.CommandType.COMMAND,id:"sheet.command.set-range-stroke",handler:async i=>{const e=i.get(l.ICommandService);return i.get(l.IContextService).getContextValue(l.FOCUSING_EDITOR)?e.executeCommand(pe.SetInlineFormatStrikethroughCommand.id):e.executeCommand(p.SetStrikeThroughCommand.id)}},Bl={type:l.CommandType.COMMAND,id:"sheet.command.set-range-subscript",handler:async i=>{const e=i.get(l.ICommandService);return i.get(l.IContextService).getContextValue(l.FOCUSING_EDITOR)?e.executeCommand(pe.SetInlineFormatSubscriptCommand.id):!1}},jl={type:l.CommandType.COMMAND,id:"sheet.command.set-range-superscript",handler:async i=>{const e=i.get(l.ICommandService);return i.get(l.IContextService).getContextValue(l.FOCUSING_EDITOR)?e.executeCommand(pe.SetInlineFormatSuperscriptCommand.id):!1}},Zo={type:l.CommandType.COMMAND,id:"sheet.command.set-range-fontsize",handler:async(i,e)=>{const t=i.get(l.ICommandService);return i.get(l.IContextService).getContextValue(l.FOCUSING_EDITOR)?t.executeCommand(pe.SetInlineFormatFontSizeCommand.id,e):t.executeCommand(p.SetFontSizeCommand.id,e)}},Go={type:l.CommandType.COMMAND,id:"sheet.command.set-range-font-family",handler:async(i,e)=>{const t=i.get(l.ICommandService);return i.get(l.IContextService).getContextValue(l.FOCUSING_EDITOR)?t.executeCommand(pe.SetInlineFormatFontFamilyCommand.id,e):t.executeCommand(p.SetFontFamilyCommand.id,e)}},Ii={type:l.CommandType.COMMAND,id:"sheet.command.set-range-text-color",handler:async(i,e)=>{const t=i.get(l.ICommandService);return i.get(l.IContextService).getContextValue(l.FOCUSING_EDITOR)?t.executeCommand(pe.SetInlineFormatTextColorCommand.id,e):t.executeCommand(p.SetTextColorCommand.id,e)}};function Ko(i,e){return e.some(t=>Wl(i,t))}function Wl(i,e){const{startRow:t,startColumn:n,endColumn:r,endRow:o}=e,s=i.getMatrixWithMergedCells(t,n,o,r);let a=!1;return s.forValue((c,d,u)=>{if(u&&(c!==t||d!==n)&&i.cellHasValue(u))return a=!0,!1}),a}function qo(i,e,t,n){const r=[],o=[],s=t.getSheetId();return n.forEach(a=>{const c=zl(t,a),d={unitId:e,subUnitId:s,cellValue:c.getData()},u=p.SetRangeValuesUndoMutationFactory(i,d);r.push({id:p.SetRangeValuesMutation.id,params:u}),o.push({id:p.SetRangeValuesMutation.id,params:d})}),{undos:r,redos:o}}function zl(i,e){const{startRow:t,startColumn:n,endColumn:r,endRow:o}=e,s=i.getMatrixWithMergedCells(t,n,o,r),a=new l.ObjectMatrix;return s.forValue((c,d,u)=>{u&&(c!==t||d!==n)&&a.setValue(c,d,null)}),a}var $l=Object.defineProperty,Yl=Object.getOwnPropertyDescriptor,Xl=(i,e,t,n)=>{for(var r=n>1?void 0:n?Yl(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&$l(e,t,r),r},Ui=(i,e)=>(t,n)=>e(t,n,i),st=(i=>(i[i.OFF=0]="OFF",i[i.ONCE=1]="ONCE",i[i.INFINITE=2]="INFINITE",i))(st||{});const sn=j.createIdentifier("univer.format-painter-service");let er=class extends l.Disposable{constructor(e,t,n){super();v(this,"status$");v(this,"_selectionFormat");v(this,"_markId",null);v(this,"_status$");this._selectionManagerService=e,this._univerInstanceService=t,this._markSelectionService=n,this._status$=new J.BehaviorSubject(0),this.status$=this._status$.asObservable(),this._selectionFormat={styles:new l.ObjectMatrix,merges:[]}}setStatus(e){e!==0&&this._getSelectionRangeFormat(),this._updateRangeMark(e),this._status$.next(e)}getStatus(){return this._status$.getValue()}_updateRangeMark(e){if(this._markSelectionService.removeAllShapes(),this._markId=null,e!==0){const t=this._selectionManagerService.getLast();if(t){const n=this._selectionManagerService.createCopyPasteSelection();e===2?this._markId=this._markSelectionService.addShape({...t,style:n}):this._markId=this._markSelectionService.addShape({...t,style:n},[p.SetRangeValuesMutation.id])}}}_getSelectionRangeFormat(){const e=this._selectionManagerService.getLast(),t=e==null?void 0:e.range;if(!t)return;const{startRow:n,endRow:r,startColumn:o,endColumn:s}=t,a=this._univerInstanceService.getCurrentUniverSheetInstance(),d=(a==null?void 0:a.getActiveSheet()).getCellMatrix(),u=this._univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getMergeData(),h=a.getStyles(),m=new l.ObjectMatrix;for(let g=n;g<=r;g++)for(let _=o;_<=s;_++){const f=d.getValue(g,_);m.setValue(g,_,h.getStyleByCell(f)||{});const{isMergedMainCell:C,...I}=y.getCellInfoInMergeData(g,_,u);C&&this._selectionFormat.merges.push({startRow:I.startRow,startColumn:I.startColumn,endRow:I.endRow,endColumn:I.endColumn})}this._selectionFormat.styles=m}getSelectionFormat(){return this._selectionFormat}};er=Xl([Ui(0,j.Inject(p.SelectionManagerService)),Ui(1,l.IUniverInstanceService),Ui(2,On)],er);const _r={id:"sheet.operation.set-format-painter",type:l.CommandType.OPERATION,handler:(i,e)=>e?(i.get(sn).setStatus(e.status),!0):!1},Jo={type:l.CommandType.COMMAND,id:"sheet.command.set-infinite-format-painter",handler:async i=>{const t=i.get(sn).getStatus();let n;return t!==st.OFF?n=st.OFF:n=st.INFINITE,i.get(l.ICommandService).executeCommand(_r.id,{status:n})}},pr={type:l.CommandType.COMMAND,id:"sheet.command.set-once-format-painter",handler:async i=>{const t=i.get(sn).getStatus();let n;return t!==st.OFF?n=st.OFF:n=st.ONCE,i.get(l.ICommandService).executeCommand(_r.id,{status:n})}},Qo={type:l.CommandType.COMMAND,id:"sheet.command.apply-format-painter",handler:async(i,e)=>{const t=i.get(l.ICommandService),n=i.get(l.IUndoRedoService),r=i.get(l.IUniverInstanceService),o=i.get(p.SelectionManagerService),s=i.get(p.SheetInterceptorService),{styleValues:a,styleRange:c,mergeRanges:d,unitId:u=r.getCurrentUniverSheetInstance().getUnitId(),subUnitId:h=r.getCurrentUniverSheetInstance().getActiveSheet().getSheetId()}=e,m=c?[c]:o.getSelectionRanges();if(!m||!m.length)return!1;const g=new l.ObjectMatrix;let _;if(l.Tools.isArray(a))for(let W=0;W<m.length;W++){const{startRow:V,startColumn:re,endRow:q,endColumn:ae}=m[W];for(let Ie=0;Ie<=q-V;Ie++)for(let de=0;de<=ae-re;de++)g.setValue(Ie+V,de+re,a[Ie][de])}else if(l.isICellData(a))for(let W=0;W<m.length;W++){const{startRow:V,startColumn:re}=m[W];g.setValue(V,re,a)}else _=a;const f={subUnitId:h,unitId:u,cellValue:_??g.getMatrix()},C=p.SetRangeValuesUndoMutationFactory(i,f);if(!s.fetchThroughInterceptors(p.INTERCEPTOR_POINT.PERMISSION)(null,{id:p.SetRangeValuesCommand.id,params:f}))return!1;const I=t.syncExecuteCommand(p.SetRangeValuesMutation.id,f),{undos:w,redos:E}=s.onCommandExecute({id:p.SetRangeValuesCommand.id,params:{...f,range:m}}),O=p.getAddMergeMutationRangeByType(d),x=r.getUniverSheetInstance(u).getSheetBySheetId(h),N=[],D=[],P=Ko(x,O),L={unitId:u,subUnitId:h,ranges:O},G={unitId:u,subUnitId:h,ranges:O};N.push({id:p.RemoveWorksheetMergeMutation.id,params:L}),N.push({id:p.AddWorksheetMergeMutation.id,params:G});const k=p.RemoveMergeUndoMutationFactory(i,L),ee=p.AddMergeUndoMutationFactory(i,G);if(D.push({id:p.RemoveWorksheetMergeMutation.id,params:ee}),D.push({id:p.AddWorksheetMergeMutation.id,params:k}),P){const W=qo(i,u,x,O);N.unshift(...W.redos),D.push(...W.undos)}const te=await l.sequenceExecute([...E,...N],t);return I&&te.result?(n.pushUndoRedo({unitID:u,undoMutations:[{id:p.SetRangeValuesMutation.id,params:C},...w,...D],redoMutations:[{id:p.SetRangeValuesMutation.id,params:f},...E,...N]}),!0):!1}},Ei={type:l.CommandType.COMMAND,id:"sheet.command.set-selection-frozen",handler:async(i,e)=>{const{type:t}=e||{},n=i.get(l.IUniverInstanceService),r=i.get(l.IUndoRedoService),o=n.getCurrentUniverSheetInstance().getUnitId(),s=n.getCurrentUniverSheetInstance().getActiveSheet().getSheetId(),a=i.get(l.ICommandService),d=i.get(p.SelectionManagerService).getSelections();if(!d)return!1;const u=d[(d==null?void 0:d.length)-1],{range:h}=u,m=i.get(Nt),{sheetViewStartRow:g=0,sheetViewStartColumn:_=0}=m.getCurrentScroll()||{};let f,C,I,w;const{startRow:E,startColumn:O,rangeType:x}=h;if(x===l.RANGE_TYPE.ROW||t===1)f=E,I=E-g,C=-1,w=0;else if(x===l.RANGE_TYPE.COLUMN||t===2)f=-1,I=0,C=O,w=O-_;else if(x===l.RANGE_TYPE.NORMAL)f=E,I=E-g,C=O,w=O-_;else return!1;const N={unitId:o,subUnitId:s,startRow:f,startColumn:C,xSplit:C>0?Math.max(1,w):w,ySplit:f>0?Math.max(1,I):I},D=p.SetFrozenMutationFactory(i,N);return a.syncExecuteCommand(p.SetFrozenMutation.id,N)&&r.pushUndoRedo({unitID:o,undoMutations:[{id:p.SetFrozenMutation.id,params:D}],redoMutations:[{id:p.SetFrozenMutation.id,params:N}]}),!0}},es={type:l.CommandType.COMMAND,id:"sheet.command.set-row-frozen",handler:async i=>(i.get(l.ICommandService).executeCommand(Ei.id,{type:1}),!0)},ts={type:l.CommandType.COMMAND,id:"sheet.command.set-col-frozen",handler:async i=>(i.get(l.ICommandService).executeCommand(Ei.id,{type:2}),!0)},ns={type:l.CommandType.COMMAND,id:"sheet.command.cancel-frozen",handler:async i=>{const e=i.get(l.ICommandService),t=i.get(l.IUniverInstanceService),n=i.get(l.IUndoRedoService),r=t.getCurrentUniverSheetInstance().getUnitId(),o=t.getCurrentUniverSheetInstance().getActiveSheet().getSheetId(),s={unitId:r,subUnitId:o,startRow:-1,startColumn:-1,xSplit:0,ySplit:0},a=p.SetFrozenMutationFactory(i,s);return e.syncExecuteCommand(p.SetFrozenMutation.id,s)&&n.pushUndoRedo({unitID:r,undoMutations:[{id:p.SetFrozenMutation.id,params:a}],redoMutations:[{id:p.SetFrozenMutation.id,params:s}]}),!0}},an="UI_PLUGIN_SHEETS",Oi=`${an}_COLOR_PICKER_COMPONENT`,Zl="univer-ui-plugin-sheets-font-family",Gl="univer-ui-plugin-sheets-font-family-item",is={uiPluginSheetsFontFamily:Zl,uiPluginSheetsFontFamilyItem:Gl},Kl=i=>{const{value:e}=i,t=me.useDependency(l.LocaleService);return S.jsx("div",{className:is.uiPluginSheetsFontFamily,style:{fontFamily:e},children:t.t(`fontFamily.${(`${e}`??"").replace(/\s/g,"")}`)})},ql=i=>{const{value:e}=i,t=me.useDependency(l.LocaleService);return S.jsx("span",{className:is.uiPluginSheetsFontFamilyItem,style:{fontFamily:e},children:t.t(`fontFamily.${(`${e}`??"").replace(/\s/g,"")}`)})},rs=`${an}_FONT_FAMILY_COMPONENT`,Ge=`${an}_FONT_FAMILY_ITEM_COMPONENT`,Jl="univer-ui-plugin-sheets-font-size",Ql="univer-ui-plugin-sheets-font-size-input",Wr={uiPluginSheetsFontSize:Jl,uiPluginSheetsFontSizeInput:Ql},ec=i=>{const{value:e,min:t,max:n,onChange:r,disabled$:o}=i,s=R.useObservable(o??new J.Observable(m=>m.next(!1))),[a,c]=X.useState(Number(e??0)),d=X.useMemo(()=>Number(e??a),[e]);function u(m){m!==null&&c(m)}function h(m){m.stopPropagation(),m.code==="Enter"&&r(a.toString())}return S.jsx("div",{className:Wr.uiPluginSheetsFontSize,children:S.jsx(Ye.InputNumber,{className:Wr.uiPluginSheetsFontSizeInput,value:d,controls:!1,min:t,max:n,onKeyDown:h,onChange:u,disabled:s})})},os=`${an}_FONT_SIZE_COMPONENT`,fr=`${an}_MENU_ITEM_INPUT_COMPONENT`,tc="univer-sheets-ui-context-menu-input",nc="univer-sheets-ui-context-menu-input-container",ic="univer-sheets-ui-context-menu-input-number",ki={sheetsUiContextMenuInput:tc,sheetsUiContextMenuInputContainer:nc,sheetsUiContextMenuInputNumber:ic},rc=i=>{const{prefix:e,suffix:t,value:n,onChange:r,min:o=Number.MIN_SAFE_INTEGER,max:s=Number.MAX_SAFE_INTEGER}=i,a=me.useDependency(l.LocaleService),[c,d]=X.useState(),u=m=>{d(m==null?void 0:m.toString()),r((m==null?void 0:m.toString())??"")};X.useEffect(()=>{d(n)},[n]);function h(m){m.key==="Backspace"&&m.stopPropagation()}return S.jsxs("div",{className:ki.sheetsUiContextMenuInput,children:[a.t(e),S.jsx("span",{className:ki.sheetsUiContextMenuInputContainer,onClick:m=>m.stopPropagation(),children:S.jsx(Ye.InputNumber,{className:ki.sheetsUiContextMenuInputNumber,value:Number(c),precision:0,onKeyDown:h,onChange:u,min:o,max:s})}),a.t(t)]})};var Be=(i=>(i.ROW_HEADER_CONTEXT_MENU="rowHeaderContextMenu",i.COL_HEADER_CONTEXT_MENU="colHeaderContextMenu",i.SHEET_BAR="sheetBar",i))(Be||{});function oc(i){const e=i.get(sn);return{id:pr.id,subId:Jo.id,group:R.MenuGroup.TOOLBAR_FORMAT,type:R.MenuItemType.BUTTON,icon:"BrushSingle",title:"Format Painter",tooltip:"toolbar.formatPainter",positions:[R.MenuPosition.TOOLBAR_START],activated$:new J.Observable(t=>{let n=!1;const r=e.status$.subscribe(o=>{n=o!==st.OFF,t.next(n)});return t.next(n),()=>{r.unsubscribe()}}),hidden$:R.getMenuHiddenObservable(i,l.UniverInstanceType.SHEET),disabled$:p.getCurrentSheetDisabled$(i)}}function sc(i){const e=i.get(l.ICommandService),t=i.get(l.IUniverInstanceService),n=i.get(l.IContextService),r=i.get(p.SelectionManagerService);return{id:ur.id,group:R.MenuGroup.TOOLBAR_FORMAT,type:R.MenuItemType.BUTTON,icon:"BoldSingle",title:"Set bold",tooltip:"toolbar.bold",positions:[R.MenuPosition.TOOLBAR_START],disabled$:p.getCurrentSheetDisabled$(i),activated$:new J.Observable(o=>{const s=e.onCommandExecuted(a=>{var d,u;const c=a.id;if(c===p.SetRangeValuesMutation.id||c===p.SetSelectionsOperation.id){const h=(d=r.getLast())==null?void 0:d.primary,m=t.getCurrentUniverSheetInstance().getActiveSheet();let g=l.FontWeight.NORMAL;if(h!=null){const _=m.getRange(h.startRow,h.startColumn);g=_==null?void 0:_.getFontWeight()}o.next(g===l.FontWeight.BOLD)}if((c===pe.SetTextSelectionsOperation.id||c===pe.SetInlineFormatCommand.id)&&n.getContextValue(l.FOCUSING_EDITOR)&&n.getContextValue(l.FOCUSING_SHEET)){const h=Nn(i);if(h==null)return;const m=(u=h.ts)==null?void 0:u.bl;o.next(m===l.BooleanNumber.TRUE)}});return o.next(!1),s.dispose}),hidden$:R.getMenuHiddenObservable(i,l.UniverInstanceType.SHEET)}}function ac(i){const e=i.get(l.ICommandService),t=i.get(l.IUniverInstanceService),n=i.get(p.SelectionManagerService),r=i.get(l.IContextService);return{id:hr.id,group:R.MenuGroup.TOOLBAR_FORMAT,type:R.MenuItemType.BUTTON,icon:"ItalicSingle",title:"Set italic",tooltip:"toolbar.italic",positions:[R.MenuPosition.TOOLBAR_START],disabled$:p.getCurrentSheetDisabled$(i),activated$:new J.Observable(o=>{const s=e.onCommandExecuted(a=>{var d,u;const c=a.id;if(c===p.SetRangeValuesMutation.id||c===p.SetSelectionsOperation.id){const h=(d=n.getLast())==null?void 0:d.primary,m=t.getCurrentUniverSheetInstance().getActiveSheet();let g=l.FontItalic.NORMAL;if(h!=null){const _=m.getRange(h.startRow,h.startColumn);g=_==null?void 0:_.getFontStyle()}o.next(g===l.FontItalic.ITALIC)}if((c===pe.SetTextSelectionsOperation.id||c===pe.SetInlineFormatCommand.id)&&r.getContextValue(l.FOCUSING_EDITOR)&&r.getContextValue(l.FOCUSING_SHEET)){const h=Nn(i);if(h==null)return;const m=(u=h.ts)==null?void 0:u.it;o.next(m===l.BooleanNumber.TRUE)}});return o.next(!1),s.dispose}),hidden$:R.getMenuHiddenObservable(i,l.UniverInstanceType.SHEET)}}function lc(i){const e=i.get(l.ICommandService),t=i.get(l.IUniverInstanceService),n=i.get(p.SelectionManagerService),r=i.get(l.IContextService);return{id:mr.id,group:R.MenuGroup.TOOLBAR_FORMAT,type:R.MenuItemType.BUTTON,icon:"UnderlineSingle",title:"Set underline",tooltip:"toolbar.underline",positions:[R.MenuPosition.TOOLBAR_START],disabled$:p.getCurrentSheetDisabled$(i),activated$:new J.Observable(o=>{const s=e.onCommandExecuted(a=>{var d,u;const c=a.id;if(c===p.SetRangeValuesMutation.id||c===p.SetSelectionsOperation.id){const h=(d=n.getLast())==null?void 0:d.primary,m=t.getCurrentUniverSheetInstance().getActiveSheet();let g;if(h!=null){const _=m.getRange(h.startRow,h.startColumn);g=_==null?void 0:_.getUnderline()}o.next(!!(g&&g.s))}if((c===pe.SetTextSelectionsOperation.id||c===pe.SetInlineFormatCommand.id)&&r.getContextValue(l.FOCUSING_EDITOR)&&r.getContextValue(l.FOCUSING_SHEET)){const h=Nn(i);if(h==null)return;const m=(u=h.ts)==null?void 0:u.ul;o.next((m==null?void 0:m.s)===l.BooleanNumber.TRUE)}});return o.next(!1),s.dispose}),hidden$:R.getMenuHiddenObservable(i,l.UniverInstanceType.SHEET)}}function cc(i){const e=i.get(l.ICommandService),t=i.get(l.IUniverInstanceService),n=i.get(p.SelectionManagerService),r=i.get(l.IContextService);return{id:gr.id,group:R.MenuGroup.TOOLBAR_FORMAT,type:R.MenuItemType.BUTTON,icon:"StrikethroughSingle",title:"Set strike through",tooltip:"toolbar.strikethrough",positions:[R.MenuPosition.TOOLBAR_START],disabled$:p.getCurrentSheetDisabled$(i),activated$:new J.Observable(o=>{const s=e.onCommandExecuted(a=>{var d,u;const c=a.id;if(c===p.SetRangeValuesMutation.id||c===p.SetSelectionsOperation.id){const h=(d=n.getLast())==null?void 0:d.primary,m=t.getCurrentUniverSheetInstance().getActiveSheet();let g;if(h!=null){const _=m.getRange(h.startRow,h.startColumn);g=_==null?void 0:_.getStrikeThrough()}o.next(!!(g&&g.s))}if((c===pe.SetTextSelectionsOperation.id||c===pe.SetInlineFormatCommand.id)&&r.getContextValue(l.FOCUSING_EDITOR)&&r.getContextValue(l.FOCUSING_SHEET)){const h=Nn(i);if(h==null)return;const m=(u=h.ts)==null?void 0:u.st;o.next((m==null?void 0:m.s)===l.BooleanNumber.TRUE)}});return o.next(!1),s.dispose}),hidden$:R.getMenuHiddenObservable(i,l.UniverInstanceType.SHEET)}}const dc=[{label:"9",value:9},{label:"10",value:10},{label:"11",value:11},{label:"12",value:12},{label:"14",value:14},{label:"16",value:16},{label:"18",value:18},{label:"20",value:20},{label:"22",value:22},{label:"24",value:24},{label:"26",value:26},{label:"28",value:28},{label:"36",value:36},{label:"48",value:48},{label:"72",value:72}],zr=[{label:Ge,value:"Times New Roman"},{label:Ge,value:"Arial"},{label:Ge,value:"Tahoma"},{label:Ge,value:"Verdana"},{label:Ge,value:"Microsoft YaHei"},{label:Ge,value:"SimSun"},{label:Ge,value:"SimHei"},{label:Ge,value:"Kaiti"},{label:Ge,value:"FangSong"},{label:Ge,value:"NSimSun"},{label:Ge,value:"STXinwei"},{label:Ge,value:"STXingkai"},{label:Ge,value:"STLiti"}];function uc(i){const e=i.get(l.ICommandService),t=i.get(l.IUniverInstanceService),n=i.get(p.SelectionManagerService);return{id:Go.id,tooltip:"toolbar.font",group:R.MenuGroup.TOOLBAR_FORMAT,type:R.MenuItemType.SELECTOR,label:rs,positions:[R.MenuPosition.TOOLBAR_START],selections:zr,disabled$:p.getCurrentSheetDisabled$(i),value$:new J.Observable(r=>{const o=zr[0].value,s=e.onCommandExecuted(a=>{var m;const c=a.id;if(c!==p.SetRangeValuesMutation.id&&c!==p.SetSelectionsOperation.id)return;const d=(m=n.getLast())==null?void 0:m.primary,u=t.getCurrentUniverSheetInstance().getActiveSheet();let h;if(d!=null){const g=u.getRange(d.startRow,d.startColumn);h=g==null?void 0:g.getFontFamily()}r.next(h??o)});return r.next(o),s.dispose}),hidden$:R.getMenuHiddenObservable(i,l.UniverInstanceType.SHEET)}}function hc(i){const e=i.get(l.ICommandService),t=i.get(l.IUniverInstanceService),n=i.get(p.SelectionManagerService),r=i.get(l.IContextService),o=p.getCurrentSheetDisabled$(i);return{id:Zo.id,group:R.MenuGroup.TOOLBAR_FORMAT,type:R.MenuItemType.SELECTOR,tooltip:"toolbar.fontSize",label:{name:os,props:{min:1,max:400,disabled$:o}},positions:[R.MenuPosition.TOOLBAR_START],selections:dc,disabled$:o,value$:new J.Observable(s=>{const c=e.onCommandExecuted(d=>{var h,m;const u=d.id;if(u===p.SetRangeValuesMutation.id||u===p.SetSelectionsOperation.id){const g=(h=n.getLast())==null?void 0:h.primary,_=t.getCurrentUniverSheetInstance().getActiveSheet();let f;if(g!=null){const C=_.getRange(g.startRow,g.startColumn);f=C==null?void 0:C.getFontSize()}s.next(f??14)}if((u===pe.SetTextSelectionsOperation.id||u===pe.SetInlineFormatCommand.id)&&r.getContextValue(l.FOCUSING_EDITOR)&&r.getContextValue(l.FOCUSING_SHEET)){const g=Nn(i);if(g==null)return;const _=(m=g.ts)==null?void 0:m.fs;s.next(_??14)}});return s.next(14),c.dispose}),hidden$:R.getMenuHiddenObservable(i,l.UniverInstanceType.SHEET)}}function mc(i){return{id:p.ResetTextColorCommand.id,type:R.MenuItemType.BUTTON,title:"toolbar.resetColor",icon:"NoColor",positions:Ii.id,disabled$:p.getCurrentSheetDisabled$(i)}}function gc(i){const e=i.get(l.ICommandService),t=i.get(l.ThemeService);return{id:Ii.id,icon:"FontColor",tooltip:"toolbar.textColor.main",group:R.MenuGroup.TOOLBAR_FORMAT,type:R.MenuItemType.BUTTON_SELECTOR,positions:[R.MenuPosition.TOOLBAR_START],selections:[{label:{name:Oi,hoverable:!1}}],value$:new J.Observable(n=>{const r=t.getCurrentTheme().textColor,o=e.onCommandExecuted(s=>{if(s.id===Ii.id){const a=s.params.value;n.next(a??r)}});return n.next(r),o.dispose}),hidden$:R.getMenuHiddenObservable(i,l.UniverInstanceType.SHEET),disabled$:p.getCurrentSheetDisabled$(i)}}function _c(i){return{id:p.ResetBackgroundColorCommand.id,type:R.MenuItemType.BUTTON,title:"toolbar.resetColor",icon:"NoColor",positions:p.SetBackgroundColorCommand.id,disabled$:p.getCurrentSheetDisabled$(i)}}function pc(i){const e=i.get(l.ICommandService),t=i.get(l.ThemeService);return{id:p.SetBackgroundColorCommand.id,tooltip:"toolbar.fillColor.main",group:R.MenuGroup.TOOLBAR_FORMAT,type:R.MenuItemType.BUTTON_SELECTOR,positions:[R.MenuPosition.TOOLBAR_START],icon:"PaintBucket",selections:[{label:{name:Oi,hoverable:!1}}],value$:new J.Observable(n=>{const r=t.getCurrentTheme().primaryColor,o=e.onCommandExecuted(s=>{if(s.id===p.SetBackgroundColorCommand.id){const a=s.params.value;n.next(a??r)}});return n.next(r),o.dispose}),hidden$:R.getMenuHiddenObservable(i,l.UniverInstanceType.SHEET),disabled$:p.getCurrentSheetDisabled$(i)}}const $r=[{label:"align.left",icon:"LeftJustifyingSingle",value:l.HorizontalAlign.LEFT},{label:"align.center",icon:"HorizontallySingle",value:l.HorizontalAlign.CENTER},{label:"align.right",icon:"RightJustifyingSingle",value:l.HorizontalAlign.RIGHT}];function fc(i){const e=i.get(l.IUniverInstanceService),t=i.get(p.SelectionManagerService);return{id:p.SetHorizontalTextAlignCommand.id,icon:$r[0].icon,positions:[R.MenuPosition.TOOLBAR_START],tooltip:"toolbar.horizontalAlignMode.main",group:R.MenuGroup.TOOLBAR_LAYOUT,type:R.MenuItemType.SELECTOR,selections:$r,value$:new J.Observable(n=>{const r=i.get(l.ICommandService).onCommandExecuted(o=>{var u;const s=o.id;if(s!==p.SetHorizontalTextAlignCommand.id&&s!==p.SetSelectionsOperation.id)return;const a=(u=t.getLast())==null?void 0:u.primary,c=e.getCurrentUniverSheetInstance().getActiveSheet();let d;if(a!=null){const h=c.getRange(a.startRow,a.startColumn);d=h==null?void 0:h.getHorizontalAlignment()}n.next(d??l.HorizontalAlign.LEFT)});return n.next(l.HorizontalAlign.LEFT),r.dispose}),hidden$:R.getMenuHiddenObservable(i,l.UniverInstanceType.SHEET),disabled$:p.getCurrentSheetDisabled$(i)}}const Yr=[{label:"align.top",icon:"AlignTopSingle",value:l.VerticalAlign.TOP},{label:"align.middle",icon:"VerticalCenterSingle",value:l.VerticalAlign.MIDDLE},{label:"align.bottom",icon:"AlignBottomSingle",value:l.VerticalAlign.BOTTOM}];function Sc(i){const e=i.get(l.IUniverInstanceService),t=i.get(p.SelectionManagerService);return{id:p.SetVerticalTextAlignCommand.id,icon:Yr[0].icon,tooltip:"toolbar.verticalAlignMode.main",group:R.MenuGroup.TOOLBAR_LAYOUT,type:R.MenuItemType.SELECTOR,positions:[R.MenuPosition.TOOLBAR_START],selections:Yr,value$:new J.Observable(n=>{const r=i.get(l.ICommandService).onCommandExecuted(o=>{var u;const s=o.id;if(s!==p.SetVerticalTextAlignCommand.id&&s!==p.SetSelectionsOperation.id)return;const a=(u=t.getLast())==null?void 0:u.primary,c=e.getCurrentUniverSheetInstance().getActiveSheet();let d;if(a!=null){const h=c.getRange(a.startRow,a.startColumn);d=h==null?void 0:h.getVerticalAlignment()}n.next(d??l.VerticalAlign.TOP)});return n.next(l.VerticalAlign.TOP),r.dispose}),hidden$:R.getMenuHiddenObservable(i,l.UniverInstanceType.SHEET),disabled$:p.getCurrentSheetDisabled$(i)}}const Xr=[{label:"textWrap.overflow",icon:"OverflowSingle",value:l.WrapStrategy.OVERFLOW},{label:"textWrap.wrap",icon:"AutowrapSingle",value:l.WrapStrategy.WRAP},{label:"textWrap.clip",icon:"TruncationSingle",value:l.WrapStrategy.CLIP}];function vc(i){const e=i.get(p.SelectionManagerService),t=i.get(l.IUniverInstanceService);return{id:p.SetTextWrapCommand.id,tooltip:"toolbar.textWrapMode.main",icon:Xr[0].icon,group:R.MenuGroup.TOOLBAR_LAYOUT,type:R.MenuItemType.SELECTOR,positions:[R.MenuPosition.TOOLBAR_START],selections:Xr,value$:new J.Observable(n=>{const r=i.get(l.ICommandService).onCommandExecuted(o=>{var u;const s=o.id;if(s!==p.SetTextWrapCommand.id&&s!==p.SetSelectionsOperation.id)return;const a=(u=e.getLast())==null?void 0:u.primary,c=t.getCurrentUniverSheetInstance().getActiveSheet();let d;if(a!=null){const h=c.getRange(a.startRow,a.startColumn);d=h==null?void 0:h.getWrapStrategy()}n.next(d??l.WrapStrategy.OVERFLOW)});return n.next(l.WrapStrategy.OVERFLOW),r.dispose}),hidden$:R.getMenuHiddenObservable(i,l.UniverInstanceType.SHEET),disabled$:p.getCurrentSheetDisabled$(i)}}const Zr=[{label:"textRotate.none",icon:"NoRotationSingle",value:0},{label:"textRotate.angleUp",icon:"LeftRotationFortyFiveDegreesSingle",value:-45},{label:"textRotate.angleDown",icon:"RightRotationFortyFiveDegreesSingle",value:45},{label:"textRotate.vertical",icon:"VerticalTextSingle",value:"v"},{label:"textRotate.rotationUp",icon:"LeftRotationNinetyDegreesSingle",value:-90},{label:"textRotate.rotationDown",icon:"RightRotationNinetyDegreesSingle",value:90}];function Cc(i){const e=i.get(p.SelectionManagerService),t=i.get(l.IUniverInstanceService);return{id:p.SetTextRotationCommand.id,tooltip:"toolbar.textRotateMode.main",icon:Zr[0].icon,group:R.MenuGroup.TOOLBAR_LAYOUT,type:R.MenuItemType.SELECTOR,selections:Zr,positions:[R.MenuPosition.TOOLBAR_START],value$:new J.Observable(n=>{const r=i.get(l.ICommandService).onCommandExecuted(o=>{var u;const s=o.id;if(s!==p.SetTextRotationCommand.id&&s!==p.SetSelectionsOperation.id)return;const a=(u=e.getLast())==null?void 0:u.primary,c=t.getCurrentUniverSheetInstance().getActiveSheet();let d;if(a!=null){const h=c.getRange(a.startRow,a.startColumn);d=h==null?void 0:h.getTextRotation()}(d==null?void 0:d.v)===l.BooleanNumber.TRUE?n.next("v"):n.next((d&&d.a)??0)});return n.next(0),r.dispose}),hidden$:R.getMenuHiddenObservable(i,l.UniverInstanceType.SHEET),disabled$:p.getCurrentSheetDisabled$(i)}}function Rc(){return{id:R.CopyCommand.id,group:R.MenuGroup.CONTEXT_MENU_FORMAT,type:R.MenuItemType.BUTTON,title:"rightClick.copy",icon:"Copy",positions:[R.MenuPosition.CONTEXT_MENU,"colHeaderContextMenu","rowHeaderContextMenu"]}}function Ic(){return{id:R.PasteCommand.id,group:R.MenuGroup.CONTEXT_MENU_FORMAT,type:R.MenuItemType.BUTTON,title:"rightClick.paste",icon:"PasteSpecial",positions:[R.MenuPosition.CONTEXT_MENU,"colHeaderContextMenu","rowHeaderContextMenu"]}}const ln="sheet.menu.paste-special";function bc(){return{id:ln,group:R.MenuGroup.CONTEXT_MENU_FORMAT,type:R.MenuItemType.SUBITEMS,icon:"PasteSpecial",title:"rightClick.pasteSpecial",positions:[R.MenuPosition.CONTEXT_MENU,"colHeaderContextMenu","rowHeaderContextMenu"]}}function Mc(){return{id:To.id,type:R.MenuItemType.BUTTON,title:"rightClick.pasteValue",positions:[ln]}}function wc(){return{id:yo.id,type:R.MenuItemType.BUTTON,title:"rightClick.pasteFormat",positions:[ln]}}function Tc(){return{id:Eo.id,type:R.MenuItemType.BUTTON,title:"rightClick.pasteColWidth",positions:[ln]}}function yc(){return{id:Oo.id,type:R.MenuItemType.BUTTON,title:"rightClick.pasteBesidesBorder",positions:[ln]}}function Ec(){return{id:p.SetWorksheetRowIsAutoHeightCommand.id,group:R.MenuGroup.CONTEXT_MENU_LAYOUT,type:R.MenuItemType.BUTTON,positions:["rowHeaderContextMenu"],icon:"AutoHeight",title:"rightClick.fitContent"}}const An="sheet.menu.sheet-frozen";function Oc(){return{id:An,group:R.MenuGroup.CONTEXT_MENU_LAYOUT,type:R.MenuItemType.SUBITEMS,title:"rightClick.freeze",icon:"FreezeToSelectedSingle",positions:[R.MenuPosition.CONTEXT_MENU]}}const Sr="sheet.header-menu.sheet-frozen";function xc(){return{id:Sr,group:R.MenuGroup.CONTEXT_MENU_LAYOUT,type:R.MenuItemType.SUBITEMS,title:"rightClick.freeze",icon:"FreezeToSelectedSingle",positions:["rowHeaderContextMenu","colHeaderContextMenu"]}}function Ac(){return{id:Ei.id,type:R.MenuItemType.BUTTON,positions:[An,Sr],title:"rightClick.freeze",icon:"FreezeToSelectedSingle"}}function Nc(){return{id:es.id,type:R.MenuItemType.BUTTON,positions:[An],title:"rightClick.freezeRow",icon:"FreezeRowSingle"}}function Dc(){return{id:ts.id,type:R.MenuItemType.BUTTON,positions:[An],title:"rightClick.freezeCol",icon:"FreezeColumnSingle"}}function Pc(){return{id:ns.id,type:R.MenuItemType.BUTTON,positions:[An,Sr],title:"rightClick.cancelFreeze",icon:"CancelFreezeSingle"}}function Hc(){return{id:p.SetRowHiddenCommand.id,group:R.MenuGroup.CONTEXT_MENU_LAYOUT,type:R.MenuItemType.BUTTON,positions:["rowHeaderContextMenu"],icon:"Hide",title:"rightClick.hideSelectedRow"}}function Lc(){return{id:p.SetColHiddenCommand.id,group:R.MenuGroup.CONTEXT_MENU_LAYOUT,type:R.MenuItemType.BUTTON,positions:["colHeaderContextMenu"],icon:"Hide",title:"rightClick.hideSelectedColumn"}}function Uc(i){const e=i.get(l.IUniverInstanceService),t=i.get(p.SelectionManagerService);function n(){var a;const o=e.getCurrentUniverSheetInstance().getActiveSheet(),s=(a=t.getSelections())==null?void 0:a.map(c=>c.range).filter(c=>c.rangeType===l.RANGE_TYPE.ROW);return!!(s!=null&&s.some(c=>{for(let d=c.startRow;d<=c.endRow;d++)if(!o.getRowVisible(d))return!0;return!1}))}const r=i.get(l.ICommandService);return{id:p.SetSelectedRowsVisibleCommand.id,group:R.MenuGroup.CONTEXT_MENU_LAYOUT,type:R.MenuItemType.BUTTON,positions:["rowHeaderContextMenu"],title:"rightClick.showHideRow",hidden$:new J.Observable(o=>{const s=r.onCommandExecuted(a=>{(a.id===p.SetSelectionsOperation.id||a.id===p.SetRowHiddenMutation.id||a.id===p.SetRowVisibleMutation.id)&&o.next(!n())});return o.next(!n()),()=>s.dispose()})}}function kc(i){const e=i.get(l.IUniverInstanceService),t=i.get(p.SelectionManagerService);function n(){var a;const o=e.getCurrentUniverSheetInstance().getActiveSheet(),s=(a=t.getSelections())==null?void 0:a.map(c=>c.range).filter(c=>c.rangeType===l.RANGE_TYPE.COLUMN);return!s||s.length===0?!1:!!s.some(c=>{for(let d=c.startColumn;d<=c.endColumn;d++)if(!o.getColVisible(d))return!0;return!1})}const r=i.get(l.ICommandService);return{id:p.SetSelectedColsVisibleCommand.id,group:R.MenuGroup.CONTEXT_MENU_LAYOUT,type:R.MenuItemType.BUTTON,positions:["colHeaderContextMenu"],title:"rightClick.showHideColumn",hidden$:new J.Observable(o=>{const s=r.onCommandExecuted(a=>{(a.id===p.SetSelectionsOperation.id||a.id===p.SetColHiddenMutation.id||a.id===p.SetColVisibleMutation.id)&&o.next(!n())});return o.next(!n()),()=>s.dispose()})}}function Vc(i){const e=i.get(l.ICommandService),t=i.get(l.IUniverInstanceService),n=i.get(p.SelectionManagerService);return{id:p.SetRowHeightCommand.id,group:R.MenuGroup.CONTEXT_MENU_LAYOUT,type:R.MenuItemType.BUTTON,icon:"AdjustHeight",positions:["rowHeaderContextMenu"],label:{name:fr,props:{prefix:"rightClick.rowHeight",suffix:"px",min:2,max:1e3}},value$:new J.Observable(r=>{function o(){var u;const a=(u=n.getLast())==null?void 0:u.primary,c=t.getCurrentUniverSheetInstance().getActiveSheet();let d;a!=null&&(d=c.getRowHeight(a.startRow)),r.next(d??0)}const s=e.onCommandExecuted(a=>{const c=a.id;if(c===p.SetRangeValuesMutation.id||c===p.SetSelectionsOperation.id)return o()});return o(),s.dispose})}}function Fc(i){const e=i.get(l.ICommandService),t=i.get(l.IUniverInstanceService),n=i.get(p.SelectionManagerService);return{id:p.SetColWidthCommand.id,group:R.MenuGroup.CONTEXT_MENU_LAYOUT,type:R.MenuItemType.BUTTON,icon:"AdjustWidth",positions:["colHeaderContextMenu"],label:{name:fr,props:{prefix:"rightClick.columnWidth",suffix:"px",min:2,max:1e3}},value$:new J.Observable(r=>{function o(){var u;const a=(u=n.getLast())==null?void 0:u.primary,c=t.getCurrentUniverSheetInstance().getActiveSheet();let d=0;a!=null&&(d=c.getColumnWidth(a.startColumn)),r.next(d)}const s=e.onCommandExecuted(a=>{const c=a.id;if(c===p.SetRangeValuesMutation.id||c===p.SetSelectionsOperation.id)return o()});return o(),s.dispose})}}function Nn(i){var c;const e=i.get(l.IUniverInstanceService),t=i.get(pe.TextSelectionManagerService),n=e.getUniverDocInstance(l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY),r=t.getActiveRange();if(n==null||r==null)return;const o=(c=n.getBody())==null?void 0:c.textRuns;if(o==null)return;const{startOffset:s}=r;return o.find(({st:d,ed:u})=>s>=d&&s<u)}function qe(i,e){const n=i.getCurrentUniverSheetInstance().getUnitId(),r=e.getRenderById(n);if(r==null)return;const{components:o,mainComponent:s,scene:a,engine:c}=r,d=s,u=o.get(Xe.ROW),h=o.get(Xe.COLUMN),m=o.get(Xe.LEFT_TOP);return{spreadsheet:d,spreadsheetRowHeader:u,spreadsheetColumnHeader:h,spreadsheetLeftTopPlaceholder:m,scene:a,engine:c}}function tr(i,e,t,n){const{startX:r,startY:o,endX:s,endY:a}=n.getCellByIndex(i,e);return{startX:r,startY:o,endX:s,endY:a}}function tn(i,e,t,n,r){const o=t.getRelativeCoord(y.Vector2.FromArray([i,e])),{x:s,y:a}=o,c=t.getScrollXYByRelativeCoords(o,r),{scaleX:d,scaleY:u}=t.getAncestorScale(),h=n.getCellPositionByOffset(s,a,d,u,c),{row:m,column:g}=h,_=n.getNoMergeCellPositionByIndex(m,g),{startX:f,startY:C,endX:I,endY:w}=_;return{startX:f,startY:C,endX:I,endY:w,row:m,column:g}}function $n(i,e,t,n){const r=t.getRelativeCoord(y.Vector2.FromArray([i,e])),o=t.getViewport(Q.VIEW_MAIN),s=t.getScrollXYByRelativeCoords(r,o),{scaleX:a,scaleY:c}=t.getAncestorScale(),{x:d,y:u}=s,h=i/a+d,m=e/c+u;return{x:h,y:m}}const Bc={spreadsheetLabel:"Spreadsheet",spreadsheetRightLabel:"more Sheets",toolbar:{undo:"Undo",redo:"Redo",formatPainter:"Paint format",currencyFormat:"Format as currency",percentageFormat:"Format as percent",numberDecrease:"Decrease decimal places",numberIncrease:"Increase decimal places",moreFormats:"More formats",font:"Font",fontSize:"Font size",bold:"Bold",italic:"Italic",strikethrough:"Strikethrough",subscript:"Subscript",superscript:"Superscript",underline:"Underline",textColor:{main:"Text color",right:"Choose color"},resetColor:"Reset",customColor:"CUSTOM",alternatingColors:"Alternating colors",confirmColor:"OK",cancelColor:"Cancel",collapse:"Collapse",fillColor:{main:"Fill color",right:"Choose color"},border:{main:"Border",right:"Border style"},mergeCell:{main:"Merge cells",right:"Choose merge type"},horizontalAlignMode:{main:"Horizontal align",right:"Alignment"},verticalAlignMode:{main:"Vertical align",right:"Alignment"},textWrapMode:{main:"Text wrap",right:"Text wrap mode"},textRotateMode:{main:"Text rotate",right:"Text rotate mode"},freezeTopRow:"Freeze top row",sortAndFilter:"Sort and filter",findAndReplace:"Find and replace",sum:"SUM",autoSum:"Auto SUM",moreFunction:"More functions",conditionalFormat:"Conditional format",comment:"Comment",pivotTable:"Pivot Table",chart:"Chart",screenshot:"Screenshot",splitColumn:"Split text",insertImage:"Insert image",insertLink:"Insert link",dataValidation:"Data validation",protection:"Protect the sheet",clearText:"Clear color",noColorSelectedText:"No color is selected",toolMore:"More",toolLess:"Less",toolClose:"Close",toolMoreTip:"More features",moreOptions:"More options",cellFormat:"Cell format config",print:"Print",borderMethod:{top:"Upper frame line",bottom:"Lower frame line",left:"Left frame line",right:"Right frame line"},more:"More"},defaultFmt:{Automatic:{text:"Automatic",value:"General",example:""},Number:{text:"Number",value:"##0.00",example:"1000.12"},Percent:{text:"Percent",value:"#0.00%",example:"12.21%"},PlainText:{text:"Plain text",value:"@",example:""},Scientific:{text:"Scientific",value:"0.00E+00",example:"1.01E+5"},Accounting:{text:"Accounting",value:"¥(0.00)",example:"¥(1200.09)"},Thousand:{text:"Ten Thousand",value:"w",example:"1亿2000万2500"},Currency:{text:"Currency",value:"¥0.00",example:"¥1200.09"},Digit:{text:"万元2位小数",value:"w0.00",example:"2万2500.55"},Date:{text:"Date",value:"yyyy-MM-dd",example:"2017-11-29"},Time:{text:"Time",value:"hh:mm AM/PM",example:"3:00 PM"},Time24H:{text:"Time 24H",value:"hh:mm",example:"15:00"},DateTime:{text:"Date time",value:"yyyy-MM-dd hh:mm AM/PM",example:"2017-11-29 3:00 PM"},DateTime24H:{text:"Date time 24H",value:"yyyy-MM-dd hh:mm",example:"2017-11-29 15:00"},CustomFormats:{text:"Custom Formats",value:"fmtOtherSelf",example:""}},format:{moreCurrency:"More currency formats",moreDateTime:"More date and time formats",moreNumber:"More number formats",titleCurrency:"Currency formats",decimalPlaces:"Decimal places",titleDateTime:"Date and time formats",titleNumber:"Number formats"},fontFamily:{TimesNewRoman:"Times New Roman",Arial:"Arial",Tahoma:"Tahoma",Verdana:"Verdana",MicrosoftYaHei:"Microsoft YaHei",SimSun:"SimSun",SimHei:"SimHei",Kaiti:"Kaiti",FangSong:"FangSong",NSimSun:"NSimSun",STXinwei:"STXinwei",STXingkai:"STXingkai",STLiti:"STLiti",HanaleiFill:"HanaleiFill",Anton:"Anton",Pacifico:"Pacifico"},print:{normalBtn:"Normal",layoutBtn:"Page Layout",pageBtn:"Page break preview",menuItemPrint:"Print (Ctrl+P)",menuItemAreas:"Print areas",menuItemRows:"Print title rows",menuItemColumns:"Print title columns"},align:{left:"left",center:"center",right:"right",top:"top",middle:"middle",bottom:"bottom"},dateFmtList:[{name:"1930-08-05",value:"yyyy-MM-dd"},{name:"1930/8/5",value:"yyyy/MM/dd"},{name:"08-05",value:"MM-dd"},{name:"8-5",value:"M-d"},{name:"13:30:30",value:"h:mm:ss"},{name:"13:30",value:"h:mm"},{name:"PM 01:30",value:"AM/PM hh:mm"},{name:"PM 1:30",value:"AM/PM h:mm"},{name:"PM 1:30:30",value:"AM/PM h:mm:ss"},{name:"08-05 PM 01:30",value:"MM-dd AM/PM hh:mm"}],numFmtList:[{name:"1235",value:"0"},{name:"1234.56",value:"0.00"},{name:"1,235",value:"#,##0"},{name:"1,234.56",value:"#,##0.00"},{name:"1,235",value:"#,##0_);(#,##0)"},{name:"1,235",value:"#,##0_);[Red](#,##0)"},{name:"1,234.56",value:"#,##0.00_);(#,##0.00)"},{name:"1,234.56",value:"#,##0.00_);[Red](#,##0.00)"},{name:"$1,235",value:"$#,##0_);($#,##0)"},{name:"$1,235",value:"$#,##0_);[Red]($#,##0)"},{name:"$1,234.56",value:"$#,##0.00_);($#,##0.00)"},{name:"$1,234.56",value:"$#,##0.00_);[Red]($#,##0.00)"},{name:"1234.56",value:"@"},{name:"123456%",value:"0%"},{name:"123456.00%",value:"0.00%"},{name:"1.23E+03",value:"0.00E+00"},{name:"1.2E+3",value:"##0.0E+0"},{name:"1234 5/9",value:"# ?/?"},{name:"1234 14/25",value:"# ??/??"},{name:"$ 1,235",value:'_($* #,##0_);_(...($* "-"_);_(@_)'},{name:"1,235",value:'_(* #,##0_);_(*..._(* "-"_);_(@_)'},{name:"$ 1,234.56",value:'_($* #,##0.00_);_(...($* "-"_);_(@_)'},{name:"1,234.56",value:'_(* #,##0.00_);...* "-"??_);_(@_)'}],button:{confirm:"OK",cancel:"Cancel",close:"Close",update:"Update",delete:"Delete",insert:"Insert",prevPage:"Previous",nextPage:"Next",total:"total:"},punctuation:{tab:"Tab",semicolon:"semicolond",comma:"comma",space:"space"},colorPicker:{collapse:"Collapse",customColor:"CUSTOM",change:"Change",confirmColor:"OK",cancelColor:"Cancel"},borderLine:{borderTop:"borderTop",borderBottom:"borderBottom",borderLeft:"borderLeft",borderRight:"borderRight",borderNone:"borderNone",borderAll:"borderAll",borderOutside:"borderOutside",borderInside:"borderInside",borderHorizontal:"borderHorizontal",borderVertical:"borderVertical",borderColor:"borderColor",borderSize:"borderSize",borderType:"borderType"},merge:{all:"Merge all",vertical:"Vertical merge",horizontal:"Horizontal merge",cancel:"Cancel merge",overlappingError:"Cannot merge overlapping areas",partiallyError:"Cannot perform this operation on partially merged cells",confirm:{title:"Continue merging would only keep the upper-left cell value, discard other values. Are you sure to continue?",cancel:"Cancel merging",confirm:"Continue merging"}},textWrap:{overflow:"Overflow",wrap:"Wrap",clip:"Clip"},textRotate:{none:"None",angleUp:"Tilt Up",angleDown:"Tilt Down",vertical:"Stack Vertically",rotationUp:"Rotate Up",rotationDown:"Rotate Down"},sheetConfig:{delete:"Delete",copy:"Copy",rename:"Rename",changeColor:"Change color",hide:"Hide",unhide:"Unhide",moveLeft:"Move left",moveRight:"Move right",resetColor:"Reset color",cancelText:"Cancel",chooseText:"Confirm color",tipNameRepeat:"The name of the tab page cannot be repeated! Please revise",noMoreSheet:"The workbook contains at least one visual worksheet. To delete the selected worksheet, please insert a new worksheet or show a hidden worksheet.",confirmDelete:"Are you sure to delete",redoDelete:"Can be undo by Ctrl+Z",noHide:"Can't hide, at least keep one sheet tag",chartEditNoOpt:"This operation is not allowed in chart editing mode!",sheetNameErrorTitle:"There was a problem",sheetNameSpecCharError:`The name cannot contain:[ ] : ? * / ' "`,sheetNameCannotIsEmptyError:"The sheet name cannot be empty.",sheetNameAlreadyExistsError:"The sheet name already exists. Please enter another name.",deleteSheet:"Delete worksheet",deleteSheetContent:"Confirm to delete this worksheet. It will not be retrieved after deletion. Are you sure you want to delete it?"},rightClick:{copy:"Copy",copyAs:"Copy as",cut:"Cut",paste:"Paste",pasteSpecial:"Paste Special",pasteValue:"Paste Value",pasteFormat:"Paste Format",pasteColWidth:"Paste Column Width",pasteBesidesBorder:"Paste Besides Border Styles",insert:"Insert",insertRow:"Insert Row",insertRowBefore:"Insert Row Before",insertColumn:"Insert Column",insertColumnBefore:"Insert Column Before",delete:"Delete",deleteCell:"Delete Cell",insertCell:"Insert Cell",deleteSelected:"Delete Selected ",hide:"Hide",hideSelected:"Hide Selected ",showHide:"Show Hidden",toTopAdd:"Towards Top Add",toBottomAdd:"Towards Bottom Add",toLeftAdd:"Towards Left Add",toRightAdd:"Towards Right Add",deleteSelectedRow:"Delete Selected row",deleteSelectedColumn:"Delete Selected column",hideSelectedRow:"Hide Selected Row",showHideRow:"Show Selected Row",rowHeight:"Row Height",hideSelectedColumn:"Hide Selected Column",showHideColumn:"Show Hide Column",columnWidth:"Column Width",to:"Towards",left:"Left",right:"Right",top:"Top",bottom:"Bottom",moveLeft:"Move Left",moveUp:"Move up",moveRight:"Move Right",moveDown:"Move Down",add:"Add",row:"Row",column:"Column",width:"Width",height:"Height",number:"Number",confirm:"Confirm",orderAZ:"A-Z order",orderZA:"Z-A order",clearSelection:"Clear",clearContent:"Clear Contents",clearFormat:"Clear Formats",clearAll:"Clear All",matrix:"Matrix operation",sortSelection:"Sort",filterSelection:"Filter",chartGeneration:"Create Chart",firstLineTitle:"First Line Title",untitled:"Untitled",array1:"One-dimensional array",array2:"Two-dimensional array",array3:"Multidimensional Arrays",diagonal:"Diagonal",antiDiagonal:"Anti-diagonal",diagonalOffset:"Diagonal offset",offset:"Offset",boolean:"Boolean",flip:"Flip",upAndDown:"Up and down",leftAndRight:"Left and right",clockwise:"Clockwise",counterclockwise:"Counterclockwise",transpose:"Transpose",matrixCalculation:"Matrix Calculation",plus:"Plus",minus:"Minus",multiply:"Multiply",divided:"Divided",power:"Power",root:"Root",log:"Log",delete0:"Delete 0 values at both ends",removeDuplicate:"Remove duplicate values",byRow:"By row",byCol:"By column",generateNewMatrix:"Generate new matrix",fitContent:"Fit for data",freeze:"Freeze",freezeCol:"Freeze to this column",freezeRow:"Freeze to this row",cancelFreeze:"Cancel freeze",zenEditor:"Full Screen Editor"},info:{tooltip:"Tooltip",notChangeMerge:"You cannot make partial changes to the merged cells",detailUpdate:"New opened",detailSave:"Local cache restored",row:"",column:"",loading:"Loading...",copy:"Copy",return:"Exit",rename:"Rename",tips:"Rename",noName:"Untitled spreadsheet",wait:"waiting for update",add:"Add",addLast:"more rows at bottom",backTop:"Back to the top",pageInfo:"Total ${total},${totalPage} page,current ${currentPage}",nextPage:"Next",tipInputNumber:"Please enter the number",tipInputNumberLimit:"The increase range is limited to 1-100",tipRowHeightLimit:"Row height must be between 0 ~ 545",tipColumnWidthLimit:"The column width must be between 0 ~ 2038",pageInfoFull:"Total ${total},${totalPage} page,All data displayed"},clipboard:{paste:{exceedMaxCells:"The number of cells pasted exceeds the maximum number of cells"}},statusbar:{sum:"Sum",average:"Average",min:"Min",max:"Max",count:"Numerical Count",countA:"Count",clickToCopy:"Click to Copy",copied:"Copied"},autoFill:{copy:"Copy Cell",series:"Fill Series",formatOnly:"Format Only",noFormat:"No Format"},rangeSelector:{placeholder:"Select range or input value",tooltip:"Select range"},shortcut:{sheet:{"zoom-in":"Zoom in","zoom-out":"Zoom out","reset-zoom":"Reset zoom level","select-below-cell":"Select the cell below","select-up-cell":"Select the cell above","select-left-cell":"Select the left cell","select-right-cell":"Select the right cell","select-next-cell":"Select the next cell","select-previous-cell":"Select the previous cell","select-up-value-cell":"Select the cell above that has value","select-below-value-cell":"Select the cell below that has value","select-left-value-cell":"Select the cell left that has value","select-right-value-cell":"Select the cell right that has value","expand-selection-down":"Expand selection down","expand-selection-up":"Expand selection up","expand-selection-left":"Expand selection left","expand-selection-right":"Expand selection right","expand-selection-to-left-gap":"Expand selection to the left gap","expand-selection-to-below-gap":"Expand selection to the below gap","expand-selection-to-right-gap":"Expand selection to the right gap","expand-selection-to-up-gap":"Expand selection to the up gap","select-all":"Select all","toggle-editing":"Toggle editing","delete-and-start-editing":"Clear and start editing","abort-editing":"Abort editing","break-line":"Break line","set-bold":"Toggle bold","set-italic":"Toggle italic","set-underline":"Toggle underline","set-strike-through":"Toggle strike through"}},"sheet-view":"Sheet View","sheet-edit":"Sheet Edit"},ss={spreadsheetLabel:"插件",spreadsheetRightLabel:"更多 Sheets",toolbar:{undo:"撤销",redo:"重做",formatPainter:"格式刷",currencyFormat:"货币格式",percentageFormat:"百分比格式",numberDecrease:"减少小数位数",numberIncrease:"增加小数位数",moreFormats:"更多格式",font:"字体",fontSize:"字号",bold:"粗体",italic:"斜体",strikethrough:"删除线",subscript:"下标",superscript:"上标",underline:"下划线",textColor:{main:"文本颜色",right:"颜色选择"},resetColor:"重置颜色",customColor:"自定义",alternatingColors:"交替颜色",confirmColor:"确定颜色",cancelColor:"取消",collapse:"收起",fillColor:{main:"单元格颜色",right:"颜色选择"},border:{main:"边框",right:"边框类型"},mergeCell:{main:"合并单元格",right:"选择合并类型"},horizontalAlignMode:{main:"水平对齐",right:"对齐方式"},verticalAlignMode:{main:"垂直对齐",right:"对齐方式"},textWrapMode:{main:"文本换行",right:"换行方式"},textRotateMode:{main:"文本旋转",right:"旋转方式"},freezeTopRow:"冻结首行",sortAndFilter:"排序和筛选",findAndReplace:"查找替换",sum:"求和",autoSum:"自动求和",moreFunction:"更多函数",conditionalalFormat:"条件格式",comment:"批注",pivotTable:"数据透视表",chart:"图表",screenshot:"截图",splitColumn:"分列",insertImage:"插入图片",insertLink:"插入链接",dataValidation:"数据验证",protection:"保护工作表内容",clearText:"清除颜色选择",noColorSelectedText:"没有颜色被选择",toolMore:"更多",toolLess:"少于",toolClose:"收起",toolMoreTip:"更多功能",moreOptions:"更多选项",cellFormat:"设置单元格格式",print:"打印",borderMethod:{top:"上框线",bottom:"下框线",left:"左框线",right:"右框线"},more:"更多"},defaultFmt:{Automatic:{text:"自动",value:"General",example:""},Number:{text:"数字",value:"##0.00",example:"1000.12"},Percent:{text:"百分比",value:"#0.00%",example:"12.21%"},PlainText:{text:"纯文本",value:"@",example:""},Scientific:{text:"科学计数",value:"0.00E+00",example:"1.01E+5"},Accounting:{text:"会计",value:"¥(0.00)",example:"¥(1200.09)"},Thousand:{text:"万元",value:"w",example:"1亿2000万2500"},Currency:{text:"货币",value:"¥0.00",example:"¥1200.09"},Digit:{text:"万元2位小数",value:"w0.00",example:"2万2500.55"},Date:{text:"日期",value:"yyyy-MM-dd",example:"2017-11-29"},Time:{text:"时间",value:"hh:mm AM/PM",example:"3:00 PM"},Time24H:{text:"时间24H",value:"hh:mm",example:"15:00"},DateTime:{text:"日期时间",value:"yyyy-MM-dd hh:mm AM/PM",example:"2017-11-29 3:00 PM"},DateTime24H:{text:"日期时间24H",value:"yyyy-MM-dd hh:mm",example:"2017-11-29 15:00"},CustomFormats:{text:"自定义格式",value:"fmtOtherSelf",example:""}},format:{moreCurrency:"更多货币格式",moreDateTime:"更多日期与时间格式",moreNumber:"更多数字格式",titleCurrency:"货币格式",decimalPlaces:"小数位数",titleDateTime:"日期与时间格式",titleNumber:"数字格式"},fontFamily:{TimesNewRoman:"Times New Roman",Arial:"Arial",Tahoma:"Tahoma",Verdana:"Verdana",MicrosoftYaHei:"微软雅黑",SimSun:"宋体",SimHei:"黑体",Kaiti:"楷体",FangSong:"仿宋",NSimSun:"新宋体",STXinwei:"华文新魏",STXingkai:"华文行楷",STLiti:"华文隶书",HanaleiFill:"HanaleiFill",Anton:"Anton",Pacifico:"Pacifico"},print:{normalBtn:"常规视图",layoutBtn:"页面布局",pageBtn:"分页预览",menuItemPrint:"打印(Ctrl+P)",menuItemAreas:"打印区域",menuItemRows:"打印标题行",menuItemColumns:"打印标题列"},align:{left:"左对齐",center:"中间对齐",right:"右对齐",top:"顶部对齐",middle:"居中对齐",bottom:"底部对齐"},button:{confirm:"确定",cancel:"取消",close:"关闭",update:"Update",delete:"Delete",insert:"新建",prevPage:"上一页",nextPage:"下一页",total:"总共:"},punctuation:{tab:"Tab 键",semicolon:"分号",comma:"逗号",space:"空格"},colorPicker:{collapse:"收起",customColor:"自定义",change:"切换",confirmColor:"确定",cancelColor:"取消"},borderLine:{borderTop:"上框线",borderBottom:"下框线",borderLeft:"左框线",borderRight:"右框线",borderNone:"无",borderAll:"所有",borderOutside:"外侧",borderInside:"内侧",borderHorizontal:"内侧横线",borderVertical:"内侧竖线",borderColor:"边框颜色",borderSize:"边框粗细",borderType:"边框线类型"},merge:{all:"全部合并",vertical:"垂直合并",horizontal:"水平合并",cancel:"取消合并",overlappingError:"不能合并重叠区域",partiallyError:"无法对部分合并单元格执行此操作",confirm:{title:"合并单元格仅保存左上角单元格的值,是否继续?",cancel:"取消合并",confirm:"继续合并"}},textWrap:{overflow:"溢出",wrap:"自动换行",clip:"截断"},textRotate:{none:"无旋转",angleUp:"向上倾斜",angleDown:"向下倾斜",vertical:"竖排文字",rotationUp:"向上90°",rotationDown:"向下90°"},sheetConfig:{delete:"删除",copy:"复制",rename:"重命名",changeColor:"更改颜色",hide:"隐藏",unhide:"取消隐藏",moveLeft:"向左移",moveRight:"向右移",resetColor:"重置颜色",cancelText:"取消",chooseText:"确定颜色",tipNameRepeat:"标签页的名称不能重复!请重新修改",noMoreSheet:"工作薄内至少含有一张可视工作表。若需删除选定的工作表,请先插入一张新工作表或显示一张隐藏的工作表。",confirmDelete:"是否删除",redoDelete:"可以通过Ctrl+Z撤销删除",noHide:"不能隐藏, 至少保留一个sheet标签",chartEditNoOpt:"图表编辑模式下不允许该操作!",sheetNameErrorTitle:"错误",sheetNameSpecCharError:`名称不能超过31个字符,首尾不能是' 且名称不能包含:\r
18
+ [ ] : \\ ? * /`,sheetNameCannotIsEmptyError:"名称不能为空。",sheetNameAlreadyExistsError:"工作表已存在,请输入其它名称。",deleteSheet:"删除工作表",deleteSheetContent:"确认删除此工作表,删除后将不可找回,确定要删除吗?"},rightClick:{copy:"复制",copyAs:"复制为",cut:"剪切",paste:"粘贴",pasteSpecial:"选择性粘贴",pasteValue:"仅粘贴值",pasteFormat:"仅粘贴格式",pasteColWidth:"仅粘贴列宽",pasteBesidesBorder:"仅粘贴边框以外内容",insert:"插入",delete:"删除",insertRow:"插入行",insertRowBefore:"在上方插入行",insertColumn:"插入列",insertColumnBefore:"在左侧插入列",deleteCell:"删除单元格",insertCell:"插入单元格",deleteSelected:"删除选中",hide:"隐藏",hideSelected:"隐藏选中",showHide:"显示隐藏",toTopAdd:"向上增加",toBottomAdd:"向下增加",toLeftAdd:"向左增加",toRightAdd:"向右增加",deleteSelectedRow:"删除选中行",deleteSelectedColumn:"删除选中列",hideSelectedRow:"隐藏选中行",showHideRow:"显示隐藏行",rowHeight:"行高",hideSelectedColumn:"隐藏选中列",showHideColumn:"显示隐藏列",columnWidth:"列宽",to:"向",left:"左",right:"右",top:"上",bottom:"下",moveLeft:"左移",moveUp:"上移",moveRight:"右移",moveDown:"下移",add:"增加",row:"行",column:"列",width:"宽",height:"高",number:"数字",confirm:"确认",orderAZ:"A-Z顺序排列",orderZA:"Z-A降序排列",clearSelection:"清除",clearContent:"清除内容",clearFormat:"清除格式",clearAll:"清除全部",matrix:"矩阵操作选区",sortSelection:"排序选区",filterSelection:"筛选选区",chartGeneration:"图表生成",firstLineTitle:"首行为标题",untitled:"无标题",array1:"一维数组",array2:"二维数组",array3:"多维数组",diagonal:"对角线",antiDiagonal:"反对角线",diagonalOffset:"对角偏移",offset:"偏移量",boolean:"布尔值",flip:"翻转",upAndDown:"上下",leftAndRight:"左右",clockwise:"顺时针",counterclockwise:"逆时针",transpose:"转置",matrixCalculation:"矩阵计算",plus:"加",minus:"减",multiply:"乘",divided:"除",power:"次方",root:"次方根",log:"log",delete0:"删除两端0值",removeDuplicate:"删除重复值",byRow:"按行",byCol:"按列",generateNewMatrix:"生成新矩阵",fitContent:"适合数据",freeze:"冻结",freezeCol:"冻结列",freezeRow:"冻结行",cancelFreeze:"取消冻结",zenEditor:"禅模式编辑"},info:{tooltip:"提示",notChangeMerge:"不能对合并单元格做部分更改",detailUpdate:"新打开",detailSave:"已恢复本地缓存",row:"行",column:"列",loading:"渲染中···",copy:"副本",return:"返回",rename:"重命名",tips:"重命名",noName:"无标题的电子表格",wait:"待更新",add:"添加",addLast:"在底部添加",backTop:"回到顶部",pageInfo:"共${total}条,${totalPage}页,当前已显示${currentPage}页",nextPage:"下一页",tipInputNumber:"请输入数字",tipInputNumberLimit:"增加范围限制在1-100",tipRowHeightLimit:"行高必须在0 ~ 545之间",tipColumnWidthLimit:"列宽必须在0 ~ 2038之间",pageInfoFull:"共${total}条,${totalPage}页,已显示全部数据"},clipboard:{paste:{exceedMaxCells:"粘贴区域超出最大单元格数"}},statusbar:{sum:"求和",average:"平均值",min:"最小值",max:"最大值",count:"数值计数",countA:"计数",clickToCopy:"点击复制数值",copied:"已复制"},autoFill:{copy:"复制单元格",series:"填充序列",formatOnly:"仅填充格式",noFormat:"不带格式填充"},rangeSelector:{placeholder:"选择范围或输入值",tooltip:"选择范围"},shortcut:{sheet:{"zoom-in":"放大","zoom-out":"缩小","reset-zoom":"恢复缩放","select-below-cell":"选择下方单元格","select-up-cell":"选择上方单元格","select-left-cell":"选择左侧单元格","select-right-cell":"选择右侧单元格","select-next-cell":"选择后一个单元格","select-previous-cell":"选择前一个单元格","select-up-value-cell":"选择上方有值的单元格","select-below-value-cell":"选择下方有值的单元格","select-left-value-cell":"选择左侧有值的单元格","select-right-value-cell":"选择右侧有值的单元格","expand-selection-down":"向下扩展选区","expand-selection-up":"向上扩展选区","expand-selection-left":"向左扩展选区","expand-selection-right":"向右扩展选区","expand-selection-to-left-gap":"向左扩展选区到下一个边界","expand-selection-to-below-gap":"向下扩展选区到下一个边界","expand-selection-to-right-gap":"向右扩展选区到下一个边界","expand-selection-to-up-gap":"向上扩展选区到下一个边界","select-all":"全选","toggle-editing":"开始 / 结束编辑","delete-and-start-editing":"清空并开始编辑","abort-editing":"放弃编辑","break-line":"换行","set-bold":"切换粗体","set-italic":"切换斜体","set-underline":"切换下划线","set-strike-through":"切换删除线"}},"sheet-view":"浏览表格","sheet-edit":"编辑表格"},jc=(i,e,t=!1)=>{const n=h=>h.endRow-h.startRow+1,r=h=>h.endColumn-h.startColumn+1,o=n(e)%n(i),s=r(e)%r(i),a={startRow:0,endRow:n(i)-1,startColumn:0,endColumn:r(i)-1},c=Math.floor(n(e)/n(i)),d=Math.floor(r(e)/r(i)),u=[];if(!o&&!s)for(let h=1;h<=c;h++)for(let m=1;m<=d;m++){const g=n(i)*(h-1),_=r(i)*(m-1),f={startRow:g+e.startRow,endRow:g+e.startRow,startColumn:_+e.startColumn,endColumn:_+e.startColumn};u.push({repeatRelativeRange:a,startRange:f})}else if(!o&&s&&!t)for(let h=1;h<=c;h++){const m=n(i)*(h-1),g=0,_={startRow:m+e.startRow,endRow:m+e.startRow,startColumn:g+e.startColumn,endColumn:g+e.startColumn};u.push({repeatRelativeRange:a,startRange:_})}else if(o&&!s&&!t)for(let h=1;h<=d;h++){const g=r(i)*(h-1),_={startRow:0+e.startRow,endRow:0+e.startRow,startColumn:g+e.startColumn,endColumn:g+e.startColumn};u.push({repeatRelativeRange:a,startRange:_})}else{const h={startRow:e.startRow,endRow:e.startRow,startColumn:e.startColumn,endColumn:e.startColumn};u.push({startRange:h,repeatRelativeRange:a})}return u};class as{constructor(){v(this,"_state",null);v(this,"_rect",null);v(this,"_focus",!1);v(this,"_state$",new J.BehaviorSubject(null));v(this,"state$",this._state$.asObservable());v(this,"_rect$",new J.BehaviorSubject(null));v(this,"rect$",this._rect$.asObservable());v(this,"_focus$",new J.BehaviorSubject(this._focus));v(this,"focus$",this._focus$.asObservable())}dispose(){this._state$.complete(),this._state=null,this._rect$.complete(),this._rect=null}setState(e){this._state=e,this._refresh(e)}getRect(){return this._rect}setRect(e){this._rect=e,this._rect$.next(e)}getState(){return this._state}setFocus(e=!1){this._focus=e,this._focus$.next(e)}_refresh(e){this._state$.next(e)}}const Dn=j.createIdentifier("univer.sheet-cell-editor-manager.service");class Wc{constructor(){v(this,"_position",null);v(this,"_position$",new J.BehaviorSubject(null));v(this,"position$",this._position$.asObservable());v(this,"_focus",!1);v(this,"_focus$",new J.BehaviorSubject(this._focus));v(this,"focus$",this._focus$.asObservable());v(this,"_fxBtnClick$",new J.BehaviorSubject(!1));v(this,"fxBtnClick$",this._fxBtnClick$.asObservable());v(this,"_foldBtnStatus$",new J.BehaviorSubject(!1));v(this,"foldBtnStatus$",this._foldBtnStatus$.asObservable())}dispose(){this._position$.complete(),this._focus$.complete(),this._position=null,this._focus=!1}setPosition(e){this._position=e,this._refresh(e)}getPosition(){return this._position}setFocus(e=!1){this._focus=e,this._focus$.next(e)}handleFxBtnClick(e){this._fxBtnClick$.next(e)}handleFoldBtnClick(e){this._foldBtnStatus$.next(e)}_refresh(e){this._position$.next(e)}}const xi=j.createIdentifier("univer.sheet-formula-editor-manager.service");var zc=Object.defineProperty,$c=Object.getOwnPropertyDescriptor,Yc=(i,e,t,n)=>{for(var r=n>1?void 0:n?$c(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&zc(e,t,r),r},Gr=(i,e)=>(t,n)=>e(t,n,i);let Yn=class extends l.Disposable{constructor(e,t){super();v(this,"_previousSheetIndex",-1);this._commandService=e,this._univerInstanceService=t,this.disposeWithMe(this._commandService.beforeCommandExecuted((n,r)=>{if(n.id===p.RemoveSheetMutation.id)return this._beforeAdjustActiveSheetOnRemoveSheet(n)})),this.disposeWithMe(this._commandService.onCommandExecuted((n,r)=>{if(n.id===p.RemoveSheetMutation.id)return this._adjustActiveSheetOnRemoveSheet(n);if(n.id===p.SetWorksheetHideMutation.id&&n.params.hidden)return this._adjustActiveSheetOnHideSheet(n);if(!(r!=null&&r.fromCollab)){if(n.id===p.InsertSheetMutation.id)return this._adjustActiveSheetOnInsertSheet(n);if(n.id===p.SetWorksheetHideMutation.id&&!n.params.hidden)return this._adjustActiveSheetOnShowSheet(n)}}))}_adjustActiveSheetOnHideSheet(e){const{unitId:t,subUnitId:n}=e.params,r=this._univerInstanceService.getUniverSheetInstance(t);if(!r||(r==null?void 0:r.getRawActiveSheet())!==n)return;const s=r.getActiveSheetIndex(),a=Xc(r,s);this._switchToNextSheet(t,a)}_beforeAdjustActiveSheetOnRemoveSheet(e){const{unitId:t,subUnitId:n}=e.params,r=this._univerInstanceService.getUniverSheetInstance(t);if(!r)return;const o=r.getSheetBySheetId(n);o&&(this._previousSheetIndex=r.getSheetIndex(o))}_adjustActiveSheetOnRemoveSheet(e){if(this._previousSheetIndex===-1)return;const{unitId:t}=e.params,n=this._univerInstanceService.getUniverSheetInstance(t);if(!n||n.getRawActiveSheet())return;const o=this._previousSheetIndex,s=o>=1?o-1:0,a=n.getSheetByIndex(s);if(!a)throw new Error("[ActiveWorksheetController]: cannot find the next sheet!");this._switchToNextSheet(t,a.getSheetId())}_adjustActiveSheetOnInsertSheet(e){const{unitId:t,sheet:n}=e.params;this._switchToNextSheet(t,n.id)}_adjustActiveSheetOnShowSheet(e){const{unitId:t,subUnitId:n}=e.params;this._switchToNextSheet(t,n)}_switchToNextSheet(e,t){this._commandService.executeCommand(p.SetWorksheetActiveOperation.id,{unitId:e,subUnitId:t})}};Yn=Yc([l.OnLifecycle(l.LifecycleStages.Ready,Yn),Gr(0,l.ICommandService),Gr(1,l.IUniverInstanceService)],Yn);function Xc(i,e){const t=i.getSheetSize();for(let n=e;n>-1;n--){const r=i.getSheetByIndex(n);if(!r.getConfig().hidden)return r.getSheetId()}for(let n=e;n<t;n++){const r=i.getSheetByIndex(n);if(!r.getConfig().hidden)return r.getSheetId()}throw new Error("[ActiveWorksheetController]: could not find the next unhidden sheet! Collaboration error perhaps.")}var Zc=Object.defineProperty,Gc=Object.getOwnPropertyDescriptor,Kc=(i,e,t,n)=>{for(var r=n>1?void 0:n?Gc(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&Zc(e,t,r),r},gn=(i,e)=>(t,n)=>e(t,n,i);let Xn=class{constructor(i,e,t,n,r){this._injector=i,this._sheetInterceptorService=e,this._selectionManagerService=t,this._univerInstanceService=n,this._sheetSkeletonManagerService=r,this._initialize()}_getUndoRedoParamsOfAutoHeight(i){const{_univerInstanceService:e,_sheetSkeletonManagerService:t,_injector:n}=this,{skeleton:r}=t.getCurrent(),o=r.calculateAutoHeightInRange(i),s=e.getCurrentUniverSheetInstance(),a=s.getUnitId(),d={subUnitId:s.getActiveSheet().getSheetId(),unitId:a,rowsAutoHeightInfo:o},u=p.SetWorksheetRowAutoHeightMutationFactory(n,d);return{undos:[{id:p.SetWorksheetRowAutoHeightMutation.id,params:u}],redos:[{id:p.SetWorksheetRowAutoHeightMutation.id,params:d}]}}_initialize(){const{_sheetInterceptorService:i,_selectionManagerService:e}=this;i.interceptCommand({getMutations:t=>t.id!==p.SetRangeValuesCommand.id?{redos:[],undos:[]}:this._getUndoRedoParamsOfAutoHeight(t.params.range)}),i.interceptCommand({getMutations:t=>t.id!==p.SetWorksheetRowIsAutoHeightCommand.id?{redos:[],undos:[]}:this._getUndoRedoParamsOfAutoHeight(t.params.ranges)}),i.interceptCommand({getMutations:t=>{var o;if(t.id!==p.SetStyleCommand.id)return{redos:[],undos:[]};if(!["ff","fs","tr","tb"].includes((o=t.params)==null?void 0:o.style.type))return{redos:[],undos:[]};const r=e.getSelectionRanges();return r!=null&&r.length?this._getUndoRedoParamsOfAutoHeight(r):{redos:[],undos:[]}}})}};Xn=Kc([l.OnLifecycle(l.LifecycleStages.Ready,Xn),gn(0,j.Inject(j.Injector)),gn(1,j.Inject(p.SheetInterceptorService)),gn(2,j.Inject(p.SelectionManagerService)),gn(3,j.Inject(l.IUniverInstanceService)),gn(4,j.Inject(exports.SheetSkeletonManagerService))],Xn);var qc=Object.defineProperty,Jc=Object.getOwnPropertyDescriptor,Qc=(i,e,t,n)=>{for(var r=n>1?void 0:n?Jc(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&qc(e,t,r),r},yt=(i,e)=>(t,n)=>e(t,n,i);let Zn=class extends l.Disposable{constructor(i,e,t,n,r,o,s,a){super(),this._currentUniverSheet=i,this._commandService=e,this._configService=t,this._sheetClipboardService=n,this._messageService=r,this._sheetSkeletonManagerService=o,this._injector=s,this._localService=a,this._init()}_init(){[wo,Pa,rn].forEach(e=>this.disposeWithMe(this._commandService.registerMultipleCommand(e))),[To,yo,Eo,Oo].forEach(e=>this.disposeWithMe(this._commandService.registerCommand(e))),this.disposeWithMe(this._sheetClipboardService.addClipboardHook(this._initCopyingHooks())),this.disposeWithMe(this._sheetClipboardService.addClipboardHook(this._initPastingHook()));const i=this._initSpecialPasteHooks().map(e=>this._sheetClipboardService.addClipboardHook(e));this.disposeWithMe({dispose:()=>i.forEach(e=>e.dispose())})}_initCopyingHooks(){const i=this;let e=null;return{id:Ke.DEFAULT_COPY,isDefaultHook:!0,onBeforeCopy(t,n){e=i._getWorksheet(t,n)},onCopyCellContent(t,n){const r=e.getCell(t,n);return`${(r==null?void 0:r.v)||""}`},onCopyCellStyle:(t,n,r,o)=>{const s={};(r||o)&&(s.rowspan=`${r||1}`,s.colspan=`${o||1}`);const c=e.getRange(t,n).getTextStyle();let d="";return c&&(d=l.handleStyleToString(c)),d&&(s.style=d),s},onCopyColumn(t){return{width:`${e.getColumnWidth(t)}`}},onCopyRow(t){return{style:`height: ${e.getRowHeight(t)}px;`}},onAfterCopy(){e=null}}}_initPastingHook(){const i=this;let e=null,t=null,n=null;return{id:Ke.DEFAULT_PASTE,isDefaultHook:!0,onBeforePaste({unitId:r,subUnitId:o,range:s}){n=i._getWorksheet(r,o),e=r,t=o;const a=i._configService.getConfig(p.MAX_CELL_PER_SHEET_KEY),{endRow:c,endColumn:d}=s;return a&&c*d>a?(i._messageService.show({type:Ye.MessageType.Error,content:i._localService.t("clipboard.paste.exceedMaxCells")}),!1):!0},onPasteRows(r,o){const{range:s}=r,a=[],c=n.getMaxRows(),d=s.endRow-c,u=o.length-d;if(d>0){const g={};o.slice(u).forEach((f,C)=>{const I=f==null?void 0:f.style;if(!I)return;const w=I.split(";");let E=l.DEFAULT_WORKSHEET_ROW_HEIGHT;w.find(O=>{O=O.toLowerCase();const x=R.textTrim(O.substr(0,O.indexOf(":"))),N=R.textTrim(O.substr(O.indexOf(":")+1));return x==="height"?(E=parseFloat(N),!0):!1}),g[C]={h:E,hd:l.BooleanNumber.FALSE}});const _={unitId:e,subUnitId:t,range:{...s,startRow:c},rowInfo:g};a.push({id:p.InsertRowMutation.id,params:_})}const h={};o.slice(0,u).forEach((g,_)=>{const f=g.style;if(!f)return;const C=f.split(";");let I=l.DEFAULT_WORKSHEET_ROW_HEIGHT;C.find(w=>{w=w.toLowerCase();const E=R.textTrim(w.substr(0,w.indexOf(":"))),O=R.textTrim(w.substr(w.indexOf(":")+1));return E==="height"?(I=parseFloat(O),!0):!1}),h[_]=I});const m={unitId:e,subUnitId:t,ranges:[{...s,endRow:Math.min(s.endRow,c)}],rowHeight:h};return a.push({id:p.SetWorksheetRowHeightMutation.id,params:m}),{redos:a,undos:[]}},onPasteColumns(r,o,s){const{range:a}=r,c=[],d=n.getMaxColumns(),u=a.endColumn-d,h=o.length-u;if(u>0){const g={unitId:e,subUnitId:t,range:{...a,startColumn:d},colInfo:o.slice(h).map(_=>({w:_.width?+_.width:l.DEFAULT_WORKSHEET_COLUMN_WIDTH,hd:l.BooleanNumber.FALSE}))};c.push({id:p.InsertColMutation.id,params:g})}const m={unitId:e,subUnitId:t,ranges:[{...a,endRow:Math.min(a.endColumn,d)}],colWidth:o.slice(0,h).map(g=>g.width?+g.width:l.DEFAULT_WORKSHEET_COLUMN_WIDTH)};return c.push({id:p.SetWorksheetColWidthMutation.id,params:m}),{redos:c,undos:[]}},onPastePlainText(r,o,s){return i._onPastePlainText(r,o,s)},onPasteCells(r,o,s,a){return i._onPasteCells(r,o,s,a)},onAfterPaste(r){n=null}}}_generateDocumentDataModelSnapshot(i){var s;const e=this._sheetSkeletonManagerService.getCurrent();if(e==null)return null;const{skeleton:t}=e,n=(s=t.getBlankCellDocumentModel())==null?void 0:s.documentModel,o={...n==null?void 0:n.getSnapshot(),...i};return n==null||n.reset(o),n==null?void 0:n.getSnapshot()}_onPastePlainText(i,e,t){const{range:n,unitId:r,subUnitId:o}=i;let s;if(/\r|\n/.test(e)){const c=Mo(e),d=this._generateDocumentDataModelSnapshot({body:c});s={[n.startRow]:{[n.startColumn]:{p:d}}}}else s={[n.startRow]:{[n.startColumn]:{v:e}}};const a={unitId:r,subUnitId:o,cellValue:s};return{redos:[{id:p.SetRangeValuesMutation.id,params:a}],undos:[{id:p.SetRangeValuesMutation.id,params:p.SetRangeValuesUndoMutationFactory(this._injector,a)}]}}_onPasteCells(i,e,t,n){const r={get:this._injector.get.bind(this._injector)};return la(i,e,t,n,r)}_initSpecialPasteHooks(){const i={get:this._injector.get.bind(this._injector)},e=this,t={id:Ke.SPECIAL_PASTE_VALUE,specialPasteInfo:{label:"specialPaste.value"},onPasteCells:(s,a,c,d)=>{const u=e._currentUniverSheet.getCurrentUniverSheetInstance();return u.getUnitId(),u.getActiveSheet().getSheetId(),Ro(a,c,i)}},n={id:Ke.SPECIAL_PASTE_FORMAT,specialPasteInfo:{label:"specialPaste.format"},onPasteCells(s,a,c,d){const u=e._currentUniverSheet.getCurrentUniverSheetInstance();u.getUnitId(),u.getActiveSheet().getSheetId();const h=[],m=[],{undos:g,redos:_}=bo(a,c,i);h.push(..._),m.push(...g);const{undos:f,redos:C}=Ki(a,c,i);h.push(...C),m.push(...f);const{undos:I,redos:w}=Io(a,c,i);return h.push(...w),m.push(...I),{undos:m,redos:h}}},r={id:Ke.SPECIAL_PASTE_COL_WIDTH,specialPasteInfo:{label:"specialPaste.colWidth"},onPasteCells(){return{undos:[],redos:[]}},onPasteColumns(s,a,c){const d=e._currentUniverSheet.getCurrentUniverSheetInstance(),u=d.getUnitId(),h=d.getActiveSheet().getSheetId(),m=[],g=e._getWorksheet(u,h),{range:_}=s,f=g.getMaxColumns(),C=_.endColumn-f,I=a.length-C,w={unitId:u,subUnitId:h,ranges:[{..._,endRow:Math.min(_.endColumn,f)}],colWidth:a.slice(0,I).map(E=>E.width?+E.width:l.DEFAULT_WORKSHEET_COLUMN_WIDTH)};return m.push({id:p.SetWorksheetColWidthMutation.id,params:w}),m.push({id:p.SetWorksheetColWidthMutation.id,params:w}),{redos:m,undos:[]}}},o={id:Ke.SPECIAL_PASTE_BESIDES_BORDER,specialPasteInfo:{label:"specialPaste.besidesBorder"},onPasteCells(s,a,c,d){e._currentUniverSheet.getCurrentUniverSheetInstance();const u=[],h=[],{range:m,unitId:g,subUnitId:_}=a,{startColumn:f,startRow:C,endColumn:I,endRow:w}=m,E=new l.ObjectMatrix;c.forValue((P,L,G)=>{const k=G.s;typeof k=="object"&&E.setValue(P+C,L+f,{s:{...k,bd:void 0},v:G.v})});const O={unitId:g,subUnitId:_,cellValue:E.getData()};u.push({id:p.SetRangeValuesMutation.id,params:O});const x=p.SetRangeValuesUndoMutationFactory(i,O);h.push({id:p.SetRangeValuesMutation.id,params:x});const{undos:N,redos:D}=Ki(a,c,i);return h.push(...N),u.push(...D),{redos:u,undos:h}}};return[t,n,r,o]}_getWorksheet(i,e){var n;const t=(n=this._currentUniverSheet.getUniverSheetInstance(i))==null?void 0:n.getSheetBySheetId(e);if(!t)throw new Error(`[SheetClipboardController]: cannot find a worksheet with unitId ${i} and subUnitId ${e}.`);return t}};Zn=Qc([l.OnLifecycle(l.LifecycleStages.Ready,Zn),yt(0,l.IUniverInstanceService),yt(1,l.ICommandService),yt(2,l.IConfigService),yt(3,nn),yt(4,R.IMessageService),yt(5,j.Inject(exports.SheetSkeletonManagerService)),yt(6,j.Inject(j.Injector)),yt(7,j.Inject(l.LocaleService))],Zn);var ed=Object.defineProperty,td=Object.getOwnPropertyDescriptor,nd=(i,e,t,n)=>{for(var r=n>1?void 0:n?td(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&ed(e,t,r),r},_n=(i,e)=>(t,n)=>e(t,n,i);let Gn=class extends l.Disposable{constructor(i,e,t,n,r){super(),this._currentUniverService=i,this._contextMenuService=e,this._renderManagerService=t,this._selectionManagerService=n,this._selectionRenderService=r,this._currentUniverService.currentSheet$.subscribe(o=>{if(o==null)throw new Error("workbook is null");this._addListeners()})}_addListeners(){const i=qe(this._currentUniverService,this._renderManagerService);if(!i)return;const e=i.spreadsheet.onPointerDownObserver,t=e.add(a=>{if(a.button===2){const c=this._selectionManagerService.getSelections(),d=c==null?void 0:c[0];if(!d)return;const u=d.range.rangeType,h=this._selectionRenderService.convertSelectionRangeToData(d).rangeWithCoord,m=()=>{if(!h)return!1;const _=a.offsetX,f=a.offsetY;switch(u){case l.RANGE_TYPE.ROW:return h.startY<=f&&h.endY>=f;case l.RANGE_TYPE.COLUMN:return h.startX<=_&&h.endX>=_;default:return h.startX<=_&&h.endX>=_&&h.startY<=f&&h.endY>=f}},g=_=>{this._contextMenuService.triggerContextMenu(a,_)};m()?u===l.RANGE_TYPE.COLUMN?g(Be.COL_HEADER_CONTEXT_MENU):u===l.RANGE_TYPE.ROW?g(Be.ROW_HEADER_CONTEXT_MENU):g(R.MenuPosition.CONTEXT_MENU):g(R.MenuPosition.CONTEXT_MENU)}});this.disposeWithMe(l.toDisposable(()=>e.remove(t)));const r=i.spreadsheetRowHeader.onPointerDownObserver.add(a=>{a.button===2&&this._contextMenuService.triggerContextMenu(a,Be.ROW_HEADER_CONTEXT_MENU)});this.disposeWithMe(l.toDisposable(()=>e.remove(r)));const s=i.spreadsheetColumnHeader.onPointerDownObserver.add(a=>{a.button===2&&this._contextMenuService.triggerContextMenu(a,Be.COL_HEADER_CONTEXT_MENU)});this.disposeWithMe(l.toDisposable(()=>e.remove(s)))}};Gn=nd([l.OnLifecycle(l.LifecycleStages.Rendered,Gn),_n(0,l.IUniverInstanceService),_n(1,R.IContextMenuService),_n(2,y.IRenderManagerService),_n(3,j.Inject(p.SelectionManagerService)),_n(4,Ze)],Gn);var id=Object.defineProperty,rd=Object.getOwnPropertyDescriptor,od=(i,e,t,n)=>{for(var r=n>1?void 0:n?rd(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&id(e,t,r),r},Vi=(i,e)=>(t,n)=>e(t,n,i);let Kn=class extends l.RxDisposable{constructor(i,e,t){super(),this._currentUniverService=i,this._renderManagerService=e,this._undoRedoService=t,this._initialize(),this._commandExecutedListener()}_initialize(){this._initialNormalInput(),this._listenEditorBlur()}_listenEditorBlur(){this._currentUniverService.currentDoc$.pipe(J.takeUntil(this.dispose$)).subscribe(i=>{if(i==null)return;i.getUnitId()!==l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY&&this._undoRedoService.clearUndoRedo(l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY)})}_initialNormalInput(){const i={};this._currentUniverService.getCurrentUniverSheetInstance().getSheets().forEach(e=>{const t=e.getConfig();i[e.getSheetId()]={cellData:new l.ObjectMatrix(t.cellData),rowCount:t.rowCount,columnCount:t.columnCount}})}_commandExecutedListener(){}_getDocObject(){return pe.getDocObject(this._currentUniverService,this._renderManagerService)}};Kn=od([l.OnLifecycle(l.LifecycleStages.Steady,Kn),Vi(0,l.IUniverInstanceService),Vi(1,y.IRenderManagerService),Vi(2,j.Inject(l.IUndoRedoService))],Kn);const ls=[R.KeyCode.ARROW_DOWN,R.KeyCode.ARROW_UP,R.KeyCode.ARROW_LEFT,R.KeyCode.ARROW_RIGHT],sd=[R.KeyCode.ENTER,R.KeyCode.TAB,...ls];function ad(){const i=[];for(const e of ls)i.push({id:Tn.id,binding:e,preconditions:t=>vi(t),staticParameters:{visible:!1,eventType:y.DeviceInputEventType.Keyboard,keycode:e,isShift:!1}}),i.push({id:Tn.id,binding:e|R.MetaKeys.SHIFT,preconditions:t=>vi(t),staticParameters:{visible:!1,eventType:y.DeviceInputEventType.Keyboard,keycode:e,isShift:!0}});return i}const ld={id:mt.id,binding:R.KeyCode.ENTER,description:"shortcut.sheet.toggle-editing",group:"4_sheet-edit",preconditions:i=>vi(i),staticParameters:{visible:!1,eventType:y.DeviceInputEventType.Keyboard,keycode:R.KeyCode.ENTER}},cd={id:mt.id,binding:R.KeyCode.TAB,preconditions:i=>vi(i),staticParameters:{visible:!1,eventType:y.DeviceInputEventType.Keyboard,keycode:R.KeyCode.TAB}},dd={id:mt.id,binding:R.KeyCode.ESC,description:"shortcut.sheet.abort-editing",group:"4_sheet-edit",preconditions:i=>vo(i),staticParameters:{visible:!1,eventType:y.DeviceInputEventType.Keyboard,keycode:R.KeyCode.ESC}},ud={id:pe.BreakLineCommand.id,description:"shortcut.sheet.break-line",group:"4_sheet-edit",preconditions:i=>vo(i),binding:R.KeyCode.ENTER|R.MetaKeys.ALT},hd={id:pe.DeleteLeftCommand.id,preconditions:i=>js(i)||Co(i),binding:R.KeyCode.BACKSPACE},md={id:mt.id,description:"shortcut.sheet.delete-and-start-editing",group:"4_sheet-edit",preconditions:i=>Bs(i)&&!Co(i),binding:R.KeyCode.BACKSPACE,staticParameters:{visible:!0,eventType:y.DeviceInputEventType.Keyboard,keycode:R.KeyCode.BACKSPACE}};var gd=Object.defineProperty,_d=Object.getOwnPropertyDescriptor,pd=(i,e,t,n)=>{for(var r=n>1?void 0:n?_d(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&gd(e,t,r),r},dt=(i,e)=>(t,n)=>e(t,n,i);function fd(i){const{textRuns:e=[],paragraphs:t=[]}=i;return e.some(n=>n.ts&&!l.Tools.isEmptyObject(n.ts))||t.some(n=>n.bullet)}let qn=class extends l.Disposable{constructor(e,t,n,r,o,s,a,c,d,u){super();v(this,"_onInputSubscription");v(this,"_cursorChangeObservers");v(this,"_editorVisiblePrevious",!1);v(this,"_isCursorChange",0);this._currentUniverService=e,this._renderManagerService=t,this._commandService=n,this._editorBridgeService=r,this._contextService=o,this._cellEditorManagerService=s,this._lexerTreeBuilder=a,this._undoRedoService=c,this._sheetInterceptorService=d,this._selectionManagerService=u,this._initialize(),this._commandExecutedListener()}dispose(){var n;(n=this._onInputSubscription)==null||n.unsubscribe();const e=this._getEditorObject();if(e==null)return;const{document:t}=e;t.onPointerDownObserver.remove(this._cursorChangeObservers)}_initialize(){this._initialExitInput(),this._cursorStateListener()}_initialExitInput(){this._onInputSubscription=this._editorBridgeService.visible$.subscribe(e=>{const{visible:t,keycode:n,eventType:r}=e;if(t===this._editorVisiblePrevious)return;if(this._editorVisiblePrevious=t,t===!0){this._isCursorChange=r===y.DeviceInputEventType.PointerDown?2:1;return}this._isCursorChange=0;const o=this._selectionManagerService.getSelections(),s=this._selectionManagerService.getCurrent();if(s==null)return;const{unitId:a,sheetId:c,pluginName:d}=s;if(this._exitInput(e),n===R.KeyCode.ESC){this._commandService.syncExecuteCommand(p.SetSelectionsOperation.id,{unitId:a,subUnitId:c,pluginName:d,selections:o});return}const u=this._editorBridgeService.getEditCellState();if(u==null)return;const{unitId:h,sheetId:m,row:g,column:_,documentLayoutObject:f}=u;if(this._moveCursor(n),this._editorBridgeService.getEditorDirty()===!1)return;const I=this._currentUniverService.getUniverSheetInstance(h),w=I==null?void 0:I.getSheetBySheetId(m);if(w==null)return;const E=Sd(w.getCellRaw(g,_)||{},f,this._lexerTreeBuilder);if(E==null)return;const O={subUnitId:m,unitId:h,workbook:I,worksheet:w,row:g,col:_},x=this._editorBridgeService.interceptor.fetchThroughInterceptors(this._editorBridgeService.interceptor.getInterceptPoints().AFTER_CELL_EDIT)(E,O);this._commandService.executeCommand(p.SetRangeValuesCommand.id,{subUnitId:m,unitId:h,range:{startRow:g,startColumn:_,endRow:g,endColumn:_},value:x}),a===h&&m!==c&&this._commandService.executeCommand(p.SetWorksheetActivateCommand.id,{subUnitId:m,unitId:h})})}_exitInput(e){this._contextService.setContextValue(l.FOCUSING_EDITOR_INPUT_FORMULA,!1),this._contextService.setContextValue(l.FOCUSING_EDITOR,!1),this._contextService.setContextValue(l.FOCUSING_EDITOR_BUT_HIDDEN,!1),this._contextService.setContextValue(l.FOCUSING_FORMULA_EDITOR,!1),this._cellEditorManagerService.setState({show:e.visible});const t=this._editorBridgeService.getCurrentEditorId();t!=null&&(this._undoRedoService.clearUndoRedo(t),this._undoRedoService.clearUndoRedo(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY))}_moveCursor(e){if(e==null||!sd.includes(e))return;let t=l.Direction.LEFT;switch(e){case R.KeyCode.ENTER:t=l.Direction.DOWN;break;case R.KeyCode.TAB:t=l.Direction.RIGHT;break;case R.KeyCode.ARROW_DOWN:t=l.Direction.DOWN;break;case R.KeyCode.ARROW_UP:t=l.Direction.UP;break;case R.KeyCode.ARROW_LEFT:t=l.Direction.LEFT;break;case R.KeyCode.ARROW_RIGHT:t=l.Direction.RIGHT;break}e===R.KeyCode.ENTER||e===R.KeyCode.TAB?this._commandService.executeCommand(jt.id,{keycode:e,direction:t}):this._commandService.executeCommand(nt.id,{direction:t})}_cursorStateListener(){const e=this._getEditorObject();if(e==null)return;const{document:t}=e;this._cursorChangeObservers=t.onPointerDownObserver.add(()=>{this._isCursorChange===1&&(this._isCursorChange=2)})}_commandExecutedListener(){const e=[Tn.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(e.includes(t.id)){const n=t.params,{keycode:r,isShift:o}=n;if(r!=null&&this._isCursorChange===2){this._moveInEditor(r,o);return}this._editorBridgeService.changeVisible(n)}}))}_moveInEditor(e,t){let n=l.Direction.LEFT;e===R.KeyCode.ARROW_DOWN?n=l.Direction.DOWN:e===R.KeyCode.ARROW_UP?n=l.Direction.UP:e===R.KeyCode.ARROW_RIGHT&&(n=l.Direction.RIGHT),t?this._commandService.executeCommand(pe.MoveSelectionOperation.id,{direction:n}):this._commandService.executeCommand(pe.MoveCursorOperation.id,{direction:n})}_getEditorObject(){return wi(this._editorBridgeService.getCurrentEditorId(),this._renderManagerService)}};qn=pd([l.OnLifecycle(l.LifecycleStages.Steady,qn),dt(0,l.IUniverInstanceService),dt(1,y.IRenderManagerService),dt(2,l.ICommandService),dt(3,at),dt(4,l.IContextService),dt(5,Dn),dt(6,j.Inject(Re.LexerTreeBuilder)),dt(7,l.IUndoRedoService),dt(8,j.Inject(p.SheetInterceptorService)),dt(9,j.Inject(p.SelectionManagerService))],qn);function Sd(i,e,t){i=l.Tools.deepClone(i);const{documentModel:n}=e;if(n==null)return null;const r=n.getSnapshot(),{body:o}=r;if(o==null)return null;const s=o.dataStream;let c=s.substring(s.length-2,s.length)===l.DEFAULT_EMPTY_DOCUMENT_VALUE?s.substring(0,s.length-2):s;if(l.isFormulaString(c)){if(i.f===c)return null;const d=t.checkIfAddBracket(c);for(let u=0;u<d;u++)c+=Re.matchToken.CLOSE_BRACKET;i.f=c,i.v=null,i.p=null}else if(fd(o))o.dataStream===`\r
19
+ `?(i.v="",i.f=null,i.si=null,i.p=null):(i.p=r,i.v=null,i.f=null,i.si=null);else{if((c===i.v||c===""&&i.v==null)&&i.p==null)return null;i.v=c,i.f=null,i.si=null,i.p=null}return i}var vd=Object.defineProperty,Cd=Object.getOwnPropertyDescriptor,Rd=(i,e,t,n)=>{for(var r=n>1?void 0:n?Cd(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&vd(e,t,r),r},ut=(i,e)=>(t,n)=>e(t,n,i);let Jn=class extends l.RxDisposable{constructor(e,t,n,r,o,s,a,c,d,u){super();v(this,"_loadedMap",new Set);this._univerInstanceService=e,this._renderManagerService=t,this._editorBridgeService=n,this._docSkeletonManagerService=r,this._docViewModelManagerService=o,this._commandService=s,this._contextService=a,this._formulaEditorManagerService=c,this._undoRedoService=d,this._textSelectionManagerService=u,this._initialize()}_initialize(){this._syncFormulaEditorContent(),this._commandExecutedListener(),this._syncEditorSize(),this._listenFxBtnClick(),this._listenFoldBtnClick(),this._renderManagerService.currentRender$.pipe(J.takeUntil(this.dispose$)).subscribe(e=>{e===l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY&&(this._loadedMap.has(e)||(this._initialMain(e),this._loadedMap.add(e)))}),this._textSelectionManagerService.textSelection$.pipe(J.takeUntil(this.dispose$)).subscribe(e=>{if(e==null)return;const{unitId:t}=e;t!==l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY&&(this._contextService.setContextValue(l.FOCUSING_FORMULA_EDITOR,!1),this._undoRedoService.clearUndoRedo(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY))})}_listenFxBtnClick(){this._formulaEditorManagerService.fxBtnClick$.pipe(J.takeUntil(this.dispose$)).subscribe(()=>{var t;if(this._contextService.getContextValue(l.FOCUSING_EDITOR_BUT_HIDDEN)&&!this._contextService.getContextValue(l.FOCUSING_EDITOR)){this._univerInstanceService.setCurrentUniverDocInstance(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY),this._contextService.setContextValue(l.FOCUSING_FORMULA_EDITOR,!0);const n=this._univerInstanceService.getUniverDocInstance(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY);this._editorBridgeService.isVisible().visible===!1&&this._editorBridgeService.changeVisible({visible:!0,eventType:y.DeviceInputEventType.PointerDown});const o=(t=n==null?void 0:n.getBody())==null?void 0:t.dataStream;if(o==null)return;let s=o.startsWith("=")?o:`=${o}`;s=s.replace(/\r\n$/,"");const a=[{startOffset:s.length,endOffset:s.length}],c={unitId:l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,body:{dataStream:s},segmentId:""};this._commandService.executeCommand(pe.CoverContentCommand.id,c),this._textSelectionManagerService.replaceTextRanges(a)}})}_listenFoldBtnClick(){this._formulaEditorManagerService.foldBtnStatus$.pipe(J.takeUntil(this.dispose$)).subscribe(()=>{this._textSelectionManagerService.refreshSelection()})}_initialMain(e){const t=this._renderManagerService.getRenderById(e);if(t==null)return;const{mainComponent:n}=t;n!=null&&this.disposeWithMe(l.toDisposable(n.onPointerDownObserver.add(()=>{this._contextService.setContextValue(l.FOCUSING_FORMULA_EDITOR,!0),this._undoRedoService.clearUndoRedo(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY),this._editorBridgeService.isVisible().visible===!1&&this._editorBridgeService.changeVisible({visible:!0,eventType:y.DeviceInputEventType.PointerDown})})))}_syncEditorSize(){this._formulaEditorManagerService.position$.pipe(J.takeUntil(this.dispose$)).subscribe(e=>{if(e==null)return;const t=wi(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,this._renderManagerService),n=this._univerInstanceService.getUniverDocInstance(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY);if(t==null||n==null)return;const{width:r,height:o}=e,{engine:s}=t;n.updateDocumentDataPageSize(r),this._autoScroll(),requestIdleCallback(()=>{s.resizeBySize(r,o)})})}_syncFormulaEditorContent(){this._editorBridgeService.currentEditCellState$.pipe(J.takeUntil(this.dispose$)).subscribe(e=>{e==null||this._editorBridgeService.isForceKeepVisible()||this._editorSyncHandler(e)}),this._editorBridgeService.visible$.pipe(J.takeUntil(this.dispose$)).subscribe(e=>{if(e==null||e.visible===!1||this._editorBridgeService.isForceKeepVisible())return;const t=this._editorBridgeService.getLatestEditCellState();t!=null&&this._editorSyncHandler(t)})}_editorSyncHandler(e){var s;const t=(s=e.documentLayoutObject.documentModel)==null?void 0:s.getBody();let n=t==null?void 0:t.dataStream,r=t==null?void 0:t.paragraphs,o=[];n==null||r==null||(e.isInArrayFormulaRange===!0&&this._editorBridgeService.isVisible().eventType===y.DeviceInputEventType.Dblclick?(n=`\r
20
+ `,r=[{startIndex:0}]):e.isInArrayFormulaRange===!0&&(o=(t==null?void 0:t.textRuns)||[]),this._syncContentAndRender(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,n,r,o),this._autoScroll())}_commandExecutedListener(){const e=[pe.RichTextEditingMutation.id,Ti.id],t=[l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY];this.disposeWithMe(this._commandService.onCommandExecuted(r=>{var o,s;if(e.includes(r.id)){const a=r.params,{unitId:c}=a;if(t.includes(c)){const d=this._univerInstanceService.getUniverDocInstance(c),u=(o=d==null?void 0:d.getBody())==null?void 0:o.dataStream,h=(s=d==null?void 0:d.getBody())==null?void 0:s.paragraphs,m=c===l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY?l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY:l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY;if(u==null||h==null)return;this._syncContentAndRender(m,u,h),this._autoScroll()}}}));const n=[p.SetRangeValuesMutation.id,p.MoveRangeMutation.id];this.disposeWithMe(this._commandService.onCommandExecuted(r=>{var o,s,a,c,d;if(n.includes(r.id)){const u=this._editorBridgeService.getLatestEditCellState();if(u==null)return;let h=!1;const{row:m,column:g}=u;if(r.id===p.SetRangeValuesMutation.id&&r.params?(s=(o=r.params.cellValue)==null?void 0:o[m])!=null&&s[g]&&(h=!0):r.id===p.MoveRangeMutation.id&&r.params&&(c=(a=r.params.to.value)==null?void 0:a[m])!=null&&c[g]&&(h=!0),h){const _=(d=u.documentLayoutObject.documentModel)==null?void 0:d.getBody();if(_==null)return;const{dataStream:f,paragraphs:C=[]}=_;this._syncContentAndRender(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,f,C),this._autoScroll()}}}))}_syncContentAndRender(e,t,n,r=[]){var h;const o=[l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY],s=this._docSkeletonManagerService.getSkeletonByUnitId(e),a=this._univerInstanceService.getUniverDocInstance(e),c=this._docViewModelManagerService.getViewModel(e);if(a==null||c==null||s==null)return;a.getBody().dataStream=t,a.getBody().paragraphs=this._clearParagraph(n),e===l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY&&(a.getBody().textRuns=[]),r.length>0&&(a.getBody().textRuns=r),c.reset(a);const{skeleton:d}=s,u=this._renderManagerService.getRenderById(e);u!=null&&(d.calculate(),o.includes(e)&&((h=u.mainComponent)==null||h.makeDirty()))}_clearParagraph(e){const t=l.Tools.deepClone(e);for(const n of t)n.paragraphStyle&&(n.paragraphStyle.horizontalAlign=l.HorizontalAlign.UNSPECIFIED);return t}_autoScroll(){var _,f;const e=(_=this._docSkeletonManagerService.getSkeletonByUnitId(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY))==null?void 0:_.skeleton,t=this._formulaEditorManagerService.getPosition(),n=this._renderManagerService.getRenderById(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY),r=this._univerInstanceService.getUniverDocInstance(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY);if(e==null||t==null||n==null||r==null)return;const{marginTop:o=0,marginBottom:s=0}=r.getSnapshot().documentStyle,{scene:a,mainComponent:c}=n;let{actualHeight:d}=e.getActualSize();d+=o+s;const{width:u,height:h}=t,m=a.getViewport(pe.VIEWPORT_KEY.VIEW_MAIN);let g=m==null?void 0:m.getScrollBar();a.transformByState({width:u,height:d}),c==null||c.resize(u,d),d>h?g==null?m&&new y.ScrollBar(m,{enableHorizontal:!1,barSize:8}):m==null||m.resetSizeAndScrollBar():(g=null,m==null||m.scrollTo({x:0,y:0}),(f=m==null?void 0:m.getScrollBar())==null||f.dispose())}};Jn=Rd([l.OnLifecycle(l.LifecycleStages.Steady,Jn),ut(0,l.IUniverInstanceService),ut(1,y.IRenderManagerService),ut(2,at),ut(3,j.Inject(pe.DocSkeletonManagerService)),ut(4,j.Inject(pe.DocViewModelManagerService)),ut(5,l.ICommandService),ut(6,l.IContextService),ut(7,xi),ut(8,l.IUndoRedoService),ut(9,j.Inject(pe.TextSelectionManagerService))],Jn);var Id=Object.defineProperty,bd=Object.getOwnPropertyDescriptor,Md=(i,e,t,n)=>{for(var r=n>1?void 0:n?bd(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&Id(e,t,r),r},wd=(i,e)=>(t,n)=>e(t,n,i);let Qn=class extends l.Disposable{constructor(i){super(),this._currentUniverService=i,setTimeout(()=>{this._initialize()},0)}_initialize(){this._currentUniverService.createDoc({id:l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,body:{dataStream:`${l.DEFAULT_EMPTY_DOCUMENT_VALUE}`,textRuns:[],paragraphs:[{startIndex:0}]},documentStyle:{}});const i={id:l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,body:{dataStream:`${l.DEFAULT_EMPTY_DOCUMENT_VALUE}`,textRuns:[],paragraphs:[{startIndex:0}]},documentStyle:{pageSize:{width:1/0,height:1/0},marginTop:5,marginBottom:5,marginRight:0,marginLeft:0,paragraphLineGapDefault:0,renderConfig:{horizontalAlign:l.HorizontalAlign.UNSPECIFIED,verticalAlign:l.VerticalAlign.UNSPECIFIED,centerAngle:0,vertexAngle:0,wrapStrategy:l.WrapStrategy.WRAP}}};this._currentUniverService.createDoc(i)}};Qn=Md([l.OnLifecycle(l.LifecycleStages.Rendered,Qn),wd(0,l.IUniverInstanceService)],Qn);const Td="36",yd="univer-sheet-container",cs={sheetFooterBarHeight:Td,sheetContainer:yd};var Ed=Object.defineProperty,Od=Object.getOwnPropertyDescriptor,xd=(i,e,t,n)=>{for(var r=n>1?void 0:n?Od(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&Ed(e,t,r),r},rt=(i,e)=>(t,n)=>e(t,n,i);const Kr=-1e3,qr=5,Ad=2;let ei=class extends l.Disposable{constructor(e,t,n,r,o,s,a,c,d,u,h){super();v(this,"_onInputSubscription");v(this,"_onInputActivateSubscription");v(this,"_editorVisiblePrevious",!1);this._docSkeletonManagerService=e,this._docViewModelManagerService=t,this._contextService=n,this._currentUniverService=r,this._renderManagerService=o,this._editorBridgeService=s,this._cellEditorManagerService=a,this._textSelectionRenderManager=c,this._textSelectionManagerService=d,this._commandService=u,this._localService=h,this._initialize(),this._commandExecutedListener()}dispose(){var e,t;(e=this._onInputSubscription)==null||e.unsubscribe(),(t=this._onInputActivateSubscription)==null||t.unsubscribe()}_initialize(){this._initialEditFocusListener(),this._initialStartEdit(),this._initialKeyboardListener(),this._initialCursorSync(),this._listenEditorFocus()}_listenEditorFocus(){const e=this._getEditorObject();e!=null&&this.disposeWithMe(l.toDisposable(e.document.onPointerDownObserver.add(()=>{var t;if(this._editorBridgeService.isVisible()){const n=this._editorBridgeService.getEditCellState(),r=this._editorBridgeService.getCurrentEditorId();if(n==null||r==null)return;const o=(t=this._docSkeletonManagerService.getSkeletonByUnitId(r))==null?void 0:t.skeleton;if(o==null)return;const{position:s,documentLayoutObject:a,canvasOffset:c,scaleX:d,scaleY:u}=n;this._fitTextSize(s,c,o,a,d,u)}})))}_initialCursorSync(){this._cellEditorManagerService.focus$.subscribe(()=>{this._textSelectionRenderManager.sync()})}_initialEditFocusListener(){this._onInputSubscription=this._editorBridgeService.currentEditCellState$.subscribe(e=>{if(e==null||this._editorBridgeService.isForceKeepVisible())return;const{position:t,documentLayoutObject:n,scaleX:r,editorUnitId:o}=e;if(this._getEditorObject()==null)return;const{startX:a,endX:c}=t,{textRotation:d,wrapStrategy:u,documentModel:h}=n,{a:m}=d;h.updateDocumentId(o),u===l.WrapStrategy.WRAP&&m===0&&h.updateDocumentDataPageSize((c-a)/r),this._currentUniverService.changeDoc(o,h),this._contextService.setContextValue(l.FOCUSING_EDITOR_BUT_HIDDEN,!0),this._textSelectionManagerService.replaceTextRanges([{startOffset:0,endOffset:0}]),this._textSelectionRenderManager.activate(Kr,Kr)})}_fitTextSize(e,t,n,r,o=1,s=1){const{startX:a,startY:c,endX:d,endY:u}=e,h=r.documentModel;if(h==null)return;const{actualWidth:m,actualHeight:g}=this._predictingSize(e,t,n,r,o,s),{verticalAlign:_,paddingData:f,fill:C}=r;let I=d-a,w=u-c;if(I<m&&(I=m),w<g)w=g,h.updateDocumentDataMargin(f);else{let E=f.t||0;_===l.VerticalAlign.MIDDLE?E=(w-g)/2:_===l.VerticalAlign.BOTTOM&&(E=w-g),E/=s,E=E<(f.t||0)?f.t||0:E,h.updateDocumentDataMargin({t:E})}n.calculate(),this._editAreaProcessing(I,w,e,t,C,o,s)}_predictingSize(e,t,n,r,o=1,s=1){const{startX:a,endX:c}=e,{textRotation:d,wrapStrategy:u}=r,h=r.documentModel,{a:m}=d,g=document.body.clientWidth;if(u===l.WrapStrategy.WRAP&&m===0){const{actualWidth:C,actualHeight:I}=n.getActualSize();return{actualWidth:C*o,actualHeight:I*s}}h==null||h.updateDocumentDataPageSize((g-a-t.left)/o),n.calculate();const _=n.getActualSize();let f=c-a;return f<_.actualWidth*o+qr*o&&(f=_.actualWidth*o+qr*o),h==null||h.updateDocumentDataPageSize(f/o),h==null||h.updateDocumentRenderConfig({horizontalAlign:l.HorizontalAlign.UNSPECIFIED}),{actualWidth:f,actualHeight:_.actualHeight*s}}_editAreaProcessing(e,t,n,r,o,s=1,a=1){var x;const c=this._getEditorObject();if(c==null)return;let{startX:d,startY:u}=n;const{document:h,scene:m,engine:g}=c,_=m.getViewport(pe.VIEWPORT_KEY.VIEW_MAIN),f=document.body.clientHeight-u-parseFloat(cs.sheetFooterBarHeight)-r.top-Ad*2,C=document.body.clientWidth-d-r.left;let I=t,w=_==null?void 0:_.getScrollBar();I>f?(I=f,w==null?_&&new y.ScrollBar(_,{enableHorizontal:!1,barSize:8}):_==null||_.resetSizeAndScrollBar()):(w=null,(x=_==null?void 0:_.getScrollBar())==null||x.dispose()),e+=(w==null?void 0:w.barSize)||0,e>C&&(e=C),d-=y.FIX_ONE_PIXEL_BLUR_OFFSET,u-=y.FIX_ONE_PIXEL_BLUR_OFFSET,this._addBackground(m,e/s,t/a,o);const{scaleX:E,scaleY:O}=m.getPrecisionScale();m.transformByState({width:e/s,height:t/a,scaleX:s,scaleY:a}),h.resize(e/s,t/a),requestIdleCallback(()=>{g.resizeBySize(y.fixLineWidthByScale(e,E),y.fixLineWidthByScale(I,O))}),this._cellEditorManagerService.setState({startX:d,startY:u,endX:e+d,endY:I+u,show:!0})}_addBackground(e,t,n,r){const o="_backgroundRectHelperColor_",s=e.getObject(o);s==null&&r==null||(s==null?e.addObjects([new y.Rect(o,{width:t,height:n,fill:r,evented:!1})],pe.DOCS_COMPONENT_MAIN_LAYER_INDEX):r==null?s.dispose():(s.setProps({fill:r}),s.transformByState({width:t,height:n})))}_initialStartEdit(){this._onInputActivateSubscription=this._editorBridgeService.visible$.subscribe(e=>{var O,x,N;const{visible:t,eventType:n,keycode:r}=e;if(t===this._editorVisiblePrevious||(this._editorVisiblePrevious=t,t===!1))return;const o=this._editorBridgeService.getEditCellState();if(o==null)return;const{position:s,documentLayoutObject:a,canvasOffset:c,scaleX:d,scaleY:u,editorUnitId:h,unitId:m,isInArrayFormulaRange:g=!1}=o,_=this._getEditorObject();if(_==null)return;const{document:f,scene:C}=_;this._contextService.setContextValue(l.FOCUSING_EDITOR,!0);const{documentModel:I}=a,w=this._docSkeletonManagerService.getSkeletonByUnitId(h);if(w==null||I==null)return;const{skeleton:E}=w;if(this._fitTextSize(s,c,E,a,d,u),n===y.DeviceInputEventType.Keyboard||n===y.DeviceInputEventType.Dblclick&&g){const D=l.Tools.deepClone(I.snapshot),P=(O=this._docViewModelManagerService.getCurrent())==null?void 0:O.docViewModel;this._resetBodyStyle(D.body),I.reset(D),P.reset(I),f.makeDirty(),(r===R.KeyCode.BACKSPACE||n===y.DeviceInputEventType.Dblclick)&&(E.calculate(),this._editorBridgeService.changeEditorDirty(!0)),this._textSelectionManagerService.replaceTextRanges([{startOffset:0,endOffset:0}])}else if(n===y.DeviceInputEventType.Dblclick){const D=I.getBody().dataStream.length-2||0;(x=C.getViewport(pe.VIEWPORT_KEY.VIEW_MAIN))==null||x.scrollTo({y:1/0}),this._textSelectionManagerService.replaceTextRanges([{startOffset:D,endOffset:D}])}(N=this._renderManagerService.getRenderById(m))==null||N.scene.resetCursor()})}_resetBodyStyle(e){e.dataStream=l.DEFAULT_EMPTY_DOCUMENT_VALUE,e.textRuns!=null&&(e.textRuns.length===1?(e.textRuns[0].st=0,e.textRuns[0].ed=1):e.textRuns=void 0),e.paragraphs!=null&&(e.paragraphs.length===1?e.paragraphs[0].startIndex=0:e.paragraphs=[{startIndex:0}]),e.sectionBreaks!=null&&(e.sectionBreaks=void 0),e.tables!=null&&(e.tables=void 0),e.customRanges!=null&&(e.customRanges=void 0),e.customBlocks!=null&&(e.customBlocks=void 0)}_initialKeyboardListener(){this._textSelectionRenderManager.onInputBefore$.subscribe(e=>{const t=this._contextService.getContextValue(l.FOCUSING_FORMULA_EDITOR);this._contextService.getContextValue(l.FOCUSING_SHEET)&&!t&&this._showEditorByKeyboard(e)})}_showEditorByKeyboard(e){if(e==null)return;const t=e.event;this._commandService.executeCommand(mt.id,{visible:!0,eventType:y.DeviceInputEventType.Keyboard,keycode:t.which})}_commandExecutedListener(){const e=[pe.RichTextEditingMutation.id,Ti.id],t=[l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY];this.disposeWithMe(this._commandService.onCommandExecuted(n=>{var r;if(e.includes(n.id)){const o=n.params,{unitId:s}=o,a=this._editorBridgeService.getCurrentEditorId();if(a==null)return;this._editorBridgeService.changeEditorDirty(!0);const c=(r=this._docSkeletonManagerService.getSkeletonByUnitId(a))==null?void 0:r.skeleton;if(c==null||!t.includes(s))return;const d=this._editorBridgeService.getEditCellState();if(d==null)return;const{position:u,documentLayoutObject:h,canvasOffset:m,scaleX:g,scaleY:_}=d;this._fitTextSize(u,m,c,h,g,_)}}))}_getEditorObject(){return wi(this._editorBridgeService.getCurrentEditorId(),this._renderManagerService)}};ei=xd([l.OnLifecycle(l.LifecycleStages.Steady,ei),rt(0,j.Inject(pe.DocSkeletonManagerService)),rt(1,j.Inject(pe.DocViewModelManagerService)),rt(2,l.IContextService),rt(3,l.IUniverInstanceService),rt(4,y.IRenderManagerService),rt(5,at),rt(6,Dn),rt(7,y.ITextSelectionRenderManager),rt(8,j.Inject(pe.TextSelectionManagerService)),rt(9,l.ICommandService),rt(10,j.Inject(l.LocaleService))],ei);const ds={id:"sheet.operation.set-activate-cell-edit",type:l.CommandType.OPERATION,handler:(i,e)=>(i.get(at).setEditCell(e),!0)};var Nd=Object.defineProperty,Dd=Object.getOwnPropertyDescriptor,Pd=(i,e,t,n)=>{for(var r=n>1?void 0:n?Dd(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&Nd(e,t,r),r},zt=(i,e)=>(t,n)=>e(t,n,i);let ti=class extends l.RxDisposable{constructor(i,e,t,n,r,o){super(),this._sheetSkeletonManagerService=i,this._currentUniverService=e,this._commandService=t,this._renderManagerService=n,this._editorBridgeService=r,this._selectionManagerService=o,this._initialize(),this._commandExecutedListener()}dispose(){}_initialize(){this._initSelectionChangeListener(),this._initialEventListener()}_initSelectionChangeListener(){J.merge(this._selectionManagerService.selectionMoveEnd$,this._selectionManagerService.selectionMoveStart$).pipe(J.takeUntil(this.dispose$)).subscribe(i=>this._handleSelectionListener(i))}_handleSelectionListener(i){const e=this._selectionManagerService.getCurrent();if((e==null?void 0:e.pluginName)!==p.NORMAL_SELECTION_PLUGIN_NAME||this._editorBridgeService.isVisible().visible===!0)return;const t=this._sheetSkeletonManagerService.getCurrent();if(t==null||i==null||i.length===0||i[i.length-1]==null)return;const{primary:n}=i[i.length-1];if(n==null)return;const r=this._getSheetObject();if(r==null)return;const{unitId:o,sheetId:s}=t,{scene:a,engine:c}=r;this._commandService.executeCommand(ds.id,{scene:a,engine:c,primary:n,unitId:o,sheetId:s})}_initialEventListener(){const i=this._getSheetObject();if(i==null)return;const{spreadsheet:e,spreadsheetColumnHeader:t,spreadsheetLeftTopPlaceholder:n,spreadsheetRowHeader:r}=i;e.onDblclickObserver.add(o=>{o.button!==2&&this._commandService.executeCommand(mt.id,{visible:!0,eventType:y.DeviceInputEventType.Dblclick})}),e.onPointerDownObserver.add(this._keepVisibleHideEditor.bind(this)),t.onPointerDownObserver.add(this._keepVisibleHideEditor.bind(this)),n.onPointerDownObserver.add(this._keepVisibleHideEditor.bind(this)),r.onPointerDownObserver.add(this._keepVisibleHideEditor.bind(this))}_keepVisibleHideEditor(){this._editorBridgeService.isForceKeepVisible()||this._hideEditor()}_hideEditor(){this._editorBridgeService.isVisible().visible===!0&&(this._selectionManagerService.makeDirty(!1),this._commandService.executeCommand(mt.id,{visible:!1,eventType:y.DeviceInputEventType.PointerDown}),setTimeout(()=>{this._selectionManagerService.makeDirty(!0)},0))}_getSheetObject(){return qe(this._currentUniverService,this._renderManagerService)}_commandExecutedListener(){const i=p.COMMAND_LISTENER_SKELETON_CHANGE;this.disposeWithMe(this._commandService.onCommandExecuted((e,t)=>{t!=null&&t.fromCollab||(e.id===p.SetWorksheetActiveOperation.id?this._keepVisibleHideEditor():i.includes(e.id)&&this._hideEditor())}))}};ti=Pd([l.OnLifecycle(l.LifecycleStages.Rendered,ti),zt(0,j.Inject(exports.SheetSkeletonManagerService)),zt(1,l.IUniverInstanceService),zt(2,l.ICommandService),zt(3,y.IRenderManagerService),zt(4,at),zt(5,j.Inject(p.SelectionManagerService))],ti);var Hd=Object.defineProperty,Ld=Object.getOwnPropertyDescriptor,Ud=(i,e,t,n)=>{for(var r=n>1?void 0:n?Ld(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&Hd(e,t,r),r},pn=(i,e)=>(t,n)=>e(t,n,i);let ni=class extends l.Disposable{constructor(i,e,t,n,r){super(),this._commandService=i,this._formatPainterService=e,this._currentUniverService=t,this._renderManagerService=n,this._selectionRenderService=r,this._initialize()}_initialize(){this._commandExecutedListener(),this._bindFormatPainterStatus()}_bindFormatPainterStatus(){this._formatPainterService.status$.subscribe(i=>{const{scene:e}=this._getSheetObject()||{};e&&(i!==st.OFF?e.setDefaultCursor(y.CURSOR_TYPE.CELL):e.setDefaultCursor(y.CURSOR_TYPE.DEFAULT))})}_commandExecutedListener(){this.disposeWithMe(l.toDisposable(this._selectionRenderService.selectionMoveEnd$.subscribe(i=>{if(this._formatPainterService.getStatus()!==st.OFF){const{rangeWithCoord:e}=i[i.length-1];this._applyFormatPainter({startRow:e.startRow,startColumn:e.startColumn,endRow:e.endRow,endColumn:e.endColumn}),this._formatPainterService.getStatus()===st.ONCE&&this._commandService.executeCommand(pr.id)}})))}async _applyFormatPainter(i){const{styles:e,merges:t}=this._formatPainterService.getSelectionFormat(),n=this._currentUniverService.getCurrentUniverSheetInstance().getUnitId(),r=this._currentUniverService.getCurrentUniverSheetInstance().getActiveSheet().getSheetId();if(!e)return;const{startRow:o,startColumn:s,endRow:a,endColumn:c}=e.getDataRange(),d=a-o+1,u=c-s+1,h=Array.from({length:i.endRow-i.startRow+1},()=>Array.from({length:i.endColumn-i.startColumn+1},()=>({}))),m=[];h.forEach((_,f)=>{_.forEach((C,I)=>{const w=f%d+o,E=I%u+s,O=e.getValue(w,E);O&&(h[f][I].s=O)})}),t.forEach(_=>{const f={startRow:_.startRow-o,startColumn:_.startColumn-s,endRow:_.endRow-o,endColumn:_.endColumn-s},C=Math.max(1,Math.floor((i.endRow-i.startRow+1)/d)),I=Math.max(1,Math.floor((i.endColumn-i.startColumn+1)/u));for(let w=0;w<C;w++)for(let E=0;E<I;E++)m.push({startRow:f.startRow+w*d+i.startRow,startColumn:f.startColumn+E*u+i.startColumn,endRow:f.endRow+w*d+i.startRow,endColumn:f.endColumn+E*u+i.startColumn})});const g={subUnitId:r,unitId:n,styleRange:i,styleValues:h,mergeRanges:m};await this._commandService.executeCommand(Qo.id,g)}_getSheetObject(){return qe(this._currentUniverService,this._renderManagerService)}};ni=Ud([l.OnLifecycle(l.LifecycleStages.Rendered,ni),pn(0,l.ICommandService),pn(1,sn),pn(2,l.IUniverInstanceService),pn(3,y.IRenderManagerService),pn(4,Ze)],ni);const ii={id:"sheet.command.set-scroll-relative",type:l.CommandType.COMMAND,handler:async(i,e={offsetX:0,offsetY:0})=>{const t=i.get(l.ICommandService),n=i.get(Nt),o=i.get(l.IUniverInstanceService).getCurrentUniverSheetInstance(),s=o.getActiveSheet(),{xSplit:a,ySplit:c}=s.getConfig().freeze,d=n.getCurrentScroll(),{offsetX:u=0,offsetY:h=0}=e||{},{sheetViewStartRow:m=0,sheetViewStartColumn:g=0,offsetX:_=0,offsetY:f=0}=d||{};return t.executeCommand(on.id,{unitId:o.getUnitId(),sheetId:s.getSheetId(),sheetViewStartRow:m+c,sheetViewStartColumn:g+a,offsetX:_+u,offsetY:f+h})}},Jt={id:"sheet.command.scroll-view",type:l.CommandType.COMMAND,handler:async(i,e)=>{if(!e)return!1;const n=i.get(l.IUniverInstanceService).getCurrentUniverSheetInstance(),r=n.getActiveSheet(),s=i.get(Nt).getCurrentScroll();if(!r)return!1;const a=i.get(l.ICommandService),{sheetViewStartRow:c,sheetViewStartColumn:d,offsetX:u,offsetY:h}=e,{sheetViewStartColumn:m,sheetViewStartRow:g,offsetX:_,offsetY:f}=s||{},{xSplit:C,ySplit:I}=r.getConfig().freeze;return a.executeCommand(on.id,{unitId:n.getUnitId(),sheetId:r.getSheetId(),sheetViewStartRow:c??(g??0)+I,sheetViewStartColumn:d??(m??0)+C,offsetX:u??_,offsetY:h??f})}};l.CommandType.COMMAND;var kd=Object.defineProperty,Vd=Object.getOwnPropertyDescriptor,Fd=(i,e,t,n)=>{for(var r=n>1?void 0:n?Vd(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&kd(e,t,r),r},ht=(i,e)=>(t,n)=>e(t,n,i);const Bd="__SpreadsheetFreezeRowMainName__",jd="__SpreadsheetFreezeRowHeaderName__",Wd="__SpreadsheetFreezeColumnMainName__",zd="__SpreadsheetFreezeColumnHeaderName__",Fi=4,$d=.01;let ri=class extends l.Disposable{constructor(e,t,n,r,o,s,a,c,d,u){super();v(this,"_rowFreezeHeaderRect");v(this,"_rowFreezeMainRect");v(this,"_columnFreezeHeaderRect");v(this,"_columnFreezeMainRect");v(this,"_freezeDownObservers",[]);v(this,"_freezeMoveObservers",[]);v(this,"_freezeLeaveObservers",[]);v(this,"_moveObserver");v(this,"_upObserver");v(this,"_changeToRow",-1);v(this,"_changeToColumn",-1);v(this,"_changeToOffsetX",0);v(this,"_changeToOffsetY",0);v(this,"_activeViewport",null);v(this,"_freezeNormalHeaderColor","");v(this,"_freezeNormalMainColor","");v(this,"_freezeActiveColor","");v(this,"_freezeHoverColor","");v(this,"_lastFreeze");this._sheetSkeletonManagerService=e,this._currentUniverService=t,this._commandService=n,this._renderManagerService=r,this._selectionRenderService=o,this._selectionManagerService=s,this._scrollManagerService=a,this._themeService=c,this._sheetInterceptorService=d,this._injector=u,this._initialize()}dispose(){super.dispose()}_initialize(){this._skeletonListener(),this._commandExecutedListener(),this._themeChangeListener(),this._interceptorCommands(),this._bindViewportScroll()}_createFreeze(e=0,t){var D;const n=t??this._getFreeze();if(n==null)return;const r=(D=this._sheetSkeletonManagerService.getCurrent())==null?void 0:D.skeleton;if(r==null)return;const{startRow:o,startColumn:s}=n,a=this._getPositionByIndex(o,s);if(a==null)return;const c=this._getSheetObject();if(c==null)return;const d=c.engine,u=(d==null?void 0:d.width)||0,h=(d==null?void 0:d.height)||0,m=c.scene,{startX:g,startY:_}=a,{rowTotalHeight:f,columnTotalWidth:C,rowHeaderWidthAndMarginLeft:I,columnHeaderHeightAndMarginTop:w}=r,E=u>C+I?u:C+w,O=h>f+w?h:f+w;this._changeToRow=o,this._changeToColumn=s,this._changeToOffsetX=g,this._changeToOffsetY=_;const x=Math.max(m.scaleX,m.scaleY),N=Fi/(x<1?1:x);if(e===0){const P=N;this._rowFreezeHeaderRect=new y.Rect(jd,{fill:this._freezeNormalHeaderColor,width:I,height:N,left:0,top:_-P,zIndex:3});let L=this._freezeNormalHeaderColor;(o===-1||o===0)&&(L=this._freezeNormalMainColor),this._rowFreezeMainRect=new y.Rect(Bd,{fill:L,width:E*2,height:N,left:I,top:_-P,zIndex:3}),m.addObjects([this._rowFreezeHeaderRect,this._rowFreezeMainRect],At)}else{const P=N;this._columnFreezeHeaderRect=new y.Rect(zd,{fill:this._freezeNormalHeaderColor,width:N,height:w,left:g-P,top:0,zIndex:3});let L=this._freezeNormalHeaderColor;(s===-1||s===0)&&(L=this._freezeNormalMainColor),this._columnFreezeMainRect=new y.Rect(Wd,{fill:L,width:N,height:O*2,left:g-P,top:w,zIndex:3}),m.addObjects([this._columnFreezeHeaderRect,this._columnFreezeMainRect],At)}this._eventBinding(e)}_eventBinding(e=0){let t=this._rowFreezeHeaderRect,n=this._rowFreezeMainRect;e===1&&(t=this._columnFreezeHeaderRect,n=this._columnFreezeMainRect);const r=this._getSheetObject();if(r==null)return;const{scene:o}=r;this._freezeMoveObservers.push(t==null?void 0:t.onPointerEnterObserver.add(()=>{t==null||t.setProps({fill:this._freezeHoverColor,zIndex:4}),o.setCursor(y.CURSOR_TYPE.GRAB)})),this._freezeMoveObservers.push(n==null?void 0:n.onPointerEnterObserver.add(()=>{t==null||t.setProps({fill:this._freezeHoverColor,zIndex:4}),o.setCursor(y.CURSOR_TYPE.GRAB)})),this._freezeLeaveObservers.push(t==null?void 0:t.onPointerLeaveObserver.add(()=>{t==null||t.setProps({fill:this._freezeNormalHeaderColor,zIndex:3}),o.resetCursor()})),this._freezeLeaveObservers.push(n==null?void 0:n.onPointerLeaveObserver.add(()=>{t==null||t.setProps({fill:this._freezeNormalHeaderColor,zIndex:3}),o.resetCursor()})),this._freezeDownObservers.push(t==null?void 0:t.onPointerDownObserver.add(s=>{this._freezeDown(s,t,n,e)})),this._freezeDownObservers.push(n==null?void 0:n.onPointerDownObserver.add(s=>{this._freezeDown(s,t,n,e)}))}_getCurrentLastVisibleRow(){var h;const e=this._getSheetObject();if(e==null)return;const t=(h=this._sheetSkeletonManagerService.getCurrent())==null?void 0:h.skeleton;if(t==null)return;const n=e.scene,r=Math.max(n.scaleX,n.scaleY),o=this._scrollManagerService.getCurrentScroll(),s=(e.engine.height-t.columnHeaderHeight)/r,a=(o==null?void 0:o.sheetViewStartRow)??0,c=a===0?-((o==null?void 0:o.offsetY)??0):t.rowHeightAccumulation[a-1]-((o==null?void 0:o.offsetY)??0);let d=0,u=!1;for(let m=a,g=t.rowHeightAccumulation.length;m<g;m++)if(t.rowHeightAccumulation[m]-c>s){d=m,u=!0;break}return u||(d=t.rowHeightAccumulation.length-1),d}_getActiveViewport(e){var n;const t=(n=this._getSheetObject())==null?void 0:n.scene.getViewports();return t&&t.find(r=>r.isHit(new y.Vector2(e.offsetX,e.offsetY)))||null}_freezeDown(e,t,n,r=0){var h;const o=(h=this._sheetSkeletonManagerService.getCurrent())==null?void 0:h.skeleton;if(o==null)return;const s=this._getSheetObject();if(s==null)return;const{scene:a}=s;a.setCursor(y.CURSOR_TYPE.GRABBING),a.disableEvent();const c=this._getCurrentLastVisibleRow(),d=c===void 0?1/0:o.rowHeightAccumulation[c];this._activeViewport=null;const u=this._getFreeze();u&&(this._changeToColumn=u.startColumn,this._changeToRow=u.startRow),this._moveObserver=a.onPointerMoveObserver.add(m=>{var E,O,x,N;const g=this._getActiveViewport(m),{startX:_,startY:f,row:C,column:I}=tn(m.offsetX,m.offsetY,a,o,g||void 0);a.setCursor(y.CURSOR_TYPE.GRABBING);const w=Fi/Math.max(a.scaleX,a.scaleY);r===0?((E=t.transformByState({top:Math.min(f,d)-w/2}))==null||E.setProps({fill:this._freezeActiveColor}),(O=n.transformByState({top:Math.min(f,d)-w/2}))==null||O.setProps({fill:this._freezeNormalHeaderColor}),this._changeToRow=c===void 0?C:Math.min(C,c),this._changeToOffsetY=Math.min(f,d),this._activeViewport=g):((x=t.transformByState({left:_-w/2}))==null||x.setProps({fill:this._freezeActiveColor}),(N=n.transformByState({left:_-w/2}))==null||N.setProps({fill:this._freezeNormalHeaderColor}),this._changeToColumn=I,this._changeToOffsetX=_,this._activeViewport=g)}),this._upObserver=a.onPointerUpObserver.add(()=>{var P,L;a.resetCursor(),a.enableEvent(),this._clearObserverEvent();const{rowHeaderWidthAndMarginLeft:m,columnHeaderHeightAndMarginTop:g}=o;r===0&&(this._changeToRow===0||this._changeToRow===-1)||r===1&&(this._changeToColumn===0||this._changeToColumn===-1)?(t.setProps({fill:this._freezeNormalHeaderColor}),n.setProps({fill:this._freezeNormalMainColor})):(t==null||t.setProps({fill:this._freezeNormalHeaderColor}),n==null||n.setProps({fill:this._freezeNormalHeaderColor}));const _=Fi/Math.max(a.scaleX,a.scaleY);r===0?(this._changeToRow===0||this._changeToRow===-1)&&(t.transformByState({top:g-_}),n.transformByState({top:g-_})):(this._changeToColumn===0||this._changeToColumn===-1)&&(t.transformByState({left:m-_}),n.transformByState({left:m-_}));const f=this._scrollManagerService.getCurrentScroll()||{sheetViewStartRow:0,sheetViewStartColumn:0},{sheetViewStartRow:C,sheetViewStartColumn:I}=f;if(I==null||C==null)return;const w=this._currentUniverService.getCurrentUniverSheetInstance(),E=w.getActiveSheet(),O=(P=E.getConfig())==null?void 0:P.freeze;let x=(O==null?void 0:O.xSplit)||0,N=(O==null?void 0:O.ySplit)||0;const D=(L=this._activeViewport)==null?void 0:L.viewPortKey;r===0&&(!D||D===Q.VIEW_LEFT_TOP||D===Q.VIEW_MAIN_LEFT_TOP||D===Q.VIEW_MAIN_TOP||D===Q.VIEW_ROW_TOP?N=this._changeToRow-(O.startRow-O.ySplit):N=this._changeToRow-C,N=N<0?0:N),r===1&&(!D||D===Q.VIEW_LEFT_TOP||D===Q.VIEW_MAIN_LEFT_TOP||D===Q.VIEW_MAIN_LEFT||D===Q.VIEW_COLUMN_LEFT?x=this._changeToColumn-(O.startColumn-O.xSplit):x=this._changeToColumn-I,x=x<0?0:x),this._commandService.executeCommand(p.SetFrozenCommand.id,{startRow:N===0?-1:this._changeToRow,startColumn:x===0?-1:this._changeToColumn,ySplit:N,xSplit:x,unitId:w.getUnitId(),subUnitId:E.getSheetId()})})}_getViewports(){const e=this._getSheetObject();if(e==null)return;const{scene:t}=e,n=t.getViewport(Q.VIEW_COLUMN_LEFT),r=t.getViewport(Q.VIEW_COLUMN_RIGHT),o=t.getViewport(Q.VIEW_ROW_TOP),s=t.getViewport(Q.VIEW_ROW_BOTTOM),a=t.getViewport(Q.VIEW_LEFT_TOP),c=t.getViewport(Q.VIEW_MAIN),d=t.getViewport(Q.VIEW_MAIN_LEFT_TOP),u=t.getViewport(Q.VIEW_MAIN_LEFT),h=t.getViewport(Q.VIEW_MAIN_TOP);if(!(n==null||r==null||o==null||s==null||a==null||c==null||d==null||u==null||h==null))return{viewMain:c,viewMainLeftTop:d,viewMainLeft:u,viewMainTop:h,viewColumnLeft:n,viewColumnRight:r,viewRowTop:o,viewRowBottom:s,viewLeftTop:a}}_bindViewportScroll(){const e=this._getViewports();if(!e)return;const{viewMain:t,viewRowBottom:n,viewColumnRight:r,viewMainLeft:o,viewMainTop:s}=e;this.disposeWithMe(t.onScrollAfterObserver.add(a=>{const{scrollX:c,scrollY:d,actualScrollX:u,actualScrollY:h}=a;n.isActive&&n.updateScroll({scrollY:d,actualScrollY:h}).makeDirty(!0),r.isActive&&r.updateScroll({scrollX:c,actualScrollX:u}).makeDirty(!0),o.isActive&&o.updateScroll({scrollY:d,actualScrollY:h}).makeDirty(!0),s.isActive&&s.updateScroll({scrollX:c,actualScrollX:u}).makeDirty(!0)}))}_updateViewport(e=-1,t=-1,n=0,r=0,o=3){var D;const s=(D=this._sheetSkeletonManagerService.getCurrent())==null?void 0:D.skeleton;if(s==null)return;const{rowHeaderWidthAndMarginLeft:a,columnHeaderHeightAndMarginTop:c}=s,d=this._getViewports();if(!d)return;const{viewMain:u,viewMainLeftTop:h,viewMainLeft:m,viewMainTop:g,viewColumnLeft:_,viewColumnRight:f,viewRowTop:C,viewRowBottom:I,viewLeftTop:w}=d;f.resize({left:a,top:0,height:c,right:0}),I.resize({left:0,top:c,bottom:0,width:a}),w.resize({left:0,top:0,width:a,height:c});let E=!0,O=!0;h.enable(),(e===-1||e===0)&&(E=!1),(t===-1||t===0)&&(O=!1);const x=s.getNoMergeCellPositionByIndexWithNoHeader(e-n,t-r),N=s.getNoMergeCellPositionByIndexWithNoHeader(e,t);if(h.disable(),g.disable(),m.disable(),C.disable(),_.disable(),h.resetPadding(),g.resetPadding(),m.resetPadding(),C.resetPadding(),_.resetPadding(),E===!1&&O===!1)u.resize({left:a,top:c,bottom:0,right:0}),u.resetPadding();else if(E===!0&&O===!1){const P=N.startY-x.startY;u.resize({left:a,top:c+P,bottom:0,right:0}),u.setPadding({startY:x.startY,endY:N.startY,startX:0,endX:0}),o&2&&this._commandService.executeCommand(Jt.id,{sheetViewStartRow:0,offsetY:0}),g.resize({left:a,top:c,height:P,right:0}),g.updateScroll({actualScrollY:x.startY,x:u.scrollX,actualScrollX:u.actualScrollX}).makeDirty(!0),C.resize({left:0,top:c,width:a,height:P}),C.updateScroll({actualScrollY:x.startY}).makeDirty(!0),I.resize({left:0,top:c+P,bottom:0,width:a}),g.enable(),C.enable()}else if(E===!1&&O===!0){const P=N.startX-x.startX;u.resize({left:a+P,top:c,bottom:0,right:0}),u.setPadding({startX:x.startX,endX:N.startX,startY:0,endY:0}),o&1&&this._commandService.executeCommand(Jt.id,{sheetViewStartColumn:0,offsetX:0}),m.resize({left:a,top:c,width:P,bottom:0,right:0}),m.updateScroll({actualScrollX:x.startX,y:u.scrollY,actualScrollY:u.actualScrollY}).makeDirty(!0),_.resize({left:a,top:0,width:P,height:c}),_.updateScroll({actualScrollX:x.startX}).makeDirty(!0),f.resize({left:a+P,top:0,height:c,right:0}),m.enable(),_.enable()}else{const P=N.startX-x.startX,L=N.startY-x.startY;u.resize({left:a+P,top:c+L,bottom:0,right:0}),u.setPadding({startY:x.startY,endY:N.startY,startX:x.startX,endX:N.startX}),o&&this._commandService.executeCommand(Jt.id,{...o&1?{sheetViewStartColumn:0,offsetX:0}:null,...o&2?{sheetViewStartRow:0,offsetY:0}:null}),m.resize({left:a,top:c+L,width:P,bottom:0}),m.updateScroll({actualScrollX:x.startX,y:u.scrollY,actualScrollY:u.actualScrollY}).makeDirty(!0),g.resize({left:a+P,top:c,height:L,right:0}),g.updateScroll({actualScrollY:x.startY,x:u.scrollX,actualScrollX:u.actualScrollX}).makeDirty(!0),h.resize({left:a,top:c,width:P,height:L}),h.updateScroll({actualScrollX:x.startX,actualScrollY:x.startY}).makeDirty(!0),C.resize({left:0,top:c,width:a,height:L}),C.updateScroll({actualScrollY:x.startY}).makeDirty(!0),I.resize({left:0,top:c+L,bottom:0,width:a}),_.resize({left:a,top:0,width:P,height:c}),_.updateScroll({actualScrollX:x.startX}).makeDirty(!0),f.resize({left:a+P,top:0,height:c,right:0}),h.enable(),g.enable(),m.enable(),C.enable(),_.enable()}}_skeletonListener(){this.disposeWithMe(l.toDisposable(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(e=>{[p.SetWorksheetActiveOperation.id].includes((e==null?void 0:e.commandId)||"")&&this._refreshCurrent()})))}_refreshCurrent(){const n=this._currentUniverService.getCurrentUniverSheetInstance().getActiveSheet().getConfig().freeze,{startRow:r=-1,startColumn:o=-1,ySplit:s=0,xSplit:a=0}=n;this._refreshFreeze(r,o,s,a,0)}_themeChangeListener(){this._themeChange(this._themeService.getCurrentTheme()),this.disposeWithMe(l.toDisposable(this._themeService.currentTheme$.subscribe(e=>{this._clearFreeze(),this._themeChange(e),this._refreshCurrent()})))}_themeChange(e){this._freezeNormalHeaderColor=e.grey400,this._freezeNormalMainColor=new l.ColorKit(e.grey400).setAlpha($d).toRgbString(),this._freezeActiveColor=e.primaryColor,this._freezeHoverColor=e.grey500}_interceptorCommands(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{const t={redos:[],undos:[]},n=this._getFreeze();if(!n)return t;const r=o=>{const s=this._currentUniverService.getCurrentUniverSheetInstance(),a=s.getUnitId(),d=s.getActiveSheet().getSheetId();this._refreshFreeze(o.startRow,o.startColumn,o.ySplit,o.xSplit,0);const u={...o,unitId:a,subUnitId:d,resetScroll:!1},h=p.SetFrozenMutationFactory(this._injector,u);return{undos:[{id:p.SetFrozenMutation.id,params:h}],redos:[{id:p.SetFrozenMutation.id,params:u}]}};if(e.id===p.MoveColsCommand.id){const o=this._selectionManagerService.getSelections(),{fromRange:{startColumn:s},toRange:{startColumn:a}}=e.params,c=o==null?void 0:o.filter(C=>C.range.rangeType===l.RANGE_TYPE.COLUMN&&C.range.startColumn<=s&&s<=C.range.endColumn);if(!(c!=null&&c.length))return t;const d=c[0].range,u={...d,startColumn:a,endColumn:a+d.endColumn-d.startColumn};if(!n||n.startColumn<=0||d.startColumn>=n.startColumn&&u.startColumn>=n.startColumn||d.startColumn===u.startColumn||d.endColumn<n.startColumn&&u.startColumn<n.startColumn)return t;const h=d.endColumn-d.startColumn+1,m=Math.max(Math.min(n.startColumn,d.endColumn+1)-d.startColumn,0);let g,_;u.startColumn>=n.startColumn?(g=Math.max(n.startColumn-m,1),_=Math.max(n.xSplit-m,1)):(g=n.startColumn+h-m,_=n.xSplit+h-m);const f={...n,startColumn:g,xSplit:_};return r(f)}if(e.id===p.MoveRowsCommand.id){const o=this._selectionManagerService.getSelections(),{fromRange:{startRow:s},toRange:{startRow:a}}=e.params,c=o==null?void 0:o.filter(C=>C.range.rangeType===l.RANGE_TYPE.ROW&&C.range.startRow<=s&&s<=C.range.endRow);if(!(c!=null&&c.length))return t;const d=c[0].range,u={...d,startRow:a,endRow:a+d.endRow-d.startRow};if(!n||n.startRow<=0||d.startRow>=n.startRow&&u.startRow>=n.startRow||d.startRow===u.startRow||d.endRow<n.startRow&&u.startRow<n.startRow)return t;const h=d.endRow-d.startRow+1,m=Math.max(Math.min(n.startRow,d.endRow+1)-d.startRow,0);let g,_;u.startRow>=n.startRow?(g=Math.max(n.startRow-m,1),_=Math.max(n.ySplit-m,1)):(g=n.startRow+h-m,_=n.ySplit+h-m);const f={...n,startRow:g,ySplit:_};return r(f)}if(e.id===p.RemoveColCommand.id||e.id===p.RemoveRowCommand.id){const o=e.params,s=o.range;if(s.rangeType===l.RANGE_TYPE.COLUMN&&s.startColumn<n.startColumn){const a=Math.min(n.startColumn,s.endColumn+1)-s.startColumn,c={...n,startColumn:Math.max(1,n.startColumn-a),xSplit:Math.max(1,n.xSplit-a)};return r(c)}if(o.range.rangeType===l.RANGE_TYPE.ROW&&s.startRow<n.startRow){const a=Math.min(n.startRow,s.endRow+1)-s.startRow,c={...n,startRow:Math.max(1,n.startRow-a),ySplit:Math.max(1,n.ySplit-a)};return r(c)}}return t}}))}_commandExecutedListener(){const e=[p.SetFrozenMutation.id,bt.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(e.includes(t.id)){const n=this._lastFreeze,r=this._currentUniverService.getCurrentUniverSheetInstance(),o=r.getActiveSheet(),s=t.params,{unitId:a,subUnitId:c}=s;if(!(a===r.getUnitId()&&c===o.getSheetId()))return;const d=o.getConfig().freeze;if(this._lastFreeze=d,d==null)return;let u=0;const{startRow:h=-1,startColumn:m=-1,ySplit:g=0,xSplit:_=0}=d;(!n||n.startRow!==h||n.ySplit!==g)&&(u|=2),(!n||n.startColumn!==m||n.xSplit!==_)&&(u|=1),s.resetScroll===!1&&(u=0),this._refreshFreeze(h,m,g,_,u)}else if(t.id===p.DeltaRowHeightCommand.id){const n=this._getFreeze();t.params&&n&&t.params.anchorRow<n.startRow&&this._refreshCurrent()}else if(t.id===p.DeltaColumnWidthCommand.id){const n=this._getFreeze();t.params&&n&&t.params.anchorCol<n.startColumn&&this._refreshCurrent()}else if(t.id===p.SetWorksheetRowAutoHeightMutation.id){const n=t.params,r=this._getFreeze();if(r&&r.startRow>-1&&n.rowsAutoHeightInfo.some(o=>o.row<r.startRow)){const o=this._sheetSkeletonManagerService.currentSkeleton$.subscribe(()=>{this._refreshCurrent(),setTimeout(()=>{o.unsubscribe()})})}}else if(t.id===p.SetColHiddenMutation.id||t.id===p.SetColVisibleMutation.id){const n=t.params,r=this._getFreeze(),o=n.ranges;r&&r.startColumn>-1&&o.some(s=>s.startColumn<r.startColumn)&&this._refreshCurrent()}else if(t.id===p.SetRowHiddenMutation.id||t.id===p.SetRowVisibleMutation.id){const n=t.params,r=this._getFreeze(),o=n.ranges;r&&r.startRow>-1&&o.some(s=>s.startRow<r.startRow)&&this._refreshCurrent()}}))}_clearObserverEvent(){const e=this._getSheetObject();if(e==null)return;const{scene:t}=e;t.onPointerMoveObserver.remove(this._moveObserver),t.onPointerUpObserver.remove(this._upObserver),this._moveObserver=null,this._upObserver=null}_clearFreeze(){var n,r,o,s;(n=this._rowFreezeHeaderRect)==null||n.dispose(),(r=this._rowFreezeMainRect)==null||r.dispose(),(o=this._columnFreezeHeaderRect)==null||o.dispose(),(s=this._columnFreezeMainRect)==null||s.dispose();const e=this._getSheetObject();if(e==null)return;const{scene:t}=e;[...this._freezeDownObservers,...this._freezeMoveObservers,...this._freezeLeaveObservers].forEach(a=>{t.onPointerDownObserver.remove(a),t.onPointerMoveObserver.remove(a),t.onPointerLeaveObserver.remove(a)}),t.onPointerEnterObserver.remove(this._moveObserver),t.onPointerMoveObserver.remove(this._upObserver)}_getPositionByIndex(e,t){var c;if(this._getSheetObject()==null)return;const r=(c=this._sheetSkeletonManagerService.getCurrent())==null?void 0:c.skeleton,o=r==null?void 0:r.getNoMergeCellPositionByIndex(e,t);if(r==null)return;if(o!=null&&(!isNaN(o.endX)||!isNaN(o.endY)))return o;const{rowHeaderWidthAndMarginLeft:s,columnHeaderHeightAndMarginTop:a}=r;return{startX:s,endX:s,startY:a,endY:a}}_getFreeze(){var t;const e=(t=this._sheetSkeletonManagerService.getCurrent())==null?void 0:t.skeleton.getWorksheetConfig();if(e!=null)return e.freeze}_getSheetObject(){return qe(this._currentUniverService,this._renderManagerService)}_refreshFreeze(e,t,n,r,o){var a;const s={startRow:e,startColumn:t,ySplit:n,xSplit:r};this._clearFreeze(),this._createFreeze(0,s),this._createFreeze(1,s),this._updateViewport(e,t,n,r,o),(a=this._getSheetObject())==null||a.spreadsheet.makeForceDirty()}};ri=Fd([l.OnLifecycle(l.LifecycleStages.Rendered,ri),ht(0,j.Inject(exports.SheetSkeletonManagerService)),ht(1,l.IUniverInstanceService),ht(2,l.ICommandService),ht(3,y.IRenderManagerService),ht(4,Ze),ht(5,j.Inject(p.SelectionManagerService)),ht(6,j.Inject(Nt)),ht(7,j.Inject(l.ThemeService)),ht(8,j.Inject(p.SheetInterceptorService)),ht(9,j.Inject(j.Injector))],ri);var nr=(i=>(i[i.NORMAL=0]="NORMAL",i[i.HIGHLIGHT=1]="HIGHLIGHT",i))(nr||{});const Yd="rgba(0, 0, 0, 0.15)",Rt="rgb(0, 0, 0)",Bn="rgb(255, 255, 255, 1)";class Xd extends y.Shape{constructor(t,n){super(t,n);v(this,"_size",12);v(this,"_iconRatio",.4);v(this,"_mode",0);this.setShapeProps(n)}setShapeProps(t){t!=null&&t.size&&(this._size=t.size),t!=null&&t.mode&&(this._mode=t.mode),this.transformByState({width:this._size,height:this._size})}_draw(t){this._mode===1&&y.Rect.drawWith(t,{width:this._size,height:this._size,radius:this._size,fill:Yd});const n=this._size*.5*this._iconRatio,r=Math.PI/180*60,o=n*Math.sin(r),s=n*Math.cos(r);y.RegularPolygon.drawWith(t,{pointsGroup:[[{x:-o+this._size/2,y:-s+this._size/2},{x:o+this._size/2,y:-s+this._size/2},{x:this._size/2,y:n+this._size/2}]],fill:Rt})}}var Zd=Object.defineProperty,Gd=Object.getOwnPropertyDescriptor,Kd=(i,e,t,n)=>{for(var r=n>1?void 0:n?Gd(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&Zd(e,t,r),r},fn=(i,e)=>(t,n)=>e(t,n,i);const qd="__SpreadsheetHeaderMenuSHAPEControllerShape__",Jd="__SpreadsheetHeaderMenuMAINControllerShape__",Qd="rgba(0, 0, 0, 0.1)";let oi=class extends l.Disposable{constructor(e,t,n,r,o){super();v(this,"_hoverRect");v(this,"_hoverMenu");v(this,"_currentColumn",1/0);v(this,"_observers",[]);this._sheetSkeletonManagerService=e,this._currentUniverService=t,this._renderManagerService=n,this._contextMenuService=r,this._selectionManagerService=o,this._initialize()}dispose(){var r,o;(r=this._hoverRect)==null||r.dispose(),(o=this._hoverMenu)==null||o.dispose();const e=this._getSheetObject();if(e==null)return;const{spreadsheetRowHeader:t,spreadsheetColumnHeader:n}=e;this._observers.forEach(s=>{t.onPointerEnterObserver.remove(s),t.onPointerMoveObserver.remove(s),t.onPointerLeaveObserver.remove(s),n.onPointerEnterObserver.remove(s),n.onPointerMoveObserver.remove(s),n.onPointerLeaveObserver.remove(s)})}_initialize(){const e=this._getSheetObject();if(e==null)return;const{scene:t}=e;this._hoverRect=new y.Rect(qd,{fill:Qd,evented:!1}),this._hoverMenu=new Xd(Jd,{zIndex:100,visible:!1}),t.addObjects([this._hoverRect,this._hoverMenu],At),this._initialHover(0),this._initialHover(1),this._initialHoverMenu()}_initialHover(e=0){const t=this._getSheetObject();if(t==null)return;const{spreadsheetColumnHeader:n,spreadsheetRowHeader:r}=t,o=e===0?r:n;this._observers.push(o==null?void 0:o.onPointerEnterObserver.add(()=>{var s;(s=this._hoverRect)==null||s.show()})),this._observers.push(o==null?void 0:o.onPointerMoveObserver.add(s=>{var C,I,w;const a=(C=this._sheetSkeletonManagerService.getCurrent())==null?void 0:C.skeleton;if(a==null)return;const c=this._getSheetObject();if(c==null)return;const{rowHeaderWidth:d,columnHeaderHeight:u}=a,{startX:h,startY:m,endX:g,endY:_,column:f}=tn(s.offsetX,s.offsetY,c.scene,a);if(e===0)(I=this._hoverRect)==null||I.transformByState({width:d,height:_-m,left:0,top:m});else{if(this._currentColumn=f,(w=this._hoverRect)==null||w.transformByState({width:g-h,height:u,left:h,top:0}),this._hoverMenu==null)return;if(g-h<u*2){this._hoverMenu.hide();return}const E=u*.8;this._hoverMenu.transformByState({left:g-u,top:u/2-E/2}),this._hoverMenu.setShapeProps({size:E}),this._hoverMenu.show()}})),this._observers.push(o==null?void 0:o.onPointerLeaveObserver.add(()=>{var s,a;(s=this._hoverRect)==null||s.hide(),(a=this._hoverMenu)==null||a.hide()}))}_initialHoverMenu(){this._hoverMenu!=null&&(this._hoverMenu.onPointerEnterObserver.add(()=>{if(this._hoverMenu==null)return;const e=this._getSheetObject();e!=null&&(this._hoverMenu.setProps({mode:nr.HIGHLIGHT,visible:!0}),e.scene.setCursor(y.CURSOR_TYPE.POINTER))}),this._hoverMenu.onPointerLeaveObserver.add(()=>{if(this._hoverMenu==null)return;const e=this._getSheetObject();e!=null&&(this._hoverMenu.setProps({mode:nr.NORMAL,visible:!1}),e.scene.resetCursor())}),this._hoverMenu.onPointerDownObserver.add(e=>{const t=this._getSheetObject();if(!t)return;const n=this._currentColumn,r=this._selectionManagerService.getSelectionRanges();!!(r!=null&&r.filter(s=>s.rangeType===l.RANGE_TYPE.COLUMN).find(s=>{const{startColumn:a,endColumn:c}=s;return n>=a&&n<=c}))||t.spreadsheetColumnHeader.onPointerDownObserver.notifyObservers(e),e.stopPropagation(),e.preventDefault(),this._contextMenuService.triggerContextMenu(e,Be.COL_HEADER_CONTEXT_MENU)}))}_getSheetObject(){return qe(this._currentUniverService,this._renderManagerService)}};oi=Kd([l.OnLifecycle(l.LifecycleStages.Rendered,oi),fn(0,j.Inject(exports.SheetSkeletonManagerService)),fn(1,l.IUniverInstanceService),fn(2,y.IRenderManagerService),fn(3,R.IContextMenuService),fn(4,j.Inject(p.SelectionManagerService))],oi);var eu=Object.defineProperty,tu=Object.getOwnPropertyDescriptor,nu=(i,e,t,n)=>{for(var r=n>1?void 0:n?tu(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&eu(e,t,r),r},$t=(i,e)=>(t,n)=>e(t,n,i);const iu="__SpreadsheetHeaderMoveControllerBackground__",ru="__SpreadsheetHeaderMoveControllerShapeLine__",ou="rgba(0, 0, 0, 0.1)",su="rgb(119, 119, 119)",au=4;let si=class extends l.Disposable{constructor(e,t,n,r,o,s){super();v(this,"_startOffsetX",-1/0);v(this,"_startOffsetY",-1/0);v(this,"_moveHelperBackgroundShape");v(this,"_moveHelperLineShape");v(this,"_sheetObject");v(this,"_rowOrColumnDownObservers",[]);v(this,"_rowOrColumnMoveObservers",[]);v(this,"_rowOrColumnLeaveObservers",[]);v(this,"_moveObserver");v(this,"_upObserver");v(this,"_scrollTimer");v(this,"_changeFromColumn",-1);v(this,"_changeFromRow",-1);v(this,"_changeToColumn",-1);v(this,"_changeToRow",-1);this._sheetSkeletonManagerService=e,this._currentUniverService=t,this._renderManagerService=n,this._commandService=r,this._selectionRenderService=o,this._selectionManagerService=s,this._initialize()}dispose(){var o,s;(o=this._moveHelperBackgroundShape)==null||o.dispose(),(s=this._moveHelperLineShape)==null||s.dispose();const e=this._getSheetObject();if(e==null)return;const{spreadsheetRowHeader:t,spreadsheetColumnHeader:n,scene:r}=e;[...this._rowOrColumnDownObservers,...this._rowOrColumnMoveObservers,...this._rowOrColumnLeaveObservers].forEach(a=>{t.onPointerDownObserver.remove(a),n.onPointerDownObserver.remove(a)}),r.onPointerMoveObserver.remove(this._moveObserver),r.onPointerUpObserver.remove(this._upObserver),this._scrollTimer.dispose()}_initialize(){const e=this._getSheetObject();e!=null&&(this._sheetObject=e,this._initialRowOrColumn(0),this._initialRowOrColumn(1))}_initialRowOrColumn(e=0){const{spreadsheetColumnHeader:t,spreadsheetRowHeader:n,scene:r}=this._sheetObject,o=e===0?n:t;this._rowOrColumnMoveObservers.push(o==null?void 0:o.onPointerMoveObserver.add(s=>{var h;const a=(h=this._sheetSkeletonManagerService.getCurrent())==null?void 0:h.skeleton;if(a==null)return;const{row:c,column:d}=tn(s.offsetX,s.offsetY,r,a);if(this._checkInHeaderRange(e===0?c:d,e)===!1){r.resetCursor(),this._selectionRenderService.enableSelection();return}r.setCursor(y.CURSOR_TYPE.GRAB),this._selectionRenderService.disableSelection()})),this._rowOrColumnLeaveObservers.push(o==null?void 0:o.onPointerLeaveObserver.add(()=>{var s,a;(s=this._moveHelperBackgroundShape)==null||s.hide(),(a=this._moveHelperLineShape)==null||a.hide(),r.resetCursor(),this._selectionRenderService.enableSelection()})),this._rowOrColumnDownObservers.push(o==null?void 0:o.onPointerDownObserver.add(s=>{var x;const a=(x=this._sheetSkeletonManagerService.getCurrent())==null?void 0:x.skeleton;if(a==null)return;const{offsetX:c,offsetY:d}=s,u=r.getRelativeCoord(y.Vector2.FromArray([c,d])),{x:h,y:m}=u;this._startOffsetX=h,this._startOffsetY=m;const{row:g,column:_}=tn(s.offsetX,s.offsetY,r,a);let f;e===0?(this._changeFromRow=g,f=y.ScrollTimerType.Y):(this._changeFromColumn=_,f=y.ScrollTimerType.X);const C=this._checkInHeaderRange(e===0?g:_,e);if(C===!1)return;const I=r.getScrollXYByRelativeCoords(y.Vector2.FromArray([this._startOffsetX,this._startOffsetY]));this._newBackgroundAndLine(),r.setCursor(y.CURSOR_TYPE.GRABBING),r.disableEvent();let w=!1,E;const O=()=>{if(w)return;E=y.ScrollTimer.create(r,f);const N=r.getViewport(Q.VIEW_MAIN);E.startScroll(h,m,N),this._scrollTimer=E,w=!0};this._moveObserver=r.onPointerMoveObserver.add(N=>{O();const{offsetX:D,offsetY:P}=N,{x:L,y:G}=r.getRelativeCoord(y.Vector2.FromArray([D,P]));r.setCursor(y.CURSOR_TYPE.GRABBING),this._rowColumnMoving(L,G,C,I,e),E.scrolling(L,G,()=>{this._rowColumnMoving(L,G,C,I,e)})}),this._upObserver=r.onPointerUpObserver.add(()=>{var D,P,L;this._disposeBackgroundAndLine(),r.resetCursor(),r.enableEvent(),this._clearObserverEvent(),(D=this._scrollTimer)==null||D.dispose();const N=this._selectionManagerService.getSelections();if(e===0){if(this._changeFromRow!==this._changeToRow&&this._changeToRow!==-1){const k=(P=((N==null?void 0:N.filter(ee=>ee.range.rangeType===l.RANGE_TYPE.ROW&&ee.range.startRow<=this._changeFromRow&&this._changeFromRow<=ee.range.endRow))||[])[0])==null?void 0:P.range;k&&this._commandService.executeCommand(p.MoveRowsCommand.id,{fromRange:k,toRange:{...k,startRow:this._changeToRow,endRow:this._changeToRow+k.endRow-k.startRow}})}this._changeToRow=this._changeFromRow=-1}else{if(this._changeFromColumn!==this._changeToColumn&&this._changeToColumn!==-1){const k=(L=((N==null?void 0:N.filter(ee=>ee.range.rangeType===l.RANGE_TYPE.COLUMN&&ee.range.startColumn<=this._changeFromColumn&&this._changeFromColumn<=ee.range.endColumn))||[])[0])==null?void 0:L.range;k&&this._commandService.executeCommand(p.MoveColsCommand.id,{fromRange:k,toRange:{...k,startColumn:this._changeToColumn,endColumn:this._changeToColumn+k.endColumn-k.startColumn}})}this._changeToColumn=this._changeFromColumn=-1}})}))}_rowColumnMoving(e,t,n,r,o){var ae,Ie,de,Ee,be,De,Oe;const{scene:s}=this._sheetObject,a=(ae=this._sheetSkeletonManagerService.getCurrent())==null?void 0:ae.skeleton;if(a==null)return;const{rowHeaderWidth:c,columnHeaderHeight:d,rowTotalHeight:u,columnTotalWidth:h}=a,m=s.getScrollXY(s.getViewport(Q.VIEW_MAIN)),{scaleX:g,scaleY:_}=s.getAncestorScale(),f=a.getCellPositionByOffset(e,t,g,_,m),{row:C,column:I}=f,w=a.getNoMergeCellPositionByIndex(C,I),{startX:E,startY:O,endX:x,endY:N}=w,D=this._selectionRenderService.convertRangeDataToSelection(n.range);if(D==null)return;const P=Math.max(g,g),{startX:L,endX:G,startY:k,endY:ee,startRow:te,startColumn:W,endRow:V,endColumn:re}=D;o===0?(Ie=this._moveHelperBackgroundShape)==null||Ie.transformByState({height:ee-k,width:h+c,left:0,top:k+(t-this._startOffsetY)/P+m.y-r.y}):(de=this._moveHelperBackgroundShape)==null||de.transformByState({height:u+d,width:G-L,left:L+(e-this._startOffsetX)/P+m.x-r.x,top:0}),(Ee=this._moveHelperBackgroundShape)==null||Ee.show();const q=au/P;if(o===0){let Le=0;if(C<=te)Le=O-q/2,this._changeToRow=C;else if(C>V)Le=N-q/2,this._changeToRow=C+1;else return;(be=this._moveHelperLineShape)==null||be.transformByState({height:q,width:h,left:c,top:Le})}else{let Le=0;if(I<=W)Le=E-q/2,this._changeToColumn=I;else if(I>re)Le=x-q/2,this._changeToColumn=I+1;else return;(De=this._moveHelperLineShape)==null||De.transformByState({height:u,width:q,left:Le,top:d})}(Oe=this._moveHelperLineShape)==null||Oe.show()}_checkInHeaderRange(e,t=0){var a;const n=this._selectionManagerService.getSelections();if(((a=this._selectionManagerService.getCurrent())==null?void 0:a.pluginName)!==p.NORMAL_SELECTION_PLUGIN_NAME)return!1;const o=n==null?void 0:n.find(c=>{const d=c.range,{startRow:u,endRow:h,startColumn:m,endColumn:g}=d;return t===1?e>=m&&e<=g:e>=u&&e<=h}),s=o==null?void 0:o.range;return o==null||s==null||s.rangeType===l.RANGE_TYPE.ALL||s.rangeType===l.RANGE_TYPE.NORMAL||s.rangeType===l.RANGE_TYPE.ROW&&t!==0||s.rangeType===l.RANGE_TYPE.COLUMN&&t!==1?!1:o}_clearObserverEvent(){const{scene:e}=this._sheetObject;e.onPointerMoveObserver.remove(this._moveObserver),e.onPointerUpObserver.remove(this._upObserver),this._moveObserver=null,this._upObserver=null}_newBackgroundAndLine(){const{scene:e}=this._sheetObject;this._moveHelperBackgroundShape=new y.Rect(iu,{fill:ou,evented:!1,zIndex:100}),this._moveHelperLineShape=new y.Rect(ru,{fill:su,evented:!1,zIndex:100}),e.addObjects([this._moveHelperBackgroundShape,this._moveHelperLineShape],At)}_disposeBackgroundAndLine(){var e,t;(e=this._moveHelperBackgroundShape)==null||e.dispose(),(t=this._moveHelperLineShape)==null||t.dispose()}_getSheetObject(){return qe(this._currentUniverService,this._renderManagerService)}};si=nu([l.OnLifecycle(l.LifecycleStages.Rendered,si),$t(0,j.Inject(exports.SheetSkeletonManagerService)),$t(1,l.IUniverInstanceService),$t(2,y.IRenderManagerService),$t(3,l.ICommandService),$t(4,Ze),$t(5,j.Inject(p.SelectionManagerService))],si);var ir=(i=>(i[i.VERTICAL=0]="VERTICAL",i[i.HORIZONTAL=1]="HORIZONTAL",i))(ir||{});const lu="rgba(120, 120, 120, 0.01)",Bi="rgb(68, 71, 70)",Cn=12,rr=4;class Jr extends y.Shape{constructor(t,n){super(t,n);v(this,"_size",Cn);v(this,"_color",Bi);v(this,"_mode",0);this.setShapeProps(n)}get size(){return this._size}get mode(){return this._mode}get color(){return this._color}_draw(t){let{width:n,height:r}=this,o=0,s=0;const a=this.getScene(),{scaleX:c,scaleY:d}=a.getAncestorScale(),u=Math.max(c,d),h=Cn/u,m=rr/u;this.mode===0?(n=m,o=h-m):(r=m,s=h-m),y.Rect.drawWith(t,{width:this.width,height:this.height,left:0,top:0,fill:lu}),y.Rect.drawWith(t,{width:n,height:r,fill:Bi,radius:m}),t.save(),t.transform(1,0,0,1,o,s),y.Rect.drawWith(t,{width:n,height:r,fill:Bi,radius:m}),t.restore()}setShapeProps(t){return t!=null&&t.size&&(this._size=t.size),t!=null&&t.mode&&(this._mode=t.mode),t!=null&&t.color&&(this._color=t.color),this.mode===0?this.transformByState({width:Cn,height:this.size}):this.transformByState({width:this.size,height:Cn}),this}}var cu=Object.defineProperty,du=Object.getOwnPropertyDescriptor,uu=(i,e,t,n)=>{for(var r=n>1?void 0:n?du(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&cu(e,t,r),r},Sn=(i,e)=>(t,n)=>e(t,n,i);const hu="__SpreadsheetHeaderResizeControllerShapeRow__",mu="__SpreadsheetHeaderResizeControllerShapeColumn__",Qr="__SpreadsheetHeaderResizeControllerShapeHelper__",eo="rgb(199, 199, 199)",gu=2;let ai=class extends l.Disposable{constructor(e,t,n,r,o){super();v(this,"_currentRow",0);v(this,"_currentColumn",0);v(this,"_rowResizeRect");v(this,"_columnResizeRect");v(this,"_observers",[]);v(this,"_moveObserver");v(this,"_upObserver");v(this,"_resizeHelperShape");v(this,"_startOffsetX",1/0);v(this,"_startOffsetY",1/0);this._sheetSkeletonManagerService=e,this._currentUniverService=t,this._commandService=n,this._renderManagerService=r,this._editorBridgeService=o,this._initialize()}dispose(){var r,o;(r=this._rowResizeRect)==null||r.dispose(),this._rowResizeRect=null,(o=this._columnResizeRect)==null||o.dispose(),this._columnResizeRect=null;const e=this._getSheetObject();if(e==null)throw new Error("sheetObject is null");const{spreadsheetRowHeader:t,spreadsheetColumnHeader:n}=e;this._observers.forEach(s=>{t.onPointerMoveObserver.remove(s),t.onPointerLeaveObserver.remove(s),n.onPointerMoveObserver.remove(s),n.onPointerLeaveObserver.remove(s)}),this._observers=[]}_initialize(){const e=this._getSheetObject();if(e==null)return;const{scene:t}=e;this._rowResizeRect=new Jr(hu,{visible:!1,mode:ir.HORIZONTAL,zIndex:100}),this._columnResizeRect=new Jr(mu,{visible:!1,mode:ir.VERTICAL,zIndex:100}),t.addObjects([this._rowResizeRect,this._columnResizeRect],At),this._initialHover(0),this._initialHover(1),this._initialHoverResize(0),this._initialHoverResize(1)}_initialHover(e=0){const t=this._getSheetObject();if(t==null)return;const{spreadsheetRowHeader:n,spreadsheetColumnHeader:r,scene:o}=t,s=e===0?n:r;this._observers.push(s==null?void 0:s.onPointerMoveObserver.add((a,c)=>{var D;const d=(D=this._sheetSkeletonManagerService.getCurrent())==null?void 0:D.skeleton;if(d==null||this._rowResizeRect==null||this._columnResizeRect==null)return;const{rowHeaderWidth:u,columnHeaderHeight:h}=d,{startX:m,startY:g,endX:_,endY:f,row:C,column:I}=tn(a.offsetX,a.offsetY,o,d),w=$n(a.offsetX,a.offsetY,o),{scaleX:E,scaleY:O}=o.getAncestorScale(),x=Math.max(E,O),N=Cn/x;if(e===0){let P=g-N/2;if(w.y<=g+N/2&&w.y>=g)this._currentRow=C-1;else if(w.y>=f-N/2&&w.y<=f)this._currentRow=C,P=f-N/2;else{this._rowResizeRect.hide();return}if(this._currentRow===-1)return;const L=u/3;this._rowResizeRect.transformByState({left:u/2-L/2,top:P}),this._rowResizeRect.setShapeProps({size:L}),this._rowResizeRect.show()}else{let P=m-N/2;if(w.x<=m+N/2&&w.x>=m)this._currentColumn=I-1;else if(w.x>=_-N/2&&w.x<=_)this._currentColumn=I,P=_-N/2;else{this._columnResizeRect.hide();return}if(this._currentColumn===-1)return;const L=h*.7;this._columnResizeRect.transformByState({left:P,top:h/2-L/2}),this._columnResizeRect.setShapeProps({size:L}),this._columnResizeRect.show()}})),this._observers.push(s==null?void 0:s.onPointerLeaveObserver.add((a,c)=>{var d,u;(d=this._rowResizeRect)==null||d.hide(),(u=this._columnResizeRect)==null||u.hide()}))}_initialHoverResize(e=0){const t=this._getSheetObject();if(t==null)return;const{scene:n}=t,r=e===0?this._rowResizeRect:this._columnResizeRect;if(r==null)return;const o=n.getEngine(),s=(o==null?void 0:o.width)||0,a=(o==null?void 0:o.height)||0;this.disposeWithMe(l.toDisposable(r.onPointerEnterObserver.add(()=>{r!=null&&(r.show(),n.setCursor(e===0?y.CURSOR_TYPE.ROW_RESIZE:y.CURSOR_TYPE.COLUMN_RESIZE))}))),this.disposeWithMe(l.toDisposable(r.onPointerLeaveObserver.add(()=>{r!=null&&(r.hide(),n.resetCursor())}))),this.disposeWithMe(l.toDisposable(r.onPointerDownObserver.add((c,d)=>{var Ie,de,Ee,be,De,Oe,Le;const u=(Ie=this._sheetSkeletonManagerService.getCurrent())==null?void 0:Ie.skeleton;if(u==null)return;const h=this._getSheetObject();if(h==null)return;const{scene:m}=h,g=m.getViewport(Q.VIEW_MAIN),_=(((Ee=(de=g==null?void 0:g.getScrollBar())==null?void 0:de.horizonBarRect)==null?void 0:Ee.height)||0)+10,f=(((De=(be=g==null?void 0:g.getScrollBar())==null?void 0:be.verticalBarRect)==null?void 0:De.width)||0)+10,C=$n(c.offsetX,c.offsetY,m),{scaleX:I,scaleY:w}=m.getAncestorScale();this._startOffsetX=C.x,this._startOffsetY=C.y;const E=u.getOffsetByPositionX(this._currentColumn),O=u.getOffsetByPositionY(this._currentRow),x=u.getNoMergeCellPositionByIndex(this._currentRow,this._currentColumn);let N=!1,D=0,P=0;const{columnTotalWidth:L,rowHeaderWidth:G,rowTotalHeight:k,columnHeaderHeight:ee}=u,te=s>L+G?s:L+G,W=a>k+ee?a:k+ee,V=Math.max(I,w),re=rr/V;e===0?this._resizeHelperShape=new y.Rect(Qr,{width:te,height:re,fill:eo,left:0,top:O-re/2}):this._resizeHelperShape=new y.Rect(Qr,{width:re,height:W,fill:eo,left:E-re/2,top:0});const q=((Oe=this._columnResizeRect)==null?void 0:Oe.left)||0,ae=((Le=this._rowResizeRect)==null?void 0:Le.top)||0;m.addObject(this._resizeHelperShape,At),m.disableEvent(),this._editorBridgeService.changeVisible({visible:!1,eventType:y.DeviceInputEventType.PointerDown}),this._moveObserver=m.onPointerMoveObserver.add(Se=>{var pt,ft,$e,Ve,He,Qe;const he=m.getRelativeCoord(y.Vector2.FromArray([this._startOffsetX,this._startOffsetY])),ge=m.getScrollXYByRelativeCoords(he,g),Ae=$n(Se.offsetX,Se.offsetY,m),{x:we,y:Pe}=Ae,{scaleX:Ue,scaleY:Ne}=m.getAncestorScale(),it=Math.max(Ue,Ne),Fe=rr/it;D=we-this._startOffsetX-Fe/2,P=Pe-this._startOffsetY-Fe/2,Math.abs(e===0?P:D)>=gu&&(N=!0),e===0?(P>a-_+ge.y-x.startY&&(P=a-_+ge.y-x.startY),P<-(x.endY-x.startY)+2&&(P=-(x.endY-x.startY)+2),N&&((pt=this._resizeHelperShape)==null||pt.transformByState({top:O+P}),(ft=this._rowResizeRect)==null||ft.transformByState({top:ae+P+Fe/2}),($e=this._rowResizeRect)==null||$e.show(),m.setCursor(y.CURSOR_TYPE.ROW_RESIZE))):(D>s-f+ge.x-x.startX&&(D=s-f+ge.x-x.startX),D<-(x.endX-x.startX)+2&&(D=-(x.endX-x.startX)+2),N&&((Ve=this._resizeHelperShape)==null||Ve.transformByState({left:E+D}),(He=this._columnResizeRect)==null||He.transformByState({left:q+D+Fe/2}),(Qe=this._columnResizeRect)==null||Qe.show(),m.setCursor(y.CURSOR_TYPE.COLUMN_RESIZE)))}),this._upObserver=m.onPointerUpObserver.add(Se=>{var Ae,we,Pe;const he=qe(this._currentUniverService,this._renderManagerService);if(he==null)return;this._clearObserverEvent(),(Ae=this._resizeHelperShape)==null||Ae.dispose(),this._resizeHelperShape=null;const{scene:ge}=he;ge.enableEvent(),N&&(ge.resetCursor(),(we=this._rowResizeRect)==null||we.hide(),(Pe=this._columnResizeRect)==null||Pe.hide(),e===0?this._commandService.executeCommand(p.DeltaRowHeightCommand.id,{deltaY:P,anchorRow:this._currentRow}):this._commandService.executeCommand(p.DeltaColumnWidthCommand.id,{deltaX:D,anchorCol:this._currentColumn}))})}))),this.disposeWithMe(l.toDisposable(r.onDblclickObserver.add(()=>{var c;if(e===0){const d=this._getSheetObject();if(d==null)return;const{scene:u}=d;u.resetCursor(),this._commandService.executeCommand(p.SetWorksheetRowIsAutoHeightCommand.id,{anchorRow:this._currentRow}),(c=this._rowResizeRect)==null||c.hide()}})))}_clearObserverEvent(){const e=this._getSheetObject();if(e==null)return;const{scene:t}=e;t.onPointerMoveObserver.remove(this._moveObserver),t.onPointerUpObserver.remove(this._upObserver),this._moveObserver=null,this._upObserver=null}_getSheetObject(){return qe(this._currentUniverService,this._renderManagerService)}};ai=uu([l.OnLifecycle(l.LifecycleStages.Rendered,ai),Sn(0,j.Inject(exports.SheetSkeletonManagerService)),Sn(1,l.IUniverInstanceService),Sn(2,l.ICommandService),Sn(3,y.IRenderManagerService),Sn(4,at)],ai);var or=(i=>(i[i.ROW=0]="ROW",i[i.COLUMN=1]="COLUMN",i))(or||{});const Rn=12,_u=.4;class to extends y.Shape{constructor(t,n,r){super(t,n);v(this,"_size",Rn);v(this,"_iconRatio",_u);v(this,"_hovered",!0);v(this,"_hasPrevious",!0);v(this,"_hasNext",!0);v(this,"_unhideType");n&&this.setShapeProps(n),this.onPointerEnterObserver.add(()=>this.setShapeProps({hovered:!0})),this.onPointerLeaveObserver.add(()=>this.setShapeProps({hovered:!1})),this.onPointerDownObserver.add(()=>r==null?void 0:r())}setShapeProps(t){t.type!==void 0&&(this._unhideType=t.type),t.hovered!==void 0&&(this._hovered=t.hovered),t.hasPrevious!==void 0&&(this._hasPrevious=t.hasPrevious),t.hasNext!==void 0&&(this._hasNext=t.hasNext),this.transformByState({width:this._size*(this._unhideType===1?2:1),height:this._size*(this._unhideType===0?2:1)})}_draw(t){this._unhideType===0?this._drawOnRow(t):this._drawOnCol(t)}_drawOnRow(t){this._hovered&&(!this._hasNext||!this._hasPrevious?y.Rect.drawWith(t,{width:this._size,height:this._size,stroke:Rt,fill:Bn}):y.Rect.drawWith(t,{width:this._size,height:2*this._size,stroke:Rt,fill:Bn}));const n=this._size*.5*this._iconRatio,r=Math.PI/3,o=n*Math.cos(r),s=n*Math.sin(r);if(this._hasPrevious&&y.RegularPolygon.drawWith(t,{pointsGroup:[[{x:this._size/2,y:this._size/2-s},{x:this._size/2-s,y:this._size/2+o},{x:this._size/2+s,y:this._size/2+o}]],fill:Rt}),this._hasNext){const a=this._hasPrevious?3:1;y.RegularPolygon.drawWith(t,{pointsGroup:[[{x:this._size/2,y:this._size*a/2+s},{x:this._size/2-s,y:this._size*a/2-o},{x:this._size/2+s,y:this._size*a/2-o}]],fill:Rt})}}_drawOnCol(t){this._hovered&&(!this._hasNext||!this._hasPrevious?y.Rect.drawWith(t,{width:this._size,height:this._size,stroke:Rt,fill:Bn}):y.Rect.drawWith(t,{width:2*this._size,height:this._size,stroke:Rt,fill:Bn}));const n=this._size*.5*this._iconRatio,r=Math.PI/3,o=n*Math.cos(r),s=n*Math.sin(r);if(this._hasPrevious&&y.RegularPolygon.drawWith(t,{pointsGroup:[[{x:-o+this._size/2,y:this._size/2},{x:this._size/2+s,y:this._size/2-s},{x:this._size/2+s,y:this._size/2+s}]],fill:Rt}),this._hasNext){const a=this._hasPrevious?3:1;y.RegularPolygon.drawWith(t,{pointsGroup:[[{x:o+this._size*a/2,y:this._size/2},{x:-s+this._size*a/2,y:this._size/2-s},{x:-s+this._size*a/2,y:this._size/2+s}]],fill:Rt})}}}var pu=Object.defineProperty,fu=Object.getOwnPropertyDescriptor,Su=(i,e,t,n)=>{for(var r=n>1?void 0:n?fu(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&pu(e,t,r),r},jn=(i,e)=>(t,n)=>e(t,n,i);const no="__SpreadsheetHeaderUnhideSHAPEControllerShape__",vu=[p.SetRowHiddenMutation.id,p.SetRowVisibleMutation.id,p.SetColHiddenMutation.id,p.SetColVisibleMutation.id];let li=class extends l.RxDisposable{constructor(e,t,n,r){super();v(this,"_shapes",new Map);this._sheetSkeletonManagerService=e,this._cmdSrv=t,this._univerInstanceService=n,this._rendererManagerService=r,this._init()}dispose(){super.dispose()}_init(){if(!this._getSheetObject())return;const t=this._univerInstanceService.getCurrentUniverSheetInstance(),n=t.getActiveSheet();n&&this._initForWorksheet(t,n),this._sheetSkeletonManagerService.currentSkeleton$.pipe(J.takeUntil(this.dispose$)).subscribe(r=>{if(r){const o=this._univerInstanceService.getUniverSheetInstance(r.unitId),s=o.getSheetBySheetId(r.sheetId);this._updateWorksheet(o,s)}}),this.disposeWithMe(this._cmdSrv.onCommandExecuted(r=>{if(!vu.includes(r.id)||!r.params||!r.params.unitId||!r.params.subUnitId)return;const o=this._univerInstanceService.getUniverSheetInstance(r.params.unitId),s=o==null?void 0:o.getSheetBySheetId(r.params.subUnitId);s&&this._updateWorksheet(o,s)}))}_initForWorksheet(e,t){var m;const n=(m=this._sheetSkeletonManagerService.getCurrent())==null?void 0:m.skeleton;if(!n)return;const r=t.getHiddenRows(),o=t.getHiddenCols(),s=this._getSheetObject();if(!s)return;const{scene:a}=s,c=t.getRowCount(),d=r.map(g=>{const{startRow:_,endRow:f}=g,C=tr(_,0,a,n),I=_!==0,w=f!==c-1;return new to(no,{type:or.ROW,hovered:!1,hasPrevious:I,hasNext:w,top:C.startY-(I?Rn:0),left:C.startX-Rn},()=>this._cmdSrv.executeCommand(p.SetSpecificRowsVisibleCommand.id,{unitId:e.getUnitId(),subUnitId:t.getSheetId(),ranges:[g]}))}),u=t.getColumnCount(),h=o.map(g=>{const{startColumn:_,endColumn:f}=g,C=tr(0,_,a,n),I=_!==0,w=f!==u-1;return new to(no,{type:or.COLUMN,hovered:!1,hasPrevious:I,hasNext:w,left:C.startX-(I?Rn:0),top:20-Rn},()=>this._cmdSrv.executeCommand(p.SetSpecificColsVisibleCommand.id,{unitId:e.getUnitId(),subUnitId:t.getSheetId(),ranges:[g]}))});a.addObjects(h,Nr),a.addObjects(d,Nr),this._shapes.set(l.getWorksheetUID(e,t),{cols:h,rows:d})}_updateWorksheet(e,t){const n=this._shapes.get(l.getWorksheetUID(e,t));n==null||n.cols.forEach(r=>r.dispose()),n==null||n.rows.forEach(r=>r.dispose()),this._initForWorksheet(e,t)}_getSheetObject(){return qe(this._univerInstanceService,this._rendererManagerService)}};li=Su([l.OnLifecycle(l.LifecycleStages.Rendered,li),jn(0,j.Inject(exports.SheetSkeletonManagerService)),jn(1,l.ICommandService),jn(2,l.IUniverInstanceService),jn(3,y.IRenderManagerService)],li);var Cu=Object.defineProperty,Ru=Object.getOwnPropertyDescriptor,Iu=(i,e,t,n)=>{for(var r=n>1?void 0:n?Ru(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&Cu(e,t,r),r},ji=(i,e)=>(t,n)=>e(t,n,i);let ci=class extends l.Disposable{constructor(i,e,t){super(),this._markSelectionService=i,this._commandService=e,this._sheetSkeletonManagerService=t,this._initListeners()}_initListeners(){this._addRemoveListener(),this._addRefreshListener()}_addRemoveListener(){const i=[mt.id];this.disposeWithMe(this._commandService.onCommandExecuted(e=>{i.includes(e.id)?this._markSelectionService.removeAllShapes():this._markSelectionService.getShapeMap().forEach((n,r)=>{n.exits.includes(e.id)&&this._markSelectionService.removeShape(r)})}))}_addRefreshListener(){this.disposeWithMe(l.toDisposable(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(i=>{i&&this._markSelectionService.refreshShapes()})))}};ci=Iu([l.OnLifecycle(l.LifecycleStages.Steady,ci),ji(0,j.Inject(On)),ji(1,l.ICommandService),ji(2,j.Inject(exports.SheetSkeletonManagerService))],ci);var bu=Object.defineProperty,Mu=Object.getOwnPropertyDescriptor,wu=(i,e,t,n)=>{for(var r=n>1?void 0:n?Mu(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&bu(e,t,r),r},Wi=(i,e)=>(t,n)=>e(t,n,i);let di=class extends l.Disposable{constructor(e,t,n){super();v(this,"_initialize",()=>{const e=new l.DisposableCollection;this.disposeWithMe(l.toDisposable(this._selectionManagerService.selectionMoveEnd$.subscribe(()=>{e.dispose();const t=this._selectionManagerService.getCurrent();if((t==null?void 0:t.pluginName)!==p.NORMAL_SELECTION_PLUGIN_NAME)return;this._selectionRenderService.getCurrentControls().forEach(r=>{e.add(l.toDisposable(r.selectionMoved$.subscribe(o=>{if(!o)return;const s=r.model.getRange(),a={startRow:s.startRow,startColumn:s.startColumn,endRow:s.endRow,endColumn:s.endColumn,rangeType:s.rangeType},c={startRow:o.startRow,startColumn:o.startColumn,endRow:o.endRow,endColumn:o.endColumn,rangeType:s.rangeType};if(a.startRow===c.startRow&&a.startColumn===c.startColumn||c.startRow<0||c.startColumn<0)return;const d={fromRange:a,toRange:c};this._commandService.executeCommand(p.MoveRangeCommand.id,d)})))})})))});this._selectionRenderService=e,this._selectionManagerService=t,this._commandService=n,this._initialize()}};di=wu([l.OnLifecycle(l.LifecycleStages.Steady,di),Wi(0,j.Inject(Ze)),Wi(1,j.Inject(p.SelectionManagerService)),Wi(2,j.Inject(l.ICommandService))],di);var Tu=Object.defineProperty,yu=Object.getOwnPropertyDescriptor,Eu=(i,e,t,n)=>{for(var r=n>1?void 0:n?yu(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&Tu(e,t,r),r},Yt=(i,e)=>(t,n)=>e(t,n,i);let Qt=class extends l.Disposable{constructor(i,e,t,n,r,o){super(),this._sheetSkeletonManagerService=i,this._currentUniverService=e,this._commandService=t,this._renderManagerService=n,this._selectionManagerService=r,this._scrollManagerService=o,this._initialize()}scrollToVisible(i=!0){var W,V,re;let e,t;const n=this._selectionManagerService.getLast();if(n==null)return;const{startRow:r,startColumn:o,actualRow:s,actualColumn:a}=n.primary,c=i?s:r,d=i?a:o,{rowHeightAccumulation:u,columnWidthAccumulation:h}=((W=this._sheetSkeletonManagerService.getCurrent())==null?void 0:W.skeleton)??{};if(u==null||h==null)return;const m=(V=this._getSheetObject())==null?void 0:V.scene;if(m==null)return;const g=m.getViewport(Q.VIEW_MAIN);if(g==null||this._getSheetObject()==null)return;const f=this._currentUniverService.getCurrentUniverSheetInstance().getActiveSheet(),{startColumn:C,startRow:I,ySplit:w,xSplit:E}=f.getFreeze(),O=g.getBounding(),x=(re=this._sheetSkeletonManagerService.getCurrent())==null?void 0:re.skeleton;if(x==null)return;const{startRow:N,startColumn:D,endRow:P,endColumn:L}=x.getRowColumnSegment(O);if(c>=I&&d>=C-E&&(c<=N&&(e=c),c>=P)){const q=u[c]-g.height;for(let ae=N;ae<=c;ae++)if(u[ae]>=q){e=ae+1;break}}if(d>=C&&c>=I-w&&(d<=D&&(t=d),d>=L)){const q=h[d]-g.width;for(let ae=D;ae<=d;ae++)if(h[ae]>=q){t=ae+1;break}}if(e===void 0&&t===void 0)return;const{sheetViewStartColumn:G,sheetViewStartRow:k,offsetX:ee,offsetY:te}=this._scrollManagerService.getCurrentScroll()||{};this._commandService.executeCommand(Jt.id,{sheetViewStartRow:e??k,sheetViewStartColumn:t??G,offsetX:t===void 0?ee:0,offsetY:e===void 0?te:0})}dispose(){super.dispose()}_initialize(){this._scrollEventBinding(),this._scrollSubscribeBinding(),this._skeletonListener()}_getFreeze(){var e;const i=(e=this._sheetSkeletonManagerService.getCurrent())==null?void 0:e.skeleton.getWorksheetConfig();if(i!=null)return i.freeze}_scrollEventBinding(){var t;const i=(t=this._getSheetObject())==null?void 0:t.scene;if(i==null)return;const e=i.getViewport(Q.VIEW_MAIN);this.disposeWithMe(l.toDisposable(e==null?void 0:e.onScrollAfterObserver.add(n=>{var m;const r=(m=this._sheetSkeletonManagerService.getCurrent())==null?void 0:m.skeleton;if(r==null||n.isTrigger===!1)return;const o=this._getSheetObject();if(r==null||o==null)return;const{actualScrollX:s=0,actualScrollY:a=0}=n,{row:c,column:d,rowOffset:u,columnOffset:h}=r.getDecomposedOffset(s,a);this._scrollManagerService.addOrReplaceNoRefresh({sheetViewStartRow:c,sheetViewStartColumn:d,offsetX:h,offsetY:u})}))),this.disposeWithMe(l.toDisposable(e==null?void 0:e.onScrollByBarObserver.add(n=>{var g;const r=(g=this._sheetSkeletonManagerService.getCurrent())==null?void 0:g.skeleton;if(r==null||n.isTrigger===!1)return;const o=this._getSheetObject();if(r==null||o==null)return;const{actualScrollX:s=0,actualScrollY:a=0}=n,c=this._getFreeze(),{row:d,column:u,rowOffset:h,columnOffset:m}=r.getDecomposedOffset(s,a);this._commandService.executeCommand(Jt.id,{sheetViewStartRow:d+((c==null?void 0:c.ySplit)||0),sheetViewStartColumn:u+((c==null?void 0:c.xSplit)||0),offsetX:m,offsetY:h})})))}_scrollSubscribeBinding(){this.disposeWithMe(l.toDisposable(this._scrollManagerService.scrollInfo$.subscribe(i=>{var _;const e=(_=this._sheetSkeletonManagerService.getCurrent())==null?void 0:_.skeleton,t=this._getSheetObject();if(e==null||t==null)return;const n=t.scene;t.scene.getAncestorScale();const r=n.getViewport(Q.VIEW_MAIN);if(r==null)return;if(i==null){r.scrollTo({x:0,y:0});return}const{sheetViewStartRow:o,sheetViewStartColumn:s,offsetX:a,offsetY:c}=i,{startX:d,startY:u}=e.getCellByIndexWithNoHeader(o,s),h=d+a,m=u+c,g=r.getBarScroll(h,m);r.scrollTo(g)})))}_skeletonListener(){this.disposeWithMe(l.toDisposable(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(i=>{if(i==null)return;const{unitId:e,sheetId:t}=i;this._renderManagerService.getRenderById(e)!=null&&(this._updateSceneSize(i),this._scrollManagerService.setCurrentScroll({unitId:e,sheetId:t}))})))}_updateSceneSize(i){var c;if(i==null)return;const{skeleton:e,unitId:t}=i,n=(c=this._renderManagerService.getRenderById(t))==null?void 0:c.scene;if(e==null||n==null)return;const{rowTotalHeight:r,columnTotalWidth:o,rowHeaderWidthAndMarginLeft:s,columnHeaderHeightAndMarginTop:a}=e;n==null||n.transformByState({width:s+o,height:a+r})}_getSheetObject(){return qe(this._currentUniverService,this._renderManagerService)}};Qt=Eu([l.OnLifecycle(l.LifecycleStages.Rendered,Qt),Yt(0,j.Inject(exports.SheetSkeletonManagerService)),Yt(1,l.IUniverInstanceService),Yt(2,l.ICommandService),Yt(3,y.IRenderManagerService),Yt(4,j.Inject(p.SelectionManagerService)),Yt(5,j.Inject(Nt))],Qt);var Ou=Object.defineProperty,xu=Object.getOwnPropertyDescriptor,Au=(i,e,t,n)=>{for(var r=n>1?void 0:n?xu(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&Ou(e,t,r),r},io=(i,e)=>(t,n)=>e(t,n,i);const Nu=[nt.id,jt.id];let ui=class extends l.Disposable{constructor(i,e){super(),this._commandService=i,this._scrollController=e,this.disposeWithMe(this._commandService.onCommandExecuted(t=>{Nu.includes(t.id)&&this._scrollController.scrollToVisible()}))}};ui=Au([l.OnLifecycle(l.LifecycleStages.Rendered,ui),io(0,l.ICommandService),io(1,j.Inject(Qt))],ui);var Du=Object.defineProperty,Pu=Object.getOwnPropertyDescriptor,Hu=(i,e,t,n)=>{for(var r=n>1?void 0:n?Pu(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&Du(e,t,r),r},Et=(i,e)=>(t,n)=>e(t,n,i);let hi=class extends l.Disposable{constructor(i,e,t,n,r,o,s,a){super(),this._sheetSkeletonManagerService=i,this._currentUniverService=e,this._commandService=t,this._renderManagerService=n,this._selectionRenderService=r,this._selectionManagerService=o,this._themeService=s,this._scrollController=a,this._initialize()}_initialize(){const i=this._currentUniverService.getCurrentUniverSheetInstance(),e=i.getActiveSheet(),t=this._getSheetObject();if(t==null)return;this._initViewMainListener(t),this._initRowHeader(t),this._initColumnHeader(t),this._initLeftTop(t),this._initSelectionChangeListener(),this._initThemeChangeListener(),this._initSkeletonChangeListener(),this._initCommandListener(),this._initUserActionSyncListener();const n=i.getUnitId(),r=e.getSheetId();this._selectionManagerService.setCurrentSelection({pluginName:p.NORMAL_SELECTION_PLUGIN_NAME,unitId:n,sheetId:r})}_getActiveViewport(i){const e=this._getSheetObject();return e==null?void 0:e.scene.getActiveViewportByCoord(y.Vector2.FromArray([i.offsetX,i.offsetY]))}_initViewMainListener(i){const{spreadsheet:e}=i;this.disposeWithMe(l.toDisposable(e==null?void 0:e.onPointerDownObserver.add((t,n)=>{this._selectionRenderService.enableDetectMergedCell(),this._selectionRenderService.eventTrigger(t,e.zIndex+1,l.RANGE_TYPE.NORMAL,this._getActiveViewport(t)),t.button!==2&&n.stopPropagation()})))}_initThemeChangeListener(){this.disposeWithMe(l.toDisposable(this._themeService.currentTheme$.subscribe(()=>{this._selectionRenderService.resetStyle();const i=this._selectionManagerService.getSelections(),e=this._selectionManagerService.getCurrent();i==null||(e==null?void 0:e.pluginName)!==p.NORMAL_SELECTION_PLUGIN_NAME||this._refreshSelection(i)})))}_refreshSelection(i){const e=i.map(t=>{const n=this._selectionRenderService.convertSelectionRangeToData(t);return n.style=p.getNormalSelectionStyle(this._themeService),n});this._selectionRenderService.updateControlForCurrentByRangeData(e)}_initRowHeader(i){const{spreadsheetRowHeader:e,spreadsheet:t}=i;this.disposeWithMe(l.toDisposable(e==null?void 0:e.onPointerDownObserver.add((n,r)=>{this._selectionRenderService.disableDetectMergedCell(),this._selectionRenderService.eventTrigger(n,((t==null?void 0:t.zIndex)||1)+1,l.RANGE_TYPE.ROW,this._getActiveViewport(n),y.ScrollTimerType.Y),n.button!==2&&r.stopPropagation()})))}_initColumnHeader(i){const{spreadsheetColumnHeader:e,spreadsheet:t}=i;this.disposeWithMe(l.toDisposable(e==null?void 0:e.onPointerDownObserver.add((n,r)=>{this._selectionRenderService.disableDetectMergedCell(),this._selectionRenderService.eventTrigger(n,((t==null?void 0:t.zIndex)||1)+1,l.RANGE_TYPE.COLUMN,this._getActiveViewport(n),y.ScrollTimerType.X),n.button!==2&&r.stopPropagation()})))}_initLeftTop(i){const{spreadsheetLeftTopPlaceholder:e}=i;this.disposeWithMe(l.toDisposable(e==null?void 0:e.onPointerDownObserver.add((t,n)=>{var a;const r=(a=this._sheetSkeletonManagerService.getCurrent())==null?void 0:a.skeleton;if(r==null)return;this._selectionRenderService.reset();const o=this._getAllRange(r),s=this._selectionRenderService.convertSelectionRangeToData(o);this._selectionRenderService.addControlToCurrentByRangeData(s),this._selectionRenderService.refreshSelectionMoveStart(),t.button!==2&&n.stopPropagation()})))}_initSelectionChangeListener(){this.disposeWithMe(l.toDisposable(this._selectionManagerService.selectionMoveEnd$.subscribe(i=>{if(this._selectionRenderService.reset(),i!=null)for(const e of i){if(e==null)continue;const t=this._selectionRenderService.convertSelectionRangeToData(e);this._selectionRenderService.addControlToCurrentByRangeData(t)}})))}_initUserActionSyncListener(){this._selectionRenderService.selectionMoveStart$.subscribe(i=>{this._move(i,p.SelectionMoveType.MOVE_START)}),this._selectionRenderService.selectionMoving$.subscribe(i=>{this._move(i,p.SelectionMoveType.MOVING)}),this._selectionRenderService.selectionMoveEnd$.subscribe(i=>{this._move(i,p.SelectionMoveType.MOVE_END),this._scrollController.scrollToVisible(!1)})}_move(i,e){const t=this._currentUniverService.getCurrentUniverSheetInstance(),n=t.getUnitId(),r=t.getActiveSheet().getSheetId(),o=this._selectionManagerService.getCurrent();i==null||i.length===0||this._commandService.executeCommand(p.SetSelectionsOperation.id,{unitId:n,subUnitId:r,type:e,pluginName:(o==null?void 0:o.pluginName)||p.NORMAL_SELECTION_PLUGIN_NAME,selections:i.map(s=>p.convertSelectionDataToRange(s))})}_getSheetObject(){return qe(this._currentUniverService,this._renderManagerService)}_initCommandListener(){const i=[bt.id];this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(i.includes(e.id)){const t=this._currentUniverService.getCurrentUniverSheetInstance(),n=t.getActiveSheet(),r=e.params,{unitId:o,subUnitId:s}=r;if(!(o===t.getUnitId()&&s===n.getSheetId()))return;this._selectionManagerService.refreshSelection()}}))}_initSkeletonChangeListener(){this._sheetSkeletonManagerService.currentSkeleton$.subscribe(i=>{if(i==null)return;const{unitId:e,sheetId:t,skeleton:n}=i,r=this._renderManagerService.getRenderById(e);if(r==null)return;const{scene:o}=r,s=o.getViewport(Q.VIEW_MAIN);this._selectionRenderService.changeRuntime(n,o,s);const a=this._selectionManagerService.getCurrent(),c=(a==null?void 0:a.pluginName)||p.NORMAL_SELECTION_PLUGIN_NAME;if((a==null?void 0:a.unitId)===e&&a.sheetId===t){const d=this._selectionManagerService.getSelections();d!=null&&this._refreshSelection(d)}else this._selectionManagerService.setCurrentSelection({pluginName:c,unitId:e,sheetId:t});c===p.NORMAL_SELECTION_PLUGIN_NAME&&this._selectionManagerService.getLast()==null&&this._selectionManagerService.add([this._getZeroRange(n)])})}_getAllRange(i){return{range:{startRow:0,startColumn:0,endRow:i.getRowCount()-1,endColumn:i.getColumnCount()-1,rangeType:l.RANGE_TYPE.ALL},primary:this._getZeroRange(i).primary,style:null}}_getZeroRange(i){const e=i.mergeData;return p.transformCellDataToSelectionData(0,0,e)||{range:{startRow:0,startColumn:0,endRow:0,endColumn:0},primary:{actualRow:0,actualColumn:0,startRow:0,startColumn:0,endRow:0,endColumn:0,isMerged:!1,isMergedMainCell:!1},style:null}}};hi=Hu([l.OnLifecycle(l.LifecycleStages.Rendered,hi),Et(0,j.Inject(exports.SheetSkeletonManagerService)),Et(1,l.IUniverInstanceService),Et(2,l.ICommandService),Et(3,y.IRenderManagerService),Et(4,Ze),Et(5,j.Inject(p.SelectionManagerService)),Et(6,j.Inject(l.ThemeService)),Et(7,j.Inject(Qt))],hi);var Lu=Object.defineProperty,Uu=Object.getOwnPropertyDescriptor,ku=(i,e,t,n)=>{for(var r=n>1?void 0:n?Uu(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&Lu(e,t,r),r},Xt=(i,e)=>(t,n)=>e(t,n,i);let mi=class extends l.Disposable{constructor(i,e,t,n,r,o){super(),this._sheetSkeletonManagerService=i,this._currentUniverService=e,this._renderManagerService=t,this._commandService=n,this._selectionRenderService=r,this._selectionManagerService=o,this._initialize(),this._commandExecutedListener()}dispose(){super.dispose()}_initialize(){this._initialRenderRefresh()}_initialRenderRefresh(){this.disposeWithMe(l.toDisposable(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(i=>{if(i==null)return;const{skeleton:e,unitId:t,sheetId:n}=i,r=this._currentUniverService.getUniverSheetInstance(t),o=r==null?void 0:r.getSheetBySheetId(n);if(r==null||o==null)return;const s=this._renderManagerService.getRenderById(t);if(s==null)return;const{mainComponent:a,components:c,scene:d}=s,u=a,h=c.get(Xe.ROW),m=c.get(Xe.COLUMN),g=c.get(Xe.LEFT_TOP),{rowHeaderWidth:_,columnHeaderHeight:f}=e;u==null||u.updateSkeleton(e),h==null||h.updateSkeleton(e),m==null||m.updateSkeleton(e),g==null||g.transformByState({width:_,height:f})})))}_commandExecutedListener(){this.disposeWithMe(this._commandService.onCommandExecuted((i,e)=>{var r,o;const t=this._currentUniverService.getCurrentUniverSheetInstance(),n=t.getUnitId();if(p.COMMAND_LISTENER_SKELETON_CHANGE.includes(i.id)){const s=t.getActiveSheet(),a=s.getSheetId(),c=i.params,{unitId:d,subUnitId:u}=c;if(!(d===t.getUnitId()&&u===s.getSheetId()))return;i.id!==p.SetWorksheetActiveOperation.id&&this._sheetSkeletonManagerService.makeDirty({unitId:d,sheetId:a,commandId:i.id},!0),this._sheetSkeletonManagerService.setCurrent({unitId:d,sheetId:a,commandId:i.id})}else p.COMMAND_LISTENER_VALUE_CHANGE.includes(i.id)&&this._sheetSkeletonManagerService.reCalculate();i.type===l.CommandType.MUTATION&&((o=(r=this._renderManagerService.getRenderById(n))==null?void 0:r.mainComponent)==null||o.makeDirty())}))}};mi=ku([l.OnLifecycle(l.LifecycleStages.Ready,mi),Xt(0,j.Inject(exports.SheetSkeletonManagerService)),Xt(1,l.IUniverInstanceService),Xt(2,y.IRenderManagerService),Xt(3,l.ICommandService),Xt(4,Ze),Xt(5,j.Inject(p.SelectionManagerService))],mi);const Mt={type:l.CommandType.COMMAND,id:"sheet.command.add-worksheet-merge",handler:async(i,e)=>{const t=i.get(l.ICommandService),n=i.get(l.IUndoRedoService),r=i.get(l.IUniverInstanceService),o=i.get(R.IConfirmService),s=i.get(l.LocaleService),a=e.unitId,c=e.subUnitId,d=e.selections,u=p.getAddMergeMutationRangeByType(d,e.value),h=r.getUniverSheetInstance(a).getSheetBySheetId(c),m=[],g=[],_=Ko(h,u);if(_&&!await o.confirm({id:"merge.confirm.add-worksheet-merge",title:{title:"merge.confirm.title"},cancelText:s.t("merge.confirm.cancel"),confirmText:s.t("merge.confirm.confirm")}))return!1;const f={unitId:a,subUnitId:c,ranges:u},C={unitId:a,subUnitId:c,ranges:u};m.push({id:p.RemoveWorksheetMergeMutation.id,params:f}),m.push({id:p.AddWorksheetMergeMutation.id,params:C});const I=p.RemoveMergeUndoMutationFactory(i,f),w=p.AddMergeUndoMutationFactory(i,C);if(g.push({id:p.RemoveWorksheetMergeMutation.id,params:w}),g.push({id:p.AddWorksheetMergeMutation.id,params:I}),_){const O=qo(i,a,h,u);m.unshift(...O.redos),g.push(...O.undos)}return l.sequenceExecute(m,t).result?(n.pushUndoRedo({unitID:a,undoMutations:g,redoMutations:m}),!0):!1}},us={type:l.CommandType.COMMAND,id:"sheet.command.add-worksheet-merge-all",handler:async i=>{const e=i.get(l.ICommandService),n=i.get(p.SelectionManagerService).getSelectionRanges();if(!(n!=null&&n.length))return!1;const o=i.get(l.IUniverInstanceService).getCurrentUniverSheetInstance();if(!o)return!1;const s=o.getActiveSheet();if(!s)return!1;const a=o.getUnitId(),c=s.getSheetId();return e.executeCommand(Mt.id,{selections:n,unitId:a,subUnitId:c})}},hs={type:l.CommandType.COMMAND,id:"sheet.command.add-worksheet-merge-vertical",handler:async i=>{const e=i.get(l.ICommandService),n=i.get(p.SelectionManagerService).getSelectionRanges();if(!(n!=null&&n.length))return!1;const o=i.get(l.IUniverInstanceService).getCurrentUniverSheetInstance();if(!o)return!1;const s=o.getActiveSheet();if(!s)return!1;const a=o.getUnitId(),c=s.getSheetId();return e.executeCommand(Mt.id,{value:l.Dimension.COLUMNS,selections:n,unitId:a,subUnitId:c})}},ms={type:l.CommandType.COMMAND,id:"sheet.command.add-worksheet-merge-horizontal",handler:async i=>{const e=i.get(l.ICommandService),n=i.get(p.SelectionManagerService).getSelectionRanges();if(!(n!=null&&n.length))return!1;const o=i.get(l.IUniverInstanceService).getCurrentUniverSheetInstance();if(!o)return!1;const s=o.getActiveSheet();if(!s)return!1;const a=o.getUnitId(),c=s.getSheetId();return e.executeCommand(Mt.id,{value:l.Dimension.ROWS,selections:n,unitId:a,subUnitId:c})}},gs={id:"sheet.command.refill",type:l.CommandType.COMMAND,handler:async(i,e)=>{const t=i.get(xn);return t.applyType=e.type,!0}},_s={id:"sheet.command.remove-sheet-confirm",type:l.CommandType.COMMAND,handler:async(i,e)=>{const{subUnitId:t}=e,n=i.get(R.IConfirmService),r=i.get(l.ICommandService),o=i.get(l.LocaleService);return await n.confirm({id:"merge.confirm.add-worksheet-merge",title:{title:o.t("sheetConfig.deleteSheet")},children:{title:o.t("sheetConfig.deleteSheetContent")},cancelText:o.t("button.cancel"),confirmText:o.t("button.confirm")})?(await r.executeCommand(p.RemoveSheetCommand.id,{subUnitId:t}),!0):!1}},Ai={id:"sheet.command.change-zoom-ratio",type:l.CommandType.COMMAND,handler:async(i,e)=>{if(!e)return!1;const{delta:t,reset:n}=e,r=i.get(l.IUniverInstanceService).getCurrentUniverSheetInstance(),o=r.getActiveSheet(),s=r.getUnitId(),a=o.getSheetId();let c=n?100:Math.round((o.getConfig().zoomRatio+t)*100);c=Math.max(Gi[0],c),c=Math.min(Gi[1],c);const d=c/100;return i.get(l.ICommandService).executeCommand(bt.id,{unitId:s,subUnitId:a,zoomRatio:d})}},vr={id:"sheet.command.set-zoom-ratio",type:l.CommandType.COMMAND,handler:async(i,e)=>{if(!e)return!1;const{unitId:t,subUnitId:n,zoomRatio:r}=e;return i.get(l.ICommandService).executeCommand(bt.id,{unitId:t,subUnitId:n,zoomRatio:r})}},cn=j.createIdentifier("univer.sheetbar-service");class Vu extends l.Disposable{constructor(){super();v(this,"renameId$");v(this,"removeId$");v(this,"scroll$");v(this,"scrollX$");v(this,"addSheet$");v(this,"_renameId$");v(this,"_removeId$");v(this,"_scroll$");v(this,"_scrollX$");v(this,"_addSheet$");v(this,"_currentHandler",null);this._renameId$=new J.Subject,this.renameId$=this._renameId$.asObservable(),this._removeId$=new J.Subject,this.removeId$=this._removeId$.asObservable(),this._scroll$=new J.Subject,this.scroll$=this._scroll$.asObservable(),this._scrollX$=new J.Subject,this.scrollX$=this._scrollX$.asObservable(),this._addSheet$=new J.Subject,this.addSheet$=this._addSheet$.asObservable()}setRenameId(t){this._renameId$.next(t)}setRemoveId(t){this._removeId$.next(t)}setScroll(t){this._scroll$.next(t)}setScrollX(t){this._scrollX$.next(t)}setAddSheet(t){this._addSheet$.next(t)}triggerSheetBarMenu(){var t;(t=this._currentHandler)==null||t.handleSheetBarMenu()}registerSheetBarMenuHandler(t){if(this._currentHandler)throw new Error("There is already a context menu handler!");return this._currentHandler=t,l.toDisposable(()=>{this._currentHandler=null})}}const ps={id:"ui-sheet.command.show-menu-list",type:l.CommandType.OPERATION,handler:async i=>(i.get(cn).triggerSheetBarMenu(),!0)},fs={id:"sheet.operation.rename-sheet",type:l.CommandType.OPERATION,handler:async(i,e)=>{const t=i.get(cn);return e&&t.setRenameId(e.subUnitId),!0}},Fu=()=>S.jsxs("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[S.jsx("path",{d:"M0.98999 1.08218H-0.0100098V0.0821838H0.98999V1.08218Z",fill:"black"}),S.jsx("path",{d:"M5.78992 1.08218H2.78992V0.0821838H5.78992V1.08218Z",fill:"black"}),S.jsx("path",{d:"M7.58984 1.08218H8.58984V0.0821838H7.58984V1.08218Z",fill:"black"}),S.jsx("path",{d:"M14.9152 1.08218H13.9152V0.0821838H14.9152V1.08218Z",fill:"black"}),S.jsx("path",{d:"M16.7151 1.08218H19.7151V0.0821838H16.7151V1.08218Z",fill:"black"}),S.jsx("path",{d:"M22.515 1.08218H21.515V0.0821838H22.515V1.08218Z",fill:"black"}),S.jsx("path",{d:"M27.8405 1.08218H28.8405V0.0821838H27.8405V1.08218Z",fill:"black"}),S.jsx("path",{d:"M33.6404 1.08218H30.6404V0.0821838H33.6404V1.08218Z",fill:"black"}),S.jsx("path",{d:"M35.4403 1.08218H36.4403V0.0821838H35.4403V1.08218Z",fill:"black"}),S.jsx("path",{d:"M42.7657 1.08218H41.7657V0.0821838H42.7657V1.08218Z",fill:"black"}),S.jsx("path",{d:"M44.5657 1.08218H47.5657V0.0821838H44.5657V1.08218Z",fill:"black"}),S.jsx("path",{d:"M50.3656 1.08218H49.3656V0.0821838H50.3656V1.08218Z",fill:"black"}),S.jsx("path",{d:"M55.691 1.08218H56.691V0.0821838H55.691V1.08218Z",fill:"black"}),S.jsx("path",{d:"M61.491 1.08218H58.491V0.0821838H61.491V1.08218Z",fill:"black"}),S.jsx("path",{d:"M63.2909 1.08218H64.2909V0.0821838H63.2909V1.08218Z",fill:"black"}),S.jsx("path",{d:"M70.6163 1.08218H69.6163V0.0821838H70.6163V1.08218Z",fill:"black"}),S.jsx("path",{d:"M72.4163 1.08218H75.4163V0.0821838H72.4163V1.08218Z",fill:"black"}),S.jsx("path",{d:"M78.2162 1.08218H77.2162V0.0821838H78.2162V1.08218Z",fill:"black"}),S.jsx("path",{d:"M83.5416 1.08218H84.5416V0.0821838H83.5416V1.08218Z",fill:"black"}),S.jsx("path",{d:"M89.3416 1.08218H86.3416V0.0821838H89.3416V1.08218Z",fill:"black"}),S.jsx("path",{d:"M91.1415 1.08218H92.1415V0.0821838H91.1415V1.08218Z",fill:"black"}),S.jsx("path",{d:"M98.4669 1.08218H97.4669V0.0821838H98.4669V1.08218Z",fill:"black"}),S.jsx("path",{d:"M100.267 1.08218H103.267V0.0821838H100.267V1.08218Z",fill:"black"}),S.jsx("path",{d:"M106.067 1.08218H105.067V0.0821838H106.067V1.08218Z",fill:"black"}),S.jsx("path",{d:"M111.392 1.08218H112.392V0.0821838H111.392V1.08218Z",fill:"black"}),S.jsx("path",{d:"M117.192 1.08218H114.192V0.0821838H117.192V1.08218Z",fill:"black"}),S.jsx("path",{d:"M118.992 1.08218H119.992V0.0821838H118.992V1.08218Z",fill:"black"})]}),Bu=()=>S.jsxs("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[S.jsx("path",{d:"M-0.0100098 1.15771H0.98999V0.157715H-0.0100098V1.15771Z",fill:"black"}),S.jsx("path",{d:"M2.78992 1.15771H5.78992V0.157715H2.78992V1.15771Z",fill:"black"}),S.jsx("path",{d:"M8.58984 1.15771H7.58984V0.157715H8.58984V1.15771Z",fill:"black"}),S.jsx("path",{d:"M10.3899 1.15771H11.3899V0.157715H10.3899V1.15771Z",fill:"black"}),S.jsx("path",{d:"M19.0903 1.15771H18.0903V0.157715H19.0903V1.15771Z",fill:"black"}),S.jsx("path",{d:"M20.8903 1.15771H23.8903V0.157715H20.8903V1.15771Z",fill:"black"}),S.jsx("path",{d:"M26.6902 1.15771H25.6902V0.157715H26.6902V1.15771Z",fill:"black"}),S.jsx("path",{d:"M28.4902 1.15771H29.4902V0.157715H28.4902V1.15771Z",fill:"black"}),S.jsx("path",{d:"M37.1907 1.15771H36.1907V0.157715H37.1907V1.15771Z",fill:"black"}),S.jsx("path",{d:"M38.9906 1.15771H41.9906V0.157715H38.9906V1.15771Z",fill:"black"}),S.jsx("path",{d:"M44.7905 1.15771H43.7905V0.157715H44.7905V1.15771Z",fill:"black"}),S.jsx("path",{d:"M46.5906 1.15771H47.5906V0.157715H46.5906V1.15771Z",fill:"black"}),S.jsx("path",{d:"M55.291 1.15771H54.291V0.157715H55.291V1.15771Z",fill:"black"}),S.jsx("path",{d:"M57.0909 1.15771H60.0909V0.157715H57.0909V1.15771Z",fill:"black"}),S.jsx("path",{d:"M62.8909 1.15771H61.8909V0.157715H62.8909V1.15771Z",fill:"black"}),S.jsx("path",{d:"M64.6909 1.15771H65.6909V0.157715H64.6909V1.15771Z",fill:"black"}),S.jsx("path",{d:"M73.3914 1.15771H72.3914V0.157715H73.3914V1.15771Z",fill:"black"}),S.jsx("path",{d:"M75.1913 1.15771H78.1913V0.157715H75.1913V1.15771Z",fill:"black"}),S.jsx("path",{d:"M80.9912 1.15771H79.9912V0.157715H80.9912V1.15771Z",fill:"black"}),S.jsx("path",{d:"M82.7913 1.15771H83.7913V0.157715H82.7913V1.15771Z",fill:"black"}),S.jsx("path",{d:"M91.4917 1.15771H90.4917V0.157715H91.4917V1.15771Z",fill:"black"}),S.jsx("path",{d:"M93.2916 1.15771H96.2916V0.157715H93.2916V1.15771Z",fill:"black"}),S.jsx("path",{d:"M99.0916 1.15771H98.0916V0.157715H99.0916V1.15771Z",fill:"black"}),S.jsx("path",{d:"M100.892 1.15771H101.892V0.157715H100.892V1.15771Z",fill:"black"}),S.jsx("path",{d:"M109.592 1.15771H108.592V0.157715H109.592V1.15771Z",fill:"black"}),S.jsx("path",{d:"M111.392 1.15771H114.392V0.157715H111.392V1.15771Z",fill:"black"}),S.jsx("path",{d:"M117.192 1.15771H116.192V0.157715H117.192V1.15771Z",fill:"black"}),S.jsx("path",{d:"M118.992 1.15771H119.992V0.157715H118.992V1.15771Z",fill:"black"})]}),ju=()=>S.jsxs("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[S.jsx("path",{d:"M-0.00842285 1.22449H2.99158V0.224487H-0.00842285V1.22449Z",fill:"black"}),S.jsx("path",{d:"M6.14941 1.22449H9.14941V0.224487H6.14941V1.22449Z",fill:"black"}),S.jsx("path",{d:"M15.3073 1.22449H12.3073V0.224487H15.3073V1.22449Z",fill:"black"}),S.jsx("path",{d:"M18.4651 1.22449H21.4651V0.224487H18.4651V1.22449Z",fill:"black"}),S.jsx("path",{d:"M27.6229 1.22449H24.6229V0.224487H27.6229V1.22449Z",fill:"black"}),S.jsx("path",{d:"M30.7808 1.22449H33.7808V0.224487H30.7808V1.22449Z",fill:"black"}),S.jsx("path",{d:"M39.9386 1.22449H36.9386V0.224487H39.9386V1.22449Z",fill:"black"}),S.jsx("path",{d:"M43.0964 1.22449H46.0964V0.224487H43.0964V1.22449Z",fill:"black"}),S.jsx("path",{d:"M52.2543 1.22449H49.2543V0.224487H52.2543V1.22449Z",fill:"black"}),S.jsx("path",{d:"M55.4121 1.22449H58.4121V0.224487H55.4121V1.22449Z",fill:"black"}),S.jsx("path",{d:"M64.5699 1.22449H61.5699V0.224487H64.5699V1.22449Z",fill:"black"}),S.jsx("path",{d:"M67.7278 1.22449H70.7278V0.224487H67.7278V1.22449Z",fill:"black"}),S.jsx("path",{d:"M76.8856 1.22449H73.8856V0.224487H76.8856V1.22449Z",fill:"black"}),S.jsx("path",{d:"M80.0435 1.22449H83.0435V0.224487H80.0435V1.22449Z",fill:"black"}),S.jsx("path",{d:"M89.2013 1.22449H86.2013V0.224487H89.2013V1.22449Z",fill:"black"}),S.jsx("path",{d:"M92.3591 1.22449H95.3591V0.224487H92.3591V1.22449Z",fill:"black"}),S.jsx("path",{d:"M101.517 1.22449H98.517V0.224487H101.517V1.22449Z",fill:"black"}),S.jsx("path",{d:"M104.675 1.22449H107.675V0.224487H104.675V1.22449Z",fill:"black"}),S.jsx("path",{d:"M113.833 1.22449H110.833V0.224487H113.833V1.22449Z",fill:"black"}),S.jsx("path",{d:"M116.99 1.22449H119.99V0.224487H116.99V1.22449Z",fill:"black"})]}),Wu=()=>S.jsxs("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[S.jsx("path",{d:"M-0.00976562 1.65707H0.990234V0.657074H-0.00976562V1.65707Z",fill:"black"}),S.jsx("path",{d:"M2.32361 1.65707H3.32361V0.657074H2.32361V1.65707Z",fill:"black"}),S.jsx("path",{d:"M5.65698 1.65707H4.65698V0.657074H5.65698V1.65707Z",fill:"black"}),S.jsx("path",{d:"M6.99036 1.65707H7.99036V0.657074H6.99036V1.65707Z",fill:"black"}),S.jsx("path",{d:"M10.3237 1.65707H9.32373V0.657074H10.3237V1.65707Z",fill:"black"}),S.jsx("path",{d:"M11.6571 1.65707H12.6571V0.657074H11.6571V1.65707Z",fill:"black"}),S.jsx("path",{d:"M14.9905 1.65707H13.9905V0.657074H14.9905V1.65707Z",fill:"black"}),S.jsx("path",{d:"M16.3239 1.65707H17.3239V0.657074H16.3239V1.65707Z",fill:"black"}),S.jsx("path",{d:"M19.6572 1.65707H18.6572V0.657074H19.6572V1.65707Z",fill:"black"}),S.jsx("path",{d:"M20.9906 1.65707H21.9906V0.657074H20.9906V1.65707Z",fill:"black"}),S.jsx("path",{d:"M24.324 1.65707H23.324V0.657074H24.324V1.65707Z",fill:"black"}),S.jsx("path",{d:"M25.6573 1.65707H26.6573V0.657074H25.6573V1.65707Z",fill:"black"}),S.jsx("path",{d:"M28.9907 1.65707H27.9907V0.657074H28.9907V1.65707Z",fill:"black"}),S.jsx("path",{d:"M30.3241 1.65707H31.3241V0.657074H30.3241V1.65707Z",fill:"black"}),S.jsx("path",{d:"M33.6575 1.65707H32.6575V0.657074H33.6575V1.65707Z",fill:"black"}),S.jsx("path",{d:"M34.9908 1.65707H35.9908V0.657074H34.9908V1.65707Z",fill:"black"}),S.jsx("path",{d:"M38.3242 1.65707H37.3242V0.657074H38.3242V1.65707Z",fill:"black"}),S.jsx("path",{d:"M39.6576 1.65707H40.6576V0.657074H39.6576V1.65707Z",fill:"black"}),S.jsx("path",{d:"M42.991 1.65707H41.991V0.657074H42.991V1.65707Z",fill:"black"}),S.jsx("path",{d:"M44.3243 1.65707H45.3243V0.657074H44.3243V1.65707Z",fill:"black"}),S.jsx("path",{d:"M47.6577 1.65707H46.6577V0.657074H47.6577V1.65707Z",fill:"black"}),S.jsx("path",{d:"M48.9911 1.65707H49.9911V0.657074H48.9911V1.65707Z",fill:"black"}),S.jsx("path",{d:"M52.3245 1.65707H51.3245V0.657074H52.3245V1.65707Z",fill:"black"}),S.jsx("path",{d:"M53.6578 1.65707H54.6578V0.657074H53.6578V1.65707Z",fill:"black"}),S.jsx("path",{d:"M56.9912 1.65707H55.9912V0.657074H56.9912V1.65707Z",fill:"black"}),S.jsx("path",{d:"M58.3246 1.65707H59.3246V0.657074H58.3246V1.65707Z",fill:"black"}),S.jsx("path",{d:"M61.658 1.65707H60.658V0.657074H61.658V1.65707Z",fill:"black"}),S.jsx("path",{d:"M62.9913 1.65707H63.9913V0.657074H62.9913V1.65707Z",fill:"black"}),S.jsx("path",{d:"M66.3247 1.65707H65.3247V0.657074H66.3247V1.65707Z",fill:"black"}),S.jsx("path",{d:"M67.6581 1.65707H68.6581V0.657074H67.6581V1.65707Z",fill:"black"}),S.jsx("path",{d:"M70.9915 1.65707H69.9915V0.657074H70.9915V1.65707Z",fill:"black"}),S.jsx("path",{d:"M72.3248 1.65707H73.3248V0.657074H72.3248V1.65707Z",fill:"black"}),S.jsx("path",{d:"M75.6582 1.65707H74.6582V0.657074H75.6582V1.65707Z",fill:"black"}),S.jsx("path",{d:"M76.9916 1.65707H77.9916V0.657074H76.9916V1.65707Z",fill:"black"}),S.jsx("path",{d:"M80.325 1.65707H79.325V0.657074H80.325V1.65707Z",fill:"black"}),S.jsx("path",{d:"M81.6583 1.65707H82.6583V0.657074H81.6583V1.65707Z",fill:"black"}),S.jsx("path",{d:"M84.9917 1.65707H83.9917V0.657074H84.9917V1.65707Z",fill:"black"}),S.jsx("path",{d:"M86.3251 1.65707H87.3251V0.657074H86.3251V1.65707Z",fill:"black"}),S.jsx("path",{d:"M89.6584 1.65707H88.6584V0.657074H89.6584V1.65707Z",fill:"black"}),S.jsx("path",{d:"M90.9918 1.65707H91.9918V0.657074H90.9918V1.65707Z",fill:"black"}),S.jsx("path",{d:"M94.3252 1.65707H93.3252V0.657074H94.3252V1.65707Z",fill:"black"}),S.jsx("path",{d:"M95.6586 1.65707H96.6586V0.657074H95.6586V1.65707Z",fill:"black"}),S.jsx("path",{d:"M98.9919 1.65707H97.9919V0.657074H98.9919V1.65707Z",fill:"black"}),S.jsx("path",{d:"M100.325 1.65707H101.325V0.657074H100.325V1.65707Z",fill:"black"}),S.jsx("path",{d:"M103.659 1.65707H102.659V0.657074H103.659V1.65707Z",fill:"black"}),S.jsx("path",{d:"M104.992 1.65707H105.992V0.657074H104.992V1.65707Z",fill:"black"}),S.jsx("path",{d:"M108.325 1.65707H107.325V0.657074H108.325V1.65707Z",fill:"black"}),S.jsx("path",{d:"M109.659 1.65707H110.659V0.657074H109.659V1.65707Z",fill:"black"}),S.jsx("path",{d:"M112.992 1.65707H111.992V0.657074H112.992V1.65707Z",fill:"black"}),S.jsx("path",{d:"M114.325 1.65707H115.325V0.657074H114.325V1.65707Z",fill:"black"}),S.jsx("path",{d:"M117.659 1.65707H116.659V0.657074H117.659V1.65707Z",fill:"black"}),S.jsx("path",{d:"M118.992 1.65707H119.992V0.657074H118.992V1.65707Z",fill:"black"})]}),zu=()=>S.jsx("svg",{width:"120",height:"3",viewBox:"0 0 120 3",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M119.991 2.42035H-0.0090332V0.420349H119.991V2.42035Z",fill:"black"})}),$u=()=>S.jsxs("svg",{width:"120",height:"3",viewBox:"0 0 120 3",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[S.jsx("path",{d:"M-0.0100098 2.47614H1.98999V0.476135H-0.0100098V2.47614Z",fill:"black"}),S.jsx("path",{d:"M3.99014 2.47614H9.99014V0.476135H3.99014V2.47614Z",fill:"black"}),S.jsx("path",{d:"M13.9901 2.47614H11.9901V0.476135H13.9901V2.47614Z",fill:"black"}),S.jsx("path",{d:"M21.1904 2.47614H23.1904V0.476135H21.1904V2.47614Z",fill:"black"}),S.jsx("path",{d:"M31.1906 2.47614H25.1906V0.476135H31.1906V2.47614Z",fill:"black"}),S.jsx("path",{d:"M33.1906 2.47614H35.1906V0.476135H33.1906V2.47614Z",fill:"black"}),S.jsx("path",{d:"M44.3909 2.47614H42.3909V0.476135H44.3909V2.47614Z",fill:"black"}),S.jsx("path",{d:"M46.391 2.47614H52.391V0.476135H46.391V2.47614Z",fill:"black"}),S.jsx("path",{d:"M56.391 2.47614H54.391V0.476135H56.391V2.47614Z",fill:"black"}),S.jsx("path",{d:"M63.5913 2.47614H65.5913V0.476135H63.5913V2.47614Z",fill:"black"}),S.jsx("path",{d:"M73.5915 2.47614H67.5915V0.476135H73.5915V2.47614Z",fill:"black"}),S.jsx("path",{d:"M75.5915 2.47614H77.5915V0.476135H75.5915V2.47614Z",fill:"black"}),S.jsx("path",{d:"M86.7917 2.47614H84.7917V0.476135H86.7917V2.47614Z",fill:"black"}),S.jsx("path",{d:"M88.7919 2.47614H94.7919V0.476135H88.7919V2.47614Z",fill:"black"}),S.jsx("path",{d:"M98.7919 2.47614H96.7919V0.476135H98.7919V2.47614Z",fill:"black"}),S.jsx("path",{d:"M105.992 2.47614H107.992V0.476135H105.992V2.47614Z",fill:"black"}),S.jsx("path",{d:"M115.992 2.47614H109.992V0.476135H115.992V2.47614Z",fill:"black"}),S.jsx("path",{d:"M117.992 2.47614H119.992V0.476135H117.992V2.47614Z",fill:"black"})]}),Yu=()=>S.jsxs("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[S.jsx("path",{d:"M-0.0100098 2.00415H1.98999V0.00415039H-0.0100098V2.00415Z",fill:"black"}),S.jsx("path",{d:"M3.99014 2.00415H9.99014V0.00415039H3.99014V2.00415Z",fill:"black"}),S.jsx("path",{d:"M13.9901 2.00415H11.9901V0.00415039H13.9901V2.00415Z",fill:"black"}),S.jsx("path",{d:"M15.9901 2.00415H17.9901V0.00415039H15.9901V2.00415Z",fill:"black"}),S.jsx("path",{d:"M27.4905 2.00415H25.4905V0.00415039H27.4905V2.00415Z",fill:"black"}),S.jsx("path",{d:"M29.4906 2.00415H35.4906V0.00415039H29.4906V2.00415Z",fill:"black"}),S.jsx("path",{d:"M39.4906 2.00415H37.4906V0.00415039H39.4906V2.00415Z",fill:"black"}),S.jsx("path",{d:"M41.4906 2.00415H43.4906V0.00415039H41.4906V2.00415Z",fill:"black"}),S.jsx("path",{d:"M52.991 2.00415H50.991V0.00415039H52.991V2.00415Z",fill:"black"}),S.jsx("path",{d:"M54.9911 2.00415H60.9911V0.00415039H54.9911V2.00415Z",fill:"black"}),S.jsx("path",{d:"M64.9911 2.00415H62.9911V0.00415039H64.9911V2.00415Z",fill:"black"}),S.jsx("path",{d:"M66.9911 2.00415H68.9911V0.00415039H66.9911V2.00415Z",fill:"black"}),S.jsx("path",{d:"M78.4915 2.00415H76.4915V0.00415039H78.4915V2.00415Z",fill:"black"}),S.jsx("path",{d:"M80.4916 2.00415H86.4916V0.00415039H80.4916V2.00415Z",fill:"black"}),S.jsx("path",{d:"M90.4916 2.00415H88.4916V0.00415039H90.4916V2.00415Z",fill:"black"}),S.jsx("path",{d:"M92.4916 2.00415H94.4916V0.00415039H92.4916V2.00415Z",fill:"black"}),S.jsx("path",{d:"M103.992 2.00415H101.992V0.00415039H103.992V2.00415Z",fill:"black"}),S.jsx("path",{d:"M105.992 2.00415H111.992V0.00415039H105.992V2.00415Z",fill:"black"}),S.jsx("path",{d:"M115.992 2.00415H113.992V0.00415039H115.992V2.00415Z",fill:"black"}),S.jsx("path",{d:"M117.992 2.00415H119.992V0.00415039H117.992V2.00415Z",fill:"black"})]}),Xu=()=>S.jsxs("svg",{width:"118",height:"3",viewBox:"0 0 118 3",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[S.jsx("path",{d:"M-0.00854492 2.94815H1.99146V0.948151H-0.00854492V2.94815Z",fill:"black"}),S.jsx("path",{d:"M6.09668 2.94815H8.09668V0.948151H6.09668V2.94815Z",fill:"black"}),S.jsx("path",{d:"M14.2019 2.94815H12.2019V0.948151H14.2019V2.94815Z",fill:"black"}),S.jsx("path",{d:"M18.3071 2.94815H20.3071V0.948151H18.3071V2.94815Z",fill:"black"}),S.jsx("path",{d:"M26.4124 2.94815H24.4124V0.948151H26.4124V2.94815Z",fill:"black"}),S.jsx("path",{d:"M30.5176 2.94815H32.5176V0.948151H30.5176V2.94815Z",fill:"black"}),S.jsx("path",{d:"M38.6228 2.94815H36.6228V0.948151H38.6228V2.94815Z",fill:"black"}),S.jsx("path",{d:"M42.728 2.94815H44.728V0.948151H42.728V2.94815Z",fill:"black"}),S.jsx("path",{d:"M50.8333 2.94815H48.8333V0.948151H50.8333V2.94815Z",fill:"black"}),S.jsx("path",{d:"M54.9385 2.94815H56.9385V0.948151H54.9385V2.94815Z",fill:"black"}),S.jsx("path",{d:"M63.0437 2.94815H61.0437V0.948151H63.0437V2.94815Z",fill:"black"}),S.jsx("path",{d:"M67.1489 2.94815H69.1489V0.948151H67.1489V2.94815Z",fill:"black"}),S.jsx("path",{d:"M75.2542 2.94815H73.2542V0.948151H75.2542V2.94815Z",fill:"black"}),S.jsx("path",{d:"M79.3594 2.94815H81.3594V0.948151H79.3594V2.94815Z",fill:"black"}),S.jsx("path",{d:"M87.4645 2.94815H85.4645V0.948151H87.4645V2.94815Z",fill:"black"}),S.jsx("path",{d:"M91.5697 2.94815H93.5697V0.948151H91.5697V2.94815Z",fill:"black"}),S.jsx("path",{d:"M99.6749 2.94815H97.6749V0.948151H99.6749V2.94815Z",fill:"black"}),S.jsx("path",{d:"M103.78 2.94815H105.78V0.948151H103.78V2.94815Z",fill:"black"}),S.jsx("path",{d:"M111.885 2.94815H109.885V0.948151H111.885V2.94815Z",fill:"black"}),S.jsx("path",{d:"M115.991 2.94815H117.991V0.948151H115.991V2.94815Z",fill:"black"})]}),Zu=()=>S.jsx("svg",{width:"120",height:"4",viewBox:"0 0 120 4",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M119.991 3.86215H-0.0090332V0.862152H119.991V3.86215Z",fill:"black"})}),ro=()=>S.jsx("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M119.991 1.15668H-0.0090332V0.156677H119.991V1.15668Z",fill:"black"})});function oo(i){const{type:e=l.BorderStyleTypes.THIN}=i;switch(e){case l.BorderStyleTypes.DASH_DOT:return S.jsx(Fu,{});case l.BorderStyleTypes.DASH_DOT_DOT:return S.jsx(Bu,{});case l.BorderStyleTypes.DASHED:return S.jsx(ju,{});case l.BorderStyleTypes.HAIR:return S.jsx(Wu,{});case l.BorderStyleTypes.MEDIUM:return S.jsx(zu,{});case l.BorderStyleTypes.MEDIUM_DASH_DOT:return S.jsx($u,{});case l.BorderStyleTypes.MEDIUM_DASH_DOT_DOT:return S.jsx(Yu,{});case l.BorderStyleTypes.MEDIUM_DASHED:return S.jsx(Xu,{});case l.BorderStyleTypes.THICK:return S.jsx(Zu,{});case l.BorderStyleTypes.THIN:return S.jsx(ro,{});default:return S.jsx(ro,{})}}const Gu="univer-ui-plugin-sheets-border-panel",Ku="univer-ui-plugin-sheets-border-panel-position",qu="univer-ui-plugin-sheets-border-panel-position-item",Ju="univer-ui-plugin-sheets-border-panel-styles",Qu="univer-ui-plugin-sheets-border-panel-board",eh="univer-ui-plugin-sheets-border-panel-button",th="univer-ui-plugin-sheets-border-panel-more-icon",Ct={uiPluginSheetsBorderPanel:Gu,uiPluginSheetsBorderPanelPosition:Ku,uiPluginSheetsBorderPanelPositionItem:qu,uiPluginSheetsBorderPanelStyles:Ju,uiPluginSheetsBorderPanelBoard:Qu,uiPluginSheetsBorderPanelButton:eh,uiPluginSheetsBorderPanelMoreIcon:th},Ss=`${an}_BORDER_PANEL_COMPONENT`,vs=[{label:"borderLine.borderTop",icon:"UpBorder",value:"top"},{label:"borderLine.borderBottom",icon:"DownBorder",value:"bottom"},{label:"borderLine.borderLeft",icon:"LeftBorder",value:"left"},{label:"borderLine.borderRight",icon:"RightBorder",value:"right"},{label:"borderLine.borderNone",icon:"NoBorderSingle",value:"none"},{label:"borderLine.borderAll",icon:"AllBorderSingle",value:"all"},{label:"borderLine.borderOutside",icon:"OuterBorder",value:"outside"},{label:"borderLine.borderInside",icon:"InnerBorder",value:"inside"},{label:"borderLine.borderHorizontal",icon:"InnerBorder",value:"horizontal"},{label:"borderLine.borderVertical",icon:"InnerBorder",value:"vertical"},{label:"borderLine.borderTlbr",icon:"BackSlashSingle",value:"tlbr"},{label:"borderLine.borderTlbcTlmr",icon:"LeftDoubleDiagonalSingle",value:"tlbc_tlmr"},{label:"borderLine.borderTlbrTlbcTlmr",icon:"LeftTridiagonalSingle",value:"tlbr_tlbc_tlmr"},{label:"borderLine.borderBlTr",icon:"SlashSingle",value:"bltr"},{label:"borderLine.borderMltrBctr",icon:"RightDoubleDiagonalSingle",value:"mltr_bctr"}],nh=[{label:l.BorderStyleTypes.THIN,value:l.BorderStyleTypes.THIN},{label:l.BorderStyleTypes.HAIR,value:l.BorderStyleTypes.HAIR},{label:l.BorderStyleTypes.DOTTED,value:l.BorderStyleTypes.DOTTED},{label:l.BorderStyleTypes.DASHED,value:l.BorderStyleTypes.DASHED},{label:l.BorderStyleTypes.DASH_DOT,value:l.BorderStyleTypes.DASH_DOT},{label:l.BorderStyleTypes.DASH_DOT_DOT,value:l.BorderStyleTypes.DASH_DOT_DOT},{label:l.BorderStyleTypes.MEDIUM,value:l.BorderStyleTypes.MEDIUM},{label:l.BorderStyleTypes.MEDIUM_DASHED,value:l.BorderStyleTypes.MEDIUM_DASHED},{label:l.BorderStyleTypes.MEDIUM_DASH_DOT,value:l.BorderStyleTypes.MEDIUM_DASH_DOT},{label:l.BorderStyleTypes.MEDIUM_DASH_DOT_DOT,value:l.BorderStyleTypes.MEDIUM_DASH_DOT_DOT},{label:l.BorderStyleTypes.THICK,value:l.BorderStyleTypes.THICK}];function ih(i){const e=me.useDependency(R.ComponentManager),{onChange:t,value:n}=i;function r(a,c){t==null||t({...n,[c]:a})}function o(a){const c=e.get(a);return c&&S.jsx(c,{extend:{colorChannel1:"rgb(var(--primary-color))"}})}function s(a){a.stopPropagation()}return S.jsxs("section",{className:Ct.uiPluginSheetsBorderPanel,children:[S.jsx("div",{className:Ct.uiPluginSheetsBorderPanelPosition,children:vs.map(a=>S.jsx("div",{className:Ct.uiPluginSheetsBorderPanelPositionItem,onClick:()=>r(a.value,"type"),children:o(a.icon)},a.value))}),S.jsxs("div",{className:Ct.uiPluginSheetsBorderPanelStyles,children:[S.jsx("div",{children:S.jsx(Ye.Dropdown,{align:{offset:[0,18]},overlay:S.jsx("section",{className:Ct.uiPluginSheetsBorderPanelBoard,onClick:s,children:S.jsx(Ye.ColorPicker,{onChange:a=>r(a,"color")})}),children:S.jsxs("a",{className:Ct.uiPluginSheetsBorderPanelButton,onClick:s,children:[S.jsx(Rl,{extend:{colorChannel1:n.color??"rgb(var(--primary-color))"}}),S.jsx("span",{className:Ct.uiPluginSheetsBorderPanelMoreIcon,children:S.jsx(Qi,{})})]})})}),S.jsx("div",{children:S.jsx(Ye.Dropdown,{align:{offset:[0,18]},overlay:S.jsx("section",{onClick:s,children:S.jsx(Ye.Menu,{children:nh.map(a=>S.jsx(Ye.MenuItem,{eventKey:a.value.toString(),onClick:()=>r(a.value,"style"),children:S.jsx(oo,{type:a.value})},a.value))})}),children:S.jsxs("a",{className:Ct.uiPluginSheetsBorderPanelButton,onClick:s,children:[S.jsx(oo,{type:l.BorderStyleTypes.THIN}),S.jsx("span",{className:Ct.uiPluginSheetsBorderPanelMoreIcon,children:S.jsx(Qi,{})})]})})})]})]})}const rh="univer-count-bar",oh={countBar:rh},sh=[50,80,100,130,150,170,200,400];function ah(){const i=me.useDependency(l.ICommandService),e=me.useDependency(l.IUniverInstanceService),t=o(),[n,r]=X.useState(t);X.useEffect(()=>i.onCommandExecuted(c=>{if(c.id===bt.id||c.id===p.SetWorksheetActivateCommand.id){const d=o();r(d)}}).dispose,[i]);function o(){const a=e.getCurrentUniverSheetInstance().getActiveSheet().getZoomRatio()*100||100;return Math.round(a)}function s(a){r(a);const c=e.getCurrentUniverSheetInstance();if(!c)return;const d=c.getActiveSheet();if(!d)return;const u=a/100;i.executeCommand(vr.id,{unitId:c.getUnitId(),subUnitId:d.getSheetId(),zoomRatio:u})}return S.jsx(Ye.Slider,{min:Gi[0],value:n,shortcuts:sh,onChange:s})}function lh(i){return S.jsx("section",{className:oh.countBar,children:S.jsx(ah,{})})}const ch="univer-editor-container",dh="univer-editor-input",so={editorContainer:ch,editorInput:dh},bi=-1e3,ao={width:0,height:0,top:bi,left:bi},uh=()=>{const[i,e]=X.useState({...ao}),t=X.useRef(null),n=me.useDependency(y.IRenderManagerService),r=me.useDependency(Dn);return X.useEffect(()=>{const o=t.current;if(!o)return;const s=n.currentRender$.pipe(uo.switchMap(()=>{var c;const a=(c=n.getRenderById(l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY))==null?void 0:c.engine;return a==null||a.setContainer(o),r.state$})).subscribe(a=>{if(a==null)return;const{startX:c=bi,startY:d=bi,endX:u=0,endY:h=0,show:m=!1}=a;if(!m)e({...ao});else{e({width:u-c,height:h-d,left:c,top:d});const g=t.current;if(!g)return;const{left:_,top:f,width:C,height:I}=g.getBoundingClientRect();r.setRect({left:_,top:f,width:C,height:I})}});return()=>{s.unsubscribe()}},[]),X.useEffect(()=>{r.setFocus(!0)},[i]),S.jsx("div",{className:so.editorContainer,style:{left:i.left,top:i.top,width:i.width,height:i.height},children:S.jsx("div",{className:so.editorInput,ref:t})})},hh="univer-formula-box",mh="univer-name-ranges",gh="univer-name-ranges-input",_h="univer-formula-bar",ph="univer-formula-icon",fh="univer-formula-icon-wrapper",Sh="univer-icon-container",vh="univer-icon-container-success",Ch="univer-formula-active",Rh="univer-icon-container-error",Ih="univer-formula-input",bh="univer-formula-content",Mh="univer-arrow-container",ze={formulaBox:hh,nameRanges:mh,nameRangesInput:gh,formulaBar:_h,formulaIcon:ph,formulaIconWrapper:fh,iconContainer:Sh,iconContainerSuccess:vh,formulaActive:Ch,iconContainerError:Rh,formulaInput:Ih,formulaContent:bh,arrowContainer:Mh};function wh(){const[i,e]=X.useState(ze.formulaGrey),[t,n]=X.useState(0),r=X.useRef(null),o=me.useDependency(y.IRenderManagerService),s=me.useDependency(xi),a=me.useDependency(at);X.useEffect(()=>{const m=r.current;if(!m)return;const g=o.currentRender$.subscribe(f=>{var I;if(f!==l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY)return;const C=(I=o.getRenderById(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY))==null?void 0:I.engine;C==null||C.setContainer(m)}),_=new ResizeObserver(()=>{const f=m.getBoundingClientRect();s.setPosition(f)});return _.observe(m),a.visible$.subscribe(f=>{e(f.visible?ze.formulaActive:ze.formulaGrey)}),()=>{_.unobserve(m),g.unsubscribe()}},[]);function c(){n(t===0?1:0),setTimeout(()=>{s.handleFoldBtnClick(t===1)},150)}function d(){a.isVisible().visible&&a.changeVisible({visible:!1,eventType:y.DeviceInputEventType.Keyboard,keycode:R.KeyCode.ESC})}function u(){a.isVisible().visible&&a.changeVisible({visible:!1,eventType:y.DeviceInputEventType.PointerDown})}function h(){s.handleFxBtnClick(!0)}return S.jsxs("div",{className:ze.formulaBox,style:{height:t===0?"28px":"82px"},children:[S.jsx("div",{className:ze.nameRanges,children:S.jsx("div",{className:ze.nameRangesInput})}),S.jsxs("div",{className:ze.formulaBar,children:[S.jsx("div",{className:ze.formulaIcon,children:S.jsxs("div",{className:ze.formulaIconWrapper,children:[S.jsx("span",{className:bn(ze.iconContainer,ze.iconContainerError,i),onClick:d,children:S.jsx(ll,{})}),S.jsx("span",{className:bn(ze.iconContainer,ze.iconContainerSuccess,i),onClick:u,children:S.jsx(Ri,{})}),S.jsx("span",{className:ze.iconContainer,onClick:h,children:S.jsx(_l,{})})]})}),S.jsxs("div",{className:ze.formulaInput,children:[S.jsx("div",{onContextMenu:m=>m.preventDefault(),className:ze.formulaContent,ref:r}),S.jsx("div",{className:ze.arrowContainer,onClick:c,children:t===0?S.jsx(Br,{}):S.jsx(Br,{style:{transform:"rotateZ(180deg)"}})})]})]})]})}const Th="univer-operate-container",yh="univer-auto-fill-popup-menu",Eh="univer-auto-fill-popup-menu-item",Oh="univer-auto-fill-popup-menu-item-icon",xh="univer-auto-fill-popup-menu-item-title",Ah="univer-auto-fill-popup-menu-item-hide",Nh="univer-btn-container",Dh="univer-btn-container-expand",kt={operateContainer:Th,autoFillPopupMenu:yh,autoFillPopupMenuItem:Eh,autoFillPopupMenuItemIcon:Oh,autoFillPopupMenuItemTitle:xh,autoFillPopupMenuItemHide:Ah,btnContainer:Nh,btnContainerExpand:Dh},Ph=()=>{const[,i]=X.useState({});return X.useCallback(()=>i(e=>!e),[])},Hh=()=>{var Ie;const i=me.useDependency(l.ICommandService),e=me.useDependency(exports.SheetSkeletonManagerService),t=me.useDependency(l.IUniverInstanceService),n=me.useDependency(y.IRenderManagerService),r=me.useDependency(Ze),o=me.useDependency(xn),s=me.useDependency(l.LocaleService),[a,c]=X.useState([]),[d,u]=X.useState(!1),[h,m]=X.useState({row:-1,col:-1}),[g,_]=X.useState(Te.SERIES),[f,C]=X.useState(!1),I=()=>{C(!0)},w=()=>{C(!1)},E=Ph(),O=qe(t,n);if(O==null)return null;const{scene:x}=O;if(X.useEffect(()=>{const de=[mt.id,zn.id,bt.id,p.SetRangeValuesMutation.id,p.SetWorksheetActiveOperation.id];return i.onCommandExecuted(be=>{be.id===on.id&&E(),de.includes(be.id)&&m({row:-1,col:-1})}).dispose},[E,i]),X.useEffect(()=>l.toDisposable(o.menu$.subscribe(Ee=>{c(Ee.map(be=>({...be,index:Ee.indexOf(be)})))})).dispose,[o]),X.useEffect(()=>l.toDisposable(o.showMenu$.subscribe(Ee=>{const{source:be,target:De}=o.autoFillLocation||{source:null,target:null};if(Ee&&be&&De){const Oe=l.Rectangle.union(be,De);m({row:Oe.endRow,col:Oe.endColumn})}})).dispose,[o]),X.useEffect(()=>l.toDisposable(o.applyType$.subscribe(Ee=>{_(Ee)})).dispose,[o]),X.useEffect(()=>{function de(){u(!1)}return document.addEventListener("wheel",de),()=>{document.removeEventListener("wheel",de)}},[d]),h.col<0||h.row<0)return null;const N=(Ie=e.getCurrent())==null?void 0:Ie.skeleton,D=r.getViewPort(),P=x==null?void 0:x.scaleX,L=x==null?void 0:x.scaleY,G=x==null?void 0:x.getScrollXY(D);if(!P||!x||!P||!L||!G)return null;const k=(N==null?void 0:N.getNoMergeCellPositionByIndex(h.row,h.col).endX)||0,ee=(N==null?void 0:N.getNoMergeCellPositionByIndex(h.row,h.col).endY)||0,te=N==null?void 0:N.convertTransformToOffsetX(k,P,G),W=N==null?void 0:N.convertTransformToOffsetY(ee,L,G);if(te==null||W==null)return null;const V=de=>{u(de)},re=de=>{i.executeCommand(gs.id,{type:de.value})},q=d||f,ae=a.filter(de=>!de.disable);return S.jsx("div",{onMouseEnter:I,onMouseLeave:w,style:{left:`${te+2}px`,top:`${W+2}px`,position:"absolute"},children:S.jsx(Ye.Dropdown,{placement:"bottomLeft",trigger:["click"],overlay:S.jsx("ul",{className:kt.autoFillPopupMenu,children:ae.map(de=>S.jsxs("li",{onClick:()=>re(de),className:kt.autoFillPopupMenuItem,children:[S.jsx("span",{className:kt.autoFillPopupMenuItemIcon,children:de.value===g&&S.jsx(Ri,{style:{color:"rgb(var(--green-700, #409f11))"}})}),S.jsx("span",{className:kt.autoFillPopupMenuItemTitle,children:s.t(de.label)})]},de.index))}),visible:d,onVisibleChange:V,children:S.jsxs("div",{className:bn(kt.btnContainer,{[kt.btnContainerExpand]:d}),children:[S.jsx(ol,{style:{color:"#35322B"},extend:{colorChannel1:"rgb(var(--green-700, #409f11))"}}),q&&S.jsx(Qi,{style:{color:"#CCCCCC",fontSize:"8px",marginLeft:"8px"}})]})})})},Lh=()=>S.jsx("div",{className:kt.operateContainer,children:S.jsx(Hh,{})}),Uh="univer-sheet-bar",kh="univer-sheet-bar-options",Vh="univer-sheet-bar-options-divider",Wn={sheetBar:Uh,sheetBarOptions:kh,sheetBarOptionsDivider:Vh},Fh="univer-sheet-bar-btn",Bh={sheetBarBtn:Fh};function gi(i){const{children:e,className:t,style:n,disabled:r=!1,onClick:o,...s}=i,a=c=>{if(r){c.preventDefault();return}o&&o(c)};return S.jsx("button",{className:Bh.sheetBarBtn,style:n,disabled:r,onClick:a,...s,children:e})}const jh="univer-sheet-bar-menu",Wh="univer-sheet-bar-menu-item",zh="univer-sheet-bar-menu-item-icon",$h="univer-sheet-bar-menu-item-hide",Yh="univer-sheet-bar-menu-item-select",Xh="univer-sheet-bar-menu-item-label",Ot={sheetBarMenu:jh,sheetBarMenuItem:Wh,sheetBarMenuItemIcon:zh,sheetBarMenuItemHide:$h,sheetBarMenuItemSelect:Yh,sheetBarMenuItemLabel:Xh};function Zh(i){const{style:e}=i,[t,n]=X.useState([]),[r,o]=X.useState(!1),s=me.useDependency(l.IUniverInstanceService),a=me.useDependency(l.ICommandService),c=me.useDependency(cn),d=s.getCurrentUniverSheetInstance(),u=f=>{const{sheetId:C}=f;C&&(f.hidden?a.executeCommand(p.SetWorksheetShowCommand.id,{value:C}):f.selected||a.executeCommand(p.SetWorksheetActivateCommand.id,{unitId:d.getUnitId(),subUnitId:C}),o(!1))};X.useEffect(()=>{m();const f=new l.DisposableCollection;return f.add(h()),f.add(c.registerSheetBarMenuHandler({handleSheetBarMenu:g})),()=>{f.dispose()}},[]);const h=()=>a.onCommandExecuted(f=>{switch(f.id){case p.SetWorksheetHideMutation.id:case p.RemoveSheetMutation.id:case p.SetWorksheetNameMutation.id:case p.InsertSheetMutation.id:case p.SetWorksheetOrderMutation.id:case p.SetWorksheetActiveOperation.id:m();break}}),m=()=>{const C=d.getSheets().map((I,w)=>({label:I.getName(),index:`${w}`,sheetId:I.getSheetId(),hidden:I.isSheetHidden()===l.BooleanNumber.TRUE,selected:I.getStatus()===l.BooleanNumber.TRUE}));n(C)};function g(){o(!0)}const _=f=>{o(f)};return S.jsx(Ye.Dropdown,{placement:"topLeft",trigger:["click"],overlay:S.jsx("ul",{className:Ot.sheetBarMenu,style:{...e},children:t.map(f=>S.jsxs("li",{onClick:()=>u(f),className:f.selected?`${Ot.sheetBarMenuItem} ${Ot.sheetBarMenuItemSelect}`:f.hidden?`${Ot.sheetBarMenuItem} ${Ot.sheetBarMenuItemHide}`:Ot.sheetBarMenuItem,children:[S.jsx("span",{className:Ot.sheetBarMenuItemIcon,children:f.selected?S.jsx(Ri,{}):f.hidden?S.jsx(ml,{}):S.jsx(Ri,{})}),S.jsx("span",{className:Ot.sheetBarMenuItemLabel,children:f.label})]},f.index))}),visible:r,onVisibleChange:_,children:S.jsx(gi,{children:S.jsx(dl,{})})})}const Gh="univer-slide-tab-bar-container",Kh="univer-slide-tab-bar",qh="univer-slide-tab-item",Jh="univer-slide-tab-active",Qh="univer-slide-tab-span",em="univer-slide-tab-span-edit",ot={slideTabBarContainer:Gh,slideTabBar:Kh,slideTabItem:qh,slideTabActive:Jh,slideTabSpan:Qh,slideTabSpanEdit:em};function tm(i){const{sheetId:e,label:t,color:n,selected:r}=i,[o,s]=X.useState(!1),[a,c]=X.useState(r),d=me.useDependency(l.ICommandService),u=me.useDependency(l.ThemeService);X.useEffect(()=>{c(r)},[r]);const h=g=>{s(g)},m=g=>{const _=u.getCurrentTheme(),f=_.textColor,C=_.colorWhite;return new l.ColorKit(g).isDark()?C:f};return S.jsx(Ye.Dropdown,{visible:o,trigger:["contextMenu"],overlay:S.jsx(R.Menu,{menuType:Be.SHEET_BAR,onOptionSelect:g=>{const{label:_,value:f}=g;d.executeCommand(_,{value:f,subUnitId:e}),s(!1)}}),onVisibleChange:h,children:S.jsx("div",{"data-id":e,className:a?`${ot.slideTabActive} ${ot.slideTabItem}`:ot.slideTabItem,style:{backgroundColor:!a&&n?n:"",color:!a&&n?m(n):"",boxShadow:a&&n?`0px 0px 8px rgba(0, 0, 0, 0.08), inset 0px -2px 0px 0px ${n}`:""},children:S.jsx("span",{className:ot.slideTabSpan,children:t})},e)})}const nm={easeOutStrong(i,e,t,n){return-t*((i=i/n-1)*i*i*i-1)+e},backOut(i,e,t,n,r){return typeof r>"u"&&(r=.7),t*((i=i/n-1)*i*((r+1)*i+r)+1)+e}},im={loop:!1,begin:0,end:0,duration:300,delay:0,type:"easeOutStrong",receive(i){},success(i){},cancel(i){},complete(i){}};class rm{constructor(e){v(this,"_config");v(this,"_status",0);v(this,"_start",0);v(this,"_handle",0);v(this,"_delayHandle",null);this._config={...im,...e},this._config.loop&&(this._config.complete=()=>{},this._config.success=()=>{this.request()})}static success(...e){let t=0;return new Promise(n=>{for(let r=0;r<e.length;r++){const o=e[r],s=o._config,a=s.success;s.loop||(s.success=d=>{t++,a&&a.call(o,d),t===e.length&&n()})}})}request(){this._config.delay===0?(this._status=0,this._start=Date.now(),this._fakeHandle()):(this._delayHandle&&clearTimeout(this._delayHandle),this._delayHandle=setTimeout(()=>{this._status=0,this._start=Date.now(),this._fakeHandle()},this._config.delay))}cancel(){this._status=1,this._delayHandle&&clearTimeout(this._delayHandle),cancelAnimationFrame(this._handle)}_fakeHandle(){let e=Date.now()-this._start;e=e>=this._config.duration?this._config.duration:e;const n=nm[this._config.type](e,this._config.begin,this._config.end-this._config.begin,this._config.duration,.7).toFixed(2);if(this._config.receive(n),this._status===1){this._config.cancel(n),this._config.complete(n);return}if(e===this._config.duration){this._config.success(n),this._config.complete(n);return}this._handle=requestAnimationFrame(()=>{this._fakeHandle()})}}class Ft{constructor(e,t){v(this,"_slideTabItem");v(this,"_animate");v(this,"_midline",0);v(this,"_translateX");v(this,"_scrollbar");v(this,"_slideTabBar");v(this,"_editMode");v(this,"_placeholder");this._slideTabItem=e,this._animate=null,this._translateX=0,this._editMode=!1,this._slideTabBar=t,this._placeholder=null,this._scrollbar=t.getScrollbar(),this.update()}static midline(e){return e.getBoundingRect().x+e.getBoundingRect().width/2}static leftLine(e){return e.getBoundingRect().x}static rightLine(e){return e.getBoundingRect().x+e.getBoundingRect().width}static make(e,t){const n=[];return e.forEach(r=>n.push(new Ft(r,t))),n}getSlideTabItem(){return this._slideTabItem}getEditor(){return this._slideTabItem.querySelector("span")}isEditMode(){return this._editMode}classList(){return this._slideTabItem.classList}translateX(e){return this._translateX=e,this._slideTabItem.style.transform=`translateX(${e}px)`,this.getTranslateXDirection()}setEditor(e){let t=!0;if(this._editMode===!1){const n=this._slideTabItem.querySelector("span"),r=d=>{if(!this.nameCheck()){if(this._editMode=!1,n&&(n.removeAttribute("contentEditable"),n.removeEventListener("blur",r),n.removeEventListener("compositionstart",s),n.removeEventListener("compositionend",a),n.removeEventListener("input",c),n.removeEventListener("keydown",o),n.classList.remove(this._slideTabBar.getConfig().slideTabBarSpanEditClassName)),this._slideTabBar.removeListener(),this._slideTabBar.updateItems(),this._slideTabBar.getConfig().onChangeName){const u=(n==null?void 0:n.innerText)||"",h=this.getId();this._slideTabBar.getConfig().onChangeName(h,u)}e&&e(d)}};let o=d=>{n&&(d.stopPropagation(),d.key==="Enter"&&n.blur())};const s=d=>{t=!1},a=d=>{t=!0},c=d=>{if(!n)return;const u=50;setTimeout(()=>{if(t){const h=n.innerText;h.length>u&&(n.innerText=h.substring(0,u),yn.keepLastIndex(n))}},0)};n&&(n.setAttribute("contentEditable","true"),n.addEventListener("blur",r),n.addEventListener("compositionstart",s),n.addEventListener("compositionend",a),n.addEventListener("input",c),n.addEventListener("keydown",o),n.classList.add(this._slideTabBar.getConfig().slideTabBarSpanEditClassName),this._editMode=!0,yn.keepSelectAll(n))}}nameCheck(){const e=this._slideTabItem.querySelector("span");if(!e)return!1;const t=e.innerText;return this._slideTabBar.getConfig().onNameCheckAlert(t)}animate(){return{translateX:e=>{this._translateX!==e&&(this._animate&&(this._animate.cancel(),this._animate=null),this._animate=new rm({begin:this._translateX,end:e,receive:t=>{this._slideTabItem.style.transform=`translateX(${t}px)`}}),this._translateX=e,this._animate.request())},cancel:()=>{this._animate&&(this._animate.cancel(),this._animate=null)}}}after(e){this._slideTabItem.after(e._slideTabItem||e)}update(){this._midline=Ft.midline(this)}disableFixed(){if(this._placeholder){const e=this._slideTabBar.primeval();this._slideTabItem.style.removeProperty("position"),this._slideTabItem.style.removeProperty("left"),this._slideTabItem.style.removeProperty("top"),this._slideTabItem.style.removeProperty("width"),this._slideTabItem.style.removeProperty("height"),this._slideTabItem.style.removeProperty("background"),this._slideTabItem.style.removeProperty("padding"),this._slideTabItem.style.removeProperty("box-sizing"),this._slideTabItem.style.removeProperty("font-size"),this._slideTabItem.style.removeProperty("font-family"),this._slideTabItem.style.removeProperty("font-weight"),this._slideTabItem.style.removeProperty("color"),this._slideTabItem.style.removeProperty("border-radius"),this._placeholder.after(this._slideTabItem),e.removeChild(this._placeholder),this._placeholder=null}}enableFixed(){const e=document.createElement("div"),t=this.getBoundingRect(),n=getComputedStyle(this._slideTabItem),r=this._slideTabItem.querySelector("span");if(this._placeholder=e,this._placeholder.style.width=`${t.width}px`,this._placeholder.style.height=`${t.height}px`,this._placeholder.style.flexShrink="0",this._placeholder.style.margin=n.margin,this._slideTabItem.style.background=n.background,r){const o=getComputedStyle(r).padding;this._slideTabItem.style.padding=o}this._slideTabItem.style.boxSizing=n.boxSizing,this._slideTabItem.style.fontSize=n.fontSize,this._slideTabItem.style.fontFamily=n.fontFamily,this._slideTabItem.style.fontWeight=n.fontWeight,this._slideTabItem.style.color=n.color,this._slideTabItem.style.borderRadius=n.borderRadius,this._slideTabItem.style.left=`${t.x-this.getScrollbar().getScrollX()}px`,this._slideTabItem.style.top=`${t.y}px`,this._slideTabItem.style.width=`${t.width}px`,this._slideTabItem.style.height=`${t.height}px`,this._slideTabItem.style.position="fixed",this._slideTabItem.after(e),document.body.appendChild(this._slideTabItem)}addEventListener(e,t,n){this._slideTabItem.addEventListener(e,t,n)}removeEventListener(e,t,n){this._slideTabItem.removeEventListener(e,t,n)}getScrollbar(){return this._scrollbar}getMidLine(){return this._midline}getBoundingRect(){const e=this._slideTabItem.getBoundingClientRect();return e.x+=this._scrollbar.getScrollX(),e}getWidth(){return this.getBoundingRect().width}getTranslateXDirection(){const e=Ft.midline(this);return e>this._midline?1:e<this._midline?-1:0}equals(e){return e&&e._slideTabItem===this._slideTabItem}getId(){return this._slideTabItem.dataset.id||""}}class om{constructor(e){v(this,"_slideTabBar");v(this,"_scrollX");const t=e.primeval();this._scrollX=t.scrollLeft,this._slideTabBar=e}scrollX(e){const t=this._slideTabBar.primeval();t.scrollLeft=e,this._scrollX=t.scrollLeft}scrollRight(){const e=this._slideTabBar.primeval();e.scrollLeft=e.scrollWidth,this._scrollX=e.scrollLeft}getScrollX(){return this._scrollX}}const qt=class qt{constructor(e){v(this,"_activeTabItemIndex",0);v(this,"_slideTabBar");v(this,"_slideTabItems",[]);v(this,"_config");v(this,"_downActionX",0);v(this,"_moveActionX",0);v(this,"_compareIndex",0);v(this,"_activeTabItem",null);v(this,"_moveAction");v(this,"_upAction");v(this,"_downAction");v(this,"_wheelAction");v(this,"_scrollIncremental",0);v(this,"_compareDirection",0);v(this,"_autoScrollTime",null);v(this,"_slideScrollbar");v(this,"_longPressTimer",null);v(this,"_leftBoundingLine",0);v(this,"_rightBoundingLine",0);v(this,"_leftMoveX",0);v(this,"_rightMoveX",0);if(e.slideTabBarContainer==null)throw new Error("not found slide-tab-bar root element");const t=e.slideTabBarContainer.querySelector(`.${e.slideTabBarClassName??"slide-tab-bar"}`);if(t==null)throw new Error("not found slide-tab-bar");this._slideTabBar=t,this._slideScrollbar=new om(this),this._config=e,this._initConfig();let n=0,r=0,o=0;this._downAction=s=>{var x,N,D,P,L,G;if((x=this._activeTabItem)!=null&&x.isEditMode())return;const a=(D=(N=s.target)==null?void 0:N.closest(`.${e.slideTabBarItemClassName}`))==null?void 0:D.getAttribute("data-id"),c=this._slideTabItems.findIndex(k=>k.getId()===a);if(a==null||c===-1)return;if(this._activeTabItemIndex!==c){(P=this._activeTabItem)==null||P.removeEventListener("pointermove",this._moveAction),(L=this._activeTabItem)==null||L.removeEventListener("pointerup",this._upAction),this.removeListener(),this._config.onChangeTab(s,a);return}if(this._compareIndex=c,this._downActionX=s.pageX,this._moveActionX=0,this._scrollIncremental=0,this._activeTabItem=this._slideTabItems[c],!this._activeTabItem){console.error("Not found active slide-tab-item in sheet bar");return}const d=this._activeTabItem.getSlideTabItem();d==null||d.setPointerCapture(s.pointerId),(G=this._activeTabItem)==null||G.addEventListener("pointerup",this._upAction);const{x:u,width:h}=this._activeTabItem.getBoundingRect(),{x:m,width:g}=this.getBoundingRect(),_=this._slideScrollbar.getScrollX();if(this._leftBoundingLine=this._downActionX-(u-_),this._rightBoundingLine=u-_+h-this._downActionX,this._leftMoveX=u-m-_,this._rightMoveX=m+g-(u+h)+_,s.button===2||this._hasEditItem())return;const{pageX:f,pageY:C}=s,I=Date.now(),w=I-o<=qt.DoubleClickDelay,E=Math.abs(f-n)<10,O=Math.abs(C-r)<10;w&&E&&O&&this._activeTabItem.setEditor(),n=f,r=C,o=I,this._longPressTimer=setTimeout(()=>{var k,ee;(k=this._activeTabItem)==null||k.enableFixed(),this._startAutoScroll(),d&&(d.setPointerCapture(s.pointerId),d.style.cursor="move",(ee=this._activeTabItem)==null||ee.addEventListener("pointermove",this._moveAction))},qt.LongPressDelay)},this._upAction=s=>{var c,d,u;if(this._longPressTimer&&(clearTimeout(this._longPressTimer),this._longPressTimer=null),!this._activeTabItem)return;this._closeAutoScroll(),this._activeTabItem.disableFixed(),this.updateItems();const a=(c=this._activeTabItem)==null?void 0:c.getSlideTabItem();a&&(a.style.cursor="",a.releasePointerCapture(s.pointerId),(d=this._activeTabItem)==null||d.removeEventListener("pointermove",this._moveAction),(u=this._activeTabItem)==null||u.removeEventListener("pointerup",this._upAction),this._config.onSlideEnd&&this._activeTabItemIndex!==this._compareIndex&&(this.removeListener(),this._config.onSlideEnd(s,this._compareIndex||0)),this._scrollIncremental=0,this._downActionX=0,this._moveActionX=0,this._compareIndex=0)},this._moveAction=s=>{this._activeTabItem&&(this._moveActionX=s.pageX-this._downActionX,this._moveActionX<=-this._leftMoveX?this._moveActionX=-this._leftMoveX:this._moveActionX>=this._rightMoveX&&(this._moveActionX=this._rightMoveX),this._scrollIncremental=0,this._scrollLeft(s),this._scrollRight(s))},this._wheelAction=s=>{this.setScroll(s.deltaY)},this.addListener()}static checkedSkipSlide(e){let t=e.target;for(;t!=null&&t!==document.body;){if(t.getAttribute("data-slide-skip"))return!0;t=t.parentElement}return!1}static keepLastIndex(e){setTimeout(()=>{const t=window.getSelection();t&&(t.selectAllChildren(e),t.collapseToEnd())})}static keepSelectAll(e){setTimeout(()=>{const t=window.getSelection();if(!t)return;const n=document.createRange();n.selectNodeContents(e),t.removeAllRanges(),t.addRange(n)})}update(e){this._config.currentIndex=e,this._initConfig(),this.removeListener(),this.addListener()}primeval(){return this._slideTabBar}updateItems(){for(let e=0;e<this._slideTabItems.length;e++)this._slideTabItems[e].animate().cancel(),this._slideTabItems[e].translateX(0),this._slideTabItems[e].update()}getScrollbar(){return this._slideScrollbar}getConfig(){return this._config}getBoundingRect(){return this._slideTabBar.getBoundingClientRect()}getSlideTabItems(){return this._slideTabItems}getActiveItem(){return this._activeTabItem}isLeftEnd(){return this._slideTabBar.scrollLeft===0}isRightEnd(){const e=this._slideTabBar.parentElement;return e?this._slideTabBar.scrollWidth-e.clientWidth===this._slideTabBar.scrollLeft:!1}addListener(){this._slideTabBar.addEventListener("wheel",this._wheelAction),this._slideTabItems.forEach(e=>{e.addEventListener("pointerdown",this._downAction)})}removeListener(){this._slideTabBar.removeEventListener("wheel",this._wheelAction),this._slideTabItems.forEach(e=>{e.removeEventListener("pointerdown",this._downAction)})}setScroll(e){if(this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+e),e>0){const t=this.calculateLeftScrollX();this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+t)}else if(e<0){const t=this.calculateRightScrollX();this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+t)}this._config.onScroll({leftEnd:this.isLeftEnd(),rightEnd:this.isRightEnd()})}flipPage(e){if(e>0){const t=this.calculateLeftScrollX(!0);this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+t)}else if(e<0){const t=this.calculateRightScrollX(!0);this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+t)}this._config.onScroll({leftEnd:this.isLeftEnd(),rightEnd:this.isRightEnd()})}calculateLeftScrollX(e){let t=0;const n=4;return this._slideTabItems.some(r=>{const o=this._slideTabBar.getBoundingClientRect(),s=o.left+o.width,a=r.getSlideTabItem().getBoundingClientRect(),c=a.left,d=a.width;return c<s&&c+d+n*2>s?(t=e?c-o.left-n:c+d-s+n,!0):!1}),t}calculateRightScrollX(e){let t=0;const n=4;return this._slideTabItems.some(r=>{const o=this._slideTabBar.getBoundingClientRect(),s=o.left,a=r.getSlideTabItem().getBoundingClientRect(),c=a.left,d=a.width;return c-n*2<s&&c+d>s?(t=e?c+d-o.left-o.width+n:c-s-n,!0):!1}),t}destroy(){this._downActionX=0,this._moveActionX=0,this._compareDirection=0,this._compareIndex=0,this._slideTabItems=[],this._activeTabItem=null,this.removeListener()}_hasEditItem(){for(let e=0;e<this._slideTabItems.length;e++)if(this._slideTabItems[e].isEditMode())return!0;return!1}_autoScrollFrame(){if(this._activeTabItem)switch(this._compareDirection=this._activeTabItem.translateX(this._moveActionX),this._compareDirection){case 1:{this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+this._scrollIncremental),this._compareRight();break}case 0:{this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+this._scrollIncremental),this._compareIndex=this._activeTabItemIndex;break}case-1:{this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+this._scrollIncremental),this._compareLeft();break}}this._autoScrollTime=requestAnimationFrame(()=>{this._autoScrollFrame()})}_startAutoScroll(){this._autoScrollTime==null&&this._autoScrollFrame()}_closeAutoScroll(){this._autoScrollTime&&cancelAnimationFrame(this._autoScrollTime),this._autoScrollTime=null}_scrollLeft(e){const t=this.getBoundingRect(),n=e.pageX-t.x;n<this._leftBoundingLine&&(this._scrollIncremental=-Math.min(Math.abs(n-this._leftBoundingLine)*.1,50))}_scrollRight(e){const t=this.getBoundingRect(),n=e.pageX-t.x;n>t.width-this._rightBoundingLine&&(this._scrollIncremental=Math.min(Math.abs(n-(t.width-this._rightBoundingLine))*.1,50))}_sortedItems(){if(this._activeTabItem!=null&&this._activeTabItemIndex!=null&&this._compareIndex!=null&&(this._slideTabItems.splice(this._activeTabItemIndex,1),this._slideTabItems.splice(this._compareIndex,0,this._activeTabItem),this._config.slideTabBarItemAutoSort))for(let e=0;e<this._slideTabItems.length;e++){const t=this._slideTabItems[e],n=this._slideTabItems[e+1];n&&t.after(n)}}_compareLeft(){if(this._activeTabItem&&this._activeTabItemIndex){const e=this._slideTabItems.findIndex(o=>o.equals(this._activeTabItem)),t=this._slideTabItems.length,n=[];for(let o=0;o<e&&!(o>=e);o++)n.push(this._slideTabItems[o]);for(let o=e+1;o<t;o++)this._slideTabItems[o].animate().translateX(0);let r=!0;for(let o=n.length-1;o>=0;o--){const s=n[o];Ft.leftLine(this._activeTabItem)<s.getMidLine()?(s.animate().translateX(this._activeTabItem.getWidth()),this._compareIndex=o,r=!1):(s.animate().translateX(0),r&&(this._compareIndex=this._activeTabItemIndex))}}}_compareRight(){if(this._activeTabItem){const e=this._slideTabItems.findIndex(o=>o.equals(this._activeTabItem)),t=this._slideTabItems.length,n=[];for(let o=e+1;o<t;o++)n.push(this._slideTabItems[o]);for(let o=0;o<e;o++)this._slideTabItems[o].animate().translateX(0);let r=!0;for(let o=0;o<n.length;o++){const s=n[o];Ft.rightLine(this._activeTabItem)>s.getMidLine()?(s.animate().translateX(-this._activeTabItem.getWidth()),this._compareIndex=e+o+1,r=!1):(s.animate().translateX(0),r&&(this._compareIndex=this._activeTabItemIndex))}}}_initConfig(){const e=this._slideTabBar.querySelectorAll(`.${this._config.slideTabBarItemClassName??"slide-tab-item"}`);this._downActionX=0,this._moveActionX=0,this._compareDirection=0,this._compareIndex=0,this._slideTabItems=Ft.make(e,this),this._activeTabItemIndex=this._config.currentIndex,this._activeTabItem=this._slideTabItems[this._activeTabItemIndex]}};v(qt,"LongPressDelay",500),v(qt,"DoubleClickDelay",300);let yn=qt;function sm(){const[i,e]=X.useState([]),[t,n]=X.useState(""),[r,o]=X.useState(""),s=X.useRef({slideTabBar:null}),a=X.useRef(null),c=me.useDependency(l.IUniverInstanceService),d=me.useDependency(l.ICommandService),u=me.useDependency(cn),h=me.useDependency(l.LocaleService),m=me.useDependency(R.IConfirmService),g=me.useInjector(),_=c.getCurrentUniverSheetInstance();X.useEffect(()=>{N();const W=f(),V=x(),re=[D(),P(),L(),G()];return()=>{V.dispose(),W.destroy(),re.forEach(q=>q.unsubscribe())}},[]),X.useEffect(()=>{i.length>0&&O()},[i]);const f=()=>{const W=new yn({slideTabBarClassName:ot.slideTabBar,slideTabBarItemActiveClassName:ot.slideTabActive,slideTabBarItemClassName:ot.slideTabItem,slideTabBarSpanEditClassName:ot.slideTabSpanEdit,slideTabBarItemAutoSort:!0,slideTabBarContainer:a.current,currentIndex:0,onChangeName:(V,re)=>{d.executeCommand(p.SetWorksheetNameCommand.id,{subUnitId:V,name:re})},onSlideEnd:(V,re)=>{d.executeCommand(p.SetWorksheetOrderCommand.id,{order:re})},onChangeTab:(V,re)=>{d.executeCommand(p.SetWorksheetActivateCommand.id,{subUnitId:re,unitId:_.getUnitId()}),setTimeout(()=>{g.get(y.ITextSelectionRenderManager).focus()},0)},onScroll:V=>{u.setScroll(V)},onNameCheckAlert:V=>C(V)||I(V)});return s.current.slideTabBar=W,te(W),W},C=W=>{if(W.trim()===""){const V="sheetNameEmptyAlert";return m.open({id:V,title:{title:h.t("sheetConfig.sheetNameErrorTitle")},children:{title:h.t("sheetConfig.sheetNameCannotIsEmptyError")},cancelText:h.t("button.cancel"),confirmText:h.t("button.confirm"),onClose(){m.close(V),w()},onConfirm(){m.close(V),w()}}),!0}return!1},I=W=>{const V=c.getCurrentUniverSheetInstance();if(V.getActiveSheet().getName()===W)return!1;const ae=V.checkSheetName(W);if(ae){const Ie="sheetNameRepeatAlert";m.open({id:Ie,title:{title:h.t("sheetConfig.sheetNameErrorTitle")},children:{title:h.t("sheetConfig.sheetNameAlreadyExistsError")},cancelText:h.t("button.cancel"),confirmText:h.t("button.confirm"),onClose(){m.close(Ie),E()},onConfirm(){m.close(Ie),E()}})}return ae},w=()=>{var V,re;const W=(re=(V=s.current.slideTabBar)==null?void 0:V.getActiveItem())==null?void 0:re.getEditor();W&&W.focus()},E=()=>{var W,V;(V=(W=s.current.slideTabBar)==null?void 0:W.getActiveItem())==null||V.setEditor()},O=()=>{var V;const W=i.findIndex(re=>re.selected);(V=s.current.slideTabBar)==null||V.update(W)},x=()=>d.onCommandExecuted(W=>{switch(W.id){case p.SetTabColorMutation.id:case p.SetWorksheetHideMutation.id:case p.RemoveSheetMutation.id:case p.SetWorksheetNameMutation.id:case p.InsertSheetMutation.id:case p.SetWorksheetOrderMutation.id:case p.SetWorksheetActiveOperation.id:N();break}}),N=()=>{const W=_.getActiveSheet().getSheetId();n(W);const re=_.getSheets().filter(q=>!q.isSheetHidden()).map((q,ae)=>({sheetId:q.getSheetId(),label:q.getName(),index:ae,selected:q.getStatus()===l.BooleanNumber.TRUE,color:q.getTabColor()??void 0}));e(re)},D=()=>u.scroll$.subscribe(W=>{k(W)}),P=()=>u.scrollX$.subscribe(W=>{var V;(V=s.current.slideTabBar)==null||V.flipPage(W)}),L=()=>u.renameId$.subscribe(()=>{E()}),G=()=>u.addSheet$.subscribe(()=>{var W;(W=s.current.slideTabBar)==null||W.getScrollbar().scrollRight()}),k=W=>{const{leftEnd:V,rightEnd:re}=W;let q="";V&&re?q="":V&&!re?q="inset -10px 0px 10px -10px rgba(0, 0, 0, 0.2)":!V&&re?q="inset 10px 0px 10px -10px rgba(0, 0, 0, 0.2)":!V&&!re&&(q="inset 10px 0px 10px -10px rgba(0, 0, 0, 0.2), inset -10px 0px 10px -10px rgba(0, 0, 0, 0.2)"),o(q)},ee=W=>{u.setScroll({leftEnd:W.isLeftEnd(),rightEnd:W.isRightEnd()})},te=W=>{var q;const V=(q=a.current)==null?void 0:q.querySelector(`.${ot.slideTabBar}`);if(!V)return;new ResizeObserver(()=>{ee(W)}).observe(V)};return S.jsx("div",{className:ot.slideTabBarContainer,ref:a,children:S.jsx("div",{className:ot.slideTabBar,style:{boxShadow:r},children:i.map(W=>X.createElement(tm,{...W,key:W.sheetId,selected:t===W.sheetId}))})})}const lo=100,am=()=>{const[i,e]=X.useState(!0),[t,n]=X.useState(!0),r=me.useDependency(l.ICommandService),o=me.useDependency(cn);X.useEffect(()=>{const u=o.scroll$.subscribe(h=>{s(h)});return()=>{u.unsubscribe()}},[]);const s=u=>{const{leftEnd:h,rightEnd:m}=u;e(h),n(m)},a=()=>{r.executeCommand(p.InsertSheetCommand.id),setTimeout(()=>{o.setAddSheet(0)},0)},c=()=>{o.setScrollX(-lo)},d=()=>{o.setScrollX(lo)};return S.jsxs("div",{className:Wn.sheetBar,children:[S.jsxs("div",{className:Wn.sheetBarOptions,children:[S.jsx(gi,{onClick:a,children:S.jsx(fl,{})}),S.jsx(Zh,{})]}),S.jsx(sm,{}),(!i||!t)&&S.jsxs("div",{className:`${Wn.sheetBarOptions} ${Wn.sheetBarOptionsDivider}`,children:[S.jsx(gi,{disabled:i,onClick:c,children:S.jsx(jr,{style:{transform:"rotateZ(180deg)"}})}),S.jsx(gi,{disabled:t,onClick:d,children:S.jsx(jr,{})})]})]})};class lm{constructor(){v(this,"_functions",[{func:Re.FUNCTION_NAMES_STATISTICAL.MAX,filter:e=>{var t,n;return(((t=e.values.find(r=>r.func===Re.FUNCTION_NAMES_STATISTICAL.COUNTA))==null?void 0:t.value)??0)>1&&(((n=e.values.find(r=>r.func===Re.FUNCTION_NAMES_STATISTICAL.COUNT))==null?void 0:n.value)??0)>0}},{func:Re.FUNCTION_NAMES_STATISTICAL.MIN,filter:e=>{var t,n;return(((t=e.values.find(r=>r.func===Re.FUNCTION_NAMES_STATISTICAL.COUNTA))==null?void 0:t.value)??0)>1&&(((n=e.values.find(r=>r.func===Re.FUNCTION_NAMES_STATISTICAL.COUNT))==null?void 0:n.value)??0)>0}},{func:Re.FUNCTION_NAMES_MATH.SUM,filter:e=>{var t,n;return(((t=e.values.find(r=>r.func===Re.FUNCTION_NAMES_STATISTICAL.COUNTA))==null?void 0:t.value)??0)>1&&(((n=e.values.find(r=>r.func===Re.FUNCTION_NAMES_STATISTICAL.COUNT))==null?void 0:n.value)??0)>0}},{func:Re.FUNCTION_NAMES_STATISTICAL.COUNTA,filter:e=>{var t;return(((t=e.values.find(n=>n.func===Re.FUNCTION_NAMES_STATISTICAL.COUNTA))==null?void 0:t.value)??0)>1}},{func:Re.FUNCTION_NAMES_STATISTICAL.COUNT,filter:e=>{var t,n;return(((t=e.values.find(r=>r.func===Re.FUNCTION_NAMES_STATISTICAL.COUNTA))==null?void 0:t.value)??0)>1&&(((n=e.values.find(r=>r.func===Re.FUNCTION_NAMES_STATISTICAL.COUNT))==null?void 0:n.value)??0)>0}},{func:Re.FUNCTION_NAMES_STATISTICAL.AVERAGE,filter:e=>{var t,n;return(((t=e.values.find(r=>r.func===Re.FUNCTION_NAMES_STATISTICAL.COUNTA))==null?void 0:t.value)??0)>1&&(((n=e.values.find(r=>r.func===Re.FUNCTION_NAMES_STATISTICAL.COUNT))==null?void 0:n.value)??0)>0}}]);v(this,"_state$",new J.BehaviorSubject(null));v(this,"state$",this._state$.asObservable())}dispose(){this._state$.complete()}setState(e){const t={values:[],pattern:null};e==null||e.values.forEach(n=>{const r=this._functions.find(o=>o.func===n.func);r&&(r.filter===void 0||r.filter(e))&&t.values.push(n)}),t.pattern=(e==null?void 0:e.pattern)??null,this._state$.next(t)}getState(){return this._state$.getValue()}getFunctions(){return this._functions}addFunctions(e){this._functions.push(...e)}}const Cr=j.createIdentifier("univer.sheet-status-bar.service");var Cs={exports:{}};(function(i,e){(function(t,n){i.exports=n()})(typeof self<"u"?self:Ya,function(){return function(){var t={d:function(M,b){for(var T in b)t.o(b,T)&&!t.o(M,T)&&Object.defineProperty(M,T,{enumerable:!0,get:b[T]})},o:function(M,b){return Object.prototype.hasOwnProperty.call(M,b)}},n={};t.d(n,{default:function(){return bs}});var r={1078:"af",1052:"sq",1118:"am",5121:"ar_DZ",15361:"ar_BH",3073:"ar_EG",2049:"ar_IQ",11265:"ar_JO",13313:"ar_KW",12289:"ar_LB",4097:"ar_LY",6145:"ar_MA",8193:"ar_OM",16385:"ar_QA",1025:"ar_SA",10241:"ar_SY",7169:"ar_TN",14337:"ar_AE",9217:"ar_YE",1067:"hy",1101:"as",2092:"az_AZ",1068:"az_AZ",1069:"eu",1059:"be",2117:"bn",1093:"bn_IN",5146:"bs",1026:"bg",1109:"my",1027:"ca",2052:"zh_CN",3076:"zh_HK",5124:"zh_MO",4100:"zh_SG",1028:"zh_TW",1050:"hr",1029:"cs",1030:"da",1125:"dv",2067:"nl_BE",1043:"nl_NL",1126:"bin",3081:"en_AU",10249:"en_BZ",4105:"en_CA",9225:"en_CB",2057:"en_GB",16393:"en_IN",6153:"en_IE",8201:"en_JM",5129:"en_NZ",13321:"en_PH",7177:"en_ZA",11273:"en_TT",1033:"en_US",12297:"en_ZW",1061:"et",1071:"mk",1080:"fo",1065:"fa",1124:"fil",1035:"fi",2060:"fr_BE",11276:"fr_CM",3084:"fr_CA",9228:"fr_CG",12300:"fr_CI",1036:"fr_FR",5132:"fr_LU",13324:"fr_ML",6156:"fr_MC",14348:"fr_MA",10252:"fr_SN",4108:"fr_CH",7180:"fr",1122:"fy_NL",2108:"gd_IE",1084:"gd",1110:"gl",1079:"ka",3079:"de_AT",1031:"de_DE",5127:"de_LI",4103:"de_LU",2055:"de_CH",1032:"el",1140:"gn",1095:"gu",1279:"en",1037:"he",1081:"hi",1038:"hu",1039:"is",1136:"ig_NG",1057:"id",1040:"it_IT",2064:"it_CH",1041:"ja",1099:"kn",1120:"ks",1087:"kk",1107:"km",1111:"kok",1042:"ko",1088:"ky",1108:"lo",1142:"la",1062:"lv",1063:"lt",2110:"ms_BN",1086:"ms_MY",1100:"ml",1082:"mt",1112:"mni",1153:"mi",1102:"mr",1104:"mn",2128:"mn",1121:"ne",1044:"no_NO",2068:"no_NO",1096:"or",1045:"pl",1046:"pt_BR",2070:"pt_PT",1094:"pa",1047:"rm",2072:"ro_MO",1048:"ro_RO",1049:"ru",2073:"ru_MO",1083:"se",1103:"sa",3098:"sr_SP",2074:"sr_SP",1072:"st",1074:"tn",1113:"sd",1115:"si",1051:"sk",1060:"sl",1143:"so",1070:"sb",11274:"es_AR",16394:"es_BO",13322:"es_CL",9226:"es_CO",5130:"es_CR",7178:"es_DO",12298:"es_EC",17418:"es_SV",4106:"es_GT",18442:"es_HN",2058:"es_MX",19466:"es_NI",6154:"es_PA",15370:"es_PY",10250:"es_PE",20490:"es_PR",1034:"es_ES",14346:"es_UY",8202:"es_VE",1089:"sw",2077:"sv_FI",1053:"sv_SE",1114:"syc",1064:"tg",1097:"ta",1092:"tt",1098:"te",1054:"th",1105:"bo",1073:"ts",1055:"tr",1090:"tk",1058:"uk",1056:"ur",2115:"uz_UZ",1091:"uz_UZ",1075:"ve",1066:"vi",1106:"cy",1076:"xh",1085:"yi",1077:"zu"};const o=/^([a-z\d]+)(?:[_-]([a-z\d]+))?(?:\.([a-z\d]+))?(?:@([a-z\d]+))?$/i,s={},a={group:" ",decimal:".",positive:"+",negative:"-",percent:"%",exponent:"E",nan:"NaN",infinity:"∞",ampm:["AM","PM"],mmmm6:["Muharram","Safar","Rabiʻ I","Rabiʻ II","Jumada I","Jumada II","Rajab","Shaʻban","Ramadan","Shawwal","Dhuʻl-Qiʻdah","Dhuʻl-Hijjah"],mmm6:["Muh.","Saf.","Rab. I","Rab. II","Jum. I","Jum. II","Raj.","Sha.","Ram.","Shaw.","Dhuʻl-Q.","Dhuʻl-H."],mmmm:["January","February","March","April","May","June","July","August","September","October","November","December"],mmm:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],dddd:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],ddd:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]};function c(M){const b=o.exec(M);if(!b)throw new SyntaxError("Malformed locale: ".concat(M));return{lang:b[1]+(b[2]?"_"+b[2]:""),language:b[1],territory:b[2]||"",codeset:b[3]||"",modifier:b[4]||""}}function d(M){if(typeof M=="number")return r[65535&M]||null;const b=parseInt(M,16);return isFinite(b)&&r[65535&b]?r[65535&b]||null:o.test(M)?M:null}function u(M){const b=d(M);let T=null;if(b){const H=c(b);T=s[H.lang]||s[H.language]||null}return T}function h(M){return Object.assign({},a,M)}function m(M,b){const T=typeof b=="object"?b:c(b);return s[T.lang]=h(M),T.language===T.lang||s[T.language]||(s[T.language]=h(M)),s[T.lang]}const g=h({group:","});function _(M,b){if(typeof M!="number")return M;if(M<0)return-_(-M,b);if(b){const T=10**(b||0)||1;return _(M*T,0)/T}return Math.round(M)}g.isDefault=!0,m({group:",",ampm:["上午","下午"],mmmm:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"],mmm:["1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"],dddd:["星期日","星期一","星期二","星期三","星期四","星期五","星期六"],ddd:["周日","周一","周二","周三","周四","周五","周六"]},"zh_CN"),m({group:",",nan:"非數值",ampm:["上午","下午"],mmmm:["1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"],mmm:["1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"],dddd:["星期日","星期一","星期二","星期三","星期四","星期五","星期六"],ddd:["週日","週一","週二","週三","週四","週五","週六"]},"zh_TW"),m({group:",",ampm:["午前","午後"],mmmm:["1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"],mmm:["1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"],dddd:["日曜日","月曜日","火曜日","水曜日","木曜日","金曜日","土曜日"],ddd:["日","月","火","水","木","金","土"]},"ja"),m({group:",",ampm:["오전","오후"],mmmm:["1월","2월","3월","4월","5월","6월","7월","8월","9월","10월","11월","12월"],mmm:["1월","2월","3월","4월","5월","6월","7월","8월","9월","10월","11월","12월"],dddd:["일요일","월요일","화요일","수요일","목요일","금요일","토요일"],ddd:["일","월","화","수","목","금","토"]},"ko"),m({group:",",ampm:["ก่อนเที่ยง","หลังเที่ยง"],mmmm:["มกราคม","กุมภาพันธ์","มีนาคม","เมษายน","พฤษภาคม","มิถุนายน","กรกฎาคม","สิงหาคม","กันยายน","ตุลาคม","พฤศจิกายน","ธันวาคม"],mmm:["ม.ค.","ก.พ.","มี.ค.","เม.ย.","พ.ค.","มิ.ย.","ก.ค.","ส.ค.","ก.ย.","ต.ค.","พ.ย.","ธ.ค."],dddd:["วันอาทิตย์","วันจันทร์","วันอังคาร","วันพุธ","วันพฤหัสบดี","วันศุกร์","วันเสาร์"],ddd:["อา.","จ.","อ.","พ.","พฤ.","ศ.","ส."]},"th"),m({decimal:",",ampm:["dop.","odp."],mmmm:["ledna","února","března","dubna","května","června","července","srpna","září","října","listopadu","prosince"],mmm:["led","úno","bře","dub","kvě","čvn","čvc","srp","zář","říj","lis","pro"],dddd:["neděle","pondělí","úterý","středa","čtvrtek","pátek","sobota"],ddd:["ne","po","út","st","čt","pá","so"]},"cs"),m({group:".",decimal:",",mmmm:["januar","februar","marts","april","maj","juni","juli","august","september","oktober","november","december"],mmm:["jan.","feb.","mar.","apr.","maj","jun.","jul.","aug.","sep.","okt.","nov.","dec."],dddd:["søndag","mandag","tirsdag","onsdag","torsdag","fredag","lørdag"],ddd:["søn.","man.","tir.","ons.","tor.","fre.","lør."]},"da"),m({group:".",decimal:",",ampm:["a.m.","p.m."],mmmm:["januari","februari","maart","april","mei","juni","juli","augustus","september","oktober","november","december"],mmm:["jan.","feb.","mrt.","apr.","mei","jun.","jul.","aug.","sep.","okt.","nov.","dec."],dddd:["zondag","maandag","dinsdag","woensdag","donderdag","vrijdag","zaterdag"],ddd:["zo","ma","di","wo","do","vr","za"]},"nl"),m({group:","},"en"),m({decimal:",",nan:"epäluku",ampm:["ap.","ip."],mmmm:["tammikuuta","helmikuuta","maaliskuuta","huhtikuuta","toukokuuta","kesäkuuta","heinäkuuta","elokuuta","syyskuuta","lokakuuta","marraskuuta","joulukuuta"],mmm:["tammik.","helmik.","maalisk.","huhtik.","toukok.","kesäk.","heinäk.","elok.","syysk.","lokak.","marrask.","jouluk."],dddd:["sunnuntaina","maanantaina","tiistaina","keskiviikkona","torstaina","perjantaina","lauantaina"],ddd:["su","ma","ti","ke","to","pe","la"]},"fi"),m({group:" ",decimal:",",mmmm:["janvier","février","mars","avril","mai","juin","juillet","août","septembre","octobre","novembre","décembre"],mmm:["janv.","févr.","mars","avr.","mai","juin","juil.","août","sept.","oct.","nov.","déc."],dddd:["dimanche","lundi","mardi","mercredi","jeudi","vendredi","samedi"],ddd:["dim.","lun.","mar.","mer.","jeu.","ven.","sam."]},"fr"),m({group:".",decimal:",",mmmm:["Januar","Februar","März","April","Mai","Juni","Juli","August","September","Oktober","November","Dezember"],mmm:["Jan.","Feb.","März","Apr.","Mai","Juni","Juli","Aug.","Sept.","Okt.","Nov.","Dez."],dddd:["Sonntag","Montag","Dienstag","Mittwoch","Donnerstag","Freitag","Samstag"],ddd:["So.","Mo.","Di.","Mi.","Do.","Fr.","Sa."]},"de"),m({group:".",decimal:",",ampm:["π.μ.","μ.μ."],mmmm:["Ιανουαρίου","Φεβρουαρίου","Μαρτίου","Απριλίου","Μαΐου","Ιουνίου","Ιουλίου","Αυγούστου","Σεπτεμβρίου","Οκτωβρίου","Νοεμβρίου","Δεκεμβρίου"],mmm:["Ιαν","Φεβ","Μαρ","Απρ","Μαΐ","Ιουν","Ιουλ","Αυγ","Σεπ","Οκτ","Νοε","Δεκ"],dddd:["Κυριακή","Δευτέρα","Τρίτη","Τετάρτη","Πέμπτη","Παρασκευή","Σάββατο"],ddd:["Κυρ","Δευ","Τρί","Τετ","Πέμ","Παρ","Σάβ"]},"el"),m({decimal:",",ampm:["de.","du."],mmmm:["január","február","március","április","május","június","július","augusztus","szeptember","október","november","december"],mmm:["jan.","febr.","márc.","ápr.","máj.","jún.","júl.","aug.","szept.","okt.","nov.","dec."],dddd:["vasárnap","hétfő","kedd","szerda","csütörtök","péntek","szombat"],ddd:["V","H","K","Sze","Cs","P","Szo"]},"hu"),m({group:".",decimal:",",ampm:["f.h.","e.h."],mmmm:["janúar","febrúar","mars","apríl","maí","júní","júlí","ágúst","september","október","nóvember","desember"],mmm:["jan.","feb.","mar.","apr.","maí","jún.","júl.","ágú.","sep.","okt.","nóv.","des."],dddd:["sunnudagur","mánudagur","þriðjudagur","miðvikudagur","fimmtudagur","föstudagur","laugardagur"],ddd:["sun.","mán.","þri.","mið.","fim.","fös.","lau."]},"is"),m({group:".",decimal:",",mmmm:["Januari","Februari","Maret","April","Mei","Juni","Juli","Agustus","September","Oktober","November","Desember"],mmm:["Jan","Feb","Mar","Apr","Mei","Jun","Jul","Agu","Sep","Okt","Nov","Des"],dddd:["Minggu","Senin","Selasa","Rabu","Kamis","Jumat","Sabtu"],ddd:["Min","Sen","Sel","Rab","Kam","Jum","Sab"]},"id"),m({group:".",decimal:",",mmmm:["gennaio","febbraio","marzo","aprile","maggio","giugno","luglio","agosto","settembre","ottobre","novembre","dicembre"],mmm:["gen","feb","mar","apr","mag","giu","lug","ago","set","ott","nov","dic"],dddd:["domenica","lunedì","martedì","mercoledì","giovedì","venerdì","sabato"],ddd:["dom","lun","mar","mer","gio","ven","sab"]},"it"),m({decimal:",",ampm:["a.m.","p.m."],mmmm:["januar","februar","mars","april","mai","juni","juli","august","september","oktober","november","desember"],mmm:["jan.","feb.","mar.","apr.","mai","jun.","jul.","aug.","sep.","okt.","nov.","des."],dddd:["søndag","mandag","tirsdag","onsdag","torsdag","fredag","lørdag"],ddd:["søn.","man.","tir.","ons.","tor.","fre.","lør."]},"nb"),m({decimal:",",mmmm:["stycznia","lutego","marca","kwietnia","maja","czerwca","lipca","sierpnia","września","października","listopada","grudnia"],mmm:["sty","lut","mar","kwi","maj","cze","lip","sie","wrz","paź","lis","gru"],dddd:["niedziela","poniedziałek","wtorek","środa","czwartek","piątek","sobota"],ddd:["niedz.","pon.","wt.","śr.","czw.","pt.","sob."]},"pl"),m({group:".",decimal:",",mmmm:["janeiro","fevereiro","março","abril","maio","junho","julho","agosto","setembro","outubro","novembro","dezembro"],mmm:["jan.","fev.","mar.","abr.","mai.","jun.","jul.","ago.","set.","out.","nov.","dez."],dddd:["domingo","segunda-feira","terça-feira","quarta-feira","quinta-feira","sexta-feira","sábado"],ddd:["dom.","seg.","ter.","qua.","qui.","sex.","sáb."]},"pt"),m({decimal:",",nan:"не число",mmmm:["января","февраля","марта","апреля","мая","июня","июля","августа","сентября","октября","ноября","декабря"],mmm:["янв.","февр.","мар.","апр.","мая","июн.","июл.","авг.","сент.","окт.","нояб.","дек."],dddd:["воскресенье","понедельник","вторник","среда","четверг","пятница","суббота"],ddd:["вс","пн","вт","ср","чт","пт","сб"]},"ru"),m({decimal:",",mmmm:["januára","februára","marca","apríla","mája","júna","júla","augusta","septembra","októbra","novembra","decembra"],mmm:["jan","feb","mar","apr","máj","jún","júl","aug","sep","okt","nov","dec"],dddd:["nedeľa","pondelok","utorok","streda","štvrtok","piatok","sobota"],ddd:["ne","po","ut","st","št","pi","so"]},"sk"),m({group:".",decimal:",",ampm:["a. m.","p. m."],mmmm:["enero","febrero","marzo","abril","mayo","junio","julio","agosto","septiembre","octubre","noviembre","diciembre"],mmm:["ene.","feb.","mar.","abr.","may.","jun.","jul.","ago.","sept.","oct.","nov.","dic."],dddd:["domingo","lunes","martes","miércoles","jueves","viernes","sábado"],ddd:["dom.","lun.","mar.","mié.","jue.","vie.","sáb."]},"es"),m({decimal:",",ampm:["fm","em"],mmmm:["januari","februari","mars","april","maj","juni","juli","augusti","september","oktober","november","december"],mmm:["jan.","feb.","mars","apr.","maj","juni","juli","aug.","sep.","okt.","nov.","dec."],dddd:["söndag","måndag","tisdag","onsdag","torsdag","fredag","lördag"],ddd:["sön","mån","tis","ons","tors","fre","lör"]},"sv"),m({group:".",decimal:",",ampm:["ÖÖ","ÖS"],mmmm:["Ocak","Şubat","Mart","Nisan","Mayıs","Haziran","Temmuz","Ağustos","Eylül","Ekim","Kasım","Aralık"],mmm:["Oca","Şub","Mar","Nis","May","Haz","Tem","Ağu","Eyl","Eki","Kas","Ara"],dddd:["Pazar","Pazartesi","Salı","Çarşamba","Perşembe","Cuma","Cumartesi"],ddd:["Paz","Pzt","Sal","Çar","Per","Cum","Cmt"]},"tr");function f(M,b,T){const H=M<0?-1:1,F=10**(b||2),Y=10**(T||2);let B,U,A=Math.abs(M),K=0,oe=0,z=0,se=1;if((M=A)%1==0)U=[M*H,1];else if(M<1e-19)U=[H,1e19];else if(M>1e19)U=[1e19*H,1];else{do if(A=1/(A-Math.floor(A)),B=se,se=se*Math.floor(A)+K,K=B,oe=z,z=Math.floor(M*se+.5),z>=F||se>=Y)return[H*oe,K];while(Math.abs(M-z/se)>=1e-10&&A!==Math.floor(A));U=[H*z,se]}return U}const C={overflow:"######",dateErrorThrows:!1,dateErrorNumber:!0,dateSpanLarge:!0,leap1900:!0,nbsp:!0,throws:!0,invalid:"######",locale:"",ignoreTimezone:!1},I=Object.assign({},C);function w(M){if(M===null&&(M=C),M){for(const b in M)if(b in C){const T=M[b];I[b]=T??C[b]}}return{...I}}const E={"#":"",0:"0","?":" "},O={"@":"text","-":"minus","+":"plus"},x=["#000","#FFF","#F00","#0F0","#00F","#FF0","#F0F","#0FF","#000","#FFF","#F00","#0F0","#00F","#FF0","#F0F","#0FF","#800","#080","#008","#880","#808","#088","#CCC","#888","#99F","#936","#FFC","#CFF","#606","#F88","#06C","#CCF","#008","#F0F","#FF0","#0FF","#808","#800","#088","#00F","#0CF","#CFF","#CFC","#FF9","#9CF","#F9C","#C9F","#FC9","#36F","#3CC","#9C0","#FC0"],N=["¤","$","£","¥","֏","؋","৳","฿","៛","₡","₦","₩","₪","₫","€","₭","₮","₱","₲","₴","₸","₹","₺","₼","₽","₾","₿"],D=new RegExp("["+N.join("")+"]");function P(M,b,T){return b[T+"_max"]=M.length,b[T+"_min"]=M.replace(/#/g,"").length,b}const L={};function G(M){if(!(M in L)){const b=[],T=M.replace(/^[#,]+/,"").replace(/[1-9]\d*/g,H=>"?".repeat(H.length));for(let H=0;H<T.length;H++){const F=T.charAt(H);b[H]=F in E?E[F]:F}L[M]=b.join("")}return L[M]}function k(M,b){typeof M=="string"&&(M={type:"string",value:M=M.replace(/ /g,E["?"])}),b.push(M)}function ee(M){const b=[],T={scale:1,percent:!1,text:!1,date:0,date_eval:!1,date_system:1,sec_decimals:0,general:!1,clock:24,int_pattern:[],frac_pattern:[],man_pattern:[],den_pattern:[],num_pattern:[],tokens:b};let H=M+"",F="int",Y=!1,B=null;const U=[];let A,K,oe=!1;for(;H&&!Y;){if(A=/^General/i.exec(H))T.general=!0,k({type:"general"},b);else if(F==="int"&&(A=/^[#?0]+(?:,[#?0]+)*/.exec(H))||F==="den"&&(A=/^[#?\d]+/.exec(H))||(A=/^[#?0]+/.exec(H)))T[F+"_pattern"].push(A[0]),B={type:F,num:A[0]},k(B,b);else if((A=/^\//.exec(H))&&T[F+"_pattern"].length){if(!B)throw new SyntaxError("Missing a numerator in pattern ".concat(M));T.fractions=!0,T.num_pattern.push(T[F+"_pattern"].pop()),B.type="num",F="den",k({type:"div"},b)}else if(A=/^,+/.exec(H)){const $=H.charAt(1)in E;K.slice(-1)in E&&(A[0].length>1||!$)?T.scale=.001**A[0].length:T.dec_fractions||k(A[0],b)}else{if(A=/^;/.exec(H)){Y=!0;break}if(A=/^[@+-]/.exec(H))A[0]==="@"&&(T.text=!0),k({type:O[A[0]]},b);else if(A=/^(?:\[(h+|m+|s+)\])/i.exec(H)){const $=A[1].toLowerCase(),ie=$[0],ce={type:"",size:0,date:1,raw:A[0],pad:$.length};ie==="h"?(ce.size=16,ce.type="hour-elap"):ie==="m"?(ce.size=32,ce.type="min-elap"):(ce.size=64,ce.type="sec-elap"),T.date=T.date|ce.size,U.push(ce),k(ce,b)}else if(A=/^(?:B2)/i.exec(H))oe||(T.date_system=6);else if(A=/^(?:B1)/i.exec(H))oe||(T.date_system=1);else if(A=/^(?:([hHmMsSyYbBdDegG])\1*)/.exec(H)){const $={type:"",size:0,date:1,raw:A[0]},ie=A[0].toLowerCase(),ce=ie[0];if(ie==="y"||ie==="yy")$.size=2,$.type="year-short";else if(ce==="y"||ce==="e")$.size=2,$.type="year";else if(ie==="b"||ie==="bb")$.size=2,$.type="b-year-short";else if(ce==="b")$.size=2,$.type="b-year";else if(ie==="d"||ie==="dd")$.size=8,$.type="day",$.pad=/dd/.test(ie);else if(ie==="ddd")$.size=8,$.type="weekday-short";else if(ce==="d")$.size=8,$.type="weekday";else if(ce==="h")$.size=16,$.type="hour",$.pad=/hh/i.test(ie);else if(ce==="m"){ie.length===3?($.size=4,$.type="monthname-short"):ie.length===5?($.size=4,$.type="monthname-single"):ie.length>=4&&($.size=4,$.type="monthname");const _e=U[U.length-1];!$.type&&_e&&!_e.used&&80&_e.size&&(_e.used=!0,$.size=32,$.type="min",$.pad=/mm/.test(ie)),$.type||($.size=4,$.type="month",$.pad=/mm/.test(ie),$.indeterminate=!0)}else if(ce==="s"){$.size=64,$.type="sec",$.pad=/ss/.test(ie);const _e=U[U.length-1];_e&&32&_e.size?$.used=!0:_e&&_e.indeterminate&&(delete _e.indeterminate,_e.size=32,_e.type="min",$.used=!0)}T.date=T.date|$.size,T.date_eval=!0,U.push($),k($,b)}else if(A=/^(?:AM\/PM|am\/pm|A\/P)/.exec(H))T.clock=12,T.date=16|T.date,T.date_eval=!0,k({type:"am",short:A[0]==="A/P"},b);else if(T.date&&(A=/^\.0{1,3}/i.exec(H))){const $=A[0].length-1,ie=[64,128,256,512][$];T.date=T.date|ie,T.date_eval=!0,T.sec_decimals=Math.max(T.sec_decimals,$),k({type:"subsec",size:ie,decimals:$,date:1,raw:A[0]},b)}else if((A=/^\\(.)/.exec(H))||(A=/^"([^"]*?)"/.exec(H)))k(A[1],b);else if(A=/^\[(<[=>]?|>=?|=)\s*(-?[.\d]+)\]/.exec(H))T.condition=[A[1],parseFloat(A[2],10)];else if(A=/^\[\$([^\]]+)\]/.exec(H)){const $=A[1].split("-"),ie=$.length<2?"":$[$.length-1],ce=$[0];ce&&k(ce,b);const _e=d(ie);_e&&(T.locale=_e);const Ce=parseInt(ie,16);isFinite(Ce)&&16711680&Ce&&(Ce>>16&255)===6&&(T.date_system=6),oe=!0}else if(A=/^\[(black|blue|cyan|green|magenta|red|white|yellow|color\s*(\d+))\]/i.exec(H))T.color=A[2]?x[parseInt(A[2],10)]||"#000":A[1].toLowerCase();else if(!(A=/^\[(DBNum1|ENG|HIJ|JPN|TWN)\]/i.exec(H))){if(A=/^%/.exec(H))T.scale=100,T.percent=!0,k("%",b);else if(A=/^_(\\.|.)/.exec(H))k(" ",b);else if(A=/^\./.exec(H))k({type:"point",value:A[0]},b),T.dec_fractions=!0,F="frac";else if(A=/^[Ee]([+-]?|(?=[0#?]))/.exec(H))T.exponential=!0,T.exp_plus=A[1]==="+",F="man",k({type:"exp",plus:A[1]==="+"},b);else if(!(A=/^\*(\\.|.)/.exec(H))){if(A=/^[BENn[]/.exec(H))throw new SyntaxError("Unexpected char ".concat(H.charAt(0)," in pattern ").concat(M));H[0]==="("&&(T.parens=!0),A=[H[0]],k(A[0],b)}}}K=A[0],H=H.slice(A?A[0].length:1)}if(T.pattern=M.slice(0,M.length-H.length),/^((?:\[[^\]]+\])+)(;|$)/.test(T.pattern)&&!/^\[(?:h+|m+|s+)\]/.test(T.pattern)&&k({type:"text"},b),T.fractions&&T.dec_fractions||T.fractions&&T.exponential)throw new SyntaxError("Invalid pattern: ".concat(T.pattern));const z=T.int_pattern.join("");if(T.grouping=z.indexOf(",")>=0,T.grouping){const $=z.split(","),ie=$.length;ie===2?(T.group_pri=$[1].length,T.group_sec=T.group_pri):ie>2&&(T.group_pri=$[ie-1].length,T.group_sec=$[ie-2].length)}else T.group_pri=0,T.group_sec=0;P(z.replace(/[,]/g,""),T,"int"),P(T.frac_pattern.join(""),T,"frac"),P(T.man_pattern.join(""),T,"man");let se=T.num_pattern.join(""),ue=T.den_pattern.join("");const le=/\?/.test(ue)||/\?/.test(se);return ue=ue.replace(/\d/g,le?"?":"#"),le&&(ue=ue.replace(/#$/g,"?")),P(se,T,"num"),P(ue,T,"den"),le&&(se=se.replace(/#$/g,"?")),T.int_padding=G(T.int_pattern.join("")),T.man_padding=G(T.man_pattern.join("")),T.num_padding=G(se),T.den_padding=G(ue),T.den_pattern.length&&(T.denominator=parseInt(T.den_pattern.join("").replace(/\D/g,""),10)),T.integer=!!T.int_pattern.join("").length,T.fractions&&b.forEach(($,ie)=>{const ce=b[ie+1];$.type==="string"&&ce&&(ce.type==="num"?$.rule="num+int":ce.type==="div"?$.rule="num":ce.type==="den"&&($.rule="den"))}),T}const te=M=>{const b=M.condition;b&&b[1]<0&&(b[0]==="<"||b[0]==="<="||b[0]==="=")||M.tokens.unshift({type:"minus",volatile:!0})};function W(M){const b=[];let T,H=!1,F=null,Y=M,B=0,U=!1,A=0,K=0;do{if(U=ee(Y),(U.date||U.general)&&(U.int_pattern.length||U.frac_pattern.length||U.scale!==1||U.text))throw new Error("Illegal format");if(U.condition&&(K++,H=!0),U.text){if(F)throw new Error("Unexpected partition");F=U}U.locale&&(T=d(U.locale)),b.push(U),B=Y.charAt(U.pattern.length)===";"?1:0,Y=Y.slice(U.pattern.length+B),A++}while(B&&A<4&&K<3);if(B)throw new Error("Unexpected partition");if(K>2)throw new Error("Unexpected condition");const oe=b[3];if(oe&&(oe.int_pattern.length||oe.frac_pattern.length||oe.date))throw new Error("Unexpected partition");if(H){const z=b.length;if(z===1&&(b[1]=ee("General"),b[1].generated=!0),z<3){const se=b[0],ue=b[1];if(te(se),ue.condition)te(ue);else{const le=se.condition;(le[0]==="="||le[1]>=0&&(le[0]===">"||le[0]===">="))&&ue.tokens.unshift({type:"minus",volatile:!0})}}else b.forEach(te)}else{if(b.length<4&&F)for(let z=0,se=b.length;z<se;z++)b[z]===F&&b.splice(z,1);if(b.length<1&&F&&(b[0]=ee("General"),b[0].generated=!0),b.length<2){const z=ee(b[0].pattern);z.tokens.unshift({type:"minus",volatile:!0}),z.generated=!0,b.push(z)}if(b.length<3){const z=ee(b[0].pattern);z.generated=!0,b.push(z)}if(b.length<4)if(F)b.push(F);else{const z=ee("@");z.generated=!0,b.push(z)}b[0].condition=[">",0],b[1].condition=["<",0],b[2].condition=null}return{pattern:M,partitions:b,locale:T}}const V=Math.floor;function re(M){if((!(arguments.length>1&&arguments[1]!==void 0)||arguments[1])&&M>=0){if(M===0)return[1900,1,0];if(M===60)return[1900,2,29];if(M<60)return[1900,M<32?1:2,(M-1)%31+1]}let T=M+68569+2415019;const H=V(4*T/146097);T-=V((146097*H+3)/4);const F=V(4e3*(T+1)/1461001);T=T-V(1461*F/4)+31;const Y=V(80*T/2447),B=T-V(2447*Y/80);T=V(Y/11);const U=Y+2-12*T;return[0|100*(H-49)+F+T,0|U,0|B]}function q(M){return re(M+1462)}function ae(M){if(M===60)throw new Error("#VALUE!");if(M<=1)return[1317,8,29];if(M<60)return[1317,M<32?9:10,1+(M-2)%30];const b=10631/30,T=.1335;let H=M+466935;const F=V(H/10631);H-=10631*F;const Y=V((H-T)/b);H-=V(Y*b+T);const B=V((H+28.5001)/29.5);return B===13?[30*F+Y,12,30]:[30*F+Y,B,H-V(29.5001*B-29)]}function Ie(M){let b=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,T=!(arguments.length>2&&arguments[2]!==void 0)||arguments[2];const H=V(M);return b===6?ae(H):b===-1?q(H):re(H,T)}const de=Math.floor,Ee=86400;function be(M,b){let T=null;if(Array.isArray(M)){const[H,F,Y,B,U,A]=M;T=Date.UTC(H,F==null?0:F-1,Y??1,B||0,U||0,A||0)}else if(M instanceof Date&&(T=1*M,!b||!b.ignoreTimezone)){const H=new Date;H.setUTCFullYear(M.getFullYear(),M.getMonth(),M.getDate()),H.setUTCHours(M.getHours(),M.getMinutes(),M.getSeconds(),M.getMilliseconds()),T=1*H}if(T!=null&&isFinite(T)){const H=T/864e5;return H-(H<=-25509?-25568:-25569)}return M}function De(M,b){let T=0|M;const H=Ee*(M-T);let F=de(H);H-F>.9999&&(F+=1,F===Ee&&(F=0,T+=1));const Y=F<0?Ee+F:F,[B,U,A]=Ie(M,0,b&&b.leap1900),K=de(Y/60/60)%60,oe=de(Y/60)%60,z=de(Y)%60;if(b&&b.nativeDate){const se=new Date(0);return se.setUTCFullYear(B,U-1,A),se.setUTCHours(K,oe,z),se}return[B,U,A,K,oe,z]}function Oe(M){return!!(M[0]&&M[0].percent||M[1]&&M[1].percent||M[2]&&M[2].percent||M[3]&&M[3].percent)}function Le(M){return!!(M[0]&&M[0].date||M[1]&&M[1].date||M[2]&&M[2].date||M[3]&&M[3].date)}function Se(M){const[b,T,H,F]=M;return!(b&&!b.generated||T&&!T.generated||H&&!H.generated||!F||!F.text||F.generated)}const he={text:15,datetime:10.8,date:10.8,time:10.8,percent:10.6,currency:10.4,grouped:10.2,scientific:6,number:4,fraction:2,general:0,error:0},ge=[["DMY",1],["DM",2],["MY",3],["MDY",4],["MD",5],["hmsa",6],["hma",7],["hms",8],["hm",9]],Ae={total:1,sign:0,period:0,int:1,frac:0},we=(M,b)=>M.replace(/\./,b.decimal);function Pe(M,b,T,H){const F=0|T;if(typeof T=="string")M.push(T);else if(T===F)M.push(Math.abs(F));else{const Y=Math.abs(T);let B=Y?Math.floor(Math.log10(Y)):0,U=B<0?Y*10**-B:Y/10**B;U===10&&(U=1,B++);const A=function(oe){let z=!(arguments.length>1&&arguments[1]!==void 0)||arguments[1];const se=Math.abs(oe);if(!se)return Ae;const ue=z&&oe<0?1:0,le=Math.floor(se),$=Math.floor(Math.log10(se)+1);let ie=0,ce=0;if(le!==se){ie=1;const _e=String(_($<0?se*10**-$:se/10**$,15));let Ce=_e.length,ve=!0,je=0;for(;je<=_e.length;){if(_e[je]==="."){Ce--;break}_e[je]==="0"&&ve?Ce--:ve=!1,je++}ce=Ce-$,ce<0&&(ce=0,ie=0)}return{total:ue+Math.max($,1)+ie+ce,digits:Math.max($,0)+ce,sign:ue,period:ie,int:Math.max($,1),frac:ce}}(Y),K=()=>{const oe=Math.abs(B);let z;z=U===1?U:_(U,5),M.push(we(z+"",H),H.exponent,B<0?H.negative:H.positive,oe<10?"0":"",oe)};if(B>=-4&&B<=-1){const oe=Y.toPrecision(10+B).replace(/\.?0+$/,"");M.push(we(oe,H))}else if(B===10){const oe=Y.toFixed(10).slice(0,12).replace(/\.$/,"");M.push(we(oe,H))}else if(Math.abs(B)<=9)if(A.total<=11){const oe=_(Y,9).toFixed(A.frac);M.push(we(oe,H))}else B===9?M.push(Math.floor(Y)):B>=0&&B<9?M.push(_(Y,9-B)):K();else A.total>=12?K():Math.floor(Y)===Y?M.push(Math.floor(Y)):M.push(we(_(Y,9).toFixed(A.frac),H))}return M}const Ue=86400,Ne={int:"integer",frac:"fraction",man:"mantissa",num:"numerator",den:"denominator"},it=function(M){let b=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;const T=Math.floor(Math.log10(M));return b>1?Math.floor(T/b)*b:T};function Fe(M,b,T,H){let F="",Y="",B="",U="",A="",K=0,oe=0|M,z=0,se=0,ue=1,le=0,$=0,ie=0,ce=0,_e=0,Ce=0;const ve=H||g;if(!b.text&&isFinite(b.scale)&&b.scale!==1&&(M=function(fe){if(fe===0)return fe;const Me=Math.ceil(Math.log10(fe<0?-fe:fe)),Z=10**(16-Math.floor(Me));return Math.round(fe*Z)/Z}(M*b.scale)),b.exponential){let fe=Math.abs(M);if(fe){const Me=10**-it(fe,b.int_max),Z=_(fe*Me,b.frac_max)/Me;K=it(Z,b.int_max)}fe/=10**K,M=M<0?-fe:fe,F+=Math.abs(K)}if(b.integer){const fe=Math.abs(_(M,b.fractions?1:b.frac_max));A+=fe<1?"":Math.floor(fe)}if(b.grouping){let fe="",Me=A.length;for(Me>b.group_pri&&(Me-=b.group_pri,fe=ve.group+A.slice(Me,Me+b.group_pri)+fe);Me>b.group_sec;)Me-=b.group_sec,fe=ve.group+A.slice(Me,Me+b.group_sec)+fe;A=Me?A.slice(0,Me)+fe:fe}b.dec_fractions&&(U=String(_(M,b.frac_max)).split(".")[1]||"");let je=!1;if(b.fractions){const fe=Math.abs(b.integer?M%1:M);if(fe)if(je=!0,isFinite(b.denominator))B+=b.denominator,Y+=_(fe*b.denominator),Y==="0"&&(Y="",B="",je=!1,A||(A="0"));else{const Me=f(fe,b.integer?b.num_max:1/0,b.den_max);Y+=Me[0],B+=Me[1],b.integer&&Y==="0"&&(A||(A="0"),Y="",B="",je=!1)}}if(b.date){oe=Math.trunc(M);const fe=Ue*(M-oe);if(z=Math.floor(fe),Ce=fe-z,Math.abs(Ce)<1e-6?Ce=0:Ce>.9999&&(Ce=0,z+=1,z===Ue&&(z=0,oe+=1)),Ce){const Me=512&b.date||256&b.date||128&b.date;(Me===512&&Ce>.9995||Me===256&&Ce>.995||Me===128&&Ce>.95||!Me&&Ce>=.5)&&(z++,Ce=0)}if(oe||b.date_system){const Me=Ie(M,b.date_system,T.leap1900);se=Me[0],ue=Me[1],le=Me[2]}if(z){const Me=z<0?Ue+z:z;_e=Math.floor(Me)%60,ce=Math.floor(Me/60)%60,ie=Math.floor(Me/60/60)%60}if($=(6+oe)%7,b.date_eval&&(St=M,Dt=oe+z/Ue,T.dateSpanLarge?St<-694324||Dt>=35830291:St<0||Dt>=2958466)){if(T.dateErrorThrows)throw new Error("Date out of bounds");return T.dateErrorNumber?Pe(M<0?[ve.negative]:[],0,M,ve).join(""):T.overflow}}var St,Dt;if(b.int_padding&&(A=b.int_padding.length===1?A||b.int_padding:b.int_padding.substring(0,b.int_padding.length-A.length)+A),b.num_padding&&(Y=b.num_padding.length===1?Y||b.num_padding:b.num_padding.substring(0,b.num_padding.length-Y.length)+Y),b.den_padding&&(B=b.den_padding.length===1?B||b.den_padding:B+b.den_padding.slice(B.length)),b.man_padding){const fe=b.exp_plus?"+":"";F=b.man_padding.length===1?(K<0?"-":fe)+(F||b.man_padding):(K<0?"-":fe)+b.man_padding.slice(0,b.man_padding.length-F.length)+F}const ne=[];let et=0;const wt={int:0,frac:0,man:0,num:0,den:0};for(let fe=0,Me=b.tokens.length;fe<Me;fe++){const Z=b.tokens[fe],Ln=Z.num?Z.num.length:0;if(Z.type==="string")Z.rule?Z.rule==="num"?je?ne.push(Z.value):(b.num_min>0||b.den_min>0)&&ne.push(Z.value.replace(/./g,E["?"])):Z.rule==="num+int"?je&&A?ne.push(Z.value):b.den_min>0&&(A||b.num_min)&&ne.push(Z.value.replace(/./g,E["?"])):Z.rule==="den"&&(je?ne.push(Z.value):(b.den_min>0||b.den_min>0)&&ne.push(Z.value.replace(/./g,E["?"]))):ne.push(Z.value);else if(Z.type==="error")ne.push(T.invalid);else if(Z.type==="point")ne.push(b.date?Z.value:ve.decimal);else if(Z.type==="general")Pe(ne,0,M,ve);else if(Z.type==="exp")ne.push(ve.exponent);else if(Z.type==="minus")Z.volatile&&b.date||Z.volatile&&(M>=0||typeof M!="number")||(Z.volatile&&!b.fractions&&(b.integer||b.dec_fractions)?(M<0&&A&&A!=="0"||U)&&ne.push(ve.negative):ne.push(ve.negative));else if(Z.type==="plus")ne.push(ve.positive);else if(Z.type==="text")ne.push(M);else if(Z.type==="div")je?ne.push("/"):b.num_min>0||b.den_min>0?ne.push(E["?"]):ne.push(E["#"]);else if(Z.type==="int")if(b.int_pattern.length===1)ne.push(A);else{const ke=et?b.int_pattern.join("").length-wt.int:1/0,Wt=et===b.int_pattern.length-1?0:b.int_pattern.join("").length-(wt.int+Z.num.length);ne.push(A.substring(A.length-ke,A.length-Wt)),et++,wt.int+=Z.num.length}else if(Z.type==="frac"){const ke=wt.frac;for(let Wt=0;Wt<Ln;Wt++)ne.push(U[Wt+ke]||E[Z.num[Wt]]);wt.frac+=Ln}else if(Z.type in Ne)b[Z.type+"_pattern"].length===1?(Z.type==="int"&&ne.push(A),Z.type==="frac"&&ne.push(U),Z.type==="man"&&ne.push(F),Z.type==="num"&&ne.push(Y),Z.type==="den"&&ne.push(B)):(ne.push(Ne[Z.type].slice(wt[Z.type],wt[Z.type]+Ln)),wt[Z.type]+=Ln);else if(Z.type==="year")se<0&&ne.push(ve.negative),ne.push(String(Math.abs(se)).padStart(4,"0"));else if(Z.type==="year-short"){const ke=se%100;ne.push(ke<10?"0":"",ke)}else if(Z.type==="month")ne.push(Z.pad&&ue<10?"0":"",ue);else if(Z.type==="monthname-single")b.date_system===6?ne.push(ve.mmmm6[ue-1].charAt(0)):ne.push(ve.mmmm[ue-1].charAt(0));else if(Z.type==="monthname-short")b.date_system===6?ne.push(ve.mmm6[ue-1]):ne.push(ve.mmm[ue-1]);else if(Z.type==="monthname")b.date_system===6?ne.push(ve.mmmm6[ue-1]):ne.push(ve.mmmm[ue-1]);else if(Z.type==="weekday-short")ne.push(ve.ddd[$]);else if(Z.type==="weekday")ne.push(ve.dddd[$]);else if(Z.type==="day")ne.push(Z.pad&&le<10?"0":"",le);else if(Z.type==="hour"){const ke=ie%b.clock||(b.clock<24?b.clock:0);ne.push(Z.pad&&ke<10?"0":"",ke)}else if(Z.type==="min")ne.push(Z.pad&&ce<10?"0":"",ce);else if(Z.type==="sec")ne.push(Z.pad&&_e<10?"0":"",_e);else if(Z.type==="subsec"){ne.push(ve.decimal);const ke=Ce.toFixed(b.sec_decimals);ne.push(ke.slice(2,2+Z.decimals))}else if(Z.type==="am"){const ke=ie<12?0:1;Z.short&&!H?ne.push("AP"[ke]):ne.push(ve.ampm[ke])}else if(Z.type==="hour-elap"){M<0&&ne.push(ve.negative);const ke=24*oe+Math.floor(Math.abs(z)/3600);ne.push(String(Math.abs(ke)).padStart(Z.pad,"0"))}else if(Z.type==="min-elap"){M<0&&ne.push(ve.negative);const ke=1440*oe+Math.floor(Math.abs(z)/60);ne.push(String(Math.abs(ke)).padStart(Z.pad,"0"))}else if(Z.type==="sec-elap"){M<0&&ne.push(ve.negative);const ke=oe*Ue+Math.abs(z);ne.push(String(Math.abs(ke)).padStart(Z.pad,"0"))}else if(Z.type==="b-year")ne.push(se+543);else if(Z.type==="b-year-short"){const ke=(se+543)%100;ne.push(ke<10?"0":"",ke)}}return T.nbsp?ne.join(""):ne.join("").replace(/\u00a0/g," ")}function pt(M,b){for(let T=0;T<3;T++){const H=b[T];if(H){let F;if(H.condition){const Y=H.condition[0],B=H.condition[1];Y==="="?F=M===B:Y===">"?F=M>B:Y==="<"?F=M<B:Y===">="?F=M>=B:Y==="<="?F=M<=B:Y==="<>"&&(F=M!==B)}else F=!0;if(F)return H}}}const ft=ee("@"),$e="black",Ve={};function He(M,b){if(M){const T=M[0];b[T]=b[T]||{},He(M.slice(1),b[T])}else b.$=!0}["d-F-y","d-F-Y","d-M-y","d-M-Y","F-d-y","F-d-Y","F-j-y","F-j-Y","j-F-y","j-F-Y","j-M-y","j-M-Y","M-d-y","M-d-Y","M-j-y","M-j-Y","m-d-y","m-d-Y","m-j-y","m-j-Y","n-d-y","n-d-Y","n-j-y","n-j-Y","y-F-d","y-F-j","y-M-d","y-M-j","Y-F-d","Y-F-j","Y-M-d","Y-m-d","Y-M-j","Y-m-j","Y-n-d","Y-n-j","j-F","j-M","d-F","d-M","n-d","n-j","n-Y","m-d","m-j","m-Y","M-Y","M-y","F-y","F-Y","Y-M","Y-n","Y-m","Y-F","Y-M"].forEach(M=>{He(M,Ve),He(M+" x",Ve),He(M+" l",Ve),He(M+" l x",Ve),He("l "+M,Ve),He("l "+M+" x",Ve),He(M+" D",Ve),He(M+" D x",Ve),He("D "+M,Ve),He("D "+M+" x",Ve)});const Qe={jan:1,feb:2,mar:3,apr:4,may:5,jun:6,jul:7,aug:8,sep:9,oct:10,nov:11,dec:12},dn={january:1,february:2,march:3,april:4,june:6,july:7,august:8,september:9,october:10,november:11,december:12},un={sunday:"l",monday:"l",tuesday:"l",wednesday:"l",thursday:"l",friday:"l",saturday:"l",sun:"D",mon:"D",tue:"D",wed:"D",thu:"D",fri:"D",sat:"D"},Rs=new Date().getUTCFullYear();function br(M){const b=new RegExp("^([\\s+%"+N.join("")+"(-]*)(((?:(?:\\d[\\d,]*)(?:\\.\\d*)?|(?:\\.\\d+)))([eE][+-]?\\d+)?)([\\s%"+N.join("")+")]*)$").exec(M);if(b){const[,T,H,F,Y,B]=b;let U=1,A="",K=!1,oe=!1,z=!1,se=!1,ue=!1,le=null,$=!1,ie=parseFloat(H.replace(/,/g,""));if(!isFinite(ie))return null;for(let _e=0;_e<T.length;_e++){const Ce=T[_e];if(Ce==="-"){if(K||oe)return null;K=!0,U=-1}else if(D.test(Ce)){if(ue)return null;ue=!0,le=Ce}else if(Ce==="("){if(oe||K)return null;oe=!0,U=-1}else if(Ce==="%"){if(se)return null;se=!0}}for(let _e=0;_e<B.length;_e++){const Ce=B[_e];if(D.test(Ce)){if(ue)return null;ue=!0,le=Ce,$=!0}else if(Ce===")"){if(z||!oe)return null;z=!0}else if(Ce==="%"){if(se)return null;se=!0}}if(Y){if(se||ue)return null;A="0.00E+00"}else if(se){if(ue)return null;A=F.includes(".")?"0.00%":"0%",ie*=.01}else if(ue){const _e=F.includes(".")?"#,##0.00":"#,##0";A=$?_e+le:le+_e}else F.includes(",")&&(A=F.includes(".")?"#,##0.00":"#,##0");const ce={v:ie*U};return A&&(ce.z=A),ce}}const lt=(M,b,T)=>{const H=T.path||"",F=Object.keys(b);for(let Y=0;Y<F.length;Y++){let B;const U=F[Y];if(b[U]){if(U==="$"||U==="€")M||(B=T);else if(U==="-"){const A=/^(\s*([./-]|,\s)\s*|\s+)/.exec(M);if(A){const K=A[1]==="-"||A[1]==="/"||A[1]==="."?A[1]:" ";if(!T.sep||T.sep===K){const oe=A[0].replace(/\s+/g," ");B=lt(M.slice(A[0].length),b[U],{...T,sep:K,path:H+oe})}}}else if(U===" "){const A=/^[,.]?\s+/.exec(M);if(A){const K=A[0].replace(/\s+/g," ");B=lt(M.slice(A[0].length),b[U],{...T,path:H+K})}}else if(U==="j"||U==="d"){const A=/^(0?[1-9]|1\d|2\d|3[01])\b/.exec(M);A&&(B=lt(M.slice(A[0].length),b[U],{...T,day:A[0],path:H+U}))}else if(U==="n"||U==="m"){const A=/^(0?[1-9]|1[012])\b/.exec(M);A&&(B=lt(M.slice(A[0].length),b[U],{...T,month:+A[0],_mon:A[0],path:H+U}))}else if(U==="F"||U==="M"){const A=/^([a-z]{3,9})\b/i.exec(M),K=A&&(U==="F"?dn:Qe)[A[0].toLowerCase()];K&&(B=lt(M.slice(A[0].length),b[U],{...T,month:K,_mon:A[0],path:H+U}))}else if(U==="l"||U==="D"){const A=/^([a-z]{3,9})\b/i.exec(M);(A&&un[A[0].toLowerCase()])===U&&(B=lt(M.slice(A[0].length),b[U],{...T,path:H+U}))}else if(U==="y"){const A=/^\d\d\b/.exec(M);if(A){const K=+A[0]>=30?+A[0]+1900:+A[0]+2e3;B=lt(M.slice(A[0].length),b[U],{...T,year:K,path:H+U})}}else if(U==="Y"){const A=/^\d\d\d\d\b/.exec(M);A&&(B=lt(M.slice(A[0].length),b[U],{...T,year:+A[0],path:H+U}))}else{if(U!=="x")throw new Error('Unknown date token "'.concat(U,'"'));{const A=Di(M);A&&(B=lt("",b[U],{...T,time:A.v,tf:A.z,path:H+U}))}}if(B)return B}}};function Mr(M,b){const T=lt(M.trim(),Ve,{path:""});if(T){var H;if(T.sep==="."&&T.path.length===3)return null;const F=+((H=T.year)!==null&&H!==void 0?H:Rs);if(T.day||(T.day=1),!function(U,A,K){if(K<1||A<1||A>12)return!1;if(A===2){if(K>(U%4==0&&U%100!=0||U%400==0||U===1900?29:28))return!1}else if((A===4||A===6||A===9||A===11)&&K>30||(A===1||A===3||A===5||A===7||A===8||A===10||A===12)&&K>31)return!1;return!0}(F,T.month,T.day))return null;let Y=-1/0;if(F<1900)return null;F<=1900&&T.month<=2?Y=25568:F<1e4&&(Y=25569);const B=Date.UTC(F,T.month-1,T.day)/864e5+Y+(T.time||0);if(B>=0&&B<=2958465){const U=T._mon[0]==="0"||T.day[0]==="0"||T._mon.length===2&&T.day.length===2,A=T.path.replace(/[jdlDnmMFyYx-]/g,K=>K==="j"||K==="d"?U?"dd":"d":K==="D"?"ddd":K==="l"?"dddd":K==="n"||K==="m"?U?"mm":"m":K==="M"?"mmm":K==="F"?"mmmm":K==="y"?"yy":K==="x"?T.tf||"":K==="Y"?"yyyy":K);return b&&b.nativeDate?{v:De(B,b),z:A}:{v:B,z:A}}}return null}function Di(M){const b=/^\s*([10]?\d|2[0-4])(?::([0-5]\d|\d))?(?::([0-5]\d|\d))?(\.\d{1,10})?(?:\s*([AP])M?)?\s*$/i.exec(M);if(b){const[,T,H,F,Y,B]=b;if(Y&&!F||!B&&!H&&!F)return null;let U=1*(T||0);if(B){if(U>=13)return null;B[0]!=="p"&&B[0]!=="P"||(U+=12)}return{v:(60*U*60+60*(1*(H||0))+1*(F||0)+1*(Y||0))/86400,z:(T.length===2?"hh":"h")+":mm"+(F?":ss":"")+(B?" AM/PM":"")}}return null}function wr(M){return/^\s*true\s*$/i.test(M)?{v:!0}:/^\s*false\s*$/i.test(M)?{v:!1}:null}const hn={};function Is(M,b){const{pattern:T,partitions:H,locale:F}=M,Y=A=>{const K=Object.assign({},w(),b,A);return F&&(K.locale=F),K},B=(A,K)=>{const oe=Y(K);return function(z,se,ue){const le=u(ue.locale),$=se[3]?se[3]:ft;if(typeof z=="boolean"&&(z=z?"TRUE":"FALSE"),z==null)return"";if(typeof z!="number")return Fe(z,$,ue,le);if(!isFinite(z)){const ce=le||g;return isNaN(z)?ce.nan:(z<0?ce.negative:"")+ce.infinity}const ie=pt(z,se);return ie?Fe(z,ie,ue,le):ue.overflow}(be(A,oe),H,oe)};B.color=(A,K)=>function(oe,z){if(typeof oe!="number"||!isFinite(oe))return(z[3]?z[3].color:ft.color)||$e;const se=pt(oe,z);return se&&se.color||$e}(be(A,Y(K)),H);const U=function(A){var K;let oe=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null;const[z,se]=A,ue=z.frac_max,le={type:"general",isDate:Le(A),isText:Se(A),isPercent:Oe(A),maxDecimals:z.general?9:ue,scale:(K=z.scale)!==null&&K!==void 0?K:1,color:0,parentheses:0,grouped:z.grouping?1:0,_partitions:A},$=!le.isDate&&!le.isText&&!z.error&&z.tokens.some(ve=>ve.type==="string"&&(oe?ve.value===oe:D.test(ve.value)));let ie="G",ce=ue>=0?Math.min(15,ue):"",_e="",Ce="";if(se&&se.color&&(Ce="-",le.color=1),z.parens&&(_e="()",le.parentheses=1),$)ie="C",le.type="currency";else if(z.error)le.type="error",le.maxDecimals=0;else if(le.isDate){let ve=0,je=0,St="";z.tokens.forEach(ne=>{const et=ne.type;/^(b-)?year/.test(et)?(St+="Y",je++):et.startsWith("month")?(St+="M",je++):/^(week)?day/.test(et)?(St+="D",je++):et!=="hour"&&et!=="min"&&et!=="sec"&&et!=="am"||(St+=et[0],ve++)}),le.type="date",je&&ve?le.type="datetime":!je&&ve&&(le.type="time");const Dt=ge.find(ne=>St.startsWith(ne[0]));ie=Dt?"D":"G",ce=Dt?Dt[1]:""}else le.isText?(ie="G",le.type="text",ce="",le.maxDecimals=0):z.general?(ie="G",le.type="general",ce=""):z.fractions?(ie="G",le.type="fraction",ce=""):z.exponential?(ie="S",le.type="scientific"):le.isPercent?(ie="P",le.type="percent"):z.grouping?(ie=",",le.type="grouped"):(z.int_max||ue)&&(ie="F",le.type="number");return le.code=ie+ce+Ce+_e,le.level=he[le.type],Object.freeze(le)}(H,(b||{}).currency)||new SyntaxError;return B.info=U,B.dateInfo=function(A){const[K]=A;return{year:!!(2&K.date),month:!!(4&K.date),day:!!(8&K.date),hours:!!(16&K.date),minutes:!!(32&K.date),seconds:!!(64&K.date),clockType:K.clock===12?12:24}}(H),B.isPercent=()=>!!U.isPercent,B.isDate=()=>!!U.isDate,B.isText=()=>!!U.isText,B.pattern=T,M.error&&(B.error=M.error),B.options=Y,B.locale=F||b&&b.locale||"",Object.freeze(B)}function xe(M,b){M||(M="General");let T=null;return hn[M]?T=hn[M]:(T=Object.assign({},w(),b).throws?W(M):function(H){try{return W(H)}catch(F){const Y={tokens:[{type:"error"}],error:F.message};return{pattern:H,partitions:[Y,Y,Y,Y],error:F.message,locale:null}}}(M),T.error||(hn[M]=T)),Is(T,b)}xe.isDate=M=>xe(M,{throws:!1}).isDate(),xe.isPercent=M=>xe(M,{throws:!1}).isPercent(),xe.isText=M=>xe(M,{throws:!1}).isText(),xe.getInfo=(M,b)=>xe(M,{...b,throws:!1}).info,xe.getDateInfo=(M,b)=>xe(M,{...b,throws:!1}).dateInfo,xe.dateToSerial=be,xe.dateFromSerial=De,xe.options=w,xe.dec2frac=f,xe.round=_,xe.codeToLocale=r,xe.parseLocale=c,xe.getLocale=u,xe.addLocale=(M,b)=>{const T=c(b);return delete hn[T.lang],delete hn[T.language],m(M,T)},xe.format=function(M,b,T){let H=arguments.length>3&&arguments[3]!==void 0&&arguments[3];const F=T&&typeof T=="object"?T:{locale:T,throws:!H};return xe(M,F)(be(b,F),F)},xe.is_date=xe.isDate,xe.parseNumber=br,xe.parseDate=Mr,xe.parseTime=Di,xe.parseBool=wr,xe.parseValue=function(M,b){var T,H,F;return(T=(H=(F=br(M))!==null&&F!==void 0?F:Mr(M,b))!==null&&H!==void 0?H:Di(M))!==null&&T!==void 0?T:wr(M)};var bs=xe;return n=n.default}()})})(Cs);var cm=Cs.exports,dm=cm;const um=Xa(dm),hm="univer-status-bar",mm="univer-single-mode",gm="univer-status-bar-div",_m="univer-statistic-list",pm="univer-statistic-list-column",fm="univer-statistic-item",Sm="univer-statistic-picker",vm="univer-statistic-picker-item",Cm="univer-statistic-more",Gt={statusBar:hm,singleMode:mm,statusBarDiv:gm,statisticList:_m,statisticListColumn:pm,statisticItem:fm,statisticPicker:Sm,statisticPickerItem:vm,statisticMore:Cm},Rm=[Re.FUNCTION_NAMES_MATH.SUM,Re.FUNCTION_NAMES_STATISTICAL.AVERAGE,Re.FUNCTION_NAMES_STATISTICAL.MIN,Re.FUNCTION_NAMES_STATISTICAL.MAX],zi={[Re.FUNCTION_NAMES_MATH.SUM]:"statusbar.sum",[Re.FUNCTION_NAMES_STATISTICAL.AVERAGE]:"statusbar.average",[Re.FUNCTION_NAMES_STATISTICAL.MIN]:"statusbar.min",[Re.FUNCTION_NAMES_STATISTICAL.MAX]:"statusbar.max",[Re.FUNCTION_NAMES_STATISTICAL.COUNT]:"statusbar.count",[Re.FUNCTION_NAMES_STATISTICAL.COUNTA]:"statusbar.countA",[Re.FUNCTION_NAMES_TEXT.CONCATENATE]:"concatenate"},$i=i=>{const e=me.useDependency(l.LocaleService),t=me.useDependency(R.IMessageService),n=me.useDependency(R.IClipboardInterfaceService),r=Im(i),o=async()=>{await n.writeText(i.value.toString()),t.show({type:Ye.MessageType.Success,content:e.t("statusbar.copied")})};return S.jsx(Ye.Tooltip,{title:e.t("statusbar.clickToCopy"),placement:"top",children:S.jsx("div",{className:Gt.statisticItem,onClick:o,children:S.jsx("span",{children:`${e.t((zi==null?void 0:zi[i.name])||i.name)}: ${r}`})},i.name)})};function Im(i){const{pattern:e,value:t}=i;return typeof t!="number"?"Invalid input":t>=1e8?t.toExponential(2):e&&Rm.includes(i.name)?um.format(e,t):t.toLocaleString()}const co=800,bm=3,Mm=()=>{const[i,e]=X.useState(window.innerWidth<co),[t,n]=X.useState(!0),r=me.useDependency(Cr),o=r.getFunctions().map((m,g)=>({name:m.func,value:0,show:!0,disable:!1,pattern:null})),[s,a]=X.useState(o),c=s.find(m=>m.show&&!m.disable),d=i&&c?[c]:s.filter(m=>m.show&&!m.disable);X.useEffect(()=>{const m=r.state$.subscribe(g=>{const _=g==null?void 0:g.values;if(!_||_.length===0)n(!1);else{n(!0);const f=s.map(C=>{const I=_.find(w=>w.func===C.name);return I?(C.value=I.value,C.disable=!1):C.disable=!0,C.pattern=(g==null?void 0:g.pattern)??null,C});a(f)}});return()=>{m.unsubscribe()}},[r]);const u=wm(()=>{const m=window.innerWidth<co;i!==m&&e(m)},100);X.useEffect(()=>(window.addEventListener("resize",u),()=>{window.removeEventListener("resize",u)}),[i]);let h=null;if(d.length>bm){const m=[];d.forEach((g,_)=>{_%2===0&&m.push(d.slice(_,_+2))}),h=S.jsxs(S.Fragment,{children:[" ",m.map((g,_)=>S.jsxs("div",{className:Gt.statisticListColumn,children:[(g==null?void 0:g[0])&&S.jsx($i,{...g==null?void 0:g[0]},g==null?void 0:g[0].name),(g==null?void 0:g[1])&&S.jsx($i,{...g==null?void 0:g[1]},g==null?void 0:g[1].name)]},`stat-col-${_}`))," "]})}else h=S.jsx(S.Fragment,{children:d.map(m=>S.jsx($i,{...m},m.name))});return t&&S.jsxs("div",{className:bn(Gt.statusBar,{[Gt.singleMode]:i}),children:[S.jsx("div",{className:bn(Gt.statisticList),children:h}),S.jsx("div",{className:Gt.statusBarDiv})]})};function wm(i,e){let t;return function(...n){const r=this,o=function(){t=null,i.apply(r,n)};clearTimeout(t),t=setTimeout(o,e)}}function Tm(){return S.jsxs("section",{className:cs.sheetContainer,"data-range-selector":!0,children:[S.jsx(am,{}),S.jsx(Mm,{}),S.jsx(lh,{})]})}function ym(){return S.jsx(S.Fragment,{children:S.jsx(wh,{})})}function Em(){return S.jsxs(S.Fragment,{children:[S.jsx(uh,{}),S.jsx(Lh,{})]})}function Om(i){const e=i.get(p.BorderStyleManagerService),t=p.getCurrentSheetDisabled$(i);return{id:p.SetBorderBasicCommand.id,icon:new J.Observable(n=>{const r="AllBorderSingle",o=i.get(p.BorderStyleManagerService),s=i.get(l.ICommandService).onCommandExecuted(a=>{if(a.id!==p.SetBorderBasicCommand.id)return;const{type:d}=o.getBorderInfo(),u=vs.find(m=>m.value===d),h=(u==null?void 0:u.icon)??r;n.next(h)});return n.next(r),s.dispose}),group:R.MenuGroup.TOOLBAR_FORMAT,tooltip:"toolbar.border.main",positions:[R.MenuPosition.TOOLBAR_START],type:R.MenuItemType.BUTTON_SELECTOR,selections:[{label:{name:Ss,hoverable:!1},value$:e.borderInfo$}],value$:e.borderInfo$,hidden$:R.getMenuHiddenObservable(i,l.UniverInstanceType.SHEET),disabled$:t}}const Ni="sheet.menu.clear-selection";function xm(){return{id:Ni,group:R.MenuGroup.CONTEXT_MENU_FORMAT,type:R.MenuItemType.SUBITEMS,icon:"ClearFormat",title:"rightClick.clearSelection",positions:[R.MenuPosition.CONTEXT_MENU,Be.COL_HEADER_CONTEXT_MENU,Be.ROW_HEADER_CONTEXT_MENU]}}function Am(){return{id:p.ClearSelectionContentCommand.id,type:R.MenuItemType.BUTTON,title:"rightClick.clearContent",positions:[Ni]}}function Nm(){return{id:p.ClearSelectionFormatCommand.id,type:R.MenuItemType.BUTTON,title:"rightClick.clearFormat",positions:[Ni]}}function Dm(){return{id:p.ClearSelectionAllCommand.id,type:R.MenuItemType.BUTTON,title:"rightClick.clearAll",positions:[Ni]}}const Pn="sheet.menu.delete";function Pm(){return{id:Pn,group:R.MenuGroup.CONTEXT_MENU_LAYOUT,type:R.MenuItemType.SUBITEMS,title:"rightClick.delete",icon:"Reduce",positions:[R.MenuPosition.CONTEXT_MENU]}}function Hm(){return{id:p.RemoveColCommand.id,group:R.MenuGroup.CONTEXT_MENU_LAYOUT,type:R.MenuItemType.BUTTON,icon:"DeleteColumn",positions:[Pn,Be.COL_HEADER_CONTEXT_MENU],title:"rightClick.deleteSelectedColumn"}}function Lm(){return{id:p.RemoveRowCommand.id,group:R.MenuGroup.CONTEXT_MENU_LAYOUT,type:R.MenuItemType.BUTTON,icon:"DeleteRow",positions:[Pn,Be.ROW_HEADER_CONTEXT_MENU],title:"rightClick.deleteSelectedRow"}}function Um(){return{id:p.DeleteRangeMoveLeftCommand.id,group:R.MenuGroup.CONTEXT_MENU_LAYOUT,type:R.MenuItemType.BUTTON,title:"rightClick.moveLeft",icon:"DeleteCellShiftLeft",positions:[Pn]}}function km(){return{id:p.DeleteRangeMoveUpCommand.id,group:R.MenuGroup.CONTEXT_MENU_LAYOUT,type:R.MenuItemType.BUTTON,title:"rightClick.moveUp",icon:"DeleteCellShiftUp",positions:[Pn]}}const Rr="sheet.menu.col-insert";function Vm(){return{id:Rr,group:R.MenuGroup.CONTEXT_MENU_LAYOUT,type:R.MenuItemType.SUBITEMS,title:"rightClick.insert",icon:"Insert",positions:[Be.COL_HEADER_CONTEXT_MENU]}}const Ir="sheet.menu.row-insert";function Fm(){return{id:Ir,group:R.MenuGroup.CONTEXT_MENU_LAYOUT,type:R.MenuItemType.SUBITEMS,title:"rightClick.insert",icon:"Insert",positions:[Be.ROW_HEADER_CONTEXT_MENU]}}const Hn="sheet.menu.cell-insert";function Bm(){return{id:Hn,group:R.MenuGroup.CONTEXT_MENU_LAYOUT,type:R.MenuItemType.SUBITEMS,title:"rightClick.insert",icon:"Insert",positions:[R.MenuPosition.CONTEXT_MENU]}}function jm(i){const e=i.get(p.SelectionManagerService);return{id:p.InsertRowBeforeCommand.id,type:R.MenuItemType.BUTTON,title:"rightClick.insertRowBefore",icon:"InsertRowAbove",positions:[Ir,Hn],hidden$:new J.Observable(t=>{const n=e.getSelections();t.next((n==null?void 0:n.length)!==1)})}}function Wm(i){const e=i.get(p.SelectionManagerService);return{id:p.InsertRowAfterCommand.id,type:R.MenuItemType.BUTTON,positions:[Ir],title:"rightClick.insertRow",icon:"InsertRowBelow",hidden$:new J.Observable(t=>{const n=e.getSelections();t.next((n==null?void 0:n.length)!==1)})}}function zm(i){const e=i.get(p.SelectionManagerService);return{id:p.InsertColBeforeCommand.id,type:R.MenuItemType.BUTTON,positions:[Rr,Hn],title:"rightClick.insertColumnBefore",icon:"LeftInsertColumn",hidden$:new J.Observable(t=>{const n=e.getSelections();t.next((n==null?void 0:n.length)!==1)})}}function $m(i){const e=i.get(p.SelectionManagerService);return{id:p.InsertColAfterCommand.id,type:R.MenuItemType.BUTTON,positions:[Rr],title:"rightClick.insertColumn",icon:"RightInsertColumn",hidden$:new J.Observable(t=>{const n=e.getSelections();t.next((n==null?void 0:n.length)!==1)})}}function Ym(){return{id:p.InsertRangeMoveRightCommand.id,type:R.MenuItemType.BUTTON,title:"rightClick.moveRight",icon:"InsertCellShiftRight",positions:[Hn]}}function Xm(){return{id:p.InsertRangeMoveDownCommand.id,type:R.MenuItemType.BUTTON,title:"rightClick.moveDown",icon:"InsertCellDown",positions:[Hn]}}function Zm(i){const e=p.getCurrentSheetDisabled$(i);return{id:Mt.id,icon:"MergeAllSingle",tooltip:"toolbar.mergeCell.main",positions:[R.MenuPosition.TOOLBAR_START],group:R.MenuGroup.TOOLBAR_LAYOUT,type:R.MenuItemType.SUBITEMS,hidden$:R.getMenuHiddenObservable(i,l.UniverInstanceType.SHEET),disabled$:e}}function Gm(i){return{id:us.id,type:R.MenuItemType.BUTTON,title:"merge.all",icon:"MergeAllSingle",positions:[Mt.id]}}function Km(i){return{id:hs.id,type:R.MenuItemType.BUTTON,title:"merge.vertical",icon:"VerticalIntegrationSingle",positions:[Mt.id]}}function qm(i){return{id:ms.id,type:R.MenuItemType.BUTTON,title:"merge.horizontal",icon:"HorizontalMergeSingle",positions:[Mt.id]}}function Jm(i){return{id:p.RemoveWorksheetMergeCommand.id,type:R.MenuItemType.BUTTON,title:"merge.cancel",icon:"CancelMergeSingle",positions:[Mt.id]}}function Qm(){return{id:_s.id,type:R.MenuItemType.BUTTON,positions:[Be.SHEET_BAR],title:"sheetConfig.delete"}}function eg(){return{id:p.CopySheetCommand.id,type:R.MenuItemType.BUTTON,positions:[Be.SHEET_BAR],title:"sheetConfig.copy"}}function tg(){return{id:fs.id,type:R.MenuItemType.BUTTON,positions:[Be.SHEET_BAR],title:"sheetConfig.rename"}}function ng(){return{id:p.SetTabColorCommand.id,title:"sheetConfig.changeColor",positions:[Be.SHEET_BAR],type:R.MenuItemType.SELECTOR,selections:[{label:{name:Oi,hoverable:!1}}]}}function ig(){return{id:p.SetWorksheetHideCommand.id,type:R.MenuItemType.BUTTON,positions:[Be.SHEET_BAR],title:"sheetConfig.hide"}}function rg(){return{id:ps.id,type:R.MenuItemType.BUTTON,positions:[Be.SHEET_BAR],title:"sheetConfig.unhide"}}const og={id:p.SetRowHiddenCommand.id,preconditions:i=>ye(i),binding:R.KeyCode.Digit9|R.MetaKeys.CTRL_COMMAND},sg={id:p.SetColHiddenCommand.id,preconditions:i=>ye(i),binding:R.KeyCode.Digit0|R.MetaKeys.CTRL_COMMAND|R.MetaKeys.SHIFT},ag={id:nt.id,description:"shortcut.sheet.select-below-cell",group:"3_sheet-view",binding:R.KeyCode.ARROW_DOWN,priority:100,preconditions:ye,staticParameters:{direction:l.Direction.DOWN}},lg={id:nt.id,description:"shortcut.sheet.select-up-cell",group:"3_sheet-view",binding:R.KeyCode.ARROW_UP,priority:100,preconditions:ye,staticParameters:{direction:l.Direction.UP}},cg={id:nt.id,description:"shortcut.sheet.select-left-cell",group:"3_sheet-view",binding:R.KeyCode.ARROW_LEFT,priority:100,preconditions:ye,staticParameters:{direction:l.Direction.LEFT}},dg={id:nt.id,description:"shortcut.sheet.select-right-cell",group:"3_sheet-view",binding:R.KeyCode.ARROW_RIGHT,priority:100,preconditions:ye,staticParameters:{direction:l.Direction.RIGHT}},ug={id:jt.id,description:"shortcut.sheet.select-next-cell",group:"3_sheet-view",binding:R.KeyCode.TAB,priority:100,preconditions:ye,staticParameters:{direction:l.Direction.RIGHT,keycode:R.KeyCode.TAB}},hg={id:jt.id,description:"shortcut.sheet.select-previous-cell",group:"3_sheet-view",binding:R.KeyCode.TAB|R.MetaKeys.SHIFT,priority:100,preconditions:ye,staticParameters:{direction:l.Direction.LEFT,keycode:R.KeyCode.TAB}},mg={id:jt.id,description:"shortcut.sheet.select-below-cell",group:"3_sheet-view",binding:R.KeyCode.ENTER,priority:100,preconditions:ye,staticParameters:{direction:l.Direction.DOWN,keycode:R.KeyCode.ENTER}},gg={id:jt.id,description:"shortcut.sheet.select-up-cell",group:"3_sheet-view",binding:R.KeyCode.ENTER|R.MetaKeys.SHIFT,priority:100,preconditions:ye,staticParameters:{direction:l.Direction.UP,keycode:R.KeyCode.ENTER}},_g={id:nt.id,description:"shortcut.sheet.select-below-value-cell",group:"3_sheet-view",binding:R.KeyCode.ARROW_DOWN|R.MetaKeys.CTRL_COMMAND,preconditions:ye,staticParameters:{direction:l.Direction.DOWN,jumpOver:gt.moveGap}},pg={id:nt.id,description:"shortcut.sheet.select-up-value-cell",group:"3_sheet-view",binding:R.KeyCode.ARROW_UP|R.MetaKeys.CTRL_COMMAND,preconditions:ye,staticParameters:{direction:l.Direction.UP,jumpOver:gt.moveGap}},fg={id:nt.id,description:"shortcut.sheet.select-left-value-cell",group:"3_sheet-view",binding:R.KeyCode.ARROW_LEFT|R.MetaKeys.CTRL_COMMAND,preconditions:ye,staticParameters:{direction:l.Direction.LEFT,jumpOver:gt.moveGap}},Sg={id:nt.id,description:"shortcut.sheet.select-right-value-cell",group:"3_sheet-view",binding:R.KeyCode.ARROW_RIGHT|R.MetaKeys.CTRL_COMMAND,preconditions:ye,staticParameters:{direction:l.Direction.RIGHT,jumpOver:gt.moveGap}},vg={id:_t.id,description:"shortcut.sheet.expand-selection-down",group:"3_sheet-view",binding:R.KeyCode.ARROW_DOWN|R.MetaKeys.SHIFT,preconditions:ye,staticParameters:{direction:l.Direction.DOWN}},Cg={id:_t.id,description:"shortcut.sheet.expand-selection-up",group:"3_sheet-view",binding:R.KeyCode.ARROW_UP|R.MetaKeys.SHIFT,preconditions:ye,staticParameters:{direction:l.Direction.UP}},Rg={id:_t.id,description:"shortcut.sheet.expand-selection-left",group:"3_sheet-view",binding:R.KeyCode.ARROW_LEFT|R.MetaKeys.SHIFT,preconditions:ye,staticParameters:{direction:l.Direction.LEFT}},Ig={id:_t.id,description:"shortcut.sheet.expand-selection-right",group:"3_sheet-view",binding:R.KeyCode.ARROW_RIGHT|R.MetaKeys.SHIFT,preconditions:ye,staticParameters:{direction:l.Direction.RIGHT}},bg={id:_t.id,description:"shortcut.sheet.expand-selection-to-below-gap",group:"3_sheet-view",binding:R.KeyCode.ARROW_DOWN|R.MetaKeys.SHIFT|R.MetaKeys.CTRL_COMMAND,preconditions:ye,staticParameters:{direction:l.Direction.DOWN,jumpOver:gt.moveGap}},Mg={id:_t.id,description:"shortcut.sheet.expand-selection-to-up-gap",group:"3_sheet-view",binding:R.KeyCode.ARROW_UP|R.MetaKeys.SHIFT|R.MetaKeys.CTRL_COMMAND,preconditions:ye,staticParameters:{direction:l.Direction.UP,jumpOver:gt.moveGap}},wg={id:_t.id,description:"shortcut.sheet.expand-selection-to-left-gap",group:"3_sheet-view",binding:R.KeyCode.ARROW_LEFT|R.MetaKeys.SHIFT|R.MetaKeys.CTRL_COMMAND,preconditions:ye,staticParameters:{direction:l.Direction.LEFT,jumpOver:gt.moveGap}},Tg={id:_t.id,description:"shortcut.sheet.expand-selection-to-right-gap",group:"3_sheet-view",binding:R.KeyCode.ARROW_RIGHT|R.MetaKeys.SHIFT|R.MetaKeys.CTRL_COMMAND,preconditions:ye,staticParameters:{direction:l.Direction.RIGHT,jumpOver:gt.moveGap}},yg={id:Ao.id,description:"shortcut.sheet.select-all",group:"3_sheet-view",binding:R.KeyCode.A|R.MetaKeys.CTRL_COMMAND,preconditions:ye,staticParameters:{expandToGapFirst:!0,loop:!0}},Eg={id:ur.id,description:"shortcut.sheet.set-bold",group:"4_sheet-edit",preconditions:i=>ye(i),binding:R.KeyCode.B|R.MetaKeys.CTRL_COMMAND},Og={id:hr.id,description:"shortcut.sheet.set-italic",group:"4_sheet-edit",preconditions:i=>ye(i),binding:R.KeyCode.I|R.MetaKeys.CTRL_COMMAND},xg={id:mr.id,description:"shortcut.sheet.set-underline",group:"4_sheet-edit",preconditions:i=>ye(i),binding:R.KeyCode.U|R.MetaKeys.CTRL_COMMAND},Ag={id:gr.id,description:"shortcut.sheet.set-strike-through",group:"4_sheet-edit",preconditions:i=>ye(i),binding:R.KeyCode.X|R.MetaKeys.SHIFT|R.MetaKeys.CTRL_COMMAND},Ng={id:p.ClearSelectionContentCommand.id,preconditions:i=>ye(i),binding:R.KeyCode.DELETE,mac:R.KeyCode.BACKSPACE},Dg={id:Ai.id,description:"shortcut.sheet.zoom-in",binding:R.KeyCode.EQUAL|R.MetaKeys.CTRL_COMMAND,group:"3_sheet-view",staticParameters:{delta:.2}},Pg={id:Ai.id,description:"shortcut.sheet.zoom-out",binding:R.KeyCode.MINUS|R.MetaKeys.CTRL_COMMAND,group:"3_sheet-view",staticParameters:{delta:-.2}},Hg={id:Ai.id,description:"shortcut.sheet.reset-zoom",binding:R.KeyCode.Digit0|R.MetaKeys.CTRL_COMMAND,group:"3_sheet-view",staticParameters:{reset:!0}};var Lg=Object.defineProperty,Ug=Object.getOwnPropertyDescriptor,kg=(i,e,t,n)=>{for(var r=n>1?void 0:n?Ug(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&Lg(e,t,r),r},Zt=(i,e)=>(t,n)=>e(t,n,i);let _i=class extends l.Disposable{constructor(i,e,t,n,r,o){super(),this._injector=i,this._componentManager=e,this._commandService=t,this._shortcutService=n,this._menuService=r,this._uiController=o,this._init()}_initCustomComponents(){const i=this._componentManager;this.disposeWithMe(i.register(fr,rc)),this.disposeWithMe(i.register(Ss,ih)),this.disposeWithMe(i.register(Oi,Ye.ColorPicker)),this.disposeWithMe(i.register(rs,Kl)),this.disposeWithMe(i.register(Ge,ql)),this.disposeWithMe(i.register(os,ec))}_initCommands(){[us,Mt,ms,hs,Ai,_t,nt,jt,fs,_s,Jt,Ao,ds,Ti,p.SetBoldCommand,Tn,mt,ur,hr,mr,gr,Bl,jl,Zo,Go,Ii,p.SetItalicCommand,p.SetStrikeThroughCommand,p.SetFontFamilyCommand,p.SetFontSizeCommand,_r,Jo,pr,Qo,on,ii,Ei,es,ts,ns,p.SetUnderlineCommand,vr,bt,ps,gs].forEach(i=>{this.disposeWithMe(this._commandService.registerCommand(i))})}_initMenus(){[Rc,Ic,bc,Mc,wc,Tc,yc,Am,Nm,Dm,xm,Vm,Fm,Bm,jm,Wm,zm,$m,Lm,Hc,Uc,Lc,kc,Hm,Vc,Ec,Fc,Pm,Um,km,Ym,Xm,Ac,Nc,Dc,Pc,Oc,xc,oc,sc,ac,lc,cc,uc,hc,mc,gc,_c,pc,Om,Zm,Gm,Km,qm,Jm,fc,Sc,vc,Cc,Qm,eg,tg,ng,ig,rg].forEach(i=>{this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(i)))})}_initShortcuts(){[ag,lg,cg,dg,ug,hg,mg,gg,_g,pg,fg,Sg,vg,Cg,Rg,Ig,bg,Mg,wg,Tg,yg,Dg,Pg,Hg,Eg,Og,xg,Ag,Ng,...ad(),ld,cd,ud,hd,md,dd,og,sg].forEach(i=>{this.disposeWithMe(this._shortcutService.registerShortcut(i))})}_initWorkbenchParts(){this.disposeWithMe(this._uiController.registerHeaderComponent(()=>me.connectInjector(ym,this._injector))),this.disposeWithMe(this._uiController.registerFooterComponent(()=>me.connectInjector(Tm,this._injector))),this.disposeWithMe(this._uiController.registerContentComponent(()=>me.connectInjector(Em,this._injector)))}_init(){this._initCustomComponents(),this._initCommands(),this._initMenus(),this._initShortcuts(),this._initWorkbenchParts()}};_i=kg([l.OnLifecycle(l.LifecycleStages.Ready,_i),Zt(0,j.Inject(j.Injector)),Zt(1,j.Inject(R.ComponentManager)),Zt(2,l.ICommandService),Zt(3,R.IShortcutService),Zt(4,R.IMenuService),Zt(5,R.IUIController)],_i);var Vg=Object.defineProperty,Fg=Object.getOwnPropertyDescriptor,Bg=(i,e,t,n)=>{for(var r=n>1?void 0:n?Fg(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&Vg(e,t,r),r},Lt=(i,e)=>(t,n)=>e(t,n,i);let pi=class extends l.Disposable{constructor(e,t,n,r,o,s,a){super();v(this,"_calculateTimeout",-1);this._univerInstanceService=e,this._selectionManagerService=t,this._functionService=n,this._statusBarService=r,this._commandService=o,this._formulaDataModel=s,this._numfmtService=a,this._init()}_init(){this._registerSelectionListener()}_registerSelectionListener(){this.disposeWithMe(l.toDisposable(this._selectionManagerService.selectionMoving$.subscribe(e=>{var t;((t=this._selectionManagerService.getCurrent())==null?void 0:t.pluginName)===p.NORMAL_SELECTION_PLUGIN_NAME&&e&&(clearTimeout(this._calculateTimeout),this._calculateTimeout=setTimeout(()=>{const n=e[e.length-1].primary;this._calculateSelection(e.map(r=>r.range),n)},100))}))),this.disposeWithMe(l.toDisposable(this._selectionManagerService.selectionMoveEnd$.subscribe(e=>{var t;if(((t=this._selectionManagerService.getCurrent())==null?void 0:t.pluginName)===p.NORMAL_SELECTION_PLUGIN_NAME&&e){const n=e[e.length-1].primary;this._calculateSelection(e.map(r=>r.range),n)}}))),this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(e.id===p.SetRangeValuesMutation.id){const t=this._selectionManagerService.getSelections();t&&(clearTimeout(this._calculateTimeout),this._calculateTimeout=setTimeout(()=>{this._calculateSelection(t.map(n=>n.range))},100))}}))}_calculateSelection(e,t){var c;const n=this._univerInstanceService.getCurrentUniverSheetInstance(),r=n.getUnitId(),o=n.getActiveSheet().getSheetId(),s={},a=this._formulaDataModel.getArrayFormulaCellData();if(this._univerInstanceService.getCurrentUniverSheetInstance().getSheets().forEach(d=>{const u=d.getConfig();s[d.getSheetId()]={cellData:new l.ObjectMatrix(u.cellData),rowCount:u.rowCount,columnCount:u.columnCount}}),e!=null&&e.length){const d=e.map(f=>new Re.RangeReferenceObject(f,o,r));d.forEach(f=>{f.setUnitData({[r]:s}),a&&f.setArrayFormulaCellData(Re.convertUnitDataToRuntime(a))});const h=this._statusBarService.getFunctions().map(f=>{const C=this._functionService.getExecutor(f.func);if(!C)return;const I=d.map(E=>E.toArrayValueObject(!1));if((C==null?void 0:C.calculate(...I)).getValue)return{func:f.func,value:(C==null?void 0:C.calculate(...I)).getValue()}});if(h.every(f=>f===void 0))return;let m=null;if(t){const{actualRow:f,actualColumn:C}=t;m=(c=this._numfmtService.getValue(r,o,f,C))==null?void 0:c.pattern}const _={values:h.filter(f=>f!==void 0),pattern:m};this._statusBarService.setState(_)}else this._statusBarService.setState(null)}_isSingleCell(e){return e.startRow===e.endRow&&e.startColumn===e.endColumn}};pi=Bg([l.OnLifecycle(l.LifecycleStages.Ready,pi),Lt(0,l.IUniverInstanceService),Lt(1,j.Inject(p.SelectionManagerService)),Lt(2,Re.IFunctionService),Lt(3,Cr),Lt(4,l.ICommandService),Lt(5,j.Inject(Re.FormulaDataModel)),Lt(6,j.Inject(p.INumfmtService))],pi);var jg=Object.defineProperty,Wg=Object.getOwnPropertyDescriptor,zg=(i,e,t,n)=>{for(var r=n>1?void 0:n?Wg(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&jg(e,t,r),r},Ut=(i,e)=>(t,n)=>e(t,n,i);let fi=class extends l.Disposable{constructor(i,e,t,n,r,o,s){super(),this._sheetSkeletonManagerService=i,this._currentUniverService=e,this._commandService=t,this._renderManagerService=n,this._selectionRenderService=r,this._selectionManagerService=o,this._scrollManagerService=s,this._initialize()}dispose(){super.dispose()}_initialize(){this._skeletonListener(),this._commandExecutedListener(),this._zoomEventBinding()}_zoomEventBinding(){var e;const i=(e=this._getSheetObject())==null?void 0:e.scene;i!=null&&(i.getViewport(Q.VIEW_MAIN),this.disposeWithMe(l.toDisposable(i.onMouseWheelObserver.add((t,n)=>{if(!t.ctrlKey)return;const r=Math.abs(t.deltaX);let o=r<40?.2:r<80?.4:.2;o*=t.deltaY>0?-1:1,i.scaleX<1&&(o/=2);const s=this._currentUniverService.getCurrentUniverSheetInstance(),a=s.getActiveSheet(),c=a.getZoomRatio();let d=+parseFloat(`${c+o}`).toFixed(1);d=d>=4?4:d<=.1?.1:d,this._commandService.executeCommand(vr.id,{zoomRatio:Math.round(d*10)/10,unitId:s.getUnitId(),subUnitId:a.getSheetId()}),t.preventDefault()}))))}_skeletonListener(){this.disposeWithMe(l.toDisposable(this._sheetSkeletonManagerService.currentSkeletonBefore$.subscribe(i=>{if(i==null)return;const n=this._currentUniverService.getCurrentUniverSheetInstance().getActiveSheet().getZoomRatio()||1;this._updateViewZoom(n)})))}_commandExecutedListener(){const i=[bt.id];this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(i.includes(e.id)){const t=this._currentUniverService.getCurrentUniverSheetInstance(),n=t.getActiveSheet(),r=e.params,{unitId:o,subUnitId:s}=r;if(!(o===t.getUnitId()&&s===n.getSheetId()))return;const a=n.getConfig().zoomRatio||1;this._updateViewZoom(a)}}))}_updateViewZoom(i){const e=this._getSheetObject();e==null||e.scene.scale(i,i),e==null||e.spreadsheet.makeForceDirty()}_getSheetObject(){return qe(this._currentUniverService,this._renderManagerService)}};fi=zg([l.OnLifecycle(l.LifecycleStages.Rendered,fi),Ut(0,j.Inject(exports.SheetSkeletonManagerService)),Ut(1,l.IUniverInstanceService),Ut(2,l.ICommandService),Ut(3,y.IRenderManagerService),Ut(4,Ze),Ut(5,j.Inject(p.SelectionManagerService)),Ut(6,j.Inject(Nt))],fi);var $g=Object.defineProperty,Yg=Object.getOwnPropertyDescriptor,Xg=(i,e,t,n)=>{for(var r=n>1?void 0:n?Yg(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&$g(e,t,r),r},vn=(i,e)=>(t,n)=>e(t,n,i);exports.SheetCanvasView=class extends l.RxDisposable{constructor(t,n,r,o,s){super();v(this,"_scene");v(this,"_currentWorkbook");v(this,"_loadedMap",new Set);v(this,"_isLoadedEditor",!1);v(this,"_fps$",new J.BehaviorSubject(""));v(this,"fps$",this._fps$.asObservable());this._currentUniverService=t,this._commandService=n,this._renderManagerService=r,this._selectionRenderService=o,this._sheetSkeletonManagerService=s,this._currentUniverService.currentSheet$.subscribe(a=>{if(a==null)return;const c=a.getUnitId();this._loadedMap.has(c)||(this._currentWorkbook=a,this._addNewRender(),this._loadedMap.add(c))})}dispose(){this._fps$.complete()}_addNewRender(){const t=this._currentWorkbook,n=t.getUnitId(),r=t.getContainer(),o=t.getParentRenderUnitId();if(r!=null&&o!=null)throw new Error("container or parentRenderUnitId can only exist one");const s=r==null&&o!=null;s?this._renderManagerService.createRenderWithParent(n,o):this._renderManagerService.createRender(n);const a=this._renderManagerService.getRenderById(n);if(a==null)return;const{scene:c,engine:d}=a;c.openTransformer(),this._scene=c,c.addLayer(new y.Layer(c,[],0),new y.Layer(c,[],2)),a!=null&&this._addComponent(a),t.getShouldRenderLoopImmediately()&&!s&&d.runRenderLoop(()=>{c.render(),this._fps$.next(Math.round(d.getFps()).toString())}),this._renderManagerService.setCurrent(n)}_addComponent(t){const n=this._scene,r=this._currentWorkbook,o=r.getActiveSheet(),s=r.getUnitId(),a=o.getSheetId();this._addViewport(o);const c=new y.Spreadsheet(Xe.MAIN),d=new y.SpreadsheetRowHeader(Xe.ROW),u=new y.SpreadsheetColumnHeader(Xe.COLUMN),h=new y.Rect(Xe.LEFT_TOP,{zIndex:2,left:-1,top:-1,fill:"rgb(248, 249, 250)",stroke:"rgb(217, 217, 217)",strokeWidth:1});t.mainComponent=c,t.components.set(Xe.MAIN,c),t.components.set(Xe.ROW,d),t.components.set(Xe.COLUMN,u),t.components.set(Xe.LEFT_TOP,h),n.addObjects([c],Ar),n.addObjects([d,u,h],At),n.enableLayerCache(Ar,At),this._sheetSkeletonManagerService.setCurrent({sheetId:a,unitId:s})}_addViewport(t){const n=this._scene;if(n==null)return;const{rowHeader:r,columnHeader:o}=t.getConfig(),s=new y.Viewport(Q.VIEW_MAIN,n,{left:r.width,top:o.height,bottom:0,right:0,isWheelPreventDefaultX:!0});return new y.Viewport(Q.VIEW_ROW_TOP,n,{active:!1,isWheelPreventDefaultX:!0}),new y.Viewport(Q.VIEW_ROW_BOTTOM,n,{left:0,top:o.height,bottom:0,width:r.width,isWheelPreventDefaultX:!0}),new y.Viewport(Q.VIEW_COLUMN_LEFT,n,{active:!1,isWheelPreventDefaultX:!0}),new y.Viewport(Q.VIEW_COLUMN_RIGHT,n,{left:r.width,top:0,height:o.height,right:0,isWheelPreventDefaultX:!0}),new y.Viewport(Q.VIEW_LEFT_TOP,n,{left:0,top:0,width:r.width,height:o.height,isWheelPreventDefaultX:!0}),new y.Viewport(Q.VIEW_MAIN_LEFT_TOP,n,{isWheelPreventDefaultX:!0,active:!1}),new y.Viewport(Q.VIEW_MAIN_LEFT,n,{isWheelPreventDefaultX:!0,active:!1}),new y.Viewport(Q.VIEW_MAIN_TOP,n,{isWheelPreventDefaultX:!0,active:!1}),n.onMouseWheelObserver.add((a,c)=>{if(a.ctrlKey)return;let d=0,u=0;const h=s.limitedScroll();if(a.inputIndex===y.PointerInput.MouseWheelX){const g=Math.abs(a.deltaX);a.deltaX>0?d=g:d=-g,this._commandService.executeCommand(ii.id,{offsetX:d}),n.getParent().classType===y.RENDER_CLASS_TYPE.SCENE_VIEWER?h!=null&&h.isLimitedX||c.stopPropagation():s.isWheelPreventDefaultX?a.preventDefault():h!=null&&h.isLimitedX||a.preventDefault()}if(a.inputIndex===y.PointerInput.MouseWheelY){let g=Math.abs(a.deltaY);a.shiftKey?(g*=3,a.deltaY>0?d=g:d=-g,this._commandService.executeCommand(ii.id,{offsetX:d}),n.getParent().classType===y.RENDER_CLASS_TYPE.SCENE_VIEWER?h!=null&&h.isLimitedX||c.stopPropagation():s.isWheelPreventDefaultX?a.preventDefault():h!=null&&h.isLimitedX||a.preventDefault()):(a.deltaY>0?u=g:u=-g,this._commandService.executeCommand(ii.id,{offsetY:u}),n.getParent().classType===y.RENDER_CLASS_TYPE.SCENE_VIEWER?h!=null&&h.isLimitedY||c.stopPropagation():s.isWheelPreventDefaultY?a.preventDefault():h!=null&&h.isLimitedY||a.preventDefault())}a.inputIndex,y.PointerInput.MouseWheelZ,this._scene.makeDirty(!0)}),new y.ScrollBar(s),n.attachControl(),s}};exports.SheetCanvasView=Xg([l.OnLifecycle(l.LifecycleStages.Ready,exports.SheetCanvasView),vn(0,l.IUniverInstanceService),vn(1,l.ICommandService),vn(2,y.IRenderManagerService),vn(3,Ze),vn(4,j.Inject(exports.SheetSkeletonManagerService))],exports.SheetCanvasView);var Zg=Object.defineProperty,Gg=Object.getOwnPropertyDescriptor,Kg=(i,e,t,n)=>{for(var r=n>1?void 0:n?Gg(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&Zg(e,t,r),r},Yi=(i,e)=>(t,n)=>e(t,n,i),Xi;exports.UniverSheetsUIPlugin=(Xi=class extends l.Plugin{constructor(e,t,n,r){super(_o),this._injector=t,this._localeService=n,this._currentUniverService=r,this._localeService.load({zhCN:ss})}onStarting(e){[[exports.SheetCanvasView],[at,{useClass:exports.EditorBridgeService}],[nn,{useClass:exports.SheetClipboardService}],[cn,{useClass:Vu}],[sn,{useClass:er}],[Dn,{useClass:as}],[xi,{useClass:Wc}],[xn,{useClass:exports.AutoFillService}],[Nt],[exports.SheetSkeletonManagerService],[Ze,{useClass:exports.SelectionRenderService}],[Cr,{useClass:lm}],[On,{useClass:exports.MarkSelectionService}],[Yn],[Xn],[ti],[qn],[Jn],[ni],[ri],[oi],[si],[ai],[li],[Qn],[di],[Qt],[hi],[Zn],[Gn],[ui],[mi],[_i],[ei],[fi],[exports.AutoFillController],[pi],[Kn],[ci]].forEach(t=>e.add(t))}onReady(){this._markSheetAsFocused()}_markSheetAsFocused(){const e=this._currentUniverService;e.currentSheet$.pipe(uo.filter(t=>!!t)).subscribe(t=>{e.focusUniverInstance(t.getUnitId())})}},v(Xi,"type",l.PluginType.Sheet),Xi);exports.UniverSheetsUIPlugin=Kg([Yi(1,j.Inject(j.Injector)),Yi(2,j.Inject(l.LocaleService)),Yi(3,l.IUniverInstanceService)],exports.UniverSheetsUIPlugin);exports.APPLY_TYPE=Te;exports.AutoFillCommand=So;exports.COPY_TYPE=Vt;exports.CellEditorManagerService=as;exports.DATA_TYPE=We;exports.DefaultRightMenuConfig=ho;exports.DefaultSheetContainerConfig=go;exports.DefaultSheetUIConfig=Ts;exports.DefaultToolbarConfig=mo;exports.ExpandSelectionCommand=_t;exports.IAutoFillService=xn;exports.ICellEditorManagerService=Dn;exports.IEditorBridgeService=at;exports.IFormulaEditorManagerService=xi;exports.IMarkSelectionService=On;exports.ISelectionRenderService=Ze;exports.ISheetClipboardService=nn;exports.JumpOver=gt;exports.MoveSelectionCommand=nt;exports.PASTE_SPECIAL_MENU_ID=ln;exports.PREDEFINED_HOOK_NAME=Ke;exports.RangeSelector=El;exports.SHEET_UI_PLUGIN_NAME=_o;exports.SelectionShape=Ci;exports.SetCellEditVisibleArrowOperation=Tn;exports.SetEditorResizeOperation=Ti;exports.SetScrollOperation=on;exports.SetZoomRatioOperation=bt;exports.SheetCopyCommand=wo;exports.SheetPasteCommand=rn;exports.VIEWPORT_KEY=Q;exports.enUS=Bc;exports.getAutoFillRepeatRange=Fs;exports.getCoordByCell=tr;exports.getCoordByOffset=tn;exports.getEditorObject=wi;exports.getRepeatRange=jc;exports.getSheetObject=qe;exports.getTransformCoord=$n;exports.whenEditorInputFormulaActivated=Ws;exports.zhCN=ss;