@univerjs/sheets-ui 0.7.0-nightly.202505231607 → 0.7.0-nightly.202505241606
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/facade.js +1 -1
- package/lib/cjs/index.js +1 -1
- package/lib/es/facade.js +16 -13
- package/lib/es/index.js +2 -2
- package/lib/facade.js +16 -13
- package/lib/index.js +2 -2
- package/lib/types/facade/f-workbook.d.ts +12 -0
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +1 -1
- package/package.json +12 -12
package/lib/cjs/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var $c=Object.defineProperty;var ed=(n,i,e)=>i in n?$c(n,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[i]=e;var w=(n,i,e)=>ed(n,typeof i!="symbol"?i+"":i,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const J=require("@univerjs/docs-ui"),a=require("@univerjs/core"),T=require("@univerjs/engine-render"),_=require("@univerjs/ui"),H=require("react"),O=require("rxjs"),m=require("@univerjs/sheets"),ve=require("@univerjs/docs"),Z=require("@univerjs/engine-formula"),vi=require("@univerjs/engine-numfmt"),I=require("react/jsx-runtime"),z=require("@univerjs/design"),de=require("rxjs/operators"),td=require("@univerjs/telemetry");function Ci(n,i){if(n==null)return;const e=i.getRenderById(n);if(e==null)return;const{mainComponent:t,scene:r,engine:o,components:s}=e,l=t,c=s.get(J.DOCS_VIEW_KEY.BACKGROUND);return{document:l,docBackground:c,scene:r,engine:o}}const _o=[10,400],Go="RANGE_SELECTOR_COMPONENT_KEY",_i="EMBEDDING_FORMULA_EDITOR_COMPONENT_KEY";var ue=(n=>(n.MAIN="__SpreadsheetRender__",n.ROW="__SpreadsheetRowHeader__",n.COLUMN="__SpreadsheetColumnHeader__",n.LEFT_TOP="__SpreadsheetLeftTopPlaceholder__",n))(ue||{});const ys=0,zr=1,ht=10,nd=11,Ms=12,Ii={id:"sheet.command.set-row-header-width",type:a.CommandType.COMMAND,handler:async(n,i)=>{if(!i)return!1;const e=n.get(T.IRenderManagerService);if(!e)return!1;const{unitId:t,subUnitId:r,size:o}=i,s=e.getRenderById(t);if(s){e.getRenderById(t).with(exports.SheetSkeletonManagerService).setRowHeaderSize(s,r,o);const{components:c}=s,d=c.get(ue.ROW);d&&d.setCustomHeader({headerStyle:{size:o}})}return!0}},bi={id:"sheet.command.set-col-header-height",type:a.CommandType.COMMAND,handler:async(n,i)=>{if(!i)return!1;const e=n.get(T.IRenderManagerService);if(!e)return!1;const{unitId:t,subUnitId:r,size:o}=i,s=e.getRenderById(t);if(s){e.getRenderById(t).with(exports.SheetSkeletonManagerService).setColumnHeaderSize(s,r,o);const{components:c}=s,d=c.get(ue.COLUMN);d&&d.setCustomHeader({headerStyle:{size:o}})}return!0}},Io=a.createInterceptorKey("rangeMovePermissionCheck"),bo=a.createInterceptorKey("rangeFillPermissionCheck");var Zo=(n=>(n[n.FORMULA_EDITOR_SHOW=100]="FORMULA_EDITOR_SHOW",n[n.MARK_SELECTION=1e4]="MARK_SELECTION",n))(Zo||{});function mt(n){const i=n.getColorFromTheme("primary.600"),e=n.getColorFromTheme("white"),t=new a.ColorKit(i).setAlpha(.07).toRgbString();return{strokeWidth:1,stroke:i,fill:t,widgets:{},widgetSize:6,widgetStrokeWidth:1,widgetStroke:e,autofillSize:6,autofillStrokeWidth:1,autofillStroke:e,rowHeaderFill:t,rowHeaderStroke:i,rowHeaderStrokeWidth:1,columnHeaderFill:t,columnHeaderStroke:i,columnHeaderStrokeWidth:1,expandCornerSize:40}}class rd{constructor(){w(this,"_startColumn",-1);w(this,"_startRow",-1);w(this,"_endColumn",-1);w(this,"_endRow",-1);w(this,"_startX",0);w(this,"_startY",0);w(this,"_endX",0);w(this,"_endY",0);w(this,"_primary");w(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._primary}get rangeType(){return this._rangeType}isEqual(i){const{startColumn:e,startRow:t,endColumn:r,endRow:o}=this,{startColumn:s,startRow:l,endColumn:c,endRow:d}=i;return e===s&&t===l&&r===c&&o===d}highlightToSelection(){if(this._primary)return a.convertCellToRange(this._primary)}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._primary}getRangeType(){return this._rangeType}setRangeType(i){this._rangeType=i}getValue(){return{rangeWithCoord:this.getRange(),primaryWithCoord:this._primary}}setValue(i,e){const{startColumn:t,startRow:r,endColumn:o,endRow:s,startX:l,startY:c,endX:d,endY:u,rangeType:h}=i;this._startColumn=t,this._startRow=r,this._endColumn=o,this._endRow=s,this._startX=l,this._startY=c,this._endX=d,this._endY=u,h!==void 0&&(this._rangeType=h),e!==void 0&&this.setCurrentCell(e)}setCurrentCell(i){this._primary=i}clearCurrentCell(){this._primary=null}}function cn(n,i){const{startRow:e,startColumn:t,endRow:r,endColumn:o,rangeType:s}=i,l=r<e?r:e,c=r<e?e:r,d=o<t?o:t,u=o<t?t:o,h=n.getNoMergeCellWithCoordByIndex(l,d),g=n.getNoMergeCellWithCoordByIndex(c,u);return{startRow:e,startColumn:t,endRow:r,endColumn:o,rangeType:s,startY:(h==null?void 0:h.startY)||0,endY:(g==null?void 0:g.endY)||0,startX:(h==null?void 0:h.startX)||0,endX:(g==null?void 0:g.endX)||0}}function we(n,i){const{range:e,primary:t,style:r}=n,o=cn(i,e),s=t&&Gn(i,t);return{rangeWithCoord:o,primaryWithCoord:s,style:r}}function Gn(n,i){const{actualRow:e,actualColumn:t,isMerged:r,isMergedMainCell:o,startRow:s,startColumn:l,endRow:c,endColumn:d}=i,u=n.getNoMergeCellWithCoordByIndex(e,t),h=n.getNoMergeCellWithCoordByIndex(s,l),g=n.getNoMergeCellWithCoordByIndex(c,d);return{actualRow:e,actualColumn:t,isMerged:r,isMergedMainCell:o,startX:u.startX,startY:u.startY,endX:u.endX,endY:u.endY,mergeInfo:{startRow:s,startColumn:l,endRow:c,endColumn:d,startY:(h==null?void 0:h.startY)||0,endY:(g==null?void 0:g.endY)||0,startX:(h==null?void 0:h.startX)||0,endX:(g==null?void 0:g.endX)||0}}}const Ps="__SpreadsheetHelperSelectionTempRect",id=35;class ya{constructor(i,e){w(this,"_startOffsetX",0);w(this,"_startOffsetY",0);w(this,"_relativeSelectionPositionRow",0);w(this,"_relativeSelectionPositionColumn",0);w(this,"_relativeSelectionRowLength",0);w(this,"_relativeSelectionColumnLength",0);w(this,"_scenePointerMoveSub");w(this,"_scenePointerUpSub");w(this,"_disabled",!1);w(this,"_helperSelection");w(this,"_scrollTimer");w(this,"_activeViewport");w(this,"_targetSelection",{startY:0,endY:0,startX:0,endX:0,startRow:-1,endRow:-1,startColumn:-1,endColumn:-1});w(this,"_isInMergeState",!1);w(this,"_fillControlColors",[]);w(this,"_skeleton");w(this,"_scene");w(this,"_themeService");w(this,"_injector");w(this,"_selectionHooks");this._control=i,this._skeleton=e.skeleton,this._scene=e.scene,this._themeService=e.themeService,this._injector=e.injector,this._selectionHooks=e.selectionHooks,this._initialControl(),this._initialWidget(),this._initialAutoFill(),this._control.dispose$.subscribe(()=>{this.dispose()})}get isHelperSelection(){return this._control.isHelperSelection}dispose(){var i,e;(i=this._scrollTimer)==null||i.dispose(),this._fillControlColors=[],this._clearObserverEvent(),(e=this._helperSelection)==null||e.dispose()}setDisabled(i){this._disabled=i}_getFreeze(){var e,t;return(t=(e=T.withCurrentTypeOfRenderer(a.UniverInstanceType.UNIVER_SHEET,exports.SheetSkeletonManagerService,this._injector.get(a.IUniverInstanceService),this._injector.get(T.IRenderManagerService)))==null?void 0:e.getCurrentParam())==null?void 0:t.skeleton.getWorksheetConfig().freeze}_isSelectionInViewport(i,e){const t=this._getFreeze()||{startRow:-1,startColumn:-1};switch(e.viewportKey){case T.SHEET_VIEWPORT_KEY.VIEW_MAIN:return i.endRow>=t.startRow&&i.endColumn>=t.startColumn;case T.SHEET_VIEWPORT_KEY.VIEW_MAIN_TOP:case T.SHEET_VIEWPORT_KEY.VIEW_COLUMN_RIGHT:return i.endColumn>=t.startColumn&&i.startRow<t.startRow;case T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT:case T.SHEET_VIEWPORT_KEY.VIEW_ROW_BOTTOM:return i.endRow>=t.startRow&&i.startColumn<t.startColumn;case T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP:case T.SHEET_VIEWPORT_KEY.VIEW_COLUMN_LEFT:case T.SHEET_VIEWPORT_KEY.VIEW_ROW_TOP:case T.SHEET_VIEWPORT_KEY.VIEW_LEFT_TOP:return i.startRow<t.startRow&&i.startColumn<t.startColumn}}_clearObserverEvent(){var i,e;(i=this._scenePointerMoveSub)==null||i.unsubscribe(),(e=this._scenePointerUpSub)==null||e.unsubscribe(),this._scenePointerMoveSub=null,this._scenePointerUpSub=null}_initialControl(){const{leftControl:i,rightControl:e,topControl:t,bottomControl:r}=this._control;[i,e,t,r].forEach(o=>{o.onPointerEnter$.subscribeEvent(()=>{var l;((l=this._injector.get(pe,a.Quantity.OPTIONAL))==null?void 0:l.interceptor.fetchThroughInterceptors(Io)(!1,null))!==!1&&o.setCursor(T.CURSOR_TYPE.MOVE)}),o.onPointerLeave$.subscribeEvent(()=>{o.resetCursor()}),o.onPointerDown$.subscribeEvent(this._controlPointerDownHandler.bind(this))})}_controlMoving(i,e){var A;const t=this._scene,r=t.getScrollXYInfoByViewport(T.Vector2.FromArray([i,e])),{scaleX:o,scaleY:s}=t.getAncestorScale(),l=this._skeleton.getCellIndexByOffset(i,e,o,s,r),{row:c,column:d}=l,u=this._skeleton.getRowCount()-1,h=this._skeleton.getColumnCount()-1;let g=Math.max(0,c+this._relativeSelectionPositionRow),S=g+this._relativeSelectionRowLength;S>u&&(S=u,S-g<this._relativeSelectionRowLength&&(g=S-this._relativeSelectionRowLength));let f=Math.max(0,d+this._relativeSelectionPositionColumn),p=f+this._relativeSelectionColumnLength;p>h&&(p=h,p-f<this._relativeSelectionColumnLength&&(f=p-this._relativeSelectionColumnLength));const v=this._skeleton.worksheet.getCellInfoInMergeData(g,f),b=we({range:{startRow:g,endRow:S,startColumn:f,endColumn:p},primary:v,style:null},this._skeleton),R=this._skeleton.getNoMergeCellWithCoordByIndex(g,f),E=this._skeleton.getNoMergeCellWithCoordByIndex(S,p),P=(R==null?void 0:R.startY)||0,y=(E==null?void 0:E.endY)||0,M=(R==null?void 0:R.startX)||0,x=(E==null?void 0:E.endX)||0;(A=this._helperSelection)==null||A.transformByState({left:M,top:P,width:x-M,height:y-P}),this._targetSelection={...b.rangeWithCoord},this._control.selectionMoving$.next(b.rangeWithCoord)}_controlPointerDownHandler(i){const{offsetX:e,offsetY:t}=i,r=this._scene,o=r.getCoordRelativeToViewport(T.Vector2.FromArray([e,t])),{x:s,y:l}=o,c=r.getScrollXYInfoByViewport(o),{scaleX:d,scaleY:u}=r.getAncestorScale(),h=this._skeleton.getCellIndexByOffset(s,l,d,u,c);this._startOffsetX=s,this._startOffsetY=l;const{row:g,column:S}=h,{startRow:f,startColumn:p,endRow:v,endColumn:C}=this._control.model;let b=0,R=0;g<f?b-=1:g>v&&(b+=1),S<p?R-=1:S>C&&(R+=1),this._relativeSelectionPositionRow=f-g+b,this._relativeSelectionPositionColumn=p-S+R,this._relativeSelectionRowLength=v-f,this._relativeSelectionColumnLength=C-p;const E=this._control.currentStyle,P=this._getScale();this.isHelperSelection&&(this._helperSelection=new T.Rect(Ps,{stroke:E.stroke,strokeWidth:E.strokeWidth/P}),r.addObject(this._helperSelection));const y=r.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN),M=T.ScrollTimer.create(r);this._scrollTimer=M,M.startScroll(s,l,y),r.disableObjectsEvent(),this._scenePointerMoveSub=r.onPointerMove$.subscribeEvent(x=>{var V;if(this._disabled)return;const{offsetX:A,offsetY:k}=x;if(((V=this._injector.get(pe,a.Quantity.OPTIONAL))==null?void 0:V.interceptor.fetchThroughInterceptors(Io)(!1,null))===!1)return;const{x:N,y:W}=r.getCoordRelativeToViewport(T.Vector2.FromArray([A,k]));this._controlMoving(N,W),r.setCursor(T.CURSOR_TYPE.MOVE),M.scrolling(N,W,()=>{this._controlMoving(N,W)})}),this._scenePointerUpSub=r.onPointerUp$.subscribeEvent(()=>{var A,k,D,N;(A=this._helperSelection)==null||A.dispose();const x=this._scene;x.resetCursor(),this._clearObserverEvent(),x.enableObjectsEvent(),(k=this._scrollTimer)==null||k.dispose(),this._control.selectionMoveEnd$.next(this._targetSelection),(N=(D=this._selectionHooks).selectionMoveEnd)==null||N.call(D)})}_initialWidget(){const{topLeftWidget:i,topCenterWidget:e,topRightWidget:t,middleLeftWidget:r,middleRightWidget:o,bottomLeftWidget:s,bottomCenterWidget:l,bottomRightWidget:c}=this._control,d=[T.CURSOR_TYPE.NORTH_WEST_RESIZE,T.CURSOR_TYPE.NORTH_RESIZE,T.CURSOR_TYPE.NORTH_EAST_RESIZE,T.CURSOR_TYPE.WEST_RESIZE,T.CURSOR_TYPE.EAST_RESIZE,T.CURSOR_TYPE.SOUTH_WEST_RESIZE,T.CURSOR_TYPE.SOUTH_RESIZE,T.CURSOR_TYPE.SOUTH_EAST_RESIZE];[i,e,t,r,o,s,l,c].forEach((u,h)=>{u.onPointerEnter$.subscribeEvent(()=>{u.setCursor(d[h])}),u.onPointerLeave$.subscribeEvent(()=>{u.resetCursor()}),u.onPointerDown$.subscribeEvent(g=>{this._widgetPointerDownEvent(g,d[h])})})}_widgetPointerDownEvent(i,e){const t=this._scene,{offsetX:r,offsetY:o}=i,s=t.getCoordRelativeToViewport(T.Vector2.FromArray([r,o])),{x:l,y:c}=s;this._startOffsetX=r,this._startOffsetY=o;const{startRow:d,startColumn:u,endRow:h,endColumn:g}=this._control.model,S=Math.min(d,h),f=Math.min(u,g),p=Math.max(d,h),v=Math.max(u,g);this._relativeSelectionPositionRow=S,this._relativeSelectionPositionColumn=f,this._relativeSelectionRowLength=p-S,this._relativeSelectionColumnLength=v-f,e===T.CURSOR_TYPE.NORTH_WEST_RESIZE?(this._relativeSelectionPositionRow=p,this._relativeSelectionPositionColumn=v):e===T.CURSOR_TYPE.NORTH_RESIZE?this._relativeSelectionPositionRow=p:e===T.CURSOR_TYPE.NORTH_EAST_RESIZE?this._relativeSelectionPositionRow=p:e===T.CURSOR_TYPE.WEST_RESIZE?this._relativeSelectionPositionColumn=v:e===T.CURSOR_TYPE.SOUTH_WEST_RESIZE?this._relativeSelectionPositionColumn=v:e===T.CURSOR_TYPE.SOUTH_RESIZE&&(this._relativeSelectionPositionRow=S);const C=T.ScrollTimer.create(t),b=t.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN);C.startScroll(l,c,b),this._scrollTimer=C,t.disableObjectsEvent(),this._scenePointerMoveSub=t.onPointerMove$.subscribeEvent(R=>{const{offsetX:E,offsetY:P}=R,{x:y,y:M}=t.getCoordRelativeToViewport(T.Vector2.FromArray([E,P]));this._widgetMoving(y,M,e),t.setCursor(e),C.scrolling(y,M,()=>{this._widgetMoving(y,M,e)})}),this._scenePointerUpSub=t.onPointerUp$.subscribeEvent(()=>{var E,P,y;const R=this._scene;R.resetCursor(),this._clearObserverEvent(),R.enableObjectsEvent(),(E=this._scrollTimer)==null||E.dispose(),this._control.selectionScaled$.next(this._targetSelection),(y=(P=this._selectionHooks).selectionMoveEnd)==null||y.call(P)})}_widgetMoving(i,e,t){const r=this._scene,o=r.getScrollXYInfoByViewport(T.Vector2.FromArray([this._startOffsetX,this._startOffsetY])),{scaleX:s,scaleY:l}=r.getAncestorScale(),c=this._skeleton.getCellIndexByOffset(i,e,s,l,o),{row:d,column:u}=c;let h=this._relativeSelectionPositionRow,g=this._relativeSelectionPositionColumn,S=d,f=u;t===T.CURSOR_TYPE.NORTH_WEST_RESIZE?(h=d,g=u,S=this._relativeSelectionPositionRow,f=this._relativeSelectionPositionColumn):t===T.CURSOR_TYPE.NORTH_RESIZE?(h=d,g=this._relativeSelectionPositionColumn,S=this._relativeSelectionPositionRow,f=this._relativeSelectionPositionColumn+this._relativeSelectionColumnLength):t===T.CURSOR_TYPE.NORTH_EAST_RESIZE?(h=d,g=this._relativeSelectionPositionColumn,S=this._relativeSelectionPositionRow,f=u):t===T.CURSOR_TYPE.WEST_RESIZE?(h=this._relativeSelectionPositionRow,g=u,S=this._relativeSelectionPositionRow+this._relativeSelectionRowLength,f=this._relativeSelectionPositionColumn):t===T.CURSOR_TYPE.EAST_RESIZE?S=this._relativeSelectionPositionRow+this._relativeSelectionRowLength:t===T.CURSOR_TYPE.SOUTH_WEST_RESIZE?(h=this._relativeSelectionPositionRow,g=u,S=d,f=this._relativeSelectionPositionColumn):t===T.CURSOR_TYPE.SOUTH_RESIZE&&(h=this._relativeSelectionPositionRow,g=this._relativeSelectionPositionColumn,S=d,f=this._relativeSelectionPositionColumn+this._relativeSelectionColumnLength);const p=this._swapPositions(h,g,S,f),v=this._skeleton.getCellWithMergeInfoByIndex(h,g),b=we({range:p,primary:v,style:null},this._skeleton);this._targetSelection={...b.rangeWithCoord},this._control.updateRangeBySelectionWithCoord(b),this._control.selectionScaling$.next(this._targetSelection)}_initialAutoFill(){const{fillControl:i}=this._control;i.onPointerEnter$.subscribeEvent(e=>{this._injector.get(pe).interceptor.fetchThroughInterceptors(bo)(!1,{x:e.offsetX,y:e.offsetY,skeleton:this._skeleton,scene:this._scene})&&i.setCursor(T.CURSOR_TYPE.CROSSHAIR)}),i.onPointerLeave$.subscribeEvent(()=>{i.resetCursor()}),i.onPointerDown$.subscribeEvent(this._autoFillForPointerdown.bind(this))}_autoFillMoving(i,e){var k,D,N;const t=this._scene,r=t.getViewportScrollXY(this._activeViewport),{scaleX:o,scaleY:s}=t.getAncestorScale(),l=this._skeleton.getCellIndexByOffset(i,e,o,s,r),{row:c,column:d}=l,u=t.getCoordRelativeToViewport(T.Vector2.FromArray([i,e])),h=this._skeleton.getRowCount()-1,g=this._skeleton.getColumnCount()-1;let S=this._relativeSelectionPositionRow,f=this._relativeSelectionPositionColumn,p=this._relativeSelectionPositionRow+this._relativeSelectionRowLength,v=this._relativeSelectionPositionColumn+this._relativeSelectionColumnLength,C=!1,b=!0;if((d<f||d>v)&&c>=S&&c<=p){const W=this._fillRuler(d,f,v,this._relativeSelectionColumnLength,g);f=W.startRowOrColumn,v=W.endRowOrColumn,C=W.isLighten,b=!1}else if((c<S||c>p)&&d>=f&&d<=v){const W=this._fillRuler(c,S,p,this._relativeSelectionRowLength,h);S=W.startRowOrColumn,p=W.endRowOrColumn,C=W.isLighten}else if(Math.abs(this._startOffsetX-u.x-r.x)/2>Math.abs(this._startOffsetY-u.y-r.y)){const W=this._fillRuler(d,f,v,this._relativeSelectionColumnLength,g);f=W.startRowOrColumn,v=W.endRowOrColumn,C=W.isLighten,b=!1}else{const W=this._fillRuler(c,S,p,this._relativeSelectionRowLength,h);S=W.startRowOrColumn,p=W.endRowOrColumn,C=W.isLighten}const R=this._skeleton.getNoMergeCellWithCoordByIndex(S,f),E=this._skeleton.getNoMergeCellWithCoordByIndex(p,v),P=(R==null?void 0:R.startY)||0,y=(E==null?void 0:E.endY)||0,M=(R==null?void 0:R.startX)||0,x=(E==null?void 0:E.endX)||0;C?this._controlHandler((W,V)=>{const U=new a.ColorKit(this._fillControlColors[V]).lighten(id).toRgbString();W.setProps({fill:U})}):this._controlHandler((W,V)=>{W.setProps({fill:this._fillControlColors[V]})});const A=m.SELECTION_CONTROL_BORDER_BUFFER_WIDTH/this._getScale();S===p&&b===!0||f===v&&b===!1?(k=this._helperSelection)==null||k.hide():((D=this._helperSelection)==null||D.transformByState({left:M-A/2,top:P-A/2,width:x-M,height:y-P}),(N=this._helperSelection)==null||N.show()),this._targetSelection={startY:P,endY:y,startX:M,endX:x,startRow:S,endRow:p,startColumn:f,endColumn:v},this._control.selectionFilling$.next(this._targetSelection)}_autoFillForPointerdown(i){const{offsetX:e,offsetY:t}=i,r=this._scene,o=r.getCoordRelativeToViewport(T.Vector2.FromArray([e,t])),{x:s,y:l}=o;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 g=this._control.currentStyle;let S=g==null?void 0:g.stroke,f=g==null?void 0:g.strokeWidth;const p=mt(this._themeService);S==null&&(S=p.stroke),f==null&&(f=p.strokeWidth);const v=this._getScale();f/=v;const C=m.SELECTION_CONTROL_BORDER_BUFFER_WIDTH/v,b=new a.ColorKit(S).darken(2).toRgbString();this.isHelperSelection&&(this._helperSelection=new T.Rect(Ps,{stroke:b,strokeWidth:f+C/2}),r.addObject(this._helperSelection)),this._activeViewport=r.getActiveViewportByCoord(T.Vector2.FromArray([e,t]));const R=r.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN),E=T.ScrollTimer.create(r,this._activeViewport.viewportKey===T.SHEET_VIEWPORT_KEY.VIEW_MAIN?T.ScrollTimerType.ALL:T.ScrollTimerType.NONE);E.startScroll(s,l,R),this._scrollTimer=E,r.disableObjectsEvent(),this._controlHandler(P=>{this._fillControlColors.push(P.fill)}),this._scenePointerMoveSub=r.onPointerMove$.subscribeEvent(P=>{var W;const{offsetX:y,offsetY:M}=P,x=r.getActiveViewportByCoord(T.Vector2.FromArray([y,M]));if(!this._injector.get(pe).interceptor.fetchThroughInterceptors(bo)(!1,{x:i.offsetX,y:i.offsetY,skeleton:this._skeleton,scene:this._scene}))return;const{x:k,y:D}=r.getCoordRelativeToViewport(T.Vector2.FromArray([y,M]));this._autoFillMoving(k,D),r.setCursor(T.CURSOR_TYPE.CROSSHAIR);const N=this._targetSelection;if(R&&x&&((W=this._activeViewport)==null?void 0:W.viewportKey)!==(x==null?void 0:x.viewportKey)){let V;N.startRow!==c?(E.scrollTimerType=T.ScrollTimerType.Y,V={...N,endRow:N.startRow}):N.endRow!==u?(E.scrollTimerType=T.ScrollTimerType.Y,V={...N,startRow:N.endRow}):N.startColumn!==d?(E.scrollTimerType=T.ScrollTimerType.X,V={...N,endColumn:N.startColumn}):(E.scrollTimerType=T.ScrollTimerType.X,V={...N,startColumn:N.endColumn}),this._isSelectionInViewport(V,x)&&(R.scrollToBarPos({x:E.scrollTimerType===T.ScrollTimerType.X?0:void 0,y:E.scrollTimerType===T.ScrollTimerType.Y?0:void 0}),this._activeViewport=x)}E.scrolling(k,D,()=>{this._autoFillMoving(k,D)})}),this._scenePointerUpSub=r.onPointerUp$.subscribeEvent(()=>{var y,M;(y=this._helperSelection)==null||y.dispose();const P=this._scene;P.resetCursor(),this._clearObserverEvent(),P.enableObjectsEvent(),(M=this._scrollTimer)==null||M.dispose(),this._control.refreshSelectionFilled(this._targetSelection),this._isInMergeState=!1,this._controlHandler((x,A)=>{x.setProps({fill:this._fillControlColors[A]})}),this._fillControlColors=[]})}_hasMergeInRange(i,e,t,r){return this._skeleton.worksheet.getMergedCellRange(i,e,t,r).length>0}_swapPositions(i,e,t,r){const o=Math.min(i,t),s=Math.min(e,r),l=Math.max(i,t),c=Math.max(e,r);return{startRow:o,startColumn:s,endRow:l,endColumn:c}}_controlHandler(i){const{leftControl:e,rightControl:t,topControl:r,bottomControl:o,backgroundControlTop:s,backgroundControlMiddleLeft:l,backgroundControlMiddleRight:c,backgroundControlBottom:d,fillControl:u}=this._control,h=[e,t,r,o,s,l,c,d,u];for(let g=0,S=h.length;g<S;g++){const f=h[g];i(f,g)}}_fillRuler(i,e,t,r,o){let s=!1;if(i<e)if(this._isInMergeState&&i<e){const l=e-i,c=r+1,d=Math.ceil(l/c);let u=e-d*c;u<0&&(u=e-(d-1)*c),e=u}else e=i;else if(i>=e&&i<=t)s=!0,this._isInMergeState||(t=i);else if(this._isInMergeState&&i>t){const l=i-t,c=r+1,d=Math.ceil(l/c);let u=t+d*c;u>o&&(u=t+(d-1)*c),t=u}else t=i;return{rowOrColumn:i,startRowOrColumn:e,endRowOrColumn:t,isLighten:s}}_getScale(){const{scaleX:i,scaleY:e}=this._scene.getAncestorScale();return Math.max(i,e)}}var Ro=(n=>(n.Selection="__SpreadsheetSelectionShape__",n.top="__SpreadsheetSelectionTopControl__",n.bottom="__SpreadsheetSelectionBottomControl__",n.left="__SpreadsheetSelectionShapeLeftControl__",n.right="__SpreadsheetSelectionShapeRightControl__",n.backgroundTop="__SpreadsheetSelectionBackgroundControlTop__",n.backgroundMiddleLeft="__SpreadsheetSelectionBackgroundControlMiddleLeft__",n.backgroundMiddleRight="__SpreadsheetSelectionBackgroundControlMiddleRight__",n.backgroundBottom="__SpreadsheetSelectionBackgroundControlBottom__",n.fill="__SpreadsheetSelectionFillControl__",n.fillTopLeft="__SpreadsheetSelectionFillControlTopLeft__",n.fillBottomRight="__SpreadsheetSelectionFillControlBottomRight__",n.fillTopLeftInner="__SpreadsheetSelectionFillControlTopLeftInner__",n.fillBottomRightInner="__SpreadsheetSelectionFillControlBottomRightInner__",n.lineMain="__SpreadsheetDragLineMainControl__",n.lineContent="__SpreadsheetDragLineContentControl__",n.line="__SpreadsheetDragLineControl__",n.dash="__SpreadsheetDragDashControl__",n.rowHeaderBackground="__SpreadSheetSelectionRowHeaderBackground__",n.rowHeaderBorder="__SpreadSheetSelectionRowHeaderBorder__",n.rowHeaderGroup="__SpreadSheetSelectionRowHeaderGroup__",n.columnHeaderBackground="__SpreadSheetSelectionColumnHeaderBackground__",n.columnHeaderBorder="__SpreadSheetSelectionColumnHeaderBorder__",n.columnHeaderGroup="__SpreadSheetSelectionColumnHeaderGroup__",n.topLeftWidget="__SpreadSheetSelectionTopLeftWidget__",n.topCenterWidget="__SpreadSheetSelectionTopCenterWidget__",n.topRightWidget="__SpreadSheetSelectionTopRightWidget__",n.middleLeftWidget="__SpreadSheetSelectionMiddleLeftWidget__",n.middleRightWidget="__SpreadSheetSelectionMiddleRightWidget__",n.bottomLeftWidget="__SpreadSheetSelectionBottomLeftWidget__",n.bottomCenterWidget="__SpreadSheetSelectionBottomCenterWidget__",n.bottomRightWidget="__SpreadSheetSelectionBottomRightWidget__",n))(Ro||{});const xs=.3;class nr extends a.Disposable{constructor(e,t,r,o){var s,l,c,d;super();w(this,"_isHelperSelection",!0);w(this,"_enableAutoFill",!0);w(this,"_showAutoFill",!1);w(this,"_highlightHeader",!0);w(this,"_selectionRenderModel");w(this,"_leftBorder");w(this,"_rightBorder");w(this,"_topBorder");w(this,"_bottomBorder");w(this,"_backgroundControlTop");w(this,"_backgroundControlBottom");w(this,"_backgroundControlMiddleLeft");w(this,"_backgroundControlMiddleRight");w(this,"_autoFillControl");w(this,"_selectionShapeGroup");w(this,"_rowHeaderBackground");w(this,"_rowHeaderBorder");w(this,"_rowHeaderGroup");w(this,"_columnHeaderBackground");w(this,"_columnHeaderBorder");w(this,"_columnHeaderGroup");w(this,"_dashedRect");w(this,"_topLeftWidget");w(this,"_topCenterWidget");w(this,"_topRightWidget");w(this,"_middleLeftWidget");w(this,"_middleRightWidget");w(this,"_bottomLeftWidget");w(this,"_bottomCenterWidget");w(this,"_bottomRightWidget");w(this,"_defaultStyle");w(this,"_currentStyle");w(this,"_rowHeaderWidth",0);w(this,"_columnHeaderHeight",0);w(this,"_widgetRects",[]);w(this,"_controlExtension");w(this,"_dispose$",new O.BehaviorSubject(this));w(this,"dispose$",this._dispose$.asObservable());w(this,"selectionMoving$",new O.Subject);w(this,"selectionMoveEnd$",new O.Subject);w(this,"selectionScaling$",new O.Subject);w(this,"selectionScaled$",new O.Subject);w(this,"selectionFilling$",new O.Subject);w(this,"_selectionFilled$",new O.Subject);w(this,"selectionFilled$",this._selectionFilled$.asObservable());w(this,"_antLineOffset",0);w(this,"_antRequestNewFrame",-1);this._scene=e,this._zIndex=t,this._themeService=r,this._enableAutoFill=(s=o==null?void 0:o.enableAutoFill)!=null?s:!0,this._highlightHeader=(l=o==null?void 0:o.highlightHeader)!=null?l:!0,this._rowHeaderWidth=(c=o==null?void 0:o.rowHeaderWidth)!=null?c:0,this._columnHeaderHeight=(d=o==null?void 0:o.columnHeaderHeight)!=null?d:0,this._initializeSheetBody(),this._initialHeader()}_initializeSheetBody(){this._defaultStyle=mt(this._themeService),this._currentStyle=mt(this._themeService),this._selectionRenderModel=new rd;const e=this._zIndex;this._leftBorder=new T.Rect("__SpreadsheetSelectionShapeLeftControl__"+e,{zIndex:e}),this._rightBorder=new T.Rect("__SpreadsheetSelectionShapeRightControl__"+e,{zIndex:e}),this._topBorder=new T.Rect("__SpreadsheetSelectionTopControl__"+e,{zIndex:e}),this._bottomBorder=new T.Rect("__SpreadsheetSelectionBottomControl__"+e,{zIndex:e}),this._backgroundControlTop=new T.Rect("__SpreadsheetSelectionBackgroundControlTop__"+e,{zIndex:e-1,evented:!1}),this._backgroundControlBottom=new T.Rect("__SpreadsheetSelectionBackgroundControlBottom__"+e,{zIndex:e-1,evented:!1}),this._backgroundControlMiddleLeft=new T.Rect("__SpreadsheetSelectionBackgroundControlMiddleLeft__"+e,{zIndex:e-1,evented:!1}),this._backgroundControlMiddleRight=new T.Rect("__SpreadsheetSelectionBackgroundControlMiddleRight__"+e,{zIndex:e-1,evented:!1}),this._autoFillControl=new T.Rect("__SpreadsheetSelectionFillControl__"+e,{zIndex:e+1}),this._autoFillControl.hide(),this._dashedRect=new T.DashedRect("__SpreadsheetDragDashControl__"+e,{zIndex:e+2,evented:!1,stroke:"#fff"});const t=[this._autoFillControl,this._leftBorder,this._rightBorder,this._topBorder,this._bottomBorder,this._backgroundControlTop,this._backgroundControlMiddleLeft,this._backgroundControlMiddleRight,this._backgroundControlBottom,this._dashedRect];this._widgetRects=this._initialWidget(),this._selectionShapeGroup=new T.Group("__SpreadsheetSelectionShape__"+e,...t,...this._widgetRects),this._selectionShapeGroup.hide(),this._selectionShapeGroup.evented=!1,this._selectionShapeGroup.zIndex=e;const r=this.getScene();r.addObject(this._selectionShapeGroup,zr),this.disposeWithMe(a.toDisposable(r.onTransformChange$.subscribeEvent(o=>{o.type===T.TRANSFORM_CHANGE_OBSERVABLE_TYPE.scale&&(this._updateLayoutOfSelectionControl(this._currentStyle),this._updateControlCoord())})))}_initialHeader(){const e=this._zIndex;this._rowHeaderBackground=new T.Rect("__SpreadSheetSelectionRowHeaderBackground__"+e,{zIndex:e-1,evented:!1}),this._rowHeaderBorder=new T.Rect("__SpreadSheetSelectionRowHeaderBorder__"+e,{zIndex:e-1,evented:!1}),this._rowHeaderGroup=new T.Group("__SpreadSheetSelectionRowHeaderGroup__"+e,this._rowHeaderBackground,this._rowHeaderBorder),this._rowHeaderGroup.hide(),this._rowHeaderGroup.evented=!1,this._rowHeaderGroup.zIndex=e,this._columnHeaderBackground=new T.Rect("__SpreadSheetSelectionColumnHeaderBackground__"+e,{zIndex:e-1,evented:!1}),this._columnHeaderBorder=new T.Rect("__SpreadSheetSelectionColumnHeaderBorder__"+e,{zIndex:e-1,evented:!1}),this._columnHeaderGroup=new T.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],nd)}_initialWidget(){const e=this._zIndex;return this._topLeftWidget=new T.Rect("__SpreadSheetSelectionTopLeftWidget__"+e,{zIndex:e+1}),this._topCenterWidget=new T.Rect("__SpreadSheetSelectionTopCenterWidget__"+e,{zIndex:e+1}),this._topRightWidget=new T.Rect("__SpreadSheetSelectionTopRightWidget__"+e,{zIndex:e+1}),this._middleLeftWidget=new T.Rect("__SpreadSheetSelectionMiddleLeftWidget__"+e,{zIndex:e+1}),this._middleRightWidget=new T.Rect("__SpreadSheetSelectionMiddleRightWidget__"+e,{zIndex:e+1}),this._bottomLeftWidget=new T.Rect("__SpreadSheetSelectionBottomLeftWidget__"+e,{zIndex:e+1}),this._bottomCenterWidget=new T.Rect("__SpreadSheetSelectionBottomCenterWidget__"+e,{zIndex:e+1}),this._bottomRightWidget=new T.Rect("__SpreadSheetSelectionBottomRightWidget__"+e,{zIndex:e+1}),[this._topLeftWidget,this._topCenterWidget,this._topRightWidget,this._middleLeftWidget,this._middleRightWidget,this._bottomLeftWidget,this._bottomCenterWidget,this._bottomRightWidget]}get zIndex(){return this._zIndex}get leftControl(){return this._leftBorder}get rightControl(){return this._rightBorder}get topControl(){return this._topBorder}get bottomControl(){return this._bottomBorder}get fillControl(){return this._autoFillControl}get backgroundControlTop(){return this._backgroundControlTop}get backgroundControlBottom(){return this._backgroundControlBottom}get backgroundControlMiddleLeft(){return this._backgroundControlMiddleLeft}get backgroundControlMiddleRight(){return this._backgroundControlMiddleRight}get selectionShape(){return this._selectionShapeGroup}get columnHeaderGroup(){return this._columnHeaderGroup}get rowHeaderGroup(){return this._rowHeaderGroup}get selectionShapeGroup(){return this._selectionShapeGroup}get model(){return this._selectionRenderModel}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 themeService(){return this._themeService}get selectionModel(){return this._selectionRenderModel}set selectionModel(e){this._selectionRenderModel=e}get currentStyle(){return this._currentStyle}set currentStyle(e){this._currentStyle=e}get dashedRect(){return this._dashedRect}get isHelperSelection(){return this._isHelperSelection}get rowHeaderWidth(){return this._rowHeaderWidth}set rowHeaderWidth(e){this._rowHeaderWidth=e}get columnHeaderHeight(){return this._columnHeaderHeight}set columnHeaderHeight(e){this._columnHeaderHeight=e}setControlExtension(e){this._controlExtension=new ya(this,e)}setControlExtensionDisable(e){this._controlExtension&&this._controlExtension.setDisabled(e)}setEvent(e){this.leftControl.evented=e,this.rightControl.evented=e,this.topControl.evented=e,this.bottomControl.evented=e}refreshSelectionFilled(e){this._selectionFilled$.next(e)}_updateLayoutOfSelectionControl(e){e&&(this.currentStyle=Object.assign({},this._defaultStyle,e));const t=this.currentStyle,{stroke:r,widgets:o,autofillStroke:s,strokeDash:l,isAnimationDash:c}=t;let d=t.autofillSize,u=t.strokeWidth,h=t.autofillStrokeWidth;const g=this._getScale(),S=(u+m.SELECTION_CONTROL_BORDER_BUFFER_WIDTH)/2/g;u/=g,d/=g,h/=g<1?1:g;const f=m.SELECTION_CONTROL_BORDER_BUFFER_WIDTH/g,p=T.FIX_ONE_PIXEL_BLUR_OFFSET/g,{startX:v,startY:C,endX:b,endY:R}=this._selectionRenderModel;if(this.leftControl.transformByState({height:R-C,left:-S+p,width:u,strokeWidth:f,top:-f/2+p}),this.leftControl.setProps({fill:r,stroke:m.SELECTION_CONTROL_BORDER_BUFFER_COLOR}),this.rightControl.transformByState({height:R-C,left:b-v-S+p,width:u,strokeWidth:f,top:-f/2+p}),this.rightControl.setProps({fill:r,stroke:m.SELECTION_CONTROL_BORDER_BUFFER_COLOR}),this.topControl.transformByState({width:b-v+u,top:-S+p,left:-S+p,height:u,strokeWidth:f}),this.topControl.setProps({fill:r,stroke:m.SELECTION_CONTROL_BORDER_BUFFER_COLOR}),this.bottomControl.transformByState({width:b-v+u,top:R-C-S+p,height:u,left:-S+p,strokeWidth:f}),this.bottomControl.setProps({fill:r,stroke:m.SELECTION_CONTROL_BORDER_BUFFER_COLOR}),l==null)this.dashedRect.hide(),this._stopAntLineAnimation();else{const E=t.strokeWidth*2/g;this.dashedRect.transformByState({height:R-C,width:b-v,strokeWidth:E,left:-E/2+p,top:-E/2+p}),this.dashedRect.setProps({strokeDashArray:[0,l/g]}),this._stopAntLineAnimation(),c!==!1&&this._startAntLineAnimation(),this.dashedRect.show()}if(this._showAutoFill=this._showAutoFill&&this._enableAutoFill,this._showAutoFill&&!this._hasWidgets(o)){const E={fill:r,stroke:s,strokeScaleEnabled:!1},P={width:d-h,height:d-h,left:b-v-d/2+h/2-p,top:R-C-d/2+h/2-p,strokeWidth:h};this._autoFillControl.setProps(E),this._autoFillControl.transformByState(P),this._autoFillControl.show()}else this._autoFillControl.hide();this._updateBackgroundControl(t),this._updateHeaderBackground(t),this._updateWidgets(t)}_updateControlCoord(){const{startX:e,startY:t}=this._selectionRenderModel;this.selectionShapeGroup.show(),this.selectionShapeGroup.translate(e,t),this.selectionShapeGroup.makeDirtyNoDebounce(!0)}updateStyle(e){this._updateLayoutOfSelectionControl(e),this._updateControlCoord()}updateRange(e,t){this._selectionRenderModel.setValue(e,t),this._showAutoFill=t!==null,this._updateLayoutOfSelectionControl(),this._updateControlCoord()}updateRangeBySelectionWithCoord(e,t){t&&(this._rowHeaderWidth=t.rowHeaderWidth,this._columnHeaderHeight=t.columnHeaderHeight),this._selectionRenderModel.setValue(e.rangeWithCoord,e.primaryWithCoord),this._showAutoFill=e.primaryWithCoord!==null,this._updateLayoutOfSelectionControl(e.style),this._updateControlCoord()}update(e,t=0,r=0,o,s){this._rowHeaderWidth=t,this._columnHeaderHeight=r,this.updateRangeBySelectionWithCoord({rangeWithCoord:e,primaryWithCoord:s,style:o}),o&&this.updateStyle(o)}updateCurrCell(e){this._showAutoFill=e!==null,this._selectionRenderModel.setCurrentCell(e)}clearHighlight(){this._showAutoFill=!1,this._selectionRenderModel.clearCurrentCell(),this._updateLayoutOfSelectionControl(this._currentStyle)}getScene(){return this._scene}dispose(){var e,t,r,o,s,l,c,d,u,h,g,S,f,p,v,C,b,R,E,P,y,M,x,A,k;(e=this._leftBorder)==null||e.dispose(),(t=this._rightBorder)==null||t.dispose(),(r=this._topBorder)==null||r.dispose(),(o=this._bottomBorder)==null||o.dispose(),(s=this._backgroundControlTop)==null||s.dispose(),(l=this._backgroundControlMiddleLeft)==null||l.dispose(),(c=this._backgroundControlMiddleRight)==null||c.dispose(),(d=this._backgroundControlBottom)==null||d.dispose(),this._autoFillControl.dispose(),(u=this._selectionShapeGroup)==null||u.dispose(),(h=this._rowHeaderBackground)==null||h.dispose(),(g=this._rowHeaderBorder)==null||g.dispose(),(S=this._rowHeaderGroup)==null||S.dispose(),(f=this._rowHeaderBackground)==null||f.dispose(),(p=this._columnHeaderBackground)==null||p.dispose(),(v=this._columnHeaderBorder)==null||v.dispose(),(C=this._columnHeaderGroup)==null||C.dispose(),(b=this._topLeftWidget)==null||b.dispose(),(R=this._topCenterWidget)==null||R.dispose(),(E=this._topRightWidget)==null||E.dispose(),(P=this._middleLeftWidget)==null||P.dispose(),(y=this._middleRightWidget)==null||y.dispose(),(M=this._bottomLeftWidget)==null||M.dispose(),(x=this._bottomCenterWidget)==null||x.dispose(),(A=this._bottomRightWidget)==null||A.dispose(),(k=this._controlExtension)==null||k.dispose(),super.dispose(),this._dispose$.next(this),this._dispose$.complete()}getCurrentCellInfo(){const e=this.model.currentCell;if(e){let t;if(e.isMerged){const r=e.mergeInfo;t={startRow:r.startRow,endRow:r.endRow,startColumn:r.startColumn,endColumn:r.endColumn,startX:r.startX,endX:r.endX,startY:r.startY,endY:r.endY}}else{const{actualRow:r,actualColumn:o,startX:s,endX:l,startY:c,endY:d}=e;t={startRow:r,endRow:r,startColumn:o,endColumn:o,startX:s,endX:l,startY:c,endY:d}}return t}}getValue(){return{...this._selectionRenderModel.getValue(),style:this._currentStyle}}getRange(){return this._selectionRenderModel.getValue().rangeWithCoord}enableHelperSelection(){this._isHelperSelection=!0}disableHelperSelection(){this._isHelperSelection=!1}_updateHeaderBackground(e){const{startX:t,startY:r,endX:o,endY:s,rangeType:l}=this._selectionRenderModel,c=this._currentStyle,d=this._getScale(),{stroke:u,rowHeaderFill:h=c.rowHeaderFill,rowHeaderStroke:g=c.rowHeaderStroke,columnHeaderFill:S=c.columnHeaderFill,columnHeaderStroke:f=c.columnHeaderStroke}=e;let{rowHeaderStrokeWidth:p=c.rowHeaderStrokeWidth,columnHeaderStrokeWidth:v=c.columnHeaderStrokeWidth}=e;p/=d,v/=d;const C=this._rowHeaderWidth,b=this._columnHeaderHeight;if(this._highlightHeader&&b>0){let R=S;l===a.RANGE_TYPE.COLUMN&&(R=new a.ColorKit(u).setAlpha(xs).toString()),this._columnHeaderBackground.setProps({fill:R}),this._columnHeaderBackground.resize(o-t,b),this._columnHeaderBorder.setProps({fill:f}),this._columnHeaderBorder.transformByState({width:o-t,height:v,top:b-v+1/d}),this._columnHeaderGroup.show(),this._columnHeaderGroup.translate(t,0)}else this._columnHeaderGroup.hide();if(this._columnHeaderGroup.makeDirty(!0),this._highlightHeader&&C>0){let R=h;l===a.RANGE_TYPE.ROW&&(R=new a.ColorKit(u).setAlpha(xs).toString()),this._rowHeaderBackground.setProps({fill:R}),this._rowHeaderBackground.resize(C,s-r),this._rowHeaderBorder.setProps({fill:g}),this._rowHeaderBorder.transformByState({width:p,height:s-r,left:C-p+1/d}),this._rowHeaderGroup.show(),this._rowHeaderGroup.translate(0,r)}else this._rowHeaderGroup.hide();this._rowHeaderGroup.makeDirty(!0)}_updateBackgroundControl(e){const{startX:t,startY:r,endX:o,endY:s}=this._selectionRenderModel,l=this._getScale(),{fill:c=e.fill}=e;let{strokeWidth:d}=e;d/=l;const u=this._selectionRenderModel.highlightToSelection();if(!u){this._backgroundControlTop.resize(o-t,s-r),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:g,endX:S,endY:f}=u,p=d/2,v={left:-p,top:-p,width:o-t+p*2,height:g-r+p};v.height<0&&(v.width=0,v.height=0),this._backgroundControlTop.transformByState(v);const C={left:-p,top:g-r,width:h-t+p,height:f-g};C.width<0&&(C.width=0,C.height=0),this._backgroundControlMiddleLeft.transformByState(C);const b={left:S-t-p,top:g-r,width:o-S+p*2,height:f-g};b.width<0&&(b.width=0,b.height=0),this._backgroundControlMiddleRight.transformByState(b);const R={left:-p,top:f-r,width:o-t+p*2,height:s-f+p};R.height<0&&(R.width=0,R.height=0),this._backgroundControlBottom.transformByState(R),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:r,endX:o,endY:s}=this._selectionRenderModel,{stroke:l=e.stroke,widgets:c=e.widgets,widgetStroke:d=e.widgetStroke}=e,u=this._getScale();let{widgetSize:h,widgetStrokeWidth:g}=e;h/=u,g/=u;const S={left:-h/2+g/2,center:(o-t)/2-h/2+g/2,right:o-t-h/2+g/2,top:-h/2,middle:(s-r)/2-h/2,bottom:s-r-h/2+g/2},f=h-g;this._widgetRects.forEach(p=>{p.setProps({fill:l,stroke:d})}),c.tl===!0?(this._topLeftWidget.transformByState({height:f,width:f,left:S.left,top:S.top,strokeWidth:g}),this._topLeftWidget.show()):this._topLeftWidget.hide(),c.tc===!0?(this._topCenterWidget.transformByState({height:f,width:f,left:S.center,top:S.top,strokeWidth:g}),this._topCenterWidget.show()):this._topCenterWidget.hide(),c.tr===!0?(this._topRightWidget.transformByState({height:f,width:f,left:S.right,top:S.top,strokeWidth:g}),this._topRightWidget.show()):this._topRightWidget.hide(),c.ml===!0?(this._middleLeftWidget.transformByState({height:f,width:f,left:S.left,top:S.middle,strokeWidth:g}),this._middleLeftWidget.show()):this._middleLeftWidget.hide(),c.mr===!0?(this._middleRightWidget.transformByState({height:f,width:f,left:S.right,top:S.middle,strokeWidth:g}),this._middleRightWidget.show()):this._middleRightWidget.hide(),c.bl===!0?(this._bottomLeftWidget.transformByState({height:f,width:f,left:S.left,top:S.bottom,strokeWidth:g}),this._bottomLeftWidget.show()):this._bottomLeftWidget.hide(),c.bc===!0?(this._bottomCenterWidget.transformByState({height:f,width:f,left:S.center,top:S.bottom,strokeWidth:g}),this._bottomCenterWidget.show()):this._bottomCenterWidget.hide(),c.br===!0?(this._bottomRightWidget.transformByState({height:f,width:f,left:S.right,top:S.bottom,strokeWidth:g}),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 r of t)if(e[r]===!0)return!0;return!1}_getScale(){const{scaleX:e,scaleY:t}=this._scene.getAncestorScale();return Math.max(e,t)}_stopAntLineAnimation(){this._antLineOffset=0,T.cancelRequestFrame(this._antRequestNewFrame)}_startAntLineAnimation(){const e=this._getScale();this._antLineOffset+=.6/e,this._antLineOffset>160/e&&(this._antLineOffset=0),this.dashedRect.setProps({strokeDashOffset:-this._antLineOffset}),this._antRequestNewFrame=T.requestNewFrame(()=>{this._startAntLineAnimation()})}}class od extends T.Layer{render(i,e=!1){const t=a.Tools.now();return super.render(i,e),this._afterRender(t),this}_afterRender(i){this.scene.getEngine().renderFrameTimeMetric$.next(["selectionLayer",a.Tools.now()-i])}}const pe=a.createIdentifier("univer.sheet.selection-render-service");class Ko extends a.Disposable{constructor(e,t,r,o,s){super();w(this,"_downObserver");w(this,"_scenePointerMoveSub");w(this,"_scenePointerUpSub");w(this,"_controlFillConfig$",new O.BehaviorSubject(null));w(this,"controlFillConfig$",this._controlFillConfig$.asObservable());w(this,"_selectionControls",[]);w(this,"_startRangeWhenPointerDown",{startY:0,endY:0,startX:0,endX:0,startRow:-1,endRow:-1,startColumn:-1,endColumn:-1});w(this,"_activeControlIndex",-1);w(this,"_startViewportPosX",0);w(this,"_startViewportPosY",0);w(this,"_scrollTimer");w(this,"_cancelDownSubscription");w(this,"_cancelUpSubscription");w(this,"_skeleton");w(this,"_scene");w(this,"_highlightHeader",!0);w(this,"_rangeType",a.RANGE_TYPE.NORMAL);w(this,"_selectionStyle");w(this,"_remainLastEnabled",!1);w(this,"_skipLastEnabled",!1);w(this,"_singleSelectionEnabled",!1);w(this,"_selectionMoveEnd$",new O.BehaviorSubject([]));w(this,"selectionMoveEnd$",this._selectionMoveEnd$.asObservable());w(this,"_selectionMoving$",new O.Subject);w(this,"selectionMoving$",this._selectionMoving$.asObservable());w(this,"_selectionMoveStart$",new O.Subject);w(this,"selectionMoveStart$",this._selectionMoveStart$.asObservable());w(this,"_selectionMoving",!1);w(this,"_selectionTheme");w(this,"_activeViewport");w(this,"interceptor",new a.InterceptorManager({RANGE_MOVE_PERMISSION_CHECK:Io,RANGE_FILL_PERMISSION_CHECK:bo}));w(this,"_escapeShortcutDisposable",null);this._injector=e,this._themeService=t,this._shortcutService=r,this._sheetSkeletonManagerService=o,this.contextService=s,this._initSelectionThemeFromThemeService(),this._initMoving()}get selectionMoving(){return this._selectionMoving}get _shouldDetectMergedCells(){return this._rangeType===a.RANGE_TYPE.NORMAL}_initMoving(){this.disposeWithMe(this._selectionMoving$.subscribe(()=>{this._selectionMoving=!0})),this.disposeWithMe(this._selectionMoveEnd$.subscribe(()=>{this._selectionMoving=!1}))}_setSelectionStyle(e){this._selectionStyle=e}getViewPort(){return this._activeViewport}setSingleSelectionEnabled(e=!1){this._singleSelectionEnabled=e}newSelectionControl(e,t,r){const o=this.getSelectionControls().length,{rowHeaderWidth:s,columnHeaderHeight:l}=t,c=new nr(e,o,this._selectionTheme,{highlightHeader:this._highlightHeader,rowHeaderWidth:s,columnHeaderHeight:l});this._selectionControls.push(c);const d=we(r,t);return c.updateRangeBySelectionWithCoord(d,t),c.setControlExtension({skeleton:t,scene:e,themeService:this._selectionTheme,injector:this._injector,selectionHooks:{selectionMoveEnd:()=>{this._selectionMoveEnd$.next(this.getSelectionDataWithStyle())}}}),c}resetSelectionsByModelData(e){const t=this.getSelectionControls(),r=this._skeleton;if(!(!t||!r)){for(let o=0,s=e.length;o<s;o++){const l=e[o],c=we(l,this._skeleton),d=t[o];d?d.updateRangeBySelectionWithCoord(c,r):this.isSelectionEnabled()&&this.newSelectionControl(this._scene,r,l)}e.length<t.length&&t.splice(e.length).forEach(s=>s.dispose())}}refreshSelectionMoveStart(){this._selectionMoveStart$.next(this.getSelectionDataWithStyle())}refreshSelectionMoveEnd(){this._selectionMoveEnd$.next(this.getSelectionDataWithStyle())}_initSelectionThemeFromThemeService(){const e=this._themeService.getCurrentTheme();this._selectionTheme=new a.ThemeService,this._selectionTheme.setTheme(e)}setSelectionTheme(e){this._selectionTheme.setTheme(e)}_changeRuntime(e,t,r){this._skeleton=e,this._scene=t,this._activeViewport=r||(t==null?void 0:t.getViewports()[0]),t.findLayerByZIndex(zr)||t.addLayer(new od(t,[],zr))}getSkeleton(){return this._skeleton}getSelectionDataWithStyle(){const e=this._selectionControls,[t,r]=this._skeleton.getLocation();return e.map(o=>{const s=o.getValue();return s.rangeWithCoord.sheetId=r,s.rangeWithCoord.unitId=t,s})}getSelectionControls(){return this._selectionControls}_addSelectionControlByModelData(e){var l;const t=this._skeleton,r=(l=e.style)!=null?l:mt(this._selectionTheme),o=this._scene;return e.style=r,this.newSelectionControl(o,t,e)}_clearAllSelectionControls(){const e=this._selectionControls;for(const t of e)t.dispose();this._selectionControls.length=0}_getFreeze(){var t;return(t=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:t.skeleton.getWorksheetConfig().freeze}_getViewportByCell(e,t){if(e===void 0||t===void 0)return null;const r=this._getFreeze();if(!r||r.startRow<=0&&r.startColumn<=0)return this._scene.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN);if(e>r.startRow&&t>r.startColumn)return this._scene.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN);if(e<=r.startRow&&t<=r.startColumn)return this._scene.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP);if(e<=r.startRow&&t>r.startColumn)return this._scene.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN_TOP);if(e>r.startRow&&t<=r.startColumn)return this._scene.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT)}getActiveRange(){const e=this.getSelectionControls(),t=e&&e[e.length-1].model;return t&&{startRow:t.startRow,startColumn:t.startColumn,endRow:t.endRow,endColumn:t.endColumn}}setActiveSelectionIndex(e){this._activeControlIndex=e}resetActiveSelectionIndex(){this._activeControlIndex=-1}getActiveSelectionControl(){const e=this.getSelectionControls();if(e)return this._activeControlIndex<0?e[e.length-1]:e[this._activeControlIndex]}endSelection(){var e;this._clearUpdatingListeners(),this._selectionMoveEnd$.next(this.getSelectionDataWithStyle()),(e=this._escapeShortcutDisposable)==null||e.dispose(),this._escapeShortcutDisposable=null}_reset(){var e;this._clearAllSelectionControls(),(e=this._downObserver)==null||e.unsubscribe(),this._downObserver=null}_setupPointerMoveListener(e,t,r,o=T.ScrollTimerType.ALL,s,l){var f,p;let c=0,d=0,u=s,h=l;this._scrollTimer=T.ScrollTimer.create(this._scene,o),this._scrollTimer.startScroll((f=e==null?void 0:e.left)!=null?f:0,(p=e==null?void 0:e.top)!=null?p:0,e);const g=this._scene,S=g.getActiveViewportByCoord(T.Vector2.FromArray([s,l]));this._scenePointerMoveSub=g.onPointerMove$.subscribeEvent(v=>{var N,W,V,U,L,j,B,F,X;const{offsetX:C,offsetY:b}=v,{x:R,y:E}=g.getCoordRelativeToViewport(T.Vector2.FromArray([C,b]));this._movingHandler(R,E,t,r);let P=R,y=E;const M=this.getActiveSelectionControl(),x=this._getFreeze(),A=M==null?void 0:M.model,k=(N=g.getActiveViewportByCoord(T.Vector2.FromArray([C,b])))!=null?N:this._getViewportByCell(A==null?void 0:A.endRow,A==null?void 0:A.endColumn);if((()=>{if(!S||!k||!e)return!1;const K=[T.SHEET_VIEWPORT_KEY.VIEW_MAIN,T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP,T.SHEET_VIEWPORT_KEY.VIEW_MAIN_TOP,T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT];return K.includes(S.viewportKey)&&K.includes(k.viewportKey)})()){if(!S||!k||!e)return!1;const K=u<e.left&&R>e.left||u>e.left&&R<e.left,te=h<e.top&&E>e.top||h>e.top&&E<e.top;K&&(c+=1),te&&(d+=1);const Q=S.viewportKey,se=k.viewportKey;if(Q===T.SHEET_VIEWPORT_KEY.VIEW_ROW_TOP)b<e.top&&((W=A==null?void 0:A.endRow)!=null?W:0)<((V=x==null?void 0:x.startRow)!=null?V:0)?y=e.top:te&&d%2===1&&e.scrollToViewportPos({viewportScrollY:0});else if(Q===T.SHEET_VIEWPORT_KEY.VIEW_COLUMN_LEFT)C<e.left&&((U=A==null?void 0:A.endColumn)!=null?U:0)<((L=x==null?void 0:x.startColumn)!=null?L:0)?P=e.left:K&&c%2===1&&e.scrollToViewportPos({viewportScrollX:0});else if(Q===se){let G=!1,Y=!1;Q===T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP?(G=!0,Y=!0):Q===T.SHEET_VIEWPORT_KEY.VIEW_MAIN_TOP?Y=!0:Q===T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT&&(G=!0),((j=A==null?void 0:A.endRow)!=null?j:0)>((B=x==null?void 0:x.startRow)!=null?B:0)&&(Y=!1),((F=A==null?void 0:A.endColumn)!=null?F:0)>((X=x==null?void 0:x.startColumn)!=null?X:0)&&(G=!1),G&&(P=e.left),Y&&(y=e.top)}else{const G={x:S.scrollX,y:S.scrollY},Y={x:k.scrollX,y:k.scrollY},q=G.x!==Y.x&&K&&c%2===1,ne=G.y!==Y.y&&te&&d%2===1;(q||ne)&&(e.scrollToBarPos({x:q?G.x:void 0,y:ne?G.y:void 0}),q||(P=e.left),ne||(y=e.top)),(Q===T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP&&se===T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT||se===T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP&&Q===T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT)&&(P=e.left),(Q===T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP&&se===T.SHEET_VIEWPORT_KEY.VIEW_MAIN_TOP||se===T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP&&Q===T.SHEET_VIEWPORT_KEY.VIEW_MAIN_TOP)&&(y=e.top)}u=R,h=E}this._scrollTimer.scrolling(P,y,()=>{this._movingHandler(R,E,t,r)})})}attachSelectionWithCoord(e){return we(e,this._skeleton)}attachPrimaryWithCoord(e){return Gn(this._skeleton,e)}getSelectionCellByPosition(e,t){return this.getCellWithCoordByOffset(e,t)}getCellWithCoordByOffset(e,t,r){const o=this._scene,s=r!=null?r:this._skeleton,l=o.getViewportScrollXY(o.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN)),{scaleX:c,scaleY:d}=o.getAncestorScale();return s.getCellWithCoordByOffset(e,t,c,d,l)}_movingHandler(e,t,r,o){var P,y,M,x,A;const s=this._skeleton,l=this._scene,[c,d]=s.getLocation(),u={startRow:(P=r==null?void 0:r.model.startRow)!=null?P:-1,endRow:(y=r==null?void 0:r.model.endRow)!=null?y:-1,startColumn:(M=r==null?void 0:r.model.startColumn)!=null?M:-1,endColumn:(x=r==null?void 0:r.model.endColumn)!=null?x:-1},h=l.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN),g=(A=this._getViewportByCell(u.endRow,u.endColumn))!=null?A:h,S=l.getScrollXYInfoByViewport(T.Vector2.FromArray([this._startViewportPosX,this._startViewportPosY]),g),{scaleX:f,scaleY:p}=l.getAncestorScale();o===a.RANGE_TYPE.ROW?e=Number.POSITIVE_INFINITY:o===a.RANGE_TYPE.COLUMN&&(t=Number.POSITIVE_INFINITY);const v=this._skeleton.getCellByOffset(e,t,f,p,S);if(!v)return;let C={startRow:Math.min(v.startRow,this._startRangeWhenPointerDown.startRow),startColumn:Math.min(v.startColumn,this._startRangeWhenPointerDown.startColumn),endRow:Math.max(v.endRow,this._startRangeWhenPointerDown.endRow),endColumn:Math.max(v.endColumn,this._startRangeWhenPointerDown.endColumn)};this._shouldDetectMergedCells&&(C=s.expandRangeByMerge(C));const R=we({range:C,primary:void 0,style:null},s);R.rangeWithCoord.unitId=c,R.rangeWithCoord.sheetId=d,R.rangeWithCoord.rangeType=o;const E=u.startRow!==C.startRow||u.startColumn!==C.startColumn||u.endRow!==C.endRow||u.endColumn!==C.endColumn;r!=null&&E&&(r.updateRangeBySelectionWithCoord(R),this._selectionMoving$.next(this.getSelectionDataWithStyle()))}_clearUpdatingListeners(){var t,r,o,s,l;this._scene.enableObjectsEvent(),(t=this._scenePointerMoveSub)==null||t.unsubscribe(),this._scenePointerMoveSub=null,(r=this._scenePointerUpSub)==null||r.unsubscribe(),this._scenePointerUpSub=null,(o=this._cancelDownSubscription)==null||o.unsubscribe(),this._cancelDownSubscription=null,(s=this._cancelUpSubscription)==null||s.unsubscribe(),this._cancelUpSubscription=null,(l=this._scrollTimer)==null||l.dispose()}_addEndingListeners(){var r,o,s;const e=this._scene,t=(r=e.getEngine())==null?void 0:r.activeScene;!t||t===e||((o=this._cancelDownSubscription)==null||o.unsubscribe(),this._cancelDownSubscription=null,(s=this._cancelUpSubscription)==null||s.unsubscribe(),this._cancelUpSubscription=null,this._cancelDownSubscription=t.onPointerDown$.subscribeEvent(()=>this._clearUpdatingListeners()),this._cancelUpSubscription=t.onPointerUp$.subscribeEvent(()=>this._clearUpdatingListeners()))}_getSelectionWithCoordByOffset(e,t,r,o,s){const l=this._skeleton;if(l==null)return null;if(this._shouldDetectMergedCells){const C=l==null?void 0:l.getCellWithCoordByOffset(e,t,r,o,s,{firstMatch:!0});if(!C)return;const b=a.convertCellToRange(C);return{primaryWithCoord:C,rangeWithCoord:b}}const{row:c,column:d}=l.getCellIndexByOffset(e,t,r,o,s),u=l.getNoMergeCellWithCoordByIndex(c,d),{startX:h,startY:g,endX:S,endY:f}=u,p={startY:g,endY:f,startX:h,endX:S,startRow:c,endRow:c,startColumn:d,endColumn:d};return{primaryWithCoord:{mergeInfo:p,actualRow:c,actualColumn:d,isMerged:!1,isMergedMainCell:!1,startY:g,endY:f,startX:h,endX:S},rangeWithCoord:p}}_checkClearPreviousControls(e){this.getSelectionControls().length!==0&&(!e.ctrlKey&&!e.shiftKey&&!this._remainLastEnabled||this._singleSelectionEnabled&&!e.shiftKey)&&this._clearAllSelectionControls()}_makeSelectionByTwoCells(e,t,r,o,s){const{actualRow:l,actualColumn:c,mergeInfo:d}=e;this._startRangeWhenPointerDown={...e.mergeInfo};const u=Math.min(l,t.startRow,d.startRow),h=Math.max(l,t.endRow,d.endRow),g=Math.min(c,t.startColumn,d.startColumn),S=Math.max(c,t.endColumn,d.endColumn),p={range:r.expandRangeByMerge({startRow:u,startColumn:g,endRow:h,endColumn:S}),primary:null,style:null},v=we(p,r);s.updateRangeBySelectionWithCoord(v)}isSelectionEnabled(){return this.contextService.getContextValue(m.SELECTIONS_ENABLED)}isSelectionDisabled(){return this.contextService.getContextValue(m.SELECTIONS_ENABLED)===!1}inRefSelectionMode(){return this.contextService.getContextValue(m.REF_SELECTIONS_ENABLED)}}function qo(n){return{range:{startRow:0,startColumn:0,endRow:n.getRowCount()-1,endColumn:n.getColumnCount()-1,rangeType:a.RANGE_TYPE.ALL},primary:Ri(n).primary,style:null}}function Ri(n){return Ma(n,{startRow:0,startColumn:0,endRow:0,endColumn:0})}function Ma(n,i){const e=n.worksheet.getCellInfoInMergeData(i.startRow,i.startColumn),t=n.worksheet.getCellInfoInMergeData(i.endRow,i.endColumn);return{range:{startRow:e.startRow,startColumn:e.startColumn,endRow:t.endRow,endColumn:t.endColumn,rangeType:a.RANGE_TYPE.NORMAL},primary:{actualRow:e.startRow,actualColumn:e.startColumn,startRow:e.startRow,startColumn:e.startColumn,endRow:e.endRow,endColumn:e.endColumn,isMerged:e.isMerged,isMergedMainCell:e.isMergedMainCell},style:null}}var sd=Object.getOwnPropertyDescriptor,ad=(n,i,e,t)=>{for(var r=t>1?void 0:t?sd(i,e):i,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=s(r)||r);return r},Os=(n,i)=>(e,t)=>i(e,t,n);exports.SheetSkeletonManagerService=class extends a.Disposable{constructor(e,t,r){super();w(this,"_sheetId","");w(this,"_sheetSkeletonParamStore",new Map);w(this,"_currentSkeleton$",new O.BehaviorSubject(null));w(this,"currentSkeleton$",this._currentSkeleton$.asObservable());w(this,"_currentSkeletonBefore$",new O.BehaviorSubject(null));w(this,"currentSkeletonBefore$",this._currentSkeletonBefore$.asObservable());this._context=e,this._injector=t,this._sheetSkService=r,this.disposeWithMe(()=>{this._currentSkeletonBefore$.complete(),this._currentSkeleton$.complete(),this._sheetSkeletonParamStore.forEach(o=>this.disposeSkeleton(o.sheetId)),this._sheetSkeletonParamStore.clear()}),this._initRemoveSheet()}_initRemoveSheet(){this.disposeWithMe(this._context.unit.sheetDisposed$.subscribe(e=>{this.disposeSkeleton(e.getSheetId())}))}getCurrentSkeleton(){var e;return(e=this.getCurrentParam())==null?void 0:e.skeleton}getCurrent(){return this.getCurrentParam()}getCurrentParam(){return this._getSkeletonParam(this._sheetId)}getSkeleton(e){return this._getSkeleton(e)}getSkeletonParam(e){return this._getSkeletonParam(e)}getWorksheetSkeleton(e){return this.getSkeletonParam(e)}getUnitSkeleton(e,t){const r=this._getSkeletonParam(t);return r!=null&&(r.unitId=e),r}setCurrent(e){this._setCurrent(e.sheetId)}setSkeletonParam(e,t){this._sheetSkService.setSkeleton(t.unitId,e,t.skeleton),this._sheetSkeletonParamStore.set(e,t)}_setCurrent(e){this._sheetId=e;const t=this._getSkeletonParam(e),r=this._context.unitId;if(t!=null)this.reCalculate(t);else{const l=this._context.unit.getSheetBySheetId(e);if(l==null)return;const c=this._context.scene,d=this._buildSkeleton(l,c);this.setSkeletonParam(e,{unitId:r,sheetId:e,skeleton:d,dirty:!1})}const o=this._getSkeletonParam(e);this._currentSkeletonBefore$.next(o),this._currentSkeleton$.next(o)}reCalculate(e){e||(e=this.getCurrentParam()),e!=null&&(e.dirty&&(e.skeleton.makeDirty(!0),e.dirty=!1),e.skeleton.calculate())}makeDirty(e,t=!0){const r=this._getSkeletonParam(e.sheetId);r!=null&&(r.dirty=t)}getOrCreateSkeleton(e){return this.ensureSkeleton(e.sheetId)}ensureSkeleton(e){const t=this._getSkeletonParam(e);if(t)return t.skeleton;const o=this._context.unit.getSheetBySheetId(e);if(!o)return;const s=this._buildSkeleton(o);return this.setSkeletonParam(e,{unitId:this._context.unitId,sheetId:e,skeleton:s,dirty:!1}),s}disposeSkeleton(e){const t=this.getSkeletonParam(e);t&&(t.skeleton.dispose(),this._sheetSkeletonParamStore.delete(e),this._sheetSkService.deleteSkeleton(t.unitId,e))}attachRangeWithCoord(e){const t=this.getCurrentSkeleton();return t?cn(t,e):null}_getSkeletonParam(e){return this._sheetSkeletonParamStore.get(e)}_getSkeleton(e){const t=this._getSkeletonParam(e);return t?t.skeleton:null}_buildSkeleton(e,t){return this._injector.createInstance(T.SpreadsheetSkeleton,e,this._context.unit.getStyles())}setColumnHeaderSize(e,t,r){var u;if(!e)return;const o=(u=this.getWorksheetSkeleton(t))==null?void 0:u.skeleton;if(!o)return;o.columnHeaderHeight=r,e.scene.getViewports()[0].top=r,e.scene.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_COLUMN_RIGHT).setViewportSize({height:r}),e.scene.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_COLUMN_LEFT).setViewportSize({height:r}),e.scene.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_ROW_BOTTOM).setViewportSize({top:r}),e.scene.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_ROW_TOP).setViewportSize({top:r}),e.scene.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_LEFT_TOP).setViewportSize({height:r});const s=e==null?void 0:e.with(m.SheetsSelectionsService),l=e==null?void 0:e.with(pe),c=s.getCurrentSelections();l.resetSelectionsByModelData(c);const d=this.getUnitSkeleton(e.unitId,t);d&&(d.commandId=bi.id,this._currentSkeleton$.next(d))}setRowHeaderSize(e,t,r){var f;const o=(f=this.getWorksheetSkeleton(t))==null?void 0:f.skeleton;if(!e||!o)return;o.rowHeaderWidth=r;const s=e.scene.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_LEFT_TOP).width||46,l=r-s,c=e.scene.getViewports()[0].left;e.scene.getViewports()[0].left=c+l,e.scene.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_ROW_BOTTOM).setViewportSize({width:r}),e.scene.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_ROW_TOP).setViewportSize({width:r}),e.scene.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_COLUMN_LEFT).setViewportSize({left:r});const d=e.scene.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_COLUMN_RIGHT).left||0;e.scene.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_COLUMN_RIGHT).setViewportSize({left:d+l}),e.scene.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_LEFT_TOP).setViewportSize({width:r});const u=e==null?void 0:e.with(m.SheetsSelectionsService),h=e==null?void 0:e.with(pe),g=u.getCurrentSelections();h.resetSelectionsByModelData(g);const S=this.getCurrent();S&&(S.commandId=Ii.id,this._currentSkeleton$.next(S))}};exports.SheetSkeletonManagerService=ad([Os(1,a.Inject(a.Injector)),Os(2,a.Inject(m.SheetSkeletonService))],exports.SheetSkeletonManagerService);function St(){const n=_.useDependency(a.IUniverInstanceService),i=_.useObservable(()=>n.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]);return i!=null?i:null}function ld(n){return _.useObservable(()=>{var e;return(e=n==null?void 0:n.activeSheet$)!=null?e:O.of(null)},void 0,void 0,[n])}function cd(){const n=_.useDependency(a.IUniverInstanceService);return _.useObservable(()=>O.merge([n.getTypeOfUnitAdded$(a.UniverInstanceType.UNIVER_SHEET),n.getTypeOfUnitDisposed$(a.UniverInstanceType.UNIVER_SHEET)]).pipe(O.map(()=>n.getAllUnitsForType(a.UniverInstanceType.UNIVER_SHEET)),O.startWith(n.getAllUnitsForType(a.UniverInstanceType.UNIVER_SHEET))),[],void 0,[n])}const dd="SheetUI";var Qo=(n=>(n.FILTER_PANEL_EMBED_POINT="filter-panel-embed-point",n.SHEETS_FOOTER="sheets-footer",n.FORMULA_AUX="formula-aux",n))(Qo||{});const xe="sheets-ui.config",Eo={formulaBar:!0,statusBarStatistic:!0,maxAutoHeightCount:1e3};var ud=Object.getOwnPropertyDescriptor,hd=(n,i,e,t)=>{for(var r=t>1?void 0:t?ud(i,e):i,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=s(r)||r);return r},xn=(n,i)=>(e,t)=>i(e,t,n);const Jo=["ff","fs","tr","tb"];exports.AutoHeightController=class extends a.Disposable{constructor(i,e,t,r,o){super(),this._renderManagerService=i,this._sheetInterceptorService=e,this._selectionManagerService=t,this._univerInstanceService=r,this._configService=o,this._initialize()}_getRangesScope(i){let e,t;for(const{startRow:r,endRow:o}of i)e=e===void 0?r:Math.min(e,r),t=t===void 0?o:Math.max(t,o);return t-e+1}getUndoRedoParamsOfAutoHeight(i,e){var b;const{_univerInstanceService:t,_configService:r}=this,o=t.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),s=o.getUnitId();let l=o.getActiveSheet(),c=l.getSheetId();if(e){const R=m.getSheetCommandTarget(t,{unitId:s,subUnitId:e});R&&(l=R.worksheet,c=l.getSheetId())}const u=this._renderManagerService.getRenderById(s).with(exports.SheetSkeletonManagerService).ensureSkeleton(c);if(!u)return{redos:[],undos:[]};const h=r.getConfig(xe);let g=i;Array.isArray(i)||(i&&i.startRow!==void 0&&i.startRow!==void 0?g=[i]:g=[]);const S=this._getRangesScope(g);if(((b=h==null?void 0:h.maxAutoHeightCount)!=null?b:1e3)<S)return{redos:[],undos:[]};const p=u.calculateAutoHeightInRange(i),v={subUnitId:c,unitId:s,rowsAutoHeightInfo:p},C=m.SetWorksheetRowAutoHeightMutationFactory(v,l);return{undos:[{id:m.SetWorksheetRowAutoHeightMutation.id,params:C}],redos:[{id:m.SetWorksheetRowAutoHeightMutation.id,params:v}]}}_initialize(){const{_sheetInterceptorService:i,_selectionManagerService:e}=this;this.disposeWithMe(i.interceptCommand({getMutations:t=>{if(t.id===m.SetRangeValuesCommand.id){const r=t.params;return this.getUndoRedoParamsOfAutoHeight(r.range,r.subUnitId)}return{redos:[],undos:[]}}})),this.disposeWithMe(i.interceptCommand({getMutations:t=>t.id!==m.SetWorksheetRowIsAutoHeightCommand.id?{redos:[],undos:[]}:this.getUndoRedoParamsOfAutoHeight(t.params.ranges,t.params.subUnitId)})),this.disposeWithMe(i.interceptCommand({getMutations:t=>{var o,s;if(t.id!==m.SetStyleCommand.id)return{redos:[],undos:[]};if(!Jo.includes((o=t.params)==null?void 0:o.style.type))return{redos:[],undos:[]};const r=(s=e.getCurrentSelections())==null?void 0:s.map(l=>l.range);return r!=null&&r.length?this.getUndoRedoParamsOfAutoHeight(r,t.params.subUnitId):{redos:[],undos:[]}}})),this.disposeWithMe(i.interceptAfterCommand({getMutations:t=>{if(t.id===m.MoveRangeCommand.id){const r=t.params;return this.getUndoRedoParamsOfAutoHeight([r.fromRange,r.toRange])}if(t.id===m.ReorderRangeCommand.id){const r=t.params;return this.getUndoRedoParamsOfAutoHeight([r.range])}return{redos:[],undos:[]}}}))}};exports.AutoHeightController=hd([xn(0,T.IRenderManagerService),xn(1,a.Inject(m.SheetInterceptorService)),xn(2,a.Inject(m.SheetsSelectionsService)),xn(3,a.Inject(a.IUniverInstanceService)),xn(4,a.IConfigService)],exports.AutoHeightController);function gt(n){const{rows:i,cols:e}=n;return{startRow:i[0],endRow:i[i.length-1],startColumn:e[0],endColumn:e[e.length-1]}}function Wt(n){let i=[],e=[];const t=[];return n.forEach(r=>{i=i.concat(r.rows),e=e.concat(r.cols)}),i=Array.from(new Set(i)).sort((r,o)=>r-o),e=Array.from(new Set(e)).sort((r,o)=>r-o),n.forEach(r=>{t.push({startRow:i.findIndex(o=>o===r.rows[0]),endRow:i.findIndex(o=>o===r.rows[r.rows.length-1]),startColumn:e.findIndex(o=>o===r.cols[0]),endColumn:e.findIndex(o=>o===r.cols[r.cols.length-1])})}),{ranges:t,mapFunc:(r,o)=>({row:i[r],col:e[o]})}}function md(n){const i=new a.ObjectMatrix;return n.forEach(e=>{const{rows:t,cols:r}=e;t.forEach(o=>{r.forEach(s=>{i.setValue(o,s,{v:null,p:null,f:null,si:null,custom:null})})})}),i.getData()}const wo={零:0,一:1,二:2,三:3,四:4,五:5,六:6,七:7,八:8,九:9},Xr=["零","一","二","三","四","五","六","七","八","九"],As=["","万","亿","万亿","亿亿"],gd=["","十","百","千"],Pa={十:{value:10,secUnit:!1},百:{value:100,secUnit:!1},千:{value:1e3,secUnit:!1},万:{value:1e4,secUnit:!0},亿:{value:1e8,secUnit:!0}};function rt(n){if(!n)return 0;let i=0,e=0,t=0,r=!1;const o=n.split("");for(let s=0;s<o.length;s++){const l=wo[o[s]];if(typeof l<"u")t=l,s===o.length-1&&(e+=t);else{const c=Pa[o[s]],d=c.value;r=c.secUnit,r?(e=(e+t)*d,i+=e,e=0):e+=t*d,t=0}}return i+e}function Sd(n){let i="",e="",t=0,r=!0;for(;n>0;){const o=n%10;o===0?r||(r=!0,e=Xr[o]+e):(r=!1,i=Xr[o],i+=gd[t],e=i+e),t++,n=Math.floor(n/10)}return e}function fd(n){let i=0,e="",t="",r=!1;if(n===0)return Xr[0];for(;n>0;){const o=n%1e4;r&&(t=Xr[0]+t),e=Sd(o),e+=o!==0?As[i]:As[0],t=e+t,r=o<1e3&&o>0,n=Math.floor(n/1e4),i++}return t}function pd(n){if(!n)return!1;let i=!0;if(n)if(n.length===1)n==="日"||n in wo?i=!0:i=!1;else{const e=n.split("");for(let t=0;t<e.length;t++)if(!(e[t]in wo||e[t]in Pa)){i=!1;break}}return i}function xr(n){if(!n)return{isExtendNumber:!1};const i=/0|([1-9]+[0-9]*)/g,e=i.test(n);if(e){const t=n.match(i);if(t&&t.length>0){const r=t[t.length-1],o=n.lastIndexOf(r),s=n.substr(0,o),l=n.substr(o+r.length);return{isExtendNumber:!0,matchTxt:Number(r),beforeTxt:s,afterTxt:l}}return{isExtendNumber:!1}}return{isExtendNumber:e}}function vd(n){let i;return n.length===2&&(n==="周一"||n==="周二"||n==="周三"||n==="周四"||n==="周五"||n==="周六"||n==="周日")?i=!0:i=!1,i}function Cd(n){let i;return n.length===3&&(n==="星期一"||n==="星期二"||n==="星期三"||n==="星期四"||n==="星期五"||n==="星期六"||n==="星期日")?i=!0:i=!1,i}function _d(n,i){let e=0;for(let t=0;t<n.length&&n[t]<i;t++)e++;return e}function rr(n){let i=!0;const e=n[1]-n[0];for(let t=1;t<n.length;t++)if(n[t]-n[t-1]!==e){i=!1;break}return i}function Id(n,i,e){const t=[],r=Math.floor(i/n),o=i%n;let s=0;if(r>0){for(let l=0;l<r;l++)for(let c=0;c<e.length;c++)t[e[c]+l*n]=s,s++;for(let l=0;l<e.length&&e[l]<o;l++)t[e[l]+n*r]=s,s++}else for(let l=0;l<e.length&&e[l]<o;l++)t[e[l]]=s,s++;return t}function kt(n,i){const e=[];for(let t=1;t<=i;t++){const r=(t-1)%n.length,o=a.Tools.deepClone(n[r]);Dt(o),e.push({v:null,s:null,p:null,f:null,si:null,t:null,...o})}return e}function bd(n,i){var t;const e=[];for(let r=1;r<=i;r++){const o=(r-1)%n.length,s={s:(t=n[o])==null?void 0:t.s};e.push(s)}return e}function Rd(n){let i=!0;const e=n[1]/n[0];for(let t=1;t<n.length;t++)if(n[t]/n[t-1]!==e){i=!1;break}return i}function Ed(n){const i=[];for(let e=1;e<=n;e++)i.push(e);return i}function Yr(n,i,e){var o,s,l,c;const t=[],r=[];for(let d=0;d<n.length;d++)r.push(Number((o=n[d])==null?void 0:o.v));if(n.length>2&&Rd(r))for(let d=1;d<=i;d++){const u=(d-1)%n.length,h=a.Tools.deepClone(n[u]);Dt(h);const g=Number((s=n[n.length-1])==null?void 0:s.v)*(Number((l=n[1])==null?void 0:l.v)/Number((c=n[0])==null?void 0:c.v))**d;h&&(Vs(h)&&(h.v=g),t.push(h))}else{const d=Ed(n.length);for(let u=1;u<=i;u++){const h=(u-1)%n.length,g=a.Tools.deepClone(n[h]);Dt(g);const S=e===a.Direction.DOWN||e===a.Direction.RIGHT,f=wd(n.length+u,r,d,S);g&&(Vs(g)&&(g.v=f),t.push(g))}}return t}function wd(n,i,e,t=!0){function r(h){let g=0;for(let S=0;S<h.length;S++)g+=h[S];return g/h.length}const o=r(e),s=r(i);let l=0,c=0;for(let h=0;h<e.length;h++)l+=(e[h]-o)*(i[h]-s),c+=(e[h]-o)*(e[h]-o);let d;c===0?d=t?1:-1:d=l/c;const u=s-d*o;return Math.round((u+d*n)*1e5)/1e5}function ks(n,i,e){var o;const t=[],r=/0|([1-9]+[0-9]*)/g;for(let s=1;s<=i;s++){const l=(s-1)%n.length,c=a.Tools.deepClone(n[l]);Dt(c);const d=`${(o=n[n.length-1])==null?void 0:o.v}`;if(!d)continue;const u=d==null?void 0:d.match(r),h=u==null?void 0:u[u.length-1];if(!h)continue;const g=Math.abs(Number(h)+e*s),S=d.lastIndexOf(h),f=d.substr(0,S)+g.toString()+d.substr(S+h.length);c&&(c.v=f,t.push(c))}return t}function dn(n,i,e,t=0){var l,c;const r=[["日","一","二","三","四","五","六"],["周日","周一","周二","周三","周四","周五","周六"],["星期日","星期一","星期二","星期三","星期四","星期五","星期六"]];if(t>=r.length)return[];const o=r[t],s=[];for(let d=1;d<=i;d++){const u=(d-1)%n.length,h=a.Tools.deepClone(n[u]);Dt(h);let g=0;if(((l=n[n.length-1])==null?void 0:l.v)===o[0])g=7+e*d;else{const f=`${(c=n[n.length-1])==null?void 0:c.v}`;if(f){const p=f.substr(f.length-1,1);g=rt(p)+e*d}}g<0&&(g=Math.ceil(Math.abs(g)/7)*7+g);const S=g%7;h&&(h.v=o[S],s.push(h))}return s}function Ds(n,i,e){var r;const t=[];for(let o=1;o<=i;o++){const s=(o-1)%n.length,l=a.Tools.deepClone(n[s]);Dt(l);const c=`${(r=n[n.length-1])==null?void 0:r.v}`,d=rt(c)+e*o;let u;d<=0?u="零":u=fd(d),l&&(l.v=u,t.push(l))}return t}const zn={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 Td(n){let i=!1;return Object.keys(zn).forEach(e=>{zn[e].includes(n)&&(i=!0)}),i}function ki(n){let i="";const e=[];return Object.keys(zn).forEach(t=>{zn[t].includes(n)&&(i=t,e.push(...zn[t]))}),{name:i,series:e}}function Ns(n,i,e,t){var s;const r=t.length,o=[];for(let l=1;l<=i;l++){const c=(l-1)%n.length,d=a.Tools.deepClone(n[c]);Dt(d);const u=`${(s=n[n.length-1])==null?void 0:s.v}`;let h=t.indexOf(u)+e*l;h<0&&(h+=Math.abs(e)*r);const g=h%r;d&&(d.v=t[g],o.push(d))}return o}function yd(n,i){const e=[];let t;if(i.startRow<n.startRow)t=a.Direction.UP;else if(i.endRow>n.endRow)t=a.Direction.DOWN;else if(i.startColumn<n.startColumn)t=a.Direction.LEFT;else if(i.endColumn>n.endColumn)t=a.Direction.RIGHT;else return[];if(t===a.Direction.DOWN||t===a.Direction.UP){const r=n.endRow-n.startRow+1,o=i.endRow-i.startRow+1,s=Math.floor(o/r),l=o%r,c={startRow:0,startColumn:0,endRow:n.endRow-n.startRow,endColumn:n.endColumn-n.startColumn};if(t===a.Direction.DOWN){for(let d=0;d<s;d++)e.push({repeatStartCell:{row:n.startRow+(d+1)*r,col:n.startColumn},relativeRange:c});l>0&&e.push({repeatStartCell:{row:n.startRow+(s+1)*r,col:n.startColumn},relativeRange:{startRow:0,startColumn:0,endRow:l-1,endColumn:n.endColumn-n.startColumn}})}else{for(let d=0;d<s;d++)e.push({repeatStartCell:{row:n.startRow-(d+1)*r,col:n.startColumn},relativeRange:c});l>0&&e.push({repeatStartCell:{row:n.startRow-(s+1)*r,col:n.startColumn},relativeRange:{startRow:r-l,endRow:r-1,startColumn:0,endColumn:n.endColumn-n.startColumn}})}}if(t===a.Direction.RIGHT||t===a.Direction.LEFT){const r=n.endColumn-n.startColumn+1,o=i.endColumn-i.startColumn+1,s=Math.floor(o/r),l=o%r,c={startRow:0,startColumn:0,endRow:n.endRow-n.startRow,endColumn:n.endColumn-n.startColumn};if(t===a.Direction.RIGHT){for(let d=0;d<s;d++)e.push({repeatStartCell:{row:n.startRow,col:n.startColumn+(d+1)*r},relativeRange:c});l>0&&e.push({repeatStartCell:{row:n.startRow,col:n.startColumn+(s+1)*r},relativeRange:{startRow:0,startColumn:0,endRow:n.endRow-n.startRow,endColumn:l-1}})}else{for(let d=0;d<s;d++)e.push({repeatStartCell:{row:n.startRow,col:n.startColumn-(d+1)*r},relativeRange:c});l>0&&e.push({repeatStartCell:{row:n.startRow,col:n.startColumn-(s+1)*r},relativeRange:{startRow:0,startColumn:r-l,endRow:n.endRow-n.startRow,endColumn:r-1}})}}return e}function Vs(n){return!(a.isFormulaString(n.f)||a.isFormulaId(n.si)||n.t===a.CellValueType.BOOLEAN)}function Dt(n){n&&"custom"in n&&delete n.custom}var en=(n=>(n.Append="APPEND",n.Default="DEFAULT",n.Only="ONLY",n))(en||{}),Ce=(n=>(n.NUMBER="number",n.DATE="date",n.EXTEND_NUMBER="extendNumber",n.CHN_NUMBER="chnNumber",n.CHN_WEEK2="chnWeek2",n.CHN_WEEK3="chnWeek3",n.LOOP_SERIES="loopSeries",n.FORMULA="formula",n.OTHER="other",n))(Ce||{}),le=(n=>(n.COPY="COPY",n.SERIES="SERIES",n.ONLY_FORMAT="ONLY_FORMAT",n.NO_FORMAT="NO_FORMAT",n))(le||{});const Md={type:Ce.DATE,priority:1100,match:(n,i)=>{var e;if(n!=null&&n.f||n!=null&&n.si)return!1;if((typeof(n==null?void 0:n.v)=="number"||(n==null?void 0:n.t)===a.CellValueType.NUMBER)&&n.s){if(typeof n.s=="string"){const r=i.get(a.IUniverInstanceService).getFocusedUnit().getStyles().get(n.s),o=(e=r==null?void 0:r.n)==null?void 0:e.pattern;if(o)return a.numfmt.getInfo(o).isDate}else if(n.s.n&&a.numfmt.getInfo(n.s.n.pattern).isDate)return!0}return!1},isContinue:(n,i)=>n.type===Ce.DATE,applyFunctions:{[le.SERIES]:(n,i,e)=>{const{data:t}=n;return e===a.Direction.LEFT||e===a.Direction.UP?(t.reverse(),Yr(t,i,e).reverse()):Yr(t,i,e)}}},Pd={type:Ce.NUMBER,priority:1e3,match:n=>typeof(n==null?void 0:n.v)=="number"||(n==null?void 0:n.t)===a.CellValueType.NUMBER,isContinue:(n,i)=>n.type===Ce.NUMBER,applyFunctions:{[le.SERIES]:(n,i,e)=>{const{data:t}=n;return e===a.Direction.LEFT||e===a.Direction.UP?(t.reverse(),Yr(t,i,e).reverse()):Yr(t,i,e)}}},xa={type:Ce.OTHER,priority:0,match:()=>!0,isContinue:(n,i)=>n.type===Ce.OTHER},xd={type:Ce.EXTEND_NUMBER,priority:900,match:n=>xr(`${n==null?void 0:n.v}`||"").isExtendNumber,isContinue:(n,i)=>{var e;if(n.type===Ce.EXTEND_NUMBER){const{beforeTxt:t,afterTxt:r}=xr(`${(e=n.cellData)==null?void 0:e.v}`||""),{beforeTxt:o,afterTxt:s}=xr(`${i==null?void 0:i.v}`||"");if(t===o&&r===s)return!0}return!1},applyFunctions:{[le.SERIES]:(n,i,e)=>{var l;const{data:t}=n,r=e===a.Direction.UP||e===a.Direction.LEFT;let o;if(t.length===1)return o=r?-1:1,De(ks(t,i,o),r);const s=[];for(let c=0;c<t.length;c++){const d=`${(l=t[c])==null?void 0:l.v}`;d&&s.push(Number(xr(d).matchTxt))}return r&&(t.reverse(),s.reverse()),rr(s)?(o=s[1]-s[0],De(ks(t,i,o),r)):kt(t,i)}}},Od={type:Ce.CHN_NUMBER,priority:830,match:n=>!!pd(`${n==null?void 0:n.v}`||""),isContinue:(n,i)=>n.type===Ce.CHN_NUMBER,applyFunctions:{[le.SERIES]:(n,i,e)=>{var c,d,u;const{data:t}=n,r=e===a.Direction.LEFT||e===a.Direction.UP;if(t.length===1){const h=`${(c=t[0])==null?void 0:c.v}`;let g;return r?g=-1:g=1,h&&(h==="日"||rt(h)<7)?De(dn(t,i,g),r):De(Ds(t,i,g),r)}let o=!1;for(let h=0;h<t.length;h++)if(((d=t[h])==null?void 0:d.v)==="日"){o=!0;break}const s=[];let l=0;for(let h=0;h<t.length;h++){const g=`${(u=t[h])==null?void 0:u.v}`;g==="日"?h===0?s.push(0):(l++,s.push(l*7)):o&&rt(g)>0&&rt(g)<7?s.push(rt(g)+l*7):s.push(rt(g))}if(r&&(t.reverse(),s.reverse()),rr(s)){if(o||s[s.length-1]<6&&s[0]>0||s[0]<6&&s[s.length-1]>0){const g=s[1]-s[0];return De(dn(t,i,g),r)}const h=s[1]-s[0];return De(Ds(t,i,h),r)}return kt(t,i)}}},Ad={type:Ce.CHN_WEEK2,priority:820,match:n=>!!vd(`${n==null?void 0:n.v}`||""),isContinue:(n,i)=>n.type===Ce.CHN_WEEK2,applyFunctions:{[le.SERIES]:(n,i,e)=>{var l;const{data:t}=n,r=e===a.Direction.LEFT||e===a.Direction.UP;if(t.length===1){let c;return r?c=-1:c=1,De(dn(t,i,c,1),r)}const o=[];let s=0;for(let c=0;c<t.length;c++){const d=`${(l=t[c])==null?void 0:l.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(rt(u)+s*7)}if(r&&(t.reverse(),o.reverse()),rr(o)){const c=o[1]-o[0];return De(dn(t,i,c,1),r)}return kt(t,i)}}},kd={type:Ce.CHN_WEEK3,priority:810,match:n=>Cd(`${n==null?void 0:n.v}`||""),isContinue:(n,i)=>n.type===Ce.CHN_WEEK3,applyFunctions:{[le.SERIES]:(n,i,e)=>{var l;const{data:t}=n,r=e===a.Direction.LEFT||e===a.Direction.UP;if(t.length===1){let c;return r?c=-1:c=1,De(dn(t,i,c,2),r)}const o=[];let s=0;for(let c=0;c<t.length;c++){const d=`${(l=t[c])==null?void 0:l.v}`;if(d){const u=d.substr(d.length-1,1);d==="星期日"?c===0?o.push(0):(s++,o.push(s*7)):o.push(rt(u)+s*7)}}if(r&&(t.reverse(),o.reverse()),rr(o)){const c=o[1]-o[0];return De(dn(t,i,c,2),r)}return kt(t,i)}}},Dd={type:Ce.LOOP_SERIES,priority:800,match:n=>Td(`${n==null?void 0:n.v}`||""),isContinue:(n,i)=>{var e;return n.type===Ce.LOOP_SERIES?ki(`${(e=n.cellData)==null?void 0:e.v}`||"").name===ki(`${i==null?void 0:i.v}`||"").name:!1},applyFunctions:{[le.SERIES]:(n,i,e)=>{var c,d;const{data:t}=n,r=e===a.Direction.LEFT||e===a.Direction.UP,{series:o}=ki(`${(c=t[0])==null?void 0:c.v}`||"");if(t.length===1){let u;return r?u=-1:u=1,De(Ns(t,i,u,o),r)}const s=[];let l=0;for(let u=0;u<t.length;u++){const h=`${(d=t[u])==null?void 0:d.v}`;h&&(h===o[0]?u===0?s.push(0):(l++,s.push(l*o.length)):s.push(o.indexOf(h)+l*7))}if(r&&(t.reverse(),s.reverse()),rr(s)){const u=s[1]-s[0];return De(Ns(t,i,u,o),r)}return kt(t,i)}}};function De(n,i){return i?n.reverse():n}var Nd=Object.getOwnPropertyDescriptor,Vd=(n,i,e,t)=>{for(var r=t>1?void 0:t?Nd(i,e):i,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=s(r)||r);return r},Zt=(n,i)=>(e,t)=>i(e,t,n);exports.AutoFillService=class extends a.Disposable{constructor(e,t,r,o,s,l){super();w(this,"_rules",[]);w(this,"_hooks",[]);w(this,"_applyType$",new O.BehaviorSubject(le.SERIES));w(this,"_isFillingStyle",!0);w(this,"_prevUndos",[]);w(this,"_autoFillLocation$",new O.BehaviorSubject(null));w(this,"autoFillLocation$",this._autoFillLocation$.asObservable());w(this,"_showMenu$",new O.BehaviorSubject(!1));w(this,"showMenu$",this._showMenu$.asObservable());w(this,"_direction",a.Direction.DOWN);w(this,"applyType$",this._applyType$.asObservable());w(this,"_menu$",new O.BehaviorSubject([{label:"autoFill.copy",value:le.COPY,disable:!1},{label:"autoFill.series",value:le.SERIES,disable:!1},{label:"autoFill.formatOnly",value:le.ONLY_FORMAT,disable:!1},{label:"autoFill.noFormat",value:le.NO_FORMAT,disable:!1}]));w(this,"menu$",this._menu$.asObservable());this._commandService=e,this._undoRedoService=t,this._renderManagerService=r,this._univerInstanceService=o,this._selectionManagerService=s,this._injector=l,this._init()}_init(){this._rules=[Md,Pd,xd,Od,Ad,kd,Dd,xa].sort((e,t)=>t.priority-e.priority),this._isFillingStyle=!0}_getOneByPriority(e){return e.length<=0?[]:[e.reduce((r,o)=>(o.priority||0)>(r.priority||0)?o:r,e[0])]}_initPrevUndo(){this._prevUndos=[]}async triggerAutoFill(e,t,r,o){var S;if(r.startColumn===o.startColumn&&r.startRow===o.startRow&&r.endColumn===o.endColumn&&r.endRow===o.endRow)return!1;if(o.endColumn<r.endColumn&&o.endColumn>r.startColumn)return this._commandService.executeCommand(un.id,{clearRange:{startRow:o.startRow,endRow:o.endRow,startColumn:o.endColumn+1,endColumn:r.endColumn},selectionRange:o});if(o.endRow<r.endRow&&o.endRow>r.startRow)return this._commandService.executeCommand(un.id,{clearRange:{startRow:o.endRow+1,endRow:r.endRow,startColumn:o.startColumn,endColumn:o.endColumn},selectionRange:o});const s={startRow:o.startRow,endRow:o.endRow,startColumn:o.startColumn,endColumn:o.endColumn};let l=null;if(o.startRow<r.startRow)l=a.Direction.UP,s.endRow=r.startRow-1;else if(o.endRow>r.endRow)l=a.Direction.DOWN,s.startRow=r.endRow+1;else if(o.startColumn<r.startColumn)l=a.Direction.LEFT,s.endColumn=r.startColumn-1;else if(o.endColumn>r.endColumn)l=a.Direction.RIGHT,s.startColumn=r.endColumn+1;else return!1;this.direction=l;const c=this._injector.invoke(f=>m.rangeToDiscreteRange(r,f)),d=this._injector.invoke(f=>m.rangeToDiscreteRange(s,f));if(!c||!d)return!1;this.autoFillLocation={source:c,target:d,unitId:e,subUnitId:t};const u=[];this.getActiveHooks().forEach(f=>{var v;const p=(v=f==null?void 0:f.onBeforeFillData)==null?void 0:v.call(f,{source:c,target:d,unitId:e,subUnitId:t},l);p&&u.unshift(p)}),this._initPrevUndo();for(let f=0;f<u.length;f++){const p=this.menu.find(v=>v.value===u[f]);if(p&&!p.disable)return this.fillData(u[f])}const g=(S=this.menu.find(f=>f.disable===!1))==null?void 0:S.value;return g?this.fillData(g):!1}addHook(e){if(this._hooks.find(t=>t.id===e.id))throw new Error(`Add hook failed, hook id '${e.id}' already exist!`);return e.priority===void 0&&(e.priority=0),e.type===void 0&&(e.type=en.Append),this._hooks.push(e),a.toDisposable(()=>{const t=this._hooks.findIndex(r=>r===e);t>-1&&this._hooks.splice(t,1)})}registerRule(e){if(this._rules.find(r=>r.type===e.type))throw new Error(`Registry rule failed, type '${e.type}' already exist!`);const t=this._rules.findIndex(r=>r.priority<e.priority);this._rules.splice(t===-1?this._rules.length:t,0,e)}getRules(){return this._rules}getAllHooks(){return this._hooks}getActiveHooks(){const{source:e,target:t,unitId:r,subUnitId:o}=this.autoFillLocation||{};if(!e||!t||!r||!o)return[];const s=this._hooks.filter(u=>{var h;return!((h=u.disable)!=null&&h.call(u,{source:e,target:t,unitId:r,subUnitId:o},this._direction,this.applyType))}),l=s.filter(u=>u.type===en.Only);if(l.length>0)return this._getOneByPriority(l);const c=this._getOneByPriority(s.filter(u=>u.type===en.Default)),d=s.filter(u=>u.type===en.Append)||[];return[...c,...d]}get applyType(){return this._applyType$.getValue()}set applyType(e){this._applyType$.next(e)}get menu(){return this._menu$.getValue()}get direction(){return this._direction}set direction(e){this._direction=e}isFillingStyle(){return this._isFillingStyle}setFillingStyle(e){this._isFillingStyle=e}get autoFillLocation(){return this._autoFillLocation$.getValue()}set autoFillLocation(e){this._autoFillLocation$.next(e)}setDisableApplyType(e,t){this._menu$.next(this._menu$.getValue().map(r=>r.value===e?{...r,disable:t}:r))}setShowMenu(e){this._showMenu$.next(e)}fillData(e){var C,b,R;this.applyType=e;const{source:t,target:r,unitId:o=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getUnitId(),subUnitId:s=(C=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:C.getSheetId()}=this.autoFillLocation||{};if(!t||!r||!o||!s)return!1;const l=this.direction;this._prevUndos.length>0&&this._prevUndos.forEach(E=>{this._commandService.syncExecuteCommand(E.id,E.params)}),this._prevUndos=[];const c=a.Rectangle.union(gt(t),gt(r)),d=this.getActiveHooks(),u=this._univerInstanceService.getUnit(o,a.UniverInstanceType.UNIVER_SHEET);this._commandService.syncExecuteCommand(m.SetSelectionsOperation.id,{selections:[{primary:{...(R=(b=this._selectionManagerService.getCurrentLastSelection())==null?void 0:b.primary)!=null?R:c},range:{...c,rangeType:a.RANGE_TYPE.NORMAL}}],unitId:o,subUnitId:s});const h=[],g=[];d.forEach(E=>{var M;const{undos:P,redos:y}=((M=E.onFillData)==null?void 0:M.call(E,{source:t,target:r,unitId:o,subUnitId:s},l,e))||{};P&&h.push(...P),y&&g.push(...y)});const S=g.every(E=>this._commandService.syncExecuteCommand(E.id,E.params)),f=[];e!==le.NO_FORMAT&&g.forEach(E=>{if(E.id===m.SetRangeValuesMutation.id){const{cellValue:P}=E.params;new a.ObjectMatrix(P).forValue((M,x,A)=>{const k=Object.keys(u.getStyles().get(A==null?void 0:A.s)||{});(A!=null&&A.p||k.length&&Jo.some(D=>k.includes(D)))&&f.push({startRow:M,endRow:M,startColumn:x,endColumn:x})})}});const p=this._getAutoHeightUndoRedos(o,s,f);return p.redos.every(E=>this._commandService.syncExecuteCommand(E.id,E.params))&&(h.push(...p.undos),g.push(...p.redos)),S&&(this._prevUndos=h,this._undoRedoService.pushUndoRedo({unitID:o,undoMutations:h,redoMutations:g})),d.forEach(E=>{var P;(P=E.onAfterFillData)==null||P.call(E,{source:t,target:r,unitId:o,subUnitId:s},l,e)}),this.setShowMenu(!0),!0}_getAutoHeightUndoRedos(e,t,r){var h,g;const o=(h=this._renderManagerService.getRenderById(e))==null?void 0:h.with(exports.SheetSkeletonManagerService),s=(g=o==null?void 0:o.getCurrentParam())==null?void 0:g.skeleton;if(!s)return{redos:[],undos:[]};const l=s.calculateAutoHeightInRange(r),c={subUnitId:t,unitId:e,rowsAutoHeightInfo:l},d=s.worksheet,u=m.SetWorksheetRowAutoHeightMutationFactory(c,d);return{undos:[{id:m.SetWorksheetRowAutoHeightMutation.id,params:u}],redos:[{id:m.SetWorksheetRowAutoHeightMutation.id,params:c}]}}};exports.AutoFillService=Vd([Zt(0,a.ICommandService),Zt(1,a.IUndoRedoService),Zt(2,T.IRenderManagerService),Zt(3,a.Inject(a.IUniverInstanceService)),Zt(4,a.Inject(m.SheetsSelectionsService)),Zt(5,a.Inject(a.Injector))],exports.AutoFillService);const ft=a.createIdentifier("univer.auto-fill-service"),dt={type:a.CommandType.COMMAND,id:"sheet.command.auto-fill",handler:async(n,i)=>{const e=n.get(ft),t=n.get(a.IUniverInstanceService),{sourceRange:r,targetRange:o}=i,s=m.getSheetCommandTarget(t);if(!s)return!1;const{subUnitId:l,unitId:c}=s;return e.triggerAutoFill(c,l,r,o)}},un={id:"sheet.command.auto-clear-content",type:a.CommandType.COMMAND,handler:async(n,i)=>{const e=n.get(a.IUniverInstanceService),t=n.get(a.ICommandService),r=n.get(a.IUndoRedoService),o=n.get(m.SheetInterceptorService),s=m.getSheetCommandTarget(e);if(!s)return!1;const{unitId:l,subUnitId:c}=s,{clearRange:d,selectionRange:u}=i,h={subUnitId:c,unitId:l,cellValue:m.generateNullCellValue([d])},g=m.SetRangeValuesUndoMutationFactory(n,h),{startColumn:S,startRow:f}=u,p={selections:[{primary:{startColumn:S,startRow:f,endColumn:S,endRow:f,actualRow:f,actualColumn:S,isMerged:!1,isMergedMainCell:!1},range:{...u}}],unitId:l,subUnitId:c};if(t.executeCommand(m.SetSelectionsOperation.id,p),t.syncExecuteCommand(m.SetRangeValuesMutation.id,h)){const C=o.afterCommandExecute({id:m.SetRangeValuesMutation.id,params:h});return a.sequenceExecute(C.redos,t),r.pushUndoRedo({unitID:l,undoMutations:[{id:m.SetRangeValuesMutation.id,params:g},...C.undos],redoMutations:[{id:m.SetRangeValuesMutation.id,params:h},...C.redos]}),!0}return!1}},ir={id:"sheet.command.refill",type:a.CommandType.COMMAND,handler:async(n,i)=>n.get(ft).fillData(i.type)};var Hd=Object.getOwnPropertyDescriptor,Wd=(n,i,e,t)=>{for(var r=t>1?void 0:t?Hd(i,e):i,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=s(r)||r);return r},Kt=(n,i)=>(e,t)=>i(e,t,n);exports.EditorBridgeService=class extends a.Disposable{constructor(e,t,r,o,s,l){super();w(this,"_editorUnitId",a.DOCS_NORMAL_EDITOR_UNIT_ID_KEY);w(this,"_editorIsDirty",!1);w(this,"_visibleParams",{visible:!1,eventType:T.DeviceInputEventType.Dblclick,unitId:""});w(this,"_currentEditCell",null);w(this,"_currentEditCellState",null);w(this,"_currentEditCellLayout",null);w(this,"helpFunctionVisible$",new O.BehaviorSubject(!0));w(this,"_currentEditCellState$",new O.BehaviorSubject(null));w(this,"currentEditCellState$",this._currentEditCellState$.asObservable());w(this,"_currentEditCellLayout$",new O.BehaviorSubject(null));w(this,"currentEditCellLayout$",this._currentEditCellLayout$.asObservable());w(this,"currentEditCell$",this._currentEditCellState$.pipe(O.switchMap(e=>this._currentEditCellLayout$.pipe(O.map(t=>e&&t?{...e,...t}:null)))));w(this,"_visibleParams$",new O.BehaviorSubject(this._visibleParams));w(this,"visible$",this._visibleParams$.asObservable());w(this,"_afterVisibleParams$",new O.BehaviorSubject(this._visibleParams));w(this,"afterVisible$",this._afterVisibleParams$.asObservable());w(this,"_forceKeepVisible$",new O.BehaviorSubject(!1));w(this,"forceKeepVisible$",this._forceKeepVisible$.asObservable());this._sheetInterceptorService=e,this._renderManagerService=t,this._themeService=r,this._univerInstanceService=o,this._editorService=s,this._contextService=l,this.disposeWithMe(a.toDisposable(()=>{this._currentEditCellState$.complete(),this._currentEditCell=null})),this._univerInstanceService.getTypeOfUnitDisposed$(a.UniverInstanceType.UNIVER_SHEET).subscribe(c=>{var d;c.getUnitId()===((d=this._currentEditCellState)==null?void 0:d.unitId)&&this._clearCurrentEditCellState()})}refreshEditCellState(){const e=this.getLatestEditCellState();if(!e){this._currentEditCellState=null,this._currentEditCellLayout=null,this._currentEditCellState$.next(null),this._currentEditCellLayout$.next(null);return}const{position:t,scaleX:r,scaleY:o,canvasOffset:s,...l}=e;this._currentEditCellState=l,this._currentEditCellLayout={position:t,scaleX:r,scaleY:o,canvasOffset:s},this._currentEditCellState$.next(this._currentEditCellState),this._currentEditCellLayout$.next(this._currentEditCellLayout)}refreshEditCellPosition(e){var P;const t=this._currentEditCell;if(t==null)return;const r=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!r)return;const o=this._renderManagerService.getRenderUnitById(r.getUnitId());if(!o)return;const s=(P=o.with(exports.SheetSkeletonManagerService).getSkeletonParam(t.sheetId))==null?void 0:P.skeleton,l=o.with(pe);if(!s||!this._currentEditCellState)return;const{primary:c,scene:d,engine:u}=t,h=Gn(s,c);if(h==null)return;const g=a.convertCellToRange(h),S=J.getCanvasOffsetByEngine(u);let{startX:f,startY:p,endX:v,endY:C}=g;const{scaleX:b,scaleY:R}=d.getAncestorScale(),E=d.getViewportScrollXY(l.getViewPort());f=T.convertTransformToOffsetX(f,b,E),p=T.convertTransformToOffsetY(p,R,E),v=T.convertTransformToOffsetX(v,b,E),C=T.convertTransformToOffsetY(C,R,E),e&&this._currentEditCellLayout&&(v=v-f+this._currentEditCellLayout.position.startX,C=C-p+this._currentEditCellLayout.position.startY,f=this._currentEditCellLayout.position.startX,p=this._currentEditCellLayout.position.startY),this._currentEditCellLayout={position:{startX:f,startY:p,endX:v,endY:C},canvasOffset:S,scaleX:b,scaleY:R},this._currentEditCellLayout$.next(this._currentEditCellLayout)}setEditCell(e){this._currentEditCell=e,this._editorService.getFocusEditor()||(this._editorService.focus(a.DOCS_NORMAL_EDITOR_UNIT_ID_KEY),this._contextService.setContextValue(a.EDITOR_ACTIVATED,!1),this._contextService.setContextValue(a.FOCUSING_EDITOR_STANDALONE,!1));const t=this.getLatestEditCellState();if(!t){this._currentEditCellState=t,this._currentEditCellLayout=t,this._currentEditCellState$.next(t),this._currentEditCellLayout$.next(t);return}const{position:r,canvasOffset:o,scaleX:s,scaleY:l,...c}=t;this._currentEditCellState=c,this._currentEditCellLayout={position:r,canvasOffset:o,scaleX:s,scaleY:l},this._currentEditCellState$.next(this._currentEditCellState),this._currentEditCellLayout$.next(this._currentEditCellLayout)}_clearCurrentEditCellState(){this._currentEditCellState=null,this._currentEditCellState$.next(null),this._currentEditCellLayout=null,this._currentEditCellLayout$.next(null)}getEditCellState(){return this._currentEditCellState==null||this._currentEditCellLayout==null?null:{...this._currentEditCellState,...this._currentEditCellLayout}}getEditCellLayout(){return this._currentEditCellLayout}getEditLocation(){return this._currentEditCellState}updateEditLocation(e,t){this._currentEditCellState&&(this._currentEditCellState={...this._currentEditCellState,row:e,column:t})}getLatestEditCellState(){var W,V,U;const e=this._currentEditCell;if(e==null)return;const t=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!t)return;const r=this._renderManagerService.getRenderUnitById(t.getUnitId());if(!r)return;const o=r.with(exports.SheetSkeletonManagerService).getCurrentSkeleton(),s=r.with(pe);if(!o)return;const{primary:l,unitId:c,sheetId:d,scene:u,engine:h}=e,{startRow:g,startColumn:S}=l,f=Gn(o,l);if(f==null)return;const p=a.convertCellToRange(f),v=J.getCanvasOffsetByEngine(h);let{startX:C,startY:b,endX:R,endY:E}=p;const{scaleX:P,scaleY:y}=u.getAncestorScale(),M=u.getViewportScrollXY(s.getViewPort());C=T.convertTransformToOffsetX(C,P,M),b=T.convertTransformToOffsetY(b,y,M),R=T.convertTransformToOffsetX(R,P,M),E=T.convertTransformToOffsetY(E,y,M);const x=t.getActiveSheet();if(!x)return;const A={workbook:t,worksheet:x,unitId:t.getUnitId(),subUnitId:x.getSheetId(),row:g,col:S,origin:x.getCellRaw(g,S)};let k;const D=this._sheetInterceptorService.writeCellInterceptor.fetchThroughInterceptors(m.BEFORE_CELL_EDIT)(x.getCell(g,S),A);k=D&&o.getCellDocumentModelWithFormula(D);const N=(W=k==null?void 0:k.documentModel)==null?void 0:W.documentStyle.renderConfig;if(N!=null&&(N.cellValueType=a.CellValueType.STRING),!k||k.documentModel==null){const L=o.getBlankCellDocumentModel(D);if(k!=null){const{verticalAlign:j,horizontalAlign:B,wrapStrategy:F,textRotation:X,fill:K}=k,{centerAngle:te,vertexAngle:Q}=T.convertTextRotation(X);L.documentModel.documentStyle.renderConfig={...N,verticalAlign:j,horizontalAlign:B,wrapStrategy:F,background:{rgb:K},centerAngle:te,vertexAngle:Q}}k=L}if(k.fill=k.fill||"#fff",(V=k.documentModel)==null||V.setZoomRatio(Math.max(P,y)),(D==null?void 0:D.isInArrayFormulaRange)===!0){const L=(U=k.documentModel)==null?void 0:U.getBody();L&&(L.textRuns=[{st:0,ed:L.dataStream.length-2,ts:{cl:{rgb:this._themeService.getColorFromTheme("gray.600")}}}])}return{position:{startX:C,startY:b,endX:R,endY:E},scaleX:P,scaleY:y,canvasOffset:v,row:g,column:S,unitId:c,sheetId:d,documentLayoutObject:k,editorUnitId:this._editorUnitId,isInArrayFormulaRange:D==null?void 0:D.isInArrayFormulaRange}}getCurrentEditorId(){return this._editorUnitId}changeVisible(e){this._visibleParams=e,e.visible&&(this._editorIsDirty=!1),this._visibleParams$.next(this._visibleParams),this._afterVisibleParams$.next(this._visibleParams)}isVisible(){return this._visibleParams}enableForceKeepVisible(){this._forceKeepVisible$.next(!0)}disableForceKeepVisible(){this._forceKeepVisible$.next(!1)}isForceKeepVisible(){return this._forceKeepVisible$.getValue()}changeEditorDirty(e){this._editorIsDirty=e}getEditorDirty(){return this._editorIsDirty}};exports.EditorBridgeService=Wd([Kt(0,a.Inject(m.SheetInterceptorService)),Kt(1,T.IRenderManagerService),Kt(2,a.Inject(a.ThemeService)),Kt(3,a.IUniverInstanceService),Kt(4,J.IEditorService),Kt(5,a.IContextService)],exports.EditorBridgeService);const he=a.createIdentifier("univer.sheet-editor-bridge.service"),Se={id:"sheet.operation.set-cell-edit-visible",type:a.CommandType.OPERATION,handler:(n,i)=>{if(!i)return!1;const{unitId:e}=i,r=n.get(a.IUniverInstanceService).getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);return r?(n.get(he).changeVisible({...i,unitId:e!=null?e:r.getUnitId()}),!0):!1}},or={id:"sheet.operation.set-cell-edit-visible-f2",type:a.CommandType.OPERATION,handler:(n,i)=>{const e=n.get(a.ICommandService),r=n.get(a.IUniverInstanceService).getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);return r?(e.syncExecuteCommand(Se.id,{...i,unitId:r.getUnitId()}),!0):!1}},Nt={id:"sheet.operation.set-cell-edit-visible-arrow",type:a.CommandType.OPERATION,handler:()=>!0},Rn={id:"sheet.command.change-zoom-ratio",type:a.CommandType.COMMAND,handler:(n,i)=>{if(!i)return!1;const e=n.get(a.IUniverInstanceService),t=m.getSheetCommandTarget(e);if(!t)return!1;const{worksheet:r,subUnitId:o,unitId:s}=t,{delta:l,reset:c}=i;let d=c?100:Math.round((r.getConfig().zoomRatio+l)*100);d=Math.max(_o[0],d),d=Math.min(_o[1],d);const u=d/100,g=n.get(he).isVisible();return(g.unitId===s||g.unitId===a.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY)&&g.visible?!1:n.get(a.ICommandService).executeCommand(Ne.id,{unitId:s,subUnitId:o,zoomRatio:u})}},En={id:"sheet.command.set-zoom-ratio",type:a.CommandType.COMMAND,handler:(n,i)=>{if(!i)return!1;const{unitId:e,subUnitId:t,zoomRatio:r}=i,s=n.get(he).isVisible();return(s.unitId===e||s.unitId===a.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY)&&s.visible?!1:n.get(a.ICommandService).executeCommand(Ne.id,{unitId:e,subUnitId:t,zoomRatio:r})}};function Ud(n){return typeof n.isMainScene>"u"}function Ve(n,i){const e=n instanceof a.Workbook?n:n.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!e)return null;const t=e.getUnitId();let r,o,s,l;if(Ud(i)){const g=i.getRenderById(t);if(g==null)return null;r=g.components,r=g.components,o=g.mainComponent,s=g.scene,l=g.engine}else r=i.components,o=i.mainComponent,s=i.scene,l=i.engine;if(!r||!o)return null;const c=o,d=r.get(ue.ROW),u=r.get(ue.COLUMN),h=r.get(ue.LEFT_TOP);return{spreadsheet:c,spreadsheetRowHeader:d,spreadsheetColumnHeader:u,spreadsheetLeftTopPlaceholder:h,scene:s,engine:l}}function To(n,i,e,t){const{startX:r,startY:o,endX:s,endY:l}=t.getCellWithCoordByIndex(n,i);return{startX:r,startY:o,endX:s,endY:l}}function ze(n,i,e,t,r,o){const s=e.getCoordRelativeToViewport(T.Vector2.FromArray([n,i])),{x:l,y:c}=s,d=e.getScrollXYInfoByViewport(s,r),{scaleX:u,scaleY:h}=e.getAncestorScale(),g=t.getCellIndexByOffset(l,c,u,h,d,{closeFirst:o}),{row:S,column:f}=g,p=t.getNoMergeCellWithCoordByIndex(S,f),{startX:v,startY:C,endX:b,endY:R}=p;return{startX:v,startY:C,endX:b,endY:R,row:S,column:f}}function Xn(n,i,e,t){const r=e.getCoordRelativeToViewport(T.Vector2.FromArray([n,i])),o=e.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN),s=e.getScrollXYInfoByViewport(r,o),{scaleX:l,scaleY:c}=e.getAncestorScale(),{x:d,y:u}=s,h=n/l+d,g=i/c+u;return{x:h,y:g}}var Ld=Object.getOwnPropertyDescriptor,Bd=(n,i,e,t)=>{for(var r=t>1?void 0:t?Ld(i,e):i,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=s(r)||r);return r},Or=(n,i)=>(e,t)=>i(e,t,n);let Zn=class extends a.Disposable{constructor(i,e,t,r,o){super();w(this,"_zoom");this._context=i,this._sheetSkeletonManagerService=e,this._commandService=t,this._contextService=r,this._editorBridgeService=o,this._initSkeletonListener(),this._initZoomEventListener()}updateZoom(i,e){const t=this._context.unit.getSheetBySheetId(i);return t?(t.getConfig().zoomRatio=e,t===this._context.unit.getActiveSheet()&&this._updateViewZoom(e),!0):!1}_initZoomEventListener(){const i=Ve(this._context.unit,this._context).scene;this.disposeWithMe(i.onMouseWheel$.subscribeEvent(e=>{if(!e.ctrlKey||!this._contextService.getContextValue(a.FOCUSING_SHEET))return;if(this._editorBridgeService){const d=this._editorBridgeService.isVisible();if((d.unitId===this._context.unitId||d.unitId===a.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY)&&d.visible)return}const t=Math.abs(e.deltaX);let r=t<40?.2:t<80?.4:.2;r*=e.deltaY>0?-1:1,i.scaleX<1&&(r/=2);const o=this._context.unit,s=o.getActiveSheet();if(!s)return;const l=s.getZoomRatio();let c=+Number.parseFloat(`${l+r}`).toFixed(1);c=c>=4?4:c<=.1?.1:c,this._commandService.executeCommand(En.id,{zoomRatio:Math.round(c*10)/10,unitId:o.getUnitId(),subUnitId:s.getSheetId()}),e.preventDefault()}))}_initSkeletonListener(){this.disposeWithMe(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(i=>{if(i==null)return;const t=this._context.unit.getActiveSheet();if(!t)return;const r=t.getZoomRatio()||1;this._zoom!==r&&this._updateViewZoom(r)}))}_updateViewZoom(i){this._zoom=i;const e=Ve(this._context.unit,this._context);e==null||e.scene.scale(i,i),e==null||e.spreadsheet.makeForceDirty()}};Zn=Bd([Or(1,a.Inject(exports.SheetSkeletonManagerService)),Or(2,a.ICommandService),Or(3,a.IContextService),Or(4,a.Optional(he))],Zn);const Ne={id:"sheet.operation.set-zoom-ratio",type:a.CommandType.OPERATION,handler:(n,i)=>{const t=n.get(T.IRenderManagerService).getRenderById(i.unitId);return t?t.with(Zn).updateZoom(i.subUnitId,i.zoomRatio):!1}};var Fd=Object.getOwnPropertyDescriptor,jd=(n,i,e,t)=>{for(var r=t>1?void 0:t?Fd(i,e):i,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=s(r)||r);return r},Ar=(n,i)=>(e,t)=>i(e,t,n);const Hs="univer-sheet-main-canvas";exports.SheetsRenderService=class extends a.RxDisposable{constructor(e,t,r,o){super();w(this,"_skeletonChangeMutations",new Set);this._contextService=e,this._instanceSrv=t,this._renderManagerService=r,this._themeService=o,Promise.resolve().then(()=>this._init())}registerSkeletonChangingMutations(e){return this._skeletonChangeMutations.has(e)?a.toDisposable(()=>{}):(this._skeletonChangeMutations.add(e),a.toDisposable(()=>this._skeletonChangeMutations.delete(e)))}checkMutationShouldTriggerRerender(e){return this._skeletonChangeMutations.has(e)}_init(){this._initWorkbookListener(),this._initContextListener(),this._initDarkModeListener()}_initDarkModeListener(){this.disposeWithMe(this._themeService.darkMode$.subscribe(()=>{this._renderManagerService.getRenderAll().forEach(e=>{e.components.forEach(t=>{t.makeForceDirty(!0),t.makeDirty(!0)})})}))}_initWorkbookListener(){this._instanceSrv.getTypeOfUnitAdded$(a.UniverInstanceType.UNIVER_SHEET).pipe(O.takeUntil(this.dispose$)).subscribe(e=>this._createRenderer(e)),this._instanceSrv.getAllUnitsForType(a.UniverInstanceType.UNIVER_SHEET).forEach(e=>this._createRenderer(e)),this._instanceSrv.getTypeOfUnitDisposed$(a.UniverInstanceType.UNIVER_SHEET).pipe(O.takeUntil(this.dispose$)).subscribe(e=>this._disposeRenderer(e))}_createRenderer(e){const t=e.getUnitId();this._renderManagerService.created$.subscribe(r=>{r.unitId===t&&(r.engine.getCanvas().setId(`${Hs}_${t}`),r.engine.getCanvas().getContext().setId(`${Hs}_${t}`))}),this._renderManagerService.createRender(t)}_disposeRenderer(e){const t=e.getUnitId();this._renderManagerService.removeRender(t)}_initContextListener(){this.disposeWithMe(this._contextService.subscribeContextValue$(T.RENDER_RAW_FORMULA_KEY).pipe(O.distinctUntilChanged()).subscribe(()=>{this._renderManagerService.getRenderAll().forEach(e=>{e.mainComponent instanceof T.Spreadsheet&&e.mainComponent.makeForceDirty(!0)})}))}};exports.SheetsRenderService=jd([Ar(0,a.IContextService),Ar(1,a.IUniverInstanceService),Ar(2,T.IRenderManagerService),Ar(3,a.Inject(a.ThemeService))],exports.SheetsRenderService);var zd=Object.getOwnPropertyDescriptor,Xd=(n,i,e,t)=>{for(var r=t>1?void 0:t?zd(i,e):i,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=s(r)||r);return r},_t=(n,i)=>(e,t)=>i(e,t,n);exports.AutoFillController=class extends a.Disposable{constructor(e,t,r,o,s,l,c){super();w(this,"_beforeApplyData",[]);w(this,"_currentLocation",null);w(this,"_copyData",[]);w(this,"_defaultHook");this._univerInstanceService=e,this._commandService=t,this._autoFillService=r,this._editorBridgeService=o,this._renderManagerService=s,this._injector=l,this._sheetsRenderService=c,this._defaultHook={id:"default",type:en.Default,priority:0,onBeforeFillData:(d,u)=>this._presetAndCacheData(d,u),onFillData:(d,u,h)=>this._fillData(d,u,h)},this._init()}_init(){this._initDefaultHook(),this._initSelectionControlFillChanged(),this._initQuitListener(),this._initSkeletonChange()}_initSkeletonChange(){this.disposeWithMe(this._sheetsRenderService.registerSkeletonChangingMutations(dt.id))}_initDefaultHook(){this.disposeWithMe(this._autoFillService.addHook(this._defaultHook))}_initQuitListener(){const e=[Se.id,un.id,m.SetRangeValuesCommand.id,Ne.id,m.SetWorksheetActiveOperation.id,m.MoveRangeMutation.id,m.RemoveRowMutation.id,m.RemoveColMutation.id,m.InsertRowMutation.id,m.InsertColMutation.id,m.MoveRowsMutation.id,m.MoveColsMutation.id,m.SetWorksheetColWidthMutation.id,m.SetWorksheetRowHeightMutation.id,m.SetRangeValuesMutation.id];this.disposeWithMe(this._commandService.onCommandExecuted((t,r)=>{var c,d;const o=r==null?void 0:r.fromCollab,s=r==null?void 0:r.fromSync,l=r==null?void 0:r.fromFormula;e.includes(t.id)&&!o&&!s&&!l&&t.params.trigger!==dt.id&&t.params.trigger!==ir.id&&this._quit(),t.id===m.RemoveSheetMutation.id&&t.params.unitId===((c=this._currentLocation)==null?void 0:c.unitId)&&t.params.subUnitId===((d=this._currentLocation)==null?void 0:d.subUnitId)&&this._quit()})),this.disposeWithMe(this._univerInstanceService.unitDisposed$.subscribe(t=>{var r;t.getUnitId()===((r=this._currentLocation)==null?void 0:r.unitId)&&this._quit()}))}_quit(){this._currentLocation=null,this._beforeApplyData=[],this._copyData=[],this._autoFillService.setShowMenu(!1)}_initSelectionControlFillChanged(){const e=new a.DisposableCollection,t=()=>{e.dispose();const r=T.getCurrentTypeOfRenderer(a.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService);if(!r)return;r.with(pe).getSelectionControls().forEach(l=>{e.add(l.selectionFilled$.subscribe(c=>{if(c==null||c.startColumn===-1||c.startRow===-1||c.endColumn===-1||c.endRow===-1)return;const d={startColumn:l.model.startColumn,endColumn:l.model.endColumn,startRow:l.model.startRow,endRow:l.model.endRow},u={startColumn:c.startColumn,endColumn:c.endColumn,startRow:c.startRow,endRow:c.endRow};this._commandService.executeCommand(dt.id,{sourceRange:d,targetRange:u})})),e.add(l.fillControl.onDblclick$.subscribeEvent(()=>{const c={startColumn:l.model.startColumn,endColumn:l.model.endColumn,startRow:l.model.startRow,endRow:l.model.endRow};this._handleDbClickFill(c)})),e.add(l.fillControl.onPointerDown$.subscribeEvent(()=>{this._editorBridgeService.isVisible().visible&&this._commandService.syncExecuteCommand(Se.id,{visible:!1,eventType:T.DeviceInputEventType.PointerDown,unitId:r.unitId})}))})};t(),this.disposeWithMe(this._commandService.onCommandExecuted(r=>{r.id===m.SetSelectionsOperation.id&&t()})),this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET).subscribe(()=>t()))}_handleDbClickFill(e){const t=this._detectFillRange(e);t.endRow<=e.endRow||this._commandService.executeCommand(dt.id,{sourceRange:e,targetRange:t})}_detectFillRange(e){var g,S,f,p,v,C;const{startRow:t,endRow:r,startColumn:o,endColumn:s}=e,l=(g=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:g.getActiveSheet();if(!l)return e;const c=l.getCellMatrix(),d=l.getMaxRows()-1,u=l.getMaxColumns()-1;let h=r;if(o>0&&((S=c.getValue(t,o-1))==null?void 0:S.v)!=null){let b=t;for(;((f=c.getValue(b,o-1))==null?void 0:f.v)!=null&&b<d;)b+=1;h=b-1}else if(s<u&&((p=c.getValue(r,s+1))==null?void 0:p.v)!=null){let b=t;for(;((v=c.getValue(b,s+1))==null?void 0:v.v)!=null&&b<d;)b+=1;h=b-1}for(let b=r+1;b<=h;b++)for(let R=o;R<=s;R++)if(((C=c.getValue(b,R))==null?void 0:C.v)!=null){h=b-1;break}return{startColumn:o,endColumn:s,startRow:t,endRow:h}}_getApplyData(e,t,r,o,s,l=!0,c){const d=[],u=Math.floor(r/t),h=r%t,g=this._autoFillService.getRules();if(!l&&s===le.ONLY_FORMAT)return console.error("ERROR: only format can not be applied when hasStyle is false"),[];const S={};g.forEach(f=>{S[f.type]=[]}),g.forEach(f=>{const{type:p,applyFunctions:v={}}=f,C=e[p];C&&C.forEach(b=>{const R=_d(b.index,h),E=b.index.length*u+R,P=this._applyFunctions(b,E,o,s,v,e,c),y=Id(t,r,b.index);S[p].push({data:P,index:y})})});for(let f=0;f<r;f++)g.forEach(p=>{const{type:v}=p,C=S[v];for(let b=0;b<C.length;b++)f in C[b].index&&d.push(C[b].data[C[b].index[f]])});return d}_applyFunctions(e,t,r,o,s,l,c){const{data:d}=e,u=r===a.Direction.UP||r===a.Direction.LEFT;if(o===le.COPY){const h=s==null?void 0:s[le.COPY];return h?h(e,t,r,l,c):(u&&d.reverse(),kt(d,t))}if(o===le.SERIES){const h=s==null?void 0:s[le.SERIES];return h?h(e,t,r,l):(u&&d.reverse(),s!=null&&s[le.COPY]?s[le.COPY](e,t,r,l,c):kt(d,t))}if(o===le.ONLY_FORMAT){const h=s==null?void 0:s[le.ONLY_FORMAT];return h?h(e,t,r,l):bd(d,t)}}_getCopyData(e,t){const r=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getActiveSheet();if(!r)throw new Error("No active sheet found");const o=r.getCellMatrix(),s=this._autoFillService.getRules(),l=[],c=t===a.Direction.DOWN||t===a.Direction.UP;let d,u;return c?(d=e.cols,u=e.rows):(d=e.rows,u=e.cols),d.forEach(h=>{const g=this._getEmptyCopyDataPiece(),S={type:void 0,cellData:void 0};u.forEach(f=>{let p;c?p=o.getValue(f,h):p=o.getValue(h,f);const{type:v,isContinue:C}=s.find(b=>b.match(p,this._injector))||xa;if(C(S,p)){const b=g[v],R=b[b.length-1];R.data.push(p),R.index.push(f-u[0])}else{const b=g[v];b?b.push({data:[p],index:[f-u[0]]}):g[v]=[{data:[p],index:[f-u[0]]}]}S.type=v,S.cellData=p}),l.push(g)}),l}_getEmptyCopyDataPiece(){const e={};return this._autoFillService.getRules().forEach(t=>{e[t.type]=[]}),e}_getMergeApplyData(e,t,r,o){const s=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getActiveSheet();if(!s)throw new Error("No active sheet found");const l=[];for(let c=e.startRow;c<=e.endRow;c++)for(let d=e.startColumn;d<=e.endColumn;d++){const{isMergedMainCell:u,startRow:h,startColumn:g,endRow:S,endColumn:f}=s.getCellInfoInMergeData(c,d);if(u){if(r===a.Direction.DOWN){let p=h+o,v=S+o;for(;v<=t.endRow;)l.push({startRow:p,startColumn:g,endRow:v,endColumn:f}),p+=o,v+=o}else if(r===a.Direction.UP){let p=h-o,v=S-o;for(;p>=t.startRow;)l.push({startRow:p,startColumn:g,endRow:v,endColumn:f}),p-=o,v-=o}else if(r===a.Direction.RIGHT){let p=g+o,v=f+o;for(;v<=t.endColumn;)l.push({startRow:h,startColumn:p,endRow:S,endColumn:v}),p+=o,v+=o}else if(r===a.Direction.LEFT){let p=g-o,v=f-o;for(;p>=t.startColumn;)l.push({startRow:h,startColumn:p,endRow:S,endColumn:v}),p-=o,v-=o}}}return l}_presetAndCacheData(e,t){const{source:r,target:o}=e,s=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getActiveSheet();if(!s)throw new Error("No active sheet found");const l=s.getCellMatrix(),c=[];return o.rows.forEach(d=>{const u=[];o.cols.forEach(h=>{u.push(a.Tools.deepClone(l.getValue(d,h)))}),c.push(u)}),this._beforeApplyData=c,this._copyData=this._getCopyData(r,t),this._currentLocation=e,this._shouldDisableSeries(this._copyData)?(this._autoFillService.setDisableApplyType(le.SERIES,!0),le.COPY):(this._autoFillService.setDisableApplyType(le.SERIES,!1),this._getPreferredApplyType(this._copyData))}_fillData(e,t,r){var W,V;const o=[],s=[];let l=!0;r===le.NO_FORMAT&&(l=!1,r=le.SERIES);const{source:c,target:d,unitId:u,subUnitId:h}=e;if(!c||!d||t==null)return{undos:o,redos:s};const g=gt(c),S=gt(d),{cols:f,rows:p}=d,{cols:v,rows:C}=c,b=this._copyData;let R;t===a.Direction.DOWN||t===a.Direction.UP?R=C.length:R=v.length;const E=[];if(t===a.Direction.DOWN||t===a.Direction.UP){const U=p.length,L=[];f.forEach((j,B)=>{const F=b[B],X=this._getApplyData(F,R,U,t,r,l,e);L.push(X)});for(let j=0;j<L[0].length;j++){const B=[];for(let F=0;F<L.length;F++)B.push({s:null,...L[F][j]});E.push(B)}}else{const U=f.length;p.forEach((L,j)=>{const B=b[j],F=this._getApplyData(B,R,U,t,r,l,e),X=[];for(let K=0;K<F.length;K++)X.push({s:null,...F[K]});E.push(X)})}let P=[];const y=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getStyles();if(l?(P=this._getMergeApplyData(g,S,t,R),E.forEach(U=>{U.forEach(L=>{L&&y&&y&&(L.s=y.getStyleByCell(L))})})):E.forEach((U,L)=>{U.forEach((j,B)=>{j&&y&&(j.s=y.getStyleByCell(this._beforeApplyData[L][B])||null)})}),r===le.ONLY_FORMAT&&E.forEach((U,L)=>{U.forEach((j,B)=>{if(j){const F=this._beforeApplyData[L][B]||{};j.f=F.f,j.si=F.si,j.t=F.t,j.v=F.v}})}),l){const U=[],L=(V=(W=this._univerInstanceService.getUniverSheetInstance(u))==null?void 0:W.getSheetBySheetId(h))==null?void 0:V.getMergeData();L&&L.forEach(F=>{a.Rectangle.intersects(F,S)&&U.push(F)});const j={unitId:u,subUnitId:h,ranges:U},B=this._injector.invoke(m.RemoveMergeUndoMutationFactory,j);U.length&&(s.push({id:m.RemoveWorksheetMergeMutation.id,params:j}),o.unshift({id:m.AddWorksheetMergeMutation.id,params:B}))}const M={subUnitId:h,unitId:u,cellValue:md([d])},x=this._injector.invoke(m.SetRangeValuesUndoMutationFactory,M);s.push({id:m.SetRangeValuesMutation.id,params:M}),o.unshift({id:m.SetRangeValuesMutation.id,params:x});const A=new a.ObjectMatrix;p.forEach((U,L)=>{f.forEach((j,B)=>{E[L][B]&&A.setValue(U,j,E[L][B])})});const k=A.getMatrix(),D={subUnitId:h,unitId:u,cellValue:k},N=this._injector.invoke(m.SetRangeValuesUndoMutationFactory,D);if(this._autoFillService.getActiveHooks().forEach(U=>{var L;(L=U.onBeforeSubmit)==null||L.call(U,e,t,r,k)}),o.unshift({id:m.SetRangeValuesMutation.id,params:N}),s.push({id:m.SetRangeValuesMutation.id,params:D}),P!=null&&P.length){const U=m.getAddMergeMutationRangeByType(P),L={unitId:u,subUnitId:h,ranges:U},j=this._injector.invoke(m.AddMergeUndoMutationFactory,L);o.unshift({id:m.RemoveWorksheetMergeMutation.id,params:j}),s.push({id:m.AddWorksheetMergeMutation.id,params:L})}return{undos:o,redos:s}}_shouldDisableSeries(e){return e.every(t=>Object.keys(t).every(r=>{var o;return((o=t[r])==null?void 0:o.length)===0||[Ce.OTHER,Ce.FORMULA].includes(r)}))}_getPreferredApplyType(e){return e.every(r=>Object.keys(r).every(o=>{var s,l;return((s=r[o])==null?void 0:s.length)===0||((l=r[o])==null?void 0:l.length)===1&&r[o][0].data.length===1&&Ce.NUMBER===o}))?le.COPY:le.SERIES}};exports.AutoFillController=Xd([_t(0,a.IUniverInstanceService),_t(1,a.ICommandService),_t(2,ft),_t(3,he),_t(4,T.IRenderManagerService),_t(5,a.Inject(a.Injector)),_t(6,a.Inject(exports.SheetsRenderService))],exports.AutoFillController);var Yd=Object.getOwnPropertyDescriptor,Gd=(n,i,e,t)=>{for(var r=t>1?void 0:t?Yd(i,e):i,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=s(r)||r);return r},Di=(n,i)=>(e,t)=>i(e,t,n);exports.CellCustomRenderController=class extends a.Disposable{constructor(e,t,r,o){super();w(this,"_enterActiveRender");this._context=e,this._sheetSkeletonManagerService=t,this._renderManagerService=r,this._permissionService=o,this._initEventBinding()}_initEventBinding(){const e=new a.DisposableCollection,t=this._context.unit,r=o=>{if(e.dispose(),!o)return;const s=this._context.unitId,{skeleton:l}=o,c=this._renderManagerService.getRenderById(s);if(c&&c.mainComponent){const d=c.mainComponent,u=S=>{const{offsetX:f,offsetY:p}=S,v=c.scene,C=t.getActiveSheet();if(!C)return;const b=v.getActiveViewportByCoord(T.Vector2.FromArray([f,p]));if(!b)return;const{scaleX:R,scaleY:E}=v.getAncestorScale(),P={x:b.viewportScrollX,y:b.viewportScrollY},y=l.getCellIndexByOffset(f,p,R,E,P),M=l.worksheet.getMergedCell(y.row,y.column),x={actualRow:M?M.startRow:y.row,actualCol:M?M.startColumn:y.column,row:y.row,col:y.column};if(!x||!l)return;const A=C.getCell(x.actualRow,x.actualCol);if(!A)return;const k=A.customRender;if(!(k!=null&&k.length))return;const D=x.actualRow,N=x.actualCol,W=k.sort(a.sortRules),V=C.getSheetId(),U={data:A,style:l.getStyles().getStyleByCell(A),primaryWithCoord:l.getCellWithCoordByIndex(x.actualRow,x.actualCol),unitId:s,subUnitId:V,row:D,col:N,workbook:t,worksheet:C},L={x:P.x+f/R,y:P.y+p/E},j=W.find(B=>{var F;return(F=B.isHit)==null?void 0:F.call(B,L,U)});if(j)return[j,U]},h=d.onPointerDown$.subscribeEvent(S=>{var p,v,C,b;const f=u(S);if(f){const[R,E]=f,{row:P,col:y,worksheet:M,unitId:x,subUnitId:A}=E;if(!((p=this._permissionService.composePermission([new m.WorkbookEditablePermission(x).id,new m.WorksheetEditPermission(x,A).id]))==null?void 0:p.every(N=>N.value)))return!1;const D=(C=(v=M.getCell(P,y))==null?void 0:v.selectionProtection)==null?void 0:C[0];if((D==null?void 0:D[m.UnitAction.Edit])===!1)return!1;(b=R.onPointerDown)==null||b.call(R,E,S)}}),g=a.fromEventSubject(d.onPointerMove$).pipe(O.throttleTime(30)).subscribe(S=>{var p,v,C,b,R,E;const f=u(S);if(f){const[P,y]=f;this._enterActiveRender?this._enterActiveRender.render!==P&&((v=(p=this._enterActiveRender.render).onPointerLeave)==null||v.call(p,this._enterActiveRender.cellContext,S),this._enterActiveRender={render:P,cellContext:y},(C=P.onPointerEnter)==null||C.call(P,y,S)):(this._enterActiveRender={render:P,cellContext:y},(b=P.onPointerEnter)==null||b.call(P,y,S))}else this._enterActiveRender&&((E=(R=this._enterActiveRender.render).onPointerLeave)==null||E.call(R,this._enterActiveRender.cellContext,S),this._enterActiveRender=null)});h&&e.add(h),g&&e.add(g)}};this.disposeWithMe(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(r)),r(this._sheetSkeletonManagerService.getCurrentParam()),this.disposeWithMe(e)}};exports.CellCustomRenderController=Gd([Di(1,a.Inject(exports.SheetSkeletonManagerService)),Di(2,T.IRenderManagerService),Di(3,a.IPermissionService)],exports.CellCustomRenderController);class $o extends a.Disposable{constructor(){super(...arguments);w(this,"rangesStack",[]);w(this,"selectedRangeWorksheet","")}}var Zd=Object.getOwnPropertyDescriptor,Kd=(n,i,e,t)=>{for(var r=t>1?void 0:t?Zd(i,e):i,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=s(r)||r);return r},Ws=(n,i)=>(e,t)=>i(e,t,n);let hn=class{constructor(n,i){w(this,"_current",null);w(this,"_shortcutParam",[]);this._univerInstanceService=n,this._localeService=i}dispose(){this._shortcutParam=[]}getCurrentBySearch(n){return this._getCurrentBySearch(n)}getCurrent(){return this._getCurrentBySearch(this._current)}addOrUpdate(n){const i=this._getCurrentBySearch({unitId:n.unitId,sheetId:n.sheetId,keycode:n.keycode});if(i!=null){const e=this._shortcutParam.indexOf(i);this._shortcutParam.splice(e,1)}return this._shortcutParam.push(n),i}remove(n){if(n==null)return;const i=this._getCurrentBySearch(n);if(i==null)return;const e=this._shortcutParam.indexOf(i);return this._shortcutParam.splice(e,1)[0]}_getCurrentBySearch(n){return n==null?void 0:this._shortcutParam.find(e=>e.unitId===n.unitId&&e.sheetId===n.sheetId&&e.keycode===n.keycode)}};hn=Kd([Ws(0,a.IUniverInstanceService),Ws(1,a.Inject(a.LocaleService))],hn);var Ei=(n=>(n.MergeAll="mergeAll",n.MergeVertical="mergeVertical",n.MergeHorizontal="mergeHorizontal",n))(Ei||{});function ut(n,i,e,t,r=!0,o=1,s=!0){let l={...n};t==null&&(t={startRow:0,endRow:e.getRowCount()-1,startColumn:0,endColumn:e.getColumnCount()-1});let c;switch(i){case a.Direction.UP:for(c=n.startRow-o;c>-1&&!e.getRowVisible(c);)c-=1;c>=t.startRow?(l.startRow=c,l.endRow=c):s&&(l.startRow=t.endRow,l.endRow=t.endRow,r&&(l=ut(l,a.Direction.LEFT,e,t,!1)));break;case a.Direction.DOWN:for(c=n.endRow+o;c<e.getRowCount()&&!e.getRowVisible(c);)c+=1;c<=t.endRow?(l.startRow=c,l.endRow=c):s&&(l.startRow=t.startRow,l.endRow=t.startRow,r&&(l=ut(l,a.Direction.RIGHT,e,t,!1)));break;case a.Direction.LEFT:for(c=n.startColumn-o;c>-1&&!e.getColVisible(c);)c-=1;c>=t.startColumn?(l.startColumn=c,l.endColumn=c):s&&(l.startColumn=t.endColumn,l.endColumn=t.endColumn,r&&(l=ut(l,a.Direction.UP,e,t,!1)));break;case a.Direction.RIGHT:for(c=n.endColumn+o;c<e.getColumnCount()&&!e.getColVisible(c);)c+=1;c<=t.endColumn?(l.startColumn=c,l.endColumn=c):s&&(l.startColumn=t.startColumn,l.endColumn=t.startColumn,r&&(l=ut(l,a.Direction.DOWN,e,t,!1)));break}return l}function es(n,i,e){const t={...n},{startRow:r,startColumn:o,endRow:s,endColumn:l}=Kn(n,i,e);let c=On(e,r,o,s,l).hasValue,d=!0,u=!0;for(;u;){if(a.Direction.UP===i){let h=t.startRow-1;for(;h>-1&&!e.getRowVisible(h);)h-=1;if(h===-1){u=!1;break}const{hasValue:g,matrix:S}=On(e,h,t.startColumn,h,t.endColumn);if(c&&!g&&!d){u=!1;break}else{if(S.getLength()!==0){let f=h;S.forValue(p=>{f=Math.min(p,f)}),t.startRow=f}else t.startRow=h;if(t.endRow=t.startRow,!c&&g){u=!1;break}c=g,d=!1}}if(a.Direction.DOWN===i){let h=t.endRow+1;for(;h<e.getRowCount()&&!e.getRowVisible(h);)h+=1;if(h===e.getRowCount()){u=!1;break}const{hasValue:g,matrix:S}=On(e,h,t.startColumn,h,t.endColumn);if(c&&!g&&!d){u=!1;break}else{if(S.getLength()!==0){let f=h;S.forValue((p,v,C)=>{f=Math.max(p+(C.rowSpan||1)-1,f)}),t.endRow=f}else t.endRow=h;if(t.startRow=t.endRow,!c&&g){u=!1;break}c=g,d=!1}}if(a.Direction.LEFT===i){let h=t.startColumn-1;for(;h>-1&&!e.getColVisible(h);)h-=1;if(h===-1){u=!1;break}const{hasValue:g,matrix:S}=On(e,t.startRow,h,t.endRow,h);if(c&&!g&&!d){u=!1;break}else{if(S.getLength()!==0){let f=h;S.forValue((p,v)=>{f=Math.min(v,f)}),t.startColumn=f}else t.startColumn=h;if(t.endColumn=t.startColumn,!c&&g){u=!1;break}c=g,d=!1}}if(a.Direction.RIGHT===i){let h=t.endColumn+1;for(;h<e.getColumnCount()&&!e.getColVisible(h);)h+=1;if(h===e.getColumnCount()){u=!1;break}const{hasValue:g,matrix:S}=On(e,t.startRow,h,t.endRow,h);if(c&&!g&&!d){u=!1;break}else{if(S.getLength()!==0){let f=h;S.forValue((p,v,C)=>{f=Math.max(v+(C.colSpan||1)-1,f)}),t.endColumn=f}else t.endColumn=h;if(t.startColumn=t.endColumn,!c&&g){u=!1;break}c=g,d=!1}}}return m.alignToMergedCellsBorders(t,e,!0)}function Oa(n,i,e){return ut(n,i,e,void 0,!1,1,!1)}function qd(n,i,e){const t=es(n,i,e);return m.alignToMergedCellsBorders(a.Rectangle.union(t,n),e,!0)}function Qd(n,i,e){const t=Oa(n,i,e),r={startRow:Math.min(n.startRow,t.startRow),startColumn:Math.min(n.startColumn,t.startColumn),endRow:Math.max(n.endRow,t.endRow),endColumn:Math.max(n.endColumn,t.endColumn)};return m.alignToMergedCellsBorders(a.Rectangle.union(n,r),e)}function Jd(n,i,e,t){const r=a.getReverseDirection(e),o=es(Kn(n,r,t),e,t);return e===a.Direction.UP&&o.startRow<=n.startRow?m.alignToMergedCellsBorders({...i,startColumn:n.startColumn,endColumn:n.endColumn},t,!0):e===a.Direction.DOWN&&o.endRow>=n.endRow?m.alignToMergedCellsBorders({...i,startColumn:n.startColumn,endColumn:n.endColumn},t,!0):e===a.Direction.LEFT&&o.startColumn<=n.startColumn?m.alignToMergedCellsBorders({...i,startRow:n.startRow,endRow:n.endRow},t,!0):e===a.Direction.RIGHT&&o.endColumn>=n.endColumn?m.alignToMergedCellsBorders({...i,startRow:n.startRow,endRow:n.endRow},t,!0):a.Rectangle.union(a.Rectangle.clone(i),o)}function $d(n,i,e){const t=a.getReverseDirection(i),r=Kn(n,t,e),o=Kn(n,i,e),s=Oa(r,i,e);return m.alignToMergedCellsBorders(a.Rectangle.union(o,s),e,!1)}function Us(n){return{startRow:0,startColumn:0,endRow:n.getRowCount()-1,endColumn:n.getColumnCount()-1,rangeType:a.RANGE_TYPE.ALL}}function Kn(n,i,e){let t;switch(i){case a.Direction.UP:t={startRow:n.startRow,startColumn:n.startColumn,endRow:n.startRow,endColumn:n.endColumn,rangeType:a.RANGE_TYPE.NORMAL};break;case a.Direction.DOWN:t={startRow:n.endRow,startColumn:n.startColumn,endRow:n.endRow,endColumn:n.endColumn,rangeType:a.RANGE_TYPE.NORMAL};break;case a.Direction.LEFT:t={startRow:n.startRow,startColumn:n.startColumn,endRow:n.endRow,endColumn:n.startColumn,rangeType:a.RANGE_TYPE.NORMAL};break;case a.Direction.RIGHT:t={startRow:n.startRow,startColumn:n.endColumn,endRow:n.endRow,endColumn:n.endColumn,rangeType:a.RANGE_TYPE.NORMAL};break;default:throw new Error("Invalid direction")}return m.alignToMergedCellsBorders(t,e,!1)}function On(n,i,e,t,r){let o=!1;const s=n.getMatrixWithMergedCells(i,e,t,r).forValue((l,c,d)=>{if(tu(d))return o=!0,!1});return{hasValue:o,matrix:s}}function yo(n,i,e){const t=a.Rectangle.clone(n);if(i==null)return t;switch(e){case a.Direction.UP:case a.Direction.DOWN:t.startColumn=t.endColumn=i.actualColumn;break;case a.Direction.LEFT:case a.Direction.RIGHT:t.startRow=t.endRow=i.actualRow;break}return t}function eu(n,i,e){var l,c,d,u;const{primary:t,range:r}=n,o=a.Rectangle.clone(r);switch(i){case a.Direction.UP:case a.Direction.DOWN:o.startRow=(l=t==null?void 0:t.startRow)!=null?l:r.startRow,o.endRow=(c=t==null?void 0:t.endRow)!=null?c:r.startRow;break;case a.Direction.LEFT:case a.Direction.RIGHT:o.startColumn=(d=t==null?void 0:t.startColumn)!=null?d:r.startColumn,o.endColumn=(u=t==null?void 0:t.endColumn)!=null?u:r.startColumn;break}const s=Kn(o,i,e);switch(i){case a.Direction.DOWN:return r.startRow<s.startRow;case a.Direction.UP:return r.endRow>s.endRow;case a.Direction.LEFT:return s.endColumn<r.endColumn;case a.Direction.RIGHT:return s.startColumn>r.startColumn}}function Aa(n,i){let e=n[0].startRow,t=n[0].endRow;n.forEach(o=>{const{startRow:s,endRow:l}=o;e=Math.min(e,s),t=Math.max(t,l)});const r=new Array(t-e+1).fill(!1);return i.forEach(o=>{const{startRow:s,endRow:l}=o;for(let c=Math.max(s,e);c<=Math.min(l,t);c++)r[c-e]=!0}),n.every(o=>{const{startRow:s,endRow:l}=o;for(let c=s;c<=l;c++)if(!r[c-e])return!1;return!0})}function ka(n,i){let e=n[0].startColumn,t=n[0].endColumn;n.forEach(o=>{const{startColumn:s,endColumn:l}=o;e=Math.min(e,s),t=Math.max(t,l)});const r=new Array(t-e+1).fill(!1);return i.forEach(o=>{const{startColumn:s,endColumn:l}=o;for(let c=Math.max(s,e);c<=Math.min(l,t);c++)r[c-e]=!0}),n.every(o=>{const{startColumn:s,endColumn:l}=o;for(let c=s;c<=l;c++)if(!r[c-e])return!1;return!0})}function ts(n,i){return i?n==="mergeAll"?i.filter(e=>!(e.startRow===e.endRow&&e.startColumn===e.endColumn)):n==="mergeVertical"?i.filter(e=>e.startRow!==e.endRow):n==="mergeHorizontal"?i.filter(e=>e.startColumn!==e.endColumn):i:null}function tu(n){return n.v!==void 0&&n.v!==null&&n.v!==""||n.p!==void 0}var Ye=(n=>(n[n.moveStopeOne=0]="moveStopeOne",n[n.moveGap=1]="moveGap",n[n.moveStepPage=2]="moveStepPage",n[n.moveStepEnd=3]="moveStepEnd",n))(Ye||{});const ye={id:"sheet.command.move-selection",type:a.CommandType.COMMAND,handler:(n,i)=>{if(!i)return!1;const e=m.getSheetCommandTarget(n.get(a.IUniverInstanceService));if(!e)return!1;const{workbook:t,worksheet:r}=e,o=m.getSelectionsService(n,i.fromCurrentSelection).getCurrentLastSelection();if(!o)return!1;const{direction:s,jumpOver:l,extra:c}=i,{range:d,primary:u}=o,h=yo(d,u,s),g=l===1?es(h,s,r):ut(h,s,r),S=m.getCellAtRowCol(g.startRow,g.startColumn,r);if(a.Rectangle.equals(S,h))return!1;const f=t.getUnitId();n.get(hn).remove({unitId:f,sheetId:r.getSheetId(),keycode:_.KeyCode.TAB});const p=[{range:a.Rectangle.clone(S),primary:{startRow:S.startRow,startColumn:S.startColumn,endRow:S.endRow,endColumn:S.endColumn,actualRow:g.startRow,actualColumn:g.startColumn,isMerged:S.isMerged,isMergedMainCell:S.startRow===g.startRow&&S.startColumn===g.startColumn}}];return n.get(a.ICommandService).executeCommand(m.SetSelectionsOperation.id,{unitId:t.getUnitId(),subUnitId:r.getSheetId(),selections:p,type:m.SelectionMoveType.MOVE_END,extra:c,reveal:!0})}},Ge={id:"sheet.command.move-selection-enter-tab",type:a.CommandType.COMMAND,handler:(n,i)=>{var U;if(!i)return!1;const e=m.getSheetCommandTarget(n.get(a.IUniverInstanceService));if(!e)return!1;const{workbook:t,worksheet:r}=e,o=m.getSelectionsService(n),{direction:s,keycode:l}=i,c=s===a.Direction.LEFT||s===a.Direction.UP,d=o.getCurrentSelections().concat(),u=d.findIndex(L=>L.primary),h=d[u];if(!h)return!1;const g=c?-1:1,S=u+g!==d.length?d[u+g]:d[0],f=d.findIndex(L=>L===S),p=t.getUnitId(),v=r.getSheetId();if(!h)return!1;const{range:C}=h,b=h.primary;let R=yo(C,b,s);const E=n.get(hn),P=E.getCurrentBySearch({unitId:p,sheetId:v,keycode:_.KeyCode.TAB});let y;const{startRow:M,endRow:x,startColumn:A,endColumn:k}=C,D=c?b.startRow===M&&b.startColumn===A:b.endRow===x&&b.endColumn===k;if(a.Rectangle.equals(C,b)){if(l===_.KeyCode.TAB)P==null&&E.addOrUpdate({unitId:p,sheetId:v,keycode:_.KeyCode.TAB,selection:h});else{const B=P==null?void 0:P.selection;if(B!=null){const{range:F,primary:X}=B;R=yo(F,X,s)}E.remove({unitId:p,sheetId:v,keycode:_.KeyCode.TAB})}const L=ut(R,s,r),j=m.getCellAtRowCol(L.startRow,L.startColumn,r);if(a.Rectangle.equals(j,R))return!1;y={range:a.Rectangle.clone(j),primary:{startRow:j.startRow,startColumn:j.startColumn,endRow:j.endRow,endColumn:j.endColumn,actualRow:L.startRow,actualColumn:L.startColumn,isMerged:j.isMerged,isMergedMainCell:j.startRow===L.startRow&&j.startColumn===L.startColumn}}}else{E.remove({unitId:p,sheetId:v,keycode:_.KeyCode.TAB});const L=a.Tools.deepClone(b),j=D?S.range:ut({startRow:L.startRow,startColumn:L.startColumn,endRow:L.endRow,endColumn:L.endColumn},s,r,{startRow:M,endRow:x,startColumn:A,endColumn:k}),B=D&&c,F=B?m.getCellAtRowCol(j.endRow,j.endColumn,r):m.getCellAtRowCol(j.startRow,j.startColumn,r);y={range:D?S.range:a.Rectangle.clone(C),primary:{startRow:F.startRow,startColumn:F.startColumn,endRow:F.endRow,endColumn:F.endColumn,actualRow:B?F.startRow:j.startRow,actualColumn:B?F.startColumn:j.startColumn,isMerged:F.isMerged,isMergedMainCell:F.startRow===j.startRow&&F.startColumn===j.startColumn},style:D?S.style:h.style}}D?(d[u].primary=null,d[f]=y,o.setSelections(p,v,[],m.SelectionMoveType.MOVE_END)):d[u]=y;const N=n.get(a.ICommandService).executeCommand(m.SetSelectionsOperation.id,{unitId:p,subUnitId:v,type:m.SelectionMoveType.MOVE_END,selections:d,reveal:!0,extra:i.extra}),V=(U=n.get(T.IRenderManagerService).getRenderById(p))==null?void 0:U.with(pe);return V==null||V.refreshSelectionMoveEnd(),N}},Oe={id:"sheet.command.expand-selection",type:a.CommandType.COMMAND,handler:(n,i)=>{if(!i)return!1;const e=m.getSheetCommandTarget(n.get(a.IUniverInstanceService));if(!e)return!1;const{worksheet:t,unitId:r,subUnitId:o}=e,s=m.getSelectionsService(n).getCurrentLastSelection();if(!s)return!1;const{range:l,primary:c}=s,{jumpOver:d,direction:u,extra:h}=i,S=eu(s,u,t)?d===1?Jd(l,{...a.Rectangle.clone(c),rangeType:a.RANGE_TYPE.NORMAL},u,t):$d(l,u,t):d===1?qd(l,u,t):Qd(l,u,t);return S.rangeType=s.range.rangeType,a.Rectangle.equals(S,l)?!1:n.get(a.ICommandService).syncExecuteCommand(m.SetSelectionsOperation.id,{unitId:r,subUnitId:o,type:m.SelectionMoveType.MOVE_END,selections:[{range:S,primary:c}],extra:h,reveal:!0})}},sr={id:"sheet.command.select-all",type:a.CommandType.COMMAND,handler:async(n,i={expandToGapFirst:!0,loop:!1})=>{const e=m.getSheetCommandTarget(n.get(a.IUniverInstanceService));if(!e)return!1;const t=m.getSelectionsService(n).getCurrentLastSelection();if(!t)return!1;const r=n.get($o),{worksheet:o,unitId:s,subUnitId:l}=e,c=`${s}|${l}`;c!==r.selectedRangeWorksheet&&(r.rangesStack=[],r.selectedRangeWorksheet=c);const d=o.getMaxRows(),u=o.getMaxColumns(),{expandToGapFirst:h,loop:g}=i,{range:S,primary:f}=t,p=S.endColumn===u-1&&S.endRow===d-1&&S.startRow===0&&S.startColumn===0;r.rangesStack.some(P=>a.Rectangle.equals(P,S))||(r.rangesStack=[],r.rangesStack.push(S));let v;if(p)if(g){if(r.rangesStack.findIndex(y=>a.Rectangle.equals(y,S))!==r.rangesStack.length-1)return!1;v=r.rangesStack[0]}else return!1;else h?(v=m.expandToContinuousRange(S,{left:!0,right:!0,up:!0,down:!0},o),a.Rectangle.equals(v,S)&&(v=Us(o))):v=Us(o);r.rangesStack.some(P=>a.Rectangle.equals(P,v))||r.rangesStack.push(v);const C=[];C.push({id:m.SetSelectionsOperation.id,params:{unitId:s,subUnitId:l,reveal:!0,selections:[{range:v,primary:f}]}});const R=n.get(m.SheetInterceptorService).onCommandExecute({id:sr.id,params:{range:S}});R.redos.length&&C.push(...R.redos);const E=n.get(a.ICommandService);return a.sequenceExecute(C,E),!0}};var nu=Object.getOwnPropertyDescriptor,ru=(n,i,e,t)=>{for(var r=t>1?void 0:t?nu(i,e):i,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=s(r)||r);return r},iu=(n,i)=>(e,t)=>i(e,t,n);exports.SheetScrollManagerService=class{constructor(i,e){w(this,"_scrollStateMap",new Map);w(this,"_rawScrollInfo$",new O.BehaviorSubject(null));w(this,"rawScrollInfo$",this._rawScrollInfo$.asObservable());w(this,"validViewportScrollInfo$",new O.BehaviorSubject(null));w(this,"_searchParamForScroll",null);this._context=i,this._sheetSkeletonManagerService=e}dispose(){this._rawScrollInfo$.complete()}calcViewportScrollFromRowColOffset(i){if(!i)return{viewportScrollX:0,viewportScrollY:0};let{sheetViewStartColumn:e,sheetViewStartRow:t,offsetX:r,offsetY:o}=i;t=t||0,o=o||0;const s=this._sheetSkeletonManagerService.getCurrentSkeleton(),l=(s==null?void 0:s.rowHeightAccumulation[t-1])||0,d=((s==null?void 0:s.columnWidthAccumulation[e-1])||0)+r,u=l+o;return{viewportScrollX:d,viewportScrollY:u}}setSearchParam(i){this._searchParamForScroll=i}getScrollStateByParam(i){return this._getCurrentScroll(i)}getCurrentScrollState(){return this._getCurrentScroll(this._searchParamForScroll)}setValidScrollState(i){this._setScrollState(i)}emitRawScrollParam(i){this._emitRawScroll(i)}setValidScrollStateToCurrSheet(i){if(this._searchParamForScroll==null)return;this._setScrollState({...this._searchParamForScroll,...i});const e=this._searchParamForScroll.sheetId,t=this._sheetSkeletonManagerService.getSkeleton(e);t&&t.setScroll(i.viewportScrollX,i.viewportScrollY)}clear(){this._searchParamForScroll!=null&&this._clearByParamAndNotify(this._searchParamForScroll)}_setScrollState(i){const{unitId:e,sheetId:t,sheetViewStartColumn:r,sheetViewStartRow:o,offsetX:s,offsetY:l}=i;this._scrollStateMap.has(e)||this._scrollStateMap.set(e,new Map);const c=this._scrollStateMap.get(e),d={sheetViewStartRow:o,sheetViewStartColumn:r,offsetX:s,offsetY:l};c.set(t,d)}_clearByParamAndNotify(i){this._setScrollState({...i,sheetViewStartRow:0,sheetViewStartColumn:0,offsetX:0,offsetY:0}),this._emitRawScroll({sheetViewStartRow:0,sheetViewStartColumn:0,offsetX:0,offsetY:0})}_getCurrentScroll(i){var s;const e={sheetViewStartRow:0,sheetViewStartColumn:0,offsetX:0,offsetY:0};if(i==null)return e;const{unitId:t,sheetId:r}=i;return((s=this._scrollStateMap.get(t))==null?void 0:s.get(r))||e}_emitRawScroll(i){this._rawScrollInfo$.next(i)}};exports.SheetScrollManagerService=ru([iu(1,a.Inject(exports.SheetSkeletonManagerService))],exports.SheetScrollManagerService);const We={id:"sheet.operation.set-scroll",type:a.CommandType.OPERATION,handler:(n,i)=>{if(!i)return!1;const{unitId:e,sheetId:t,offsetX:r,offsetY:o,sheetViewStartColumn:s,sheetViewStartRow:l}=i;return n.get(T.IRenderManagerService).getRenderById(e).with(exports.SheetScrollManagerService).emitRawScrollParam({unitId:e,sheetId:t,offsetX:r,offsetY:o,sheetViewStartRow:l,sheetViewStartColumn:s}),!0}},mn={id:"sheet.command.set-scroll-relative",type:a.CommandType.COMMAND,handler:async(n,i)=>{const e=n.get(a.ICommandService),t=n.get(a.IUniverInstanceService),r=n.get(T.IRenderManagerService),o=m.getSheetCommandTarget(t);if(!o)return!1;const{unitId:s,subUnitId:l}=o,d=r.getRenderById(s).with(exports.SheetScrollManagerService).getCurrentScrollState(),{offsetX:u=0,offsetY:h=0}=i||{},{sheetViewStartRow:g=0,sheetViewStartColumn:S=0,offsetX:f=0,offsetY:p=0}=d||{};return e.executeCommand(We.id,{unitId:s,sheetId:l,sheetViewStartRow:g,sheetViewStartColumn:S,offsetX:f+u,offsetY:p+h})}},Ue={id:"sheet.command.scroll-view",type:a.CommandType.COMMAND,handler:(n,i)=>{if(!i)return!1;const e=n.get(a.IUniverInstanceService),t=n.get(T.IRenderManagerService),r=m.getSheetCommandTarget(e);if(!r)return!1;const{workbook:o,worksheet:s,unitId:l}=r,d=t.getRenderById(l).with(exports.SheetScrollManagerService).getCurrentScrollState();if(!s)return!1;const{sheetViewStartRow:u,sheetViewStartColumn:h,offsetX:g,offsetY:S}=i,{sheetViewStartColumn:f,sheetViewStartRow:p,offsetX:v,offsetY:C}=d||{},{xSplit:b,ySplit:R}=r.worksheet.getConfig().freeze;return n.get(a.ICommandService).syncExecuteCommand(We.id,{unitId:o.getUnitId(),sheetId:s.getSheetId(),sheetViewStartRow:u!=null?u:p!=null?p:0+R,sheetViewStartColumn:h!=null?h:f!=null?f:0+b,offsetX:g!=null?g:v,offsetY:S!=null?S:C})}},ns={id:"sheet.command.scroll-to-cell",type:a.CommandType.COMMAND,handler:(n,i)=>{const e=n.get(a.IUniverInstanceService);return n.get(T.IRenderManagerService).getRenderById(e.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getUnitId()).with(exports.SheetsScrollRenderController).scrollToRange(i.range,i.forceTop,i.forceLeft)}},ou={id:"sheet.command.scroll-view-reset",type:a.CommandType.COMMAND,handler:async n=>{const i=n.get(a.IUniverInstanceService),e=m.getSheetCommandTarget(i);if(!e)return!1;const{subUnitId:t,unitId:r}=e;return n.get(a.ICommandService).executeCommand(We.id,{unitId:r,sheetId:t,sheetViewStartRow:0,sheetViewStartColumn:0})}};var su=Object.getOwnPropertyDescriptor,au=(n,i,e,t)=>{for(var r=t>1?void 0:t?su(i,e):i,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=s(r)||r);return r},qt=(n,i)=>(e,t)=>i(e,t,n);ye.id,Ge.id;const lu=3;exports.SheetsScrollRenderController=class extends a.Disposable{constructor(i,e,t,r,o,s,l){super(),this._context=i,this._injector=e,this._sheetSkeletonManagerService=t,this._contextService=r,this._commandService=o,this._renderManagerService=s,this._scrollManagerService=l,this._initCommandListener(),this._wheelEventListener(),this._scrollBarEventListener(),this._initSkeletonListener()}_wheelEventListener(){const{scene:i}=this._context;if(!i)return;const e=i.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN);e&&this.disposeWithMe(i.onMouseWheel$.subscribeEvent((t,r)=>{if(t.ctrlKey||!this._contextService.getContextValue(a.FOCUSING_SHEET))return;let o=0,s=0;o=t.deltaX,t.shiftKey?o=(t.deltaY||t.deltaX)*lu:s=t.deltaY,this._commandService.executeCommand(mn.id,{offsetX:o,offsetY:s}),this._context.scene.makeDirty(!0);const l=e.limitedScroll(e.scrollX+o,e.scrollY+s);l&&!l.isLimitedX&&!l.isLimitedY&&(t.preventDefault(),i.getParent().classType===T.RENDER_CLASS_TYPE.SCENE_VIEWER&&r.stopPropagation()),e.isWheelPreventDefaultX&&e.isWheelPreventDefaultY&&t.preventDefault()}))}_scrollBarEventListener(){const{scene:i}=this._context;if(i==null)return;const e=i.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN);e&&(this.disposeWithMe(a.toDisposable(this._scrollManagerService.rawScrollInfo$.subscribe(t=>{var S;const r=(S=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:S.skeleton;if(!r)return;if(t==null){e.scrollToViewportPos({viewportScrollX:0,viewportScrollY:0});return}const{sheetViewStartRow:o,sheetViewStartColumn:s,offsetX:l,offsetY:c}=t,{startX:d,startY:u}=r.getCellWithCoordByIndex(o,s,!1),h=d+l,g=u+c;e.scrollToViewportPos({viewportScrollX:h,viewportScrollY:g})}))),this.disposeWithMe(e.onScrollAfter$.subscribeEvent(t=>{var p;const r=(p=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:p.skeleton;if(r==null||t.isTrigger===!1)return;const o=this._getSheetObject();if(r==null||o==null)return;const{viewportScrollX:s,viewportScrollY:l,scrollX:c,scrollY:d}=t,{row:u,column:h,rowOffset:g,columnOffset:S}=r.getOffsetRelativeToRowCol(s,l),f={sheetViewStartRow:u,sheetViewStartColumn:h,offsetX:S,offsetY:g,viewportScrollX:s,viewportScrollY:l,scrollX:c,scrollY:d};this._scrollManagerService.setValidScrollStateToCurrSheet(f),this._scrollManagerService.validViewportScrollInfo$.next({...f,viewportScrollX:s,viewportScrollY:l,scrollX:c,scrollY:d})})),this.disposeWithMe(e.onScrollByBar$.subscribeEvent(t=>{var g;const r=(g=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:g.skeleton;if(r==null||t.isTrigger===!1)return;const o=this._getSheetObject();if(r==null||o==null)return;const{viewportScrollX:s=0,viewportScrollY:l=0}=t;this._getFreeze();const{row:c,column:d,rowOffset:u,columnOffset:h}=r.getOffsetRelativeToRowCol(s,l);this._commandService.executeCommand(Ue.id,{sheetViewStartRow:c,sheetViewStartColumn:d,offsetX:h,offsetY:u})})))}_initSkeletonListener(){this.disposeWithMe(a.toDisposable(this._sheetSkeletonManagerService.currentSkeletonBefore$.subscribe(i=>{if(i==null)return;const e={unitId:i.unitId,sheetId:i.sheetId};if(this._scrollManagerService.setSearchParam(e),!this._getSheetObject())return;const r=this._scrollManagerService.getScrollStateByParam(e),{viewportScrollX:o,viewportScrollY:s}=this._scrollManagerService.calcViewportScrollFromRowColOffset(r);r&&this._updateViewportScroll(o,s)})))}_updateViewportScroll(i=0,e=0){const t=this._getSheetObject();if(!t)return;const r=t.scene,o=r.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN),s=r.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_COLUMN_RIGHT),l=r.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_ROW_BOTTOM),c=r.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT),d=r.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN_TOP);o&&(o.viewportScrollX=i,o.viewportScrollY=e),l&&(l.viewportScrollY=e),s&&(s.viewportScrollX=i),c&&(c.viewportScrollY=e),d&&(d.viewportScrollX=i)}scrollToRange(i,e,t){let{endRow:r,endColumn:o,startColumn:s,startRow:l}=i;const c=this._getViewportBounding();if(i.rangeType===a.RANGE_TYPE.ROW?(s=0,o=0):i.rangeType===a.RANGE_TYPE.COLUMN&&(l=0,r=0),c&&!e&&!t){const d=c.startRow>r?l:r,u=c.startColumn>o?s:o;return this._scrollToCell(d,u)}else return this._scrollToCell(l,s,e,t)}scrollToCell(i,e){const t=this._context.unit.getActiveSheet(),{ySplit:r,xSplit:o}=t.getFreeze();return this._commandService.syncExecuteCommand(Ue.id,{sheetViewStartRow:i-r,sheetViewStartColumn:e-o,offsetX:0,offsetY:0})}_initCommandListener(){this.disposeWithMe(this._commandService.onCommandExecuted(i=>{switch(i.id){case m.SetSelectionsOperation.id:{const e=i.params;e.unitId===this._context.unitId&&e.reveal&&this._scrollToSelection()}break;case m.ScrollToCellOperation.id:{const e=i.params;if(e.unitId===this._context.unitId){const t=e.range;this.scrollToRange(t)}}break;case Oe.id:{const e=i.params;this._scrollToSelectionForExpand(e)}break}}))}_scrollToSelectionForExpand(i){setTimeout(()=>{const e=this._getSelectionsService().getCurrentLastSelection();if(e==null)return;const{startRow:t,startColumn:r,endRow:o,endColumn:s}=e.range,l=this._getViewportBounding();if(l==null)return;const{startRow:c,startColumn:d,endRow:u,endColumn:h}=l;let g=0,S=0;t>c?g=o:o<u?g=t:g=c,r>d?S=s:s<h?S=r:S=d,i.direction===a.Direction.DOWN?g=o:i.direction===a.Direction.UP?g=t:i.direction===a.Direction.RIGHT?S=s:i.direction===a.Direction.LEFT&&(S=r),this._scrollToCell(g,S)},0)}_getFreeze(){var e;const i=(e=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:e.skeleton.getWorksheetConfig();if(i!=null)return i.freeze}_updateSceneSize(i){var h;if(i==null)return;const{unitId:e}=this._context,{skeleton:t}=i,r=(h=this._renderManagerService.getRenderById(e))==null?void 0:h.scene;if(t==null||r==null)return;const{rowTotalHeight:o,columnTotalWidth:s,rowHeaderWidthAndMarginLeft:l,columnHeaderHeightAndMarginTop:c}=t;this._context.unit.getActiveSheet()&&(r==null||r.transformByState({width:l+s,height:c+o}))}_getSheetObject(){return Ve(this._context.unit,this._context)}_scrollToSelectionByDirection(i){const e=this._getViewportBounding();if(e==null)return!1;const{startRow:t,startColumn:r,endRow:o,endColumn:s}=e;let l=0,c=0;const{startRow:d,startColumn:u,endRow:h,endColumn:g}=i;d>=t&&(l=h),h<=o&&(l=d),u>=r&&(c=g),g<=s&&(c=u),this._scrollToCell(l,c)}_scrollToSelection(i=!0){var d;const e=this._getSelectionsService().getCurrentLastSelection();if(!e)return;const{startRow:t,startColumn:r,actualRow:o,actualColumn:s}=(d=e.primary)!=null?d:e.range,l=i&&o!=null?o:t,c=i&&s!=null?s:r;this._scrollToCell(l,c)}_getSelectionsService(){return m.getSelectionsService(this._injector)}_getViewportBounding(){var o,s;const i=(o=this._getSheetObject())==null?void 0:o.scene;if(i==null)return;const e=i.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN);if(e==null)return;const t=(s=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:s.skeleton;if(t==null)return;const r=e.calcViewportInfo();return t.getRangeByViewBound(r.viewBound)}_scrollToCell(i,e,t=!1,r=!1){var k,D,N;const{rowHeightAccumulation:o,columnWidthAccumulation:s}=(k=this._sheetSkeletonManagerService.getCurrentSkeleton())!=null?k:{};if(o==null||s==null)return!1;const l=(D=this._getSheetObject())==null?void 0:D.scene;if(l==null)return!1;const c=l.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN);if(c==null)return!1;const d=(N=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:N.skeleton;if(d==null)return!1;const u=this._context.unit.getActiveSheet();if(!u)return!1;i=a.Tools.clamp(i,0,o.length-1),e=a.Tools.clamp(e,0,s.length-1);const{startColumn:h,startRow:g,ySplit:S,xSplit:f}=u.getFreeze(),p=this._getViewportBounding();if(p==null)return!1;const{startRow:v,startColumn:C,endRow:b,endColumn:R}=p;let E,P;if(i>=g&&e>=h-S&&(i<=v&&(E=i,t=!0),i>=b)){const W=o[i]-c.height;for(let V=v;V<=i&&(E=V+1,!(o[V]>=W));V++);}if(e>=h&&i>=g-S&&(e<=C&&(P=e,r=!0),e>=R)){const W=s[e]-c.width;for(let V=C;V<=e&&(P=V+1,!(s[V]>=W));V++);}if(E===void 0&&P===void 0)return!1;let{offsetX:y,offsetY:M,sheetViewStartRow:x,sheetViewStartColumn:A}=this._scrollManagerService.getCurrentScrollState()||{};if(E=E?Math.min(E,i):x+S,P=P?Math.min(P,e):A+f,r){y=0,P=e;const W=d.getHiddenColumnsInRange({startColumn:P-f,endColumn:P});P=P-W.length}if(t){M=0,E=i;const W=d.getHiddenRowsInRange({startRow:E-S,endRow:E});E=E-W.length}return this._commandService.syncExecuteCommand(Ue.id,{sheetViewStartRow:Math.max(0,E-S),sheetViewStartColumn:Math.max(0,P-f),offsetX:y,offsetY:M})}};exports.SheetsScrollRenderController=au([qt(1,a.Inject(a.Injector)),qt(2,a.Inject(exports.SheetSkeletonManagerService)),qt(3,a.IContextService),qt(4,a.ICommandService),qt(5,T.IRenderManagerService),qt(6,a.Inject(exports.SheetScrollManagerService))],exports.SheetsScrollRenderController);const rs={id:"sheet.operation.scroll-to-range",type:a.CommandType.OPERATION,handler:(n,i)=>{if(!i)return!1;const e=n.get(a.IUniverInstanceService);return n.get(T.IRenderManagerService).getRenderById(e.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getUnitId()).with(exports.SheetsScrollRenderController).scrollToRange(i.range,i.forceTop,i.forceLeft)}};class Da{constructor(){w(this,"_state",null);w(this,"_rect",null);w(this,"_state$",new O.BehaviorSubject(null));w(this,"state$",this._state$.asObservable());w(this,"_rect$",new O.BehaviorSubject(null));w(this,"rect$",this._rect$.asObservable());w(this,"_focus",!1);w(this,"_focus$",new O.BehaviorSubject(this._focus));w(this,"focus$",this._focus$.asObservable())}dispose(){this._state$.complete(),this._state=null,this._rect$.complete(),this._rect=null}setState(i){this._state=i,this._refresh(i)}getRect(){return this._rect}setRect(i){this._rect=i,this._rect$.next(i)}getState(){return this._state}setFocus(i=!1){this._focus=i,this._focus$.next(i)}_refresh(i){this._state$.next(i)}}const ar=a.createIdentifier("univer.sheet-cell-editor-manager.service");var Ae=function(){return Ae=Object.assign||function(n){for(var i,e=1,t=arguments.length;e<t;e++){i=arguments[e];for(var r in i)Object.prototype.hasOwnProperty.call(i,r)&&(n[r]=i[r])}return n},Ae.apply(this,arguments)},cu=function(n,i){var e={};for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&i.indexOf(t)<0&&(e[t]=n[t]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,t=Object.getOwnPropertySymbols(n);r<t.length;r++)i.indexOf(t[r])<0&&Object.prototype.propertyIsEnumerable.call(n,t[r])&&(e[t[r]]=n[t[r]]);return e},_e=H.forwardRef(function(n,i){var e=n.icon,t=n.id,r=n.className,o=n.extend,s=cu(n,["icon","id","className","extend"]),l="univerjs-icon univerjs-icon-".concat(t," ").concat(r||"").trim(),c=H.useRef("_".concat(hu()));return Na(e,"".concat(t),{defIds:e.defIds,idSuffix:c.current},Ae({ref:i,className:l},s),o)});function Na(n,i,e,t,r){return H.createElement(n.tag,Ae(Ae({key:i},du(n,e,r)),t),(uu(n,e).children||[]).map(function(o,s){return Na(o,"".concat(i,"-").concat(n.tag,"-").concat(s),e,void 0,r)}))}function du(n,i,e){var t=Ae({},n.attrs);e!=null&&e.colorChannel1&&t.fill==="colorChannel1"&&(t.fill=e.colorChannel1),n.tag==="mask"&&t.id&&(t.id=t.id+i.idSuffix),Object.entries(t).forEach(function(o){var s=o[0],l=o[1];s==="mask"&&typeof l=="string"&&(t[s]=l.replace(/url\(#(.*)\)/,"url(#$1".concat(i.idSuffix,")")))});var r=i.defIds;return!r||r.length===0||(n.tag==="use"&&t["xlink:href"]&&(t["xlink:href"]=t["xlink:href"]+i.idSuffix),Object.entries(t).forEach(function(o){var s=o[0],l=o[1];typeof l=="string"&&(t[s]=l.replace(/url\(#(.*)\)/,"url(#$1".concat(i.idSuffix,")")))})),t}function uu(n,i){var e,t=i.defIds;return!t||t.length===0?n:n.tag==="defs"&&(!((e=n.children)===null||e===void 0)&&e.length)?Ae(Ae({},n),{children:n.children.map(function(r){return typeof r.attrs.id=="string"&&t&&t.indexOf(r.attrs.id)>-1?Ae(Ae({},r),{attrs:Ae(Ae({},r.attrs),{id:r.attrs.id+i.idSuffix})}):r})}):n}function hu(){return Math.random().toString(36).substring(2,8)}_e.displayName="UniverIcon";var mu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"colorChannel1",d:"M11.0363 12.2367V14.0367C11.0363 14.3681 11.3049 14.6367 11.6363 14.6367C11.9676 14.6367 12.2363 14.3681 12.2363 14.0367V12.2367H14.0364C14.3677 12.2367 14.6364 11.9681 14.6364 11.6367C14.6364 11.3054 14.3677 11.0367 14.0364 11.0367H12.2363V9.23672C12.2363 8.90535 11.9676 8.63672 11.6363 8.63672C11.3049 8.63672 11.0363 8.90535 11.0363 9.23672V11.0367H9.23635C8.90498 11.0367 8.63635 11.3054 8.63635 11.6367C8.63635 11.9681 8.90498 12.2367 9.23635 12.2367H11.0363Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M2.56365 1.36377C1.90091 1.36377 1.36365 1.90103 1.36365 2.56377V6.16377C1.36365 6.82651 1.90091 7.36377 2.56365 7.36377H6.16365C6.82639 7.36377 7.36365 6.82651 7.36365 6.16377V2.56377C7.36365 1.90103 6.82639 1.36377 6.16365 1.36377H2.56365zM6.16365 2.56377H2.56365L2.56365 6.16377H6.16365V2.56377zM2.56365 8.63647C1.90091 8.63647 1.36365 9.17373 1.36365 9.83647V13.4365C1.36365 14.0992 1.90091 14.6365 2.56365 14.6365H6.16365C6.82639 14.6365 7.36365 14.0992 7.36365 13.4365V9.83647C7.36365 9.17373 6.82639 8.63647 6.16365 8.63647H2.56365zM6.16365 9.83647H2.56365L2.56365 13.4365H6.16365V9.83647zM9.83635 7.36377C9.17361 7.36377 8.63635 6.82651 8.63635 6.16377V2.56377C8.63635 1.90103 9.17361 1.36377 9.83635 1.36377H13.4364C14.0991 1.36377 14.6364 1.90103 14.6364 2.56377V6.16377C14.6364 6.82651 14.0991 7.36377 13.4364 7.36377H9.83635zM9.83635 6.16377V2.56377L13.4364 2.56377V6.16377H9.83635z",fillRule:"evenodd",clipRule:"evenodd"}}]},Va=H.forwardRef(function(n,i){return H.createElement(_e,Object.assign({},n,{id:"autofill",ref:i,icon:mu}))});Va.displayName="Autofill";var gu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M14.1544 3.75557C14.3887 3.98988 14.3887 4.36978 14.1544 4.6041L6.51409 12.2444C6.40157 12.3569 6.24896 12.4201 6.08983 12.4201C5.9307 12.4201 5.77808 12.3569 5.66556 12.2444L1.84541 8.42425C1.6111 8.18993 1.6111 7.81003 1.84541 7.57572C2.07973 7.34141 2.45963 7.34141 2.69394 7.57572L6.08983 10.9716L13.3059 3.75557C13.5402 3.52126 13.9201 3.52126 14.1544 3.75557Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Ut=H.forwardRef(function(n,i){return H.createElement(_e,Object.assign({},n,{id:"check-mark-single",ref:i,icon:gu}))});Ut.displayName="CheckMarkSingle";var Su={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M3.71274 2.86421C3.47843 2.6299 3.09853 2.6299 2.86421 2.86421C2.6299 3.09853 2.6299 3.47843 2.86421 3.71274L7.15154 8.00007L2.86421 12.2874C2.6299 12.5217 2.6299 12.9016 2.86421 13.1359C3.09853 13.3702 3.47843 13.3702 3.71274 13.1359L8.00007 8.84859L12.2874 13.1359C12.5217 13.3702 12.9016 13.3702 13.1359 13.1359C13.3702 12.9016 13.3702 12.5217 13.1359 12.2874L8.84859 8.00007L13.1359 3.71274C13.3702 3.47843 13.3702 3.09853 13.1359 2.86421C12.9016 2.6299 12.5217 2.6299 12.2874 2.86421L8.00007 7.15154L3.71274 2.86421Z"}}]},Ha=H.forwardRef(function(n,i){return H.createElement(_e,Object.assign({},n,{id:"close-single",ref:i,icon:Su}))});Ha.displayName="CloseSingle";var fu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"g",attrs:{fill:"currentColor",clipPath:"url(#convert-single_clip0_911_593)"},children:[{tag:"path",attrs:{d:"M2.44766.848145C1.564.848145.847656 1.56449.847656 2.44814V6.44814C.847656 7.3318 1.564 8.04814 2.44766 8.04814H6.44766C7.33131 8.04814 8.04766 7.3318 8.04766 6.44814V2.44814C8.04766 1.56449 7.33131.848145 6.44766.848145H2.44766zM2.04766 6.44814V5.04824H3.84775V6.84814H2.44766C2.22674 6.84814 2.04766 6.66906 2.04766 6.44814zM2.04766 3.84824H3.84775V2.04814H2.44766C2.22674 2.04814 2.04766 2.22723 2.04766 2.44814V3.84824zM5.04775 6.84814V5.04824H6.84766V6.44814C6.84766 6.66906 6.66857 6.84814 6.44766 6.84814H5.04775zM5.04775 3.84824H6.84766V2.44814C6.84766 2.22723 6.66857 2.04814 6.44766 2.04814H5.04775V3.84824zM9.55215 7.95166C8.66849 7.95166 7.95215 8.668 7.95215 9.55166V13.5517C7.95215 14.4353 8.66849 15.1517 9.55215 15.1517L11.5522 15.1517 13.5521 15.1517C14.4358 15.1517 15.1521 14.4353 15.1521 13.5517L15.1521 11.5518 15.1521 9.55166C15.1521 8.668 14.4358 7.95166 13.5521 7.95166H9.55215zM13.9521 10.9518V9.55166C13.9521 9.33075 13.7731 9.15166 13.5521 9.15166H12.1522V10.9518H13.9521zM10.9522 10.9518V9.15166H9.55215C9.33123 9.15166 9.15215 9.33075 9.15215 9.55166V10.9518H10.9522zM9.15215 12.1518H10.9522V13.9517H9.55215C9.33123 13.9517 9.15215 13.7726 9.15215 13.5517V12.1518zM12.1522 12.1518H13.9521V13.5517C13.9521 13.7726 13.7731 13.9517 13.5521 13.9517H12.1522V12.1518z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{d:"M9.62158 2.44912C9.62158 2.11775 9.89021 1.84912 10.2216 1.84912H12.7516C13.6352 1.84912 14.3516 2.56547 14.3516 3.44912V5.9791C14.3516 6.31047 14.0829 6.5791 13.7516 6.5791 13.4202 6.5791 13.1516 6.31047 13.1516 5.9791V3.44912C13.1516 3.22821 12.9725 3.04912 12.7516 3.04912H10.2216C9.89021 3.04912 9.62158 2.78049 9.62158 2.44912zM5.77871 14.1507C6.11008 14.1507 6.37871 13.8821 6.37871 13.5507 6.37871 13.2193 6.11008 12.9507 5.77871 12.9507L3.24873 12.9507C3.02782 12.9507 2.84873 12.7716 2.84873 12.5507L2.84873 10.0207C2.84873 9.68933 2.5801 9.4207 2.24873 9.4207 1.91736 9.4207 1.64873 9.68933 1.64873 10.0207L1.64873 12.5507C1.64873 13.4343 2.36507 14.1507 3.24873 14.1507H5.77871z"}}]},{tag:"defs",attrs:{},children:[{tag:"clipPath",attrs:{id:"convert-single_clip0_911_593"},children:[{tag:"path",attrs:{fill:"#fff",d:"M0 0H16V16H0z"}}]}]}],defIds:["convert-single_clip0_911_593"]},Wa=H.forwardRef(function(n,i){return H.createElement(_e,Object.assign({},n,{id:"convert-single",ref:i,icon:fu}))});Wa.displayName="ConvertSingle";var pu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.3313 1.4667C5.3313 1.13533 5.59993.866699 5.9313.866699H10.069C10.4004.866699 10.669 1.13533 10.669 1.4667 10.669 1.79807 10.4004 2.0667 10.069 2.0667H5.9313C5.59993 2.0667 5.3313 1.79807 5.3313 1.4667zM1.09985 3.64443C1.09985 3.31306 1.36848 3.04443 1.69985 3.04443H14.2999C14.6312 3.04443 14.8999 3.31306 14.8999 3.64443 14.8999 3.9758 14.6312 4.24443 14.2999 4.24443H1.69985C1.36848 4.24443 1.09985 3.9758 1.09985 3.64443zM6.12398 8.30171C6.35829 8.0674 6.73819 8.0674 6.97251 8.30171L8.00007 9.32928 9.02764 8.30171C9.26195 8.0674 9.64185 8.0674 9.87617 8.30171 10.1105 8.53603 10.1105 8.91593 9.87617 9.15024L8.8486 10.1778 9.87617 11.2054C10.1105 11.4397 10.1105 11.8196 9.87617 12.0539 9.64185 12.2882 9.26195 12.2882 9.02764 12.0539L8.00007 11.0263 6.97251 12.0539C6.73819 12.2882 6.35829 12.2882 6.12398 12.0539 5.88966 11.8196 5.88966 11.4397 6.12398 11.2054L7.15154 10.1778 6.12398 9.15024C5.88966 8.91593 5.88966 8.53603 6.12398 8.30171z"}},{tag:"path",attrs:{fill:"currentColor",d:"M4.75332 5.22217C3.86966 5.22217 3.15332 5.93851 3.15332 6.82217V12.5331C3.15332 13.9691 4.31738 15.1332 5.75332 15.1332H10.2465C11.6825 15.1332 12.8465 13.9691 12.8465 12.5331V6.82217C12.8465 5.93851 12.1302 5.22217 11.2465 5.22217H4.75332ZM4.35332 6.82217C4.35332 6.60125 4.53241 6.42217 4.75332 6.42217H11.2465C11.4674 6.42217 11.6465 6.60125 11.6465 6.82217V12.5331C11.6465 13.3063 11.0197 13.9332 10.2465 13.9332H5.75332C4.98012 13.9332 4.35332 13.3063 4.35332 12.5331V6.82217Z",fillRule:"evenodd",clipRule:"evenodd"}}]},wi=H.forwardRef(function(n,i){return H.createElement(_e,Object.assign({},n,{id:"delete-single",ref:i,icon:pu}))});wi.displayName="DeleteSingle";var vu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.85869 12.9216C8.38445 13.4708 7.61555 13.4708 7.14131 12.9216L0.358114 5.06726C-0.406895 4.18144 0.134916 2.66683 1.2168 2.66683L14.7832 2.66683C15.8651 2.66683 16.4069 4.18144 15.6419 5.06726L8.85869 12.9216Z"}}]},Mo=H.forwardRef(function(n,i){return H.createElement(_e,Object.assign({},n,{id:"dropdown-single",ref:i,icon:vu}))});Mo.displayName="DropdownSingle";var Cu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M15 8C15 11.866 11.866 15 8 15C4.13401 15 1 11.866 1 8C1 4.13401 4.13401 1 8 1C11.866 1 15 4.13401 15 8ZM10.3097 5.69014C10.544 5.92445 10.544 6.30435 10.3097 6.53867L8.84843 7.9999L10.3099 9.46137C10.5442 9.69569 10.5442 10.0756 10.3099 10.3099C10.0756 10.5442 9.69569 10.5442 9.46137 10.3099L7.9999 8.84843L6.53842 10.3099C6.30411 10.5442 5.92421 10.5442 5.6899 10.3099C5.45558 10.0756 5.45558 9.69569 5.6899 9.46137L7.15137 7.9999L5.69014 6.53867C5.45583 6.30435 5.45583 5.92445 5.69014 5.69014C5.92445 5.45583 6.30435 5.45583 6.53867 5.69014L7.9999 7.15137L9.46113 5.69014C9.69544 5.45583 10.0753 5.45583 10.3097 5.69014Z",fillRule:"evenodd",clipRule:"evenodd"}}]},is=H.forwardRef(function(n,i){return H.createElement(_e,Object.assign({},n,{id:"error-single",ref:i,icon:Cu}))});is.displayName="ErrorSingle";var _u={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M1.28096 4.6541C1.57489 4.50109 1.93721 4.61533 2.09022 4.90926C2.27315 5.26067 2.55999 5.60455 2.94829 5.92278C4.04628 6.82266 5.87505 7.44865 7.99828 7.44865C10.1215 7.44865 11.9503 6.82267 13.0482 5.92279C13.4366 5.60455 13.7234 5.26067 13.9063 4.90927C14.0594 4.61533 14.4217 4.50109 14.7156 4.65409C15.0095 4.8071 15.1238 5.16941 14.9708 5.46334C14.6995 5.98445 14.2981 6.44997 13.8089 6.8509C13.7298 6.91575 13.6481 6.97914 13.564 7.041L15.2245 8.70153C15.4588 8.93585 15.4588 9.31575 15.2245 9.55006C14.9902 9.78438 14.6103 9.78438 14.376 9.55006L12.5041 7.67822C11.8977 7.97568 11.2181 8.21208 10.4884 8.37706L11.0996 10.6581C11.1853 10.9782 10.9954 11.3072 10.6753 11.393C10.3552 11.4787 10.0262 11.2888 9.94045 10.9687L9.29949 8.57652C8.8758 8.62404 8.44081 8.64865 7.99828 8.64865C7.55276 8.64865 7.11487 8.62371 6.68846 8.57555L6.04723 10.9687C5.96147 11.2888 5.63247 11.4788 5.31239 11.393C4.99231 11.3073 4.80236 10.9783 4.88812 10.6582L5.49983 8.37516C4.7743 8.2105 4.09843 7.9752 3.49498 7.67947L1.62436 9.55009C1.39005 9.78441 1.01015 9.78441 0.775835 9.5501C0.54152 9.31578 0.541518 8.93588 0.775832 8.70157L2.43478 7.04261C2.34987 6.98024 2.26746 6.91632 2.18764 6.8509C1.69842 6.44997 1.29706 5.98445 1.0258 5.46335C0.872791 5.16942 0.987031 4.80711 1.28096 4.6541Z"}}]},Ua=H.forwardRef(function(n,i){return H.createElement(_e,Object.assign({},n,{id:"eyelash-single",ref:i,icon:_u}))});Ua.displayName="EyelashSingle";var Iu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M6.06409 5.53454C5.93592 5.53454 5.84083 5.41567 5.86897 5.29063L5.95442 4.9109C6.05444 4.48178 6.23806 4.11547 6.51182 3.81952 6.81082 3.49628 7.25398 3.35405 7.79738 3.35405 7.99847 3.35405 8.21359 3.37775 8.44188 3.42245 8.46089 3.42617 8.47974 3.43006 8.49846 3.4341 8.7099 3.4798 8.93698 3.38478 9.02031 3.18514L9.24767 2.6404C9.33457 2.43219 9.23178 2.19404 9.01582 2.12874 8.98358 2.11899 8.95028 2.10912 8.91591 2.09914 8.62745 2.01631 8.28392 1.97217 7.88074 1.97217 6.82015 1.97217 6.02714 2.23936 5.4746 2.7444 4.90987 3.26069 4.50889 3.99917 4.28413 4.9762L2.83703 11.1909C2.76126 11.5286 2.666 11.8917 2.54844 12.2812 2.42975 12.6734 2.2873 13.0595 2.12221 13.4373 1.95577 13.8159 1.76813 14.1762 1.55955 14.5171 1.49345 14.6251 1.42515 14.7282 1.35467 14.8263 1.26508 14.9509 1.3347 15.133 1.48655 15.1554 2.13635 15.2509 2.8179 15.0763 3.18197 14.5296 3.32661 14.3124 3.46779 14.0646 3.60509 13.7851 3.96635 13.0497 4.30522 12.0103 4.61867 10.6574L5.469 7.01534C5.49013 6.92483 5.57082 6.86081 5.66376 6.86081H7.62478C7.8097 6.86081 7.97051 6.73405 8.01371 6.55425L8.14014 6.02798C8.20057 5.77642 8.00992 5.53454 7.75121 5.53454H6.06409zM14.3211 5.72037L12.5124 7.96963 11.4089 5.77754C11.3422 5.63012 11.1954 5.5354 11.0336 5.5354H10.3129C10.0085 5.5354 9.80921 5.85428 9.9427 6.1279L11.4089 9.05502 8.79783 12.1493C8.56587 12.4158 8.75519 12.8315 9.10855 12.8315H9.68607C9.80672 12.8315 9.9605 12.7822 10.0388 12.6904L12.1108 10.2648 13.1176 12.561C13.1786 12.7231 13.333 12.8315 13.5061 12.8315H14.3C14.5831 12.8315 14.7417 12.6175 14.6426 12.3524L13.1728 9.28628C13.1728 9.28628 15.4009 6.45542 15.6013 6.17892 15.7966 5.90929 15.6023 5.5354 15.2693 5.5354H14.6661C14.5275 5.5354 14.4333 5.58887 14.3211 5.72037z"}}]},La=H.forwardRef(function(n,i){return H.createElement(_e,Object.assign({},n,{id:"fx-single",ref:i,icon:Iu}))});La.displayName="FxSingle";var bu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"colorChannel1",d:"M6.4833 1.65005C6.4833 1.31868 6.21467 1.05005 5.8833 1.05005C5.55193 1.05005 5.2833 1.31868 5.2833 1.65005V5.28345H1.65029C1.31892 5.28345 1.05029 5.55208 1.05029 5.88345C1.05029 6.21482 1.31892 6.48345 1.65029 6.48345H5.2833V9.51684H1.65029C1.31892 9.51684 1.05029 9.78547 1.05029 10.1168C1.05029 10.4482 1.31892 10.7168 1.65029 10.7168H5.2833V14.35C5.2833 14.6814 5.55193 14.95 5.8833 14.95C6.21467 14.95 6.4833 14.6814 6.4833 14.35V10.7168H9.5167V14.35C9.5167 14.6814 9.78533 14.95 10.1167 14.95C10.4481 14.95 10.7167 14.6814 10.7167 14.35V10.7168H14.3503C14.6817 10.7168 14.9503 10.4482 14.9503 10.1168C14.9503 9.78547 14.6817 9.51685 14.3503 9.51685H10.7167V6.48345H14.3503C14.6817 6.48345 14.9503 6.21482 14.9503 5.88345C14.9503 5.55208 14.6817 5.28345 14.3503 5.28345H10.7167V1.65005C10.7167 1.31868 10.4481 1.05005 10.1167 1.05005C9.78533 1.05005 9.5167 1.31868 9.5167 1.65005V5.28345L6.4833 5.28345V1.65005ZM6.4833 6.48345V9.51684L9.5167 9.51685V6.48345L6.4833 6.48345Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.0498 3.65005C1.0498 2.21411 2.21386 1.05005 3.6498 1.05005H12.3498C13.7857 1.05005 14.9498 2.21411 14.9498 3.65005V12.3501C14.9498 13.786 13.7857 14.95 12.3498 14.95H3.6498C2.21386 14.95 1.0498 13.786 1.0498 12.35V3.65005ZM3.6498 2.25005C2.87661 2.25005 2.2498 2.87685 2.2498 3.65005V12.35C2.2498 13.1232 2.87661 13.75 3.6498 13.75H12.3498C13.123 13.75 13.7498 13.1232 13.7498 12.3501V3.65005C13.7498 2.87685 13.123 2.25005 12.3498 2.25005H3.6498Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Ba=H.forwardRef(function(n,i){return H.createElement(_e,Object.assign({},n,{id:"hide-gridlines",ref:i,icon:bu}))});Ba.displayName="HideGridlines";var Ru={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.6 1.99991C8.60001 1.66854 8.33138 1.39991 8.00001 1.3999C7.66864 1.3999 7.40001 1.66853 7.4 1.9999L7.39996 7.3999H1.9999C1.66853 7.3999 1.3999 7.66853 1.3999 7.9999C1.3999 8.33127 1.66853 8.5999 1.9999 8.5999H7.39995L7.3999 13.9999C7.3999 14.3313 7.66853 14.5999 7.9999 14.5999C8.33127 14.5999 8.5999 14.3313 8.5999 13.9999L8.59995 8.5999H13.9999C14.3313 8.5999 14.5999 8.33127 14.5999 7.9999C14.5999 7.66853 14.3313 7.3999 13.9999 7.3999H8.59996L8.6 1.99991Z"}}]},os=H.forwardRef(function(n,i){return H.createElement(_e,Object.assign({},n,{id:"increase-single",ref:i,icon:Ru}))});os.displayName="IncreaseSingle";var Eu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.00016 1.33203C6.68162 1.33203 5.39269 1.72302 4.29636 2.45557C3.20004 3.18811 2.34555 4.2293 1.84097 5.44747C1.33638 6.66565 1.20436 8.00609 1.4616 9.2993C1.71883 10.5925 2.35377 11.7804 3.28612 12.7127C4.21847 13.6451 5.40636 14.28 6.69956 14.5373C7.99277 14.7945 9.33321 14.6625 10.5514 14.1579C11.7696 13.6533 12.8108 12.7988 13.5433 11.7025C14.2758 10.6062 14.6668 9.31724 14.6668 7.9987C14.6649 6.23118 13.9619 4.53662 12.7121 3.2868C11.4622 2.03697 9.76768 1.33397 8.00016 1.33203ZM7.66683 3.9987C7.86461 3.9987 8.05795 4.05735 8.2224 4.16723C8.38685 4.27711 8.51502 4.43329 8.59071 4.61601C8.6664 4.79874 8.6862 4.99981 8.64762 5.19379C8.60903 5.38777 8.51379 5.56595 8.37394 5.7058C8.23409 5.84566 8.0559 5.9409 7.86192 5.97948C7.66794 6.01807 7.46687 5.99826 7.28415 5.92258C7.10142 5.84689 6.94524 5.71872 6.83536 5.55427C6.72548 5.38982 6.66683 5.19648 6.66683 4.9987C6.66683 4.73348 6.77219 4.47913 6.95972 4.29159C7.14726 4.10405 7.40162 3.9987 7.66683 3.9987ZM9.3335 11.332H6.66683C6.49002 11.332 6.32045 11.2618 6.19543 11.1368C6.0704 11.0117 6.00016 10.8422 6.00016 10.6654C6.00016 10.4886 6.0704 10.319 6.19543 10.194C6.32045 10.0689 6.49002 9.9987 6.66683 9.9987H7.3335V7.9987H6.66683C6.49002 7.9987 6.32045 7.92846 6.19543 7.80343C6.0704 7.67841 6.00016 7.50884 6.00016 7.33203C6.00016 7.15522 6.0704 6.98565 6.19543 6.86063C6.32045 6.7356 6.49002 6.66536 6.66683 6.66536H8.00016C8.17698 6.66536 8.34655 6.7356 8.47157 6.86063C8.59659 6.98565 8.66683 7.15522 8.66683 7.33203V9.9987H9.3335C9.51031 9.9987 9.67988 10.0689 9.8049 10.194C9.92993 10.319 10.0002 10.4886 10.0002 10.6654C10.0002 10.8422 9.92993 11.0117 9.8049 11.1368C9.67988 11.2618 9.51031 11.332 9.3335 11.332Z"}}]},Fa=H.forwardRef(function(n,i){return H.createElement(_e,Object.assign({},n,{id:"info-single",ref:i,icon:Eu}))});Fa.displayName="InfoSingle";var wu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M2.62402 7.72905C2.58427 7.72905 2.55205 7.76127 2.55205 7.80102V13.6782C2.55205 13.7179 2.58427 13.7502 2.62402 13.7502H13.3755C13.4152 13.7502 13.4474 13.7179 13.4474 13.6782V7.80102C13.4474 7.76127 13.4152 7.72905 13.3755 7.72905H2.62402ZM1.35205 7.80102C1.35205 7.09853 1.92153 6.52905 2.62402 6.52905H13.3755C14.0779 6.52905 14.6474 7.09853 14.6474 7.80102V13.6782C14.6474 14.3807 14.0779 14.9502 13.3755 14.9502H2.62402C1.92153 14.9502 1.35205 14.3807 1.35205 13.6782V7.80102Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M8 2.25005C6.69847 2.25003 5.64336 3.30513 5.64336 4.60666V7.12895C5.64336 7.46032 5.37473 7.72895 5.04336 7.72895 4.71199 7.72895 4.44336 7.46032 4.44336 7.12895V4.60666C4.44336 2.64239 6.04451 1.05565 8.00879 1.05566M8 2.25005L8.00879 1.05566 8 2.25005zM8.00879 1.05566L8 2.25005C9.30154 2.25003 10.3567 3.30513 10.3567 4.60666V7.12895C10.3567 7.46032 10.6253 7.72895 10.9567 7.72895 11.288 7.72895 11.5567 7.46032 11.5567 7.12895V4.60666C11.5567 2.64239 9.97306 1.05565 8.00879 1.05566zM8.00039 9.4668C8.33176 9.4668 8.60039 9.73543 8.60039 10.0668V12.0827C8.60039 12.4141 8.33176 12.6827 8.00039 12.6827 7.66902 12.6827 7.40039 12.4141 7.40039 12.0827V10.0668C7.40039 9.73543 7.66902 9.4668 8.00039 9.4668z",fillRule:"evenodd",clipRule:"evenodd"}}]},ss=H.forwardRef(function(n,i){return H.createElement(_e,Object.assign({},n,{id:"lock-single",ref:i,icon:wu}))});ss.displayName="LockSingle";var Tu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M11.3536 6.14645C11.5488 6.34171 11.5488 6.65829 11.3536 6.85355L8.35355 9.85355C8.15829 10.0488 7.84171 10.0488 7.64645 9.85355L4.64645 6.85355C4.45118 6.65829 4.45118 6.34171 4.64645 6.14645C4.84171 5.95118 5.15829 5.95118 5.35355 6.14645L8 8.79289L10.6464 6.14645C10.8417 5.95118 11.1583 5.95118 11.3536 6.14645Z",fillRule:"evenodd",clipRule:"evenodd"}}]},gn=H.forwardRef(function(n,i){return H.createElement(_e,Object.assign({},n,{id:"more-down-single",ref:i,icon:Tu}))});gn.displayName="MoreDownSingle";var yu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.90913 3.57564C6.14345 3.34132 6.52335 3.34132 6.75766 3.57564L10.7577 7.57564C10.992 7.80995 10.992 8.18985 10.7577 8.42417L6.75766 12.4242C6.52335 12.6585 6.14345 12.6585 5.90913 12.4242C5.67482 12.1899 5.67482 11.81 5.90913 11.5756L9.48487 7.9999L5.90913 4.42417C5.67482 4.18985 5.67482 3.80995 5.90913 3.57564Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Po=H.forwardRef(function(n,i){return H.createElement(_e,Object.assign({},n,{id:"more-single",ref:i,icon:yu}))});Po.displayName="MoreSingle";var Mu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.01281 1.36643C8.79386 0.585377 10.0602 0.585378 10.8412 1.36643L12.9223 3.44752C13.7034 4.22857 13.7034 5.4949 12.9223 6.27595L9.36445 9.83383C8.5834 10.6149 7.31707 10.6149 6.53602 9.83383L4.45493 7.75273C3.67388 6.97168 3.67388 5.70535 4.45493 4.9243L8.01281 1.36643ZM9.9927 2.21495C9.68028 1.90253 9.17375 1.90253 8.86133 2.21495L5.30346 5.77283L5.29671 5.77966L10.839 6.66224L12.0738 5.42742C12.3862 5.115 12.3862 4.60847 12.0738 4.29605L9.9927 2.21495Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M14.5179 9.48875C14.5179 9.99175 14.1101 10.3995 13.607 10.3995C13.1041 10.3995 12.6963 9.99175 12.6963 9.48875C12.6963 9.1773 13.0455 8.59966 13.3114 8.20487C13.4549 7.99177 13.7591 7.99177 13.9027 8.20486C14.1687 8.59965 14.5179 9.1773 14.5179 9.48875Z"}},{tag:"path",attrs:{fill:"colorChannel1",d:"M1.98682 13.4992C1.98682 12.5603 2.74793 11.7992 3.68682 11.7992H14.2868C15.2257 11.7992 15.9868 12.5603 15.9868 13.4992V13.4992C15.9868 14.4381 15.2257 15.1992 14.2868 15.1992H3.68682C2.74793 15.1992 1.98682 14.4381 1.98682 13.4992V13.4992Z"}}]},ja=H.forwardRef(function(n,i){return H.createElement(_e,Object.assign({},n,{id:"paint-bucket",ref:i,icon:Mu}))});ja.displayName="PaintBucket";var Pu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_102_1138",style:{maskType:"alpha"},width:16,height:16,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#DCDCDC",d:"M0 0H16V16H0z"}}]},{tag:"g",attrs:{mask:"url(#mask0_102_1138)"},children:[{tag:"path",attrs:{fill:"colorChannel1",d:"M7.74692 9.12463C7.74692 9.46018 8.01893 9.73219 8.35448 9.73219H11.4933C11.8288 9.73219 12.1009 9.46018 12.1009 9.12463 12.1009 8.78909 11.8288 8.51707 11.4933 8.51707H8.35448C8.01893 8.51707 7.74692 8.78909 7.74692 9.12463zM10.8636 10.8523C10.8636 11.1879 10.5915 11.4599 10.256 11.4599H8.35448C8.01893 11.4599 7.74692 11.1879 7.74692 10.8523 7.74692 10.5168 8.01893 10.2447 8.35448 10.2447H10.256C10.5915 10.2447 10.8636 10.5168 10.8636 10.8523z"}},{tag:"path",attrs:{fill:"currentColor",d:"M5.4791 1.98268C5.47913 1.71529 5.87912 1.49854 6.37252 1.49854C6.86593 1.49854 7.26592 1.71529 7.26595 1.98268H7.62187C8.22277 1.98268 8.72459 2.39534 8.84412 2.9452H9.39563C10.0856 2.9452 10.6449 3.48923 10.6449 4.16032V6.00569H12.1261C13.161 6.00569 14 6.82174 14 7.82838V11.334C14 11.8174 13.8025 12.281 13.4511 12.6228L12.0693 13.9647C11.7179 14.3065 11.2412 14.4985 10.7442 14.4985H7.91116C7.05024 14.4985 6.32492 14.0431 6.10535 13.2737H3.34925C2.6593 13.2737 2.09998 12.7297 2.09998 12.0586V4.16032C2.09998 3.48923 2.6593 2.9452 3.34925 2.9452H3.90107C4.0206 2.39534 4.52241 1.98268 5.12332 1.98268H5.4791ZM3.97249 4.16032H3.24925L3.24925 12.0586H6.03725V7.82838C6.03725 6.82174 6.87623 6.00569 7.91116 6.00569H9.49563V4.16032H8.7727C8.58289 4.59611 8.13909 4.90183 7.62187 4.90183H5.12332C4.6061 4.90183 4.1623 4.59611 3.97249 4.16032ZM5.12332 2.89403H7.62187C7.79436 2.89403 7.93419 3.03003 7.93419 3.19781V3.68671C7.93419 3.85448 7.79436 3.99049 7.62187 3.99049H5.12332C4.95083 3.99049 4.811 3.85448 4.811 3.68671V3.19781C4.811 3.03003 4.95083 2.89403 5.12332 2.89403ZM7.91116 7.11157C7.56618 7.11157 7.28652 7.38359 7.28652 7.71913V12.7851C7.28652 13.1206 7.56618 13.3927 7.91116 13.3927H10.7442C10.8401 13.3927 10.9337 13.3712 11.0182 13.3311C11.1373 13.2746 11.1859 13.1423 11.1859 13.0134V12.0066C11.1859 11.8724 11.2978 11.7636 11.4358 11.7636H12.4709C12.6034 11.7636 12.7394 11.7163 12.7975 11.6004C12.8388 11.5182 12.8608 11.4272 12.8608 11.334V7.71913C12.8608 7.38359 12.5811 7.11157 12.2362 7.11157H7.91116Z",fillRule:"evenodd",clipRule:"evenodd"}}]}]},za=H.forwardRef(function(n,i){return H.createElement(_e,Object.assign({},n,{id:"paste-special",ref:i,icon:Pu}))});za.displayName="PasteSpecial";var xu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.785 6.77762C5.78908 6.7777 5.79316 6.77774 5.79725 6.77774C5.80134 6.77774 5.80543 6.7777 5.8095 6.77762H10.0184C10.0225 6.7777 10.0266 6.77774 10.0307 6.77774C10.0347 6.77774 10.0388 6.7777 10.0429 6.77762H13.6638V7.63727C13.6638 7.96864 13.9324 8.23727 14.2638 8.23727C14.5951 8.23727 14.8638 7.96864 14.8638 7.63727V3.9999C14.8638 2.56395 13.6997 1.39989 12.2637 1.3999L3.56389 1.39999C2.12797 1.40001 0.96393 2.56405 0.96392 3.99998L0.963867 11.6666C0.963857 13.1025 2.12792 14.2666 3.56387 14.2666H8.0542C8.38557 14.2666 8.6542 13.9979 8.6542 13.6666C8.6542 13.3352 8.38557 13.0666 8.0542 13.0666H3.56387C2.79067 13.0666 2.16386 12.4398 2.16387 11.6666L2.1639 6.77762H5.785ZM6.39725 2.59996L9.43065 2.59993V5.57762H6.39725V2.59996ZM5.19725 5.57762V2.59998L3.56391 2.59999C2.79072 2.6 2.16393 3.22679 2.16392 3.99998L2.16391 5.57762H5.19725ZM13.6638 5.57762V3.9999C13.6638 3.2267 13.037 2.59989 12.2638 2.5999L10.6307 2.59992V5.57762H13.6638Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M14.1223 10.2333V10.7496C14.7087 10.9869 15.1223 11.5618 15.1223 12.2333V12.8999C15.1223 13.7836 14.406 14.4999 13.5223 14.4999H11.5223C10.6387 14.4999 9.92235 13.7836 9.92235 12.8999V12.2333C9.92235 11.5618 10.336 10.9869 10.9223 10.7496V10.2333C10.9223 9.34961 11.6387 8.63328 12.5223 8.63328C13.406 8.63328 14.1223 9.34961 14.1223 10.2333ZM11.1223 12.2333C11.1223 12.0124 11.3014 11.8333 11.5223 11.8333H13.5223C13.7433 11.8333 13.9223 12.0124 13.9223 12.2333V12.8999C13.9223 13.1209 13.7433 13.2999 13.5223 13.2999H11.5223C11.3014 13.2999 11.1223 13.1209 11.1223 12.8999V12.2333ZM12.9223 10.2333V10.6333H12.1223V10.2333C12.1223 10.0124 12.3014 9.83328 12.5223 9.83328C12.7433 9.83328 12.9223 10.0124 12.9223 10.2333Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Xa=H.forwardRef(function(n,i){return H.createElement(_e,Object.assign({},n,{id:"protect-single",ref:i,icon:xu}))});Xa.displayName="ProtectSingle";var Ou={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M15 8C15 11.866 11.866 15 8 15C4.13401 15 1 11.866 1 8C1 4.13401 4.13401 1 8 1C11.866 1 15 4.13401 15 8ZM8.00008 12.3671C8.46031 12.3671 8.83342 11.994 8.83342 11.5338C8.83342 11.0735 8.46031 10.7004 8.00008 10.7004C7.53985 10.7004 7.16675 11.0735 7.16675 11.5338C7.16675 11.994 7.53985 12.3671 8.00008 12.3671ZM8.5999 4.4335C8.5999 4.10213 8.33127 3.8335 7.9999 3.8335C7.66853 3.8335 7.3999 4.10213 7.3999 4.4335V9.36683C7.3999 9.6982 7.66853 9.96683 7.9999 9.96683C8.33127 9.96683 8.5999 9.6982 8.5999 9.36683V4.4335Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Ya=H.forwardRef(function(n,i){return H.createElement(_e,Object.assign({},n,{id:"warning-single",ref:i,icon:Ou}))});Ya.displayName="WarningSingle";var Au={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M12.6551 1.98906C11.7476 1.08113 10.2757 1.08149 9.3686 1.98987L4.82542 6.53955C4.75087 6.61421 4.69336 6.70411 4.65682 6.80309L3.2461 10.625C3.16506 10.8446 3.21909 11.0912 3.3845 11.2568C3.54991 11.4224 3.79651 11.4767 4.01616 11.3959L7.85031 9.98517C7.94979 9.94856 8.04014 9.89077 8.11508 9.81579L12.6552 5.27327C13.5618 4.36621 13.5618 2.89607 12.6551 1.98906ZM10.2177 2.83779C10.6562 2.39869 11.3677 2.39851 11.8064 2.8374C12.2447 3.27584 12.2447 3.9865 11.8065 4.42497L7.3392 8.89457L4.82213 9.82068L5.74706 7.31487L10.2177 2.83779Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.79238 13.2999C1.46101 13.2999 1.19238 13.5685 1.19238 13.8999C1.19238 14.2313 1.46101 14.4999 1.79238 14.4999H14.4924C14.8238 14.4999 15.0924 14.2313 15.0924 13.8999C15.0924 13.5685 14.8238 13.2999 14.4924 13.2999H1.79238Z"}}]},as=H.forwardRef(function(n,i){return H.createElement(_e,Object.assign({},n,{id:"write-single",ref:i,icon:Au}))});as.displayName="WriteSingle";const ku=()=>{const[,n]=H.useState({});return H.useCallback(()=>n(i=>!i),[])},Du=()=>{const n=_.useDependency(a.ICommandService),i=_.useDependency(a.IUniverInstanceService),e=_.useDependency(T.IRenderManagerService),t=_.useDependency(ft),r=_.useDependency(a.LocaleService),[o,s]=H.useState([]),[l,c]=H.useState(!1),[d,u]=H.useState({row:-1,col:-1}),[h,g]=H.useState(le.SERIES),[S,f]=H.useState(!1),p=St(),{sheetSkeletonManagerService:v,selectionRenderService:C}=H.useMemo(()=>{if(p){const X=e.getRenderById(p.getUnitId());return{sheetSkeletonManagerService:X==null?void 0:X.with(exports.SheetSkeletonManagerService),selectionRenderService:X==null?void 0:X.with(pe)}}return{sheetSkeletonManagerService:null,selectionRenderService:null}},[p,e]),b=()=>{f(!0)},R=()=>{f(!1)},E=ku();if(H.useEffect(()=>n.onCommandExecuted((K,te)=>{K.id===We.id&&E()}).dispose,[E,n]),H.useEffect(()=>{const X=v&&a.toDisposable(v.currentSkeleton$.subscribe(K=>{K&&E()}));return X==null?void 0:X.dispose},[v,E]),H.useEffect(()=>a.toDisposable(t.menu$.subscribe(K=>{s(K.map(te=>({...te,index:K.indexOf(te)})))})).dispose,[t]),H.useEffect(()=>a.toDisposable(t.showMenu$.subscribe(K=>{const{source:te,target:Q}=t.autoFillLocation||{source:null,target:null};if(K&&te&&Q){const se=Math.max(te.rows[te.rows.length-1],Q.rows[Q.rows.length-1]),G=Math.max(te.cols[te.cols.length-1],Q.cols[Q.cols.length-1]);u({row:se,col:G})}else u({row:-1,col:-1})})).dispose,[t]),H.useEffect(()=>a.toDisposable(t.applyType$.subscribe(K=>{g(K)})).dispose,[t]),H.useEffect(()=>{function X(){c(!1)}return document.addEventListener("wheel",X),()=>{document.removeEventListener("wheel",X)}},[l]),d.col<0||d.row<0)return null;const P=Ve(i,e);if(!P||!C)return null;const{scene:y}=P,M=v==null?void 0:v.getCurrentSkeleton(),x=C.getViewPort(),A=y==null?void 0:y.scaleX,k=y==null?void 0:y.scaleY,D=y==null?void 0:y.getViewportScrollXY(x);if(!A||!y||!A||!k||!D)return null;const N=(M==null?void 0:M.getNoMergeCellWithCoordByIndex(d.row,d.col).endX)||0,W=(M==null?void 0:M.getNoMergeCellWithCoordByIndex(d.row,d.col).endY)||0,V=T.convertTransformToOffsetX(N,A,D),U=T.convertTransformToOffsetY(W,k,D);if(V==null||U==null)return null;const L=X=>{c(X)},j=X=>{n.executeCommand(ir.id,{type:X.value}),c(!1)},B=l||S,F=o.filter(X=>!X.disable);return I.jsx("div",{className:"univer-absolute univer-inset-0 univer-z-10 univer-size-0",children:I.jsx("div",{className:"univer-absolute",style:{left:`${V+2}px`,top:`${U+2}px`},onMouseEnter:b,onMouseLeave:R,children:I.jsx(z.DropdownMenu,{align:"start",items:F.map(X=>({type:"radio",value:h,options:[{label:r.t(X.label),value:X.value}],onSelect:()=>j(X)})),open:l,onOpenChange:L,children:I.jsxs("div",{className:z.clsx("univer-flex univer-items-center univer-gap-2 univer-rounded univer-p-1 dark:hover:!univer-bg-gray-800 hover:univer-bg-gray-100",z.borderClassName,{"univer-bg-gray-100 dark:!univer-bg-gray-800":l,"univer-bg-white dark:!univer-bg-gray-900":!l}),children:[I.jsx(Va,{className:"univer-fill-primary-600 univer-text-gray-900 dark:!univer-text-white"}),B&&I.jsx(gn,{className:"dark:!univer-text-white"})]})})})})};function ls(n,i){const e=_.useDependency(he),t=_.useDependency(a.ICommandService);return H.useMemo(()=>({keyCodes:[{keyCode:_.KeyCode.ENTER},{keyCode:_.KeyCode.ESC},{keyCode:_.KeyCode.TAB}],handler:o=>{(o===_.KeyCode.ENTER||o===_.KeyCode.ESC||o===_.KeyCode.TAB)&&(e.disableForceKeepVisible(),t.executeCommand(Se.id,{visible:!1,eventType:T.DeviceInputEventType.Keyboard,keycode:o,unitId:i}))}}),[t,e,i])}const Gr=-1e3,Ls={width:0,height:0,top:Gr,left:Gr},Nu=()=>{const[n,i]=H.useState({...Ls}),e=_.useDependency(ar),t=_.useDependency(J.IEditorService),r=_.useDependency(a.IContextService),o=_.useDependency(_.ComponentManager),s=_.useDependency(he),l=_.useObservable(s.visible$),c=_.useDependency(a.ICommandService),d=H.useRef(0),u=_.useObservable(()=>r.subscribeContextValue$(_.DISABLE_AUTO_FOCUS_KEY),!1,void 0,[r,_.DISABLE_AUTO_FOCUS_KEY]),h=o.get(_i),g=s.getEditLocation();H.useEffect(()=>{const v=e.state$.subscribe(C=>{if(C==null)return;const{startX:b=Gr,startY:R=Gr,endX:E=0,endY:P=0,show:y=!1}=C;if(!y)i({...Ls});else{i({width:E-b,height:P-R,left:b,top:R});const M=t.getEditor(a.DOCS_NORMAL_EDITOR_UNIT_ID_KEY);if(M==null)return;const{left:x,top:A,width:k,height:D}=M.getBoundingClientRect();e.setRect({left:x,top:A,width:k,height:D})}});return()=>{v.unsubscribe()}},[]),H.useEffect(()=>{u||e.setFocus(!0)},[u,n]);const S=_.useEvent(()=>{s.isVisible().visible&&c.executeCommand(Se.id,{visible:!1,eventType:T.DeviceInputEventType.PointerUp,unitId:g==null?void 0:g.unitId})});_.useSidebarClick(S);const f=ls(d,g==null?void 0:g.unitId),p=_.useEvent((v,C)=>{c.executeCommand(Nt.id,{keycode:v,visible:!1,eventType:T.DeviceInputEventType.Keyboard,isShift:C===_.MetaKeys.SHIFT||C===(_.MetaKeys.CTRL_COMMAND|_.MetaKeys.SHIFT),unitId:g==null?void 0:g.unitId})});return I.jsx("div",{className:"univer-absolute univer-z-10 univer-flex",style:{left:n.left,top:n.top,width:n.width,height:n.height},children:h&&I.jsx(h,{editorId:a.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,className:"univer-relative univer-flex univer-h-full univer-w-full [&_canvas]:univer-absolute",initValue:"",onChange:()=>{},isFocus:l==null?void 0:l.visible,unitId:g==null?void 0:g.unitId,subUnitId:g==null?void 0:g.sheetId,keyboardEventConfig:f,onMoveInEditor:p,isSupportAcrossSheet:!0,resetSelectionOnBlur:!1,isSingle:!1,autoScrollbar:!1,onFormulaSelectingChange:(v,C)=>{d.current=v,C&&(v?s.enableForceKeepVisible():s.disableForceKeepVisible())},disableSelectionOnClick:!0,disableContextMenu:!1})})};class Vu{constructor(){w(this,"_position",null);w(this,"_position$",new O.BehaviorSubject(null));w(this,"position$",this._position$.asObservable());w(this,"_focus",!1);w(this,"_focus$",new O.BehaviorSubject(this._focus));w(this,"focus$",this._focus$.asObservable());w(this,"_fxBtnClick$",new O.Subject);w(this,"fxBtnClick$",this._fxBtnClick$.asObservable());w(this,"_foldBtnStatus$",new O.Subject);w(this,"foldBtnStatus$",this._foldBtnStatus$.asObservable())}dispose(){this._position$.complete(),this._focus$.complete(),this._position=null,this._focus=!1}setPosition(i){this._position=i,this._refresh(i)}getPosition(){return this._position}setFocus(i=!1){this._focus=i,this._focus$.next(i)}handleFxBtnClick(i){this._fxBtnClick$.next(i)}handleFoldBtnClick(i){this._foldBtnStatus$.next(i)}_refresh(i){this._position$.next(i)}}const lr=a.createIdentifier("univer.sheet-formula-editor-manager.service"),qn="DefinedNameContainer",Ti={id:"sidebar.operation.defined-name",type:a.CommandType.COMMAND,handler:async(n,i)=>{const e=n.get(_.ISidebarService);n.get(J.IEditorService);const t=n.get(a.LocaleService),r=n.get(a.IUniverInstanceService),o=m.getSheetCommandTarget(r);if(!o)return!1;const{unitId:s}=o;switch(i.value){case"open":e.open({id:qn,header:{title:t.t("definedName.featureTitle")},children:{label:qn},onClose:()=>{},width:333});break;case"close":default:e.close();break}return!0}};function Hu(){const n=_.useDependency(a.ICommandService),i=_.useDependency(a.LocaleService),e=_.useDependency(Z.IDefinedNamesService),t=_.useDependency(a.IUniverInstanceService),r=_.useDependency(_.ISidebarService),s=t.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getUnitId(),l=()=>{const g=e.getDefinedNameMap(s);return g?Array.from(Object.values(g)):[]},[c,d]=H.useState(l());H.useEffect(()=>{const g=e.update$.subscribe(()=>{d(l())});return()=>{g.unsubscribe()}},[]),H.useEffect(()=>{const g=r.sidebarOptions$.subscribe(S=>{S.id===qn&&(S.visible||setTimeout(()=>{r.sidebarOptions$.next({visible:!1})}))});return()=>{g.unsubscribe()}},[]);const u=()=>{n.executeCommand(Ti.id,{value:"open"})},h=async g=>{const{formulaOrRefString:S,id:f}=g,p=e.getWorksheetByRef(s,S);if(!p)return;p.isSheetHidden()&&await n.executeCommand(m.SetWorksheetShowCommand.id,{unitId:s,subUnitId:p.getSheetId()}),e.focusRange(s,f)};return I.jsxs("div",{className:"univer-w-[300px]",children:[I.jsx("ul",{className:z.clsx("univer-m-0 univer-max-h-[360px] univer-list-none univer-overflow-y-auto univer-p-0",z.scrollbarClassName),children:c.map((g,S)=>I.jsx("li",{className:"univer-cursor-pointer univer-px-2 univer-transition-colors univer-duration-200 dark:hover:!univer-bg-gray-600 hover:univer-bg-gray-100",onClick:()=>{h(g)},children:I.jsxs("div",{className:z.clsx("univer-flex univer-items-center univer-justify-between univer-gap-2 univer-py-1",z.borderBottomClassName),children:[I.jsx("div",{className:"univer-w-[50%] univer-flex-shrink-0 univer-overflow-hidden univer-text-ellipsis univer-whitespace-nowrap univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",title:g.name,children:g.name}),I.jsx("div",{className:"univer-w-[50%] univer-flex-shrink-0 univer-overflow-hidden univer-text-ellipsis univer-whitespace-nowrap univer-text-xs univer-text-gray-400",title:g.formulaOrRefString,children:g.formulaOrRefString})]})},S))}),I.jsxs("div",{className:"univer-cursor-pointer univer-p-2 univer-transition-colors univer-duration-200 dark:hover:!univer-bg-gray-600 hover:univer-bg-gray-100",onClick:u,children:[I.jsx("div",{className:"univer-mb-2 univer-text-sm univer-font-semibold univer-text-gray-600 dark:!univer-text-gray-200",children:i.t("definedName.managerTitle")}),I.jsx("div",{className:"univer-text-xs univer-text-gray-400",children:i.t("definedName.managerDescription")})]})]})}function Wu({disable:n}){const[i,e]=H.useState(""),t=_.useDependency(Z.IDefinedNamesService);H.useEffect(()=>{const o=t.currentRange$.subscribe(()=>{e(t.getCurrentRangeForString())});return()=>{o.unsubscribe()}},[]);function r(){}return I.jsxs("div",{"data-u-comp":"defined-name",className:"univer-relative univer-box-border univer-flex univer-h-full univer-w-24 univer-border-r-gray-200 univer-py-1.5 univer-transition-all",children:[I.jsx("input",{className:z.clsx("univer-box-border univer-h-full univer-w-full univer-appearance-none univer-px-1.5 univer-text-gray-900 dark:!univer-border-r-gray-700 dark:!univer-bg-gray-900 dark:!univer-text-white focus:univer-outline-none",z.borderRightClassName,{"univer-cursor-not-allowed":n}),type:"text",value:i,onChange:r}),I.jsx(z.Dropdown,{overlay:I.jsx("div",{className:"univer-z-[1001]",children:I.jsx(Hu,{})}),disabled:n,children:I.jsx("a",{className:z.clsx("univer-absolute univer-right-0 univer-top-0 univer-flex univer-h-full univer-cursor-pointer univer-items-center univer-justify-center univer-px-1 univer-transition-colors univer-duration-200 dark:!univer-text-white dark:hover:!univer-bg-gray-800 hover:univer-bg-gray-100",{"univer-cursor-not-allowed univer-text-gray-300 dark:!univer-text-gray-700 hover:univer-bg-transparent":n}),children:I.jsx(gn,{})})})]})}function Ga(n){var q,ne,ce,ie;const{className:i,disableDefinedName:e}=n,[t,r]=H.useState(!1),[o,s]=H.useState(0),l=_.useDependency(lr),c=_.useDependency(he),d=_.useDependency(m.WorksheetProtectionRuleModel),u=_.useDependency(m.RangeProtectionRuleModel),h=_.useDependency(a.IUniverInstanceService),g=_.useDependency(m.SheetsSelectionsService),S=_.useDependency(a.IPermissionService),f=_.useDependency(m.RangeProtectionCache),p=_.useDependency(a.ICommandService),[v,C]=H.useState({editDisable:!1,viewDisable:!1}),[b,R]=H.useState(!1),E=_.useDependency(_.ComponentManager),P=_.useObservable(()=>h.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]),y=H.useRef(0),M=_.useObservable(c.currentEditCellState$),x=ls(y,(q=M==null?void 0:M.unitId)!=null?q:""),A=E.get(_i),k=_.useComponentsOfPart(Qo.FORMULA_AUX),D=_.useDependency(a.IContextService);_.useObservable(H.useMemo(()=>D.subscribeContextValue$(a.FOCUSING_FX_BAR_EDITOR),[D]));const N=D.getContextValue(a.FOCUSING_FX_BAR_EDITOR),W=H.useRef(null),V=_.useDependency(J.IEditorService);H.useLayoutEffect(()=>{const oe=P.activeSheet$.pipe(O.switchMap($=>$?O.merge(d.ruleChange$,u.ruleChange$,g.selectionMoveEnd$,g.selectionSet$).pipe(O.switchMap(()=>{var ot,st;const me=P.getUnitId(),fe=$.getSheetId();if(!((ot=g.getCurrentLastSelection())==null?void 0:ot.range))return O.EMPTY;const Re=(st=g.getCurrentLastSelection())==null?void 0:st.primary;return Re?O.of({unitId:me,subUnitId:fe,primary:Re}):O.of(null)})):O.EMPTY)).subscribe($=>{var me,fe,be,Re,ot,st;if($){const{unitId:Ct,subUnitId:Pr,primary:Zc}=$;if(d.getRule(Ct,Pr)){const Qc=!((fe=(me=S.getPermissionPoint(new m.WorksheetEditPermission(Ct,Pr).id))==null?void 0:me.value)==null||fe),Jc=!((Re=(be=S.getPermissionPoint(new m.WorksheetViewPermission(Ct,Pr).id))==null?void 0:be.value)==null||Re);C({viewDisable:Jc,editDisable:Qc});return}const{actualRow:Kc,actualColumn:qc}=Zc,Gt=f.getCellInfo(Ct,Pr,Kc,qc);C({editDisable:!((ot=Gt==null?void 0:Gt[m.UnitAction.Edit])==null||ot),viewDisable:!((st=Gt==null?void 0:Gt[m.UnitAction.View])==null||st)})}else C({viewDisable:!1,editDisable:!1})});return()=>{oe.unsubscribe()}},[P]),H.useEffect(()=>{const oe=c.visible$.subscribe($=>{r($.visible)});return()=>oe.unsubscribe()},[c.visible$]),H.useEffect(()=>{const oe=c.currentEditCellState$.subscribe($=>{var me,fe,be;(be=(fe=(me=$==null?void 0:$.documentLayoutObject.documentModel)==null?void 0:me.getBody())==null?void 0:fe.customBlocks)!=null&&be.length?R(!0):R(!1)});return()=>oe.unsubscribe()},[c.currentEditCellState$]),H.useEffect(()=>{const oe=()=>{if(!W.current)return;const $=W.current.getBoundingClientRect();l.setPosition($)};if(W.current){oe();const $=new ResizeObserver(oe);return $.observe(W.current),()=>$.disconnect()}},[l]);function U(){s(o===0?1:0),setTimeout(()=>{l.handleFoldBtnClick(o===1)},150)}function L(){c.isVisible().visible&&p.executeCommand(Se.id,{visible:!1,eventType:T.DeviceInputEventType.Keyboard,keycode:_.KeyCode.ESC,unitId:M.unitId})}function j(){c.isVisible().visible&&p.executeCommand(Se.id,{visible:!1,eventType:T.DeviceInputEventType.PointerDown,unitId:M.unitId})}function B(){l.handleFxBtnClick(!0)}const{viewDisable:F,editDisable:X}=v,K=X||b,te=H.useRef(!1),Q=()=>{try{c.isVisible().visible===!1&&p.syncExecuteCommand(Se.id,{visible:!0,eventType:T.DeviceInputEventType.PointerDown,unitId:M.unitId}),D.setContextValue(a.FOCUSING_FX_BAR_EDITOR,!0)}catch(oe){throw te.current=!0,oe}},se=oe=>{te.current&&setTimeout(()=>{V.blur(!0)},30),te.current=!1},Y=((ie=(ce=(ne=M==null?void 0:M.documentLayoutObject.documentModel)==null?void 0:ne.getDrawingsOrder())==null?void 0:ce.length)!=null?ie:0)>0||F;return I.jsxs("div",{"data-u-comp":"formula-bar",className:z.clsx("univer-box-border univer-flex univer-h-7 univer-bg-white univer-transition-[height] univer-ease-linear dark:!univer-bg-gray-900",z.borderBottomClassName,i),style:{height:o===0?"28px":"82px",pointerEvents:X?"none":"auto"},children:[I.jsx("div",{className:"univer-relative univer-box-border univer-h-full univer-w-[100px]",children:I.jsx(Wu,{disable:e!=null?e:X})}),I.jsxs("div",{className:"univer-flex univer-h-full univer-w-full",children:[I.jsx("div",{className:z.clsx("univer-py-1.5",{"univer-cursor-not-allowed univer-text-gray-200":K}),children:I.jsxs("div",{className:z.clsx("univer-relative univer-box-border univer-flex univer-h-full univer-w-20 univer-items-center univer-justify-center univer-text-xs",z.borderRightClassName),children:[I.jsx("span",{className:z.clsx("univer-flex univer-items-center univer-justify-center univer-rounded univer-p-1 univer-text-base dark:!univer-text-white",{"univer-cursor-pointer univer-text-green-600 dark:!univer-text-green-400 dark:hover:!univer-bg-gray-700 hover:univer-bg-gray-100":t}),onClick:L,children:I.jsx(Ha,{})}),I.jsx("span",{className:z.clsx("univer-flex univer-items-center univer-justify-center univer-rounded univer-p-1 univer-text-base dark:!univer-text-white",{"univer-cursor-pointer univer-text-red-600 dark:!univer-text-red-400 dark:hover:!univer-bg-gray-700 hover:univer-bg-gray-100":t}),onClick:j,children:I.jsx(Ut,{})}),I.jsx("span",{className:z.clsx("univer-flex univer-cursor-pointer univer-items-center univer-justify-center univer-rounded univer-p-1 univer-text-base dark:!univer-text-white dark:hover:!univer-bg-gray-700 hover:univer-bg-gray-100"),onClick:B,children:I.jsx(La,{})})]})}),I.jsxs("div",{className:"univer-flex univer-w-full univer-flex-1 univer-overflow-hidden univer-pl-3",children:[I.jsxs("div",{className:"univer-relative univer-flex-1",onPointerDown:Q,onPointerUp:se,ref:W,style:{pointerEvents:Y?"none":"auto"},children:[A&&I.jsx(A,{className:"univer-relative univer-h-full univer-w-full univer-break-words univer-outline-none [&>div]:univer-ring-transparent",disableSelectionOnClick:!0,editorId:a.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,initValue:"",onChange:()=>{},isFocus:N,unitId:M==null?void 0:M.unitId,subUnitId:M==null?void 0:M.sheetId,isSupportAcrossSheet:!0,resetSelectionOnBlur:!1,isSingle:!1,keyboardEventConfig:x,onFormulaSelectingChange:(oe,$)=>{y.current=oe,$&&(oe?c.enableForceKeepVisible():c.disableForceKeepVisible())},autoScrollbar:!1,disableContextMenu:!1}),Y?I.jsx("div",{className:"univer-pointer-events-none univer-relative univer-left-0 univer-top-0 univer-z-[100] univer-h-full univer-w-full univer-cursor-not-allowed univer-bg-white"}):null]}),I.jsx("div",{className:z.clsx("univer-flex univer-h-full univer-w-5 univer-cursor-pointer univer-items-center univer-justify-center univer-text-xs univer-text-gray-700 dark:!univer-text-gray-200",{"univer-cursor-not-allowed univer-text-gray-200 dark:!univer-text-gray-700":X}),onClick:U,children:o===0?I.jsx(Mo,{}):I.jsx(Mo,{style:{transform:"rotateZ(180deg)"}})})]})]}),I.jsx(_.ComponentContainer,{components:k},"formula-aux")]})}const Lt=a.createIdentifier("univer.sheetbar-service");class Za extends a.Disposable{constructor(){super();w(this,"renameId$");w(this,"removeId$");w(this,"scroll$");w(this,"scrollX$");w(this,"addSheet$");w(this,"_renameId$");w(this,"_removeId$");w(this,"_scroll$");w(this,"_scrollX$");w(this,"_addSheet$");w(this,"_currentHandler",null);this._renameId$=new O.Subject,this.renameId$=this._renameId$.asObservable(),this._removeId$=new O.Subject,this.removeId$=this._removeId$.asObservable(),this._scroll$=new O.Subject,this.scroll$=this._scroll$.asObservable(),this._scrollX$=new O.Subject,this.scrollX$=this._scrollX$.asObservable(),this._addSheet$=new O.Subject,this.addSheet$=this._addSheet$.asObservable()}setRenameId(e){this._renameId$.next(e)}setRemoveId(e){this._removeId$.next(e)}setScroll(e){this._scroll$.next(e)}setScrollX(e){this._scrollX$.next(e)}setAddSheet(e){this._addSheet$.next(e)}triggerSheetBarMenu(){var e;(e=this._currentHandler)==null||e.handleSheetBarMenu()}registerSheetBarMenuHandler(e){if(this._currentHandler)throw new Error("There is already a context menu handler!");return this._currentHandler=e,a.toDisposable(()=>{this._currentHandler=null})}}function Lr(n){const{children:i,className:e,style:t,disabled:r=!1,onClick:o,...s}=n,l=c=>{if(r){c.preventDefault();return}o&&o(c)};return I.jsx(z.Button,{"data-u-comp":"sheet-bar-append-button",size:"small",disabled:r,onClick:l,style:t,...s,variant:"text",className:e,children:i})}function Uu(){const[n,i]=H.useState([]),[e,t]=H.useState(!1),r=_.useDependency(a.IUniverInstanceService),o=_.useDependency(a.ICommandService),s=_.useDependency(Lt),l=_.useDependency(m.WorksheetProtectionRuleModel),c=_.useObservable(()=>r.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET),null,!1,[]),d=p=>{const{sheetId:v}=p;!v||!c||(p.hidden?o.executeCommand(m.SetWorksheetShowCommand.id,{unitId:c.getUnitId(),subUnitId:v,value:v}):p.selected||o.executeCommand(m.SetWorksheetActivateCommand.id,{unitId:c.getUnitId(),subUnitId:v}),t(!1))},u=H.useCallback(()=>{if(!c)return;const p=c.getSheets(),v=c.getActiveSheet(),C=p.map((b,R)=>({label:b.getName(),index:`${R}`,sheetId:b.getSheetId(),hidden:b.isSheetHidden()===a.BooleanNumber.TRUE,selected:v===b}));i(C)},[c,l]),h=H.useCallback(()=>o.onCommandExecuted(p=>{switch(p.id){case m.SetWorksheetHideMutation.id:case m.RemoveSheetMutation.id:case m.SetWorksheetNameMutation.id:case m.InsertSheetMutation.id:case m.SetWorksheetOrderMutation.id:case m.SetWorksheetActiveOperation.id:u();break}}),[o,u]);function g(){t(!0)}const S=p=>{t(p)};H.useEffect(()=>{u();const p=new a.DisposableCollection;return p.add(h()),p.add(s.registerSheetBarMenuHandler({handleSheetBarMenu:g})),()=>p.dispose()},[h,s,u,c]);const f=H.useMemo(()=>n.map(p=>({type:"item",children:I.jsxs("div",{className:"univer-relative univer-box-border univer-pl-6",children:[(p.selected||p.hidden)&&I.jsxs("span",{className:"univer-absolute univer-left-1 univer-top-0.5",children:[p.selected&&I.jsx(Ut,{className:"univer-size-4 univer-text-primary-600"}),p.hidden&&I.jsx(Ua,{className:"univer-size-4 univer-text-gray-400"})]}),I.jsx("span",{className:z.clsx({"univer-text-primary-600":p.selected}),children:p.label})]}),onSelect:()=>{d(p)}})),[n]);return I.jsx(z.DropdownMenu,{align:"start",items:f,open:e,onOpenChange:S,children:I.jsx("div",{children:I.jsx(Lr,{children:I.jsx(Wa,{})})})})}function Lu(n){const{sheetId:i,label:e,color:t,selected:r,menuOverlay:o}=n,[s,l]=H.useState(r),c=_.useDependency(a.ThemeService);H.useEffect(()=>{l(r)},[r]);const d=u=>{const h=c.getColorFromTheme("gray.900"),g=c.getColorFromTheme("white");return new a.ColorKit(u).isDark()?g:h};return I.jsx("div",{"data-u-comp":"slide-tab-item","data-id":i,className:z.clsx("univer-mx-1 univer-box-border univer-flex univer-flex-grow univer-cursor-pointer univer-select-none univer-flex-row univer-items-center univer-rounded univer-text-xs univer-text-gray-900 univer-transition-colors dark:!univer-text-white",s?`
|
|
1
|
+
"use strict";var $c=Object.defineProperty;var ed=(n,i,e)=>i in n?$c(n,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[i]=e;var w=(n,i,e)=>ed(n,typeof i!="symbol"?i+"":i,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const J=require("@univerjs/docs-ui"),a=require("@univerjs/core"),T=require("@univerjs/engine-render"),_=require("@univerjs/ui"),H=require("react"),O=require("rxjs"),m=require("@univerjs/sheets"),ve=require("@univerjs/docs"),Z=require("@univerjs/engine-formula"),vi=require("@univerjs/engine-numfmt"),I=require("react/jsx-runtime"),z=require("@univerjs/design"),de=require("rxjs/operators"),td=require("@univerjs/telemetry");function Ci(n,i){if(n==null)return;const e=i.getRenderById(n);if(e==null)return;const{mainComponent:t,scene:r,engine:o,components:s}=e,l=t,c=s.get(J.DOCS_VIEW_KEY.BACKGROUND);return{document:l,docBackground:c,scene:r,engine:o}}const _o=[10,400],Go="RANGE_SELECTOR_COMPONENT_KEY",_i="EMBEDDING_FORMULA_EDITOR_COMPONENT_KEY";var ue=(n=>(n.MAIN="__SpreadsheetRender__",n.ROW="__SpreadsheetRowHeader__",n.COLUMN="__SpreadsheetColumnHeader__",n.LEFT_TOP="__SpreadsheetLeftTopPlaceholder__",n))(ue||{});const ys=0,zr=1,ht=10,nd=11,Ms=12,Ii={id:"sheet.command.set-row-header-width",type:a.CommandType.COMMAND,handler:async(n,i)=>{if(!i)return!1;const e=n.get(T.IRenderManagerService);if(!e)return!1;const{unitId:t,subUnitId:r,size:o}=i,s=e.getRenderById(t);if(s){e.getRenderById(t).with(exports.SheetSkeletonManagerService).setRowHeaderSize(s,r,o);const{components:c}=s,d=c.get(ue.ROW);d&&d.setCustomHeader({headerStyle:{size:o}})}return!0}},bi={id:"sheet.command.set-col-header-height",type:a.CommandType.COMMAND,handler:async(n,i)=>{if(!i)return!1;const e=n.get(T.IRenderManagerService);if(!e)return!1;const{unitId:t,subUnitId:r,size:o}=i,s=e.getRenderById(t);if(s){e.getRenderById(t).with(exports.SheetSkeletonManagerService).setColumnHeaderSize(s,r,o);const{components:c}=s,d=c.get(ue.COLUMN);d&&d.setCustomHeader({headerStyle:{size:o}})}return!0}},Io=a.createInterceptorKey("rangeMovePermissionCheck"),bo=a.createInterceptorKey("rangeFillPermissionCheck");var Zo=(n=>(n[n.FORMULA_EDITOR_SHOW=100]="FORMULA_EDITOR_SHOW",n[n.MARK_SELECTION=1e4]="MARK_SELECTION",n))(Zo||{});function mt(n){const i=n.getColorFromTheme("primary.600"),e=n.getColorFromTheme("white"),t=new a.ColorKit(i).setAlpha(.07).toRgbString();return{strokeWidth:1,stroke:i,fill:t,widgets:{},widgetSize:6,widgetStrokeWidth:1,widgetStroke:e,autofillSize:6,autofillStrokeWidth:1,autofillStroke:e,rowHeaderFill:t,rowHeaderStroke:i,rowHeaderStrokeWidth:1,columnHeaderFill:t,columnHeaderStroke:i,columnHeaderStrokeWidth:1,expandCornerSize:40}}class rd{constructor(){w(this,"_startColumn",-1);w(this,"_startRow",-1);w(this,"_endColumn",-1);w(this,"_endRow",-1);w(this,"_startX",0);w(this,"_startY",0);w(this,"_endX",0);w(this,"_endY",0);w(this,"_primary");w(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._primary}get rangeType(){return this._rangeType}isEqual(i){const{startColumn:e,startRow:t,endColumn:r,endRow:o}=this,{startColumn:s,startRow:l,endColumn:c,endRow:d}=i;return e===s&&t===l&&r===c&&o===d}highlightToSelection(){if(this._primary)return a.convertCellToRange(this._primary)}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._primary}getRangeType(){return this._rangeType}setRangeType(i){this._rangeType=i}getValue(){return{rangeWithCoord:this.getRange(),primaryWithCoord:this._primary}}setValue(i,e){const{startColumn:t,startRow:r,endColumn:o,endRow:s,startX:l,startY:c,endX:d,endY:u,rangeType:h}=i;this._startColumn=t,this._startRow=r,this._endColumn=o,this._endRow=s,this._startX=l,this._startY=c,this._endX=d,this._endY=u,h!==void 0&&(this._rangeType=h),e!==void 0&&this.setCurrentCell(e)}setCurrentCell(i){this._primary=i}clearCurrentCell(){this._primary=null}}function cn(n,i){const{startRow:e,startColumn:t,endRow:r,endColumn:o,rangeType:s}=i,l=r<e?r:e,c=r<e?e:r,d=o<t?o:t,u=o<t?t:o,h=n.getNoMergeCellWithCoordByIndex(l,d),g=n.getNoMergeCellWithCoordByIndex(c,u);return{startRow:e,startColumn:t,endRow:r,endColumn:o,rangeType:s,startY:(h==null?void 0:h.startY)||0,endY:(g==null?void 0:g.endY)||0,startX:(h==null?void 0:h.startX)||0,endX:(g==null?void 0:g.endX)||0}}function we(n,i){const{range:e,primary:t,style:r}=n,o=cn(i,e),s=t&&Gn(i,t);return{rangeWithCoord:o,primaryWithCoord:s,style:r}}function Gn(n,i){const{actualRow:e,actualColumn:t,isMerged:r,isMergedMainCell:o,startRow:s,startColumn:l,endRow:c,endColumn:d}=i,u=n.getNoMergeCellWithCoordByIndex(e,t),h=n.getNoMergeCellWithCoordByIndex(s,l),g=n.getNoMergeCellWithCoordByIndex(c,d);return{actualRow:e,actualColumn:t,isMerged:r,isMergedMainCell:o,startX:u.startX,startY:u.startY,endX:u.endX,endY:u.endY,mergeInfo:{startRow:s,startColumn:l,endRow:c,endColumn:d,startY:(h==null?void 0:h.startY)||0,endY:(g==null?void 0:g.endY)||0,startX:(h==null?void 0:h.startX)||0,endX:(g==null?void 0:g.endX)||0}}}const Ps="__SpreadsheetHelperSelectionTempRect",id=35;class ya{constructor(i,e){w(this,"_startOffsetX",0);w(this,"_startOffsetY",0);w(this,"_relativeSelectionPositionRow",0);w(this,"_relativeSelectionPositionColumn",0);w(this,"_relativeSelectionRowLength",0);w(this,"_relativeSelectionColumnLength",0);w(this,"_scenePointerMoveSub");w(this,"_scenePointerUpSub");w(this,"_disabled",!1);w(this,"_helperSelection");w(this,"_scrollTimer");w(this,"_activeViewport");w(this,"_targetSelection",{startY:0,endY:0,startX:0,endX:0,startRow:-1,endRow:-1,startColumn:-1,endColumn:-1});w(this,"_isInMergeState",!1);w(this,"_fillControlColors",[]);w(this,"_skeleton");w(this,"_scene");w(this,"_themeService");w(this,"_injector");w(this,"_selectionHooks");this._control=i,this._skeleton=e.skeleton,this._scene=e.scene,this._themeService=e.themeService,this._injector=e.injector,this._selectionHooks=e.selectionHooks,this._initialControl(),this._initialWidget(),this._initialAutoFill(),this._control.dispose$.subscribe(()=>{this.dispose()})}get isHelperSelection(){return this._control.isHelperSelection}dispose(){var i,e;(i=this._scrollTimer)==null||i.dispose(),this._fillControlColors=[],this._clearObserverEvent(),(e=this._helperSelection)==null||e.dispose()}setDisabled(i){this._disabled=i}_getFreeze(){var e,t;return(t=(e=T.withCurrentTypeOfRenderer(a.UniverInstanceType.UNIVER_SHEET,exports.SheetSkeletonManagerService,this._injector.get(a.IUniverInstanceService),this._injector.get(T.IRenderManagerService)))==null?void 0:e.getCurrentParam())==null?void 0:t.skeleton.getWorksheetConfig().freeze}_isSelectionInViewport(i,e){const t=this._getFreeze()||{startRow:-1,startColumn:-1};switch(e.viewportKey){case T.SHEET_VIEWPORT_KEY.VIEW_MAIN:return i.endRow>=t.startRow&&i.endColumn>=t.startColumn;case T.SHEET_VIEWPORT_KEY.VIEW_MAIN_TOP:case T.SHEET_VIEWPORT_KEY.VIEW_COLUMN_RIGHT:return i.endColumn>=t.startColumn&&i.startRow<t.startRow;case T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT:case T.SHEET_VIEWPORT_KEY.VIEW_ROW_BOTTOM:return i.endRow>=t.startRow&&i.startColumn<t.startColumn;case T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP:case T.SHEET_VIEWPORT_KEY.VIEW_COLUMN_LEFT:case T.SHEET_VIEWPORT_KEY.VIEW_ROW_TOP:case T.SHEET_VIEWPORT_KEY.VIEW_LEFT_TOP:return i.startRow<t.startRow&&i.startColumn<t.startColumn}}_clearObserverEvent(){var i,e;(i=this._scenePointerMoveSub)==null||i.unsubscribe(),(e=this._scenePointerUpSub)==null||e.unsubscribe(),this._scenePointerMoveSub=null,this._scenePointerUpSub=null}_initialControl(){const{leftControl:i,rightControl:e,topControl:t,bottomControl:r}=this._control;[i,e,t,r].forEach(o=>{o.onPointerEnter$.subscribeEvent(()=>{var l;((l=this._injector.get(pe,a.Quantity.OPTIONAL))==null?void 0:l.interceptor.fetchThroughInterceptors(Io)(!1,null))!==!1&&o.setCursor(T.CURSOR_TYPE.MOVE)}),o.onPointerLeave$.subscribeEvent(()=>{o.resetCursor()}),o.onPointerDown$.subscribeEvent(this._controlPointerDownHandler.bind(this))})}_controlMoving(i,e){var A;const t=this._scene,r=t.getScrollXYInfoByViewport(T.Vector2.FromArray([i,e])),{scaleX:o,scaleY:s}=t.getAncestorScale(),l=this._skeleton.getCellIndexByOffset(i,e,o,s,r),{row:c,column:d}=l,u=this._skeleton.getRowCount()-1,h=this._skeleton.getColumnCount()-1;let g=Math.max(0,c+this._relativeSelectionPositionRow),S=g+this._relativeSelectionRowLength;S>u&&(S=u,S-g<this._relativeSelectionRowLength&&(g=S-this._relativeSelectionRowLength));let f=Math.max(0,d+this._relativeSelectionPositionColumn),p=f+this._relativeSelectionColumnLength;p>h&&(p=h,p-f<this._relativeSelectionColumnLength&&(f=p-this._relativeSelectionColumnLength));const v=this._skeleton.worksheet.getCellInfoInMergeData(g,f),b=we({range:{startRow:g,endRow:S,startColumn:f,endColumn:p},primary:v,style:null},this._skeleton),R=this._skeleton.getNoMergeCellWithCoordByIndex(g,f),E=this._skeleton.getNoMergeCellWithCoordByIndex(S,p),P=(R==null?void 0:R.startY)||0,y=(E==null?void 0:E.endY)||0,M=(R==null?void 0:R.startX)||0,x=(E==null?void 0:E.endX)||0;(A=this._helperSelection)==null||A.transformByState({left:M,top:P,width:x-M,height:y-P}),this._targetSelection={...b.rangeWithCoord},this._control.selectionMoving$.next(b.rangeWithCoord)}_controlPointerDownHandler(i){const{offsetX:e,offsetY:t}=i,r=this._scene,o=r.getCoordRelativeToViewport(T.Vector2.FromArray([e,t])),{x:s,y:l}=o,c=r.getScrollXYInfoByViewport(o),{scaleX:d,scaleY:u}=r.getAncestorScale(),h=this._skeleton.getCellIndexByOffset(s,l,d,u,c);this._startOffsetX=s,this._startOffsetY=l;const{row:g,column:S}=h,{startRow:f,startColumn:p,endRow:v,endColumn:C}=this._control.model;let b=0,R=0;g<f?b-=1:g>v&&(b+=1),S<p?R-=1:S>C&&(R+=1),this._relativeSelectionPositionRow=f-g+b,this._relativeSelectionPositionColumn=p-S+R,this._relativeSelectionRowLength=v-f,this._relativeSelectionColumnLength=C-p;const E=this._control.currentStyle,P=this._getScale();this.isHelperSelection&&(this._helperSelection=new T.Rect(Ps,{stroke:E.stroke,strokeWidth:E.strokeWidth/P}),r.addObject(this._helperSelection));const y=r.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN),M=T.ScrollTimer.create(r);this._scrollTimer=M,M.startScroll(s,l,y),r.disableObjectsEvent(),this._scenePointerMoveSub=r.onPointerMove$.subscribeEvent(x=>{var V;if(this._disabled)return;const{offsetX:A,offsetY:k}=x;if(((V=this._injector.get(pe,a.Quantity.OPTIONAL))==null?void 0:V.interceptor.fetchThroughInterceptors(Io)(!1,null))===!1)return;const{x:N,y:W}=r.getCoordRelativeToViewport(T.Vector2.FromArray([A,k]));this._controlMoving(N,W),r.setCursor(T.CURSOR_TYPE.MOVE),M.scrolling(N,W,()=>{this._controlMoving(N,W)})}),this._scenePointerUpSub=r.onPointerUp$.subscribeEvent(()=>{var A,k,D,N;(A=this._helperSelection)==null||A.dispose();const x=this._scene;x.resetCursor(),this._clearObserverEvent(),x.enableObjectsEvent(),(k=this._scrollTimer)==null||k.dispose(),this._control.selectionMoveEnd$.next(this._targetSelection),(N=(D=this._selectionHooks).selectionMoveEnd)==null||N.call(D)})}_initialWidget(){const{topLeftWidget:i,topCenterWidget:e,topRightWidget:t,middleLeftWidget:r,middleRightWidget:o,bottomLeftWidget:s,bottomCenterWidget:l,bottomRightWidget:c}=this._control,d=[T.CURSOR_TYPE.NORTH_WEST_RESIZE,T.CURSOR_TYPE.NORTH_RESIZE,T.CURSOR_TYPE.NORTH_EAST_RESIZE,T.CURSOR_TYPE.WEST_RESIZE,T.CURSOR_TYPE.EAST_RESIZE,T.CURSOR_TYPE.SOUTH_WEST_RESIZE,T.CURSOR_TYPE.SOUTH_RESIZE,T.CURSOR_TYPE.SOUTH_EAST_RESIZE];[i,e,t,r,o,s,l,c].forEach((u,h)=>{u.onPointerEnter$.subscribeEvent(()=>{u.setCursor(d[h])}),u.onPointerLeave$.subscribeEvent(()=>{u.resetCursor()}),u.onPointerDown$.subscribeEvent(g=>{this._widgetPointerDownEvent(g,d[h])})})}_widgetPointerDownEvent(i,e){const t=this._scene,{offsetX:r,offsetY:o}=i,s=t.getCoordRelativeToViewport(T.Vector2.FromArray([r,o])),{x:l,y:c}=s;this._startOffsetX=r,this._startOffsetY=o;const{startRow:d,startColumn:u,endRow:h,endColumn:g}=this._control.model,S=Math.min(d,h),f=Math.min(u,g),p=Math.max(d,h),v=Math.max(u,g);this._relativeSelectionPositionRow=S,this._relativeSelectionPositionColumn=f,this._relativeSelectionRowLength=p-S,this._relativeSelectionColumnLength=v-f,e===T.CURSOR_TYPE.NORTH_WEST_RESIZE?(this._relativeSelectionPositionRow=p,this._relativeSelectionPositionColumn=v):e===T.CURSOR_TYPE.NORTH_RESIZE?this._relativeSelectionPositionRow=p:e===T.CURSOR_TYPE.NORTH_EAST_RESIZE?this._relativeSelectionPositionRow=p:e===T.CURSOR_TYPE.WEST_RESIZE?this._relativeSelectionPositionColumn=v:e===T.CURSOR_TYPE.SOUTH_WEST_RESIZE?this._relativeSelectionPositionColumn=v:e===T.CURSOR_TYPE.SOUTH_RESIZE&&(this._relativeSelectionPositionRow=S);const C=T.ScrollTimer.create(t),b=t.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN);C.startScroll(l,c,b),this._scrollTimer=C,t.disableObjectsEvent(),this._scenePointerMoveSub=t.onPointerMove$.subscribeEvent(R=>{const{offsetX:E,offsetY:P}=R,{x:y,y:M}=t.getCoordRelativeToViewport(T.Vector2.FromArray([E,P]));this._widgetMoving(y,M,e),t.setCursor(e),C.scrolling(y,M,()=>{this._widgetMoving(y,M,e)})}),this._scenePointerUpSub=t.onPointerUp$.subscribeEvent(()=>{var E,P,y;const R=this._scene;R.resetCursor(),this._clearObserverEvent(),R.enableObjectsEvent(),(E=this._scrollTimer)==null||E.dispose(),this._control.selectionScaled$.next(this._targetSelection),(y=(P=this._selectionHooks).selectionMoveEnd)==null||y.call(P)})}_widgetMoving(i,e,t){const r=this._scene,o=r.getScrollXYInfoByViewport(T.Vector2.FromArray([this._startOffsetX,this._startOffsetY])),{scaleX:s,scaleY:l}=r.getAncestorScale(),c=this._skeleton.getCellIndexByOffset(i,e,s,l,o),{row:d,column:u}=c;let h=this._relativeSelectionPositionRow,g=this._relativeSelectionPositionColumn,S=d,f=u;t===T.CURSOR_TYPE.NORTH_WEST_RESIZE?(h=d,g=u,S=this._relativeSelectionPositionRow,f=this._relativeSelectionPositionColumn):t===T.CURSOR_TYPE.NORTH_RESIZE?(h=d,g=this._relativeSelectionPositionColumn,S=this._relativeSelectionPositionRow,f=this._relativeSelectionPositionColumn+this._relativeSelectionColumnLength):t===T.CURSOR_TYPE.NORTH_EAST_RESIZE?(h=d,g=this._relativeSelectionPositionColumn,S=this._relativeSelectionPositionRow,f=u):t===T.CURSOR_TYPE.WEST_RESIZE?(h=this._relativeSelectionPositionRow,g=u,S=this._relativeSelectionPositionRow+this._relativeSelectionRowLength,f=this._relativeSelectionPositionColumn):t===T.CURSOR_TYPE.EAST_RESIZE?S=this._relativeSelectionPositionRow+this._relativeSelectionRowLength:t===T.CURSOR_TYPE.SOUTH_WEST_RESIZE?(h=this._relativeSelectionPositionRow,g=u,S=d,f=this._relativeSelectionPositionColumn):t===T.CURSOR_TYPE.SOUTH_RESIZE&&(h=this._relativeSelectionPositionRow,g=this._relativeSelectionPositionColumn,S=d,f=this._relativeSelectionPositionColumn+this._relativeSelectionColumnLength);const p=this._swapPositions(h,g,S,f),v=this._skeleton.getCellWithMergeInfoByIndex(h,g),b=we({range:p,primary:v,style:null},this._skeleton);this._targetSelection={...b.rangeWithCoord},this._control.updateRangeBySelectionWithCoord(b),this._control.selectionScaling$.next(this._targetSelection)}_initialAutoFill(){const{fillControl:i}=this._control;i.onPointerEnter$.subscribeEvent(e=>{this._injector.get(pe).interceptor.fetchThroughInterceptors(bo)(!1,{x:e.offsetX,y:e.offsetY,skeleton:this._skeleton,scene:this._scene})&&i.setCursor(T.CURSOR_TYPE.CROSSHAIR)}),i.onPointerLeave$.subscribeEvent(()=>{i.resetCursor()}),i.onPointerDown$.subscribeEvent(this._autoFillForPointerdown.bind(this))}_autoFillMoving(i,e){var k,D,N;const t=this._scene,r=t.getViewportScrollXY(this._activeViewport),{scaleX:o,scaleY:s}=t.getAncestorScale(),l=this._skeleton.getCellIndexByOffset(i,e,o,s,r),{row:c,column:d}=l,u=t.getCoordRelativeToViewport(T.Vector2.FromArray([i,e])),h=this._skeleton.getRowCount()-1,g=this._skeleton.getColumnCount()-1;let S=this._relativeSelectionPositionRow,f=this._relativeSelectionPositionColumn,p=this._relativeSelectionPositionRow+this._relativeSelectionRowLength,v=this._relativeSelectionPositionColumn+this._relativeSelectionColumnLength,C=!1,b=!0;if((d<f||d>v)&&c>=S&&c<=p){const W=this._fillRuler(d,f,v,this._relativeSelectionColumnLength,g);f=W.startRowOrColumn,v=W.endRowOrColumn,C=W.isLighten,b=!1}else if((c<S||c>p)&&d>=f&&d<=v){const W=this._fillRuler(c,S,p,this._relativeSelectionRowLength,h);S=W.startRowOrColumn,p=W.endRowOrColumn,C=W.isLighten}else if(Math.abs(this._startOffsetX-u.x-r.x)/2>Math.abs(this._startOffsetY-u.y-r.y)){const W=this._fillRuler(d,f,v,this._relativeSelectionColumnLength,g);f=W.startRowOrColumn,v=W.endRowOrColumn,C=W.isLighten,b=!1}else{const W=this._fillRuler(c,S,p,this._relativeSelectionRowLength,h);S=W.startRowOrColumn,p=W.endRowOrColumn,C=W.isLighten}const R=this._skeleton.getNoMergeCellWithCoordByIndex(S,f),E=this._skeleton.getNoMergeCellWithCoordByIndex(p,v),P=(R==null?void 0:R.startY)||0,y=(E==null?void 0:E.endY)||0,M=(R==null?void 0:R.startX)||0,x=(E==null?void 0:E.endX)||0;C?this._controlHandler((W,V)=>{const U=new a.ColorKit(this._fillControlColors[V]).lighten(id).toRgbString();W.setProps({fill:U})}):this._controlHandler((W,V)=>{W.setProps({fill:this._fillControlColors[V]})});const A=m.SELECTION_CONTROL_BORDER_BUFFER_WIDTH/this._getScale();S===p&&b===!0||f===v&&b===!1?(k=this._helperSelection)==null||k.hide():((D=this._helperSelection)==null||D.transformByState({left:M-A/2,top:P-A/2,width:x-M,height:y-P}),(N=this._helperSelection)==null||N.show()),this._targetSelection={startY:P,endY:y,startX:M,endX:x,startRow:S,endRow:p,startColumn:f,endColumn:v},this._control.selectionFilling$.next(this._targetSelection)}_autoFillForPointerdown(i){const{offsetX:e,offsetY:t}=i,r=this._scene,o=r.getCoordRelativeToViewport(T.Vector2.FromArray([e,t])),{x:s,y:l}=o;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 g=this._control.currentStyle;let S=g==null?void 0:g.stroke,f=g==null?void 0:g.strokeWidth;const p=mt(this._themeService);S==null&&(S=p.stroke),f==null&&(f=p.strokeWidth);const v=this._getScale();f/=v;const C=m.SELECTION_CONTROL_BORDER_BUFFER_WIDTH/v,b=new a.ColorKit(S).darken(2).toRgbString();this.isHelperSelection&&(this._helperSelection=new T.Rect(Ps,{stroke:b,strokeWidth:f+C/2}),r.addObject(this._helperSelection)),this._activeViewport=r.getActiveViewportByCoord(T.Vector2.FromArray([e,t]));const R=r.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN),E=T.ScrollTimer.create(r,this._activeViewport.viewportKey===T.SHEET_VIEWPORT_KEY.VIEW_MAIN?T.ScrollTimerType.ALL:T.ScrollTimerType.NONE);E.startScroll(s,l,R),this._scrollTimer=E,r.disableObjectsEvent(),this._controlHandler(P=>{this._fillControlColors.push(P.fill)}),this._scenePointerMoveSub=r.onPointerMove$.subscribeEvent(P=>{var W;const{offsetX:y,offsetY:M}=P,x=r.getActiveViewportByCoord(T.Vector2.FromArray([y,M]));if(!this._injector.get(pe).interceptor.fetchThroughInterceptors(bo)(!1,{x:i.offsetX,y:i.offsetY,skeleton:this._skeleton,scene:this._scene}))return;const{x:k,y:D}=r.getCoordRelativeToViewport(T.Vector2.FromArray([y,M]));this._autoFillMoving(k,D),r.setCursor(T.CURSOR_TYPE.CROSSHAIR);const N=this._targetSelection;if(R&&x&&((W=this._activeViewport)==null?void 0:W.viewportKey)!==(x==null?void 0:x.viewportKey)){let V;N.startRow!==c?(E.scrollTimerType=T.ScrollTimerType.Y,V={...N,endRow:N.startRow}):N.endRow!==u?(E.scrollTimerType=T.ScrollTimerType.Y,V={...N,startRow:N.endRow}):N.startColumn!==d?(E.scrollTimerType=T.ScrollTimerType.X,V={...N,endColumn:N.startColumn}):(E.scrollTimerType=T.ScrollTimerType.X,V={...N,startColumn:N.endColumn}),this._isSelectionInViewport(V,x)&&(R.scrollToBarPos({x:E.scrollTimerType===T.ScrollTimerType.X?0:void 0,y:E.scrollTimerType===T.ScrollTimerType.Y?0:void 0}),this._activeViewport=x)}E.scrolling(k,D,()=>{this._autoFillMoving(k,D)})}),this._scenePointerUpSub=r.onPointerUp$.subscribeEvent(()=>{var y,M;(y=this._helperSelection)==null||y.dispose();const P=this._scene;P.resetCursor(),this._clearObserverEvent(),P.enableObjectsEvent(),(M=this._scrollTimer)==null||M.dispose(),this._control.refreshSelectionFilled(this._targetSelection),this._isInMergeState=!1,this._controlHandler((x,A)=>{x.setProps({fill:this._fillControlColors[A]})}),this._fillControlColors=[]})}_hasMergeInRange(i,e,t,r){return this._skeleton.worksheet.getMergedCellRange(i,e,t,r).length>0}_swapPositions(i,e,t,r){const o=Math.min(i,t),s=Math.min(e,r),l=Math.max(i,t),c=Math.max(e,r);return{startRow:o,startColumn:s,endRow:l,endColumn:c}}_controlHandler(i){const{leftControl:e,rightControl:t,topControl:r,bottomControl:o,backgroundControlTop:s,backgroundControlMiddleLeft:l,backgroundControlMiddleRight:c,backgroundControlBottom:d,fillControl:u}=this._control,h=[e,t,r,o,s,l,c,d,u];for(let g=0,S=h.length;g<S;g++){const f=h[g];i(f,g)}}_fillRuler(i,e,t,r,o){let s=!1;if(i<e)if(this._isInMergeState&&i<e){const l=e-i,c=r+1,d=Math.ceil(l/c);let u=e-d*c;u<0&&(u=e-(d-1)*c),e=u}else e=i;else if(i>=e&&i<=t)s=!0,this._isInMergeState||(t=i);else if(this._isInMergeState&&i>t){const l=i-t,c=r+1,d=Math.ceil(l/c);let u=t+d*c;u>o&&(u=t+(d-1)*c),t=u}else t=i;return{rowOrColumn:i,startRowOrColumn:e,endRowOrColumn:t,isLighten:s}}_getScale(){const{scaleX:i,scaleY:e}=this._scene.getAncestorScale();return Math.max(i,e)}}var Ro=(n=>(n.Selection="__SpreadsheetSelectionShape__",n.top="__SpreadsheetSelectionTopControl__",n.bottom="__SpreadsheetSelectionBottomControl__",n.left="__SpreadsheetSelectionShapeLeftControl__",n.right="__SpreadsheetSelectionShapeRightControl__",n.backgroundTop="__SpreadsheetSelectionBackgroundControlTop__",n.backgroundMiddleLeft="__SpreadsheetSelectionBackgroundControlMiddleLeft__",n.backgroundMiddleRight="__SpreadsheetSelectionBackgroundControlMiddleRight__",n.backgroundBottom="__SpreadsheetSelectionBackgroundControlBottom__",n.fill="__SpreadsheetSelectionFillControl__",n.fillTopLeft="__SpreadsheetSelectionFillControlTopLeft__",n.fillBottomRight="__SpreadsheetSelectionFillControlBottomRight__",n.fillTopLeftInner="__SpreadsheetSelectionFillControlTopLeftInner__",n.fillBottomRightInner="__SpreadsheetSelectionFillControlBottomRightInner__",n.lineMain="__SpreadsheetDragLineMainControl__",n.lineContent="__SpreadsheetDragLineContentControl__",n.line="__SpreadsheetDragLineControl__",n.dash="__SpreadsheetDragDashControl__",n.rowHeaderBackground="__SpreadSheetSelectionRowHeaderBackground__",n.rowHeaderBorder="__SpreadSheetSelectionRowHeaderBorder__",n.rowHeaderGroup="__SpreadSheetSelectionRowHeaderGroup__",n.columnHeaderBackground="__SpreadSheetSelectionColumnHeaderBackground__",n.columnHeaderBorder="__SpreadSheetSelectionColumnHeaderBorder__",n.columnHeaderGroup="__SpreadSheetSelectionColumnHeaderGroup__",n.topLeftWidget="__SpreadSheetSelectionTopLeftWidget__",n.topCenterWidget="__SpreadSheetSelectionTopCenterWidget__",n.topRightWidget="__SpreadSheetSelectionTopRightWidget__",n.middleLeftWidget="__SpreadSheetSelectionMiddleLeftWidget__",n.middleRightWidget="__SpreadSheetSelectionMiddleRightWidget__",n.bottomLeftWidget="__SpreadSheetSelectionBottomLeftWidget__",n.bottomCenterWidget="__SpreadSheetSelectionBottomCenterWidget__",n.bottomRightWidget="__SpreadSheetSelectionBottomRightWidget__",n))(Ro||{});const xs=.3;class nr extends a.Disposable{constructor(e,t,r,o){var s,l,c,d;super();w(this,"_isHelperSelection",!0);w(this,"_enableAutoFill",!0);w(this,"_showAutoFill",!1);w(this,"_highlightHeader",!0);w(this,"_selectionRenderModel");w(this,"_leftBorder");w(this,"_rightBorder");w(this,"_topBorder");w(this,"_bottomBorder");w(this,"_backgroundControlTop");w(this,"_backgroundControlBottom");w(this,"_backgroundControlMiddleLeft");w(this,"_backgroundControlMiddleRight");w(this,"_autoFillControl");w(this,"_selectionShapeGroup");w(this,"_rowHeaderBackground");w(this,"_rowHeaderBorder");w(this,"_rowHeaderGroup");w(this,"_columnHeaderBackground");w(this,"_columnHeaderBorder");w(this,"_columnHeaderGroup");w(this,"_dashedRect");w(this,"_topLeftWidget");w(this,"_topCenterWidget");w(this,"_topRightWidget");w(this,"_middleLeftWidget");w(this,"_middleRightWidget");w(this,"_bottomLeftWidget");w(this,"_bottomCenterWidget");w(this,"_bottomRightWidget");w(this,"_defaultStyle");w(this,"_currentStyle");w(this,"_rowHeaderWidth",0);w(this,"_columnHeaderHeight",0);w(this,"_widgetRects",[]);w(this,"_controlExtension");w(this,"_dispose$",new O.BehaviorSubject(this));w(this,"dispose$",this._dispose$.asObservable());w(this,"selectionMoving$",new O.Subject);w(this,"selectionMoveEnd$",new O.Subject);w(this,"selectionScaling$",new O.Subject);w(this,"selectionScaled$",new O.Subject);w(this,"selectionFilling$",new O.Subject);w(this,"_selectionFilled$",new O.Subject);w(this,"selectionFilled$",this._selectionFilled$.asObservable());w(this,"_antLineOffset",0);w(this,"_antRequestNewFrame",-1);this._scene=e,this._zIndex=t,this._themeService=r,this._enableAutoFill=(s=o==null?void 0:o.enableAutoFill)!=null?s:!0,this._highlightHeader=(l=o==null?void 0:o.highlightHeader)!=null?l:!0,this._rowHeaderWidth=(c=o==null?void 0:o.rowHeaderWidth)!=null?c:0,this._columnHeaderHeight=(d=o==null?void 0:o.columnHeaderHeight)!=null?d:0,this._initializeSheetBody(),this._initialHeader()}_initializeSheetBody(){this._defaultStyle=mt(this._themeService),this._currentStyle=mt(this._themeService),this._selectionRenderModel=new rd;const e=this._zIndex;this._leftBorder=new T.Rect("__SpreadsheetSelectionShapeLeftControl__"+e,{zIndex:e}),this._rightBorder=new T.Rect("__SpreadsheetSelectionShapeRightControl__"+e,{zIndex:e}),this._topBorder=new T.Rect("__SpreadsheetSelectionTopControl__"+e,{zIndex:e}),this._bottomBorder=new T.Rect("__SpreadsheetSelectionBottomControl__"+e,{zIndex:e}),this._backgroundControlTop=new T.Rect("__SpreadsheetSelectionBackgroundControlTop__"+e,{zIndex:e-1,evented:!1}),this._backgroundControlBottom=new T.Rect("__SpreadsheetSelectionBackgroundControlBottom__"+e,{zIndex:e-1,evented:!1}),this._backgroundControlMiddleLeft=new T.Rect("__SpreadsheetSelectionBackgroundControlMiddleLeft__"+e,{zIndex:e-1,evented:!1}),this._backgroundControlMiddleRight=new T.Rect("__SpreadsheetSelectionBackgroundControlMiddleRight__"+e,{zIndex:e-1,evented:!1}),this._autoFillControl=new T.Rect("__SpreadsheetSelectionFillControl__"+e,{zIndex:e+1}),this._autoFillControl.hide(),this._dashedRect=new T.DashedRect("__SpreadsheetDragDashControl__"+e,{zIndex:e+2,evented:!1,stroke:"#fff"});const t=[this._autoFillControl,this._leftBorder,this._rightBorder,this._topBorder,this._bottomBorder,this._backgroundControlTop,this._backgroundControlMiddleLeft,this._backgroundControlMiddleRight,this._backgroundControlBottom,this._dashedRect];this._widgetRects=this._initialWidget(),this._selectionShapeGroup=new T.Group("__SpreadsheetSelectionShape__"+e,...t,...this._widgetRects),this._selectionShapeGroup.hide(),this._selectionShapeGroup.evented=!1,this._selectionShapeGroup.zIndex=e;const r=this.getScene();r.addObject(this._selectionShapeGroup,zr),this.disposeWithMe(a.toDisposable(r.onTransformChange$.subscribeEvent(o=>{o.type===T.TRANSFORM_CHANGE_OBSERVABLE_TYPE.scale&&(this._updateLayoutOfSelectionControl(this._currentStyle),this._updateControlCoord())})))}_initialHeader(){const e=this._zIndex;this._rowHeaderBackground=new T.Rect("__SpreadSheetSelectionRowHeaderBackground__"+e,{zIndex:e-1,evented:!1}),this._rowHeaderBorder=new T.Rect("__SpreadSheetSelectionRowHeaderBorder__"+e,{zIndex:e-1,evented:!1}),this._rowHeaderGroup=new T.Group("__SpreadSheetSelectionRowHeaderGroup__"+e,this._rowHeaderBackground,this._rowHeaderBorder),this._rowHeaderGroup.hide(),this._rowHeaderGroup.evented=!1,this._rowHeaderGroup.zIndex=e,this._columnHeaderBackground=new T.Rect("__SpreadSheetSelectionColumnHeaderBackground__"+e,{zIndex:e-1,evented:!1}),this._columnHeaderBorder=new T.Rect("__SpreadSheetSelectionColumnHeaderBorder__"+e,{zIndex:e-1,evented:!1}),this._columnHeaderGroup=new T.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],nd)}_initialWidget(){const e=this._zIndex;return this._topLeftWidget=new T.Rect("__SpreadSheetSelectionTopLeftWidget__"+e,{zIndex:e+1}),this._topCenterWidget=new T.Rect("__SpreadSheetSelectionTopCenterWidget__"+e,{zIndex:e+1}),this._topRightWidget=new T.Rect("__SpreadSheetSelectionTopRightWidget__"+e,{zIndex:e+1}),this._middleLeftWidget=new T.Rect("__SpreadSheetSelectionMiddleLeftWidget__"+e,{zIndex:e+1}),this._middleRightWidget=new T.Rect("__SpreadSheetSelectionMiddleRightWidget__"+e,{zIndex:e+1}),this._bottomLeftWidget=new T.Rect("__SpreadSheetSelectionBottomLeftWidget__"+e,{zIndex:e+1}),this._bottomCenterWidget=new T.Rect("__SpreadSheetSelectionBottomCenterWidget__"+e,{zIndex:e+1}),this._bottomRightWidget=new T.Rect("__SpreadSheetSelectionBottomRightWidget__"+e,{zIndex:e+1}),[this._topLeftWidget,this._topCenterWidget,this._topRightWidget,this._middleLeftWidget,this._middleRightWidget,this._bottomLeftWidget,this._bottomCenterWidget,this._bottomRightWidget]}get zIndex(){return this._zIndex}get leftControl(){return this._leftBorder}get rightControl(){return this._rightBorder}get topControl(){return this._topBorder}get bottomControl(){return this._bottomBorder}get fillControl(){return this._autoFillControl}get backgroundControlTop(){return this._backgroundControlTop}get backgroundControlBottom(){return this._backgroundControlBottom}get backgroundControlMiddleLeft(){return this._backgroundControlMiddleLeft}get backgroundControlMiddleRight(){return this._backgroundControlMiddleRight}get selectionShape(){return this._selectionShapeGroup}get columnHeaderGroup(){return this._columnHeaderGroup}get rowHeaderGroup(){return this._rowHeaderGroup}get selectionShapeGroup(){return this._selectionShapeGroup}get model(){return this._selectionRenderModel}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 themeService(){return this._themeService}get selectionModel(){return this._selectionRenderModel}set selectionModel(e){this._selectionRenderModel=e}get currentStyle(){return this._currentStyle}set currentStyle(e){this._currentStyle=e}get dashedRect(){return this._dashedRect}get isHelperSelection(){return this._isHelperSelection}get rowHeaderWidth(){return this._rowHeaderWidth}set rowHeaderWidth(e){this._rowHeaderWidth=e}get columnHeaderHeight(){return this._columnHeaderHeight}set columnHeaderHeight(e){this._columnHeaderHeight=e}setControlExtension(e){this._controlExtension=new ya(this,e)}setControlExtensionDisable(e){this._controlExtension&&this._controlExtension.setDisabled(e)}setEvent(e){this.leftControl.evented=e,this.rightControl.evented=e,this.topControl.evented=e,this.bottomControl.evented=e}refreshSelectionFilled(e){this._selectionFilled$.next(e)}_updateLayoutOfSelectionControl(e){e&&(this.currentStyle=Object.assign({},this._defaultStyle,e));const t=this.currentStyle,{stroke:r,widgets:o,autofillStroke:s,strokeDash:l,isAnimationDash:c}=t;let d=t.autofillSize,u=t.strokeWidth,h=t.autofillStrokeWidth;const g=this._getScale(),S=(u+m.SELECTION_CONTROL_BORDER_BUFFER_WIDTH)/2/g;u/=g,d/=g,h/=g<1?1:g;const f=m.SELECTION_CONTROL_BORDER_BUFFER_WIDTH/g,p=T.FIX_ONE_PIXEL_BLUR_OFFSET/g,{startX:v,startY:C,endX:b,endY:R}=this._selectionRenderModel;if(this.leftControl.transformByState({height:R-C,left:-S+p,width:u,strokeWidth:f,top:-f/2+p}),this.leftControl.setProps({fill:r,stroke:m.SELECTION_CONTROL_BORDER_BUFFER_COLOR}),this.rightControl.transformByState({height:R-C,left:b-v-S+p,width:u,strokeWidth:f,top:-f/2+p}),this.rightControl.setProps({fill:r,stroke:m.SELECTION_CONTROL_BORDER_BUFFER_COLOR}),this.topControl.transformByState({width:b-v+u,top:-S+p,left:-S+p,height:u,strokeWidth:f}),this.topControl.setProps({fill:r,stroke:m.SELECTION_CONTROL_BORDER_BUFFER_COLOR}),this.bottomControl.transformByState({width:b-v+u,top:R-C-S+p,height:u,left:-S+p,strokeWidth:f}),this.bottomControl.setProps({fill:r,stroke:m.SELECTION_CONTROL_BORDER_BUFFER_COLOR}),l==null)this.dashedRect.hide(),this._stopAntLineAnimation();else{const E=t.strokeWidth*2/g;this.dashedRect.transformByState({height:R-C,width:b-v,strokeWidth:E,left:-E/2+p,top:-E/2+p}),this.dashedRect.setProps({strokeDashArray:[0,l/g]}),this._stopAntLineAnimation(),c!==!1&&this._startAntLineAnimation(),this.dashedRect.show()}if(this._showAutoFill=this._showAutoFill&&this._enableAutoFill,this._showAutoFill&&!this._hasWidgets(o)){const E={fill:r,stroke:s,strokeScaleEnabled:!1},P={width:d-h,height:d-h,left:b-v-d/2+h/2-p,top:R-C-d/2+h/2-p,strokeWidth:h};this._autoFillControl.setProps(E),this._autoFillControl.transformByState(P),this._autoFillControl.show()}else this._autoFillControl.hide();this._updateBackgroundControl(t),this._updateHeaderBackground(t),this._updateWidgets(t)}_updateControlCoord(){const{startX:e,startY:t}=this._selectionRenderModel;this.selectionShapeGroup.show(),this.selectionShapeGroup.translate(e,t),this.selectionShapeGroup.makeDirtyNoDebounce(!0)}updateStyle(e){this._updateLayoutOfSelectionControl(e),this._updateControlCoord()}updateRange(e,t){this._selectionRenderModel.setValue(e,t),this._showAutoFill=t!==null,this._updateLayoutOfSelectionControl(),this._updateControlCoord()}updateRangeBySelectionWithCoord(e,t){t&&(this._rowHeaderWidth=t.rowHeaderWidth,this._columnHeaderHeight=t.columnHeaderHeight),this._selectionRenderModel.setValue(e.rangeWithCoord,e.primaryWithCoord),this._showAutoFill=e.primaryWithCoord!==null,this._updateLayoutOfSelectionControl(e.style),this._updateControlCoord()}update(e,t=0,r=0,o,s){this._rowHeaderWidth=t,this._columnHeaderHeight=r,this.updateRangeBySelectionWithCoord({rangeWithCoord:e,primaryWithCoord:s,style:o}),o&&this.updateStyle(o)}updateCurrCell(e){this._showAutoFill=e!==null,this._selectionRenderModel.setCurrentCell(e)}clearHighlight(){this._showAutoFill=!1,this._selectionRenderModel.clearCurrentCell(),this._updateLayoutOfSelectionControl(this._currentStyle)}getScene(){return this._scene}dispose(){var e,t,r,o,s,l,c,d,u,h,g,S,f,p,v,C,b,R,E,P,y,M,x,A,k;(e=this._leftBorder)==null||e.dispose(),(t=this._rightBorder)==null||t.dispose(),(r=this._topBorder)==null||r.dispose(),(o=this._bottomBorder)==null||o.dispose(),(s=this._backgroundControlTop)==null||s.dispose(),(l=this._backgroundControlMiddleLeft)==null||l.dispose(),(c=this._backgroundControlMiddleRight)==null||c.dispose(),(d=this._backgroundControlBottom)==null||d.dispose(),this._autoFillControl.dispose(),(u=this._selectionShapeGroup)==null||u.dispose(),(h=this._rowHeaderBackground)==null||h.dispose(),(g=this._rowHeaderBorder)==null||g.dispose(),(S=this._rowHeaderGroup)==null||S.dispose(),(f=this._rowHeaderBackground)==null||f.dispose(),(p=this._columnHeaderBackground)==null||p.dispose(),(v=this._columnHeaderBorder)==null||v.dispose(),(C=this._columnHeaderGroup)==null||C.dispose(),(b=this._topLeftWidget)==null||b.dispose(),(R=this._topCenterWidget)==null||R.dispose(),(E=this._topRightWidget)==null||E.dispose(),(P=this._middleLeftWidget)==null||P.dispose(),(y=this._middleRightWidget)==null||y.dispose(),(M=this._bottomLeftWidget)==null||M.dispose(),(x=this._bottomCenterWidget)==null||x.dispose(),(A=this._bottomRightWidget)==null||A.dispose(),(k=this._controlExtension)==null||k.dispose(),super.dispose(),this._dispose$.next(this),this._dispose$.complete()}getCurrentCellInfo(){const e=this.model.currentCell;if(e){let t;if(e.isMerged){const r=e.mergeInfo;t={startRow:r.startRow,endRow:r.endRow,startColumn:r.startColumn,endColumn:r.endColumn,startX:r.startX,endX:r.endX,startY:r.startY,endY:r.endY}}else{const{actualRow:r,actualColumn:o,startX:s,endX:l,startY:c,endY:d}=e;t={startRow:r,endRow:r,startColumn:o,endColumn:o,startX:s,endX:l,startY:c,endY:d}}return t}}getValue(){return{...this._selectionRenderModel.getValue(),style:this._currentStyle}}getRange(){return this._selectionRenderModel.getValue().rangeWithCoord}enableHelperSelection(){this._isHelperSelection=!0}disableHelperSelection(){this._isHelperSelection=!1}_updateHeaderBackground(e){const{startX:t,startY:r,endX:o,endY:s,rangeType:l}=this._selectionRenderModel,c=this._currentStyle,d=this._getScale(),{stroke:u,rowHeaderFill:h=c.rowHeaderFill,rowHeaderStroke:g=c.rowHeaderStroke,columnHeaderFill:S=c.columnHeaderFill,columnHeaderStroke:f=c.columnHeaderStroke}=e;let{rowHeaderStrokeWidth:p=c.rowHeaderStrokeWidth,columnHeaderStrokeWidth:v=c.columnHeaderStrokeWidth}=e;p/=d,v/=d;const C=this._rowHeaderWidth,b=this._columnHeaderHeight;if(this._highlightHeader&&b>0){let R=S;l===a.RANGE_TYPE.COLUMN&&(R=new a.ColorKit(u).setAlpha(xs).toString()),this._columnHeaderBackground.setProps({fill:R}),this._columnHeaderBackground.resize(o-t,b),this._columnHeaderBorder.setProps({fill:f}),this._columnHeaderBorder.transformByState({width:o-t,height:v,top:b-v+1/d}),this._columnHeaderGroup.show(),this._columnHeaderGroup.translate(t,0)}else this._columnHeaderGroup.hide();if(this._columnHeaderGroup.makeDirty(!0),this._highlightHeader&&C>0){let R=h;l===a.RANGE_TYPE.ROW&&(R=new a.ColorKit(u).setAlpha(xs).toString()),this._rowHeaderBackground.setProps({fill:R}),this._rowHeaderBackground.resize(C,s-r),this._rowHeaderBorder.setProps({fill:g}),this._rowHeaderBorder.transformByState({width:p,height:s-r,left:C-p+1/d}),this._rowHeaderGroup.show(),this._rowHeaderGroup.translate(0,r)}else this._rowHeaderGroup.hide();this._rowHeaderGroup.makeDirty(!0)}_updateBackgroundControl(e){const{startX:t,startY:r,endX:o,endY:s}=this._selectionRenderModel,l=this._getScale(),{fill:c=e.fill}=e;let{strokeWidth:d}=e;d/=l;const u=this._selectionRenderModel.highlightToSelection();if(!u){this._backgroundControlTop.resize(o-t,s-r),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:g,endX:S,endY:f}=u,p=d/2,v={left:-p,top:-p,width:o-t+p*2,height:g-r+p};v.height<0&&(v.width=0,v.height=0),this._backgroundControlTop.transformByState(v);const C={left:-p,top:g-r,width:h-t+p,height:f-g};C.width<0&&(C.width=0,C.height=0),this._backgroundControlMiddleLeft.transformByState(C);const b={left:S-t-p,top:g-r,width:o-S+p*2,height:f-g};b.width<0&&(b.width=0,b.height=0),this._backgroundControlMiddleRight.transformByState(b);const R={left:-p,top:f-r,width:o-t+p*2,height:s-f+p};R.height<0&&(R.width=0,R.height=0),this._backgroundControlBottom.transformByState(R),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:r,endX:o,endY:s}=this._selectionRenderModel,{stroke:l=e.stroke,widgets:c=e.widgets,widgetStroke:d=e.widgetStroke}=e,u=this._getScale();let{widgetSize:h,widgetStrokeWidth:g}=e;h/=u,g/=u;const S={left:-h/2+g/2,center:(o-t)/2-h/2+g/2,right:o-t-h/2+g/2,top:-h/2,middle:(s-r)/2-h/2,bottom:s-r-h/2+g/2},f=h-g;this._widgetRects.forEach(p=>{p.setProps({fill:l,stroke:d})}),c.tl===!0?(this._topLeftWidget.transformByState({height:f,width:f,left:S.left,top:S.top,strokeWidth:g}),this._topLeftWidget.show()):this._topLeftWidget.hide(),c.tc===!0?(this._topCenterWidget.transformByState({height:f,width:f,left:S.center,top:S.top,strokeWidth:g}),this._topCenterWidget.show()):this._topCenterWidget.hide(),c.tr===!0?(this._topRightWidget.transformByState({height:f,width:f,left:S.right,top:S.top,strokeWidth:g}),this._topRightWidget.show()):this._topRightWidget.hide(),c.ml===!0?(this._middleLeftWidget.transformByState({height:f,width:f,left:S.left,top:S.middle,strokeWidth:g}),this._middleLeftWidget.show()):this._middleLeftWidget.hide(),c.mr===!0?(this._middleRightWidget.transformByState({height:f,width:f,left:S.right,top:S.middle,strokeWidth:g}),this._middleRightWidget.show()):this._middleRightWidget.hide(),c.bl===!0?(this._bottomLeftWidget.transformByState({height:f,width:f,left:S.left,top:S.bottom,strokeWidth:g}),this._bottomLeftWidget.show()):this._bottomLeftWidget.hide(),c.bc===!0?(this._bottomCenterWidget.transformByState({height:f,width:f,left:S.center,top:S.bottom,strokeWidth:g}),this._bottomCenterWidget.show()):this._bottomCenterWidget.hide(),c.br===!0?(this._bottomRightWidget.transformByState({height:f,width:f,left:S.right,top:S.bottom,strokeWidth:g}),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 r of t)if(e[r]===!0)return!0;return!1}_getScale(){const{scaleX:e,scaleY:t}=this._scene.getAncestorScale();return Math.max(e,t)}_stopAntLineAnimation(){this._antLineOffset=0,T.cancelRequestFrame(this._antRequestNewFrame)}_startAntLineAnimation(){const e=this._getScale();this._antLineOffset+=.6/e,this._antLineOffset>160/e&&(this._antLineOffset=0),this.dashedRect.setProps({strokeDashOffset:-this._antLineOffset}),this._antRequestNewFrame=T.requestNewFrame(()=>{this._startAntLineAnimation()})}}class od extends T.Layer{render(i,e=!1){const t=a.Tools.now();return super.render(i,e),this._afterRender(t),this}_afterRender(i){this.scene.getEngine().renderFrameTimeMetric$.next(["selectionLayer",a.Tools.now()-i])}}const pe=a.createIdentifier("univer.sheet.selection-render-service");class Ko extends a.Disposable{constructor(e,t,r,o,s){super();w(this,"_downObserver");w(this,"_scenePointerMoveSub");w(this,"_scenePointerUpSub");w(this,"_controlFillConfig$",new O.BehaviorSubject(null));w(this,"controlFillConfig$",this._controlFillConfig$.asObservable());w(this,"_selectionControls",[]);w(this,"_startRangeWhenPointerDown",{startY:0,endY:0,startX:0,endX:0,startRow:-1,endRow:-1,startColumn:-1,endColumn:-1});w(this,"_activeControlIndex",-1);w(this,"_startViewportPosX",0);w(this,"_startViewportPosY",0);w(this,"_scrollTimer");w(this,"_cancelDownSubscription");w(this,"_cancelUpSubscription");w(this,"_skeleton");w(this,"_scene");w(this,"_highlightHeader",!0);w(this,"_rangeType",a.RANGE_TYPE.NORMAL);w(this,"_selectionStyle");w(this,"_remainLastEnabled",!1);w(this,"_skipLastEnabled",!1);w(this,"_singleSelectionEnabled",!1);w(this,"_selectionMoveEnd$",new O.BehaviorSubject([]));w(this,"selectionMoveEnd$",this._selectionMoveEnd$.asObservable());w(this,"_selectionMoving$",new O.Subject);w(this,"selectionMoving$",this._selectionMoving$.asObservable());w(this,"_selectionMoveStart$",new O.Subject);w(this,"selectionMoveStart$",this._selectionMoveStart$.asObservable());w(this,"_selectionMoving",!1);w(this,"_selectionTheme");w(this,"_activeViewport");w(this,"interceptor",new a.InterceptorManager({RANGE_MOVE_PERMISSION_CHECK:Io,RANGE_FILL_PERMISSION_CHECK:bo}));w(this,"_escapeShortcutDisposable",null);this._injector=e,this._themeService=t,this._shortcutService=r,this._sheetSkeletonManagerService=o,this.contextService=s,this._initSelectionThemeFromThemeService(),this._initMoving()}get selectionMoving(){return this._selectionMoving}get _shouldDetectMergedCells(){return this._rangeType===a.RANGE_TYPE.NORMAL}_initMoving(){this.disposeWithMe(this._selectionMoving$.subscribe(()=>{this._selectionMoving=!0})),this.disposeWithMe(this._selectionMoveEnd$.subscribe(()=>{this._selectionMoving=!1}))}_setSelectionStyle(e){this._selectionStyle=e}getViewPort(){return this._activeViewport}setSingleSelectionEnabled(e=!1){this._singleSelectionEnabled=e}newSelectionControl(e,t,r){const o=this.getSelectionControls().length,{rowHeaderWidth:s,columnHeaderHeight:l}=t,c=new nr(e,o,this._selectionTheme,{highlightHeader:this._highlightHeader,rowHeaderWidth:s,columnHeaderHeight:l});this._selectionControls.push(c);const d=we(r,t);return c.updateRangeBySelectionWithCoord(d,t),c.setControlExtension({skeleton:t,scene:e,themeService:this._selectionTheme,injector:this._injector,selectionHooks:{selectionMoveEnd:()=>{this._selectionMoveEnd$.next(this.getSelectionDataWithStyle())}}}),c}resetSelectionsByModelData(e){const t=this.getSelectionControls(),r=this._skeleton;if(!(!t||!r)){for(let o=0,s=e.length;o<s;o++){const l=e[o],c=we(l,this._skeleton),d=t[o];d?d.updateRangeBySelectionWithCoord(c,r):this.isSelectionEnabled()&&this.newSelectionControl(this._scene,r,l)}e.length<t.length&&t.splice(e.length).forEach(s=>s.dispose())}}refreshSelectionMoveStart(){this._selectionMoveStart$.next(this.getSelectionDataWithStyle())}refreshSelectionMoveEnd(){this._selectionMoveEnd$.next(this.getSelectionDataWithStyle())}_initSelectionThemeFromThemeService(){const e=this._themeService.getCurrentTheme();this._selectionTheme=new a.ThemeService,this._selectionTheme.setTheme(e)}setSelectionTheme(e){this._selectionTheme.setTheme(e)}_changeRuntime(e,t,r){this._skeleton=e,this._scene=t,this._activeViewport=r||(t==null?void 0:t.getViewports()[0]),t.findLayerByZIndex(zr)||t.addLayer(new od(t,[],zr))}getSkeleton(){return this._skeleton}getSelectionDataWithStyle(){const e=this._selectionControls,[t,r]=this._skeleton.getLocation();return e.map(o=>{const s=o.getValue();return s.rangeWithCoord.sheetId=r,s.rangeWithCoord.unitId=t,s})}getSelectionControls(){return this._selectionControls}_addSelectionControlByModelData(e){var l;const t=this._skeleton,r=(l=e.style)!=null?l:mt(this._selectionTheme),o=this._scene;return e.style=r,this.newSelectionControl(o,t,e)}_clearAllSelectionControls(){const e=this._selectionControls;for(const t of e)t.dispose();this._selectionControls.length=0}_getFreeze(){var t;return(t=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:t.skeleton.getWorksheetConfig().freeze}_getViewportByCell(e,t){if(e===void 0||t===void 0)return null;const r=this._getFreeze();if(!r||r.startRow<=0&&r.startColumn<=0)return this._scene.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN);if(e>r.startRow&&t>r.startColumn)return this._scene.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN);if(e<=r.startRow&&t<=r.startColumn)return this._scene.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP);if(e<=r.startRow&&t>r.startColumn)return this._scene.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN_TOP);if(e>r.startRow&&t<=r.startColumn)return this._scene.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT)}getActiveRange(){const e=this.getSelectionControls(),t=e&&e[e.length-1].model;return t&&{startRow:t.startRow,startColumn:t.startColumn,endRow:t.endRow,endColumn:t.endColumn}}setActiveSelectionIndex(e){this._activeControlIndex=e}resetActiveSelectionIndex(){this._activeControlIndex=-1}getActiveSelectionControl(){const e=this.getSelectionControls();if(e)return this._activeControlIndex<0?e[e.length-1]:e[this._activeControlIndex]}endSelection(){var e;this._clearUpdatingListeners(),this._selectionMoveEnd$.next(this.getSelectionDataWithStyle()),(e=this._escapeShortcutDisposable)==null||e.dispose(),this._escapeShortcutDisposable=null}_reset(){var e;this._clearAllSelectionControls(),(e=this._downObserver)==null||e.unsubscribe(),this._downObserver=null}_setupPointerMoveListener(e,t,r,o=T.ScrollTimerType.ALL,s,l){var f,p;let c=0,d=0,u=s,h=l;this._scrollTimer=T.ScrollTimer.create(this._scene,o),this._scrollTimer.startScroll((f=e==null?void 0:e.left)!=null?f:0,(p=e==null?void 0:e.top)!=null?p:0,e);const g=this._scene,S=g.getActiveViewportByCoord(T.Vector2.FromArray([s,l]));this._scenePointerMoveSub=g.onPointerMove$.subscribeEvent(v=>{var N,W,V,U,L,j,B,F,X;const{offsetX:C,offsetY:b}=v,{x:R,y:E}=g.getCoordRelativeToViewport(T.Vector2.FromArray([C,b]));this._movingHandler(R,E,t,r);let P=R,y=E;const M=this.getActiveSelectionControl(),x=this._getFreeze(),A=M==null?void 0:M.model,k=(N=g.getActiveViewportByCoord(T.Vector2.FromArray([C,b])))!=null?N:this._getViewportByCell(A==null?void 0:A.endRow,A==null?void 0:A.endColumn);if((()=>{if(!S||!k||!e)return!1;const K=[T.SHEET_VIEWPORT_KEY.VIEW_MAIN,T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP,T.SHEET_VIEWPORT_KEY.VIEW_MAIN_TOP,T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT];return K.includes(S.viewportKey)&&K.includes(k.viewportKey)})()){if(!S||!k||!e)return!1;const K=u<e.left&&R>e.left||u>e.left&&R<e.left,te=h<e.top&&E>e.top||h>e.top&&E<e.top;K&&(c+=1),te&&(d+=1);const Q=S.viewportKey,se=k.viewportKey;if(Q===T.SHEET_VIEWPORT_KEY.VIEW_ROW_TOP)b<e.top&&((W=A==null?void 0:A.endRow)!=null?W:0)<((V=x==null?void 0:x.startRow)!=null?V:0)?y=e.top:te&&d%2===1&&e.scrollToViewportPos({viewportScrollY:0});else if(Q===T.SHEET_VIEWPORT_KEY.VIEW_COLUMN_LEFT)C<e.left&&((U=A==null?void 0:A.endColumn)!=null?U:0)<((L=x==null?void 0:x.startColumn)!=null?L:0)?P=e.left:K&&c%2===1&&e.scrollToViewportPos({viewportScrollX:0});else if(Q===se){let G=!1,Y=!1;Q===T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP?(G=!0,Y=!0):Q===T.SHEET_VIEWPORT_KEY.VIEW_MAIN_TOP?Y=!0:Q===T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT&&(G=!0),((j=A==null?void 0:A.endRow)!=null?j:0)>((B=x==null?void 0:x.startRow)!=null?B:0)&&(Y=!1),((F=A==null?void 0:A.endColumn)!=null?F:0)>((X=x==null?void 0:x.startColumn)!=null?X:0)&&(G=!1),G&&(P=e.left),Y&&(y=e.top)}else{const G={x:S.scrollX,y:S.scrollY},Y={x:k.scrollX,y:k.scrollY},q=G.x!==Y.x&&K&&c%2===1,ne=G.y!==Y.y&&te&&d%2===1;(q||ne)&&(e.scrollToBarPos({x:q?G.x:void 0,y:ne?G.y:void 0}),q||(P=e.left),ne||(y=e.top)),(Q===T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP&&se===T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT||se===T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP&&Q===T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT)&&(P=e.left),(Q===T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP&&se===T.SHEET_VIEWPORT_KEY.VIEW_MAIN_TOP||se===T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP&&Q===T.SHEET_VIEWPORT_KEY.VIEW_MAIN_TOP)&&(y=e.top)}u=R,h=E}this._scrollTimer.scrolling(P,y,()=>{this._movingHandler(R,E,t,r)})})}attachSelectionWithCoord(e){return we(e,this._skeleton)}attachPrimaryWithCoord(e){return Gn(this._skeleton,e)}getSelectionCellByPosition(e,t){return this.getCellWithCoordByOffset(e,t)}getCellWithCoordByOffset(e,t,r){const o=this._scene,s=r!=null?r:this._skeleton,l=o.getViewportScrollXY(o.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN)),{scaleX:c,scaleY:d}=o.getAncestorScale();return s.getCellWithCoordByOffset(e,t,c,d,l)}_movingHandler(e,t,r,o){var P,y,M,x,A;const s=this._skeleton,l=this._scene,[c,d]=s.getLocation(),u={startRow:(P=r==null?void 0:r.model.startRow)!=null?P:-1,endRow:(y=r==null?void 0:r.model.endRow)!=null?y:-1,startColumn:(M=r==null?void 0:r.model.startColumn)!=null?M:-1,endColumn:(x=r==null?void 0:r.model.endColumn)!=null?x:-1},h=l.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN),g=(A=this._getViewportByCell(u.endRow,u.endColumn))!=null?A:h,S=l.getScrollXYInfoByViewport(T.Vector2.FromArray([this._startViewportPosX,this._startViewportPosY]),g),{scaleX:f,scaleY:p}=l.getAncestorScale();o===a.RANGE_TYPE.ROW?e=Number.POSITIVE_INFINITY:o===a.RANGE_TYPE.COLUMN&&(t=Number.POSITIVE_INFINITY);const v=this._skeleton.getCellByOffset(e,t,f,p,S);if(!v)return;let C={startRow:Math.min(v.startRow,this._startRangeWhenPointerDown.startRow),startColumn:Math.min(v.startColumn,this._startRangeWhenPointerDown.startColumn),endRow:Math.max(v.endRow,this._startRangeWhenPointerDown.endRow),endColumn:Math.max(v.endColumn,this._startRangeWhenPointerDown.endColumn)};this._shouldDetectMergedCells&&(C=s.expandRangeByMerge(C));const R=we({range:C,primary:void 0,style:null},s);R.rangeWithCoord.unitId=c,R.rangeWithCoord.sheetId=d,R.rangeWithCoord.rangeType=o;const E=u.startRow!==C.startRow||u.startColumn!==C.startColumn||u.endRow!==C.endRow||u.endColumn!==C.endColumn;r!=null&&E&&(r.updateRangeBySelectionWithCoord(R),this._selectionMoving$.next(this.getSelectionDataWithStyle()))}_clearUpdatingListeners(){var t,r,o,s,l;this._scene.enableObjectsEvent(),(t=this._scenePointerMoveSub)==null||t.unsubscribe(),this._scenePointerMoveSub=null,(r=this._scenePointerUpSub)==null||r.unsubscribe(),this._scenePointerUpSub=null,(o=this._cancelDownSubscription)==null||o.unsubscribe(),this._cancelDownSubscription=null,(s=this._cancelUpSubscription)==null||s.unsubscribe(),this._cancelUpSubscription=null,(l=this._scrollTimer)==null||l.dispose()}_addEndingListeners(){var r,o,s;const e=this._scene,t=(r=e.getEngine())==null?void 0:r.activeScene;!t||t===e||((o=this._cancelDownSubscription)==null||o.unsubscribe(),this._cancelDownSubscription=null,(s=this._cancelUpSubscription)==null||s.unsubscribe(),this._cancelUpSubscription=null,this._cancelDownSubscription=t.onPointerDown$.subscribeEvent(()=>this._clearUpdatingListeners()),this._cancelUpSubscription=t.onPointerUp$.subscribeEvent(()=>this._clearUpdatingListeners()))}_getSelectionWithCoordByOffset(e,t,r,o,s){const l=this._skeleton;if(l==null)return null;if(this._shouldDetectMergedCells){const C=l==null?void 0:l.getCellWithCoordByOffset(e,t,r,o,s,{firstMatch:!0});if(!C)return;const b=a.convertCellToRange(C);return{primaryWithCoord:C,rangeWithCoord:b}}const{row:c,column:d}=l.getCellIndexByOffset(e,t,r,o,s),u=l.getNoMergeCellWithCoordByIndex(c,d),{startX:h,startY:g,endX:S,endY:f}=u,p={startY:g,endY:f,startX:h,endX:S,startRow:c,endRow:c,startColumn:d,endColumn:d};return{primaryWithCoord:{mergeInfo:p,actualRow:c,actualColumn:d,isMerged:!1,isMergedMainCell:!1,startY:g,endY:f,startX:h,endX:S},rangeWithCoord:p}}_checkClearPreviousControls(e){this.getSelectionControls().length!==0&&(!e.ctrlKey&&!e.shiftKey&&!this._remainLastEnabled||this._singleSelectionEnabled&&!e.shiftKey)&&this._clearAllSelectionControls()}_makeSelectionByTwoCells(e,t,r,o,s){const{actualRow:l,actualColumn:c,mergeInfo:d}=e;this._startRangeWhenPointerDown={...e.mergeInfo};const u=Math.min(l,t.startRow,d.startRow),h=Math.max(l,t.endRow,d.endRow),g=Math.min(c,t.startColumn,d.startColumn),S=Math.max(c,t.endColumn,d.endColumn),p={range:r.expandRangeByMerge({startRow:u,startColumn:g,endRow:h,endColumn:S}),primary:null,style:null},v=we(p,r);s.updateRangeBySelectionWithCoord(v)}isSelectionEnabled(){return this.contextService.getContextValue(m.SELECTIONS_ENABLED)}isSelectionDisabled(){return this.contextService.getContextValue(m.SELECTIONS_ENABLED)===!1}inRefSelectionMode(){return this.contextService.getContextValue(m.REF_SELECTIONS_ENABLED)}}function qo(n){return{range:{startRow:0,startColumn:0,endRow:n.getRowCount()-1,endColumn:n.getColumnCount()-1,rangeType:a.RANGE_TYPE.ALL},primary:Ri(n).primary,style:null}}function Ri(n){return Ma(n,{startRow:0,startColumn:0,endRow:0,endColumn:0})}function Ma(n,i){const e=n.worksheet.getCellInfoInMergeData(i.startRow,i.startColumn),t=n.worksheet.getCellInfoInMergeData(i.endRow,i.endColumn);return{range:{startRow:e.startRow,startColumn:e.startColumn,endRow:t.endRow,endColumn:t.endColumn,rangeType:a.RANGE_TYPE.NORMAL},primary:{actualRow:e.startRow,actualColumn:e.startColumn,startRow:e.startRow,startColumn:e.startColumn,endRow:e.endRow,endColumn:e.endColumn,isMerged:e.isMerged,isMergedMainCell:e.isMergedMainCell},style:null}}var sd=Object.getOwnPropertyDescriptor,ad=(n,i,e,t)=>{for(var r=t>1?void 0:t?sd(i,e):i,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=s(r)||r);return r},Os=(n,i)=>(e,t)=>i(e,t,n);exports.SheetSkeletonManagerService=class extends a.Disposable{constructor(e,t,r){super();w(this,"_sheetId","");w(this,"_sheetSkeletonParamStore",new Map);w(this,"_currentSkeleton$",new O.BehaviorSubject(null));w(this,"currentSkeleton$",this._currentSkeleton$.asObservable());w(this,"_currentSkeletonBefore$",new O.BehaviorSubject(null));w(this,"currentSkeletonBefore$",this._currentSkeletonBefore$.asObservable());this._context=e,this._injector=t,this._sheetSkService=r,this.disposeWithMe(()=>{this._currentSkeletonBefore$.complete(),this._currentSkeleton$.complete(),this._sheetSkeletonParamStore.forEach(o=>this.disposeSkeleton(o.sheetId)),this._sheetSkeletonParamStore.clear()}),this._initRemoveSheet()}_initRemoveSheet(){this.disposeWithMe(this._context.unit.sheetDisposed$.subscribe(e=>{this.disposeSkeleton(e.getSheetId())}))}getCurrentSkeleton(){var e;return(e=this.getCurrentParam())==null?void 0:e.skeleton}getCurrent(){return this.getCurrentParam()}getCurrentParam(){return this._getSkeletonParam(this._sheetId)}getSkeleton(e){return this._getSkeleton(e)}getSkeletonParam(e){return this._getSkeletonParam(e)}getWorksheetSkeleton(e){return this.getSkeletonParam(e)}getUnitSkeleton(e,t){const r=this._getSkeletonParam(t);return r!=null&&(r.unitId=e),r}setCurrent(e){this._setCurrent(e.sheetId)}setSkeletonParam(e,t){this._sheetSkService.setSkeleton(t.unitId,e,t.skeleton),this._sheetSkeletonParamStore.set(e,t)}_setCurrent(e){this._sheetId=e;const t=this._getSkeletonParam(e),r=this._context.unitId;if(t!=null)this.reCalculate(t);else{const l=this._context.unit.getSheetBySheetId(e);if(l==null)return;const c=this._context.scene,d=this._buildSkeleton(l,c);this.setSkeletonParam(e,{unitId:r,sheetId:e,skeleton:d,dirty:!1})}const o=this._getSkeletonParam(e);this._currentSkeletonBefore$.next(o),this._currentSkeleton$.next(o)}reCalculate(e){e||(e=this.getCurrentParam()),e!=null&&(e.dirty&&(e.skeleton.makeDirty(!0),e.dirty=!1),e.skeleton.calculate())}makeDirty(e,t=!0){const r=this._getSkeletonParam(e.sheetId);r!=null&&(r.dirty=t)}getOrCreateSkeleton(e){return this.ensureSkeleton(e.sheetId)}ensureSkeleton(e){const t=this._getSkeletonParam(e);if(t)return t.skeleton;const o=this._context.unit.getSheetBySheetId(e);if(!o)return;const s=this._buildSkeleton(o);return this.setSkeletonParam(e,{unitId:this._context.unitId,sheetId:e,skeleton:s,dirty:!1}),s}disposeSkeleton(e){const t=this.getSkeletonParam(e);t&&(t.skeleton.dispose(),this._sheetSkeletonParamStore.delete(e),this._sheetSkService.deleteSkeleton(t.unitId,e))}attachRangeWithCoord(e){const t=this.getCurrentSkeleton();return t?cn(t,e):null}_getSkeletonParam(e){return this._sheetSkeletonParamStore.get(e)}_getSkeleton(e){const t=this._getSkeletonParam(e);return t?t.skeleton:null}_buildSkeleton(e,t){return this._injector.createInstance(T.SpreadsheetSkeleton,e,this._context.unit.getStyles())}setColumnHeaderSize(e,t,r){var u;if(!e)return;const o=(u=this.getWorksheetSkeleton(t))==null?void 0:u.skeleton;if(!o)return;o.columnHeaderHeight=r,e.scene.getViewports()[0].top=r,e.scene.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_COLUMN_RIGHT).setViewportSize({height:r}),e.scene.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_COLUMN_LEFT).setViewportSize({height:r}),e.scene.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_ROW_BOTTOM).setViewportSize({top:r}),e.scene.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_ROW_TOP).setViewportSize({top:r}),e.scene.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_LEFT_TOP).setViewportSize({height:r});const s=e==null?void 0:e.with(m.SheetsSelectionsService),l=e==null?void 0:e.with(pe),c=s.getCurrentSelections();l.resetSelectionsByModelData(c);const d=this.getUnitSkeleton(e.unitId,t);d&&(d.commandId=bi.id,this._currentSkeleton$.next(d))}setRowHeaderSize(e,t,r){var f;const o=(f=this.getWorksheetSkeleton(t))==null?void 0:f.skeleton;if(!e||!o)return;o.rowHeaderWidth=r;const s=e.scene.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_LEFT_TOP).width||46,l=r-s,c=e.scene.getViewports()[0].left;e.scene.getViewports()[0].left=c+l,e.scene.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_ROW_BOTTOM).setViewportSize({width:r}),e.scene.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_ROW_TOP).setViewportSize({width:r}),e.scene.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_COLUMN_LEFT).setViewportSize({left:r});const d=e.scene.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_COLUMN_RIGHT).left||0;e.scene.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_COLUMN_RIGHT).setViewportSize({left:d+l}),e.scene.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_LEFT_TOP).setViewportSize({width:r});const u=e==null?void 0:e.with(m.SheetsSelectionsService),h=e==null?void 0:e.with(pe),g=u.getCurrentSelections();h.resetSelectionsByModelData(g);const S=this.getCurrent();S&&(S.commandId=Ii.id,this._currentSkeleton$.next(S))}};exports.SheetSkeletonManagerService=ad([Os(1,a.Inject(a.Injector)),Os(2,a.Inject(m.SheetSkeletonService))],exports.SheetSkeletonManagerService);function St(){const n=_.useDependency(a.IUniverInstanceService),i=_.useObservable(()=>n.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]);return i!=null?i:null}function ld(n){return _.useObservable(()=>{var e;return(e=n==null?void 0:n.activeSheet$)!=null?e:O.of(null)},void 0,void 0,[n])}function cd(){const n=_.useDependency(a.IUniverInstanceService);return _.useObservable(()=>O.merge([n.getTypeOfUnitAdded$(a.UniverInstanceType.UNIVER_SHEET),n.getTypeOfUnitDisposed$(a.UniverInstanceType.UNIVER_SHEET)]).pipe(O.map(()=>n.getAllUnitsForType(a.UniverInstanceType.UNIVER_SHEET)),O.startWith(n.getAllUnitsForType(a.UniverInstanceType.UNIVER_SHEET))),[],void 0,[n])}const dd="SheetUI";var Qo=(n=>(n.FILTER_PANEL_EMBED_POINT="filter-panel-embed-point",n.SHEETS_FOOTER="sheets-footer",n.FORMULA_AUX="formula-aux",n))(Qo||{});const xe="sheets-ui.config",Eo={formulaBar:!0,statusBarStatistic:!0,maxAutoHeightCount:1e3};var ud=Object.getOwnPropertyDescriptor,hd=(n,i,e,t)=>{for(var r=t>1?void 0:t?ud(i,e):i,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=s(r)||r);return r},xn=(n,i)=>(e,t)=>i(e,t,n);const Jo=["ff","fs","tr","tb"];exports.AutoHeightController=class extends a.Disposable{constructor(i,e,t,r,o){super(),this._renderManagerService=i,this._sheetInterceptorService=e,this._selectionManagerService=t,this._univerInstanceService=r,this._configService=o,this._initialize()}_getRangesScope(i){let e,t;for(const{startRow:r,endRow:o}of i)e=e===void 0?r:Math.min(e,r),t=t===void 0?o:Math.max(t,o);return t-e+1}getUndoRedoParamsOfAutoHeight(i,e){var b;const{_univerInstanceService:t,_configService:r}=this,o=t.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),s=o.getUnitId();let l=o.getActiveSheet(),c=l.getSheetId();if(e){const R=m.getSheetCommandTarget(t,{unitId:s,subUnitId:e});R&&(l=R.worksheet,c=l.getSheetId())}const u=this._renderManagerService.getRenderById(s).with(exports.SheetSkeletonManagerService).ensureSkeleton(c);if(!u)return{redos:[],undos:[]};const h=r.getConfig(xe);let g=i;Array.isArray(i)||(i&&i.startRow!==void 0&&i.startRow!==void 0?g=[i]:g=[]);const S=this._getRangesScope(g);if(((b=h==null?void 0:h.maxAutoHeightCount)!=null?b:1e3)<S)return{redos:[],undos:[]};const p=u.calculateAutoHeightInRange(i),v={subUnitId:c,unitId:s,rowsAutoHeightInfo:p},C=m.SetWorksheetRowAutoHeightMutationFactory(v,l);return{undos:[{id:m.SetWorksheetRowAutoHeightMutation.id,params:C}],redos:[{id:m.SetWorksheetRowAutoHeightMutation.id,params:v}]}}_initialize(){const{_sheetInterceptorService:i,_selectionManagerService:e}=this;this.disposeWithMe(i.interceptCommand({getMutations:t=>{if(t.id===m.SetRangeValuesCommand.id){const r=t.params;return this.getUndoRedoParamsOfAutoHeight(r.range,r.subUnitId)}return{redos:[],undos:[]}}})),this.disposeWithMe(i.interceptCommand({getMutations:t=>t.id!==m.SetWorksheetRowIsAutoHeightCommand.id?{redos:[],undos:[]}:this.getUndoRedoParamsOfAutoHeight(t.params.ranges,t.params.subUnitId)})),this.disposeWithMe(i.interceptCommand({getMutations:t=>{var o,s;if(t.id!==m.SetStyleCommand.id)return{redos:[],undos:[]};if(!Jo.includes((o=t.params)==null?void 0:o.style.type))return{redos:[],undos:[]};const r=(s=e.getCurrentSelections())==null?void 0:s.map(l=>l.range);return r!=null&&r.length?this.getUndoRedoParamsOfAutoHeight(r,t.params.subUnitId):{redos:[],undos:[]}}})),this.disposeWithMe(i.interceptAfterCommand({getMutations:t=>{if(t.id===m.MoveRangeCommand.id){const r=t.params;return this.getUndoRedoParamsOfAutoHeight([r.fromRange,r.toRange])}if(t.id===m.ReorderRangeCommand.id){const r=t.params;return this.getUndoRedoParamsOfAutoHeight([r.range])}return{redos:[],undos:[]}}}))}};exports.AutoHeightController=hd([xn(0,T.IRenderManagerService),xn(1,a.Inject(m.SheetInterceptorService)),xn(2,a.Inject(m.SheetsSelectionsService)),xn(3,a.Inject(a.IUniverInstanceService)),xn(4,a.IConfigService)],exports.AutoHeightController);function gt(n){const{rows:i,cols:e}=n;return{startRow:i[0],endRow:i[i.length-1],startColumn:e[0],endColumn:e[e.length-1]}}function Wt(n){let i=[],e=[];const t=[];return n.forEach(r=>{i=i.concat(r.rows),e=e.concat(r.cols)}),i=Array.from(new Set(i)).sort((r,o)=>r-o),e=Array.from(new Set(e)).sort((r,o)=>r-o),n.forEach(r=>{t.push({startRow:i.findIndex(o=>o===r.rows[0]),endRow:i.findIndex(o=>o===r.rows[r.rows.length-1]),startColumn:e.findIndex(o=>o===r.cols[0]),endColumn:e.findIndex(o=>o===r.cols[r.cols.length-1])})}),{ranges:t,mapFunc:(r,o)=>({row:i[r],col:e[o]})}}function md(n){const i=new a.ObjectMatrix;return n.forEach(e=>{const{rows:t,cols:r}=e;t.forEach(o=>{r.forEach(s=>{i.setValue(o,s,{v:null,p:null,f:null,si:null,custom:null})})})}),i.getData()}const wo={零:0,一:1,二:2,三:3,四:4,五:5,六:6,七:7,八:8,九:9},Xr=["零","一","二","三","四","五","六","七","八","九"],As=["","万","亿","万亿","亿亿"],gd=["","十","百","千"],Pa={十:{value:10,secUnit:!1},百:{value:100,secUnit:!1},千:{value:1e3,secUnit:!1},万:{value:1e4,secUnit:!0},亿:{value:1e8,secUnit:!0}};function rt(n){if(!n)return 0;let i=0,e=0,t=0,r=!1;const o=n.split("");for(let s=0;s<o.length;s++){const l=wo[o[s]];if(typeof l<"u")t=l,s===o.length-1&&(e+=t);else{const c=Pa[o[s]],d=c.value;r=c.secUnit,r?(e=(e+t)*d,i+=e,e=0):e+=t*d,t=0}}return i+e}function Sd(n){let i="",e="",t=0,r=!0;for(;n>0;){const o=n%10;o===0?r||(r=!0,e=Xr[o]+e):(r=!1,i=Xr[o],i+=gd[t],e=i+e),t++,n=Math.floor(n/10)}return e}function fd(n){let i=0,e="",t="",r=!1;if(n===0)return Xr[0];for(;n>0;){const o=n%1e4;r&&(t=Xr[0]+t),e=Sd(o),e+=o!==0?As[i]:As[0],t=e+t,r=o<1e3&&o>0,n=Math.floor(n/1e4),i++}return t}function pd(n){if(!n)return!1;let i=!0;if(n)if(n.length===1)n==="日"||n in wo?i=!0:i=!1;else{const e=n.split("");for(let t=0;t<e.length;t++)if(!(e[t]in wo||e[t]in Pa)){i=!1;break}}return i}function xr(n){if(!n)return{isExtendNumber:!1};const i=/0|([1-9]+[0-9]*)/g,e=i.test(n);if(e){const t=n.match(i);if(t&&t.length>0){const r=t[t.length-1],o=n.lastIndexOf(r),s=n.substr(0,o),l=n.substr(o+r.length);return{isExtendNumber:!0,matchTxt:Number(r),beforeTxt:s,afterTxt:l}}return{isExtendNumber:!1}}return{isExtendNumber:e}}function vd(n){let i;return n.length===2&&(n==="周一"||n==="周二"||n==="周三"||n==="周四"||n==="周五"||n==="周六"||n==="周日")?i=!0:i=!1,i}function Cd(n){let i;return n.length===3&&(n==="星期一"||n==="星期二"||n==="星期三"||n==="星期四"||n==="星期五"||n==="星期六"||n==="星期日")?i=!0:i=!1,i}function _d(n,i){let e=0;for(let t=0;t<n.length&&n[t]<i;t++)e++;return e}function rr(n){let i=!0;const e=n[1]-n[0];for(let t=1;t<n.length;t++)if(n[t]-n[t-1]!==e){i=!1;break}return i}function Id(n,i,e){const t=[],r=Math.floor(i/n),o=i%n;let s=0;if(r>0){for(let l=0;l<r;l++)for(let c=0;c<e.length;c++)t[e[c]+l*n]=s,s++;for(let l=0;l<e.length&&e[l]<o;l++)t[e[l]+n*r]=s,s++}else for(let l=0;l<e.length&&e[l]<o;l++)t[e[l]]=s,s++;return t}function kt(n,i){const e=[];for(let t=1;t<=i;t++){const r=(t-1)%n.length,o=a.Tools.deepClone(n[r]);Dt(o),e.push({v:null,s:null,p:null,f:null,si:null,t:null,...o})}return e}function bd(n,i){var t;const e=[];for(let r=1;r<=i;r++){const o=(r-1)%n.length,s={s:(t=n[o])==null?void 0:t.s};e.push(s)}return e}function Rd(n){let i=!0;const e=n[1]/n[0];for(let t=1;t<n.length;t++)if(n[t]/n[t-1]!==e){i=!1;break}return i}function Ed(n){const i=[];for(let e=1;e<=n;e++)i.push(e);return i}function Yr(n,i,e){var o,s,l,c;const t=[],r=[];for(let d=0;d<n.length;d++)r.push(Number((o=n[d])==null?void 0:o.v));if(n.length>2&&Rd(r))for(let d=1;d<=i;d++){const u=(d-1)%n.length,h=a.Tools.deepClone(n[u]);Dt(h);const g=Number((s=n[n.length-1])==null?void 0:s.v)*(Number((l=n[1])==null?void 0:l.v)/Number((c=n[0])==null?void 0:c.v))**d;h&&(Vs(h)&&(h.v=g),t.push(h))}else{const d=Ed(n.length);for(let u=1;u<=i;u++){const h=(u-1)%n.length,g=a.Tools.deepClone(n[h]);Dt(g);const S=e===a.Direction.DOWN||e===a.Direction.RIGHT,f=wd(n.length+u,r,d,S);g&&(Vs(g)&&(g.v=f),t.push(g))}}return t}function wd(n,i,e,t=!0){function r(h){let g=0;for(let S=0;S<h.length;S++)g+=h[S];return g/h.length}const o=r(e),s=r(i);let l=0,c=0;for(let h=0;h<e.length;h++)l+=(e[h]-o)*(i[h]-s),c+=(e[h]-o)*(e[h]-o);let d;c===0?d=t?1:-1:d=l/c;const u=s-d*o;return Math.round((u+d*n)*1e5)/1e5}function ks(n,i,e){var o;const t=[],r=/0|([1-9]+[0-9]*)/g;for(let s=1;s<=i;s++){const l=(s-1)%n.length,c=a.Tools.deepClone(n[l]);Dt(c);const d=`${(o=n[n.length-1])==null?void 0:o.v}`;if(!d)continue;const u=d==null?void 0:d.match(r),h=u==null?void 0:u[u.length-1];if(!h)continue;const g=Math.abs(Number(h)+e*s),S=d.lastIndexOf(h),f=d.substr(0,S)+g.toString()+d.substr(S+h.length);c&&(c.v=f,t.push(c))}return t}function dn(n,i,e,t=0){var l,c;const r=[["日","一","二","三","四","五","六"],["周日","周一","周二","周三","周四","周五","周六"],["星期日","星期一","星期二","星期三","星期四","星期五","星期六"]];if(t>=r.length)return[];const o=r[t],s=[];for(let d=1;d<=i;d++){const u=(d-1)%n.length,h=a.Tools.deepClone(n[u]);Dt(h);let g=0;if(((l=n[n.length-1])==null?void 0:l.v)===o[0])g=7+e*d;else{const f=`${(c=n[n.length-1])==null?void 0:c.v}`;if(f){const p=f.substr(f.length-1,1);g=rt(p)+e*d}}g<0&&(g=Math.ceil(Math.abs(g)/7)*7+g);const S=g%7;h&&(h.v=o[S],s.push(h))}return s}function Ds(n,i,e){var r;const t=[];for(let o=1;o<=i;o++){const s=(o-1)%n.length,l=a.Tools.deepClone(n[s]);Dt(l);const c=`${(r=n[n.length-1])==null?void 0:r.v}`,d=rt(c)+e*o;let u;d<=0?u="零":u=fd(d),l&&(l.v=u,t.push(l))}return t}const zn={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 Td(n){let i=!1;return Object.keys(zn).forEach(e=>{zn[e].includes(n)&&(i=!0)}),i}function ki(n){let i="";const e=[];return Object.keys(zn).forEach(t=>{zn[t].includes(n)&&(i=t,e.push(...zn[t]))}),{name:i,series:e}}function Ns(n,i,e,t){var s;const r=t.length,o=[];for(let l=1;l<=i;l++){const c=(l-1)%n.length,d=a.Tools.deepClone(n[c]);Dt(d);const u=`${(s=n[n.length-1])==null?void 0:s.v}`;let h=t.indexOf(u)+e*l;h<0&&(h+=Math.abs(e)*r);const g=h%r;d&&(d.v=t[g],o.push(d))}return o}function yd(n,i){const e=[];let t;if(i.startRow<n.startRow)t=a.Direction.UP;else if(i.endRow>n.endRow)t=a.Direction.DOWN;else if(i.startColumn<n.startColumn)t=a.Direction.LEFT;else if(i.endColumn>n.endColumn)t=a.Direction.RIGHT;else return[];if(t===a.Direction.DOWN||t===a.Direction.UP){const r=n.endRow-n.startRow+1,o=i.endRow-i.startRow+1,s=Math.floor(o/r),l=o%r,c={startRow:0,startColumn:0,endRow:n.endRow-n.startRow,endColumn:n.endColumn-n.startColumn};if(t===a.Direction.DOWN){for(let d=0;d<s;d++)e.push({repeatStartCell:{row:n.startRow+(d+1)*r,col:n.startColumn},relativeRange:c});l>0&&e.push({repeatStartCell:{row:n.startRow+(s+1)*r,col:n.startColumn},relativeRange:{startRow:0,startColumn:0,endRow:l-1,endColumn:n.endColumn-n.startColumn}})}else{for(let d=0;d<s;d++)e.push({repeatStartCell:{row:n.startRow-(d+1)*r,col:n.startColumn},relativeRange:c});l>0&&e.push({repeatStartCell:{row:n.startRow-(s+1)*r,col:n.startColumn},relativeRange:{startRow:r-l,endRow:r-1,startColumn:0,endColumn:n.endColumn-n.startColumn}})}}if(t===a.Direction.RIGHT||t===a.Direction.LEFT){const r=n.endColumn-n.startColumn+1,o=i.endColumn-i.startColumn+1,s=Math.floor(o/r),l=o%r,c={startRow:0,startColumn:0,endRow:n.endRow-n.startRow,endColumn:n.endColumn-n.startColumn};if(t===a.Direction.RIGHT){for(let d=0;d<s;d++)e.push({repeatStartCell:{row:n.startRow,col:n.startColumn+(d+1)*r},relativeRange:c});l>0&&e.push({repeatStartCell:{row:n.startRow,col:n.startColumn+(s+1)*r},relativeRange:{startRow:0,startColumn:0,endRow:n.endRow-n.startRow,endColumn:l-1}})}else{for(let d=0;d<s;d++)e.push({repeatStartCell:{row:n.startRow,col:n.startColumn-(d+1)*r},relativeRange:c});l>0&&e.push({repeatStartCell:{row:n.startRow,col:n.startColumn-(s+1)*r},relativeRange:{startRow:0,startColumn:r-l,endRow:n.endRow-n.startRow,endColumn:r-1}})}}return e}function Vs(n){return!(a.isFormulaString(n.f)||a.isFormulaId(n.si)||n.t===a.CellValueType.BOOLEAN)}function Dt(n){n&&"custom"in n&&delete n.custom}var en=(n=>(n.Append="APPEND",n.Default="DEFAULT",n.Only="ONLY",n))(en||{}),Ce=(n=>(n.NUMBER="number",n.DATE="date",n.EXTEND_NUMBER="extendNumber",n.CHN_NUMBER="chnNumber",n.CHN_WEEK2="chnWeek2",n.CHN_WEEK3="chnWeek3",n.LOOP_SERIES="loopSeries",n.FORMULA="formula",n.OTHER="other",n))(Ce||{}),le=(n=>(n.COPY="COPY",n.SERIES="SERIES",n.ONLY_FORMAT="ONLY_FORMAT",n.NO_FORMAT="NO_FORMAT",n))(le||{});const Md={type:Ce.DATE,priority:1100,match:(n,i)=>{var e;if(n!=null&&n.f||n!=null&&n.si)return!1;if((typeof(n==null?void 0:n.v)=="number"||(n==null?void 0:n.t)===a.CellValueType.NUMBER)&&n.s){if(typeof n.s=="string"){const r=i.get(a.IUniverInstanceService).getFocusedUnit().getStyles().get(n.s),o=(e=r==null?void 0:r.n)==null?void 0:e.pattern;if(o)return a.numfmt.getInfo(o).isDate}else if(n.s.n&&a.numfmt.getInfo(n.s.n.pattern).isDate)return!0}return!1},isContinue:(n,i)=>n.type===Ce.DATE,applyFunctions:{[le.SERIES]:(n,i,e)=>{const{data:t}=n;return e===a.Direction.LEFT||e===a.Direction.UP?(t.reverse(),Yr(t,i,e).reverse()):Yr(t,i,e)}}},Pd={type:Ce.NUMBER,priority:1e3,match:n=>typeof(n==null?void 0:n.v)=="number"||(n==null?void 0:n.t)===a.CellValueType.NUMBER,isContinue:(n,i)=>n.type===Ce.NUMBER,applyFunctions:{[le.SERIES]:(n,i,e)=>{const{data:t}=n;return e===a.Direction.LEFT||e===a.Direction.UP?(t.reverse(),Yr(t,i,e).reverse()):Yr(t,i,e)}}},xa={type:Ce.OTHER,priority:0,match:()=>!0,isContinue:(n,i)=>n.type===Ce.OTHER},xd={type:Ce.EXTEND_NUMBER,priority:900,match:n=>xr(`${n==null?void 0:n.v}`||"").isExtendNumber,isContinue:(n,i)=>{var e;if(n.type===Ce.EXTEND_NUMBER){const{beforeTxt:t,afterTxt:r}=xr(`${(e=n.cellData)==null?void 0:e.v}`||""),{beforeTxt:o,afterTxt:s}=xr(`${i==null?void 0:i.v}`||"");if(t===o&&r===s)return!0}return!1},applyFunctions:{[le.SERIES]:(n,i,e)=>{var l;const{data:t}=n,r=e===a.Direction.UP||e===a.Direction.LEFT;let o;if(t.length===1)return o=r?-1:1,De(ks(t,i,o),r);const s=[];for(let c=0;c<t.length;c++){const d=`${(l=t[c])==null?void 0:l.v}`;d&&s.push(Number(xr(d).matchTxt))}return r&&(t.reverse(),s.reverse()),rr(s)?(o=s[1]-s[0],De(ks(t,i,o),r)):kt(t,i)}}},Od={type:Ce.CHN_NUMBER,priority:830,match:n=>!!pd(`${n==null?void 0:n.v}`||""),isContinue:(n,i)=>n.type===Ce.CHN_NUMBER,applyFunctions:{[le.SERIES]:(n,i,e)=>{var c,d,u;const{data:t}=n,r=e===a.Direction.LEFT||e===a.Direction.UP;if(t.length===1){const h=`${(c=t[0])==null?void 0:c.v}`;let g;return r?g=-1:g=1,h&&(h==="日"||rt(h)<7)?De(dn(t,i,g),r):De(Ds(t,i,g),r)}let o=!1;for(let h=0;h<t.length;h++)if(((d=t[h])==null?void 0:d.v)==="日"){o=!0;break}const s=[];let l=0;for(let h=0;h<t.length;h++){const g=`${(u=t[h])==null?void 0:u.v}`;g==="日"?h===0?s.push(0):(l++,s.push(l*7)):o&&rt(g)>0&&rt(g)<7?s.push(rt(g)+l*7):s.push(rt(g))}if(r&&(t.reverse(),s.reverse()),rr(s)){if(o||s[s.length-1]<6&&s[0]>0||s[0]<6&&s[s.length-1]>0){const g=s[1]-s[0];return De(dn(t,i,g),r)}const h=s[1]-s[0];return De(Ds(t,i,h),r)}return kt(t,i)}}},Ad={type:Ce.CHN_WEEK2,priority:820,match:n=>!!vd(`${n==null?void 0:n.v}`||""),isContinue:(n,i)=>n.type===Ce.CHN_WEEK2,applyFunctions:{[le.SERIES]:(n,i,e)=>{var l;const{data:t}=n,r=e===a.Direction.LEFT||e===a.Direction.UP;if(t.length===1){let c;return r?c=-1:c=1,De(dn(t,i,c,1),r)}const o=[];let s=0;for(let c=0;c<t.length;c++){const d=`${(l=t[c])==null?void 0:l.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(rt(u)+s*7)}if(r&&(t.reverse(),o.reverse()),rr(o)){const c=o[1]-o[0];return De(dn(t,i,c,1),r)}return kt(t,i)}}},kd={type:Ce.CHN_WEEK3,priority:810,match:n=>Cd(`${n==null?void 0:n.v}`||""),isContinue:(n,i)=>n.type===Ce.CHN_WEEK3,applyFunctions:{[le.SERIES]:(n,i,e)=>{var l;const{data:t}=n,r=e===a.Direction.LEFT||e===a.Direction.UP;if(t.length===1){let c;return r?c=-1:c=1,De(dn(t,i,c,2),r)}const o=[];let s=0;for(let c=0;c<t.length;c++){const d=`${(l=t[c])==null?void 0:l.v}`;if(d){const u=d.substr(d.length-1,1);d==="星期日"?c===0?o.push(0):(s++,o.push(s*7)):o.push(rt(u)+s*7)}}if(r&&(t.reverse(),o.reverse()),rr(o)){const c=o[1]-o[0];return De(dn(t,i,c,2),r)}return kt(t,i)}}},Dd={type:Ce.LOOP_SERIES,priority:800,match:n=>Td(`${n==null?void 0:n.v}`||""),isContinue:(n,i)=>{var e;return n.type===Ce.LOOP_SERIES?ki(`${(e=n.cellData)==null?void 0:e.v}`||"").name===ki(`${i==null?void 0:i.v}`||"").name:!1},applyFunctions:{[le.SERIES]:(n,i,e)=>{var c,d;const{data:t}=n,r=e===a.Direction.LEFT||e===a.Direction.UP,{series:o}=ki(`${(c=t[0])==null?void 0:c.v}`||"");if(t.length===1){let u;return r?u=-1:u=1,De(Ns(t,i,u,o),r)}const s=[];let l=0;for(let u=0;u<t.length;u++){const h=`${(d=t[u])==null?void 0:d.v}`;h&&(h===o[0]?u===0?s.push(0):(l++,s.push(l*o.length)):s.push(o.indexOf(h)+l*7))}if(r&&(t.reverse(),s.reverse()),rr(s)){const u=s[1]-s[0];return De(Ns(t,i,u,o),r)}return kt(t,i)}}};function De(n,i){return i?n.reverse():n}var Nd=Object.getOwnPropertyDescriptor,Vd=(n,i,e,t)=>{for(var r=t>1?void 0:t?Nd(i,e):i,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=s(r)||r);return r},Zt=(n,i)=>(e,t)=>i(e,t,n);exports.AutoFillService=class extends a.Disposable{constructor(e,t,r,o,s,l){super();w(this,"_rules",[]);w(this,"_hooks",[]);w(this,"_applyType$",new O.BehaviorSubject(le.SERIES));w(this,"_isFillingStyle",!0);w(this,"_prevUndos",[]);w(this,"_autoFillLocation$",new O.BehaviorSubject(null));w(this,"autoFillLocation$",this._autoFillLocation$.asObservable());w(this,"_showMenu$",new O.BehaviorSubject(!1));w(this,"showMenu$",this._showMenu$.asObservable());w(this,"_direction",a.Direction.DOWN);w(this,"applyType$",this._applyType$.asObservable());w(this,"_menu$",new O.BehaviorSubject([{label:"autoFill.copy",value:le.COPY,disable:!1},{label:"autoFill.series",value:le.SERIES,disable:!1},{label:"autoFill.formatOnly",value:le.ONLY_FORMAT,disable:!1},{label:"autoFill.noFormat",value:le.NO_FORMAT,disable:!1}]));w(this,"menu$",this._menu$.asObservable());this._commandService=e,this._undoRedoService=t,this._renderManagerService=r,this._univerInstanceService=o,this._selectionManagerService=s,this._injector=l,this._init()}_init(){this._rules=[Md,Pd,xd,Od,Ad,kd,Dd,xa].sort((e,t)=>t.priority-e.priority),this._isFillingStyle=!0}_getOneByPriority(e){return e.length<=0?[]:[e.reduce((r,o)=>(o.priority||0)>(r.priority||0)?o:r,e[0])]}_initPrevUndo(){this._prevUndos=[]}async triggerAutoFill(e,t,r,o){var S;if(r.startColumn===o.startColumn&&r.startRow===o.startRow&&r.endColumn===o.endColumn&&r.endRow===o.endRow)return!1;if(o.endColumn<r.endColumn&&o.endColumn>r.startColumn)return this._commandService.executeCommand(un.id,{clearRange:{startRow:o.startRow,endRow:o.endRow,startColumn:o.endColumn+1,endColumn:r.endColumn},selectionRange:o});if(o.endRow<r.endRow&&o.endRow>r.startRow)return this._commandService.executeCommand(un.id,{clearRange:{startRow:o.endRow+1,endRow:r.endRow,startColumn:o.startColumn,endColumn:o.endColumn},selectionRange:o});const s={startRow:o.startRow,endRow:o.endRow,startColumn:o.startColumn,endColumn:o.endColumn};let l=null;if(o.startRow<r.startRow)l=a.Direction.UP,s.endRow=r.startRow-1;else if(o.endRow>r.endRow)l=a.Direction.DOWN,s.startRow=r.endRow+1;else if(o.startColumn<r.startColumn)l=a.Direction.LEFT,s.endColumn=r.startColumn-1;else if(o.endColumn>r.endColumn)l=a.Direction.RIGHT,s.startColumn=r.endColumn+1;else return!1;this.direction=l;const c=this._injector.invoke(f=>m.rangeToDiscreteRange(r,f)),d=this._injector.invoke(f=>m.rangeToDiscreteRange(s,f));if(!c||!d)return!1;this.autoFillLocation={source:c,target:d,unitId:e,subUnitId:t};const u=[];this.getActiveHooks().forEach(f=>{var v;const p=(v=f==null?void 0:f.onBeforeFillData)==null?void 0:v.call(f,{source:c,target:d,unitId:e,subUnitId:t},l);p&&u.unshift(p)}),this._initPrevUndo();for(let f=0;f<u.length;f++){const p=this.menu.find(v=>v.value===u[f]);if(p&&!p.disable)return this.fillData(u[f])}const g=(S=this.menu.find(f=>f.disable===!1))==null?void 0:S.value;return g?this.fillData(g):!1}addHook(e){if(this._hooks.find(t=>t.id===e.id))throw new Error(`Add hook failed, hook id '${e.id}' already exist!`);return e.priority===void 0&&(e.priority=0),e.type===void 0&&(e.type=en.Append),this._hooks.push(e),a.toDisposable(()=>{const t=this._hooks.findIndex(r=>r===e);t>-1&&this._hooks.splice(t,1)})}registerRule(e){if(this._rules.find(r=>r.type===e.type))throw new Error(`Registry rule failed, type '${e.type}' already exist!`);const t=this._rules.findIndex(r=>r.priority<e.priority);this._rules.splice(t===-1?this._rules.length:t,0,e)}getRules(){return this._rules}getAllHooks(){return this._hooks}getActiveHooks(){const{source:e,target:t,unitId:r,subUnitId:o}=this.autoFillLocation||{};if(!e||!t||!r||!o)return[];const s=this._hooks.filter(u=>{var h;return!((h=u.disable)!=null&&h.call(u,{source:e,target:t,unitId:r,subUnitId:o},this._direction,this.applyType))}),l=s.filter(u=>u.type===en.Only);if(l.length>0)return this._getOneByPriority(l);const c=this._getOneByPriority(s.filter(u=>u.type===en.Default)),d=s.filter(u=>u.type===en.Append)||[];return[...c,...d]}get applyType(){return this._applyType$.getValue()}set applyType(e){this._applyType$.next(e)}get menu(){return this._menu$.getValue()}get direction(){return this._direction}set direction(e){this._direction=e}isFillingStyle(){return this._isFillingStyle}setFillingStyle(e){this._isFillingStyle=e}get autoFillLocation(){return this._autoFillLocation$.getValue()}set autoFillLocation(e){this._autoFillLocation$.next(e)}setDisableApplyType(e,t){this._menu$.next(this._menu$.getValue().map(r=>r.value===e?{...r,disable:t}:r))}setShowMenu(e){this._showMenu$.next(e)}fillData(e){var C,b,R;this.applyType=e;const{source:t,target:r,unitId:o=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getUnitId(),subUnitId:s=(C=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:C.getSheetId()}=this.autoFillLocation||{};if(!t||!r||!o||!s)return!1;const l=this.direction;this._prevUndos.length>0&&this._prevUndos.forEach(E=>{this._commandService.syncExecuteCommand(E.id,E.params)}),this._prevUndos=[];const c=a.Rectangle.union(gt(t),gt(r)),d=this.getActiveHooks(),u=this._univerInstanceService.getUnit(o,a.UniverInstanceType.UNIVER_SHEET);this._commandService.syncExecuteCommand(m.SetSelectionsOperation.id,{selections:[{primary:{...(R=(b=this._selectionManagerService.getCurrentLastSelection())==null?void 0:b.primary)!=null?R:c},range:{...c,rangeType:a.RANGE_TYPE.NORMAL}}],unitId:o,subUnitId:s});const h=[],g=[];d.forEach(E=>{var M;const{undos:P,redos:y}=((M=E.onFillData)==null?void 0:M.call(E,{source:t,target:r,unitId:o,subUnitId:s},l,e))||{};P&&h.push(...P),y&&g.push(...y)});const S=g.every(E=>this._commandService.syncExecuteCommand(E.id,E.params)),f=[];e!==le.NO_FORMAT&&g.forEach(E=>{if(E.id===m.SetRangeValuesMutation.id){const{cellValue:P}=E.params;new a.ObjectMatrix(P).forValue((M,x,A)=>{const k=Object.keys(u.getStyles().get(A==null?void 0:A.s)||{});(A!=null&&A.p||k.length&&Jo.some(D=>k.includes(D)))&&f.push({startRow:M,endRow:M,startColumn:x,endColumn:x})})}});const p=this._getAutoHeightUndoRedos(o,s,f);return p.redos.every(E=>this._commandService.syncExecuteCommand(E.id,E.params))&&(h.push(...p.undos),g.push(...p.redos)),S&&(this._prevUndos=h,this._undoRedoService.pushUndoRedo({unitID:o,undoMutations:h,redoMutations:g})),d.forEach(E=>{var P;(P=E.onAfterFillData)==null||P.call(E,{source:t,target:r,unitId:o,subUnitId:s},l,e)}),this.setShowMenu(!0),!0}_getAutoHeightUndoRedos(e,t,r){var h,g;const o=(h=this._renderManagerService.getRenderById(e))==null?void 0:h.with(exports.SheetSkeletonManagerService),s=(g=o==null?void 0:o.getCurrentParam())==null?void 0:g.skeleton;if(!s)return{redos:[],undos:[]};const l=s.calculateAutoHeightInRange(r),c={subUnitId:t,unitId:e,rowsAutoHeightInfo:l},d=s.worksheet,u=m.SetWorksheetRowAutoHeightMutationFactory(c,d);return{undos:[{id:m.SetWorksheetRowAutoHeightMutation.id,params:u}],redos:[{id:m.SetWorksheetRowAutoHeightMutation.id,params:c}]}}};exports.AutoFillService=Vd([Zt(0,a.ICommandService),Zt(1,a.IUndoRedoService),Zt(2,T.IRenderManagerService),Zt(3,a.Inject(a.IUniverInstanceService)),Zt(4,a.Inject(m.SheetsSelectionsService)),Zt(5,a.Inject(a.Injector))],exports.AutoFillService);const ft=a.createIdentifier("univer.auto-fill-service"),dt={type:a.CommandType.COMMAND,id:"sheet.command.auto-fill",handler:async(n,i)=>{const e=n.get(ft),t=n.get(a.IUniverInstanceService),{sourceRange:r,targetRange:o}=i,s=m.getSheetCommandTarget(t);if(!s)return!1;const{subUnitId:l,unitId:c}=s;return e.triggerAutoFill(c,l,r,o)}},un={id:"sheet.command.auto-clear-content",type:a.CommandType.COMMAND,handler:async(n,i)=>{const e=n.get(a.IUniverInstanceService),t=n.get(a.ICommandService),r=n.get(a.IUndoRedoService),o=n.get(m.SheetInterceptorService),s=m.getSheetCommandTarget(e);if(!s)return!1;const{unitId:l,subUnitId:c}=s,{clearRange:d,selectionRange:u}=i,h={subUnitId:c,unitId:l,cellValue:m.generateNullCellValue([d])},g=m.SetRangeValuesUndoMutationFactory(n,h),{startColumn:S,startRow:f}=u,p={selections:[{primary:{startColumn:S,startRow:f,endColumn:S,endRow:f,actualRow:f,actualColumn:S,isMerged:!1,isMergedMainCell:!1},range:{...u}}],unitId:l,subUnitId:c};if(t.executeCommand(m.SetSelectionsOperation.id,p),t.syncExecuteCommand(m.SetRangeValuesMutation.id,h)){const C=o.afterCommandExecute({id:m.SetRangeValuesMutation.id,params:h});return a.sequenceExecute(C.redos,t),r.pushUndoRedo({unitID:l,undoMutations:[{id:m.SetRangeValuesMutation.id,params:g},...C.undos],redoMutations:[{id:m.SetRangeValuesMutation.id,params:h},...C.redos]}),!0}return!1}},ir={id:"sheet.command.refill",type:a.CommandType.COMMAND,handler:async(n,i)=>n.get(ft).fillData(i.type)};var Hd=Object.getOwnPropertyDescriptor,Wd=(n,i,e,t)=>{for(var r=t>1?void 0:t?Hd(i,e):i,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=s(r)||r);return r},Kt=(n,i)=>(e,t)=>i(e,t,n);exports.EditorBridgeService=class extends a.Disposable{constructor(e,t,r,o,s,l){super();w(this,"_editorUnitId",a.DOCS_NORMAL_EDITOR_UNIT_ID_KEY);w(this,"_editorIsDirty",!1);w(this,"_visibleParams",{visible:!1,eventType:T.DeviceInputEventType.Dblclick,unitId:""});w(this,"_currentEditCell",null);w(this,"_currentEditCellState",null);w(this,"_currentEditCellLayout",null);w(this,"helpFunctionVisible$",new O.BehaviorSubject(!0));w(this,"_currentEditCellState$",new O.BehaviorSubject(null));w(this,"currentEditCellState$",this._currentEditCellState$.asObservable());w(this,"_currentEditCellLayout$",new O.BehaviorSubject(null));w(this,"currentEditCellLayout$",this._currentEditCellLayout$.asObservable());w(this,"currentEditCell$",this._currentEditCellState$.pipe(O.switchMap(e=>this._currentEditCellLayout$.pipe(O.map(t=>e&&t?{...e,...t}:null)))));w(this,"_visibleParams$",new O.BehaviorSubject(this._visibleParams));w(this,"visible$",this._visibleParams$.asObservable());w(this,"_afterVisibleParams$",new O.BehaviorSubject(this._visibleParams));w(this,"afterVisible$",this._afterVisibleParams$.asObservable());w(this,"_forceKeepVisible$",new O.BehaviorSubject(!1));w(this,"forceKeepVisible$",this._forceKeepVisible$.asObservable());this._sheetInterceptorService=e,this._renderManagerService=t,this._themeService=r,this._univerInstanceService=o,this._editorService=s,this._contextService=l,this.disposeWithMe(a.toDisposable(()=>{this._currentEditCellState$.complete(),this._currentEditCell=null})),this._univerInstanceService.getTypeOfUnitDisposed$(a.UniverInstanceType.UNIVER_SHEET).subscribe(c=>{var d;c.getUnitId()===((d=this._currentEditCellState)==null?void 0:d.unitId)&&this._clearCurrentEditCellState()})}refreshEditCellState(){const e=this.getLatestEditCellState();if(!e){this._currentEditCellState=null,this._currentEditCellLayout=null,this._currentEditCellState$.next(null),this._currentEditCellLayout$.next(null);return}const{position:t,scaleX:r,scaleY:o,canvasOffset:s,...l}=e;this._currentEditCellState=l,this._currentEditCellLayout={position:t,scaleX:r,scaleY:o,canvasOffset:s},this._currentEditCellState$.next(this._currentEditCellState),this._currentEditCellLayout$.next(this._currentEditCellLayout)}refreshEditCellPosition(e){var P;const t=this._currentEditCell;if(t==null)return;const r=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!r)return;const o=this._renderManagerService.getRenderUnitById(r.getUnitId());if(!o)return;const s=(P=o.with(exports.SheetSkeletonManagerService).getSkeletonParam(t.sheetId))==null?void 0:P.skeleton,l=o.with(pe);if(!s||!this._currentEditCellState)return;const{primary:c,scene:d,engine:u}=t,h=Gn(s,c);if(h==null)return;const g=a.convertCellToRange(h),S=J.getCanvasOffsetByEngine(u);let{startX:f,startY:p,endX:v,endY:C}=g;const{scaleX:b,scaleY:R}=d.getAncestorScale(),E=d.getViewportScrollXY(l.getViewPort());f=T.convertTransformToOffsetX(f,b,E),p=T.convertTransformToOffsetY(p,R,E),v=T.convertTransformToOffsetX(v,b,E),C=T.convertTransformToOffsetY(C,R,E),e&&this._currentEditCellLayout&&(v=v-f+this._currentEditCellLayout.position.startX,C=C-p+this._currentEditCellLayout.position.startY,f=this._currentEditCellLayout.position.startX,p=this._currentEditCellLayout.position.startY),this._currentEditCellLayout={position:{startX:f,startY:p,endX:v,endY:C},canvasOffset:S,scaleX:b,scaleY:R},this._currentEditCellLayout$.next(this._currentEditCellLayout)}setEditCell(e){this._currentEditCell=e,this._editorService.getFocusEditor()||(this._editorService.focus(a.DOCS_NORMAL_EDITOR_UNIT_ID_KEY),this._contextService.setContextValue(a.EDITOR_ACTIVATED,!1),this._contextService.setContextValue(a.FOCUSING_EDITOR_STANDALONE,!1));const t=this.getLatestEditCellState();if(!t){this._currentEditCellState=t,this._currentEditCellLayout=t,this._currentEditCellState$.next(t),this._currentEditCellLayout$.next(t);return}const{position:r,canvasOffset:o,scaleX:s,scaleY:l,...c}=t;this._currentEditCellState=c,this._currentEditCellLayout={position:r,canvasOffset:o,scaleX:s,scaleY:l},this._currentEditCellState$.next(this._currentEditCellState),this._currentEditCellLayout$.next(this._currentEditCellLayout)}_clearCurrentEditCellState(){this._currentEditCellState=null,this._currentEditCellState$.next(null),this._currentEditCellLayout=null,this._currentEditCellLayout$.next(null)}getEditCellState(){return this._currentEditCellState==null||this._currentEditCellLayout==null?null:{...this._currentEditCellState,...this._currentEditCellLayout}}getEditCellLayout(){return this._currentEditCellLayout}getEditLocation(){return this._currentEditCellState}updateEditLocation(e,t){this._currentEditCellState&&(this._currentEditCellState={...this._currentEditCellState,row:e,column:t})}getLatestEditCellState(){var W,V,U;const e=this._currentEditCell;if(e==null)return;const t=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!t)return;const r=this._renderManagerService.getRenderUnitById(t.getUnitId());if(!r)return;const o=r.with(exports.SheetSkeletonManagerService).getCurrentSkeleton(),s=r.with(pe);if(!o)return;const{primary:l,unitId:c,sheetId:d,scene:u,engine:h}=e,{startRow:g,startColumn:S}=l,f=Gn(o,l);if(f==null)return;const p=a.convertCellToRange(f),v=J.getCanvasOffsetByEngine(h);let{startX:C,startY:b,endX:R,endY:E}=p;const{scaleX:P,scaleY:y}=u.getAncestorScale(),M=u.getViewportScrollXY(s.getViewPort());C=T.convertTransformToOffsetX(C,P,M),b=T.convertTransformToOffsetY(b,y,M),R=T.convertTransformToOffsetX(R,P,M),E=T.convertTransformToOffsetY(E,y,M);const x=t.getActiveSheet();if(!x)return;const A={workbook:t,worksheet:x,unitId:t.getUnitId(),subUnitId:x.getSheetId(),row:g,col:S,origin:x.getCellRaw(g,S)};let k;const D=this._sheetInterceptorService.writeCellInterceptor.fetchThroughInterceptors(m.BEFORE_CELL_EDIT)(x.getCell(g,S),A);k=D&&o.getCellDocumentModelWithFormula(D);const N=(W=k==null?void 0:k.documentModel)==null?void 0:W.documentStyle.renderConfig;if(N!=null&&(N.cellValueType=a.CellValueType.STRING),!k||k.documentModel==null){const L=o.getBlankCellDocumentModel(D);if(k!=null){const{verticalAlign:j,horizontalAlign:B,wrapStrategy:F,textRotation:X,fill:K}=k,{centerAngle:te,vertexAngle:Q}=T.convertTextRotation(X);L.documentModel.documentStyle.renderConfig={...N,verticalAlign:j,horizontalAlign:B,wrapStrategy:F,background:{rgb:K},centerAngle:te,vertexAngle:Q}}k=L}if(k.fill=k.fill||"#fff",(V=k.documentModel)==null||V.setZoomRatio(Math.max(P,y)),(D==null?void 0:D.isInArrayFormulaRange)===!0){const L=(U=k.documentModel)==null?void 0:U.getBody();L&&(L.textRuns=[{st:0,ed:L.dataStream.length-2,ts:{cl:{rgb:this._themeService.getColorFromTheme("gray.600")}}}])}return{position:{startX:C,startY:b,endX:R,endY:E},scaleX:P,scaleY:y,canvasOffset:v,row:g,column:S,unitId:c,sheetId:d,documentLayoutObject:k,editorUnitId:this._editorUnitId,isInArrayFormulaRange:D==null?void 0:D.isInArrayFormulaRange}}getCurrentEditorId(){return this._editorUnitId}changeVisible(e){this._visibleParams=e,e.visible&&(this._editorIsDirty=!1),this._visibleParams$.next(this._visibleParams),this._afterVisibleParams$.next(this._visibleParams)}isVisible(){return this._visibleParams}enableForceKeepVisible(){this._forceKeepVisible$.next(!0)}disableForceKeepVisible(){this._forceKeepVisible$.next(!1)}isForceKeepVisible(){return this._forceKeepVisible$.getValue()}changeEditorDirty(e){this._editorIsDirty=e}getEditorDirty(){return this._editorIsDirty}};exports.EditorBridgeService=Wd([Kt(0,a.Inject(m.SheetInterceptorService)),Kt(1,T.IRenderManagerService),Kt(2,a.Inject(a.ThemeService)),Kt(3,a.IUniverInstanceService),Kt(4,J.IEditorService),Kt(5,a.IContextService)],exports.EditorBridgeService);const he=a.createIdentifier("univer.sheet-editor-bridge.service"),Se={id:"sheet.operation.set-cell-edit-visible",type:a.CommandType.OPERATION,handler:(n,i)=>{if(!i)return!1;const{unitId:e}=i,r=n.get(a.IUniverInstanceService).getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);return r?(n.get(he).changeVisible({...i,unitId:e!=null?e:r.getUnitId()}),!0):!1}},or={id:"sheet.operation.set-cell-edit-visible-f2",type:a.CommandType.OPERATION,handler:(n,i)=>{const e=n.get(a.ICommandService),r=n.get(a.IUniverInstanceService).getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);return r?e.syncExecuteCommand(Se.id,{...i,unitId:r.getUnitId()}):!1}},Nt={id:"sheet.operation.set-cell-edit-visible-arrow",type:a.CommandType.OPERATION,handler:()=>!0},Rn={id:"sheet.command.change-zoom-ratio",type:a.CommandType.COMMAND,handler:(n,i)=>{if(!i)return!1;const e=n.get(a.IUniverInstanceService),t=m.getSheetCommandTarget(e);if(!t)return!1;const{worksheet:r,subUnitId:o,unitId:s}=t,{delta:l,reset:c}=i;let d=c?100:Math.round((r.getConfig().zoomRatio+l)*100);d=Math.max(_o[0],d),d=Math.min(_o[1],d);const u=d/100,g=n.get(he).isVisible();return(g.unitId===s||g.unitId===a.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY)&&g.visible?!1:n.get(a.ICommandService).executeCommand(Ne.id,{unitId:s,subUnitId:o,zoomRatio:u})}},En={id:"sheet.command.set-zoom-ratio",type:a.CommandType.COMMAND,handler:(n,i)=>{if(!i)return!1;const{unitId:e,subUnitId:t,zoomRatio:r}=i,s=n.get(he).isVisible();return(s.unitId===e||s.unitId===a.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY)&&s.visible?!1:n.get(a.ICommandService).executeCommand(Ne.id,{unitId:e,subUnitId:t,zoomRatio:r})}};function Ud(n){return typeof n.isMainScene>"u"}function Ve(n,i){const e=n instanceof a.Workbook?n:n.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!e)return null;const t=e.getUnitId();let r,o,s,l;if(Ud(i)){const g=i.getRenderById(t);if(g==null)return null;r=g.components,r=g.components,o=g.mainComponent,s=g.scene,l=g.engine}else r=i.components,o=i.mainComponent,s=i.scene,l=i.engine;if(!r||!o)return null;const c=o,d=r.get(ue.ROW),u=r.get(ue.COLUMN),h=r.get(ue.LEFT_TOP);return{spreadsheet:c,spreadsheetRowHeader:d,spreadsheetColumnHeader:u,spreadsheetLeftTopPlaceholder:h,scene:s,engine:l}}function To(n,i,e,t){const{startX:r,startY:o,endX:s,endY:l}=t.getCellWithCoordByIndex(n,i);return{startX:r,startY:o,endX:s,endY:l}}function ze(n,i,e,t,r,o){const s=e.getCoordRelativeToViewport(T.Vector2.FromArray([n,i])),{x:l,y:c}=s,d=e.getScrollXYInfoByViewport(s,r),{scaleX:u,scaleY:h}=e.getAncestorScale(),g=t.getCellIndexByOffset(l,c,u,h,d,{closeFirst:o}),{row:S,column:f}=g,p=t.getNoMergeCellWithCoordByIndex(S,f),{startX:v,startY:C,endX:b,endY:R}=p;return{startX:v,startY:C,endX:b,endY:R,row:S,column:f}}function Xn(n,i,e,t){const r=e.getCoordRelativeToViewport(T.Vector2.FromArray([n,i])),o=e.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN),s=e.getScrollXYInfoByViewport(r,o),{scaleX:l,scaleY:c}=e.getAncestorScale(),{x:d,y:u}=s,h=n/l+d,g=i/c+u;return{x:h,y:g}}var Ld=Object.getOwnPropertyDescriptor,Bd=(n,i,e,t)=>{for(var r=t>1?void 0:t?Ld(i,e):i,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=s(r)||r);return r},Or=(n,i)=>(e,t)=>i(e,t,n);let Zn=class extends a.Disposable{constructor(i,e,t,r,o){super();w(this,"_zoom");this._context=i,this._sheetSkeletonManagerService=e,this._commandService=t,this._contextService=r,this._editorBridgeService=o,this._initSkeletonListener(),this._initZoomEventListener()}updateZoom(i,e){const t=this._context.unit.getSheetBySheetId(i);return t?(t.getConfig().zoomRatio=e,t===this._context.unit.getActiveSheet()&&this._updateViewZoom(e),!0):!1}_initZoomEventListener(){const i=Ve(this._context.unit,this._context).scene;this.disposeWithMe(i.onMouseWheel$.subscribeEvent(e=>{if(!e.ctrlKey||!this._contextService.getContextValue(a.FOCUSING_SHEET))return;if(this._editorBridgeService){const d=this._editorBridgeService.isVisible();if((d.unitId===this._context.unitId||d.unitId===a.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY)&&d.visible)return}const t=Math.abs(e.deltaX);let r=t<40?.2:t<80?.4:.2;r*=e.deltaY>0?-1:1,i.scaleX<1&&(r/=2);const o=this._context.unit,s=o.getActiveSheet();if(!s)return;const l=s.getZoomRatio();let c=+Number.parseFloat(`${l+r}`).toFixed(1);c=c>=4?4:c<=.1?.1:c,this._commandService.executeCommand(En.id,{zoomRatio:Math.round(c*10)/10,unitId:o.getUnitId(),subUnitId:s.getSheetId()}),e.preventDefault()}))}_initSkeletonListener(){this.disposeWithMe(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(i=>{if(i==null)return;const t=this._context.unit.getActiveSheet();if(!t)return;const r=t.getZoomRatio()||1;this._zoom!==r&&this._updateViewZoom(r)}))}_updateViewZoom(i){this._zoom=i;const e=Ve(this._context.unit,this._context);e==null||e.scene.scale(i,i),e==null||e.spreadsheet.makeForceDirty()}};Zn=Bd([Or(1,a.Inject(exports.SheetSkeletonManagerService)),Or(2,a.ICommandService),Or(3,a.IContextService),Or(4,a.Optional(he))],Zn);const Ne={id:"sheet.operation.set-zoom-ratio",type:a.CommandType.OPERATION,handler:(n,i)=>{const t=n.get(T.IRenderManagerService).getRenderById(i.unitId);return t?t.with(Zn).updateZoom(i.subUnitId,i.zoomRatio):!1}};var Fd=Object.getOwnPropertyDescriptor,jd=(n,i,e,t)=>{for(var r=t>1?void 0:t?Fd(i,e):i,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=s(r)||r);return r},Ar=(n,i)=>(e,t)=>i(e,t,n);const Hs="univer-sheet-main-canvas";exports.SheetsRenderService=class extends a.RxDisposable{constructor(e,t,r,o){super();w(this,"_skeletonChangeMutations",new Set);this._contextService=e,this._instanceSrv=t,this._renderManagerService=r,this._themeService=o,Promise.resolve().then(()=>this._init())}registerSkeletonChangingMutations(e){return this._skeletonChangeMutations.has(e)?a.toDisposable(()=>{}):(this._skeletonChangeMutations.add(e),a.toDisposable(()=>this._skeletonChangeMutations.delete(e)))}checkMutationShouldTriggerRerender(e){return this._skeletonChangeMutations.has(e)}_init(){this._initWorkbookListener(),this._initContextListener(),this._initDarkModeListener()}_initDarkModeListener(){this.disposeWithMe(this._themeService.darkMode$.subscribe(()=>{this._renderManagerService.getRenderAll().forEach(e=>{e.components.forEach(t=>{t.makeForceDirty(!0),t.makeDirty(!0)})})}))}_initWorkbookListener(){this._instanceSrv.getTypeOfUnitAdded$(a.UniverInstanceType.UNIVER_SHEET).pipe(O.takeUntil(this.dispose$)).subscribe(e=>this._createRenderer(e)),this._instanceSrv.getAllUnitsForType(a.UniverInstanceType.UNIVER_SHEET).forEach(e=>this._createRenderer(e)),this._instanceSrv.getTypeOfUnitDisposed$(a.UniverInstanceType.UNIVER_SHEET).pipe(O.takeUntil(this.dispose$)).subscribe(e=>this._disposeRenderer(e))}_createRenderer(e){const t=e.getUnitId();this._renderManagerService.created$.subscribe(r=>{r.unitId===t&&(r.engine.getCanvas().setId(`${Hs}_${t}`),r.engine.getCanvas().getContext().setId(`${Hs}_${t}`))}),this._renderManagerService.createRender(t)}_disposeRenderer(e){const t=e.getUnitId();this._renderManagerService.removeRender(t)}_initContextListener(){this.disposeWithMe(this._contextService.subscribeContextValue$(T.RENDER_RAW_FORMULA_KEY).pipe(O.distinctUntilChanged()).subscribe(()=>{this._renderManagerService.getRenderAll().forEach(e=>{e.mainComponent instanceof T.Spreadsheet&&e.mainComponent.makeForceDirty(!0)})}))}};exports.SheetsRenderService=jd([Ar(0,a.IContextService),Ar(1,a.IUniverInstanceService),Ar(2,T.IRenderManagerService),Ar(3,a.Inject(a.ThemeService))],exports.SheetsRenderService);var zd=Object.getOwnPropertyDescriptor,Xd=(n,i,e,t)=>{for(var r=t>1?void 0:t?zd(i,e):i,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=s(r)||r);return r},_t=(n,i)=>(e,t)=>i(e,t,n);exports.AutoFillController=class extends a.Disposable{constructor(e,t,r,o,s,l,c){super();w(this,"_beforeApplyData",[]);w(this,"_currentLocation",null);w(this,"_copyData",[]);w(this,"_defaultHook");this._univerInstanceService=e,this._commandService=t,this._autoFillService=r,this._editorBridgeService=o,this._renderManagerService=s,this._injector=l,this._sheetsRenderService=c,this._defaultHook={id:"default",type:en.Default,priority:0,onBeforeFillData:(d,u)=>this._presetAndCacheData(d,u),onFillData:(d,u,h)=>this._fillData(d,u,h)},this._init()}_init(){this._initDefaultHook(),this._initSelectionControlFillChanged(),this._initQuitListener(),this._initSkeletonChange()}_initSkeletonChange(){this.disposeWithMe(this._sheetsRenderService.registerSkeletonChangingMutations(dt.id))}_initDefaultHook(){this.disposeWithMe(this._autoFillService.addHook(this._defaultHook))}_initQuitListener(){const e=[Se.id,un.id,m.SetRangeValuesCommand.id,Ne.id,m.SetWorksheetActiveOperation.id,m.MoveRangeMutation.id,m.RemoveRowMutation.id,m.RemoveColMutation.id,m.InsertRowMutation.id,m.InsertColMutation.id,m.MoveRowsMutation.id,m.MoveColsMutation.id,m.SetWorksheetColWidthMutation.id,m.SetWorksheetRowHeightMutation.id,m.SetRangeValuesMutation.id];this.disposeWithMe(this._commandService.onCommandExecuted((t,r)=>{var c,d;const o=r==null?void 0:r.fromCollab,s=r==null?void 0:r.fromSync,l=r==null?void 0:r.fromFormula;e.includes(t.id)&&!o&&!s&&!l&&t.params.trigger!==dt.id&&t.params.trigger!==ir.id&&this._quit(),t.id===m.RemoveSheetMutation.id&&t.params.unitId===((c=this._currentLocation)==null?void 0:c.unitId)&&t.params.subUnitId===((d=this._currentLocation)==null?void 0:d.subUnitId)&&this._quit()})),this.disposeWithMe(this._univerInstanceService.unitDisposed$.subscribe(t=>{var r;t.getUnitId()===((r=this._currentLocation)==null?void 0:r.unitId)&&this._quit()}))}_quit(){this._currentLocation=null,this._beforeApplyData=[],this._copyData=[],this._autoFillService.setShowMenu(!1)}_initSelectionControlFillChanged(){const e=new a.DisposableCollection,t=()=>{e.dispose();const r=T.getCurrentTypeOfRenderer(a.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService);if(!r)return;r.with(pe).getSelectionControls().forEach(l=>{e.add(l.selectionFilled$.subscribe(c=>{if(c==null||c.startColumn===-1||c.startRow===-1||c.endColumn===-1||c.endRow===-1)return;const d={startColumn:l.model.startColumn,endColumn:l.model.endColumn,startRow:l.model.startRow,endRow:l.model.endRow},u={startColumn:c.startColumn,endColumn:c.endColumn,startRow:c.startRow,endRow:c.endRow};this._commandService.executeCommand(dt.id,{sourceRange:d,targetRange:u})})),e.add(l.fillControl.onDblclick$.subscribeEvent(()=>{const c={startColumn:l.model.startColumn,endColumn:l.model.endColumn,startRow:l.model.startRow,endRow:l.model.endRow};this._handleDbClickFill(c)})),e.add(l.fillControl.onPointerDown$.subscribeEvent(()=>{this._editorBridgeService.isVisible().visible&&this._commandService.syncExecuteCommand(Se.id,{visible:!1,eventType:T.DeviceInputEventType.PointerDown,unitId:r.unitId})}))})};t(),this.disposeWithMe(this._commandService.onCommandExecuted(r=>{r.id===m.SetSelectionsOperation.id&&t()})),this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET).subscribe(()=>t()))}_handleDbClickFill(e){const t=this._detectFillRange(e);t.endRow<=e.endRow||this._commandService.executeCommand(dt.id,{sourceRange:e,targetRange:t})}_detectFillRange(e){var g,S,f,p,v,C;const{startRow:t,endRow:r,startColumn:o,endColumn:s}=e,l=(g=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:g.getActiveSheet();if(!l)return e;const c=l.getCellMatrix(),d=l.getMaxRows()-1,u=l.getMaxColumns()-1;let h=r;if(o>0&&((S=c.getValue(t,o-1))==null?void 0:S.v)!=null){let b=t;for(;((f=c.getValue(b,o-1))==null?void 0:f.v)!=null&&b<d;)b+=1;h=b-1}else if(s<u&&((p=c.getValue(r,s+1))==null?void 0:p.v)!=null){let b=t;for(;((v=c.getValue(b,s+1))==null?void 0:v.v)!=null&&b<d;)b+=1;h=b-1}for(let b=r+1;b<=h;b++)for(let R=o;R<=s;R++)if(((C=c.getValue(b,R))==null?void 0:C.v)!=null){h=b-1;break}return{startColumn:o,endColumn:s,startRow:t,endRow:h}}_getApplyData(e,t,r,o,s,l=!0,c){const d=[],u=Math.floor(r/t),h=r%t,g=this._autoFillService.getRules();if(!l&&s===le.ONLY_FORMAT)return console.error("ERROR: only format can not be applied when hasStyle is false"),[];const S={};g.forEach(f=>{S[f.type]=[]}),g.forEach(f=>{const{type:p,applyFunctions:v={}}=f,C=e[p];C&&C.forEach(b=>{const R=_d(b.index,h),E=b.index.length*u+R,P=this._applyFunctions(b,E,o,s,v,e,c),y=Id(t,r,b.index);S[p].push({data:P,index:y})})});for(let f=0;f<r;f++)g.forEach(p=>{const{type:v}=p,C=S[v];for(let b=0;b<C.length;b++)f in C[b].index&&d.push(C[b].data[C[b].index[f]])});return d}_applyFunctions(e,t,r,o,s,l,c){const{data:d}=e,u=r===a.Direction.UP||r===a.Direction.LEFT;if(o===le.COPY){const h=s==null?void 0:s[le.COPY];return h?h(e,t,r,l,c):(u&&d.reverse(),kt(d,t))}if(o===le.SERIES){const h=s==null?void 0:s[le.SERIES];return h?h(e,t,r,l):(u&&d.reverse(),s!=null&&s[le.COPY]?s[le.COPY](e,t,r,l,c):kt(d,t))}if(o===le.ONLY_FORMAT){const h=s==null?void 0:s[le.ONLY_FORMAT];return h?h(e,t,r,l):bd(d,t)}}_getCopyData(e,t){const r=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getActiveSheet();if(!r)throw new Error("No active sheet found");const o=r.getCellMatrix(),s=this._autoFillService.getRules(),l=[],c=t===a.Direction.DOWN||t===a.Direction.UP;let d,u;return c?(d=e.cols,u=e.rows):(d=e.rows,u=e.cols),d.forEach(h=>{const g=this._getEmptyCopyDataPiece(),S={type:void 0,cellData:void 0};u.forEach(f=>{let p;c?p=o.getValue(f,h):p=o.getValue(h,f);const{type:v,isContinue:C}=s.find(b=>b.match(p,this._injector))||xa;if(C(S,p)){const b=g[v],R=b[b.length-1];R.data.push(p),R.index.push(f-u[0])}else{const b=g[v];b?b.push({data:[p],index:[f-u[0]]}):g[v]=[{data:[p],index:[f-u[0]]}]}S.type=v,S.cellData=p}),l.push(g)}),l}_getEmptyCopyDataPiece(){const e={};return this._autoFillService.getRules().forEach(t=>{e[t.type]=[]}),e}_getMergeApplyData(e,t,r,o){const s=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getActiveSheet();if(!s)throw new Error("No active sheet found");const l=[];for(let c=e.startRow;c<=e.endRow;c++)for(let d=e.startColumn;d<=e.endColumn;d++){const{isMergedMainCell:u,startRow:h,startColumn:g,endRow:S,endColumn:f}=s.getCellInfoInMergeData(c,d);if(u){if(r===a.Direction.DOWN){let p=h+o,v=S+o;for(;v<=t.endRow;)l.push({startRow:p,startColumn:g,endRow:v,endColumn:f}),p+=o,v+=o}else if(r===a.Direction.UP){let p=h-o,v=S-o;for(;p>=t.startRow;)l.push({startRow:p,startColumn:g,endRow:v,endColumn:f}),p-=o,v-=o}else if(r===a.Direction.RIGHT){let p=g+o,v=f+o;for(;v<=t.endColumn;)l.push({startRow:h,startColumn:p,endRow:S,endColumn:v}),p+=o,v+=o}else if(r===a.Direction.LEFT){let p=g-o,v=f-o;for(;p>=t.startColumn;)l.push({startRow:h,startColumn:p,endRow:S,endColumn:v}),p-=o,v-=o}}}return l}_presetAndCacheData(e,t){const{source:r,target:o}=e,s=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getActiveSheet();if(!s)throw new Error("No active sheet found");const l=s.getCellMatrix(),c=[];return o.rows.forEach(d=>{const u=[];o.cols.forEach(h=>{u.push(a.Tools.deepClone(l.getValue(d,h)))}),c.push(u)}),this._beforeApplyData=c,this._copyData=this._getCopyData(r,t),this._currentLocation=e,this._shouldDisableSeries(this._copyData)?(this._autoFillService.setDisableApplyType(le.SERIES,!0),le.COPY):(this._autoFillService.setDisableApplyType(le.SERIES,!1),this._getPreferredApplyType(this._copyData))}_fillData(e,t,r){var W,V;const o=[],s=[];let l=!0;r===le.NO_FORMAT&&(l=!1,r=le.SERIES);const{source:c,target:d,unitId:u,subUnitId:h}=e;if(!c||!d||t==null)return{undos:o,redos:s};const g=gt(c),S=gt(d),{cols:f,rows:p}=d,{cols:v,rows:C}=c,b=this._copyData;let R;t===a.Direction.DOWN||t===a.Direction.UP?R=C.length:R=v.length;const E=[];if(t===a.Direction.DOWN||t===a.Direction.UP){const U=p.length,L=[];f.forEach((j,B)=>{const F=b[B],X=this._getApplyData(F,R,U,t,r,l,e);L.push(X)});for(let j=0;j<L[0].length;j++){const B=[];for(let F=0;F<L.length;F++)B.push({s:null,...L[F][j]});E.push(B)}}else{const U=f.length;p.forEach((L,j)=>{const B=b[j],F=this._getApplyData(B,R,U,t,r,l,e),X=[];for(let K=0;K<F.length;K++)X.push({s:null,...F[K]});E.push(X)})}let P=[];const y=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getStyles();if(l?(P=this._getMergeApplyData(g,S,t,R),E.forEach(U=>{U.forEach(L=>{L&&y&&y&&(L.s=y.getStyleByCell(L))})})):E.forEach((U,L)=>{U.forEach((j,B)=>{j&&y&&(j.s=y.getStyleByCell(this._beforeApplyData[L][B])||null)})}),r===le.ONLY_FORMAT&&E.forEach((U,L)=>{U.forEach((j,B)=>{if(j){const F=this._beforeApplyData[L][B]||{};j.f=F.f,j.si=F.si,j.t=F.t,j.v=F.v}})}),l){const U=[],L=(V=(W=this._univerInstanceService.getUniverSheetInstance(u))==null?void 0:W.getSheetBySheetId(h))==null?void 0:V.getMergeData();L&&L.forEach(F=>{a.Rectangle.intersects(F,S)&&U.push(F)});const j={unitId:u,subUnitId:h,ranges:U},B=this._injector.invoke(m.RemoveMergeUndoMutationFactory,j);U.length&&(s.push({id:m.RemoveWorksheetMergeMutation.id,params:j}),o.unshift({id:m.AddWorksheetMergeMutation.id,params:B}))}const M={subUnitId:h,unitId:u,cellValue:md([d])},x=this._injector.invoke(m.SetRangeValuesUndoMutationFactory,M);s.push({id:m.SetRangeValuesMutation.id,params:M}),o.unshift({id:m.SetRangeValuesMutation.id,params:x});const A=new a.ObjectMatrix;p.forEach((U,L)=>{f.forEach((j,B)=>{E[L][B]&&A.setValue(U,j,E[L][B])})});const k=A.getMatrix(),D={subUnitId:h,unitId:u,cellValue:k},N=this._injector.invoke(m.SetRangeValuesUndoMutationFactory,D);if(this._autoFillService.getActiveHooks().forEach(U=>{var L;(L=U.onBeforeSubmit)==null||L.call(U,e,t,r,k)}),o.unshift({id:m.SetRangeValuesMutation.id,params:N}),s.push({id:m.SetRangeValuesMutation.id,params:D}),P!=null&&P.length){const U=m.getAddMergeMutationRangeByType(P),L={unitId:u,subUnitId:h,ranges:U},j=this._injector.invoke(m.AddMergeUndoMutationFactory,L);o.unshift({id:m.RemoveWorksheetMergeMutation.id,params:j}),s.push({id:m.AddWorksheetMergeMutation.id,params:L})}return{undos:o,redos:s}}_shouldDisableSeries(e){return e.every(t=>Object.keys(t).every(r=>{var o;return((o=t[r])==null?void 0:o.length)===0||[Ce.OTHER,Ce.FORMULA].includes(r)}))}_getPreferredApplyType(e){return e.every(r=>Object.keys(r).every(o=>{var s,l;return((s=r[o])==null?void 0:s.length)===0||((l=r[o])==null?void 0:l.length)===1&&r[o][0].data.length===1&&Ce.NUMBER===o}))?le.COPY:le.SERIES}};exports.AutoFillController=Xd([_t(0,a.IUniverInstanceService),_t(1,a.ICommandService),_t(2,ft),_t(3,he),_t(4,T.IRenderManagerService),_t(5,a.Inject(a.Injector)),_t(6,a.Inject(exports.SheetsRenderService))],exports.AutoFillController);var Yd=Object.getOwnPropertyDescriptor,Gd=(n,i,e,t)=>{for(var r=t>1?void 0:t?Yd(i,e):i,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=s(r)||r);return r},Di=(n,i)=>(e,t)=>i(e,t,n);exports.CellCustomRenderController=class extends a.Disposable{constructor(e,t,r,o){super();w(this,"_enterActiveRender");this._context=e,this._sheetSkeletonManagerService=t,this._renderManagerService=r,this._permissionService=o,this._initEventBinding()}_initEventBinding(){const e=new a.DisposableCollection,t=this._context.unit,r=o=>{if(e.dispose(),!o)return;const s=this._context.unitId,{skeleton:l}=o,c=this._renderManagerService.getRenderById(s);if(c&&c.mainComponent){const d=c.mainComponent,u=S=>{const{offsetX:f,offsetY:p}=S,v=c.scene,C=t.getActiveSheet();if(!C)return;const b=v.getActiveViewportByCoord(T.Vector2.FromArray([f,p]));if(!b)return;const{scaleX:R,scaleY:E}=v.getAncestorScale(),P={x:b.viewportScrollX,y:b.viewportScrollY},y=l.getCellIndexByOffset(f,p,R,E,P),M=l.worksheet.getMergedCell(y.row,y.column),x={actualRow:M?M.startRow:y.row,actualCol:M?M.startColumn:y.column,row:y.row,col:y.column};if(!x||!l)return;const A=C.getCell(x.actualRow,x.actualCol);if(!A)return;const k=A.customRender;if(!(k!=null&&k.length))return;const D=x.actualRow,N=x.actualCol,W=k.sort(a.sortRules),V=C.getSheetId(),U={data:A,style:l.getStyles().getStyleByCell(A),primaryWithCoord:l.getCellWithCoordByIndex(x.actualRow,x.actualCol),unitId:s,subUnitId:V,row:D,col:N,workbook:t,worksheet:C},L={x:P.x+f/R,y:P.y+p/E},j=W.find(B=>{var F;return(F=B.isHit)==null?void 0:F.call(B,L,U)});if(j)return[j,U]},h=d.onPointerDown$.subscribeEvent(S=>{var p,v,C,b;const f=u(S);if(f){const[R,E]=f,{row:P,col:y,worksheet:M,unitId:x,subUnitId:A}=E;if(!((p=this._permissionService.composePermission([new m.WorkbookEditablePermission(x).id,new m.WorksheetEditPermission(x,A).id]))==null?void 0:p.every(N=>N.value)))return!1;const D=(C=(v=M.getCell(P,y))==null?void 0:v.selectionProtection)==null?void 0:C[0];if((D==null?void 0:D[m.UnitAction.Edit])===!1)return!1;(b=R.onPointerDown)==null||b.call(R,E,S)}}),g=a.fromEventSubject(d.onPointerMove$).pipe(O.throttleTime(30)).subscribe(S=>{var p,v,C,b,R,E;const f=u(S);if(f){const[P,y]=f;this._enterActiveRender?this._enterActiveRender.render!==P&&((v=(p=this._enterActiveRender.render).onPointerLeave)==null||v.call(p,this._enterActiveRender.cellContext,S),this._enterActiveRender={render:P,cellContext:y},(C=P.onPointerEnter)==null||C.call(P,y,S)):(this._enterActiveRender={render:P,cellContext:y},(b=P.onPointerEnter)==null||b.call(P,y,S))}else this._enterActiveRender&&((E=(R=this._enterActiveRender.render).onPointerLeave)==null||E.call(R,this._enterActiveRender.cellContext,S),this._enterActiveRender=null)});h&&e.add(h),g&&e.add(g)}};this.disposeWithMe(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(r)),r(this._sheetSkeletonManagerService.getCurrentParam()),this.disposeWithMe(e)}};exports.CellCustomRenderController=Gd([Di(1,a.Inject(exports.SheetSkeletonManagerService)),Di(2,T.IRenderManagerService),Di(3,a.IPermissionService)],exports.CellCustomRenderController);class $o extends a.Disposable{constructor(){super(...arguments);w(this,"rangesStack",[]);w(this,"selectedRangeWorksheet","")}}var Zd=Object.getOwnPropertyDescriptor,Kd=(n,i,e,t)=>{for(var r=t>1?void 0:t?Zd(i,e):i,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=s(r)||r);return r},Ws=(n,i)=>(e,t)=>i(e,t,n);let hn=class{constructor(n,i){w(this,"_current",null);w(this,"_shortcutParam",[]);this._univerInstanceService=n,this._localeService=i}dispose(){this._shortcutParam=[]}getCurrentBySearch(n){return this._getCurrentBySearch(n)}getCurrent(){return this._getCurrentBySearch(this._current)}addOrUpdate(n){const i=this._getCurrentBySearch({unitId:n.unitId,sheetId:n.sheetId,keycode:n.keycode});if(i!=null){const e=this._shortcutParam.indexOf(i);this._shortcutParam.splice(e,1)}return this._shortcutParam.push(n),i}remove(n){if(n==null)return;const i=this._getCurrentBySearch(n);if(i==null)return;const e=this._shortcutParam.indexOf(i);return this._shortcutParam.splice(e,1)[0]}_getCurrentBySearch(n){return n==null?void 0:this._shortcutParam.find(e=>e.unitId===n.unitId&&e.sheetId===n.sheetId&&e.keycode===n.keycode)}};hn=Kd([Ws(0,a.IUniverInstanceService),Ws(1,a.Inject(a.LocaleService))],hn);var Ei=(n=>(n.MergeAll="mergeAll",n.MergeVertical="mergeVertical",n.MergeHorizontal="mergeHorizontal",n))(Ei||{});function ut(n,i,e,t,r=!0,o=1,s=!0){let l={...n};t==null&&(t={startRow:0,endRow:e.getRowCount()-1,startColumn:0,endColumn:e.getColumnCount()-1});let c;switch(i){case a.Direction.UP:for(c=n.startRow-o;c>-1&&!e.getRowVisible(c);)c-=1;c>=t.startRow?(l.startRow=c,l.endRow=c):s&&(l.startRow=t.endRow,l.endRow=t.endRow,r&&(l=ut(l,a.Direction.LEFT,e,t,!1)));break;case a.Direction.DOWN:for(c=n.endRow+o;c<e.getRowCount()&&!e.getRowVisible(c);)c+=1;c<=t.endRow?(l.startRow=c,l.endRow=c):s&&(l.startRow=t.startRow,l.endRow=t.startRow,r&&(l=ut(l,a.Direction.RIGHT,e,t,!1)));break;case a.Direction.LEFT:for(c=n.startColumn-o;c>-1&&!e.getColVisible(c);)c-=1;c>=t.startColumn?(l.startColumn=c,l.endColumn=c):s&&(l.startColumn=t.endColumn,l.endColumn=t.endColumn,r&&(l=ut(l,a.Direction.UP,e,t,!1)));break;case a.Direction.RIGHT:for(c=n.endColumn+o;c<e.getColumnCount()&&!e.getColVisible(c);)c+=1;c<=t.endColumn?(l.startColumn=c,l.endColumn=c):s&&(l.startColumn=t.startColumn,l.endColumn=t.startColumn,r&&(l=ut(l,a.Direction.DOWN,e,t,!1)));break}return l}function es(n,i,e){const t={...n},{startRow:r,startColumn:o,endRow:s,endColumn:l}=Kn(n,i,e);let c=On(e,r,o,s,l).hasValue,d=!0,u=!0;for(;u;){if(a.Direction.UP===i){let h=t.startRow-1;for(;h>-1&&!e.getRowVisible(h);)h-=1;if(h===-1){u=!1;break}const{hasValue:g,matrix:S}=On(e,h,t.startColumn,h,t.endColumn);if(c&&!g&&!d){u=!1;break}else{if(S.getLength()!==0){let f=h;S.forValue(p=>{f=Math.min(p,f)}),t.startRow=f}else t.startRow=h;if(t.endRow=t.startRow,!c&&g){u=!1;break}c=g,d=!1}}if(a.Direction.DOWN===i){let h=t.endRow+1;for(;h<e.getRowCount()&&!e.getRowVisible(h);)h+=1;if(h===e.getRowCount()){u=!1;break}const{hasValue:g,matrix:S}=On(e,h,t.startColumn,h,t.endColumn);if(c&&!g&&!d){u=!1;break}else{if(S.getLength()!==0){let f=h;S.forValue((p,v,C)=>{f=Math.max(p+(C.rowSpan||1)-1,f)}),t.endRow=f}else t.endRow=h;if(t.startRow=t.endRow,!c&&g){u=!1;break}c=g,d=!1}}if(a.Direction.LEFT===i){let h=t.startColumn-1;for(;h>-1&&!e.getColVisible(h);)h-=1;if(h===-1){u=!1;break}const{hasValue:g,matrix:S}=On(e,t.startRow,h,t.endRow,h);if(c&&!g&&!d){u=!1;break}else{if(S.getLength()!==0){let f=h;S.forValue((p,v)=>{f=Math.min(v,f)}),t.startColumn=f}else t.startColumn=h;if(t.endColumn=t.startColumn,!c&&g){u=!1;break}c=g,d=!1}}if(a.Direction.RIGHT===i){let h=t.endColumn+1;for(;h<e.getColumnCount()&&!e.getColVisible(h);)h+=1;if(h===e.getColumnCount()){u=!1;break}const{hasValue:g,matrix:S}=On(e,t.startRow,h,t.endRow,h);if(c&&!g&&!d){u=!1;break}else{if(S.getLength()!==0){let f=h;S.forValue((p,v,C)=>{f=Math.max(v+(C.colSpan||1)-1,f)}),t.endColumn=f}else t.endColumn=h;if(t.startColumn=t.endColumn,!c&&g){u=!1;break}c=g,d=!1}}}return m.alignToMergedCellsBorders(t,e,!0)}function Oa(n,i,e){return ut(n,i,e,void 0,!1,1,!1)}function qd(n,i,e){const t=es(n,i,e);return m.alignToMergedCellsBorders(a.Rectangle.union(t,n),e,!0)}function Qd(n,i,e){const t=Oa(n,i,e),r={startRow:Math.min(n.startRow,t.startRow),startColumn:Math.min(n.startColumn,t.startColumn),endRow:Math.max(n.endRow,t.endRow),endColumn:Math.max(n.endColumn,t.endColumn)};return m.alignToMergedCellsBorders(a.Rectangle.union(n,r),e)}function Jd(n,i,e,t){const r=a.getReverseDirection(e),o=es(Kn(n,r,t),e,t);return e===a.Direction.UP&&o.startRow<=n.startRow?m.alignToMergedCellsBorders({...i,startColumn:n.startColumn,endColumn:n.endColumn},t,!0):e===a.Direction.DOWN&&o.endRow>=n.endRow?m.alignToMergedCellsBorders({...i,startColumn:n.startColumn,endColumn:n.endColumn},t,!0):e===a.Direction.LEFT&&o.startColumn<=n.startColumn?m.alignToMergedCellsBorders({...i,startRow:n.startRow,endRow:n.endRow},t,!0):e===a.Direction.RIGHT&&o.endColumn>=n.endColumn?m.alignToMergedCellsBorders({...i,startRow:n.startRow,endRow:n.endRow},t,!0):a.Rectangle.union(a.Rectangle.clone(i),o)}function $d(n,i,e){const t=a.getReverseDirection(i),r=Kn(n,t,e),o=Kn(n,i,e),s=Oa(r,i,e);return m.alignToMergedCellsBorders(a.Rectangle.union(o,s),e,!1)}function Us(n){return{startRow:0,startColumn:0,endRow:n.getRowCount()-1,endColumn:n.getColumnCount()-1,rangeType:a.RANGE_TYPE.ALL}}function Kn(n,i,e){let t;switch(i){case a.Direction.UP:t={startRow:n.startRow,startColumn:n.startColumn,endRow:n.startRow,endColumn:n.endColumn,rangeType:a.RANGE_TYPE.NORMAL};break;case a.Direction.DOWN:t={startRow:n.endRow,startColumn:n.startColumn,endRow:n.endRow,endColumn:n.endColumn,rangeType:a.RANGE_TYPE.NORMAL};break;case a.Direction.LEFT:t={startRow:n.startRow,startColumn:n.startColumn,endRow:n.endRow,endColumn:n.startColumn,rangeType:a.RANGE_TYPE.NORMAL};break;case a.Direction.RIGHT:t={startRow:n.startRow,startColumn:n.endColumn,endRow:n.endRow,endColumn:n.endColumn,rangeType:a.RANGE_TYPE.NORMAL};break;default:throw new Error("Invalid direction")}return m.alignToMergedCellsBorders(t,e,!1)}function On(n,i,e,t,r){let o=!1;const s=n.getMatrixWithMergedCells(i,e,t,r).forValue((l,c,d)=>{if(tu(d))return o=!0,!1});return{hasValue:o,matrix:s}}function yo(n,i,e){const t=a.Rectangle.clone(n);if(i==null)return t;switch(e){case a.Direction.UP:case a.Direction.DOWN:t.startColumn=t.endColumn=i.actualColumn;break;case a.Direction.LEFT:case a.Direction.RIGHT:t.startRow=t.endRow=i.actualRow;break}return t}function eu(n,i,e){var l,c,d,u;const{primary:t,range:r}=n,o=a.Rectangle.clone(r);switch(i){case a.Direction.UP:case a.Direction.DOWN:o.startRow=(l=t==null?void 0:t.startRow)!=null?l:r.startRow,o.endRow=(c=t==null?void 0:t.endRow)!=null?c:r.startRow;break;case a.Direction.LEFT:case a.Direction.RIGHT:o.startColumn=(d=t==null?void 0:t.startColumn)!=null?d:r.startColumn,o.endColumn=(u=t==null?void 0:t.endColumn)!=null?u:r.startColumn;break}const s=Kn(o,i,e);switch(i){case a.Direction.DOWN:return r.startRow<s.startRow;case a.Direction.UP:return r.endRow>s.endRow;case a.Direction.LEFT:return s.endColumn<r.endColumn;case a.Direction.RIGHT:return s.startColumn>r.startColumn}}function Aa(n,i){let e=n[0].startRow,t=n[0].endRow;n.forEach(o=>{const{startRow:s,endRow:l}=o;e=Math.min(e,s),t=Math.max(t,l)});const r=new Array(t-e+1).fill(!1);return i.forEach(o=>{const{startRow:s,endRow:l}=o;for(let c=Math.max(s,e);c<=Math.min(l,t);c++)r[c-e]=!0}),n.every(o=>{const{startRow:s,endRow:l}=o;for(let c=s;c<=l;c++)if(!r[c-e])return!1;return!0})}function ka(n,i){let e=n[0].startColumn,t=n[0].endColumn;n.forEach(o=>{const{startColumn:s,endColumn:l}=o;e=Math.min(e,s),t=Math.max(t,l)});const r=new Array(t-e+1).fill(!1);return i.forEach(o=>{const{startColumn:s,endColumn:l}=o;for(let c=Math.max(s,e);c<=Math.min(l,t);c++)r[c-e]=!0}),n.every(o=>{const{startColumn:s,endColumn:l}=o;for(let c=s;c<=l;c++)if(!r[c-e])return!1;return!0})}function ts(n,i){return i?n==="mergeAll"?i.filter(e=>!(e.startRow===e.endRow&&e.startColumn===e.endColumn)):n==="mergeVertical"?i.filter(e=>e.startRow!==e.endRow):n==="mergeHorizontal"?i.filter(e=>e.startColumn!==e.endColumn):i:null}function tu(n){return n.v!==void 0&&n.v!==null&&n.v!==""||n.p!==void 0}var Ye=(n=>(n[n.moveStopeOne=0]="moveStopeOne",n[n.moveGap=1]="moveGap",n[n.moveStepPage=2]="moveStepPage",n[n.moveStepEnd=3]="moveStepEnd",n))(Ye||{});const ye={id:"sheet.command.move-selection",type:a.CommandType.COMMAND,handler:(n,i)=>{if(!i)return!1;const e=m.getSheetCommandTarget(n.get(a.IUniverInstanceService));if(!e)return!1;const{workbook:t,worksheet:r}=e,o=m.getSelectionsService(n,i.fromCurrentSelection).getCurrentLastSelection();if(!o)return!1;const{direction:s,jumpOver:l,extra:c}=i,{range:d,primary:u}=o,h=yo(d,u,s),g=l===1?es(h,s,r):ut(h,s,r),S=m.getCellAtRowCol(g.startRow,g.startColumn,r);if(a.Rectangle.equals(S,h))return!1;const f=t.getUnitId();n.get(hn).remove({unitId:f,sheetId:r.getSheetId(),keycode:_.KeyCode.TAB});const p=[{range:a.Rectangle.clone(S),primary:{startRow:S.startRow,startColumn:S.startColumn,endRow:S.endRow,endColumn:S.endColumn,actualRow:g.startRow,actualColumn:g.startColumn,isMerged:S.isMerged,isMergedMainCell:S.startRow===g.startRow&&S.startColumn===g.startColumn}}];return n.get(a.ICommandService).executeCommand(m.SetSelectionsOperation.id,{unitId:t.getUnitId(),subUnitId:r.getSheetId(),selections:p,type:m.SelectionMoveType.MOVE_END,extra:c,reveal:!0})}},Ge={id:"sheet.command.move-selection-enter-tab",type:a.CommandType.COMMAND,handler:(n,i)=>{var U;if(!i)return!1;const e=m.getSheetCommandTarget(n.get(a.IUniverInstanceService));if(!e)return!1;const{workbook:t,worksheet:r}=e,o=m.getSelectionsService(n),{direction:s,keycode:l}=i,c=s===a.Direction.LEFT||s===a.Direction.UP,d=o.getCurrentSelections().concat(),u=d.findIndex(L=>L.primary),h=d[u];if(!h)return!1;const g=c?-1:1,S=u+g!==d.length?d[u+g]:d[0],f=d.findIndex(L=>L===S),p=t.getUnitId(),v=r.getSheetId();if(!h)return!1;const{range:C}=h,b=h.primary;let R=yo(C,b,s);const E=n.get(hn),P=E.getCurrentBySearch({unitId:p,sheetId:v,keycode:_.KeyCode.TAB});let y;const{startRow:M,endRow:x,startColumn:A,endColumn:k}=C,D=c?b.startRow===M&&b.startColumn===A:b.endRow===x&&b.endColumn===k;if(a.Rectangle.equals(C,b)){if(l===_.KeyCode.TAB)P==null&&E.addOrUpdate({unitId:p,sheetId:v,keycode:_.KeyCode.TAB,selection:h});else{const B=P==null?void 0:P.selection;if(B!=null){const{range:F,primary:X}=B;R=yo(F,X,s)}E.remove({unitId:p,sheetId:v,keycode:_.KeyCode.TAB})}const L=ut(R,s,r),j=m.getCellAtRowCol(L.startRow,L.startColumn,r);if(a.Rectangle.equals(j,R))return!1;y={range:a.Rectangle.clone(j),primary:{startRow:j.startRow,startColumn:j.startColumn,endRow:j.endRow,endColumn:j.endColumn,actualRow:L.startRow,actualColumn:L.startColumn,isMerged:j.isMerged,isMergedMainCell:j.startRow===L.startRow&&j.startColumn===L.startColumn}}}else{E.remove({unitId:p,sheetId:v,keycode:_.KeyCode.TAB});const L=a.Tools.deepClone(b),j=D?S.range:ut({startRow:L.startRow,startColumn:L.startColumn,endRow:L.endRow,endColumn:L.endColumn},s,r,{startRow:M,endRow:x,startColumn:A,endColumn:k}),B=D&&c,F=B?m.getCellAtRowCol(j.endRow,j.endColumn,r):m.getCellAtRowCol(j.startRow,j.startColumn,r);y={range:D?S.range:a.Rectangle.clone(C),primary:{startRow:F.startRow,startColumn:F.startColumn,endRow:F.endRow,endColumn:F.endColumn,actualRow:B?F.startRow:j.startRow,actualColumn:B?F.startColumn:j.startColumn,isMerged:F.isMerged,isMergedMainCell:F.startRow===j.startRow&&F.startColumn===j.startColumn},style:D?S.style:h.style}}D?(d[u].primary=null,d[f]=y,o.setSelections(p,v,[],m.SelectionMoveType.MOVE_END)):d[u]=y;const N=n.get(a.ICommandService).executeCommand(m.SetSelectionsOperation.id,{unitId:p,subUnitId:v,type:m.SelectionMoveType.MOVE_END,selections:d,reveal:!0,extra:i.extra}),V=(U=n.get(T.IRenderManagerService).getRenderById(p))==null?void 0:U.with(pe);return V==null||V.refreshSelectionMoveEnd(),N}},Oe={id:"sheet.command.expand-selection",type:a.CommandType.COMMAND,handler:(n,i)=>{if(!i)return!1;const e=m.getSheetCommandTarget(n.get(a.IUniverInstanceService));if(!e)return!1;const{worksheet:t,unitId:r,subUnitId:o}=e,s=m.getSelectionsService(n).getCurrentLastSelection();if(!s)return!1;const{range:l,primary:c}=s,{jumpOver:d,direction:u,extra:h}=i,S=eu(s,u,t)?d===1?Jd(l,{...a.Rectangle.clone(c),rangeType:a.RANGE_TYPE.NORMAL},u,t):$d(l,u,t):d===1?qd(l,u,t):Qd(l,u,t);return S.rangeType=s.range.rangeType,a.Rectangle.equals(S,l)?!1:n.get(a.ICommandService).syncExecuteCommand(m.SetSelectionsOperation.id,{unitId:r,subUnitId:o,type:m.SelectionMoveType.MOVE_END,selections:[{range:S,primary:c}],extra:h,reveal:!0})}},sr={id:"sheet.command.select-all",type:a.CommandType.COMMAND,handler:async(n,i={expandToGapFirst:!0,loop:!1})=>{const e=m.getSheetCommandTarget(n.get(a.IUniverInstanceService));if(!e)return!1;const t=m.getSelectionsService(n).getCurrentLastSelection();if(!t)return!1;const r=n.get($o),{worksheet:o,unitId:s,subUnitId:l}=e,c=`${s}|${l}`;c!==r.selectedRangeWorksheet&&(r.rangesStack=[],r.selectedRangeWorksheet=c);const d=o.getMaxRows(),u=o.getMaxColumns(),{expandToGapFirst:h,loop:g}=i,{range:S,primary:f}=t,p=S.endColumn===u-1&&S.endRow===d-1&&S.startRow===0&&S.startColumn===0;r.rangesStack.some(P=>a.Rectangle.equals(P,S))||(r.rangesStack=[],r.rangesStack.push(S));let v;if(p)if(g){if(r.rangesStack.findIndex(y=>a.Rectangle.equals(y,S))!==r.rangesStack.length-1)return!1;v=r.rangesStack[0]}else return!1;else h?(v=m.expandToContinuousRange(S,{left:!0,right:!0,up:!0,down:!0},o),a.Rectangle.equals(v,S)&&(v=Us(o))):v=Us(o);r.rangesStack.some(P=>a.Rectangle.equals(P,v))||r.rangesStack.push(v);const C=[];C.push({id:m.SetSelectionsOperation.id,params:{unitId:s,subUnitId:l,reveal:!0,selections:[{range:v,primary:f}]}});const R=n.get(m.SheetInterceptorService).onCommandExecute({id:sr.id,params:{range:S}});R.redos.length&&C.push(...R.redos);const E=n.get(a.ICommandService);return a.sequenceExecute(C,E),!0}};var nu=Object.getOwnPropertyDescriptor,ru=(n,i,e,t)=>{for(var r=t>1?void 0:t?nu(i,e):i,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=s(r)||r);return r},iu=(n,i)=>(e,t)=>i(e,t,n);exports.SheetScrollManagerService=class{constructor(i,e){w(this,"_scrollStateMap",new Map);w(this,"_rawScrollInfo$",new O.BehaviorSubject(null));w(this,"rawScrollInfo$",this._rawScrollInfo$.asObservable());w(this,"validViewportScrollInfo$",new O.BehaviorSubject(null));w(this,"_searchParamForScroll",null);this._context=i,this._sheetSkeletonManagerService=e}dispose(){this._rawScrollInfo$.complete()}calcViewportScrollFromRowColOffset(i){if(!i)return{viewportScrollX:0,viewportScrollY:0};let{sheetViewStartColumn:e,sheetViewStartRow:t,offsetX:r,offsetY:o}=i;t=t||0,o=o||0;const s=this._sheetSkeletonManagerService.getCurrentSkeleton(),l=(s==null?void 0:s.rowHeightAccumulation[t-1])||0,d=((s==null?void 0:s.columnWidthAccumulation[e-1])||0)+r,u=l+o;return{viewportScrollX:d,viewportScrollY:u}}setSearchParam(i){this._searchParamForScroll=i}getScrollStateByParam(i){return this._getCurrentScroll(i)}getCurrentScrollState(){return this._getCurrentScroll(this._searchParamForScroll)}setValidScrollState(i){this._setScrollState(i)}emitRawScrollParam(i){this._emitRawScroll(i)}setValidScrollStateToCurrSheet(i){if(this._searchParamForScroll==null)return;this._setScrollState({...this._searchParamForScroll,...i});const e=this._searchParamForScroll.sheetId,t=this._sheetSkeletonManagerService.getSkeleton(e);t&&t.setScroll(i.viewportScrollX,i.viewportScrollY)}clear(){this._searchParamForScroll!=null&&this._clearByParamAndNotify(this._searchParamForScroll)}_setScrollState(i){const{unitId:e,sheetId:t,sheetViewStartColumn:r,sheetViewStartRow:o,offsetX:s,offsetY:l}=i;this._scrollStateMap.has(e)||this._scrollStateMap.set(e,new Map);const c=this._scrollStateMap.get(e),d={sheetViewStartRow:o,sheetViewStartColumn:r,offsetX:s,offsetY:l};c.set(t,d)}_clearByParamAndNotify(i){this._setScrollState({...i,sheetViewStartRow:0,sheetViewStartColumn:0,offsetX:0,offsetY:0}),this._emitRawScroll({sheetViewStartRow:0,sheetViewStartColumn:0,offsetX:0,offsetY:0})}_getCurrentScroll(i){var s;const e={sheetViewStartRow:0,sheetViewStartColumn:0,offsetX:0,offsetY:0};if(i==null)return e;const{unitId:t,sheetId:r}=i;return((s=this._scrollStateMap.get(t))==null?void 0:s.get(r))||e}_emitRawScroll(i){this._rawScrollInfo$.next(i)}};exports.SheetScrollManagerService=ru([iu(1,a.Inject(exports.SheetSkeletonManagerService))],exports.SheetScrollManagerService);const We={id:"sheet.operation.set-scroll",type:a.CommandType.OPERATION,handler:(n,i)=>{if(!i)return!1;const{unitId:e,sheetId:t,offsetX:r,offsetY:o,sheetViewStartColumn:s,sheetViewStartRow:l}=i;return n.get(T.IRenderManagerService).getRenderById(e).with(exports.SheetScrollManagerService).emitRawScrollParam({unitId:e,sheetId:t,offsetX:r,offsetY:o,sheetViewStartRow:l,sheetViewStartColumn:s}),!0}},mn={id:"sheet.command.set-scroll-relative",type:a.CommandType.COMMAND,handler:async(n,i)=>{const e=n.get(a.ICommandService),t=n.get(a.IUniverInstanceService),r=n.get(T.IRenderManagerService),o=m.getSheetCommandTarget(t);if(!o)return!1;const{unitId:s,subUnitId:l}=o,d=r.getRenderById(s).with(exports.SheetScrollManagerService).getCurrentScrollState(),{offsetX:u=0,offsetY:h=0}=i||{},{sheetViewStartRow:g=0,sheetViewStartColumn:S=0,offsetX:f=0,offsetY:p=0}=d||{};return e.executeCommand(We.id,{unitId:s,sheetId:l,sheetViewStartRow:g,sheetViewStartColumn:S,offsetX:f+u,offsetY:p+h})}},Ue={id:"sheet.command.scroll-view",type:a.CommandType.COMMAND,handler:(n,i)=>{if(!i)return!1;const e=n.get(a.IUniverInstanceService),t=n.get(T.IRenderManagerService),r=m.getSheetCommandTarget(e);if(!r)return!1;const{workbook:o,worksheet:s,unitId:l}=r,d=t.getRenderById(l).with(exports.SheetScrollManagerService).getCurrentScrollState();if(!s)return!1;const{sheetViewStartRow:u,sheetViewStartColumn:h,offsetX:g,offsetY:S}=i,{sheetViewStartColumn:f,sheetViewStartRow:p,offsetX:v,offsetY:C}=d||{},{xSplit:b,ySplit:R}=r.worksheet.getConfig().freeze;return n.get(a.ICommandService).syncExecuteCommand(We.id,{unitId:o.getUnitId(),sheetId:s.getSheetId(),sheetViewStartRow:u!=null?u:p!=null?p:0+R,sheetViewStartColumn:h!=null?h:f!=null?f:0+b,offsetX:g!=null?g:v,offsetY:S!=null?S:C})}},ns={id:"sheet.command.scroll-to-cell",type:a.CommandType.COMMAND,handler:(n,i)=>{const e=n.get(a.IUniverInstanceService);return n.get(T.IRenderManagerService).getRenderById(e.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getUnitId()).with(exports.SheetsScrollRenderController).scrollToRange(i.range,i.forceTop,i.forceLeft)}},ou={id:"sheet.command.scroll-view-reset",type:a.CommandType.COMMAND,handler:async n=>{const i=n.get(a.IUniverInstanceService),e=m.getSheetCommandTarget(i);if(!e)return!1;const{subUnitId:t,unitId:r}=e;return n.get(a.ICommandService).executeCommand(We.id,{unitId:r,sheetId:t,sheetViewStartRow:0,sheetViewStartColumn:0})}};var su=Object.getOwnPropertyDescriptor,au=(n,i,e,t)=>{for(var r=t>1?void 0:t?su(i,e):i,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=s(r)||r);return r},qt=(n,i)=>(e,t)=>i(e,t,n);ye.id,Ge.id;const lu=3;exports.SheetsScrollRenderController=class extends a.Disposable{constructor(i,e,t,r,o,s,l){super(),this._context=i,this._injector=e,this._sheetSkeletonManagerService=t,this._contextService=r,this._commandService=o,this._renderManagerService=s,this._scrollManagerService=l,this._initCommandListener(),this._wheelEventListener(),this._scrollBarEventListener(),this._initSkeletonListener()}_wheelEventListener(){const{scene:i}=this._context;if(!i)return;const e=i.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN);e&&this.disposeWithMe(i.onMouseWheel$.subscribeEvent((t,r)=>{if(t.ctrlKey||!this._contextService.getContextValue(a.FOCUSING_SHEET))return;let o=0,s=0;o=t.deltaX,t.shiftKey?o=(t.deltaY||t.deltaX)*lu:s=t.deltaY,this._commandService.executeCommand(mn.id,{offsetX:o,offsetY:s}),this._context.scene.makeDirty(!0);const l=e.limitedScroll(e.scrollX+o,e.scrollY+s);l&&!l.isLimitedX&&!l.isLimitedY&&(t.preventDefault(),i.getParent().classType===T.RENDER_CLASS_TYPE.SCENE_VIEWER&&r.stopPropagation()),e.isWheelPreventDefaultX&&e.isWheelPreventDefaultY&&t.preventDefault()}))}_scrollBarEventListener(){const{scene:i}=this._context;if(i==null)return;const e=i.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN);e&&(this.disposeWithMe(a.toDisposable(this._scrollManagerService.rawScrollInfo$.subscribe(t=>{var S;const r=(S=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:S.skeleton;if(!r)return;if(t==null){e.scrollToViewportPos({viewportScrollX:0,viewportScrollY:0});return}const{sheetViewStartRow:o,sheetViewStartColumn:s,offsetX:l,offsetY:c}=t,{startX:d,startY:u}=r.getCellWithCoordByIndex(o,s,!1),h=d+l,g=u+c;e.scrollToViewportPos({viewportScrollX:h,viewportScrollY:g})}))),this.disposeWithMe(e.onScrollAfter$.subscribeEvent(t=>{var p;const r=(p=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:p.skeleton;if(r==null||t.isTrigger===!1)return;const o=this._getSheetObject();if(r==null||o==null)return;const{viewportScrollX:s,viewportScrollY:l,scrollX:c,scrollY:d}=t,{row:u,column:h,rowOffset:g,columnOffset:S}=r.getOffsetRelativeToRowCol(s,l),f={sheetViewStartRow:u,sheetViewStartColumn:h,offsetX:S,offsetY:g,viewportScrollX:s,viewportScrollY:l,scrollX:c,scrollY:d};this._scrollManagerService.setValidScrollStateToCurrSheet(f),this._scrollManagerService.validViewportScrollInfo$.next({...f,viewportScrollX:s,viewportScrollY:l,scrollX:c,scrollY:d})})),this.disposeWithMe(e.onScrollByBar$.subscribeEvent(t=>{var g;const r=(g=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:g.skeleton;if(r==null||t.isTrigger===!1)return;const o=this._getSheetObject();if(r==null||o==null)return;const{viewportScrollX:s=0,viewportScrollY:l=0}=t;this._getFreeze();const{row:c,column:d,rowOffset:u,columnOffset:h}=r.getOffsetRelativeToRowCol(s,l);this._commandService.executeCommand(Ue.id,{sheetViewStartRow:c,sheetViewStartColumn:d,offsetX:h,offsetY:u})})))}_initSkeletonListener(){this.disposeWithMe(a.toDisposable(this._sheetSkeletonManagerService.currentSkeletonBefore$.subscribe(i=>{if(i==null)return;const e={unitId:i.unitId,sheetId:i.sheetId};if(this._scrollManagerService.setSearchParam(e),!this._getSheetObject())return;const r=this._scrollManagerService.getScrollStateByParam(e),{viewportScrollX:o,viewportScrollY:s}=this._scrollManagerService.calcViewportScrollFromRowColOffset(r);r&&this._updateViewportScroll(o,s)})))}_updateViewportScroll(i=0,e=0){const t=this._getSheetObject();if(!t)return;const r=t.scene,o=r.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN),s=r.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_COLUMN_RIGHT),l=r.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_ROW_BOTTOM),c=r.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT),d=r.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN_TOP);o&&(o.viewportScrollX=i,o.viewportScrollY=e),l&&(l.viewportScrollY=e),s&&(s.viewportScrollX=i),c&&(c.viewportScrollY=e),d&&(d.viewportScrollX=i)}scrollToRange(i,e,t){let{endRow:r,endColumn:o,startColumn:s,startRow:l}=i;const c=this._getViewportBounding();if(i.rangeType===a.RANGE_TYPE.ROW?(s=0,o=0):i.rangeType===a.RANGE_TYPE.COLUMN&&(l=0,r=0),c&&!e&&!t){const d=c.startRow>r?l:r,u=c.startColumn>o?s:o;return this._scrollToCell(d,u)}else return this._scrollToCell(l,s,e,t)}scrollToCell(i,e){const t=this._context.unit.getActiveSheet(),{ySplit:r,xSplit:o}=t.getFreeze();return this._commandService.syncExecuteCommand(Ue.id,{sheetViewStartRow:i-r,sheetViewStartColumn:e-o,offsetX:0,offsetY:0})}_initCommandListener(){this.disposeWithMe(this._commandService.onCommandExecuted(i=>{switch(i.id){case m.SetSelectionsOperation.id:{const e=i.params;e.unitId===this._context.unitId&&e.reveal&&this._scrollToSelection()}break;case m.ScrollToCellOperation.id:{const e=i.params;if(e.unitId===this._context.unitId){const t=e.range;this.scrollToRange(t)}}break;case Oe.id:{const e=i.params;this._scrollToSelectionForExpand(e)}break}}))}_scrollToSelectionForExpand(i){setTimeout(()=>{const e=this._getSelectionsService().getCurrentLastSelection();if(e==null)return;const{startRow:t,startColumn:r,endRow:o,endColumn:s}=e.range,l=this._getViewportBounding();if(l==null)return;const{startRow:c,startColumn:d,endRow:u,endColumn:h}=l;let g=0,S=0;t>c?g=o:o<u?g=t:g=c,r>d?S=s:s<h?S=r:S=d,i.direction===a.Direction.DOWN?g=o:i.direction===a.Direction.UP?g=t:i.direction===a.Direction.RIGHT?S=s:i.direction===a.Direction.LEFT&&(S=r),this._scrollToCell(g,S)},0)}_getFreeze(){var e;const i=(e=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:e.skeleton.getWorksheetConfig();if(i!=null)return i.freeze}_updateSceneSize(i){var h;if(i==null)return;const{unitId:e}=this._context,{skeleton:t}=i,r=(h=this._renderManagerService.getRenderById(e))==null?void 0:h.scene;if(t==null||r==null)return;const{rowTotalHeight:o,columnTotalWidth:s,rowHeaderWidthAndMarginLeft:l,columnHeaderHeightAndMarginTop:c}=t;this._context.unit.getActiveSheet()&&(r==null||r.transformByState({width:l+s,height:c+o}))}_getSheetObject(){return Ve(this._context.unit,this._context)}_scrollToSelectionByDirection(i){const e=this._getViewportBounding();if(e==null)return!1;const{startRow:t,startColumn:r,endRow:o,endColumn:s}=e;let l=0,c=0;const{startRow:d,startColumn:u,endRow:h,endColumn:g}=i;d>=t&&(l=h),h<=o&&(l=d),u>=r&&(c=g),g<=s&&(c=u),this._scrollToCell(l,c)}_scrollToSelection(i=!0){var d;const e=this._getSelectionsService().getCurrentLastSelection();if(!e)return;const{startRow:t,startColumn:r,actualRow:o,actualColumn:s}=(d=e.primary)!=null?d:e.range,l=i&&o!=null?o:t,c=i&&s!=null?s:r;this._scrollToCell(l,c)}_getSelectionsService(){return m.getSelectionsService(this._injector)}_getViewportBounding(){var o,s;const i=(o=this._getSheetObject())==null?void 0:o.scene;if(i==null)return;const e=i.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN);if(e==null)return;const t=(s=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:s.skeleton;if(t==null)return;const r=e.calcViewportInfo();return t.getRangeByViewBound(r.viewBound)}_scrollToCell(i,e,t=!1,r=!1){var k,D,N;const{rowHeightAccumulation:o,columnWidthAccumulation:s}=(k=this._sheetSkeletonManagerService.getCurrentSkeleton())!=null?k:{};if(o==null||s==null)return!1;const l=(D=this._getSheetObject())==null?void 0:D.scene;if(l==null)return!1;const c=l.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN);if(c==null)return!1;const d=(N=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:N.skeleton;if(d==null)return!1;const u=this._context.unit.getActiveSheet();if(!u)return!1;i=a.Tools.clamp(i,0,o.length-1),e=a.Tools.clamp(e,0,s.length-1);const{startColumn:h,startRow:g,ySplit:S,xSplit:f}=u.getFreeze(),p=this._getViewportBounding();if(p==null)return!1;const{startRow:v,startColumn:C,endRow:b,endColumn:R}=p;let E,P;if(i>=g&&e>=h-S&&(i<=v&&(E=i,t=!0),i>=b)){const W=o[i]-c.height;for(let V=v;V<=i&&(E=V+1,!(o[V]>=W));V++);}if(e>=h&&i>=g-S&&(e<=C&&(P=e,r=!0),e>=R)){const W=s[e]-c.width;for(let V=C;V<=e&&(P=V+1,!(s[V]>=W));V++);}if(E===void 0&&P===void 0)return!1;let{offsetX:y,offsetY:M,sheetViewStartRow:x,sheetViewStartColumn:A}=this._scrollManagerService.getCurrentScrollState()||{};if(E=E?Math.min(E,i):x+S,P=P?Math.min(P,e):A+f,r){y=0,P=e;const W=d.getHiddenColumnsInRange({startColumn:P-f,endColumn:P});P=P-W.length}if(t){M=0,E=i;const W=d.getHiddenRowsInRange({startRow:E-S,endRow:E});E=E-W.length}return this._commandService.syncExecuteCommand(Ue.id,{sheetViewStartRow:Math.max(0,E-S),sheetViewStartColumn:Math.max(0,P-f),offsetX:y,offsetY:M})}};exports.SheetsScrollRenderController=au([qt(1,a.Inject(a.Injector)),qt(2,a.Inject(exports.SheetSkeletonManagerService)),qt(3,a.IContextService),qt(4,a.ICommandService),qt(5,T.IRenderManagerService),qt(6,a.Inject(exports.SheetScrollManagerService))],exports.SheetsScrollRenderController);const rs={id:"sheet.operation.scroll-to-range",type:a.CommandType.OPERATION,handler:(n,i)=>{if(!i)return!1;const e=n.get(a.IUniverInstanceService);return n.get(T.IRenderManagerService).getRenderById(e.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getUnitId()).with(exports.SheetsScrollRenderController).scrollToRange(i.range,i.forceTop,i.forceLeft)}};class Da{constructor(){w(this,"_state",null);w(this,"_rect",null);w(this,"_state$",new O.BehaviorSubject(null));w(this,"state$",this._state$.asObservable());w(this,"_rect$",new O.BehaviorSubject(null));w(this,"rect$",this._rect$.asObservable());w(this,"_focus",!1);w(this,"_focus$",new O.BehaviorSubject(this._focus));w(this,"focus$",this._focus$.asObservable())}dispose(){this._state$.complete(),this._state=null,this._rect$.complete(),this._rect=null}setState(i){this._state=i,this._refresh(i)}getRect(){return this._rect}setRect(i){this._rect=i,this._rect$.next(i)}getState(){return this._state}setFocus(i=!1){this._focus=i,this._focus$.next(i)}_refresh(i){this._state$.next(i)}}const ar=a.createIdentifier("univer.sheet-cell-editor-manager.service");var Ae=function(){return Ae=Object.assign||function(n){for(var i,e=1,t=arguments.length;e<t;e++){i=arguments[e];for(var r in i)Object.prototype.hasOwnProperty.call(i,r)&&(n[r]=i[r])}return n},Ae.apply(this,arguments)},cu=function(n,i){var e={};for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&i.indexOf(t)<0&&(e[t]=n[t]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,t=Object.getOwnPropertySymbols(n);r<t.length;r++)i.indexOf(t[r])<0&&Object.prototype.propertyIsEnumerable.call(n,t[r])&&(e[t[r]]=n[t[r]]);return e},_e=H.forwardRef(function(n,i){var e=n.icon,t=n.id,r=n.className,o=n.extend,s=cu(n,["icon","id","className","extend"]),l="univerjs-icon univerjs-icon-".concat(t," ").concat(r||"").trim(),c=H.useRef("_".concat(hu()));return Na(e,"".concat(t),{defIds:e.defIds,idSuffix:c.current},Ae({ref:i,className:l},s),o)});function Na(n,i,e,t,r){return H.createElement(n.tag,Ae(Ae({key:i},du(n,e,r)),t),(uu(n,e).children||[]).map(function(o,s){return Na(o,"".concat(i,"-").concat(n.tag,"-").concat(s),e,void 0,r)}))}function du(n,i,e){var t=Ae({},n.attrs);e!=null&&e.colorChannel1&&t.fill==="colorChannel1"&&(t.fill=e.colorChannel1),n.tag==="mask"&&t.id&&(t.id=t.id+i.idSuffix),Object.entries(t).forEach(function(o){var s=o[0],l=o[1];s==="mask"&&typeof l=="string"&&(t[s]=l.replace(/url\(#(.*)\)/,"url(#$1".concat(i.idSuffix,")")))});var r=i.defIds;return!r||r.length===0||(n.tag==="use"&&t["xlink:href"]&&(t["xlink:href"]=t["xlink:href"]+i.idSuffix),Object.entries(t).forEach(function(o){var s=o[0],l=o[1];typeof l=="string"&&(t[s]=l.replace(/url\(#(.*)\)/,"url(#$1".concat(i.idSuffix,")")))})),t}function uu(n,i){var e,t=i.defIds;return!t||t.length===0?n:n.tag==="defs"&&(!((e=n.children)===null||e===void 0)&&e.length)?Ae(Ae({},n),{children:n.children.map(function(r){return typeof r.attrs.id=="string"&&t&&t.indexOf(r.attrs.id)>-1?Ae(Ae({},r),{attrs:Ae(Ae({},r.attrs),{id:r.attrs.id+i.idSuffix})}):r})}):n}function hu(){return Math.random().toString(36).substring(2,8)}_e.displayName="UniverIcon";var mu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"colorChannel1",d:"M11.0363 12.2367V14.0367C11.0363 14.3681 11.3049 14.6367 11.6363 14.6367C11.9676 14.6367 12.2363 14.3681 12.2363 14.0367V12.2367H14.0364C14.3677 12.2367 14.6364 11.9681 14.6364 11.6367C14.6364 11.3054 14.3677 11.0367 14.0364 11.0367H12.2363V9.23672C12.2363 8.90535 11.9676 8.63672 11.6363 8.63672C11.3049 8.63672 11.0363 8.90535 11.0363 9.23672V11.0367H9.23635C8.90498 11.0367 8.63635 11.3054 8.63635 11.6367C8.63635 11.9681 8.90498 12.2367 9.23635 12.2367H11.0363Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M2.56365 1.36377C1.90091 1.36377 1.36365 1.90103 1.36365 2.56377V6.16377C1.36365 6.82651 1.90091 7.36377 2.56365 7.36377H6.16365C6.82639 7.36377 7.36365 6.82651 7.36365 6.16377V2.56377C7.36365 1.90103 6.82639 1.36377 6.16365 1.36377H2.56365zM6.16365 2.56377H2.56365L2.56365 6.16377H6.16365V2.56377zM2.56365 8.63647C1.90091 8.63647 1.36365 9.17373 1.36365 9.83647V13.4365C1.36365 14.0992 1.90091 14.6365 2.56365 14.6365H6.16365C6.82639 14.6365 7.36365 14.0992 7.36365 13.4365V9.83647C7.36365 9.17373 6.82639 8.63647 6.16365 8.63647H2.56365zM6.16365 9.83647H2.56365L2.56365 13.4365H6.16365V9.83647zM9.83635 7.36377C9.17361 7.36377 8.63635 6.82651 8.63635 6.16377V2.56377C8.63635 1.90103 9.17361 1.36377 9.83635 1.36377H13.4364C14.0991 1.36377 14.6364 1.90103 14.6364 2.56377V6.16377C14.6364 6.82651 14.0991 7.36377 13.4364 7.36377H9.83635zM9.83635 6.16377V2.56377L13.4364 2.56377V6.16377H9.83635z",fillRule:"evenodd",clipRule:"evenodd"}}]},Va=H.forwardRef(function(n,i){return H.createElement(_e,Object.assign({},n,{id:"autofill",ref:i,icon:mu}))});Va.displayName="Autofill";var gu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M14.1544 3.75557C14.3887 3.98988 14.3887 4.36978 14.1544 4.6041L6.51409 12.2444C6.40157 12.3569 6.24896 12.4201 6.08983 12.4201C5.9307 12.4201 5.77808 12.3569 5.66556 12.2444L1.84541 8.42425C1.6111 8.18993 1.6111 7.81003 1.84541 7.57572C2.07973 7.34141 2.45963 7.34141 2.69394 7.57572L6.08983 10.9716L13.3059 3.75557C13.5402 3.52126 13.9201 3.52126 14.1544 3.75557Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Ut=H.forwardRef(function(n,i){return H.createElement(_e,Object.assign({},n,{id:"check-mark-single",ref:i,icon:gu}))});Ut.displayName="CheckMarkSingle";var Su={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M3.71274 2.86421C3.47843 2.6299 3.09853 2.6299 2.86421 2.86421C2.6299 3.09853 2.6299 3.47843 2.86421 3.71274L7.15154 8.00007L2.86421 12.2874C2.6299 12.5217 2.6299 12.9016 2.86421 13.1359C3.09853 13.3702 3.47843 13.3702 3.71274 13.1359L8.00007 8.84859L12.2874 13.1359C12.5217 13.3702 12.9016 13.3702 13.1359 13.1359C13.3702 12.9016 13.3702 12.5217 13.1359 12.2874L8.84859 8.00007L13.1359 3.71274C13.3702 3.47843 13.3702 3.09853 13.1359 2.86421C12.9016 2.6299 12.5217 2.6299 12.2874 2.86421L8.00007 7.15154L3.71274 2.86421Z"}}]},Ha=H.forwardRef(function(n,i){return H.createElement(_e,Object.assign({},n,{id:"close-single",ref:i,icon:Su}))});Ha.displayName="CloseSingle";var fu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"g",attrs:{fill:"currentColor",clipPath:"url(#convert-single_clip0_911_593)"},children:[{tag:"path",attrs:{d:"M2.44766.848145C1.564.848145.847656 1.56449.847656 2.44814V6.44814C.847656 7.3318 1.564 8.04814 2.44766 8.04814H6.44766C7.33131 8.04814 8.04766 7.3318 8.04766 6.44814V2.44814C8.04766 1.56449 7.33131.848145 6.44766.848145H2.44766zM2.04766 6.44814V5.04824H3.84775V6.84814H2.44766C2.22674 6.84814 2.04766 6.66906 2.04766 6.44814zM2.04766 3.84824H3.84775V2.04814H2.44766C2.22674 2.04814 2.04766 2.22723 2.04766 2.44814V3.84824zM5.04775 6.84814V5.04824H6.84766V6.44814C6.84766 6.66906 6.66857 6.84814 6.44766 6.84814H5.04775zM5.04775 3.84824H6.84766V2.44814C6.84766 2.22723 6.66857 2.04814 6.44766 2.04814H5.04775V3.84824zM9.55215 7.95166C8.66849 7.95166 7.95215 8.668 7.95215 9.55166V13.5517C7.95215 14.4353 8.66849 15.1517 9.55215 15.1517L11.5522 15.1517 13.5521 15.1517C14.4358 15.1517 15.1521 14.4353 15.1521 13.5517L15.1521 11.5518 15.1521 9.55166C15.1521 8.668 14.4358 7.95166 13.5521 7.95166H9.55215zM13.9521 10.9518V9.55166C13.9521 9.33075 13.7731 9.15166 13.5521 9.15166H12.1522V10.9518H13.9521zM10.9522 10.9518V9.15166H9.55215C9.33123 9.15166 9.15215 9.33075 9.15215 9.55166V10.9518H10.9522zM9.15215 12.1518H10.9522V13.9517H9.55215C9.33123 13.9517 9.15215 13.7726 9.15215 13.5517V12.1518zM12.1522 12.1518H13.9521V13.5517C13.9521 13.7726 13.7731 13.9517 13.5521 13.9517H12.1522V12.1518z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{d:"M9.62158 2.44912C9.62158 2.11775 9.89021 1.84912 10.2216 1.84912H12.7516C13.6352 1.84912 14.3516 2.56547 14.3516 3.44912V5.9791C14.3516 6.31047 14.0829 6.5791 13.7516 6.5791 13.4202 6.5791 13.1516 6.31047 13.1516 5.9791V3.44912C13.1516 3.22821 12.9725 3.04912 12.7516 3.04912H10.2216C9.89021 3.04912 9.62158 2.78049 9.62158 2.44912zM5.77871 14.1507C6.11008 14.1507 6.37871 13.8821 6.37871 13.5507 6.37871 13.2193 6.11008 12.9507 5.77871 12.9507L3.24873 12.9507C3.02782 12.9507 2.84873 12.7716 2.84873 12.5507L2.84873 10.0207C2.84873 9.68933 2.5801 9.4207 2.24873 9.4207 1.91736 9.4207 1.64873 9.68933 1.64873 10.0207L1.64873 12.5507C1.64873 13.4343 2.36507 14.1507 3.24873 14.1507H5.77871z"}}]},{tag:"defs",attrs:{},children:[{tag:"clipPath",attrs:{id:"convert-single_clip0_911_593"},children:[{tag:"path",attrs:{fill:"#fff",d:"M0 0H16V16H0z"}}]}]}],defIds:["convert-single_clip0_911_593"]},Wa=H.forwardRef(function(n,i){return H.createElement(_e,Object.assign({},n,{id:"convert-single",ref:i,icon:fu}))});Wa.displayName="ConvertSingle";var pu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.3313 1.4667C5.3313 1.13533 5.59993.866699 5.9313.866699H10.069C10.4004.866699 10.669 1.13533 10.669 1.4667 10.669 1.79807 10.4004 2.0667 10.069 2.0667H5.9313C5.59993 2.0667 5.3313 1.79807 5.3313 1.4667zM1.09985 3.64443C1.09985 3.31306 1.36848 3.04443 1.69985 3.04443H14.2999C14.6312 3.04443 14.8999 3.31306 14.8999 3.64443 14.8999 3.9758 14.6312 4.24443 14.2999 4.24443H1.69985C1.36848 4.24443 1.09985 3.9758 1.09985 3.64443zM6.12398 8.30171C6.35829 8.0674 6.73819 8.0674 6.97251 8.30171L8.00007 9.32928 9.02764 8.30171C9.26195 8.0674 9.64185 8.0674 9.87617 8.30171 10.1105 8.53603 10.1105 8.91593 9.87617 9.15024L8.8486 10.1778 9.87617 11.2054C10.1105 11.4397 10.1105 11.8196 9.87617 12.0539 9.64185 12.2882 9.26195 12.2882 9.02764 12.0539L8.00007 11.0263 6.97251 12.0539C6.73819 12.2882 6.35829 12.2882 6.12398 12.0539 5.88966 11.8196 5.88966 11.4397 6.12398 11.2054L7.15154 10.1778 6.12398 9.15024C5.88966 8.91593 5.88966 8.53603 6.12398 8.30171z"}},{tag:"path",attrs:{fill:"currentColor",d:"M4.75332 5.22217C3.86966 5.22217 3.15332 5.93851 3.15332 6.82217V12.5331C3.15332 13.9691 4.31738 15.1332 5.75332 15.1332H10.2465C11.6825 15.1332 12.8465 13.9691 12.8465 12.5331V6.82217C12.8465 5.93851 12.1302 5.22217 11.2465 5.22217H4.75332ZM4.35332 6.82217C4.35332 6.60125 4.53241 6.42217 4.75332 6.42217H11.2465C11.4674 6.42217 11.6465 6.60125 11.6465 6.82217V12.5331C11.6465 13.3063 11.0197 13.9332 10.2465 13.9332H5.75332C4.98012 13.9332 4.35332 13.3063 4.35332 12.5331V6.82217Z",fillRule:"evenodd",clipRule:"evenodd"}}]},wi=H.forwardRef(function(n,i){return H.createElement(_e,Object.assign({},n,{id:"delete-single",ref:i,icon:pu}))});wi.displayName="DeleteSingle";var vu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.85869 12.9216C8.38445 13.4708 7.61555 13.4708 7.14131 12.9216L0.358114 5.06726C-0.406895 4.18144 0.134916 2.66683 1.2168 2.66683L14.7832 2.66683C15.8651 2.66683 16.4069 4.18144 15.6419 5.06726L8.85869 12.9216Z"}}]},Mo=H.forwardRef(function(n,i){return H.createElement(_e,Object.assign({},n,{id:"dropdown-single",ref:i,icon:vu}))});Mo.displayName="DropdownSingle";var Cu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M15 8C15 11.866 11.866 15 8 15C4.13401 15 1 11.866 1 8C1 4.13401 4.13401 1 8 1C11.866 1 15 4.13401 15 8ZM10.3097 5.69014C10.544 5.92445 10.544 6.30435 10.3097 6.53867L8.84843 7.9999L10.3099 9.46137C10.5442 9.69569 10.5442 10.0756 10.3099 10.3099C10.0756 10.5442 9.69569 10.5442 9.46137 10.3099L7.9999 8.84843L6.53842 10.3099C6.30411 10.5442 5.92421 10.5442 5.6899 10.3099C5.45558 10.0756 5.45558 9.69569 5.6899 9.46137L7.15137 7.9999L5.69014 6.53867C5.45583 6.30435 5.45583 5.92445 5.69014 5.69014C5.92445 5.45583 6.30435 5.45583 6.53867 5.69014L7.9999 7.15137L9.46113 5.69014C9.69544 5.45583 10.0753 5.45583 10.3097 5.69014Z",fillRule:"evenodd",clipRule:"evenodd"}}]},is=H.forwardRef(function(n,i){return H.createElement(_e,Object.assign({},n,{id:"error-single",ref:i,icon:Cu}))});is.displayName="ErrorSingle";var _u={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M1.28096 4.6541C1.57489 4.50109 1.93721 4.61533 2.09022 4.90926C2.27315 5.26067 2.55999 5.60455 2.94829 5.92278C4.04628 6.82266 5.87505 7.44865 7.99828 7.44865C10.1215 7.44865 11.9503 6.82267 13.0482 5.92279C13.4366 5.60455 13.7234 5.26067 13.9063 4.90927C14.0594 4.61533 14.4217 4.50109 14.7156 4.65409C15.0095 4.8071 15.1238 5.16941 14.9708 5.46334C14.6995 5.98445 14.2981 6.44997 13.8089 6.8509C13.7298 6.91575 13.6481 6.97914 13.564 7.041L15.2245 8.70153C15.4588 8.93585 15.4588 9.31575 15.2245 9.55006C14.9902 9.78438 14.6103 9.78438 14.376 9.55006L12.5041 7.67822C11.8977 7.97568 11.2181 8.21208 10.4884 8.37706L11.0996 10.6581C11.1853 10.9782 10.9954 11.3072 10.6753 11.393C10.3552 11.4787 10.0262 11.2888 9.94045 10.9687L9.29949 8.57652C8.8758 8.62404 8.44081 8.64865 7.99828 8.64865C7.55276 8.64865 7.11487 8.62371 6.68846 8.57555L6.04723 10.9687C5.96147 11.2888 5.63247 11.4788 5.31239 11.393C4.99231 11.3073 4.80236 10.9783 4.88812 10.6582L5.49983 8.37516C4.7743 8.2105 4.09843 7.9752 3.49498 7.67947L1.62436 9.55009C1.39005 9.78441 1.01015 9.78441 0.775835 9.5501C0.54152 9.31578 0.541518 8.93588 0.775832 8.70157L2.43478 7.04261C2.34987 6.98024 2.26746 6.91632 2.18764 6.8509C1.69842 6.44997 1.29706 5.98445 1.0258 5.46335C0.872791 5.16942 0.987031 4.80711 1.28096 4.6541Z"}}]},Ua=H.forwardRef(function(n,i){return H.createElement(_e,Object.assign({},n,{id:"eyelash-single",ref:i,icon:_u}))});Ua.displayName="EyelashSingle";var Iu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M6.06409 5.53454C5.93592 5.53454 5.84083 5.41567 5.86897 5.29063L5.95442 4.9109C6.05444 4.48178 6.23806 4.11547 6.51182 3.81952 6.81082 3.49628 7.25398 3.35405 7.79738 3.35405 7.99847 3.35405 8.21359 3.37775 8.44188 3.42245 8.46089 3.42617 8.47974 3.43006 8.49846 3.4341 8.7099 3.4798 8.93698 3.38478 9.02031 3.18514L9.24767 2.6404C9.33457 2.43219 9.23178 2.19404 9.01582 2.12874 8.98358 2.11899 8.95028 2.10912 8.91591 2.09914 8.62745 2.01631 8.28392 1.97217 7.88074 1.97217 6.82015 1.97217 6.02714 2.23936 5.4746 2.7444 4.90987 3.26069 4.50889 3.99917 4.28413 4.9762L2.83703 11.1909C2.76126 11.5286 2.666 11.8917 2.54844 12.2812 2.42975 12.6734 2.2873 13.0595 2.12221 13.4373 1.95577 13.8159 1.76813 14.1762 1.55955 14.5171 1.49345 14.6251 1.42515 14.7282 1.35467 14.8263 1.26508 14.9509 1.3347 15.133 1.48655 15.1554 2.13635 15.2509 2.8179 15.0763 3.18197 14.5296 3.32661 14.3124 3.46779 14.0646 3.60509 13.7851 3.96635 13.0497 4.30522 12.0103 4.61867 10.6574L5.469 7.01534C5.49013 6.92483 5.57082 6.86081 5.66376 6.86081H7.62478C7.8097 6.86081 7.97051 6.73405 8.01371 6.55425L8.14014 6.02798C8.20057 5.77642 8.00992 5.53454 7.75121 5.53454H6.06409zM14.3211 5.72037L12.5124 7.96963 11.4089 5.77754C11.3422 5.63012 11.1954 5.5354 11.0336 5.5354H10.3129C10.0085 5.5354 9.80921 5.85428 9.9427 6.1279L11.4089 9.05502 8.79783 12.1493C8.56587 12.4158 8.75519 12.8315 9.10855 12.8315H9.68607C9.80672 12.8315 9.9605 12.7822 10.0388 12.6904L12.1108 10.2648 13.1176 12.561C13.1786 12.7231 13.333 12.8315 13.5061 12.8315H14.3C14.5831 12.8315 14.7417 12.6175 14.6426 12.3524L13.1728 9.28628C13.1728 9.28628 15.4009 6.45542 15.6013 6.17892 15.7966 5.90929 15.6023 5.5354 15.2693 5.5354H14.6661C14.5275 5.5354 14.4333 5.58887 14.3211 5.72037z"}}]},La=H.forwardRef(function(n,i){return H.createElement(_e,Object.assign({},n,{id:"fx-single",ref:i,icon:Iu}))});La.displayName="FxSingle";var bu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"colorChannel1",d:"M6.4833 1.65005C6.4833 1.31868 6.21467 1.05005 5.8833 1.05005C5.55193 1.05005 5.2833 1.31868 5.2833 1.65005V5.28345H1.65029C1.31892 5.28345 1.05029 5.55208 1.05029 5.88345C1.05029 6.21482 1.31892 6.48345 1.65029 6.48345H5.2833V9.51684H1.65029C1.31892 9.51684 1.05029 9.78547 1.05029 10.1168C1.05029 10.4482 1.31892 10.7168 1.65029 10.7168H5.2833V14.35C5.2833 14.6814 5.55193 14.95 5.8833 14.95C6.21467 14.95 6.4833 14.6814 6.4833 14.35V10.7168H9.5167V14.35C9.5167 14.6814 9.78533 14.95 10.1167 14.95C10.4481 14.95 10.7167 14.6814 10.7167 14.35V10.7168H14.3503C14.6817 10.7168 14.9503 10.4482 14.9503 10.1168C14.9503 9.78547 14.6817 9.51685 14.3503 9.51685H10.7167V6.48345H14.3503C14.6817 6.48345 14.9503 6.21482 14.9503 5.88345C14.9503 5.55208 14.6817 5.28345 14.3503 5.28345H10.7167V1.65005C10.7167 1.31868 10.4481 1.05005 10.1167 1.05005C9.78533 1.05005 9.5167 1.31868 9.5167 1.65005V5.28345L6.4833 5.28345V1.65005ZM6.4833 6.48345V9.51684L9.5167 9.51685V6.48345L6.4833 6.48345Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.0498 3.65005C1.0498 2.21411 2.21386 1.05005 3.6498 1.05005H12.3498C13.7857 1.05005 14.9498 2.21411 14.9498 3.65005V12.3501C14.9498 13.786 13.7857 14.95 12.3498 14.95H3.6498C2.21386 14.95 1.0498 13.786 1.0498 12.35V3.65005ZM3.6498 2.25005C2.87661 2.25005 2.2498 2.87685 2.2498 3.65005V12.35C2.2498 13.1232 2.87661 13.75 3.6498 13.75H12.3498C13.123 13.75 13.7498 13.1232 13.7498 12.3501V3.65005C13.7498 2.87685 13.123 2.25005 12.3498 2.25005H3.6498Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Ba=H.forwardRef(function(n,i){return H.createElement(_e,Object.assign({},n,{id:"hide-gridlines",ref:i,icon:bu}))});Ba.displayName="HideGridlines";var Ru={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.6 1.99991C8.60001 1.66854 8.33138 1.39991 8.00001 1.3999C7.66864 1.3999 7.40001 1.66853 7.4 1.9999L7.39996 7.3999H1.9999C1.66853 7.3999 1.3999 7.66853 1.3999 7.9999C1.3999 8.33127 1.66853 8.5999 1.9999 8.5999H7.39995L7.3999 13.9999C7.3999 14.3313 7.66853 14.5999 7.9999 14.5999C8.33127 14.5999 8.5999 14.3313 8.5999 13.9999L8.59995 8.5999H13.9999C14.3313 8.5999 14.5999 8.33127 14.5999 7.9999C14.5999 7.66853 14.3313 7.3999 13.9999 7.3999H8.59996L8.6 1.99991Z"}}]},os=H.forwardRef(function(n,i){return H.createElement(_e,Object.assign({},n,{id:"increase-single",ref:i,icon:Ru}))});os.displayName="IncreaseSingle";var Eu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.00016 1.33203C6.68162 1.33203 5.39269 1.72302 4.29636 2.45557C3.20004 3.18811 2.34555 4.2293 1.84097 5.44747C1.33638 6.66565 1.20436 8.00609 1.4616 9.2993C1.71883 10.5925 2.35377 11.7804 3.28612 12.7127C4.21847 13.6451 5.40636 14.28 6.69956 14.5373C7.99277 14.7945 9.33321 14.6625 10.5514 14.1579C11.7696 13.6533 12.8108 12.7988 13.5433 11.7025C14.2758 10.6062 14.6668 9.31724 14.6668 7.9987C14.6649 6.23118 13.9619 4.53662 12.7121 3.2868C11.4622 2.03697 9.76768 1.33397 8.00016 1.33203ZM7.66683 3.9987C7.86461 3.9987 8.05795 4.05735 8.2224 4.16723C8.38685 4.27711 8.51502 4.43329 8.59071 4.61601C8.6664 4.79874 8.6862 4.99981 8.64762 5.19379C8.60903 5.38777 8.51379 5.56595 8.37394 5.7058C8.23409 5.84566 8.0559 5.9409 7.86192 5.97948C7.66794 6.01807 7.46687 5.99826 7.28415 5.92258C7.10142 5.84689 6.94524 5.71872 6.83536 5.55427C6.72548 5.38982 6.66683 5.19648 6.66683 4.9987C6.66683 4.73348 6.77219 4.47913 6.95972 4.29159C7.14726 4.10405 7.40162 3.9987 7.66683 3.9987ZM9.3335 11.332H6.66683C6.49002 11.332 6.32045 11.2618 6.19543 11.1368C6.0704 11.0117 6.00016 10.8422 6.00016 10.6654C6.00016 10.4886 6.0704 10.319 6.19543 10.194C6.32045 10.0689 6.49002 9.9987 6.66683 9.9987H7.3335V7.9987H6.66683C6.49002 7.9987 6.32045 7.92846 6.19543 7.80343C6.0704 7.67841 6.00016 7.50884 6.00016 7.33203C6.00016 7.15522 6.0704 6.98565 6.19543 6.86063C6.32045 6.7356 6.49002 6.66536 6.66683 6.66536H8.00016C8.17698 6.66536 8.34655 6.7356 8.47157 6.86063C8.59659 6.98565 8.66683 7.15522 8.66683 7.33203V9.9987H9.3335C9.51031 9.9987 9.67988 10.0689 9.8049 10.194C9.92993 10.319 10.0002 10.4886 10.0002 10.6654C10.0002 10.8422 9.92993 11.0117 9.8049 11.1368C9.67988 11.2618 9.51031 11.332 9.3335 11.332Z"}}]},Fa=H.forwardRef(function(n,i){return H.createElement(_e,Object.assign({},n,{id:"info-single",ref:i,icon:Eu}))});Fa.displayName="InfoSingle";var wu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M2.62402 7.72905C2.58427 7.72905 2.55205 7.76127 2.55205 7.80102V13.6782C2.55205 13.7179 2.58427 13.7502 2.62402 13.7502H13.3755C13.4152 13.7502 13.4474 13.7179 13.4474 13.6782V7.80102C13.4474 7.76127 13.4152 7.72905 13.3755 7.72905H2.62402ZM1.35205 7.80102C1.35205 7.09853 1.92153 6.52905 2.62402 6.52905H13.3755C14.0779 6.52905 14.6474 7.09853 14.6474 7.80102V13.6782C14.6474 14.3807 14.0779 14.9502 13.3755 14.9502H2.62402C1.92153 14.9502 1.35205 14.3807 1.35205 13.6782V7.80102Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M8 2.25005C6.69847 2.25003 5.64336 3.30513 5.64336 4.60666V7.12895C5.64336 7.46032 5.37473 7.72895 5.04336 7.72895 4.71199 7.72895 4.44336 7.46032 4.44336 7.12895V4.60666C4.44336 2.64239 6.04451 1.05565 8.00879 1.05566M8 2.25005L8.00879 1.05566 8 2.25005zM8.00879 1.05566L8 2.25005C9.30154 2.25003 10.3567 3.30513 10.3567 4.60666V7.12895C10.3567 7.46032 10.6253 7.72895 10.9567 7.72895 11.288 7.72895 11.5567 7.46032 11.5567 7.12895V4.60666C11.5567 2.64239 9.97306 1.05565 8.00879 1.05566zM8.00039 9.4668C8.33176 9.4668 8.60039 9.73543 8.60039 10.0668V12.0827C8.60039 12.4141 8.33176 12.6827 8.00039 12.6827 7.66902 12.6827 7.40039 12.4141 7.40039 12.0827V10.0668C7.40039 9.73543 7.66902 9.4668 8.00039 9.4668z",fillRule:"evenodd",clipRule:"evenodd"}}]},ss=H.forwardRef(function(n,i){return H.createElement(_e,Object.assign({},n,{id:"lock-single",ref:i,icon:wu}))});ss.displayName="LockSingle";var Tu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M11.3536 6.14645C11.5488 6.34171 11.5488 6.65829 11.3536 6.85355L8.35355 9.85355C8.15829 10.0488 7.84171 10.0488 7.64645 9.85355L4.64645 6.85355C4.45118 6.65829 4.45118 6.34171 4.64645 6.14645C4.84171 5.95118 5.15829 5.95118 5.35355 6.14645L8 8.79289L10.6464 6.14645C10.8417 5.95118 11.1583 5.95118 11.3536 6.14645Z",fillRule:"evenodd",clipRule:"evenodd"}}]},gn=H.forwardRef(function(n,i){return H.createElement(_e,Object.assign({},n,{id:"more-down-single",ref:i,icon:Tu}))});gn.displayName="MoreDownSingle";var yu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.90913 3.57564C6.14345 3.34132 6.52335 3.34132 6.75766 3.57564L10.7577 7.57564C10.992 7.80995 10.992 8.18985 10.7577 8.42417L6.75766 12.4242C6.52335 12.6585 6.14345 12.6585 5.90913 12.4242C5.67482 12.1899 5.67482 11.81 5.90913 11.5756L9.48487 7.9999L5.90913 4.42417C5.67482 4.18985 5.67482 3.80995 5.90913 3.57564Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Po=H.forwardRef(function(n,i){return H.createElement(_e,Object.assign({},n,{id:"more-single",ref:i,icon:yu}))});Po.displayName="MoreSingle";var Mu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.01281 1.36643C8.79386 0.585377 10.0602 0.585378 10.8412 1.36643L12.9223 3.44752C13.7034 4.22857 13.7034 5.4949 12.9223 6.27595L9.36445 9.83383C8.5834 10.6149 7.31707 10.6149 6.53602 9.83383L4.45493 7.75273C3.67388 6.97168 3.67388 5.70535 4.45493 4.9243L8.01281 1.36643ZM9.9927 2.21495C9.68028 1.90253 9.17375 1.90253 8.86133 2.21495L5.30346 5.77283L5.29671 5.77966L10.839 6.66224L12.0738 5.42742C12.3862 5.115 12.3862 4.60847 12.0738 4.29605L9.9927 2.21495Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M14.5179 9.48875C14.5179 9.99175 14.1101 10.3995 13.607 10.3995C13.1041 10.3995 12.6963 9.99175 12.6963 9.48875C12.6963 9.1773 13.0455 8.59966 13.3114 8.20487C13.4549 7.99177 13.7591 7.99177 13.9027 8.20486C14.1687 8.59965 14.5179 9.1773 14.5179 9.48875Z"}},{tag:"path",attrs:{fill:"colorChannel1",d:"M1.98682 13.4992C1.98682 12.5603 2.74793 11.7992 3.68682 11.7992H14.2868C15.2257 11.7992 15.9868 12.5603 15.9868 13.4992V13.4992C15.9868 14.4381 15.2257 15.1992 14.2868 15.1992H3.68682C2.74793 15.1992 1.98682 14.4381 1.98682 13.4992V13.4992Z"}}]},ja=H.forwardRef(function(n,i){return H.createElement(_e,Object.assign({},n,{id:"paint-bucket",ref:i,icon:Mu}))});ja.displayName="PaintBucket";var Pu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_102_1138",style:{maskType:"alpha"},width:16,height:16,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#DCDCDC",d:"M0 0H16V16H0z"}}]},{tag:"g",attrs:{mask:"url(#mask0_102_1138)"},children:[{tag:"path",attrs:{fill:"colorChannel1",d:"M7.74692 9.12463C7.74692 9.46018 8.01893 9.73219 8.35448 9.73219H11.4933C11.8288 9.73219 12.1009 9.46018 12.1009 9.12463 12.1009 8.78909 11.8288 8.51707 11.4933 8.51707H8.35448C8.01893 8.51707 7.74692 8.78909 7.74692 9.12463zM10.8636 10.8523C10.8636 11.1879 10.5915 11.4599 10.256 11.4599H8.35448C8.01893 11.4599 7.74692 11.1879 7.74692 10.8523 7.74692 10.5168 8.01893 10.2447 8.35448 10.2447H10.256C10.5915 10.2447 10.8636 10.5168 10.8636 10.8523z"}},{tag:"path",attrs:{fill:"currentColor",d:"M5.4791 1.98268C5.47913 1.71529 5.87912 1.49854 6.37252 1.49854C6.86593 1.49854 7.26592 1.71529 7.26595 1.98268H7.62187C8.22277 1.98268 8.72459 2.39534 8.84412 2.9452H9.39563C10.0856 2.9452 10.6449 3.48923 10.6449 4.16032V6.00569H12.1261C13.161 6.00569 14 6.82174 14 7.82838V11.334C14 11.8174 13.8025 12.281 13.4511 12.6228L12.0693 13.9647C11.7179 14.3065 11.2412 14.4985 10.7442 14.4985H7.91116C7.05024 14.4985 6.32492 14.0431 6.10535 13.2737H3.34925C2.6593 13.2737 2.09998 12.7297 2.09998 12.0586V4.16032C2.09998 3.48923 2.6593 2.9452 3.34925 2.9452H3.90107C4.0206 2.39534 4.52241 1.98268 5.12332 1.98268H5.4791ZM3.97249 4.16032H3.24925L3.24925 12.0586H6.03725V7.82838C6.03725 6.82174 6.87623 6.00569 7.91116 6.00569H9.49563V4.16032H8.7727C8.58289 4.59611 8.13909 4.90183 7.62187 4.90183H5.12332C4.6061 4.90183 4.1623 4.59611 3.97249 4.16032ZM5.12332 2.89403H7.62187C7.79436 2.89403 7.93419 3.03003 7.93419 3.19781V3.68671C7.93419 3.85448 7.79436 3.99049 7.62187 3.99049H5.12332C4.95083 3.99049 4.811 3.85448 4.811 3.68671V3.19781C4.811 3.03003 4.95083 2.89403 5.12332 2.89403ZM7.91116 7.11157C7.56618 7.11157 7.28652 7.38359 7.28652 7.71913V12.7851C7.28652 13.1206 7.56618 13.3927 7.91116 13.3927H10.7442C10.8401 13.3927 10.9337 13.3712 11.0182 13.3311C11.1373 13.2746 11.1859 13.1423 11.1859 13.0134V12.0066C11.1859 11.8724 11.2978 11.7636 11.4358 11.7636H12.4709C12.6034 11.7636 12.7394 11.7163 12.7975 11.6004C12.8388 11.5182 12.8608 11.4272 12.8608 11.334V7.71913C12.8608 7.38359 12.5811 7.11157 12.2362 7.11157H7.91116Z",fillRule:"evenodd",clipRule:"evenodd"}}]}]},za=H.forwardRef(function(n,i){return H.createElement(_e,Object.assign({},n,{id:"paste-special",ref:i,icon:Pu}))});za.displayName="PasteSpecial";var xu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.785 6.77762C5.78908 6.7777 5.79316 6.77774 5.79725 6.77774C5.80134 6.77774 5.80543 6.7777 5.8095 6.77762H10.0184C10.0225 6.7777 10.0266 6.77774 10.0307 6.77774C10.0347 6.77774 10.0388 6.7777 10.0429 6.77762H13.6638V7.63727C13.6638 7.96864 13.9324 8.23727 14.2638 8.23727C14.5951 8.23727 14.8638 7.96864 14.8638 7.63727V3.9999C14.8638 2.56395 13.6997 1.39989 12.2637 1.3999L3.56389 1.39999C2.12797 1.40001 0.96393 2.56405 0.96392 3.99998L0.963867 11.6666C0.963857 13.1025 2.12792 14.2666 3.56387 14.2666H8.0542C8.38557 14.2666 8.6542 13.9979 8.6542 13.6666C8.6542 13.3352 8.38557 13.0666 8.0542 13.0666H3.56387C2.79067 13.0666 2.16386 12.4398 2.16387 11.6666L2.1639 6.77762H5.785ZM6.39725 2.59996L9.43065 2.59993V5.57762H6.39725V2.59996ZM5.19725 5.57762V2.59998L3.56391 2.59999C2.79072 2.6 2.16393 3.22679 2.16392 3.99998L2.16391 5.57762H5.19725ZM13.6638 5.57762V3.9999C13.6638 3.2267 13.037 2.59989 12.2638 2.5999L10.6307 2.59992V5.57762H13.6638Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M14.1223 10.2333V10.7496C14.7087 10.9869 15.1223 11.5618 15.1223 12.2333V12.8999C15.1223 13.7836 14.406 14.4999 13.5223 14.4999H11.5223C10.6387 14.4999 9.92235 13.7836 9.92235 12.8999V12.2333C9.92235 11.5618 10.336 10.9869 10.9223 10.7496V10.2333C10.9223 9.34961 11.6387 8.63328 12.5223 8.63328C13.406 8.63328 14.1223 9.34961 14.1223 10.2333ZM11.1223 12.2333C11.1223 12.0124 11.3014 11.8333 11.5223 11.8333H13.5223C13.7433 11.8333 13.9223 12.0124 13.9223 12.2333V12.8999C13.9223 13.1209 13.7433 13.2999 13.5223 13.2999H11.5223C11.3014 13.2999 11.1223 13.1209 11.1223 12.8999V12.2333ZM12.9223 10.2333V10.6333H12.1223V10.2333C12.1223 10.0124 12.3014 9.83328 12.5223 9.83328C12.7433 9.83328 12.9223 10.0124 12.9223 10.2333Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Xa=H.forwardRef(function(n,i){return H.createElement(_e,Object.assign({},n,{id:"protect-single",ref:i,icon:xu}))});Xa.displayName="ProtectSingle";var Ou={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M15 8C15 11.866 11.866 15 8 15C4.13401 15 1 11.866 1 8C1 4.13401 4.13401 1 8 1C11.866 1 15 4.13401 15 8ZM8.00008 12.3671C8.46031 12.3671 8.83342 11.994 8.83342 11.5338C8.83342 11.0735 8.46031 10.7004 8.00008 10.7004C7.53985 10.7004 7.16675 11.0735 7.16675 11.5338C7.16675 11.994 7.53985 12.3671 8.00008 12.3671ZM8.5999 4.4335C8.5999 4.10213 8.33127 3.8335 7.9999 3.8335C7.66853 3.8335 7.3999 4.10213 7.3999 4.4335V9.36683C7.3999 9.6982 7.66853 9.96683 7.9999 9.96683C8.33127 9.96683 8.5999 9.6982 8.5999 9.36683V4.4335Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Ya=H.forwardRef(function(n,i){return H.createElement(_e,Object.assign({},n,{id:"warning-single",ref:i,icon:Ou}))});Ya.displayName="WarningSingle";var Au={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M12.6551 1.98906C11.7476 1.08113 10.2757 1.08149 9.3686 1.98987L4.82542 6.53955C4.75087 6.61421 4.69336 6.70411 4.65682 6.80309L3.2461 10.625C3.16506 10.8446 3.21909 11.0912 3.3845 11.2568C3.54991 11.4224 3.79651 11.4767 4.01616 11.3959L7.85031 9.98517C7.94979 9.94856 8.04014 9.89077 8.11508 9.81579L12.6552 5.27327C13.5618 4.36621 13.5618 2.89607 12.6551 1.98906ZM10.2177 2.83779C10.6562 2.39869 11.3677 2.39851 11.8064 2.8374C12.2447 3.27584 12.2447 3.9865 11.8065 4.42497L7.3392 8.89457L4.82213 9.82068L5.74706 7.31487L10.2177 2.83779Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.79238 13.2999C1.46101 13.2999 1.19238 13.5685 1.19238 13.8999C1.19238 14.2313 1.46101 14.4999 1.79238 14.4999H14.4924C14.8238 14.4999 15.0924 14.2313 15.0924 13.8999C15.0924 13.5685 14.8238 13.2999 14.4924 13.2999H1.79238Z"}}]},as=H.forwardRef(function(n,i){return H.createElement(_e,Object.assign({},n,{id:"write-single",ref:i,icon:Au}))});as.displayName="WriteSingle";const ku=()=>{const[,n]=H.useState({});return H.useCallback(()=>n(i=>!i),[])},Du=()=>{const n=_.useDependency(a.ICommandService),i=_.useDependency(a.IUniverInstanceService),e=_.useDependency(T.IRenderManagerService),t=_.useDependency(ft),r=_.useDependency(a.LocaleService),[o,s]=H.useState([]),[l,c]=H.useState(!1),[d,u]=H.useState({row:-1,col:-1}),[h,g]=H.useState(le.SERIES),[S,f]=H.useState(!1),p=St(),{sheetSkeletonManagerService:v,selectionRenderService:C}=H.useMemo(()=>{if(p){const X=e.getRenderById(p.getUnitId());return{sheetSkeletonManagerService:X==null?void 0:X.with(exports.SheetSkeletonManagerService),selectionRenderService:X==null?void 0:X.with(pe)}}return{sheetSkeletonManagerService:null,selectionRenderService:null}},[p,e]),b=()=>{f(!0)},R=()=>{f(!1)},E=ku();if(H.useEffect(()=>n.onCommandExecuted((K,te)=>{K.id===We.id&&E()}).dispose,[E,n]),H.useEffect(()=>{const X=v&&a.toDisposable(v.currentSkeleton$.subscribe(K=>{K&&E()}));return X==null?void 0:X.dispose},[v,E]),H.useEffect(()=>a.toDisposable(t.menu$.subscribe(K=>{s(K.map(te=>({...te,index:K.indexOf(te)})))})).dispose,[t]),H.useEffect(()=>a.toDisposable(t.showMenu$.subscribe(K=>{const{source:te,target:Q}=t.autoFillLocation||{source:null,target:null};if(K&&te&&Q){const se=Math.max(te.rows[te.rows.length-1],Q.rows[Q.rows.length-1]),G=Math.max(te.cols[te.cols.length-1],Q.cols[Q.cols.length-1]);u({row:se,col:G})}else u({row:-1,col:-1})})).dispose,[t]),H.useEffect(()=>a.toDisposable(t.applyType$.subscribe(K=>{g(K)})).dispose,[t]),H.useEffect(()=>{function X(){c(!1)}return document.addEventListener("wheel",X),()=>{document.removeEventListener("wheel",X)}},[l]),d.col<0||d.row<0)return null;const P=Ve(i,e);if(!P||!C)return null;const{scene:y}=P,M=v==null?void 0:v.getCurrentSkeleton(),x=C.getViewPort(),A=y==null?void 0:y.scaleX,k=y==null?void 0:y.scaleY,D=y==null?void 0:y.getViewportScrollXY(x);if(!A||!y||!A||!k||!D)return null;const N=(M==null?void 0:M.getNoMergeCellWithCoordByIndex(d.row,d.col).endX)||0,W=(M==null?void 0:M.getNoMergeCellWithCoordByIndex(d.row,d.col).endY)||0,V=T.convertTransformToOffsetX(N,A,D),U=T.convertTransformToOffsetY(W,k,D);if(V==null||U==null)return null;const L=X=>{c(X)},j=X=>{n.executeCommand(ir.id,{type:X.value}),c(!1)},B=l||S,F=o.filter(X=>!X.disable);return I.jsx("div",{className:"univer-absolute univer-inset-0 univer-z-10 univer-size-0",children:I.jsx("div",{className:"univer-absolute",style:{left:`${V+2}px`,top:`${U+2}px`},onMouseEnter:b,onMouseLeave:R,children:I.jsx(z.DropdownMenu,{align:"start",items:F.map(X=>({type:"radio",value:h,options:[{label:r.t(X.label),value:X.value}],onSelect:()=>j(X)})),open:l,onOpenChange:L,children:I.jsxs("div",{className:z.clsx("univer-flex univer-items-center univer-gap-2 univer-rounded univer-p-1 dark:hover:!univer-bg-gray-800 hover:univer-bg-gray-100",z.borderClassName,{"univer-bg-gray-100 dark:!univer-bg-gray-800":l,"univer-bg-white dark:!univer-bg-gray-900":!l}),children:[I.jsx(Va,{className:"univer-fill-primary-600 univer-text-gray-900 dark:!univer-text-white"}),B&&I.jsx(gn,{className:"dark:!univer-text-white"})]})})})})};function ls(n,i){const e=_.useDependency(he),t=_.useDependency(a.ICommandService);return H.useMemo(()=>({keyCodes:[{keyCode:_.KeyCode.ENTER},{keyCode:_.KeyCode.ESC},{keyCode:_.KeyCode.TAB}],handler:o=>{(o===_.KeyCode.ENTER||o===_.KeyCode.ESC||o===_.KeyCode.TAB)&&(e.disableForceKeepVisible(),t.executeCommand(Se.id,{visible:!1,eventType:T.DeviceInputEventType.Keyboard,keycode:o,unitId:i}))}}),[t,e,i])}const Gr=-1e3,Ls={width:0,height:0,top:Gr,left:Gr},Nu=()=>{const[n,i]=H.useState({...Ls}),e=_.useDependency(ar),t=_.useDependency(J.IEditorService),r=_.useDependency(a.IContextService),o=_.useDependency(_.ComponentManager),s=_.useDependency(he),l=_.useObservable(s.visible$),c=_.useDependency(a.ICommandService),d=H.useRef(0),u=_.useObservable(()=>r.subscribeContextValue$(_.DISABLE_AUTO_FOCUS_KEY),!1,void 0,[r,_.DISABLE_AUTO_FOCUS_KEY]),h=o.get(_i),g=s.getEditLocation();H.useEffect(()=>{const v=e.state$.subscribe(C=>{if(C==null)return;const{startX:b=Gr,startY:R=Gr,endX:E=0,endY:P=0,show:y=!1}=C;if(!y)i({...Ls});else{i({width:E-b,height:P-R,left:b,top:R});const M=t.getEditor(a.DOCS_NORMAL_EDITOR_UNIT_ID_KEY);if(M==null)return;const{left:x,top:A,width:k,height:D}=M.getBoundingClientRect();e.setRect({left:x,top:A,width:k,height:D})}});return()=>{v.unsubscribe()}},[]),H.useEffect(()=>{u||e.setFocus(!0)},[u,n]);const S=_.useEvent(()=>{s.isVisible().visible&&c.executeCommand(Se.id,{visible:!1,eventType:T.DeviceInputEventType.PointerUp,unitId:g==null?void 0:g.unitId})});_.useSidebarClick(S);const f=ls(d,g==null?void 0:g.unitId),p=_.useEvent((v,C)=>{c.executeCommand(Nt.id,{keycode:v,visible:!1,eventType:T.DeviceInputEventType.Keyboard,isShift:C===_.MetaKeys.SHIFT||C===(_.MetaKeys.CTRL_COMMAND|_.MetaKeys.SHIFT),unitId:g==null?void 0:g.unitId})});return I.jsx("div",{className:"univer-absolute univer-z-10 univer-flex",style:{left:n.left,top:n.top,width:n.width,height:n.height},children:h&&I.jsx(h,{editorId:a.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,className:"univer-relative univer-flex univer-h-full univer-w-full [&_canvas]:univer-absolute",initValue:"",onChange:()=>{},isFocus:l==null?void 0:l.visible,unitId:g==null?void 0:g.unitId,subUnitId:g==null?void 0:g.sheetId,keyboardEventConfig:f,onMoveInEditor:p,isSupportAcrossSheet:!0,resetSelectionOnBlur:!1,isSingle:!1,autoScrollbar:!1,onFormulaSelectingChange:(v,C)=>{d.current=v,C&&(v?s.enableForceKeepVisible():s.disableForceKeepVisible())},disableSelectionOnClick:!0,disableContextMenu:!1})})};class Vu{constructor(){w(this,"_position",null);w(this,"_position$",new O.BehaviorSubject(null));w(this,"position$",this._position$.asObservable());w(this,"_focus",!1);w(this,"_focus$",new O.BehaviorSubject(this._focus));w(this,"focus$",this._focus$.asObservable());w(this,"_fxBtnClick$",new O.Subject);w(this,"fxBtnClick$",this._fxBtnClick$.asObservable());w(this,"_foldBtnStatus$",new O.Subject);w(this,"foldBtnStatus$",this._foldBtnStatus$.asObservable())}dispose(){this._position$.complete(),this._focus$.complete(),this._position=null,this._focus=!1}setPosition(i){this._position=i,this._refresh(i)}getPosition(){return this._position}setFocus(i=!1){this._focus=i,this._focus$.next(i)}handleFxBtnClick(i){this._fxBtnClick$.next(i)}handleFoldBtnClick(i){this._foldBtnStatus$.next(i)}_refresh(i){this._position$.next(i)}}const lr=a.createIdentifier("univer.sheet-formula-editor-manager.service"),qn="DefinedNameContainer",Ti={id:"sidebar.operation.defined-name",type:a.CommandType.COMMAND,handler:async(n,i)=>{const e=n.get(_.ISidebarService);n.get(J.IEditorService);const t=n.get(a.LocaleService),r=n.get(a.IUniverInstanceService),o=m.getSheetCommandTarget(r);if(!o)return!1;const{unitId:s}=o;switch(i.value){case"open":e.open({id:qn,header:{title:t.t("definedName.featureTitle")},children:{label:qn},onClose:()=>{},width:333});break;case"close":default:e.close();break}return!0}};function Hu(){const n=_.useDependency(a.ICommandService),i=_.useDependency(a.LocaleService),e=_.useDependency(Z.IDefinedNamesService),t=_.useDependency(a.IUniverInstanceService),r=_.useDependency(_.ISidebarService),s=t.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getUnitId(),l=()=>{const g=e.getDefinedNameMap(s);return g?Array.from(Object.values(g)):[]},[c,d]=H.useState(l());H.useEffect(()=>{const g=e.update$.subscribe(()=>{d(l())});return()=>{g.unsubscribe()}},[]),H.useEffect(()=>{const g=r.sidebarOptions$.subscribe(S=>{S.id===qn&&(S.visible||setTimeout(()=>{r.sidebarOptions$.next({visible:!1})}))});return()=>{g.unsubscribe()}},[]);const u=()=>{n.executeCommand(Ti.id,{value:"open"})},h=async g=>{const{formulaOrRefString:S,id:f}=g,p=e.getWorksheetByRef(s,S);if(!p)return;p.isSheetHidden()&&await n.executeCommand(m.SetWorksheetShowCommand.id,{unitId:s,subUnitId:p.getSheetId()}),e.focusRange(s,f)};return I.jsxs("div",{className:"univer-w-[300px]",children:[I.jsx("ul",{className:z.clsx("univer-m-0 univer-max-h-[360px] univer-list-none univer-overflow-y-auto univer-p-0",z.scrollbarClassName),children:c.map((g,S)=>I.jsx("li",{className:"univer-cursor-pointer univer-px-2 univer-transition-colors univer-duration-200 dark:hover:!univer-bg-gray-600 hover:univer-bg-gray-100",onClick:()=>{h(g)},children:I.jsxs("div",{className:z.clsx("univer-flex univer-items-center univer-justify-between univer-gap-2 univer-py-1",z.borderBottomClassName),children:[I.jsx("div",{className:"univer-w-[50%] univer-flex-shrink-0 univer-overflow-hidden univer-text-ellipsis univer-whitespace-nowrap univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",title:g.name,children:g.name}),I.jsx("div",{className:"univer-w-[50%] univer-flex-shrink-0 univer-overflow-hidden univer-text-ellipsis univer-whitespace-nowrap univer-text-xs univer-text-gray-400",title:g.formulaOrRefString,children:g.formulaOrRefString})]})},S))}),I.jsxs("div",{className:"univer-cursor-pointer univer-p-2 univer-transition-colors univer-duration-200 dark:hover:!univer-bg-gray-600 hover:univer-bg-gray-100",onClick:u,children:[I.jsx("div",{className:"univer-mb-2 univer-text-sm univer-font-semibold univer-text-gray-600 dark:!univer-text-gray-200",children:i.t("definedName.managerTitle")}),I.jsx("div",{className:"univer-text-xs univer-text-gray-400",children:i.t("definedName.managerDescription")})]})]})}function Wu({disable:n}){const[i,e]=H.useState(""),t=_.useDependency(Z.IDefinedNamesService);H.useEffect(()=>{const o=t.currentRange$.subscribe(()=>{e(t.getCurrentRangeForString())});return()=>{o.unsubscribe()}},[]);function r(){}return I.jsxs("div",{"data-u-comp":"defined-name",className:"univer-relative univer-box-border univer-flex univer-h-full univer-w-24 univer-border-r-gray-200 univer-py-1.5 univer-transition-all",children:[I.jsx("input",{className:z.clsx("univer-box-border univer-h-full univer-w-full univer-appearance-none univer-px-1.5 univer-text-gray-900 dark:!univer-border-r-gray-700 dark:!univer-bg-gray-900 dark:!univer-text-white focus:univer-outline-none",z.borderRightClassName,{"univer-cursor-not-allowed":n}),type:"text",value:i,onChange:r}),I.jsx(z.Dropdown,{overlay:I.jsx("div",{className:"univer-z-[1001]",children:I.jsx(Hu,{})}),disabled:n,children:I.jsx("a",{className:z.clsx("univer-absolute univer-right-0 univer-top-0 univer-flex univer-h-full univer-cursor-pointer univer-items-center univer-justify-center univer-px-1 univer-transition-colors univer-duration-200 dark:!univer-text-white dark:hover:!univer-bg-gray-800 hover:univer-bg-gray-100",{"univer-cursor-not-allowed univer-text-gray-300 dark:!univer-text-gray-700 hover:univer-bg-transparent":n}),children:I.jsx(gn,{})})})]})}function Ga(n){var q,ne,ce,ie;const{className:i,disableDefinedName:e}=n,[t,r]=H.useState(!1),[o,s]=H.useState(0),l=_.useDependency(lr),c=_.useDependency(he),d=_.useDependency(m.WorksheetProtectionRuleModel),u=_.useDependency(m.RangeProtectionRuleModel),h=_.useDependency(a.IUniverInstanceService),g=_.useDependency(m.SheetsSelectionsService),S=_.useDependency(a.IPermissionService),f=_.useDependency(m.RangeProtectionCache),p=_.useDependency(a.ICommandService),[v,C]=H.useState({editDisable:!1,viewDisable:!1}),[b,R]=H.useState(!1),E=_.useDependency(_.ComponentManager),P=_.useObservable(()=>h.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]),y=H.useRef(0),M=_.useObservable(c.currentEditCellState$),x=ls(y,(q=M==null?void 0:M.unitId)!=null?q:""),A=E.get(_i),k=_.useComponentsOfPart(Qo.FORMULA_AUX),D=_.useDependency(a.IContextService);_.useObservable(H.useMemo(()=>D.subscribeContextValue$(a.FOCUSING_FX_BAR_EDITOR),[D]));const N=D.getContextValue(a.FOCUSING_FX_BAR_EDITOR),W=H.useRef(null),V=_.useDependency(J.IEditorService);H.useLayoutEffect(()=>{const oe=P.activeSheet$.pipe(O.switchMap($=>$?O.merge(d.ruleChange$,u.ruleChange$,g.selectionMoveEnd$,g.selectionSet$).pipe(O.switchMap(()=>{var ot,st;const me=P.getUnitId(),fe=$.getSheetId();if(!((ot=g.getCurrentLastSelection())==null?void 0:ot.range))return O.EMPTY;const Re=(st=g.getCurrentLastSelection())==null?void 0:st.primary;return Re?O.of({unitId:me,subUnitId:fe,primary:Re}):O.of(null)})):O.EMPTY)).subscribe($=>{var me,fe,be,Re,ot,st;if($){const{unitId:Ct,subUnitId:Pr,primary:Zc}=$;if(d.getRule(Ct,Pr)){const Qc=!((fe=(me=S.getPermissionPoint(new m.WorksheetEditPermission(Ct,Pr).id))==null?void 0:me.value)==null||fe),Jc=!((Re=(be=S.getPermissionPoint(new m.WorksheetViewPermission(Ct,Pr).id))==null?void 0:be.value)==null||Re);C({viewDisable:Jc,editDisable:Qc});return}const{actualRow:Kc,actualColumn:qc}=Zc,Gt=f.getCellInfo(Ct,Pr,Kc,qc);C({editDisable:!((ot=Gt==null?void 0:Gt[m.UnitAction.Edit])==null||ot),viewDisable:!((st=Gt==null?void 0:Gt[m.UnitAction.View])==null||st)})}else C({viewDisable:!1,editDisable:!1})});return()=>{oe.unsubscribe()}},[P]),H.useEffect(()=>{const oe=c.visible$.subscribe($=>{r($.visible)});return()=>oe.unsubscribe()},[c.visible$]),H.useEffect(()=>{const oe=c.currentEditCellState$.subscribe($=>{var me,fe,be;(be=(fe=(me=$==null?void 0:$.documentLayoutObject.documentModel)==null?void 0:me.getBody())==null?void 0:fe.customBlocks)!=null&&be.length?R(!0):R(!1)});return()=>oe.unsubscribe()},[c.currentEditCellState$]),H.useEffect(()=>{const oe=()=>{if(!W.current)return;const $=W.current.getBoundingClientRect();l.setPosition($)};if(W.current){oe();const $=new ResizeObserver(oe);return $.observe(W.current),()=>$.disconnect()}},[l]);function U(){s(o===0?1:0),setTimeout(()=>{l.handleFoldBtnClick(o===1)},150)}function L(){c.isVisible().visible&&p.executeCommand(Se.id,{visible:!1,eventType:T.DeviceInputEventType.Keyboard,keycode:_.KeyCode.ESC,unitId:M.unitId})}function j(){c.isVisible().visible&&p.executeCommand(Se.id,{visible:!1,eventType:T.DeviceInputEventType.PointerDown,unitId:M.unitId})}function B(){l.handleFxBtnClick(!0)}const{viewDisable:F,editDisable:X}=v,K=X||b,te=H.useRef(!1),Q=()=>{try{c.isVisible().visible===!1&&p.syncExecuteCommand(Se.id,{visible:!0,eventType:T.DeviceInputEventType.PointerDown,unitId:M.unitId}),D.setContextValue(a.FOCUSING_FX_BAR_EDITOR,!0)}catch(oe){throw te.current=!0,oe}},se=oe=>{te.current&&setTimeout(()=>{V.blur(!0)},30),te.current=!1},Y=((ie=(ce=(ne=M==null?void 0:M.documentLayoutObject.documentModel)==null?void 0:ne.getDrawingsOrder())==null?void 0:ce.length)!=null?ie:0)>0||F;return I.jsxs("div",{"data-u-comp":"formula-bar",className:z.clsx("univer-box-border univer-flex univer-h-7 univer-bg-white univer-transition-[height] univer-ease-linear dark:!univer-bg-gray-900",z.borderBottomClassName,i),style:{height:o===0?"28px":"82px",pointerEvents:X?"none":"auto"},children:[I.jsx("div",{className:"univer-relative univer-box-border univer-h-full univer-w-[100px]",children:I.jsx(Wu,{disable:e!=null?e:X})}),I.jsxs("div",{className:"univer-flex univer-h-full univer-w-full",children:[I.jsx("div",{className:z.clsx("univer-py-1.5",{"univer-cursor-not-allowed univer-text-gray-200":K}),children:I.jsxs("div",{className:z.clsx("univer-relative univer-box-border univer-flex univer-h-full univer-w-20 univer-items-center univer-justify-center univer-text-xs",z.borderRightClassName),children:[I.jsx("span",{className:z.clsx("univer-flex univer-items-center univer-justify-center univer-rounded univer-p-1 univer-text-base dark:!univer-text-white",{"univer-cursor-pointer univer-text-green-600 dark:!univer-text-green-400 dark:hover:!univer-bg-gray-700 hover:univer-bg-gray-100":t}),onClick:L,children:I.jsx(Ha,{})}),I.jsx("span",{className:z.clsx("univer-flex univer-items-center univer-justify-center univer-rounded univer-p-1 univer-text-base dark:!univer-text-white",{"univer-cursor-pointer univer-text-red-600 dark:!univer-text-red-400 dark:hover:!univer-bg-gray-700 hover:univer-bg-gray-100":t}),onClick:j,children:I.jsx(Ut,{})}),I.jsx("span",{className:z.clsx("univer-flex univer-cursor-pointer univer-items-center univer-justify-center univer-rounded univer-p-1 univer-text-base dark:!univer-text-white dark:hover:!univer-bg-gray-700 hover:univer-bg-gray-100"),onClick:B,children:I.jsx(La,{})})]})}),I.jsxs("div",{className:"univer-flex univer-w-full univer-flex-1 univer-overflow-hidden univer-pl-3",children:[I.jsxs("div",{className:"univer-relative univer-flex-1",onPointerDown:Q,onPointerUp:se,ref:W,style:{pointerEvents:Y?"none":"auto"},children:[A&&I.jsx(A,{className:"univer-relative univer-h-full univer-w-full univer-break-words univer-outline-none [&>div]:univer-ring-transparent",disableSelectionOnClick:!0,editorId:a.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,initValue:"",onChange:()=>{},isFocus:N,unitId:M==null?void 0:M.unitId,subUnitId:M==null?void 0:M.sheetId,isSupportAcrossSheet:!0,resetSelectionOnBlur:!1,isSingle:!1,keyboardEventConfig:x,onFormulaSelectingChange:(oe,$)=>{y.current=oe,$&&(oe?c.enableForceKeepVisible():c.disableForceKeepVisible())},autoScrollbar:!1,disableContextMenu:!1}),Y?I.jsx("div",{className:"univer-pointer-events-none univer-relative univer-left-0 univer-top-0 univer-z-[100] univer-h-full univer-w-full univer-cursor-not-allowed univer-bg-white"}):null]}),I.jsx("div",{className:z.clsx("univer-flex univer-h-full univer-w-5 univer-cursor-pointer univer-items-center univer-justify-center univer-text-xs univer-text-gray-700 dark:!univer-text-gray-200",{"univer-cursor-not-allowed univer-text-gray-200 dark:!univer-text-gray-700":X}),onClick:U,children:o===0?I.jsx(Mo,{}):I.jsx(Mo,{style:{transform:"rotateZ(180deg)"}})})]})]}),I.jsx(_.ComponentContainer,{components:k},"formula-aux")]})}const Lt=a.createIdentifier("univer.sheetbar-service");class Za extends a.Disposable{constructor(){super();w(this,"renameId$");w(this,"removeId$");w(this,"scroll$");w(this,"scrollX$");w(this,"addSheet$");w(this,"_renameId$");w(this,"_removeId$");w(this,"_scroll$");w(this,"_scrollX$");w(this,"_addSheet$");w(this,"_currentHandler",null);this._renameId$=new O.Subject,this.renameId$=this._renameId$.asObservable(),this._removeId$=new O.Subject,this.removeId$=this._removeId$.asObservable(),this._scroll$=new O.Subject,this.scroll$=this._scroll$.asObservable(),this._scrollX$=new O.Subject,this.scrollX$=this._scrollX$.asObservable(),this._addSheet$=new O.Subject,this.addSheet$=this._addSheet$.asObservable()}setRenameId(e){this._renameId$.next(e)}setRemoveId(e){this._removeId$.next(e)}setScroll(e){this._scroll$.next(e)}setScrollX(e){this._scrollX$.next(e)}setAddSheet(e){this._addSheet$.next(e)}triggerSheetBarMenu(){var e;(e=this._currentHandler)==null||e.handleSheetBarMenu()}registerSheetBarMenuHandler(e){if(this._currentHandler)throw new Error("There is already a context menu handler!");return this._currentHandler=e,a.toDisposable(()=>{this._currentHandler=null})}}function Lr(n){const{children:i,className:e,style:t,disabled:r=!1,onClick:o,...s}=n,l=c=>{if(r){c.preventDefault();return}o&&o(c)};return I.jsx(z.Button,{"data-u-comp":"sheet-bar-append-button",size:"small",disabled:r,onClick:l,style:t,...s,variant:"text",className:e,children:i})}function Uu(){const[n,i]=H.useState([]),[e,t]=H.useState(!1),r=_.useDependency(a.IUniverInstanceService),o=_.useDependency(a.ICommandService),s=_.useDependency(Lt),l=_.useDependency(m.WorksheetProtectionRuleModel),c=_.useObservable(()=>r.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET),null,!1,[]),d=p=>{const{sheetId:v}=p;!v||!c||(p.hidden?o.executeCommand(m.SetWorksheetShowCommand.id,{unitId:c.getUnitId(),subUnitId:v,value:v}):p.selected||o.executeCommand(m.SetWorksheetActivateCommand.id,{unitId:c.getUnitId(),subUnitId:v}),t(!1))},u=H.useCallback(()=>{if(!c)return;const p=c.getSheets(),v=c.getActiveSheet(),C=p.map((b,R)=>({label:b.getName(),index:`${R}`,sheetId:b.getSheetId(),hidden:b.isSheetHidden()===a.BooleanNumber.TRUE,selected:v===b}));i(C)},[c,l]),h=H.useCallback(()=>o.onCommandExecuted(p=>{switch(p.id){case m.SetWorksheetHideMutation.id:case m.RemoveSheetMutation.id:case m.SetWorksheetNameMutation.id:case m.InsertSheetMutation.id:case m.SetWorksheetOrderMutation.id:case m.SetWorksheetActiveOperation.id:u();break}}),[o,u]);function g(){t(!0)}const S=p=>{t(p)};H.useEffect(()=>{u();const p=new a.DisposableCollection;return p.add(h()),p.add(s.registerSheetBarMenuHandler({handleSheetBarMenu:g})),()=>p.dispose()},[h,s,u,c]);const f=H.useMemo(()=>n.map(p=>({type:"item",children:I.jsxs("div",{className:"univer-relative univer-box-border univer-pl-6",children:[(p.selected||p.hidden)&&I.jsxs("span",{className:"univer-absolute univer-left-1 univer-top-0.5",children:[p.selected&&I.jsx(Ut,{className:"univer-size-4 univer-text-primary-600"}),p.hidden&&I.jsx(Ua,{className:"univer-size-4 univer-text-gray-400"})]}),I.jsx("span",{className:z.clsx({"univer-text-primary-600":p.selected}),children:p.label})]}),onSelect:()=>{d(p)}})),[n]);return I.jsx(z.DropdownMenu,{align:"start",items:f,open:e,onOpenChange:S,children:I.jsx("div",{children:I.jsx(Lr,{children:I.jsx(Wa,{})})})})}function Lu(n){const{sheetId:i,label:e,color:t,selected:r,menuOverlay:o}=n,[s,l]=H.useState(r),c=_.useDependency(a.ThemeService);H.useEffect(()=>{l(r)},[r]);const d=u=>{const h=c.getColorFromTheme("gray.900"),g=c.getColorFromTheme("white");return new a.ColorKit(u).isDark()?g:h};return I.jsx("div",{"data-u-comp":"slide-tab-item","data-id":i,className:z.clsx("univer-mx-1 univer-box-border univer-flex univer-flex-grow univer-cursor-pointer univer-select-none univer-flex-row univer-items-center univer-rounded univer-text-xs univer-text-gray-900 univer-transition-colors dark:!univer-text-white",s?`
|
|
2
2
|
univer-justify-center univer-bg-white univer-font-bold univer-text-primary-700 univer-shadow-sm
|
|
3
3
|
univer-transition-shadow
|
|
4
4
|
dark:!univer-bg-gray-900
|