@univerjs/sheets-drawing-ui 0.1.13-nightly.202406041140

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/README.md +16 -0
  2. package/lib/cjs/index.js +1 -0
  3. package/lib/es/index.js +2056 -0
  4. package/lib/index.css +1 -0
  5. package/lib/locale/en-US.json +31 -0
  6. package/lib/locale/ru-RU.json +31 -0
  7. package/lib/locale/zh-CN.json +31 -0
  8. package/lib/types/basics/transform-position.d.ts +6 -0
  9. package/lib/types/commands/commands/delete-drawings.command.d.ts +3 -0
  10. package/lib/types/commands/commands/group-sheet-drawing.command.d.ts +6 -0
  11. package/lib/types/commands/commands/insert-sheet-drawing.command.d.ts +6 -0
  12. package/lib/types/commands/commands/interfaces.d.ts +21 -0
  13. package/lib/types/commands/commands/move-drawings.command.d.ts +6 -0
  14. package/lib/types/commands/commands/remove-sheet-drawing.command.d.ts +6 -0
  15. package/lib/types/commands/commands/set-drawing-arrange.command.d.ts +10 -0
  16. package/lib/types/commands/commands/set-sheet-drawing.command.d.ts +6 -0
  17. package/lib/types/commands/commands/ungroup-sheet-drawing.command.d.ts +6 -0
  18. package/lib/types/commands/commands/utils.d.ts +4 -0
  19. package/lib/types/commands/operations/clear-drawing-transformer.operation.d.ts +3 -0
  20. package/lib/types/commands/operations/edit-sheet-drawing.operation.d.ts +4 -0
  21. package/lib/types/commands/operations/insert-image.operation.d.ts +7 -0
  22. package/lib/types/commands/operations/open-drawing-panel.operation.d.ts +6 -0
  23. package/lib/types/controllers/drawing-popup-menu.controller.d.ts +24 -0
  24. package/lib/types/controllers/sheet-drawing-transform-affected.controller.d.ts +34 -0
  25. package/lib/types/controllers/sheet-drawing-update.controller.d.ts +35 -0
  26. package/lib/types/controllers/sheet-drawing.controller.d.ts +23 -0
  27. package/lib/types/controllers/shortcuts/drawing.shortcut.d.ts +10 -0
  28. package/lib/types/index.d.ts +17 -0
  29. package/lib/types/locale/en-US.d.ts +4 -0
  30. package/lib/types/locale/ru-RU.d.ts +4 -0
  31. package/lib/types/locale/zh-CN.d.ts +47 -0
  32. package/lib/types/plugin.d.ts +14 -0
  33. package/lib/types/services/canvas-float-dom-manager.service.d.ts +60 -0
  34. package/lib/types/views/menu/image.menu.d.ts +7 -0
  35. package/lib/types/views/sheet-image-panel/SheetDrawingAnchor.d.ts +7 -0
  36. package/lib/types/views/sheet-image-panel/SheetDrawingPanel.d.ts +3 -0
  37. package/lib/types/views/sheet-image-panel/component-name.d.ts +16 -0
  38. package/lib/types/views/upload-component/UploadFile.d.ts +9 -0
  39. package/lib/types/views/upload-component/component-name.d.ts +20 -0
  40. package/lib/types/views/upload-loading/UploadLoading.d.ts +3 -0
  41. package/lib/umd/index.js +1 -0
  42. package/package.json +99 -0
package/README.md ADDED
@@ -0,0 +1,16 @@
1
+ # @univerjs/sheets-drawing-ui
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)
5
+
6
+ ## Introduction
7
+
8
+ > TODO: Introduction
9
+
10
+ ## Usage
11
+
12
+ ### Installation
13
+
14
+ ```shell
15
+ npm i @univerjs/sheets-drawing-ui
16
+ ```
@@ -0,0 +1 @@
1
+ "use strict";var Le=Object.defineProperty;var je=(e,n,t)=>n in e?Le(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t;var X=(e,n,t)=>(je(e,typeof n!="symbol"?n+"":n,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("@univerjs/core"),B=require("@wendellhu/redi"),ee=require("@univerjs/drawing-ui"),m=require("@univerjs/sheets-drawing"),E=require("@univerjs/drawing"),k=require("@univerjs/engine-render"),z=require("@univerjs/sheets-ui"),ne=require("rxjs"),W=require("@univerjs/ui"),$=require("@wendellhu/redi/react-bindings"),C=require("@univerjs/sheets"),O=require("react"),J=require("@univerjs/design"),se=require("clsx"),j={id:"sheet.operation.clear-drawing-transformer",type:p.CommandType.MUTATION,handler:(e,n)=>{const t=e.get(k.IRenderManagerService);return n.forEach(r=>{var i,o;(o=(i=t.getRenderById(r))==null?void 0:i.scene.getTransformer())==null||o.debounceRefreshControls()}),!0}},fe={id:"sheet.command.remove-sheet-image",type:p.CommandType.COMMAND,handler:(e,n)=>{const t=e.get(p.ICommandService),r=e.get(p.IUndoRedoService),i=e.get(m.ISheetDrawingService);if(!n)return!1;const{drawings:o}=n,s=[];o.forEach(w=>{const{unitId:f}=w;s.push(f)});const a=i.getBatchRemoveOp(o),{unitId:c,subUnitId:u,undo:l,redo:d,objects:h}=a;return t.syncExecuteCommand(m.SetDrawingApplyMutation.id,{unitId:c,subUnitId:u,op:d,objects:h,type:m.DrawingApplyType.REMOVE})?(r.pushUndoRedo({unitID:c,undoMutations:[{id:m.SetDrawingApplyMutation.id,params:{unitId:c,subUnitId:u,op:l,objects:h,type:m.DrawingApplyType.INSERT}},{id:j.id,params:s}],redoMutations:[{id:m.SetDrawingApplyMutation.id,params:{unitId:c,subUnitId:u,op:d,objects:h,type:m.DrawingApplyType.REMOVE}},{id:j.id,params:s}]}),!0):!1}},Ce="COMPONENT_SHEET_DRAWING_PANEL",Ie={id:"sidebar.operation.sheet-image",type:p.CommandType.COMMAND,handler:async(e,n)=>{const t=e.get(W.ISidebarService),r=e.get(p.LocaleService),i=e.get(p.IUniverInstanceService),o=e.get(E.IDrawingManagerService);if(!C.getSheetCommandTarget(i))return!1;switch(n.value){case"open":t.open({header:{title:r.t("sheetImage.panel.title")},children:{label:Ce},onClose:()=>{o.focusDrawing(null)},width:360});break;case"close":default:t.close();break}return!0}},De={id:"sheet.operation.edit-sheet-image",type:p.CommandType.OPERATION,handler:(e,n)=>{const t=e.get(E.IDrawingManagerService),r=e.get(p.ICommandService);return n==null?!1:(t.focusDrawing([n]),r.executeCommand(Ie.id,{value:"open"}),!0)}},We="univer-upload-loading",Ge="univer-upload-loading-body",Be="univer-upload-loading-body-animation",ke="univer-UniverCircleAnimation",xe="univer-upload-loading-body-text",ae={uploadLoading:We,uploadLoadingBody:Ge,uploadLoadingBodyAnimation:Be,univerCircleAnimation:ke,uploadLoadingBodyText:xe},Fe=()=>{const e=$.useDependency(E.IImageIoService),n=$.useDependency(p.LocaleService),[t,r]=O.useState(0);return O.useEffect(()=>{const i=e.change$.subscribe(o=>{r(o)});return()=>{i.unsubscribe()}},[e]),O.createElement("div",{style:{display:t>0?"block":"none"},className:ae.uploadLoading},O.createElement("div",{className:ae.uploadLoadingBody},O.createElement("div",{className:ae.uploadLoadingBodyAnimation}),O.createElement("div",{className:ae.uploadLoadingBodyText},`${n.t("uploadLoading.loading")}: ${t}`)))};var Ve=(e,n,t,r)=>{for(var i=n,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},Z=(e,n)=>(t,r)=>n(t,r,e);let ce=class extends p.RxDisposable{constructor(n,t,r,i,o,s,a){super();X(this,"_initImagePopupMenu",new Set);this._injector=n,this._drawingManagerService=t,this._canvasPopManagerService=r,this._renderManagerService=i,this._univerInstanceService=o,this._contextService=s,this._uiPartsService=a,this._init()}_init(){this._univerInstanceService.getCurrentTypeOfUnit$(p.UniverInstanceType.UNIVER_SHEET).pipe(ne.takeUntil(this.dispose$)).subscribe(n=>this._create(n)),this._univerInstanceService.getTypeOfUnitDisposed$(p.UniverInstanceType.UNIVER_SHEET).pipe(ne.takeUntil(this.dispose$)).subscribe(n=>this._dispose(n)),this._univerInstanceService.getAllUnitsForType(p.UniverInstanceType.UNIVER_SHEET).forEach(n=>this._create(n)),this._uiPartsService.registerComponent(W.BuiltInUIPart.CONTENT,()=>$.connectInjector(Fe,this._injector))}_dispose(n){const t=n.getUnitId();this._renderManagerService.removeRender(t)}_create(n){if(!n)return;const t=n.getUnitId();this._renderManagerService.has(t)&&!this._initImagePopupMenu.has(t)&&(this._popupMenuListener(t),this._initImagePopupMenu.add(t))}_hasCropObject(n){const t=n.getAllObjects();for(const r of t)if(r instanceof ee.ImageCropperObject)return!0;return!1}_popupMenuListener(n){var o;const t=(o=this._renderManagerService.getRenderById(n))==null?void 0:o.scene;if(!t)return;const r=t.getTransformerByCreate();if(!r)return;const i=[];this.disposeWithMe(p.toDisposable(r.onCreateControlObservable.add(()=>{if(this._contextService.setContextValue(p.FOCUSING_COMMON_DRAWINGS,!0),this._hasCropObject(t))return;const s=r.getSelectedObjectMap();if(s.size>1){i.forEach(g=>g.dispose());return}const a=s.values().next().value;if(!a)return;const c=a.oKey,u=this._drawingManagerService.getDrawingOKey(c);if(!u)return;const{unitId:l,subUnitId:d,drawingId:h}=u;i.push(this.disposeWithMe(this._canvasPopManagerService.attachPopupToObject(a,{componentKey:ee.COMPONENT_IMAGE_POPUP_MENU,direction:"horizontal",offset:[2,0],extraProps:{menuItems:this._getImageMenuItems(l,d,h)}}))),this._drawingManagerService.focusDrawing([{unitId:l,subUnitId:d,drawingId:h}])}))),this.disposeWithMe(p.toDisposable(r.onClearControlObservable.add(()=>{i.forEach(s=>s.dispose()),this._contextService.setContextValue(p.FOCUSING_COMMON_DRAWINGS,!1),this._drawingManagerService.focusDrawing(null)}))),this.disposeWithMe(p.toDisposable(r.onChangingObservable.add(()=>{i.forEach(s=>s.dispose())})))}_getImageMenuItems(n,t,r){return[{label:"image-popup.edit",index:0,commandId:De.id,commandParams:{unitId:n,subUnitId:t,drawingId:r},disable:!1},{label:"image-popup.delete",index:1,commandId:fe.id,commandParams:{unitId:n,drawings:[{unitId:n,subUnitId:t,drawingId:r}]},disable:!1},{label:"image-popup.crop",index:2,commandId:ee.OpenImageCropOperation.id,commandParams:{unitId:n,subUnitId:t,drawingId:r},disable:!1},{label:"image-popup.reset",index:3,commandId:ee.ImageResetSizeOperation.id,commandParams:[{unitId:n,subUnitId:t,drawingId:r}],disable:!1}]}};ce=Ve([p.OnLifecycle(p.LifecycleStages.Steady,ce),Z(0,B.Inject(B.Injector)),Z(1,E.IDrawingManagerService),Z(2,B.Inject(z.SheetCanvasPopManagerService)),Z(3,k.IRenderManagerService),Z(4,p.IUniverInstanceService),Z(5,p.IContextService),Z(6,B.Inject(W.IUIPartsService))],ce);const ge={id:"sheet.operation.insert-float-image",type:p.CommandType.OPERATION,handler:(e,n)=>!0},ue={id:"sheet.operation.insert-cell-image",type:p.CommandType.OPERATION,handler:(e,n)=>!0},we={id:"sheet.command.insert-sheet-image",type:p.CommandType.COMMAND,handler:(e,n)=>{const t=e.get(p.ICommandService),r=e.get(p.IUndoRedoService),i=e.get(m.ISheetDrawingService);if(!n)return!1;const o=n.drawings,s=o.map(w=>w.unitId),a=i.getBatchAddOp(o),{unitId:c,subUnitId:u,undo:l,redo:d,objects:h}=a;return t.syncExecuteCommand(m.SetDrawingApplyMutation.id,{op:d,unitId:c,subUnitId:u,objects:h,type:m.DrawingApplyType.INSERT})?(r.pushUndoRedo({unitID:c,undoMutations:[{id:m.SetDrawingApplyMutation.id,params:{op:l,unitId:c,subUnitId:u,objects:h,type:m.DrawingApplyType.REMOVE}},{id:j.id,params:s}],redoMutations:[{id:m.SetDrawingApplyMutation.id,params:{op:d,unitId:c,subUnitId:u,objects:h,type:m.DrawingApplyType.INSERT}},{id:j.id,params:s}]}),!0):!1}},he={id:"sheet.command.set-sheet-image",type:p.CommandType.COMMAND,handler:(e,n)=>{const t=e.get(p.ICommandService),r=e.get(p.IUndoRedoService),i=e.get(m.ISheetDrawingService);if(!n)return!1;const{drawings:o}=n,s=i.getBatchUpdateOp(o),{unitId:a,subUnitId:c,undo:u,redo:l,objects:d}=s;return t.syncExecuteCommand(m.SetDrawingApplyMutation.id,{unitId:a,subUnitId:c,op:l,objects:d,type:m.DrawingApplyType.UPDATE})?(r.pushUndoRedo({unitID:a,undoMutations:[{id:m.SetDrawingApplyMutation.id,params:{unitId:a,subUnitId:c,op:u,objects:d,type:m.DrawingApplyType.UPDATE}},{id:j.id,params:[a]}],redoMutations:[{id:m.SetDrawingApplyMutation.id,params:{unitId:a,subUnitId:c,op:l,objects:d,type:m.DrawingApplyType.UPDATE}},{id:j.id,params:[a]}]}),!0):!1}},ye={id:"sheet.command.set-drawing-arrange",type:p.CommandType.COMMAND,handler:(e,n)=>{const t=e.get(p.ICommandService),r=e.get(p.IUndoRedoService);if(!n)return!1;const i=e.get(m.ISheetDrawingService),{unitId:o,subUnitId:s,drawingIds:a,arrangeType:c}=n,u={unitId:o,subUnitId:s,drawingIds:a};let l;if(c===E.ArrangeTypeEnum.forward?l=i.getForwardDrawingsOp(u):c===E.ArrangeTypeEnum.backward?l=i.getBackwardDrawingOp(u):c===E.ArrangeTypeEnum.front?l=i.getFrontDrawingsOp(u):c===E.ArrangeTypeEnum.back&&(l=i.getBackDrawingsOp(u)),l==null)return!1;const{objects:d,redo:h,undo:g}=l;return t.syncExecuteCommand(m.SetDrawingApplyMutation.id,{op:h,unitId:o,subUnitId:s,objects:d,type:m.DrawingApplyType.ARRANGE})?(r.pushUndoRedo({unitID:o,undoMutations:[{id:m.SetDrawingApplyMutation.id,params:{op:g,unitId:o,subUnitId:s,objects:d,type:m.DrawingApplyType.ARRANGE}}],redoMutations:[{id:m.SetDrawingApplyMutation.id,params:{op:h,unitId:o,subUnitId:s,objects:d,type:m.DrawingApplyType.ARRANGE}}]}),!0):!1}};function He(e){const n=[];return e.forEach(t=>{const{parent:r,children:i}=t,{unitId:o,subUnitId:s,drawingId:a}=r,c=k.getGroupState(0,0,i.map(d=>d.transform||{})),u=i.map(d=>{const h=d.transform||{left:0,top:0},{unitId:g,subUnitId:w,drawingId:f}=d;return{unitId:g,subUnitId:w,drawingId:f,transform:{...h,left:h.left-c.left,top:h.top-c.top},groupId:a}}),l={unitId:o,subUnitId:s,drawingId:a,drawingType:E.DrawingTypeEnum.DRAWING_GROUP,transform:c};n.push({parent:l,children:u})}),n}function Ye(e){const n=[];return e.forEach(t=>{const{parent:r,children:i}=t,{unitId:o,subUnitId:s,drawingId:a,transform:c={width:0,height:0}}=r;if(c==null)return;const u=i.map(d=>{const{transform:h}=d,{unitId:g,subUnitId:w,drawingId:f}=d,_=k.transformObjectOutOfGroup(h||{},c,c.width||0,c.height||0);return{unitId:g,subUnitId:w,drawingId:f,transform:_,groupId:void 0}}),l={unitId:o,subUnitId:s,drawingId:a,drawingType:E.DrawingTypeEnum.DRAWING_GROUP,transform:{left:0,top:0}};n.push({parent:l,children:u})}),n}const Re={id:"sheet.command.group-sheet-image",type:p.CommandType.COMMAND,handler:(e,n)=>{const t=e.get(p.ICommandService),r=e.get(p.IUndoRedoService),i=e.get(m.ISheetDrawingService);if(!n)return!1;const o=[];n.forEach(({parent:g,children:w})=>{o.push(g.unitId),w.forEach(f=>{o.push(f.unitId)})});const s=i.getGroupDrawingOp(n),{unitId:a,subUnitId:c,undo:u,redo:l,objects:d}=s;return t.syncExecuteCommand(m.SetDrawingApplyMutation.id,{op:l,unitId:a,subUnitId:c,objects:d,type:m.DrawingApplyType.GROUP})?(r.pushUndoRedo({unitID:a,undoMutations:[{id:m.SetDrawingApplyMutation.id,params:{op:u,unitId:a,subUnitId:c,objects:Ye(d),type:m.DrawingApplyType.UNGROUP}},{id:j.id,params:o}],redoMutations:[{id:m.SetDrawingApplyMutation.id,params:{op:l,unitId:a,subUnitId:c,objects:d,type:m.DrawingApplyType.GROUP}},{id:j.id,params:o}]}),!0):!1}},Me={id:"sheet.command.ungroup-sheet-image",type:p.CommandType.COMMAND,handler:(e,n)=>{const t=e.get(p.ICommandService),r=e.get(p.IUndoRedoService),i=e.get(m.ISheetDrawingService);if(!n)return!1;const o=[];n.forEach(({parent:g,children:w})=>{o.push(g.unitId),w.forEach(f=>{o.push(f.unitId)})});const s=i.getUngroupDrawingOp(n),{unitId:a,subUnitId:c,undo:u,redo:l,objects:d}=s;return t.syncExecuteCommand(m.SetDrawingApplyMutation.id,{op:l,unitId:a,subUnitId:c,objects:d,type:m.DrawingApplyType.UNGROUP})?(r.pushUndoRedo({unitID:a,undoMutations:[{id:m.SetDrawingApplyMutation.id,params:{op:u,unitId:a,subUnitId:c,objects:He(d),type:m.DrawingApplyType.GROUP}},{id:j.id,params:o}],redoMutations:[{id:m.SetDrawingApplyMutation.id,params:{op:l,unitId:a,subUnitId:c,objects:d,type:m.DrawingApplyType.UNGROUP}},{id:j.id,params:o}]}),!0):!1}};function F(e,n){const{from:t,to:r}=e,{column:i,columnOffset:o,row:s,rowOffset:a}=t,{column:c,columnOffset:u,row:l,rowOffset:d}=r,h=n.attachRangeWithCoord({startColumn:i,endColumn:i,startRow:s,endRow:s});if(h==null)return;const g=n.attachRangeWithCoord({startColumn:c,endColumn:c,startRow:l,endRow:l});if(g==null)return;const{startX:w,startY:f}=h,{startX:_,startY:M}=g,D=k.precisionTo(w+o,1),I=k.precisionTo(f+a,1);let R=k.precisionTo(_+u-D,1),v=k.precisionTo(M+d-I,1);return h.startX===g.endX&&(R=0),h.startY===g.endY&&(v=0),{left:D,top:I,width:R,height:v}}function L(e,n){const{left:t=0,top:r=0,width:i=0,height:o=0}=e,s=n.getSelectionCellByPosition(t,r);if(s==null)return;const a={column:s.actualColumn,columnOffset:k.precisionTo(t-s.startX,1),row:s.actualRow,rowOffset:k.precisionTo(r-s.startY,1)},c=n.getSelectionCellByPosition(t+i,r+o);if(c==null)return;const u={column:c.actualColumn,columnOffset:k.precisionTo(t+i-c.startX,1),row:c.actualRow,rowOffset:k.precisionTo(r+o-c.startY,1)};return{from:a,to:u}}var Xe=(e,n,t,r)=>{for(var i=n,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},H=(e,n)=>(t,r)=>n(t,r,e);let le=class extends p.Disposable{constructor(e,n,t,r,i,o,s,a,c,u,l){super(),this._commandService=e,this._univerInstanceService=n,this._selectionManagerService=t,this._selectionRenderService=r,this._imageIoService=i,this._sheetDrawingService=o,this._drawingManagerService=s,this._contextService=a,this._messageService=c,this._localeService=u,this._renderManagerService=l,this._init()}_init(){this._initCommandListeners(),this._updateImageListener(),this._updateOrderListener(),this._groupDrawingListener(),this._focusDrawingListener()}_initCommandListeners(){this.disposeWithMe(this._commandService.onCommandExecuted(async e=>{if(e.id===ue.id||e.id===ge.id){const n=e.params;if(n.files==null)return;const t=n.files.length;if(t>E.DRAWING_IMAGE_COUNT_LIMIT){this._messageService.show({type:J.MessageType.Error,content:this._localeService.t("update-status.exceedMaxCount",String(E.DRAWING_IMAGE_COUNT_LIMIT))});return}this._imageIoService.setWaitCount(t),e.id===ue.id?n.files.forEach(async r=>{await this._insertCellImage(r)}):n.files.forEach(async r=>{await this._insertFloatImage(r)})}}))}async _insertCellImage(e){}async _insertFloatImage(e){let n;try{n=await this._imageIoService.saveImage(e)}catch(D){const I=D.message;I===E.ImageUploadStatusType.ERROR_EXCEED_SIZE?this._messageService.show({type:J.MessageType.Error,content:this._localeService.t("update-status.exceedMaxSize",String(E.DRAWING_IMAGE_ALLOW_SIZE/(1024*1024)))}):I===E.ImageUploadStatusType.ERROR_IMAGE_TYPE?this._messageService.show({type:J.MessageType.Error,content:this._localeService.t("update-status.invalidImageType")}):I===E.ImageUploadStatusType.ERROR_IMAGE&&this._messageService.show({type:J.MessageType.Error,content:this._localeService.t("update-status.invalidImage")})}if(n==null)return;const t=this._getUnitInfo();if(t==null)return;const{unitId:r,subUnitId:i}=t,{imageId:o,imageSourceType:s,source:a,base64Cache:c}=n,{width:u,height:l,image:d}=await E.getImageSize(c||""),h=this._renderManagerService.getRenderById(r);if(h==null)return;const{width:g,height:w}=h.scene;this._imageIoService.addImageSourceCache(a,s,d);let f=1;if(u>E.DRAWING_IMAGE_WIDTH_LIMIT||l>E.DRAWING_IMAGE_HEIGHT_LIMIT){const D=E.DRAWING_IMAGE_WIDTH_LIMIT/u,I=E.DRAWING_IMAGE_HEIGHT_LIMIT/l;f=Math.max(D,I)}const _=this._getImagePosition(u*f,l*f,g,w);if(_==null)return;const M={unitId:r,subUnitId:i,drawingId:o,drawingType:E.DrawingTypeEnum.DRAWING_IMAGE,imageSourceType:s,source:a,transform:F(_,this._selectionRenderService),sheetTransform:_};this._commandService.executeCommand(we.id,{unitId:r,drawings:[M]})}_getUnitInfo(){const e=this._univerInstanceService.getCurrentUnitForType(p.UniverInstanceType.UNIVER_SHEET);if(e==null)return;const n=e.getActiveSheet();if(n==null)return;const t=e.getUnitId(),r=n.getSheetId();return{unitId:t,subUnitId:r}}_getImagePosition(e,n,t,r){const i=this._selectionManagerService.getSelections();let o={startRow:0,endRow:0,startColumn:0,endColumn:0};i&&i.length>0&&(o=i[i.length-1].range);const s=this._selectionRenderService.attachRangeWithCoord(o);if(s==null)return;let{startColumn:a,startRow:c,startX:u,startY:l}=s,d=!1;if(u+e>t&&(u=t-e,u<0&&(u=0,e=t),d=!0),l+n>r&&(l=r-n,l<0&&(l=0,n=r),d=!0),d){const f=this._selectionRenderService.getSelectionCellByPosition(u,l);if(f==null)return;u=f.startX,l=f.startY,a=f.actualColumn,c=f.actualRow}const h={column:a,columnOffset:0,row:c,rowOffset:0},g=this._selectionRenderService.getSelectionCellByPosition(u+e,l+n);if(g==null)return;const w={column:g.actualColumn,columnOffset:u+e-g.startX,row:g.actualRow,rowOffset:l+n-g.startY};return{from:h,to:w}}_updateOrderListener(){this._drawingManagerService.featurePluginOrderUpdate$.subscribe(e=>{const{unitId:n,subUnitId:t,drawingIds:r,arrangeType:i}=e;this._commandService.executeCommand(ye.id,{unitId:n,subUnitId:t,drawingIds:r,arrangeType:i})})}_updateImageListener(){this._drawingManagerService.featurePluginUpdate$.subscribe(e=>{const n=[];e.length!==0&&(e.forEach(t=>{const{unitId:r,subUnitId:i,drawingId:o,drawingType:s,transform:a}=t;if(a==null)return;const c=this._sheetDrawingService.getDrawingByParam({unitId:r,subUnitId:i,drawingId:o});if(c==null)return;const u=L({...c.transform,...a},this._selectionRenderService);if(u==null)return;const l={...t,transform:{...c.transform,...a,...F(u,this._selectionRenderService)},sheetTransform:{...u}};n.push(l)}),n.length>0&&this._commandService.executeCommand(he.id,{unitId:e[0].unitId,drawings:n}))})}_groupDrawingListener(){this._drawingManagerService.featurePluginGroupUpdate$.subscribe(e=>{this._commandService.executeCommand(Re.id,e);const{unitId:n,subUnitId:t,drawingId:r}=e[0].parent;this._drawingManagerService.focusDrawing([{unitId:n,subUnitId:t,drawingId:r}])}),this._drawingManagerService.featurePluginUngroupUpdate$.subscribe(e=>{this._commandService.executeCommand(Me.id,e)})}_focusDrawingListener(){this.disposeWithMe(this._drawingManagerService.focus$.subscribe(e=>{e==null||e.length===0?(this._contextService.setContextValue(p.FOCUSING_COMMON_DRAWINGS,!1),this._sheetDrawingService.focusDrawing([])):(this._contextService.setContextValue(p.FOCUSING_COMMON_DRAWINGS,!0),this._sheetDrawingService.focusDrawing(e))}))}};le=Xe([p.OnLifecycle(p.LifecycleStages.Rendered,le),H(0,p.ICommandService),H(1,p.IUniverInstanceService),H(2,B.Inject(C.SelectionManagerService)),H(3,z.ISelectionRenderService),H(4,E.IImageIoService),H(5,m.ISheetDrawingService),H(6,E.IDrawingManagerService),H(7,p.IContextService),H(8,W.IMessageService),H(9,B.Inject(p.LocaleService)),H(10,k.IRenderManagerService)],le);var V=function(){return V=Object.assign||function(e){for(var n,t=1,r=arguments.length;t<r;t++){n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},V.apply(this,arguments)},$e=function(e,n){var t={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&n.indexOf(r)<0&&(t[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)n.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(t[r[i]]=e[r[i]]);return t},Te=O.forwardRef(function(e,n){var t=e.icon,r=e.id,i=e.className,o=e.extend,s=$e(e,["icon","id","className","extend"]),a="univerjs-icon univerjs-icon-".concat(r," ").concat(i||"").trim(),c=O.useRef("_".concat(qe()));return Ae(t,"".concat(r),{defIds:t.defIds,idSuffix:c.current},V({ref:n,className:a},s),o)});function Ae(e,n,t,r,i){return O.createElement(e.tag,V(V({key:n},ze(e,t,i)),r),(Ke(e,t).children||[]).map(function(o,s){return Ae(o,"".concat(n,"-").concat(e.tag,"-").concat(s),t,void 0,i)}))}function ze(e,n,t){var r=V({},e.attrs);t!=null&&t.colorChannel1&&r.fill==="colorChannel1"&&(r.fill=t.colorChannel1);var i=n.defIds;return!i||i.length===0||(e.tag==="use"&&r["xlink:href"]&&(r["xlink:href"]=r["xlink:href"]+n.idSuffix),Object.entries(r).forEach(function(o){var s=o[0],a=o[1];typeof a=="string"&&(r[s]=a.replace(/url\(#(.*)\)/,"url(#$1".concat(n.idSuffix,")")))})),r}function Ke(e,n){var t,r=n.defIds;return!r||r.length===0?e:e.tag==="defs"&&(!((t=e.children)===null||t===void 0)&&t.length)?V(V({},e),{children:e.children.map(function(i){return typeof i.attrs.id=="string"&&r&&r.indexOf(i.attrs.id)>-1?V(V({},i),{attrs:V(V({},i.attrs),{id:i.attrs.id+n.idSuffix})}):i})}):e}function qe(){return Math.random().toString(36).substring(2,8)}Te.displayName="UniverIcon";var Je={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"}}]},Oe=O.forwardRef(function(e,n){return O.createElement(Te,Object.assign({},e,{id:"add-image-single",ref:n,icon:Je}))});Oe.displayName="AddImageSingle";const Ze="univer-upload-file-menu",Qe="univer-upload-file-menu-input",ve={uploadFileMenu:Ze,uploadFileMenuInput:Qe},be="COMPONENT_UPLOAD_FILE_MENU";var me=(e=>(e[e.cellImage=0]="cellImage",e[e.floatImage=1]="floatImage",e))(me||{});const et=e=>{const{type:n}=e,t=$.useDependency(p.ICommandService),r=O.useRef(null),i=()=>{var a;(a=r.current)==null||a.click()},o=E.DRAWING_IMAGE_ALLOW_IMAGE_LIST.map(a=>`.${a.replace("image/","")}`).join(","),s=a=>{const c=a.target.files;if(c==null)return;const u=Array.from(c);n===me.floatImage?t.executeCommand(ge.id,{files:u}):n===me.cellImage&&t.executeCommand(ue.id,{files:u}),r.current&&(r.current.value="")};return O.createElement("div",{onClick:i,className:ve.uploadFileMenu},O.createElement("input",{type:"file",className:ve.uploadFileMenuInput,ref:r,onChange:s,accept:o,multiple:!0}))},Ee="addition-and-subtraction-single",Ue="sheet.menu.image";function tt(e){return{id:Ue,type:W.MenuItemType.SUBITEMS,positions:[W.MenuPosition.TOOLBAR_START],group:W.MenuGroup.TOOLBAR_FORMULAS_INSERT,icon:Ee,tooltip:"sheetImage.title",hidden$:W.getMenuHiddenObservable(e,p.UniverInstanceType.UNIVER_SHEET)}}function nt(e){return{id:ge.id,title:"sheetImage.upload.float",type:W.MenuItemType.SELECTOR,label:{name:be,props:{type:me.floatImage}},positions:[Ue],hidden$:W.getMenuHiddenObservable(e,p.UniverInstanceType.UNIVER_SHEET)}}const rt="univer-image-common-panel",it="univer-image-common-panel-grid",ot="univer-image-common-panel-border",st="univer-image-common-panel-title",at="univer-image-common-panel-row",ct="univer-image-common-panel-row-vertical",lt="univer-image-common-panel-column",dt="univer-image-common-panel-column-center",ut="univer-image-common-panel-inline",mt="univer-image-common-panel-span2",gt="univer-image-common-panel-span3",ht="univer-image-common-panel-input",pt="univer-sheet-image-menu",ft="univer-sheet-image-menu-input",q={imageCommonPanel:rt,imageCommonPanelGrid:it,imageCommonPanelBorder:ot,imageCommonPanelTitle:st,imageCommonPanelRow:at,imageCommonPanelRowVertical:ct,imageCommonPanelColumn:lt,imageCommonPanelColumnCenter:dt,imageCommonPanelInline:ut,imageCommonPanelSpan2:mt,imageCommonPanelSpan3:gt,imageCommonPanelInput:ht,sheetImageMenu:pt,sheetImageMenuInput:ft},wt=e=>{var I;const n=$.useDependency(p.ICommandService),t=$.useDependency(p.LocaleService),r=$.useDependency(E.IDrawingManagerService),i=$.useDependency(k.IRenderManagerService),{drawings:o}=e,s=o[0];if(s==null)return;const{unitId:a}=s,c=i.getRenderById(a),u=c==null?void 0:c.scene;if(u==null)return;const l=u.getTransformerByCreate(),[d,h]=O.useState(!0),g=(I=s.anchorType)!=null?I:m.SheetDrawingAnchorType.Position,[w,f]=O.useState(g);function _(R,v){const A=[];return R.forEach(S=>{const{oKey:P}=S,T=v.getDrawingOKey(P);if(T==null)return A.push(null),!0;const{unitId:G,subUnitId:U,drawingId:b,drawingType:y,anchorType:N,sheetTransform:Y}=T;A.push({unitId:G,subUnitId:U,drawingId:b,anchorType:N,sheetTransform:Y,drawingType:y})}),A}O.useEffect(()=>{const R=l.onClearControlObservable.add(A=>{A===!0&&h(!1)}),v=l.onChangeStartObservable.add(A=>{var T;const{objects:S}=A,P=_(S,r);if(P.length===0)h(!1);else if(P.length>=1){h(!0);const G=((T=P[0])==null?void 0:T.anchorType)||m.SheetDrawingAnchorType.Position;f(G)}});return()=>{v==null||v.dispose(),R==null||R.dispose()}},[]);function M(R){f(R);const v=r.getFocusDrawings();if(v.length===0)return;const A=v.map(S=>({unitId:S.unitId,subUnitId:S.subUnitId,drawingId:S.drawingId,anchorType:R}));n.executeCommand(he.id,{unitId:v[0].unitId,drawings:A})}const D=R=>R?"block":"none";return O.createElement("div",{className:se(q.imageCommonPanelGrid,q.imageCommonPanelBorder),style:{display:D(d)}},O.createElement("div",{className:q.imageCommonPanelRow},O.createElement("div",{className:se(q.imageCommonPanelColumn,q.imageCommonPanelTitle)},O.createElement("div",null,t.t("drawing-anchor.title")))),O.createElement("div",{className:se(q.imageCommonPanelRow)},O.createElement("div",{className:se(q.imageCommonPanelColumn)},O.createElement(J.RadioGroup,{value:w,onChange:M,direction:"vertical"},O.createElement(J.Radio,{value:m.SheetDrawingAnchorType.Both},t.t("drawing-anchor.both")),O.createElement(J.Radio,{value:m.SheetDrawingAnchorType.Position},t.t("drawing-anchor.position")),O.createElement(J.Radio,{value:m.SheetDrawingAnchorType.None},t.t("drawing-anchor.none"))))))},St=()=>{const e=$.useDependency(E.IDrawingManagerService),n=e.getFocusDrawings();if(n==null||n.length===0)return;const[t,r]=O.useState(n);return O.useEffect(()=>{const i=e.focus$.subscribe(o=>{r(o)});return()=>{i.unsubscribe()}},[]),O.createElement("div",{className:q.imageCommonPanel},O.createElement(ee.DrawingCommonPanel,{drawings:t}),O.createElement(wt,{drawings:t}))},ie={id:"sheet.command.move-drawing",type:p.CommandType.COMMAND,handler:(e,n)=>{const t=e.get(p.ICommandService),r=e.get(m.ISheetDrawingService),i=e.get(z.ISelectionRenderService),{direction:o}=n,s=r.getFocusDrawings();if(s.length===0)return!1;const a=s[0].unitId,c=s.map(l=>{const{transform:d}=l;if(d==null)return null;const h={...d},{left:g=0,top:w=0}=d;return o===p.Direction.UP?h.top=w-1:o===p.Direction.DOWN?h.top=w+1:o===p.Direction.LEFT?h.left=g-1:o===p.Direction.RIGHT&&(h.left=g+1),{...l,transform:h,sheetTransform:L(h,i)}}).filter(l=>l!=null);return t.syncExecuteCommand(he.id,{unitId:a,drawings:c})?(t.syncExecuteCommand(j.id,[a]),!0):!1}},Pe={id:"sheet.command.delete-drawing",type:p.CommandType.COMMAND,handler:e=>{const n=e.get(p.ICommandService),r=e.get(m.ISheetDrawingService).getFocusDrawings();if(r.length===0)return!1;const i=r[0].unitId,o=r.map(s=>{const{unitId:a,subUnitId:c,drawingId:u,drawingType:l}=s;return{unitId:a,subUnitId:c,drawingId:u,drawingType:l}});return n.executeCommand(fe.id,{unitId:i,drawings:o})}};function oe(e){return!e.getContextValue(p.FOCUSING_FORMULA_EDITOR)&&!e.getContextValue(p.EDITOR_ACTIVATED)&&e.getContextValue(p.FOCUSING_COMMON_DRAWINGS)}const vt={id:ie.id,description:"shortcut.sheet.drawing-move-down",group:"4_sheet-drawing-view",binding:W.KeyCode.ARROW_DOWN,priority:100,preconditions:oe,staticParameters:{direction:p.Direction.DOWN}},_t={id:ie.id,description:"shortcut.sheet.drawing-move-up",group:"4_sheet-drawing-view",binding:W.KeyCode.ARROW_UP,priority:100,preconditions:oe,staticParameters:{direction:p.Direction.UP}},Ct={id:ie.id,description:"shortcut.sheet.drawing-move-left",group:"4_sheet-drawing-view",binding:W.KeyCode.ARROW_LEFT,priority:100,preconditions:oe,staticParameters:{direction:p.Direction.LEFT}},It={id:ie.id,description:"shortcut.sheet.drawing-move-right",group:"4_sheet-drawing-view",binding:W.KeyCode.ARROW_RIGHT,priority:100,preconditions:oe,staticParameters:{direction:p.Direction.RIGHT}},Dt={id:Pe.id,description:"shortcut.sheet.drawing-delete",group:"4_sheet-drawing-view",preconditions:oe,binding:W.KeyCode.DELETE,mac:W.KeyCode.BACKSPACE};var yt=(e,n,t,r)=>{for(var i=n,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},te=(e,n)=>(t,r)=>n(t,r,e);const Rt={};let re=class extends p.Disposable{constructor(e,n,t,r,i,o){super(),this._config=e,this._injector=n,this._componentManager=t,this._menuService=r,this._commandService=i,this._shortcutService=o,this._init()}_initCustomComponents(){const e=this._componentManager;this.disposeWithMe(e.register(Ee,Oe)),this.disposeWithMe(e.register(be,et)),this.disposeWithMe(e.register(Ce,St))}_initMenus(){const{menu:e={}}=this._config;[tt,nt].forEach(n=>{this._menuService.addMenuItem(n(this._injector),e)})}_initCommands(){[ge,ue,we,fe,he,Ie,j,De,Re,Me,ie,Pe,ye].forEach(e=>this.disposeWithMe(this._commandService.registerCommand(e)))}_initShortcuts(){[vt,_t,Ct,It,Dt].forEach(e=>{this.disposeWithMe(this._shortcutService.registerShortcut(e))})}_init(){this._initCommands(),this._initCustomComponents(),this._initMenus(),this._initShortcuts()}};re=yt([p.OnLifecycle(p.LifecycleStages.Rendered,re),te(1,B.Inject(B.Injector)),te(2,B.Inject(W.ComponentManager)),te(3,W.IMenuService),te(4,p.ICommandService),te(5,W.IShortcutService)],re);var Mt=(e,n,t,r)=>{for(var i=n,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},Q=(e,n)=>(t,r)=>n(t,r,e);const Tt=[C.InsertRowCommand.id,C.InsertColCommand.id,C.RemoveRowCommand.id,C.RemoveColCommand.id,C.DeleteRangeMoveLeftCommand.id,C.DeleteRangeMoveUpCommand.id,C.InsertRangeMoveDownCommand.id,C.InsertRangeMoveRightCommand.id,C.DeltaRowHeightCommand.id,C.SetRowHeightCommand.id,C.DeltaColumnWidthCommand.id,C.SetColWidthCommand.id,C.SetRowHiddenCommand.id,C.SetSpecificRowsVisibleCommand.id,C.SetSpecificColsVisibleCommand.id,C.SetColHiddenCommand.id],At=[C.SetRowVisibleMutation.id,C.SetRowHiddenMutation.id,C.SetColVisibleMutation.id,C.SetColHiddenMutation.id,C.SetWorksheetRowHeightMutation.id,C.SetWorksheetColWidthMutation.id];let de=class extends p.Disposable{constructor(e,n,t,r,i,o){super(),this._commandService=e,this._sheetInterceptorService=n,this._sheetDrawingService=t,this._drawingManagerService=r,this._selectionRenderService=i,this._univerInstanceService=o,this._init()}_init(){this._sheetInterceptorListener(),this._commandListener(),this._sheetRefreshListener()}_sheetInterceptorListener(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{if(!Tt.includes(e.id))return{redos:[],undos:[]};if(e.params==null)return{redos:[],undos:[]};const n=e.id;if(n===C.InsertRowCommand.id)return this._moveRowInterceptor(e.params,"insert");if(n===C.InsertColCommand.id)return this._moveColInterceptor(e.params,"insert");if(n===C.RemoveRowCommand.id)return this._moveRowInterceptor(e.params,"remove");if(n===C.RemoveColCommand.id)return this._moveColInterceptor(e.params,"remove");if(n===C.DeleteRangeMoveLeftCommand.id){const{range:t}=e.params;return this._getRangeMoveUndo(t,0)}else if(n===C.DeleteRangeMoveUpCommand.id){const{range:t}=e.params;return this._getRangeMoveUndo(t,1)}else if(n===C.InsertRangeMoveDownCommand.id){const{range:t}=e.params;return this._getRangeMoveUndo(t,2)}else if(n===C.InsertRangeMoveRightCommand.id){const{range:t}=e.params;return this._getRangeMoveUndo(t,3)}else if(n===C.SetRowHiddenCommand.id||n===C.SetSpecificRowsVisibleCommand.id){const t=e.params,{unitId:r,subUnitId:i,ranges:o}=t;return this._getDrawingUndoForRowVisible(r,i,o)}else if(n===C.SetSpecificColsVisibleCommand.id||n===C.SetColHiddenCommand.id){const t=e.params,{unitId:r,subUnitId:i,ranges:o}=t;return this._getDrawingUndoForColVisible(r,i,o)}else if(n===C.DeltaRowHeightCommand.id||n===C.SetRowHeightCommand.id||n===C.DeltaColumnWidthCommand.id||n===C.SetColWidthCommand.id){const t=e.params,{unitId:r,subUnitId:i,ranges:o}=t,s=n===C.DeltaRowHeightCommand.id||n===C.SetRowHeightCommand.id;return this._getDrawingUndoForRowAndColSize(r,i,o,s)}return{redos:[],undos:[]}}}))}_getRangeMoveUndo(e,n){const t=C.getSheetCommandTarget(this._univerInstanceService);if(t==null)return{redos:[],undos:[]};const r=t.unitId,i=t.subUnitId,o=[],s=[],a=this._sheetDrawingService.getDrawingData(r,i),c=[],u=[];if(Object.keys(a).forEach(l=>{const d=a[l],{updateDrawings:h,deleteDrawings:g}=this._getUpdateOrDeleteDrawings(e,n,d);c.push(...h),u.push(...g)}),c.length===0&&u.length===0)return{redos:[],undos:[]};if(c.length>0){const l=this._sheetDrawingService.getBatchUpdateOp(c),{undo:d,redo:h,objects:g}=l;o.push({id:m.SetDrawingApplyMutation.id,params:{unitId:r,subUnitId:i,op:h,objects:g,type:m.DrawingApplyType.UPDATE}}),s.push({id:m.SetDrawingApplyMutation.id,params:{unitId:r,subUnitId:i,op:d,objects:g,type:m.DrawingApplyType.UPDATE}})}if(u.length>0){const l=this._sheetDrawingService.getBatchRemoveOp(u),d=l.undo,h=l.redo,g=l.objects;o.push({id:m.SetDrawingApplyMutation.id,params:{unitId:r,subUnitId:i,op:h,objects:g,type:m.DrawingApplyType.REMOVE}}),s.push({id:m.SetDrawingApplyMutation.id,params:{unitId:r,subUnitId:i,op:d,objects:g,type:m.DrawingApplyType.INSERT}})}return o.push({id:j.id,params:[r]}),s.push({id:j.id,params:[r]}),{redos:o,undos:s}}_getUpdateOrDeleteDrawings(e,n,t){const r=[],i=[],{sheetTransform:o,anchorType:s=m.SheetDrawingAnchorType.Position,transform:a,unitId:c,subUnitId:u,drawingId:l}=t,{from:d,to:h}=o,{row:g,column:w}=d,{row:f,column:_}=h;if(o==null||a==null)return{updateDrawings:r,deleteDrawings:i};const{startRow:M,endRow:D,startColumn:I,endColumn:R}=e;let v=null,A=null;if(n===0&&g>=M&&f<=D)if(w>=I&&_<=R)i.push({unitId:c,subUnitId:u,drawingId:l});else{const S=this._shrinkCol(o,a,I,R,s);v=S==null?void 0:S.newSheetTransform,A=S==null?void 0:S.newTransform}else if(n===1&&w>=I&&_<=R)if(g>=M&&f<=D)i.push({unitId:c,subUnitId:u,drawingId:l});else{const S=this._shrinkRow(o,a,M,D,s);v=S==null?void 0:S.newSheetTransform,A=S==null?void 0:S.newTransform}else if(n===2){const S=this._expandRow(o,a,M,D,s);v=S==null?void 0:S.newSheetTransform,A=S==null?void 0:S.newTransform}else if(n===3){const S=this._expandCol(o,a,I,R,s);v=S==null?void 0:S.newSheetTransform,A=S==null?void 0:S.newTransform}if(v!=null&&A!=null){const S=F(v,this._selectionRenderService);r.push({...t,sheetTransform:v,transform:S})}return{updateDrawings:r,deleteDrawings:i}}_remainDrawingSize(e,n,t){const r=L({...e},this._selectionRenderService);r!=null&&n.push({...t,sheetTransform:r})}_getDrawingUndoForColVisible(e,n,t){const r=this._drawingManagerService.getDrawingData(e,n),i=[],o=[];if(Object.keys(r).forEach(l=>{const d=r[l],{sheetTransform:h,transform:g,anchorType:w=m.SheetDrawingAnchorType.Position}=d;if(w===m.SheetDrawingAnchorType.None)this._remainDrawingSize(g,i,d);else{const{from:f,to:_}=h,{row:M,column:D}=f,{row:I,column:R}=_;for(let v=0;v<t.length;v++){const A=t[v],{startRow:S,endRow:P,startColumn:T,endColumn:G}=A;if(R<T)continue;if(w===m.SheetDrawingAnchorType.Position){let y=null,N=null;if(D>=T&&D<=G){const Y=this._selectionRenderService.attachRangeWithCoord({startColumn:D,endColumn:G,startRow:f.row,endRow:_.row});if(Y==null)return;N={...g,left:Y.startX}}if(N!=null&&(y=L(N,this._selectionRenderService),y!=null&&N!=null)){i.push({...d,sheetTransform:y,transform:N});break}this._remainDrawingSize(g,i,d);continue}if(D>=T&&R<=G)continue;let U=null,b=null;if(D>=T&&D<=G){const y=this._selectionRenderService.attachRangeWithCoord({startColumn:D,endColumn:G,startRow:f.row,endRow:_.row});if(y==null)return;b={...g,left:(y==null?void 0:y.startX)||0,width:((g==null?void 0:g.width)||0)-y.endX+y.startX}}else if(R>=T&&R<=G){const y=this._selectionRenderService.attachRangeWithCoord({startColumn:T,endColumn:R,startRow:f.row,endRow:_.row});if(y==null)return;b={...g,left:y.startX-((g==null?void 0:g.width)||0)}}else{const y=this._selectionRenderService.attachRangeWithCoord({startColumn:T,endColumn:G,startRow:f.row,endRow:_.row});if(y==null)return;if(b={...g,width:((g==null?void 0:g.width)||0)-y.endX+y.startX},U=L(b,this._selectionRenderService),U!=null&&b!=null){o.push({...d,sheetTransform:U,transform:b});break}}if(b!=null&&(U=L(b,this._selectionRenderService)),b!=null&&U!=null){i.push({...d,sheetTransform:U,transform:b});break}else this._remainDrawingSize(g,i,d)}}}),i.length===0&&o.length===0)return{redos:[],undos:[]};const{redos:s,undos:a}=this._createUndoAndRedoMutation(e,n,i),c=[],u=[];if(o.length>0){const{redos:l,undos:d}=this._createUndoAndRedoMutation(e,n,o);c.push(...l),u.push(...d)}return{redos:s,undos:a,preRedos:c,preUndos:u}}_createUndoAndRedoMutation(e,n,t){const r=this._sheetDrawingService.getBatchUpdateOp(t),{undo:i,redo:o,objects:s}=r,a=[{id:m.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:n,op:o,objects:s,type:m.DrawingApplyType.UPDATE}},{id:j.id,params:[e]}],c=[{id:m.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:n,op:i,objects:s,type:m.DrawingApplyType.UPDATE}},{id:j.id,params:[e]}];return{redos:a,undos:c}}_getDrawingUndoForRowVisible(e,n,t){const r=this._drawingManagerService.getDrawingData(e,n),i=[],o=[];if(Object.keys(r).forEach(l=>{const d=r[l],{sheetTransform:h,transform:g,anchorType:w=m.SheetDrawingAnchorType.Position}=d;if(w===m.SheetDrawingAnchorType.None)this._remainDrawingSize(g,i,d);else{const{from:f,to:_}=h,{row:M,column:D}=f,{row:I,column:R}=_;for(let v=0;v<t.length;v++){const A=t[v],{startRow:S,endRow:P,startColumn:T,endColumn:G}=A;if(I<S)continue;if(w===m.SheetDrawingAnchorType.Position){let y=null,N=null;if(M>=S&&M<=P){const Y=this._selectionRenderService.attachRangeWithCoord({startColumn:f.column,endColumn:_.column,startRow:M,endRow:P});if(Y==null)return;N={...g,top:Y.startY}}if(N!=null&&(y=L(N,this._selectionRenderService),y!=null&&N!=null)){i.push({...d,sheetTransform:y,transform:N});break}this._remainDrawingSize(g,i,d);continue}if(M>=S&&I<=P)continue;let U=null,b=null;if(M>=S&&M<=P){const y=this._selectionRenderService.attachRangeWithCoord({startColumn:f.column,endColumn:_.column,startRow:M,endRow:P});if(y==null)return;b={...g,top:(y==null?void 0:y.startY)||0,height:((g==null?void 0:g.height)||0)-y.endY+y.startY}}else if(I>=S&&I<=P){const y=this._selectionRenderService.attachRangeWithCoord({startColumn:f.column,endColumn:_.column,startRow:S,endRow:I});if(y==null)return;b={...g,top:y.startY-((g==null?void 0:g.height)||0)}}else{const y=this._selectionRenderService.attachRangeWithCoord({startColumn:f.column,endColumn:_.column,startRow:S,endRow:P});if(y==null)return;if(b={...g,height:((g==null?void 0:g.height)||0)-y.endY+y.startY},U=L(b,this._selectionRenderService),U!=null&&b!=null){o.push({...d,sheetTransform:U,transform:b});break}}if(b!=null&&(U=L(b,this._selectionRenderService)),b!=null&&U!=null){i.push({...d,sheetTransform:U,transform:b});break}else this._remainDrawingSize(g,i,d)}}}),i.length===0&&o.length===0)return{redos:[],undos:[]};const{redos:s,undos:a}=this._createUndoAndRedoMutation(e,n,i),c=[],u=[];if(o.length>0){const{redos:l,undos:d}=this._createUndoAndRedoMutation(e,n,o);c.push(...l),u.push(...d)}return{redos:s,undos:a,preRedos:c,preUndos:u}}_getDrawingUndoForRowAndColSize(e,n,t,r){const i=this._drawingManagerService.getDrawingData(e,n),o=[];return Object.keys(i).forEach(s=>{const a=i[s],{sheetTransform:c,transform:u,anchorType:l=m.SheetDrawingAnchorType.Position}=a;if(l===m.SheetDrawingAnchorType.None)this._remainDrawingSize(u,o,a);else{const{from:d,to:h}=c,{row:g,column:w}=d,{row:f,column:_}=h;for(let M=0;M<t.length;M++){const D=t[M],{startRow:I,endRow:R,startColumn:v,endColumn:A}=D;if(f<I||_<v)continue;if(l===m.SheetDrawingAnchorType.Position&&(g<=I&&f>=R||w<=v&&_>=A)){this._remainDrawingSize(u,o,a);continue}const S=F({...c},this._selectionRenderService);if(S!=null){o.push({...a,transform:S});break}}}}),o.length===0?{redos:[],undos:[]}:this._createUndoAndRedoMutation(e,n,o)}_getUnitIdAndSubUnitId(e,n){let t,r;if(n==="insert")t=e.unitId,r=e.subUnitId;else{const i=C.getSheetCommandTarget(this._univerInstanceService);if(i==null)return;t=i.unitId,r=i.subUnitId}return{unitId:t,subUnitId:r}}_moveRowInterceptor(e,n){const t=this._getUnitIdAndSubUnitId(e,n);if(t==null)return{redos:[],undos:[]};const{unitId:r,subUnitId:i}=t,{range:o}=e,s=o.startRow,a=o.endRow,c=[],u=[],l=this._sheetDrawingService.getDrawingData(r,i),d=[],h=[];if(Object.keys(l).forEach(g=>{const w=l[g],{sheetTransform:f,transform:_,anchorType:M=m.SheetDrawingAnchorType.Position}=w;if(f==null||_==null)return;let D,I;if(n==="insert"){const v=this._expandRow(f,_,s,a,M);D=v==null?void 0:v.newSheetTransform,I=v==null?void 0:v.newTransform}else{const{from:v,to:A}=f,{row:S}=v,{row:P}=A;if(S>=s&&P<=a)h.push({unitId:r,subUnitId:i,drawingId:g});else{const T=this._shrinkRow(f,_,s,a,M);D=T==null?void 0:T.newSheetTransform,I=T==null?void 0:T.newTransform}}if(!D||!I)return;const R={unitId:r,subUnitId:i,drawingId:g,transform:I,sheetTransform:D};d.push(R)}),d.length===0&&h.length===0)return{redos:[],undos:[]};if(d.length>0){const g=this._sheetDrawingService.getBatchUpdateOp(d),{undo:w,redo:f,objects:_}=g;c.push({id:m.SetDrawingApplyMutation.id,params:{unitId:r,subUnitId:i,op:f,objects:_,type:m.DrawingApplyType.UPDATE}}),u.push({id:m.SetDrawingApplyMutation.id,params:{unitId:r,subUnitId:i,op:w,objects:_,type:m.DrawingApplyType.UPDATE}})}if(h.length>0){const g=this._sheetDrawingService.getBatchRemoveOp(h),w=g.undo,f=g.redo,_=g.objects;c.push({id:m.SetDrawingApplyMutation.id,params:{unitId:r,subUnitId:i,op:f,objects:_,type:m.DrawingApplyType.REMOVE}}),u.push({id:m.SetDrawingApplyMutation.id,params:{unitId:r,subUnitId:i,op:w,objects:_,type:m.DrawingApplyType.INSERT}})}return c.push({id:j.id,params:[r]}),u.push({id:j.id,params:[r]}),{redos:c,undos:u}}_moveColInterceptor(e,n){const t=this._getUnitIdAndSubUnitId(e,n);if(t==null)return{redos:[],undos:[]};const{unitId:r,subUnitId:i}=t,{range:o}=e,s=o.startColumn,a=o.endColumn,c=[],u=[],l=this._sheetDrawingService.getDrawingData(r,i),d=[],h=[];if(Object.keys(l).forEach(g=>{const w=l[g],{sheetTransform:f,transform:_,anchorType:M=m.SheetDrawingAnchorType.Position}=w;if(f==null||_==null)return;let D,I;if(n==="insert"){const v=this._expandCol(f,_,s,a,M);D=v==null?void 0:v.newSheetTransform,I=v==null?void 0:v.newTransform}else{const{from:v,to:A}=f,{column:S}=v,{column:P}=A;if(S>=s&&P<=a)h.push({unitId:r,subUnitId:i,drawingId:g});else{const T=this._shrinkCol(f,_,s,a,M);D=T==null?void 0:T.newSheetTransform,I=T==null?void 0:T.newTransform}}if(!D||!I)return;const R={unitId:r,subUnitId:i,drawingId:g,transform:I,sheetTransform:D};d.push(R)}),d.length===0&&h.length===0)return{redos:[],undos:[]};if(d.length>0){const g=this._sheetDrawingService.getBatchUpdateOp(d),{undo:w,redo:f,objects:_}=g;c.push({id:m.SetDrawingApplyMutation.id,params:{unitId:r,subUnitId:i,op:f,objects:_,type:m.DrawingApplyType.UPDATE}}),u.push({id:m.SetDrawingApplyMutation.id,params:{unitId:r,subUnitId:i,op:w,objects:_,type:m.DrawingApplyType.UPDATE}})}if(h.length>0){const g=this._sheetDrawingService.getBatchRemoveOp(h),w=g.undo,f=g.redo,_=g.objects;c.push({id:m.SetDrawingApplyMutation.id,params:{unitId:r,subUnitId:i,op:f,objects:_,type:m.DrawingApplyType.REMOVE}}),u.push({id:m.SetDrawingApplyMutation.id,params:{unitId:r,subUnitId:i,op:w,objects:_,type:m.DrawingApplyType.INSERT}})}return c.push({id:j.id,params:[r]}),u.push({id:j.id,params:[r]}),{redos:c,undos:u}}_expandCol(e,n,t,r,i=m.SheetDrawingAnchorType.Position){const o=r-t+1,{from:s,to:a}=e,{column:c}=s,{column:u}=a;if(i===m.SheetDrawingAnchorType.None)return{newSheetTransform:L({...n},this._selectionRenderService),newTransform:n};let l=null,d=null;if(c>=t){const h=this._selectionRenderService.attachRangeWithCoord({startColumn:t,endColumn:r,startRow:s.row,endRow:a.row});if(h==null)return;d={...n,left:(n.left||0)+h.endX-h.startX},l=L(d,this._selectionRenderService)}else if(u>=r)if(i===m.SheetDrawingAnchorType.Both)l={from:{...s},to:{...a,column:u+o}},d=F(l,this._selectionRenderService);else return{newSheetTransform:L({...n},this._selectionRenderService),newTransform:n};return l!=null&&d!=null?{newSheetTransform:l,newTransform:d}:null}_shrinkCol(e,n,t,r,i=m.SheetDrawingAnchorType.Position){const o=r-t+1,{from:s,to:a}=e,{column:c}=s,{column:u}=a;if(i===m.SheetDrawingAnchorType.None)return{newSheetTransform:L({...n},this._selectionRenderService),newTransform:n};let l=null,d=null;if(c>r)l={from:{...s,column:c-o},to:{...a,column:u-o}},d=F(l,this._selectionRenderService);else{if(c>=t&&u<=r)return null;if(c<t&&u>r)if(i===m.SheetDrawingAnchorType.Both)l={from:{...s},to:{...a,column:u-o}},d=F(l,this._selectionRenderService);else return{newSheetTransform:L({...n},this._selectionRenderService),newTransform:n};else if(c>=t&&c<=r){if(c===t)d={...n,left:(n.left||0)-e.from.columnOffset};else{const h=this._selectionRenderService.attachRangeWithCoord({startColumn:t,endColumn:c-1,startRow:s.row,endRow:a.row});if(h==null)return;d={...n,left:(n.left||0)-h.endX+h.startX-e.from.columnOffset}}l=L(d,this._selectionRenderService)}else if(u>=t&&u<=r&&i===m.SheetDrawingAnchorType.Both){const h=this._selectionRenderService.attachRangeWithCoord({startColumn:t-1,endColumn:t-1,startRow:s.row,endRow:a.row});if(h==null)return;l={from:{...s},to:{...a,column:t-1,columnOffset:h.endX-h.startX}},d=F(l,this._selectionRenderService)}}return l!=null&&d!=null?{newSheetTransform:l,newTransform:d}:null}_expandRow(e,n,t,r,i=m.SheetDrawingAnchorType.Position){const o=r-t+1,{from:s,to:a}=e,{row:c}=s,{row:u}=a;if(i===m.SheetDrawingAnchorType.None)return{newSheetTransform:L({...n},this._selectionRenderService),newTransform:n};let l=null,d=null;if(c>=t){const h=this._selectionRenderService.attachRangeWithCoord({startRow:t,endRow:r,startColumn:s.column,endColumn:a.column});if(h==null)return;d={...n,top:(n.top||0)+h.endY-h.startY},l=L(d,this._selectionRenderService)}else if(u>=r)if(i===m.SheetDrawingAnchorType.Both)l={from:{...s},to:{...a,row:u+o}},d=F(l,this._selectionRenderService);else return{newSheetTransform:L({...n},this._selectionRenderService),newTransform:n};return l!=null&&d!=null?{newSheetTransform:l,newTransform:d}:null}_shrinkRow(e,n,t,r,i=m.SheetDrawingAnchorType.Position){const o=r-t+1,{from:s,to:a}=e,{row:c}=s,{row:u}=a;if(i===m.SheetDrawingAnchorType.None)return{newSheetTransform:L({...n},this._selectionRenderService),newTransform:n};let l=null,d=null;if(c>r)l={from:{...s,row:c-o},to:{...a,row:u-o}},d=F(l,this._selectionRenderService);else{if(c>=t&&u<=r)return null;if(c<t&&u>r)if(i===m.SheetDrawingAnchorType.Both)l={from:{...s},to:{...a,row:u-o}},d=F(l,this._selectionRenderService);else return{newSheetTransform:L({...n},this._selectionRenderService),newTransform:n};else if(c>=t&&c<=r){if(c===t)d={...n,top:(n.top||0)-e.from.rowOffset};else{const h=this._selectionRenderService.attachRangeWithCoord({startRow:t,endRow:c-1,startColumn:s.column,endColumn:a.column});if(h==null)return;d={...n,top:(n.top||0)-h.endY+h.startY-e.from.rowOffset}}l=L(d,this._selectionRenderService)}else if(u>=t&&u<=r&&i===m.SheetDrawingAnchorType.Both){const h=this._selectionRenderService.attachRangeWithCoord({startColumn:s.column,endColumn:s.column,startRow:t-1,endRow:t-1});if(h==null)return;l={from:{...s},to:{...a,row:t-1,rowOffset:h.endY-h.startY}},d=F(l,this._selectionRenderService)}}return l!=null&&d!=null?{newSheetTransform:l,newTransform:d}:null}_commandListener(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(e.id===C.SetWorksheetActiveOperation.id){const n=e.params,{unitId:t,subUnitId:r}=n,i=this._drawingManagerService.drawingManagerData,o=[],s=[];Object.keys(i).forEach(a=>{const c=i[a];Object.keys(c).forEach(u=>{const l=c[u].data;l!=null&&Object.keys(l).forEach(d=>{a===t&&u===r?o.push(l[d]):s.push(l[d])})})}),this._drawingManagerService.removeNotification(s),this._drawingManagerService.addNotification(o)}}))}_sheetRefreshListener(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{At.includes(e.id)&&requestIdleCallback(()=>{const n=e.params,{unitId:t,subUnitId:r,ranges:i}=n;this._refreshDrawingTransform(t,r,i)})}))}_refreshDrawingTransform(e,n,t){const r=this._drawingManagerService.getDrawingData(e,n),i=[];Object.keys(r).forEach(o=>{const s=r[o],{sheetTransform:a,anchorType:c=m.SheetDrawingAnchorType.Position}=s;if(c===m.SheetDrawingAnchorType.None)return!0;const{from:u,to:l}=a,{row:d,column:h}=u,{row:g,column:w}=l;for(let f=0;f<t.length;f++){const _=t[f],{startRow:M,endRow:D,startColumn:I,endColumn:R}=_;if(p.Rectangle.intersects({startRow:M,endRow:D,startColumn:I,endColumn:R},{startRow:d,endRow:g,startColumn:h,endColumn:w})||d>D||h>R){i.push({...s,transform:F(a,this._selectionRenderService)});break}}}),i.length!==0&&(this._drawingManagerService.refreshTransform(i),this._commandService.syncExecuteCommand(j.id,[e]))}};de=Mt([p.OnLifecycle(p.LifecycleStages.Rendered,de),Q(0,p.ICommandService),Q(1,B.Inject(C.SheetInterceptorService)),Q(2,m.ISheetDrawingService),Q(3,E.IDrawingManagerService),Q(4,z.ISelectionRenderService),Q(5,p.IUniverInstanceService)],de);var Ot=(e,n,t,r)=>{for(var i=n,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},K=(e,n)=>(t,r)=>n(t,r,e);function bt(e,n,t,r){const{scaleX:i,scaleY:o}=n.getAncestorScale(),s=n.getViewport(z.VIEWPORT_KEY.VIEW_MAIN),a={left:!0,top:!0};if(!s)return{...e,absolute:a};const{left:c,right:u,top:l,bottom:d}=e,h=r.getFreeze(),{startColumn:g,startRow:w,xSplit:f,ySplit:_}=h,M=t.getNoMergeCellPositionByIndexWithNoHeader(w-_,g-f),D=t.getNoMergeCellPositionByIndexWithNoHeader(w,g),{rowHeaderWidth:I,columnHeaderHeight:R}=t,v=D.startX-M.startX,A=D.startY-M.startY,{top:S,left:P,viewportScrollX:T,viewportScrollY:G}=s;let U,b;c<P?(a.left=!0,U=(v+I+(c-P))*i,b=Math.max(Math.min((v+I+(u-P))*i,(v+I)*i),(u-T)*i)):(a.left=!1,U=Math.max((c-T)*i,(v+I)*i),b=Math.max((u-T)*i,(v+I)*i));let y,N;return l<S?(a.top=!0,y=(A+R+(l-S))*o,N=Math.max(Math.min((A+R+(u-S))*o,(A+R)*o),(d-G)*o)):(a.top=!1,y=Math.max((l-G)*o,(A+R)*o),N=Math.max((d-G)*o,(A+R)*o)),{left:U,right:b,top:y,bottom:N,absolute:a}}const pe=(e,n,t,r)=>{const{scene:i}=n,{left:o,top:s,width:a,height:c,angle:u}=e,l={left:o,right:o+a,top:s,bottom:s+c},d=bt(l,i,t,r);return{startX:d.left,endX:d.right,startY:d.top,endY:d.bottom,rotate:u,width:a,height:c,absolute:d.absolute}};exports.SheetCanvasFloatDomManagerService=class extends p.Disposable{constructor(t,r,i,o,s,a,c,u){super();X(this,"_domLayerMap",new Map);X(this,"_domLayerInfoMap",new Map);X(this,"_transformChange$",new ne.Subject);X(this,"transformChange$",this._transformChange$.asObservable());X(this,"_remove$",new ne.Subject);X(this,"remove$",this._remove$.asObservable());this._renderManagerService=t,this._univerInstanceService=r,this._sheetSkeletonManagerService=i,this._commandService=o,this._drawingManagerService=s,this._selectionRenderService=a,this._canvasFloatDomService=c,this._sheetDrawingService=u,this._drawingAddListener(),this._scrollUpdateListener(),this._featureUpdateListener(),this._deleteListener()}_ensureMap(t,r){let i=this._domLayerMap.get(t);i||(i=new Map,this._domLayerMap.set(t,i));let o=i.get(r);return o||(o=new Map,i.set(r,o)),o}_getSceneAndTransformerByDrawingSearch(t){if(t==null)return;const r=this._renderManagerService.getRenderById(t),i=r==null?void 0:r.scene;if(r==null||i==null)return null;const o=i.getTransformerByCreate(),s=r.engine.getCanvasElement();return{scene:i,transformer:o,renderObject:r,canvas:s}}_drawingAddListener(){this.disposeWithMe(this._drawingManagerService.add$.subscribe(t=>{t.forEach(r=>{const{unitId:i,subUnitId:o,drawingId:s}=r,a=C.getSheetCommandTarget(this._univerInstanceService,{unitId:i,subUnitId:o}),c=this._drawingManagerService.getDrawingByParam(r),u=this._sheetSkeletonManagerService.getUnitSkeleton(i,o);if(c==null||a==null||u==null)return;const{transform:l,drawingType:d}=c;if(d!==p.DrawingTypeEnum.DRAWING_DOM)return;const h=this._getSceneAndTransformerByDrawingSearch(i);if(h==null)return;const{scene:g,canvas:w}=h;if(l==null)return!0;const{left:f,top:_,width:M,height:D,angle:I,flipX:R,flipY:v,skewX:A,skewY:S}=l,P=E.getDrawingShapeKeyByDrawingSearch({unitId:i,subUnitId:o,drawingId:s}),T=g.getObject(P);if(T!=null){T.transformByState({left:f,top:_,width:M,height:D,angle:I,flipX:R,flipY:v,skewX:A,skewY:S});return}const G={left:f,top:_,width:M,height:D,zIndex:this._drawingManagerService.getDrawingOrder(i,o).length-1},U=new k.Rect(P,G);g.addObject(U,k.DRAWING_OBJECT_LAYER_INDEX).attachTransformerTo(U);const b=new p.DisposableCollection,y=pe(U,h.renderObject,u.skeleton,a.worksheet),N=new ne.BehaviorSubject(y),Y={dispose:b,rect:U,position$:N,unitId:i,subUnitId:o};this._canvasFloatDomService.addFloatDom({position$:N,id:s,componentKey:c.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))}});const Se=U.onTransformChangeObservable.add(()=>{const x=pe(U,h.renderObject,u.skeleton,a.worksheet);N.next(x)});b.add(()=>{this._canvasFloatDomService.removeFloatDom(s)}),Se&&b.add(Se),this._domLayerInfoMap.set(s,Y)})}))}_scrollUpdateListener(){this.disposeWithMe(this._commandService.onCommandExecuted(t=>{var i,o;const r=(s,a)=>{const c=this._getSceneAndTransformerByDrawingSearch(s),u=this._ensureMap(s,a),l=Array.from(u.keys()),d=C.getSheetCommandTarget(this._univerInstanceService,{unitId:s,subUnitId:a}),h=this._sheetSkeletonManagerService.getUnitSkeleton(s,a);!c||!d||!h||l.forEach(g=>{const w=this._domLayerInfoMap.get(g);if(w){const f=pe(w.rect,c.renderObject,h.skeleton,d.worksheet);w.position$.next(f)}})};if(t.id===z.SetScrollOperation.id){const s=t.params,{unitId:a,sheetId:c}=s;r(a,c)}else if(t.id===z.SetZoomRatioOperation.id){const s=t.params,{unitId:a}=s;Array.from((o=(i=this._domLayerMap.get(a))==null?void 0:i.keys())!=null?o:[]).forEach(u=>{r(a,u)})}else if(t.id===C.SetFrozenMutation.id){const{unitId:s,subUnitId:a}=t.params;r(s,a)}}))}_getPosition(t){const{startX:r,endX:i,startY:o,endY:s}=t,a=this._selectionRenderService.getSelectionCellByPosition(r,o);if(a==null)return;const c={column:a.actualColumn,columnOffset:r-a.startX,row:a.actualRow,rowOffset:o-a.startY},u=this._selectionRenderService.getSelectionCellByPosition(i,s);if(u==null)return;const l={column:u.actualColumn,columnOffset:i-u.startX,row:u.actualRow,rowOffset:s-u.startY};return{from:c,to:l}}_featureUpdateListener(){this.disposeWithMe(this._drawingManagerService.update$.subscribe(t=>{t.forEach(r=>{const i=this._drawingManagerService.getDrawingByParam(r);if(!i||i.drawingType!==p.DrawingTypeEnum.DRAWING_DOM)return;const o={...i.transform};this._transformChange$.next({id:r.drawingId,value:o})})}))}_deleteListener(){this.disposeWithMe(this._drawingManagerService.remove$.subscribe(t=>{t.forEach(r=>{this._removeDom(r.drawingId)})}))}addFloatDomToPosition(t){const r=C.getSheetCommandTarget(this._univerInstanceService,{unitId:t.unitId,subUnitId:t.subUnitId});if(!r)throw new Error("cannot find current target!");const{unitId:i,subUnitId:o}=r,{initPosition:s,componentKey:a}=t,c=p.Tools.generateRandomId(),u=this._getPosition(s);if(u==null)return;const l={unitId:i,subUnitId:o,drawingId:c,drawingType:p.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(we.id,{unitId:i,drawings:[l]}),this._ensureMap(i,o).set(c,t),{id:c,dispose:()=>{this._removeDom(c,!0)}}}_removeDom(t,r=!1){const i=this._domLayerInfoMap.get(t);if(!i)return;const{unitId:o,subUnitId:s}=i,a=this._ensureMap(o,s);this._domLayerInfoMap.delete(t),a.delete(t),i.dispose.dispose();const c=this._getSceneAndTransformerByDrawingSearch(o);if(c&&c.scene.removeObject(i.rect),r){const u=this._drawingManagerService.getDrawingByParam({unitId:o,subUnitId:s,drawingId:t});if(!u)return;const l=this._sheetDrawingService.getBatchRemoveOp([u]),{redo:d,objects:h}=l;this._commandService.syncExecuteCommand(m.SetDrawingApplyMutation.id,{unitId:o,subUnitId:s,op:d,objects:h,type:m.DrawingApplyType.REMOVE})}}};exports.SheetCanvasFloatDomManagerService=Ot([K(0,B.Inject(k.IRenderManagerService)),K(1,p.IUniverInstanceService),K(2,B.Inject(z.SheetSkeletonManagerService)),K(3,B.Inject(p.ICommandService)),K(4,E.IDrawingManagerService),K(5,z.ISelectionRenderService),K(6,B.Inject(W.CanvasFloatDomService)),K(7,m.ISheetDrawingService)],exports.SheetCanvasFloatDomManagerService);var Et=Object.defineProperty,Ut=(e,n,t)=>n in e?Et(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,Pt=(e,n,t,r)=>{for(var i=n,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},_e=(e,n)=>(t,r)=>n(t,r,e),Ne=(e,n,t)=>(Ut(e,typeof n!="symbol"?n+"":n,t),t);const Nt="SHEET_IMAGE_UI_PLUGIN";exports.UniverSheetsDrawingUIPlugin=class extends p.Plugin{constructor(t={},r,i){super();X(this,"_pluginConfig");this._injector=r,this._localeService=i,this._pluginConfig=p.Tools.deepMerge({},Rt,t)}onStarting(t){super.onStarting(t),this._initDependencies(t)}_initDependencies(t){[[exports.SheetCanvasFloatDomManagerService],[re,{useFactory:()=>this._injector.createInstance(re,this._pluginConfig)}],[le],[ce],[de]].forEach(i=>t.add(i))}};Ne(exports.UniverSheetsDrawingUIPlugin,"type",p.UniverInstanceType.UNIVER_SHEET);Ne(exports.UniverSheetsDrawingUIPlugin,"pluginName",Nt);exports.UniverSheetsDrawingUIPlugin=Pt([p.DependentOn(E.UniverDrawingPlugin,ee.UniverDrawingUIPlugin,m.UniverSheetsDrawingPlugin),_e(1,B.Inject(B.Injector)),_e(2,B.Inject(p.LocaleService))],exports.UniverSheetsDrawingUIPlugin);