@univerjs/sheets-drawing-ui 0.2.3 → 0.2.4
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 +1 -1
- package/lib/es/index.js +555 -537
- package/lib/types/services/canvas-float-dom-manager.service.d.ts +8 -3
- package/lib/umd/index.js +1 -1
- package/package.json +25 -25
|
@@ -2,8 +2,8 @@ import { IPosition, ITransformState, Worksheet, Disposable, ICommandService, IUn
|
|
|
2
2
|
import { IDrawingManagerService } from '@univerjs/drawing';
|
|
3
3
|
import { IBoundRectNoAngle, Scene, SpreadsheetSkeleton, IRenderManagerService } from '@univerjs/engine-render';
|
|
4
4
|
import { ISheetDrawingService } from '@univerjs/sheets-drawing';
|
|
5
|
-
import { ISheetSelectionRenderService } from '@univerjs/sheets-ui';
|
|
6
5
|
import { CanvasFloatDomService } from '@univerjs/ui';
|
|
6
|
+
import { IDisposable } from '@wendellhu/redi';
|
|
7
7
|
|
|
8
8
|
export interface ICanvasFloatDom {
|
|
9
9
|
allowTransform: boolean;
|
|
@@ -23,12 +23,14 @@ export declare function transformBound2DOMBound(originBound: IBoundRectNoAngle,
|
|
|
23
23
|
right: number;
|
|
24
24
|
bottom: number;
|
|
25
25
|
};
|
|
26
|
+
export interface ISheetCanvasFloatDomHook {
|
|
27
|
+
onGetFloatDomProps: (id: string) => Record<string, any>;
|
|
28
|
+
}
|
|
26
29
|
export declare class SheetCanvasFloatDomManagerService extends Disposable {
|
|
27
30
|
private _renderManagerService;
|
|
28
31
|
private _univerInstanceService;
|
|
29
32
|
private _commandService;
|
|
30
33
|
private _drawingManagerService;
|
|
31
|
-
private readonly _selectionRenderService;
|
|
32
34
|
private readonly _canvasFloatDomService;
|
|
33
35
|
private readonly _sheetDrawingService;
|
|
34
36
|
private _domLayerMap;
|
|
@@ -44,9 +46,11 @@ export declare class SheetCanvasFloatDomManagerService extends Disposable {
|
|
|
44
46
|
subUnitId: string;
|
|
45
47
|
id: string;
|
|
46
48
|
}>;
|
|
47
|
-
|
|
49
|
+
private _hooks;
|
|
50
|
+
constructor(_renderManagerService: IRenderManagerService, _univerInstanceService: IUniverInstanceService, _commandService: ICommandService, _drawingManagerService: IDrawingManagerService, _canvasFloatDomService: CanvasFloatDomService, _sheetDrawingService: ISheetDrawingService);
|
|
48
51
|
private _ensureMap;
|
|
49
52
|
private _getSceneAndTransformerByDrawingSearch;
|
|
53
|
+
private _getFloatDomProps;
|
|
50
54
|
private _drawingAddListener;
|
|
51
55
|
private _scrollUpdateListener;
|
|
52
56
|
private _getPosition;
|
|
@@ -57,4 +61,5 @@ export declare class SheetCanvasFloatDomManagerService extends Disposable {
|
|
|
57
61
|
dispose: () => void;
|
|
58
62
|
} | undefined;
|
|
59
63
|
private _removeDom;
|
|
64
|
+
addHook(hook: ISheetCanvasFloatDomHook): IDisposable;
|
|
60
65
|
}
|
package/lib/umd/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(T,p){typeof exports=="object"&&typeof module<"u"?p(exports,require("@univerjs/core"),require("@wendellhu/redi"),require("@univerjs/drawing-ui"),require("@univerjs/sheets-drawing"),require("@univerjs/drawing"),require("@univerjs/engine-render"),require("@univerjs/sheets-ui"),require("rxjs"),require("@univerjs/ui"),require("@wendellhu/redi/react-bindings"),require("@univerjs/sheets"),require("react"),require("@univerjs/design"),require("clsx")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@wendellhu/redi","@univerjs/drawing-ui","@univerjs/sheets-drawing","@univerjs/drawing","@univerjs/engine-render","@univerjs/sheets-ui","rxjs","@univerjs/ui","@wendellhu/redi/react-bindings","@univerjs/sheets","react","@univerjs/design","clsx"],p):(T=typeof globalThis<"u"?globalThis:T||self,p(T.UniverSheetsDrawingUi={},T.UniverCore,T["@wendellhu/redi"],T.UniverDrawingUi,T.UniverSheetsDrawing,T.UniverDrawing,T.UniverEngineRender,T.UniverSheetsUi,T.rxjs,T.UniverUi,T["@wendellhu/redi/react-bindings"],T.UniverSheets,T.React,T.UniverDesign,T.clsx))})(this,function(T,p,B,Q,h,A,L,$,k,F,q,_,N,J,me){"use strict";var Ft=Object.defineProperty;var kt=(T,p,B)=>p in T?Ft(T,p,{enumerable:!0,configurable:!0,writable:!0,value:B}):T[p]=B;var z=(T,p,B)=>kt(T,typeof p!="symbol"?p+"":p,B);const G={id:"sheet.operation.clear-drawing-transformer",type:p.CommandType.MUTATION,handler:(i,t)=>{const n=i.get(L.IRenderManagerService);return t.forEach(e=>{var r,o;(o=(r=n.getRenderById(e))==null?void 0:r.scene.getTransformer())==null||o.debounceRefreshControls()}),!0}},ge={id:"sheet.command.remove-sheet-image",type:p.CommandType.COMMAND,handler:(i,t)=>{const n=i.get(p.ICommandService),e=i.get(p.IUndoRedoService),r=i.get(h.ISheetDrawingService);if(!t)return!1;const{drawings:o}=t,a=[];o.forEach(S=>{const{unitId:f}=S;a.push(f)});const s=r.getBatchRemoveOp(o),{unitId:l,subUnitId:u,undo:d,redo:c,objects:m}=s;return n.syncExecuteCommand(h.SetDrawingApplyMutation.id,{unitId:l,subUnitId:u,op:c,objects:m,type:h.DrawingApplyType.REMOVE})?(e.pushUndoRedo({unitID:l,undoMutations:[{id:h.SetDrawingApplyMutation.id,params:{unitId:l,subUnitId:u,op:d,objects:m,type:h.DrawingApplyType.INSERT}},{id:G.id,params:a}],redoMutations:[{id:h.SetDrawingApplyMutation.id,params:{unitId:l,subUnitId:u,op:c,objects:m,type:h.DrawingApplyType.REMOVE}},{id:G.id,params:a}]}),!0):!1}},Ue="COMPONENT_SHEET_DRAWING_PANEL",Me={id:"sidebar.operation.sheet-image",type:p.CommandType.COMMAND,handler:async(i,t)=>{const n=i.get(F.ISidebarService),e=i.get(p.LocaleService),r=i.get(p.IUniverInstanceService),o=i.get(A.IDrawingManagerService);if(!_.getSheetCommandTarget(r))return!1;switch(t.value){case"open":n.open({header:{title:e.t("sheetImage.panel.title")},children:{label:Ue},onClose:()=>{o.focusDrawing(null)},width:360});break;case"close":default:n.close();break}return!0}},De={id:"sheet.operation.edit-sheet-image",type:p.CommandType.OPERATION,handler:(i,t)=>{const n=i.get(A.IDrawingManagerService),e=i.get(p.ICommandService);return t==null?!1:(n.focusDrawing([t]),e.executeCommand(Me.id,{value:"open"}),!0)}},pe={uploadLoading:"univer-upload-loading",uploadLoadingBody:"univer-upload-loading-body",uploadLoadingBodyAnimation:"univer-upload-loading-body-animation",univerCircleAnimation:"univer-UniverCircleAnimation",uploadLoadingBodyText:"univer-upload-loading-body-text"},Xe=()=>{const i=q.useDependency(A.IImageIoService),t=q.useDependency(p.LocaleService),[n,e]=N.useState(0);return N.useEffect(()=>{const r=i.change$.subscribe(o=>{e(o)});return()=>{r.unsubscribe()}},[i]),N.createElement("div",{style:{display:n>0?"block":"none"},className:pe.uploadLoading},N.createElement("div",{className:pe.uploadLoadingBody},N.createElement("div",{className:pe.uploadLoadingBodyAnimation}),N.createElement("div",{className:pe.uploadLoadingBodyText},`${t.t("uploadLoading.loading")}: ${n}`)))};var xe=Object.defineProperty,Ke=Object.getOwnPropertyDescriptor,ze=(i,t,n,e)=>{for(var r=e>1?void 0:e?Ke(t,n):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(t,n,r):a(r))||r);return e&&r&&xe(t,n,r),r},ee=(i,t)=>(n,e)=>t(n,e,i);let he=class extends p.RxDisposable{constructor(t,n,e,r,o,a,s){super();z(this,"_initImagePopupMenu",new Set);this._injector=t,this._drawingManagerService=n,this._canvasPopManagerService=e,this._renderManagerService=r,this._univerInstanceService=o,this._contextService=a,this._uiPartsService=s,this._init()}_init(){this._univerInstanceService.getCurrentTypeOfUnit$(p.UniverInstanceType.UNIVER_SHEET).pipe(k.takeUntil(this.dispose$)).subscribe(t=>this._create(t)),this._univerInstanceService.getTypeOfUnitDisposed$(p.UniverInstanceType.UNIVER_SHEET).pipe(k.takeUntil(this.dispose$)).subscribe(t=>this._dispose(t)),this._univerInstanceService.getAllUnitsForType(p.UniverInstanceType.UNIVER_SHEET).forEach(t=>this._create(t)),this._uiPartsService.registerComponent(F.BuiltInUIPart.CONTENT,()=>q.connectInjector(Xe,this._injector))}_dispose(t){const n=t.getUnitId();this._renderManagerService.removeRender(n)}_create(t){if(!t)return;const n=t.getUnitId();this._renderManagerService.has(n)&&!this._initImagePopupMenu.has(n)&&(this._popupMenuListener(n),this._initImagePopupMenu.add(n))}_hasCropObject(t){const n=t.getAllObjects();for(const e of n)if(e instanceof Q.ImageCropperObject)return!0;return!1}_popupMenuListener(t){var o;const n=(o=this._renderManagerService.getRenderById(t))==null?void 0:o.scene;if(!n)return;const e=n.getTransformerByCreate();if(!e)return;let r;this.disposeWithMe(p.toDisposable(e.createControl$.subscribe(()=>{if(this._contextService.setContextValue(p.FOCUSING_COMMON_DRAWINGS,!0),this._hasCropObject(n))return;const a=e.getSelectedObjectMap();if(a.size>1){r==null||r.dispose();return}const s=a.values().next().value;if(!s)return;const l=s.oKey,u=this._drawingManagerService.getDrawingOKey(l);if(!u)return;const{unitId:d,subUnitId:c,drawingId:m}=u;r==null||r.dispose(),r=this.disposeWithMe(this._canvasPopManagerService.attachPopupToObject(s,{componentKey:Q.COMPONENT_IMAGE_POPUP_MENU,direction:"horizontal",offset:[2,0],extraProps:{menuItems:this._getImageMenuItems(d,c,m)}})),this._drawingManagerService.focusDrawing([{unitId:d,subUnitId:c,drawingId:m}])}))),this.disposeWithMe(e.clearControl$.subscribe(()=>{r==null||r.dispose(),this._contextService.setContextValue(p.FOCUSING_COMMON_DRAWINGS,!1),this._drawingManagerService.focusDrawing(null)})),this.disposeWithMe(e.changing$.subscribe(()=>{r==null||r.dispose()}))}_getImageMenuItems(t,n,e){return[{label:"image-popup.edit",index:0,commandId:De.id,commandParams:{unitId:t,subUnitId:n,drawingId:e},disable:!1},{label:"image-popup.delete",index:1,commandId:ge.id,commandParams:{unitId:t,drawings:[{unitId:t,subUnitId:n,drawingId:e}]},disable:!1},{label:"image-popup.crop",index:2,commandId:Q.OpenImageCropOperation.id,commandParams:{unitId:t,subUnitId:n,drawingId:e},disable:!1},{label:"image-popup.reset",index:3,commandId:Q.ImageResetSizeOperation.id,commandParams:[{unitId:t,subUnitId:n,drawingId:e}],disable:!1}]}};he=ze([p.OnLifecycle(p.LifecycleStages.Steady,he),ee(0,B.Inject(B.Injector)),ee(1,A.IDrawingManagerService),ee(2,B.Inject($.SheetCanvasPopManagerService)),ee(3,L.IRenderManagerService),ee(4,p.IUniverInstanceService),ee(5,p.IContextService),ee(6,B.Inject(F.IUIPartsService))],he);const oe={id:"sheet.operation.insert-float-image",type:p.CommandType.OPERATION,handler:(i,t)=>!0},ae={id:"sheet.operation.insert-cell-image",type:p.CommandType.OPERATION,handler:(i,t)=>!0},fe={id:"sheet.command.insert-sheet-image",type:p.CommandType.COMMAND,handler:(i,t)=>{const n=i.get(p.ICommandService),e=i.get(p.IUndoRedoService),r=i.get(h.ISheetDrawingService);if(!t)return!1;const o=t.drawings,a=o.map(S=>S.unitId),s=r.getBatchAddOp(o),{unitId:l,subUnitId:u,undo:d,redo:c,objects:m}=s;return n.syncExecuteCommand(h.SetDrawingApplyMutation.id,{op:c,unitId:l,subUnitId:u,objects:m,type:h.DrawingApplyType.INSERT})?(e.pushUndoRedo({unitID:l,undoMutations:[{id:h.SetDrawingApplyMutation.id,params:{op:d,unitId:l,subUnitId:u,objects:m,type:h.DrawingApplyType.REMOVE}},{id:G.id,params:a}],redoMutations:[{id:h.SetDrawingApplyMutation.id,params:{op:c,unitId:l,subUnitId:u,objects:m,type:h.DrawingApplyType.INSERT}},{id:G.id,params:a}]}),!0):!1}},se={id:"sheet.command.set-sheet-image",type:p.CommandType.COMMAND,handler:(i,t)=>{const n=i.get(p.ICommandService),e=i.get(p.IUndoRedoService),r=i.get(h.ISheetDrawingService);if(!t)return!1;const{drawings:o}=t,a=r.getBatchUpdateOp(o),{unitId:s,subUnitId:l,undo:u,redo:d,objects:c}=a;return n.syncExecuteCommand(h.SetDrawingApplyMutation.id,{unitId:s,subUnitId:l,op:d,objects:c,type:h.DrawingApplyType.UPDATE})?(e.pushUndoRedo({unitID:s,undoMutations:[{id:h.SetDrawingApplyMutation.id,params:{unitId:s,subUnitId:l,op:u,objects:c,type:h.DrawingApplyType.UPDATE}},{id:G.id,params:[s]}],redoMutations:[{id:h.SetDrawingApplyMutation.id,params:{unitId:s,subUnitId:l,op:d,objects:c,type:h.DrawingApplyType.UPDATE}},{id:G.id,params:[s]}]}),!0):!1}},Te={id:"sheet.command.set-drawing-arrange",type:p.CommandType.COMMAND,handler:(i,t)=>{const n=i.get(p.ICommandService),e=i.get(p.IUndoRedoService);if(!t)return!1;const r=i.get(h.ISheetDrawingService),{unitId:o,subUnitId:a,drawingIds:s,arrangeType:l}=t,u={unitId:o,subUnitId:a,drawingIds:s};let d;if(l===A.ArrangeTypeEnum.forward?d=r.getForwardDrawingsOp(u):l===A.ArrangeTypeEnum.backward?d=r.getBackwardDrawingOp(u):l===A.ArrangeTypeEnum.front?d=r.getFrontDrawingsOp(u):l===A.ArrangeTypeEnum.back&&(d=r.getBackDrawingsOp(u)),d==null)return!1;const{objects:c,redo:m,undo:g}=d;return n.syncExecuteCommand(h.SetDrawingApplyMutation.id,{op:m,unitId:o,subUnitId:a,objects:c,type:h.DrawingApplyType.ARRANGE})?(e.pushUndoRedo({unitID:o,undoMutations:[{id:h.SetDrawingApplyMutation.id,params:{op:g,unitId:o,subUnitId:a,objects:c,type:h.DrawingApplyType.ARRANGE}}],redoMutations:[{id:h.SetDrawingApplyMutation.id,params:{op:m,unitId:o,subUnitId:a,objects:c,type:h.DrawingApplyType.ARRANGE}}]}),!0):!1}};function qe(i){const t=[];return i.forEach(n=>{const{parent:e,children:r}=n,{unitId:o,subUnitId:a,drawingId:s}=e,l=L.getGroupState(0,0,r.map(c=>c.transform||{})),u=r.map(c=>{const m=c.transform||{left:0,top:0},{unitId:g,subUnitId:S,drawingId:f}=c;return{unitId:g,subUnitId:S,drawingId:f,transform:{...m,left:m.left-l.left,top:m.top-l.top},groupId:s}}),d={unitId:o,subUnitId:a,drawingId:s,drawingType:A.DrawingTypeEnum.DRAWING_GROUP,transform:l};t.push({parent:d,children:u})}),t}function Je(i){const t=[];return i.forEach(n=>{const{parent:e,children:r}=n,{unitId:o,subUnitId:a,drawingId:s,transform:l={width:0,height:0}}=e;if(l==null)return;const u=r.map(c=>{const{transform:m}=c,{unitId:g,subUnitId:S,drawingId:f}=c,v=L.transformObjectOutOfGroup(m||{},l,l.width||0,l.height||0);return{unitId:g,subUnitId:S,drawingId:f,transform:v,groupId:void 0}}),d={unitId:o,subUnitId:a,drawingId:s,drawingType:A.DrawingTypeEnum.DRAWING_GROUP,transform:{left:0,top:0}};t.push({parent:d,children:u})}),t}const Re={id:"sheet.command.group-sheet-image",type:p.CommandType.COMMAND,handler:(i,t)=>{const n=i.get(p.ICommandService),e=i.get(p.IUndoRedoService),r=i.get(h.ISheetDrawingService);if(!t)return!1;const o=[];t.forEach(({parent:g,children:S})=>{o.push(g.unitId),S.forEach(f=>{o.push(f.unitId)})});const a=r.getGroupDrawingOp(t),{unitId:s,subUnitId:l,undo:u,redo:d,objects:c}=a;return n.syncExecuteCommand(h.SetDrawingApplyMutation.id,{op:d,unitId:s,subUnitId:l,objects:c,type:h.DrawingApplyType.GROUP})?(e.pushUndoRedo({unitID:s,undoMutations:[{id:h.SetDrawingApplyMutation.id,params:{op:u,unitId:s,subUnitId:l,objects:Je(c),type:h.DrawingApplyType.UNGROUP}},{id:G.id,params:o}],redoMutations:[{id:h.SetDrawingApplyMutation.id,params:{op:d,unitId:s,subUnitId:l,objects:c,type:h.DrawingApplyType.GROUP}},{id:G.id,params:o}]}),!0):!1}},Ee={id:"sheet.command.ungroup-sheet-image",type:p.CommandType.COMMAND,handler:(i,t)=>{const n=i.get(p.ICommandService),e=i.get(p.IUndoRedoService),r=i.get(h.ISheetDrawingService);if(!t)return!1;const o=[];t.forEach(({parent:g,children:S})=>{o.push(g.unitId),S.forEach(f=>{o.push(f.unitId)})});const a=r.getUngroupDrawingOp(t),{unitId:s,subUnitId:l,undo:u,redo:d,objects:c}=a;return n.syncExecuteCommand(h.SetDrawingApplyMutation.id,{op:d,unitId:s,subUnitId:l,objects:c,type:h.DrawingApplyType.UNGROUP})?(e.pushUndoRedo({unitID:s,undoMutations:[{id:h.SetDrawingApplyMutation.id,params:{op:u,unitId:s,subUnitId:l,objects:qe(c),type:h.DrawingApplyType.GROUP}},{id:G.id,params:o}],redoMutations:[{id:h.SetDrawingApplyMutation.id,params:{op:d,unitId:s,subUnitId:l,objects:c,type:h.DrawingApplyType.UNGROUP}},{id:G.id,params:o}]}),!0):!1}};function H(i,t,n){const{from:e,to:r,flipY:o=!1,flipX:a=!1,angle:s=0,skewX:l=0,skewY:u=0}=i,{column:d,columnOffset:c,row:m,rowOffset:g}=e,{column:S,columnOffset:f,row:v,rowOffset:y}=r,M=n.attachRangeWithCoord({startColumn:d,endColumn:d,startRow:m,endRow:m});if(M==null)return;const C=n.attachRangeWithCoord({startColumn:S,endColumn:S,startRow:v,endRow:v});if(C==null)return;const{startX:R,startY:I}=M,{startX:O,startY:w}=C;let U=L.precisionTo(R+c,1),E=L.precisionTo(I+g,1),j=L.precisionTo(O+f-U,1),P=L.precisionTo(w+y-E,1);M.startX===C.endX&&(j=0),M.startY===C.endY&&(P=0);const b=n.getCurrentSkeleton(),D=b.rowHeaderWidth+b.columnTotalWidth,W=b.columnHeaderHeight+b.rowTotalHeight;return U+j>D&&(U=D-j),E+P>W&&(E=W-P),{flipY:o,flipX:a,angle:s,skewX:l,skewY:u,left:U,top:E,width:j,height:P}}function V(i,t){const{left:n=0,top:e=0,width:r=0,height:o=0,flipY:a=!1,flipX:s=!1,angle:l=0,skewX:u=0,skewY:d=0}=i,c=t.getSelectionCellByPosition(n,e);if(c==null)return;const m={column:c.actualColumn,columnOffset:L.precisionTo(n-c.startX,1),row:c.actualRow,rowOffset:L.precisionTo(e-c.startY,1)},g=t.getSelectionCellByPosition(n+r,e+o);if(g==null)return;const S={column:g.actualColumn,columnOffset:L.precisionTo(n+r-g.startX,1),row:g.actualRow,rowOffset:L.precisionTo(e+o-g.startY,1)};return{flipY:a,flipX:s,angle:l,skewX:u,skewY:d,from:m,to:S}}var Ze=Object.defineProperty,Qe=Object.getOwnPropertyDescriptor,et=(i,t,n,e)=>{for(var r=e>1?void 0:e?Qe(t,n):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(t,n,r):a(r))||r);return e&&r&&Ze(t,n,r),r},K=(i,t)=>(n,e)=>t(n,e,i);let Se=class extends p.Disposable{constructor(i,t,n,e,r,o,a,s,l,u){super(),this._commandService=i,this._univerInstanceService=t,this._selectionManagerService=n,this._imageIoService=e,this._sheetDrawingService=r,this._drawingManagerService=o,this._contextService=a,this._messageService=s,this._localeService=l,this._renderManagerService=u,this._init()}get _selectionRenderService(){return this._renderManagerService.getRenderById(this._univerInstanceService.getCurrentUnitForType(p.UniverInstanceType.UNIVER_SHEET).getUnitId()).with($.ISheetSelectionRenderService)}get _skeletonManagerService(){return this._renderManagerService.getRenderById(this._univerInstanceService.getCurrentUnitForType(p.UniverInstanceType.UNIVER_SHEET).getUnitId()).with($.SheetSkeletonManagerService)}_init(){this._initCommandListeners(),this._updateImageListener(),this._updateOrderListener(),this._groupDrawingListener(),this._focusDrawingListener(),this._drawingAddListener()}_initCommandListeners(){this.disposeWithMe(this._commandService.onCommandExecuted(async i=>{if(i.id===ae.id||i.id===oe.id){const t=i.params;if(t.files==null)return;const n=t.files.length;if(n>A.DRAWING_IMAGE_COUNT_LIMIT){this._messageService.show({type:J.MessageType.Error,content:this._localeService.t("update-status.exceedMaxCount",String(A.DRAWING_IMAGE_COUNT_LIMIT))});return}this._imageIoService.setWaitCount(n),i.id===ae.id?t.files.forEach(async e=>{await this._insertCellImage(e)}):t.files.forEach(async e=>{await this._insertFloatImage(e)})}}))}async _insertCellImage(i){}async _insertFloatImage(i){let t;try{t=await this._imageIoService.saveImage(i)}catch(M){const C=M.message;C===A.ImageUploadStatusType.ERROR_EXCEED_SIZE?this._messageService.show({type:J.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:J.MessageType.Error,content:this._localeService.t("update-status.invalidImageType")}):C===A.ImageUploadStatusType.ERROR_IMAGE&&this._messageService.show({type:J.MessageType.Error,content:this._localeService.t("update-status.invalidImage")})}if(t==null)return;const n=this._getUnitInfo();if(n==null)return;const{unitId:e,subUnitId:r}=n,{imageId:o,imageSourceType:a,source:s,base64Cache:l}=t,{width:u,height:d,image:c}=await A.getImageSize(l||""),m=this._renderManagerService.getRenderById(e);if(m==null)return;const{width:g,height:S}=m.scene;this._imageIoService.addImageSourceCache(s,a,c);let f=1;if(u>A.DRAWING_IMAGE_WIDTH_LIMIT||d>A.DRAWING_IMAGE_HEIGHT_LIMIT){const M=A.DRAWING_IMAGE_WIDTH_LIMIT/u,C=A.DRAWING_IMAGE_HEIGHT_LIMIT/d;f=Math.max(M,C)}const v=this._getImagePosition(u*f,d*f,g,S);if(v==null)return;const y={unitId:e,subUnitId:r,drawingId:o,drawingType:A.DrawingTypeEnum.DRAWING_IMAGE,imageSourceType:a,source:s,transform:H(v,this._selectionRenderService,this._skeletonManagerService),sheetTransform:v};this._commandService.executeCommand(fe.id,{unitId:e,drawings:[y]})}_getUnitInfo(){const i=this._univerInstanceService.getCurrentUnitForType(p.UniverInstanceType.UNIVER_SHEET);if(i==null)return;const t=i.getActiveSheet();if(t==null)return;const n=i.getUnitId(),e=t.getSheetId();return{unitId:n,subUnitId:e}}_getImagePosition(i,t,n,e){const r=this._selectionManagerService.getCurrentSelections();let o={startRow:0,endRow:0,startColumn:0,endColumn:0};r&&r.length>0&&(o=r[r.length-1].range);const a=$.attachRangeWithCoord(this._skeletonManagerService.getCurrent().skeleton,o);if(a==null)return;let{startColumn:s,startRow:l,startX:u,startY:d}=a,c=!1;if(u+i>n&&(u=n-i,u<0&&(u=0,i=n),c=!0),d+t>e&&(d=e-t,d<0&&(d=0,t=e),c=!0),c){const f=this._selectionRenderService.getSelectionCellByPosition(u,d);if(f==null)return;u=f.startX,d=f.startY,s=f.actualColumn,l=f.actualRow}const m={column:s,columnOffset:0,row:l,rowOffset:0},g=this._selectionRenderService.getSelectionCellByPosition(u+i,d+t);if(g==null)return;const S={column:g.actualColumn,columnOffset:u+i-g.startX,row:g.actualRow,rowOffset:d+t-g.startY};return{from:m,to:S}}_updateOrderListener(){this._drawingManagerService.featurePluginOrderUpdate$.subscribe(i=>{const{unitId:t,subUnitId:n,drawingIds:e,arrangeType:r}=i;this._commandService.executeCommand(Te.id,{unitId:t,subUnitId:n,drawingIds:e,arrangeType:r})})}_updateImageListener(){this._drawingManagerService.featurePluginUpdate$.subscribe(i=>{const t=[];i.length!==0&&(i.forEach(n=>{const{unitId:e,subUnitId:r,drawingId:o,drawingType:a,transform:s}=n;if(s==null)return;const l=this._sheetDrawingService.getDrawingByParam({unitId:e,subUnitId:r,drawingId:o});if(l==null)return;const u=V({...l.transform,...s},this._selectionRenderService);if(u==null)return;const d={...n,transform:{...l.transform,...s,...H(u,this._selectionRenderService,this._skeletonManagerService)},sheetTransform:{...u}};t.push(d)}),t.length>0&&this._commandService.executeCommand(se.id,{unitId:i[0].unitId,drawings:t}))})}_groupDrawingListener(){this._drawingManagerService.featurePluginGroupUpdate$.subscribe(i=>{this._commandService.executeCommand(Re.id,i);const{unitId:t,subUnitId:n,drawingId:e}=i[0].parent;this._drawingManagerService.focusDrawing([{unitId:t,subUnitId:n,drawingId:e}])}),this._drawingManagerService.featurePluginUngroupUpdate$.subscribe(i=>{this._commandService.executeCommand(Ee.id,i)})}_focusDrawingListener(){this.disposeWithMe(this._drawingManagerService.focus$.subscribe(i=>{i==null||i.length===0?(this._contextService.setContextValue(p.FOCUSING_COMMON_DRAWINGS,!1),this._sheetDrawingService.focusDrawing([])):(this._contextService.setContextValue(p.FOCUSING_COMMON_DRAWINGS,!0),this._sheetDrawingService.focusDrawing(i))}))}_drawingAddListener(){this.disposeWithMe(this._sheetDrawingService.add$.subscribe(i=>{this._registerDrawing(i)}))}_registerDrawing(i){i.forEach(n=>{const e=this._sheetDrawingService.getDrawingByParam(n);if(e==null)return;const{sheetTransform:r}=e;e.transform=H(r,this._selectionRenderService,this._skeletonManagerService)});const t=i[0].unitId;this._drawingManagerService.registerDrawingData(t,this._sheetDrawingService.getDrawingDataForUnit(t)),this._drawingManagerService.initializeNotification(t)}};Se=et([p.OnLifecycle(p.LifecycleStages.Rendered,Se),K(0,p.ICommandService),K(1,p.IUniverInstanceService),K(2,B.Inject(_.SheetsSelectionsService)),K(3,A.IImageIoService),K(4,h.ISheetDrawingService),K(5,A.IDrawingManagerService),K(6,p.IContextService),K(7,F.IMessageService),K(8,B.Inject(p.LocaleService)),K(9,L.IRenderManagerService)],Se);var x=function(){return x=Object.assign||function(i){for(var t,n=1,e=arguments.length;n<e;n++){t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(i[r]=t[r])}return i},x.apply(this,arguments)},tt=function(i,t){var n={};for(var e in i)Object.prototype.hasOwnProperty.call(i,e)&&t.indexOf(e)<0&&(n[e]=i[e]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,e=Object.getOwnPropertySymbols(i);r<e.length;r++)t.indexOf(e[r])<0&&Object.prototype.propertyIsEnumerable.call(i,e[r])&&(n[e[r]]=i[e[r]]);return n},Ne=N.forwardRef(function(i,t){var n=i.icon,e=i.id,r=i.className,o=i.extend,a=tt(i,["icon","id","className","extend"]),s="univerjs-icon univerjs-icon-".concat(e," ").concat(r||"").trim(),l=N.useRef("_".concat(it()));return Le(n,"".concat(e),{defIds:n.defIds,idSuffix:l.current},x({ref:t,className:s},a),o)});function Le(i,t,n,e,r){return N.createElement(i.tag,x(x({key:t},nt(i,n,r)),e),(rt(i,n).children||[]).map(function(o,a){return Le(o,"".concat(t,"-").concat(i.tag,"-").concat(a),n,void 0,r)}))}function nt(i,t,n){var e=x({},i.attrs);n!=null&&n.colorChannel1&&e.fill==="colorChannel1"&&(e.fill=n.colorChannel1);var r=t.defIds;return!r||r.length===0||(i.tag==="use"&&e["xlink:href"]&&(e["xlink:href"]=e["xlink:href"]+t.idSuffix),Object.entries(e).forEach(function(o){var a=o[0],s=o[1];typeof s=="string"&&(e[a]=s.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),e}function rt(i,t){var n,e=t.defIds;return!e||e.length===0?i:i.tag==="defs"&&(!((n=i.children)===null||n===void 0)&&n.length)?x(x({},i),{children:i.children.map(function(r){return typeof r.attrs.id=="string"&&e&&e.indexOf(r.attrs.id)>-1?x(x({},r),{attrs:x(x({},r.attrs),{id:r.attrs.id+t.idSuffix})}):r})}):i}function it(){return Math.random().toString(36).substring(2,8)}Ne.displayName="UniverIcon";var ot={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"}}]},je=N.forwardRef(function(i,t){return N.createElement(Ne,Object.assign({},i,{id:"add-image-single",ref:t,icon:ot}))});je.displayName="AddImageSingle";const We={uploadFileMenu:"univer-upload-file-menu",uploadFileMenuInput:"univer-upload-file-menu-input"},$e="COMPONENT_UPLOAD_FILE_MENU";var ve=(i=>(i[i.cellImage=0]="cellImage",i[i.floatImage=1]="floatImage",i))(ve||{});const at=i=>{const{type:t}=i,n=q.useDependency(p.ICommandService),e=N.useRef(null),r=()=>{var s;(s=e.current)==null||s.click()},o=A.DRAWING_IMAGE_ALLOW_IMAGE_LIST.map(s=>`.${s.replace("image/","")}`).join(","),a=s=>{const l=s.target.files;if(l==null)return;const u=Array.from(l);t===ve.floatImage?n.executeCommand(oe.id,{files:u}):t===ve.cellImage&&n.executeCommand(ae.id,{files:u}),e.current&&(e.current.value="")};return N.createElement("div",{onClick:r,className:We.uploadFileMenu},N.createElement("input",{type:"file",className:We.uploadFileMenuInput,ref:e,onChange:a,accept:o,multiple:!0}))},Be="addition-and-subtraction-single",Ge="sheet.menu.image";function st(i){return{id:Ge,type:F.MenuItemType.SUBITEMS,positions:[F.MenuPosition.TOOLBAR_START],group:F.MenuGroup.TOOLBAR_FORMULAS_INSERT,icon:Be,tooltip:"sheetImage.title",hidden$:F.getMenuHiddenObservable(i,p.UniverInstanceType.UNIVER_SHEET),disabled$:$.getCurrentRangeDisable$(i,{workbookTypes:[_.WorkbookEditablePermission],worksheetTypes:[_.WorksheetEditPermission],rangeTypes:[_.RangeProtectionPermissionEditPoint]})}}function ct(i){return{id:oe.id,title:"sheetImage.upload.float",type:F.MenuItemType.SELECTOR,label:{name:$e,props:{type:ve.floatImage}},positions:[Ge],hidden$:F.getMenuHiddenObservable(i,p.UniverInstanceType.UNIVER_SHEET)}}const Z={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"},lt=i=>{var C;const t=q.useDependency(p.ICommandService),n=q.useDependency(p.LocaleService),e=q.useDependency(A.IDrawingManagerService),r=q.useDependency(L.IRenderManagerService),{drawings:o}=i,a=o[0];if(a==null)return;const{unitId:s}=a,l=r.getRenderById(s),u=l==null?void 0:l.scene;if(u==null)return;const d=u.getTransformerByCreate(),[c,m]=N.useState(!0),g=(C=a.anchorType)!=null?C:h.SheetDrawingAnchorType.Position,[S,f]=N.useState(g);function v(R,I){const O=[];return R.forEach(w=>{const{oKey:U}=w,E=I.getDrawingOKey(U);if(E==null)return O.push(null),!0;const{unitId:j,subUnitId:P,drawingId:b,drawingType:D,anchorType:W,sheetTransform:Y}=E;O.push({unitId:j,subUnitId:P,drawingId:b,anchorType:W,sheetTransform:Y,drawingType:D})}),O}N.useEffect(()=>{const R=d.clearControl$.subscribe(O=>{O===!0&&m(!1)}),I=d.changeStart$.subscribe(O=>{var E;const{objects:w}=O,U=v(w,e);if(U.length===0)m(!1);else if(U.length>=1){m(!0);const j=((E=U[0])==null?void 0:E.anchorType)||h.SheetDrawingAnchorType.Position;f(j)}});return()=>{I.unsubscribe(),R.unsubscribe()}},[]);function y(R){f(R);const I=e.getFocusDrawings();if(I.length===0)return;const O=I.map(w=>({unitId:w.unitId,subUnitId:w.subUnitId,drawingId:w.drawingId,anchorType:R}));t.executeCommand(se.id,{unitId:I[0].unitId,drawings:O})}const M=R=>R?"block":"none";return N.createElement("div",{className:me(Z.imageCommonPanelGrid,Z.imageCommonPanelBorder),style:{display:M(c)}},N.createElement("div",{className:Z.imageCommonPanelRow},N.createElement("div",{className:me(Z.imageCommonPanelColumn,Z.imageCommonPanelTitle)},N.createElement("div",null,n.t("drawing-anchor.title")))),N.createElement("div",{className:me(Z.imageCommonPanelRow)},N.createElement("div",{className:me(Z.imageCommonPanelColumn)},N.createElement(J.RadioGroup,{value:S,onChange:y,direction:"vertical"},N.createElement(J.Radio,{value:h.SheetDrawingAnchorType.Both},n.t("drawing-anchor.both")),N.createElement(J.Radio,{value:h.SheetDrawingAnchorType.Position},n.t("drawing-anchor.position")),N.createElement(J.Radio,{value:h.SheetDrawingAnchorType.None},n.t("drawing-anchor.none"))))))},dt=()=>{const i=q.useDependency(A.IDrawingManagerService),t=i.getFocusDrawings(),[n,e]=N.useState(t);return N.useEffect(()=>{const r=i.focus$.subscribe(o=>{e(o)});return()=>{r.unsubscribe()}},[]),!!(n!=null&&n.length)&&N.createElement("div",{className:Z.imageCommonPanel},N.createElement(Q.DrawingCommonPanel,{drawings:n}),N.createElement(lt,{drawings:n}))},re={id:"sheet.command.move-drawing",type:p.CommandType.COMMAND,handler:(i,t)=>{const n=i.get(p.ICommandService),e=i.get(h.ISheetDrawingService),r=i.get($.ISheetSelectionRenderService),{direction:o}=t,a=e.getFocusDrawings();if(a.length===0)return!1;const s=a[0].unitId,l=a.map(d=>{const{transform:c}=d;if(c==null)return null;const m={...c},{left:g=0,top:S=0}=c;return o===p.Direction.UP?m.top=S-1:o===p.Direction.DOWN?m.top=S+1:o===p.Direction.LEFT?m.left=g-1:o===p.Direction.RIGHT&&(m.left=g+1),{...d,transform:m,sheetTransform:V(m,r)}}).filter(d=>d!=null);return n.syncExecuteCommand(se.id,{unitId:s,drawings:l})?(n.syncExecuteCommand(G.id,[s]),!0):!1}},be={id:"sheet.command.delete-drawing",type:p.CommandType.COMMAND,handler:i=>{const t=i.get(p.ICommandService),e=i.get(h.ISheetDrawingService).getFocusDrawings();if(e.length===0)return!1;const r=e[0].unitId,o=e.map(a=>{const{unitId:s,subUnitId:l,drawingId:u,drawingType:d}=a;return{unitId:s,subUnitId:l,drawingId:u,drawingType:d}});return t.executeCommand(ge.id,{unitId:r,drawings:o})}};function ce(i){return!i.getContextValue(p.FOCUSING_FORMULA_EDITOR)&&!i.getContextValue(p.EDITOR_ACTIVATED)&&i.getContextValue(p.FOCUSING_COMMON_DRAWINGS)}const ut={id:re.id,description:"shortcut.sheet.drawing-move-down",group:"4_sheet-drawing-view",binding:F.KeyCode.ARROW_DOWN,priority:100,preconditions:ce,staticParameters:{direction:p.Direction.DOWN}},mt={id:re.id,description:"shortcut.sheet.drawing-move-up",group:"4_sheet-drawing-view",binding:F.KeyCode.ARROW_UP,priority:100,preconditions:ce,staticParameters:{direction:p.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:ce,staticParameters:{direction:p.Direction.LEFT}},pt={id:re.id,description:"shortcut.sheet.drawing-move-right",group:"4_sheet-drawing-view",binding:F.KeyCode.ARROW_RIGHT,priority:100,preconditions:ce,staticParameters:{direction:p.Direction.RIGHT}},ht={id:be.id,description:"shortcut.sheet.drawing-delete",group:"4_sheet-drawing-view",preconditions:ce,binding:F.KeyCode.DELETE,mac:F.KeyCode.BACKSPACE};var ft=Object.defineProperty,St=Object.getOwnPropertyDescriptor,vt=(i,t,n,e)=>{for(var r=e>1?void 0:e?St(t,n):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(t,n,r):a(r))||r);return e&&r&&ft(t,n,r),r},le=(i,t)=>(n,e)=>t(n,e,i);const wt={};let de=class extends p.Disposable{constructor(i,t,n,e,r,o){super(),this._config=i,this._injector=t,this._componentManager=n,this._menuService=e,this._commandService=r,this._shortcutService=o,this._init()}_initCustomComponents(){const i=this._componentManager;this.disposeWithMe(i.register(Be,je)),this.disposeWithMe(i.register($e,at)),this.disposeWithMe(i.register(Ue,dt))}_initMenus(){const{menu:i={}}=this._config;[st,ct].forEach(t=>{this._menuService.addMenuItem(t(this._injector),i)})}_initCommands(){[oe,ae,fe,ge,se,Me,G,De,Re,Ee,re,be,Te].forEach(i=>this.disposeWithMe(this._commandService.registerCommand(i)))}_initShortcuts(){[ut,mt,gt,pt,ht].forEach(i=>{this.disposeWithMe(this._shortcutService.registerShortcut(i))})}_init(){this._initCommands(),this._initCustomComponents(),this._initMenus(),this._initShortcuts()}};de=vt([p.OnLifecycle(p.LifecycleStages.Rendered,de),le(1,B.Inject(B.Injector)),le(2,B.Inject(F.ComponentManager)),le(3,F.IMenuService),le(4,p.ICommandService),le(5,F.IShortcutService)],de);var _t=Object.defineProperty,It=Object.getOwnPropertyDescriptor,Ct=(i,t,n,e)=>{for(var r=e>1?void 0:e?It(t,n):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(t,n,r):a(r))||r);return e&&r&&_t(t,n,r),r},ie=(i,t)=>(n,e)=>t(n,e,i);const yt=[_.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],Mt=[_.SetRowVisibleMutation.id,_.SetRowHiddenMutation.id,_.SetColVisibleMutation.id,_.SetColHiddenMutation.id,_.SetWorksheetRowHeightMutation.id,_.SetWorksheetColWidthMutation.id];let we=class extends p.Disposable{constructor(i,t,n,e,r,o){super(),this._commandService=i,this._sheetInterceptorService=t,this._renderManagerService=n,this._sheetDrawingService=e,this._drawingManagerService=r,this._univerInstanceService=o,this._init()}get _selectionRenderService(){return this._renderManagerService.getRenderById(this._univerInstanceService.getCurrentUnitForType(p.UniverInstanceType.UNIVER_SHEET).getUnitId()).with($.ISheetSelectionRenderService)}get _skeletonManagerService(){return this._renderManagerService.getRenderById(this._univerInstanceService.getCurrentUnitForType(p.UniverInstanceType.UNIVER_SHEET).getUnitId()).with($.SheetSkeletonManagerService)}_init(){this._sheetInterceptorListener(),this._commandListener(),this._sheetRefreshListener()}_sheetInterceptorListener(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:i=>{if(!yt.includes(i.id))return{redos:[],undos:[]};if(i.params==null)return{redos:[],undos:[]};const t=i.id;if(t===_.InsertRowCommand.id)return this._moveRowInterceptor(i.params,"insert");if(t===_.InsertColCommand.id)return this._moveColInterceptor(i.params,"insert");if(t===_.RemoveRowCommand.id)return this._moveRowInterceptor(i.params,"remove");if(t===_.RemoveColCommand.id)return this._moveColInterceptor(i.params,"remove");if(t===_.DeleteRangeMoveLeftCommand.id){const{range:n}=i.params;return this._getRangeMoveUndo(n,0)}else if(t===_.DeleteRangeMoveUpCommand.id){const{range:n}=i.params;return this._getRangeMoveUndo(n,1)}else if(t===_.InsertRangeMoveDownCommand.id){const{range:n}=i.params;return this._getRangeMoveUndo(n,2)}else if(t===_.InsertRangeMoveRightCommand.id){const{range:n}=i.params;return this._getRangeMoveUndo(n,3)}else if(t===_.SetRowHiddenCommand.id||t===_.SetSpecificRowsVisibleCommand.id){const n=i.params,{unitId:e,subUnitId:r,ranges:o}=n;return this._getDrawingUndoForRowVisible(e,r,o)}else if(t===_.SetSpecificColsVisibleCommand.id||t===_.SetColHiddenCommand.id){const n=i.params,{unitId:e,subUnitId:r,ranges:o}=n;return this._getDrawingUndoForColVisible(e,r,o)}else if(t===_.DeltaRowHeightCommand.id||t===_.SetRowHeightCommand.id||t===_.DeltaColumnWidthCommand.id||t===_.SetColWidthCommand.id){const n=i.params,{unitId:e,subUnitId:r,ranges:o}=n,a=t===_.DeltaRowHeightCommand.id||t===_.SetRowHeightCommand.id;return this._getDrawingUndoForRowAndColSize(e,r,o,a)}return{redos:[],undos:[]}}}))}_getRangeMoveUndo(i,t){const n=_.getSheetCommandTarget(this._univerInstanceService);if(n==null)return{redos:[],undos:[]};const e=n.unitId,r=n.subUnitId,o=[],a=[],s=this._sheetDrawingService.getDrawingData(e,r),l=[],u=[];if(Object.keys(s).forEach(d=>{const c=s[d],{updateDrawings:m,deleteDrawings:g}=this._getUpdateOrDeleteDrawings(i,t,c);l.push(...m),u.push(...g)}),l.length===0&&u.length===0)return{redos:[],undos:[]};if(l.length>0){const d=this._sheetDrawingService.getBatchUpdateOp(l),{undo:c,redo:m,objects:g}=d;o.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:r,op:m,objects:g,type:h.DrawingApplyType.UPDATE}}),a.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:r,op:c,objects:g,type:h.DrawingApplyType.UPDATE}})}if(u.length>0){const d=this._sheetDrawingService.getBatchRemoveOp(u),c=d.undo,m=d.redo,g=d.objects;o.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:r,op:m,objects:g,type:h.DrawingApplyType.REMOVE}}),a.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:r,op:c,objects:g,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,t,n){const e=[],r=[],{sheetTransform:o,anchorType:a=h.SheetDrawingAnchorType.Position,transform:s,unitId:l,subUnitId:u,drawingId:d}=n,{from:c,to:m}=o,{row:g,column:S}=c,{row:f,column:v}=m;if(o==null||s==null)return{updateDrawings:e,deleteDrawings:r};const{startRow:y,endRow:M,startColumn:C,endColumn:R}=i;let I=null,O=null;if(t===0&&g>=y&&f<=M)if(S>=C&&v<=R)r.push({unitId:l,subUnitId:u,drawingId:d});else{const w=this._shrinkCol(o,s,C,R,a);I=w==null?void 0:w.newSheetTransform,O=w==null?void 0:w.newTransform}else if(t===1&&S>=C&&v<=R)if(g>=y&&f<=M)r.push({unitId:l,subUnitId:u,drawingId:d});else{const w=this._shrinkRow(o,s,y,M,a);I=w==null?void 0:w.newSheetTransform,O=w==null?void 0:w.newTransform}else if(t===2){const w=this._expandRow(o,s,y,M,a);I=w==null?void 0:w.newSheetTransform,O=w==null?void 0:w.newTransform}else if(t===3){const w=this._expandCol(o,s,C,R,a);I=w==null?void 0:w.newSheetTransform,O=w==null?void 0:w.newTransform}if(I!=null&&O!=null){const w=H(I,this._selectionRenderService,this._skeletonManagerService);e.push({...n,sheetTransform:I,transform:w})}return{updateDrawings:e,deleteDrawings:r}}_remainDrawingSize(i,t,n){const e=V({...i},this._selectionRenderService);e!=null&&t.push({...n,sheetTransform:e})}_getDrawingUndoForColVisible(i,t,n){const e=this._drawingManagerService.getDrawingData(i,t),r=[],o=[];if(Object.keys(e).forEach(d=>{const c=e[d],{sheetTransform:m,transform:g,anchorType:S=h.SheetDrawingAnchorType.Position}=c;if(S===h.SheetDrawingAnchorType.None)this._remainDrawingSize(g,r,c);else{const{from:f,to:v}=m,{row:y,column:M}=f,{row:C,column:R}=v;for(let I=0;I<n.length;I++){const O=n[I],{startRow:w,endRow:U,startColumn:E,endColumn:j}=O;if(R<E)continue;if(S===h.SheetDrawingAnchorType.Position){let D=null,W=null;if(M>=E&&M<=j){const Y=this._skeletonManagerService.attachRangeWithCoord({startColumn:M,endColumn:j,startRow:f.row,endRow:v.row});if(Y==null)return;W={...g,left:Y.startX}}if(W!=null&&(D=V(W,this._selectionRenderService),D!=null&&W!=null)){r.push({...c,sheetTransform:D,transform:W});break}this._remainDrawingSize(g,r,c);continue}if(M>=E&&R<=j)continue;let P=null,b=null;if(M>=E&&M<=j){const D=this._skeletonManagerService.attachRangeWithCoord({startColumn:M,endColumn:j,startRow:f.row,endRow:v.row});if(D==null)return;b={...g,left:(D==null?void 0:D.startX)||0,width:((g==null?void 0:g.width)||0)-D.endX+D.startX}}else if(R>=E&&R<=j){const D=this._skeletonManagerService.attachRangeWithCoord({startColumn:E,endColumn:R,startRow:f.row,endRow:v.row});if(D==null)return;b={...g,left:D.startX-((g==null?void 0:g.width)||0)}}else{const D=this._skeletonManagerService.attachRangeWithCoord({startColumn:E,endColumn:j,startRow:f.row,endRow:v.row});if(D==null)return;if(b={...g,width:((g==null?void 0:g.width)||0)-D.endX+D.startX},P=V(b,this._selectionRenderService),P!=null&&b!=null){o.push({...c,sheetTransform:P,transform:b});break}}if(b!=null&&(P=V(b,this._selectionRenderService)),b!=null&&P!=null){r.push({...c,sheetTransform:P,transform:b});break}else this._remainDrawingSize(g,r,c)}}}),r.length===0&&o.length===0)return{redos:[],undos:[]};const{redos:a,undos:s}=this._createUndoAndRedoMutation(i,t,r),l=[],u=[];if(o.length>0){const{redos:d,undos:c}=this._createUndoAndRedoMutation(i,t,o);l.push(...d),u.push(...c)}return{redos:a,undos:s,preRedos:l,preUndos:u}}_createUndoAndRedoMutation(i,t,n){const e=this._sheetDrawingService.getBatchUpdateOp(n),{undo:r,redo:o,objects:a}=e,s=[{id:h.SetDrawingApplyMutation.id,params:{unitId:i,subUnitId:t,op:o,objects:a,type:h.DrawingApplyType.UPDATE}},{id:G.id,params:[i]}],l=[{id:h.SetDrawingApplyMutation.id,params:{unitId:i,subUnitId:t,op:r,objects:a,type:h.DrawingApplyType.UPDATE}},{id:G.id,params:[i]}];return{redos:s,undos:l}}_getDrawingUndoForRowVisible(i,t,n){const e=this._drawingManagerService.getDrawingData(i,t),r=[],o=[];if(Object.keys(e).forEach(d=>{const c=e[d],{sheetTransform:m,transform:g,anchorType:S=h.SheetDrawingAnchorType.Position}=c;if(S===h.SheetDrawingAnchorType.None)this._remainDrawingSize(g,r,c);else{const{from:f,to:v}=m,{row:y,column:M}=f,{row:C,column:R}=v;for(let I=0;I<n.length;I++){const O=n[I],{startRow:w,endRow:U,startColumn:E,endColumn:j}=O;if(C<w)continue;if(S===h.SheetDrawingAnchorType.Position){let D=null,W=null;if(y>=w&&y<=U){const Y=this._skeletonManagerService.attachRangeWithCoord({startColumn:f.column,endColumn:v.column,startRow:y,endRow:U});if(Y==null)return;W={...g,top:Y.startY}}if(W!=null&&(D=V(W,this._selectionRenderService),D!=null&&W!=null)){r.push({...c,sheetTransform:D,transform:W});break}this._remainDrawingSize(g,r,c);continue}if(y>=w&&C<=U)continue;let P=null,b=null;if(y>=w&&y<=U){const D=this._skeletonManagerService.attachRangeWithCoord({startColumn:f.column,endColumn:v.column,startRow:y,endRow:U});if(D==null)return;b={...g,top:(D==null?void 0:D.startY)||0,height:((g==null?void 0:g.height)||0)-D.endY+D.startY}}else if(C>=w&&C<=U){const D=this._skeletonManagerService.attachRangeWithCoord({startColumn:f.column,endColumn:v.column,startRow:w,endRow:C});if(D==null)return;b={...g,top:D.startY-((g==null?void 0:g.height)||0)}}else{const D=this._skeletonManagerService.attachRangeWithCoord({startColumn:f.column,endColumn:v.column,startRow:w,endRow:U});if(D==null)return;if(b={...g,height:((g==null?void 0:g.height)||0)-D.endY+D.startY},P=V(b,this._selectionRenderService),P!=null&&b!=null){o.push({...c,sheetTransform:P,transform:b});break}}if(b!=null&&(P=V(b,this._selectionRenderService)),b!=null&&P!=null){r.push({...c,sheetTransform:P,transform:b});break}else this._remainDrawingSize(g,r,c)}}}),r.length===0&&o.length===0)return{redos:[],undos:[]};const{redos:a,undos:s}=this._createUndoAndRedoMutation(i,t,r),l=[],u=[];if(o.length>0){const{redos:d,undos:c}=this._createUndoAndRedoMutation(i,t,o);l.push(...d),u.push(...c)}return{redos:a,undos:s,preRedos:l,preUndos:u}}_getDrawingUndoForRowAndColSize(i,t,n,e){const r=this._drawingManagerService.getDrawingData(i,t),o=[];return Object.keys(r).forEach(a=>{const s=r[a],{sheetTransform:l,transform:u,anchorType:d=h.SheetDrawingAnchorType.Position}=s;if(d===h.SheetDrawingAnchorType.None)this._remainDrawingSize(u,o,s);else{const{from:c,to:m}=l,{row:g,column:S}=c,{row:f,column:v}=m;for(let y=0;y<n.length;y++){const M=n[y],{startRow:C,endRow:R,startColumn:I,endColumn:O}=M;if(f<C||v<I)continue;if(d===h.SheetDrawingAnchorType.Position&&(g<=C&&f>=R||S<=I&&v>=O)){this._remainDrawingSize(u,o,s);continue}const w=H({...l},this._selectionRenderService,this._skeletonManagerService);if(w!=null){o.push({...s,transform:w});break}}}}),o.length===0?{redos:[],undos:[]}:this._createUndoAndRedoMutation(i,t,o)}_getUnitIdAndSubUnitId(i,t){let n,e;if(t==="insert")n=i.unitId,e=i.subUnitId;else{const r=_.getSheetCommandTarget(this._univerInstanceService);if(r==null)return;n=r.unitId,e=r.subUnitId}return{unitId:n,subUnitId:e}}_moveRowInterceptor(i,t){const n=this._getUnitIdAndSubUnitId(i,t);if(n==null)return{redos:[],undos:[]};const{unitId:e,subUnitId:r}=n,{range:o}=i,a=o.startRow,s=o.endRow,l=[],u=[],d=this._sheetDrawingService.getDrawingData(e,r),c=[],m=[];if(Object.keys(d).forEach(g=>{const S=d[g],{sheetTransform:f,transform:v,anchorType:y=h.SheetDrawingAnchorType.Position}=S;if(f==null||v==null)return;let M,C;if(t==="insert"){const I=this._expandRow(f,v,a,s,y);M=I==null?void 0:I.newSheetTransform,C=I==null?void 0:I.newTransform}else{const{from:I,to:O}=f,{row:w}=I,{row:U}=O;if(w>=a&&U<=s)m.push({unitId:e,subUnitId:r,drawingId:g});else{const E=this._shrinkRow(f,v,a,s,y);M=E==null?void 0:E.newSheetTransform,C=E==null?void 0:E.newTransform}}if(!M||!C)return;const R={unitId:e,subUnitId:r,drawingId:g,transform:C,sheetTransform:M};c.push(R)}),c.length===0&&m.length===0)return{redos:[],undos:[]};if(c.length>0){const g=this._sheetDrawingService.getBatchUpdateOp(c),{undo:S,redo:f,objects:v}=g;l.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:r,op:f,objects:v,type:h.DrawingApplyType.UPDATE}}),u.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:r,op:S,objects:v,type:h.DrawingApplyType.UPDATE}})}if(m.length>0){const g=this._sheetDrawingService.getBatchRemoveOp(m),S=g.undo,f=g.redo,v=g.objects;l.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:r,op:f,objects:v,type:h.DrawingApplyType.REMOVE}}),u.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:r,op:S,objects:v,type:h.DrawingApplyType.INSERT}})}return l.push({id:G.id,params:[e]}),u.push({id:G.id,params:[e]}),{redos:l,undos:u}}_moveColInterceptor(i,t){const n=this._getUnitIdAndSubUnitId(i,t);if(n==null)return{redos:[],undos:[]};const{unitId:e,subUnitId:r}=n,{range:o}=i,a=o.startColumn,s=o.endColumn,l=[],u=[],d=this._sheetDrawingService.getDrawingData(e,r),c=[],m=[];if(Object.keys(d).forEach(g=>{const S=d[g],{sheetTransform:f,transform:v,anchorType:y=h.SheetDrawingAnchorType.Position}=S;if(f==null||v==null)return;let M,C;if(t==="insert"){const I=this._expandCol(f,v,a,s,y);M=I==null?void 0:I.newSheetTransform,C=I==null?void 0:I.newTransform}else{const{from:I,to:O}=f,{column:w}=I,{column:U}=O;if(w>=a&&U<=s)m.push({unitId:e,subUnitId:r,drawingId:g});else{const E=this._shrinkCol(f,v,a,s,y);M=E==null?void 0:E.newSheetTransform,C=E==null?void 0:E.newTransform}}if(!M||!C)return;const R={unitId:e,subUnitId:r,drawingId:g,transform:C,sheetTransform:M};c.push(R)}),c.length===0&&m.length===0)return{redos:[],undos:[]};if(c.length>0){const g=this._sheetDrawingService.getBatchUpdateOp(c),{undo:S,redo:f,objects:v}=g;l.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:r,op:f,objects:v,type:h.DrawingApplyType.UPDATE}}),u.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:r,op:S,objects:v,type:h.DrawingApplyType.UPDATE}})}if(m.length>0){const g=this._sheetDrawingService.getBatchRemoveOp(m),S=g.undo,f=g.redo,v=g.objects;l.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:r,op:f,objects:v,type:h.DrawingApplyType.REMOVE}}),u.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:r,op:S,objects:v,type:h.DrawingApplyType.INSERT}})}return l.push({id:G.id,params:[e]}),u.push({id:G.id,params:[e]}),{redos:l,undos:u}}_expandCol(i,t,n,e,r=h.SheetDrawingAnchorType.Position){const o=e-n+1,{from:a,to:s}=i,{column:l}=a,{column:u}=s;if(r===h.SheetDrawingAnchorType.None)return{newSheetTransform:V({...t},this._selectionRenderService),newTransform:t};let d=null,c=null;if(l>=n){const m=this._skeletonManagerService.attachRangeWithCoord({startColumn:n,endColumn:e,startRow:a.row,endRow:s.row});if(m==null)return;c={...t,left:(t.left||0)+m.endX-m.startX},d=V(c,this._selectionRenderService)}else if(u>=e)if(r===h.SheetDrawingAnchorType.Both)d={from:{...a},to:{...s,column:u+o}},c=H(d,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:V({...t},this._selectionRenderService),newTransform:t};return d!=null&&c!=null?{newSheetTransform:d,newTransform:c}:null}_shrinkCol(i,t,n,e,r=h.SheetDrawingAnchorType.Position){const o=e-n+1,{from:a,to:s}=i,{column:l}=a,{column:u}=s;if(r===h.SheetDrawingAnchorType.None)return{newSheetTransform:V({...t},this._selectionRenderService),newTransform:t};let d=null,c=null;if(l>e)d={from:{...a,column:l-o},to:{...s,column:u-o}},c=H(d,this._selectionRenderService,this._skeletonManagerService);else{if(l>=n&&u<=e)return null;if(l<n&&u>e)if(r===h.SheetDrawingAnchorType.Both)d={from:{...a},to:{...s,column:u-o}},c=H(d,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:V({...t},this._selectionRenderService),newTransform:t};else if(l>=n&&l<=e){if(l===n)c={...t,left:(t.left||0)-i.from.columnOffset};else{const m=this._skeletonManagerService.attachRangeWithCoord({startColumn:n,endColumn:l-1,startRow:a.row,endRow:s.row});if(m==null)return;c={...t,left:(t.left||0)-m.endX+m.startX-i.from.columnOffset}}d=V(c,this._selectionRenderService)}else if(u>=n&&u<=e&&r===h.SheetDrawingAnchorType.Both){const m=this._skeletonManagerService.attachRangeWithCoord({startColumn:n-1,endColumn:n-1,startRow:a.row,endRow:s.row});if(m==null)return;d={from:{...a},to:{...s,column:n-1,columnOffset:m.endX-m.startX}},c=H(d,this._selectionRenderService,this._skeletonManagerService)}}return d!=null&&c!=null?{newSheetTransform:d,newTransform:c}:null}_expandRow(i,t,n,e,r=h.SheetDrawingAnchorType.Position){const o=e-n+1,{from:a,to:s}=i,{row:l}=a,{row:u}=s;if(r===h.SheetDrawingAnchorType.None)return{newSheetTransform:V({...t},this._selectionRenderService),newTransform:t};let d=null,c=null;if(l>=n){const m=this._skeletonManagerService.attachRangeWithCoord({startRow:n,endRow:e,startColumn:a.column,endColumn:s.column});if(m==null)return;c={...t,top:(t.top||0)+m.endY-m.startY},d=V(c,this._selectionRenderService)}else if(u>=e)if(r===h.SheetDrawingAnchorType.Both)d={from:{...a},to:{...s,row:u+o}},c=H(d,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:V({...t},this._selectionRenderService),newTransform:t};return d!=null&&c!=null?{newSheetTransform:d,newTransform:c}:null}_shrinkRow(i,t,n,e,r=h.SheetDrawingAnchorType.Position){const o=e-n+1,{from:a,to:s}=i,{row:l}=a,{row:u}=s;if(r===h.SheetDrawingAnchorType.None)return{newSheetTransform:V({...t},this._selectionRenderService),newTransform:t};let d=null,c=null;if(l>e)d={from:{...a,row:l-o},to:{...s,row:u-o}},c=H(d,this._selectionRenderService,this._skeletonManagerService);else{if(l>=n&&u<=e)return null;if(l<n&&u>e)if(r===h.SheetDrawingAnchorType.Both)d={from:{...a},to:{...s,row:u-o}},c=H(d,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:V({...t},this._selectionRenderService),newTransform:t};else if(l>=n&&l<=e){if(l===n)c={...t,top:(t.top||0)-i.from.rowOffset};else{const m=this._skeletonManagerService.attachRangeWithCoord({startRow:n,endRow:l-1,startColumn:a.column,endColumn:s.column});if(m==null)return;c={...t,top:(t.top||0)-m.endY+m.startY-i.from.rowOffset}}d=V(c,this._selectionRenderService)}else if(u>=n&&u<=e&&r===h.SheetDrawingAnchorType.Both){const m=this._skeletonManagerService.attachRangeWithCoord({startColumn:a.column,endColumn:a.column,startRow:n-1,endRow:n-1});if(m==null)return;d={from:{...a},to:{...s,row:n-1,rowOffset:m.endY-m.startY}},c=H(d,this._selectionRenderService,this._skeletonManagerService)}}return d!=null&&c!=null?{newSheetTransform:d,newTransform:c}:null}_commandListener(){this.disposeWithMe(this._commandService.onCommandExecuted(i=>{i.id===_.SetWorksheetActiveOperation.id&&setTimeout(()=>{const t=i.params,{unitId:n,subUnitId:e}=t,r=this._drawingManagerService.drawingManagerData,o=[],a=[];Object.keys(r).forEach(s=>{const l=r[s];Object.keys(l).forEach(u=>{const d=l[u].data;d!=null&&Object.keys(d).forEach(c=>{if(s===n&&u===e){const m=d[c];m.transform=H(m.sheetTransform,this._selectionRenderService,this._skeletonManagerService),o.push(d[c])}else a.push(d[c])})})}),this._drawingManagerService.removeNotification(a),this._drawingManagerService.addNotification(o)},0)}))}_sheetRefreshListener(){this.disposeWithMe(this._commandService.onCommandExecuted(i=>{Mt.includes(i.id)&&requestIdleCallback(()=>{const t=i.params,{unitId:n,subUnitId:e,ranges:r}=t;this._refreshDrawingTransform(n,e,r)})}))}_refreshDrawingTransform(i,t,n){const e=this._drawingManagerService.getDrawingData(i,t),r=[];Object.keys(e).forEach(o=>{const a=e[o],{sheetTransform:s,anchorType:l=h.SheetDrawingAnchorType.Position}=a;if(l===h.SheetDrawingAnchorType.None)return!0;const{from:u,to:d}=s,{row:c,column:m}=u,{row:g,column:S}=d;for(let f=0;f<n.length;f++){const v=n[f],{startRow:y,endRow:M,startColumn:C,endColumn:R}=v;if(p.Rectangle.intersects({startRow:y,endRow:M,startColumn:C,endColumn:R},{startRow:c,endRow:g,startColumn:m,endColumn:S})||c>M||m>R){r.push({...a,transform:H(s,this._selectionRenderService,this._skeletonManagerService)});break}}}),r.length!==0&&(this._drawingManagerService.refreshTransform(r),this._commandService.syncExecuteCommand(G.id,[i]))}};we=Ct([p.OnLifecycle(p.LifecycleStages.Rendered,we),ie(0,p.ICommandService),ie(1,B.Inject(_.SheetInterceptorService)),ie(2,L.IRenderManagerService),ie(3,h.ISheetDrawingService),ie(4,A.IDrawingManagerService),ie(5,p.IUniverInstanceService)],we);var Dt=Object.defineProperty,Tt=Object.getOwnPropertyDescriptor,Rt=(i,t,n,e)=>{for(var r=e>1?void 0:e?Tt(t,n):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(t,n,r):a(r))||r);return e&&r&&Dt(t,n,r),r},te=(i,t)=>(n,e)=>t(n,e,i);function Et(i,t,n,e){const{scaleX:r,scaleY:o}=t.getAncestorScale(),a=t.getViewport(L.SHEET_VIEWPORT_KEY.VIEW_MAIN),s={left:!0,top:!0};if(!a)return{...i,absolute:s};const{left:l,right:u,top:d,bottom:c}=i,m=e.getFreeze(),{startColumn:g,startRow:S,xSplit:f,ySplit:v}=m,y=n.getNoMergeCellPositionByIndexWithNoHeader(S-v,g-f),M=n.getNoMergeCellPositionByIndexWithNoHeader(S,g),{rowHeaderWidth:C,columnHeaderHeight:R}=n,I=M.startX-y.startX,O=M.startY-y.startY,{top:w,left:U,viewportScrollX:E,viewportScrollY:j}=a;let P,b;l<U?(s.left=!0,P=(I+C+(l-U))*r,b=Math.max(Math.min((I+C+(u-U))*r,(I+C)*r),(u-E)*r)):(s.left=!1,P=Math.max((l-E)*r,(I+C)*r),b=Math.max((u-E)*r,(I+C)*r));let D,W;return d<w?(s.top=!0,D=(O+R+(d-w))*o,W=Math.max(Math.min((O+R+(u-w))*o,(O+R)*o),(c-j)*o)):(s.top=!1,D=Math.max((d-j)*o,(O+R)*o),W=Math.max((c-j)*o,(O+R)*o)),{left:P,right:b,top:D,bottom:W,absolute:s}}const Oe=(i,t,n,e)=>{const{scene:r}=t,{left:o,top:a,width:s,height:l,angle:u}=i,d={left:o,right:o+s,top:a,bottom:a+l},c=Et(d,r,n,e);return{startX:c.left,endX:c.right,startY:c.top,endY:c.bottom,rotate:u,width:s,height:l,absolute:c.absolute}};T.SheetCanvasFloatDomManagerService=class extends p.Disposable{constructor(n,e,r,o,a,s,l){super();z(this,"_domLayerMap",new Map);z(this,"_domLayerInfoMap",new Map);z(this,"_transformChange$",new k.Subject);z(this,"transformChange$",this._transformChange$.asObservable());z(this,"_remove$",new k.Subject);z(this,"remove$",this._remove$.asObservable());this._renderManagerService=n,this._univerInstanceService=e,this._commandService=r,this._drawingManagerService=o,this._selectionRenderService=a,this._canvasFloatDomService=s,this._sheetDrawingService=l,this._drawingAddListener(),this._scrollUpdateListener(),this._featureUpdateListener(),this._deleteListener()}_ensureMap(n,e){let r=this._domLayerMap.get(n);r||(r=new Map,this._domLayerMap.set(n,r));let o=r.get(e);return o||(o=new Map,r.set(e,o)),o}_getSceneAndTransformerByDrawingSearch(n){if(n==null)return;const e=this._renderManagerService.getRenderById(n),r=e==null?void 0:e.scene;if(e==null||r==null)return null;const o=r.getTransformerByCreate(),a=e.engine.getCanvasElement();return{scene:r,transformer:o,renderObject:e,canvas:a}}_drawingAddListener(){this.disposeWithMe(this._drawingManagerService.add$.subscribe(n=>{n.forEach(e=>{var He,Ye;const{unitId:r,subUnitId:o,drawingId:a}=e,s=_.getSheetCommandTarget(this._univerInstanceService,{unitId:r,subUnitId:o}),l=this._drawingManagerService.getDrawingByParam(e),u=(He=this._renderManagerService.getRenderById(r))==null?void 0:He.with($.SheetSkeletonManagerService).getWorksheetSkeleton(o);if(l==null||s==null||u==null)return;const{transform:d,drawingType:c}=l;if(c!==p.DrawingTypeEnum.DRAWING_DOM)return;const m=this._getSceneAndTransformerByDrawingSearch(r);if(m==null)return;const{scene:g,canvas:S}=m;if(d==null)return!0;const{left:f,top:v,width:y,height:M,angle:C,flipX:R,flipY:I,skewX:O,skewY:w}=d,U=A.getDrawingShapeKeyByDrawingSearch({unitId:r,subUnitId:o,drawingId:a}),E=g.getObject(U);if(E!=null){E.transformByState({left:f,top:v,width:y,height:M,angle:C,flipX:R,flipY:I,skewX:O,skewY:w});return}const j={left:f,top:v,width:y,height:M,zIndex:this._drawingManagerService.getDrawingOrder(r,o).length-1},P=new L.Rect(U,j);g.addObject(P,L.DRAWING_OBJECT_LAYER_INDEX).attachTransformerTo(P);const b=this._ensureMap(r,o),D=new p.DisposableCollection,W=Oe(P,m.renderObject,u.skeleton,s.worksheet),Y=new k.BehaviorSubject(W),ne={dispose:D,rect:P,position$:Y,unitId:r,subUnitId:o};this._canvasFloatDomService.addFloatDom({position$:Y,id:a,componentKey:l.componentKey,onPointerDown:X=>{S.dispatchEvent(new PointerEvent(X.type,X))},onPointerMove:X=>{S.dispatchEvent(new PointerEvent(X.type,X))},onPointerUp:X=>{S.dispatchEvent(new PointerEvent(X.type,X))},onWheel:X=>{S.dispatchEvent(new WheelEvent(X.type,X))},props:(Ye=b.get(a))==null?void 0:Ye.props});const ke=P.onTransformChange$.subscribeEvent(()=>{const X=Oe(P,m.renderObject,u.skeleton,s.worksheet);Y.next(X)});D.add(()=>{this._canvasFloatDomService.removeFloatDom(a)}),ke&&D.add(ke),this._domLayerInfoMap.set(a,ne)})}))}_scrollUpdateListener(){this.disposeWithMe(this._commandService.onCommandExecuted(n=>{var r,o;const e=(a,s)=>{var g;const l=this._getSceneAndTransformerByDrawingSearch(a),u=this._ensureMap(a,s),d=Array.from(u.keys()),c=_.getSheetCommandTarget(this._univerInstanceService,{unitId:a,subUnitId:s}),m=(g=this._renderManagerService.getRenderById(a))==null?void 0:g.with($.SheetSkeletonManagerService).getWorksheetSkeleton(s);!l||!c||!m||d.forEach(S=>{const f=this._domLayerInfoMap.get(S);if(f){const v=Oe(f.rect,l.renderObject,m.skeleton,c.worksheet);f.position$.next(v)}})};if(n.id===$.SetScrollOperation.id){const a=n.params,{unitId:s,sheetId:l}=a;e(s,l)}else if(n.id===$.SetZoomRatioOperation.id){const a=n.params,{unitId:s}=a;Array.from((o=(r=this._domLayerMap.get(s))==null?void 0:r.keys())!=null?o:[]).forEach(u=>{e(s,u)})}else if(n.id===_.SetFrozenMutation.id){const{unitId:a,subUnitId:s}=n.params;e(a,s)}}))}_getPosition(n){const{startX:e,endX:r,startY:o,endY:a}=n,s=this._selectionRenderService.getSelectionCellByPosition(e,o);if(s==null)return;const l={column:s.actualColumn,columnOffset:e-s.startX,row:s.actualRow,rowOffset:o-s.startY},u=this._selectionRenderService.getSelectionCellByPosition(r,a);if(u==null)return;const d={column:u.actualColumn,columnOffset:r-u.startX,row:u.actualRow,rowOffset:a-u.startY};return{from:l,to:d}}_featureUpdateListener(){this.disposeWithMe(this._drawingManagerService.update$.subscribe(n=>{n.forEach(e=>{const r=this._drawingManagerService.getDrawingByParam(e);if(!r||r.drawingType!==p.DrawingTypeEnum.DRAWING_DOM)return;const o={...r.transform};this._transformChange$.next({id:e.drawingId,value:o})})}))}_deleteListener(){this.disposeWithMe(this._drawingManagerService.remove$.subscribe(n=>{n.forEach(e=>{this._removeDom(e.drawingId)})}))}addFloatDomToPosition(n){const e=_.getSheetCommandTarget(this._univerInstanceService,{unitId:n.unitId,subUnitId:n.subUnitId});if(!e)throw new Error("cannot find current target!");const{unitId:r,subUnitId:o}=e,{initPosition:a,componentKey:s}=n,l=p.Tools.generateRandomId(),u=this._getPosition(a);if(u==null)return;this._ensureMap(r,o).set(l,n);const c={unitId:r,subUnitId:o,drawingId:l,drawingType:p.DrawingTypeEnum.DRAWING_DOM,componentKey:s,sheetTransform:u,transform:{left:a.startX,top:a.startY,width:a.endX-a.startX,height:a.endY-a.startY}};return this._commandService.executeCommand(fe.id,{unitId:r,drawings:[c]}),{id:l,dispose:()=>{this._removeDom(l,!0)}}}_removeDom(n,e=!1){const r=this._domLayerInfoMap.get(n);if(!r)return;const{unitId:o,subUnitId:a}=r;this._domLayerInfoMap.delete(n),r.dispose.dispose();const s=this._getSceneAndTransformerByDrawingSearch(o);if(s&&s.scene.removeObject(r.rect),e){this._ensureMap(o,a).delete(n);const u=this._drawingManagerService.getDrawingByParam({unitId:o,subUnitId:a,drawingId:n});if(!u)return;const d=this._sheetDrawingService.getBatchRemoveOp([u]),{redo:c,objects:m}=d;this._commandService.syncExecuteCommand(h.SetDrawingApplyMutation.id,{unitId:o,subUnitId:a,op:c,objects:m,type:h.DrawingApplyType.REMOVE})}}},T.SheetCanvasFloatDomManagerService=Rt([te(0,B.Inject(L.IRenderManagerService)),te(1,p.IUniverInstanceService),te(2,B.Inject(p.ICommandService)),te(3,A.IDrawingManagerService),te(4,$.ISheetSelectionRenderService),te(5,B.Inject(F.CanvasFloatDomService)),te(6,h.ISheetDrawingService)],T.SheetCanvasFloatDomManagerService);var bt=Object.defineProperty,Ot=Object.getOwnPropertyDescriptor,Pt=(i,t,n,e)=>{for(var r=e>1?void 0:e?Ot(t,n):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(t,n,r):a(r))||r);return e&&r&&bt(t,n,r),r},_e=(i,t)=>(n,e)=>t(n,e,i);let Ie=class extends p.Disposable{constructor(i,t,n,e){super(),this._sheetPrintInterceptorService=i,this._drawingRenderService=t,this._drawingManagerService=n,this._renderManagerService=e,this._initPrinting()}_initPrinting(){this.disposeWithMe(this._sheetPrintInterceptorService.interceptor.intercept(this._sheetPrintInterceptorService.interceptor.getInterceptPoints().PRINTING_COMPONENT_COLLECT,{handler:(i,t,n)=>{const{unitId:e,scene:r,subUnitId:o}=t,a=this._drawingManagerService.getDrawingDataForUnit(e),s=a==null?void 0:a[o];return s&&s.order.forEach(l=>{this._drawingRenderService.renderDrawing(s.data[l],r)}),n()}})),this.disposeWithMe(this._sheetPrintInterceptorService.interceptor.intercept(this._sheetPrintInterceptorService.interceptor.getInterceptPoints().PRINTING_RANGE,{handler:(i,t,n)=>{const{unitId:e,subUnitId:r}=t,o=this._renderManagerService.getRenderById(e);if(!o)return n(i);const a=o.with($.SheetSkeletonManagerService).getWorksheetSkeleton(r);if(!a)return n(i);const s=this._drawingManagerService.getDrawingDataForUnit(e),l=s==null?void 0:s[t.subUnitId];if(!l)return n(i);const{scaleX:u,scaleY:d}=o.scene,c=i?{...i}:{startColumn:0,endColumn:0,endRow:0,startRow:0},m=l.order.map(g=>l.data[g]).filter(g=>g.drawingType!==A.DrawingTypeEnum.DRAWING_DOM);return m.length?(m.forEach(g=>{if(!g.groupId&&g.transform&&p.Tools.isDefine(g.transform.left)&&p.Tools.isDefine(g.transform.top)&&p.Tools.isDefine(g.transform.width)&&p.Tools.isDefine(g.transform.height)){const S=a.skeleton.getCellPositionByOffset(g.transform.left,g.transform.top,u,d,{x:0,y:0}),f=a.skeleton.getCellPositionByOffset(g.transform.left+g.transform.width,g.transform.top+g.transform.height,u,d,{x:0,y:0});S.column<c.startColumn&&(c.startColumn=S.column),S.row<c.startRow&&(c.startRow=S.row),c.endRow<f.row&&(c.endRow=f.row),c.endColumn<f.column&&(c.endColumn=f.column)}}),n(c)):n(i)}}))}};Ie=Pt([p.OnLifecycle(p.LifecycleStages.Rendered,Ie),_e(0,B.Inject($.SheetPrintInterceptorService)),_e(1,B.Inject(Q.DrawingRenderService)),_e(2,A.IDrawingManagerService),_e(3,L.IRenderManagerService)],Ie);var At=Object.defineProperty,Ut=Object.getOwnPropertyDescriptor,Nt=(i,t,n,e)=>{for(var r=e>1?void 0:e?Ut(t,n):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(t,n,r):a(r))||r);return e&&r&&At(t,n,r),r},ue=(i,t)=>(n,e)=>t(n,e,i);let Ce=class extends p.Disposable{constructor(i,t,n,e,r){super(),this._drawingManagerService=i,this._renderManagerService=t,this._permissionService=n,this._univerInstanceService=e,this._userManagerService=r,this._initDrawingVisible(),this._initDrawingEditable(),this._initViewPermissionChange(),this._initEditPermissionChange()}_initDrawingVisible(){const i=this._univerInstanceService.getCurrentTypeOfUnit$(p.UniverInstanceType.UNIVER_SHEET);this.disposeWithMe(k.combineLatest([i,this._userManagerService.currentUser$]).subscribe(([t,n])=>{if(!t){this._drawingManagerService.setDrawingVisible(!1);return}t.activeSheet$.subscribe(e=>{if(!e){this._drawingManagerService.setDrawingVisible(!1);return}const r=t.getUnitId(),o=e.getSheetId();if(this._permissionService.composePermission([new _.WorkbookViewPermission(r).id,new _.WorksheetViewPermission(r,o).id]).every(s=>s.value))this._drawingManagerService.setDrawingVisible(!0);else{this._drawingManagerService.setDrawingVisible(!1);const s=t.getUnitId(),l=e.getSheetId(),u=this._drawingManagerService.getDrawingData(s,l),d=Object.values(u),c=this._renderManagerService.getRenderById(s),m=c==null?void 0:c.scene;if(m==null)return;m.getAllObjects().forEach(S=>{S.classType===L.RENDER_CLASS_TYPE.IMAGE&&d.some(f=>S.oKey.includes(f.drawingId))&&m.removeObject(S)})}})}))}_initDrawingEditable(){const i=this._univerInstanceService.getCurrentTypeOfUnit$(p.UniverInstanceType.UNIVER_SHEET);this.disposeWithMe(k.combineLatest([i,this._userManagerService.currentUser$]).subscribe(([t,n])=>{if(!t){this._drawingManagerService.setDrawingEditable(!1);return}t.activeSheet$.subscribe(e=>{if(!e){this._drawingManagerService.setDrawingEditable(!1);return}const r=t.getUnitId(),o=e.getSheetId();if(this._permissionService.composePermission([new _.WorkbookEditablePermission(r).id,new _.WorksheetEditPermission(r,o).id]).every(s=>s.value))this._drawingManagerService.setDrawingEditable(!0);else{this._drawingManagerService.setDrawingEditable(!1);const s=t.getUnitId(),l=e.getSheetId(),u=this._drawingManagerService.getDrawingData(s,l),d=Object.values(u),c=this._renderManagerService.getRenderById(s),m=c==null?void 0:c.scene;if(m==null)return;m.getAllObjects().forEach(S=>{S.classType===L.RENDER_CLASS_TYPE.IMAGE&&d.some(f=>S.oKey.includes(f.drawingId))&&m.detachTransformerFrom(S)})}})}))}_initViewPermissionChange(){const i=this._univerInstanceService.getCurrentTypeOfUnit$(p.UniverInstanceType.UNIVER_SHEET);this.disposeWithMe(k.combineLatest([i,this._userManagerService.currentUser$]).subscribe(([t,n])=>{t&&t.activeSheet$.subscribe(e=>{var c;if(!e)return;const r=t.getUnitId(),o=e.getSheetId();let a=!0;const s=this._renderManagerService.getRenderById(r),l=s==null?void 0:s.scene;if(l==null)return;const u=l.getTransformerByCreate(),d=this._permissionService.composePermission$([new _.WorkbookViewPermission(r).id,new _.WorksheetViewPermission(r,o).id]).pipe(k.map(m=>m.every(g=>g.value)));d==null||d.pipe(k.filter(m=>m!==a),k.distinctUntilChanged()).subscribe({next:m=>{a=m,this._drawingManagerService.setDrawingVisible(m);const g=l.getAllObjects(),S=this._drawingManagerService.getDrawingData(r,o),f=Object.values(S);m?this._drawingManagerService.addNotification(f):(g.forEach(v=>{v.classType===L.RENDER_CLASS_TYPE.IMAGE&&f.some(y=>v.oKey.includes(y.drawingId))&&l.removeObject(v)}),u.clearSelectedObjects())}}),(c=this._permissionService.getPermissionPoint$(new _.WorksheetViewPermission(r,o).id))==null||c.pipe(k.filter(m=>m.value!==a),k.distinctUntilChanged()).subscribe({complete:()=>{a=!0,this._drawingManagerService.setDrawingVisible(!0);const m=this._drawingManagerService.getDrawingData(r,o),g=Object.values(m);this._drawingManagerService.addNotification(g)}})})}))}_initEditPermissionChange(){const i=this._univerInstanceService.getCurrentTypeOfUnit$(p.UniverInstanceType.UNIVER_SHEET);this.disposeWithMe(k.combineLatest([i,this._userManagerService.currentUser$]).subscribe(([t,n])=>{t&&t.activeSheet$.subscribe(e=>{var c;if(!e)return;const r=t.getUnitId(),o=e.getSheetId();let a=!0;const s=this._renderManagerService.getRenderById(r),l=s==null?void 0:s.scene;if(l==null)return;const u=l.getTransformerByCreate(),d=this._permissionService.composePermission$([new _.WorkbookEditablePermission(r).id,new _.WorksheetEditPermission(r,o).id]).pipe(k.map(m=>m.every(g=>g.value)));d==null||d.pipe(k.filter(m=>m!==a),k.distinctUntilChanged()).subscribe({next:m=>{a=m,this._drawingManagerService.setDrawingEditable(m);const g=l.getAllObjects(),S=this._drawingManagerService.getDrawingData(r,o),f=Object.values(S);m?(g.forEach(v=>{v.classType===L.RENDER_CLASS_TYPE.IMAGE&&f.some(y=>v.oKey.includes(y.drawingId))&&l.attachTransformerTo(v)}),this._drawingManagerService.addNotification(f)):(g.forEach(v=>{v.classType===L.RENDER_CLASS_TYPE.IMAGE&&f.some(y=>v.oKey.includes(y.drawingId))&&l.detachTransformerFrom(v)}),u.clearSelectedObjects())}}),(c=this._permissionService.getPermissionPoint$(new _.WorksheetEditPermission(r,o).id))==null||c.pipe(k.filter(m=>m.value!==a),k.distinctUntilChanged()).subscribe({complete:()=>{a=!0;const m=t.getUnitId(),g=e.getSheetId(),S=this._drawingManagerService.getDrawingData(m,g),f=Object.values(S),v=this._renderManagerService.getRenderById(m),y=v==null?void 0:v.scene;if(y==null)return;this._drawingManagerService.setDrawingEditable(!0),y.getAllObjects().forEach(C=>{C.classType===L.RENDER_CLASS_TYPE.IMAGE&&f.some(R=>C.oKey.includes(R.drawingId))&&y.detachTransformerFrom(C)})}})})}))}};Ce=Nt([p.OnLifecycle(p.LifecycleStages.Rendered,Ce),ue(0,A.IDrawingManagerService),ue(1,L.IRenderManagerService),ue(2,p.IPermissionService),ue(3,p.IUniverInstanceService),ue(4,B.Inject(p.UserManagerService))],Ce);var Lt=Object.defineProperty,jt=Object.getOwnPropertyDescriptor,Wt=(i,t,n,e)=>{for(var r=e>1?void 0:e?jt(t,n):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(t,n,r):a(r))||r);return e&&r&&Lt(t,n,r),r},Pe=(i,t)=>(n,e)=>t(n,e,i);let ye=class extends p.Disposable{constructor(t,n,e){super();z(this,"_copyInfo");this._sheetClipboardService=t,this._renderManagerService=n,this._sheetDrawingService=e,this._initCopyPaste()}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:"SHEET_IMAGE_UI_PLUGIN",onBeforeCopy:(t,n,e)=>this._collect(t,n,e),onPasteCells:(t,n,e,r)=>{const{copyType:o=$.COPY_TYPE.COPY,pasteType:a}=r,{range:s}=t||{},{range:l,unitId:u,subUnitId:d}=n;return this._generateMutations(l,{copyType:o,pasteType:a,copyRange:s,unitId:u,subUnitId:d})},onPastePlainText:(t,n)=>({undos:[],redos:[]})})}_collect(t,n,e){var m;const r=(m=this._renderManagerService.getRenderById(t))==null?void 0:m.with($.SheetSkeletonManagerService);if(!r)return;const o=r.attachRangeWithCoord(e);if(!o)return;const{startX:a,endX:s,startY:l,endY:u}=o,d=this._sheetDrawingService.getDrawingData(t,n),c=[];Object.keys(d).forEach(g=>{const S=d[g],{transform:f}=S;if(S.anchorType!==h.SheetDrawingAnchorType.Both||!f)return;const{left:v=0,top:y=0,width:M=0,height:C=0}=f,{drawingStartX:R,drawingEndX:I,drawingStartY:O,drawingEndY:w}={drawingStartX:v,drawingEndX:v+M,drawingStartY:y,drawingEndY:y+C};a<=R&&I<=s&&l<=O&&w<=u&&c.push(S)}),c.length&&(this._copyInfo={drawings:c,unitId:t,subUnitId:n})}_generateMutations(t,n){var E;if(!this._copyInfo)return{redos:[],undos:[]};if([$.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,$.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,$.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,$.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMULA].includes(n.pasteType))return{redos:[],undos:[]};const{copyRange:e}=n;if(!e)return{redos:[],undos:[]};const{drawings:r,unitId:o,subUnitId:a}=this._copyInfo,{ranges:[s,l],mapFunc:u}=$.virtualizeDiscreteRanges([e,t]),{row:d,col:c}=u(s.startRow,s.startColumn),{row:m,col:g}=u(l.startRow,l.startColumn),S=(E=this._renderManagerService.getRenderById(o))==null?void 0:E.with($.SheetSkeletonManagerService);if(!S)return{redos:[],undos:[]};const f=S.attachRangeWithCoord({startRow:d,endRow:d,startColumn:c,endColumn:c}),v=S.attachRangeWithCoord({startRow:m,endRow:m,startColumn:g,endColumn:g});if(!f||!v)return{redos:[],undos:[]};const y=[],M=[],C=v.startX-f.startX,R=v.startY-f.startY,I=m-d,O=g-c,w=n.copyType===$.COPY_TYPE.CUT,{_sheetDrawingService:U}=this;return r.forEach(j=>{const{transform:P,sheetTransform:b}=j;if(!P)return;const D={...j,unitId:o,subUnitId:a,drawingId:w?j.drawingId:p.Tools.generateRandomId(),transform:{...P,left:P.left+C,top:P.top+R},sheetTransform:{to:{...b.to,row:b.to.row+I,column:b.to.column+O},from:{...b.from,row:b.from.row+I,column:b.from.column+O}}};if(w){const{undo:W,redo:Y,objects:ne}=U.getBatchUpdateOp([D]);y.push({id:h.SetDrawingApplyMutation.id,params:{unitId:o,subUnitId:a,type:h.DrawingApplyType.UPDATE,op:Y,objects:ne}}),M.push({id:h.SetDrawingApplyMutation.id,params:{unitId:o,subUnitId:a,type:h.DrawingApplyType.UPDATE,op:W,objects:ne}})}else{const{undo:W,redo:Y,objects:ne}=U.getBatchAddOp([D]);y.push({id:h.SetDrawingApplyMutation.id,params:{op:Y,unitId:o,subUnitId:a,objects:ne,type:h.DrawingApplyType.INSERT}}),M.push({id:h.SetDrawingApplyMutation.id,params:{op:W,unitId:o,subUnitId:a,objects:ne,type:h.DrawingApplyType.REMOVE}})}}),{redos:y,undos:M}}};ye=Wt([p.OnLifecycle(p.LifecycleStages.Ready,ye),Pe(0,$.ISheetClipboardService),Pe(1,L.IRenderManagerService),Pe(2,h.ISheetDrawingService)],ye);var Ve=Object.defineProperty,$t=Object.getOwnPropertyDescriptor,Bt=(i,t,n)=>t in i?Ve(i,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[t]=n,Gt=(i,t,n,e)=>{for(var r=e>1?void 0:e?$t(t,n):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(t,n,r):a(r))||r);return e&&r&&Ve(t,n,r),r},Ae=(i,t)=>(n,e)=>t(n,e,i),Fe=(i,t,n)=>Bt(i,typeof t!="symbol"?t+"":t,n);const Vt="SHEET_IMAGE_UI_PLUGIN";T.UniverSheetsDrawingUIPlugin=class extends p.Plugin{constructor(n={},e,r,o){super();z(this,"_pluginConfig");this._injector=e,this._localeService=r,this._renderManagerService=o,this._pluginConfig=p.Tools.deepMerge({},wt,n)}onStarting(n){super.onStarting(n),this._initDependencies(n)}onRendered(){this._registerRenderModules()}_initDependencies(n){const e=[[T.SheetCanvasFloatDomManagerService],[de,{useFactory:()=>this._injector.createInstance(de,this._pluginConfig)}],[he],[Ie],[Ce]],r=[Se,we];e.forEach(o=>n.add(o)),r.forEach(o=>this._renderManagerService.registerRenderModule(p.UniverInstanceType.UNIVER_SHEET,o))}_registerRenderModules(){[[ye]].forEach(n=>{this.disposeWithMe(this._renderManagerService.registerRenderModule(p.UniverInstanceType.UNIVER_SHEET,n))})}},Fe(T.UniverSheetsDrawingUIPlugin,"type",p.UniverInstanceType.UNIVER_SHEET),Fe(T.UniverSheetsDrawingUIPlugin,"pluginName",Vt),T.UniverSheetsDrawingUIPlugin=Gt([p.DependentOn(A.UniverDrawingPlugin,Q.UniverDrawingUIPlugin,h.UniverSheetsDrawingPlugin),Ae(1,B.Inject(B.Injector)),Ae(2,B.Inject(p.LocaleService)),Ae(3,L.IRenderManagerService)],T.UniverSheetsDrawingUIPlugin),T.ClearSheetDrawingTransformerOperation=G,T.DeleteDrawingsCommand=be,T.EditSheetDrawingOperation=De,T.GroupSheetDrawingCommand=Re,T.InsertCellImageOperation=ae,T.InsertFloatImageOperation=oe,T.InsertSheetDrawingCommand=fe,T.MoveDrawingsCommand=re,T.RemoveSheetDrawingCommand=ge,T.SetDrawingArrangeCommand=Te,T.SetSheetDrawingCommand=se,T.SidebarSheetDrawingOperation=Me,T.UngroupSheetDrawingCommand=Ee,Object.defineProperty(T,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(T,p){typeof exports=="object"&&typeof module<"u"?p(exports,require("@univerjs/core"),require("@wendellhu/redi"),require("@univerjs/drawing-ui"),require("@univerjs/sheets-drawing"),require("@univerjs/drawing"),require("@univerjs/engine-render"),require("@univerjs/sheets-ui"),require("rxjs"),require("@univerjs/ui"),require("@wendellhu/redi/react-bindings"),require("@univerjs/sheets"),require("react"),require("@univerjs/design"),require("clsx")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@wendellhu/redi","@univerjs/drawing-ui","@univerjs/sheets-drawing","@univerjs/drawing","@univerjs/engine-render","@univerjs/sheets-ui","rxjs","@univerjs/ui","@wendellhu/redi/react-bindings","@univerjs/sheets","react","@univerjs/design","clsx"],p):(T=typeof globalThis<"u"?globalThis:T||self,p(T.UniverSheetsDrawingUi={},T.UniverCore,T["@wendellhu/redi"],T.UniverDrawingUi,T.UniverSheetsDrawing,T.UniverDrawing,T.UniverEngineRender,T.UniverSheetsUi,T.rxjs,T.UniverUi,T["@wendellhu/redi/react-bindings"],T.UniverSheets,T.React,T.UniverDesign,T.clsx))})(this,function(T,p,$,Q,h,A,L,B,k,F,q,_,N,J,me){"use strict";var kt=Object.defineProperty;var Ht=(T,p,$)=>p in T?kt(T,p,{enumerable:!0,configurable:!0,writable:!0,value:$}):T[p]=$;var K=(T,p,$)=>Ht(T,typeof p!="symbol"?p+"":p,$);const G={id:"sheet.operation.clear-drawing-transformer",type:p.CommandType.MUTATION,handler:(i,r)=>{const t=i.get(L.IRenderManagerService);return r.forEach(e=>{var n,o;(o=(n=t.getRenderById(e))==null?void 0:n.scene.getTransformer())==null||o.debounceRefreshControls()}),!0}},ge={id:"sheet.command.remove-sheet-image",type:p.CommandType.COMMAND,handler:(i,r)=>{const t=i.get(p.ICommandService),e=i.get(p.IUndoRedoService),n=i.get(h.ISheetDrawingService);if(!r)return!1;const{drawings:o}=r,a=[];o.forEach(S=>{const{unitId:f}=S;a.push(f)});const s=n.getBatchRemoveOp(o),{unitId:l,subUnitId:u,undo:d,redo:c,objects:m}=s;return t.syncExecuteCommand(h.SetDrawingApplyMutation.id,{unitId:l,subUnitId:u,op:c,objects:m,type:h.DrawingApplyType.REMOVE})?(e.pushUndoRedo({unitID:l,undoMutations:[{id:h.SetDrawingApplyMutation.id,params:{unitId:l,subUnitId:u,op:d,objects:m,type:h.DrawingApplyType.INSERT}},{id:G.id,params:a}],redoMutations:[{id:h.SetDrawingApplyMutation.id,params:{unitId:l,subUnitId:u,op:c,objects:m,type:h.DrawingApplyType.REMOVE}},{id:G.id,params:a}]}),!0):!1}},Ue="COMPONENT_SHEET_DRAWING_PANEL",Me={id:"sidebar.operation.sheet-image",type:p.CommandType.COMMAND,handler:async(i,r)=>{const t=i.get(F.ISidebarService),e=i.get(p.LocaleService),n=i.get(p.IUniverInstanceService),o=i.get(A.IDrawingManagerService);if(!_.getSheetCommandTarget(n))return!1;switch(r.value){case"open":t.open({header:{title:e.t("sheetImage.panel.title")},children:{label:Ue},onClose:()=>{o.focusDrawing(null)},width:360});break;case"close":default:t.close();break}return!0}},De={id:"sheet.operation.edit-sheet-image",type:p.CommandType.OPERATION,handler:(i,r)=>{const t=i.get(A.IDrawingManagerService),e=i.get(p.ICommandService);return r==null?!1:(t.focusDrawing([r]),e.executeCommand(Me.id,{value:"open"}),!0)}},pe={uploadLoading:"univer-upload-loading",uploadLoadingBody:"univer-upload-loading-body",uploadLoadingBodyAnimation:"univer-upload-loading-body-animation",univerCircleAnimation:"univer-UniverCircleAnimation",uploadLoadingBodyText:"univer-upload-loading-body-text"},xe=()=>{const i=q.useDependency(A.IImageIoService),r=q.useDependency(p.LocaleService),[t,e]=N.useState(0);return N.useEffect(()=>{const n=i.change$.subscribe(o=>{e(o)});return()=>{n.unsubscribe()}},[i]),N.createElement("div",{style:{display:t>0?"block":"none"},className:pe.uploadLoading},N.createElement("div",{className:pe.uploadLoadingBody},N.createElement("div",{className:pe.uploadLoadingBodyAnimation}),N.createElement("div",{className:pe.uploadLoadingBodyText},`${r.t("uploadLoading.loading")}: ${t}`)))};var Ke=Object.defineProperty,ze=Object.getOwnPropertyDescriptor,qe=(i,r,t,e)=>{for(var n=e>1?void 0:e?ze(r,t):r,o=i.length-1,a;o>=0;o--)(a=i[o])&&(n=(e?a(r,t,n):a(n))||n);return e&&n&&Ke(r,t,n),n},ee=(i,r)=>(t,e)=>r(t,e,i);let he=class extends p.RxDisposable{constructor(r,t,e,n,o,a,s){super();K(this,"_initImagePopupMenu",new Set);this._injector=r,this._drawingManagerService=t,this._canvasPopManagerService=e,this._renderManagerService=n,this._univerInstanceService=o,this._contextService=a,this._uiPartsService=s,this._init()}_init(){this._univerInstanceService.getCurrentTypeOfUnit$(p.UniverInstanceType.UNIVER_SHEET).pipe(k.takeUntil(this.dispose$)).subscribe(r=>this._create(r)),this._univerInstanceService.getTypeOfUnitDisposed$(p.UniverInstanceType.UNIVER_SHEET).pipe(k.takeUntil(this.dispose$)).subscribe(r=>this._dispose(r)),this._univerInstanceService.getAllUnitsForType(p.UniverInstanceType.UNIVER_SHEET).forEach(r=>this._create(r)),this._uiPartsService.registerComponent(F.BuiltInUIPart.CONTENT,()=>q.connectInjector(xe,this._injector))}_dispose(r){const t=r.getUnitId();this._renderManagerService.removeRender(t)}_create(r){if(!r)return;const t=r.getUnitId();this._renderManagerService.has(t)&&!this._initImagePopupMenu.has(t)&&(this._popupMenuListener(t),this._initImagePopupMenu.add(t))}_hasCropObject(r){const t=r.getAllObjects();for(const e of t)if(e instanceof Q.ImageCropperObject)return!0;return!1}_popupMenuListener(r){var o;const t=(o=this._renderManagerService.getRenderById(r))==null?void 0:o.scene;if(!t)return;const e=t.getTransformerByCreate();if(!e)return;let n;this.disposeWithMe(p.toDisposable(e.createControl$.subscribe(()=>{if(this._contextService.setContextValue(p.FOCUSING_COMMON_DRAWINGS,!0),this._hasCropObject(t))return;const a=e.getSelectedObjectMap();if(a.size>1){n==null||n.dispose();return}const s=a.values().next().value;if(!s)return;const l=s.oKey,u=this._drawingManagerService.getDrawingOKey(l);if(!u)return;const{unitId:d,subUnitId:c,drawingId:m}=u;n==null||n.dispose(),n=this.disposeWithMe(this._canvasPopManagerService.attachPopupToObject(s,{componentKey:Q.COMPONENT_IMAGE_POPUP_MENU,direction:"horizontal",offset:[2,0],extraProps:{menuItems:this._getImageMenuItems(d,c,m)}})),this._drawingManagerService.focusDrawing([{unitId:d,subUnitId:c,drawingId:m}])}))),this.disposeWithMe(e.clearControl$.subscribe(()=>{n==null||n.dispose(),this._contextService.setContextValue(p.FOCUSING_COMMON_DRAWINGS,!1),this._drawingManagerService.focusDrawing(null)})),this.disposeWithMe(e.changing$.subscribe(()=>{n==null||n.dispose()}))}_getImageMenuItems(r,t,e){return[{label:"image-popup.edit",index:0,commandId:De.id,commandParams:{unitId:r,subUnitId:t,drawingId:e},disable:!1},{label:"image-popup.delete",index:1,commandId:ge.id,commandParams:{unitId:r,drawings:[{unitId:r,subUnitId:t,drawingId:e}]},disable:!1},{label:"image-popup.crop",index:2,commandId:Q.OpenImageCropOperation.id,commandParams:{unitId:r,subUnitId:t,drawingId:e},disable:!1},{label:"image-popup.reset",index:3,commandId:Q.ImageResetSizeOperation.id,commandParams:[{unitId:r,subUnitId:t,drawingId:e}],disable:!1}]}};he=qe([p.OnLifecycle(p.LifecycleStages.Steady,he),ee(0,$.Inject($.Injector)),ee(1,A.IDrawingManagerService),ee(2,$.Inject(B.SheetCanvasPopManagerService)),ee(3,L.IRenderManagerService),ee(4,p.IUniverInstanceService),ee(5,p.IContextService),ee(6,$.Inject(F.IUIPartsService))],he);const oe={id:"sheet.operation.insert-float-image",type:p.CommandType.OPERATION,handler:(i,r)=>!0},ae={id:"sheet.operation.insert-cell-image",type:p.CommandType.OPERATION,handler:(i,r)=>!0},fe={id:"sheet.command.insert-sheet-image",type:p.CommandType.COMMAND,handler:(i,r)=>{const t=i.get(p.ICommandService),e=i.get(p.IUndoRedoService),n=i.get(h.ISheetDrawingService);if(!r)return!1;const o=r.drawings,a=o.map(S=>S.unitId),s=n.getBatchAddOp(o),{unitId:l,subUnitId:u,undo:d,redo:c,objects:m}=s;return t.syncExecuteCommand(h.SetDrawingApplyMutation.id,{op:c,unitId:l,subUnitId:u,objects:m,type:h.DrawingApplyType.INSERT})?(e.pushUndoRedo({unitID:l,undoMutations:[{id:h.SetDrawingApplyMutation.id,params:{op:d,unitId:l,subUnitId:u,objects:m,type:h.DrawingApplyType.REMOVE}},{id:G.id,params:a}],redoMutations:[{id:h.SetDrawingApplyMutation.id,params:{op:c,unitId:l,subUnitId:u,objects:m,type:h.DrawingApplyType.INSERT}},{id:G.id,params:a}]}),!0):!1}},se={id:"sheet.command.set-sheet-image",type:p.CommandType.COMMAND,handler:(i,r)=>{const t=i.get(p.ICommandService),e=i.get(p.IUndoRedoService),n=i.get(h.ISheetDrawingService);if(!r)return!1;const{drawings:o}=r,a=n.getBatchUpdateOp(o),{unitId:s,subUnitId:l,undo:u,redo:d,objects:c}=a;return t.syncExecuteCommand(h.SetDrawingApplyMutation.id,{unitId:s,subUnitId:l,op:d,objects:c,type:h.DrawingApplyType.UPDATE})?(e.pushUndoRedo({unitID:s,undoMutations:[{id:h.SetDrawingApplyMutation.id,params:{unitId:s,subUnitId:l,op:u,objects:c,type:h.DrawingApplyType.UPDATE}},{id:G.id,params:[s]}],redoMutations:[{id:h.SetDrawingApplyMutation.id,params:{unitId:s,subUnitId:l,op:d,objects:c,type:h.DrawingApplyType.UPDATE}},{id:G.id,params:[s]}]}),!0):!1}},Te={id:"sheet.command.set-drawing-arrange",type:p.CommandType.COMMAND,handler:(i,r)=>{const t=i.get(p.ICommandService),e=i.get(p.IUndoRedoService);if(!r)return!1;const n=i.get(h.ISheetDrawingService),{unitId:o,subUnitId:a,drawingIds:s,arrangeType:l}=r,u={unitId:o,subUnitId:a,drawingIds:s};let d;if(l===A.ArrangeTypeEnum.forward?d=n.getForwardDrawingsOp(u):l===A.ArrangeTypeEnum.backward?d=n.getBackwardDrawingOp(u):l===A.ArrangeTypeEnum.front?d=n.getFrontDrawingsOp(u):l===A.ArrangeTypeEnum.back&&(d=n.getBackDrawingsOp(u)),d==null)return!1;const{objects:c,redo:m,undo:g}=d;return t.syncExecuteCommand(h.SetDrawingApplyMutation.id,{op:m,unitId:o,subUnitId:a,objects:c,type:h.DrawingApplyType.ARRANGE})?(e.pushUndoRedo({unitID:o,undoMutations:[{id:h.SetDrawingApplyMutation.id,params:{op:g,unitId:o,subUnitId:a,objects:c,type:h.DrawingApplyType.ARRANGE}}],redoMutations:[{id:h.SetDrawingApplyMutation.id,params:{op:m,unitId:o,subUnitId:a,objects:c,type:h.DrawingApplyType.ARRANGE}}]}),!0):!1}};function Je(i){const r=[];return i.forEach(t=>{const{parent:e,children:n}=t,{unitId:o,subUnitId:a,drawingId:s}=e,l=L.getGroupState(0,0,n.map(c=>c.transform||{})),u=n.map(c=>{const m=c.transform||{left:0,top:0},{unitId:g,subUnitId:S,drawingId:f}=c;return{unitId:g,subUnitId:S,drawingId:f,transform:{...m,left:m.left-l.left,top:m.top-l.top},groupId:s}}),d={unitId:o,subUnitId:a,drawingId:s,drawingType:A.DrawingTypeEnum.DRAWING_GROUP,transform:l};r.push({parent:d,children:u})}),r}function Ze(i){const r=[];return i.forEach(t=>{const{parent:e,children:n}=t,{unitId:o,subUnitId:a,drawingId:s,transform:l={width:0,height:0}}=e;if(l==null)return;const u=n.map(c=>{const{transform:m}=c,{unitId:g,subUnitId:S,drawingId:f}=c,v=L.transformObjectOutOfGroup(m||{},l,l.width||0,l.height||0);return{unitId:g,subUnitId:S,drawingId:f,transform:v,groupId:void 0}}),d={unitId:o,subUnitId:a,drawingId:s,drawingType:A.DrawingTypeEnum.DRAWING_GROUP,transform:{left:0,top:0}};r.push({parent:d,children:u})}),r}const Re={id:"sheet.command.group-sheet-image",type:p.CommandType.COMMAND,handler:(i,r)=>{const t=i.get(p.ICommandService),e=i.get(p.IUndoRedoService),n=i.get(h.ISheetDrawingService);if(!r)return!1;const o=[];r.forEach(({parent:g,children:S})=>{o.push(g.unitId),S.forEach(f=>{o.push(f.unitId)})});const a=n.getGroupDrawingOp(r),{unitId:s,subUnitId:l,undo:u,redo:d,objects:c}=a;return t.syncExecuteCommand(h.SetDrawingApplyMutation.id,{op:d,unitId:s,subUnitId:l,objects:c,type:h.DrawingApplyType.GROUP})?(e.pushUndoRedo({unitID:s,undoMutations:[{id:h.SetDrawingApplyMutation.id,params:{op:u,unitId:s,subUnitId:l,objects:Ze(c),type:h.DrawingApplyType.UNGROUP}},{id:G.id,params:o}],redoMutations:[{id:h.SetDrawingApplyMutation.id,params:{op:d,unitId:s,subUnitId:l,objects:c,type:h.DrawingApplyType.GROUP}},{id:G.id,params:o}]}),!0):!1}},Ee={id:"sheet.command.ungroup-sheet-image",type:p.CommandType.COMMAND,handler:(i,r)=>{const t=i.get(p.ICommandService),e=i.get(p.IUndoRedoService),n=i.get(h.ISheetDrawingService);if(!r)return!1;const o=[];r.forEach(({parent:g,children:S})=>{o.push(g.unitId),S.forEach(f=>{o.push(f.unitId)})});const a=n.getUngroupDrawingOp(r),{unitId:s,subUnitId:l,undo:u,redo:d,objects:c}=a;return t.syncExecuteCommand(h.SetDrawingApplyMutation.id,{op:d,unitId:s,subUnitId:l,objects:c,type:h.DrawingApplyType.UNGROUP})?(e.pushUndoRedo({unitID:s,undoMutations:[{id:h.SetDrawingApplyMutation.id,params:{op:u,unitId:s,subUnitId:l,objects:Je(c),type:h.DrawingApplyType.GROUP}},{id:G.id,params:o}],redoMutations:[{id:h.SetDrawingApplyMutation.id,params:{op:d,unitId:s,subUnitId:l,objects:c,type:h.DrawingApplyType.UNGROUP}},{id:G.id,params:o}]}),!0):!1}};function H(i,r,t){const{from:e,to:n,flipY:o=!1,flipX:a=!1,angle:s=0,skewX:l=0,skewY:u=0}=i,{column:d,columnOffset:c,row:m,rowOffset:g}=e,{column:S,columnOffset:f,row:v,rowOffset:y}=n,M=t.attachRangeWithCoord({startColumn:d,endColumn:d,startRow:m,endRow:m});if(M==null)return;const C=t.attachRangeWithCoord({startColumn:S,endColumn:S,startRow:v,endRow:v});if(C==null)return;const{startX:R,startY:I}=M,{startX:P,startY:w}=C;let U=L.precisionTo(R+c,1),E=L.precisionTo(I+g,1),j=L.precisionTo(P+f-U,1),O=L.precisionTo(w+y-E,1);M.startX===C.endX&&(j=0),M.startY===C.endY&&(O=0);const b=t.getCurrentSkeleton(),D=b.rowHeaderWidth+b.columnTotalWidth,W=b.columnHeaderHeight+b.rowTotalHeight;return U+j>D&&(U=D-j),E+O>W&&(E=W-O),{flipY:o,flipX:a,angle:s,skewX:l,skewY:u,left:U,top:E,width:j,height:O}}function V(i,r){const{left:t=0,top:e=0,width:n=0,height:o=0,flipY:a=!1,flipX:s=!1,angle:l=0,skewX:u=0,skewY:d=0}=i,c=r.getSelectionCellByPosition(t,e);if(c==null)return;const m={column:c.actualColumn,columnOffset:L.precisionTo(t-c.startX,1),row:c.actualRow,rowOffset:L.precisionTo(e-c.startY,1)},g=r.getSelectionCellByPosition(t+n,e+o);if(g==null)return;const S={column:g.actualColumn,columnOffset:L.precisionTo(t+n-g.startX,1),row:g.actualRow,rowOffset:L.precisionTo(e+o-g.startY,1)};return{flipY:a,flipX:s,angle:l,skewX:u,skewY:d,from:m,to:S}}var Qe=Object.defineProperty,et=Object.getOwnPropertyDescriptor,tt=(i,r,t,e)=>{for(var n=e>1?void 0:e?et(r,t):r,o=i.length-1,a;o>=0;o--)(a=i[o])&&(n=(e?a(r,t,n):a(n))||n);return e&&n&&Qe(r,t,n),n},z=(i,r)=>(t,e)=>r(t,e,i);let Se=class extends p.Disposable{constructor(i,r,t,e,n,o,a,s,l,u){super(),this._commandService=i,this._univerInstanceService=r,this._selectionManagerService=t,this._imageIoService=e,this._sheetDrawingService=n,this._drawingManagerService=o,this._contextService=a,this._messageService=s,this._localeService=l,this._renderManagerService=u,this._init()}get _selectionRenderService(){return this._renderManagerService.getRenderById(this._univerInstanceService.getCurrentUnitForType(p.UniverInstanceType.UNIVER_SHEET).getUnitId()).with(B.ISheetSelectionRenderService)}get _skeletonManagerService(){return this._renderManagerService.getRenderById(this._univerInstanceService.getCurrentUnitForType(p.UniverInstanceType.UNIVER_SHEET).getUnitId()).with(B.SheetSkeletonManagerService)}_init(){this._initCommandListeners(),this._updateImageListener(),this._updateOrderListener(),this._groupDrawingListener(),this._focusDrawingListener(),this._drawingAddListener()}_initCommandListeners(){this.disposeWithMe(this._commandService.onCommandExecuted(async i=>{if(i.id===ae.id||i.id===oe.id){const r=i.params;if(r.files==null)return;const t=r.files.length;if(t>A.DRAWING_IMAGE_COUNT_LIMIT){this._messageService.show({type:J.MessageType.Error,content:this._localeService.t("update-status.exceedMaxCount",String(A.DRAWING_IMAGE_COUNT_LIMIT))});return}this._imageIoService.setWaitCount(t),i.id===ae.id?r.files.forEach(async e=>{await this._insertCellImage(e)}):r.files.forEach(async e=>{await this._insertFloatImage(e)})}}))}async _insertCellImage(i){}async _insertFloatImage(i){let r;try{r=await this._imageIoService.saveImage(i)}catch(M){const C=M.message;C===A.ImageUploadStatusType.ERROR_EXCEED_SIZE?this._messageService.show({type:J.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:J.MessageType.Error,content:this._localeService.t("update-status.invalidImageType")}):C===A.ImageUploadStatusType.ERROR_IMAGE&&this._messageService.show({type:J.MessageType.Error,content:this._localeService.t("update-status.invalidImage")})}if(r==null)return;const t=this._getUnitInfo();if(t==null)return;const{unitId:e,subUnitId:n}=t,{imageId:o,imageSourceType:a,source:s,base64Cache:l}=r,{width:u,height:d,image:c}=await A.getImageSize(l||""),m=this._renderManagerService.getRenderById(e);if(m==null)return;const{width:g,height:S}=m.scene;this._imageIoService.addImageSourceCache(s,a,c);let f=1;if(u>A.DRAWING_IMAGE_WIDTH_LIMIT||d>A.DRAWING_IMAGE_HEIGHT_LIMIT){const M=A.DRAWING_IMAGE_WIDTH_LIMIT/u,C=A.DRAWING_IMAGE_HEIGHT_LIMIT/d;f=Math.max(M,C)}const v=this._getImagePosition(u*f,d*f,g,S);if(v==null)return;const y={unitId:e,subUnitId:n,drawingId:o,drawingType:A.DrawingTypeEnum.DRAWING_IMAGE,imageSourceType:a,source:s,transform:H(v,this._selectionRenderService,this._skeletonManagerService),sheetTransform:v};this._commandService.executeCommand(fe.id,{unitId:e,drawings:[y]})}_getUnitInfo(){const i=this._univerInstanceService.getCurrentUnitForType(p.UniverInstanceType.UNIVER_SHEET);if(i==null)return;const r=i.getActiveSheet();if(r==null)return;const t=i.getUnitId(),e=r.getSheetId();return{unitId:t,subUnitId:e}}_getImagePosition(i,r,t,e){const n=this._selectionManagerService.getCurrentSelections();let o={startRow:0,endRow:0,startColumn:0,endColumn:0};n&&n.length>0&&(o=n[n.length-1].range);const a=B.attachRangeWithCoord(this._skeletonManagerService.getCurrent().skeleton,o);if(a==null)return;let{startColumn:s,startRow:l,startX:u,startY:d}=a,c=!1;if(u+i>t&&(u=t-i,u<0&&(u=0,i=t),c=!0),d+r>e&&(d=e-r,d<0&&(d=0,r=e),c=!0),c){const f=this._selectionRenderService.getSelectionCellByPosition(u,d);if(f==null)return;u=f.startX,d=f.startY,s=f.actualColumn,l=f.actualRow}const m={column:s,columnOffset:0,row:l,rowOffset:0},g=this._selectionRenderService.getSelectionCellByPosition(u+i,d+r);if(g==null)return;const S={column:g.actualColumn,columnOffset:u+i-g.startX,row:g.actualRow,rowOffset:d+r-g.startY};return{from:m,to:S}}_updateOrderListener(){this._drawingManagerService.featurePluginOrderUpdate$.subscribe(i=>{const{unitId:r,subUnitId:t,drawingIds:e,arrangeType:n}=i;this._commandService.executeCommand(Te.id,{unitId:r,subUnitId:t,drawingIds:e,arrangeType:n})})}_updateImageListener(){this._drawingManagerService.featurePluginUpdate$.subscribe(i=>{const r=[];i.length!==0&&(i.forEach(t=>{const{unitId:e,subUnitId:n,drawingId:o,drawingType:a,transform:s}=t;if(s==null)return;const l=this._sheetDrawingService.getDrawingByParam({unitId:e,subUnitId:n,drawingId:o});if(l==null)return;const u=V({...l.transform,...s},this._selectionRenderService);if(u==null)return;const d={...t,transform:{...l.transform,...s,...H(u,this._selectionRenderService,this._skeletonManagerService)},sheetTransform:{...u}};r.push(d)}),r.length>0&&this._commandService.executeCommand(se.id,{unitId:i[0].unitId,drawings:r}))})}_groupDrawingListener(){this._drawingManagerService.featurePluginGroupUpdate$.subscribe(i=>{this._commandService.executeCommand(Re.id,i);const{unitId:r,subUnitId:t,drawingId:e}=i[0].parent;this._drawingManagerService.focusDrawing([{unitId:r,subUnitId:t,drawingId:e}])}),this._drawingManagerService.featurePluginUngroupUpdate$.subscribe(i=>{this._commandService.executeCommand(Ee.id,i)})}_focusDrawingListener(){this.disposeWithMe(this._drawingManagerService.focus$.subscribe(i=>{i==null||i.length===0?(this._contextService.setContextValue(p.FOCUSING_COMMON_DRAWINGS,!1),this._sheetDrawingService.focusDrawing([])):(this._contextService.setContextValue(p.FOCUSING_COMMON_DRAWINGS,!0),this._sheetDrawingService.focusDrawing(i))}))}_drawingAddListener(){this.disposeWithMe(this._sheetDrawingService.add$.subscribe(i=>{this._registerDrawing(i)}))}_registerDrawing(i){i.forEach(t=>{const e=this._sheetDrawingService.getDrawingByParam(t);if(e==null)return;const{sheetTransform:n}=e;e.transform=H(n,this._selectionRenderService,this._skeletonManagerService)});const r=i[0].unitId;this._drawingManagerService.registerDrawingData(r,this._sheetDrawingService.getDrawingDataForUnit(r)),this._drawingManagerService.initializeNotification(r)}};Se=tt([p.OnLifecycle(p.LifecycleStages.Rendered,Se),z(0,p.ICommandService),z(1,p.IUniverInstanceService),z(2,$.Inject(_.SheetsSelectionsService)),z(3,A.IImageIoService),z(4,h.ISheetDrawingService),z(5,A.IDrawingManagerService),z(6,p.IContextService),z(7,F.IMessageService),z(8,$.Inject(p.LocaleService)),z(9,L.IRenderManagerService)],Se);var x=function(){return x=Object.assign||function(i){for(var r,t=1,e=arguments.length;t<e;t++){r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(i[n]=r[n])}return i},x.apply(this,arguments)},nt=function(i,r){var t={};for(var e in i)Object.prototype.hasOwnProperty.call(i,e)&&r.indexOf(e)<0&&(t[e]=i[e]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,e=Object.getOwnPropertySymbols(i);n<e.length;n++)r.indexOf(e[n])<0&&Object.prototype.propertyIsEnumerable.call(i,e[n])&&(t[e[n]]=i[e[n]]);return t},Ne=N.forwardRef(function(i,r){var t=i.icon,e=i.id,n=i.className,o=i.extend,a=nt(i,["icon","id","className","extend"]),s="univerjs-icon univerjs-icon-".concat(e," ").concat(n||"").trim(),l=N.useRef("_".concat(ot()));return Le(t,"".concat(e),{defIds:t.defIds,idSuffix:l.current},x({ref:r,className:s},a),o)});function Le(i,r,t,e,n){return N.createElement(i.tag,x(x({key:r},rt(i,t,n)),e),(it(i,t).children||[]).map(function(o,a){return Le(o,"".concat(r,"-").concat(i.tag,"-").concat(a),t,void 0,n)}))}function rt(i,r,t){var e=x({},i.attrs);t!=null&&t.colorChannel1&&e.fill==="colorChannel1"&&(e.fill=t.colorChannel1);var n=r.defIds;return!n||n.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],s=o[1];typeof s=="string"&&(e[a]=s.replace(/url\(#(.*)\)/,"url(#$1".concat(r.idSuffix,")")))})),e}function it(i,r){var t,e=r.defIds;return!e||e.length===0?i:i.tag==="defs"&&(!((t=i.children)===null||t===void 0)&&t.length)?x(x({},i),{children:i.children.map(function(n){return typeof n.attrs.id=="string"&&e&&e.indexOf(n.attrs.id)>-1?x(x({},n),{attrs:x(x({},n.attrs),{id:n.attrs.id+r.idSuffix})}):n})}):i}function ot(){return Math.random().toString(36).substring(2,8)}Ne.displayName="UniverIcon";var at={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"}}]},je=N.forwardRef(function(i,r){return N.createElement(Ne,Object.assign({},i,{id:"add-image-single",ref:r,icon:at}))});je.displayName="AddImageSingle";const We={uploadFileMenu:"univer-upload-file-menu",uploadFileMenuInput:"univer-upload-file-menu-input"},Be="COMPONENT_UPLOAD_FILE_MENU";var ve=(i=>(i[i.cellImage=0]="cellImage",i[i.floatImage=1]="floatImage",i))(ve||{});const st=i=>{const{type:r}=i,t=q.useDependency(p.ICommandService),e=N.useRef(null),n=()=>{var s;(s=e.current)==null||s.click()},o=A.DRAWING_IMAGE_ALLOW_IMAGE_LIST.map(s=>`.${s.replace("image/","")}`).join(","),a=s=>{const l=s.target.files;if(l==null)return;const u=Array.from(l);r===ve.floatImage?t.executeCommand(oe.id,{files:u}):r===ve.cellImage&&t.executeCommand(ae.id,{files:u}),e.current&&(e.current.value="")};return N.createElement("div",{onClick:n,className:We.uploadFileMenu},N.createElement("input",{type:"file",className:We.uploadFileMenuInput,ref:e,onChange:a,accept:o,multiple:!0}))},$e="addition-and-subtraction-single",Ge="sheet.menu.image";function ct(i){return{id:Ge,type:F.MenuItemType.SUBITEMS,positions:[F.MenuPosition.TOOLBAR_START],group:F.MenuGroup.TOOLBAR_FORMULAS_INSERT,icon:$e,tooltip:"sheetImage.title",hidden$:F.getMenuHiddenObservable(i,p.UniverInstanceType.UNIVER_SHEET),disabled$:B.getCurrentRangeDisable$(i,{workbookTypes:[_.WorkbookEditablePermission],worksheetTypes:[_.WorksheetEditPermission],rangeTypes:[_.RangeProtectionPermissionEditPoint]})}}function lt(i){return{id:oe.id,title:"sheetImage.upload.float",type:F.MenuItemType.SELECTOR,label:{name:Be,props:{type:ve.floatImage}},positions:[Ge],hidden$:F.getMenuHiddenObservable(i,p.UniverInstanceType.UNIVER_SHEET)}}const Z={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"},dt=i=>{var C;const r=q.useDependency(p.ICommandService),t=q.useDependency(p.LocaleService),e=q.useDependency(A.IDrawingManagerService),n=q.useDependency(L.IRenderManagerService),{drawings:o}=i,a=o[0];if(a==null)return;const{unitId:s}=a,l=n.getRenderById(s),u=l==null?void 0:l.scene;if(u==null)return;const d=u.getTransformerByCreate(),[c,m]=N.useState(!0),g=(C=a.anchorType)!=null?C:h.SheetDrawingAnchorType.Position,[S,f]=N.useState(g);function v(R,I){const P=[];return R.forEach(w=>{const{oKey:U}=w,E=I.getDrawingOKey(U);if(E==null)return P.push(null),!0;const{unitId:j,subUnitId:O,drawingId:b,drawingType:D,anchorType:W,sheetTransform:Y}=E;P.push({unitId:j,subUnitId:O,drawingId:b,anchorType:W,sheetTransform:Y,drawingType:D})}),P}N.useEffect(()=>{const R=d.clearControl$.subscribe(P=>{P===!0&&m(!1)}),I=d.changeStart$.subscribe(P=>{var E;const{objects:w}=P,U=v(w,e);if(U.length===0)m(!1);else if(U.length>=1){m(!0);const j=((E=U[0])==null?void 0:E.anchorType)||h.SheetDrawingAnchorType.Position;f(j)}});return()=>{I.unsubscribe(),R.unsubscribe()}},[]);function y(R){f(R);const I=e.getFocusDrawings();if(I.length===0)return;const P=I.map(w=>({unitId:w.unitId,subUnitId:w.subUnitId,drawingId:w.drawingId,anchorType:R}));r.executeCommand(se.id,{unitId:I[0].unitId,drawings:P})}const M=R=>R?"block":"none";return N.createElement("div",{className:me(Z.imageCommonPanelGrid,Z.imageCommonPanelBorder),style:{display:M(c)}},N.createElement("div",{className:Z.imageCommonPanelRow},N.createElement("div",{className:me(Z.imageCommonPanelColumn,Z.imageCommonPanelTitle)},N.createElement("div",null,t.t("drawing-anchor.title")))),N.createElement("div",{className:me(Z.imageCommonPanelRow)},N.createElement("div",{className:me(Z.imageCommonPanelColumn)},N.createElement(J.RadioGroup,{value:S,onChange:y,direction:"vertical"},N.createElement(J.Radio,{value:h.SheetDrawingAnchorType.Both},t.t("drawing-anchor.both")),N.createElement(J.Radio,{value:h.SheetDrawingAnchorType.Position},t.t("drawing-anchor.position")),N.createElement(J.Radio,{value:h.SheetDrawingAnchorType.None},t.t("drawing-anchor.none"))))))},ut=()=>{const i=q.useDependency(A.IDrawingManagerService),r=i.getFocusDrawings(),[t,e]=N.useState(r);return N.useEffect(()=>{const n=i.focus$.subscribe(o=>{e(o)});return()=>{n.unsubscribe()}},[]),!!(t!=null&&t.length)&&N.createElement("div",{className:Z.imageCommonPanel},N.createElement(Q.DrawingCommonPanel,{drawings:t}),N.createElement(dt,{drawings:t}))},ne={id:"sheet.command.move-drawing",type:p.CommandType.COMMAND,handler:(i,r)=>{const t=i.get(p.ICommandService),e=i.get(h.ISheetDrawingService),n=i.get(B.ISheetSelectionRenderService),{direction:o}=r,a=e.getFocusDrawings();if(a.length===0)return!1;const s=a[0].unitId,l=a.map(d=>{const{transform:c}=d;if(c==null)return null;const m={...c},{left:g=0,top:S=0}=c;return o===p.Direction.UP?m.top=S-1:o===p.Direction.DOWN?m.top=S+1:o===p.Direction.LEFT?m.left=g-1:o===p.Direction.RIGHT&&(m.left=g+1),{...d,transform:m,sheetTransform:V(m,n)}}).filter(d=>d!=null);return t.syncExecuteCommand(se.id,{unitId:s,drawings:l})?(t.syncExecuteCommand(G.id,[s]),!0):!1}},be={id:"sheet.command.delete-drawing",type:p.CommandType.COMMAND,handler:i=>{const r=i.get(p.ICommandService),e=i.get(h.ISheetDrawingService).getFocusDrawings();if(e.length===0)return!1;const n=e[0].unitId,o=e.map(a=>{const{unitId:s,subUnitId:l,drawingId:u,drawingType:d}=a;return{unitId:s,subUnitId:l,drawingId:u,drawingType:d}});return r.executeCommand(ge.id,{unitId:n,drawings:o})}};function ce(i){return!i.getContextValue(p.FOCUSING_FORMULA_EDITOR)&&!i.getContextValue(p.EDITOR_ACTIVATED)&&i.getContextValue(p.FOCUSING_COMMON_DRAWINGS)}const mt={id:ne.id,description:"shortcut.sheet.drawing-move-down",group:"4_sheet-drawing-view",binding:F.KeyCode.ARROW_DOWN,priority:100,preconditions:ce,staticParameters:{direction:p.Direction.DOWN}},gt={id:ne.id,description:"shortcut.sheet.drawing-move-up",group:"4_sheet-drawing-view",binding:F.KeyCode.ARROW_UP,priority:100,preconditions:ce,staticParameters:{direction:p.Direction.UP}},pt={id:ne.id,description:"shortcut.sheet.drawing-move-left",group:"4_sheet-drawing-view",binding:F.KeyCode.ARROW_LEFT,priority:100,preconditions:ce,staticParameters:{direction:p.Direction.LEFT}},ht={id:ne.id,description:"shortcut.sheet.drawing-move-right",group:"4_sheet-drawing-view",binding:F.KeyCode.ARROW_RIGHT,priority:100,preconditions:ce,staticParameters:{direction:p.Direction.RIGHT}},ft={id:be.id,description:"shortcut.sheet.drawing-delete",group:"4_sheet-drawing-view",preconditions:ce,binding:F.KeyCode.DELETE,mac:F.KeyCode.BACKSPACE};var St=Object.defineProperty,vt=Object.getOwnPropertyDescriptor,wt=(i,r,t,e)=>{for(var n=e>1?void 0:e?vt(r,t):r,o=i.length-1,a;o>=0;o--)(a=i[o])&&(n=(e?a(r,t,n):a(n))||n);return e&&n&&St(r,t,n),n},le=(i,r)=>(t,e)=>r(t,e,i);const _t={};let de=class extends p.Disposable{constructor(i,r,t,e,n,o){super(),this._config=i,this._injector=r,this._componentManager=t,this._menuService=e,this._commandService=n,this._shortcutService=o,this._init()}_initCustomComponents(){const i=this._componentManager;this.disposeWithMe(i.register($e,je)),this.disposeWithMe(i.register(Be,st)),this.disposeWithMe(i.register(Ue,ut))}_initMenus(){const{menu:i={}}=this._config;[ct,lt].forEach(r=>{this._menuService.addMenuItem(r(this._injector),i)})}_initCommands(){[oe,ae,fe,ge,se,Me,G,De,Re,Ee,ne,be,Te].forEach(i=>this.disposeWithMe(this._commandService.registerCommand(i)))}_initShortcuts(){[mt,gt,pt,ht,ft].forEach(i=>{this.disposeWithMe(this._shortcutService.registerShortcut(i))})}_init(){this._initCommands(),this._initCustomComponents(),this._initMenus(),this._initShortcuts()}};de=wt([p.OnLifecycle(p.LifecycleStages.Rendered,de),le(1,$.Inject($.Injector)),le(2,$.Inject(F.ComponentManager)),le(3,F.IMenuService),le(4,p.ICommandService),le(5,F.IShortcutService)],de);var It=Object.defineProperty,Ct=Object.getOwnPropertyDescriptor,yt=(i,r,t,e)=>{for(var n=e>1?void 0:e?Ct(r,t):r,o=i.length-1,a;o>=0;o--)(a=i[o])&&(n=(e?a(r,t,n):a(n))||n);return e&&n&&It(r,t,n),n},re=(i,r)=>(t,e)=>r(t,e,i);const Mt=[_.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],Dt=[_.SetRowVisibleMutation.id,_.SetRowHiddenMutation.id,_.SetColVisibleMutation.id,_.SetColHiddenMutation.id,_.SetWorksheetRowHeightMutation.id,_.SetWorksheetColWidthMutation.id];let we=class extends p.Disposable{constructor(i,r,t,e,n,o){super(),this._commandService=i,this._sheetInterceptorService=r,this._renderManagerService=t,this._sheetDrawingService=e,this._drawingManagerService=n,this._univerInstanceService=o,this._init()}get _selectionRenderService(){return this._renderManagerService.getRenderById(this._univerInstanceService.getCurrentUnitForType(p.UniverInstanceType.UNIVER_SHEET).getUnitId()).with(B.ISheetSelectionRenderService)}get _skeletonManagerService(){return this._renderManagerService.getRenderById(this._univerInstanceService.getCurrentUnitForType(p.UniverInstanceType.UNIVER_SHEET).getUnitId()).with(B.SheetSkeletonManagerService)}_init(){this._sheetInterceptorListener(),this._commandListener(),this._sheetRefreshListener()}_sheetInterceptorListener(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:i=>{if(!Mt.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(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:t}=i.params;return this._getRangeMoveUndo(t,0)}else if(r===_.DeleteRangeMoveUpCommand.id){const{range:t}=i.params;return this._getRangeMoveUndo(t,1)}else if(r===_.InsertRangeMoveDownCommand.id){const{range:t}=i.params;return this._getRangeMoveUndo(t,2)}else if(r===_.InsertRangeMoveRightCommand.id){const{range:t}=i.params;return this._getRangeMoveUndo(t,3)}else if(r===_.SetRowHiddenCommand.id||r===_.SetSpecificRowsVisibleCommand.id){const t=i.params,{unitId:e,subUnitId:n,ranges:o}=t;return this._getDrawingUndoForRowVisible(e,n,o)}else if(r===_.SetSpecificColsVisibleCommand.id||r===_.SetColHiddenCommand.id){const t=i.params,{unitId:e,subUnitId:n,ranges:o}=t;return this._getDrawingUndoForColVisible(e,n,o)}else if(r===_.DeltaRowHeightCommand.id||r===_.SetRowHeightCommand.id||r===_.DeltaColumnWidthCommand.id||r===_.SetColWidthCommand.id){const t=i.params,{unitId:e,subUnitId:n,ranges:o}=t,a=r===_.DeltaRowHeightCommand.id||r===_.SetRowHeightCommand.id;return this._getDrawingUndoForRowAndColSize(e,n,o,a)}return{redos:[],undos:[]}}}))}_getRangeMoveUndo(i,r){const t=_.getSheetCommandTarget(this._univerInstanceService);if(t==null)return{redos:[],undos:[]};const e=t.unitId,n=t.subUnitId,o=[],a=[],s=this._sheetDrawingService.getDrawingData(e,n),l=[],u=[];if(Object.keys(s).forEach(d=>{const c=s[d],{updateDrawings:m,deleteDrawings:g}=this._getUpdateOrDeleteDrawings(i,r,c);l.push(...m),u.push(...g)}),l.length===0&&u.length===0)return{redos:[],undos:[]};if(l.length>0){const d=this._sheetDrawingService.getBatchUpdateOp(l),{undo:c,redo:m,objects:g}=d;o.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:n,op:m,objects:g,type:h.DrawingApplyType.UPDATE}}),a.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:n,op:c,objects:g,type:h.DrawingApplyType.UPDATE}})}if(u.length>0){const d=this._sheetDrawingService.getBatchRemoveOp(u),c=d.undo,m=d.redo,g=d.objects;o.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:n,op:m,objects:g,type:h.DrawingApplyType.REMOVE}}),a.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:n,op:c,objects:g,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,t){const e=[],n=[],{sheetTransform:o,anchorType:a=h.SheetDrawingAnchorType.Position,transform:s,unitId:l,subUnitId:u,drawingId:d}=t,{from:c,to:m}=o,{row:g,column:S}=c,{row:f,column:v}=m;if(o==null||s==null)return{updateDrawings:e,deleteDrawings:n};const{startRow:y,endRow:M,startColumn:C,endColumn:R}=i;let I=null,P=null;if(r===0&&g>=y&&f<=M)if(S>=C&&v<=R)n.push({unitId:l,subUnitId:u,drawingId:d});else{const w=this._shrinkCol(o,s,C,R,a);I=w==null?void 0:w.newSheetTransform,P=w==null?void 0:w.newTransform}else if(r===1&&S>=C&&v<=R)if(g>=y&&f<=M)n.push({unitId:l,subUnitId:u,drawingId:d});else{const w=this._shrinkRow(o,s,y,M,a);I=w==null?void 0:w.newSheetTransform,P=w==null?void 0:w.newTransform}else if(r===2){const w=this._expandRow(o,s,y,M,a);I=w==null?void 0:w.newSheetTransform,P=w==null?void 0:w.newTransform}else if(r===3){const w=this._expandCol(o,s,C,R,a);I=w==null?void 0:w.newSheetTransform,P=w==null?void 0:w.newTransform}if(I!=null&&P!=null){const w=H(I,this._selectionRenderService,this._skeletonManagerService);e.push({...t,sheetTransform:I,transform:w})}return{updateDrawings:e,deleteDrawings:n}}_remainDrawingSize(i,r,t){const e=V({...i},this._selectionRenderService);e!=null&&r.push({...t,sheetTransform:e})}_getDrawingUndoForColVisible(i,r,t){const e=this._drawingManagerService.getDrawingData(i,r),n=[],o=[];if(Object.keys(e).forEach(d=>{const c=e[d],{sheetTransform:m,transform:g,anchorType:S=h.SheetDrawingAnchorType.Position}=c;if(S===h.SheetDrawingAnchorType.None)this._remainDrawingSize(g,n,c);else{const{from:f,to:v}=m,{row:y,column:M}=f,{row:C,column:R}=v;for(let I=0;I<t.length;I++){const P=t[I],{startRow:w,endRow:U,startColumn:E,endColumn:j}=P;if(R<E)continue;if(S===h.SheetDrawingAnchorType.Position){let D=null,W=null;if(M>=E&&M<=j){const Y=this._skeletonManagerService.attachRangeWithCoord({startColumn:M,endColumn:j,startRow:f.row,endRow:v.row});if(Y==null)return;W={...g,left:Y.startX}}if(W!=null&&(D=V(W,this._selectionRenderService),D!=null&&W!=null)){n.push({...c,sheetTransform:D,transform:W});break}this._remainDrawingSize(g,n,c);continue}if(M>=E&&R<=j)continue;let O=null,b=null;if(M>=E&&M<=j){const D=this._skeletonManagerService.attachRangeWithCoord({startColumn:M,endColumn:j,startRow:f.row,endRow:v.row});if(D==null)return;b={...g,left:(D==null?void 0:D.startX)||0,width:((g==null?void 0:g.width)||0)-D.endX+D.startX}}else if(R>=E&&R<=j){const D=this._skeletonManagerService.attachRangeWithCoord({startColumn:E,endColumn:R,startRow:f.row,endRow:v.row});if(D==null)return;b={...g,left:D.startX-((g==null?void 0:g.width)||0)}}else{const D=this._skeletonManagerService.attachRangeWithCoord({startColumn:E,endColumn:j,startRow:f.row,endRow:v.row});if(D==null)return;if(b={...g,width:((g==null?void 0:g.width)||0)-D.endX+D.startX},O=V(b,this._selectionRenderService),O!=null&&b!=null){o.push({...c,sheetTransform:O,transform:b});break}}if(b!=null&&(O=V(b,this._selectionRenderService)),b!=null&&O!=null){n.push({...c,sheetTransform:O,transform:b});break}else this._remainDrawingSize(g,n,c)}}}),n.length===0&&o.length===0)return{redos:[],undos:[]};const{redos:a,undos:s}=this._createUndoAndRedoMutation(i,r,n),l=[],u=[];if(o.length>0){const{redos:d,undos:c}=this._createUndoAndRedoMutation(i,r,o);l.push(...d),u.push(...c)}return{redos:a,undos:s,preRedos:l,preUndos:u}}_createUndoAndRedoMutation(i,r,t){const e=this._sheetDrawingService.getBatchUpdateOp(t),{undo:n,redo:o,objects:a}=e,s=[{id:h.SetDrawingApplyMutation.id,params:{unitId:i,subUnitId:r,op:o,objects:a,type:h.DrawingApplyType.UPDATE}},{id:G.id,params:[i]}],l=[{id:h.SetDrawingApplyMutation.id,params:{unitId:i,subUnitId:r,op:n,objects:a,type:h.DrawingApplyType.UPDATE}},{id:G.id,params:[i]}];return{redos:s,undos:l}}_getDrawingUndoForRowVisible(i,r,t){const e=this._drawingManagerService.getDrawingData(i,r),n=[],o=[];if(Object.keys(e).forEach(d=>{const c=e[d],{sheetTransform:m,transform:g,anchorType:S=h.SheetDrawingAnchorType.Position}=c;if(S===h.SheetDrawingAnchorType.None)this._remainDrawingSize(g,n,c);else{const{from:f,to:v}=m,{row:y,column:M}=f,{row:C,column:R}=v;for(let I=0;I<t.length;I++){const P=t[I],{startRow:w,endRow:U,startColumn:E,endColumn:j}=P;if(C<w)continue;if(S===h.SheetDrawingAnchorType.Position){let D=null,W=null;if(y>=w&&y<=U){const Y=this._skeletonManagerService.attachRangeWithCoord({startColumn:f.column,endColumn:v.column,startRow:y,endRow:U});if(Y==null)return;W={...g,top:Y.startY}}if(W!=null&&(D=V(W,this._selectionRenderService),D!=null&&W!=null)){n.push({...c,sheetTransform:D,transform:W});break}this._remainDrawingSize(g,n,c);continue}if(y>=w&&C<=U)continue;let O=null,b=null;if(y>=w&&y<=U){const D=this._skeletonManagerService.attachRangeWithCoord({startColumn:f.column,endColumn:v.column,startRow:y,endRow:U});if(D==null)return;b={...g,top:(D==null?void 0:D.startY)||0,height:((g==null?void 0:g.height)||0)-D.endY+D.startY}}else if(C>=w&&C<=U){const D=this._skeletonManagerService.attachRangeWithCoord({startColumn:f.column,endColumn:v.column,startRow:w,endRow:C});if(D==null)return;b={...g,top:D.startY-((g==null?void 0:g.height)||0)}}else{const D=this._skeletonManagerService.attachRangeWithCoord({startColumn:f.column,endColumn:v.column,startRow:w,endRow:U});if(D==null)return;if(b={...g,height:((g==null?void 0:g.height)||0)-D.endY+D.startY},O=V(b,this._selectionRenderService),O!=null&&b!=null){o.push({...c,sheetTransform:O,transform:b});break}}if(b!=null&&(O=V(b,this._selectionRenderService)),b!=null&&O!=null){n.push({...c,sheetTransform:O,transform:b});break}else this._remainDrawingSize(g,n,c)}}}),n.length===0&&o.length===0)return{redos:[],undos:[]};const{redos:a,undos:s}=this._createUndoAndRedoMutation(i,r,n),l=[],u=[];if(o.length>0){const{redos:d,undos:c}=this._createUndoAndRedoMutation(i,r,o);l.push(...d),u.push(...c)}return{redos:a,undos:s,preRedos:l,preUndos:u}}_getDrawingUndoForRowAndColSize(i,r,t,e){const n=this._drawingManagerService.getDrawingData(i,r),o=[];return Object.keys(n).forEach(a=>{const s=n[a],{sheetTransform:l,transform:u,anchorType:d=h.SheetDrawingAnchorType.Position}=s;if(d===h.SheetDrawingAnchorType.None)this._remainDrawingSize(u,o,s);else{const{from:c,to:m}=l,{row:g,column:S}=c,{row:f,column:v}=m;for(let y=0;y<t.length;y++){const M=t[y],{startRow:C,endRow:R,startColumn:I,endColumn:P}=M;if(f<C||v<I)continue;if(d===h.SheetDrawingAnchorType.Position&&(g<=C&&f>=R||S<=I&&v>=P)){this._remainDrawingSize(u,o,s);continue}const w=H({...l},this._selectionRenderService,this._skeletonManagerService);if(w!=null){o.push({...s,transform:w});break}}}}),o.length===0?{redos:[],undos:[]}:this._createUndoAndRedoMutation(i,r,o)}_getUnitIdAndSubUnitId(i,r){let t,e;if(r==="insert")t=i.unitId,e=i.subUnitId;else{const n=_.getSheetCommandTarget(this._univerInstanceService);if(n==null)return;t=n.unitId,e=n.subUnitId}return{unitId:t,subUnitId:e}}_moveRowInterceptor(i,r){const t=this._getUnitIdAndSubUnitId(i,r);if(t==null)return{redos:[],undos:[]};const{unitId:e,subUnitId:n}=t,{range:o}=i,a=o.startRow,s=o.endRow,l=[],u=[],d=this._sheetDrawingService.getDrawingData(e,n),c=[],m=[];if(Object.keys(d).forEach(g=>{const S=d[g],{sheetTransform:f,transform:v,anchorType:y=h.SheetDrawingAnchorType.Position}=S;if(f==null||v==null)return;let M,C;if(r==="insert"){const I=this._expandRow(f,v,a,s,y);M=I==null?void 0:I.newSheetTransform,C=I==null?void 0:I.newTransform}else{const{from:I,to:P}=f,{row:w}=I,{row:U}=P;if(w>=a&&U<=s)m.push({unitId:e,subUnitId:n,drawingId:g});else{const E=this._shrinkRow(f,v,a,s,y);M=E==null?void 0:E.newSheetTransform,C=E==null?void 0:E.newTransform}}if(!M||!C)return;const R={unitId:e,subUnitId:n,drawingId:g,transform:C,sheetTransform:M};c.push(R)}),c.length===0&&m.length===0)return{redos:[],undos:[]};if(c.length>0){const g=this._sheetDrawingService.getBatchUpdateOp(c),{undo:S,redo:f,objects:v}=g;l.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:n,op:f,objects:v,type:h.DrawingApplyType.UPDATE}}),u.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:n,op:S,objects:v,type:h.DrawingApplyType.UPDATE}})}if(m.length>0){const g=this._sheetDrawingService.getBatchRemoveOp(m),S=g.undo,f=g.redo,v=g.objects;l.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:n,op:f,objects:v,type:h.DrawingApplyType.REMOVE}}),u.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:n,op:S,objects:v,type:h.DrawingApplyType.INSERT}})}return l.push({id:G.id,params:[e]}),u.push({id:G.id,params:[e]}),{redos:l,undos:u}}_moveColInterceptor(i,r){const t=this._getUnitIdAndSubUnitId(i,r);if(t==null)return{redos:[],undos:[]};const{unitId:e,subUnitId:n}=t,{range:o}=i,a=o.startColumn,s=o.endColumn,l=[],u=[],d=this._sheetDrawingService.getDrawingData(e,n),c=[],m=[];if(Object.keys(d).forEach(g=>{const S=d[g],{sheetTransform:f,transform:v,anchorType:y=h.SheetDrawingAnchorType.Position}=S;if(f==null||v==null)return;let M,C;if(r==="insert"){const I=this._expandCol(f,v,a,s,y);M=I==null?void 0:I.newSheetTransform,C=I==null?void 0:I.newTransform}else{const{from:I,to:P}=f,{column:w}=I,{column:U}=P;if(w>=a&&U<=s)m.push({unitId:e,subUnitId:n,drawingId:g});else{const E=this._shrinkCol(f,v,a,s,y);M=E==null?void 0:E.newSheetTransform,C=E==null?void 0:E.newTransform}}if(!M||!C)return;const R={unitId:e,subUnitId:n,drawingId:g,transform:C,sheetTransform:M};c.push(R)}),c.length===0&&m.length===0)return{redos:[],undos:[]};if(c.length>0){const g=this._sheetDrawingService.getBatchUpdateOp(c),{undo:S,redo:f,objects:v}=g;l.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:n,op:f,objects:v,type:h.DrawingApplyType.UPDATE}}),u.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:n,op:S,objects:v,type:h.DrawingApplyType.UPDATE}})}if(m.length>0){const g=this._sheetDrawingService.getBatchRemoveOp(m),S=g.undo,f=g.redo,v=g.objects;l.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:n,op:f,objects:v,type:h.DrawingApplyType.REMOVE}}),u.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:n,op:S,objects:v,type:h.DrawingApplyType.INSERT}})}return l.push({id:G.id,params:[e]}),u.push({id:G.id,params:[e]}),{redos:l,undos:u}}_expandCol(i,r,t,e,n=h.SheetDrawingAnchorType.Position){const o=e-t+1,{from:a,to:s}=i,{column:l}=a,{column:u}=s;if(n===h.SheetDrawingAnchorType.None)return{newSheetTransform:V({...r},this._selectionRenderService),newTransform:r};let d=null,c=null;if(l>=t){const m=this._skeletonManagerService.attachRangeWithCoord({startColumn:t,endColumn:e,startRow:a.row,endRow:s.row});if(m==null)return;c={...r,left:(r.left||0)+m.endX-m.startX},d=V(c,this._selectionRenderService)}else if(u>=e)if(n===h.SheetDrawingAnchorType.Both)d={from:{...a},to:{...s,column:u+o}},c=H(d,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:V({...r},this._selectionRenderService),newTransform:r};return d!=null&&c!=null?{newSheetTransform:d,newTransform:c}:null}_shrinkCol(i,r,t,e,n=h.SheetDrawingAnchorType.Position){const o=e-t+1,{from:a,to:s}=i,{column:l}=a,{column:u}=s;if(n===h.SheetDrawingAnchorType.None)return{newSheetTransform:V({...r},this._selectionRenderService),newTransform:r};let d=null,c=null;if(l>e)d={from:{...a,column:l-o},to:{...s,column:u-o}},c=H(d,this._selectionRenderService,this._skeletonManagerService);else{if(l>=t&&u<=e)return null;if(l<t&&u>e)if(n===h.SheetDrawingAnchorType.Both)d={from:{...a},to:{...s,column:u-o}},c=H(d,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:V({...r},this._selectionRenderService),newTransform:r};else if(l>=t&&l<=e){if(l===t)c={...r,left:(r.left||0)-i.from.columnOffset};else{const m=this._skeletonManagerService.attachRangeWithCoord({startColumn:t,endColumn:l-1,startRow:a.row,endRow:s.row});if(m==null)return;c={...r,left:(r.left||0)-m.endX+m.startX-i.from.columnOffset}}d=V(c,this._selectionRenderService)}else if(u>=t&&u<=e&&n===h.SheetDrawingAnchorType.Both){const m=this._skeletonManagerService.attachRangeWithCoord({startColumn:t-1,endColumn:t-1,startRow:a.row,endRow:s.row});if(m==null)return;d={from:{...a},to:{...s,column:t-1,columnOffset:m.endX-m.startX}},c=H(d,this._selectionRenderService,this._skeletonManagerService)}}return d!=null&&c!=null?{newSheetTransform:d,newTransform:c}:null}_expandRow(i,r,t,e,n=h.SheetDrawingAnchorType.Position){const o=e-t+1,{from:a,to:s}=i,{row:l}=a,{row:u}=s;if(n===h.SheetDrawingAnchorType.None)return{newSheetTransform:V({...r},this._selectionRenderService),newTransform:r};let d=null,c=null;if(l>=t){const m=this._skeletonManagerService.attachRangeWithCoord({startRow:t,endRow:e,startColumn:a.column,endColumn:s.column});if(m==null)return;c={...r,top:(r.top||0)+m.endY-m.startY},d=V(c,this._selectionRenderService)}else if(u>=e)if(n===h.SheetDrawingAnchorType.Both)d={from:{...a},to:{...s,row:u+o}},c=H(d,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:V({...r},this._selectionRenderService),newTransform:r};return d!=null&&c!=null?{newSheetTransform:d,newTransform:c}:null}_shrinkRow(i,r,t,e,n=h.SheetDrawingAnchorType.Position){const o=e-t+1,{from:a,to:s}=i,{row:l}=a,{row:u}=s;if(n===h.SheetDrawingAnchorType.None)return{newSheetTransform:V({...r},this._selectionRenderService),newTransform:r};let d=null,c=null;if(l>e)d={from:{...a,row:l-o},to:{...s,row:u-o}},c=H(d,this._selectionRenderService,this._skeletonManagerService);else{if(l>=t&&u<=e)return null;if(l<t&&u>e)if(n===h.SheetDrawingAnchorType.Both)d={from:{...a},to:{...s,row:u-o}},c=H(d,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:V({...r},this._selectionRenderService),newTransform:r};else if(l>=t&&l<=e){if(l===t)c={...r,top:(r.top||0)-i.from.rowOffset};else{const m=this._skeletonManagerService.attachRangeWithCoord({startRow:t,endRow:l-1,startColumn:a.column,endColumn:s.column});if(m==null)return;c={...r,top:(r.top||0)-m.endY+m.startY-i.from.rowOffset}}d=V(c,this._selectionRenderService)}else if(u>=t&&u<=e&&n===h.SheetDrawingAnchorType.Both){const m=this._skeletonManagerService.attachRangeWithCoord({startColumn:a.column,endColumn:a.column,startRow:t-1,endRow:t-1});if(m==null)return;d={from:{...a},to:{...s,row:t-1,rowOffset:m.endY-m.startY}},c=H(d,this._selectionRenderService,this._skeletonManagerService)}}return d!=null&&c!=null?{newSheetTransform:d,newTransform:c}:null}_commandListener(){this.disposeWithMe(this._commandService.onCommandExecuted(i=>{i.id===_.SetWorksheetActiveOperation.id&&setTimeout(()=>{const r=i.params,{unitId:t,subUnitId:e}=r,n=this._drawingManagerService.drawingManagerData,o=[],a=[];Object.keys(n).forEach(s=>{const l=n[s];Object.keys(l).forEach(u=>{const d=l[u].data;d!=null&&Object.keys(d).forEach(c=>{if(s===t&&u===e){const m=d[c];m.transform=H(m.sheetTransform,this._selectionRenderService,this._skeletonManagerService),o.push(d[c])}else a.push(d[c])})})}),this._drawingManagerService.removeNotification(a),this._drawingManagerService.addNotification(o)},0)}))}_sheetRefreshListener(){this.disposeWithMe(this._commandService.onCommandExecuted(i=>{Dt.includes(i.id)&&requestIdleCallback(()=>{const r=i.params,{unitId:t,subUnitId:e,ranges:n}=r;this._refreshDrawingTransform(t,e,n)})}))}_refreshDrawingTransform(i,r,t){const e=this._drawingManagerService.getDrawingData(i,r),n=[];Object.keys(e).forEach(o=>{const a=e[o],{sheetTransform:s,anchorType:l=h.SheetDrawingAnchorType.Position}=a;if(l===h.SheetDrawingAnchorType.None)return!0;const{from:u,to:d}=s,{row:c,column:m}=u,{row:g,column:S}=d;for(let f=0;f<t.length;f++){const v=t[f],{startRow:y,endRow:M,startColumn:C,endColumn:R}=v;if(p.Rectangle.intersects({startRow:y,endRow:M,startColumn:C,endColumn:R},{startRow:c,endRow:g,startColumn:m,endColumn:S})||c>M||m>R){n.push({...a,transform:H(s,this._selectionRenderService,this._skeletonManagerService)});break}}}),n.length!==0&&(this._drawingManagerService.refreshTransform(n),this._commandService.syncExecuteCommand(G.id,[i]))}};we=yt([p.OnLifecycle(p.LifecycleStages.Rendered,we),re(0,p.ICommandService),re(1,$.Inject(_.SheetInterceptorService)),re(2,L.IRenderManagerService),re(3,h.ISheetDrawingService),re(4,A.IDrawingManagerService),re(5,p.IUniverInstanceService)],we);var Tt=Object.defineProperty,Rt=Object.getOwnPropertyDescriptor,Et=(i,r,t,e)=>{for(var n=e>1?void 0:e?Rt(r,t):r,o=i.length-1,a;o>=0;o--)(a=i[o])&&(n=(e?a(r,t,n):a(n))||n);return e&&n&&Tt(r,t,n),n},ie=(i,r)=>(t,e)=>r(t,e,i);function bt(i,r,t,e){const{scaleX:n,scaleY:o}=r.getAncestorScale(),a=r.getViewport(L.SHEET_VIEWPORT_KEY.VIEW_MAIN),s={left:!0,top:!0};if(!a)return{...i,absolute:s};const{left:l,right:u,top:d,bottom:c}=i,m=e.getFreeze(),{startColumn:g,startRow:S,xSplit:f,ySplit:v}=m,y=t.getNoMergeCellPositionByIndexWithNoHeader(S-v,g-f),M=t.getNoMergeCellPositionByIndexWithNoHeader(S,g),{rowHeaderWidth:C,columnHeaderHeight:R}=t,I=M.startX-y.startX,P=M.startY-y.startY,{top:w,left:U,viewportScrollX:E,viewportScrollY:j}=a;let O,b;l<U?(s.left=!0,O=(I+C+(l-U))*n,b=Math.max(Math.min((I+C+(u-U))*n,(I+C)*n),(u-E)*n)):(s.left=!1,O=Math.max((l-E)*n,(I+C)*n),b=Math.max((u-E)*n,(I+C)*n));let D,W;return d<w?(s.top=!0,D=(P+R+(d-w))*o,W=Math.max(Math.min((P+R+(u-w))*o,(P+R)*o),(c-j)*o)):(s.top=!1,D=Math.max((d-j)*o,(P+R)*o),W=Math.max((c-j)*o,(P+R)*o)),{left:O,right:b,top:D,bottom:W,absolute:s}}const Pe=(i,r,t,e)=>{const{scene:n}=r,{left:o,top:a,width:s,height:l,angle:u}=i,d={left:o,right:o+s,top:a,bottom:a+l},c=bt(d,n,t,e);return{startX:c.left,endX:c.right,startY:c.top,endY:c.bottom,rotate:u,width:s,height:l,absolute:c.absolute}};T.SheetCanvasFloatDomManagerService=class extends p.Disposable{constructor(t,e,n,o,a,s){super();K(this,"_domLayerMap",new Map);K(this,"_domLayerInfoMap",new Map);K(this,"_transformChange$",new k.Subject);K(this,"transformChange$",this._transformChange$.asObservable());K(this,"_remove$",new k.Subject);K(this,"remove$",this._remove$.asObservable());K(this,"_hooks",[]);this._renderManagerService=t,this._univerInstanceService=e,this._commandService=n,this._drawingManagerService=o,this._canvasFloatDomService=a,this._sheetDrawingService=s,this._drawingAddListener(),this._scrollUpdateListener(),this._featureUpdateListener(),this._deleteListener()}_ensureMap(t,e){let n=this._domLayerMap.get(t);n||(n=new Map,this._domLayerMap.set(t,n));let o=n.get(e);return o||(o=new Map,n.set(e,o)),o}_getSceneAndTransformerByDrawingSearch(t){if(t==null)return;const e=this._renderManagerService.getRenderById(t),n=e==null?void 0:e.scene;if(e==null||n==null)return null;const o=n.getTransformerByCreate(),a=e.engine.getCanvasElement();return{scene:n,transformer:o,renderObject:e,canvas:a}}_getFloatDomProps(t){let e;return this._hooks.forEach(n=>{e=n.onGetFloatDomProps(t)}),e}_drawingAddListener(){this.disposeWithMe(this._drawingManagerService.add$.subscribe(t=>{t.forEach(e=>{var He,Ye,Xe;const{unitId:n,subUnitId:o,drawingId:a}=e,s=_.getSheetCommandTarget(this._univerInstanceService,{unitId:n,subUnitId:o}),l=this._drawingManagerService.getDrawingByParam(e),u=(He=this._renderManagerService.getRenderById(n))==null?void 0:He.with(B.SheetSkeletonManagerService).getWorksheetSkeleton(o);if(l==null||s==null||u==null)return;const{transform:d,drawingType:c}=l;if(c!==p.DrawingTypeEnum.DRAWING_DOM)return;const m=this._getSceneAndTransformerByDrawingSearch(n);if(m==null)return;const{scene:g,canvas:S}=m;if(d==null)return!0;const{left:f,top:v,width:y,height:M,angle:C,flipX:R,flipY:I,skewX:P,skewY:w}=d,U=A.getDrawingShapeKeyByDrawingSearch({unitId:n,subUnitId:o,drawingId:a}),E=g.getObject(U);if(E!=null){E.transformByState({left:f,top:v,width:y,height:M,angle:C,flipX:R,flipY:I,skewX:P,skewY:w});return}const j={left:f,top:v,width:y,height:M,zIndex:this._drawingManagerService.getDrawingOrder(n,o).length-1},O=new L.Rect(U,j);g.addObject(O,L.DRAWING_OBJECT_LAYER_INDEX).attachTransformerTo(O);const b=this._ensureMap(n,o),D=new p.DisposableCollection,W=Pe(O,m.renderObject,u.skeleton,s.worksheet),Y=new k.BehaviorSubject(W),te={dispose:D,rect:O,position$:Y,unitId:n,subUnitId:o};this._canvasFloatDomService.addFloatDom({position$:Y,id:a,componentKey:l.componentKey,onPointerDown:X=>{S.dispatchEvent(new PointerEvent(X.type,X))},onPointerMove:X=>{S.dispatchEvent(new PointerEvent(X.type,X))},onPointerUp:X=>{S.dispatchEvent(new PointerEvent(X.type,X))},onWheel:X=>{S.dispatchEvent(new WheelEvent(X.type,X))},props:(Xe=(Ye=b.get(a))==null?void 0:Ye.props)!=null?Xe:this._getFloatDomProps(a)});const ke=O.onTransformChange$.subscribeEvent(()=>{const X=Pe(O,m.renderObject,u.skeleton,s.worksheet);Y.next(X)});D.add(()=>{this._canvasFloatDomService.removeFloatDom(a)}),ke&&D.add(ke),this._domLayerInfoMap.set(a,te)})}))}_scrollUpdateListener(){this.disposeWithMe(this._commandService.onCommandExecuted(t=>{var n,o;const e=(a,s)=>{var g;const l=this._getSceneAndTransformerByDrawingSearch(a),u=this._ensureMap(a,s),d=Array.from(u.keys()),c=_.getSheetCommandTarget(this._univerInstanceService,{unitId:a,subUnitId:s}),m=(g=this._renderManagerService.getRenderById(a))==null?void 0:g.with(B.SheetSkeletonManagerService).getWorksheetSkeleton(s);!l||!c||!m||d.forEach(S=>{const f=this._domLayerInfoMap.get(S);if(f){const v=Pe(f.rect,l.renderObject,m.skeleton,c.worksheet);f.position$.next(v)}})};if(t.id===B.SetScrollOperation.id){const a=t.params,{unitId:s,sheetId:l}=a;e(s,l)}else if(t.id===B.SetZoomRatioOperation.id){const a=t.params,{unitId:s}=a;Array.from((o=(n=this._domLayerMap.get(s))==null?void 0:n.keys())!=null?o:[]).forEach(u=>{e(s,u)})}else if(t.id===_.SetFrozenMutation.id){const{unitId:a,subUnitId:s}=t.params;e(a,s)}}))}_getPosition(t,e){var g;const{startX:n,endX:o,startY:a,endY:s}=t,l=(g=this._renderManagerService.getRenderById(e))==null?void 0:g.with(B.ISheetSelectionRenderService);if(l==null)return;const u=l.getSelectionCellByPosition(n,a);if(u==null)return;const d={column:u.actualColumn,columnOffset:n-u.startX,row:u.actualRow,rowOffset:a-u.startY},c=l.getSelectionCellByPosition(o,s);if(c==null)return;const m={column:c.actualColumn,columnOffset:o-c.startX,row:c.actualRow,rowOffset:s-c.startY};return{from:d,to:m}}_featureUpdateListener(){this.disposeWithMe(this._drawingManagerService.update$.subscribe(t=>{t.forEach(e=>{const n=this._drawingManagerService.getDrawingByParam(e);if(!n||n.drawingType!==p.DrawingTypeEnum.DRAWING_DOM)return;const o={...n.transform};this._transformChange$.next({id:e.drawingId,value:o})})}))}_deleteListener(){this.disposeWithMe(this._drawingManagerService.remove$.subscribe(t=>{t.forEach(e=>{this._removeDom(e.drawingId)})}))}addFloatDomToPosition(t){const e=_.getSheetCommandTarget(this._univerInstanceService,{unitId:t.unitId,subUnitId:t.subUnitId});if(!e)throw new Error("cannot find current target!");const{unitId:n,subUnitId:o}=e,{initPosition:a,componentKey:s}=t,l=p.Tools.generateRandomId(),u=this._getPosition(a,n);if(u==null)return;this._ensureMap(n,o).set(l,t);const c={unitId:n,subUnitId:o,drawingId:l,drawingType:p.DrawingTypeEnum.DRAWING_DOM,componentKey:s,sheetTransform:u,transform:{left:a.startX,top:a.startY,width:a.endX-a.startX,height:a.endY-a.startY}};return this._commandService.executeCommand(fe.id,{unitId:n,drawings:[c]}),{id:l,dispose:()=>{this._removeDom(l,!0)}}}_removeDom(t,e=!1){const n=this._domLayerInfoMap.get(t);if(!n)return;const{unitId:o,subUnitId:a}=n;this._domLayerInfoMap.delete(t),n.dispose.dispose();const s=this._getSceneAndTransformerByDrawingSearch(o);if(s&&s.scene.removeObject(n.rect),e){this._ensureMap(o,a).delete(t);const u=this._drawingManagerService.getDrawingByParam({unitId:o,subUnitId:a,drawingId:t});if(!u)return;const d=this._sheetDrawingService.getBatchRemoveOp([u]),{redo:c,objects:m}=d;this._commandService.syncExecuteCommand(h.SetDrawingApplyMutation.id,{unitId:o,subUnitId:a,op:c,objects:m,type:h.DrawingApplyType.REMOVE})}}addHook(t){return this._hooks.push(t),{dispose:()=>{const e=this._hooks.findIndex(n=>n===t);this._hooks.splice(e,1)}}}},T.SheetCanvasFloatDomManagerService=Et([ie(0,$.Inject(L.IRenderManagerService)),ie(1,p.IUniverInstanceService),ie(2,$.Inject(p.ICommandService)),ie(3,A.IDrawingManagerService),ie(4,$.Inject(F.CanvasFloatDomService)),ie(5,h.ISheetDrawingService)],T.SheetCanvasFloatDomManagerService);var Pt=Object.defineProperty,Ot=Object.getOwnPropertyDescriptor,At=(i,r,t,e)=>{for(var n=e>1?void 0:e?Ot(r,t):r,o=i.length-1,a;o>=0;o--)(a=i[o])&&(n=(e?a(r,t,n):a(n))||n);return e&&n&&Pt(r,t,n),n},_e=(i,r)=>(t,e)=>r(t,e,i);let Ie=class extends p.Disposable{constructor(i,r,t,e){super(),this._sheetPrintInterceptorService=i,this._drawingRenderService=r,this._drawingManagerService=t,this._renderManagerService=e,this._initPrinting()}_initPrinting(){this.disposeWithMe(this._sheetPrintInterceptorService.interceptor.intercept(this._sheetPrintInterceptorService.interceptor.getInterceptPoints().PRINTING_COMPONENT_COLLECT,{handler:(i,r,t)=>{const{unitId:e,scene:n,subUnitId:o}=r,a=this._drawingManagerService.getDrawingDataForUnit(e),s=a==null?void 0:a[o];return s&&s.order.forEach(l=>{this._drawingRenderService.renderDrawing(s.data[l],n)}),t()}})),this.disposeWithMe(this._sheetPrintInterceptorService.interceptor.intercept(this._sheetPrintInterceptorService.interceptor.getInterceptPoints().PRINTING_RANGE,{handler:(i,r,t)=>{const{unitId:e,subUnitId:n}=r,o=this._renderManagerService.getRenderById(e);if(!o)return t(i);const a=o.with(B.SheetSkeletonManagerService).getWorksheetSkeleton(n);if(!a)return t(i);const s=this._drawingManagerService.getDrawingDataForUnit(e),l=s==null?void 0:s[r.subUnitId];if(!l)return t(i);const{scaleX:u,scaleY:d}=o.scene,c=i?{...i}:{startColumn:0,endColumn:0,endRow:0,startRow:0},m=l.order.map(g=>l.data[g]).filter(g=>g.drawingType!==A.DrawingTypeEnum.DRAWING_DOM);return m.length?(m.forEach(g=>{if(!g.groupId&&g.transform&&p.Tools.isDefine(g.transform.left)&&p.Tools.isDefine(g.transform.top)&&p.Tools.isDefine(g.transform.width)&&p.Tools.isDefine(g.transform.height)){const S=a.skeleton.getCellPositionByOffset(g.transform.left,g.transform.top,u,d,{x:0,y:0}),f=a.skeleton.getCellPositionByOffset(g.transform.left+g.transform.width,g.transform.top+g.transform.height,u,d,{x:0,y:0});S.column<c.startColumn&&(c.startColumn=S.column),S.row<c.startRow&&(c.startRow=S.row),c.endRow<f.row&&(c.endRow=f.row),c.endColumn<f.column&&(c.endColumn=f.column)}}),t(c)):t(i)}}))}};Ie=At([p.OnLifecycle(p.LifecycleStages.Rendered,Ie),_e(0,$.Inject(B.SheetPrintInterceptorService)),_e(1,$.Inject(Q.DrawingRenderService)),_e(2,A.IDrawingManagerService),_e(3,L.IRenderManagerService)],Ie);var Ut=Object.defineProperty,Nt=Object.getOwnPropertyDescriptor,Lt=(i,r,t,e)=>{for(var n=e>1?void 0:e?Nt(r,t):r,o=i.length-1,a;o>=0;o--)(a=i[o])&&(n=(e?a(r,t,n):a(n))||n);return e&&n&&Ut(r,t,n),n},ue=(i,r)=>(t,e)=>r(t,e,i);let Ce=class extends p.Disposable{constructor(i,r,t,e,n){super(),this._drawingManagerService=i,this._renderManagerService=r,this._permissionService=t,this._univerInstanceService=e,this._userManagerService=n,this._initDrawingVisible(),this._initDrawingEditable(),this._initViewPermissionChange(),this._initEditPermissionChange()}_initDrawingVisible(){const i=this._univerInstanceService.getCurrentTypeOfUnit$(p.UniverInstanceType.UNIVER_SHEET);this.disposeWithMe(k.combineLatest([i,this._userManagerService.currentUser$]).subscribe(([r,t])=>{if(!r){this._drawingManagerService.setDrawingVisible(!1);return}r.activeSheet$.subscribe(e=>{if(!e){this._drawingManagerService.setDrawingVisible(!1);return}const n=r.getUnitId(),o=e.getSheetId();if(this._permissionService.composePermission([new _.WorkbookViewPermission(n).id,new _.WorksheetViewPermission(n,o).id]).every(s=>s.value))this._drawingManagerService.setDrawingVisible(!0);else{this._drawingManagerService.setDrawingVisible(!1);const s=r.getUnitId(),l=e.getSheetId(),u=this._drawingManagerService.getDrawingData(s,l),d=Object.values(u),c=this._renderManagerService.getRenderById(s),m=c==null?void 0:c.scene;if(m==null)return;m.getAllObjects().forEach(S=>{S.classType===L.RENDER_CLASS_TYPE.IMAGE&&d.some(f=>S.oKey.includes(f.drawingId))&&m.removeObject(S)})}})}))}_initDrawingEditable(){const i=this._univerInstanceService.getCurrentTypeOfUnit$(p.UniverInstanceType.UNIVER_SHEET);this.disposeWithMe(k.combineLatest([i,this._userManagerService.currentUser$]).subscribe(([r,t])=>{if(!r){this._drawingManagerService.setDrawingEditable(!1);return}r.activeSheet$.subscribe(e=>{if(!e){this._drawingManagerService.setDrawingEditable(!1);return}const n=r.getUnitId(),o=e.getSheetId();if(this._permissionService.composePermission([new _.WorkbookEditablePermission(n).id,new _.WorksheetEditPermission(n,o).id]).every(s=>s.value))this._drawingManagerService.setDrawingEditable(!0);else{this._drawingManagerService.setDrawingEditable(!1);const s=r.getUnitId(),l=e.getSheetId(),u=this._drawingManagerService.getDrawingData(s,l),d=Object.values(u),c=this._renderManagerService.getRenderById(s),m=c==null?void 0:c.scene;if(m==null)return;m.getAllObjects().forEach(S=>{S.classType===L.RENDER_CLASS_TYPE.IMAGE&&d.some(f=>S.oKey.includes(f.drawingId))&&m.detachTransformerFrom(S)})}})}))}_initViewPermissionChange(){const i=this._univerInstanceService.getCurrentTypeOfUnit$(p.UniverInstanceType.UNIVER_SHEET);this.disposeWithMe(k.combineLatest([i,this._userManagerService.currentUser$]).subscribe(([r,t])=>{r&&r.activeSheet$.subscribe(e=>{var c;if(!e)return;const n=r.getUnitId(),o=e.getSheetId();let a=!0;const s=this._renderManagerService.getRenderById(n),l=s==null?void 0:s.scene;if(l==null)return;const u=l.getTransformerByCreate(),d=this._permissionService.composePermission$([new _.WorkbookViewPermission(n).id,new _.WorksheetViewPermission(n,o).id]).pipe(k.map(m=>m.every(g=>g.value)));d==null||d.pipe(k.filter(m=>m!==a),k.distinctUntilChanged()).subscribe({next:m=>{a=m,this._drawingManagerService.setDrawingVisible(m);const g=l.getAllObjects(),S=this._drawingManagerService.getDrawingData(n,o),f=Object.values(S);m?this._drawingManagerService.addNotification(f):(g.forEach(v=>{v.classType===L.RENDER_CLASS_TYPE.IMAGE&&f.some(y=>v.oKey.includes(y.drawingId))&&l.removeObject(v)}),u.clearSelectedObjects())}}),(c=this._permissionService.getPermissionPoint$(new _.WorksheetViewPermission(n,o).id))==null||c.pipe(k.filter(m=>m.value!==a),k.distinctUntilChanged()).subscribe({complete:()=>{a=!0,this._drawingManagerService.setDrawingVisible(!0);const m=this._drawingManagerService.getDrawingData(n,o),g=Object.values(m);this._drawingManagerService.addNotification(g)}})})}))}_initEditPermissionChange(){const i=this._univerInstanceService.getCurrentTypeOfUnit$(p.UniverInstanceType.UNIVER_SHEET);this.disposeWithMe(k.combineLatest([i,this._userManagerService.currentUser$]).subscribe(([r,t])=>{r&&r.activeSheet$.subscribe(e=>{var c;if(!e)return;const n=r.getUnitId(),o=e.getSheetId();let a=!0;const s=this._renderManagerService.getRenderById(n),l=s==null?void 0:s.scene;if(l==null)return;const u=l.getTransformerByCreate(),d=this._permissionService.composePermission$([new _.WorkbookEditablePermission(n).id,new _.WorksheetEditPermission(n,o).id]).pipe(k.map(m=>m.every(g=>g.value)));d==null||d.pipe(k.filter(m=>m!==a),k.distinctUntilChanged()).subscribe({next:m=>{a=m,this._drawingManagerService.setDrawingEditable(m);const g=l.getAllObjects(),S=this._drawingManagerService.getDrawingData(n,o),f=Object.values(S);m?(g.forEach(v=>{v.classType===L.RENDER_CLASS_TYPE.IMAGE&&f.some(y=>v.oKey.includes(y.drawingId))&&l.attachTransformerTo(v)}),this._drawingManagerService.addNotification(f)):(g.forEach(v=>{v.classType===L.RENDER_CLASS_TYPE.IMAGE&&f.some(y=>v.oKey.includes(y.drawingId))&&l.detachTransformerFrom(v)}),u.clearSelectedObjects())}}),(c=this._permissionService.getPermissionPoint$(new _.WorksheetEditPermission(n,o).id))==null||c.pipe(k.filter(m=>m.value!==a),k.distinctUntilChanged()).subscribe({complete:()=>{a=!0;const m=r.getUnitId(),g=e.getSheetId(),S=this._drawingManagerService.getDrawingData(m,g),f=Object.values(S),v=this._renderManagerService.getRenderById(m),y=v==null?void 0:v.scene;if(y==null)return;this._drawingManagerService.setDrawingEditable(!0),y.getAllObjects().forEach(C=>{C.classType===L.RENDER_CLASS_TYPE.IMAGE&&f.some(R=>C.oKey.includes(R.drawingId))&&y.detachTransformerFrom(C)})}})})}))}};Ce=Lt([p.OnLifecycle(p.LifecycleStages.Rendered,Ce),ue(0,A.IDrawingManagerService),ue(1,L.IRenderManagerService),ue(2,p.IPermissionService),ue(3,p.IUniverInstanceService),ue(4,$.Inject(p.UserManagerService))],Ce);var jt=Object.defineProperty,Wt=Object.getOwnPropertyDescriptor,Bt=(i,r,t,e)=>{for(var n=e>1?void 0:e?Wt(r,t):r,o=i.length-1,a;o>=0;o--)(a=i[o])&&(n=(e?a(r,t,n):a(n))||n);return e&&n&&jt(r,t,n),n},Oe=(i,r)=>(t,e)=>r(t,e,i);let ye=class extends p.Disposable{constructor(r,t,e){super();K(this,"_copyInfo");this._sheetClipboardService=r,this._renderManagerService=t,this._sheetDrawingService=e,this._initCopyPaste()}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:"SHEET_IMAGE_UI_PLUGIN",onBeforeCopy:(r,t,e)=>this._collect(r,t,e),onPasteCells:(r,t,e,n)=>{const{copyType:o=B.COPY_TYPE.COPY,pasteType:a}=n,{range:s}=r||{},{range:l,unitId:u,subUnitId:d}=t;return this._generateMutations(l,{copyType:o,pasteType:a,copyRange:s,unitId:u,subUnitId:d})},onPastePlainText:(r,t)=>({undos:[],redos:[]})})}_collect(r,t,e){var m;const n=(m=this._renderManagerService.getRenderById(r))==null?void 0:m.with(B.SheetSkeletonManagerService);if(!n)return;const o=n.attachRangeWithCoord(e);if(!o)return;const{startX:a,endX:s,startY:l,endY:u}=o,d=this._sheetDrawingService.getDrawingData(r,t),c=[];Object.keys(d).forEach(g=>{const S=d[g],{transform:f}=S;if(S.anchorType!==h.SheetDrawingAnchorType.Both||!f)return;const{left:v=0,top:y=0,width:M=0,height:C=0}=f,{drawingStartX:R,drawingEndX:I,drawingStartY:P,drawingEndY:w}={drawingStartX:v,drawingEndX:v+M,drawingStartY:y,drawingEndY:y+C};a<=R&&I<=s&&l<=P&&w<=u&&c.push(S)}),c.length&&(this._copyInfo={drawings:c,unitId:r,subUnitId:t})}_generateMutations(r,t){var E;if(!this._copyInfo)return{redos:[],undos:[]};if([B.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,B.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,B.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,B.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMULA].includes(t.pasteType))return{redos:[],undos:[]};const{copyRange:e}=t;if(!e)return{redos:[],undos:[]};const{drawings:n,unitId:o,subUnitId:a}=this._copyInfo,{ranges:[s,l],mapFunc:u}=B.virtualizeDiscreteRanges([e,r]),{row:d,col:c}=u(s.startRow,s.startColumn),{row:m,col:g}=u(l.startRow,l.startColumn),S=(E=this._renderManagerService.getRenderById(o))==null?void 0:E.with(B.SheetSkeletonManagerService);if(!S)return{redos:[],undos:[]};const f=S.attachRangeWithCoord({startRow:d,endRow:d,startColumn:c,endColumn:c}),v=S.attachRangeWithCoord({startRow:m,endRow:m,startColumn:g,endColumn:g});if(!f||!v)return{redos:[],undos:[]};const y=[],M=[],C=v.startX-f.startX,R=v.startY-f.startY,I=m-d,P=g-c,w=t.copyType===B.COPY_TYPE.CUT,{_sheetDrawingService:U}=this;return n.forEach(j=>{const{transform:O,sheetTransform:b}=j;if(!O)return;const D={...j,unitId:o,subUnitId:a,drawingId:w?j.drawingId:p.Tools.generateRandomId(),transform:{...O,left:O.left+C,top:O.top+R},sheetTransform:{to:{...b.to,row:b.to.row+I,column:b.to.column+P},from:{...b.from,row:b.from.row+I,column:b.from.column+P}}};if(w){const{undo:W,redo:Y,objects:te}=U.getBatchUpdateOp([D]);y.push({id:h.SetDrawingApplyMutation.id,params:{unitId:o,subUnitId:a,type:h.DrawingApplyType.UPDATE,op:Y,objects:te}}),M.push({id:h.SetDrawingApplyMutation.id,params:{unitId:o,subUnitId:a,type:h.DrawingApplyType.UPDATE,op:W,objects:te}})}else{const{undo:W,redo:Y,objects:te}=U.getBatchAddOp([D]);y.push({id:h.SetDrawingApplyMutation.id,params:{op:Y,unitId:o,subUnitId:a,objects:te,type:h.DrawingApplyType.INSERT}}),M.push({id:h.SetDrawingApplyMutation.id,params:{op:W,unitId:o,subUnitId:a,objects:te,type:h.DrawingApplyType.REMOVE}})}}),{redos:y,undos:M}}};ye=Bt([p.OnLifecycle(p.LifecycleStages.Ready,ye),Oe(0,B.ISheetClipboardService),Oe(1,L.IRenderManagerService),Oe(2,h.ISheetDrawingService)],ye);var Ve=Object.defineProperty,$t=Object.getOwnPropertyDescriptor,Gt=(i,r,t)=>r in i?Ve(i,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[r]=t,Vt=(i,r,t,e)=>{for(var n=e>1?void 0:e?$t(r,t):r,o=i.length-1,a;o>=0;o--)(a=i[o])&&(n=(e?a(r,t,n):a(n))||n);return e&&n&&Ve(r,t,n),n},Ae=(i,r)=>(t,e)=>r(t,e,i),Fe=(i,r,t)=>Gt(i,typeof r!="symbol"?r+"":r,t);const Ft="SHEET_IMAGE_UI_PLUGIN";T.UniverSheetsDrawingUIPlugin=class extends p.Plugin{constructor(t={},e,n,o){super();K(this,"_pluginConfig");this._injector=e,this._localeService=n,this._renderManagerService=o,this._pluginConfig=p.Tools.deepMerge({},_t,t)}onStarting(t){super.onStarting(t),this._initDependencies(t)}onRendered(){this._registerRenderModules()}_initDependencies(t){const e=[[T.SheetCanvasFloatDomManagerService],[de,{useFactory:()=>this._injector.createInstance(de,this._pluginConfig)}],[he],[Ie],[Ce]],n=[Se,we];e.forEach(o=>t.add(o)),n.forEach(o=>this._renderManagerService.registerRenderModule(p.UniverInstanceType.UNIVER_SHEET,o))}_registerRenderModules(){[[ye]].forEach(t=>{this.disposeWithMe(this._renderManagerService.registerRenderModule(p.UniverInstanceType.UNIVER_SHEET,t))})}},Fe(T.UniverSheetsDrawingUIPlugin,"type",p.UniverInstanceType.UNIVER_SHEET),Fe(T.UniverSheetsDrawingUIPlugin,"pluginName",Ft),T.UniverSheetsDrawingUIPlugin=Vt([p.DependentOn(A.UniverDrawingPlugin,Q.UniverDrawingUIPlugin,h.UniverSheetsDrawingPlugin),Ae(1,$.Inject($.Injector)),Ae(2,$.Inject(p.LocaleService)),Ae(3,L.IRenderManagerService)],T.UniverSheetsDrawingUIPlugin),T.ClearSheetDrawingTransformerOperation=G,T.DeleteDrawingsCommand=be,T.EditSheetDrawingOperation=De,T.GroupSheetDrawingCommand=Re,T.InsertCellImageOperation=ae,T.InsertFloatImageOperation=oe,T.InsertSheetDrawingCommand=fe,T.MoveDrawingsCommand=ne,T.RemoveSheetDrawingCommand=ge,T.SetDrawingArrangeCommand=Te,T.SetSheetDrawingCommand=se,T.SidebarSheetDrawingOperation=Me,T.UngroupSheetDrawingCommand=Ee,Object.defineProperty(T,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/sheets-drawing-ui",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -48,42 +48,42 @@
|
|
|
48
48
|
"lib"
|
|
49
49
|
],
|
|
50
50
|
"peerDependencies": {
|
|
51
|
-
"@wendellhu/redi": "0.
|
|
51
|
+
"@wendellhu/redi": "0.16.0",
|
|
52
52
|
"clsx": ">=2.0.0",
|
|
53
53
|
"react": "^16.9.0 || ^17.0.0 || ^18.0.0",
|
|
54
54
|
"rxjs": ">=7.0.0",
|
|
55
|
-
"@univerjs/core": "0.2.
|
|
56
|
-
"@univerjs/design": "0.2.
|
|
57
|
-
"@univerjs/drawing": "0.2.
|
|
58
|
-
"@univerjs/drawing-ui": "0.2.
|
|
59
|
-
"@univerjs/engine-render": "0.2.
|
|
60
|
-
"@univerjs/sheets": "0.2.
|
|
61
|
-
"@univerjs/sheets-drawing": "0.2.
|
|
62
|
-
"@univerjs/sheets-ui": "0.2.
|
|
63
|
-
"@univerjs/ui": "0.2.
|
|
55
|
+
"@univerjs/core": "0.2.4",
|
|
56
|
+
"@univerjs/design": "0.2.4",
|
|
57
|
+
"@univerjs/drawing": "0.2.4",
|
|
58
|
+
"@univerjs/drawing-ui": "0.2.4",
|
|
59
|
+
"@univerjs/engine-render": "0.2.4",
|
|
60
|
+
"@univerjs/sheets": "0.2.4",
|
|
61
|
+
"@univerjs/sheets-drawing": "0.2.4",
|
|
62
|
+
"@univerjs/sheets-ui": "0.2.4",
|
|
63
|
+
"@univerjs/ui": "0.2.4"
|
|
64
64
|
},
|
|
65
65
|
"dependencies": {
|
|
66
|
-
"@univerjs/icons": "^0.1.
|
|
66
|
+
"@univerjs/icons": "^0.1.65"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
|
-
"@wendellhu/redi": "0.
|
|
69
|
+
"@wendellhu/redi": "0.16.0",
|
|
70
70
|
"clsx": "^2.1.1",
|
|
71
71
|
"less": "^4.2.0",
|
|
72
72
|
"react": "18.3.1",
|
|
73
73
|
"rxjs": "^7.8.1",
|
|
74
74
|
"typescript": "^5.5.3",
|
|
75
|
-
"vite": "^5.3.
|
|
76
|
-
"vitest": "^
|
|
77
|
-
"@univerjs/
|
|
78
|
-
"@univerjs/
|
|
79
|
-
"@univerjs/drawing": "0.2.
|
|
80
|
-
"@univerjs/
|
|
81
|
-
"@univerjs/
|
|
82
|
-
"@univerjs/
|
|
83
|
-
"@univerjs/sheets": "0.2.
|
|
84
|
-
"@univerjs/
|
|
85
|
-
"@univerjs/sheets-
|
|
86
|
-
"@univerjs/ui": "0.2.
|
|
75
|
+
"vite": "^5.3.4",
|
|
76
|
+
"vitest": "^2.0.3",
|
|
77
|
+
"@univerjs/core": "0.2.4",
|
|
78
|
+
"@univerjs/design": "0.2.4",
|
|
79
|
+
"@univerjs/drawing": "0.2.4",
|
|
80
|
+
"@univerjs/engine-render": "0.2.4",
|
|
81
|
+
"@univerjs/sheets": "0.2.4",
|
|
82
|
+
"@univerjs/shared": "0.2.4",
|
|
83
|
+
"@univerjs/sheets-drawing": "0.2.4",
|
|
84
|
+
"@univerjs/drawing-ui": "0.2.4",
|
|
85
|
+
"@univerjs/sheets-ui": "0.2.4",
|
|
86
|
+
"@univerjs/ui": "0.2.4"
|
|
87
87
|
},
|
|
88
88
|
"univerSpace": {
|
|
89
89
|
".": {
|