@univerjs/sheets-drawing-ui 0.2.2 → 0.2.4-alpha.0

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/README.md CHANGED
@@ -1,16 +1,27 @@
1
1
  # @univerjs/sheets-drawing-ui
2
2
 
3
- [![npm version](https://img.shields.io/npm/v/@univerjs/sheets-drawing-ui)](https://npmjs.org/packages/@univerjs/sheets-drawing-ui)
4
- [![license](https://img.shields.io/npm/l/@univerjs/sheets-drawing-ui)](https://img.shields.io/npm/l/@univerjs/sheets-drawing-ui)
3
+ ## Package Overview
5
4
 
6
- ## Introduction
5
+ | Package Name | UMD Namespace | Version | License | Downloads | Contains CSS | Contains i18n locales |
6
+ | --- | --- | --- | --- | --- | :---: | :---: |
7
+ | `@univerjs/sheets-drawing-ui` | `UniverSheetsDrawingUi` | [![][npm-version-shield]][npm-version-link] | ![][npm-license-shield] | ![][npm-downloads-shield] | ⭕️ | ⭕️ |
7
8
 
8
- > TODO: Introduction
9
+ ## Introduction
9
10
 
10
11
  ## Usage
11
12
 
12
13
  ### Installation
13
14
 
14
15
  ```shell
15
- npm i @univerjs/sheets-drawing-ui
16
+ # Using npm
17
+ npm install @univerjs/sheets-drawing-ui
18
+
19
+ # Using pnpm
20
+ pnpm add @univerjs/sheets-drawing-ui
16
21
  ```
22
+
23
+ <!-- Links -->
24
+ [npm-version-shield]: https://img.shields.io/npm/v/@univerjs/sheets-drawing-ui?style=flat-square
25
+ [npm-version-link]: https://npmjs.com/package/@univerjs/sheets-drawing-ui
26
+ [npm-license-shield]: https://img.shields.io/npm/l/@univerjs/sheets-drawing-ui?style=flat-square
27
+ [npm-downloads-shield]: https://img.shields.io/npm/dm/@univerjs/sheets-drawing-ui?style=flat-square
package/lib/cjs/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var xe=Object.defineProperty;var He=(i,e,n)=>e in i?xe(i,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[e]=n;var q=(i,e,n)=>He(i,typeof e!="symbol"?e+"":e,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("@univerjs/core"),$=require("@wendellhu/redi"),re=require("@univerjs/drawing-ui"),m=require("@univerjs/sheets-drawing"),N=require("@univerjs/drawing"),j=require("@univerjs/engine-render"),B=require("@univerjs/sheets-ui"),Y=require("rxjs"),V=require("@univerjs/ui"),J=require("@wendellhu/redi/react-bindings"),_=require("@univerjs/sheets"),L=require("react"),Q=require("@univerjs/design"),he=require("clsx"),G={id:"sheet.operation.clear-drawing-transformer",type:p.CommandType.MUTATION,handler:(i,e)=>{const n=i.get(j.IRenderManagerService);return e.forEach(t=>{var r,o;(o=(r=n.getRenderById(t))==null?void 0:r.scene.getTransformer())==null||o.debounceRefreshControls()}),!0}},ye={id:"sheet.command.remove-sheet-image",type:p.CommandType.COMMAND,handler:(i,e)=>{const n=i.get(p.ICommandService),t=i.get(p.IUndoRedoService),r=i.get(m.ISheetDrawingService);if(!e)return!1;const{drawings:o}=e,s=[];o.forEach(w=>{const{unitId:f}=w;s.push(f)});const a=r.getBatchRemoveOp(o),{unitId:d,subUnitId:g,undo:u,redo:c,objects:l}=a;return n.syncExecuteCommand(m.SetDrawingApplyMutation.id,{unitId:d,subUnitId:g,op:c,objects:l,type:m.DrawingApplyType.REMOVE})?(t.pushUndoRedo({unitID:d,undoMutations:[{id:m.SetDrawingApplyMutation.id,params:{unitId:d,subUnitId:g,op:u,objects:l,type:m.DrawingApplyType.INSERT}},{id:G.id,params:s}],redoMutations:[{id:m.SetDrawingApplyMutation.id,params:{unitId:d,subUnitId:g,op:c,objects:l,type:m.DrawingApplyType.REMOVE}},{id:G.id,params:s}]}),!0):!1}},je="COMPONENT_SHEET_DRAWING_PANEL",Ee={id:"sidebar.operation.sheet-image",type:p.CommandType.COMMAND,handler:async(i,e)=>{const n=i.get(V.ISidebarService),t=i.get(p.LocaleService),r=i.get(p.IUniverInstanceService),o=i.get(N.IDrawingManagerService);if(!_.getSheetCommandTarget(r))return!1;switch(e.value){case"open":n.open({header:{title:t.t("sheetImage.panel.title")},children:{label:je},onClose:()=>{o.focusDrawing(null)},width:360});break;case"close":default:n.close();break}return!0}},be={id:"sheet.operation.edit-sheet-image",type:p.CommandType.OPERATION,handler:(i,e)=>{const n=i.get(N.IDrawingManagerService),t=i.get(p.ICommandService);return e==null?!1:(n.focusDrawing([e]),t.executeCommand(Ee.id,{value:"open"}),!0)}},ke="univer-upload-loading",Ke="univer-upload-loading-body",ze="univer-upload-loading-body-animation",qe="univer-UniverCircleAnimation",Je="univer-upload-loading-body-text",me={uploadLoading:ke,uploadLoadingBody:Ke,uploadLoadingBodyAnimation:ze,univerCircleAnimation:qe,uploadLoadingBodyText:Je},Ze=()=>{const i=J.useDependency(N.IImageIoService),e=J.useDependency(p.LocaleService),[n,t]=L.useState(0);return L.useEffect(()=>{const r=i.change$.subscribe(o=>{t(o)});return()=>{r.unsubscribe()}},[i]),L.createElement("div",{style:{display:n>0?"block":"none"},className:me.uploadLoading},L.createElement("div",{className:me.uploadLoadingBody},L.createElement("div",{className:me.uploadLoadingBodyAnimation}),L.createElement("div",{className:me.uploadLoadingBodyText},`${e.t("uploadLoading.loading")}: ${n}`)))};var Qe=Object.defineProperty,et=Object.getOwnPropertyDescriptor,tt=(i,e,n,t)=>{for(var r=t>1?void 0:t?et(e,n):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(t?s(e,n,r):s(r))||r);return t&&r&&Qe(e,n,r),r},ee=(i,e)=>(n,t)=>e(n,t,i);let we=class extends p.RxDisposable{constructor(e,n,t,r,o,s,a){super();q(this,"_initImagePopupMenu",new Set);this._injector=e,this._drawingManagerService=n,this._canvasPopManagerService=t,this._renderManagerService=r,this._univerInstanceService=o,this._contextService=s,this._uiPartsService=a,this._init()}_init(){this._univerInstanceService.getCurrentTypeOfUnit$(p.UniverInstanceType.UNIVER_SHEET).pipe(Y.takeUntil(this.dispose$)).subscribe(e=>this._create(e)),this._univerInstanceService.getTypeOfUnitDisposed$(p.UniverInstanceType.UNIVER_SHEET).pipe(Y.takeUntil(this.dispose$)).subscribe(e=>this._dispose(e)),this._univerInstanceService.getAllUnitsForType(p.UniverInstanceType.UNIVER_SHEET).forEach(e=>this._create(e)),this._uiPartsService.registerComponent(V.BuiltInUIPart.CONTENT,()=>J.connectInjector(Ze,this._injector))}_dispose(e){const n=e.getUnitId();this._renderManagerService.removeRender(n)}_create(e){if(!e)return;const n=e.getUnitId();this._renderManagerService.has(n)&&!this._initImagePopupMenu.has(n)&&(this._popupMenuListener(n),this._initImagePopupMenu.add(n))}_hasCropObject(e){const n=e.getAllObjects();for(const t of n)if(t instanceof re.ImageCropperObject)return!0;return!1}_popupMenuListener(e){var o;const n=(o=this._renderManagerService.getRenderById(e))==null?void 0:o.scene;if(!n)return;const t=n.getTransformerByCreate();if(!t)return;let r;this.disposeWithMe(p.toDisposable(t.createControl$.subscribe(()=>{if(this._contextService.setContextValue(p.FOCUSING_COMMON_DRAWINGS,!0),this._hasCropObject(n))return;const s=t.getSelectedObjectMap();if(s.size>1){r==null||r.dispose();return}const a=s.values().next().value;if(!a)return;const d=a.oKey,g=this._drawingManagerService.getDrawingOKey(d);if(!g)return;const{unitId:u,subUnitId:c,drawingId:l}=g;r==null||r.dispose(),r=this.disposeWithMe(this._canvasPopManagerService.attachPopupToObject(a,{componentKey:re.COMPONENT_IMAGE_POPUP_MENU,direction:"horizontal",offset:[2,0],extraProps:{menuItems:this._getImageMenuItems(u,c,l)}})),this._drawingManagerService.focusDrawing([{unitId:u,subUnitId:c,drawingId:l}])}))),this.disposeWithMe(t.clearControl$.subscribe(()=>{r==null||r.dispose(),this._contextService.setContextValue(p.FOCUSING_COMMON_DRAWINGS,!1),this._drawingManagerService.focusDrawing(null)})),this.disposeWithMe(t.changing$.subscribe(()=>{r==null||r.dispose()}))}_getImageMenuItems(e,n,t){return[{label:"image-popup.edit",index:0,commandId:be.id,commandParams:{unitId:e,subUnitId:n,drawingId:t},disable:!1},{label:"image-popup.delete",index:1,commandId:ye.id,commandParams:{unitId:e,drawings:[{unitId:e,subUnitId:n,drawingId:t}]},disable:!1},{label:"image-popup.crop",index:2,commandId:re.OpenImageCropOperation.id,commandParams:{unitId:e,subUnitId:n,drawingId:t},disable:!1},{label:"image-popup.reset",index:3,commandId:re.ImageResetSizeOperation.id,commandParams:[{unitId:e,subUnitId:n,drawingId:t}],disable:!1}]}};we=tt([p.OnLifecycle(p.LifecycleStages.Steady,we),ee(0,$.Inject($.Injector)),ee(1,N.IDrawingManagerService),ee(2,$.Inject(B.SheetCanvasPopManagerService)),ee(3,j.IRenderManagerService),ee(4,p.IUniverInstanceService),ee(5,p.IContextService),ee(6,$.Inject(V.IUIPartsService))],we);const le={id:"sheet.operation.insert-float-image",type:p.CommandType.OPERATION,handler:(i,e)=>!0},de={id:"sheet.operation.insert-cell-image",type:p.CommandType.OPERATION,handler:(i,e)=>!0},Re={id:"sheet.command.insert-sheet-image",type:p.CommandType.COMMAND,handler:(i,e)=>{const n=i.get(p.ICommandService),t=i.get(p.IUndoRedoService),r=i.get(m.ISheetDrawingService);if(!e)return!1;const o=e.drawings,s=o.map(w=>w.unitId),a=r.getBatchAddOp(o),{unitId:d,subUnitId:g,undo:u,redo:c,objects:l}=a;return n.syncExecuteCommand(m.SetDrawingApplyMutation.id,{op:c,unitId:d,subUnitId:g,objects:l,type:m.DrawingApplyType.INSERT})?(t.pushUndoRedo({unitID:d,undoMutations:[{id:m.SetDrawingApplyMutation.id,params:{op:u,unitId:d,subUnitId:g,objects:l,type:m.DrawingApplyType.REMOVE}},{id:G.id,params:s}],redoMutations:[{id:m.SetDrawingApplyMutation.id,params:{op:c,unitId:d,subUnitId:g,objects:l,type:m.DrawingApplyType.INSERT}},{id:G.id,params:s}]}),!0):!1}},ue={id:"sheet.command.set-sheet-image",type:p.CommandType.COMMAND,handler:(i,e)=>{const n=i.get(p.ICommandService),t=i.get(p.IUndoRedoService),r=i.get(m.ISheetDrawingService);if(!e)return!1;const{drawings:o}=e,s=r.getBatchUpdateOp(o),{unitId:a,subUnitId:d,undo:g,redo:u,objects:c}=s;return n.syncExecuteCommand(m.SetDrawingApplyMutation.id,{unitId:a,subUnitId:d,op:u,objects:c,type:m.DrawingApplyType.UPDATE})?(t.pushUndoRedo({unitID:a,undoMutations:[{id:m.SetDrawingApplyMutation.id,params:{unitId:a,subUnitId:d,op:g,objects:c,type:m.DrawingApplyType.UPDATE}},{id:G.id,params:[a]}],redoMutations:[{id:m.SetDrawingApplyMutation.id,params:{unitId:a,subUnitId:d,op:u,objects:c,type:m.DrawingApplyType.UPDATE}},{id:G.id,params:[a]}]}),!0):!1}},Pe={id:"sheet.command.set-drawing-arrange",type:p.CommandType.COMMAND,handler:(i,e)=>{const n=i.get(p.ICommandService),t=i.get(p.IUndoRedoService);if(!e)return!1;const r=i.get(m.ISheetDrawingService),{unitId:o,subUnitId:s,drawingIds:a,arrangeType:d}=e,g={unitId:o,subUnitId:s,drawingIds:a};let u;if(d===N.ArrangeTypeEnum.forward?u=r.getForwardDrawingsOp(g):d===N.ArrangeTypeEnum.backward?u=r.getBackwardDrawingOp(g):d===N.ArrangeTypeEnum.front?u=r.getFrontDrawingsOp(g):d===N.ArrangeTypeEnum.back&&(u=r.getBackDrawingsOp(g)),u==null)return!1;const{objects:c,redo:l,undo:h}=u;return n.syncExecuteCommand(m.SetDrawingApplyMutation.id,{op:l,unitId:o,subUnitId:s,objects:c,type:m.DrawingApplyType.ARRANGE})?(t.pushUndoRedo({unitID:o,undoMutations:[{id:m.SetDrawingApplyMutation.id,params:{op:h,unitId:o,subUnitId:s,objects:c,type:m.DrawingApplyType.ARRANGE}}],redoMutations:[{id:m.SetDrawingApplyMutation.id,params:{op:l,unitId:o,subUnitId:s,objects:c,type:m.DrawingApplyType.ARRANGE}}]}),!0):!1}};function nt(i){const e=[];return i.forEach(n=>{const{parent:t,children:r}=n,{unitId:o,subUnitId:s,drawingId:a}=t,d=j.getGroupState(0,0,r.map(c=>c.transform||{})),g=r.map(c=>{const l=c.transform||{left:0,top:0},{unitId:h,subUnitId:w,drawingId:f}=c;return{unitId:h,subUnitId:w,drawingId:f,transform:{...l,left:l.left-d.left,top:l.top-d.top},groupId:a}}),u={unitId:o,subUnitId:s,drawingId:a,drawingType:N.DrawingTypeEnum.DRAWING_GROUP,transform:d};e.push({parent:u,children:g})}),e}function rt(i){const e=[];return i.forEach(n=>{const{parent:t,children:r}=n,{unitId:o,subUnitId:s,drawingId:a,transform:d={width:0,height:0}}=t;if(d==null)return;const g=r.map(c=>{const{transform:l}=c,{unitId:h,subUnitId:w,drawingId:f}=c,S=j.transformObjectOutOfGroup(l||{},d,d.width||0,d.height||0);return{unitId:h,subUnitId:w,drawingId:f,transform:S,groupId:void 0}}),u={unitId:o,subUnitId:s,drawingId:a,drawingType:N.DrawingTypeEnum.DRAWING_GROUP,transform:{left:0,top:0}};e.push({parent:u,children:g})}),e}const Ae={id:"sheet.command.group-sheet-image",type:p.CommandType.COMMAND,handler:(i,e)=>{const n=i.get(p.ICommandService),t=i.get(p.IUndoRedoService),r=i.get(m.ISheetDrawingService);if(!e)return!1;const o=[];e.forEach(({parent:h,children:w})=>{o.push(h.unitId),w.forEach(f=>{o.push(f.unitId)})});const s=r.getGroupDrawingOp(e),{unitId:a,subUnitId:d,undo:g,redo:u,objects:c}=s;return n.syncExecuteCommand(m.SetDrawingApplyMutation.id,{op:u,unitId:a,subUnitId:d,objects:c,type:m.DrawingApplyType.GROUP})?(t.pushUndoRedo({unitID:a,undoMutations:[{id:m.SetDrawingApplyMutation.id,params:{op:g,unitId:a,subUnitId:d,objects:rt(c),type:m.DrawingApplyType.UNGROUP}},{id:G.id,params:o}],redoMutations:[{id:m.SetDrawingApplyMutation.id,params:{op:u,unitId:a,subUnitId:d,objects:c,type:m.DrawingApplyType.GROUP}},{id:G.id,params:o}]}),!0):!1}},Ue={id:"sheet.command.ungroup-sheet-image",type:p.CommandType.COMMAND,handler:(i,e)=>{const n=i.get(p.ICommandService),t=i.get(p.IUndoRedoService),r=i.get(m.ISheetDrawingService);if(!e)return!1;const o=[];e.forEach(({parent:h,children:w})=>{o.push(h.unitId),w.forEach(f=>{o.push(f.unitId)})});const s=r.getUngroupDrawingOp(e),{unitId:a,subUnitId:d,undo:g,redo:u,objects:c}=s;return n.syncExecuteCommand(m.SetDrawingApplyMutation.id,{op:u,unitId:a,subUnitId:d,objects:c,type:m.DrawingApplyType.UNGROUP})?(t.pushUndoRedo({unitID:a,undoMutations:[{id:m.SetDrawingApplyMutation.id,params:{op:g,unitId:a,subUnitId:d,objects:nt(c),type:m.DrawingApplyType.GROUP}},{id:G.id,params:o}],redoMutations:[{id:m.SetDrawingApplyMutation.id,params:{op:u,unitId:a,subUnitId:d,objects:c,type:m.DrawingApplyType.UNGROUP}},{id:G.id,params:o}]}),!0):!1}};function x(i,e,n){const{from:t,to:r,flipY:o=!1,flipX:s=!1,angle:a=0,skewX:d=0,skewY:g=0}=i,{column:u,columnOffset:c,row:l,rowOffset:h}=t,{column:w,columnOffset:f,row:S,rowOffset:C}=r,R=e.attachRangeWithCoord({startColumn:u,endColumn:u,startRow:l,endRow:l});if(R==null)return;const I=e.attachRangeWithCoord({startColumn:w,endColumn:w,startRow:S,endRow:S});if(I==null)return;const{startX:M,startY:D}=R,{startX:b,startY:v}=I;let A=j.precisionTo(M+c,1),P=j.precisionTo(D+h,1),T=j.precisionTo(b+f-A,1),E=j.precisionTo(v+C-P,1);R.startX===I.endX&&(T=0),R.startY===I.endY&&(E=0);const O=n.getCurrentSkeleton(),y=O.rowHeaderWidth+O.columnTotalWidth,U=O.columnHeaderHeight+O.rowTotalHeight;return A+T>y&&(A=y-T),P+E>U&&(P=U-E),{flipY:o,flipX:s,angle:a,skewX:d,skewY:g,left:A,top:P,width:T,height:E}}function W(i,e){const{left:n=0,top:t=0,width:r=0,height:o=0,flipY:s=!1,flipX:a=!1,angle:d=0,skewX:g=0,skewY:u=0}=i,c=e.getSelectionCellByPosition(n,t);if(c==null)return;const l={column:c.actualColumn,columnOffset:j.precisionTo(n-c.startX,1),row:c.actualRow,rowOffset:j.precisionTo(t-c.startY,1)},h=e.getSelectionCellByPosition(n+r,t+o);if(h==null)return;const w={column:h.actualColumn,columnOffset:j.precisionTo(n+r-h.startX,1),row:h.actualRow,rowOffset:j.precisionTo(t+o-h.startY,1)};return{flipY:s,flipX:a,angle:d,skewX:g,skewY:u,from:l,to:w}}var it=Object.defineProperty,ot=Object.getOwnPropertyDescriptor,st=(i,e,n,t)=>{for(var r=t>1?void 0:t?ot(e,n):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(t?s(e,n,r):s(r))||r);return t&&r&&it(e,n,r),r},H=(i,e)=>(n,t)=>e(n,t,i);let Se=class extends p.Disposable{constructor(i,e,n,t,r,o,s,a,d,g,u,c,l){super(),this._context=i,this._commandService=e,this._univerInstanceService=n,this._selectionManagerService=t,this._selectionRenderService=r,this._imageIoService=o,this._sheetDrawingService=s,this._drawingManagerService=a,this._contextService=d,this._messageService=g,this._localeService=u,this._renderManagerService=c,this._sheetSkeletonManagerService=l,this._init()}_init(){this._initCommandListeners(),this._updateImageListener(),this._updateOrderListener(),this._groupDrawingListener(),this._focusDrawingListener(),this._drawingAddListener()}_initCommandListeners(){this.disposeWithMe(this._commandService.onCommandExecuted(async i=>{if(i.id===de.id||i.id===le.id){const e=i.params;if(e.files==null)return;const n=e.files.length;if(n>N.DRAWING_IMAGE_COUNT_LIMIT){this._messageService.show({type:Q.MessageType.Error,content:this._localeService.t("update-status.exceedMaxCount",String(N.DRAWING_IMAGE_COUNT_LIMIT))});return}this._imageIoService.setWaitCount(n),i.id===de.id?e.files.forEach(async t=>{await this._insertCellImage(t)}):e.files.forEach(async t=>{await this._insertFloatImage(t)})}}))}async _insertCellImage(i){}async _insertFloatImage(i){let e;try{e=await this._imageIoService.saveImage(i)}catch(R){const I=R.message;I===N.ImageUploadStatusType.ERROR_EXCEED_SIZE?this._messageService.show({type:Q.MessageType.Error,content:this._localeService.t("update-status.exceedMaxSize",String(N.DRAWING_IMAGE_ALLOW_SIZE/(1024*1024)))}):I===N.ImageUploadStatusType.ERROR_IMAGE_TYPE?this._messageService.show({type:Q.MessageType.Error,content:this._localeService.t("update-status.invalidImageType")}):I===N.ImageUploadStatusType.ERROR_IMAGE&&this._messageService.show({type:Q.MessageType.Error,content:this._localeService.t("update-status.invalidImage")})}if(e==null)return;const n=this._getUnitInfo();if(n==null)return;const{unitId:t,subUnitId:r}=n,{imageId:o,imageSourceType:s,source:a,base64Cache:d}=e,{width:g,height:u,image:c}=await N.getImageSize(d||""),l=this._renderManagerService.getRenderById(t);if(l==null)return;const{width:h,height:w}=l.scene;this._imageIoService.addImageSourceCache(a,s,c);let f=1;if(g>N.DRAWING_IMAGE_WIDTH_LIMIT||u>N.DRAWING_IMAGE_HEIGHT_LIMIT){const R=N.DRAWING_IMAGE_WIDTH_LIMIT/g,I=N.DRAWING_IMAGE_HEIGHT_LIMIT/u;f=Math.max(R,I)}const S=this._getImagePosition(g*f,u*f,h,w);if(S==null)return;const C={unitId:t,subUnitId:r,drawingId:o,drawingType:N.DrawingTypeEnum.DRAWING_IMAGE,imageSourceType:s,source:a,transform:x(S,this._selectionRenderService,this._sheetSkeletonManagerService),sheetTransform:S};this._commandService.executeCommand(Re.id,{unitId:t,drawings:[C]})}_getUnitInfo(){const i=this._univerInstanceService.getCurrentUnitForType(p.UniverInstanceType.UNIVER_SHEET);if(i==null)return;const e=i.getActiveSheet();if(e==null)return;const n=i.getUnitId(),t=e.getSheetId();return{unitId:n,subUnitId:t}}_getImagePosition(i,e,n,t){const r=this._selectionManagerService.getSelections();let o={startRow:0,endRow:0,startColumn:0,endColumn:0};r&&r.length>0&&(o=r[r.length-1].range);const s=this._selectionRenderService.attachRangeWithCoord(o);if(s==null)return;let{startColumn:a,startRow:d,startX:g,startY:u}=s,c=!1;if(g+i>n&&(g=n-i,g<0&&(g=0,i=n),c=!0),u+e>t&&(u=t-e,u<0&&(u=0,e=t),c=!0),c){const f=this._selectionRenderService.getSelectionCellByPosition(g,u);if(f==null)return;g=f.startX,u=f.startY,a=f.actualColumn,d=f.actualRow}const l={column:a,columnOffset:0,row:d,rowOffset:0},h=this._selectionRenderService.getSelectionCellByPosition(g+i,u+e);if(h==null)return;const w={column:h.actualColumn,columnOffset:g+i-h.startX,row:h.actualRow,rowOffset:u+e-h.startY};return{from:l,to:w}}_updateOrderListener(){this._drawingManagerService.featurePluginOrderUpdate$.subscribe(i=>{const{unitId:e,subUnitId:n,drawingIds:t,arrangeType:r}=i;this._commandService.executeCommand(Pe.id,{unitId:e,subUnitId:n,drawingIds:t,arrangeType:r})})}_updateImageListener(){this._drawingManagerService.featurePluginUpdate$.subscribe(i=>{const e=[];i.length!==0&&(i.forEach(n=>{const{unitId:t,subUnitId:r,drawingId:o,drawingType:s,transform:a}=n;if(a==null)return;const d=this._sheetDrawingService.getDrawingByParam({unitId:t,subUnitId:r,drawingId:o});if(d==null)return;const g=W({...d.transform,...a},this._selectionRenderService);if(g==null)return;const u={...n,transform:{...d.transform,...a,...x(g,this._selectionRenderService,this._sheetSkeletonManagerService)},sheetTransform:{...g}};e.push(u)}),e.length>0&&this._commandService.executeCommand(ue.id,{unitId:i[0].unitId,drawings:e}))})}_groupDrawingListener(){this._drawingManagerService.featurePluginGroupUpdate$.subscribe(i=>{this._commandService.executeCommand(Ae.id,i);const{unitId:e,subUnitId:n,drawingId:t}=i[0].parent;this._drawingManagerService.focusDrawing([{unitId:e,subUnitId:n,drawingId:t}])}),this._drawingManagerService.featurePluginUngroupUpdate$.subscribe(i=>{this._commandService.executeCommand(Ue.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 t=this._sheetDrawingService.getDrawingByParam(n);if(t==null)return;const{sheetTransform:r}=t;t.transform=x(r,this._selectionRenderService,this._sheetSkeletonManagerService)});const e=i[0].unitId;this._drawingManagerService.registerDrawingData(e,this._sheetDrawingService.getDrawingDataForUnit(e)),this._drawingManagerService.initializeNotification(e)}};Se=st([p.OnLifecycle(p.LifecycleStages.Rendered,Se),H(1,p.ICommandService),H(2,p.IUniverInstanceService),H(3,$.Inject(_.SelectionManagerService)),H(4,B.ISelectionRenderService),H(5,N.IImageIoService),H(6,m.ISheetDrawingService),H(7,N.IDrawingManagerService),H(8,p.IContextService),H(9,V.IMessageService),H(10,$.Inject(p.LocaleService)),H(11,j.IRenderManagerService),H(12,$.Inject(B.SheetSkeletonManagerService))],Se);var k=function(){return k=Object.assign||function(i){for(var e,n=1,t=arguments.length;n<t;n++){e=arguments[n];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(i[r]=e[r])}return i},k.apply(this,arguments)},at=function(i,e){var n={};for(var t in i)Object.prototype.hasOwnProperty.call(i,t)&&e.indexOf(t)<0&&(n[t]=i[t]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,t=Object.getOwnPropertySymbols(i);r<t.length;r++)e.indexOf(t[r])<0&&Object.prototype.propertyIsEnumerable.call(i,t[r])&&(n[t[r]]=i[t[r]]);return n},We=L.forwardRef(function(i,e){var n=i.icon,t=i.id,r=i.className,o=i.extend,s=at(i,["icon","id","className","extend"]),a="univerjs-icon univerjs-icon-".concat(t," ").concat(r||"").trim(),d=L.useRef("_".concat(lt()));return Be(n,"".concat(t),{defIds:n.defIds,idSuffix:d.current},k({ref:e,className:a},s),o)});function Be(i,e,n,t,r){return L.createElement(i.tag,k(k({key:e},ct(i,n,r)),t),(dt(i,n).children||[]).map(function(o,s){return Be(o,"".concat(e,"-").concat(i.tag,"-").concat(s),n,void 0,r)}))}function ct(i,e,n){var t=k({},i.attrs);n!=null&&n.colorChannel1&&t.fill==="colorChannel1"&&(t.fill=n.colorChannel1);var r=e.defIds;return!r||r.length===0||(i.tag==="use"&&t["xlink:href"]&&(t["xlink:href"]=t["xlink:href"]+e.idSuffix),Object.entries(t).forEach(function(o){var s=o[0],a=o[1];typeof a=="string"&&(t[s]=a.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),t}function dt(i,e){var n,t=e.defIds;return!t||t.length===0?i:i.tag==="defs"&&(!((n=i.children)===null||n===void 0)&&n.length)?k(k({},i),{children:i.children.map(function(r){return typeof r.attrs.id=="string"&&t&&t.indexOf(r.attrs.id)>-1?k(k({},r),{attrs:k(k({},r.attrs),{id:r.attrs.id+e.idSuffix})}):r})}):i}function lt(){return Math.random().toString(36).substring(2,8)}We.displayName="UniverIcon";var ut={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"}}]},$e=L.forwardRef(function(i,e){return L.createElement(We,Object.assign({},i,{id:"add-image-single",ref:e,icon:ut}))});$e.displayName="AddImageSingle";const gt="univer-upload-file-menu",ht="univer-upload-file-menu-input",Le={uploadFileMenu:gt,uploadFileMenuInput:ht},Ge="COMPONENT_UPLOAD_FILE_MENU";var Ie=(i=>(i[i.cellImage=0]="cellImage",i[i.floatImage=1]="floatImage",i))(Ie||{});const mt=i=>{const{type:e}=i,n=J.useDependency(p.ICommandService),t=L.useRef(null),r=()=>{var a;(a=t.current)==null||a.click()},o=N.DRAWING_IMAGE_ALLOW_IMAGE_LIST.map(a=>`.${a.replace("image/","")}`).join(","),s=a=>{const d=a.target.files;if(d==null)return;const g=Array.from(d);e===Ie.floatImage?n.executeCommand(le.id,{files:g}):e===Ie.cellImage&&n.executeCommand(de.id,{files:g}),t.current&&(t.current.value="")};return L.createElement("div",{onClick:r,className:Le.uploadFileMenu},L.createElement("input",{type:"file",className:Le.uploadFileMenuInput,ref:t,onChange:s,accept:o,multiple:!0}))},Ve="addition-and-subtraction-single",Ye="sheet.menu.image";function pt(i){return{id:Ye,type:V.MenuItemType.SUBITEMS,positions:[V.MenuPosition.TOOLBAR_START],group:V.MenuGroup.TOOLBAR_FORMULAS_INSERT,icon:Ve,tooltip:"sheetImage.title",hidden$:V.getMenuHiddenObservable(i,p.UniverInstanceType.UNIVER_SHEET),disabled$:B.getCurrentRangeDisable$(i,{workbookTypes:[_.WorkbookEditablePermission],worksheetTypes:[_.WorksheetEditPermission],rangeTypes:[_.RangeProtectionPermissionEditPoint]})}}function ft(i){return{id:le.id,title:"sheetImage.upload.float",type:V.MenuItemType.SELECTOR,label:{name:Ge,props:{type:Ie.floatImage}},positions:[Ye],hidden$:V.getMenuHiddenObservable(i,p.UniverInstanceType.UNIVER_SHEET)}}const wt="univer-image-common-panel",St="univer-image-common-panel-grid",vt="univer-image-common-panel-border",_t="univer-image-common-panel-title",Dt="univer-image-common-panel-row",Ct="univer-image-common-panel-row-vertical",It="univer-image-common-panel-column",yt="univer-image-common-panel-column-center",Rt="univer-image-common-panel-inline",Mt="univer-image-common-panel-span2",Tt="univer-image-common-panel-span3",Ot="univer-image-common-panel-input",Et="univer-sheet-image-menu",bt="univer-sheet-image-menu-input",Z={imageCommonPanel:wt,imageCommonPanelGrid:St,imageCommonPanelBorder:vt,imageCommonPanelTitle:_t,imageCommonPanelRow:Dt,imageCommonPanelRowVertical:Ct,imageCommonPanelColumn:It,imageCommonPanelColumnCenter:yt,imageCommonPanelInline:Rt,imageCommonPanelSpan2:Mt,imageCommonPanelSpan3:Tt,imageCommonPanelInput:Ot,sheetImageMenu:Et,sheetImageMenuInput:bt},Pt=i=>{var I;const e=J.useDependency(p.ICommandService),n=J.useDependency(p.LocaleService),t=J.useDependency(N.IDrawingManagerService),r=J.useDependency(j.IRenderManagerService),{drawings:o}=i,s=o[0];if(s==null)return;const{unitId:a}=s,d=r.getRenderById(a),g=d==null?void 0:d.scene;if(g==null)return;const u=g.getTransformerByCreate(),[c,l]=L.useState(!0),h=(I=s.anchorType)!=null?I:m.SheetDrawingAnchorType.Position,[w,f]=L.useState(h);function S(M,D){const b=[];return M.forEach(v=>{const{oKey:A}=v,P=D.getDrawingOKey(A);if(P==null)return b.push(null),!0;const{unitId:T,subUnitId:E,drawingId:O,drawingType:y,anchorType:U,sheetTransform:F}=P;b.push({unitId:T,subUnitId:E,drawingId:O,anchorType:U,sheetTransform:F,drawingType:y})}),b}L.useEffect(()=>{const M=u.clearControl$.subscribe(b=>{b===!0&&l(!1)}),D=u.changeStart$.subscribe(b=>{var P;const{objects:v}=b,A=S(v,t);if(A.length===0)l(!1);else if(A.length>=1){l(!0);const T=((P=A[0])==null?void 0:P.anchorType)||m.SheetDrawingAnchorType.Position;f(T)}});return()=>{D.unsubscribe(),M.unsubscribe()}},[]);function C(M){f(M);const D=t.getFocusDrawings();if(D.length===0)return;const b=D.map(v=>({unitId:v.unitId,subUnitId:v.subUnitId,drawingId:v.drawingId,anchorType:M}));e.executeCommand(ue.id,{unitId:D[0].unitId,drawings:b})}const R=M=>M?"block":"none";return L.createElement("div",{className:he(Z.imageCommonPanelGrid,Z.imageCommonPanelBorder),style:{display:R(c)}},L.createElement("div",{className:Z.imageCommonPanelRow},L.createElement("div",{className:he(Z.imageCommonPanelColumn,Z.imageCommonPanelTitle)},L.createElement("div",null,n.t("drawing-anchor.title")))),L.createElement("div",{className:he(Z.imageCommonPanelRow)},L.createElement("div",{className:he(Z.imageCommonPanelColumn)},L.createElement(Q.RadioGroup,{value:w,onChange:C,direction:"vertical"},L.createElement(Q.Radio,{value:m.SheetDrawingAnchorType.Both},n.t("drawing-anchor.both")),L.createElement(Q.Radio,{value:m.SheetDrawingAnchorType.Position},n.t("drawing-anchor.position")),L.createElement(Q.Radio,{value:m.SheetDrawingAnchorType.None},n.t("drawing-anchor.none"))))))},At=()=>{const i=J.useDependency(N.IDrawingManagerService),e=i.getFocusDrawings(),[n,t]=L.useState(e);return L.useEffect(()=>{const r=i.focus$.subscribe(o=>{t(o)});return()=>{r.unsubscribe()}},[]),!!(n!=null&&n.length)&&L.createElement("div",{className:Z.imageCommonPanel},L.createElement(re.DrawingCommonPanel,{drawings:n}),L.createElement(Pt,{drawings:n}))},ie={id:"sheet.command.move-drawing",type:p.CommandType.COMMAND,handler:(i,e)=>{const n=i.get(p.ICommandService),t=i.get(m.ISheetDrawingService),r=i.get(B.ISelectionRenderService),{direction:o}=e,s=t.getFocusDrawings();if(s.length===0)return!1;const a=s[0].unitId,d=s.map(u=>{const{transform:c}=u;if(c==null)return null;const l={...c},{left:h=0,top:w=0}=c;return o===p.Direction.UP?l.top=w-1:o===p.Direction.DOWN?l.top=w+1:o===p.Direction.LEFT?l.left=h-1:o===p.Direction.RIGHT&&(l.left=h+1),{...u,transform:l,sheetTransform:W(l,r)}}).filter(u=>u!=null);return n.syncExecuteCommand(ue.id,{unitId:a,drawings:d})?(n.syncExecuteCommand(G.id,[a]),!0):!1}},Ne={id:"sheet.command.delete-drawing",type:p.CommandType.COMMAND,handler:i=>{const e=i.get(p.ICommandService),t=i.get(m.ISheetDrawingService).getFocusDrawings();if(t.length===0)return!1;const r=t[0].unitId,o=t.map(s=>{const{unitId:a,subUnitId:d,drawingId:g,drawingType:u}=s;return{unitId:a,subUnitId:d,drawingId:g,drawingType:u}});return e.executeCommand(ye.id,{unitId:r,drawings:o})}};function ge(i){return!i.getContextValue(p.FOCUSING_FORMULA_EDITOR)&&!i.getContextValue(p.EDITOR_ACTIVATED)&&i.getContextValue(p.FOCUSING_COMMON_DRAWINGS)}const Ut={id:ie.id,description:"shortcut.sheet.drawing-move-down",group:"4_sheet-drawing-view",binding:V.KeyCode.ARROW_DOWN,priority:100,preconditions:ge,staticParameters:{direction:p.Direction.DOWN}},Nt={id:ie.id,description:"shortcut.sheet.drawing-move-up",group:"4_sheet-drawing-view",binding:V.KeyCode.ARROW_UP,priority:100,preconditions:ge,staticParameters:{direction:p.Direction.UP}},Lt={id:ie.id,description:"shortcut.sheet.drawing-move-left",group:"4_sheet-drawing-view",binding:V.KeyCode.ARROW_LEFT,priority:100,preconditions:ge,staticParameters:{direction:p.Direction.LEFT}},jt={id:ie.id,description:"shortcut.sheet.drawing-move-right",group:"4_sheet-drawing-view",binding:V.KeyCode.ARROW_RIGHT,priority:100,preconditions:ge,staticParameters:{direction:p.Direction.RIGHT}},Wt={id:Ne.id,description:"shortcut.sheet.drawing-delete",group:"4_sheet-drawing-view",preconditions:ge,binding:V.KeyCode.DELETE,mac:V.KeyCode.BACKSPACE};var Bt=Object.defineProperty,$t=Object.getOwnPropertyDescriptor,Gt=(i,e,n,t)=>{for(var r=t>1?void 0:t?$t(e,n):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(t?s(e,n,r):s(r))||r);return t&&r&&Bt(e,n,r),r},se=(i,e)=>(n,t)=>e(n,t,i);const Vt={};let ce=class extends p.Disposable{constructor(i,e,n,t,r,o){super(),this._config=i,this._injector=e,this._componentManager=n,this._menuService=t,this._commandService=r,this._shortcutService=o,this._init()}_initCustomComponents(){const i=this._componentManager;this.disposeWithMe(i.register(Ve,$e)),this.disposeWithMe(i.register(Ge,mt)),this.disposeWithMe(i.register(je,At))}_initMenus(){const{menu:i={}}=this._config;[pt,ft].forEach(e=>{this._menuService.addMenuItem(e(this._injector),i)})}_initCommands(){[le,de,Re,ye,ue,Ee,G,be,Ae,Ue,ie,Ne,Pe].forEach(i=>this.disposeWithMe(this._commandService.registerCommand(i)))}_initShortcuts(){[Ut,Nt,Lt,jt,Wt].forEach(i=>{this.disposeWithMe(this._shortcutService.registerShortcut(i))})}_init(){this._initCommands(),this._initCustomComponents(),this._initMenus(),this._initShortcuts()}};ce=Gt([p.OnLifecycle(p.LifecycleStages.Rendered,ce),se(1,$.Inject($.Injector)),se(2,$.Inject(V.ComponentManager)),se(3,V.IMenuService),se(4,p.ICommandService),se(5,V.IShortcutService)],ce);var Yt=Object.defineProperty,Ft=Object.getOwnPropertyDescriptor,Xt=(i,e,n,t)=>{for(var r=t>1?void 0:t?Ft(e,n):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(t?s(e,n,r):s(r))||r);return t&&r&&Yt(e,n,r),r},te=(i,e)=>(n,t)=>e(n,t,i);const xt=[_.InsertRowCommand.id,_.InsertColCommand.id,_.RemoveRowCommand.id,_.RemoveColCommand.id,_.DeleteRangeMoveLeftCommand.id,_.DeleteRangeMoveUpCommand.id,_.InsertRangeMoveDownCommand.id,_.InsertRangeMoveRightCommand.id,_.DeltaRowHeightCommand.id,_.SetRowHeightCommand.id,_.DeltaColumnWidthCommand.id,_.SetColWidthCommand.id,_.SetRowHiddenCommand.id,_.SetSpecificRowsVisibleCommand.id,_.SetSpecificColsVisibleCommand.id,_.SetColHiddenCommand.id,_.MoveRangeCommand.id],Ht=[_.SetRowVisibleMutation.id,_.SetRowHiddenMutation.id,_.SetColVisibleMutation.id,_.SetColHiddenMutation.id,_.SetWorksheetRowHeightMutation.id,_.SetWorksheetColWidthMutation.id];let ve=class extends p.Disposable{constructor(i,e,n,t,r,o,s,a){super(),this._context=i,this._commandService=e,this._sheetInterceptorService=n,this._sheetDrawingService=t,this._drawingManagerService=r,this._selectionRenderService=o,this._univerInstanceService=s,this._sheetSkeletonManagerService=a,this._init()}_init(){this._sheetInterceptorListener(),this._commandListener(),this._sheetRefreshListener()}_sheetInterceptorListener(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:i=>{if(!xt.includes(i.id))return{redos:[],undos:[]};if(i.params==null)return{redos:[],undos:[]};const e=i.id;if(e===_.InsertRowCommand.id)return this._moveRowInterceptor(i.params,"insert");if(e===_.InsertColCommand.id)return this._moveColInterceptor(i.params,"insert");if(e===_.RemoveRowCommand.id)return this._moveRowInterceptor(i.params,"remove");if(e===_.RemoveColCommand.id)return this._moveColInterceptor(i.params,"remove");if(e===_.MoveRangeCommand.id)return this._moveRangeInterceptor(i.params);if(e===_.DeleteRangeMoveLeftCommand.id){const{range:n}=i.params;return this._getRangeMoveUndo(n,0)}else if(e===_.DeleteRangeMoveUpCommand.id){const{range:n}=i.params;return this._getRangeMoveUndo(n,1)}else if(e===_.InsertRangeMoveDownCommand.id){const{range:n}=i.params;return this._getRangeMoveUndo(n,2)}else if(e===_.InsertRangeMoveRightCommand.id){const{range:n}=i.params;return this._getRangeMoveUndo(n,3)}else if(e===_.SetRowHiddenCommand.id||e===_.SetSpecificRowsVisibleCommand.id){const n=i.params,{unitId:t,subUnitId:r,ranges:o}=n;return this._getDrawingUndoForRowVisible(t,r,o)}else if(e===_.SetSpecificColsVisibleCommand.id||e===_.SetColHiddenCommand.id){const n=i.params,{unitId:t,subUnitId:r,ranges:o}=n;return this._getDrawingUndoForColVisible(t,r,o)}else if(e===_.DeltaRowHeightCommand.id||e===_.SetRowHeightCommand.id||e===_.DeltaColumnWidthCommand.id||e===_.SetColWidthCommand.id){const n=i.params,{unitId:t,subUnitId:r,ranges:o}=n,s=e===_.DeltaRowHeightCommand.id||e===_.SetRowHeightCommand.id;return this._getDrawingUndoForRowAndColSize(t,r,o,s)}return{redos:[],undos:[]}}}))}_getRangeMoveUndo(i,e){const n=_.getSheetCommandTarget(this._univerInstanceService);if(n==null)return{redos:[],undos:[]};const t=n.unitId,r=n.subUnitId,o=[],s=[],a=this._sheetDrawingService.getDrawingData(t,r),d=[],g=[];if(Object.keys(a).forEach(u=>{const c=a[u],{updateDrawings:l,deleteDrawings:h}=this._getUpdateOrDeleteDrawings(i,e,c);d.push(...l),g.push(...h)}),d.length===0&&g.length===0)return{redos:[],undos:[]};if(d.length>0){const u=this._sheetDrawingService.getBatchUpdateOp(d),{undo:c,redo:l,objects:h}=u;o.push({id:m.SetDrawingApplyMutation.id,params:{unitId:t,subUnitId:r,op:l,objects:h,type:m.DrawingApplyType.UPDATE}}),s.push({id:m.SetDrawingApplyMutation.id,params:{unitId:t,subUnitId:r,op:c,objects:h,type:m.DrawingApplyType.UPDATE}})}if(g.length>0){const u=this._sheetDrawingService.getBatchRemoveOp(g),c=u.undo,l=u.redo,h=u.objects;o.push({id:m.SetDrawingApplyMutation.id,params:{unitId:t,subUnitId:r,op:l,objects:h,type:m.DrawingApplyType.REMOVE}}),s.push({id:m.SetDrawingApplyMutation.id,params:{unitId:t,subUnitId:r,op:c,objects:h,type:m.DrawingApplyType.INSERT}})}return o.push({id:G.id,params:[t]}),s.push({id:G.id,params:[t]}),{redos:o,undos:s}}_getUpdateOrDeleteDrawings(i,e,n){const t=[],r=[],{sheetTransform:o,anchorType:s=m.SheetDrawingAnchorType.Position,transform:a,unitId:d,subUnitId:g,drawingId:u}=n,{from:c,to:l}=o,{row:h,column:w}=c,{row:f,column:S}=l;if(o==null||a==null)return{updateDrawings:t,deleteDrawings:r};const{startRow:C,endRow:R,startColumn:I,endColumn:M}=i;let D=null,b=null;if(e===0&&h>=C&&f<=R)if(w>=I&&S<=M)r.push({unitId:d,subUnitId:g,drawingId:u});else{const v=this._shrinkCol(o,a,I,M,s);D=v==null?void 0:v.newSheetTransform,b=v==null?void 0:v.newTransform}else if(e===1&&w>=I&&S<=M)if(h>=C&&f<=R)r.push({unitId:d,subUnitId:g,drawingId:u});else{const v=this._shrinkRow(o,a,C,R,s);D=v==null?void 0:v.newSheetTransform,b=v==null?void 0:v.newTransform}else if(e===2){const v=this._expandRow(o,a,C,R,s);D=v==null?void 0:v.newSheetTransform,b=v==null?void 0:v.newTransform}else if(e===3){const v=this._expandCol(o,a,I,M,s);D=v==null?void 0:v.newSheetTransform,b=v==null?void 0:v.newTransform}if(D!=null&&b!=null){const v=x(D,this._selectionRenderService,this._sheetSkeletonManagerService);t.push({...n,sheetTransform:D,transform:v})}return{updateDrawings:t,deleteDrawings:r}}_remainDrawingSize(i,e,n){const t=W({...i},this._selectionRenderService);t!=null&&e.push({...n,sheetTransform:t})}_getDrawingUndoForColVisible(i,e,n){const t=this._drawingManagerService.getDrawingData(i,e),r=[],o=[];if(Object.keys(t).forEach(u=>{const c=t[u],{sheetTransform:l,transform:h,anchorType:w=m.SheetDrawingAnchorType.Position}=c;if(w===m.SheetDrawingAnchorType.None)this._remainDrawingSize(h,r,c);else{const{from:f,to:S}=l,{row:C,column:R}=f,{row:I,column:M}=S;for(let D=0;D<n.length;D++){const b=n[D],{startRow:v,endRow:A,startColumn:P,endColumn:T}=b;if(M<P)continue;if(w===m.SheetDrawingAnchorType.Position){let y=null,U=null;if(R>=P&&R<=T){const F=this._selectionRenderService.attachRangeWithCoord({startColumn:R,endColumn:T,startRow:f.row,endRow:S.row});if(F==null)return;U={...h,left:F.startX}}if(U!=null&&(y=W(U,this._selectionRenderService),y!=null&&U!=null)){r.push({...c,sheetTransform:y,transform:U});break}this._remainDrawingSize(h,r,c);continue}if(R>=P&&M<=T)continue;let E=null,O=null;if(R>=P&&R<=T){const y=this._selectionRenderService.attachRangeWithCoord({startColumn:R,endColumn:T,startRow:f.row,endRow:S.row});if(y==null)return;O={...h,left:(y==null?void 0:y.startX)||0,width:((h==null?void 0:h.width)||0)-y.endX+y.startX}}else if(M>=P&&M<=T){const y=this._selectionRenderService.attachRangeWithCoord({startColumn:P,endColumn:M,startRow:f.row,endRow:S.row});if(y==null)return;O={...h,left:y.startX-((h==null?void 0:h.width)||0)}}else{const y=this._selectionRenderService.attachRangeWithCoord({startColumn:P,endColumn:T,startRow:f.row,endRow:S.row});if(y==null)return;if(O={...h,width:((h==null?void 0:h.width)||0)-y.endX+y.startX},E=W(O,this._selectionRenderService),E!=null&&O!=null){o.push({...c,sheetTransform:E,transform:O});break}}if(O!=null&&(E=W(O,this._selectionRenderService)),O!=null&&E!=null){r.push({...c,sheetTransform:E,transform:O});break}else this._remainDrawingSize(h,r,c)}}}),r.length===0&&o.length===0)return{redos:[],undos:[]};const{redos:s,undos:a}=this._createUndoAndRedoMutation(i,e,r),d=[],g=[];if(o.length>0){const{redos:u,undos:c}=this._createUndoAndRedoMutation(i,e,o);d.push(...u),g.push(...c)}return{redos:s,undos:a,preRedos:d,preUndos:g}}_createUndoAndRedoMutation(i,e,n){const t=this._sheetDrawingService.getBatchUpdateOp(n),{undo:r,redo:o,objects:s}=t,a=[{id:m.SetDrawingApplyMutation.id,params:{unitId:i,subUnitId:e,op:o,objects:s,type:m.DrawingApplyType.UPDATE}},{id:G.id,params:[i]}],d=[{id:m.SetDrawingApplyMutation.id,params:{unitId:i,subUnitId:e,op:r,objects:s,type:m.DrawingApplyType.UPDATE}},{id:G.id,params:[i]}];return{redos:a,undos:d}}_getDrawingUndoForRowVisible(i,e,n){const t=this._drawingManagerService.getDrawingData(i,e),r=[],o=[];if(Object.keys(t).forEach(u=>{const c=t[u],{sheetTransform:l,transform:h,anchorType:w=m.SheetDrawingAnchorType.Position}=c;if(w===m.SheetDrawingAnchorType.None)this._remainDrawingSize(h,r,c);else{const{from:f,to:S}=l,{row:C,column:R}=f,{row:I,column:M}=S;for(let D=0;D<n.length;D++){const b=n[D],{startRow:v,endRow:A,startColumn:P,endColumn:T}=b;if(I<v)continue;if(w===m.SheetDrawingAnchorType.Position){let y=null,U=null;if(C>=v&&C<=A){const F=this._selectionRenderService.attachRangeWithCoord({startColumn:f.column,endColumn:S.column,startRow:C,endRow:A});if(F==null)return;U={...h,top:F.startY}}if(U!=null&&(y=W(U,this._selectionRenderService),y!=null&&U!=null)){r.push({...c,sheetTransform:y,transform:U});break}this._remainDrawingSize(h,r,c);continue}if(C>=v&&I<=A)continue;let E=null,O=null;if(C>=v&&C<=A){const y=this._selectionRenderService.attachRangeWithCoord({startColumn:f.column,endColumn:S.column,startRow:C,endRow:A});if(y==null)return;O={...h,top:(y==null?void 0:y.startY)||0,height:((h==null?void 0:h.height)||0)-y.endY+y.startY}}else if(I>=v&&I<=A){const y=this._selectionRenderService.attachRangeWithCoord({startColumn:f.column,endColumn:S.column,startRow:v,endRow:I});if(y==null)return;O={...h,top:y.startY-((h==null?void 0:h.height)||0)}}else{const y=this._selectionRenderService.attachRangeWithCoord({startColumn:f.column,endColumn:S.column,startRow:v,endRow:A});if(y==null)return;if(O={...h,height:((h==null?void 0:h.height)||0)-y.endY+y.startY},E=W(O,this._selectionRenderService),E!=null&&O!=null){o.push({...c,sheetTransform:E,transform:O});break}}if(O!=null&&(E=W(O,this._selectionRenderService)),O!=null&&E!=null){r.push({...c,sheetTransform:E,transform:O});break}else this._remainDrawingSize(h,r,c)}}}),r.length===0&&o.length===0)return{redos:[],undos:[]};const{redos:s,undos:a}=this._createUndoAndRedoMutation(i,e,r),d=[],g=[];if(o.length>0){const{redos:u,undos:c}=this._createUndoAndRedoMutation(i,e,o);d.push(...u),g.push(...c)}return{redos:s,undos:a,preRedos:d,preUndos:g}}_getDrawingUndoForRowAndColSize(i,e,n,t){const r=this._drawingManagerService.getDrawingData(i,e),o=[];return Object.keys(r).forEach(s=>{const a=r[s],{sheetTransform:d,transform:g,anchorType:u=m.SheetDrawingAnchorType.Position}=a;if(u===m.SheetDrawingAnchorType.None)this._remainDrawingSize(g,o,a);else{const{from:c,to:l}=d,{row:h,column:w}=c,{row:f,column:S}=l;for(let C=0;C<n.length;C++){const R=n[C],{startRow:I,endRow:M,startColumn:D,endColumn:b}=R;if(f<I||S<D)continue;if(u===m.SheetDrawingAnchorType.Position&&(h<=I&&f>=M||w<=D&&S>=b)){this._remainDrawingSize(g,o,a);continue}const v=x({...d},this._selectionRenderService,this._sheetSkeletonManagerService);if(v!=null){o.push({...a,transform:v});break}}}}),o.length===0?{redos:[],undos:[]}:this._createUndoAndRedoMutation(i,e,o)}_getUnitIdAndSubUnitId(i,e){let n,t;if(e==="insert")n=i.unitId,t=i.subUnitId;else{const r=_.getSheetCommandTarget(this._univerInstanceService);if(r==null)return;n=r.unitId,t=r.subUnitId}return{unitId:n,subUnitId:t}}_moveRowInterceptor(i,e){const n=this._getUnitIdAndSubUnitId(i,e);if(n==null)return{redos:[],undos:[]};const{unitId:t,subUnitId:r}=n,{range:o}=i,s=o.startRow,a=o.endRow,d=[],g=[],u=this._sheetDrawingService.getDrawingData(t,r),c=[],l=[];if(Object.keys(u).forEach(h=>{const w=u[h],{sheetTransform:f,transform:S,anchorType:C=m.SheetDrawingAnchorType.Position}=w;if(f==null||S==null)return;let R,I;if(e==="insert"){const D=this._expandRow(f,S,s,a,C);R=D==null?void 0:D.newSheetTransform,I=D==null?void 0:D.newTransform}else{const{from:D,to:b}=f,{row:v}=D,{row:A}=b;if(C===m.SheetDrawingAnchorType.Both&&v>=s&&A<=a)l.push({unitId:t,subUnitId:r,drawingId:h});else{const P=this._shrinkRow(f,S,s,a,C);R=P==null?void 0:P.newSheetTransform,I=P==null?void 0:P.newTransform}}if(!R||!I)return;const M={unitId:t,subUnitId:r,drawingId:h,transform:I,sheetTransform:R};c.push(M)}),c.length===0&&l.length===0)return{redos:[],undos:[]};if(c.length>0){const h=this._sheetDrawingService.getBatchUpdateOp(c),{undo:w,redo:f,objects:S}=h;d.push({id:m.SetDrawingApplyMutation.id,params:{unitId:t,subUnitId:r,op:f,objects:S,type:m.DrawingApplyType.UPDATE}}),g.push({id:m.SetDrawingApplyMutation.id,params:{unitId:t,subUnitId:r,op:w,objects:S,type:m.DrawingApplyType.UPDATE}})}if(l.length>0){const h=this._sheetDrawingService.getBatchRemoveOp(l),w=h.undo,f=h.redo,S=h.objects;d.push({id:m.SetDrawingApplyMutation.id,params:{unitId:t,subUnitId:r,op:f,objects:S,type:m.DrawingApplyType.REMOVE}}),g.push({id:m.SetDrawingApplyMutation.id,params:{unitId:t,subUnitId:r,op:w,objects:S,type:m.DrawingApplyType.INSERT}})}return d.push({id:G.id,params:[t]}),g.push({id:G.id,params:[t]}),{redos:d,undos:g}}_moveRangeInterceptor(i){const{fromRange:e,toRange:n}=i,t=_.getSheetCommandTarget(this._univerInstanceService);if(!t)return{redos:[],undos:[]};const{unitId:r,subUnitId:o}=t,s=this._sheetDrawingService.getDrawingData(r,o),a=[],d=this._selectionRenderService.attachRangeWithCoord(e),g=this._selectionRenderService.attachRangeWithCoord(n);if(!d||!g)return{redos:[],undos:[]};Object.keys(s).forEach(l=>{const h=s[l],{sheetTransform:w,transform:f,anchorType:S=m.SheetDrawingAnchorType.Position}=h;if(!w||!f||S===m.SheetDrawingAnchorType.None)return;const{left:C=0,top:R=0,width:I=0,height:M=0}=f,{drawingStartX:D,drawingEndX:b,drawingStartY:v,drawingEndY:A}={drawingStartX:C,drawingEndX:C+I,drawingStartY:R,drawingEndY:R+M};if(!(d.startX<=D&&b<=d.endX&&d.startY<=A&&v<=d.endY))return;const{to:T,from:E}=w,O=n.startRow-e.startRow,y=n.startColumn-e.startColumn;let U,F;if(S===m.SheetDrawingAnchorType.Both){const K=this._selectionRenderService.attachRangeWithCoord({startRow:T.row,endRow:E.row,startColumn:T.column,endColumn:E.column}),z=this._selectionRenderService.attachRangeWithCoord({startRow:T.row+O,endRow:E.row+O,startColumn:T.column+y,endColumn:E.column+y});if(!z||!K)return;const oe=z.endX-z.startX-(K.endX-K.startX),X=z.endY-z.startY-(K.endY-K.startY);U={to:{...T,row:T.row+O,column:T.column+y,columnOffset:T.columnOffset+oe},from:{...E,row:E.row+O,column:E.column+y,columnOffset:T.columnOffset+oe,rowOffset:T.rowOffset+X}},F=x(U,this._selectionRenderService,this._sheetSkeletonManagerService)}else{const K=g.startX-d.startX,z=g.startY-d.startY;F={...f,left:C+K,top:R+z},U=W(F,this._selectionRenderService)}if(!U||!F)return;const Me={unitId:r,subUnitId:o,drawingId:l,transform:F,sheetTransform:U};a.push(Me)});const u=[],c=[];if(a.length>0){const l=this._sheetDrawingService.getBatchUpdateOp(a),{undo:h,redo:w,objects:f}=l;u.push({id:m.SetDrawingApplyMutation.id,params:{unitId:r,subUnitId:o,op:w,objects:f,type:m.DrawingApplyType.UPDATE}}),c.push({id:m.SetDrawingApplyMutation.id,params:{unitId:r,subUnitId:o,op:h,objects:f,type:m.DrawingApplyType.UPDATE}})}return{redos:u,undos:c}}_moveColInterceptor(i,e){const n=this._getUnitIdAndSubUnitId(i,e);if(n==null)return{redos:[],undos:[]};const{unitId:t,subUnitId:r}=n,{range:o}=i,s=o.startColumn,a=o.endColumn,d=[],g=[],u=this._sheetDrawingService.getDrawingData(t,r),c=[],l=[];if(Object.keys(u).forEach(h=>{const w=u[h],{sheetTransform:f,transform:S,anchorType:C=m.SheetDrawingAnchorType.Position}=w;if(f==null||S==null)return;let R,I;if(e==="insert"){const D=this._expandCol(f,S,s,a,C);R=D==null?void 0:D.newSheetTransform,I=D==null?void 0:D.newTransform}else{const{from:D,to:b}=f,{column:v}=D,{column:A}=b;if(v>=s&&A<=a&&C===m.SheetDrawingAnchorType.Both)l.push({unitId:t,subUnitId:r,drawingId:h});else{const T=this._shrinkCol(f,S,s,a,C);R=T==null?void 0:T.newSheetTransform,I=T==null?void 0:T.newTransform}}if(!R||!I)return;const M={unitId:t,subUnitId:r,drawingId:h,transform:I,sheetTransform:R};c.push(M)}),c.length===0&&l.length===0)return{redos:[],undos:[]};if(c.length>0){const h=this._sheetDrawingService.getBatchUpdateOp(c),{undo:w,redo:f,objects:S}=h;d.push({id:m.SetDrawingApplyMutation.id,params:{unitId:t,subUnitId:r,op:f,objects:S,type:m.DrawingApplyType.UPDATE}}),g.push({id:m.SetDrawingApplyMutation.id,params:{unitId:t,subUnitId:r,op:w,objects:S,type:m.DrawingApplyType.UPDATE}})}if(l.length>0){const h=this._sheetDrawingService.getBatchRemoveOp(l),w=h.undo,f=h.redo,S=h.objects;d.push({id:m.SetDrawingApplyMutation.id,params:{unitId:t,subUnitId:r,op:f,objects:S,type:m.DrawingApplyType.REMOVE}}),g.push({id:m.SetDrawingApplyMutation.id,params:{unitId:t,subUnitId:r,op:w,objects:S,type:m.DrawingApplyType.INSERT}})}return d.push({id:G.id,params:[t]}),g.push({id:G.id,params:[t]}),{redos:d,undos:g}}_expandCol(i,e,n,t,r=m.SheetDrawingAnchorType.Position){const o=t-n+1,{from:s,to:a}=i,{column:d}=s,{column:g}=a;if(r===m.SheetDrawingAnchorType.None)return{newSheetTransform:W({...e},this._selectionRenderService),newTransform:e};let u=null,c=null;if(d>=n){const l=this._selectionRenderService.attachRangeWithCoord({startColumn:n,endColumn:t,startRow:s.row,endRow:a.row});if(l==null)return;c={...e,left:(e.left||0)+l.endX-l.startX},u=W(c,this._selectionRenderService)}else if(g>=t)if(r===m.SheetDrawingAnchorType.Both)u={from:{...s},to:{...a,column:g+o}},c=x(u,this._selectionRenderService,this._sheetSkeletonManagerService);else return{newSheetTransform:W({...e},this._selectionRenderService),newTransform:e};return u!=null&&c!=null?{newSheetTransform:u,newTransform:c}:null}_shrinkCol(i,e,n,t,r=m.SheetDrawingAnchorType.Position){const o=t-n+1,{from:s,to:a}=i,{column:d}=s,{column:g}=a;if(r===m.SheetDrawingAnchorType.None)return{newSheetTransform:W({...e},this._selectionRenderService),newTransform:e};let u=null,c=null;if(d>t){const l=this._selectionRenderService.attachRangeWithCoord({startColumn:n,endColumn:t,startRow:s.row,endRow:a.row});if(l==null)return;c={...e,left:(e.left||0)-(l.endX-l.startX)},u=W(c,this._selectionRenderService)}else if(d>=n&&g<=t){const l=this._selectionRenderService.attachRangeWithCoord({startColumn:n,endColumn:t,startRow:0,endRow:0});u={from:{...s,columnOffset:0},to:{...a,columnOffset:a.columnOffset-s.columnOffset}},c={...e,left:l==null?void 0:l.startX}}else if(d<n&&g>t)if(r===m.SheetDrawingAnchorType.Both)u={from:{...s},to:{...a,column:g-o}},c=x(u,this._selectionRenderService,this._sheetSkeletonManagerService);else return{newSheetTransform:W({...e},this._selectionRenderService),newTransform:e};else if(d>=n&&d<=t){if(d===n)c={...e,left:(e.left||0)-i.from.columnOffset};else{const l=this._selectionRenderService.attachRangeWithCoord({startColumn:n,endColumn:d-1,startRow:s.row,endRow:a.row});if(l==null)return;c={...e,left:(e.left||0)-l.endX+l.startX-i.from.columnOffset}}u=W(c,this._selectionRenderService)}else if(g>=n&&g<=t&&r===m.SheetDrawingAnchorType.Both){const l=this._selectionRenderService.attachRangeWithCoord({startColumn:n-1,endColumn:n-1,startRow:s.row,endRow:a.row});if(l==null)return;u={from:{...s},to:{...a,column:n-1,columnOffset:l.endX-l.startX}},c=x(u,this._selectionRenderService,this._sheetSkeletonManagerService)}return u!=null&&c!=null?{newSheetTransform:u,newTransform:c}:null}_expandRow(i,e,n,t,r=m.SheetDrawingAnchorType.Position){const o=t-n+1,{from:s,to:a}=i,{row:d}=s,{row:g}=a;if(r===m.SheetDrawingAnchorType.None)return{newSheetTransform:W({...e},this._selectionRenderService),newTransform:e};let u=null,c=null;if(d>=n){const l=this._selectionRenderService.attachRangeWithCoord({startRow:n,endRow:t,startColumn:s.column,endColumn:a.column});if(l==null)return;c={...e,top:(e.top||0)+l.endY-l.startY},u=W(c,this._selectionRenderService)}else if(g>=t)if(r===m.SheetDrawingAnchorType.Both)u={from:{...s},to:{...a,row:g+o}},c=x(u,this._selectionRenderService,this._sheetSkeletonManagerService);else return{newSheetTransform:W({...e},this._selectionRenderService),newTransform:e};return u!=null&&c!=null?{newSheetTransform:u,newTransform:c}:null}_shrinkRow(i,e,n,t,r=m.SheetDrawingAnchorType.Position){const o=t-n+1,{from:s,to:a}=i,{row:d}=s,{row:g}=a;if(r===m.SheetDrawingAnchorType.None)return{newSheetTransform:W({...e},this._selectionRenderService),newTransform:e};let u=null,c=null;if(d>t)u={from:{...s,row:d-o},to:{...a,row:g-o}},c=x(u,this._selectionRenderService,this._sheetSkeletonManagerService);else if(d>=n&&g<=t){const l=this._selectionRenderService.attachRangeWithCoord({startColumn:0,endColumn:0,startRow:n,endRow:t});u={from:{...s,rowOffset:0},to:{...a,rowOffset:a.rowOffset-s.rowOffset}},c={...e,top:l==null?void 0:l.startY}}else if(d<n&&g>t)if(r===m.SheetDrawingAnchorType.Both)u={from:{...s},to:{...a,row:g-o}},c=x(u,this._selectionRenderService,this._sheetSkeletonManagerService);else return{newSheetTransform:W({...e},this._selectionRenderService),newTransform:e};else if(d>=n&&d<=t){if(d===n)c={...e,top:(e.top||0)-i.from.rowOffset};else{const l=this._selectionRenderService.attachRangeWithCoord({startRow:n,endRow:d-1,startColumn:s.column,endColumn:a.column});if(l==null)return;c={...e,top:(e.top||0)-l.endY+l.startY-i.from.rowOffset}}u=W(c,this._selectionRenderService)}else if(g>=n&&g<=t&&r===m.SheetDrawingAnchorType.Both){const l=this._selectionRenderService.attachRangeWithCoord({startColumn:s.column,endColumn:s.column,startRow:n-1,endRow:n-1});if(l==null)return;u={from:{...s},to:{...a,row:n-1,rowOffset:l.endY-l.startY}},c=x(u,this._selectionRenderService,this._sheetSkeletonManagerService)}return u!=null&&c!=null?{newSheetTransform:u,newTransform:c}:null}_commandListener(){this.disposeWithMe(this._commandService.onCommandExecuted(i=>{i.id===_.SetWorksheetActiveOperation.id&&setTimeout(()=>{const e=i.params,{unitId:n,subUnitId:t}=e,r=this._drawingManagerService.drawingManagerData,o=[],s=[];Object.keys(r).forEach(a=>{const d=r[a];Object.keys(d).forEach(g=>{const u=d[g].data;u!=null&&Object.keys(u).forEach(c=>{if(a===n&&g===t){const l=u[c];l.transform=x(l.sheetTransform,this._selectionRenderService,this._sheetSkeletonManagerService),o.push(u[c])}else s.push(u[c])})})}),this._drawingManagerService.removeNotification(s),this._drawingManagerService.addNotification(o)},0)}))}_sheetRefreshListener(){this.disposeWithMe(this._commandService.onCommandExecuted(i=>{Ht.includes(i.id)&&requestIdleCallback(()=>{const e=i.params,{unitId:n,subUnitId:t,ranges:r}=e;this._refreshDrawingTransform(n,t,r)})}))}_refreshDrawingTransform(i,e,n){const t=this._drawingManagerService.getDrawingData(i,e),r=[];Object.keys(t).forEach(o=>{const s=t[o],{sheetTransform:a,anchorType:d=m.SheetDrawingAnchorType.Position}=s;if(d===m.SheetDrawingAnchorType.None)return!0;const{from:g,to:u}=a,{row:c,column:l}=g,{row:h,column:w}=u;for(let f=0;f<n.length;f++){const S=n[f],{startRow:C,endRow:R,startColumn:I,endColumn:M}=S;if(p.Rectangle.intersects({startRow:C,endRow:R,startColumn:I,endColumn:M},{startRow:c,endRow:h,startColumn:l,endColumn:w})||c>R||l>M){r.push({...s,transform:x(a,this._selectionRenderService,this._sheetSkeletonManagerService)});break}}}),r.length!==0&&(this._drawingManagerService.refreshTransform(r),this._commandService.syncExecuteCommand(G.id,[i]))}};ve=Xt([p.OnLifecycle(p.LifecycleStages.Rendered,ve),te(1,p.ICommandService),te(2,$.Inject(_.SheetInterceptorService)),te(3,m.ISheetDrawingService),te(4,N.IDrawingManagerService),te(5,B.ISelectionRenderService),te(6,p.IUniverInstanceService),te(7,$.Inject(B.SheetSkeletonManagerService))],ve);var kt=Object.defineProperty,Kt=Object.getOwnPropertyDescriptor,zt=(i,e,n,t)=>{for(var r=t>1?void 0:t?Kt(e,n):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(t?s(e,n,r):s(r))||r);return t&&r&&kt(e,n,r),r},ne=(i,e)=>(n,t)=>e(n,t,i);function qt(i,e,n,t){const{scaleX:r,scaleY:o}=e.getAncestorScale(),s=e.getViewport(j.SHEET_VIEWPORT_KEY.VIEW_MAIN),a={left:!0,top:!0};if(!s)return{...i,absolute:a};const{left:d,right:g,top:u,bottom:c}=i,l=t.getFreeze(),{startColumn:h,startRow:w,xSplit:f,ySplit:S}=l,C=n.getNoMergeCellPositionByIndexWithNoHeader(w-S,h-f),R=n.getNoMergeCellPositionByIndexWithNoHeader(w,h),{rowHeaderWidth:I,columnHeaderHeight:M}=n,D=R.startX-C.startX,b=R.startY-C.startY,{top:v,left:A,viewportScrollX:P,viewportScrollY:T}=s;let E,O;d<A?(a.left=!0,E=(D+I+(d-A))*r,O=Math.max(Math.min((D+I+(g-A))*r,(D+I)*r),(g-P)*r)):(a.left=!1,E=Math.max((d-P)*r,(D+I)*r),O=Math.max((g-P)*r,(D+I)*r));let y,U;return u<v?(a.top=!0,y=(b+M+(u-v))*o,U=Math.max(Math.min((b+M+(g-v))*o,(b+M)*o),(c-T)*o)):(a.top=!1,y=Math.max((u-T)*o,(b+M)*o),U=Math.max((c-T)*o,(b+M)*o)),{left:E,right:O,top:y,bottom:U,absolute:a}}const Te=(i,e,n,t)=>{const{scene:r}=e,{left:o,top:s,width:a,height:d,angle:g}=i,u={left:o,right:o+a,top:s,bottom:s+d},c=qt(u,r,n,t);return{startX:c.left,endX:c.right,startY:c.top,endY:c.bottom,rotate:g,width:a,height:d,absolute:c.absolute}};exports.SheetCanvasFloatDomManagerService=class extends p.Disposable{constructor(n,t,r,o,s,a,d){super();q(this,"_domLayerMap",new Map);q(this,"_domLayerInfoMap",new Map);q(this,"_transformChange$",new Y.Subject);q(this,"transformChange$",this._transformChange$.asObservable());q(this,"_remove$",new Y.Subject);q(this,"remove$",this._remove$.asObservable());this._renderManagerService=n,this._univerInstanceService=t,this._commandService=r,this._drawingManagerService=o,this._selectionRenderService=s,this._canvasFloatDomService=a,this._sheetDrawingService=d,this._drawingAddListener(),this._scrollUpdateListener(),this._featureUpdateListener(),this._deleteListener()}_ensureMap(n,t){let r=this._domLayerMap.get(n);r||(r=new Map,this._domLayerMap.set(n,r));let o=r.get(t);return o||(o=new Map,r.set(t,o)),o}_getSceneAndTransformerByDrawingSearch(n){if(n==null)return;const t=this._renderManagerService.getRenderById(n),r=t==null?void 0:t.scene;if(t==null||r==null)return null;const o=r.getTransformerByCreate(),s=t.engine.getCanvasElement();return{scene:r,transformer:o,renderObject:t,canvas:s}}_drawingAddListener(){this.disposeWithMe(this._drawingManagerService.add$.subscribe(n=>{n.forEach(t=>{var z,oe;const{unitId:r,subUnitId:o,drawingId:s}=t,a=_.getSheetCommandTarget(this._univerInstanceService,{unitId:r,subUnitId:o}),d=this._drawingManagerService.getDrawingByParam(t),g=(z=this._renderManagerService.getRenderById(r))==null?void 0:z.with(B.SheetSkeletonManagerService).getUnitSkeleton(r,o);if(d==null||a==null||g==null)return;const{transform:u,drawingType:c}=d;if(c!==p.DrawingTypeEnum.DRAWING_DOM)return;const l=this._getSceneAndTransformerByDrawingSearch(r);if(l==null)return;const{scene:h,canvas:w}=l;if(u==null)return!0;const{left:f,top:S,width:C,height:R,angle:I,flipX:M,flipY:D,skewX:b,skewY:v}=u,A=N.getDrawingShapeKeyByDrawingSearch({unitId:r,subUnitId:o,drawingId:s}),P=h.getObject(A);if(P!=null){P.transformByState({left:f,top:S,width:C,height:R,angle:I,flipX:M,flipY:D,skewX:b,skewY:v});return}const T={left:f,top:S,width:C,height:R,zIndex:this._drawingManagerService.getDrawingOrder(r,o).length-1},E=new j.Rect(A,T);h.addObject(E,j.DRAWING_OBJECT_LAYER_INDEX).attachTransformerTo(E);const O=this._ensureMap(r,o),y=new p.DisposableCollection,U=Te(E,l.renderObject,g.skeleton,a.worksheet),F=new Y.BehaviorSubject(U),Me={dispose:y,rect:E,position$:F,unitId:r,subUnitId:o};this._canvasFloatDomService.addFloatDom({position$:F,id:s,componentKey:d.componentKey,onPointerDown:X=>{w.dispatchEvent(new PointerEvent(X.type,X))},onPointerMove:X=>{w.dispatchEvent(new PointerEvent(X.type,X))},onPointerUp:X=>{w.dispatchEvent(new PointerEvent(X.type,X))},onWheel:X=>{w.dispatchEvent(new WheelEvent(X.type,X))},props:(oe=O.get(s))==null?void 0:oe.props});const K=E.onTransformChange$.subscribeEvent(()=>{const X=Te(E,l.renderObject,g.skeleton,a.worksheet);F.next(X)});y.add(()=>{this._canvasFloatDomService.removeFloatDom(s)}),K&&y.add(K),this._domLayerInfoMap.set(s,Me)})}))}_scrollUpdateListener(){this.disposeWithMe(this._commandService.onCommandExecuted(n=>{var r,o;const t=(s,a)=>{var h;const d=this._getSceneAndTransformerByDrawingSearch(s),g=this._ensureMap(s,a),u=Array.from(g.keys()),c=_.getSheetCommandTarget(this._univerInstanceService,{unitId:s,subUnitId:a}),l=(h=this._renderManagerService.getRenderById(s))==null?void 0:h.with(B.SheetSkeletonManagerService).getUnitSkeleton(s,a);!d||!c||!l||u.forEach(w=>{const f=this._domLayerInfoMap.get(w);if(f){const S=Te(f.rect,d.renderObject,l.skeleton,c.worksheet);f.position$.next(S)}})};if(n.id===B.SetScrollOperation.id){const s=n.params,{unitId:a,sheetId:d}=s;t(a,d)}else if(n.id===B.SetZoomRatioOperation.id){const s=n.params,{unitId:a}=s;Array.from((o=(r=this._domLayerMap.get(a))==null?void 0:r.keys())!=null?o:[]).forEach(g=>{t(a,g)})}else if(n.id===_.SetFrozenMutation.id){const{unitId:s,subUnitId:a}=n.params;t(s,a)}}))}_getPosition(n){const{startX:t,endX:r,startY:o,endY:s}=n,a=this._selectionRenderService.getSelectionCellByPosition(t,o);if(a==null)return;const d={column:a.actualColumn,columnOffset:t-a.startX,row:a.actualRow,rowOffset:o-a.startY},g=this._selectionRenderService.getSelectionCellByPosition(r,s);if(g==null)return;const u={column:g.actualColumn,columnOffset:r-g.startX,row:g.actualRow,rowOffset:s-g.startY};return{from:d,to:u}}_featureUpdateListener(){this.disposeWithMe(this._drawingManagerService.update$.subscribe(n=>{n.forEach(t=>{const r=this._drawingManagerService.getDrawingByParam(t);if(!r||r.drawingType!==p.DrawingTypeEnum.DRAWING_DOM)return;const o={...r.transform};this._transformChange$.next({id:t.drawingId,value:o})})}))}_deleteListener(){this.disposeWithMe(this._drawingManagerService.remove$.subscribe(n=>{n.forEach(t=>{this._removeDom(t.drawingId)})}))}addFloatDomToPosition(n){const t=_.getSheetCommandTarget(this._univerInstanceService,{unitId:n.unitId,subUnitId:n.subUnitId});if(!t)throw new Error("cannot find current target!");const{unitId:r,subUnitId:o}=t,{initPosition:s,componentKey:a}=n,d=p.Tools.generateRandomId(),g=this._getPosition(s);if(g==null)return;this._ensureMap(r,o).set(d,n);const c={unitId:r,subUnitId:o,drawingId:d,drawingType:p.DrawingTypeEnum.DRAWING_DOM,componentKey:a,sheetTransform:g,transform:{left:s.startX,top:s.startY,width:s.endX-s.startX,height:s.endY-s.startY}};return this._commandService.executeCommand(Re.id,{unitId:r,drawings:[c]}),{id:d,dispose:()=>{this._removeDom(d,!0)}}}_removeDom(n,t=!1){const r=this._domLayerInfoMap.get(n);if(!r)return;const{unitId:o,subUnitId:s}=r;this._domLayerInfoMap.delete(n),r.dispose.dispose();const a=this._getSceneAndTransformerByDrawingSearch(o);if(a&&a.scene.removeObject(r.rect),t){this._ensureMap(o,s).delete(n);const g=this._drawingManagerService.getDrawingByParam({unitId:o,subUnitId:s,drawingId:n});if(!g)return;const u=this._sheetDrawingService.getBatchRemoveOp([g]),{redo:c,objects:l}=u;this._commandService.syncExecuteCommand(m.SetDrawingApplyMutation.id,{unitId:o,subUnitId:s,op:c,objects:l,type:m.DrawingApplyType.REMOVE})}}};exports.SheetCanvasFloatDomManagerService=zt([ne(0,$.Inject(j.IRenderManagerService)),ne(1,p.IUniverInstanceService),ne(2,$.Inject(p.ICommandService)),ne(3,N.IDrawingManagerService),ne(4,B.ISelectionRenderService),ne(5,$.Inject(V.CanvasFloatDomService)),ne(6,m.ISheetDrawingService)],exports.SheetCanvasFloatDomManagerService);var Jt=Object.defineProperty,Zt=Object.getOwnPropertyDescriptor,Qt=(i,e,n,t)=>{for(var r=t>1?void 0:t?Zt(e,n):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(t?s(e,n,r):s(r))||r);return t&&r&&Jt(e,n,r),r},pe=(i,e)=>(n,t)=>e(n,t,i);let _e=class extends p.Disposable{constructor(i,e,n,t){super(),this._sheetPrintInterceptorService=i,this._drawingRenderService=e,this._drawingManagerService=n,this._renderManagerService=t,this._initPrinting()}_initPrinting(){this.disposeWithMe(this._sheetPrintInterceptorService.interceptor.intercept(this._sheetPrintInterceptorService.interceptor.getInterceptPoints().PRINTING_COMPONENT_COLLECT,{handler:(i,e,n)=>{const{unitId:t,scene:r,subUnitId:o}=e,s=this._drawingManagerService.getDrawingDataForUnit(t),a=s==null?void 0:s[o];return a&&a.order.forEach(d=>{this._drawingRenderService.renderDrawing(a.data[d],r)}),n()}})),this.disposeWithMe(this._sheetPrintInterceptorService.interceptor.intercept(this._sheetPrintInterceptorService.interceptor.getInterceptPoints().PRINTING_RANGE,{handler:(i,e,n)=>{const{unitId:t,subUnitId:r}=e,o=this._renderManagerService.getRenderById(t);if(!o)return n(i);const s=o.with(B.SheetSkeletonManagerService).getUnitSkeleton(t,r);if(!s)return n(i);const a=this._drawingManagerService.getDrawingDataForUnit(t),d=a==null?void 0:a[e.subUnitId];if(!d)return n(i);const{scaleX:g,scaleY:u}=o.scene,c=i?{...i}:{startColumn:0,endColumn:0,endRow:0,startRow:0},l=d.order.map(h=>d.data[h]).filter(h=>h.drawingType!==N.DrawingTypeEnum.DRAWING_DOM);return l.length?(l.forEach(h=>{if(!h.groupId&&h.transform&&p.Tools.isDefine(h.transform.left)&&p.Tools.isDefine(h.transform.top)&&p.Tools.isDefine(h.transform.width)&&p.Tools.isDefine(h.transform.height)){const w=s.skeleton.getCellPositionByOffset(h.transform.left,h.transform.top,g,u,{x:0,y:0}),f=s.skeleton.getCellPositionByOffset(h.transform.left+h.transform.width,h.transform.top+h.transform.height,g,u,{x:0,y:0});w.column<c.startColumn&&(c.startColumn=w.column),w.row<c.startRow&&(c.startRow=w.row),c.endRow<f.row&&(c.endRow=f.row),c.endColumn<f.column&&(c.endColumn=f.column)}}),n(c)):n(i)}}))}};_e=Qt([p.OnLifecycle(p.LifecycleStages.Rendered,_e),pe(0,$.Inject(B.SheetPrintInterceptorService)),pe(1,$.Inject(re.DrawingRenderService)),pe(2,N.IDrawingManagerService),pe(3,j.IRenderManagerService)],_e);var en=Object.defineProperty,tn=Object.getOwnPropertyDescriptor,nn=(i,e,n,t)=>{for(var r=t>1?void 0:t?tn(e,n):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(t?s(e,n,r):s(r))||r);return t&&r&&en(e,n,r),r},ae=(i,e)=>(n,t)=>e(n,t,i);let De=class extends p.Disposable{constructor(i,e,n,t,r){super(),this._drawingManagerService=i,this._renderManagerService=e,this._permissionService=n,this._univerInstanceService=t,this._userManagerService=r,this._initDrawingVisible(),this._initDrawingEditable(),this._initViewPermissionChange(),this._initEditPermissionChange()}_initDrawingVisible(){const i=this._univerInstanceService.getCurrentTypeOfUnit$(p.UniverInstanceType.UNIVER_SHEET);this.disposeWithMe(Y.combineLatest([i,this._userManagerService.currentUser$]).subscribe(([e,n])=>{if(!e){this._drawingManagerService.setDrawingVisible(!1);return}e.activeSheet$.subscribe(t=>{if(!t){this._drawingManagerService.setDrawingVisible(!1);return}const r=e.getUnitId(),o=t.getSheetId();if(this._permissionService.composePermission([new _.WorkbookViewPermission(r).id,new _.WorksheetViewPermission(r,o).id]).every(a=>a.value))this._drawingManagerService.setDrawingVisible(!0);else{this._drawingManagerService.setDrawingVisible(!1);const a=e.getUnitId(),d=t.getSheetId(),g=this._drawingManagerService.getDrawingData(a,d),u=Object.values(g),c=this._renderManagerService.getRenderById(a),l=c==null?void 0:c.scene;if(l==null)return;l.getAllObjects().forEach(w=>{w.classType===j.RENDER_CLASS_TYPE.IMAGE&&u.some(f=>w.oKey.includes(f.drawingId))&&l.removeObject(w)})}})}))}_initDrawingEditable(){const i=this._univerInstanceService.getCurrentTypeOfUnit$(p.UniverInstanceType.UNIVER_SHEET);this.disposeWithMe(Y.combineLatest([i,this._userManagerService.currentUser$]).subscribe(([e,n])=>{if(!e){this._drawingManagerService.setDrawingEditable(!1);return}e.activeSheet$.subscribe(t=>{if(!t){this._drawingManagerService.setDrawingEditable(!1);return}const r=e.getUnitId(),o=t.getSheetId();if(this._permissionService.composePermission([new _.WorkbookEditablePermission(r).id,new _.WorksheetEditPermission(r,o).id]).every(a=>a.value))this._drawingManagerService.setDrawingEditable(!0);else{this._drawingManagerService.setDrawingEditable(!1);const a=e.getUnitId(),d=t.getSheetId(),g=this._drawingManagerService.getDrawingData(a,d),u=Object.values(g),c=this._renderManagerService.getRenderById(a),l=c==null?void 0:c.scene;if(l==null)return;l.getAllObjects().forEach(w=>{w.classType===j.RENDER_CLASS_TYPE.IMAGE&&u.some(f=>w.oKey.includes(f.drawingId))&&l.detachTransformerFrom(w)})}})}))}_initViewPermissionChange(){const i=this._univerInstanceService.getCurrentTypeOfUnit$(p.UniverInstanceType.UNIVER_SHEET);this.disposeWithMe(Y.combineLatest([i,this._userManagerService.currentUser$]).subscribe(([e,n])=>{e&&e.activeSheet$.subscribe(t=>{var c;if(!t)return;const r=e.getUnitId(),o=t.getSheetId();let s=!0;const a=this._renderManagerService.getRenderById(r),d=a==null?void 0:a.scene;if(d==null)return;const g=d.getTransformerByCreate(),u=this._permissionService.composePermission$([new _.WorkbookViewPermission(r).id,new _.WorksheetViewPermission(r,o).id]).pipe(Y.map(l=>l.every(h=>h.value)));u==null||u.pipe(Y.filter(l=>l!==s),Y.distinctUntilChanged()).subscribe({next:l=>{s=l,this._drawingManagerService.setDrawingVisible(l);const h=d.getAllObjects(),w=this._drawingManagerService.getDrawingData(r,o),f=Object.values(w);l?this._drawingManagerService.addNotification(f):(h.forEach(S=>{S.classType===j.RENDER_CLASS_TYPE.IMAGE&&f.some(C=>S.oKey.includes(C.drawingId))&&d.removeObject(S)}),g.clearSelectedObjects())}}),(c=this._permissionService.getPermissionPoint$(new _.WorksheetViewPermission(r,o).id))==null||c.pipe(Y.filter(l=>l.value!==s),Y.distinctUntilChanged()).subscribe({complete:()=>{s=!0,this._drawingManagerService.setDrawingVisible(!0);const l=this._drawingManagerService.getDrawingData(r,o),h=Object.values(l);this._drawingManagerService.addNotification(h)}})})}))}_initEditPermissionChange(){const i=this._univerInstanceService.getCurrentTypeOfUnit$(p.UniverInstanceType.UNIVER_SHEET);this.disposeWithMe(Y.combineLatest([i,this._userManagerService.currentUser$]).subscribe(([e,n])=>{e&&e.activeSheet$.subscribe(t=>{var c;if(!t)return;const r=e.getUnitId(),o=t.getSheetId();let s=!0;const a=this._renderManagerService.getRenderById(r),d=a==null?void 0:a.scene;if(d==null)return;const g=d.getTransformerByCreate(),u=this._permissionService.composePermission$([new _.WorkbookEditablePermission(r).id,new _.WorksheetEditPermission(r,o).id]).pipe(Y.map(l=>l.every(h=>h.value)));u==null||u.pipe(Y.filter(l=>l!==s),Y.distinctUntilChanged()).subscribe({next:l=>{s=l,this._drawingManagerService.setDrawingEditable(l);const h=d.getAllObjects(),w=this._drawingManagerService.getDrawingData(r,o),f=Object.values(w);l?(h.forEach(S=>{S.classType===j.RENDER_CLASS_TYPE.IMAGE&&f.some(C=>S.oKey.includes(C.drawingId))&&d.attachTransformerTo(S)}),this._drawingManagerService.addNotification(f)):(h.forEach(S=>{S.classType===j.RENDER_CLASS_TYPE.IMAGE&&f.some(C=>S.oKey.includes(C.drawingId))&&d.detachTransformerFrom(S)}),g.clearSelectedObjects())}}),(c=this._permissionService.getPermissionPoint$(new _.WorksheetEditPermission(r,o).id))==null||c.pipe(Y.filter(l=>l.value!==s),Y.distinctUntilChanged()).subscribe({complete:()=>{s=!0;const l=e.getUnitId(),h=t.getSheetId(),w=this._drawingManagerService.getDrawingData(l,h),f=Object.values(w),S=this._renderManagerService.getRenderById(l),C=S==null?void 0:S.scene;if(C==null)return;this._drawingManagerService.setDrawingEditable(!0),C.getAllObjects().forEach(I=>{I.classType===j.RENDER_CLASS_TYPE.IMAGE&&f.some(M=>I.oKey.includes(M.drawingId))&&C.detachTransformerFrom(I)})}})})}))}};De=nn([p.OnLifecycle(p.LifecycleStages.Rendered,De),ae(0,N.IDrawingManagerService),ae(1,j.IRenderManagerService),ae(2,p.IPermissionService),ae(3,p.IUniverInstanceService),ae(4,$.Inject(p.UserManagerService))],De);var rn=Object.defineProperty,on=Object.getOwnPropertyDescriptor,sn=(i,e,n,t)=>{for(var r=t>1?void 0:t?on(e,n):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(t?s(e,n,r):s(r))||r);return t&&r&&rn(e,n,r),r},fe=(i,e)=>(n,t)=>e(n,t,i);let Ce=class extends p.Disposable{constructor(e,n,t,r){super();q(this,"_copyInfo");this._sheetClipboardService=e,this._selectionRenderService=n,this._sheetDrawingService=t,this._injector=r,this._initCopyPaste()}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:"SHEET_IMAGE_UI_PLUGIN",onBeforeCopy:(e,n,t)=>this._collect(e,n,t),onPasteCells:(e,n,t,r)=>{const{copyType:o=B.COPY_TYPE.COPY,pasteType:s}=r,{range:a}=e||{},{range:d,unitId:g,subUnitId:u}=n;return this._generateMutations(d,{copyType:o,pasteType:s,copyRange:a,unitId:g,subUnitId:u})},onPastePlainText:(e,n)=>({undos:[],redos:[]})})}_collect(e,n,t){const r=this._selectionRenderService.attachRangeWithCoord(t);if(!r)return;const{startX:o,endX:s,startY:a,endY:d}=r,g=this._sheetDrawingService.getDrawingData(e,n),u=[];Object.keys(g).forEach(c=>{const l=g[c],{transform:h}=l;if(l.anchorType!==m.SheetDrawingAnchorType.Both||!h)return;const{left:w=0,top:f=0,width:S=0,height:C=0}=h,{drawingStartX:R,drawingEndX:I,drawingStartY:M,drawingEndY:D}={drawingStartX:w,drawingEndX:w+S,drawingStartY:f,drawingEndY:f+C};o<=R&&I<=s&&a<=M&&D<=d&&u.push(l)}),u.length&&(this._copyInfo={drawings:u,unitId:e,subUnitId:n})}_generateMutations(e,n){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(n.pasteType))return{redos:[],undos:[]};const{copyRange:t}=n;if(!t)return{redos:[],undos:[]};const{drawings:r,unitId:o,subUnitId:s}=this._copyInfo,{ranges:[a,d],mapFunc:g}=B.virtualizeDiscreteRanges([t,e]),{row:u,col:c}=g(a.startRow,a.startColumn),{row:l,col:h}=g(d.startRow,d.startColumn),w=this._selectionRenderService.attachRangeWithCoord({startRow:u,endRow:u,startColumn:c,endColumn:c}),f=this._selectionRenderService.attachRangeWithCoord({startRow:l,endRow:l,startColumn:h,endColumn:h});if(!w||!f)return{redos:[],undos:[]};const S=[],C=[],R=f.startX-w.startX,I=f.startY-w.startY,M=l-u,D=h-c,b=n.copyType===B.COPY_TYPE.CUT,{_sheetDrawingService:v}=this;return r.forEach(A=>{const{transform:P,sheetTransform:T}=A;if(!P)return;const E={...A,unitId:o,subUnitId:s,drawingId:b?A.drawingId:p.Tools.generateRandomId(),transform:{...P,left:P.left+R,top:P.top+I},sheetTransform:{to:{...T.to,row:T.to.row+M,column:T.to.column+D},from:{...T.from,row:T.from.row+M,column:T.from.column+D}}};if(b){const{undo:O,redo:y,objects:U}=v.getBatchUpdateOp([E]);S.push({id:m.SetDrawingApplyMutation.id,params:{unitId:o,subUnitId:s,type:m.DrawingApplyType.UPDATE,op:y,objects:U}}),C.push({id:m.SetDrawingApplyMutation.id,params:{unitId:o,subUnitId:s,type:m.DrawingApplyType.UPDATE,op:O,objects:U}})}else{const{undo:O,redo:y,objects:U}=v.getBatchAddOp([E]);S.push({id:m.SetDrawingApplyMutation.id,params:{op:y,unitId:o,subUnitId:s,objects:U,type:m.DrawingApplyType.INSERT}}),C.push({id:m.SetDrawingApplyMutation.id,params:{op:O,unitId:o,subUnitId:s,objects:U,type:m.DrawingApplyType.REMOVE}})}}),{redos:S,undos:C}}};Ce=sn([p.OnLifecycle(p.LifecycleStages.Ready,Ce),fe(0,B.ISheetClipboardService),fe(1,B.ISelectionRenderService),fe(2,m.ISheetDrawingService),fe(3,$.Inject($.Injector))],Ce);var Fe=Object.defineProperty,an=Object.getOwnPropertyDescriptor,cn=(i,e,n)=>e in i?Fe(i,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[e]=n,dn=(i,e,n,t)=>{for(var r=t>1?void 0:t?an(e,n):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(t?s(e,n,r):s(r))||r);return t&&r&&Fe(e,n,r),r},Oe=(i,e)=>(n,t)=>e(n,t,i),Xe=(i,e,n)=>cn(i,typeof e!="symbol"?e+"":e,n);const ln="SHEET_IMAGE_UI_PLUGIN";exports.UniverSheetsDrawingUIPlugin=class extends p.Plugin{constructor(n={},t,r,o){super();q(this,"_pluginConfig");this._injector=t,this._localeService=r,this._renderManagerService=o,this._pluginConfig=p.Tools.deepMerge({},Vt,n)}onStarting(n){super.onStarting(n),this._initDependencies(n)}_initDependencies(n){const t=[[exports.SheetCanvasFloatDomManagerService],[ce,{useFactory:()=>this._injector.createInstance(ce,this._pluginConfig)}],[we],[_e],[De],[Ce]],r=[Se,ve];t.forEach(o=>n.add(o)),r.forEach(o=>this._renderManagerService.registerRenderModule(p.UniverInstanceType.UNIVER_SHEET,o))}};Xe(exports.UniverSheetsDrawingUIPlugin,"type",p.UniverInstanceType.UNIVER_SHEET);Xe(exports.UniverSheetsDrawingUIPlugin,"pluginName",ln);exports.UniverSheetsDrawingUIPlugin=dn([p.DependentOn(N.UniverDrawingPlugin,re.UniverDrawingUIPlugin,m.UniverSheetsDrawingPlugin),Oe(1,$.Inject($.Injector)),Oe(2,$.Inject(p.LocaleService)),Oe(3,j.IRenderManagerService)],exports.UniverSheetsDrawingUIPlugin);exports.ClearSheetDrawingTransformerOperation=G;exports.DeleteDrawingsCommand=Ne;exports.EditSheetDrawingOperation=be;exports.GroupSheetDrawingCommand=Ae;exports.InsertCellImageOperation=de;exports.InsertFloatImageOperation=le;exports.InsertSheetDrawingCommand=Re;exports.MoveDrawingsCommand=ie;exports.RemoveSheetDrawingCommand=ye;exports.SetDrawingArrangeCommand=Pe;exports.SetSheetDrawingCommand=ue;exports.SidebarSheetDrawingOperation=Ee;exports.UngroupSheetDrawingCommand=Ue;
1
+ "use strict";var He=Object.defineProperty;var xe=(i,t,e)=>t in i?He(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e;var Y=(i,t,e)=>xe(i,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("@univerjs/core"),Z=require("@univerjs/drawing-ui"),p=require("@univerjs/sheets-drawing"),P=require("@univerjs/drawing"),N=require("@univerjs/engine-render"),W=require("@univerjs/sheets-ui"),V=require("rxjs"),G=require("@univerjs/ui"),_=require("@univerjs/sheets"),U=require("react"),z=require("@univerjs/design"),de=require("clsx"),B={id:"sheet.operation.clear-drawing-transformer",type:m.CommandType.MUTATION,handler:(i,t)=>{const e=i.get(N.IRenderManagerService);return t.forEach(n=>{var r,o;(o=(r=e.getRenderById(n))==null?void 0:r.scene.getTransformer())==null||o.debounceRefreshControls()}),!0}},ve={id:"sheet.command.remove-sheet-image",type:m.CommandType.COMMAND,handler:(i,t)=>{const e=i.get(m.ICommandService),n=i.get(m.IUndoRedoService),r=i.get(p.ISheetDrawingService);if(!t)return!1;const{drawings:o}=t,s=[];o.forEach(w=>{const{unitId:f}=w;s.push(f)});const a=r.getBatchRemoveOp(o),{unitId:d,subUnitId:u,undo:l,redo:c,objects:g}=a;return e.syncExecuteCommand(p.SetDrawingApplyMutation.id,{unitId:d,subUnitId:u,op:c,objects:g,type:p.DrawingApplyType.REMOVE})?(n.pushUndoRedo({unitID:d,undoMutations:[{id:p.SetDrawingApplyMutation.id,params:{unitId:d,subUnitId:u,op:l,objects:g,type:p.DrawingApplyType.INSERT}},{id:B.id,params:s}],redoMutations:[{id:p.SetDrawingApplyMutation.id,params:{unitId:d,subUnitId:u,op:c,objects:g,type:p.DrawingApplyType.REMOVE}},{id:B.id,params:s}]}),!0):!1}},Le="COMPONENT_SHEET_DRAWING_PANEL",ye={id:"sidebar.operation.sheet-image",type:m.CommandType.COMMAND,handler:async(i,t)=>{const e=i.get(G.ISidebarService),n=i.get(m.LocaleService),r=i.get(m.IUniverInstanceService),o=i.get(P.IDrawingManagerService);if(!_.getSheetCommandTarget(r))return!1;switch(t.value){case"open":e.open({header:{title:n.t("sheetImage.panel.title")},children:{label:Le},onClose:()=>{o.focusDrawing(null)},width:360});break;case"close":default:e.close();break}return!0}},Me={id:"sheet.operation.edit-sheet-image",type:m.CommandType.OPERATION,handler:(i,t)=>{const e=i.get(P.IDrawingManagerService),n=i.get(m.ICommandService);return t==null?!1:(e.focusDrawing([t]),n.executeCommand(ye.id,{value:"open"}),!0)}},Ye="univer-upload-loading",Xe="univer-upload-loading-body",Ke="univer-upload-loading-body-animation",ze="univer-UniverCircleAnimation",qe="univer-upload-loading-body-text",le={uploadLoading:Ye,uploadLoadingBody:Xe,uploadLoadingBodyAnimation:Ke,univerCircleAnimation:ze,uploadLoadingBodyText:qe},Je=()=>{const i=m.useDependency(P.IImageIoService),t=m.useDependency(m.LocaleService),[e,n]=U.useState(0);return U.useEffect(()=>{const r=i.change$.subscribe(o=>{n(o)});return()=>{r.unsubscribe()}},[i]),U.createElement("div",{style:{display:e>0?"block":"none"},className:le.uploadLoading},U.createElement("div",{className:le.uploadLoadingBody},U.createElement("div",{className:le.uploadLoadingBodyAnimation}),U.createElement("div",{className:le.uploadLoadingBodyText},`${t.t("uploadLoading.loading")}: ${e}`)))};var Ze=Object.defineProperty,Qe=Object.getOwnPropertyDescriptor,et=(i,t,e,n)=>{for(var r=n>1?void 0:n?Qe(t,e):t,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(t,e,r):s(r))||r);return n&&r&&Ze(t,e,r),r},J=(i,t)=>(e,n)=>t(e,n,i);let ge=class extends m.RxDisposable{constructor(t,e,n,r,o,s,a){super();Y(this,"_initImagePopupMenu",new Set);this._injector=t,this._drawingManagerService=e,this._canvasPopManagerService=n,this._renderManagerService=r,this._univerInstanceService=o,this._contextService=s,this._uiPartsService=a,this._init()}_init(){this._univerInstanceService.getCurrentTypeOfUnit$(m.UniverInstanceType.UNIVER_SHEET).pipe(V.takeUntil(this.dispose$)).subscribe(t=>this._create(t)),this._univerInstanceService.getTypeOfUnitDisposed$(m.UniverInstanceType.UNIVER_SHEET).pipe(V.takeUntil(this.dispose$)).subscribe(t=>this._dispose(t)),this._univerInstanceService.getAllUnitsForType(m.UniverInstanceType.UNIVER_SHEET).forEach(t=>this._create(t)),this._uiPartsService.registerComponent(G.BuiltInUIPart.CONTENT,()=>m.connectInjector(Je,this._injector))}_dispose(t){const e=t.getUnitId();this._renderManagerService.removeRender(e)}_create(t){if(!t)return;const e=t.getUnitId();this._renderManagerService.has(e)&&!this._initImagePopupMenu.has(e)&&(this._popupMenuListener(e),this._initImagePopupMenu.add(e))}_hasCropObject(t){const e=t.getAllObjects();for(const n of e)if(n instanceof Z.ImageCropperObject)return!0;return!1}_popupMenuListener(t){var o;const e=(o=this._renderManagerService.getRenderById(t))==null?void 0:o.scene;if(!e)return;const n=e.getTransformerByCreate();if(!n)return;let r;this.disposeWithMe(m.toDisposable(n.createControl$.subscribe(()=>{if(this._contextService.setContextValue(m.FOCUSING_COMMON_DRAWINGS,!0),this._hasCropObject(e))return;const s=n.getSelectedObjectMap();if(s.size>1){r==null||r.dispose();return}const a=s.values().next().value;if(!a)return;const d=a.oKey,u=this._drawingManagerService.getDrawingOKey(d);if(!u)return;const{unitId:l,subUnitId:c,drawingId:g}=u;r==null||r.dispose(),r=this.disposeWithMe(this._canvasPopManagerService.attachPopupToObject(a,{componentKey:Z.COMPONENT_IMAGE_POPUP_MENU,direction:"horizontal",offset:[2,0],extraProps:{menuItems:this._getImageMenuItems(l,c,g)}})),this._drawingManagerService.focusDrawing([{unitId:l,subUnitId:c,drawingId:g}])}))),this.disposeWithMe(n.clearControl$.subscribe(()=>{r==null||r.dispose(),this._contextService.setContextValue(m.FOCUSING_COMMON_DRAWINGS,!1),this._drawingManagerService.focusDrawing(null)})),this.disposeWithMe(n.changing$.subscribe(()=>{r==null||r.dispose()}))}_getImageMenuItems(t,e,n){return[{label:"image-popup.edit",index:0,commandId:Me.id,commandParams:{unitId:t,subUnitId:e,drawingId:n},disable:!1},{label:"image-popup.delete",index:1,commandId:ve.id,commandParams:{unitId:t,drawings:[{unitId:t,subUnitId:e,drawingId:n}]},disable:!1},{label:"image-popup.crop",index:2,commandId:Z.OpenImageCropOperation.id,commandParams:{unitId:t,subUnitId:e,drawingId:n},disable:!1},{label:"image-popup.reset",index:3,commandId:Z.ImageResetSizeOperation.id,commandParams:[{unitId:t,subUnitId:e,drawingId:n}],disable:!1}]}};ge=et([m.OnLifecycle(m.LifecycleStages.Steady,ge),J(0,m.Inject(m.Injector)),J(1,P.IDrawingManagerService),J(2,m.Inject(W.SheetCanvasPopManagerService)),J(3,N.IRenderManagerService),J(4,m.IUniverInstanceService),J(5,m.IContextService),J(6,m.Inject(G.IUIPartsService))],ge);const se={id:"sheet.operation.insert-float-image",type:m.CommandType.OPERATION,handler:(i,t)=>!0},oe={id:"sheet.operation.insert-cell-image",type:m.CommandType.OPERATION,handler:(i,t)=>!0},_e={id:"sheet.command.insert-sheet-image",type:m.CommandType.COMMAND,handler:(i,t)=>{const e=i.get(m.ICommandService),n=i.get(m.IUndoRedoService),r=i.get(p.ISheetDrawingService);if(!t)return!1;const o=t.drawings,s=o.map(w=>w.unitId),a=r.getBatchAddOp(o),{unitId:d,subUnitId:u,undo:l,redo:c,objects:g}=a;return e.syncExecuteCommand(p.SetDrawingApplyMutation.id,{op:c,unitId:d,subUnitId:u,objects:g,type:p.DrawingApplyType.INSERT})?(n.pushUndoRedo({unitID:d,undoMutations:[{id:p.SetDrawingApplyMutation.id,params:{op:l,unitId:d,subUnitId:u,objects:g,type:p.DrawingApplyType.REMOVE}},{id:B.id,params:s}],redoMutations:[{id:p.SetDrawingApplyMutation.id,params:{op:c,unitId:d,subUnitId:u,objects:g,type:p.DrawingApplyType.INSERT}},{id:B.id,params:s}]}),!0):!1}},ae={id:"sheet.command.set-sheet-image",type:m.CommandType.COMMAND,handler:(i,t)=>{const e=i.get(m.ICommandService),n=i.get(m.IUndoRedoService),r=i.get(p.ISheetDrawingService);if(!t)return!1;const{drawings:o}=t,s=r.getBatchUpdateOp(o),{unitId:a,subUnitId:d,undo:u,redo:l,objects:c}=s;return e.syncExecuteCommand(p.SetDrawingApplyMutation.id,{unitId:a,subUnitId:d,op:l,objects:c,type:p.DrawingApplyType.UPDATE})?(n.pushUndoRedo({unitID:a,undoMutations:[{id:p.SetDrawingApplyMutation.id,params:{unitId:a,subUnitId:d,op:u,objects:c,type:p.DrawingApplyType.UPDATE}},{id:B.id,params:[a]}],redoMutations:[{id:p.SetDrawingApplyMutation.id,params:{unitId:a,subUnitId:d,op:l,objects:c,type:p.DrawingApplyType.UPDATE}},{id:B.id,params:[a]}]}),!0):!1}},Re={id:"sheet.command.set-drawing-arrange",type:m.CommandType.COMMAND,handler:(i,t)=>{const e=i.get(m.ICommandService),n=i.get(m.IUndoRedoService);if(!t)return!1;const r=i.get(p.ISheetDrawingService),{unitId:o,subUnitId:s,drawingIds:a,arrangeType:d}=t,u={unitId:o,subUnitId:s,drawingIds:a};let l;if(d===P.ArrangeTypeEnum.forward?l=r.getForwardDrawingsOp(u):d===P.ArrangeTypeEnum.backward?l=r.getBackwardDrawingOp(u):d===P.ArrangeTypeEnum.front?l=r.getFrontDrawingsOp(u):d===P.ArrangeTypeEnum.back&&(l=r.getBackDrawingsOp(u)),l==null)return!1;const{objects:c,redo:g,undo:h}=l;return e.syncExecuteCommand(p.SetDrawingApplyMutation.id,{op:g,unitId:o,subUnitId:s,objects:c,type:p.DrawingApplyType.ARRANGE})?(n.pushUndoRedo({unitID:o,undoMutations:[{id:p.SetDrawingApplyMutation.id,params:{op:h,unitId:o,subUnitId:s,objects:c,type:p.DrawingApplyType.ARRANGE}}],redoMutations:[{id:p.SetDrawingApplyMutation.id,params:{op:g,unitId:o,subUnitId:s,objects:c,type:p.DrawingApplyType.ARRANGE}}]}),!0):!1}};function tt(i){const t=[];return i.forEach(e=>{const{parent:n,children:r}=e,{unitId:o,subUnitId:s,drawingId:a}=n,d=N.getGroupState(0,0,r.map(c=>c.transform||{})),u=r.map(c=>{const g=c.transform||{left:0,top:0},{unitId:h,subUnitId:w,drawingId:f}=c;return{unitId:h,subUnitId:w,drawingId:f,transform:{...g,left:g.left-d.left,top:g.top-d.top},groupId:a}}),l={unitId:o,subUnitId:s,drawingId:a,drawingType:P.DrawingTypeEnum.DRAWING_GROUP,transform:d};t.push({parent:l,children:u})}),t}function nt(i){const t=[];return i.forEach(e=>{const{parent:n,children:r}=e,{unitId:o,subUnitId:s,drawingId:a,transform:d={width:0,height:0}}=n;if(d==null)return;const u=r.map(c=>{const{transform:g}=c,{unitId:h,subUnitId:w,drawingId:f}=c,S=N.transformObjectOutOfGroup(g||{},d,d.width||0,d.height||0);return{unitId:h,subUnitId:w,drawingId:f,transform:S,groupId:void 0}}),l={unitId:o,subUnitId:s,drawingId:a,drawingType:P.DrawingTypeEnum.DRAWING_GROUP,transform:{left:0,top:0}};t.push({parent:l,children:u})}),t}const Te={id:"sheet.command.group-sheet-image",type:m.CommandType.COMMAND,handler:(i,t)=>{const e=i.get(m.ICommandService),n=i.get(m.IUndoRedoService),r=i.get(p.ISheetDrawingService);if(!t)return!1;const o=[];t.forEach(({parent:h,children:w})=>{o.push(h.unitId),w.forEach(f=>{o.push(f.unitId)})});const s=r.getGroupDrawingOp(t),{unitId:a,subUnitId:d,undo:u,redo:l,objects:c}=s;return e.syncExecuteCommand(p.SetDrawingApplyMutation.id,{op:l,unitId:a,subUnitId:d,objects:c,type:p.DrawingApplyType.GROUP})?(n.pushUndoRedo({unitID:a,undoMutations:[{id:p.SetDrawingApplyMutation.id,params:{op:u,unitId:a,subUnitId:d,objects:nt(c),type:p.DrawingApplyType.UNGROUP}},{id:B.id,params:o}],redoMutations:[{id:p.SetDrawingApplyMutation.id,params:{op:l,unitId:a,subUnitId:d,objects:c,type:p.DrawingApplyType.GROUP}},{id:B.id,params:o}]}),!0):!1}},Ee={id:"sheet.command.ungroup-sheet-image",type:m.CommandType.COMMAND,handler:(i,t)=>{const e=i.get(m.ICommandService),n=i.get(m.IUndoRedoService),r=i.get(p.ISheetDrawingService);if(!t)return!1;const o=[];t.forEach(({parent:h,children:w})=>{o.push(h.unitId),w.forEach(f=>{o.push(f.unitId)})});const s=r.getUngroupDrawingOp(t),{unitId:a,subUnitId:d,undo:u,redo:l,objects:c}=s;return e.syncExecuteCommand(p.SetDrawingApplyMutation.id,{op:l,unitId:a,subUnitId:d,objects:c,type:p.DrawingApplyType.UNGROUP})?(n.pushUndoRedo({unitID:a,undoMutations:[{id:p.SetDrawingApplyMutation.id,params:{op:u,unitId:a,subUnitId:d,objects:tt(c),type:p.DrawingApplyType.GROUP}},{id:B.id,params:o}],redoMutations:[{id:p.SetDrawingApplyMutation.id,params:{op:l,unitId:a,subUnitId:d,objects:c,type:p.DrawingApplyType.UNGROUP}},{id:B.id,params:o}]}),!0):!1}};function k(i,t,e){const{from:n,to:r,flipY:o=!1,flipX:s=!1,angle:a=0,skewX:d=0,skewY:u=0}=i,{column:l,columnOffset:c,row:g,rowOffset:h}=n,{column:w,columnOffset:f,row:S,rowOffset:C}=r,y=e.attachRangeWithCoord({startColumn:l,endColumn:l,startRow:g,endRow:g});if(y==null)return;const D=e.attachRangeWithCoord({startColumn:w,endColumn:w,startRow:S,endRow:S});if(D==null)return;const{startX:R,startY:I}=y,{startX:b,startY:v}=D;let A=N.precisionTo(R+c,1),T=N.precisionTo(I+h,1),L=N.precisionTo(b+f-A,1),O=N.precisionTo(v+C-T,1);y.startX===D.endX&&(L=0),y.startY===D.endY&&(O=0);const E=e.getCurrentSkeleton(),M=E.rowHeaderWidth+E.columnTotalWidth,j=E.columnHeaderHeight+E.rowTotalHeight;return A+L>M&&(A=M-L),T+O>j&&(T=j-O),{flipY:o,flipX:s,angle:a,skewX:d,skewY:u,left:A,top:T,width:L,height:O}}function $(i,t){const{left:e=0,top:n=0,width:r=0,height:o=0,flipY:s=!1,flipX:a=!1,angle:d=0,skewX:u=0,skewY:l=0}=i,c=t.getSelectionCellByPosition(e,n);if(c==null)return;const g={column:c.actualColumn,columnOffset:N.precisionTo(e-c.startX,1),row:c.actualRow,rowOffset:N.precisionTo(n-c.startY,1)},h=t.getSelectionCellByPosition(e+r,n+o);if(h==null)return;const w={column:h.actualColumn,columnOffset:N.precisionTo(e+r-h.startX,1),row:h.actualRow,rowOffset:N.precisionTo(n+o-h.startY,1)};return{flipY:s,flipX:a,angle:d,skewX:u,skewY:l,from:g,to:w}}var rt=Object.defineProperty,it=Object.getOwnPropertyDescriptor,ot=(i,t,e,n)=>{for(var r=n>1?void 0:n?it(t,e):t,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(t,e,r):s(r))||r);return n&&r&&rt(t,e,r),r},X=(i,t)=>(e,n)=>t(e,n,i);let he=class extends m.Disposable{constructor(i,t,e,n,r,o,s,a,d,u){super(),this._commandService=i,this._univerInstanceService=t,this._selectionManagerService=e,this._imageIoService=n,this._sheetDrawingService=r,this._drawingManagerService=o,this._contextService=s,this._messageService=a,this._localeService=d,this._renderManagerService=u,this._init()}get _selectionRenderService(){return this._renderManagerService.getRenderById(this._univerInstanceService.getCurrentUnitForType(m.UniverInstanceType.UNIVER_SHEET).getUnitId()).with(W.ISheetSelectionRenderService)}get _skeletonManagerService(){return this._renderManagerService.getRenderById(this._univerInstanceService.getCurrentUnitForType(m.UniverInstanceType.UNIVER_SHEET).getUnitId()).with(W.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===oe.id||i.id===se.id){const t=i.params;if(t.files==null)return;const e=t.files.length;if(e>P.DRAWING_IMAGE_COUNT_LIMIT){this._messageService.show({type:z.MessageType.Error,content:this._localeService.t("update-status.exceedMaxCount",String(P.DRAWING_IMAGE_COUNT_LIMIT))});return}this._imageIoService.setWaitCount(e),i.id===oe.id?t.files.forEach(async n=>{await this._insertCellImage(n)}):t.files.forEach(async n=>{await this._insertFloatImage(n)})}}))}async _insertCellImage(i){}async _insertFloatImage(i){let t;try{t=await this._imageIoService.saveImage(i)}catch(y){const D=y.message;D===P.ImageUploadStatusType.ERROR_EXCEED_SIZE?this._messageService.show({type:z.MessageType.Error,content:this._localeService.t("update-status.exceedMaxSize",String(P.DRAWING_IMAGE_ALLOW_SIZE/(1024*1024)))}):D===P.ImageUploadStatusType.ERROR_IMAGE_TYPE?this._messageService.show({type:z.MessageType.Error,content:this._localeService.t("update-status.invalidImageType")}):D===P.ImageUploadStatusType.ERROR_IMAGE&&this._messageService.show({type:z.MessageType.Error,content:this._localeService.t("update-status.invalidImage")})}if(t==null)return;const e=this._getUnitInfo();if(e==null)return;const{unitId:n,subUnitId:r}=e,{imageId:o,imageSourceType:s,source:a,base64Cache:d}=t,{width:u,height:l,image:c}=await P.getImageSize(d||""),g=this._renderManagerService.getRenderById(n);if(g==null)return;const{width:h,height:w}=g.scene;this._imageIoService.addImageSourceCache(a,s,c);let f=1;if(u>P.DRAWING_IMAGE_WIDTH_LIMIT||l>P.DRAWING_IMAGE_HEIGHT_LIMIT){const y=P.DRAWING_IMAGE_WIDTH_LIMIT/u,D=P.DRAWING_IMAGE_HEIGHT_LIMIT/l;f=Math.max(y,D)}const S=this._getImagePosition(u*f,l*f,h,w);if(S==null)return;const C={unitId:n,subUnitId:r,drawingId:o,drawingType:P.DrawingTypeEnum.DRAWING_IMAGE,imageSourceType:s,source:a,transform:k(S,this._selectionRenderService,this._skeletonManagerService),sheetTransform:S};this._commandService.executeCommand(_e.id,{unitId:n,drawings:[C]})}_getUnitInfo(){const i=this._univerInstanceService.getCurrentUnitForType(m.UniverInstanceType.UNIVER_SHEET);if(i==null)return;const t=i.getActiveSheet();if(t==null)return;const e=i.getUnitId(),n=t.getSheetId();return{unitId:e,subUnitId:n}}_getImagePosition(i,t,e,n){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 s=W.attachRangeWithCoord(this._skeletonManagerService.getCurrent().skeleton,o);if(s==null)return;let{startColumn:a,startRow:d,startX:u,startY:l}=s,c=!1;if(u+i>e&&(u=e-i,u<0&&(u=0,i=e),c=!0),l+t>n&&(l=n-t,l<0&&(l=0,t=n),c=!0),c){const f=this._selectionRenderService.getSelectionCellByPosition(u,l);if(f==null)return;u=f.startX,l=f.startY,a=f.actualColumn,d=f.actualRow}const g={column:a,columnOffset:0,row:d,rowOffset:0},h=this._selectionRenderService.getSelectionCellByPosition(u+i,l+t);if(h==null)return;const w={column:h.actualColumn,columnOffset:u+i-h.startX,row:h.actualRow,rowOffset:l+t-h.startY};return{from:g,to:w}}_updateOrderListener(){this._drawingManagerService.featurePluginOrderUpdate$.subscribe(i=>{const{unitId:t,subUnitId:e,drawingIds:n,arrangeType:r}=i;this._commandService.executeCommand(Re.id,{unitId:t,subUnitId:e,drawingIds:n,arrangeType:r})})}_updateImageListener(){this._drawingManagerService.featurePluginUpdate$.subscribe(i=>{const t=[];i.length!==0&&(i.forEach(e=>{const{unitId:n,subUnitId:r,drawingId:o,drawingType:s,transform:a}=e;if(a==null)return;const d=this._sheetDrawingService.getDrawingByParam({unitId:n,subUnitId:r,drawingId:o});if(d==null)return;const u=$({...d.transform,...a},this._selectionRenderService);if(u==null)return;const l={...e,transform:{...d.transform,...a,...k(u,this._selectionRenderService,this._skeletonManagerService)},sheetTransform:{...u}};t.push(l)}),t.length>0&&this._commandService.executeCommand(ae.id,{unitId:i[0].unitId,drawings:t}))})}_groupDrawingListener(){this._drawingManagerService.featurePluginGroupUpdate$.subscribe(i=>{this._commandService.executeCommand(Te.id,i);const{unitId:t,subUnitId:e,drawingId:n}=i[0].parent;this._drawingManagerService.focusDrawing([{unitId:t,subUnitId:e,drawingId:n}])}),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(m.FOCUSING_COMMON_DRAWINGS,!1),this._sheetDrawingService.focusDrawing([])):(this._contextService.setContextValue(m.FOCUSING_COMMON_DRAWINGS,!0),this._sheetDrawingService.focusDrawing(i))}))}_drawingAddListener(){this.disposeWithMe(this._sheetDrawingService.add$.subscribe(i=>{this._registerDrawing(i)}))}_registerDrawing(i){i.forEach(e=>{const n=this._sheetDrawingService.getDrawingByParam(e);if(n==null)return;const{sheetTransform:r}=n;n.transform=k(r,this._selectionRenderService,this._skeletonManagerService)});const t=i[0].unitId;this._drawingManagerService.registerDrawingData(t,this._sheetDrawingService.getDrawingDataForUnit(t)),this._drawingManagerService.initializeNotification(t)}};he=ot([m.OnLifecycle(m.LifecycleStages.Rendered,he),X(0,m.ICommandService),X(1,m.IUniverInstanceService),X(2,m.Inject(_.SheetsSelectionsService)),X(3,P.IImageIoService),X(4,p.ISheetDrawingService),X(5,P.IDrawingManagerService),X(6,m.IContextService),X(7,G.IMessageService),X(8,m.Inject(m.LocaleService)),X(9,N.IRenderManagerService)],he);var x=function(){return x=Object.assign||function(i){for(var t,e=1,n=arguments.length;e<n;e++){t=arguments[e];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(i[r]=t[r])}return i},x.apply(this,arguments)},st=function(i,t){var e={};for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&t.indexOf(n)<0&&(e[n]=i[n]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,n=Object.getOwnPropertySymbols(i);r<n.length;r++)t.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(i,n[r])&&(e[n[r]]=i[n[r]]);return e},je=U.forwardRef(function(i,t){var e=i.icon,n=i.id,r=i.className,o=i.extend,s=st(i,["icon","id","className","extend"]),a="univerjs-icon univerjs-icon-".concat(n," ").concat(r||"").trim(),d=U.useRef("_".concat(dt()));return We(e,"".concat(n),{defIds:e.defIds,idSuffix:d.current},x({ref:t,className:a},s),o)});function We(i,t,e,n,r){return U.createElement(i.tag,x(x({key:t},at(i,e,r)),n),(ct(i,e).children||[]).map(function(o,s){return We(o,"".concat(t,"-").concat(i.tag,"-").concat(s),e,void 0,r)}))}function at(i,t,e){var n=x({},i.attrs);e!=null&&e.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=e.colorChannel1);var r=t.defIds;return!r||r.length===0||(i.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+t.idSuffix),Object.entries(n).forEach(function(o){var s=o[0],a=o[1];typeof a=="string"&&(n[s]=a.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),n}function ct(i,t){var e,n=t.defIds;return!n||n.length===0?i:i.tag==="defs"&&(!((e=i.children)===null||e===void 0)&&e.length)?x(x({},i),{children:i.children.map(function(r){return typeof r.attrs.id=="string"&&n&&n.indexOf(r.attrs.id)>-1?x(x({},r),{attrs:x(x({},r.attrs),{id:r.attrs.id+t.idSuffix})}):r})}):i}function dt(){return Math.random().toString(36).substring(2,8)}je.displayName="UniverIcon";var lt={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"}}]},Be=U.forwardRef(function(i,t){return U.createElement(je,Object.assign({},i,{id:"add-image-single",ref:t,icon:lt}))});Be.displayName="AddImageSingle";const ut="univer-upload-file-menu",gt="univer-upload-file-menu-input",Ne={uploadFileMenu:ut,uploadFileMenuInput:gt},$e="COMPONENT_UPLOAD_FILE_MENU";var Se=(i=>(i[i.cellImage=0]="cellImage",i[i.floatImage=1]="floatImage",i))(Se||{});const ht=i=>{const{type:t}=i,e=m.useDependency(m.ICommandService),n=U.useRef(null),r=()=>{var a;(a=n.current)==null||a.click()},o=P.DRAWING_IMAGE_ALLOW_IMAGE_LIST.map(a=>`.${a.replace("image/","")}`).join(","),s=a=>{const d=a.target.files;if(d==null)return;const u=Array.from(d);t===Se.floatImage?e.executeCommand(se.id,{files:u}):t===Se.cellImage&&e.executeCommand(oe.id,{files:u}),n.current&&(n.current.value="")};return U.createElement("div",{onClick:r,className:Ne.uploadFileMenu},U.createElement("input",{type:"file",className:Ne.uploadFileMenuInput,ref:n,onChange:s,accept:o,multiple:!0}))},Ge="addition-and-subtraction-single",Ve="sheet.menu.image";function mt(i){return{id:Ve,type:G.MenuItemType.SUBITEMS,positions:[G.MenuPosition.TOOLBAR_START],group:G.MenuGroup.TOOLBAR_FORMULAS_INSERT,icon:Ge,tooltip:"sheetImage.title",hidden$:G.getMenuHiddenObservable(i,m.UniverInstanceType.UNIVER_SHEET),disabled$:W.getCurrentRangeDisable$(i,{workbookTypes:[_.WorkbookEditablePermission],worksheetTypes:[_.WorksheetEditPermission],rangeTypes:[_.RangeProtectionPermissionEditPoint]})}}function pt(i){return{id:se.id,title:"sheetImage.upload.float",type:G.MenuItemType.SELECTOR,label:{name:$e,props:{type:Se.floatImage}},positions:[Ve],hidden$:G.getMenuHiddenObservable(i,m.UniverInstanceType.UNIVER_SHEET)}}const ft="univer-image-common-panel",wt="univer-image-common-panel-grid",St="univer-image-common-panel-border",vt="univer-image-common-panel-title",_t="univer-image-common-panel-subtitle",It="univer-image-common-panel-row",Dt="univer-image-common-panel-row-vertical",Ct="univer-image-common-panel-column",yt="univer-image-common-panel-column-center",Mt="univer-image-common-panel-inline",Rt="univer-image-common-panel-span2",Tt="univer-image-common-panel-span3",Et="univer-image-common-panel-input",bt="univer-sheet-image-menu",Ot="univer-sheet-image-menu-input",K={imageCommonPanel:ft,imageCommonPanelGrid:wt,imageCommonPanelBorder:St,imageCommonPanelTitle:vt,imageCommonPanelSubtitle:_t,imageCommonPanelRow:It,imageCommonPanelRowVertical:Dt,imageCommonPanelColumn:Ct,imageCommonPanelColumnCenter:yt,imageCommonPanelInline:Mt,imageCommonPanelSpan2:Rt,imageCommonPanelSpan3:Tt,imageCommonPanelInput:Et,sheetImageMenu:bt,sheetImageMenuInput:Ot},Pt=i=>{var D;const t=m.useDependency(m.ICommandService),e=m.useDependency(m.LocaleService),n=m.useDependency(P.IDrawingManagerService),r=m.useDependency(N.IRenderManagerService),{drawings:o}=i,s=o[0];if(s==null)return;const{unitId:a}=s,d=r.getRenderById(a),u=d==null?void 0:d.scene;if(u==null)return;const l=u.getTransformerByCreate(),[c,g]=U.useState(!0),h=(D=s.anchorType)!=null?D:p.SheetDrawingAnchorType.Position,[w,f]=U.useState(h);function S(R,I){const b=[];return R.forEach(v=>{const{oKey:A}=v,T=I.getDrawingOKey(A);if(T==null)return b.push(null),!0;const{unitId:L,subUnitId:O,drawingId:E,drawingType:M,anchorType:j,sheetTransform:F}=T;b.push({unitId:L,subUnitId:O,drawingId:E,anchorType:j,sheetTransform:F,drawingType:M})}),b}U.useEffect(()=>{const R=l.clearControl$.subscribe(b=>{b===!0&&g(!1)}),I=l.changeStart$.subscribe(b=>{var T;const{objects:v}=b,A=S(v,n);if(A.length===0)g(!1);else if(A.length>=1){g(!0);const L=((T=A[0])==null?void 0:T.anchorType)||p.SheetDrawingAnchorType.Position;f(L)}});return()=>{I.unsubscribe(),R.unsubscribe()}},[]);function C(R){f(R);const I=n.getFocusDrawings();if(I.length===0)return;const b=I.map(v=>({unitId:v.unitId,subUnitId:v.subUnitId,drawingId:v.drawingId,anchorType:R}));t.executeCommand(ae.id,{unitId:I[0].unitId,drawings:b})}const y=R=>R?"block":"none";return U.createElement("div",{className:de(K.imageCommonPanelGrid,K.imageCommonPanelBorder),style:{display:y(c)}},U.createElement("div",{className:K.imageCommonPanelRow},U.createElement("div",{className:de(K.imageCommonPanelColumn,K.imageCommonPanelTitle)},U.createElement("div",null,e.t("drawing-anchor.title")))),U.createElement("div",{className:de(K.imageCommonPanelRow)},U.createElement("div",{className:de(K.imageCommonPanelColumn)},U.createElement(z.RadioGroup,{value:w,onChange:C,direction:"vertical"},U.createElement(z.Radio,{value:p.SheetDrawingAnchorType.Both},e.t("drawing-anchor.both")),U.createElement(z.Radio,{value:p.SheetDrawingAnchorType.Position},e.t("drawing-anchor.position")),U.createElement(z.Radio,{value:p.SheetDrawingAnchorType.None},e.t("drawing-anchor.none"))))))},At=()=>{const i=m.useDependency(P.IDrawingManagerService),t=i.getFocusDrawings(),[e,n]=U.useState(t);return U.useEffect(()=>{const r=i.focus$.subscribe(o=>{n(o)});return()=>{r.unsubscribe()}},[]),!!(e!=null&&e.length)&&U.createElement("div",{className:K.imageCommonPanel},U.createElement(Z.DrawingCommonPanel,{drawings:e}),U.createElement(Pt,{drawings:e}))},te={id:"sheet.command.move-drawing",type:m.CommandType.COMMAND,handler:(i,t)=>{const e=i.get(m.ICommandService),n=i.get(p.ISheetDrawingService),r=i.get(W.ISheetSelectionRenderService),{direction:o}=t,s=n.getFocusDrawings();if(s.length===0)return!1;const a=s[0].unitId,d=s.map(l=>{const{transform:c}=l;if(c==null)return null;const g={...c},{left:h=0,top:w=0}=c;return o===m.Direction.UP?g.top=w-1:o===m.Direction.DOWN?g.top=w+1:o===m.Direction.LEFT?g.left=h-1:o===m.Direction.RIGHT&&(g.left=h+1),{...l,transform:g,sheetTransform:$(g,r)}}).filter(l=>l!=null);return e.syncExecuteCommand(ae.id,{unitId:a,drawings:d})?(e.syncExecuteCommand(B.id,[a]),!0):!1}},be={id:"sheet.command.delete-drawing",type:m.CommandType.COMMAND,handler:i=>{const t=i.get(m.ICommandService),n=i.get(p.ISheetDrawingService).getFocusDrawings();if(n.length===0)return!1;const r=n[0].unitId,o=n.map(s=>{const{unitId:a,subUnitId:d,drawingId:u,drawingType:l}=s;return{unitId:a,subUnitId:d,drawingId:u,drawingType:l}});return t.executeCommand(ve.id,{unitId:r,drawings:o})}};function ce(i){return!i.getContextValue(m.FOCUSING_FORMULA_EDITOR)&&!i.getContextValue(m.EDITOR_ACTIVATED)&&i.getContextValue(m.FOCUSING_COMMON_DRAWINGS)}const Ut={id:te.id,description:"shortcut.sheet.drawing-move-down",group:"4_sheet-drawing-view",binding:G.KeyCode.ARROW_DOWN,priority:100,preconditions:ce,staticParameters:{direction:m.Direction.DOWN}},Nt={id:te.id,description:"shortcut.sheet.drawing-move-up",group:"4_sheet-drawing-view",binding:G.KeyCode.ARROW_UP,priority:100,preconditions:ce,staticParameters:{direction:m.Direction.UP}},Lt={id:te.id,description:"shortcut.sheet.drawing-move-left",group:"4_sheet-drawing-view",binding:G.KeyCode.ARROW_LEFT,priority:100,preconditions:ce,staticParameters:{direction:m.Direction.LEFT}},jt={id:te.id,description:"shortcut.sheet.drawing-move-right",group:"4_sheet-drawing-view",binding:G.KeyCode.ARROW_RIGHT,priority:100,preconditions:ce,staticParameters:{direction:m.Direction.RIGHT}},Wt={id:be.id,description:"shortcut.sheet.drawing-delete",group:"4_sheet-drawing-view",preconditions:ce,binding:G.KeyCode.DELETE,mac:G.KeyCode.BACKSPACE};var Bt=Object.defineProperty,$t=Object.getOwnPropertyDescriptor,Gt=(i,t,e,n)=>{for(var r=n>1?void 0:n?$t(t,e):t,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(t,e,r):s(r))||r);return n&&r&&Bt(t,e,r),r},ne=(i,t)=>(e,n)=>t(e,n,i);const Vt={};let ie=class extends m.Disposable{constructor(i,t,e,n,r,o){super(),this._config=i,this._injector=t,this._componentManager=e,this._menuService=n,this._commandService=r,this._shortcutService=o,this._init()}_initCustomComponents(){const i=this._componentManager;this.disposeWithMe(i.register(Ge,Be)),this.disposeWithMe(i.register($e,ht)),this.disposeWithMe(i.register(Le,At))}_initMenus(){const{menu:i={}}=this._config;[mt,pt].forEach(t=>{this._menuService.addMenuItem(t(this._injector),i)})}_initCommands(){[se,oe,_e,ve,ae,ye,B,Me,Te,Ee,te,be,Re].forEach(i=>this.disposeWithMe(this._commandService.registerCommand(i)))}_initShortcuts(){[Ut,Nt,Lt,jt,Wt].forEach(i=>{this.disposeWithMe(this._shortcutService.registerShortcut(i))})}_init(){this._initCommands(),this._initCustomComponents(),this._initMenus(),this._initShortcuts()}};ie=Gt([m.OnLifecycle(m.LifecycleStages.Rendered,ie),ne(1,m.Inject(m.Injector)),ne(2,m.Inject(G.ComponentManager)),ne(3,G.IMenuService),ne(4,m.ICommandService),ne(5,G.IShortcutService)],ie);var Ft=Object.defineProperty,kt=Object.getOwnPropertyDescriptor,Ht=(i,t,e,n)=>{for(var r=n>1?void 0:n?kt(t,e):t,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(t,e,r):s(r))||r);return n&&r&&Ft(t,e,r),r},Q=(i,t)=>(e,n)=>t(e,n,i);const xt=[_.InsertRowCommand.id,_.InsertColCommand.id,_.RemoveRowCommand.id,_.RemoveColCommand.id,_.DeleteRangeMoveLeftCommand.id,_.DeleteRangeMoveUpCommand.id,_.InsertRangeMoveDownCommand.id,_.InsertRangeMoveRightCommand.id,_.DeltaRowHeightCommand.id,_.SetRowHeightCommand.id,_.DeltaColumnWidthCommand.id,_.SetColWidthCommand.id,_.SetRowHiddenCommand.id,_.SetSpecificRowsVisibleCommand.id,_.SetSpecificColsVisibleCommand.id,_.SetColHiddenCommand.id],Yt=[_.SetRowVisibleMutation.id,_.SetRowHiddenMutation.id,_.SetColVisibleMutation.id,_.SetColHiddenMutation.id,_.SetWorksheetRowHeightMutation.id,_.SetWorksheetColWidthMutation.id];let me=class extends m.Disposable{constructor(i,t,e,n,r,o){super(),this._commandService=i,this._sheetInterceptorService=t,this._renderManagerService=e,this._sheetDrawingService=n,this._drawingManagerService=r,this._univerInstanceService=o,this._init()}get _selectionRenderService(){return this._renderManagerService.getRenderById(this._univerInstanceService.getCurrentUnitForType(m.UniverInstanceType.UNIVER_SHEET).getUnitId()).with(W.ISheetSelectionRenderService)}get _skeletonManagerService(){return this._renderManagerService.getRenderById(this._univerInstanceService.getCurrentUnitForType(m.UniverInstanceType.UNIVER_SHEET).getUnitId()).with(W.SheetSkeletonManagerService)}_init(){this._sheetInterceptorListener(),this._commandListener(),this._sheetRefreshListener()}_sheetInterceptorListener(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:i=>{if(!xt.includes(i.id))return{redos:[],undos:[]};if(i.params==null)return{redos:[],undos:[]};const 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:e}=i.params;return this._getRangeMoveUndo(e,0)}else if(t===_.DeleteRangeMoveUpCommand.id){const{range:e}=i.params;return this._getRangeMoveUndo(e,1)}else if(t===_.InsertRangeMoveDownCommand.id){const{range:e}=i.params;return this._getRangeMoveUndo(e,2)}else if(t===_.InsertRangeMoveRightCommand.id){const{range:e}=i.params;return this._getRangeMoveUndo(e,3)}else if(t===_.SetRowHiddenCommand.id||t===_.SetSpecificRowsVisibleCommand.id){const e=i.params,{unitId:n,subUnitId:r,ranges:o}=e;return this._getDrawingUndoForRowVisible(n,r,o)}else if(t===_.SetSpecificColsVisibleCommand.id||t===_.SetColHiddenCommand.id){const e=i.params,{unitId:n,subUnitId:r,ranges:o}=e;return this._getDrawingUndoForColVisible(n,r,o)}else if(t===_.DeltaRowHeightCommand.id||t===_.SetRowHeightCommand.id||t===_.DeltaColumnWidthCommand.id||t===_.SetColWidthCommand.id){const e=i.params,{unitId:n,subUnitId:r,ranges:o}=e,s=t===_.DeltaRowHeightCommand.id||t===_.SetRowHeightCommand.id;return this._getDrawingUndoForRowAndColSize(n,r,o,s)}return{redos:[],undos:[]}}}))}_getRangeMoveUndo(i,t){const e=_.getSheetCommandTarget(this._univerInstanceService);if(e==null)return{redos:[],undos:[]};const n=e.unitId,r=e.subUnitId,o=[],s=[],a=this._sheetDrawingService.getDrawingData(n,r),d=[],u=[];if(Object.keys(a).forEach(l=>{const c=a[l],{updateDrawings:g,deleteDrawings:h}=this._getUpdateOrDeleteDrawings(i,t,c);d.push(...g),u.push(...h)}),d.length===0&&u.length===0)return{redos:[],undos:[]};if(d.length>0){const l=this._sheetDrawingService.getBatchUpdateOp(d),{undo:c,redo:g,objects:h}=l;o.push({id:p.SetDrawingApplyMutation.id,params:{unitId:n,subUnitId:r,op:g,objects:h,type:p.DrawingApplyType.UPDATE}}),s.push({id:p.SetDrawingApplyMutation.id,params:{unitId:n,subUnitId:r,op:c,objects:h,type:p.DrawingApplyType.UPDATE}})}if(u.length>0){const l=this._sheetDrawingService.getBatchRemoveOp(u),c=l.undo,g=l.redo,h=l.objects;o.push({id:p.SetDrawingApplyMutation.id,params:{unitId:n,subUnitId:r,op:g,objects:h,type:p.DrawingApplyType.REMOVE}}),s.push({id:p.SetDrawingApplyMutation.id,params:{unitId:n,subUnitId:r,op:c,objects:h,type:p.DrawingApplyType.INSERT}})}return o.push({id:B.id,params:[n]}),s.push({id:B.id,params:[n]}),{redos:o,undos:s}}_getUpdateOrDeleteDrawings(i,t,e){const n=[],r=[],{sheetTransform:o,anchorType:s=p.SheetDrawingAnchorType.Position,transform:a,unitId:d,subUnitId:u,drawingId:l}=e,{from:c,to:g}=o,{row:h,column:w}=c,{row:f,column:S}=g;if(o==null||a==null)return{updateDrawings:n,deleteDrawings:r};const{startRow:C,endRow:y,startColumn:D,endColumn:R}=i;let I=null,b=null;if(t===0&&h>=C&&f<=y)if(w>=D&&S<=R)r.push({unitId:d,subUnitId:u,drawingId:l});else{const v=this._shrinkCol(o,a,D,R,s);I=v==null?void 0:v.newSheetTransform,b=v==null?void 0:v.newTransform}else if(t===1&&w>=D&&S<=R)if(h>=C&&f<=y)r.push({unitId:d,subUnitId:u,drawingId:l});else{const v=this._shrinkRow(o,a,C,y,s);I=v==null?void 0:v.newSheetTransform,b=v==null?void 0:v.newTransform}else if(t===2){const v=this._expandRow(o,a,C,y,s);I=v==null?void 0:v.newSheetTransform,b=v==null?void 0:v.newTransform}else if(t===3){const v=this._expandCol(o,a,D,R,s);I=v==null?void 0:v.newSheetTransform,b=v==null?void 0:v.newTransform}if(I!=null&&b!=null){const v=k(I,this._selectionRenderService,this._skeletonManagerService);n.push({...e,sheetTransform:I,transform:v})}return{updateDrawings:n,deleteDrawings:r}}_remainDrawingSize(i,t,e){const n=$({...i},this._selectionRenderService);n!=null&&t.push({...e,sheetTransform:n})}_getDrawingUndoForColVisible(i,t,e){const n=this._drawingManagerService.getDrawingData(i,t),r=[],o=[];if(Object.keys(n).forEach(l=>{const c=n[l],{sheetTransform:g,transform:h,anchorType:w=p.SheetDrawingAnchorType.Position}=c;if(w===p.SheetDrawingAnchorType.None)this._remainDrawingSize(h,r,c);else{const{from:f,to:S}=g,{row:C,column:y}=f,{row:D,column:R}=S;for(let I=0;I<e.length;I++){const b=e[I],{startRow:v,endRow:A,startColumn:T,endColumn:L}=b;if(R<T)continue;if(w===p.SheetDrawingAnchorType.Position){let M=null,j=null;if(y>=T&&y<=L){const F=this._skeletonManagerService.attachRangeWithCoord({startColumn:y,endColumn:L,startRow:f.row,endRow:S.row});if(F==null)return;j={...h,left:F.startX}}if(j!=null&&(M=$(j,this._selectionRenderService),M!=null&&j!=null)){r.push({...c,sheetTransform:M,transform:j});break}this._remainDrawingSize(h,r,c);continue}if(y>=T&&R<=L)continue;let O=null,E=null;if(y>=T&&y<=L){const M=this._skeletonManagerService.attachRangeWithCoord({startColumn:y,endColumn:L,startRow:f.row,endRow:S.row});if(M==null)return;E={...h,left:(M==null?void 0:M.startX)||0,width:((h==null?void 0:h.width)||0)-M.endX+M.startX}}else if(R>=T&&R<=L){const M=this._skeletonManagerService.attachRangeWithCoord({startColumn:T,endColumn:R,startRow:f.row,endRow:S.row});if(M==null)return;E={...h,left:M.startX-((h==null?void 0:h.width)||0)}}else{const M=this._skeletonManagerService.attachRangeWithCoord({startColumn:T,endColumn:L,startRow:f.row,endRow:S.row});if(M==null)return;if(E={...h,width:((h==null?void 0:h.width)||0)-M.endX+M.startX},O=$(E,this._selectionRenderService),O!=null&&E!=null){o.push({...c,sheetTransform:O,transform:E});break}}if(E!=null&&(O=$(E,this._selectionRenderService)),E!=null&&O!=null){r.push({...c,sheetTransform:O,transform:E});break}else this._remainDrawingSize(h,r,c)}}}),r.length===0&&o.length===0)return{redos:[],undos:[]};const{redos:s,undos:a}=this._createUndoAndRedoMutation(i,t,r),d=[],u=[];if(o.length>0){const{redos:l,undos:c}=this._createUndoAndRedoMutation(i,t,o);d.push(...l),u.push(...c)}return{redos:s,undos:a,preRedos:d,preUndos:u}}_createUndoAndRedoMutation(i,t,e){const n=this._sheetDrawingService.getBatchUpdateOp(e),{undo:r,redo:o,objects:s}=n,a=[{id:p.SetDrawingApplyMutation.id,params:{unitId:i,subUnitId:t,op:o,objects:s,type:p.DrawingApplyType.UPDATE}},{id:B.id,params:[i]}],d=[{id:p.SetDrawingApplyMutation.id,params:{unitId:i,subUnitId:t,op:r,objects:s,type:p.DrawingApplyType.UPDATE}},{id:B.id,params:[i]}];return{redos:a,undos:d}}_getDrawingUndoForRowVisible(i,t,e){const n=this._drawingManagerService.getDrawingData(i,t),r=[],o=[];if(Object.keys(n).forEach(l=>{const c=n[l],{sheetTransform:g,transform:h,anchorType:w=p.SheetDrawingAnchorType.Position}=c;if(w===p.SheetDrawingAnchorType.None)this._remainDrawingSize(h,r,c);else{const{from:f,to:S}=g,{row:C,column:y}=f,{row:D,column:R}=S;for(let I=0;I<e.length;I++){const b=e[I],{startRow:v,endRow:A,startColumn:T,endColumn:L}=b;if(D<v)continue;if(w===p.SheetDrawingAnchorType.Position){let M=null,j=null;if(C>=v&&C<=A){const F=this._skeletonManagerService.attachRangeWithCoord({startColumn:f.column,endColumn:S.column,startRow:C,endRow:A});if(F==null)return;j={...h,top:F.startY}}if(j!=null&&(M=$(j,this._selectionRenderService),M!=null&&j!=null)){r.push({...c,sheetTransform:M,transform:j});break}this._remainDrawingSize(h,r,c);continue}if(C>=v&&D<=A)continue;let O=null,E=null;if(C>=v&&C<=A){const M=this._skeletonManagerService.attachRangeWithCoord({startColumn:f.column,endColumn:S.column,startRow:C,endRow:A});if(M==null)return;E={...h,top:(M==null?void 0:M.startY)||0,height:((h==null?void 0:h.height)||0)-M.endY+M.startY}}else if(D>=v&&D<=A){const M=this._skeletonManagerService.attachRangeWithCoord({startColumn:f.column,endColumn:S.column,startRow:v,endRow:D});if(M==null)return;E={...h,top:M.startY-((h==null?void 0:h.height)||0)}}else{const M=this._skeletonManagerService.attachRangeWithCoord({startColumn:f.column,endColumn:S.column,startRow:v,endRow:A});if(M==null)return;if(E={...h,height:((h==null?void 0:h.height)||0)-M.endY+M.startY},O=$(E,this._selectionRenderService),O!=null&&E!=null){o.push({...c,sheetTransform:O,transform:E});break}}if(E!=null&&(O=$(E,this._selectionRenderService)),E!=null&&O!=null){r.push({...c,sheetTransform:O,transform:E});break}else this._remainDrawingSize(h,r,c)}}}),r.length===0&&o.length===0)return{redos:[],undos:[]};const{redos:s,undos:a}=this._createUndoAndRedoMutation(i,t,r),d=[],u=[];if(o.length>0){const{redos:l,undos:c}=this._createUndoAndRedoMutation(i,t,o);d.push(...l),u.push(...c)}return{redos:s,undos:a,preRedos:d,preUndos:u}}_getDrawingUndoForRowAndColSize(i,t,e,n){const r=this._drawingManagerService.getDrawingData(i,t),o=[];return Object.keys(r).forEach(s=>{const a=r[s],{sheetTransform:d,transform:u,anchorType:l=p.SheetDrawingAnchorType.Position}=a;if(l===p.SheetDrawingAnchorType.None)this._remainDrawingSize(u,o,a);else{const{from:c,to:g}=d,{row:h,column:w}=c,{row:f,column:S}=g;for(let C=0;C<e.length;C++){const y=e[C],{startRow:D,endRow:R,startColumn:I,endColumn:b}=y;if(f<D||S<I)continue;if(l===p.SheetDrawingAnchorType.Position&&(h<=D&&f>=R||w<=I&&S>=b)){this._remainDrawingSize(u,o,a);continue}const v=k({...d},this._selectionRenderService,this._skeletonManagerService);if(v!=null){o.push({...a,transform:v});break}}}}),o.length===0?{redos:[],undos:[]}:this._createUndoAndRedoMutation(i,t,o)}_getUnitIdAndSubUnitId(i,t){let e,n;if(t==="insert")e=i.unitId,n=i.subUnitId;else{const r=_.getSheetCommandTarget(this._univerInstanceService);if(r==null)return;e=r.unitId,n=r.subUnitId}return{unitId:e,subUnitId:n}}_moveRowInterceptor(i,t){const e=this._getUnitIdAndSubUnitId(i,t);if(e==null)return{redos:[],undos:[]};const{unitId:n,subUnitId:r}=e,{range:o}=i,s=o.startRow,a=o.endRow,d=[],u=[],l=this._sheetDrawingService.getDrawingData(n,r),c=[],g=[];if(Object.keys(l).forEach(h=>{const w=l[h],{sheetTransform:f,transform:S,anchorType:C=p.SheetDrawingAnchorType.Position}=w;if(f==null||S==null)return;let y,D;if(t==="insert"){const I=this._expandRow(f,S,s,a,C);y=I==null?void 0:I.newSheetTransform,D=I==null?void 0:I.newTransform}else{const{from:I,to:b}=f,{row:v}=I,{row:A}=b;if(v>=s&&A<=a)g.push({unitId:n,subUnitId:r,drawingId:h});else{const T=this._shrinkRow(f,S,s,a,C);y=T==null?void 0:T.newSheetTransform,D=T==null?void 0:T.newTransform}}if(!y||!D)return;const R={unitId:n,subUnitId:r,drawingId:h,transform:D,sheetTransform:y};c.push(R)}),c.length===0&&g.length===0)return{redos:[],undos:[]};if(c.length>0){const h=this._sheetDrawingService.getBatchUpdateOp(c),{undo:w,redo:f,objects:S}=h;d.push({id:p.SetDrawingApplyMutation.id,params:{unitId:n,subUnitId:r,op:f,objects:S,type:p.DrawingApplyType.UPDATE}}),u.push({id:p.SetDrawingApplyMutation.id,params:{unitId:n,subUnitId:r,op:w,objects:S,type:p.DrawingApplyType.UPDATE}})}if(g.length>0){const h=this._sheetDrawingService.getBatchRemoveOp(g),w=h.undo,f=h.redo,S=h.objects;d.push({id:p.SetDrawingApplyMutation.id,params:{unitId:n,subUnitId:r,op:f,objects:S,type:p.DrawingApplyType.REMOVE}}),u.push({id:p.SetDrawingApplyMutation.id,params:{unitId:n,subUnitId:r,op:w,objects:S,type:p.DrawingApplyType.INSERT}})}return d.push({id:B.id,params:[n]}),u.push({id:B.id,params:[n]}),{redos:d,undos:u}}_moveColInterceptor(i,t){const e=this._getUnitIdAndSubUnitId(i,t);if(e==null)return{redos:[],undos:[]};const{unitId:n,subUnitId:r}=e,{range:o}=i,s=o.startColumn,a=o.endColumn,d=[],u=[],l=this._sheetDrawingService.getDrawingData(n,r),c=[],g=[];if(Object.keys(l).forEach(h=>{const w=l[h],{sheetTransform:f,transform:S,anchorType:C=p.SheetDrawingAnchorType.Position}=w;if(f==null||S==null)return;let y,D;if(t==="insert"){const I=this._expandCol(f,S,s,a,C);y=I==null?void 0:I.newSheetTransform,D=I==null?void 0:I.newTransform}else{const{from:I,to:b}=f,{column:v}=I,{column:A}=b;if(v>=s&&A<=a)g.push({unitId:n,subUnitId:r,drawingId:h});else{const T=this._shrinkCol(f,S,s,a,C);y=T==null?void 0:T.newSheetTransform,D=T==null?void 0:T.newTransform}}if(!y||!D)return;const R={unitId:n,subUnitId:r,drawingId:h,transform:D,sheetTransform:y};c.push(R)}),c.length===0&&g.length===0)return{redos:[],undos:[]};if(c.length>0){const h=this._sheetDrawingService.getBatchUpdateOp(c),{undo:w,redo:f,objects:S}=h;d.push({id:p.SetDrawingApplyMutation.id,params:{unitId:n,subUnitId:r,op:f,objects:S,type:p.DrawingApplyType.UPDATE}}),u.push({id:p.SetDrawingApplyMutation.id,params:{unitId:n,subUnitId:r,op:w,objects:S,type:p.DrawingApplyType.UPDATE}})}if(g.length>0){const h=this._sheetDrawingService.getBatchRemoveOp(g),w=h.undo,f=h.redo,S=h.objects;d.push({id:p.SetDrawingApplyMutation.id,params:{unitId:n,subUnitId:r,op:f,objects:S,type:p.DrawingApplyType.REMOVE}}),u.push({id:p.SetDrawingApplyMutation.id,params:{unitId:n,subUnitId:r,op:w,objects:S,type:p.DrawingApplyType.INSERT}})}return d.push({id:B.id,params:[n]}),u.push({id:B.id,params:[n]}),{redos:d,undos:u}}_expandCol(i,t,e,n,r=p.SheetDrawingAnchorType.Position){const o=n-e+1,{from:s,to:a}=i,{column:d}=s,{column:u}=a;if(r===p.SheetDrawingAnchorType.None)return{newSheetTransform:$({...t},this._selectionRenderService),newTransform:t};let l=null,c=null;if(d>=e){const g=this._skeletonManagerService.attachRangeWithCoord({startColumn:e,endColumn:n,startRow:s.row,endRow:a.row});if(g==null)return;c={...t,left:(t.left||0)+g.endX-g.startX},l=$(c,this._selectionRenderService)}else if(u>=n)if(r===p.SheetDrawingAnchorType.Both)l={from:{...s},to:{...a,column:u+o}},c=k(l,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:$({...t},this._selectionRenderService),newTransform:t};return l!=null&&c!=null?{newSheetTransform:l,newTransform:c}:null}_shrinkCol(i,t,e,n,r=p.SheetDrawingAnchorType.Position){const o=n-e+1,{from:s,to:a}=i,{column:d}=s,{column:u}=a;if(r===p.SheetDrawingAnchorType.None)return{newSheetTransform:$({...t},this._selectionRenderService),newTransform:t};let l=null,c=null;if(d>n)l={from:{...s,column:d-o},to:{...a,column:u-o}},c=k(l,this._selectionRenderService,this._skeletonManagerService);else{if(d>=e&&u<=n)return null;if(d<e&&u>n)if(r===p.SheetDrawingAnchorType.Both)l={from:{...s},to:{...a,column:u-o}},c=k(l,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:$({...t},this._selectionRenderService),newTransform:t};else if(d>=e&&d<=n){if(d===e)c={...t,left:(t.left||0)-i.from.columnOffset};else{const g=this._skeletonManagerService.attachRangeWithCoord({startColumn:e,endColumn:d-1,startRow:s.row,endRow:a.row});if(g==null)return;c={...t,left:(t.left||0)-g.endX+g.startX-i.from.columnOffset}}l=$(c,this._selectionRenderService)}else if(u>=e&&u<=n&&r===p.SheetDrawingAnchorType.Both){const g=this._skeletonManagerService.attachRangeWithCoord({startColumn:e-1,endColumn:e-1,startRow:s.row,endRow:a.row});if(g==null)return;l={from:{...s},to:{...a,column:e-1,columnOffset:g.endX-g.startX}},c=k(l,this._selectionRenderService,this._skeletonManagerService)}}return l!=null&&c!=null?{newSheetTransform:l,newTransform:c}:null}_expandRow(i,t,e,n,r=p.SheetDrawingAnchorType.Position){const o=n-e+1,{from:s,to:a}=i,{row:d}=s,{row:u}=a;if(r===p.SheetDrawingAnchorType.None)return{newSheetTransform:$({...t},this._selectionRenderService),newTransform:t};let l=null,c=null;if(d>=e){const g=this._skeletonManagerService.attachRangeWithCoord({startRow:e,endRow:n,startColumn:s.column,endColumn:a.column});if(g==null)return;c={...t,top:(t.top||0)+g.endY-g.startY},l=$(c,this._selectionRenderService)}else if(u>=n)if(r===p.SheetDrawingAnchorType.Both)l={from:{...s},to:{...a,row:u+o}},c=k(l,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:$({...t},this._selectionRenderService),newTransform:t};return l!=null&&c!=null?{newSheetTransform:l,newTransform:c}:null}_shrinkRow(i,t,e,n,r=p.SheetDrawingAnchorType.Position){const o=n-e+1,{from:s,to:a}=i,{row:d}=s,{row:u}=a;if(r===p.SheetDrawingAnchorType.None)return{newSheetTransform:$({...t},this._selectionRenderService),newTransform:t};let l=null,c=null;if(d>n)l={from:{...s,row:d-o},to:{...a,row:u-o}},c=k(l,this._selectionRenderService,this._skeletonManagerService);else{if(d>=e&&u<=n)return null;if(d<e&&u>n)if(r===p.SheetDrawingAnchorType.Both)l={from:{...s},to:{...a,row:u-o}},c=k(l,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:$({...t},this._selectionRenderService),newTransform:t};else if(d>=e&&d<=n){if(d===e)c={...t,top:(t.top||0)-i.from.rowOffset};else{const g=this._skeletonManagerService.attachRangeWithCoord({startRow:e,endRow:d-1,startColumn:s.column,endColumn:a.column});if(g==null)return;c={...t,top:(t.top||0)-g.endY+g.startY-i.from.rowOffset}}l=$(c,this._selectionRenderService)}else if(u>=e&&u<=n&&r===p.SheetDrawingAnchorType.Both){const g=this._skeletonManagerService.attachRangeWithCoord({startColumn:s.column,endColumn:s.column,startRow:e-1,endRow:e-1});if(g==null)return;l={from:{...s},to:{...a,row:e-1,rowOffset:g.endY-g.startY}},c=k(l,this._selectionRenderService,this._skeletonManagerService)}}return l!=null&&c!=null?{newSheetTransform:l,newTransform:c}:null}_commandListener(){this.disposeWithMe(this._commandService.onCommandExecuted(i=>{i.id===_.SetWorksheetActiveOperation.id&&setTimeout(()=>{const t=i.params,{unitId:e,subUnitId:n}=t,r=this._drawingManagerService.drawingManagerData,o=[],s=[];Object.keys(r).forEach(a=>{const d=r[a];Object.keys(d).forEach(u=>{const l=d[u].data;l!=null&&Object.keys(l).forEach(c=>{if(a===e&&u===n){const g=l[c];g.transform=k(g.sheetTransform,this._selectionRenderService,this._skeletonManagerService),o.push(l[c])}else s.push(l[c])})})}),this._drawingManagerService.removeNotification(s),this._drawingManagerService.addNotification(o)},0)}))}_sheetRefreshListener(){this.disposeWithMe(this._commandService.onCommandExecuted(i=>{Yt.includes(i.id)&&requestIdleCallback(()=>{const t=i.params,{unitId:e,subUnitId:n,ranges:r}=t;this._refreshDrawingTransform(e,n,r)})}))}_refreshDrawingTransform(i,t,e){const n=this._drawingManagerService.getDrawingData(i,t),r=[];Object.keys(n).forEach(o=>{const s=n[o],{sheetTransform:a,anchorType:d=p.SheetDrawingAnchorType.Position}=s;if(d===p.SheetDrawingAnchorType.None)return!0;const{from:u,to:l}=a,{row:c,column:g}=u,{row:h,column:w}=l;for(let f=0;f<e.length;f++){const S=e[f],{startRow:C,endRow:y,startColumn:D,endColumn:R}=S;if(m.Rectangle.intersects({startRow:C,endRow:y,startColumn:D,endColumn:R},{startRow:c,endRow:h,startColumn:g,endColumn:w})||c>y||g>R){r.push({...s,transform:k(a,this._selectionRenderService,this._skeletonManagerService)});break}}}),r.length!==0&&(this._drawingManagerService.refreshTransform(r),this._commandService.syncExecuteCommand(B.id,[i]))}};me=Ht([m.OnLifecycle(m.LifecycleStages.Rendered,me),Q(0,m.ICommandService),Q(1,m.Inject(_.SheetInterceptorService)),Q(2,N.IRenderManagerService),Q(3,p.ISheetDrawingService),Q(4,P.IDrawingManagerService),Q(5,m.IUniverInstanceService)],me);var Xt=Object.defineProperty,Kt=Object.getOwnPropertyDescriptor,zt=(i,t,e,n)=>{for(var r=n>1?void 0:n?Kt(t,e):t,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(t,e,r):s(r))||r);return n&&r&&Xt(t,e,r),r},ee=(i,t)=>(e,n)=>t(e,n,i);function qt(i,t,e,n){const{scaleX:r,scaleY:o}=t.getAncestorScale(),s=t.getViewport(N.SHEET_VIEWPORT_KEY.VIEW_MAIN),a={left:!0,top:!0};if(!s)return{...i,absolute:a};const{left:d,right:u,top:l,bottom:c}=i,g=n.getFreeze(),{startColumn:h,startRow:w,xSplit:f,ySplit:S}=g,C=e.getNoMergeCellPositionByIndexWithNoHeader(w-S,h-f),y=e.getNoMergeCellPositionByIndexWithNoHeader(w,h),{rowHeaderWidth:D,columnHeaderHeight:R}=e,I=y.startX-C.startX,b=y.startY-C.startY,{top:v,left:A,viewportScrollX:T,viewportScrollY:L}=s;let O,E;d<A?(a.left=!0,O=(I+D+(d-A))*r,E=Math.max(Math.min((I+D+(u-A))*r,(I+D)*r),(u-T)*r)):(a.left=!1,O=Math.max((d-T)*r,(I+D)*r),E=Math.max((u-T)*r,(I+D)*r));let M,j;return l<v?(a.top=!0,M=(b+R+(l-v))*o,j=Math.max(Math.min((b+R+(u-v))*o,(b+R)*o),(c-L)*o)):(a.top=!1,M=Math.max((l-L)*o,(b+R)*o),j=Math.max((c-L)*o,(b+R)*o)),{left:O,right:E,top:M,bottom:j,absolute:a}}const Ie=(i,t,e,n)=>{const{scene:r}=t,{left:o,top:s,width:a,height:d,angle:u}=i,l={left:o,right:o+a,top:s,bottom:s+d},c=qt(l,r,e,n);return{startX:c.left,endX:c.right,startY:c.top,endY:c.bottom,rotate:u,width:a,height:d,absolute:c.absolute}};exports.SheetCanvasFloatDomManagerService=class extends m.Disposable{constructor(e,n,r,o,s,a){super();Y(this,"_domLayerMap",new Map);Y(this,"_domLayerInfoMap",new Map);Y(this,"_transformChange$",new V.Subject);Y(this,"transformChange$",this._transformChange$.asObservable());Y(this,"_remove$",new V.Subject);Y(this,"remove$",this._remove$.asObservable());Y(this,"_hooks",[]);this._renderManagerService=e,this._univerInstanceService=n,this._commandService=r,this._drawingManagerService=o,this._canvasFloatDomService=s,this._sheetDrawingService=a,this._drawingAddListener(),this._scrollUpdateListener(),this._featureUpdateListener(),this._deleteListener()}_ensureMap(e,n){let r=this._domLayerMap.get(e);r||(r=new Map,this._domLayerMap.set(e,r));let o=r.get(n);return o||(o=new Map,r.set(n,o)),o}_getSceneAndTransformerByDrawingSearch(e){if(e==null)return;const n=this._renderManagerService.getRenderById(e),r=n==null?void 0:n.scene;if(n==null||r==null)return null;const o=r.getTransformerByCreate(),s=n.engine.getCanvasElement();return{scene:r,transformer:o,renderObject:n,canvas:s}}_getFloatDomProps(e){let n;return this._hooks.forEach(r=>{n=r.onGetFloatDomProps(e)}),n}_drawingAddListener(){this.disposeWithMe(this._drawingManagerService.add$.subscribe(e=>{e.forEach(n=>{var Pe,Ae,Ue;const{unitId:r,subUnitId:o,drawingId:s}=n,a=_.getSheetCommandTarget(this._univerInstanceService,{unitId:r,subUnitId:o}),d=this._drawingManagerService.getDrawingByParam(n),u=(Pe=this._renderManagerService.getRenderById(r))==null?void 0:Pe.with(W.SheetSkeletonManagerService).getWorksheetSkeleton(o);if(d==null||a==null||u==null)return;const{transform:l,drawingType:c}=d;if(c!==m.DrawingTypeEnum.DRAWING_DOM)return;const g=this._getSceneAndTransformerByDrawingSearch(r);if(g==null)return;const{scene:h,canvas:w}=g;if(l==null)return!0;const{left:f,top:S,width:C,height:y,angle:D,flipX:R,flipY:I,skewX:b,skewY:v}=l,A=P.getDrawingShapeKeyByDrawingSearch({unitId:r,subUnitId:o,drawingId:s}),T=h.getObject(A);if(T!=null){T.transformByState({left:f,top:S,width:C,height:y,angle:D,flipX:R,flipY:I,skewX:b,skewY:v});return}const L={left:f,top:S,width:C,height:y,zIndex:this._drawingManagerService.getDrawingOrder(r,o).length-1},O=new N.Rect(A,L);h.addObject(O,N.DRAWING_OBJECT_LAYER_INDEX).attachTransformerTo(O);const E=this._ensureMap(r,o),M=new m.DisposableCollection,j=Ie(O,g.renderObject,u.skeleton,a.worksheet),F=new V.BehaviorSubject(j),q={dispose:M,rect:O,position$:F,unitId:r,subUnitId:o};this._canvasFloatDomService.addFloatDom({position$:F,id:s,componentKey:d.componentKey,onPointerDown:H=>{w.dispatchEvent(new PointerEvent(H.type,H))},onPointerMove:H=>{w.dispatchEvent(new PointerEvent(H.type,H))},onPointerUp:H=>{w.dispatchEvent(new PointerEvent(H.type,H))},onWheel:H=>{w.dispatchEvent(new WheelEvent(H.type,H))},props:(Ue=(Ae=E.get(s))==null?void 0:Ae.props)!=null?Ue:this._getFloatDomProps(s)});const Oe=O.onTransformChange$.subscribeEvent(()=>{const H=Ie(O,g.renderObject,u.skeleton,a.worksheet);F.next(H)});M.add(()=>{this._canvasFloatDomService.removeFloatDom(s)}),Oe&&M.add(Oe),this._domLayerInfoMap.set(s,q)})}))}_scrollUpdateListener(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{var r,o;const n=(s,a)=>{var h;const d=this._getSceneAndTransformerByDrawingSearch(s),u=this._ensureMap(s,a),l=Array.from(u.keys()),c=_.getSheetCommandTarget(this._univerInstanceService,{unitId:s,subUnitId:a}),g=(h=this._renderManagerService.getRenderById(s))==null?void 0:h.with(W.SheetSkeletonManagerService).getWorksheetSkeleton(a);!d||!c||!g||l.forEach(w=>{const f=this._domLayerInfoMap.get(w);if(f){const S=Ie(f.rect,d.renderObject,g.skeleton,c.worksheet);f.position$.next(S)}})};if(e.id===W.SetScrollOperation.id){const s=e.params,{unitId:a,sheetId:d}=s;n(a,d)}else if(e.id===W.SetZoomRatioOperation.id){const s=e.params,{unitId:a}=s;Array.from((o=(r=this._domLayerMap.get(a))==null?void 0:r.keys())!=null?o:[]).forEach(u=>{n(a,u)})}else if(e.id===_.SetFrozenMutation.id){const{unitId:s,subUnitId:a}=e.params;n(s,a)}}))}_getPosition(e,n){var h;const{startX:r,endX:o,startY:s,endY:a}=e,d=(h=this._renderManagerService.getRenderById(n))==null?void 0:h.with(W.ISheetSelectionRenderService);if(d==null)return;const u=d.getSelectionCellByPosition(r,s);if(u==null)return;const l={column:u.actualColumn,columnOffset:r-u.startX,row:u.actualRow,rowOffset:s-u.startY},c=d.getSelectionCellByPosition(o,a);if(c==null)return;const g={column:c.actualColumn,columnOffset:o-c.startX,row:c.actualRow,rowOffset:a-c.startY};return{from:l,to:g}}_featureUpdateListener(){this.disposeWithMe(this._drawingManagerService.update$.subscribe(e=>{e.forEach(n=>{const r=this._drawingManagerService.getDrawingByParam(n);if(!r||r.drawingType!==m.DrawingTypeEnum.DRAWING_DOM)return;const o={...r.transform};this._transformChange$.next({id:n.drawingId,value:o})})}))}_deleteListener(){this.disposeWithMe(this._drawingManagerService.remove$.subscribe(e=>{e.forEach(n=>{this._removeDom(n.drawingId)})}))}addFloatDomToPosition(e){const n=_.getSheetCommandTarget(this._univerInstanceService,{unitId:e.unitId,subUnitId:e.subUnitId});if(!n)throw new Error("cannot find current target!");const{unitId:r,subUnitId:o}=n,{initPosition:s,componentKey:a}=e,d=m.Tools.generateRandomId(),u=this._getPosition(s,r);if(u==null)return;this._ensureMap(r,o).set(d,e);const c={unitId:r,subUnitId:o,drawingId:d,drawingType:m.DrawingTypeEnum.DRAWING_DOM,componentKey:a,sheetTransform:u,transform:{left:s.startX,top:s.startY,width:s.endX-s.startX,height:s.endY-s.startY}};return this._commandService.executeCommand(_e.id,{unitId:r,drawings:[c]}),{id:d,dispose:()=>{this._removeDom(d,!0)}}}_removeDom(e,n=!1){const r=this._domLayerInfoMap.get(e);if(!r)return;const{unitId:o,subUnitId:s}=r;this._domLayerInfoMap.delete(e),r.dispose.dispose();const a=this._getSceneAndTransformerByDrawingSearch(o);if(a&&a.scene.removeObject(r.rect),n){this._ensureMap(o,s).delete(e);const u=this._drawingManagerService.getDrawingByParam({unitId:o,subUnitId:s,drawingId:e});if(!u)return;const l=this._sheetDrawingService.getBatchRemoveOp([u]),{redo:c,objects:g}=l;this._commandService.syncExecuteCommand(p.SetDrawingApplyMutation.id,{unitId:o,subUnitId:s,op:c,objects:g,type:p.DrawingApplyType.REMOVE})}}addHook(e){return this._hooks.push(e),{dispose:()=>{const n=this._hooks.findIndex(r=>r===e);this._hooks.splice(n,1)}}}};exports.SheetCanvasFloatDomManagerService=zt([ee(0,m.Inject(N.IRenderManagerService)),ee(1,m.IUniverInstanceService),ee(2,m.Inject(m.ICommandService)),ee(3,P.IDrawingManagerService),ee(4,m.Inject(G.CanvasFloatDomService)),ee(5,p.ISheetDrawingService)],exports.SheetCanvasFloatDomManagerService);var Jt=Object.defineProperty,Zt=Object.getOwnPropertyDescriptor,Qt=(i,t,e,n)=>{for(var r=n>1?void 0:n?Zt(t,e):t,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(t,e,r):s(r))||r);return n&&r&&Jt(t,e,r),r},ue=(i,t)=>(e,n)=>t(e,n,i);let pe=class extends m.Disposable{constructor(i,t,e,n){super(),this._sheetPrintInterceptorService=i,this._drawingRenderService=t,this._drawingManagerService=e,this._renderManagerService=n,this._initPrinting()}_initPrinting(){this.disposeWithMe(this._sheetPrintInterceptorService.interceptor.intercept(this._sheetPrintInterceptorService.interceptor.getInterceptPoints().PRINTING_COMPONENT_COLLECT,{handler:(i,t,e)=>{const{unitId:n,scene:r,subUnitId:o}=t,s=this._drawingManagerService.getDrawingDataForUnit(n),a=s==null?void 0:s[o];return a&&a.order.forEach(d=>{this._drawingRenderService.renderDrawing(a.data[d],r)}),e()}})),this.disposeWithMe(this._sheetPrintInterceptorService.interceptor.intercept(this._sheetPrintInterceptorService.interceptor.getInterceptPoints().PRINTING_RANGE,{handler:(i,t,e)=>{const{unitId:n,subUnitId:r}=t,o=this._renderManagerService.getRenderById(n);if(!o)return e(i);const s=o.with(W.SheetSkeletonManagerService).getWorksheetSkeleton(r);if(!s)return e(i);const a=this._drawingManagerService.getDrawingDataForUnit(n),d=a==null?void 0:a[t.subUnitId];if(!d)return e(i);const{scaleX:u,scaleY:l}=o.scene,c=i?{...i}:{startColumn:0,endColumn:0,endRow:0,startRow:0},g=d.order.map(h=>d.data[h]).filter(h=>h.drawingType!==P.DrawingTypeEnum.DRAWING_DOM);return g.length?(g.forEach(h=>{if(!h.groupId&&h.transform&&m.Tools.isDefine(h.transform.left)&&m.Tools.isDefine(h.transform.top)&&m.Tools.isDefine(h.transform.width)&&m.Tools.isDefine(h.transform.height)){const w=s.skeleton.getCellPositionByOffset(h.transform.left,h.transform.top,u,l,{x:0,y:0}),f=s.skeleton.getCellPositionByOffset(h.transform.left+h.transform.width,h.transform.top+h.transform.height,u,l,{x:0,y:0});w.column<c.startColumn&&(c.startColumn=w.column),w.row<c.startRow&&(c.startRow=w.row),c.endRow<f.row&&(c.endRow=f.row),c.endColumn<f.column&&(c.endColumn=f.column)}}),e(c)):e(i)}}))}};pe=Qt([m.OnLifecycle(m.LifecycleStages.Rendered,pe),ue(0,m.Inject(W.SheetPrintInterceptorService)),ue(1,m.Inject(Z.DrawingRenderService)),ue(2,P.IDrawingManagerService),ue(3,N.IRenderManagerService)],pe);var en=Object.defineProperty,tn=Object.getOwnPropertyDescriptor,nn=(i,t,e,n)=>{for(var r=n>1?void 0:n?tn(t,e):t,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(t,e,r):s(r))||r);return n&&r&&en(t,e,r),r},re=(i,t)=>(e,n)=>t(e,n,i);let fe=class extends m.Disposable{constructor(i,t,e,n,r){super(),this._drawingManagerService=i,this._renderManagerService=t,this._permissionService=e,this._univerInstanceService=n,this._userManagerService=r,this._initDrawingVisible(),this._initDrawingEditable(),this._initViewPermissionChange(),this._initEditPermissionChange()}_initDrawingVisible(){const i=this._univerInstanceService.getCurrentTypeOfUnit$(m.UniverInstanceType.UNIVER_SHEET);this.disposeWithMe(V.combineLatest([i,this._userManagerService.currentUser$]).subscribe(([t,e])=>{if(!t){this._drawingManagerService.setDrawingVisible(!1);return}t.activeSheet$.subscribe(n=>{if(!n){this._drawingManagerService.setDrawingVisible(!1);return}const r=t.getUnitId(),o=n.getSheetId();if(this._permissionService.composePermission([new _.WorkbookViewPermission(r).id,new _.WorksheetViewPermission(r,o).id]).every(a=>a.value))this._drawingManagerService.setDrawingVisible(!0);else{this._drawingManagerService.setDrawingVisible(!1);const a=t.getUnitId(),d=n.getSheetId(),u=this._drawingManagerService.getDrawingData(a,d),l=Object.values(u),c=this._renderManagerService.getRenderById(a),g=c==null?void 0:c.scene;if(g==null)return;g.getAllObjects().forEach(w=>{w.classType===N.RENDER_CLASS_TYPE.IMAGE&&l.some(f=>w.oKey.includes(f.drawingId))&&g.removeObject(w)})}})}))}_initDrawingEditable(){const i=this._univerInstanceService.getCurrentTypeOfUnit$(m.UniverInstanceType.UNIVER_SHEET);this.disposeWithMe(V.combineLatest([i,this._userManagerService.currentUser$]).subscribe(([t,e])=>{if(!t){this._drawingManagerService.setDrawingEditable(!1);return}t.activeSheet$.subscribe(n=>{if(!n){this._drawingManagerService.setDrawingEditable(!1);return}const r=t.getUnitId(),o=n.getSheetId();if(this._permissionService.composePermission([new _.WorkbookEditablePermission(r).id,new _.WorksheetEditPermission(r,o).id]).every(a=>a.value))this._drawingManagerService.setDrawingEditable(!0);else{this._drawingManagerService.setDrawingEditable(!1);const a=t.getUnitId(),d=n.getSheetId(),u=this._drawingManagerService.getDrawingData(a,d),l=Object.values(u),c=this._renderManagerService.getRenderById(a),g=c==null?void 0:c.scene;if(g==null)return;g.getAllObjects().forEach(w=>{w.classType===N.RENDER_CLASS_TYPE.IMAGE&&l.some(f=>w.oKey.includes(f.drawingId))&&g.detachTransformerFrom(w)})}})}))}_initViewPermissionChange(){const i=this._univerInstanceService.getCurrentTypeOfUnit$(m.UniverInstanceType.UNIVER_SHEET);this.disposeWithMe(V.combineLatest([i,this._userManagerService.currentUser$]).subscribe(([t,e])=>{t&&t.activeSheet$.subscribe(n=>{var c;if(!n)return;const r=t.getUnitId(),o=n.getSheetId();let s=!0;const a=this._renderManagerService.getRenderById(r),d=a==null?void 0:a.scene;if(d==null)return;const u=d.getTransformerByCreate(),l=this._permissionService.composePermission$([new _.WorkbookViewPermission(r).id,new _.WorksheetViewPermission(r,o).id]).pipe(V.map(g=>g.every(h=>h.value)));l==null||l.pipe(V.filter(g=>g!==s),V.distinctUntilChanged()).subscribe({next:g=>{s=g,this._drawingManagerService.setDrawingVisible(g);const h=d.getAllObjects(),w=this._drawingManagerService.getDrawingData(r,o),f=Object.values(w);g?this._drawingManagerService.addNotification(f):(h.forEach(S=>{S.classType===N.RENDER_CLASS_TYPE.IMAGE&&f.some(C=>S.oKey.includes(C.drawingId))&&d.removeObject(S)}),u.clearSelectedObjects())}}),(c=this._permissionService.getPermissionPoint$(new _.WorksheetViewPermission(r,o).id))==null||c.pipe(V.filter(g=>g.value!==s),V.distinctUntilChanged()).subscribe({complete:()=>{s=!0,this._drawingManagerService.setDrawingVisible(!0);const g=this._drawingManagerService.getDrawingData(r,o),h=Object.values(g);this._drawingManagerService.addNotification(h)}})})}))}_initEditPermissionChange(){const i=this._univerInstanceService.getCurrentTypeOfUnit$(m.UniverInstanceType.UNIVER_SHEET);this.disposeWithMe(V.combineLatest([i,this._userManagerService.currentUser$]).subscribe(([t,e])=>{t&&t.activeSheet$.subscribe(n=>{var c;if(!n)return;const r=t.getUnitId(),o=n.getSheetId();let s=!0;const a=this._renderManagerService.getRenderById(r),d=a==null?void 0:a.scene;if(d==null)return;const u=d.getTransformerByCreate(),l=this._permissionService.composePermission$([new _.WorkbookEditablePermission(r).id,new _.WorksheetEditPermission(r,o).id]).pipe(V.map(g=>g.every(h=>h.value)));l==null||l.pipe(V.filter(g=>g!==s),V.distinctUntilChanged()).subscribe({next:g=>{s=g,this._drawingManagerService.setDrawingEditable(g);const h=d.getAllObjects(),w=this._drawingManagerService.getDrawingData(r,o),f=Object.values(w);g?(h.forEach(S=>{S.classType===N.RENDER_CLASS_TYPE.IMAGE&&f.some(C=>S.oKey.includes(C.drawingId))&&d.attachTransformerTo(S)}),this._drawingManagerService.addNotification(f)):(h.forEach(S=>{S.classType===N.RENDER_CLASS_TYPE.IMAGE&&f.some(C=>S.oKey.includes(C.drawingId))&&d.detachTransformerFrom(S)}),u.clearSelectedObjects())}}),(c=this._permissionService.getPermissionPoint$(new _.WorksheetEditPermission(r,o).id))==null||c.pipe(V.filter(g=>g.value!==s),V.distinctUntilChanged()).subscribe({complete:()=>{s=!0;const g=t.getUnitId(),h=n.getSheetId(),w=this._drawingManagerService.getDrawingData(g,h),f=Object.values(w),S=this._renderManagerService.getRenderById(g),C=S==null?void 0:S.scene;if(C==null)return;this._drawingManagerService.setDrawingEditable(!0),C.getAllObjects().forEach(D=>{D.classType===N.RENDER_CLASS_TYPE.IMAGE&&f.some(R=>D.oKey.includes(R.drawingId))&&C.detachTransformerFrom(D)})}})})}))}};fe=nn([m.OnLifecycle(m.LifecycleStages.Rendered,fe),re(0,P.IDrawingManagerService),re(1,N.IRenderManagerService),re(2,m.IPermissionService),re(3,m.IUniverInstanceService),re(4,m.Inject(m.UserManagerService))],fe);var rn=Object.defineProperty,on=Object.getOwnPropertyDescriptor,sn=(i,t,e,n)=>{for(var r=n>1?void 0:n?on(t,e):t,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(t,e,r):s(r))||r);return n&&r&&rn(t,e,r),r},De=(i,t)=>(e,n)=>t(e,n,i);let we=class extends m.Disposable{constructor(t,e,n){super();Y(this,"_copyInfo");this._sheetClipboardService=t,this._renderManagerService=e,this._sheetDrawingService=n,this._initCopyPaste()}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:"SHEET_IMAGE_UI_PLUGIN",onBeforeCopy:(t,e,n)=>this._collect(t,e,n),onPasteCells:(t,e,n,r)=>{const{copyType:o=W.COPY_TYPE.COPY,pasteType:s}=r,{range:a}=t||{},{range:d,unitId:u,subUnitId:l}=e;return this._generateMutations(d,{copyType:o,pasteType:s,copyRange:a,unitId:u,subUnitId:l})},onPastePlainText:(t,e)=>({undos:[],redos:[]})})}_collect(t,e,n){var g;const r=(g=this._renderManagerService.getRenderById(t))==null?void 0:g.with(W.SheetSkeletonManagerService);if(!r)return;const o=r.attachRangeWithCoord(n);if(!o)return;const{startX:s,endX:a,startY:d,endY:u}=o,l=this._sheetDrawingService.getDrawingData(t,e),c=[];Object.keys(l).forEach(h=>{const w=l[h],{transform:f}=w;if(w.anchorType!==p.SheetDrawingAnchorType.Both||!f)return;const{left:S=0,top:C=0,width:y=0,height:D=0}=f,{drawingStartX:R,drawingEndX:I,drawingStartY:b,drawingEndY:v}={drawingStartX:S,drawingEndX:S+y,drawingStartY:C,drawingEndY:C+D};s<=R&&I<=a&&d<=b&&v<=u&&c.push(w)}),c.length&&(this._copyInfo={drawings:c,unitId:t,subUnitId:e})}_generateMutations(t,e){var T;if(!this._copyInfo)return{redos:[],undos:[]};if([W.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,W.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,W.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,W.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMULA].includes(e.pasteType))return{redos:[],undos:[]};const{copyRange:n}=e;if(!n)return{redos:[],undos:[]};const{drawings:r,unitId:o,subUnitId:s}=this._copyInfo,{ranges:[a,d],mapFunc:u}=W.virtualizeDiscreteRanges([n,t]),{row:l,col:c}=u(a.startRow,a.startColumn),{row:g,col:h}=u(d.startRow,d.startColumn),w=(T=this._renderManagerService.getRenderById(o))==null?void 0:T.with(W.SheetSkeletonManagerService);if(!w)return{redos:[],undos:[]};const f=w.attachRangeWithCoord({startRow:l,endRow:l,startColumn:c,endColumn:c}),S=w.attachRangeWithCoord({startRow:g,endRow:g,startColumn:h,endColumn:h});if(!f||!S)return{redos:[],undos:[]};const C=[],y=[],D=S.startX-f.startX,R=S.startY-f.startY,I=g-l,b=h-c,v=e.copyType===W.COPY_TYPE.CUT,{_sheetDrawingService:A}=this;return r.forEach(L=>{const{transform:O,sheetTransform:E}=L;if(!O)return;const M={...L,unitId:o,subUnitId:s,drawingId:v?L.drawingId:m.Tools.generateRandomId(),transform:{...O,left:O.left+D,top:O.top+R},sheetTransform:{to:{...E.to,row:E.to.row+I,column:E.to.column+b},from:{...E.from,row:E.from.row+I,column:E.from.column+b}}};if(v){const{undo:j,redo:F,objects:q}=A.getBatchUpdateOp([M]);C.push({id:p.SetDrawingApplyMutation.id,params:{unitId:o,subUnitId:s,type:p.DrawingApplyType.UPDATE,op:F,objects:q}}),y.push({id:p.SetDrawingApplyMutation.id,params:{unitId:o,subUnitId:s,type:p.DrawingApplyType.UPDATE,op:j,objects:q}})}else{const{undo:j,redo:F,objects:q}=A.getBatchAddOp([M]);C.push({id:p.SetDrawingApplyMutation.id,params:{op:F,unitId:o,subUnitId:s,objects:q,type:p.DrawingApplyType.INSERT}}),y.push({id:p.SetDrawingApplyMutation.id,params:{op:j,unitId:o,subUnitId:s,objects:q,type:p.DrawingApplyType.REMOVE}})}}),{redos:C,undos:y}}};we=sn([m.OnLifecycle(m.LifecycleStages.Ready,we),De(0,W.ISheetClipboardService),De(1,N.IRenderManagerService),De(2,p.ISheetDrawingService)],we);var Fe=Object.defineProperty,an=Object.getOwnPropertyDescriptor,cn=(i,t,e)=>t in i?Fe(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,dn=(i,t,e,n)=>{for(var r=n>1?void 0:n?an(t,e):t,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(t,e,r):s(r))||r);return n&&r&&Fe(t,e,r),r},Ce=(i,t)=>(e,n)=>t(e,n,i),ke=(i,t,e)=>cn(i,typeof t!="symbol"?t+"":t,e);const ln="SHEET_IMAGE_UI_PLUGIN";exports.UniverSheetsDrawingUIPlugin=class extends m.Plugin{constructor(e={},n,r,o){super();Y(this,"_pluginConfig");this._injector=n,this._localeService=r,this._renderManagerService=o,this._pluginConfig=m.Tools.deepMerge({},Vt,e)}onStarting(e){super.onStarting(e),this._initDependencies(e)}onRendered(){this._registerRenderModules()}_initDependencies(e){const n=[[exports.SheetCanvasFloatDomManagerService],[ie,{useFactory:()=>this._injector.createInstance(ie,this._pluginConfig)}],[ge],[pe],[fe]],r=[he,me];n.forEach(o=>e.add(o)),r.forEach(o=>this._renderManagerService.registerRenderModule(m.UniverInstanceType.UNIVER_SHEET,o))}_registerRenderModules(){[[we]].forEach(e=>{this.disposeWithMe(this._renderManagerService.registerRenderModule(m.UniverInstanceType.UNIVER_SHEET,e))})}};ke(exports.UniverSheetsDrawingUIPlugin,"type",m.UniverInstanceType.UNIVER_SHEET);ke(exports.UniverSheetsDrawingUIPlugin,"pluginName",ln);exports.UniverSheetsDrawingUIPlugin=dn([m.DependentOn(P.UniverDrawingPlugin,Z.UniverDrawingUIPlugin,p.UniverSheetsDrawingPlugin),Ce(1,m.Inject(m.Injector)),Ce(2,m.Inject(m.LocaleService)),Ce(3,N.IRenderManagerService)],exports.UniverSheetsDrawingUIPlugin);exports.ClearSheetDrawingTransformerOperation=B;exports.DeleteDrawingsCommand=be;exports.EditSheetDrawingOperation=Me;exports.GroupSheetDrawingCommand=Te;exports.InsertCellImageOperation=oe;exports.InsertFloatImageOperation=se;exports.InsertSheetDrawingCommand=_e;exports.MoveDrawingsCommand=te;exports.RemoveSheetDrawingCommand=ve;exports.SetDrawingArrangeCommand=Re;exports.SetSheetDrawingCommand=ae;exports.SidebarSheetDrawingOperation=ye;exports.UngroupSheetDrawingCommand=Ee;