@univerjs/sheets-drawing-ui 0.5.0-nightly.202411291606 → 0.5.1-nightly.202411301606
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/index.js +2 -2
- package/lib/es/index.js +1846 -1551
- package/lib/types/commands/commands/insert-image.command.d.ts +1 -0
- package/lib/types/controllers/sheet-cell-image-autofill.controller.d.ts +8 -0
- package/lib/types/controllers/sheet-cell-image.controller.d.ts +20 -0
- package/lib/types/controllers/sheet-celll-image-hover.controller.d.ts +15 -0
- package/lib/types/controllers/sheet-drawing-update.controller.d.ts +11 -4
- package/lib/types/views/menu/image.menu.d.ts +1 -0
- package/lib/umd/index.js +2 -2
- package/package.json +15 -13
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Disposable, Injector } from '@univerjs/core';
|
|
2
|
+
import { IAutoFillService } from '@univerjs/sheets-ui';
|
|
3
|
+
export declare class SheetCellImageAutofillController extends Disposable {
|
|
4
|
+
private readonly _autoFillService;
|
|
5
|
+
private readonly _injector;
|
|
6
|
+
constructor(_autoFillService: IAutoFillService, _injector: Injector);
|
|
7
|
+
private _initAutoFillHooks;
|
|
8
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ICellData, Nullable, Disposable, ICommandService, Injector, IUniverInstanceService } from '@univerjs/core';
|
|
2
|
+
import { ISheetLocationBase, SheetInterceptorService } from '@univerjs/sheets';
|
|
3
|
+
import { DocDrawingController } from '@univerjs/docs-drawing';
|
|
4
|
+
import { IDrawingManagerService } from '@univerjs/drawing';
|
|
5
|
+
import { IEditorBridgeService } from '@univerjs/sheets-ui';
|
|
6
|
+
export declare function resizeImageByCell(injector: Injector, location: ISheetLocationBase, cell: Nullable<ICellData>): boolean;
|
|
7
|
+
export declare class SheetCellImageController extends Disposable {
|
|
8
|
+
private readonly _commandService;
|
|
9
|
+
private readonly _sheetInterceptorService;
|
|
10
|
+
private readonly _univerInstanceService;
|
|
11
|
+
private readonly _injector;
|
|
12
|
+
private readonly _drawingManagerService;
|
|
13
|
+
private readonly _docDrawingController;
|
|
14
|
+
private readonly _editorBridgeService;
|
|
15
|
+
constructor(_commandService: ICommandService, _sheetInterceptorService: SheetInterceptorService, _univerInstanceService: IUniverInstanceService, _injector: Injector, _drawingManagerService: IDrawingManagerService, _docDrawingController: DocDrawingController, _editorBridgeService: IEditorBridgeService);
|
|
16
|
+
private _initHandleResize;
|
|
17
|
+
private _handleInitEditor;
|
|
18
|
+
private _handleWriteCell;
|
|
19
|
+
private _initCellContentInterceptor;
|
|
20
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Disposable } from '@univerjs/core';
|
|
2
|
+
import { DrawingRenderService } from '@univerjs/drawing-ui';
|
|
3
|
+
import { IRenderManagerService } from '@univerjs/engine-render';
|
|
4
|
+
import { SheetsSelectionsService } from '@univerjs/sheets';
|
|
5
|
+
import { HoverManagerService } from '@univerjs/sheets-ui';
|
|
6
|
+
export declare class SheetCellImageHoverController extends Disposable {
|
|
7
|
+
private _hoverManagerService;
|
|
8
|
+
private _renderManagerService;
|
|
9
|
+
private _selectionsService;
|
|
10
|
+
private _drawingRenderService;
|
|
11
|
+
private _isSetCursor;
|
|
12
|
+
constructor(_hoverManagerService: HoverManagerService, _renderManagerService: IRenderManagerService, _selectionsService: SheetsSelectionsService, _drawingRenderService: DrawingRenderService);
|
|
13
|
+
private _initHover;
|
|
14
|
+
private _initImageClick;
|
|
15
|
+
}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
import { Workbook, Disposable, ICommandService, IContextService, LocaleService } from '@univerjs/core';
|
|
2
|
-
import {
|
|
1
|
+
import { IAccessor, Workbook, Disposable, ICommandService, IContextService, Injector, LocaleService } from '@univerjs/core';
|
|
2
|
+
import { ISheetLocationBase, SheetsSelectionsService } from '@univerjs/sheets';
|
|
3
3
|
import { IDrawingManagerService, IImageIoService } from '@univerjs/drawing';
|
|
4
|
-
import {
|
|
4
|
+
import { IRenderContext, IRenderModule } from '@univerjs/engine-render';
|
|
5
5
|
import { ISheetDrawingService } from '@univerjs/sheets-drawing';
|
|
6
6
|
import { ISheetSelectionRenderService, SheetSkeletonManagerService } from '@univerjs/sheets-ui';
|
|
7
7
|
import { ILocalFileService, IMessageService } from '@univerjs/ui';
|
|
8
|
+
export declare function getDrawingSizeByCell(accessor: IAccessor, location: ISheetLocationBase, originImageWidth: number, originImageHeight: number, angle: number): false | {
|
|
9
|
+
width: number;
|
|
10
|
+
height: number;
|
|
11
|
+
};
|
|
8
12
|
export declare class SheetDrawingUpdateController extends Disposable implements IRenderModule {
|
|
9
13
|
private readonly _context;
|
|
10
14
|
private readonly _skeletonManagerService;
|
|
@@ -17,10 +21,13 @@ export declare class SheetDrawingUpdateController extends Disposable implements
|
|
|
17
21
|
private readonly _contextService;
|
|
18
22
|
private readonly _messageService;
|
|
19
23
|
private readonly _localeService;
|
|
24
|
+
private readonly _injector;
|
|
20
25
|
private readonly _workbookSelections;
|
|
21
|
-
constructor(_context: IRenderContext<Workbook>, _skeletonManagerService: SheetSkeletonManagerService, _commandService: ICommandService, _selectionRenderService: ISheetSelectionRenderService, _imageIoService: IImageIoService, _fileOpenerService: ILocalFileService, _sheetDrawingService: ISheetDrawingService, _drawingManagerService: IDrawingManagerService, _contextService: IContextService, _messageService: IMessageService, _localeService: LocaleService, selectionManagerService: SheetsSelectionsService);
|
|
26
|
+
constructor(_context: IRenderContext<Workbook>, _skeletonManagerService: SheetSkeletonManagerService, _commandService: ICommandService, _selectionRenderService: ISheetSelectionRenderService, _imageIoService: IImageIoService, _fileOpenerService: ILocalFileService, _sheetDrawingService: ISheetDrawingService, _drawingManagerService: IDrawingManagerService, _contextService: IContextService, _messageService: IMessageService, _localeService: LocaleService, selectionManagerService: SheetsSelectionsService, _injector: Injector);
|
|
22
27
|
insertFloatImage(): Promise<boolean>;
|
|
28
|
+
insertCellImage(): Promise<boolean>;
|
|
23
29
|
private _insertFloatImage;
|
|
30
|
+
private _insertCellImage;
|
|
24
31
|
private _getUnitInfo;
|
|
25
32
|
private _getImagePosition;
|
|
26
33
|
private _updateOrderListener;
|
|
@@ -4,3 +4,4 @@ export declare const IMAGE_UPLOAD_ICON = "addition-and-subtraction-single";
|
|
|
4
4
|
export declare const SHEETS_IMAGE_MENU_ID = "sheet.menu.image";
|
|
5
5
|
export declare function ImageMenuFactory(accessor: IAccessor): IMenuItem;
|
|
6
6
|
export declare function UploadFloatImageMenuFactory(_accessor: IAccessor): IMenuItem;
|
|
7
|
+
export declare function UploadCellImageMenuFactory(_accessor: IAccessor): IMenuItem;
|
package/lib/umd/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(b,d){typeof exports=="object"&&typeof module<"u"?d(exports,require("@univerjs/core"),require("@univerjs/drawing"),require("@univerjs/drawing-ui"),require("@univerjs/engine-render"),require("@univerjs/sheets-drawing"),require("@univerjs/sheets-ui"),require("@univerjs/ui"),require("rxjs"),require("@univerjs/sheets"),require("react"),require("@univerjs/docs-drawing"),require("@univerjs/docs-ui"),require("@univerjs/design")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/drawing","@univerjs/drawing-ui","@univerjs/engine-render","@univerjs/sheets-drawing","@univerjs/sheets-ui","@univerjs/ui","rxjs","@univerjs/sheets","react","@univerjs/docs-drawing","@univerjs/docs-ui","@univerjs/design"],d):(b=typeof globalThis<"u"?globalThis:b||self,d(b.UniverSheetsDrawingUi={},b.UniverCore,b.UniverDrawing,b.UniverDrawingUi,b.UniverEngineRender,b.UniverSheetsDrawing,b.UniverSheetsUi,b.UniverUi,b.rxjs,b.UniverSheets,b.React,b.UniverDocsDrawing,b.UniverDocsUi,b.UniverDesign))})(this,function(b,d,P,q,U,p,N,k,W,_,x,st,Ve,J){"use strict";var Mn=Object.defineProperty;var Dn=(b,d,P)=>d in b?Mn(b,d,{enumerable:!0,configurable:!0,writable:!0,value:P}):b[d]=P;var Y=(b,d,P)=>Dn(b,typeof d!="symbol"?d+"":d,P);const ct="sheets-drawing-ui.config",dt={},G={id:"sheet.operation.clear-drawing-transformer",type:d.CommandType.MUTATION,handler:(i,r)=>{const n=i.get(U.IRenderManagerService);return r.forEach(e=>{var t,o;(o=(t=n.getRenderById(e))==null?void 0:t.scene.getTransformer())==null||o.debounceRefreshControls()}),!0}},oe={id:"sheet.command.remove-sheet-image",type:d.CommandType.COMMAND,handler:(i,r)=>{var M,y,T;const n=i.get(d.ICommandService),e=i.get(d.IUndoRedoService),t=i.get(_.SheetInterceptorService),o=i.get(p.ISheetDrawingService);if(!r)return!1;const{drawings:a}=r,c=[];a.forEach(I=>{const{unitId:D}=I;c.push(D)});const l=o.getBatchRemoveOp(a),{unitId:h,subUnitId:u,undo:s,redo:g,objects:m}=l,f=t.onCommandExecute({id:oe.id,params:r}),S={id:p.SetDrawingApplyMutation.id,params:{unitId:h,subUnitId:u,op:g,objects:m,type:p.DrawingApplyType.REMOVE}},v={id:p.SetDrawingApplyMutation.id,params:{unitId:h,subUnitId:u,op:s,objects:m,type:p.DrawingApplyType.INSERT}};return d.sequenceExecute([...(M=f.preRedos)!=null?M:[],S,...f.redos],n)?(e.pushUndoRedo({unitID:h,undoMutations:[...(y=f.preUndos)!=null?y:[],v,...f.undos,{id:G.id,params:c}],redoMutations:[...(T=f.preRedos)!=null?T:[],S,...f.redos,{id:G.id,params:c}]}),!0):!1}},Ye="COMPONENT_SHEET_DRAWING_PANEL",Te={id:"sidebar.operation.sheet-image",type:d.CommandType.COMMAND,handler:async(i,r)=>{const n=i.get(k.ISidebarService),e=i.get(d.LocaleService),t=i.get(d.IUniverInstanceService),o=i.get(P.IDrawingManagerService);if(!_.getSheetCommandTarget(t))return!1;switch(r.value){case"open":n.open({header:{title:e.t("sheetImage.panel.title")},children:{label:Ye},onClose:()=>{o.focusDrawing(null)},width:360});break;case"close":default:n.close();break}return!0}},be={id:"sheet.operation.edit-sheet-image",type:d.CommandType.OPERATION,handler:(i,r)=>{const n=i.get(P.IDrawingManagerService),e=i.get(d.ICommandService);return r==null?!1:(n.focusDrawing([r]),e.executeCommand(Te.id,{value:"open"}),!0)}};var Ee={exports:{}},ae={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.min.js
|
|
4
4
|
*
|
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var Be;function Qe(){if(Be)return oe;Be=1;var i=H,r=Symbol.for("react.element"),n=Symbol.for("react.fragment"),e=Object.prototype.hasOwnProperty,t=i.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,o={key:!0,ref:!0,__self:!0,__source:!0};function a(c,d,p){var l,s={},u=null,m=null;p!==void 0&&(u=""+p),d.key!==void 0&&(u=""+d.key),d.ref!==void 0&&(m=d.ref);for(l in d)e.call(d,l)&&!o.hasOwnProperty(l)&&(s[l]=d[l]);if(c&&c.defaultProps)for(l in d=c.defaultProps,d)s[l]===void 0&&(s[l]=d[l]);return{$$typeof:r,type:c,key:u,ref:m,props:s,_owner:t.current}}return oe.Fragment=n,oe.jsx=a,oe.jsxs=a,oe}var Ge;function et(){return Ge||(Ge=1,Me.exports=Qe()),Me.exports}var $=et();const le={uploadLoading:"univer-upload-loading",uploadLoadingBody:"univer-upload-loading-body",uploadLoadingBodyAnimation:"univer-upload-loading-body-animation",univerCircleAnimation:"univer-UniverCircleAnimation",uploadLoadingBodyText:"univer-upload-loading-body-text"},tt=()=>{const i=g.useDependency(A.IImageIoService),r=g.useDependency(g.LocaleService),[n,e]=H.useState(0);return H.useEffect(()=>{const t=i.change$.subscribe(o=>{e(o)});return()=>{t.unsubscribe()}},[i]),$.jsx("div",{style:{display:n>0?"block":"none"},className:le.uploadLoading,children:$.jsxs("div",{className:le.uploadLoadingBody,children:[$.jsx("div",{className:le.uploadLoadingBodyAnimation}),$.jsx("div",{className:le.uploadLoadingBodyText,children:`${r.t("uploadLoading.loading")}: ${n}`})]})})};var nt=Object.defineProperty,rt=Object.getOwnPropertyDescriptor,it=(i,r,n,e)=>{for(var t=e>1?void 0:e?rt(r,n):r,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(r,n,t):a(t))||t);return e&&t&&nt(r,n,t),t},te=(i,r)=>(n,e)=>r(n,e,i);let ue=class extends g.RxDisposable{constructor(r,n,e,t,o,a,c){super();X(this,"_initImagePopupMenu",new Set);this._injector=r,this._drawingManagerService=n,this._canvasPopManagerService=e,this._renderManagerService=t,this._univerInstanceService=o,this._contextService=a,this._uiPartsService=c,this._init()}_init(){this._univerInstanceService.getCurrentTypeOfUnit$(g.UniverInstanceType.UNIVER_SHEET).pipe(W.takeUntil(this.dispose$)).subscribe(r=>this._create(r)),this._univerInstanceService.getTypeOfUnitDisposed$(g.UniverInstanceType.UNIVER_SHEET).pipe(W.takeUntil(this.dispose$)).subscribe(r=>this._dispose(r)),this._univerInstanceService.getAllUnitsForType(g.UniverInstanceType.UNIVER_SHEET).forEach(r=>this._create(r)),this._uiPartsService.registerComponent(F.BuiltInUIPart.CONTENT,()=>g.connectInjector(tt,this._injector))}_dispose(r){const n=r.getUnitId();this._renderManagerService.removeRender(n)}_create(r){if(!r)return;const n=r.getUnitId();this._renderManagerService.has(n)&&!this._initImagePopupMenu.has(n)&&(this._popupMenuListener(n),this._initImagePopupMenu.add(n))}_hasCropObject(r){const n=r.getAllObjectsByOrder();for(const e of n)if(e instanceof ee.ImageCropperObject)return!0;return!1}_popupMenuListener(r){var o;const n=(o=this._renderManagerService.getRenderById(r))==null?void 0:o.scene;if(!n)return;const e=n.getTransformerByCreate();if(!e)return;let t;this.disposeWithMe(g.toDisposable(e.createControl$.subscribe(()=>{if(this._contextService.setContextValue(g.FOCUSING_COMMON_DRAWINGS,!0),this._hasCropObject(n))return;const a=e.getSelectedObjectMap();if(a.size>1){t==null||t.dispose();return}const c=a.values().next().value;if(!c)return;const d=c.oKey,p=this._drawingManagerService.getDrawingOKey(d);if(!p)return;const{unitId:l,subUnitId:s,drawingId:u,drawingType:m}=p,f=p.data;if(f&&f.disablePopup)return;t==null||t.dispose();const S=this._canvasPopManagerService.getFeatureMenu(l,s,u,m);t=this.disposeWithMe(this._canvasPopManagerService.attachPopupToObject(c,{componentKey:ee.COMPONENT_IMAGE_POPUP_MENU,direction:"horizontal",offset:[2,0],extraProps:{menuItems:S||this._getImageMenuItems(l,s,u,m)}})),this._drawingManagerService.focusDrawing([{unitId:l,subUnitId:s,drawingId:u}])}))),this.disposeWithMe(e.clearControl$.subscribe(()=>{t==null||t.dispose(),this._contextService.setContextValue(g.FOCUSING_COMMON_DRAWINGS,!1),this._drawingManagerService.focusDrawing(null)})),this.disposeWithMe(e.changing$.subscribe(()=>{t==null||t.dispose()}))}_getImageMenuItems(r,n,e,t){return[{label:"image-popup.edit",index:0,commandId:ye.id,commandParams:{unitId:r,subUnitId:n,drawingId:e},disable:t===g.DrawingTypeEnum.DRAWING_DOM},{label:"image-popup.delete",index:1,commandId:ie.id,commandParams:{unitId:r,drawings:[{unitId:r,subUnitId:n,drawingId:e}]},disable:!1},{label:"image-popup.crop",index:2,commandId:ee.OpenImageCropOperation.id,commandParams:{unitId:r,subUnitId:n,drawingId:e},disable:t===g.DrawingTypeEnum.DRAWING_DOM},{label:"image-popup.reset",index:3,commandId:ee.ImageResetSizeOperation.id,commandParams:[{unitId:r,subUnitId:n,drawingId:e}],disable:t===g.DrawingTypeEnum.DRAWING_DOM}]}};ue=it([te(0,g.Inject(g.Injector)),te(1,A.IDrawingManagerService),te(2,g.Inject(j.SheetCanvasPopManagerService)),te(3,N.IRenderManagerService),te(4,g.IUniverInstanceService),te(5,g.IContextService),te(6,g.Inject(F.IUIPartsService))],ue);function Y(i,r,n){const{from:e,to:t,flipY:o=!1,flipX:a=!1,angle:c=0,skewX:d=0,skewY:p=0}=i,{column:l,columnOffset:s,row:u,rowOffset:m}=e,{column:f,columnOffset:S,row:w,rowOffset:y}=t,M=n.getCurrentSkeleton(),C=j.attachRangeWithCoord(M,{startColumn:l,endColumn:l,startRow:u,endRow:u});if(C==null)return;const T=j.attachRangeWithCoord(M,{startColumn:f,endColumn:f,startRow:w,endRow:w});if(T==null)return;const{startX:_,startY:D}=C,{startX:v,startY:P}=T;let b=N.precisionTo(_+s,1),L=N.precisionTo(D+m,1),U=N.precisionTo(v+S-b,1),O=N.precisionTo(P+y-L,1);C.startX===T.endX&&(U=0),C.startY===T.endY&&(O=0);const R=M.rowHeaderWidth+M.columnTotalWidth,B=M.columnHeaderHeight+M.rowTotalHeight;return b+U>R&&(b=R-U),L+O>B&&(L=B-O),{flipY:o,flipX:a,angle:c,skewX:d,skewY:p,left:b,top:L,width:U,height:O}}function k(i,r){const{left:n=0,top:e=0,width:t=0,height:o=0,flipY:a=!1,flipX:c=!1,angle:d=0,skewX:p=0,skewY:l=0}=i,s=r.getCellWithCoordByOffset(n,e);if(s==null)return;const u={column:s.actualColumn,columnOffset:N.precisionTo(n-s.startX,1),row:s.actualRow,rowOffset:N.precisionTo(e-s.startY,1)},m=r.getCellWithCoordByOffset(n+t,e+o);if(m==null)return;const f={column:m.actualColumn,columnOffset:N.precisionTo(n+t-m.startX,1),row:m.actualRow,rowOffset:N.precisionTo(e+o-m.startY,1)};return{flipY:a,flipX:c,angle:d,skewX:p,skewY:l,from:u,to:f}}var ot=Object.defineProperty,at=Object.getOwnPropertyDescriptor,st=(i,r,n,e)=>{for(var t=e>1?void 0:e?at(r,n):r,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(r,n,t):a(t))||t);return e&&t&&ot(r,n,t),t},me=(i,r)=>(n,e)=>r(n,e,i);let De=class extends g.Disposable{constructor(i,r,n,e,t){super(),this._context=i,this._sheetDrawingService=r,this._drawingManagerService=n,this._sheetSelectionRenderService=e,this._sheetSkeletonManagerService=t,this._init()}_init(){this._drawingInitializeListener()}_drawingInitializeListener(){this._sheetDrawingService.initializeNotification(this._context.unitId);const i=this._sheetDrawingService.getDrawingDataForUnit(this._context.unitId);for(const r in i){const n=i[r];for(const e in n.data){const t=n.data[e];t.transform=Y(t.sheetTransform,this._sheetSelectionRenderService,this._sheetSkeletonManagerService)}}this._drawingManagerService.registerDrawingData(this._context.unitId,this._sheetDrawingService.getDrawingDataForUnit(this._context.unitId)),this._drawingManagerService.initializeNotification(this._context.unitId)}};De=st([me(1,h.ISheetDrawingService),me(2,A.IDrawingManagerService),me(3,g.Inject(j.ISheetSelectionRenderService)),me(4,g.Inject(j.SheetSkeletonManagerService))],De);var ct=Object.defineProperty,dt=Object.getOwnPropertyDescriptor,lt=(i,r,n,e)=>{for(var t=e>1?void 0:e?dt(r,n):r,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(r,n,t):a(t))||t);return e&&t&&ct(r,n,t),t},Re=(i,r)=>(n,e)=>r(n,e,i);let ge=class extends g.Disposable{constructor(r,n,e){super();X(this,"_copyInfo");this._sheetClipboardService=r,this._renderManagerService=n,this._sheetDrawingService=e,this._initCopyPaste()}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:"SHEET_IMAGE_UI_PLUGIN",onBeforeCopy:(r,n,e)=>this._collect(r,n,e),onPasteCells:(r,n,e,t)=>{const{copyType:o=j.COPY_TYPE.COPY,pasteType:a}=t,{range:c}=r||{},{range:d,unitId:p,subUnitId:l}=n;return this._generateMutations(d,{copyType:o,pasteType:a,copyRange:c,unitId:p,subUnitId:l})},onPastePlainText:(r,n)=>({undos:[],redos:[]})})}_collect(r,n,e){var u;const t=(u=this._renderManagerService.getRenderById(r))==null?void 0:u.with(j.SheetSkeletonManagerService);if(!t)return;const o=t.attachRangeWithCoord(e);if(!o)return;const{startX:a,endX:c,startY:d,endY:p}=o,l=this._sheetDrawingService.getDrawingData(r,n),s=[];Object.keys(l).forEach(m=>{const f=l[m],{transform:S}=f;if(f.anchorType!==h.SheetDrawingAnchorType.Both||!S)return;const{left:w=0,top:y=0,width:M=0,height:C=0}=S,{drawingStartX:T,drawingEndX:_,drawingStartY:D,drawingEndY:v}={drawingStartX:w,drawingEndX:w+M,drawingStartY:y,drawingEndY:y+C};a<=T&&_<=c&&d<=D&&v<=p&&s.push(f)}),s.length&&(this._copyInfo={drawings:s,unitId:r,subUnitId:n})}_generateMutations(r,n){var b;if(!this._copyInfo)return{redos:[],undos:[]};if([j.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,j.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,j.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,j.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMULA].includes(n.pasteType))return{redos:[],undos:[]};const{copyRange:e}=n;if(!e)return{redos:[],undos:[]};const{drawings:t,unitId:o,subUnitId:a}=this._copyInfo,{ranges:[c,d],mapFunc:p}=j.virtualizeDiscreteRanges([e,r]),{row:l,col:s}=p(c.startRow,c.startColumn),{row:u,col:m}=p(d.startRow,d.startColumn),f=(b=this._renderManagerService.getRenderById(o))==null?void 0:b.with(j.SheetSkeletonManagerService);if(!f)return{redos:[],undos:[]};const S=f.attachRangeWithCoord({startRow:l,endRow:l,startColumn:s,endColumn:s}),w=f.attachRangeWithCoord({startRow:u,endRow:u,startColumn:m,endColumn:m});if(!S||!w)return{redos:[],undos:[]};const y=[],M=[],C=w.startX-S.startX,T=w.startY-S.startY,_=u-l,D=m-s,v=n.copyType===j.COPY_TYPE.CUT,{_sheetDrawingService:P}=this;return t.forEach(L=>{const{transform:U,sheetTransform:O}=L;if(!U)return;const R={...L,unitId:o,subUnitId:a,drawingId:v?L.drawingId:g.Tools.generateRandomId(),transform:{...U,left:U.left+C,top:U.top+T},sheetTransform:{to:{...O.to,row:O.to.row+_,column:O.to.column+D},from:{...O.from,row:O.from.row+_,column:O.from.column+D}}};if(v){const{undo:B,redo:V,objects:J}=P.getBatchUpdateOp([R]);y.push({id:h.SetDrawingApplyMutation.id,params:{unitId:o,subUnitId:a,type:h.DrawingApplyType.UPDATE,op:V,objects:J}}),M.push({id:h.SetDrawingApplyMutation.id,params:{unitId:o,subUnitId:a,type:h.DrawingApplyType.UPDATE,op:B,objects:J}})}else{const{undo:B,redo:V,objects:J}=P.getBatchAddOp([R]);y.push({id:h.SetDrawingApplyMutation.id,params:{op:V,unitId:o,subUnitId:a,objects:J,type:h.DrawingApplyType.INSERT}}),M.push({id:h.SetDrawingApplyMutation.id,params:{op:B,unitId:o,subUnitId:a,objects:J,type:h.DrawingApplyType.REMOVE}})}}),{redos:y,undos:M}}};ge=lt([Re(0,j.ISheetClipboardService),Re(1,N.IRenderManagerService),Re(2,h.ISheetDrawingService)],ge);var ut=Object.defineProperty,mt=Object.getOwnPropertyDescriptor,gt=(i,r,n,e)=>{for(var t=e>1?void 0:e?mt(r,n):r,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(r,n,t):a(t))||t);return e&&t&&ut(r,n,t),t},ae=(i,r)=>(n,e)=>r(n,e,i);let pe=class extends g.Disposable{constructor(i,r,n,e,t){super(),this._drawingManagerService=i,this._renderManagerService=r,this._permissionService=n,this._univerInstanceService=e,this._userManagerService=t,this._initDrawingVisible(),this._initDrawingEditable(),this._initViewPermissionChange(),this._initEditPermissionChange()}_initDrawingVisible(){const i=this._univerInstanceService.getCurrentTypeOfUnit$(g.UniverInstanceType.UNIVER_SHEET);this.disposeWithMe(W.combineLatest([i,this._userManagerService.currentUser$]).subscribe(([r,n])=>{if(!r){this._drawingManagerService.setDrawingVisible(!1);return}r.activeSheet$.subscribe(e=>{if(!e){this._drawingManagerService.setDrawingVisible(!1);return}const t=r.getUnitId(),o=e.getSheetId();if(this._permissionService.composePermission([new I.WorkbookViewPermission(t).id,new I.WorksheetViewPermission(t,o).id]).every(c=>c.value))this._drawingManagerService.setDrawingVisible(!0);else{this._drawingManagerService.setDrawingVisible(!1);const c=r.getUnitId(),d=e.getSheetId(),p=this._drawingManagerService.getDrawingData(c,d),l=Object.values(p),s=this._renderManagerService.getRenderById(c),u=s==null?void 0:s.scene;if(u==null)return;u.getAllObjectsByOrder().forEach(f=>{f.classType===N.RENDER_CLASS_TYPE.IMAGE&&l.some(S=>f.oKey.includes(S.drawingId))&&u.removeObject(f)})}})}))}_initDrawingEditable(){const i=this._univerInstanceService.getCurrentTypeOfUnit$(g.UniverInstanceType.UNIVER_SHEET);this.disposeWithMe(W.combineLatest([i,this._userManagerService.currentUser$]).subscribe(([r,n])=>{if(!r){this._drawingManagerService.setDrawingEditable(!1);return}r.activeSheet$.subscribe(e=>{if(!e){this._drawingManagerService.setDrawingEditable(!1);return}const t=r.getUnitId(),o=e.getSheetId();if(this._permissionService.composePermission([new I.WorkbookEditablePermission(t).id,new I.WorksheetEditPermission(t,o).id]).every(c=>c.value))this._drawingManagerService.setDrawingEditable(!0);else{this._drawingManagerService.setDrawingEditable(!1);const c=r.getUnitId(),d=e.getSheetId(),p=this._drawingManagerService.getDrawingData(c,d),l=Object.values(p),s=this._renderManagerService.getRenderById(c),u=s==null?void 0:s.scene;if(u==null)return;u.getAllObjectsByOrder().forEach(f=>{f.classType===N.RENDER_CLASS_TYPE.IMAGE&&l.some(S=>f.oKey.includes(S.drawingId))&&u.detachTransformerFrom(f)})}})}))}_initViewPermissionChange(){const i=this._univerInstanceService.getCurrentTypeOfUnit$(g.UniverInstanceType.UNIVER_SHEET);this.disposeWithMe(W.combineLatest([i,this._userManagerService.currentUser$]).subscribe(([r,n])=>{r&&r.activeSheet$.subscribe(e=>{var s;if(!e)return;const t=r.getUnitId(),o=e.getSheetId();let a=!0;const c=this._renderManagerService.getRenderById(t),d=c==null?void 0:c.scene;if(d==null)return;const p=d.getTransformerByCreate(),l=this._permissionService.composePermission$([new I.WorkbookViewPermission(t).id,new I.WorksheetViewPermission(t,o).id]).pipe(W.map(u=>u.every(m=>m.value)));l==null||l.pipe(W.filter(u=>u!==a),W.distinctUntilChanged()).subscribe({next:u=>{a=u,this._drawingManagerService.setDrawingVisible(u);const m=d.getAllObjectsByOrder(),f=this._drawingManagerService.getDrawingData(t,o),S=Object.values(f);u?this._drawingManagerService.addNotification(S):(m.forEach(w=>{w.classType===N.RENDER_CLASS_TYPE.IMAGE&&S.some(y=>w.oKey.includes(y.drawingId))&&d.removeObject(w)}),p.clearSelectedObjects())}}),(s=this._permissionService.getPermissionPoint$(new I.WorksheetViewPermission(t,o).id))==null||s.pipe(W.filter(u=>u.value!==a),W.distinctUntilChanged()).subscribe({complete:()=>{a=!0,this._drawingManagerService.setDrawingVisible(!0);const u=this._drawingManagerService.getDrawingData(t,o),m=Object.values(u);this._drawingManagerService.addNotification(m)}})})}))}_initEditPermissionChange(){const i=this._univerInstanceService.getCurrentTypeOfUnit$(g.UniverInstanceType.UNIVER_SHEET);this.disposeWithMe(W.combineLatest([i,this._userManagerService.currentUser$]).subscribe(([r,n])=>{r&&r.activeSheet$.subscribe(e=>{var s;if(!e)return;const t=r.getUnitId(),o=e.getSheetId();let a=!0;const c=this._renderManagerService.getRenderById(t),d=c==null?void 0:c.scene;if(d==null)return;const p=d.getTransformerByCreate(),l=this._permissionService.composePermission$([new I.WorkbookEditablePermission(t).id,new I.WorksheetEditPermission(t,o).id]).pipe(W.map(u=>u.every(m=>m.value)));l==null||l.pipe(W.filter(u=>u!==a),W.distinctUntilChanged()).subscribe({next:u=>{a=u,this._drawingManagerService.setDrawingEditable(u);const m=d.getAllObjectsByOrder(),f=this._drawingManagerService.getDrawingData(t,o),S=Object.values(f);u?(m.forEach(w=>{w.classType===N.RENDER_CLASS_TYPE.IMAGE&&S.some(y=>w.oKey.includes(y.drawingId))&&d.attachTransformerTo(w)}),this._drawingManagerService.addNotification(S)):(m.forEach(w=>{w.classType===N.RENDER_CLASS_TYPE.IMAGE&&S.some(y=>w.oKey.includes(y.drawingId))&&d.detachTransformerFrom(w)}),p.clearSelectedObjects())}}),(s=this._permissionService.getPermissionPoint$(new I.WorksheetEditPermission(t,o).id))==null||s.pipe(W.filter(u=>u.value!==a),W.distinctUntilChanged()).subscribe({complete:()=>{a=!0;const u=r.getUnitId(),m=e.getSheetId(),f=this._drawingManagerService.getDrawingData(u,m),S=Object.values(f),w=this._renderManagerService.getRenderById(u),y=w==null?void 0:w.scene;if(y==null)return;this._drawingManagerService.setDrawingEditable(!0),y.getAllObjectsByOrder().forEach(C=>{C.classType===N.RENDER_CLASS_TYPE.IMAGE&&S.some(T=>C.oKey.includes(T.drawingId))&&y.detachTransformerFrom(C)})}})})}))}};pe=gt([ae(0,A.IDrawingManagerService),ae(1,N.IRenderManagerService),ae(2,g.IPermissionService),ae(3,g.IUniverInstanceService),ae(4,g.Inject(g.UserManagerService))],pe);var pt=Object.defineProperty,ht=Object.getOwnPropertyDescriptor,ft=(i,r,n,e)=>{for(var t=e>1?void 0:e?ht(r,n):r,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(r,n,t):a(t))||t);return e&&t&&pt(r,n,t),t},he=(i,r)=>(n,e)=>r(n,e,i);let fe=class extends g.Disposable{constructor(i,r,n,e){super(),this._sheetPrintInterceptorService=i,this._drawingRenderService=r,this._drawingManagerService=n,this._renderManagerService=e,this._initPrinting()}_initPrinting(){this.disposeWithMe(this._sheetPrintInterceptorService.interceptor.intercept(this._sheetPrintInterceptorService.interceptor.getInterceptPoints().PRINTING_COMPONENT_COLLECT,{handler:(i,r,n)=>{const{unitId:e,scene:t,subUnitId:o}=r,a=this._drawingManagerService.getDrawingDataForUnit(e),c=a==null?void 0:a[o];return c&&c.order.forEach(d=>{this._drawingRenderService.renderDrawing(c.data[d],t)}),n()}})),this.disposeWithMe(this._sheetPrintInterceptorService.interceptor.intercept(this._sheetPrintInterceptorService.interceptor.getInterceptPoints().PRINTING_RANGE,{handler:(i,r,n)=>{const{unitId:e,subUnitId:t}=r,o=this._renderManagerService.getRenderById(e);if(!o)return n(i);const a=o.with(j.SheetSkeletonManagerService).getWorksheetSkeleton(t);if(!a)return n(i);const c=this._drawingManagerService.getDrawingDataForUnit(e),d=c==null?void 0:c[r.subUnitId];if(!d)return n(i);const{scaleX:p,scaleY:l}=o.scene,s=i?{...i}:{startColumn:0,endColumn:0,endRow:0,startRow:0},u=d.order.map(m=>d.data[m]).filter(m=>m.drawingType!==g.DrawingTypeEnum.DRAWING_DOM);return u.length?(u.forEach(m=>{if(!m.groupId&&m.transform&&g.Tools.isDefine(m.transform.left)&&g.Tools.isDefine(m.transform.top)&&g.Tools.isDefine(m.transform.width)&&g.Tools.isDefine(m.transform.height)){const f=a.skeleton.getCellIndexByOffset(m.transform.left,m.transform.top,p,l,{x:0,y:0}),S=a.skeleton.getCellIndexByOffset(m.transform.left+m.transform.width,m.transform.top+m.transform.height,p,l,{x:0,y:0});f.column<s.startColumn&&(s.startColumn=f.column),f.row<s.startRow&&(s.startRow=f.row),s.endRow<S.row&&(s.endRow=S.row),s.endColumn<S.column&&(s.endColumn=S.column)}}),n(s)):n(i)}}))}};fe=ft([he(0,g.Inject(j.SheetPrintInterceptorService)),he(1,g.Inject(ee.DrawingRenderService)),he(2,A.IDrawingManagerService),he(3,N.IRenderManagerService)],fe);var St=Object.defineProperty,wt=Object.getOwnPropertyDescriptor,vt=(i,r,n,e)=>{for(var t=e>1?void 0:e?wt(r,n):r,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(r,n,t):a(t))||t);return e&&t&&St(r,n,t),t},Z=(i,r)=>(n,e)=>r(n,e,i);const _t=[I.InsertRowCommand.id,I.InsertColCommand.id,I.RemoveRowCommand.id,I.RemoveColCommand.id,I.DeleteRangeMoveLeftCommand.id,I.DeleteRangeMoveUpCommand.id,I.InsertRangeMoveDownCommand.id,I.InsertRangeMoveRightCommand.id,I.DeltaRowHeightCommand.id,I.SetRowHeightCommand.id,I.DeltaColumnWidthCommand.id,I.SetColWidthCommand.id,I.SetRowHiddenCommand.id,I.SetSpecificRowsVisibleCommand.id,I.SetSpecificColsVisibleCommand.id,I.SetColHiddenCommand.id,I.MoveColsCommand.id,I.MoveRowsCommand.id,I.MoveRangeCommand.id],It=[I.SetRowVisibleMutation.id,I.SetRowHiddenMutation.id,I.SetColVisibleMutation.id,I.SetColHiddenMutation.id,I.SetWorksheetRowHeightMutation.id,I.SetWorksheetColWidthMutation.id];let Te=class extends g.Disposable{constructor(i,r,n,e,t,o,a,c,d){super(),this._context=i,this._renderManagerService=r,this._commandService=n,this._selectionRenderService=e,this._skeletonManagerService=t,this._sheetInterceptorService=o,this._sheetDrawingService=a,this._drawingManagerService=c,this._univerInstanceService=d,this._sheetInterceptorListener(),this._commandListener(),this._sheetRefreshListener()}_sheetInterceptorListener(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:i=>{if(!_t.includes(i.id))return{redos:[],undos:[]};if(i.params==null)return{redos:[],undos:[]};const r=i.id;if(r===I.InsertRowCommand.id)return this._moveRowInterceptor(i.params,"insert");if([I.MoveColsCommand.id,I.MoveRowsCommand.id,I.MoveRangeCommand.id].includes(r))return this._moveRangeInterceptor(i.params);if(r===I.InsertColCommand.id)return this._moveColInterceptor(i.params,"insert");if(r===I.RemoveRowCommand.id)return this._moveRowInterceptor(i.params,"remove");if(r===I.RemoveColCommand.id)return this._moveColInterceptor(i.params,"remove");if(r===I.DeleteRangeMoveLeftCommand.id){const{range:n}=i.params;return this._getRangeMoveUndo(n,0)}else if(r===I.DeleteRangeMoveUpCommand.id){const{range:n}=i.params;return this._getRangeMoveUndo(n,1)}else if(r===I.InsertRangeMoveDownCommand.id){const{range:n}=i.params;return this._getRangeMoveUndo(n,2)}else if(r===I.InsertRangeMoveRightCommand.id){const{range:n}=i.params;return this._getRangeMoveUndo(n,3)}else if(r===I.SetRowHiddenCommand.id||r===I.SetSpecificRowsVisibleCommand.id){const n=i.params,{unitId:e,subUnitId:t,ranges:o}=n;return this._getDrawingUndoForRowVisible(e,t,o)}else if(r===I.SetSpecificColsVisibleCommand.id||r===I.SetColHiddenCommand.id){const n=i.params,{unitId:e,subUnitId:t,ranges:o}=n;return this._getDrawingUndoForColVisible(e,t,o)}else if(r===I.DeltaRowHeightCommand.id||r===I.SetRowHeightCommand.id||r===I.DeltaColumnWidthCommand.id||r===I.SetColWidthCommand.id){const n=i.params,{unitId:e,subUnitId:t,ranges:o}=n,a=r===I.DeltaRowHeightCommand.id||r===I.SetRowHeightCommand.id;return this._getDrawingUndoForRowAndColSize(e,t,o,a)}return{redos:[],undos:[]}}}))}_getRangeMoveUndo(i,r){const n=I.getSheetCommandTarget(this._univerInstanceService);if(n==null)return{redos:[],undos:[]};const e=n.unitId,t=n.subUnitId,o=[],a=[],c=this._sheetDrawingService.getDrawingData(e,t),d=[],p=[];if(Object.keys(c).forEach(l=>{const s=c[l],{updateDrawings:u,deleteDrawings:m}=this._getUpdateOrDeleteDrawings(i,r,s);d.push(...u),p.push(...m)}),d.length===0&&p.length===0)return{redos:[],undos:[]};if(d.length>0){const l=this._sheetDrawingService.getBatchUpdateOp(d),{undo:s,redo:u,objects:m}=l;o.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:u,objects:m,type:h.DrawingApplyType.UPDATE}}),a.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:s,objects:m,type:h.DrawingApplyType.UPDATE}})}if(p.length>0){const l=this._sheetDrawingService.getBatchRemoveOp(p),s=l.undo,u=l.redo,m=l.objects;o.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:u,objects:m,type:h.DrawingApplyType.REMOVE}}),a.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:s,objects:m,type:h.DrawingApplyType.INSERT}})}return o.push({id:G.id,params:[e]}),a.push({id:G.id,params:[e]}),{redos:o,undos:a}}_getUpdateOrDeleteDrawings(i,r,n){const e=[],t=[],{sheetTransform:o,anchorType:a=h.SheetDrawingAnchorType.Position,transform:c,unitId:d,subUnitId:p,drawingId:l}=n,{from:s,to:u}=o,{row:m,column:f}=s,{row:S,column:w}=u;if(o==null||c==null)return{updateDrawings:e,deleteDrawings:t};const{startRow:y,endRow:M,startColumn:C,endColumn:T}=i;let _=null,D=null;if(r===0&&m>=y&&S<=M)if(f>=C&&w<=T)t.push({unitId:d,subUnitId:p,drawingId:l});else{const v=this._shrinkCol(o,c,C,T,a);_=v==null?void 0:v.newSheetTransform,D=v==null?void 0:v.newTransform}else if(r===1&&f>=C&&w<=T)if(m>=y&&S<=M)t.push({unitId:d,subUnitId:p,drawingId:l});else{const v=this._shrinkRow(o,c,y,M,a);_=v==null?void 0:v.newSheetTransform,D=v==null?void 0:v.newTransform}else if(r===2){const v=this._expandRow(o,c,y,M,a);_=v==null?void 0:v.newSheetTransform,D=v==null?void 0:v.newTransform}else if(r===3){const v=this._expandCol(o,c,C,T,a);_=v==null?void 0:v.newSheetTransform,D=v==null?void 0:v.newTransform}if(_!=null&&D!=null){const v=Y(_,this._selectionRenderService,this._skeletonManagerService);e.push({...n,sheetTransform:_,transform:v})}return{updateDrawings:e,deleteDrawings:t}}_remainDrawingSize(i,r,n){const e=k({...i},this._selectionRenderService);e!=null&&r.push({...n,sheetTransform:e})}_getDrawingUndoForColVisible(i,r,n){const e=this._drawingManagerService.getDrawingData(i,r),t=[],o=[];if(Object.keys(e).forEach(l=>{const s=e[l],{sheetTransform:u,transform:m,anchorType:f=h.SheetDrawingAnchorType.Position}=s;if(f===h.SheetDrawingAnchorType.None)this._remainDrawingSize(m,t,s);else{const{from:S,to:w}=u,{row:y,column:M}=S,{row:C,column:T}=w;for(let _=0;_<n.length;_++){const D=n[_],{startRow:v,endRow:P,startColumn:b,endColumn:L}=D;if(T<b)continue;if(f===h.SheetDrawingAnchorType.Position){let R=null,B=null;if(M>=b&&M<=L){const V=this._skeletonManagerService.attachRangeWithCoord({startColumn:M,endColumn:L,startRow:S.row,endRow:w.row});if(V==null)return;B={...m,left:V.startX}}if(B!=null&&(R=k(B,this._selectionRenderService),R!=null&&B!=null)){t.push({...s,sheetTransform:R,transform:B});break}this._remainDrawingSize(m,t,s);continue}if(M>=b&&T<=L)continue;let U=null,O=null;if(M>=b&&M<=L){const R=this._skeletonManagerService.attachRangeWithCoord({startColumn:M,endColumn:L,startRow:S.row,endRow:w.row});if(R==null)return;O={...m,left:(R==null?void 0:R.startX)||0,width:((m==null?void 0:m.width)||0)-R.endX+R.startX}}else if(T>=b&&T<=L){const R=this._skeletonManagerService.attachRangeWithCoord({startColumn:b,endColumn:T,startRow:S.row,endRow:w.row});if(R==null)return;O={...m,left:R.startX-((m==null?void 0:m.width)||0)}}else{const R=this._skeletonManagerService.attachRangeWithCoord({startColumn:b,endColumn:L,startRow:S.row,endRow:w.row});if(R==null)return;if(O={...m,width:((m==null?void 0:m.width)||0)-R.endX+R.startX},U=k(O,this._selectionRenderService),U!=null&&O!=null){o.push({...s,sheetTransform:U,transform:O});break}}if(O!=null&&(U=k(O,this._selectionRenderService)),O!=null&&U!=null){t.push({...s,sheetTransform:U,transform:O});break}else this._remainDrawingSize(m,t,s)}}}),t.length===0&&o.length===0)return{redos:[],undos:[]};const{redos:a,undos:c}=this._createUndoAndRedoMutation(i,r,t),d=[],p=[];if(o.length>0){const{redos:l,undos:s}=this._createUndoAndRedoMutation(i,r,o);d.push(...l),p.push(...s)}return{redos:a,undos:c,preRedos:d,preUndos:p}}_createUndoAndRedoMutation(i,r,n){const e=this._sheetDrawingService.getBatchUpdateOp(n),{undo:t,redo:o,objects:a}=e,c=[{id:h.SetDrawingApplyMutation.id,params:{unitId:i,subUnitId:r,op:o,objects:a,type:h.DrawingApplyType.UPDATE}},{id:G.id,params:[i]}],d=[{id:h.SetDrawingApplyMutation.id,params:{unitId:i,subUnitId:r,op:t,objects:a,type:h.DrawingApplyType.UPDATE}},{id:G.id,params:[i]}];return{redos:c,undos:d}}_getDrawingUndoForRowVisible(i,r,n){const e=this._drawingManagerService.getDrawingData(i,r),t=[],o=[];if(Object.keys(e).forEach(l=>{const s=e[l],{sheetTransform:u,transform:m,anchorType:f=h.SheetDrawingAnchorType.Position}=s;if(f===h.SheetDrawingAnchorType.None)this._remainDrawingSize(m,t,s);else{const{from:S,to:w}=u,{row:y,column:M}=S,{row:C,column:T}=w;for(let _=0;_<n.length;_++){const D=n[_],{startRow:v,endRow:P,startColumn:b,endColumn:L}=D;if(C<v)continue;if(f===h.SheetDrawingAnchorType.Position){let R=null,B=null;if(y>=v&&y<=P){const V=this._skeletonManagerService.attachRangeWithCoord({startColumn:S.column,endColumn:w.column,startRow:y,endRow:P});if(V==null)return;B={...m,top:V.startY}}if(B!=null&&(R=k(B,this._selectionRenderService),R!=null&&B!=null)){t.push({...s,sheetTransform:R,transform:B});break}this._remainDrawingSize(m,t,s);continue}if(y>=v&&C<=P)continue;let U=null,O=null;if(y>=v&&y<=P){const R=this._skeletonManagerService.attachRangeWithCoord({startColumn:S.column,endColumn:w.column,startRow:y,endRow:P});if(R==null)return;O={...m,top:(R==null?void 0:R.startY)||0,height:((m==null?void 0:m.height)||0)-R.endY+R.startY}}else if(C>=v&&C<=P){const R=this._skeletonManagerService.attachRangeWithCoord({startColumn:S.column,endColumn:w.column,startRow:v,endRow:C});if(R==null)return;O={...m,top:R.startY-((m==null?void 0:m.height)||0)}}else{const R=this._skeletonManagerService.attachRangeWithCoord({startColumn:S.column,endColumn:w.column,startRow:v,endRow:P});if(R==null)return;if(O={...m,height:((m==null?void 0:m.height)||0)-R.endY+R.startY},U=k(O,this._selectionRenderService),U!=null&&O!=null){o.push({...s,sheetTransform:U,transform:O});break}}if(O!=null&&(U=k(O,this._selectionRenderService)),O!=null&&U!=null){t.push({...s,sheetTransform:U,transform:O});break}else this._remainDrawingSize(m,t,s)}}}),t.length===0&&o.length===0)return{redos:[],undos:[]};const{redos:a,undos:c}=this._createUndoAndRedoMutation(i,r,t),d=[],p=[];if(o.length>0){const{redos:l,undos:s}=this._createUndoAndRedoMutation(i,r,o);d.push(...l),p.push(...s)}return{redos:a,undos:c,preRedos:d,preUndos:p}}_getDrawingUndoForRowAndColSize(i,r,n,e){const t=this._drawingManagerService.getDrawingData(i,r),o=[];return Object.keys(t).forEach(a=>{const c=t[a],{sheetTransform:d,transform:p,anchorType:l=h.SheetDrawingAnchorType.Position}=c;if(l===h.SheetDrawingAnchorType.None)this._remainDrawingSize(p,o,c);else{const{from:s,to:u}=d,{row:m,column:f}=s,{row:S,column:w}=u;for(let y=0;y<n.length;y++){const M=n[y],{startRow:C,endRow:T,startColumn:_,endColumn:D}=M;if(S<C||w<_)continue;if(l===h.SheetDrawingAnchorType.Position&&(m<=C&&S>=T||f<=_&&w>=D)){this._remainDrawingSize(p,o,c);continue}const v=Y({...d},this._selectionRenderService,this._skeletonManagerService);if(v!=null){o.push({...c,transform:v});break}}}}),o.length===0?{redos:[],undos:[]}:this._createUndoAndRedoMutation(i,r,o)}_getUnitIdAndSubUnitId(i,r){let n,e;if(r==="insert")n=i.unitId,e=i.subUnitId;else{const t=I.getSheetCommandTarget(this._univerInstanceService);if(t==null)return;n=t.unitId,e=t.subUnitId}return{unitId:n,subUnitId:e}}_moveRangeInterceptor(i){var C,T;const{toRange:r,fromRange:n}=i,e=I.getSheetCommandTarget(this._univerInstanceService);if(!e)return{redos:[],undos:[]};const{unitId:t,subUnitId:o}=e,a=(T=(C=this._renderManagerService.getRenderById(t))==null?void 0:C.with(j.SheetSkeletonManagerService))==null?void 0:T.getCurrentSkeleton();if(!a)return{redos:[],undos:[]};const c=j.attachRangeWithCoord(a,n);if(!c)return{redos:[],undos:[]};const{startX:d,endX:p,startY:l,endY:s}=c,u=this._sheetDrawingService.getDrawingData(t,o),m=[];Object.keys(u).forEach(_=>{const D=u[_];if(D.anchorType!==h.SheetDrawingAnchorType.Both)return;const{transform:v}=D;if(!v)return;const{left:P=0,top:b=0,width:L=0,height:U=0}=v,{drawingStartX:O,drawingEndX:R,drawingStartY:B,drawingEndY:V}={drawingStartX:P,drawingEndX:P+L,drawingStartY:b,drawingEndY:b+U};d<=O&&R<=p&&l<=B&&V<=s&&m.push(D)});const f=[],S=[],w=r.startRow-n.startRow,y=r.startColumn-n.startColumn,M=m.map(_=>{const D=_.sheetTransform,v={to:{...D.to,row:D.to.row+w,column:D.to.column+y},from:{...D.from,row:D.from.row+w,column:D.from.column+y}},P=Y(v,this._selectionRenderService,this._skeletonManagerService);return{unitId:t,subUnitId:o,drawingId:_.drawingId,transform:P,sheetTransform:v}});if(M.length){const _=this._sheetDrawingService.getBatchUpdateOp(M),{undo:D,redo:v,objects:P}=_;f.push({id:h.SetDrawingApplyMutation.id,params:{unitId:t,subUnitId:o,op:v,objects:P,type:h.DrawingApplyType.UPDATE}}),S.push({id:h.SetDrawingApplyMutation.id,params:{unitId:t,subUnitId:o,op:D,objects:P,type:h.DrawingApplyType.UPDATE}})}return{redos:f,undos:S}}_moveRowInterceptor(i,r){const n=this._getUnitIdAndSubUnitId(i,r);if(n==null)return{redos:[],undos:[]};const{unitId:e,subUnitId:t}=n,{range:o}=i,a=o.startRow,c=o.endRow,d=[],p=[],l=this._sheetDrawingService.getDrawingData(e,t),s=[],u=[];if(Object.keys(l).forEach(m=>{const f=l[m],{sheetTransform:S,transform:w,anchorType:y=h.SheetDrawingAnchorType.Position}=f;if(S==null||w==null)return;let M,C;if(r==="insert"){const _=this._expandRow(S,w,a,c,y);M=_==null?void 0:_.newSheetTransform,C=_==null?void 0:_.newTransform}else{const{from:_,to:D}=S,{row:v}=_,{row:P}=D;if(y===h.SheetDrawingAnchorType.Both&&v>=a&&P<=c)u.push({unitId:e,subUnitId:t,drawingId:m});else{const b=this._shrinkRow(S,w,a,c,y);M=b==null?void 0:b.newSheetTransform,C=b==null?void 0:b.newTransform}}if(!M||!C)return;const T={unitId:e,subUnitId:t,drawingId:m,transform:C,sheetTransform:M};s.push(T)}),s.length===0&&u.length===0)return{redos:[],undos:[]};if(s.length>0){const m=this._sheetDrawingService.getBatchUpdateOp(s),{undo:f,redo:S,objects:w}=m;d.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:S,objects:w,type:h.DrawingApplyType.UPDATE}}),p.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:f,objects:w,type:h.DrawingApplyType.UPDATE}})}if(u.length>0){const m=this._sheetDrawingService.getBatchRemoveOp(u),f=m.undo,S=m.redo,w=m.objects;d.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:S,objects:w,type:h.DrawingApplyType.REMOVE}}),p.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:f,objects:w,type:h.DrawingApplyType.INSERT}})}return d.push({id:G.id,params:[e]}),p.push({id:G.id,params:[e]}),{redos:d,undos:p}}_moveColInterceptor(i,r){const n=this._getUnitIdAndSubUnitId(i,r);if(n==null)return{redos:[],undos:[]};const{unitId:e,subUnitId:t}=n,{range:o}=i,a=o.startColumn,c=o.endColumn,d=[],p=[],l=this._sheetDrawingService.getDrawingData(e,t),s=[],u=[];if(Object.keys(l).forEach(m=>{const f=l[m],{sheetTransform:S,transform:w,anchorType:y=h.SheetDrawingAnchorType.Position}=f;if(S==null||w==null)return;let M,C;if(r==="insert"){const _=this._expandCol(S,w,a,c,y);M=_==null?void 0:_.newSheetTransform,C=_==null?void 0:_.newTransform}else{const{from:_,to:D}=S,{column:v}=_,{column:P}=D;if(y===h.SheetDrawingAnchorType.Both&&v>=a&&P<=c)u.push({unitId:e,subUnitId:t,drawingId:m});else{const b=this._shrinkCol(S,w,a,c,y);M=b==null?void 0:b.newSheetTransform,C=b==null?void 0:b.newTransform}}if(!M||!C)return;const T={unitId:e,subUnitId:t,drawingId:m,transform:C,sheetTransform:M};s.push(T)}),s.length===0&&u.length===0)return{redos:[],undos:[]};if(s.length>0){const m=this._sheetDrawingService.getBatchUpdateOp(s),{undo:f,redo:S,objects:w}=m;d.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:S,objects:w,type:h.DrawingApplyType.UPDATE}}),p.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:f,objects:w,type:h.DrawingApplyType.UPDATE}})}if(u.length>0){const m=this._sheetDrawingService.getBatchRemoveOp(u),f=m.undo,S=m.redo,w=m.objects;d.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:S,objects:w,type:h.DrawingApplyType.REMOVE}}),p.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:f,objects:w,type:h.DrawingApplyType.INSERT}})}return d.push({id:G.id,params:[e]}),p.push({id:G.id,params:[e]}),{redos:d,undos:p}}_expandCol(i,r,n,e,t=h.SheetDrawingAnchorType.Position){const o=e-n+1,{from:a,to:c}=i,{column:d}=a,{column:p}=c;if(t===h.SheetDrawingAnchorType.None)return{newSheetTransform:k({...r},this._selectionRenderService),newTransform:r};let l=null,s=null;if(d>=n){const u=this._skeletonManagerService.attachRangeWithCoord({startColumn:n,endColumn:e,startRow:a.row,endRow:c.row});if(u==null)return;s={...r,left:(r.left||0)+u.endX-u.startX},l=k(s,this._selectionRenderService)}else if(p>=e)if(t===h.SheetDrawingAnchorType.Both)l={from:{...a},to:{...c,column:p+o}},s=Y(l,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:k({...r},this._selectionRenderService),newTransform:r};return l!=null&&s!=null?{newSheetTransform:l,newTransform:s}:null}_shrinkCol(i,r,n,e,t=h.SheetDrawingAnchorType.Position){const o=e-n+1,{from:a,to:c}=i,{column:d}=a,{column:p}=c;if(t===h.SheetDrawingAnchorType.None)return{newSheetTransform:k({...r},this._selectionRenderService),newTransform:r};let l=null,s=null;if(d>e)l={from:{...a,column:d-o},to:{...c,column:p-o}},s=Y(l,this._selectionRenderService,this._skeletonManagerService);else{if(d>=n&&p<=e)return null;if(d<n&&p>e)if(t===h.SheetDrawingAnchorType.Both)l={from:{...a},to:{...c,column:p-o}},s=Y(l,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:k({...r},this._selectionRenderService),newTransform:r};else if(d>=n&&d<=e){if(d===n)s={...r,left:(r.left||0)-i.from.columnOffset};else{const u=this._skeletonManagerService.attachRangeWithCoord({startColumn:n,endColumn:d-1,startRow:a.row,endRow:c.row});if(u==null)return;s={...r,left:(r.left||0)-u.endX+u.startX-i.from.columnOffset}}l=k(s,this._selectionRenderService)}else if(p>=n&&p<=e&&t===h.SheetDrawingAnchorType.Both){const u=this._skeletonManagerService.attachRangeWithCoord({startColumn:n-1,endColumn:n-1,startRow:a.row,endRow:c.row});if(u==null)return;l={from:{...a},to:{...c,column:n-1,columnOffset:u.endX-u.startX}},s=Y(l,this._selectionRenderService,this._skeletonManagerService)}}return l!=null&&s!=null?{newSheetTransform:l,newTransform:s}:null}_expandRow(i,r,n,e,t=h.SheetDrawingAnchorType.Position){const o=e-n+1,{from:a,to:c}=i,{row:d}=a,{row:p}=c;if(t===h.SheetDrawingAnchorType.None)return{newSheetTransform:k({...r},this._selectionRenderService),newTransform:r};let l=null,s=null;if(d>=n){const u=this._skeletonManagerService.attachRangeWithCoord({startRow:n,endRow:e,startColumn:a.column,endColumn:c.column});if(u==null)return;s={...r,top:(r.top||0)+u.endY-u.startY},l=k(s,this._selectionRenderService)}else if(p>=e)if(t===h.SheetDrawingAnchorType.Both)l={from:{...a},to:{...c,row:p+o}},s=Y(l,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:k({...r},this._selectionRenderService),newTransform:r};return l!=null&&s!=null?{newSheetTransform:l,newTransform:s}:null}_shrinkRow(i,r,n,e,t=h.SheetDrawingAnchorType.Position){const o=e-n+1,{from:a,to:c}=i,{row:d}=a,{row:p}=c;if(t===h.SheetDrawingAnchorType.None)return{newSheetTransform:k({...r},this._selectionRenderService),newTransform:r};let l=null,s=null;if(d>e)l={from:{...a,row:d-o},to:{...c,row:p-o}},s=Y(l,this._selectionRenderService,this._skeletonManagerService);else{if(d>=n&&p<=e)return null;if(d<n&&p>e)if(t===h.SheetDrawingAnchorType.Both)l={from:{...a},to:{...c,row:p-o}},s=Y(l,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:k({...r},this._selectionRenderService),newTransform:r};else if(d>=n&&d<=e){if(d===n)s={...r,top:(r.top||0)-i.from.rowOffset};else{const u=this._skeletonManagerService.attachRangeWithCoord({startRow:n,endRow:d-1,startColumn:a.column,endColumn:c.column});if(u==null)return;s={...r,top:(r.top||0)-u.endY+u.startY-i.from.rowOffset}}l=k(s,this._selectionRenderService)}else if(p>=n&&p<=e&&t===h.SheetDrawingAnchorType.Both){const u=this._skeletonManagerService.attachRangeWithCoord({startColumn:a.column,endColumn:a.column,startRow:n-1,endRow:n-1});if(u==null)return;l={from:{...a},to:{...c,row:n-1,rowOffset:u.endY-u.startY}},s=Y(l,this._selectionRenderService,this._skeletonManagerService)}}return l!=null&&s!=null?{newSheetTransform:l,newTransform:s}:null}_commandListener(){this.disposeWithMe(this._commandService.onCommandExecuted(i=>{i.id===I.SetWorksheetActiveOperation.id&&setTimeout(()=>{const r=i.params,{unitId:n,subUnitId:e}=r,t=this._drawingManagerService.drawingManagerData,o=[],a=[];Object.keys(t).forEach(c=>{const d=t[c];d!=null&&Object.keys(d).forEach(p=>{const l=d[p].data;l!=null&&Object.keys(l).forEach(s=>{if(c===n&&p===e){const u=l[s];u.transform=Y(u.sheetTransform,this._selectionRenderService,this._skeletonManagerService),o.push(l[s])}else a.push(l[s])})})}),this._drawingManagerService.removeNotification(a),this._drawingManagerService.addNotification(o)},0)}))}_sheetRefreshListener(){this.disposeWithMe(this._commandService.onCommandExecuted(i=>{It.includes(i.id)&&requestIdleCallback(()=>{const r=i.params,{unitId:n,subUnitId:e,ranges:t}=r;this._refreshDrawingTransform(n,e,t)})}))}_refreshDrawingTransform(i,r,n){const e=this._drawingManagerService.getDrawingData(i,r),t=[];Object.keys(e).forEach(o=>{const a=e[o],{sheetTransform:c,transform:d,anchorType:p=h.SheetDrawingAnchorType.Position}=a;if(p===h.SheetDrawingAnchorType.None)return!0;const{from:l,to:s}=c,{row:u,column:m}=l,{row:f,column:S}=s;for(let w=0;w<n.length;w++){const y=n[w],{startRow:M,endRow:C,startColumn:T,endColumn:_}=y;if(g.Rectangle.intersects({startRow:M,endRow:C,startColumn:T,endColumn:_},{startRow:u,endRow:f,startColumn:m,endColumn:S})||u>C||m>_){const D=p===h.SheetDrawingAnchorType.Position,v=Y(c,this._selectionRenderService,this._skeletonManagerService);t.push({...a,transform:{...v,width:D?d==null?void 0:d.width:v==null?void 0:v.width,height:D?d==null?void 0:d.height:v==null?void 0:v.height}});break}}}),t.length!==0&&(this._drawingManagerService.refreshTransform(t),this._commandService.syncExecuteCommand(G.id,[i]))}};Te=vt([Z(1,N.IRenderManagerService),Z(2,g.ICommandService),Z(3,j.ISheetSelectionRenderService),Z(4,g.Inject(j.SheetSkeletonManagerService)),Z(5,g.Inject(I.SheetInterceptorService)),Z(6,h.ISheetDrawingService),Z(7,A.IDrawingManagerService),Z(8,g.IUniverInstanceService)],Te);function Ct(i){const r=[];return i.forEach(n=>{const{parent:e,children:t}=n,{unitId:o,subUnitId:a,drawingId:c}=e,d=N.getGroupState(0,0,t.map(s=>s.transform||{})),p=t.map(s=>{const u=s.transform||{left:0,top:0},{unitId:m,subUnitId:f,drawingId:S}=s;return{unitId:m,subUnitId:f,drawingId:S,transform:{...u,left:u.left-d.left,top:u.top-d.top},groupId:c}}),l={unitId:o,subUnitId:a,drawingId:c,drawingType:g.DrawingTypeEnum.DRAWING_GROUP,transform:d};r.push({parent:l,children:p})}),r}function yt(i){const r=[];return i.forEach(n=>{const{parent:e,children:t}=n,{unitId:o,subUnitId:a,drawingId:c,transform:d={width:0,height:0}}=e;if(d==null)return;const p=t.map(s=>{const{transform:u}=s,{unitId:m,subUnitId:f,drawingId:S}=s,w=N.transformObjectOutOfGroup(u||{},d,d.width||0,d.height||0);return{unitId:m,subUnitId:f,drawingId:S,transform:w,groupId:void 0}}),l={unitId:o,subUnitId:a,drawingId:c,drawingType:g.DrawingTypeEnum.DRAWING_GROUP,transform:{left:0,top:0}};r.push({parent:l,children:p})}),r}const be={id:"sheet.command.group-sheet-image",type:g.CommandType.COMMAND,handler:(i,r)=>{const n=i.get(g.ICommandService),e=i.get(g.IUndoRedoService),t=i.get(h.ISheetDrawingService);if(!r)return!1;const o=[];r.forEach(({parent:m,children:f})=>{o.push(m.unitId),f.forEach(S=>{o.push(S.unitId)})});const a=t.getGroupDrawingOp(r),{unitId:c,subUnitId:d,undo:p,redo:l,objects:s}=a;return n.syncExecuteCommand(h.SetDrawingApplyMutation.id,{op:l,unitId:c,subUnitId:d,objects:s,type:h.DrawingApplyType.GROUP})?(e.pushUndoRedo({unitID:c,undoMutations:[{id:h.SetDrawingApplyMutation.id,params:{op:p,unitId:c,subUnitId:d,objects:yt(s),type:h.DrawingApplyType.UNGROUP}},{id:G.id,params:o}],redoMutations:[{id:h.SetDrawingApplyMutation.id,params:{op:l,unitId:c,subUnitId:d,objects:s,type:h.DrawingApplyType.GROUP}},{id:G.id,params:o}]}),!0):!1}},se={id:"sheet.command.insert-sheet-image",type:g.CommandType.COMMAND,handler:(i,r)=>{var M,C,T;const n=i.get(g.ICommandService),e=i.get(g.IUndoRedoService),t=i.get(h.ISheetDrawingService),o=i.get(I.SheetInterceptorService);if(!r)return!1;const a=r.drawings,c=a.map(_=>_.unitId),d=t.getBatchAddOp(a),{unitId:p,subUnitId:l,undo:s,redo:u,objects:m}=d,f=o.onCommandExecute({id:se.id,params:r}),S={id:h.SetDrawingApplyMutation.id,params:{op:u,unitId:p,subUnitId:l,objects:m,type:h.DrawingApplyType.INSERT}},w={id:h.SetDrawingApplyMutation.id,params:{op:s,unitId:p,subUnitId:l,objects:m,type:h.DrawingApplyType.REMOVE}};return g.sequenceExecute([...(M=f.preRedos)!=null?M:[],S,...f.redos],n)?(e.pushUndoRedo({unitID:p,undoMutations:[...(C=f.preUndos)!=null?C:[],w,...f.undos,{id:G.id,params:c}],redoMutations:[...(T=f.preRedos)!=null?T:[],S,...f.redos,{id:G.id,params:c}]}),!0):!1}},Ee={id:"sheet.command.set-drawing-arrange",type:g.CommandType.COMMAND,handler:(i,r)=>{const n=i.get(g.ICommandService),e=i.get(g.IUndoRedoService);if(!r)return!1;const t=i.get(h.ISheetDrawingService),{unitId:o,subUnitId:a,drawingIds:c,arrangeType:d}=r,p={unitId:o,subUnitId:a,drawingIds:c};let l;if(d===g.ArrangeTypeEnum.forward?l=t.getForwardDrawingsOp(p):d===g.ArrangeTypeEnum.backward?l=t.getBackwardDrawingOp(p):d===g.ArrangeTypeEnum.front?l=t.getFrontDrawingsOp(p):d===g.ArrangeTypeEnum.back&&(l=t.getBackDrawingsOp(p)),l==null)return!1;const{objects:s,redo:u,undo:m}=l;return n.syncExecuteCommand(h.SetDrawingApplyMutation.id,{op:u,unitId:o,subUnitId:a,objects:s,type:h.DrawingApplyType.ARRANGE})?(e.pushUndoRedo({unitID:o,undoMutations:[{id:h.SetDrawingApplyMutation.id,params:{op:m,unitId:o,subUnitId:a,objects:s,type:h.DrawingApplyType.ARRANGE}}],redoMutations:[{id:h.SetDrawingApplyMutation.id,params:{op:u,unitId:o,subUnitId:a,objects:s,type:h.DrawingApplyType.ARRANGE}}]}),!0):!1}},ce={id:"sheet.command.set-sheet-image",type:g.CommandType.COMMAND,handler:(i,r)=>{const n=i.get(g.ICommandService),e=i.get(g.IUndoRedoService),t=i.get(h.ISheetDrawingService);if(!r)return!1;const{drawings:o}=r,a=t.getBatchUpdateOp(o),{unitId:c,subUnitId:d,undo:p,redo:l,objects:s}=a;return n.syncExecuteCommand(h.SetDrawingApplyMutation.id,{unitId:c,subUnitId:d,op:l,objects:s,type:h.DrawingApplyType.UPDATE})?(e.pushUndoRedo({unitID:c,undoMutations:[{id:h.SetDrawingApplyMutation.id,params:{unitId:c,subUnitId:d,op:p,objects:s,type:h.DrawingApplyType.UPDATE}},{id:G.id,params:[c]}],redoMutations:[{id:h.SetDrawingApplyMutation.id,params:{unitId:c,subUnitId:d,op:l,objects:s,type:h.DrawingApplyType.UPDATE}},{id:G.id,params:[c]}]}),!0):!1}},Oe={id:"sheet.command.ungroup-sheet-image",type:g.CommandType.COMMAND,handler:(i,r)=>{const n=i.get(g.ICommandService),e=i.get(g.IUndoRedoService),t=i.get(h.ISheetDrawingService);if(!r)return!1;const o=[];r.forEach(({parent:m,children:f})=>{o.push(m.unitId),f.forEach(S=>{o.push(S.unitId)})});const a=t.getUngroupDrawingOp(r),{unitId:c,subUnitId:d,undo:p,redo:l,objects:s}=a;return n.syncExecuteCommand(h.SetDrawingApplyMutation.id,{op:l,unitId:c,subUnitId:d,objects:s,type:h.DrawingApplyType.UNGROUP})?(e.pushUndoRedo({unitID:c,undoMutations:[{id:h.SetDrawingApplyMutation.id,params:{op:p,unitId:c,subUnitId:d,objects:Ct(s),type:h.DrawingApplyType.GROUP}},{id:G.id,params:o}],redoMutations:[{id:h.SetDrawingApplyMutation.id,params:{op:l,unitId:c,subUnitId:d,objects:s,type:h.DrawingApplyType.UNGROUP}},{id:G.id,params:o}]}),!0):!1}};var Mt=Object.defineProperty,Dt=Object.getOwnPropertyDescriptor,Rt=(i,r,n,e)=>{for(var t=e>1?void 0:e?Dt(r,n):r,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(r,n,t):a(t))||t);return e&&t&&Mt(r,n,t),t},z=(i,r)=>(n,e)=>r(n,e,i);let Se=class extends g.Disposable{constructor(r,n,e,t,o,a,c,d,p,l,s,u){super();X(this,"_workbookSelections");this._context=r,this._skeletonManagerService=n,this._commandService=e,this._selectionRenderService=t,this._imageIoService=o,this._fileOpenerService=a,this._sheetDrawingService=c,this._drawingManagerService=d,this._contextService=p,this._messageService=l,this._localeService=s,this._workbookSelections=u.getWorkbookSelections(this._context.unitId),this._updateImageListener(),this._updateOrderListener(),this._groupDrawingListener(),this._focusDrawingListener()}async insertFloatImage(){const r=await this._fileOpenerService.openFile({multiple:!0,accept:A.DRAWING_IMAGE_ALLOW_IMAGE_LIST.map(e=>`.${e.replace("image/","")}`).join(",")}),n=r.length;return n>A.DRAWING_IMAGE_COUNT_LIMIT?(this._messageService.show({type:q.MessageType.Error,content:this._localeService.t("update-status.exceedMaxCount",String(A.DRAWING_IMAGE_COUNT_LIMIT))}),!1):n===0?!1:(r.forEach(async e=>await this._insertFloatImage(e)),!0)}async _insertFloatImage(r){let n;try{n=await this._imageIoService.saveImage(r)}catch(M){const C=M.message;C===A.ImageUploadStatusType.ERROR_EXCEED_SIZE?this._messageService.show({type:q.MessageType.Error,content:this._localeService.t("update-status.exceedMaxSize",String(A.DRAWING_IMAGE_ALLOW_SIZE/(1024*1024)))}):C===A.ImageUploadStatusType.ERROR_IMAGE_TYPE?this._messageService.show({type:q.MessageType.Error,content:this._localeService.t("update-status.invalidImageType")}):C===A.ImageUploadStatusType.ERROR_IMAGE&&this._messageService.show({type:q.MessageType.Error,content:this._localeService.t("update-status.invalidImage")})}if(n==null)return;const e=this._getUnitInfo(),{unitId:t,subUnitId:o}=e,{imageId:a,imageSourceType:c,source:d,base64Cache:p}=n,{width:l,height:s,image:u}=await A.getImageSize(p||""),{width:m,height:f}=this._context.scene;this._imageIoService.addImageSourceCache(d,c,u);let S=1;if(l>A.DRAWING_IMAGE_WIDTH_LIMIT||s>A.DRAWING_IMAGE_HEIGHT_LIMIT){const M=A.DRAWING_IMAGE_WIDTH_LIMIT/l,C=A.DRAWING_IMAGE_HEIGHT_LIMIT/s;S=Math.max(M,C)}const w=this._getImagePosition(l*S,s*S,m,f);if(w==null)return;const y={unitId:t,subUnitId:o,drawingId:a,drawingType:g.DrawingTypeEnum.DRAWING_IMAGE,imageSourceType:c,source:d,transform:Y(w,this._selectionRenderService,this._skeletonManagerService),sheetTransform:w};this._commandService.executeCommand(se.id,{unitId:t,drawings:[y]})}_getUnitInfo(){const r=this._context.unit,n=r.getActiveSheet(),e=r.getUnitId(),t=n.getSheetId();return{unitId:e,subUnitId:t}}_getImagePosition(r,n,e,t){const o=this._workbookSelections.getCurrentSelections();let a={startRow:0,endRow:0,startColumn:0,endColumn:0};o&&o.length>0&&(a=o[o.length-1].range);const c=j.attachRangeWithCoord(this._skeletonManagerService.getCurrent().skeleton,a);if(c==null)return;let{startColumn:d,startRow:p,startX:l,startY:s}=c,u=!1;if(l+r>e&&(l=e-r,l<0&&(l=0,r=e),u=!0),s+n>t&&(s=t-n,s<0&&(s=0,n=t),u=!0),u){const w=this._selectionRenderService.getCellWithCoordByOffset(l,s);if(w==null)return;l=w.startX,s=w.startY,d=w.actualColumn,p=w.actualRow}const m={column:d,columnOffset:0,row:p,rowOffset:0},f=this._selectionRenderService.getCellWithCoordByOffset(l+r,s+n);if(f==null)return;const S={column:f.actualColumn,columnOffset:l+r-f.startX,row:f.actualRow,rowOffset:s+n-f.startY};return{from:m,to:S}}_updateOrderListener(){this.disposeWithMe(this._drawingManagerService.featurePluginOrderUpdate$.subscribe(r=>{const{unitId:n,subUnitId:e,drawingIds:t,arrangeType:o}=r;this._commandService.executeCommand(Ee.id,{unitId:n,subUnitId:e,drawingIds:t,arrangeType:o})}))}_updateImageListener(){this.disposeWithMe(this._drawingManagerService.featurePluginUpdate$.subscribe(r=>{const n=[];r.length!==0&&(r.forEach(e=>{const{unitId:t,subUnitId:o,drawingId:a,drawingType:c,transform:d}=e;if(d==null)return;const p=this._sheetDrawingService.getDrawingByParam({unitId:t,subUnitId:o,drawingId:a});if(p==null||p.unitId!==this._context.unitId)return;const l=k({...p.transform,...d},this._selectionRenderService);if(l==null)return;const s={...e,transform:{...p.transform,...d,...Y(l,this._selectionRenderService,this._skeletonManagerService)},sheetTransform:{...l}};n.push(s)}),n.length>0&&this._commandService.executeCommand(ce.id,{unitId:r[0].unitId,drawings:n}))}))}_groupDrawingListener(){this.disposeWithMe(this._drawingManagerService.featurePluginGroupUpdate$.subscribe(r=>{this._commandService.executeCommand(be.id,r);const{unitId:n,subUnitId:e,drawingId:t}=r[0].parent;this._drawingManagerService.focusDrawing([{unitId:n,subUnitId:e,drawingId:t}])})),this.disposeWithMe(this._drawingManagerService.featurePluginUngroupUpdate$.subscribe(r=>{this._commandService.executeCommand(Oe.id,r)}))}_focusDrawingListener(){this.disposeWithMe(this._drawingManagerService.focus$.subscribe(r=>{r==null||r.length===0?(this._contextService.setContextValue(g.FOCUSING_COMMON_DRAWINGS,!1),this._sheetDrawingService.focusDrawing([])):(this._contextService.setContextValue(g.FOCUSING_COMMON_DRAWINGS,!0),this._sheetDrawingService.focusDrawing(r))}))}};Se=Rt([z(1,g.Inject(j.SheetSkeletonManagerService)),z(2,g.ICommandService),z(3,j.ISheetSelectionRenderService),z(4,A.IImageIoService),z(5,F.ILocalFileService),z(6,h.ISheetDrawingService),z(7,A.IDrawingManagerService),z(8,g.IContextService),z(9,F.IMessageService),z(10,g.Inject(g.LocaleService)),z(11,g.Inject(I.SheetsSelectionsService))],Se);var K=function(){return K=Object.assign||function(i){for(var r,n=1,e=arguments.length;n<e;n++){r=arguments[n];for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(i[t]=r[t])}return i},K.apply(this,arguments)},Tt=function(i,r){var n={};for(var e in i)Object.prototype.hasOwnProperty.call(i,e)&&r.indexOf(e)<0&&(n[e]=i[e]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var t=0,e=Object.getOwnPropertySymbols(i);t<e.length;t++)r.indexOf(e[t])<0&&Object.prototype.propertyIsEnumerable.call(i,e[t])&&(n[e[t]]=i[e[t]]);return n},ke=H.forwardRef(function(i,r){var n=i.icon,e=i.id,t=i.className,o=i.extend,a=Tt(i,["icon","id","className","extend"]),c="univerjs-icon univerjs-icon-".concat(e," ").concat(t||"").trim(),d=H.useRef("_".concat(Ot()));return Ve(n,"".concat(e),{defIds:n.defIds,idSuffix:d.current},K({ref:r,className:c},a),o)});function Ve(i,r,n,e,t){return H.createElement(i.tag,K(K({key:r},bt(i,n,t)),e),(Et(i,n).children||[]).map(function(o,a){return Ve(o,"".concat(r,"-").concat(i.tag,"-").concat(a),n,void 0,t)}))}function bt(i,r,n){var e=K({},i.attrs);n!=null&&n.colorChannel1&&e.fill==="colorChannel1"&&(e.fill=n.colorChannel1);var t=r.defIds;return!t||t.length===0||(i.tag==="use"&&e["xlink:href"]&&(e["xlink:href"]=e["xlink:href"]+r.idSuffix),Object.entries(e).forEach(function(o){var a=o[0],c=o[1];typeof c=="string"&&(e[a]=c.replace(/url\(#(.*)\)/,"url(#$1".concat(r.idSuffix,")")))})),e}function Et(i,r){var n,e=r.defIds;return!e||e.length===0?i:i.tag==="defs"&&(!((n=i.children)===null||n===void 0)&&n.length)?K(K({},i),{children:i.children.map(function(t){return typeof t.attrs.id=="string"&&e&&e.indexOf(t.attrs.id)>-1?K(K({},t),{attrs:K(K({},t.attrs),{id:t.attrs.id+r.idSuffix})}):t})}):i}function Ot(){return Math.random().toString(36).substring(2,8)}ke.displayName="UniverIcon";var Pt={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M2.2498 3.65005C2.2498 2.87685 2.87661 2.25005 3.64981 2.25005H7.9998C8.33118 2.25005 8.5998 1.98142 8.5998 1.65005C8.5998 1.31868 8.33118 1.05005 7.9998 1.05005H3.64981C2.21387 1.05005 1.0498 2.21411 1.0498 3.65005V12.35C1.0498 13.786 2.21386 14.95 3.6498 14.95H12.3498C13.7857 14.95 14.9498 13.786 14.9498 12.3501V8.00005C14.9498 7.66868 14.6812 7.40005 14.3498 7.40005C14.0184 7.40005 13.7498 7.66868 13.7498 8.00005V9.23974L12.2385 8.1063C11.7252 7.72129 11.0068 7.7723 10.5531 8.22605L9.00869 9.77041L6.73916 7.8251C6.24387 7.40055 5.5095 7.41278 5.02864 7.85359L2.2498 10.4009V3.65005ZM2.2498 12.0287V12.35C2.2498 13.1232 2.87661 13.75 3.6498 13.75H12.3498C13.123 13.75 13.7498 13.1232 13.7498 12.3501V10.7397L11.5186 9.06631C11.4829 9.03956 11.433 9.04314 11.4016 9.07458L9.92249 10.5537L11.1015 11.5642C11.3531 11.7799 11.3822 12.1587 11.1666 12.4103C10.9509 12.6619 10.5721 12.691 10.3205 12.4753L5.9582 8.7362C5.92384 8.70674 5.87288 8.70758 5.83952 8.73816L2.2498 12.0287Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M11.8097 1.14783C12.1411 1.14783 12.4097 1.41646 12.4097 1.74783V3.297H14.1541C14.4855 3.297 14.7541 3.56563 14.7541 3.897C14.7541 4.22837 14.4855 4.497 14.1541 4.497H12.4097V6.24167C12.4097 6.57304 12.1411 6.84167 11.8097 6.84167C11.4783 6.84167 11.2097 6.57304 11.2097 6.24167V4.497H9.6603C9.32893 4.497 9.0603 4.22837 9.0603 3.897C9.0603 3.56563 9.32893 3.297 9.6603 3.297H11.2097V1.74783C11.2097 1.41646 11.4783 1.14783 11.8097 1.14783Z"}}]},Fe=H.forwardRef(function(i,r){return H.createElement(ke,Object.assign({},i,{id:"add-image-single",ref:r,icon:Pt}))});Fe.displayName="AddImageSingle";const Pe={id:"sheet.command.delete-drawing",type:g.CommandType.COMMAND,handler:i=>{const r=i.get(g.ICommandService),e=i.get(h.ISheetDrawingService).getFocusDrawings();if(e.length===0)return!1;const t=e[0].unitId,o=e.map(a=>{const{unitId:c,subUnitId:d,drawingId:p,drawingType:l}=a;return{unitId:c,subUnitId:d,drawingId:p,drawingType:l}});return r.executeCommand(ie.id,{unitId:t,drawings:o})}},we={id:"sheet.command.insert-float-image",type:g.CommandType.COMMAND,handler:i=>{var n,e;return(e=(n=i.get(N.IRenderManagerService).getCurrentTypeOfRenderer(g.UniverInstanceType.UNIVER_SHEET))==null?void 0:n.with(Se).insertFloatImage())!=null?e:!1}},re={id:"sheet.command.move-drawing",type:g.CommandType.COMMAND,handler:(i,r)=>{const n=i.get(g.ICommandService),e=i.get(h.ISheetDrawingService),t=i.get(j.ISheetSelectionRenderService),{direction:o}=r,a=e.getFocusDrawings();if(a.length===0)return!1;const c=a[0].unitId,d=a.map(l=>{const{transform:s}=l;if(s==null)return null;const u={...s},{left:m=0,top:f=0}=s;return o===g.Direction.UP?u.top=f-1:o===g.Direction.DOWN?u.top=f+1:o===g.Direction.LEFT?u.left=m-1:o===g.Direction.RIGHT&&(u.left=m+1),{...l,transform:u,sheetTransform:k(u,t)}}).filter(l=>l!=null);return n.syncExecuteCommand(ce.id,{unitId:c,drawings:d})?(n.syncExecuteCommand(G.id,[c]),!0):!1}},$e="addition-and-subtraction-single",Ae="sheet.menu.image";function At(i){return{id:Ae,type:F.MenuItemType.SUBITEMS,icon:$e,tooltip:"sheetImage.title",hidden$:F.getMenuHiddenObservable(i,g.UniverInstanceType.UNIVER_SHEET),disabled$:j.getCurrentRangeDisable$(i,{workbookTypes:[I.WorkbookEditablePermission],worksheetTypes:[I.WorksheetEditPermission],rangeTypes:[I.RangeProtectionPermissionEditPoint]})}}function Ut(i){return{id:we.id,title:"sheetImage.upload.float",type:F.MenuItemType.BUTTON,hidden$:F.getMenuHiddenObservable(i,g.UniverInstanceType.UNIVER_SHEET)}}const Q={imageCommonPanel:"univer-image-common-panel",imageCommonPanelGrid:"univer-image-common-panel-grid",imageCommonPanelBorder:"univer-image-common-panel-border",imageCommonPanelTitle:"univer-image-common-panel-title",imageCommonPanelSubtitle:"univer-image-common-panel-subtitle",imageCommonPanelRow:"univer-image-common-panel-row",imageCommonPanelRowVertical:"univer-image-common-panel-row-vertical",imageCommonPanelColumn:"univer-image-common-panel-column",imageCommonPanelColumnCenter:"univer-image-common-panel-column-center",imageCommonPanelInline:"univer-image-common-panel-inline",imageCommonPanelSpan2:"univer-image-common-panel-span2",imageCommonPanelSpan3:"univer-image-common-panel-span3",imageCommonPanelInput:"univer-image-common-panel-input",sheetImageMenu:"univer-sheet-image-menu",sheetImageMenuInput:"univer-sheet-image-menu-input"};function Ye(i){var r,n,e="";if(typeof i=="string"||typeof i=="number")e+=i;else if(typeof i=="object")if(Array.isArray(i)){var t=i.length;for(r=0;r<t;r++)i[r]&&(n=Ye(i[r]))&&(e&&(e+=" "),e+=n)}else for(n in i)i[n]&&(e&&(e+=" "),e+=n);return e}function ve(){for(var i,r,n=0,e="",t=arguments.length;n<t;n++)(i=arguments[n])&&(r=Ye(i))&&(e&&(e+=" "),e+=r);return e}const Nt=i=>{var C;const r=g.useDependency(g.ICommandService),n=g.useDependency(g.LocaleService),e=g.useDependency(A.IDrawingManagerService),t=g.useDependency(N.IRenderManagerService),{drawings:o}=i,a=o[0];if(a==null)return;const{unitId:c}=a,d=t.getRenderById(c),p=d==null?void 0:d.scene;if(p==null)return;const l=p.getTransformerByCreate(),[s,u]=H.useState(!0),m=(C=a.anchorType)!=null?C:h.SheetDrawingAnchorType.Position,[f,S]=H.useState(m);function w(T,_){const D=[];return T.forEach(v=>{const{oKey:P}=v,b=_.getDrawingOKey(P);if(b==null)return D.push(null),!0;const{unitId:L,subUnitId:U,drawingId:O,drawingType:R,anchorType:B,sheetTransform:V}=b;D.push({unitId:L,subUnitId:U,drawingId:O,anchorType:B,sheetTransform:V,drawingType:R})}),D}H.useEffect(()=>{const T=l.clearControl$.subscribe(D=>{D===!0&&u(!1)}),_=l.changeStart$.subscribe(D=>{var b;const{objects:v}=D,P=w(v,e);if(P.length===0)u(!1);else if(P.length>=1){u(!0);const L=((b=P[0])==null?void 0:b.anchorType)||h.SheetDrawingAnchorType.Position;S(L)}});return()=>{_.unsubscribe(),T.unsubscribe()}},[]);function y(T){S(T);const _=e.getFocusDrawings();if(_.length===0)return;const D=_.map(v=>({unitId:v.unitId,subUnitId:v.subUnitId,drawingId:v.drawingId,anchorType:T}));r.executeCommand(ce.id,{unitId:_[0].unitId,drawings:D})}const M=T=>T?"block":"none";return $.jsxs("div",{className:ve(Q.imageCommonPanelGrid,Q.imageCommonPanelBorder),style:{display:M(s)},children:[$.jsx("div",{className:Q.imageCommonPanelRow,children:$.jsx("div",{className:ve(Q.imageCommonPanelColumn,Q.imageCommonPanelTitle),children:$.jsx("div",{children:n.t("drawing-anchor.title")})})}),$.jsx("div",{className:ve(Q.imageCommonPanelRow),children:$.jsx("div",{className:ve(Q.imageCommonPanelColumn),children:$.jsxs(q.RadioGroup,{value:f,onChange:y,direction:"vertical",children:[$.jsx(q.Radio,{value:h.SheetDrawingAnchorType.Both,children:n.t("drawing-anchor.both")}),$.jsx(q.Radio,{value:h.SheetDrawingAnchorType.Position,children:n.t("drawing-anchor.position")}),$.jsx(q.Radio,{value:h.SheetDrawingAnchorType.None,children:n.t("drawing-anchor.none")})]})})})]})},jt=()=>{const i=g.useDependency(A.IDrawingManagerService),r=i.getFocusDrawings(),[n,e]=H.useState(r);return H.useEffect(()=>{const t=i.focus$.subscribe(o=>{e(o)});return()=>{t.unsubscribe()}},[]),!!(n!=null&&n.length)&&$.jsxs("div",{className:Q.imageCommonPanel,children:[$.jsx(ee.DrawingCommonPanel,{drawings:n}),$.jsx(Nt,{drawings:n})]})},Wt={[F.RibbonStartGroup.FORMULAS_INSERT]:{[Ae]:{order:3,menuItemFactory:At,[we.id]:{order:0,menuItemFactory:Ut}}}};function de(i){return!i.getContextValue(g.FOCUSING_FX_BAR_EDITOR)&&!i.getContextValue(g.EDITOR_ACTIVATED)&&!i.getContextValue(g.FOCUSING_PANEL_EDITOR)&&i.getContextValue(g.FOCUSING_COMMON_DRAWINGS)}const Lt={id:re.id,description:"shortcut.sheet.drawing-move-down",group:"4_sheet-drawing-view",binding:F.KeyCode.ARROW_DOWN,priority:100,preconditions:de,staticParameters:{direction:g.Direction.DOWN}},Bt={id:re.id,description:"shortcut.sheet.drawing-move-up",group:"4_sheet-drawing-view",binding:F.KeyCode.ARROW_UP,priority:100,preconditions:de,staticParameters:{direction:g.Direction.UP}},Gt={id:re.id,description:"shortcut.sheet.drawing-move-left",group:"4_sheet-drawing-view",binding:F.KeyCode.ARROW_LEFT,priority:100,preconditions:de,staticParameters:{direction:g.Direction.LEFT}},kt={id:re.id,description:"shortcut.sheet.drawing-move-right",group:"4_sheet-drawing-view",binding:F.KeyCode.ARROW_RIGHT,priority:100,preconditions:de,staticParameters:{direction:g.Direction.RIGHT}},Vt={id:Pe.id,description:"shortcut.sheet.drawing-delete",group:"4_sheet-drawing-view",preconditions:de,binding:F.KeyCode.DELETE,mac:F.KeyCode.BACKSPACE};var Ft=Object.defineProperty,$t=Object.getOwnPropertyDescriptor,Yt=(i,r,n,e)=>{for(var t=e>1?void 0:e?$t(r,n):r,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(r,n,t):a(t))||t);return e&&t&&Ft(r,n,t),t},_e=(i,r)=>(n,e)=>r(n,e,i);let Ie=class extends g.Disposable{constructor(i,r,n,e){super(),this._componentManager=i,this._menuManagerService=r,this._commandService=n,this._shortcutService=e,this._init()}_initCustomComponents(){const i=this._componentManager;this.disposeWithMe(i.register($e,Fe)),this.disposeWithMe(i.register(Le,jt))}_initMenus(){this._menuManagerService.mergeMenu(Wt)}_initCommands(){[we,se,ie,ce,Ce,G,ye,be,Oe,re,Pe,Ee].forEach(i=>this.disposeWithMe(this._commandService.registerCommand(i)))}_initShortcuts(){[Lt,Bt,Gt,kt,Vt].forEach(i=>{this.disposeWithMe(this._shortcutService.registerShortcut(i))})}_init(){this._initCommands(),this._initCustomComponents(),this._initMenus(),this._initShortcuts()}};Ie=Yt([_e(0,g.Inject(F.ComponentManager)),_e(1,F.IMenuManagerService),_e(2,g.ICommandService),_e(3,F.IShortcutService)],Ie);var Ht=Object.defineProperty,xt=Object.getOwnPropertyDescriptor,Xt=(i,r,n,e)=>{for(var t=e>1?void 0:e?xt(r,n):r,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(r,n,t):a(t))||t);return e&&t&&Ht(r,n,t),t},ne=(i,r)=>(n,e)=>r(n,e,i);function Kt(i,r,n,e){const{scaleX:t,scaleY:o}=r.getAncestorScale(),a=r.getViewport(N.SHEET_VIEWPORT_KEY.VIEW_MAIN),c={left:!0,top:!0};if(!a)return{...i,absolute:c};const{left:d,right:p,top:l,bottom:s}=i,u=e.getFreeze(),{startColumn:m,startRow:f,xSplit:S,ySplit:w}=u,y=n.getNoMergeCellPositionByIndexWithNoHeader(f-w,m-S),M=n.getNoMergeCellPositionByIndexWithNoHeader(f,m),{rowHeaderWidth:C,columnHeaderHeight:T}=n,_=M.startX-y.startX,D=M.startY-y.startY,{top:v,left:P,viewportScrollX:b,viewportScrollY:L}=a;let U,O;d<P?(c.left=!0,U=(_+C+(d-P))*t,O=Math.max(Math.min((_+C+(p-P))*t,(_+C)*t),(p-b)*t)):(c.left=!1,U=Math.max((d-b)*t,(_+C)*t),O=Math.max((p-b)*t,(_+C)*t));let R,B;return l<v?(c.top=!0,R=(D+T+(l-v))*o,B=Math.max(Math.min((D+T+(p-v))*o,(D+T)*o),(s-L)*o)):(c.top=!1,R=Math.max((l-L)*o,(D+T)*o),B=Math.max((s-L)*o,(D+T)*o)),{left:U,right:O,top:R,bottom:B,absolute:c}}const Ue=(i,r,n,e)=>{const{scene:t}=r,{left:o,top:a,width:c,height:d,angle:p}=i,l={left:o,right:o+c,top:a,bottom:a+d},s=Kt(l,t,n,e),{scaleX:u,scaleY:m}=t.getAncestorScale();return{startX:s.left,endX:s.right,startY:s.top,endY:s.bottom,rotate:p,width:c*u,height:d*m,absolute:s.absolute}};E.SheetCanvasFloatDomManagerService=class extends g.Disposable{constructor(n,e,t,o,a,c,d){super();X(this,"_domLayerMap",new Map);X(this,"_domLayerInfoMap",new Map);X(this,"_transformChange$",new W.Subject);X(this,"transformChange$",this._transformChange$.asObservable());X(this,"_add$",new W.Subject);X(this,"add$",this._add$.asObservable());X(this,"_remove$",new W.Subject);X(this,"remove$",this._remove$.asObservable());X(this,"_hooks",[]);this._renderManagerService=n,this._univerInstanceService=e,this._commandService=t,this._drawingManagerService=o,this._canvasFloatDomService=a,this._sheetDrawingService=c,this._lifecycleService=d,this._drawingAddListener(),this._featureUpdateListener(),this._deleteListener(),this._bindScrollEvent()}_bindScrollEvent(){this._lifecycleService.lifecycle$.pipe(W.filter(n=>n===g.LifecycleStages.Rendered),W.take(1)).subscribe(()=>{this._scrollUpdateListener()})}_ensureMap(n,e){let t=this._domLayerMap.get(n);t||(t=new Map,this._domLayerMap.set(n,t));let o=t.get(e);return o||(o=new Map,t.set(e,o)),o}getFloatDomInfo(n){return this._domLayerInfoMap.get(n)}_getSceneAndTransformerByDrawingSearch(n){if(n==null)return;const e=this._renderManagerService.getRenderById(n),t=e==null?void 0:e.scene;if(e==null||t==null)return null;const o=t.getTransformerByCreate(),a=e.engine.getCanvasElement();return{scene:t,transformer:o,renderObject:e,canvas:a}}_getFloatDomProps(n){let e;return this._hooks.forEach(t=>{e=t.onGetFloatDomProps(n)}),e}_drawingAddListener(){this.disposeWithMe(this._drawingManagerService.add$.subscribe(n=>{n.forEach(e=>{var Ke,ze,Je;const{unitId:t,subUnitId:o,drawingId:a}=e,c=I.getSheetCommandTarget(this._univerInstanceService,{unitId:t,subUnitId:o}),d=this._drawingManagerService.getDrawingByParam(e),p=this._univerInstanceService.getUnit(t);if(!p)return;const l=p.getActiveSheet().getSheetId();if(!d||!c)return;const s=(Ke=this._renderManagerService.getRenderById(t))==null?void 0:Ke.with(j.SheetSkeletonManagerService).getWorksheetSkeleton(o);if(!s)return;const{transform:u,drawingType:m,data:f}=d;if(m!==g.DrawingTypeEnum.DRAWING_DOM&&m!==g.DrawingTypeEnum.DRAWING_CHART)return;const S=this._getSceneAndTransformerByDrawingSearch(t);if(S==null)return;const{scene:w,canvas:y}=S;if(u==null)return!0;if(l!==o)return;const{left:M,top:C,width:T,height:_,angle:D,flipX:v,flipY:P,skewX:b,skewY:L}=u,U=A.getDrawingShapeKeyByDrawingSearch({unitId:t,subUnitId:o,drawingId:a}),O=w.getObject(U);if(O!=null){O.transformByState({left:M,top:C,width:T,height:_,angle:D,flipX:v,flipY:P,skewX:b,skewY:L});return}const R={left:M,top:C,width:T,height:_,zIndex:this._drawingManagerService.getDrawingOrder(t,o).length-1},B=m===g.DrawingTypeEnum.DRAWING_CHART;B&&(R.fill="white",R.rotateEnabled=!1,f&&f.border&&(R.stroke=f.border),R.paintFirst="stroke",R.strokeWidth=1,R.borderEnabled=!1,R.radius=8);const V=new N.Rect(U,R);B&&V.setObjectType(N.ObjectType.CHART),w.addObject(V,N.DRAWING_OBJECT_LAYER_INDEX),d.allowTransform!==!1&&w.attachTransformerTo(V);const J=this._ensureMap(t,o),je=new g.DisposableCollection,Qt=Ue(V,S.renderObject,s.skeleton,c.worksheet),We=new W.BehaviorSubject(Qt),en={dispose:je,rect:V,position$:We,unitId:t,subUnitId:o};this._canvasFloatDomService.addFloatDom({position$:We,id:a,componentKey:d.componentKey,onPointerDown:x=>{y.dispatchEvent(new PointerEvent(x.type,x))},onPointerMove:x=>{y.dispatchEvent(new PointerEvent(x.type,x))},onPointerUp:x=>{y.dispatchEvent(new PointerEvent(x.type,x))},onWheel:x=>{y.dispatchEvent(new WheelEvent(x.type,x))},props:(Je=(ze=J.get(a))==null?void 0:ze.props)!=null?Je:this._getFloatDomProps(a),data:f,unitId:t});const Xe=V.onTransformChange$.subscribeEvent(()=>{const x=Ue(V,S.renderObject,s.skeleton,c.worksheet);We.next(x)});je.add(()=>{this._canvasFloatDomService.removeFloatDom(a)}),Xe&&je.add(Xe),this._domLayerInfoMap.set(a,en),J.set(a,{...J.get(a)})})})),this.disposeWithMe(this._drawingManagerService.remove$.subscribe(n=>{n.forEach(e=>{const{unitId:t,subUnitId:o,drawingId:a}=e,c=A.getDrawingShapeKeyByDrawingSearch({unitId:t,subUnitId:o,drawingId:a}),d=this._getSceneAndTransformerByDrawingSearch(t);if(d==null)return;const{transformer:p,scene:l}=d,s=l.getObject(c);s!=null&&s.oKey&&p.clearControlByIds([s==null?void 0:s.oKey])})}))}_scrollUpdateListener(){const n=(e,t)=>{var l;const o=this._getSceneAndTransformerByDrawingSearch(e),a=this._ensureMap(e,t),c=Array.from(a.keys()),d=I.getSheetCommandTarget(this._univerInstanceService,{unitId:e,subUnitId:t}),p=(l=this._renderManagerService.getRenderById(e))==null?void 0:l.with(j.SheetSkeletonManagerService).getWorksheetSkeleton(t);!o||!d||!p||c.forEach(s=>{const u=this._domLayerInfoMap.get(s);if(u){const m=Ue(u.rect,o.renderObject,p.skeleton,d.worksheet);u.position$.next(m)}})};this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(g.UniverInstanceType.UNIVER_SHEET).pipe(W.filter(e=>!!e),W.switchMap(e=>e.activeSheet$),W.filter(e=>!!e),W.map(e=>{const t=this._renderManagerService.getRenderById(e.getUnitId());return t?{render:t,unitId:e.getUnitId(),subUnitId:e.getSheetId()}:null}),W.filter(e=>!!e),W.switchMap(e=>g.fromEventSubject(e.render.scene.getViewport(N.SHEET_VIEWPORT_KEY.VIEW_MAIN).onScrollAfter$).pipe(W.map(()=>({unitId:e.unitId,subUnitId:e.subUnitId}))))).subscribe(({unitId:e,subUnitId:t})=>{n(e,t)})),this.disposeWithMe(this._commandService.onCommandExecuted(e=>{var t,o;if(e.id===j.SetZoomRatioOperation.id){const a=e.params,{unitId:c}=a;Array.from((o=(t=this._domLayerMap.get(c))==null?void 0:t.keys())!=null?o:[]).forEach(p=>{n(c,p)})}else if(e.id===I.SetFrozenMutation.id){const{unitId:a,subUnitId:c}=e.params;n(a,c)}}))}_getPosition(n,e){var m;const{startX:t,endX:o,startY:a,endY:c}=n,d=(m=this._renderManagerService.getRenderById(e))==null?void 0:m.with(j.ISheetSelectionRenderService);if(d==null)return;const p=d.getCellWithCoordByOffset(t,a);if(p==null)return;const l={column:p.actualColumn,columnOffset:t-p.startX,row:p.actualRow,rowOffset:a-p.startY},s=d.getCellWithCoordByOffset(o,c);if(s==null)return;const u={column:s.actualColumn,columnOffset:o-s.startX,row:s.actualRow,rowOffset:c-s.startY};return{from:l,to:u}}_featureUpdateListener(){this.disposeWithMe(this._drawingManagerService.update$.subscribe(n=>{n.forEach(e=>{const t=this._drawingManagerService.getDrawingByParam(e);if(!t||t.drawingType!==g.DrawingTypeEnum.DRAWING_DOM&&t.drawingType!==g.DrawingTypeEnum.DRAWING_CHART)return;const o={...t.transform};this._transformChange$.next({id:e.drawingId,value:o})})}))}_deleteListener(){this.disposeWithMe(this._drawingManagerService.remove$.subscribe(n=>{n.forEach(e=>{this._removeDom(e.drawingId)})}))}updateFloatDomProps(n,e,t,o){const a=this._domLayerInfoMap.get(t),c=this._getSceneAndTransformerByDrawingSearch(n);if(a&&c){const{scene:d}=c,p=A.getDrawingShapeKeyByDrawingSearch({unitId:n,subUnitId:e,drawingId:t}),l=d.getObject(p);l&&l instanceof N.Rect&&l.setProps(o)}}addFloatDomToPosition(n,e){const t=I.getSheetCommandTarget(this._univerInstanceService,{unitId:n.unitId,subUnitId:n.subUnitId});if(!t)throw new Error("cannot find current target!");const{unitId:o,subUnitId:a}=t,{initPosition:c,componentKey:d,data:p,allowTransform:l=!0}=n,s=e!=null?e:g.generateRandomId(),u=this._getPosition(c,o);if(u==null)return;this._ensureMap(o,a).set(s,n);const f={unitId:o,subUnitId:a,drawingId:s,drawingType:n.type||g.DrawingTypeEnum.DRAWING_DOM,componentKey:d,sheetTransform:u,transform:{left:c.startX,top:c.startY,width:c.endX-c.startX,height:c.endY-c.startY},data:p,allowTransform:l};return this._commandService.executeCommand(se.id,{unitId:o,drawings:[f]}),this._add$.next({unitId:o,subUnitId:a,id:s}),{id:s,dispose:()=>{this._removeDom(s,!0)}}}_removeDom(n,e=!1){const t=this._domLayerInfoMap.get(n);if(!t)return;const{unitId:o,subUnitId:a}=t;this._domLayerInfoMap.delete(n),t.dispose.dispose();const c=this._getSceneAndTransformerByDrawingSearch(o);if(c&&c.scene.removeObject(t.rect),e){this._ensureMap(o,a).delete(n);const p=this._drawingManagerService.getDrawingByParam({unitId:o,subUnitId:a,drawingId:n});if(!p)return;const l=this._sheetDrawingService.getBatchRemoveOp([p]),{redo:s,objects:u}=l;this._commandService.syncExecuteCommand(h.SetDrawingApplyMutation.id,{unitId:o,subUnitId:a,op:s,objects:u,type:h.DrawingApplyType.REMOVE})}}addHook(n){return this._hooks.push(n),{dispose:()=>{const e=this._hooks.findIndex(t=>t===n);this._hooks.splice(e,1)}}}},E.SheetCanvasFloatDomManagerService=Xt([ne(0,g.Inject(N.IRenderManagerService)),ne(1,g.IUniverInstanceService),ne(2,g.Inject(g.ICommandService)),ne(3,A.IDrawingManagerService),ne(4,g.Inject(F.CanvasFloatDomService)),ne(5,h.ISheetDrawingService),ne(6,g.Inject(g.LifecycleService))],E.SheetCanvasFloatDomManagerService);var He=Object.defineProperty,zt=Object.getOwnPropertyDescriptor,Jt=(i,r,n)=>r in i?He(i,r,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[r]=n,qt=(i,r,n,e)=>{for(var t=e>1?void 0:e?zt(r,n):r,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(r,n,t):a(t))||t);return e&&t&&He(r,n,t),t},Ne=(i,r)=>(n,e)=>r(n,e,i),xe=(i,r,n)=>Jt(i,typeof r!="symbol"?r+"":r,n);const Zt="SHEET_IMAGE_UI_PLUGIN";E.UniverSheetsDrawingUIPlugin=class extends g.Plugin{constructor(r=Ze,n,e,t){super(),this._config=r,this._injector=n,this._renderManagerService=e,this._configService=t;const{menu:o,...a}=this._config;o&&this._configService.setConfig("menu",o,{merge:!0}),this._configService.setConfig(qe,a)}onStarting(){g.registerDependencies(this._injector,[[E.SheetCanvasFloatDomManagerService],[Ie],[ue],[fe],[pe],[ge]]),g.touchDependencies(this._injector,[[E.SheetCanvasFloatDomManagerService]])}onReady(){g.touchDependencies(this._injector,[[ge]])}onRendered(){this._registerRenderModules(),g.touchDependencies(this._injector,[[pe],[fe],[Ie]])}onSteady(){this._injector.get(ue)}_registerRenderModules(){[[Se],[Te],[De]].forEach(r=>{this.disposeWithMe(this._renderManagerService.registerRenderModule(g.UniverInstanceType.UNIVER_SHEET,r))})}},xe(E.UniverSheetsDrawingUIPlugin,"type",g.UniverInstanceType.UNIVER_SHEET),xe(E.UniverSheetsDrawingUIPlugin,"pluginName",Zt),E.UniverSheetsDrawingUIPlugin=qt([g.DependentOn(A.UniverDrawingPlugin,ee.UniverDrawingUIPlugin,h.UniverSheetsDrawingPlugin),Ne(1,g.Inject(g.Injector)),Ne(2,N.IRenderManagerService),Ne(3,g.IConfigService)],E.UniverSheetsDrawingUIPlugin),E.ClearSheetDrawingTransformerOperation=G,E.DeleteDrawingsCommand=Pe,E.EditSheetDrawingOperation=ye,E.GroupSheetDrawingCommand=be,E.InsertFloatImageCommand=we,E.InsertSheetDrawingCommand=se,E.MoveDrawingsCommand=re,E.RemoveSheetDrawingCommand=ie,E.SHEETS_IMAGE_MENU_ID=Ae,E.SetDrawingArrangeCommand=Ee,E.SetSheetDrawingCommand=ce,E.SidebarSheetDrawingOperation=Ce,E.UngroupSheetDrawingCommand=Oe,Object.defineProperty(E,Symbol.toStringTag,{value:"Module"})});
|
|
9
|
+
*/var xe;function lt(){if(xe)return ae;xe=1;var i=x,r=Symbol.for("react.element"),n=Symbol.for("react.fragment"),e=Object.prototype.hasOwnProperty,t=i.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,o={key:!0,ref:!0,__self:!0,__source:!0};function a(c,l,h){var u,s={},g=null,m=null;h!==void 0&&(g=""+h),l.key!==void 0&&(g=""+l.key),l.ref!==void 0&&(m=l.ref);for(u in l)e.call(l,u)&&!o.hasOwnProperty(u)&&(s[u]=l[u]);if(c&&c.defaultProps)for(u in l=c.defaultProps,l)s[u]===void 0&&(s[u]=l[u]);return{$$typeof:r,type:c,key:g,ref:m,props:s,_owner:t.current}}return ae.Fragment=n,ae.jsx=a,ae.jsxs=a,ae}var Xe;function ut(){return Xe||(Xe=1,Ee.exports=lt()),Ee.exports}var $=ut();const ge={uploadLoading:"univer-upload-loading",uploadLoadingBody:"univer-upload-loading-body",uploadLoadingBodyAnimation:"univer-upload-loading-body-animation",univerCircleAnimation:"univer-UniverCircleAnimation",uploadLoadingBodyText:"univer-upload-loading-body-text"},gt=()=>{const i=d.useDependency(P.IImageIoService),r=d.useDependency(d.LocaleService),[n,e]=x.useState(0);return x.useEffect(()=>{const t=i.change$.subscribe(o=>{e(o)});return()=>{t.unsubscribe()}},[i]),$.jsx("div",{style:{display:n>0?"block":"none"},className:ge.uploadLoading,children:$.jsxs("div",{className:ge.uploadLoadingBody,children:[$.jsx("div",{className:ge.uploadLoadingBodyAnimation}),$.jsx("div",{className:ge.uploadLoadingBodyText,children:`${r.t("uploadLoading.loading")}: ${n}`})]})})};var mt=Object.defineProperty,ht=Object.getOwnPropertyDescriptor,pt=(i,r,n,e)=>{for(var t=e>1?void 0:e?ht(r,n):r,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(r,n,t):a(t))||t);return e&&t&&mt(r,n,t),t},te=(i,r)=>(n,e)=>r(n,e,i);let me=class extends d.RxDisposable{constructor(r,n,e,t,o,a,c){super();Y(this,"_initImagePopupMenu",new Set);this._injector=r,this._drawingManagerService=n,this._canvasPopManagerService=e,this._renderManagerService=t,this._univerInstanceService=o,this._contextService=a,this._uiPartsService=c,this._init()}_init(){this._univerInstanceService.getCurrentTypeOfUnit$(d.UniverInstanceType.UNIVER_SHEET).pipe(W.takeUntil(this.dispose$)).subscribe(r=>this._create(r)),this._univerInstanceService.getTypeOfUnitDisposed$(d.UniverInstanceType.UNIVER_SHEET).pipe(W.takeUntil(this.dispose$)).subscribe(r=>this._dispose(r)),this._univerInstanceService.getAllUnitsForType(d.UniverInstanceType.UNIVER_SHEET).forEach(r=>this._create(r)),this._uiPartsService.registerComponent(k.BuiltInUIPart.CONTENT,()=>d.connectInjector(gt,this._injector))}_dispose(r){const n=r.getUnitId();this._renderManagerService.removeRender(n)}_create(r){if(!r)return;const n=r.getUnitId();this._renderManagerService.has(n)&&!this._initImagePopupMenu.has(n)&&(this._popupMenuListener(n),this._initImagePopupMenu.add(n))}_hasCropObject(r){const n=r.getAllObjectsByOrder();for(const e of n)if(e instanceof q.ImageCropperObject)return!0;return!1}_popupMenuListener(r){var o;const n=(o=this._renderManagerService.getRenderById(r))==null?void 0:o.scene;if(!n)return;const e=n.getTransformerByCreate();if(!e)return;let t;this.disposeWithMe(d.toDisposable(e.createControl$.subscribe(()=>{if(this._contextService.setContextValue(d.FOCUSING_COMMON_DRAWINGS,!0),this._hasCropObject(n))return;const a=e.getSelectedObjectMap();if(a.size>1){t==null||t.dispose();return}const c=a.values().next().value;if(!c)return;const l=c.oKey,h=this._drawingManagerService.getDrawingOKey(l);if(!h)return;const{unitId:u,subUnitId:s,drawingId:g,drawingType:m}=h,f=h.data;if(f&&f.disablePopup)return;t==null||t.dispose();const S=this._canvasPopManagerService.getFeatureMenu(u,s,g,m);t=this.disposeWithMe(this._canvasPopManagerService.attachPopupToObject(c,{componentKey:q.COMPONENT_IMAGE_POPUP_MENU,direction:"horizontal",offset:[2,0],extraProps:{menuItems:S||this._getImageMenuItems(u,s,g,m)}})),this._drawingManagerService.focusDrawing([{unitId:u,subUnitId:s,drawingId:g}])}))),this.disposeWithMe(e.clearControl$.subscribe(()=>{t==null||t.dispose(),this._contextService.setContextValue(d.FOCUSING_COMMON_DRAWINGS,!1),this._drawingManagerService.focusDrawing(null)})),this.disposeWithMe(e.changing$.subscribe(()=>{t==null||t.dispose()}))}_getImageMenuItems(r,n,e,t){return[{label:"image-popup.edit",index:0,commandId:be.id,commandParams:{unitId:r,subUnitId:n,drawingId:e},disable:t===d.DrawingTypeEnum.DRAWING_DOM},{label:"image-popup.delete",index:1,commandId:oe.id,commandParams:{unitId:r,drawings:[{unitId:r,subUnitId:n,drawingId:e}]},disable:!1},{label:"image-popup.crop",index:2,commandId:q.OpenImageCropOperation.id,commandParams:{unitId:r,subUnitId:n,drawingId:e},disable:t===d.DrawingTypeEnum.DRAWING_DOM},{label:"image-popup.reset",index:3,commandId:q.ImageResetSizeOperation.id,commandParams:[{unitId:r,subUnitId:n,drawingId:e}],disable:t===d.DrawingTypeEnum.DRAWING_DOM}]}};me=pt([te(0,d.Inject(d.Injector)),te(1,P.IDrawingManagerService),te(2,d.Inject(N.SheetCanvasPopManagerService)),te(3,U.IRenderManagerService),te(4,d.IUniverInstanceService),te(5,d.IContextService),te(6,d.Inject(k.IUIPartsService))],me);function V(i,r,n){const{from:e,to:t,flipY:o=!1,flipX:a=!1,angle:c=0,skewX:l=0,skewY:h=0}=i,{column:u,columnOffset:s,row:g,rowOffset:m}=e,{column:f,columnOffset:S,row:v,rowOffset:C}=t,M=n.getCurrentSkeleton(),y=N.attachRangeWithCoord(M,{startColumn:u,endColumn:u,startRow:g,endRow:g});if(y==null)return;const T=N.attachRangeWithCoord(M,{startColumn:f,endColumn:f,startRow:v,endRow:v});if(T==null)return;const{startX:I,startY:D}=y,{startX:w,startY:A}=T;let E=U.precisionTo(I+s,1),L=U.precisionTo(D+m,1),j=U.precisionTo(w+S-E,1),O=U.precisionTo(A+C-L,1);y.startX===T.endX&&(j=0),y.startY===T.endY&&(O=0);const R=M.rowHeaderWidth+M.columnTotalWidth,B=M.columnHeaderHeight+M.rowTotalHeight;return E+j>R&&(E=R-j),L+O>B&&(L=B-O),{flipY:o,flipX:a,angle:c,skewX:l,skewY:h,left:E,top:L,width:j,height:O}}function F(i,r){const{left:n=0,top:e=0,width:t=0,height:o=0,flipY:a=!1,flipX:c=!1,angle:l=0,skewX:h=0,skewY:u=0}=i,s=r.getCellWithCoordByOffset(n,e);if(s==null)return;const g={column:s.actualColumn,columnOffset:U.precisionTo(n-s.startX,1),row:s.actualRow,rowOffset:U.precisionTo(e-s.startY,1)},m=r.getCellWithCoordByOffset(n+t,e+o);if(m==null)return;const f={column:m.actualColumn,columnOffset:U.precisionTo(n+t-m.startX,1),row:m.actualRow,rowOffset:U.precisionTo(e+o-m.startY,1)};return{flipY:a,flipX:c,angle:l,skewX:h,skewY:u,from:g,to:f}}var ft=Object.defineProperty,St=Object.getOwnPropertyDescriptor,vt=(i,r,n,e)=>{for(var t=e>1?void 0:e?St(r,n):r,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(r,n,t):a(t))||t);return e&&t&&ft(r,n,t),t},he=(i,r)=>(n,e)=>r(n,e,i);let Oe=class extends d.Disposable{constructor(i,r,n,e,t){super(),this._context=i,this._sheetDrawingService=r,this._drawingManagerService=n,this._sheetSelectionRenderService=e,this._sheetSkeletonManagerService=t,this._init()}_init(){this._drawingInitializeListener()}_drawingInitializeListener(){this._sheetDrawingService.initializeNotification(this._context.unitId);const i=this._sheetDrawingService.getDrawingDataForUnit(this._context.unitId);for(const r in i){const n=i[r];for(const e in n.data){const t=n.data[e];t.transform=V(t.sheetTransform,this._sheetSelectionRenderService,this._sheetSkeletonManagerService)}}this._drawingManagerService.registerDrawingData(this._context.unitId,this._sheetDrawingService.getDrawingDataForUnit(this._context.unitId)),this._drawingManagerService.initializeNotification(this._context.unitId)}};Oe=vt([he(1,p.ISheetDrawingService),he(2,P.IDrawingManagerService),he(3,d.Inject(N.ISheetSelectionRenderService)),he(4,d.Inject(N.SheetSkeletonManagerService))],Oe);function _t(i){const r=[];return i.forEach(n=>{const{parent:e,children:t}=n,{unitId:o,subUnitId:a,drawingId:c}=e,l=U.getGroupState(0,0,t.map(s=>s.transform||{})),h=t.map(s=>{const g=s.transform||{left:0,top:0},{unitId:m,subUnitId:f,drawingId:S}=s;return{unitId:m,subUnitId:f,drawingId:S,transform:{...g,left:g.left-l.left,top:g.top-l.top},groupId:c}}),u={unitId:o,subUnitId:a,drawingId:c,drawingType:d.DrawingTypeEnum.DRAWING_GROUP,transform:l};r.push({parent:u,children:h})}),r}function wt(i){const r=[];return i.forEach(n=>{const{parent:e,children:t}=n,{unitId:o,subUnitId:a,drawingId:c,transform:l={width:0,height:0}}=e;if(l==null)return;const h=t.map(s=>{const{transform:g}=s,{unitId:m,subUnitId:f,drawingId:S}=s,v=U.transformObjectOutOfGroup(g||{},l,l.width||0,l.height||0);return{unitId:m,subUnitId:f,drawingId:S,transform:v,groupId:void 0}}),u={unitId:o,subUnitId:a,drawingId:c,drawingType:d.DrawingTypeEnum.DRAWING_GROUP,transform:{left:0,top:0}};r.push({parent:u,children:h})}),r}const Pe={id:"sheet.command.group-sheet-image",type:d.CommandType.COMMAND,handler:(i,r)=>{const n=i.get(d.ICommandService),e=i.get(d.IUndoRedoService),t=i.get(p.ISheetDrawingService);if(!r)return!1;const o=[];r.forEach(({parent:m,children:f})=>{o.push(m.unitId),f.forEach(S=>{o.push(S.unitId)})});const a=t.getGroupDrawingOp(r),{unitId:c,subUnitId:l,undo:h,redo:u,objects:s}=a;return n.syncExecuteCommand(p.SetDrawingApplyMutation.id,{op:u,unitId:c,subUnitId:l,objects:s,type:p.DrawingApplyType.GROUP})?(e.pushUndoRedo({unitID:c,undoMutations:[{id:p.SetDrawingApplyMutation.id,params:{op:h,unitId:c,subUnitId:l,objects:wt(s),type:p.DrawingApplyType.UNGROUP}},{id:G.id,params:o}],redoMutations:[{id:p.SetDrawingApplyMutation.id,params:{op:u,unitId:c,subUnitId:l,objects:s,type:p.DrawingApplyType.GROUP}},{id:G.id,params:o}]}),!0):!1}},se={id:"sheet.command.insert-sheet-image",type:d.CommandType.COMMAND,handler:(i,r)=>{var M,y,T;const n=i.get(d.ICommandService),e=i.get(d.IUndoRedoService),t=i.get(p.ISheetDrawingService),o=i.get(_.SheetInterceptorService);if(!r)return!1;const a=r.drawings,c=a.map(I=>I.unitId),l=t.getBatchAddOp(a),{unitId:h,subUnitId:u,undo:s,redo:g,objects:m}=l,f=o.onCommandExecute({id:se.id,params:r}),S={id:p.SetDrawingApplyMutation.id,params:{op:g,unitId:h,subUnitId:u,objects:m,type:p.DrawingApplyType.INSERT}},v={id:p.SetDrawingApplyMutation.id,params:{op:s,unitId:h,subUnitId:u,objects:m,type:p.DrawingApplyType.REMOVE}};return d.sequenceExecute([...(M=f.preRedos)!=null?M:[],S,...f.redos],n)?(e.pushUndoRedo({unitID:h,undoMutations:[...(y=f.preUndos)!=null?y:[],v,...f.undos,{id:G.id,params:c}],redoMutations:[...(T=f.preRedos)!=null?T:[],S,...f.redos,{id:G.id,params:c}]}),!0):!1}},Ae={id:"sheet.command.set-drawing-arrange",type:d.CommandType.COMMAND,handler:(i,r)=>{const n=i.get(d.ICommandService),e=i.get(d.IUndoRedoService);if(!r)return!1;const t=i.get(p.ISheetDrawingService),{unitId:o,subUnitId:a,drawingIds:c,arrangeType:l}=r,h={unitId:o,subUnitId:a,drawingIds:c};let u;if(l===d.ArrangeTypeEnum.forward?u=t.getForwardDrawingsOp(h):l===d.ArrangeTypeEnum.backward?u=t.getBackwardDrawingOp(h):l===d.ArrangeTypeEnum.front?u=t.getFrontDrawingsOp(h):l===d.ArrangeTypeEnum.back&&(u=t.getBackDrawingsOp(h)),u==null)return!1;const{objects:s,redo:g,undo:m}=u;return n.syncExecuteCommand(p.SetDrawingApplyMutation.id,{op:g,unitId:o,subUnitId:a,objects:s,type:p.DrawingApplyType.ARRANGE})?(e.pushUndoRedo({unitID:o,undoMutations:[{id:p.SetDrawingApplyMutation.id,params:{op:m,unitId:o,subUnitId:a,objects:s,type:p.DrawingApplyType.ARRANGE}}],redoMutations:[{id:p.SetDrawingApplyMutation.id,params:{op:g,unitId:o,subUnitId:a,objects:s,type:p.DrawingApplyType.ARRANGE}}]}),!0):!1}},ce={id:"sheet.command.set-sheet-image",type:d.CommandType.COMMAND,handler:(i,r)=>{const n=i.get(d.ICommandService),e=i.get(d.IUndoRedoService),t=i.get(p.ISheetDrawingService);if(!r)return!1;const{drawings:o}=r,a=t.getBatchUpdateOp(o),{unitId:c,subUnitId:l,undo:h,redo:u,objects:s}=a;return n.syncExecuteCommand(p.SetDrawingApplyMutation.id,{unitId:c,subUnitId:l,op:u,objects:s,type:p.DrawingApplyType.UPDATE})?(e.pushUndoRedo({unitID:c,undoMutations:[{id:p.SetDrawingApplyMutation.id,params:{unitId:c,subUnitId:l,op:h,objects:s,type:p.DrawingApplyType.UPDATE}},{id:G.id,params:[c]}],redoMutations:[{id:p.SetDrawingApplyMutation.id,params:{unitId:c,subUnitId:l,op:u,objects:s,type:p.DrawingApplyType.UPDATE}},{id:G.id,params:[c]}]}),!0):!1}},Ue={id:"sheet.command.ungroup-sheet-image",type:d.CommandType.COMMAND,handler:(i,r)=>{const n=i.get(d.ICommandService),e=i.get(d.IUndoRedoService),t=i.get(p.ISheetDrawingService);if(!r)return!1;const o=[];r.forEach(({parent:m,children:f})=>{o.push(m.unitId),f.forEach(S=>{o.push(S.unitId)})});const a=t.getUngroupDrawingOp(r),{unitId:c,subUnitId:l,undo:h,redo:u,objects:s}=a;return n.syncExecuteCommand(p.SetDrawingApplyMutation.id,{op:u,unitId:c,subUnitId:l,objects:s,type:p.DrawingApplyType.UNGROUP})?(e.pushUndoRedo({unitID:c,undoMutations:[{id:p.SetDrawingApplyMutation.id,params:{op:h,unitId:c,subUnitId:l,objects:_t(s),type:p.DrawingApplyType.GROUP}},{id:G.id,params:o}],redoMutations:[{id:p.SetDrawingApplyMutation.id,params:{op:u,unitId:c,subUnitId:l,objects:s,type:p.DrawingApplyType.UNGROUP}},{id:G.id,params:o}]}),!0):!1}};var It=Object.defineProperty,Ct=Object.getOwnPropertyDescriptor,yt=(i,r,n,e)=>{for(var t=e>1?void 0:e?Ct(r,n):r,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(r,n,t):a(t))||t);return e&&t&&It(r,n,t),t},z=(i,r)=>(n,e)=>r(n,e,i);function Mt(i,r,n){const e=n*Math.PI/180,t=Math.abs(i*Math.cos(e))+Math.abs(r*Math.sin(e)),o=Math.abs(i*Math.sin(e))+Math.abs(r*Math.cos(e));return{rotatedWidth:t,rotatedHeight:o}}function ze(i,r,n,e,t){var M;const{rotatedHeight:o,rotatedWidth:a}=Mt(n,e,t),l=i.get(U.IRenderManagerService).getRenderById(r.unitId);if(!l)return!1;const u=(M=l.with(N.SheetSkeletonManagerService).getWorksheetSkeleton(r.subUnitId))==null?void 0:M.skeleton;if(u==null)return!1;const s=u.getCellByIndex(r.row,r.col),g=s.mergeInfo.endX-s.mergeInfo.startX-2,m=s.mergeInfo.endY-s.mergeInfo.startY-2,f=a/o,v=Math.ceil(Math.min(g,m*f))/a,C=!v||Number.isNaN(v)?.001:v;return{width:n*C,height:e*C}}let de=class extends d.Disposable{constructor(r,n,e,t,o,a,c,l,h,u,s,g,m){super();Y(this,"_workbookSelections");this._context=r,this._skeletonManagerService=n,this._commandService=e,this._selectionRenderService=t,this._imageIoService=o,this._fileOpenerService=a,this._sheetDrawingService=c,this._drawingManagerService=l,this._contextService=h,this._messageService=u,this._localeService=s,this._injector=m,this._workbookSelections=g.getWorkbookSelections(this._context.unitId),this._updateImageListener(),this._updateOrderListener(),this._groupDrawingListener(),this._focusDrawingListener()}async insertFloatImage(){const r=await this._fileOpenerService.openFile({multiple:!0,accept:P.DRAWING_IMAGE_ALLOW_IMAGE_LIST.map(e=>`.${e.replace("image/","")}`).join(",")}),n=r.length;return n>P.DRAWING_IMAGE_COUNT_LIMIT?(this._messageService.show({type:J.MessageType.Error,content:this._localeService.t("update-status.exceedMaxCount",String(P.DRAWING_IMAGE_COUNT_LIMIT))}),!1):n===0?!1:(r.forEach(async e=>await this._insertFloatImage(e)),!0)}async insertCellImage(){const n=(await this._fileOpenerService.openFile({multiple:!1,accept:P.DRAWING_IMAGE_ALLOW_IMAGE_LIST.map(e=>`.${e.replace("image/","")}`).join(",")}))[0];return n?(await this._insertCellImage(n),!0):!1}async _insertFloatImage(r){let n;try{n=await this._imageIoService.saveImage(r)}catch(M){const y=M.message;y===P.ImageUploadStatusType.ERROR_EXCEED_SIZE?this._messageService.show({type:J.MessageType.Error,content:this._localeService.t("update-status.exceedMaxSize",String(P.DRAWING_IMAGE_ALLOW_SIZE/(1024*1024)))}):y===P.ImageUploadStatusType.ERROR_IMAGE_TYPE?this._messageService.show({type:J.MessageType.Error,content:this._localeService.t("update-status.invalidImageType")}):y===P.ImageUploadStatusType.ERROR_IMAGE&&this._messageService.show({type:J.MessageType.Error,content:this._localeService.t("update-status.invalidImage")})}if(n==null)return;const e=this._getUnitInfo(),{unitId:t,subUnitId:o}=e,{imageId:a,imageSourceType:c,source:l,base64Cache:h}=n,{width:u,height:s,image:g}=await P.getImageSize(h||""),{width:m,height:f}=this._context.scene;this._imageIoService.addImageSourceCache(l,c,g);let S=1;if(u>P.DRAWING_IMAGE_WIDTH_LIMIT||s>P.DRAWING_IMAGE_HEIGHT_LIMIT){const M=P.DRAWING_IMAGE_WIDTH_LIMIT/u,y=P.DRAWING_IMAGE_HEIGHT_LIMIT/s;S=Math.max(M,y)}const v=this._getImagePosition(u*S,s*S,m,f);if(v==null)return;const C={unitId:t,subUnitId:o,drawingId:a,drawingType:d.DrawingTypeEnum.DRAWING_IMAGE,imageSourceType:c,source:l,transform:V(v,this._selectionRenderService,this._skeletonManagerService),sheetTransform:v};this._commandService.executeCommand(se.id,{unitId:t,drawings:[C]})}async _insertCellImage(r){let n;try{n=await this._imageIoService.saveImage(r)}catch(v){const C=v.message;C===P.ImageUploadStatusType.ERROR_EXCEED_SIZE?this._messageService.show({type:J.MessageType.Error,content:this._localeService.t("update-status.exceedMaxSize",String(P.DRAWING_IMAGE_ALLOW_SIZE/(1024*1024)))}):C===P.ImageUploadStatusType.ERROR_IMAGE_TYPE?this._messageService.show({type:J.MessageType.Error,content:this._localeService.t("update-status.invalidImageType")}):C===P.ImageUploadStatusType.ERROR_IMAGE&&this._messageService.show({type:J.MessageType.Error,content:this._localeService.t("update-status.invalidImage")})}if(n==null)return;const{imageId:e,imageSourceType:t,source:o,base64Cache:a}=n,{width:c,height:l,image:h}=await P.getImageSize(a||"");this._imageIoService.addImageSourceCache(o,t,h);const u=this._workbookSelections.getCurrentLastSelection();if(!u)return!1;const s=d.createDocumentModelWithStyle("",{}),g=ze(this._injector,{unitId:this._context.unitId,subUnitId:this._context.unit.getActiveSheet().getSheetId(),row:u.primary.actualRow,col:u.primary.actualColumn},c,l,0);if(!g)return!1;const m={size:{width:g.width,height:g.height},positionH:{relativeFrom:d.ObjectRelativeFromH.PAGE,posOffset:0},positionV:{relativeFrom:d.ObjectRelativeFromV.PARAGRAPH,posOffset:0},angle:0},f={unitId:s.getUnitId(),subUnitId:s.getUnitId(),drawingId:e,drawingType:d.DrawingTypeEnum.DRAWING_IMAGE,imageSourceType:t,source:o,transform:Ve.docDrawingPositionToTransform(m),docTransform:m,behindDoc:d.BooleanNumber.FALSE,title:"",description:"",layoutType:d.PositionedObjectLayoutType.INLINE,wrapText:d.WrapTextType.BOTH_SIDES,distB:0,distL:0,distR:0,distT:0},S=d.BuildTextUtils.drawing.add({documentDataModel:s,drawings:[f],selection:{collapsed:!0,startOffset:0,endOffset:0}});return S?(s.apply(S),this._commandService.syncExecuteCommand(_.SetRangeValuesCommand.id,{value:{[u.primary.actualRow]:{[u.primary.actualColumn]:{p:s.getSnapshot(),t:1}}}})):!1}_getUnitInfo(){const r=this._context.unit,n=r.getActiveSheet(),e=r.getUnitId(),t=n.getSheetId();return{unitId:e,subUnitId:t}}_getImagePosition(r,n,e,t){const o=this._workbookSelections.getCurrentSelections();let a={startRow:0,endRow:0,startColumn:0,endColumn:0};o&&o.length>0&&(a=o[o.length-1].range);const c=N.attachRangeWithCoord(this._skeletonManagerService.getCurrent().skeleton,a);if(c==null)return;let{startColumn:l,startRow:h,startX:u,startY:s}=c,g=!1;if(u+r>e&&(u=e-r,u<0&&(u=0,r=e),g=!0),s+n>t&&(s=t-n,s<0&&(s=0,n=t),g=!0),g){const v=this._selectionRenderService.getCellWithCoordByOffset(u,s);if(v==null)return;u=v.startX,s=v.startY,l=v.actualColumn,h=v.actualRow}const m={column:l,columnOffset:0,row:h,rowOffset:0},f=this._selectionRenderService.getCellWithCoordByOffset(u+r,s+n);if(f==null)return;const S={column:f.actualColumn,columnOffset:u+r-f.startX,row:f.actualRow,rowOffset:s+n-f.startY};return{from:m,to:S}}_updateOrderListener(){this.disposeWithMe(this._drawingManagerService.featurePluginOrderUpdate$.subscribe(r=>{const{unitId:n,subUnitId:e,drawingIds:t,arrangeType:o}=r;this._commandService.executeCommand(Ae.id,{unitId:n,subUnitId:e,drawingIds:t,arrangeType:o})}))}_updateImageListener(){this.disposeWithMe(this._drawingManagerService.featurePluginUpdate$.subscribe(r=>{const n=[];r.length!==0&&(r.forEach(e=>{const{unitId:t,subUnitId:o,drawingId:a,drawingType:c,transform:l}=e;if(l==null)return;const h=this._sheetDrawingService.getDrawingByParam({unitId:t,subUnitId:o,drawingId:a});if(h==null||h.unitId!==this._context.unitId)return;const u=F({...h.transform,...l},this._selectionRenderService);if(u==null)return;const s={...e,transform:{...h.transform,...l,...V(u,this._selectionRenderService,this._skeletonManagerService)},sheetTransform:{...u}};n.push(s)}),n.length>0&&this._commandService.executeCommand(ce.id,{unitId:r[0].unitId,drawings:n}))}))}_groupDrawingListener(){this.disposeWithMe(this._drawingManagerService.featurePluginGroupUpdate$.subscribe(r=>{this._commandService.executeCommand(Pe.id,r);const{unitId:n,subUnitId:e,drawingId:t}=r[0].parent;this._drawingManagerService.focusDrawing([{unitId:n,subUnitId:e,drawingId:t}])})),this.disposeWithMe(this._drawingManagerService.featurePluginUngroupUpdate$.subscribe(r=>{this._commandService.executeCommand(Ue.id,r)}))}_focusDrawingListener(){this.disposeWithMe(this._drawingManagerService.focus$.subscribe(r=>{r==null||r.length===0?(this._contextService.setContextValue(d.FOCUSING_COMMON_DRAWINGS,!1),this._sheetDrawingService.focusDrawing([])):(this._contextService.setContextValue(d.FOCUSING_COMMON_DRAWINGS,!0),this._sheetDrawingService.focusDrawing(r))}))}};de=yt([z(1,d.Inject(N.SheetSkeletonManagerService)),z(2,d.ICommandService),z(3,N.ISheetSelectionRenderService),z(4,P.IImageIoService),z(5,k.ILocalFileService),z(6,p.ISheetDrawingService),z(7,P.IDrawingManagerService),z(8,d.IContextService),z(9,k.IMessageService),z(10,d.Inject(d.LocaleService)),z(11,d.Inject(_.SheetsSelectionsService)),z(12,d.Inject(d.Injector))],de);var Dt=Object.defineProperty,Rt=Object.getOwnPropertyDescriptor,Tt=(i,r,n,e)=>{for(var t=e>1?void 0:e?Rt(r,n):r,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(r,n,t):a(t))||t);return e&&t&&Dt(r,n,t),t},ne=(i,r)=>(n,e)=>r(n,e,i);function Ne(i,r,n){var e,t,o,a;if(((t=(e=n==null?void 0:n.p)==null?void 0:e.body)==null?void 0:t.dataStream.length)===3&&((a=(o=n.p)==null?void 0:o.drawingsOrder)==null?void 0:a.length)===1){const c=n.p.drawings[n.p.drawingsOrder[0]],l=ze(i,{unitId:r.unitId,subUnitId:r.subUnitId,row:r.row,col:r.col},c.docTransform.size.width,c.docTransform.size.height,c.docTransform.angle);if(l)return c.transform.width=l.width,c.transform.height=l.height,c.docTransform.size.width=l.width,c.docTransform.size.height=l.height,c.transform.left=0,c.transform.top=0,c.docTransform.positionH.posOffset=0,c.docTransform.positionV.posOffset=0,n.p.documentStyle.pageSize.width=1/0,n.p.documentStyle.pageSize.height=1/0,!0}return!1}let pe=class extends d.Disposable{constructor(i,r,n,e,t,o,a){super(),this._commandService=i,this._sheetInterceptorService=r,this._univerInstanceService=n,this._injector=e,this._drawingManagerService=t,this._docDrawingController=o,this._editorBridgeService=a,this._initHandleResize(),this._handleInitEditor(),this._handleWriteCell(),this._initCellContentInterceptor()}_initHandleResize(){this.disposeWithMe(this._commandService.onCommandExecuted(i=>{let r,n=[];if(i.id===_.SetWorksheetRowHeightMutation.id){const e=i.params;n=e.ranges,r=_.getSheetCommandTarget(this._univerInstanceService,{unitId:e.unitId,subUnitId:e.subUnitId})}else if(i.id===_.SetWorksheetColWidthMutation.id){const e=i.params;n=e.ranges,r=_.getSheetCommandTarget(this._univerInstanceService,{unitId:e.unitId,subUnitId:e.subUnitId})}else if(i.id===_.SetWorksheetRowIsAutoHeightMutation.id){const e=i.params;n=e.ranges,r=_.getSheetCommandTarget(this._univerInstanceService,{unitId:e.unitId,subUnitId:e.subUnitId})}else if(i.id===_.SetWorksheetRowAutoHeightMutation.id){const e=i.params;r=_.getSheetCommandTarget(this._univerInstanceService,{unitId:e.unitId,subUnitId:e.subUnitId}),n=e.rowsAutoHeightInfo.map(t=>({startRow:t.row,endRow:t.row,startColumn:0,endColumn:9999}))}else if(i.id===_.AddWorksheetMergeMutation.id){const e=i.params;n=e.ranges,r=_.getSheetCommandTarget(this._univerInstanceService,{unitId:e.unitId,subUnitId:e.subUnitId})}else if(i.id===_.RemoveWorksheetMergeMutation.id){const e=i.params;n=e.ranges,r=_.getSheetCommandTarget(this._univerInstanceService,{unitId:e.unitId,subUnitId:e.subUnitId})}r&&n.length&&n.forEach(e=>{const t=d.Range.transformRange(e,r.worksheet);for(let o=t.startRow;o<=t.endRow;o++)for(let a=t.startColumn;a<=t.endColumn;a++)Ne(this._injector,{unitId:r.unitId,subUnitId:r.subUnitId,row:o,col:a},r.worksheet.getCellRaw(o,a))})}))}_handleInitEditor(){this.disposeWithMe(this._editorBridgeService.visible$.subscribe(i=>{i.visible?i.visible&&(this._drawingManagerService.removeDrawingDataForUnit(d.DOCS_NORMAL_EDITOR_UNIT_ID_KEY),this._docDrawingController.loadDrawingDataForUnit(d.DOCS_NORMAL_EDITOR_UNIT_ID_KEY),this._drawingManagerService.initializeNotification(d.DOCS_NORMAL_EDITOR_UNIT_ID_KEY)):this._drawingManagerService.removeDrawingDataForUnit(d.DOCS_NORMAL_EDITOR_UNIT_ID_KEY)})),this.disposeWithMe(this._commandService.onCommandExecuted(i=>{i.id===Ve.ReplaceSnapshotCommand.id&&i.params.unitId===d.DOCS_ZEN_EDITOR_UNIT_ID_KEY&&(this._drawingManagerService.removeDrawingDataForUnit(d.DOCS_ZEN_EDITOR_UNIT_ID_KEY),this._docDrawingController.loadDrawingDataForUnit(d.DOCS_ZEN_EDITOR_UNIT_ID_KEY),this._drawingManagerService.initializeNotification(d.DOCS_ZEN_EDITOR_UNIT_ID_KEY))}))}_handleWriteCell(){this.disposeWithMe(this._sheetInterceptorService.writeCellInterceptor.intercept(_.AFTER_CELL_EDIT,{priority:9999,handler:(i,r,n)=>(Ne(this._injector,{unitId:r.unitId,subUnitId:r.subUnitId,row:r.row,col:r.col},i),n(i))}))}_initCellContentInterceptor(){this.disposeWithMe(this._sheetInterceptorService.intercept(_.INTERCEPTOR_POINT.CELL_CONTENT,{effect:d.InterceptorEffectEnum.Style,priority:_.InterceptCellContentPriority.CELL_IMAGE,handler:(i,r,n)=>{var e;return i!=null&&i.p&&((e=i.p.drawingsOrder)!=null&&e.length)&&(i.interceptorStyle||(i.interceptorStyle={}),i.interceptorStyle.tr={a:0}),n(i)}}))}};pe=Tt([ne(0,d.ICommandService),ne(1,d.Inject(_.SheetInterceptorService)),ne(2,d.IUniverInstanceService),ne(3,d.Inject(d.Injector)),ne(4,P.IDrawingManagerService),ne(5,d.Inject(st.DocDrawingController)),ne(6,d.Inject(N.IEditorBridgeService))],pe);var bt=Object.defineProperty,Et=Object.getOwnPropertyDescriptor,Ot=(i,r,n,e)=>{for(var t=e>1?void 0:e?Et(r,n):r,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(r,n,t):a(t))||t);return e&&t&&bt(r,n,t),t},Ke=(i,r)=>(n,e)=>r(n,e,i);let fe=class extends d.Disposable{constructor(i,r){super(),this._autoFillService=i,this._injector=r,this._initAutoFillHooks()}_initAutoFillHooks(){this.disposeWithMe(this._autoFillService.addHook({id:"sheet-cell-image-autofill",onBeforeSubmit:(i,r,n,e)=>{new d.ObjectMatrix(e).forValue((t,o,a)=>{Ne(this._injector,{unitId:i.unitId,subUnitId:i.subUnitId,row:t,col:o},a)})}}))}};fe=Ot([Ke(0,d.Inject(N.IAutoFillService)),Ke(1,d.Inject(d.Injector))],fe);var Pt=Object.defineProperty,At=Object.getOwnPropertyDescriptor,Ut=(i,r,n,e)=>{for(var t=e>1?void 0:e?At(r,n):r,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(r,n,t):a(t))||t);return e&&t&&Pt(r,n,t),t},Se=(i,r)=>(n,e)=>r(n,e,i);let ve=class extends d.Disposable{constructor(r,n,e,t){super();Y(this,"_isSetCursor",!1);this._hoverManagerService=r,this._renderManagerService=n,this._selectionsService=e,this._drawingRenderService=t}_initHover(){}_initImageClick(){}};ve=Ut([Se(0,d.Inject(N.HoverManagerService)),Se(1,d.Inject(U.IRenderManagerService)),Se(2,d.Inject(_.SheetsSelectionsService)),Se(3,d.Inject(q.DrawingRenderService))],ve);var Nt=Object.defineProperty,jt=Object.getOwnPropertyDescriptor,Wt=(i,r,n,e)=>{for(var t=e>1?void 0:e?jt(r,n):r,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(r,n,t):a(t))||t);return e&&t&&Nt(r,n,t),t},je=(i,r)=>(n,e)=>r(n,e,i);let _e=class extends d.Disposable{constructor(r,n,e){super();Y(this,"_copyInfo");this._sheetClipboardService=r,this._renderManagerService=n,this._sheetDrawingService=e,this._initCopyPaste()}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:"SHEET_IMAGE_UI_PLUGIN",onBeforeCopy:(r,n,e)=>this._collect(r,n,e),onPasteCells:(r,n,e,t)=>{const{copyType:o=N.COPY_TYPE.COPY,pasteType:a}=t,{range:c}=r||{},{range:l,unitId:h,subUnitId:u}=n;return this._generateMutations(l,{copyType:o,pasteType:a,copyRange:c,unitId:h,subUnitId:u})},onPastePlainText:(r,n)=>({undos:[],redos:[]})})}_collect(r,n,e){var g;const t=(g=this._renderManagerService.getRenderById(r))==null?void 0:g.with(N.SheetSkeletonManagerService);if(!t)return;const o=t.attachRangeWithCoord(e);if(!o)return;const{startX:a,endX:c,startY:l,endY:h}=o,u=this._sheetDrawingService.getDrawingData(r,n),s=[];Object.keys(u).forEach(m=>{const f=u[m],{transform:S}=f;if(f.anchorType!==p.SheetDrawingAnchorType.Both||!S)return;const{left:v=0,top:C=0,width:M=0,height:y=0}=S,{drawingStartX:T,drawingEndX:I,drawingStartY:D,drawingEndY:w}={drawingStartX:v,drawingEndX:v+M,drawingStartY:C,drawingEndY:C+y};a<=T&&I<=c&&l<=D&&w<=h&&s.push(f)}),s.length&&(this._copyInfo={drawings:s,unitId:r,subUnitId:n})}_generateMutations(r,n){var E;if(!this._copyInfo)return{redos:[],undos:[]};if([N.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,N.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,N.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,N.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMULA].includes(n.pasteType))return{redos:[],undos:[]};const{copyRange:e}=n;if(!e)return{redos:[],undos:[]};const{drawings:t,unitId:o,subUnitId:a}=this._copyInfo,{ranges:[c,l],mapFunc:h}=N.virtualizeDiscreteRanges([e,r]),{row:u,col:s}=h(c.startRow,c.startColumn),{row:g,col:m}=h(l.startRow,l.startColumn),f=(E=this._renderManagerService.getRenderById(o))==null?void 0:E.with(N.SheetSkeletonManagerService);if(!f)return{redos:[],undos:[]};const S=f.attachRangeWithCoord({startRow:u,endRow:u,startColumn:s,endColumn:s}),v=f.attachRangeWithCoord({startRow:g,endRow:g,startColumn:m,endColumn:m});if(!S||!v)return{redos:[],undos:[]};const C=[],M=[],y=v.startX-S.startX,T=v.startY-S.startY,I=g-u,D=m-s,w=n.copyType===N.COPY_TYPE.CUT,{_sheetDrawingService:A}=this;return t.forEach(L=>{const{transform:j,sheetTransform:O}=L;if(!j)return;const R={...L,unitId:o,subUnitId:a,drawingId:w?L.drawingId:d.Tools.generateRandomId(),transform:{...j,left:j.left+y,top:j.top+T},sheetTransform:{to:{...O.to,row:O.to.row+I,column:O.to.column+D},from:{...O.from,row:O.from.row+I,column:O.from.column+D}}};if(w){const{undo:B,redo:H,objects:Z}=A.getBatchUpdateOp([R]);C.push({id:p.SetDrawingApplyMutation.id,params:{unitId:o,subUnitId:a,type:p.DrawingApplyType.UPDATE,op:H,objects:Z}}),M.push({id:p.SetDrawingApplyMutation.id,params:{unitId:o,subUnitId:a,type:p.DrawingApplyType.UPDATE,op:B,objects:Z}})}else{const{undo:B,redo:H,objects:Z}=A.getBatchAddOp([R]);C.push({id:p.SetDrawingApplyMutation.id,params:{op:H,unitId:o,subUnitId:a,objects:Z,type:p.DrawingApplyType.INSERT}}),M.push({id:p.SetDrawingApplyMutation.id,params:{op:B,unitId:o,subUnitId:a,objects:Z,type:p.DrawingApplyType.REMOVE}})}}),{redos:C,undos:M}}};_e=Wt([je(0,N.ISheetClipboardService),je(1,U.IRenderManagerService),je(2,p.ISheetDrawingService)],_e);var Lt=Object.defineProperty,Bt=Object.getOwnPropertyDescriptor,Gt=(i,r,n,e)=>{for(var t=e>1?void 0:e?Bt(r,n):r,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(r,n,t):a(t))||t);return e&&t&&Lt(r,n,t),t},le=(i,r)=>(n,e)=>r(n,e,i);let we=class extends d.Disposable{constructor(i,r,n,e,t){super(),this._drawingManagerService=i,this._renderManagerService=r,this._permissionService=n,this._univerInstanceService=e,this._userManagerService=t,this._initDrawingVisible(),this._initDrawingEditable(),this._initViewPermissionChange(),this._initEditPermissionChange()}_initDrawingVisible(){const i=this._univerInstanceService.getCurrentTypeOfUnit$(d.UniverInstanceType.UNIVER_SHEET);this.disposeWithMe(W.combineLatest([i,this._userManagerService.currentUser$]).subscribe(([r,n])=>{if(!r){this._drawingManagerService.setDrawingVisible(!1);return}r.activeSheet$.subscribe(e=>{if(!e){this._drawingManagerService.setDrawingVisible(!1);return}const t=r.getUnitId(),o=e.getSheetId();if(this._permissionService.composePermission([new _.WorkbookViewPermission(t).id,new _.WorksheetViewPermission(t,o).id]).every(c=>c.value))this._drawingManagerService.setDrawingVisible(!0);else{this._drawingManagerService.setDrawingVisible(!1);const c=r.getUnitId(),l=e.getSheetId(),h=this._drawingManagerService.getDrawingData(c,l),u=Object.values(h),s=this._renderManagerService.getRenderById(c),g=s==null?void 0:s.scene;if(g==null)return;g.getAllObjectsByOrder().forEach(f=>{f.classType===U.RENDER_CLASS_TYPE.IMAGE&&u.some(S=>f.oKey.includes(S.drawingId))&&g.removeObject(f)})}})}))}_initDrawingEditable(){const i=this._univerInstanceService.getCurrentTypeOfUnit$(d.UniverInstanceType.UNIVER_SHEET);this.disposeWithMe(W.combineLatest([i,this._userManagerService.currentUser$]).subscribe(([r,n])=>{if(!r){this._drawingManagerService.setDrawingEditable(!1);return}r.activeSheet$.subscribe(e=>{if(!e){this._drawingManagerService.setDrawingEditable(!1);return}const t=r.getUnitId(),o=e.getSheetId();if(this._permissionService.composePermission([new _.WorkbookEditablePermission(t).id,new _.WorksheetEditPermission(t,o).id]).every(c=>c.value))this._drawingManagerService.setDrawingEditable(!0);else{this._drawingManagerService.setDrawingEditable(!1);const c=r.getUnitId(),l=e.getSheetId(),h=this._drawingManagerService.getDrawingData(c,l),u=Object.values(h),s=this._renderManagerService.getRenderById(c),g=s==null?void 0:s.scene;if(g==null)return;g.getAllObjectsByOrder().forEach(f=>{f.classType===U.RENDER_CLASS_TYPE.IMAGE&&u.some(S=>f.oKey.includes(S.drawingId))&&g.detachTransformerFrom(f)})}})}))}_initViewPermissionChange(){const i=this._univerInstanceService.getCurrentTypeOfUnit$(d.UniverInstanceType.UNIVER_SHEET);this.disposeWithMe(W.combineLatest([i,this._userManagerService.currentUser$]).subscribe(([r,n])=>{r&&r.activeSheet$.subscribe(e=>{var s;if(!e)return;const t=r.getUnitId(),o=e.getSheetId();let a=!0;const c=this._renderManagerService.getRenderById(t),l=c==null?void 0:c.scene;if(l==null)return;const h=l.getTransformerByCreate(),u=this._permissionService.composePermission$([new _.WorkbookViewPermission(t).id,new _.WorksheetViewPermission(t,o).id]).pipe(W.map(g=>g.every(m=>m.value)));u==null||u.pipe(W.filter(g=>g!==a),W.distinctUntilChanged()).subscribe({next:g=>{a=g,this._drawingManagerService.setDrawingVisible(g);const m=l.getAllObjectsByOrder(),f=this._drawingManagerService.getDrawingData(t,o),S=Object.values(f);g?this._drawingManagerService.addNotification(S):(m.forEach(v=>{v.classType===U.RENDER_CLASS_TYPE.IMAGE&&S.some(C=>v.oKey.includes(C.drawingId))&&l.removeObject(v)}),h.clearSelectedObjects())}}),(s=this._permissionService.getPermissionPoint$(new _.WorksheetViewPermission(t,o).id))==null||s.pipe(W.filter(g=>g.value!==a),W.distinctUntilChanged()).subscribe({complete:()=>{a=!0,this._drawingManagerService.setDrawingVisible(!0);const g=this._drawingManagerService.getDrawingData(t,o),m=Object.values(g);this._drawingManagerService.addNotification(m)}})})}))}_initEditPermissionChange(){const i=this._univerInstanceService.getCurrentTypeOfUnit$(d.UniverInstanceType.UNIVER_SHEET);this.disposeWithMe(W.combineLatest([i,this._userManagerService.currentUser$]).subscribe(([r,n])=>{r&&r.activeSheet$.subscribe(e=>{var s;if(!e)return;const t=r.getUnitId(),o=e.getSheetId();let a=!0;const c=this._renderManagerService.getRenderById(t),l=c==null?void 0:c.scene;if(l==null)return;const h=l.getTransformerByCreate(),u=this._permissionService.composePermission$([new _.WorkbookEditablePermission(t).id,new _.WorksheetEditPermission(t,o).id]).pipe(W.map(g=>g.every(m=>m.value)));u==null||u.pipe(W.filter(g=>g!==a),W.distinctUntilChanged()).subscribe({next:g=>{a=g,this._drawingManagerService.setDrawingEditable(g);const m=l.getAllObjectsByOrder(),f=this._drawingManagerService.getDrawingData(t,o),S=Object.values(f);g?(m.forEach(v=>{v.classType===U.RENDER_CLASS_TYPE.IMAGE&&S.some(C=>v.oKey.includes(C.drawingId))&&l.attachTransformerTo(v)}),this._drawingManagerService.addNotification(S)):(m.forEach(v=>{v.classType===U.RENDER_CLASS_TYPE.IMAGE&&S.some(C=>v.oKey.includes(C.drawingId))&&l.detachTransformerFrom(v)}),h.clearSelectedObjects())}}),(s=this._permissionService.getPermissionPoint$(new _.WorksheetEditPermission(t,o).id))==null||s.pipe(W.filter(g=>g.value!==a),W.distinctUntilChanged()).subscribe({complete:()=>{a=!0;const g=r.getUnitId(),m=e.getSheetId(),f=this._drawingManagerService.getDrawingData(g,m),S=Object.values(f),v=this._renderManagerService.getRenderById(g),C=v==null?void 0:v.scene;if(C==null)return;this._drawingManagerService.setDrawingEditable(!0),C.getAllObjectsByOrder().forEach(y=>{y.classType===U.RENDER_CLASS_TYPE.IMAGE&&S.some(T=>y.oKey.includes(T.drawingId))&&C.detachTransformerFrom(y)})}})})}))}};we=Gt([le(0,P.IDrawingManagerService),le(1,U.IRenderManagerService),le(2,d.IPermissionService),le(3,d.IUniverInstanceService),le(4,d.Inject(d.UserManagerService))],we);var kt=Object.defineProperty,Ft=Object.getOwnPropertyDescriptor,Ht=(i,r,n,e)=>{for(var t=e>1?void 0:e?Ft(r,n):r,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(r,n,t):a(t))||t);return e&&t&&kt(r,n,t),t},Ie=(i,r)=>(n,e)=>r(n,e,i);let Ce=class extends d.Disposable{constructor(i,r,n,e){super(),this._sheetPrintInterceptorService=i,this._drawingRenderService=r,this._drawingManagerService=n,this._renderManagerService=e,this._initPrinting()}_initPrinting(){this.disposeWithMe(this._sheetPrintInterceptorService.interceptor.intercept(this._sheetPrintInterceptorService.interceptor.getInterceptPoints().PRINTING_COMPONENT_COLLECT,{handler:(i,r,n)=>{const{unitId:e,scene:t,subUnitId:o}=r,a=this._drawingManagerService.getDrawingDataForUnit(e),c=a==null?void 0:a[o];return c&&c.order.forEach(l=>{this._drawingRenderService.renderDrawing(c.data[l],t)}),n()}})),this.disposeWithMe(this._sheetPrintInterceptorService.interceptor.intercept(this._sheetPrintInterceptorService.interceptor.getInterceptPoints().PRINTING_RANGE,{handler:(i,r,n)=>{const{unitId:e,subUnitId:t}=r,o=this._renderManagerService.getRenderById(e);if(!o)return n(i);const a=o.with(N.SheetSkeletonManagerService).getWorksheetSkeleton(t);if(!a)return n(i);const c=this._drawingManagerService.getDrawingDataForUnit(e),l=c==null?void 0:c[r.subUnitId];if(!l)return n(i);const{scaleX:h,scaleY:u}=o.scene,s=i?{...i}:{startColumn:0,endColumn:0,endRow:0,startRow:0},g=l.order.map(m=>l.data[m]).filter(m=>m.drawingType!==d.DrawingTypeEnum.DRAWING_DOM);return g.length?(g.forEach(m=>{if(!m.groupId&&m.transform&&d.Tools.isDefine(m.transform.left)&&d.Tools.isDefine(m.transform.top)&&d.Tools.isDefine(m.transform.width)&&d.Tools.isDefine(m.transform.height)){const f=a.skeleton.getCellIndexByOffset(m.transform.left,m.transform.top,h,u,{x:0,y:0}),S=a.skeleton.getCellIndexByOffset(m.transform.left+m.transform.width,m.transform.top+m.transform.height,h,u,{x:0,y:0});f.column<s.startColumn&&(s.startColumn=f.column),f.row<s.startRow&&(s.startRow=f.row),s.endRow<S.row&&(s.endRow=S.row),s.endColumn<S.column&&(s.endColumn=S.column)}}),n(s)):n(i)}}))}};Ce=Ht([Ie(0,d.Inject(N.SheetPrintInterceptorService)),Ie(1,d.Inject(q.DrawingRenderService)),Ie(2,P.IDrawingManagerService),Ie(3,U.IRenderManagerService)],Ce);var $t=Object.defineProperty,Vt=Object.getOwnPropertyDescriptor,Yt=(i,r,n,e)=>{for(var t=e>1?void 0:e?Vt(r,n):r,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(r,n,t):a(t))||t);return e&&t&&$t(r,n,t),t},Q=(i,r)=>(n,e)=>r(n,e,i);const xt=[_.InsertRowCommand.id,_.InsertColCommand.id,_.RemoveRowCommand.id,_.RemoveColCommand.id,_.DeleteRangeMoveLeftCommand.id,_.DeleteRangeMoveUpCommand.id,_.InsertRangeMoveDownCommand.id,_.InsertRangeMoveRightCommand.id,_.DeltaRowHeightCommand.id,_.SetRowHeightCommand.id,_.DeltaColumnWidthCommand.id,_.SetColWidthCommand.id,_.SetRowHiddenCommand.id,_.SetSpecificRowsVisibleCommand.id,_.SetSpecificColsVisibleCommand.id,_.SetColHiddenCommand.id,_.MoveColsCommand.id,_.MoveRowsCommand.id,_.MoveRangeCommand.id],Xt=[_.SetRowVisibleMutation.id,_.SetRowHiddenMutation.id,_.SetColVisibleMutation.id,_.SetColHiddenMutation.id,_.SetWorksheetRowHeightMutation.id,_.SetWorksheetColWidthMutation.id];let We=class extends d.Disposable{constructor(i,r,n,e,t,o,a,c,l){super(),this._context=i,this._renderManagerService=r,this._commandService=n,this._selectionRenderService=e,this._skeletonManagerService=t,this._sheetInterceptorService=o,this._sheetDrawingService=a,this._drawingManagerService=c,this._univerInstanceService=l,this._sheetInterceptorListener(),this._commandListener(),this._sheetRefreshListener()}_sheetInterceptorListener(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:i=>{if(!xt.includes(i.id))return{redos:[],undos:[]};if(i.params==null)return{redos:[],undos:[]};const r=i.id;if(r===_.InsertRowCommand.id)return this._moveRowInterceptor(i.params,"insert");if([_.MoveColsCommand.id,_.MoveRowsCommand.id,_.MoveRangeCommand.id].includes(r))return this._moveRangeInterceptor(i.params);if(r===_.InsertColCommand.id)return this._moveColInterceptor(i.params,"insert");if(r===_.RemoveRowCommand.id)return this._moveRowInterceptor(i.params,"remove");if(r===_.RemoveColCommand.id)return this._moveColInterceptor(i.params,"remove");if(r===_.DeleteRangeMoveLeftCommand.id){const{range:n}=i.params;return this._getRangeMoveUndo(n,0)}else if(r===_.DeleteRangeMoveUpCommand.id){const{range:n}=i.params;return this._getRangeMoveUndo(n,1)}else if(r===_.InsertRangeMoveDownCommand.id){const{range:n}=i.params;return this._getRangeMoveUndo(n,2)}else if(r===_.InsertRangeMoveRightCommand.id){const{range:n}=i.params;return this._getRangeMoveUndo(n,3)}else if(r===_.SetRowHiddenCommand.id||r===_.SetSpecificRowsVisibleCommand.id){const n=i.params,{unitId:e,subUnitId:t,ranges:o}=n;return this._getDrawingUndoForRowVisible(e,t,o)}else if(r===_.SetSpecificColsVisibleCommand.id||r===_.SetColHiddenCommand.id){const n=i.params,{unitId:e,subUnitId:t,ranges:o}=n;return this._getDrawingUndoForColVisible(e,t,o)}else if(r===_.DeltaRowHeightCommand.id||r===_.SetRowHeightCommand.id||r===_.DeltaColumnWidthCommand.id||r===_.SetColWidthCommand.id){const n=i.params,{unitId:e,subUnitId:t,ranges:o}=n,a=r===_.DeltaRowHeightCommand.id||r===_.SetRowHeightCommand.id;return this._getDrawingUndoForRowAndColSize(e,t,o,a)}return{redos:[],undos:[]}}}))}_getRangeMoveUndo(i,r){const n=_.getSheetCommandTarget(this._univerInstanceService);if(n==null)return{redos:[],undos:[]};const e=n.unitId,t=n.subUnitId,o=[],a=[],c=this._sheetDrawingService.getDrawingData(e,t),l=[],h=[];if(Object.keys(c).forEach(u=>{const s=c[u],{updateDrawings:g,deleteDrawings:m}=this._getUpdateOrDeleteDrawings(i,r,s);l.push(...g),h.push(...m)}),l.length===0&&h.length===0)return{redos:[],undos:[]};if(l.length>0){const u=this._sheetDrawingService.getBatchUpdateOp(l),{undo:s,redo:g,objects:m}=u;o.push({id:p.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:g,objects:m,type:p.DrawingApplyType.UPDATE}}),a.push({id:p.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:s,objects:m,type:p.DrawingApplyType.UPDATE}})}if(h.length>0){const u=this._sheetDrawingService.getBatchRemoveOp(h),s=u.undo,g=u.redo,m=u.objects;o.push({id:p.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:g,objects:m,type:p.DrawingApplyType.REMOVE}}),a.push({id:p.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:s,objects:m,type:p.DrawingApplyType.INSERT}})}return o.push({id:G.id,params:[e]}),a.push({id:G.id,params:[e]}),{redos:o,undos:a}}_getUpdateOrDeleteDrawings(i,r,n){const e=[],t=[],{sheetTransform:o,anchorType:a=p.SheetDrawingAnchorType.Position,transform:c,unitId:l,subUnitId:h,drawingId:u}=n,{from:s,to:g}=o,{row:m,column:f}=s,{row:S,column:v}=g;if(o==null||c==null)return{updateDrawings:e,deleteDrawings:t};const{startRow:C,endRow:M,startColumn:y,endColumn:T}=i;let I=null,D=null;if(r===0&&m>=C&&S<=M)if(f>=y&&v<=T)t.push({unitId:l,subUnitId:h,drawingId:u});else{const w=this._shrinkCol(o,c,y,T,a);I=w==null?void 0:w.newSheetTransform,D=w==null?void 0:w.newTransform}else if(r===1&&f>=y&&v<=T)if(m>=C&&S<=M)t.push({unitId:l,subUnitId:h,drawingId:u});else{const w=this._shrinkRow(o,c,C,M,a);I=w==null?void 0:w.newSheetTransform,D=w==null?void 0:w.newTransform}else if(r===2){const w=this._expandRow(o,c,C,M,a);I=w==null?void 0:w.newSheetTransform,D=w==null?void 0:w.newTransform}else if(r===3){const w=this._expandCol(o,c,y,T,a);I=w==null?void 0:w.newSheetTransform,D=w==null?void 0:w.newTransform}if(I!=null&&D!=null){const w=V(I,this._selectionRenderService,this._skeletonManagerService);e.push({...n,sheetTransform:I,transform:w})}return{updateDrawings:e,deleteDrawings:t}}_remainDrawingSize(i,r,n){const e=F({...i},this._selectionRenderService);e!=null&&r.push({...n,sheetTransform:e})}_getDrawingUndoForColVisible(i,r,n){const e=this._drawingManagerService.getDrawingData(i,r),t=[],o=[];if(Object.keys(e).forEach(u=>{const s=e[u],{sheetTransform:g,transform:m,anchorType:f=p.SheetDrawingAnchorType.Position}=s;if(f===p.SheetDrawingAnchorType.None)this._remainDrawingSize(m,t,s);else{const{from:S,to:v}=g,{row:C,column:M}=S,{row:y,column:T}=v;for(let I=0;I<n.length;I++){const D=n[I],{startRow:w,endRow:A,startColumn:E,endColumn:L}=D;if(T<E)continue;if(f===p.SheetDrawingAnchorType.Position){let R=null,B=null;if(M>=E&&M<=L){const H=this._skeletonManagerService.attachRangeWithCoord({startColumn:M,endColumn:L,startRow:S.row,endRow:v.row});if(H==null)return;B={...m,left:H.startX}}if(B!=null&&(R=F(B,this._selectionRenderService),R!=null&&B!=null)){t.push({...s,sheetTransform:R,transform:B});break}this._remainDrawingSize(m,t,s);continue}if(M>=E&&T<=L)continue;let j=null,O=null;if(M>=E&&M<=L){const R=this._skeletonManagerService.attachRangeWithCoord({startColumn:M,endColumn:L,startRow:S.row,endRow:v.row});if(R==null)return;O={...m,left:(R==null?void 0:R.startX)||0,width:((m==null?void 0:m.width)||0)-R.endX+R.startX}}else if(T>=E&&T<=L){const R=this._skeletonManagerService.attachRangeWithCoord({startColumn:E,endColumn:T,startRow:S.row,endRow:v.row});if(R==null)return;O={...m,left:R.startX-((m==null?void 0:m.width)||0)}}else{const R=this._skeletonManagerService.attachRangeWithCoord({startColumn:E,endColumn:L,startRow:S.row,endRow:v.row});if(R==null)return;if(O={...m,width:((m==null?void 0:m.width)||0)-R.endX+R.startX},j=F(O,this._selectionRenderService),j!=null&&O!=null){o.push({...s,sheetTransform:j,transform:O});break}}if(O!=null&&(j=F(O,this._selectionRenderService)),O!=null&&j!=null){t.push({...s,sheetTransform:j,transform:O});break}else this._remainDrawingSize(m,t,s)}}}),t.length===0&&o.length===0)return{redos:[],undos:[]};const{redos:a,undos:c}=this._createUndoAndRedoMutation(i,r,t),l=[],h=[];if(o.length>0){const{redos:u,undos:s}=this._createUndoAndRedoMutation(i,r,o);l.push(...u),h.push(...s)}return{redos:a,undos:c,preRedos:l,preUndos:h}}_createUndoAndRedoMutation(i,r,n){const e=this._sheetDrawingService.getBatchUpdateOp(n),{undo:t,redo:o,objects:a}=e,c=[{id:p.SetDrawingApplyMutation.id,params:{unitId:i,subUnitId:r,op:o,objects:a,type:p.DrawingApplyType.UPDATE}},{id:G.id,params:[i]}],l=[{id:p.SetDrawingApplyMutation.id,params:{unitId:i,subUnitId:r,op:t,objects:a,type:p.DrawingApplyType.UPDATE}},{id:G.id,params:[i]}];return{redos:c,undos:l}}_getDrawingUndoForRowVisible(i,r,n){const e=this._drawingManagerService.getDrawingData(i,r),t=[],o=[];if(Object.keys(e).forEach(u=>{const s=e[u],{sheetTransform:g,transform:m,anchorType:f=p.SheetDrawingAnchorType.Position}=s;if(f===p.SheetDrawingAnchorType.None)this._remainDrawingSize(m,t,s);else{const{from:S,to:v}=g,{row:C,column:M}=S,{row:y,column:T}=v;for(let I=0;I<n.length;I++){const D=n[I],{startRow:w,endRow:A,startColumn:E,endColumn:L}=D;if(y<w)continue;if(f===p.SheetDrawingAnchorType.Position){let R=null,B=null;if(C>=w&&C<=A){const H=this._skeletonManagerService.attachRangeWithCoord({startColumn:S.column,endColumn:v.column,startRow:C,endRow:A});if(H==null)return;B={...m,top:H.startY}}if(B!=null&&(R=F(B,this._selectionRenderService),R!=null&&B!=null)){t.push({...s,sheetTransform:R,transform:B});break}this._remainDrawingSize(m,t,s);continue}if(C>=w&&y<=A)continue;let j=null,O=null;if(C>=w&&C<=A){const R=this._skeletonManagerService.attachRangeWithCoord({startColumn:S.column,endColumn:v.column,startRow:C,endRow:A});if(R==null)return;O={...m,top:(R==null?void 0:R.startY)||0,height:((m==null?void 0:m.height)||0)-R.endY+R.startY}}else if(y>=w&&y<=A){const R=this._skeletonManagerService.attachRangeWithCoord({startColumn:S.column,endColumn:v.column,startRow:w,endRow:y});if(R==null)return;O={...m,top:R.startY-((m==null?void 0:m.height)||0)}}else{const R=this._skeletonManagerService.attachRangeWithCoord({startColumn:S.column,endColumn:v.column,startRow:w,endRow:A});if(R==null)return;if(O={...m,height:((m==null?void 0:m.height)||0)-R.endY+R.startY},j=F(O,this._selectionRenderService),j!=null&&O!=null){o.push({...s,sheetTransform:j,transform:O});break}}if(O!=null&&(j=F(O,this._selectionRenderService)),O!=null&&j!=null){t.push({...s,sheetTransform:j,transform:O});break}else this._remainDrawingSize(m,t,s)}}}),t.length===0&&o.length===0)return{redos:[],undos:[]};const{redos:a,undos:c}=this._createUndoAndRedoMutation(i,r,t),l=[],h=[];if(o.length>0){const{redos:u,undos:s}=this._createUndoAndRedoMutation(i,r,o);l.push(...u),h.push(...s)}return{redos:a,undos:c,preRedos:l,preUndos:h}}_getDrawingUndoForRowAndColSize(i,r,n,e){const t=this._drawingManagerService.getDrawingData(i,r),o=[];return Object.keys(t).forEach(a=>{const c=t[a],{sheetTransform:l,transform:h,anchorType:u=p.SheetDrawingAnchorType.Position}=c;if(u===p.SheetDrawingAnchorType.None)this._remainDrawingSize(h,o,c);else{const{from:s,to:g}=l,{row:m,column:f}=s,{row:S,column:v}=g;for(let C=0;C<n.length;C++){const M=n[C],{startRow:y,endRow:T,startColumn:I,endColumn:D}=M;if(S<y||v<I)continue;if(u===p.SheetDrawingAnchorType.Position&&(m<=y&&S>=T||f<=I&&v>=D)){this._remainDrawingSize(h,o,c);continue}const w=V({...l},this._selectionRenderService,this._skeletonManagerService);if(w!=null){o.push({...c,transform:w});break}}}}),o.length===0?{redos:[],undos:[]}:this._createUndoAndRedoMutation(i,r,o)}_getUnitIdAndSubUnitId(i,r){let n,e;if(r==="insert")n=i.unitId,e=i.subUnitId;else{const t=_.getSheetCommandTarget(this._univerInstanceService);if(t==null)return;n=t.unitId,e=t.subUnitId}return{unitId:n,subUnitId:e}}_moveRangeInterceptor(i){var y,T;const{toRange:r,fromRange:n}=i,e=_.getSheetCommandTarget(this._univerInstanceService);if(!e)return{redos:[],undos:[]};const{unitId:t,subUnitId:o}=e,a=(T=(y=this._renderManagerService.getRenderById(t))==null?void 0:y.with(N.SheetSkeletonManagerService))==null?void 0:T.getCurrentSkeleton();if(!a)return{redos:[],undos:[]};const c=N.attachRangeWithCoord(a,n);if(!c)return{redos:[],undos:[]};const{startX:l,endX:h,startY:u,endY:s}=c,g=this._sheetDrawingService.getDrawingData(t,o),m=[];Object.keys(g).forEach(I=>{const D=g[I];if(D.anchorType!==p.SheetDrawingAnchorType.Both)return;const{transform:w}=D;if(!w)return;const{left:A=0,top:E=0,width:L=0,height:j=0}=w,{drawingStartX:O,drawingEndX:R,drawingStartY:B,drawingEndY:H}={drawingStartX:A,drawingEndX:A+L,drawingStartY:E,drawingEndY:E+j};l<=O&&R<=h&&u<=B&&H<=s&&m.push(D)});const f=[],S=[],v=r.startRow-n.startRow,C=r.startColumn-n.startColumn,M=m.map(I=>{const D=I.sheetTransform,w={to:{...D.to,row:D.to.row+v,column:D.to.column+C},from:{...D.from,row:D.from.row+v,column:D.from.column+C}},A=V(w,this._selectionRenderService,this._skeletonManagerService);return{unitId:t,subUnitId:o,drawingId:I.drawingId,transform:A,sheetTransform:w}});if(M.length){const I=this._sheetDrawingService.getBatchUpdateOp(M),{undo:D,redo:w,objects:A}=I;f.push({id:p.SetDrawingApplyMutation.id,params:{unitId:t,subUnitId:o,op:w,objects:A,type:p.DrawingApplyType.UPDATE}}),S.push({id:p.SetDrawingApplyMutation.id,params:{unitId:t,subUnitId:o,op:D,objects:A,type:p.DrawingApplyType.UPDATE}})}return{redos:f,undos:S}}_moveRowInterceptor(i,r){const n=this._getUnitIdAndSubUnitId(i,r);if(n==null)return{redos:[],undos:[]};const{unitId:e,subUnitId:t}=n,{range:o}=i,a=o.startRow,c=o.endRow,l=[],h=[],u=this._sheetDrawingService.getDrawingData(e,t),s=[],g=[];if(Object.keys(u).forEach(m=>{const f=u[m],{sheetTransform:S,transform:v,anchorType:C=p.SheetDrawingAnchorType.Position}=f;if(S==null||v==null)return;let M,y;if(r==="insert"){const I=this._expandRow(S,v,a,c,C);M=I==null?void 0:I.newSheetTransform,y=I==null?void 0:I.newTransform}else{const{from:I,to:D}=S,{row:w}=I,{row:A}=D;if(C===p.SheetDrawingAnchorType.Both&&w>=a&&A<=c)g.push({unitId:e,subUnitId:t,drawingId:m});else{const E=this._shrinkRow(S,v,a,c,C);M=E==null?void 0:E.newSheetTransform,y=E==null?void 0:E.newTransform}}if(!M||!y)return;const T={unitId:e,subUnitId:t,drawingId:m,transform:y,sheetTransform:M};s.push(T)}),s.length===0&&g.length===0)return{redos:[],undos:[]};if(s.length>0){const m=this._sheetDrawingService.getBatchUpdateOp(s),{undo:f,redo:S,objects:v}=m;l.push({id:p.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:S,objects:v,type:p.DrawingApplyType.UPDATE}}),h.push({id:p.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:f,objects:v,type:p.DrawingApplyType.UPDATE}})}if(g.length>0){const m=this._sheetDrawingService.getBatchRemoveOp(g),f=m.undo,S=m.redo,v=m.objects;l.push({id:p.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:S,objects:v,type:p.DrawingApplyType.REMOVE}}),h.push({id:p.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:f,objects:v,type:p.DrawingApplyType.INSERT}})}return l.push({id:G.id,params:[e]}),h.push({id:G.id,params:[e]}),{redos:l,undos:h}}_moveColInterceptor(i,r){const n=this._getUnitIdAndSubUnitId(i,r);if(n==null)return{redos:[],undos:[]};const{unitId:e,subUnitId:t}=n,{range:o}=i,a=o.startColumn,c=o.endColumn,l=[],h=[],u=this._sheetDrawingService.getDrawingData(e,t),s=[],g=[];if(Object.keys(u).forEach(m=>{const f=u[m],{sheetTransform:S,transform:v,anchorType:C=p.SheetDrawingAnchorType.Position}=f;if(S==null||v==null)return;let M,y;if(r==="insert"){const I=this._expandCol(S,v,a,c,C);M=I==null?void 0:I.newSheetTransform,y=I==null?void 0:I.newTransform}else{const{from:I,to:D}=S,{column:w}=I,{column:A}=D;if(C===p.SheetDrawingAnchorType.Both&&w>=a&&A<=c)g.push({unitId:e,subUnitId:t,drawingId:m});else{const E=this._shrinkCol(S,v,a,c,C);M=E==null?void 0:E.newSheetTransform,y=E==null?void 0:E.newTransform}}if(!M||!y)return;const T={unitId:e,subUnitId:t,drawingId:m,transform:y,sheetTransform:M};s.push(T)}),s.length===0&&g.length===0)return{redos:[],undos:[]};if(s.length>0){const m=this._sheetDrawingService.getBatchUpdateOp(s),{undo:f,redo:S,objects:v}=m;l.push({id:p.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:S,objects:v,type:p.DrawingApplyType.UPDATE}}),h.push({id:p.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:f,objects:v,type:p.DrawingApplyType.UPDATE}})}if(g.length>0){const m=this._sheetDrawingService.getBatchRemoveOp(g),f=m.undo,S=m.redo,v=m.objects;l.push({id:p.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:S,objects:v,type:p.DrawingApplyType.REMOVE}}),h.push({id:p.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:f,objects:v,type:p.DrawingApplyType.INSERT}})}return l.push({id:G.id,params:[e]}),h.push({id:G.id,params:[e]}),{redos:l,undos:h}}_expandCol(i,r,n,e,t=p.SheetDrawingAnchorType.Position){const o=e-n+1,{from:a,to:c}=i,{column:l}=a,{column:h}=c;if(t===p.SheetDrawingAnchorType.None)return{newSheetTransform:F({...r},this._selectionRenderService),newTransform:r};let u=null,s=null;if(l>=n){const g=this._skeletonManagerService.attachRangeWithCoord({startColumn:n,endColumn:e,startRow:a.row,endRow:c.row});if(g==null)return;s={...r,left:(r.left||0)+g.endX-g.startX},u=F(s,this._selectionRenderService)}else if(h>=e)if(t===p.SheetDrawingAnchorType.Both)u={from:{...a},to:{...c,column:h+o}},s=V(u,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:F({...r},this._selectionRenderService),newTransform:r};return u!=null&&s!=null?{newSheetTransform:u,newTransform:s}:null}_shrinkCol(i,r,n,e,t=p.SheetDrawingAnchorType.Position){const o=e-n+1,{from:a,to:c}=i,{column:l}=a,{column:h}=c;if(t===p.SheetDrawingAnchorType.None)return{newSheetTransform:F({...r},this._selectionRenderService),newTransform:r};let u=null,s=null;if(l>e)u={from:{...a,column:l-o},to:{...c,column:h-o}},s=V(u,this._selectionRenderService,this._skeletonManagerService);else{if(l>=n&&h<=e)return null;if(l<n&&h>e)if(t===p.SheetDrawingAnchorType.Both)u={from:{...a},to:{...c,column:h-o}},s=V(u,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:F({...r},this._selectionRenderService),newTransform:r};else if(l>=n&&l<=e){if(l===n)s={...r,left:(r.left||0)-i.from.columnOffset};else{const g=this._skeletonManagerService.attachRangeWithCoord({startColumn:n,endColumn:l-1,startRow:a.row,endRow:c.row});if(g==null)return;s={...r,left:(r.left||0)-g.endX+g.startX-i.from.columnOffset}}u=F(s,this._selectionRenderService)}else if(h>=n&&h<=e&&t===p.SheetDrawingAnchorType.Both){const g=this._skeletonManagerService.attachRangeWithCoord({startColumn:n-1,endColumn:n-1,startRow:a.row,endRow:c.row});if(g==null)return;u={from:{...a},to:{...c,column:n-1,columnOffset:g.endX-g.startX}},s=V(u,this._selectionRenderService,this._skeletonManagerService)}}return u!=null&&s!=null?{newSheetTransform:u,newTransform:s}:null}_expandRow(i,r,n,e,t=p.SheetDrawingAnchorType.Position){const o=e-n+1,{from:a,to:c}=i,{row:l}=a,{row:h}=c;if(t===p.SheetDrawingAnchorType.None)return{newSheetTransform:F({...r},this._selectionRenderService),newTransform:r};let u=null,s=null;if(l>=n){const g=this._skeletonManagerService.attachRangeWithCoord({startRow:n,endRow:e,startColumn:a.column,endColumn:c.column});if(g==null)return;s={...r,top:(r.top||0)+g.endY-g.startY},u=F(s,this._selectionRenderService)}else if(h>=e)if(t===p.SheetDrawingAnchorType.Both)u={from:{...a},to:{...c,row:h+o}},s=V(u,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:F({...r},this._selectionRenderService),newTransform:r};return u!=null&&s!=null?{newSheetTransform:u,newTransform:s}:null}_shrinkRow(i,r,n,e,t=p.SheetDrawingAnchorType.Position){const o=e-n+1,{from:a,to:c}=i,{row:l}=a,{row:h}=c;if(t===p.SheetDrawingAnchorType.None)return{newSheetTransform:F({...r},this._selectionRenderService),newTransform:r};let u=null,s=null;if(l>e)u={from:{...a,row:l-o},to:{...c,row:h-o}},s=V(u,this._selectionRenderService,this._skeletonManagerService);else{if(l>=n&&h<=e)return null;if(l<n&&h>e)if(t===p.SheetDrawingAnchorType.Both)u={from:{...a},to:{...c,row:h-o}},s=V(u,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:F({...r},this._selectionRenderService),newTransform:r};else if(l>=n&&l<=e){if(l===n)s={...r,top:(r.top||0)-i.from.rowOffset};else{const g=this._skeletonManagerService.attachRangeWithCoord({startRow:n,endRow:l-1,startColumn:a.column,endColumn:c.column});if(g==null)return;s={...r,top:(r.top||0)-g.endY+g.startY-i.from.rowOffset}}u=F(s,this._selectionRenderService)}else if(h>=n&&h<=e&&t===p.SheetDrawingAnchorType.Both){const g=this._skeletonManagerService.attachRangeWithCoord({startColumn:a.column,endColumn:a.column,startRow:n-1,endRow:n-1});if(g==null)return;u={from:{...a},to:{...c,row:n-1,rowOffset:g.endY-g.startY}},s=V(u,this._selectionRenderService,this._skeletonManagerService)}}return u!=null&&s!=null?{newSheetTransform:u,newTransform:s}:null}_commandListener(){this.disposeWithMe(this._commandService.onCommandExecuted(i=>{i.id===_.SetWorksheetActiveOperation.id&&setTimeout(()=>{const r=i.params,{unitId:n,subUnitId:e}=r,t=this._drawingManagerService.drawingManagerData,o=[],a=[];Object.keys(t).forEach(c=>{const l=t[c];l!=null&&Object.keys(l).forEach(h=>{const u=l[h].data;u!=null&&Object.keys(u).forEach(s=>{if(c===n&&h===e){const g=u[s];g.transform=V(g.sheetTransform,this._selectionRenderService,this._skeletonManagerService),o.push(u[s])}else a.push(u[s])})})}),this._drawingManagerService.removeNotification(a),this._drawingManagerService.addNotification(o)},0)}))}_sheetRefreshListener(){this.disposeWithMe(this._commandService.onCommandExecuted(i=>{Xt.includes(i.id)&&requestIdleCallback(()=>{const r=i.params,{unitId:n,subUnitId:e,ranges:t}=r;this._refreshDrawingTransform(n,e,t)})}))}_refreshDrawingTransform(i,r,n){const e=this._drawingManagerService.getDrawingData(i,r),t=[];Object.keys(e).forEach(o=>{const a=e[o],{sheetTransform:c,transform:l,anchorType:h=p.SheetDrawingAnchorType.Position}=a;if(h===p.SheetDrawingAnchorType.None)return!0;const{from:u,to:s}=c,{row:g,column:m}=u,{row:f,column:S}=s;for(let v=0;v<n.length;v++){const C=n[v],{startRow:M,endRow:y,startColumn:T,endColumn:I}=C;if(d.Rectangle.intersects({startRow:M,endRow:y,startColumn:T,endColumn:I},{startRow:g,endRow:f,startColumn:m,endColumn:S})||g>y||m>I){const D=h===p.SheetDrawingAnchorType.Position,w=V(c,this._selectionRenderService,this._skeletonManagerService);t.push({...a,transform:{...w,width:D?l==null?void 0:l.width:w==null?void 0:w.width,height:D?l==null?void 0:l.height:w==null?void 0:w.height}});break}}}),t.length!==0&&(this._drawingManagerService.refreshTransform(t),this._commandService.syncExecuteCommand(G.id,[i]))}};We=Yt([Q(1,U.IRenderManagerService),Q(2,d.ICommandService),Q(3,N.ISheetSelectionRenderService),Q(4,d.Inject(N.SheetSkeletonManagerService)),Q(5,d.Inject(_.SheetInterceptorService)),Q(6,p.ISheetDrawingService),Q(7,P.IDrawingManagerService),Q(8,d.IUniverInstanceService)],We);var K=function(){return K=Object.assign||function(i){for(var r,n=1,e=arguments.length;n<e;n++){r=arguments[n];for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(i[t]=r[t])}return i},K.apply(this,arguments)},zt=function(i,r){var n={};for(var e in i)Object.prototype.hasOwnProperty.call(i,e)&&r.indexOf(e)<0&&(n[e]=i[e]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var t=0,e=Object.getOwnPropertySymbols(i);t<e.length;t++)r.indexOf(e[t])<0&&Object.prototype.propertyIsEnumerable.call(i,e[t])&&(n[e[t]]=i[e[t]]);return n},Je=x.forwardRef(function(i,r){var n=i.icon,e=i.id,t=i.className,o=i.extend,a=zt(i,["icon","id","className","extend"]),c="univerjs-icon univerjs-icon-".concat(e," ").concat(t||"").trim(),l=x.useRef("_".concat(Zt()));return Ze(n,"".concat(e),{defIds:n.defIds,idSuffix:l.current},K({ref:r,className:c},a),o)});function Ze(i,r,n,e,t){return x.createElement(i.tag,K(K({key:r},Kt(i,n,t)),e),(Jt(i,n).children||[]).map(function(o,a){return Ze(o,"".concat(r,"-").concat(i.tag,"-").concat(a),n,void 0,t)}))}function Kt(i,r,n){var e=K({},i.attrs);n!=null&&n.colorChannel1&&e.fill==="colorChannel1"&&(e.fill=n.colorChannel1);var t=r.defIds;return!t||t.length===0||(i.tag==="use"&&e["xlink:href"]&&(e["xlink:href"]=e["xlink:href"]+r.idSuffix),Object.entries(e).forEach(function(o){var a=o[0],c=o[1];typeof c=="string"&&(e[a]=c.replace(/url\(#(.*)\)/,"url(#$1".concat(r.idSuffix,")")))})),e}function Jt(i,r){var n,e=r.defIds;return!e||e.length===0?i:i.tag==="defs"&&(!((n=i.children)===null||n===void 0)&&n.length)?K(K({},i),{children:i.children.map(function(t){return typeof t.attrs.id=="string"&&e&&e.indexOf(t.attrs.id)>-1?K(K({},t),{attrs:K(K({},t.attrs),{id:t.attrs.id+r.idSuffix})}):t})}):i}function Zt(){return Math.random().toString(36).substring(2,8)}Je.displayName="UniverIcon";var qt={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M2.2498 3.65005C2.2498 2.87685 2.87661 2.25005 3.64981 2.25005H7.9998C8.33118 2.25005 8.5998 1.98142 8.5998 1.65005C8.5998 1.31868 8.33118 1.05005 7.9998 1.05005H3.64981C2.21387 1.05005 1.0498 2.21411 1.0498 3.65005V12.35C1.0498 13.786 2.21386 14.95 3.6498 14.95H12.3498C13.7857 14.95 14.9498 13.786 14.9498 12.3501V8.00005C14.9498 7.66868 14.6812 7.40005 14.3498 7.40005C14.0184 7.40005 13.7498 7.66868 13.7498 8.00005V9.23974L12.2385 8.1063C11.7252 7.72129 11.0068 7.7723 10.5531 8.22605L9.00869 9.77041L6.73916 7.8251C6.24387 7.40055 5.5095 7.41278 5.02864 7.85359L2.2498 10.4009V3.65005ZM2.2498 12.0287V12.35C2.2498 13.1232 2.87661 13.75 3.6498 13.75H12.3498C13.123 13.75 13.7498 13.1232 13.7498 12.3501V10.7397L11.5186 9.06631C11.4829 9.03956 11.433 9.04314 11.4016 9.07458L9.92249 10.5537L11.1015 11.5642C11.3531 11.7799 11.3822 12.1587 11.1666 12.4103C10.9509 12.6619 10.5721 12.691 10.3205 12.4753L5.9582 8.7362C5.92384 8.70674 5.87288 8.70758 5.83952 8.73816L2.2498 12.0287Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M11.8097 1.14783C12.1411 1.14783 12.4097 1.41646 12.4097 1.74783V3.297H14.1541C14.4855 3.297 14.7541 3.56563 14.7541 3.897C14.7541 4.22837 14.4855 4.497 14.1541 4.497H12.4097V6.24167C12.4097 6.57304 12.1411 6.84167 11.8097 6.84167C11.4783 6.84167 11.2097 6.57304 11.2097 6.24167V4.497H9.6603C9.32893 4.497 9.0603 4.22837 9.0603 3.897C9.0603 3.56563 9.32893 3.297 9.6603 3.297H11.2097V1.74783C11.2097 1.41646 11.4783 1.14783 11.8097 1.14783Z"}}]},qe=x.forwardRef(function(i,r){return x.createElement(Je,Object.assign({},i,{id:"add-image-single",ref:r,icon:qt}))});qe.displayName="AddImageSingle";const Le={id:"sheet.command.delete-drawing",type:d.CommandType.COMMAND,handler:i=>{const r=i.get(d.ICommandService),e=i.get(p.ISheetDrawingService).getFocusDrawings();if(e.length===0)return!1;const t=e[0].unitId,o=e.map(a=>{const{unitId:c,subUnitId:l,drawingId:h,drawingType:u}=a;return{unitId:c,subUnitId:l,drawingId:h,drawingType:u}});return r.executeCommand(oe.id,{unitId:t,drawings:o})}},ye={id:"sheet.command.insert-float-image",type:d.CommandType.COMMAND,handler:i=>{var n,e;return(e=(n=i.get(U.IRenderManagerService).getCurrentTypeOfRenderer(d.UniverInstanceType.UNIVER_SHEET))==null?void 0:n.with(de).insertFloatImage())!=null?e:!1}},Be={id:"sheet.command.insert-cell-image",type:d.CommandType.COMMAND,handler:i=>{var n,e;return(e=(n=i.get(U.IRenderManagerService).getCurrentTypeOfRenderer(d.UniverInstanceType.UNIVER_SHEET))==null?void 0:n.with(de).insertCellImage())!=null?e:!1}},ie={id:"sheet.command.move-drawing",type:d.CommandType.COMMAND,handler:(i,r)=>{const n=i.get(d.ICommandService),e=i.get(p.ISheetDrawingService),t=i.get(N.ISheetSelectionRenderService),{direction:o}=r,a=e.getFocusDrawings();if(a.length===0)return!1;const c=a[0].unitId,l=a.map(u=>{const{transform:s}=u;if(s==null)return null;const g={...s},{left:m=0,top:f=0}=s;return o===d.Direction.UP?g.top=f-1:o===d.Direction.DOWN?g.top=f+1:o===d.Direction.LEFT?g.left=m-1:o===d.Direction.RIGHT&&(g.left=m+1),{...u,transform:g,sheetTransform:F(g,t)}}).filter(u=>u!=null);return n.syncExecuteCommand(ce.id,{unitId:c,drawings:l})?(n.syncExecuteCommand(G.id,[c]),!0):!1}},Qe="addition-and-subtraction-single",Ge="sheet.menu.image";function Qt(i){return{id:Ge,type:k.MenuItemType.SUBITEMS,icon:Qe,tooltip:"sheetImage.title",hidden$:k.getMenuHiddenObservable(i,d.UniverInstanceType.UNIVER_SHEET),disabled$:N.getCurrentRangeDisable$(i,{workbookTypes:[_.WorkbookEditablePermission],worksheetTypes:[_.WorksheetEditPermission],rangeTypes:[_.RangeProtectionPermissionEditPoint]})}}function en(i){return{id:ye.id,title:"sheetImage.upload.float",type:k.MenuItemType.BUTTON,hidden$:k.getMenuHiddenObservable(i,d.UniverInstanceType.UNIVER_SHEET)}}function tn(i){return{id:Be.id,title:"sheetImage.upload.cell",type:k.MenuItemType.BUTTON}}const ee={imageCommonPanel:"univer-image-common-panel",imageCommonPanelGrid:"univer-image-common-panel-grid",imageCommonPanelBorder:"univer-image-common-panel-border",imageCommonPanelTitle:"univer-image-common-panel-title",imageCommonPanelSubtitle:"univer-image-common-panel-subtitle",imageCommonPanelRow:"univer-image-common-panel-row",imageCommonPanelRowVertical:"univer-image-common-panel-row-vertical",imageCommonPanelColumn:"univer-image-common-panel-column",imageCommonPanelColumnCenter:"univer-image-common-panel-column-center",imageCommonPanelInline:"univer-image-common-panel-inline",imageCommonPanelSpan2:"univer-image-common-panel-span2",imageCommonPanelSpan3:"univer-image-common-panel-span3",imageCommonPanelInput:"univer-image-common-panel-input",sheetImageMenu:"univer-sheet-image-menu",sheetImageMenuInput:"univer-sheet-image-menu-input"};function et(i){var r,n,e="";if(typeof i=="string"||typeof i=="number")e+=i;else if(typeof i=="object")if(Array.isArray(i)){var t=i.length;for(r=0;r<t;r++)i[r]&&(n=et(i[r]))&&(e&&(e+=" "),e+=n)}else for(n in i)i[n]&&(e&&(e+=" "),e+=n);return e}function Me(){for(var i,r,n=0,e="",t=arguments.length;n<t;n++)(i=arguments[n])&&(r=et(i))&&(e&&(e+=" "),e+=r);return e}const nn=i=>{var y;const r=d.useDependency(d.ICommandService),n=d.useDependency(d.LocaleService),e=d.useDependency(P.IDrawingManagerService),t=d.useDependency(U.IRenderManagerService),{drawings:o}=i,a=o[0];if(a==null)return;const{unitId:c}=a,l=t.getRenderById(c),h=l==null?void 0:l.scene;if(h==null)return;const u=h.getTransformerByCreate(),[s,g]=x.useState(!0),m=(y=a.anchorType)!=null?y:p.SheetDrawingAnchorType.Position,[f,S]=x.useState(m);function v(T,I){const D=[];return T.forEach(w=>{const{oKey:A}=w,E=I.getDrawingOKey(A);if(E==null)return D.push(null),!0;const{unitId:L,subUnitId:j,drawingId:O,drawingType:R,anchorType:B,sheetTransform:H}=E;D.push({unitId:L,subUnitId:j,drawingId:O,anchorType:B,sheetTransform:H,drawingType:R})}),D}x.useEffect(()=>{const T=u.clearControl$.subscribe(D=>{D===!0&&g(!1)}),I=u.changeStart$.subscribe(D=>{var E;const{objects:w}=D,A=v(w,e);if(A.length===0)g(!1);else if(A.length>=1){g(!0);const L=((E=A[0])==null?void 0:E.anchorType)||p.SheetDrawingAnchorType.Position;S(L)}});return()=>{I.unsubscribe(),T.unsubscribe()}},[]);function C(T){S(T);const I=e.getFocusDrawings();if(I.length===0)return;const D=I.map(w=>({unitId:w.unitId,subUnitId:w.subUnitId,drawingId:w.drawingId,anchorType:T}));r.executeCommand(ce.id,{unitId:I[0].unitId,drawings:D})}const M=T=>T?"block":"none";return $.jsxs("div",{className:Me(ee.imageCommonPanelGrid,ee.imageCommonPanelBorder),style:{display:M(s)},children:[$.jsx("div",{className:ee.imageCommonPanelRow,children:$.jsx("div",{className:Me(ee.imageCommonPanelColumn,ee.imageCommonPanelTitle),children:$.jsx("div",{children:n.t("drawing-anchor.title")})})}),$.jsx("div",{className:Me(ee.imageCommonPanelRow),children:$.jsx("div",{className:Me(ee.imageCommonPanelColumn),children:$.jsxs(J.RadioGroup,{value:f,onChange:C,direction:"vertical",children:[$.jsx(J.Radio,{value:p.SheetDrawingAnchorType.Both,children:n.t("drawing-anchor.both")}),$.jsx(J.Radio,{value:p.SheetDrawingAnchorType.Position,children:n.t("drawing-anchor.position")}),$.jsx(J.Radio,{value:p.SheetDrawingAnchorType.None,children:n.t("drawing-anchor.none")})]})})})]})},rn=()=>{const i=d.useDependency(P.IDrawingManagerService),r=i.getFocusDrawings(),[n,e]=x.useState(r);return x.useEffect(()=>{const t=i.focus$.subscribe(o=>{e(o)});return()=>{t.unsubscribe()}},[]),!!(n!=null&&n.length)&&$.jsxs("div",{className:ee.imageCommonPanel,children:[$.jsx(q.DrawingCommonPanel,{drawings:n}),$.jsx(nn,{drawings:n})]})},on={[k.RibbonStartGroup.FORMULAS_INSERT]:{[Ge]:{order:3,menuItemFactory:Qt,[ye.id]:{order:0,menuItemFactory:en},[Be.id]:{order:1,menuItemFactory:tn}}}};function ue(i){return!i.getContextValue(d.FOCUSING_FX_BAR_EDITOR)&&!i.getContextValue(d.EDITOR_ACTIVATED)&&!i.getContextValue(d.FOCUSING_PANEL_EDITOR)&&i.getContextValue(d.FOCUSING_COMMON_DRAWINGS)}const an={id:ie.id,description:"shortcut.sheet.drawing-move-down",group:"4_sheet-drawing-view",binding:k.KeyCode.ARROW_DOWN,priority:100,preconditions:ue,staticParameters:{direction:d.Direction.DOWN}},sn={id:ie.id,description:"shortcut.sheet.drawing-move-up",group:"4_sheet-drawing-view",binding:k.KeyCode.ARROW_UP,priority:100,preconditions:ue,staticParameters:{direction:d.Direction.UP}},cn={id:ie.id,description:"shortcut.sheet.drawing-move-left",group:"4_sheet-drawing-view",binding:k.KeyCode.ARROW_LEFT,priority:100,preconditions:ue,staticParameters:{direction:d.Direction.LEFT}},dn={id:ie.id,description:"shortcut.sheet.drawing-move-right",group:"4_sheet-drawing-view",binding:k.KeyCode.ARROW_RIGHT,priority:100,preconditions:ue,staticParameters:{direction:d.Direction.RIGHT}},ln={id:Le.id,description:"shortcut.sheet.drawing-delete",group:"4_sheet-drawing-view",preconditions:ue,binding:k.KeyCode.DELETE,mac:k.KeyCode.BACKSPACE};var un=Object.defineProperty,gn=Object.getOwnPropertyDescriptor,mn=(i,r,n,e)=>{for(var t=e>1?void 0:e?gn(r,n):r,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(r,n,t):a(t))||t);return e&&t&&un(r,n,t),t},De=(i,r)=>(n,e)=>r(n,e,i);let Re=class extends d.Disposable{constructor(i,r,n,e){super(),this._componentManager=i,this._menuManagerService=r,this._commandService=n,this._shortcutService=e,this._init()}_initCustomComponents(){const i=this._componentManager;this.disposeWithMe(i.register(Qe,qe)),this.disposeWithMe(i.register(Ye,rn))}_initMenus(){this._menuManagerService.mergeMenu(on)}_initCommands(){[ye,Be,se,oe,ce,Te,G,be,Pe,Ue,ie,Le,Ae].forEach(i=>this.disposeWithMe(this._commandService.registerCommand(i)))}_initShortcuts(){[an,sn,cn,dn,ln].forEach(i=>{this.disposeWithMe(this._shortcutService.registerShortcut(i))})}_init(){this._initCommands(),this._initCustomComponents(),this._initMenus(),this._initShortcuts()}};Re=mn([De(0,d.Inject(k.ComponentManager)),De(1,k.IMenuManagerService),De(2,d.ICommandService),De(3,k.IShortcutService)],Re);var hn=Object.defineProperty,pn=Object.getOwnPropertyDescriptor,fn=(i,r,n,e)=>{for(var t=e>1?void 0:e?pn(r,n):r,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(r,n,t):a(t))||t);return e&&t&&hn(r,n,t),t},re=(i,r)=>(n,e)=>r(n,e,i);function Sn(i,r,n,e){const{scaleX:t,scaleY:o}=r.getAncestorScale(),a=r.getViewport(U.SHEET_VIEWPORT_KEY.VIEW_MAIN),c={left:!0,top:!0};if(!a)return{...i,absolute:c};const{left:l,right:h,top:u,bottom:s}=i,g=e.getFreeze(),{startColumn:m,startRow:f,xSplit:S,ySplit:v}=g,C=n.getNoMergeCellPositionByIndexWithNoHeader(f-v,m-S),M=n.getNoMergeCellPositionByIndexWithNoHeader(f,m),{rowHeaderWidth:y,columnHeaderHeight:T}=n,I=M.startX-C.startX,D=M.startY-C.startY,{top:w,left:A,viewportScrollX:E,viewportScrollY:L}=a;let j,O;l<A?(c.left=!0,j=(I+y+(l-A))*t,O=Math.max(Math.min((I+y+(h-A))*t,(I+y)*t),(h-E)*t)):(c.left=!1,j=Math.max((l-E)*t,(I+y)*t),O=Math.max((h-E)*t,(I+y)*t));let R,B;return u<w?(c.top=!0,R=(D+T+(u-w))*o,B=Math.max(Math.min((D+T+(h-w))*o,(D+T)*o),(s-L)*o)):(c.top=!1,R=Math.max((u-L)*o,(D+T)*o),B=Math.max((s-L)*o,(D+T)*o)),{left:j,right:O,top:R,bottom:B,absolute:c}}const ke=(i,r,n,e)=>{const{scene:t}=r,{left:o,top:a,width:c,height:l,angle:h}=i,u={left:o,right:o+c,top:a,bottom:a+l},s=Sn(u,t,n,e),{scaleX:g,scaleY:m}=t.getAncestorScale();return{startX:s.left,endX:s.right,startY:s.top,endY:s.bottom,rotate:h,width:c*g,height:l*m,absolute:s.absolute}};b.SheetCanvasFloatDomManagerService=class extends d.Disposable{constructor(n,e,t,o,a,c,l){super();Y(this,"_domLayerMap",new Map);Y(this,"_domLayerInfoMap",new Map);Y(this,"_transformChange$",new W.Subject);Y(this,"transformChange$",this._transformChange$.asObservable());Y(this,"_add$",new W.Subject);Y(this,"add$",this._add$.asObservable());Y(this,"_remove$",new W.Subject);Y(this,"remove$",this._remove$.asObservable());Y(this,"_hooks",[]);this._renderManagerService=n,this._univerInstanceService=e,this._commandService=t,this._drawingManagerService=o,this._canvasFloatDomService=a,this._sheetDrawingService=c,this._lifecycleService=l,this._drawingAddListener(),this._featureUpdateListener(),this._deleteListener(),this._bindScrollEvent()}_bindScrollEvent(){this._lifecycleService.lifecycle$.pipe(W.filter(n=>n===d.LifecycleStages.Rendered),W.take(1)).subscribe(()=>{this._scrollUpdateListener()})}_ensureMap(n,e){let t=this._domLayerMap.get(n);t||(t=new Map,this._domLayerMap.set(n,t));let o=t.get(e);return o||(o=new Map,t.set(e,o)),o}getFloatDomInfo(n){return this._domLayerInfoMap.get(n)}_getSceneAndTransformerByDrawingSearch(n){if(n==null)return;const e=this._renderManagerService.getRenderById(n),t=e==null?void 0:e.scene;if(e==null||t==null)return null;const o=t.getTransformerByCreate(),a=e.engine.getCanvasElement();return{scene:t,transformer:o,renderObject:e,canvas:a}}_getFloatDomProps(n){let e;return this._hooks.forEach(t=>{e=t.onGetFloatDomProps(n)}),e}_drawingAddListener(){this.disposeWithMe(this._drawingManagerService.add$.subscribe(n=>{n.forEach(e=>{var it,ot,at;const{unitId:t,subUnitId:o,drawingId:a}=e,c=_.getSheetCommandTarget(this._univerInstanceService,{unitId:t,subUnitId:o}),l=this._drawingManagerService.getDrawingByParam(e),h=this._univerInstanceService.getUnit(t,d.UniverInstanceType.UNIVER_SHEET);if(!h)return;const u=h.getActiveSheet().getSheetId();if(!l||!c)return;const s=(it=this._renderManagerService.getRenderById(t))==null?void 0:it.with(N.SheetSkeletonManagerService).getWorksheetSkeleton(o);if(!s)return;const{transform:g,drawingType:m,data:f}=l;if(m!==d.DrawingTypeEnum.DRAWING_DOM&&m!==d.DrawingTypeEnum.DRAWING_CHART)return;const S=this._getSceneAndTransformerByDrawingSearch(t);if(S==null)return;const{scene:v,canvas:C}=S;if(g==null)return!0;if(u!==o)return;const{left:M,top:y,width:T,height:I,angle:D,flipX:w,flipY:A,skewX:E,skewY:L}=g,j=P.getDrawingShapeKeyByDrawingSearch({unitId:t,subUnitId:o,drawingId:a}),O=v.getObject(j);if(O!=null){O.transformByState({left:M,top:y,width:T,height:I,angle:D,flipX:w,flipY:A,skewX:E,skewY:L});return}const R={left:M,top:y,width:T,height:I,zIndex:this._drawingManagerService.getDrawingOrder(t,o).length-1},B=m===d.DrawingTypeEnum.DRAWING_CHART;B&&(R.fill="white",R.rotateEnabled=!1,f&&f.border&&(R.stroke=f.border),R.paintFirst="stroke",R.strokeWidth=1,R.borderEnabled=!1,R.radius=8);const H=new U.Rect(j,R);B&&H.setObjectType(U.ObjectType.CHART),v.addObject(H,U.DRAWING_OBJECT_LAYER_INDEX),l.allowTransform!==!1&&v.attachTransformerTo(H);const Z=this._ensureMap(t,o),He=new d.DisposableCollection,Cn=ke(H,S.renderObject,s.skeleton,c.worksheet),$e=new W.BehaviorSubject(Cn),yn={dispose:He,rect:H,position$:$e,unitId:t,subUnitId:o};this._canvasFloatDomService.addFloatDom({position$:$e,id:a,componentKey:l.componentKey,onPointerDown:X=>{C.dispatchEvent(new PointerEvent(X.type,X))},onPointerMove:X=>{C.dispatchEvent(new PointerEvent(X.type,X))},onPointerUp:X=>{C.dispatchEvent(new PointerEvent(X.type,X))},onWheel:X=>{C.dispatchEvent(new WheelEvent(X.type,X))},props:(at=(ot=Z.get(a))==null?void 0:ot.props)!=null?at:this._getFloatDomProps(a),data:f,unitId:t});const rt=H.onTransformChange$.subscribeEvent(()=>{const X=ke(H,S.renderObject,s.skeleton,c.worksheet);$e.next(X)});He.add(()=>{this._canvasFloatDomService.removeFloatDom(a)}),rt&&He.add(rt),this._domLayerInfoMap.set(a,yn),Z.set(a,{...Z.get(a)})})})),this.disposeWithMe(this._drawingManagerService.remove$.subscribe(n=>{n.forEach(e=>{const{unitId:t,subUnitId:o,drawingId:a}=e,c=P.getDrawingShapeKeyByDrawingSearch({unitId:t,subUnitId:o,drawingId:a}),l=this._getSceneAndTransformerByDrawingSearch(t);if(l==null)return;const{transformer:h,scene:u}=l,s=u.getObject(c);s!=null&&s.oKey&&h.clearControlByIds([s==null?void 0:s.oKey])})}))}_scrollUpdateListener(){const n=(e,t)=>{var u;const o=this._getSceneAndTransformerByDrawingSearch(e),a=this._ensureMap(e,t),c=Array.from(a.keys()),l=_.getSheetCommandTarget(this._univerInstanceService,{unitId:e,subUnitId:t}),h=(u=this._renderManagerService.getRenderById(e))==null?void 0:u.with(N.SheetSkeletonManagerService).getWorksheetSkeleton(t);!o||!l||!h||c.forEach(s=>{const g=this._domLayerInfoMap.get(s);if(g){const m=ke(g.rect,o.renderObject,h.skeleton,l.worksheet);g.position$.next(m)}})};this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(d.UniverInstanceType.UNIVER_SHEET).pipe(W.filter(e=>!!e),W.switchMap(e=>e.activeSheet$),W.filter(e=>!!e),W.map(e=>{const t=this._renderManagerService.getRenderById(e.getUnitId());return t?{render:t,unitId:e.getUnitId(),subUnitId:e.getSheetId()}:null}),W.filter(e=>!!e),W.switchMap(e=>d.fromEventSubject(e.render.scene.getViewport(U.SHEET_VIEWPORT_KEY.VIEW_MAIN).onScrollAfter$).pipe(W.map(()=>({unitId:e.unitId,subUnitId:e.subUnitId}))))).subscribe(({unitId:e,subUnitId:t})=>{n(e,t)})),this.disposeWithMe(this._commandService.onCommandExecuted(e=>{var t,o;if(e.id===N.SetZoomRatioOperation.id){const a=e.params,{unitId:c}=a;Array.from((o=(t=this._domLayerMap.get(c))==null?void 0:t.keys())!=null?o:[]).forEach(h=>{n(c,h)})}else if(e.id===_.SetFrozenMutation.id){const{unitId:a,subUnitId:c}=e.params;n(a,c)}}))}_getPosition(n,e){var m;const{startX:t,endX:o,startY:a,endY:c}=n,l=(m=this._renderManagerService.getRenderById(e))==null?void 0:m.with(N.ISheetSelectionRenderService);if(l==null)return;const h=l.getCellWithCoordByOffset(t,a);if(h==null)return;const u={column:h.actualColumn,columnOffset:t-h.startX,row:h.actualRow,rowOffset:a-h.startY},s=l.getCellWithCoordByOffset(o,c);if(s==null)return;const g={column:s.actualColumn,columnOffset:o-s.startX,row:s.actualRow,rowOffset:c-s.startY};return{from:u,to:g}}_featureUpdateListener(){this.disposeWithMe(this._drawingManagerService.update$.subscribe(n=>{n.forEach(e=>{const t=this._drawingManagerService.getDrawingByParam(e);if(!t||t.drawingType!==d.DrawingTypeEnum.DRAWING_DOM&&t.drawingType!==d.DrawingTypeEnum.DRAWING_CHART)return;const o={...t.transform};this._transformChange$.next({id:e.drawingId,value:o})})}))}_deleteListener(){this.disposeWithMe(this._drawingManagerService.remove$.subscribe(n=>{n.forEach(e=>{this._removeDom(e.drawingId)})}))}updateFloatDomProps(n,e,t,o){const a=this._domLayerInfoMap.get(t),c=this._getSceneAndTransformerByDrawingSearch(n);if(a&&c){const{scene:l}=c,h=P.getDrawingShapeKeyByDrawingSearch({unitId:n,subUnitId:e,drawingId:t}),u=l.getObject(h);u&&u instanceof U.Rect&&u.setProps(o)}}addFloatDomToPosition(n,e){const t=_.getSheetCommandTarget(this._univerInstanceService,{unitId:n.unitId,subUnitId:n.subUnitId});if(!t)throw new Error("cannot find current target!");const{unitId:o,subUnitId:a}=t,{initPosition:c,componentKey:l,data:h,allowTransform:u=!0}=n,s=e!=null?e:d.generateRandomId(),g=this._getPosition(c,o);if(g==null)return;this._ensureMap(o,a).set(s,n);const f={unitId:o,subUnitId:a,drawingId:s,drawingType:n.type||d.DrawingTypeEnum.DRAWING_DOM,componentKey:l,sheetTransform:g,transform:{left:c.startX,top:c.startY,width:c.endX-c.startX,height:c.endY-c.startY},data:h,allowTransform:u};return this._commandService.executeCommand(se.id,{unitId:o,drawings:[f]}),this._add$.next({unitId:o,subUnitId:a,id:s}),{id:s,dispose:()=>{this._removeDom(s,!0)}}}_removeDom(n,e=!1){const t=this._domLayerInfoMap.get(n);if(!t)return;const{unitId:o,subUnitId:a}=t;this._domLayerInfoMap.delete(n),t.dispose.dispose();const c=this._getSceneAndTransformerByDrawingSearch(o);if(c&&c.scene.removeObject(t.rect),e){this._ensureMap(o,a).delete(n);const h=this._drawingManagerService.getDrawingByParam({unitId:o,subUnitId:a,drawingId:n});if(!h)return;const u=this._sheetDrawingService.getBatchRemoveOp([h]),{redo:s,objects:g}=u;this._commandService.syncExecuteCommand(p.SetDrawingApplyMutation.id,{unitId:o,subUnitId:a,op:s,objects:g,type:p.DrawingApplyType.REMOVE})}}addHook(n){return this._hooks.push(n),{dispose:()=>{const e=this._hooks.findIndex(t=>t===n);this._hooks.splice(e,1)}}}},b.SheetCanvasFloatDomManagerService=fn([re(0,d.Inject(U.IRenderManagerService)),re(1,d.IUniverInstanceService),re(2,d.Inject(d.ICommandService)),re(3,P.IDrawingManagerService),re(4,d.Inject(k.CanvasFloatDomService)),re(5,p.ISheetDrawingService),re(6,d.Inject(d.LifecycleService))],b.SheetCanvasFloatDomManagerService);var tt=Object.defineProperty,vn=Object.getOwnPropertyDescriptor,_n=(i,r,n)=>r in i?tt(i,r,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[r]=n,wn=(i,r,n,e)=>{for(var t=e>1?void 0:e?vn(r,n):r,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(r,n,t):a(t))||t);return e&&t&&tt(r,n,t),t},Fe=(i,r)=>(n,e)=>r(n,e,i),nt=(i,r,n)=>_n(i,typeof r!="symbol"?r+"":r,n);const In="SHEET_IMAGE_UI_PLUGIN";b.UniverSheetsDrawingUIPlugin=class extends d.Plugin{constructor(r=dt,n,e,t){super(),this._config=r,this._injector=n,this._renderManagerService=e,this._configService=t;const{menu:o,...a}=this._config;o&&this._configService.setConfig("menu",o,{merge:!0}),this._configService.setConfig(ct,a)}onStarting(){d.registerDependencies(this._injector,[[b.SheetCanvasFloatDomManagerService],[Re],[me],[Ce],[we],[_e],[pe],[ve],[fe]]),d.touchDependencies(this._injector,[[b.SheetCanvasFloatDomManagerService]])}onReady(){d.touchDependencies(this._injector,[[_e]])}onRendered(){this._registerRenderModules(),d.touchDependencies(this._injector,[[we],[Ce],[Re],[pe],[ve],[fe]])}onSteady(){this._injector.get(me)}_registerRenderModules(){[[de],[We],[Oe]].forEach(r=>{this.disposeWithMe(this._renderManagerService.registerRenderModule(d.UniverInstanceType.UNIVER_SHEET,r))})}},nt(b.UniverSheetsDrawingUIPlugin,"type",d.UniverInstanceType.UNIVER_SHEET),nt(b.UniverSheetsDrawingUIPlugin,"pluginName",In),b.UniverSheetsDrawingUIPlugin=wn([d.DependentOn(P.UniverDrawingPlugin,q.UniverDrawingUIPlugin,p.UniverSheetsDrawingPlugin),Fe(1,d.Inject(d.Injector)),Fe(2,U.IRenderManagerService),Fe(3,d.IConfigService)],b.UniverSheetsDrawingUIPlugin),b.ClearSheetDrawingTransformerOperation=G,b.DeleteDrawingsCommand=Le,b.EditSheetDrawingOperation=be,b.GroupSheetDrawingCommand=Pe,b.InsertFloatImageCommand=ye,b.InsertSheetDrawingCommand=se,b.MoveDrawingsCommand=ie,b.RemoveSheetDrawingCommand=oe,b.SHEETS_IMAGE_MENU_ID=Ge,b.SetDrawingArrangeCommand=Ae,b.SetSheetDrawingCommand=ce,b.SidebarSheetDrawingOperation=Te,b.UngroupSheetDrawingCommand=Ue,Object.defineProperty(b,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/sheets-drawing-ui",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.1-nightly.202411301606",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -57,17 +57,19 @@
|
|
|
57
57
|
"rxjs": ">=7.0.0"
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"@univerjs/icons": "^0.2.
|
|
60
|
+
"@univerjs/icons": "^0.2.8",
|
|
61
61
|
"clsx": "^2.1.1",
|
|
62
|
-
"@univerjs/core": "0.5.
|
|
63
|
-
"@univerjs/design": "0.5.
|
|
64
|
-
"@univerjs/drawing": "0.5.
|
|
65
|
-
"@univerjs/drawing
|
|
66
|
-
"@univerjs/
|
|
67
|
-
"@univerjs/
|
|
68
|
-
"@univerjs/ui": "0.5.
|
|
69
|
-
"@univerjs/sheets
|
|
70
|
-
"@univerjs/sheets-ui": "0.5.
|
|
62
|
+
"@univerjs/core": "0.5.1-nightly.202411301606",
|
|
63
|
+
"@univerjs/design": "0.5.1-nightly.202411301606",
|
|
64
|
+
"@univerjs/docs-drawing": "0.5.1-nightly.202411301606",
|
|
65
|
+
"@univerjs/drawing": "0.5.1-nightly.202411301606",
|
|
66
|
+
"@univerjs/docs-ui": "0.5.1-nightly.202411301606",
|
|
67
|
+
"@univerjs/engine-render": "0.5.1-nightly.202411301606",
|
|
68
|
+
"@univerjs/drawing-ui": "0.5.1-nightly.202411301606",
|
|
69
|
+
"@univerjs/sheets": "0.5.1-nightly.202411301606",
|
|
70
|
+
"@univerjs/sheets-ui": "0.5.1-nightly.202411301606",
|
|
71
|
+
"@univerjs/sheets-drawing": "0.5.1-nightly.202411301606",
|
|
72
|
+
"@univerjs/ui": "0.5.1-nightly.202411301606"
|
|
71
73
|
},
|
|
72
74
|
"devDependencies": {
|
|
73
75
|
"less": "^4.2.1",
|
|
@@ -76,9 +78,9 @@
|
|
|
76
78
|
"rxjs": "^7.8.1",
|
|
77
79
|
"tailwindcss": "^3.4.15",
|
|
78
80
|
"typescript": "^5.7.2",
|
|
79
|
-
"vite": "^6.0.
|
|
81
|
+
"vite": "^6.0.1",
|
|
80
82
|
"vitest": "^2.1.6",
|
|
81
|
-
"@univerjs-infra/shared": "0.5.
|
|
83
|
+
"@univerjs-infra/shared": "0.5.1"
|
|
82
84
|
},
|
|
83
85
|
"space": {
|
|
84
86
|
".": {
|