@univerjs/sheets-drawing-ui 0.2.1 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/umd/index.js CHANGED
@@ -1 +1 @@
1
- (function(O,h){typeof exports=="object"&&typeof module<"u"?h(exports,require("@univerjs/core"),require("@wendellhu/redi"),require("@univerjs/drawing-ui"),require("@univerjs/sheets-drawing"),require("@univerjs/drawing"),require("@univerjs/engine-render"),require("@univerjs/sheets-ui"),require("rxjs"),require("@univerjs/ui"),require("@wendellhu/redi/react-bindings"),require("@univerjs/sheets"),require("react"),require("@univerjs/design"),require("clsx")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@wendellhu/redi","@univerjs/drawing-ui","@univerjs/sheets-drawing","@univerjs/drawing","@univerjs/engine-render","@univerjs/sheets-ui","rxjs","@univerjs/ui","@wendellhu/redi/react-bindings","@univerjs/sheets","react","@univerjs/design","clsx"],h):(O=typeof globalThis<"u"?globalThis:O||self,h(O.UniverSheetsDrawingUi={},O.UniverCore,O["@wendellhu/redi"],O.UniverDrawingUi,O.UniverSheetsDrawing,O.UniverDrawing,O.UniverEngineRender,O.UniverSheetsUi,O.rxjs,O.UniverUi,O["@wendellhu/redi/react-bindings"],O.UniverSheets,O.React,O.UniverDesign,O.clsx))})(this,function(O,h,W,te,p,N,$,G,F,Y,Z,v,j,Q,pe){"use strict";var Yt=Object.defineProperty;var Ft=(O,h,W)=>h in O?Yt(O,h,{enumerable:!0,configurable:!0,writable:!0,value:W}):O[h]=W;var J=(O,h,W)=>Ft(O,typeof h!="symbol"?h+"":h,W);const V={id:"sheet.operation.clear-drawing-transformer",type:h.CommandType.MUTATION,handler:(i,e)=>{const r=i.get($.IRenderManagerService);return e.forEach(t=>{var n,o;(o=(n=r.getRenderById(t))==null?void 0:n.scene.getTransformer())==null||o.debounceRefreshControls()}),!0}},he={id:"sheet.command.remove-sheet-image",type:h.CommandType.COMMAND,handler:(i,e)=>{const r=i.get(h.ICommandService),t=i.get(h.IUndoRedoService),n=i.get(p.ISheetDrawingService);if(!e)return!1;const{drawings:o}=e,a=[];o.forEach(S=>{const{unitId:f}=S;a.push(f)});const s=n.getBatchRemoveOp(o),{unitId:l,subUnitId:m,undo:u,redo:c,objects:d}=s;return r.syncExecuteCommand(p.SetDrawingApplyMutation.id,{unitId:l,subUnitId:m,op:c,objects:d,type:p.DrawingApplyType.REMOVE})?(t.pushUndoRedo({unitID:l,undoMutations:[{id:p.SetDrawingApplyMutation.id,params:{unitId:l,subUnitId:m,op:u,objects:d,type:p.DrawingApplyType.INSERT}},{id:V.id,params:a}],redoMutations:[{id:p.SetDrawingApplyMutation.id,params:{unitId:l,subUnitId:m,op:c,objects:d,type:p.DrawingApplyType.REMOVE}},{id:V.id,params:a}]}),!0):!1}},je="COMPONENT_SHEET_DRAWING_PANEL",Te={id:"sidebar.operation.sheet-image",type:h.CommandType.COMMAND,handler:async(i,e)=>{const r=i.get(Y.ISidebarService),t=i.get(h.LocaleService),n=i.get(h.IUniverInstanceService),o=i.get(N.IDrawingManagerService);if(!v.getSheetCommandTarget(n))return!1;switch(e.value){case"open":r.open({header:{title:t.t("sheetImage.panel.title")},children:{label:je},onClose:()=>{o.focusDrawing(null)},width:360});break;case"close":default:r.close();break}return!0}},Oe={id:"sheet.operation.edit-sheet-image",type:h.CommandType.OPERATION,handler:(i,e)=>{const r=i.get(N.IDrawingManagerService),t=i.get(h.ICommandService);return e==null?!1:(r.focusDrawing([e]),t.executeCommand(Te.id,{value:"open"}),!0)}},fe={uploadLoading:"univer-upload-loading",uploadLoadingBody:"univer-upload-loading-body",uploadLoadingBodyAnimation:"univer-upload-loading-body-animation",univerCircleAnimation:"univer-UniverCircleAnimation",uploadLoadingBodyText:"univer-upload-loading-body-text"},ke=()=>{const i=Z.useDependency(N.IImageIoService),e=Z.useDependency(h.LocaleService),[r,t]=j.useState(0);return j.useEffect(()=>{const n=i.change$.subscribe(o=>{t(o)});return()=>{n.unsubscribe()}},[i]),j.createElement("div",{style:{display:r>0?"block":"none"},className:fe.uploadLoading},j.createElement("div",{className:fe.uploadLoadingBody},j.createElement("div",{className:fe.uploadLoadingBodyAnimation}),j.createElement("div",{className:fe.uploadLoadingBodyText},`${e.t("uploadLoading.loading")}: ${r}`)))};var Ke=Object.defineProperty,xe=Object.getOwnPropertyDescriptor,ze=(i,e,r,t)=>{for(var n=t>1?void 0:t?xe(e,r):e,o=i.length-1,a;o>=0;o--)(a=i[o])&&(n=(t?a(e,r,n):a(n))||n);return t&&n&&Ke(e,r,n),n},ne=(i,e)=>(r,t)=>e(r,t,i);let Se=class extends h.RxDisposable{constructor(e,r,t,n,o,a,s){super();J(this,"_initImagePopupMenu",new Set);this._injector=e,this._drawingManagerService=r,this._canvasPopManagerService=t,this._renderManagerService=n,this._univerInstanceService=o,this._contextService=a,this._uiPartsService=s,this._init()}_init(){this._univerInstanceService.getCurrentTypeOfUnit$(h.UniverInstanceType.UNIVER_SHEET).pipe(F.takeUntil(this.dispose$)).subscribe(e=>this._create(e)),this._univerInstanceService.getTypeOfUnitDisposed$(h.UniverInstanceType.UNIVER_SHEET).pipe(F.takeUntil(this.dispose$)).subscribe(e=>this._dispose(e)),this._univerInstanceService.getAllUnitsForType(h.UniverInstanceType.UNIVER_SHEET).forEach(e=>this._create(e)),this._uiPartsService.registerComponent(Y.BuiltInUIPart.CONTENT,()=>Z.connectInjector(ke,this._injector))}_dispose(e){const r=e.getUnitId();this._renderManagerService.removeRender(r)}_create(e){if(!e)return;const r=e.getUnitId();this._renderManagerService.has(r)&&!this._initImagePopupMenu.has(r)&&(this._popupMenuListener(r),this._initImagePopupMenu.add(r))}_hasCropObject(e){const r=e.getAllObjects();for(const t of r)if(t instanceof te.ImageCropperObject)return!0;return!1}_popupMenuListener(e){var o;const r=(o=this._renderManagerService.getRenderById(e))==null?void 0:o.scene;if(!r)return;const t=r.getTransformerByCreate();if(!t)return;let n;this.disposeWithMe(h.toDisposable(t.createControl$.subscribe(()=>{if(this._contextService.setContextValue(h.FOCUSING_COMMON_DRAWINGS,!0),this._hasCropObject(r))return;const a=t.getSelectedObjectMap();if(a.size>1){n==null||n.dispose();return}const s=a.values().next().value;if(!s)return;const l=s.oKey,m=this._drawingManagerService.getDrawingOKey(l);if(!m)return;const{unitId:u,subUnitId:c,drawingId:d}=m;n==null||n.dispose(),n=this.disposeWithMe(this._canvasPopManagerService.attachPopupToObject(s,{componentKey:te.COMPONENT_IMAGE_POPUP_MENU,direction:"horizontal",offset:[2,0],extraProps:{menuItems:this._getImageMenuItems(u,c,d)}})),this._drawingManagerService.focusDrawing([{unitId:u,subUnitId:c,drawingId:d}])}))),this.disposeWithMe(t.clearControl$.subscribe(()=>{n==null||n.dispose(),this._contextService.setContextValue(h.FOCUSING_COMMON_DRAWINGS,!1),this._drawingManagerService.focusDrawing(null)})),this.disposeWithMe(t.changing$.subscribe(()=>{n==null||n.dispose()}))}_getImageMenuItems(e,r,t){return[{label:"image-popup.edit",index:0,commandId:Oe.id,commandParams:{unitId:e,subUnitId:r,drawingId:t},disable:!1},{label:"image-popup.delete",index:1,commandId:he.id,commandParams:{unitId:e,drawings:[{unitId:e,subUnitId:r,drawingId:t}]},disable:!1},{label:"image-popup.crop",index:2,commandId:te.OpenImageCropOperation.id,commandParams:{unitId:e,subUnitId:r,drawingId:t},disable:!1},{label:"image-popup.reset",index:3,commandId:te.ImageResetSizeOperation.id,commandParams:[{unitId:e,subUnitId:r,drawingId:t}],disable:!1}]}};Se=ze([h.OnLifecycle(h.LifecycleStages.Steady,Se),ne(0,W.Inject(W.Injector)),ne(1,N.IDrawingManagerService),ne(2,W.Inject(G.SheetCanvasPopManagerService)),ne(3,$.IRenderManagerService),ne(4,h.IUniverInstanceService),ne(5,h.IContextService),ne(6,W.Inject(Y.IUIPartsService))],Se);const ae={id:"sheet.operation.insert-float-image",type:h.CommandType.OPERATION,handler:(i,e)=>!0},se={id:"sheet.operation.insert-cell-image",type:h.CommandType.OPERATION,handler:(i,e)=>!0},we={id:"sheet.command.insert-sheet-image",type:h.CommandType.COMMAND,handler:(i,e)=>{const r=i.get(h.ICommandService),t=i.get(h.IUndoRedoService),n=i.get(p.ISheetDrawingService);if(!e)return!1;const o=e.drawings,a=o.map(S=>S.unitId),s=n.getBatchAddOp(o),{unitId:l,subUnitId:m,undo:u,redo:c,objects:d}=s;return r.syncExecuteCommand(p.SetDrawingApplyMutation.id,{op:c,unitId:l,subUnitId:m,objects:d,type:p.DrawingApplyType.INSERT})?(t.pushUndoRedo({unitID:l,undoMutations:[{id:p.SetDrawingApplyMutation.id,params:{op:u,unitId:l,subUnitId:m,objects:d,type:p.DrawingApplyType.REMOVE}},{id:V.id,params:a}],redoMutations:[{id:p.SetDrawingApplyMutation.id,params:{op:c,unitId:l,subUnitId:m,objects:d,type:p.DrawingApplyType.INSERT}},{id:V.id,params:a}]}),!0):!1}},ce={id:"sheet.command.set-sheet-image",type:h.CommandType.COMMAND,handler:(i,e)=>{const r=i.get(h.ICommandService),t=i.get(h.IUndoRedoService),n=i.get(p.ISheetDrawingService);if(!e)return!1;const{drawings:o}=e,a=n.getBatchUpdateOp(o),{unitId:s,subUnitId:l,undo:m,redo:u,objects:c}=a;return r.syncExecuteCommand(p.SetDrawingApplyMutation.id,{unitId:s,subUnitId:l,op:u,objects:c,type:p.DrawingApplyType.UPDATE})?(t.pushUndoRedo({unitID:s,undoMutations:[{id:p.SetDrawingApplyMutation.id,params:{unitId:s,subUnitId:l,op:m,objects:c,type:p.DrawingApplyType.UPDATE}},{id:V.id,params:[s]}],redoMutations:[{id:p.SetDrawingApplyMutation.id,params:{unitId:s,subUnitId:l,op:u,objects:c,type:p.DrawingApplyType.UPDATE}},{id:V.id,params:[s]}]}),!0):!1}},Ee={id:"sheet.command.set-drawing-arrange",type:h.CommandType.COMMAND,handler:(i,e)=>{const r=i.get(h.ICommandService),t=i.get(h.IUndoRedoService);if(!e)return!1;const n=i.get(p.ISheetDrawingService),{unitId:o,subUnitId:a,drawingIds:s,arrangeType:l}=e,m={unitId:o,subUnitId:a,drawingIds:s};let u;if(l===N.ArrangeTypeEnum.forward?u=n.getForwardDrawingsOp(m):l===N.ArrangeTypeEnum.backward?u=n.getBackwardDrawingOp(m):l===N.ArrangeTypeEnum.front?u=n.getFrontDrawingsOp(m):l===N.ArrangeTypeEnum.back&&(u=n.getBackDrawingsOp(m)),u==null)return!1;const{objects:c,redo:d,undo:g}=u;return r.syncExecuteCommand(p.SetDrawingApplyMutation.id,{op:d,unitId:o,subUnitId:a,objects:c,type:p.DrawingApplyType.ARRANGE})?(t.pushUndoRedo({unitID:o,undoMutations:[{id:p.SetDrawingApplyMutation.id,params:{op:g,unitId:o,subUnitId:a,objects:c,type:p.DrawingApplyType.ARRANGE}}],redoMutations:[{id:p.SetDrawingApplyMutation.id,params:{op:d,unitId:o,subUnitId:a,objects:c,type:p.DrawingApplyType.ARRANGE}}]}),!0):!1}};function qe(i){const e=[];return i.forEach(r=>{const{parent:t,children:n}=r,{unitId:o,subUnitId:a,drawingId:s}=t,l=$.getGroupState(0,0,n.map(c=>c.transform||{})),m=n.map(c=>{const d=c.transform||{left:0,top:0},{unitId:g,subUnitId:S,drawingId:f}=c;return{unitId:g,subUnitId:S,drawingId:f,transform:{...d,left:d.left-l.left,top:d.top-l.top},groupId:s}}),u={unitId:o,subUnitId:a,drawingId:s,drawingType:N.DrawingTypeEnum.DRAWING_GROUP,transform:l};e.push({parent:u,children:m})}),e}function Je(i){const e=[];return i.forEach(r=>{const{parent:t,children:n}=r,{unitId:o,subUnitId:a,drawingId:s,transform:l={width:0,height:0}}=t;if(l==null)return;const m=n.map(c=>{const{transform:d}=c,{unitId:g,subUnitId:S,drawingId:f}=c,w=$.transformObjectOutOfGroup(d||{},l,l.width||0,l.height||0);return{unitId:g,subUnitId:S,drawingId:f,transform:w,groupId:void 0}}),u={unitId:o,subUnitId:a,drawingId:s,drawingType:N.DrawingTypeEnum.DRAWING_GROUP,transform:{left:0,top:0}};e.push({parent:u,children:m})}),e}const be={id:"sheet.command.group-sheet-image",type:h.CommandType.COMMAND,handler:(i,e)=>{const r=i.get(h.ICommandService),t=i.get(h.IUndoRedoService),n=i.get(p.ISheetDrawingService);if(!e)return!1;const o=[];e.forEach(({parent:g,children:S})=>{o.push(g.unitId),S.forEach(f=>{o.push(f.unitId)})});const a=n.getGroupDrawingOp(e),{unitId:s,subUnitId:l,undo:m,redo:u,objects:c}=a;return r.syncExecuteCommand(p.SetDrawingApplyMutation.id,{op:u,unitId:s,subUnitId:l,objects:c,type:p.DrawingApplyType.GROUP})?(t.pushUndoRedo({unitID:s,undoMutations:[{id:p.SetDrawingApplyMutation.id,params:{op:m,unitId:s,subUnitId:l,objects:Je(c),type:p.DrawingApplyType.UNGROUP}},{id:V.id,params:o}],redoMutations:[{id:p.SetDrawingApplyMutation.id,params:{op:u,unitId:s,subUnitId:l,objects:c,type:p.DrawingApplyType.GROUP}},{id:V.id,params:o}]}),!0):!1}},Pe={id:"sheet.command.ungroup-sheet-image",type:h.CommandType.COMMAND,handler:(i,e)=>{const r=i.get(h.ICommandService),t=i.get(h.IUndoRedoService),n=i.get(p.ISheetDrawingService);if(!e)return!1;const o=[];e.forEach(({parent:g,children:S})=>{o.push(g.unitId),S.forEach(f=>{o.push(f.unitId)})});const a=n.getUngroupDrawingOp(e),{unitId:s,subUnitId:l,undo:m,redo:u,objects:c}=a;return r.syncExecuteCommand(p.SetDrawingApplyMutation.id,{op:u,unitId:s,subUnitId:l,objects:c,type:p.DrawingApplyType.UNGROUP})?(t.pushUndoRedo({unitID:s,undoMutations:[{id:p.SetDrawingApplyMutation.id,params:{op:m,unitId:s,subUnitId:l,objects:qe(c),type:p.DrawingApplyType.GROUP}},{id:V.id,params:o}],redoMutations:[{id:p.SetDrawingApplyMutation.id,params:{op:u,unitId:s,subUnitId:l,objects:c,type:p.DrawingApplyType.UNGROUP}},{id:V.id,params:o}]}),!0):!1}};function H(i,e,r){const{from:t,to:n,flipY:o=!1,flipX:a=!1,angle:s=0,skewX:l=0,skewY:m=0}=i,{column:u,columnOffset:c,row:d,rowOffset:g}=t,{column:S,columnOffset:f,row:w,rowOffset:I}=n,D=e.attachRangeWithCoord({startColumn:u,endColumn:u,startRow:d,endRow:d});if(D==null)return;const y=e.attachRangeWithCoord({startColumn:S,endColumn:S,startRow:w,endRow:w});if(y==null)return;const{startX:R,startY:C}=D,{startX:P,startY:_}=y;let U=$.precisionTo(R+c,1),A=$.precisionTo(C+g,1),T=$.precisionTo(P+f-U,1),b=$.precisionTo(_+I-A,1);D.startX===y.endX&&(T=0),D.startY===y.endY&&(b=0);const E=r.getCurrentSkeleton(),M=E.rowHeaderWidth+E.columnTotalWidth,L=E.columnHeaderHeight+E.rowTotalHeight;return U+T>M&&(U=M-T),A+b>L&&(A=L-b),{flipY:o,flipX:a,angle:s,skewX:l,skewY:m,left:U,top:A,width:T,height:b}}function B(i,e){const{left:r=0,top:t=0,width:n=0,height:o=0,flipY:a=!1,flipX:s=!1,angle:l=0,skewX:m=0,skewY:u=0}=i,c=e.getSelectionCellByPosition(r,t);if(c==null)return;const d={column:c.actualColumn,columnOffset:$.precisionTo(r-c.startX,1),row:c.actualRow,rowOffset:$.precisionTo(t-c.startY,1)},g=e.getSelectionCellByPosition(r+n,t+o);if(g==null)return;const S={column:g.actualColumn,columnOffset:$.precisionTo(r+n-g.startX,1),row:g.actualRow,rowOffset:$.precisionTo(t+o-g.startY,1)};return{flipY:a,flipX:s,angle:l,skewX:m,skewY:u,from:d,to:S}}var Ze=Object.defineProperty,Qe=Object.getOwnPropertyDescriptor,et=(i,e,r,t)=>{for(var n=t>1?void 0:t?Qe(e,r):e,o=i.length-1,a;o>=0;o--)(a=i[o])&&(n=(t?a(e,r,n):a(n))||n);return t&&n&&Ze(e,r,n),n},K=(i,e)=>(r,t)=>e(r,t,i);let ve=class extends h.Disposable{constructor(i,e,r,t,n,o,a,s,l,m,u,c,d){super(),this._context=i,this._commandService=e,this._univerInstanceService=r,this._selectionManagerService=t,this._selectionRenderService=n,this._imageIoService=o,this._sheetDrawingService=a,this._drawingManagerService=s,this._contextService=l,this._messageService=m,this._localeService=u,this._renderManagerService=c,this._sheetSkeletonManagerService=d,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===se.id||i.id===ae.id){const e=i.params;if(e.files==null)return;const r=e.files.length;if(r>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(r),i.id===se.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(D){const y=D.message;y===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)))}):y===N.ImageUploadStatusType.ERROR_IMAGE_TYPE?this._messageService.show({type:Q.MessageType.Error,content:this._localeService.t("update-status.invalidImageType")}):y===N.ImageUploadStatusType.ERROR_IMAGE&&this._messageService.show({type:Q.MessageType.Error,content:this._localeService.t("update-status.invalidImage")})}if(e==null)return;const r=this._getUnitInfo();if(r==null)return;const{unitId:t,subUnitId:n}=r,{imageId:o,imageSourceType:a,source:s,base64Cache:l}=e,{width:m,height:u,image:c}=await N.getImageSize(l||""),d=this._renderManagerService.getRenderById(t);if(d==null)return;const{width:g,height:S}=d.scene;this._imageIoService.addImageSourceCache(s,a,c);let f=1;if(m>N.DRAWING_IMAGE_WIDTH_LIMIT||u>N.DRAWING_IMAGE_HEIGHT_LIMIT){const D=N.DRAWING_IMAGE_WIDTH_LIMIT/m,y=N.DRAWING_IMAGE_HEIGHT_LIMIT/u;f=Math.max(D,y)}const w=this._getImagePosition(m*f,u*f,g,S);if(w==null)return;const I={unitId:t,subUnitId:n,drawingId:o,drawingType:N.DrawingTypeEnum.DRAWING_IMAGE,imageSourceType:a,source:s,transform:H(w,this._selectionRenderService,this._sheetSkeletonManagerService),sheetTransform:w};this._commandService.executeCommand(we.id,{unitId:t,drawings:[I]})}_getUnitInfo(){const i=this._univerInstanceService.getCurrentUnitForType(h.UniverInstanceType.UNIVER_SHEET);if(i==null)return;const e=i.getActiveSheet();if(e==null)return;const r=i.getUnitId(),t=e.getSheetId();return{unitId:r,subUnitId:t}}_getImagePosition(i,e,r,t){const n=this._selectionManagerService.getSelections();let o={startRow:0,endRow:0,startColumn:0,endColumn:0};n&&n.length>0&&(o=n[n.length-1].range);const a=this._selectionRenderService.attachRangeWithCoord(o);if(a==null)return;let{startColumn:s,startRow:l,startX:m,startY:u}=a,c=!1;if(m+i>r&&(m=r-i,m<0&&(m=0,i=r),c=!0),u+e>t&&(u=t-e,u<0&&(u=0,e=t),c=!0),c){const f=this._selectionRenderService.getSelectionCellByPosition(m,u);if(f==null)return;m=f.startX,u=f.startY,s=f.actualColumn,l=f.actualRow}const d={column:s,columnOffset:0,row:l,rowOffset:0},g=this._selectionRenderService.getSelectionCellByPosition(m+i,u+e);if(g==null)return;const S={column:g.actualColumn,columnOffset:m+i-g.startX,row:g.actualRow,rowOffset:u+e-g.startY};return{from:d,to:S}}_updateOrderListener(){this._drawingManagerService.featurePluginOrderUpdate$.subscribe(i=>{const{unitId:e,subUnitId:r,drawingIds:t,arrangeType:n}=i;this._commandService.executeCommand(Ee.id,{unitId:e,subUnitId:r,drawingIds:t,arrangeType:n})})}_updateImageListener(){this._drawingManagerService.featurePluginUpdate$.subscribe(i=>{const e=[];i.length!==0&&(i.forEach(r=>{const{unitId:t,subUnitId:n,drawingId:o,drawingType:a,transform:s}=r;if(s==null)return;const l=this._sheetDrawingService.getDrawingByParam({unitId:t,subUnitId:n,drawingId:o});if(l==null)return;const m=B({...l.transform,...s},this._selectionRenderService);if(m==null)return;const u={...r,transform:{...l.transform,...s,...H(m,this._selectionRenderService,this._sheetSkeletonManagerService)},sheetTransform:{...m}};e.push(u)}),e.length>0&&this._commandService.executeCommand(ce.id,{unitId:i[0].unitId,drawings:e}))})}_groupDrawingListener(){this._drawingManagerService.featurePluginGroupUpdate$.subscribe(i=>{this._commandService.executeCommand(be.id,i);const{unitId:e,subUnitId:r,drawingId:t}=i[0].parent;this._drawingManagerService.focusDrawing([{unitId:e,subUnitId:r,drawingId:t}])}),this._drawingManagerService.featurePluginUngroupUpdate$.subscribe(i=>{this._commandService.executeCommand(Pe.id,i)})}_focusDrawingListener(){this.disposeWithMe(this._drawingManagerService.focus$.subscribe(i=>{i==null||i.length===0?(this._contextService.setContextValue(h.FOCUSING_COMMON_DRAWINGS,!1),this._sheetDrawingService.focusDrawing([])):(this._contextService.setContextValue(h.FOCUSING_COMMON_DRAWINGS,!0),this._sheetDrawingService.focusDrawing(i))}))}_drawingAddListener(){this.disposeWithMe(this._sheetDrawingService.add$.subscribe(i=>{this._registerDrawing(i)}))}_registerDrawing(i){i.forEach(r=>{const t=this._sheetDrawingService.getDrawingByParam(r);if(t==null)return;const{sheetTransform:n}=t;t.transform=H(n,this._selectionRenderService,this._sheetSkeletonManagerService)});const e=i[0].unitId;this._drawingManagerService.registerDrawingData(e,this._sheetDrawingService.getDrawingDataForUnit(e)),this._drawingManagerService.initializeNotification(e)}};ve=et([h.OnLifecycle(h.LifecycleStages.Rendered,ve),K(1,h.ICommandService),K(2,h.IUniverInstanceService),K(3,W.Inject(v.SelectionManagerService)),K(4,G.ISelectionRenderService),K(5,N.IImageIoService),K(6,p.ISheetDrawingService),K(7,N.IDrawingManagerService),K(8,h.IContextService),K(9,Y.IMessageService),K(10,W.Inject(h.LocaleService)),K(11,$.IRenderManagerService),K(12,W.Inject(G.SheetSkeletonManagerService))],ve);var x=function(){return x=Object.assign||function(i){for(var e,r=1,t=arguments.length;r<t;r++){e=arguments[r];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(i[n]=e[n])}return i},x.apply(this,arguments)},tt=function(i,e){var r={};for(var t in i)Object.prototype.hasOwnProperty.call(i,t)&&e.indexOf(t)<0&&(r[t]=i[t]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,t=Object.getOwnPropertySymbols(i);n<t.length;n++)e.indexOf(t[n])<0&&Object.prototype.propertyIsEnumerable.call(i,t[n])&&(r[t[n]]=i[t[n]]);return r},We=j.forwardRef(function(i,e){var r=i.icon,t=i.id,n=i.className,o=i.extend,a=tt(i,["icon","id","className","extend"]),s="univerjs-icon univerjs-icon-".concat(t," ").concat(n||"").trim(),l=j.useRef("_".concat(it()));return $e(r,"".concat(t),{defIds:r.defIds,idSuffix:l.current},x({ref:e,className:s},a),o)});function $e(i,e,r,t,n){return j.createElement(i.tag,x(x({key:e},nt(i,r,n)),t),(rt(i,r).children||[]).map(function(o,a){return $e(o,"".concat(e,"-").concat(i.tag,"-").concat(a),r,void 0,n)}))}function nt(i,e,r){var t=x({},i.attrs);r!=null&&r.colorChannel1&&t.fill==="colorChannel1"&&(t.fill=r.colorChannel1);var n=e.defIds;return!n||n.length===0||(i.tag==="use"&&t["xlink:href"]&&(t["xlink:href"]=t["xlink:href"]+e.idSuffix),Object.entries(t).forEach(function(o){var a=o[0],s=o[1];typeof s=="string"&&(t[a]=s.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),t}function rt(i,e){var r,t=e.defIds;return!t||t.length===0?i:i.tag==="defs"&&(!((r=i.children)===null||r===void 0)&&r.length)?x(x({},i),{children:i.children.map(function(n){return typeof n.attrs.id=="string"&&t&&t.indexOf(n.attrs.id)>-1?x(x({},n),{attrs:x(x({},n.attrs),{id:n.attrs.id+e.idSuffix})}):n})}):i}function it(){return Math.random().toString(36).substring(2,8)}We.displayName="UniverIcon";var ot={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M2.2498 3.65005C2.2498 2.87685 2.87661 2.25005 3.64981 2.25005H7.9998C8.33118 2.25005 8.5998 1.98142 8.5998 1.65005C8.5998 1.31868 8.33118 1.05005 7.9998 1.05005H3.64981C2.21387 1.05005 1.0498 2.21411 1.0498 3.65005V12.35C1.0498 13.786 2.21386 14.95 3.6498 14.95H12.3498C13.7857 14.95 14.9498 13.786 14.9498 12.3501V8.00005C14.9498 7.66868 14.6812 7.40005 14.3498 7.40005C14.0184 7.40005 13.7498 7.66868 13.7498 8.00005V9.23974L12.2385 8.1063C11.7252 7.72129 11.0068 7.7723 10.5531 8.22605L9.00869 9.77041L6.73916 7.8251C6.24387 7.40055 5.5095 7.41278 5.02864 7.85359L2.2498 10.4009V3.65005ZM2.2498 12.0287V12.35C2.2498 13.1232 2.87661 13.75 3.6498 13.75H12.3498C13.123 13.75 13.7498 13.1232 13.7498 12.3501V10.7397L11.5186 9.06631C11.4829 9.03956 11.433 9.04314 11.4016 9.07458L9.92249 10.5537L11.1015 11.5642C11.3531 11.7799 11.3822 12.1587 11.1666 12.4103C10.9509 12.6619 10.5721 12.691 10.3205 12.4753L5.9582 8.7362C5.92384 8.70674 5.87288 8.70758 5.83952 8.73816L2.2498 12.0287Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M11.8097 1.14783C12.1411 1.14783 12.4097 1.41646 12.4097 1.74783V3.297H14.1541C14.4855 3.297 14.7541 3.56563 14.7541 3.897C14.7541 4.22837 14.4855 4.497 14.1541 4.497H12.4097V6.24167C12.4097 6.57304 12.1411 6.84167 11.8097 6.84167C11.4783 6.84167 11.2097 6.57304 11.2097 6.24167V4.497H9.6603C9.32893 4.497 9.0603 4.22837 9.0603 3.897C9.0603 3.56563 9.32893 3.297 9.6603 3.297H11.2097V1.74783C11.2097 1.41646 11.4783 1.14783 11.8097 1.14783Z"}}]},Ge=j.forwardRef(function(i,e){return j.createElement(We,Object.assign({},i,{id:"add-image-single",ref:e,icon:ot}))});Ge.displayName="AddImageSingle";const Be={uploadFileMenu:"univer-upload-file-menu",uploadFileMenuInput:"univer-upload-file-menu-input"},Ve="COMPONENT_UPLOAD_FILE_MENU";var _e=(i=>(i[i.cellImage=0]="cellImage",i[i.floatImage=1]="floatImage",i))(_e||{});const at=i=>{const{type:e}=i,r=Z.useDependency(h.ICommandService),t=j.useRef(null),n=()=>{var s;(s=t.current)==null||s.click()},o=N.DRAWING_IMAGE_ALLOW_IMAGE_LIST.map(s=>`.${s.replace("image/","")}`).join(","),a=s=>{const l=s.target.files;if(l==null)return;const m=Array.from(l);e===_e.floatImage?r.executeCommand(ae.id,{files:m}):e===_e.cellImage&&r.executeCommand(se.id,{files:m}),t.current&&(t.current.value="")};return j.createElement("div",{onClick:n,className:Be.uploadFileMenu},j.createElement("input",{type:"file",className:Be.uploadFileMenuInput,ref:t,onChange:a,accept:o,multiple:!0}))},Ye="addition-and-subtraction-single",Fe="sheet.menu.image";function st(i){return{id:Fe,type:Y.MenuItemType.SUBITEMS,positions:[Y.MenuPosition.TOOLBAR_START],group:Y.MenuGroup.TOOLBAR_FORMULAS_INSERT,icon:Ye,tooltip:"sheetImage.title",hidden$:Y.getMenuHiddenObservable(i,h.UniverInstanceType.UNIVER_SHEET),disabled$:G.getCurrentRangeDisable$(i,{workbookTypes:[v.WorkbookEditablePermission],worksheetTypes:[v.WorksheetEditPermission],rangeTypes:[v.RangeProtectionPermissionEditPoint]})}}function ct(i){return{id:ae.id,title:"sheetImage.upload.float",type:Y.MenuItemType.SELECTOR,label:{name:Ve,props:{type:_e.floatImage}},positions:[Fe],hidden$:Y.getMenuHiddenObservable(i,h.UniverInstanceType.UNIVER_SHEET)}}const ee={imageCommonPanel:"univer-image-common-panel",imageCommonPanelGrid:"univer-image-common-panel-grid",imageCommonPanelBorder:"univer-image-common-panel-border",imageCommonPanelTitle:"univer-image-common-panel-title",imageCommonPanelRow:"univer-image-common-panel-row",imageCommonPanelRowVertical:"univer-image-common-panel-row-vertical",imageCommonPanelColumn:"univer-image-common-panel-column",imageCommonPanelColumnCenter:"univer-image-common-panel-column-center",imageCommonPanelInline:"univer-image-common-panel-inline",imageCommonPanelSpan2:"univer-image-common-panel-span2",imageCommonPanelSpan3:"univer-image-common-panel-span3",imageCommonPanelInput:"univer-image-common-panel-input",sheetImageMenu:"univer-sheet-image-menu",sheetImageMenuInput:"univer-sheet-image-menu-input"},lt=i=>{var y;const e=Z.useDependency(h.ICommandService),r=Z.useDependency(h.LocaleService),t=Z.useDependency(N.IDrawingManagerService),n=Z.useDependency($.IRenderManagerService),{drawings:o}=i,a=o[0];if(a==null)return;const{unitId:s}=a,l=n.getRenderById(s),m=l==null?void 0:l.scene;if(m==null)return;const u=m.getTransformerByCreate(),[c,d]=j.useState(!0),g=(y=a.anchorType)!=null?y:p.SheetDrawingAnchorType.Position,[S,f]=j.useState(g);function w(R,C){const P=[];return R.forEach(_=>{const{oKey:U}=_,A=C.getDrawingOKey(U);if(A==null)return P.push(null),!0;const{unitId:T,subUnitId:b,drawingId:E,drawingType:M,anchorType:L,sheetTransform:X}=A;P.push({unitId:T,subUnitId:b,drawingId:E,anchorType:L,sheetTransform:X,drawingType:M})}),P}j.useEffect(()=>{const R=u.clearControl$.subscribe(P=>{P===!0&&d(!1)}),C=u.changeStart$.subscribe(P=>{var A;const{objects:_}=P,U=w(_,t);if(U.length===0)d(!1);else if(U.length>=1){d(!0);const T=((A=U[0])==null?void 0:A.anchorType)||p.SheetDrawingAnchorType.Position;f(T)}});return()=>{C.unsubscribe(),R.unsubscribe()}},[]);function I(R){f(R);const C=t.getFocusDrawings();if(C.length===0)return;const P=C.map(_=>({unitId:_.unitId,subUnitId:_.subUnitId,drawingId:_.drawingId,anchorType:R}));e.executeCommand(ce.id,{unitId:C[0].unitId,drawings:P})}const D=R=>R?"block":"none";return j.createElement("div",{className:pe(ee.imageCommonPanelGrid,ee.imageCommonPanelBorder),style:{display:D(c)}},j.createElement("div",{className:ee.imageCommonPanelRow},j.createElement("div",{className:pe(ee.imageCommonPanelColumn,ee.imageCommonPanelTitle)},j.createElement("div",null,r.t("drawing-anchor.title")))),j.createElement("div",{className:pe(ee.imageCommonPanelRow)},j.createElement("div",{className:pe(ee.imageCommonPanelColumn)},j.createElement(Q.RadioGroup,{value:S,onChange:I,direction:"vertical"},j.createElement(Q.Radio,{value:p.SheetDrawingAnchorType.Both},r.t("drawing-anchor.both")),j.createElement(Q.Radio,{value:p.SheetDrawingAnchorType.Position},r.t("drawing-anchor.position")),j.createElement(Q.Radio,{value:p.SheetDrawingAnchorType.None},r.t("drawing-anchor.none"))))))},dt=()=>{const i=Z.useDependency(N.IDrawingManagerService),e=i.getFocusDrawings(),[r,t]=j.useState(e);return j.useEffect(()=>{const n=i.focus$.subscribe(o=>{t(o)});return()=>{n.unsubscribe()}},[]),!!(r!=null&&r.length)&&j.createElement("div",{className:ee.imageCommonPanel},j.createElement(te.DrawingCommonPanel,{drawings:r}),j.createElement(lt,{drawings:r}))},oe={id:"sheet.command.move-drawing",type:h.CommandType.COMMAND,handler:(i,e)=>{const r=i.get(h.ICommandService),t=i.get(p.ISheetDrawingService),n=i.get(G.ISelectionRenderService),{direction:o}=e,a=t.getFocusDrawings();if(a.length===0)return!1;const s=a[0].unitId,l=a.map(u=>{const{transform:c}=u;if(c==null)return null;const d={...c},{left:g=0,top:S=0}=c;return o===h.Direction.UP?d.top=S-1:o===h.Direction.DOWN?d.top=S+1:o===h.Direction.LEFT?d.left=g-1:o===h.Direction.RIGHT&&(d.left=g+1),{...u,transform:d,sheetTransform:B(d,n)}}).filter(u=>u!=null);return r.syncExecuteCommand(ce.id,{unitId:s,drawings:l})?(r.syncExecuteCommand(V.id,[s]),!0):!1}},Ae={id:"sheet.command.delete-drawing",type:h.CommandType.COMMAND,handler:i=>{const e=i.get(h.ICommandService),t=i.get(p.ISheetDrawingService).getFocusDrawings();if(t.length===0)return!1;const n=t[0].unitId,o=t.map(a=>{const{unitId:s,subUnitId:l,drawingId:m,drawingType:u}=a;return{unitId:s,subUnitId:l,drawingId:m,drawingType:u}});return e.executeCommand(he.id,{unitId:n,drawings:o})}};function le(i){return!i.getContextValue(h.FOCUSING_FORMULA_EDITOR)&&!i.getContextValue(h.EDITOR_ACTIVATED)&&i.getContextValue(h.FOCUSING_COMMON_DRAWINGS)}const ut={id:oe.id,description:"shortcut.sheet.drawing-move-down",group:"4_sheet-drawing-view",binding:Y.KeyCode.ARROW_DOWN,priority:100,preconditions:le,staticParameters:{direction:h.Direction.DOWN}},mt={id:oe.id,description:"shortcut.sheet.drawing-move-up",group:"4_sheet-drawing-view",binding:Y.KeyCode.ARROW_UP,priority:100,preconditions:le,staticParameters:{direction:h.Direction.UP}},gt={id:oe.id,description:"shortcut.sheet.drawing-move-left",group:"4_sheet-drawing-view",binding:Y.KeyCode.ARROW_LEFT,priority:100,preconditions:le,staticParameters:{direction:h.Direction.LEFT}},pt={id:oe.id,description:"shortcut.sheet.drawing-move-right",group:"4_sheet-drawing-view",binding:Y.KeyCode.ARROW_RIGHT,priority:100,preconditions:le,staticParameters:{direction:h.Direction.RIGHT}},ht={id:Ae.id,description:"shortcut.sheet.drawing-delete",group:"4_sheet-drawing-view",preconditions:le,binding:Y.KeyCode.DELETE,mac:Y.KeyCode.BACKSPACE};var ft=Object.defineProperty,St=Object.getOwnPropertyDescriptor,wt=(i,e,r,t)=>{for(var n=t>1?void 0:t?St(e,r):e,o=i.length-1,a;o>=0;o--)(a=i[o])&&(n=(t?a(e,r,n):a(n))||n);return t&&n&&ft(e,r,n),n},de=(i,e)=>(r,t)=>e(r,t,i);const vt={};let ue=class extends h.Disposable{constructor(i,e,r,t,n,o){super(),this._config=i,this._injector=e,this._componentManager=r,this._menuService=t,this._commandService=n,this._shortcutService=o,this._init()}_initCustomComponents(){const i=this._componentManager;this.disposeWithMe(i.register(Ye,Ge)),this.disposeWithMe(i.register(Ve,at)),this.disposeWithMe(i.register(je,dt))}_initMenus(){const{menu:i={}}=this._config;[st,ct].forEach(e=>{this._menuService.addMenuItem(e(this._injector),i)})}_initCommands(){[ae,se,we,he,ce,Te,V,Oe,be,Pe,oe,Ae,Ee].forEach(i=>this.disposeWithMe(this._commandService.registerCommand(i)))}_initShortcuts(){[ut,mt,gt,pt,ht].forEach(i=>{this.disposeWithMe(this._shortcutService.registerShortcut(i))})}_init(){this._initCommands(),this._initCustomComponents(),this._initMenus(),this._initShortcuts()}};ue=wt([h.OnLifecycle(h.LifecycleStages.Rendered,ue),de(1,W.Inject(W.Injector)),de(2,W.Inject(Y.ComponentManager)),de(3,Y.IMenuService),de(4,h.ICommandService),de(5,Y.IShortcutService)],ue);var _t=Object.defineProperty,Ct=Object.getOwnPropertyDescriptor,It=(i,e,r,t)=>{for(var n=t>1?void 0:t?Ct(e,r):e,o=i.length-1,a;o>=0;o--)(a=i[o])&&(n=(t?a(e,r,n):a(n))||n);return t&&n&&_t(e,r,n),n},re=(i,e)=>(r,t)=>e(r,t,i);const yt=[v.InsertRowCommand.id,v.InsertColCommand.id,v.RemoveRowCommand.id,v.RemoveColCommand.id,v.DeleteRangeMoveLeftCommand.id,v.DeleteRangeMoveUpCommand.id,v.InsertRangeMoveDownCommand.id,v.InsertRangeMoveRightCommand.id,v.DeltaRowHeightCommand.id,v.SetRowHeightCommand.id,v.DeltaColumnWidthCommand.id,v.SetColWidthCommand.id,v.SetRowHiddenCommand.id,v.SetSpecificRowsVisibleCommand.id,v.SetSpecificColsVisibleCommand.id,v.SetColHiddenCommand.id,v.MoveRangeCommand.id],Mt=[v.SetRowVisibleMutation.id,v.SetRowHiddenMutation.id,v.SetColVisibleMutation.id,v.SetColHiddenMutation.id,v.SetWorksheetRowHeightMutation.id,v.SetWorksheetColWidthMutation.id];let Ce=class extends h.Disposable{constructor(i,e,r,t,n,o,a,s){super(),this._context=i,this._commandService=e,this._sheetInterceptorService=r,this._sheetDrawingService=t,this._drawingManagerService=n,this._selectionRenderService=o,this._univerInstanceService=a,this._sheetSkeletonManagerService=s,this._init()}_init(){this._sheetInterceptorListener(),this._commandListener(),this._sheetRefreshListener()}_sheetInterceptorListener(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:i=>{if(!yt.includes(i.id))return{redos:[],undos:[]};if(i.params==null)return{redos:[],undos:[]};const e=i.id;if(e===v.InsertRowCommand.id)return this._moveRowInterceptor(i.params,"insert");if(e===v.InsertColCommand.id)return this._moveColInterceptor(i.params,"insert");if(e===v.RemoveRowCommand.id)return this._moveRowInterceptor(i.params,"remove");if(e===v.RemoveColCommand.id)return this._moveColInterceptor(i.params,"remove");if(e===v.MoveRangeCommand.id)return this._moveRangeInterceptor(i.params);if(e===v.DeleteRangeMoveLeftCommand.id){const{range:r}=i.params;return this._getRangeMoveUndo(r,0)}else if(e===v.DeleteRangeMoveUpCommand.id){const{range:r}=i.params;return this._getRangeMoveUndo(r,1)}else if(e===v.InsertRangeMoveDownCommand.id){const{range:r}=i.params;return this._getRangeMoveUndo(r,2)}else if(e===v.InsertRangeMoveRightCommand.id){const{range:r}=i.params;return this._getRangeMoveUndo(r,3)}else if(e===v.SetRowHiddenCommand.id||e===v.SetSpecificRowsVisibleCommand.id){const r=i.params,{unitId:t,subUnitId:n,ranges:o}=r;return this._getDrawingUndoForRowVisible(t,n,o)}else if(e===v.SetSpecificColsVisibleCommand.id||e===v.SetColHiddenCommand.id){const r=i.params,{unitId:t,subUnitId:n,ranges:o}=r;return this._getDrawingUndoForColVisible(t,n,o)}else if(e===v.DeltaRowHeightCommand.id||e===v.SetRowHeightCommand.id||e===v.DeltaColumnWidthCommand.id||e===v.SetColWidthCommand.id){const r=i.params,{unitId:t,subUnitId:n,ranges:o}=r,a=e===v.DeltaRowHeightCommand.id||e===v.SetRowHeightCommand.id;return this._getDrawingUndoForRowAndColSize(t,n,o,a)}return{redos:[],undos:[]}}}))}_getRangeMoveUndo(i,e){const r=v.getSheetCommandTarget(this._univerInstanceService);if(r==null)return{redos:[],undos:[]};const t=r.unitId,n=r.subUnitId,o=[],a=[],s=this._sheetDrawingService.getDrawingData(t,n),l=[],m=[];if(Object.keys(s).forEach(u=>{const c=s[u],{updateDrawings:d,deleteDrawings:g}=this._getUpdateOrDeleteDrawings(i,e,c);l.push(...d),m.push(...g)}),l.length===0&&m.length===0)return{redos:[],undos:[]};if(l.length>0){const u=this._sheetDrawingService.getBatchUpdateOp(l),{undo:c,redo:d,objects:g}=u;o.push({id:p.SetDrawingApplyMutation.id,params:{unitId:t,subUnitId:n,op:d,objects:g,type:p.DrawingApplyType.UPDATE}}),a.push({id:p.SetDrawingApplyMutation.id,params:{unitId:t,subUnitId:n,op:c,objects:g,type:p.DrawingApplyType.UPDATE}})}if(m.length>0){const u=this._sheetDrawingService.getBatchRemoveOp(m),c=u.undo,d=u.redo,g=u.objects;o.push({id:p.SetDrawingApplyMutation.id,params:{unitId:t,subUnitId:n,op:d,objects:g,type:p.DrawingApplyType.REMOVE}}),a.push({id:p.SetDrawingApplyMutation.id,params:{unitId:t,subUnitId:n,op:c,objects:g,type:p.DrawingApplyType.INSERT}})}return o.push({id:V.id,params:[t]}),a.push({id:V.id,params:[t]}),{redos:o,undos:a}}_getUpdateOrDeleteDrawings(i,e,r){const t=[],n=[],{sheetTransform:o,anchorType:a=p.SheetDrawingAnchorType.Position,transform:s,unitId:l,subUnitId:m,drawingId:u}=r,{from:c,to:d}=o,{row:g,column:S}=c,{row:f,column:w}=d;if(o==null||s==null)return{updateDrawings:t,deleteDrawings:n};const{startRow:I,endRow:D,startColumn:y,endColumn:R}=i;let C=null,P=null;if(e===0&&g>=I&&f<=D)if(S>=y&&w<=R)n.push({unitId:l,subUnitId:m,drawingId:u});else{const _=this._shrinkCol(o,s,y,R,a);C=_==null?void 0:_.newSheetTransform,P=_==null?void 0:_.newTransform}else if(e===1&&S>=y&&w<=R)if(g>=I&&f<=D)n.push({unitId:l,subUnitId:m,drawingId:u});else{const _=this._shrinkRow(o,s,I,D,a);C=_==null?void 0:_.newSheetTransform,P=_==null?void 0:_.newTransform}else if(e===2){const _=this._expandRow(o,s,I,D,a);C=_==null?void 0:_.newSheetTransform,P=_==null?void 0:_.newTransform}else if(e===3){const _=this._expandCol(o,s,y,R,a);C=_==null?void 0:_.newSheetTransform,P=_==null?void 0:_.newTransform}if(C!=null&&P!=null){const _=H(C,this._selectionRenderService,this._sheetSkeletonManagerService);t.push({...r,sheetTransform:C,transform:_})}return{updateDrawings:t,deleteDrawings:n}}_remainDrawingSize(i,e,r){const t=B({...i},this._selectionRenderService);t!=null&&e.push({...r,sheetTransform:t})}_getDrawingUndoForColVisible(i,e,r){const t=this._drawingManagerService.getDrawingData(i,e),n=[],o=[];if(Object.keys(t).forEach(u=>{const c=t[u],{sheetTransform:d,transform:g,anchorType:S=p.SheetDrawingAnchorType.Position}=c;if(S===p.SheetDrawingAnchorType.None)this._remainDrawingSize(g,n,c);else{const{from:f,to:w}=d,{row:I,column:D}=f,{row:y,column:R}=w;for(let C=0;C<r.length;C++){const P=r[C],{startRow:_,endRow:U,startColumn:A,endColumn:T}=P;if(R<A)continue;if(S===p.SheetDrawingAnchorType.Position){let M=null,L=null;if(D>=A&&D<=T){const X=this._selectionRenderService.attachRangeWithCoord({startColumn:D,endColumn:T,startRow:f.row,endRow:w.row});if(X==null)return;L={...g,left:X.startX}}if(L!=null&&(M=B(L,this._selectionRenderService),M!=null&&L!=null)){n.push({...c,sheetTransform:M,transform:L});break}this._remainDrawingSize(g,n,c);continue}if(D>=A&&R<=T)continue;let b=null,E=null;if(D>=A&&D<=T){const M=this._selectionRenderService.attachRangeWithCoord({startColumn:D,endColumn:T,startRow:f.row,endRow:w.row});if(M==null)return;E={...g,left:(M==null?void 0:M.startX)||0,width:((g==null?void 0:g.width)||0)-M.endX+M.startX}}else if(R>=A&&R<=T){const M=this._selectionRenderService.attachRangeWithCoord({startColumn:A,endColumn:R,startRow:f.row,endRow:w.row});if(M==null)return;E={...g,left:M.startX-((g==null?void 0:g.width)||0)}}else{const M=this._selectionRenderService.attachRangeWithCoord({startColumn:A,endColumn:T,startRow:f.row,endRow:w.row});if(M==null)return;if(E={...g,width:((g==null?void 0:g.width)||0)-M.endX+M.startX},b=B(E,this._selectionRenderService),b!=null&&E!=null){o.push({...c,sheetTransform:b,transform:E});break}}if(E!=null&&(b=B(E,this._selectionRenderService)),E!=null&&b!=null){n.push({...c,sheetTransform:b,transform:E});break}else this._remainDrawingSize(g,n,c)}}}),n.length===0&&o.length===0)return{redos:[],undos:[]};const{redos:a,undos:s}=this._createUndoAndRedoMutation(i,e,n),l=[],m=[];if(o.length>0){const{redos:u,undos:c}=this._createUndoAndRedoMutation(i,e,o);l.push(...u),m.push(...c)}return{redos:a,undos:s,preRedos:l,preUndos:m}}_createUndoAndRedoMutation(i,e,r){const t=this._sheetDrawingService.getBatchUpdateOp(r),{undo:n,redo:o,objects:a}=t,s=[{id:p.SetDrawingApplyMutation.id,params:{unitId:i,subUnitId:e,op:o,objects:a,type:p.DrawingApplyType.UPDATE}},{id:V.id,params:[i]}],l=[{id:p.SetDrawingApplyMutation.id,params:{unitId:i,subUnitId:e,op:n,objects:a,type:p.DrawingApplyType.UPDATE}},{id:V.id,params:[i]}];return{redos:s,undos:l}}_getDrawingUndoForRowVisible(i,e,r){const t=this._drawingManagerService.getDrawingData(i,e),n=[],o=[];if(Object.keys(t).forEach(u=>{const c=t[u],{sheetTransform:d,transform:g,anchorType:S=p.SheetDrawingAnchorType.Position}=c;if(S===p.SheetDrawingAnchorType.None)this._remainDrawingSize(g,n,c);else{const{from:f,to:w}=d,{row:I,column:D}=f,{row:y,column:R}=w;for(let C=0;C<r.length;C++){const P=r[C],{startRow:_,endRow:U,startColumn:A,endColumn:T}=P;if(y<_)continue;if(S===p.SheetDrawingAnchorType.Position){let M=null,L=null;if(I>=_&&I<=U){const X=this._selectionRenderService.attachRangeWithCoord({startColumn:f.column,endColumn:w.column,startRow:I,endRow:U});if(X==null)return;L={...g,top:X.startY}}if(L!=null&&(M=B(L,this._selectionRenderService),M!=null&&L!=null)){n.push({...c,sheetTransform:M,transform:L});break}this._remainDrawingSize(g,n,c);continue}if(I>=_&&y<=U)continue;let b=null,E=null;if(I>=_&&I<=U){const M=this._selectionRenderService.attachRangeWithCoord({startColumn:f.column,endColumn:w.column,startRow:I,endRow:U});if(M==null)return;E={...g,top:(M==null?void 0:M.startY)||0,height:((g==null?void 0:g.height)||0)-M.endY+M.startY}}else if(y>=_&&y<=U){const M=this._selectionRenderService.attachRangeWithCoord({startColumn:f.column,endColumn:w.column,startRow:_,endRow:y});if(M==null)return;E={...g,top:M.startY-((g==null?void 0:g.height)||0)}}else{const M=this._selectionRenderService.attachRangeWithCoord({startColumn:f.column,endColumn:w.column,startRow:_,endRow:U});if(M==null)return;if(E={...g,height:((g==null?void 0:g.height)||0)-M.endY+M.startY},b=B(E,this._selectionRenderService),b!=null&&E!=null){o.push({...c,sheetTransform:b,transform:E});break}}if(E!=null&&(b=B(E,this._selectionRenderService)),E!=null&&b!=null){n.push({...c,sheetTransform:b,transform:E});break}else this._remainDrawingSize(g,n,c)}}}),n.length===0&&o.length===0)return{redos:[],undos:[]};const{redos:a,undos:s}=this._createUndoAndRedoMutation(i,e,n),l=[],m=[];if(o.length>0){const{redos:u,undos:c}=this._createUndoAndRedoMutation(i,e,o);l.push(...u),m.push(...c)}return{redos:a,undos:s,preRedos:l,preUndos:m}}_getDrawingUndoForRowAndColSize(i,e,r,t){const n=this._drawingManagerService.getDrawingData(i,e),o=[];return Object.keys(n).forEach(a=>{const s=n[a],{sheetTransform:l,transform:m,anchorType:u=p.SheetDrawingAnchorType.Position}=s;if(u===p.SheetDrawingAnchorType.None)this._remainDrawingSize(m,o,s);else{const{from:c,to:d}=l,{row:g,column:S}=c,{row:f,column:w}=d;for(let I=0;I<r.length;I++){const D=r[I],{startRow:y,endRow:R,startColumn:C,endColumn:P}=D;if(f<y||w<C)continue;if(u===p.SheetDrawingAnchorType.Position&&(g<=y&&f>=R||S<=C&&w>=P)){this._remainDrawingSize(m,o,s);continue}const _=H({...l},this._selectionRenderService,this._sheetSkeletonManagerService);if(_!=null){o.push({...s,transform:_});break}}}}),o.length===0?{redos:[],undos:[]}:this._createUndoAndRedoMutation(i,e,o)}_getUnitIdAndSubUnitId(i,e){let r,t;if(e==="insert")r=i.unitId,t=i.subUnitId;else{const n=v.getSheetCommandTarget(this._univerInstanceService);if(n==null)return;r=n.unitId,t=n.subUnitId}return{unitId:r,subUnitId:t}}_moveRowInterceptor(i,e){const r=this._getUnitIdAndSubUnitId(i,e);if(r==null)return{redos:[],undos:[]};const{unitId:t,subUnitId:n}=r,{range:o}=i,a=o.startRow,s=o.endRow,l=[],m=[],u=this._sheetDrawingService.getDrawingData(t,n),c=[],d=[];if(Object.keys(u).forEach(g=>{const S=u[g],{sheetTransform:f,transform:w,anchorType:I=p.SheetDrawingAnchorType.Position}=S;if(f==null||w==null)return;let D,y;if(e==="insert"){const C=this._expandRow(f,w,a,s,I);D=C==null?void 0:C.newSheetTransform,y=C==null?void 0:C.newTransform}else{const{from:C,to:P}=f,{row:_}=C,{row:U}=P;if(I===p.SheetDrawingAnchorType.Both&&_>=a&&U<=s)d.push({unitId:t,subUnitId:n,drawingId:g});else{const A=this._shrinkRow(f,w,a,s,I);D=A==null?void 0:A.newSheetTransform,y=A==null?void 0:A.newTransform}}if(!D||!y)return;const R={unitId:t,subUnitId:n,drawingId:g,transform:y,sheetTransform:D};c.push(R)}),c.length===0&&d.length===0)return{redos:[],undos:[]};if(c.length>0){const g=this._sheetDrawingService.getBatchUpdateOp(c),{undo:S,redo:f,objects:w}=g;l.push({id:p.SetDrawingApplyMutation.id,params:{unitId:t,subUnitId:n,op:f,objects:w,type:p.DrawingApplyType.UPDATE}}),m.push({id:p.SetDrawingApplyMutation.id,params:{unitId:t,subUnitId:n,op:S,objects:w,type:p.DrawingApplyType.UPDATE}})}if(d.length>0){const g=this._sheetDrawingService.getBatchRemoveOp(d),S=g.undo,f=g.redo,w=g.objects;l.push({id:p.SetDrawingApplyMutation.id,params:{unitId:t,subUnitId:n,op:f,objects:w,type:p.DrawingApplyType.REMOVE}}),m.push({id:p.SetDrawingApplyMutation.id,params:{unitId:t,subUnitId:n,op:S,objects:w,type:p.DrawingApplyType.INSERT}})}return l.push({id:V.id,params:[t]}),m.push({id:V.id,params:[t]}),{redos:l,undos:m}}_moveRangeInterceptor(i){const{fromRange:e,toRange:r}=i,t=v.getSheetCommandTarget(this._univerInstanceService);if(!t)return{redos:[],undos:[]};const{unitId:n,subUnitId:o}=t,a=this._sheetDrawingService.getDrawingData(n,o),s=[],l=this._selectionRenderService.attachRangeWithCoord(e),m=this._selectionRenderService.attachRangeWithCoord(r);if(!l||!m)return{redos:[],undos:[]};Object.keys(a).forEach(d=>{const g=a[d],{sheetTransform:S,transform:f,anchorType:w=p.SheetDrawingAnchorType.Position}=g;if(!S||!f||w===p.SheetDrawingAnchorType.None)return;const{left:I=0,top:D=0,width:y=0,height:R=0}=f,{drawingStartX:C,drawingEndX:P,drawingStartY:_,drawingEndY:U}={drawingStartX:I,drawingEndX:I+y,drawingStartY:D,drawingEndY:D+R};if(!(l.startX<=C&&P<=l.endX&&l.startY<=U&&_<=l.endY))return;const{to:T,from:b}=S,E=r.startRow-e.startRow,M=r.startColumn-e.startColumn;let L,X;if(w===p.SheetDrawingAnchorType.Both){const z=this._selectionRenderService.attachRangeWithCoord({startRow:T.row,endRow:b.row,startColumn:T.column,endColumn:b.column}),q=this._selectionRenderService.attachRangeWithCoord({startRow:T.row+E,endRow:b.row+E,startColumn:T.column+M,endColumn:b.column+M});if(!q||!z)return;const ge=q.endX-q.startX-(z.endX-z.startX),k=q.endY-q.startY-(z.endY-z.startY);L={to:{...T,row:T.row+E,column:T.column+M,columnOffset:T.columnOffset+ge},from:{...b,row:b.row+E,column:b.column+M,columnOffset:T.columnOffset+ge,rowOffset:T.rowOffset+k}},X=H(L,this._selectionRenderService,this._sheetSkeletonManagerService)}else{const z=m.startX-l.startX,q=m.startY-l.startY;X={...f,left:I+z,top:D+q},L=B(X,this._selectionRenderService)}if(!L||!X)return;const Le={unitId:n,subUnitId:o,drawingId:d,transform:X,sheetTransform:L};s.push(Le)});const u=[],c=[];if(s.length>0){const d=this._sheetDrawingService.getBatchUpdateOp(s),{undo:g,redo:S,objects:f}=d;u.push({id:p.SetDrawingApplyMutation.id,params:{unitId:n,subUnitId:o,op:S,objects:f,type:p.DrawingApplyType.UPDATE}}),c.push({id:p.SetDrawingApplyMutation.id,params:{unitId:n,subUnitId:o,op:g,objects:f,type:p.DrawingApplyType.UPDATE}})}return{redos:u,undos:c}}_moveColInterceptor(i,e){const r=this._getUnitIdAndSubUnitId(i,e);if(r==null)return{redos:[],undos:[]};const{unitId:t,subUnitId:n}=r,{range:o}=i,a=o.startColumn,s=o.endColumn,l=[],m=[],u=this._sheetDrawingService.getDrawingData(t,n),c=[],d=[];if(Object.keys(u).forEach(g=>{const S=u[g],{sheetTransform:f,transform:w,anchorType:I=p.SheetDrawingAnchorType.Position}=S;if(f==null||w==null)return;let D,y;if(e==="insert"){const C=this._expandCol(f,w,a,s,I);D=C==null?void 0:C.newSheetTransform,y=C==null?void 0:C.newTransform}else{const{from:C,to:P}=f,{column:_}=C,{column:U}=P;if(_>=a&&U<=s&&I===p.SheetDrawingAnchorType.Both)d.push({unitId:t,subUnitId:n,drawingId:g});else{const T=this._shrinkCol(f,w,a,s,I);D=T==null?void 0:T.newSheetTransform,y=T==null?void 0:T.newTransform}}if(!D||!y)return;const R={unitId:t,subUnitId:n,drawingId:g,transform:y,sheetTransform:D};c.push(R)}),c.length===0&&d.length===0)return{redos:[],undos:[]};if(c.length>0){const g=this._sheetDrawingService.getBatchUpdateOp(c),{undo:S,redo:f,objects:w}=g;l.push({id:p.SetDrawingApplyMutation.id,params:{unitId:t,subUnitId:n,op:f,objects:w,type:p.DrawingApplyType.UPDATE}}),m.push({id:p.SetDrawingApplyMutation.id,params:{unitId:t,subUnitId:n,op:S,objects:w,type:p.DrawingApplyType.UPDATE}})}if(d.length>0){const g=this._sheetDrawingService.getBatchRemoveOp(d),S=g.undo,f=g.redo,w=g.objects;l.push({id:p.SetDrawingApplyMutation.id,params:{unitId:t,subUnitId:n,op:f,objects:w,type:p.DrawingApplyType.REMOVE}}),m.push({id:p.SetDrawingApplyMutation.id,params:{unitId:t,subUnitId:n,op:S,objects:w,type:p.DrawingApplyType.INSERT}})}return l.push({id:V.id,params:[t]}),m.push({id:V.id,params:[t]}),{redos:l,undos:m}}_expandCol(i,e,r,t,n=p.SheetDrawingAnchorType.Position){const o=t-r+1,{from:a,to:s}=i,{column:l}=a,{column:m}=s;if(n===p.SheetDrawingAnchorType.None)return{newSheetTransform:B({...e},this._selectionRenderService),newTransform:e};let u=null,c=null;if(l>=r){const d=this._selectionRenderService.attachRangeWithCoord({startColumn:r,endColumn:t,startRow:a.row,endRow:s.row});if(d==null)return;c={...e,left:(e.left||0)+d.endX-d.startX},u=B(c,this._selectionRenderService)}else if(m>=t)if(n===p.SheetDrawingAnchorType.Both)u={from:{...a},to:{...s,column:m+o}},c=H(u,this._selectionRenderService,this._sheetSkeletonManagerService);else return{newSheetTransform:B({...e},this._selectionRenderService),newTransform:e};return u!=null&&c!=null?{newSheetTransform:u,newTransform:c}:null}_shrinkCol(i,e,r,t,n=p.SheetDrawingAnchorType.Position){const o=t-r+1,{from:a,to:s}=i,{column:l}=a,{column:m}=s;if(n===p.SheetDrawingAnchorType.None)return{newSheetTransform:B({...e},this._selectionRenderService),newTransform:e};let u=null,c=null;if(l>t){const d=this._selectionRenderService.attachRangeWithCoord({startColumn:r,endColumn:t,startRow:a.row,endRow:s.row});if(d==null)return;c={...e,left:(e.left||0)-(d.endX-d.startX)},u=B(c,this._selectionRenderService)}else if(l>=r&&m<=t){const d=this._selectionRenderService.attachRangeWithCoord({startColumn:r,endColumn:t,startRow:0,endRow:0});u={from:{...a,columnOffset:0},to:{...s,columnOffset:s.columnOffset-a.columnOffset}},c={...e,left:d==null?void 0:d.startX}}else if(l<r&&m>t)if(n===p.SheetDrawingAnchorType.Both)u={from:{...a},to:{...s,column:m-o}},c=H(u,this._selectionRenderService,this._sheetSkeletonManagerService);else return{newSheetTransform:B({...e},this._selectionRenderService),newTransform:e};else if(l>=r&&l<=t){if(l===r)c={...e,left:(e.left||0)-i.from.columnOffset};else{const d=this._selectionRenderService.attachRangeWithCoord({startColumn:r,endColumn:l-1,startRow:a.row,endRow:s.row});if(d==null)return;c={...e,left:(e.left||0)-d.endX+d.startX-i.from.columnOffset}}u=B(c,this._selectionRenderService)}else if(m>=r&&m<=t&&n===p.SheetDrawingAnchorType.Both){const d=this._selectionRenderService.attachRangeWithCoord({startColumn:r-1,endColumn:r-1,startRow:a.row,endRow:s.row});if(d==null)return;u={from:{...a},to:{...s,column:r-1,columnOffset:d.endX-d.startX}},c=H(u,this._selectionRenderService,this._sheetSkeletonManagerService)}return u!=null&&c!=null?{newSheetTransform:u,newTransform:c}:null}_expandRow(i,e,r,t,n=p.SheetDrawingAnchorType.Position){const o=t-r+1,{from:a,to:s}=i,{row:l}=a,{row:m}=s;if(n===p.SheetDrawingAnchorType.None)return{newSheetTransform:B({...e},this._selectionRenderService),newTransform:e};let u=null,c=null;if(l>=r){const d=this._selectionRenderService.attachRangeWithCoord({startRow:r,endRow:t,startColumn:a.column,endColumn:s.column});if(d==null)return;c={...e,top:(e.top||0)+d.endY-d.startY},u=B(c,this._selectionRenderService)}else if(m>=t)if(n===p.SheetDrawingAnchorType.Both)u={from:{...a},to:{...s,row:m+o}},c=H(u,this._selectionRenderService,this._sheetSkeletonManagerService);else return{newSheetTransform:B({...e},this._selectionRenderService),newTransform:e};return u!=null&&c!=null?{newSheetTransform:u,newTransform:c}:null}_shrinkRow(i,e,r,t,n=p.SheetDrawingAnchorType.Position){const o=t-r+1,{from:a,to:s}=i,{row:l}=a,{row:m}=s;if(n===p.SheetDrawingAnchorType.None)return{newSheetTransform:B({...e},this._selectionRenderService),newTransform:e};let u=null,c=null;if(l>t)u={from:{...a,row:l-o},to:{...s,row:m-o}},c=H(u,this._selectionRenderService,this._sheetSkeletonManagerService);else if(l>=r&&m<=t){const d=this._selectionRenderService.attachRangeWithCoord({startColumn:0,endColumn:0,startRow:r,endRow:t});u={from:{...a,rowOffset:0},to:{...s,rowOffset:s.rowOffset-a.rowOffset}},c={...e,top:d==null?void 0:d.startY}}else if(l<r&&m>t)if(n===p.SheetDrawingAnchorType.Both)u={from:{...a},to:{...s,row:m-o}},c=H(u,this._selectionRenderService,this._sheetSkeletonManagerService);else return{newSheetTransform:B({...e},this._selectionRenderService),newTransform:e};else if(l>=r&&l<=t){if(l===r)c={...e,top:(e.top||0)-i.from.rowOffset};else{const d=this._selectionRenderService.attachRangeWithCoord({startRow:r,endRow:l-1,startColumn:a.column,endColumn:s.column});if(d==null)return;c={...e,top:(e.top||0)-d.endY+d.startY-i.from.rowOffset}}u=B(c,this._selectionRenderService)}else if(m>=r&&m<=t&&n===p.SheetDrawingAnchorType.Both){const d=this._selectionRenderService.attachRangeWithCoord({startColumn:a.column,endColumn:a.column,startRow:r-1,endRow:r-1});if(d==null)return;u={from:{...a},to:{...s,row:r-1,rowOffset:d.endY-d.startY}},c=H(u,this._selectionRenderService,this._sheetSkeletonManagerService)}return u!=null&&c!=null?{newSheetTransform:u,newTransform:c}:null}_commandListener(){this.disposeWithMe(this._commandService.onCommandExecuted(i=>{i.id===v.SetWorksheetActiveOperation.id&&setTimeout(()=>{const e=i.params,{unitId:r,subUnitId:t}=e,n=this._drawingManagerService.drawingManagerData,o=[],a=[];Object.keys(n).forEach(s=>{const l=n[s];Object.keys(l).forEach(m=>{const u=l[m].data;u!=null&&Object.keys(u).forEach(c=>{if(s===r&&m===t){const d=u[c];d.transform=H(d.sheetTransform,this._selectionRenderService,this._sheetSkeletonManagerService),o.push(u[c])}else a.push(u[c])})})}),this._drawingManagerService.removeNotification(a),this._drawingManagerService.addNotification(o)},0)}))}_sheetRefreshListener(){this.disposeWithMe(this._commandService.onCommandExecuted(i=>{Mt.includes(i.id)&&requestIdleCallback(()=>{const e=i.params,{unitId:r,subUnitId:t,ranges:n}=e;this._refreshDrawingTransform(r,t,n)})}))}_refreshDrawingTransform(i,e,r){const t=this._drawingManagerService.getDrawingData(i,e),n=[];Object.keys(t).forEach(o=>{const a=t[o],{sheetTransform:s,anchorType:l=p.SheetDrawingAnchorType.Position}=a;if(l===p.SheetDrawingAnchorType.None)return!0;const{from:m,to:u}=s,{row:c,column:d}=m,{row:g,column:S}=u;for(let f=0;f<r.length;f++){const w=r[f],{startRow:I,endRow:D,startColumn:y,endColumn:R}=w;if(h.Rectangle.intersects({startRow:I,endRow:D,startColumn:y,endColumn:R},{startRow:c,endRow:g,startColumn:d,endColumn:S})||c>D||d>R){n.push({...a,transform:H(s,this._selectionRenderService,this._sheetSkeletonManagerService)});break}}}),n.length!==0&&(this._drawingManagerService.refreshTransform(n),this._commandService.syncExecuteCommand(V.id,[i]))}};Ce=It([h.OnLifecycle(h.LifecycleStages.Rendered,Ce),re(1,h.ICommandService),re(2,W.Inject(v.SheetInterceptorService)),re(3,p.ISheetDrawingService),re(4,N.IDrawingManagerService),re(5,G.ISelectionRenderService),re(6,h.IUniverInstanceService),re(7,W.Inject(G.SheetSkeletonManagerService))],Ce);var Dt=Object.defineProperty,Rt=Object.getOwnPropertyDescriptor,Tt=(i,e,r,t)=>{for(var n=t>1?void 0:t?Rt(e,r):e,o=i.length-1,a;o>=0;o--)(a=i[o])&&(n=(t?a(e,r,n):a(n))||n);return t&&n&&Dt(e,r,n),n},ie=(i,e)=>(r,t)=>e(r,t,i);function Ot(i,e,r,t){const{scaleX:n,scaleY:o}=e.getAncestorScale(),a=e.getViewport($.SHEET_VIEWPORT_KEY.VIEW_MAIN),s={left:!0,top:!0};if(!a)return{...i,absolute:s};const{left:l,right:m,top:u,bottom:c}=i,d=t.getFreeze(),{startColumn:g,startRow:S,xSplit:f,ySplit:w}=d,I=r.getNoMergeCellPositionByIndexWithNoHeader(S-w,g-f),D=r.getNoMergeCellPositionByIndexWithNoHeader(S,g),{rowHeaderWidth:y,columnHeaderHeight:R}=r,C=D.startX-I.startX,P=D.startY-I.startY,{top:_,left:U,viewportScrollX:A,viewportScrollY:T}=a;let b,E;l<U?(s.left=!0,b=(C+y+(l-U))*n,E=Math.max(Math.min((C+y+(m-U))*n,(C+y)*n),(m-A)*n)):(s.left=!1,b=Math.max((l-A)*n,(C+y)*n),E=Math.max((m-A)*n,(C+y)*n));let M,L;return u<_?(s.top=!0,M=(P+R+(u-_))*o,L=Math.max(Math.min((P+R+(m-_))*o,(P+R)*o),(c-T)*o)):(s.top=!1,M=Math.max((u-T)*o,(P+R)*o),L=Math.max((c-T)*o,(P+R)*o)),{left:b,right:E,top:M,bottom:L,absolute:s}}const Ue=(i,e,r,t)=>{const{scene:n}=e,{left:o,top:a,width:s,height:l,angle:m}=i,u={left:o,right:o+s,top:a,bottom:a+l},c=Ot(u,n,r,t);return{startX:c.left,endX:c.right,startY:c.top,endY:c.bottom,rotate:m,width:s,height:l,absolute:c.absolute}};O.SheetCanvasFloatDomManagerService=class extends h.Disposable{constructor(r,t,n,o,a,s,l){super();J(this,"_domLayerMap",new Map);J(this,"_domLayerInfoMap",new Map);J(this,"_transformChange$",new F.Subject);J(this,"transformChange$",this._transformChange$.asObservable());J(this,"_remove$",new F.Subject);J(this,"remove$",this._remove$.asObservable());this._renderManagerService=r,this._univerInstanceService=t,this._commandService=n,this._drawingManagerService=o,this._selectionRenderService=a,this._canvasFloatDomService=s,this._sheetDrawingService=l,this._drawingAddListener(),this._scrollUpdateListener(),this._featureUpdateListener(),this._deleteListener()}_ensureMap(r,t){let n=this._domLayerMap.get(r);n||(n=new Map,this._domLayerMap.set(r,n));let o=n.get(t);return o||(o=new Map,n.set(t,o)),o}_getSceneAndTransformerByDrawingSearch(r){if(r==null)return;const t=this._renderManagerService.getRenderById(r),n=t==null?void 0:t.scene;if(t==null||n==null)return null;const o=n.getTransformerByCreate(),a=t.engine.getCanvasElement();return{scene:n,transformer:o,renderObject:t,canvas:a}}_drawingAddListener(){this.disposeWithMe(this._drawingManagerService.add$.subscribe(r=>{r.forEach(t=>{var q,ge;const{unitId:n,subUnitId:o,drawingId:a}=t,s=v.getSheetCommandTarget(this._univerInstanceService,{unitId:n,subUnitId:o}),l=this._drawingManagerService.getDrawingByParam(t),m=(q=this._renderManagerService.getRenderById(n))==null?void 0:q.with(G.SheetSkeletonManagerService).getUnitSkeleton(n,o);if(l==null||s==null||m==null)return;const{transform:u,drawingType:c}=l;if(c!==h.DrawingTypeEnum.DRAWING_DOM)return;const d=this._getSceneAndTransformerByDrawingSearch(n);if(d==null)return;const{scene:g,canvas:S}=d;if(u==null)return!0;const{left:f,top:w,width:I,height:D,angle:y,flipX:R,flipY:C,skewX:P,skewY:_}=u,U=N.getDrawingShapeKeyByDrawingSearch({unitId:n,subUnitId:o,drawingId:a}),A=g.getObject(U);if(A!=null){A.transformByState({left:f,top:w,width:I,height:D,angle:y,flipX:R,flipY:C,skewX:P,skewY:_});return}const T={left:f,top:w,width:I,height:D,zIndex:this._drawingManagerService.getDrawingOrder(n,o).length-1},b=new $.Rect(U,T);g.addObject(b,$.DRAWING_OBJECT_LAYER_INDEX).attachTransformerTo(b);const E=this._ensureMap(n,o),M=new h.DisposableCollection,L=Ue(b,d.renderObject,m.skeleton,s.worksheet),X=new F.BehaviorSubject(L),Le={dispose:M,rect:b,position$:X,unitId:n,subUnitId:o};this._canvasFloatDomService.addFloatDom({position$:X,id:a,componentKey:l.componentKey,onPointerDown:k=>{S.dispatchEvent(new PointerEvent(k.type,k))},onPointerMove:k=>{S.dispatchEvent(new PointerEvent(k.type,k))},onPointerUp:k=>{S.dispatchEvent(new PointerEvent(k.type,k))},onWheel:k=>{S.dispatchEvent(new WheelEvent(k.type,k))},props:(ge=E.get(a))==null?void 0:ge.props});const z=b.onTransformChange$.subscribeEvent(()=>{const k=Ue(b,d.renderObject,m.skeleton,s.worksheet);X.next(k)});M.add(()=>{this._canvasFloatDomService.removeFloatDom(a)}),z&&M.add(z),this._domLayerInfoMap.set(a,Le)})}))}_scrollUpdateListener(){this.disposeWithMe(this._commandService.onCommandExecuted(r=>{var n,o;const t=(a,s)=>{var g;const l=this._getSceneAndTransformerByDrawingSearch(a),m=this._ensureMap(a,s),u=Array.from(m.keys()),c=v.getSheetCommandTarget(this._univerInstanceService,{unitId:a,subUnitId:s}),d=(g=this._renderManagerService.getRenderById(a))==null?void 0:g.with(G.SheetSkeletonManagerService).getUnitSkeleton(a,s);!l||!c||!d||u.forEach(S=>{const f=this._domLayerInfoMap.get(S);if(f){const w=Ue(f.rect,l.renderObject,d.skeleton,c.worksheet);f.position$.next(w)}})};if(r.id===G.SetScrollOperation.id){const a=r.params,{unitId:s,sheetId:l}=a;t(s,l)}else if(r.id===G.SetZoomRatioOperation.id){const a=r.params,{unitId:s}=a;Array.from((o=(n=this._domLayerMap.get(s))==null?void 0:n.keys())!=null?o:[]).forEach(m=>{t(s,m)})}else if(r.id===v.SetFrozenMutation.id){const{unitId:a,subUnitId:s}=r.params;t(a,s)}}))}_getPosition(r){const{startX:t,endX:n,startY:o,endY:a}=r,s=this._selectionRenderService.getSelectionCellByPosition(t,o);if(s==null)return;const l={column:s.actualColumn,columnOffset:t-s.startX,row:s.actualRow,rowOffset:o-s.startY},m=this._selectionRenderService.getSelectionCellByPosition(n,a);if(m==null)return;const u={column:m.actualColumn,columnOffset:n-m.startX,row:m.actualRow,rowOffset:a-m.startY};return{from:l,to:u}}_featureUpdateListener(){this.disposeWithMe(this._drawingManagerService.update$.subscribe(r=>{r.forEach(t=>{const n=this._drawingManagerService.getDrawingByParam(t);if(!n||n.drawingType!==h.DrawingTypeEnum.DRAWING_DOM)return;const o={...n.transform};this._transformChange$.next({id:t.drawingId,value:o})})}))}_deleteListener(){this.disposeWithMe(this._drawingManagerService.remove$.subscribe(r=>{r.forEach(t=>{this._removeDom(t.drawingId)})}))}addFloatDomToPosition(r){const t=v.getSheetCommandTarget(this._univerInstanceService,{unitId:r.unitId,subUnitId:r.subUnitId});if(!t)throw new Error("cannot find current target!");const{unitId:n,subUnitId:o}=t,{initPosition:a,componentKey:s}=r,l=h.Tools.generateRandomId(),m=this._getPosition(a);if(m==null)return;this._ensureMap(n,o).set(l,r);const c={unitId:n,subUnitId:o,drawingId:l,drawingType:h.DrawingTypeEnum.DRAWING_DOM,componentKey:s,sheetTransform:m,transform:{left:a.startX,top:a.startY,width:a.endX-a.startX,height:a.endY-a.startY}};return this._commandService.executeCommand(we.id,{unitId:n,drawings:[c]}),{id:l,dispose:()=>{this._removeDom(l,!0)}}}_removeDom(r,t=!1){const n=this._domLayerInfoMap.get(r);if(!n)return;const{unitId:o,subUnitId:a}=n;this._domLayerInfoMap.delete(r),n.dispose.dispose();const s=this._getSceneAndTransformerByDrawingSearch(o);if(s&&s.scene.removeObject(n.rect),t){this._ensureMap(o,a).delete(r);const m=this._drawingManagerService.getDrawingByParam({unitId:o,subUnitId:a,drawingId:r});if(!m)return;const u=this._sheetDrawingService.getBatchRemoveOp([m]),{redo:c,objects:d}=u;this._commandService.syncExecuteCommand(p.SetDrawingApplyMutation.id,{unitId:o,subUnitId:a,op:c,objects:d,type:p.DrawingApplyType.REMOVE})}}},O.SheetCanvasFloatDomManagerService=Tt([ie(0,W.Inject($.IRenderManagerService)),ie(1,h.IUniverInstanceService),ie(2,W.Inject(h.ICommandService)),ie(3,N.IDrawingManagerService),ie(4,G.ISelectionRenderService),ie(5,W.Inject(Y.CanvasFloatDomService)),ie(6,p.ISheetDrawingService)],O.SheetCanvasFloatDomManagerService);var Et=Object.defineProperty,bt=Object.getOwnPropertyDescriptor,Pt=(i,e,r,t)=>{for(var n=t>1?void 0:t?bt(e,r):e,o=i.length-1,a;o>=0;o--)(a=i[o])&&(n=(t?a(e,r,n):a(n))||n);return t&&n&&Et(e,r,n),n},Ie=(i,e)=>(r,t)=>e(r,t,i);let ye=class extends h.Disposable{constructor(i,e,r,t){super(),this._sheetPrintInterceptorService=i,this._drawingRenderService=e,this._drawingManagerService=r,this._renderManagerService=t,this._initPrinting()}_initPrinting(){this.disposeWithMe(this._sheetPrintInterceptorService.interceptor.intercept(this._sheetPrintInterceptorService.interceptor.getInterceptPoints().PRINTING_COMPONENT_COLLECT,{handler:(i,e,r)=>{const{unitId:t,scene:n,subUnitId:o}=e,a=this._drawingManagerService.getDrawingDataForUnit(t),s=a==null?void 0:a[o];return s&&s.order.forEach(l=>{this._drawingRenderService.renderDrawing(s.data[l],n)}),r()}})),this.disposeWithMe(this._sheetPrintInterceptorService.interceptor.intercept(this._sheetPrintInterceptorService.interceptor.getInterceptPoints().PRINTING_RANGE,{handler:(i,e,r)=>{const{unitId:t,subUnitId:n}=e,o=this._renderManagerService.getRenderById(t);if(!o)return r(i);const a=o.with(G.SheetSkeletonManagerService).getUnitSkeleton(t,n);if(!a)return r(i);const s=this._drawingManagerService.getDrawingDataForUnit(t),l=s==null?void 0:s[e.subUnitId];if(!l)return r(i);const{scaleX:m,scaleY:u}=o.scene,c=i?{...i}:{startColumn:0,endColumn:0,endRow:0,startRow:0},d=l.order.map(g=>l.data[g]).filter(g=>g.drawingType!==N.DrawingTypeEnum.DRAWING_DOM);return d.length?(d.forEach(g=>{if(!g.groupId&&g.transform&&h.Tools.isDefine(g.transform.left)&&h.Tools.isDefine(g.transform.top)&&h.Tools.isDefine(g.transform.width)&&h.Tools.isDefine(g.transform.height)){const S=a.skeleton.getCellPositionByOffset(g.transform.left,g.transform.top,m,u,{x:0,y:0}),f=a.skeleton.getCellPositionByOffset(g.transform.left+g.transform.width,g.transform.top+g.transform.height,m,u,{x:0,y:0});S.column<c.startColumn&&(c.startColumn=S.column),S.row<c.startRow&&(c.startRow=S.row),c.endRow<f.row&&(c.endRow=f.row),c.endColumn<f.column&&(c.endColumn=f.column)}}),r(c)):r(i)}}))}};ye=Pt([h.OnLifecycle(h.LifecycleStages.Rendered,ye),Ie(0,W.Inject(G.SheetPrintInterceptorService)),Ie(1,W.Inject(te.DrawingRenderService)),Ie(2,N.IDrawingManagerService),Ie(3,$.IRenderManagerService)],ye);var At=Object.defineProperty,Ut=Object.getOwnPropertyDescriptor,Nt=(i,e,r,t)=>{for(var n=t>1?void 0:t?Ut(e,r):e,o=i.length-1,a;o>=0;o--)(a=i[o])&&(n=(t?a(e,r,n):a(n))||n);return t&&n&&At(e,r,n),n},me=(i,e)=>(r,t)=>e(r,t,i);let Me=class extends h.Disposable{constructor(i,e,r,t,n){super(),this._drawingManagerService=i,this._renderManagerService=e,this._permissionService=r,this._univerInstanceService=t,this._userManagerService=n,this._initDrawingVisible(),this._initDrawingEditable(),this._initViewPermissionChange(),this._initEditPermissionChange()}_initDrawingVisible(){const i=this._univerInstanceService.getCurrentTypeOfUnit$(h.UniverInstanceType.UNIVER_SHEET);this.disposeWithMe(F.combineLatest([i,this._userManagerService.currentUser$]).subscribe(([e,r])=>{if(!e){this._drawingManagerService.setDrawingVisible(!1);return}e.activeSheet$.subscribe(t=>{if(!t){this._drawingManagerService.setDrawingVisible(!1);return}const n=e.getUnitId(),o=t.getSheetId();if(this._permissionService.composePermission([new v.WorkbookViewPermission(n).id,new v.WorksheetViewPermission(n,o).id]).every(s=>s.value))this._drawingManagerService.setDrawingVisible(!0);else{this._drawingManagerService.setDrawingVisible(!1);const s=e.getUnitId(),l=t.getSheetId(),m=this._drawingManagerService.getDrawingData(s,l),u=Object.values(m),c=this._renderManagerService.getRenderById(s),d=c==null?void 0:c.scene;if(d==null)return;d.getAllObjects().forEach(S=>{S.classType===$.RENDER_CLASS_TYPE.IMAGE&&u.some(f=>S.oKey.includes(f.drawingId))&&d.removeObject(S)})}})}))}_initDrawingEditable(){const i=this._univerInstanceService.getCurrentTypeOfUnit$(h.UniverInstanceType.UNIVER_SHEET);this.disposeWithMe(F.combineLatest([i,this._userManagerService.currentUser$]).subscribe(([e,r])=>{if(!e){this._drawingManagerService.setDrawingEditable(!1);return}e.activeSheet$.subscribe(t=>{if(!t){this._drawingManagerService.setDrawingEditable(!1);return}const n=e.getUnitId(),o=t.getSheetId();if(this._permissionService.composePermission([new v.WorkbookEditablePermission(n).id,new v.WorksheetEditPermission(n,o).id]).every(s=>s.value))this._drawingManagerService.setDrawingEditable(!0);else{this._drawingManagerService.setDrawingEditable(!1);const s=e.getUnitId(),l=t.getSheetId(),m=this._drawingManagerService.getDrawingData(s,l),u=Object.values(m),c=this._renderManagerService.getRenderById(s),d=c==null?void 0:c.scene;if(d==null)return;d.getAllObjects().forEach(S=>{S.classType===$.RENDER_CLASS_TYPE.IMAGE&&u.some(f=>S.oKey.includes(f.drawingId))&&d.detachTransformerFrom(S)})}})}))}_initViewPermissionChange(){const i=this._univerInstanceService.getCurrentTypeOfUnit$(h.UniverInstanceType.UNIVER_SHEET);this.disposeWithMe(F.combineLatest([i,this._userManagerService.currentUser$]).subscribe(([e,r])=>{e&&e.activeSheet$.subscribe(t=>{var c;if(!t)return;const n=e.getUnitId(),o=t.getSheetId();let a=!0;const s=this._renderManagerService.getRenderById(n),l=s==null?void 0:s.scene;if(l==null)return;const m=l.getTransformerByCreate(),u=this._permissionService.composePermission$([new v.WorkbookViewPermission(n).id,new v.WorksheetViewPermission(n,o).id]).pipe(F.map(d=>d.every(g=>g.value)));u==null||u.pipe(F.filter(d=>d!==a),F.distinctUntilChanged()).subscribe({next:d=>{a=d,this._drawingManagerService.setDrawingVisible(d);const g=l.getAllObjects(),S=this._drawingManagerService.getDrawingData(n,o),f=Object.values(S);d?this._drawingManagerService.addNotification(f):(g.forEach(w=>{w.classType===$.RENDER_CLASS_TYPE.IMAGE&&f.some(I=>w.oKey.includes(I.drawingId))&&l.removeObject(w)}),m.clearSelectedObjects())}}),(c=this._permissionService.getPermissionPoint$(new v.WorksheetViewPermission(n,o).id))==null||c.pipe(F.filter(d=>d.value!==a),F.distinctUntilChanged()).subscribe({complete:()=>{a=!0,this._drawingManagerService.setDrawingVisible(!0);const d=this._drawingManagerService.getDrawingData(n,o),g=Object.values(d);this._drawingManagerService.addNotification(g)}})})}))}_initEditPermissionChange(){const i=this._univerInstanceService.getCurrentTypeOfUnit$(h.UniverInstanceType.UNIVER_SHEET);this.disposeWithMe(F.combineLatest([i,this._userManagerService.currentUser$]).subscribe(([e,r])=>{e&&e.activeSheet$.subscribe(t=>{var c;if(!t)return;const n=e.getUnitId(),o=t.getSheetId();let a=!0;const s=this._renderManagerService.getRenderById(n),l=s==null?void 0:s.scene;if(l==null)return;const m=l.getTransformerByCreate(),u=this._permissionService.composePermission$([new v.WorkbookEditablePermission(n).id,new v.WorksheetEditPermission(n,o).id]).pipe(F.map(d=>d.every(g=>g.value)));u==null||u.pipe(F.filter(d=>d!==a),F.distinctUntilChanged()).subscribe({next:d=>{a=d,this._drawingManagerService.setDrawingEditable(d);const g=l.getAllObjects(),S=this._drawingManagerService.getDrawingData(n,o),f=Object.values(S);d?(g.forEach(w=>{w.classType===$.RENDER_CLASS_TYPE.IMAGE&&f.some(I=>w.oKey.includes(I.drawingId))&&l.attachTransformerTo(w)}),this._drawingManagerService.addNotification(f)):(g.forEach(w=>{w.classType===$.RENDER_CLASS_TYPE.IMAGE&&f.some(I=>w.oKey.includes(I.drawingId))&&l.detachTransformerFrom(w)}),m.clearSelectedObjects())}}),(c=this._permissionService.getPermissionPoint$(new v.WorksheetEditPermission(n,o).id))==null||c.pipe(F.filter(d=>d.value!==a),F.distinctUntilChanged()).subscribe({complete:()=>{a=!0;const d=e.getUnitId(),g=t.getSheetId(),S=this._drawingManagerService.getDrawingData(d,g),f=Object.values(S),w=this._renderManagerService.getRenderById(d),I=w==null?void 0:w.scene;if(I==null)return;this._drawingManagerService.setDrawingEditable(!0),I.getAllObjects().forEach(y=>{y.classType===$.RENDER_CLASS_TYPE.IMAGE&&f.some(R=>y.oKey.includes(R.drawingId))&&I.detachTransformerFrom(y)})}})})}))}};Me=Nt([h.OnLifecycle(h.LifecycleStages.Rendered,Me),me(0,N.IDrawingManagerService),me(1,$.IRenderManagerService),me(2,h.IPermissionService),me(3,h.IUniverInstanceService),me(4,W.Inject(h.UserManagerService))],Me);var Lt=Object.defineProperty,jt=Object.getOwnPropertyDescriptor,Wt=(i,e,r,t)=>{for(var n=t>1?void 0:t?jt(e,r):e,o=i.length-1,a;o>=0;o--)(a=i[o])&&(n=(t?a(e,r,n):a(n))||n);return t&&n&&Lt(e,r,n),n},De=(i,e)=>(r,t)=>e(r,t,i);let Re=class extends h.Disposable{constructor(e,r,t,n){super();J(this,"_copyInfo");this._sheetClipboardService=e,this._selectionRenderService=r,this._sheetDrawingService=t,this._injector=n,this._initCopyPaste()}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:"SHEET_IMAGE_UI_PLUGIN",onBeforeCopy:(e,r,t)=>this._collect(e,r,t),onPasteCells:(e,r,t,n)=>{const{copyType:o=G.COPY_TYPE.COPY,pasteType:a}=n,{range:s}=e||{},{range:l,unitId:m,subUnitId:u}=r;return this._generateMutations(l,{copyType:o,pasteType:a,copyRange:s,unitId:m,subUnitId:u})},onPastePlainText:(e,r)=>({undos:[],redos:[]})})}_collect(e,r,t){const n=this._selectionRenderService.attachRangeWithCoord(t);if(!n)return;const{startX:o,endX:a,startY:s,endY:l}=n,m=this._sheetDrawingService.getDrawingData(e,r),u=[];Object.keys(m).forEach(c=>{const d=m[c],{transform:g}=d;if(d.anchorType!==p.SheetDrawingAnchorType.Both||!g)return;const{left:S=0,top:f=0,width:w=0,height:I=0}=g,{drawingStartX:D,drawingEndX:y,drawingStartY:R,drawingEndY:C}={drawingStartX:S,drawingEndX:S+w,drawingStartY:f,drawingEndY:f+I};o<=D&&y<=a&&s<=R&&C<=l&&u.push(d)}),u.length&&(this._copyInfo={drawings:u,unitId:e,subUnitId:r})}_generateMutations(e,r){if(!this._copyInfo)return{redos:[],undos:[]};if([G.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,G.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,G.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,G.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMULA].includes(r.pasteType))return{redos:[],undos:[]};const{copyRange:t}=r;if(!t)return{redos:[],undos:[]};const{drawings:n,unitId:o,subUnitId:a}=this._copyInfo,{ranges:[s,l],mapFunc:m}=G.virtualizeDiscreteRanges([t,e]),{row:u,col:c}=m(s.startRow,s.startColumn),{row:d,col:g}=m(l.startRow,l.startColumn),S=this._selectionRenderService.attachRangeWithCoord({startRow:u,endRow:u,startColumn:c,endColumn:c}),f=this._selectionRenderService.attachRangeWithCoord({startRow:d,endRow:d,startColumn:g,endColumn:g});if(!S||!f)return{redos:[],undos:[]};const w=[],I=[],D=f.startX-S.startX,y=f.startY-S.startY,R=d-u,C=g-c,P=r.copyType===G.COPY_TYPE.CUT,{_sheetDrawingService:_}=this;return n.forEach(U=>{const{transform:A,sheetTransform:T}=U;if(!A)return;const b={...U,unitId:o,subUnitId:a,drawingId:P?U.drawingId:h.Tools.generateRandomId(),transform:{...A,left:A.left+D,top:A.top+y},sheetTransform:{to:{...T.to,row:T.to.row+R,column:T.to.column+C},from:{...T.from,row:T.from.row+R,column:T.from.column+C}}};if(P){const{undo:E,redo:M,objects:L}=_.getBatchUpdateOp([b]);w.push({id:p.SetDrawingApplyMutation.id,params:{unitId:o,subUnitId:a,type:p.DrawingApplyType.UPDATE,op:M,objects:L}}),I.push({id:p.SetDrawingApplyMutation.id,params:{unitId:o,subUnitId:a,type:p.DrawingApplyType.UPDATE,op:E,objects:L}})}else{const{undo:E,redo:M,objects:L}=_.getBatchAddOp([b]);w.push({id:p.SetDrawingApplyMutation.id,params:{op:M,unitId:o,subUnitId:a,objects:L,type:p.DrawingApplyType.INSERT}}),I.push({id:p.SetDrawingApplyMutation.id,params:{op:E,unitId:o,subUnitId:a,objects:L,type:p.DrawingApplyType.REMOVE}})}}),{redos:w,undos:I}}};Re=Wt([h.OnLifecycle(h.LifecycleStages.Ready,Re),De(0,G.ISheetClipboardService),De(1,G.ISelectionRenderService),De(2,p.ISheetDrawingService),De(3,W.Inject(W.Injector))],Re);var Xe=Object.defineProperty,$t=Object.getOwnPropertyDescriptor,Gt=(i,e,r)=>e in i?Xe(i,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):i[e]=r,Bt=(i,e,r,t)=>{for(var n=t>1?void 0:t?$t(e,r):e,o=i.length-1,a;o>=0;o--)(a=i[o])&&(n=(t?a(e,r,n):a(n))||n);return t&&n&&Xe(e,r,n),n},Ne=(i,e)=>(r,t)=>e(r,t,i),He=(i,e,r)=>Gt(i,typeof e!="symbol"?e+"":e,r);const Vt="SHEET_IMAGE_UI_PLUGIN";O.UniverSheetsDrawingUIPlugin=class extends h.Plugin{constructor(r={},t,n,o){super();J(this,"_pluginConfig");this._injector=t,this._localeService=n,this._renderManagerService=o,this._pluginConfig=h.Tools.deepMerge({},vt,r)}onStarting(r){super.onStarting(r),this._initDependencies(r)}_initDependencies(r){const t=[[O.SheetCanvasFloatDomManagerService],[ue,{useFactory:()=>this._injector.createInstance(ue,this._pluginConfig)}],[Se],[ye],[Me],[Re]],n=[ve,Ce];t.forEach(o=>r.add(o)),n.forEach(o=>this._renderManagerService.registerRenderModule(h.UniverInstanceType.UNIVER_SHEET,o))}},He(O.UniverSheetsDrawingUIPlugin,"type",h.UniverInstanceType.UNIVER_SHEET),He(O.UniverSheetsDrawingUIPlugin,"pluginName",Vt),O.UniverSheetsDrawingUIPlugin=Bt([h.DependentOn(N.UniverDrawingPlugin,te.UniverDrawingUIPlugin,p.UniverSheetsDrawingPlugin),Ne(1,W.Inject(W.Injector)),Ne(2,W.Inject(h.LocaleService)),Ne(3,$.IRenderManagerService)],O.UniverSheetsDrawingUIPlugin),O.ClearSheetDrawingTransformerOperation=V,O.DeleteDrawingsCommand=Ae,O.EditSheetDrawingOperation=Oe,O.GroupSheetDrawingCommand=be,O.InsertCellImageOperation=se,O.InsertFloatImageOperation=ae,O.InsertSheetDrawingCommand=we,O.MoveDrawingsCommand=oe,O.RemoveSheetDrawingCommand=he,O.SetDrawingArrangeCommand=Ee,O.SetSheetDrawingCommand=ce,O.SidebarSheetDrawingOperation=Te,O.UngroupSheetDrawingCommand=Pe,Object.defineProperty(O,Symbol.toStringTag,{value:"Module"})});
1
+ (function(T,p){typeof exports=="object"&&typeof module<"u"?p(exports,require("@univerjs/core"),require("@wendellhu/redi"),require("@univerjs/drawing-ui"),require("@univerjs/sheets-drawing"),require("@univerjs/drawing"),require("@univerjs/engine-render"),require("@univerjs/sheets-ui"),require("rxjs"),require("@univerjs/ui"),require("@wendellhu/redi/react-bindings"),require("@univerjs/sheets"),require("react"),require("@univerjs/design"),require("clsx")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@wendellhu/redi","@univerjs/drawing-ui","@univerjs/sheets-drawing","@univerjs/drawing","@univerjs/engine-render","@univerjs/sheets-ui","rxjs","@univerjs/ui","@wendellhu/redi/react-bindings","@univerjs/sheets","react","@univerjs/design","clsx"],p):(T=typeof globalThis<"u"?globalThis:T||self,p(T.UniverSheetsDrawingUi={},T.UniverCore,T["@wendellhu/redi"],T.UniverDrawingUi,T.UniverSheetsDrawing,T.UniverDrawing,T.UniverEngineRender,T.UniverSheetsUi,T.rxjs,T.UniverUi,T["@wendellhu/redi/react-bindings"],T.UniverSheets,T.React,T.UniverDesign,T.clsx))})(this,function(T,p,B,Q,h,A,L,$,k,F,q,_,N,J,me){"use strict";var Ft=Object.defineProperty;var kt=(T,p,B)=>p in T?Ft(T,p,{enumerable:!0,configurable:!0,writable:!0,value:B}):T[p]=B;var z=(T,p,B)=>kt(T,typeof p!="symbol"?p+"":p,B);const G={id:"sheet.operation.clear-drawing-transformer",type:p.CommandType.MUTATION,handler:(i,t)=>{const n=i.get(L.IRenderManagerService);return t.forEach(e=>{var r,o;(o=(r=n.getRenderById(e))==null?void 0:r.scene.getTransformer())==null||o.debounceRefreshControls()}),!0}},ge={id:"sheet.command.remove-sheet-image",type:p.CommandType.COMMAND,handler:(i,t)=>{const n=i.get(p.ICommandService),e=i.get(p.IUndoRedoService),r=i.get(h.ISheetDrawingService);if(!t)return!1;const{drawings:o}=t,a=[];o.forEach(S=>{const{unitId:f}=S;a.push(f)});const s=r.getBatchRemoveOp(o),{unitId:l,subUnitId:u,undo:d,redo:c,objects:m}=s;return n.syncExecuteCommand(h.SetDrawingApplyMutation.id,{unitId:l,subUnitId:u,op:c,objects:m,type:h.DrawingApplyType.REMOVE})?(e.pushUndoRedo({unitID:l,undoMutations:[{id:h.SetDrawingApplyMutation.id,params:{unitId:l,subUnitId:u,op:d,objects:m,type:h.DrawingApplyType.INSERT}},{id:G.id,params:a}],redoMutations:[{id:h.SetDrawingApplyMutation.id,params:{unitId:l,subUnitId:u,op:c,objects:m,type:h.DrawingApplyType.REMOVE}},{id:G.id,params:a}]}),!0):!1}},Ue="COMPONENT_SHEET_DRAWING_PANEL",Me={id:"sidebar.operation.sheet-image",type:p.CommandType.COMMAND,handler:async(i,t)=>{const n=i.get(F.ISidebarService),e=i.get(p.LocaleService),r=i.get(p.IUniverInstanceService),o=i.get(A.IDrawingManagerService);if(!_.getSheetCommandTarget(r))return!1;switch(t.value){case"open":n.open({header:{title:e.t("sheetImage.panel.title")},children:{label:Ue},onClose:()=>{o.focusDrawing(null)},width:360});break;case"close":default:n.close();break}return!0}},De={id:"sheet.operation.edit-sheet-image",type:p.CommandType.OPERATION,handler:(i,t)=>{const n=i.get(A.IDrawingManagerService),e=i.get(p.ICommandService);return t==null?!1:(n.focusDrawing([t]),e.executeCommand(Me.id,{value:"open"}),!0)}},pe={uploadLoading:"univer-upload-loading",uploadLoadingBody:"univer-upload-loading-body",uploadLoadingBodyAnimation:"univer-upload-loading-body-animation",univerCircleAnimation:"univer-UniverCircleAnimation",uploadLoadingBodyText:"univer-upload-loading-body-text"},Xe=()=>{const i=q.useDependency(A.IImageIoService),t=q.useDependency(p.LocaleService),[n,e]=N.useState(0);return N.useEffect(()=>{const r=i.change$.subscribe(o=>{e(o)});return()=>{r.unsubscribe()}},[i]),N.createElement("div",{style:{display:n>0?"block":"none"},className:pe.uploadLoading},N.createElement("div",{className:pe.uploadLoadingBody},N.createElement("div",{className:pe.uploadLoadingBodyAnimation}),N.createElement("div",{className:pe.uploadLoadingBodyText},`${t.t("uploadLoading.loading")}: ${n}`)))};var xe=Object.defineProperty,Ke=Object.getOwnPropertyDescriptor,ze=(i,t,n,e)=>{for(var r=e>1?void 0:e?Ke(t,n):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(t,n,r):a(r))||r);return e&&r&&xe(t,n,r),r},ee=(i,t)=>(n,e)=>t(n,e,i);let he=class extends p.RxDisposable{constructor(t,n,e,r,o,a,s){super();z(this,"_initImagePopupMenu",new Set);this._injector=t,this._drawingManagerService=n,this._canvasPopManagerService=e,this._renderManagerService=r,this._univerInstanceService=o,this._contextService=a,this._uiPartsService=s,this._init()}_init(){this._univerInstanceService.getCurrentTypeOfUnit$(p.UniverInstanceType.UNIVER_SHEET).pipe(k.takeUntil(this.dispose$)).subscribe(t=>this._create(t)),this._univerInstanceService.getTypeOfUnitDisposed$(p.UniverInstanceType.UNIVER_SHEET).pipe(k.takeUntil(this.dispose$)).subscribe(t=>this._dispose(t)),this._univerInstanceService.getAllUnitsForType(p.UniverInstanceType.UNIVER_SHEET).forEach(t=>this._create(t)),this._uiPartsService.registerComponent(F.BuiltInUIPart.CONTENT,()=>q.connectInjector(Xe,this._injector))}_dispose(t){const n=t.getUnitId();this._renderManagerService.removeRender(n)}_create(t){if(!t)return;const n=t.getUnitId();this._renderManagerService.has(n)&&!this._initImagePopupMenu.has(n)&&(this._popupMenuListener(n),this._initImagePopupMenu.add(n))}_hasCropObject(t){const n=t.getAllObjects();for(const e of n)if(e instanceof Q.ImageCropperObject)return!0;return!1}_popupMenuListener(t){var o;const n=(o=this._renderManagerService.getRenderById(t))==null?void 0:o.scene;if(!n)return;const e=n.getTransformerByCreate();if(!e)return;let r;this.disposeWithMe(p.toDisposable(e.createControl$.subscribe(()=>{if(this._contextService.setContextValue(p.FOCUSING_COMMON_DRAWINGS,!0),this._hasCropObject(n))return;const a=e.getSelectedObjectMap();if(a.size>1){r==null||r.dispose();return}const s=a.values().next().value;if(!s)return;const l=s.oKey,u=this._drawingManagerService.getDrawingOKey(l);if(!u)return;const{unitId:d,subUnitId:c,drawingId:m}=u;r==null||r.dispose(),r=this.disposeWithMe(this._canvasPopManagerService.attachPopupToObject(s,{componentKey:Q.COMPONENT_IMAGE_POPUP_MENU,direction:"horizontal",offset:[2,0],extraProps:{menuItems:this._getImageMenuItems(d,c,m)}})),this._drawingManagerService.focusDrawing([{unitId:d,subUnitId:c,drawingId:m}])}))),this.disposeWithMe(e.clearControl$.subscribe(()=>{r==null||r.dispose(),this._contextService.setContextValue(p.FOCUSING_COMMON_DRAWINGS,!1),this._drawingManagerService.focusDrawing(null)})),this.disposeWithMe(e.changing$.subscribe(()=>{r==null||r.dispose()}))}_getImageMenuItems(t,n,e){return[{label:"image-popup.edit",index:0,commandId:De.id,commandParams:{unitId:t,subUnitId:n,drawingId:e},disable:!1},{label:"image-popup.delete",index:1,commandId:ge.id,commandParams:{unitId:t,drawings:[{unitId:t,subUnitId:n,drawingId:e}]},disable:!1},{label:"image-popup.crop",index:2,commandId:Q.OpenImageCropOperation.id,commandParams:{unitId:t,subUnitId:n,drawingId:e},disable:!1},{label:"image-popup.reset",index:3,commandId:Q.ImageResetSizeOperation.id,commandParams:[{unitId:t,subUnitId:n,drawingId:e}],disable:!1}]}};he=ze([p.OnLifecycle(p.LifecycleStages.Steady,he),ee(0,B.Inject(B.Injector)),ee(1,A.IDrawingManagerService),ee(2,B.Inject($.SheetCanvasPopManagerService)),ee(3,L.IRenderManagerService),ee(4,p.IUniverInstanceService),ee(5,p.IContextService),ee(6,B.Inject(F.IUIPartsService))],he);const oe={id:"sheet.operation.insert-float-image",type:p.CommandType.OPERATION,handler:(i,t)=>!0},ae={id:"sheet.operation.insert-cell-image",type:p.CommandType.OPERATION,handler:(i,t)=>!0},fe={id:"sheet.command.insert-sheet-image",type:p.CommandType.COMMAND,handler:(i,t)=>{const n=i.get(p.ICommandService),e=i.get(p.IUndoRedoService),r=i.get(h.ISheetDrawingService);if(!t)return!1;const o=t.drawings,a=o.map(S=>S.unitId),s=r.getBatchAddOp(o),{unitId:l,subUnitId:u,undo:d,redo:c,objects:m}=s;return n.syncExecuteCommand(h.SetDrawingApplyMutation.id,{op:c,unitId:l,subUnitId:u,objects:m,type:h.DrawingApplyType.INSERT})?(e.pushUndoRedo({unitID:l,undoMutations:[{id:h.SetDrawingApplyMutation.id,params:{op:d,unitId:l,subUnitId:u,objects:m,type:h.DrawingApplyType.REMOVE}},{id:G.id,params:a}],redoMutations:[{id:h.SetDrawingApplyMutation.id,params:{op:c,unitId:l,subUnitId:u,objects:m,type:h.DrawingApplyType.INSERT}},{id:G.id,params:a}]}),!0):!1}},se={id:"sheet.command.set-sheet-image",type:p.CommandType.COMMAND,handler:(i,t)=>{const n=i.get(p.ICommandService),e=i.get(p.IUndoRedoService),r=i.get(h.ISheetDrawingService);if(!t)return!1;const{drawings:o}=t,a=r.getBatchUpdateOp(o),{unitId:s,subUnitId:l,undo:u,redo:d,objects:c}=a;return n.syncExecuteCommand(h.SetDrawingApplyMutation.id,{unitId:s,subUnitId:l,op:d,objects:c,type:h.DrawingApplyType.UPDATE})?(e.pushUndoRedo({unitID:s,undoMutations:[{id:h.SetDrawingApplyMutation.id,params:{unitId:s,subUnitId:l,op:u,objects:c,type:h.DrawingApplyType.UPDATE}},{id:G.id,params:[s]}],redoMutations:[{id:h.SetDrawingApplyMutation.id,params:{unitId:s,subUnitId:l,op:d,objects:c,type:h.DrawingApplyType.UPDATE}},{id:G.id,params:[s]}]}),!0):!1}},Te={id:"sheet.command.set-drawing-arrange",type:p.CommandType.COMMAND,handler:(i,t)=>{const n=i.get(p.ICommandService),e=i.get(p.IUndoRedoService);if(!t)return!1;const r=i.get(h.ISheetDrawingService),{unitId:o,subUnitId:a,drawingIds:s,arrangeType:l}=t,u={unitId:o,subUnitId:a,drawingIds:s};let d;if(l===A.ArrangeTypeEnum.forward?d=r.getForwardDrawingsOp(u):l===A.ArrangeTypeEnum.backward?d=r.getBackwardDrawingOp(u):l===A.ArrangeTypeEnum.front?d=r.getFrontDrawingsOp(u):l===A.ArrangeTypeEnum.back&&(d=r.getBackDrawingsOp(u)),d==null)return!1;const{objects:c,redo:m,undo:g}=d;return n.syncExecuteCommand(h.SetDrawingApplyMutation.id,{op:m,unitId:o,subUnitId:a,objects:c,type:h.DrawingApplyType.ARRANGE})?(e.pushUndoRedo({unitID:o,undoMutations:[{id:h.SetDrawingApplyMutation.id,params:{op:g,unitId:o,subUnitId:a,objects:c,type:h.DrawingApplyType.ARRANGE}}],redoMutations:[{id:h.SetDrawingApplyMutation.id,params:{op:m,unitId:o,subUnitId:a,objects:c,type:h.DrawingApplyType.ARRANGE}}]}),!0):!1}};function qe(i){const t=[];return i.forEach(n=>{const{parent:e,children:r}=n,{unitId:o,subUnitId:a,drawingId:s}=e,l=L.getGroupState(0,0,r.map(c=>c.transform||{})),u=r.map(c=>{const m=c.transform||{left:0,top:0},{unitId:g,subUnitId:S,drawingId:f}=c;return{unitId:g,subUnitId:S,drawingId:f,transform:{...m,left:m.left-l.left,top:m.top-l.top},groupId:s}}),d={unitId:o,subUnitId:a,drawingId:s,drawingType:A.DrawingTypeEnum.DRAWING_GROUP,transform:l};t.push({parent:d,children:u})}),t}function Je(i){const t=[];return i.forEach(n=>{const{parent:e,children:r}=n,{unitId:o,subUnitId:a,drawingId:s,transform:l={width:0,height:0}}=e;if(l==null)return;const u=r.map(c=>{const{transform:m}=c,{unitId:g,subUnitId:S,drawingId:f}=c,v=L.transformObjectOutOfGroup(m||{},l,l.width||0,l.height||0);return{unitId:g,subUnitId:S,drawingId:f,transform:v,groupId:void 0}}),d={unitId:o,subUnitId:a,drawingId:s,drawingType:A.DrawingTypeEnum.DRAWING_GROUP,transform:{left:0,top:0}};t.push({parent:d,children:u})}),t}const Re={id:"sheet.command.group-sheet-image",type:p.CommandType.COMMAND,handler:(i,t)=>{const n=i.get(p.ICommandService),e=i.get(p.IUndoRedoService),r=i.get(h.ISheetDrawingService);if(!t)return!1;const o=[];t.forEach(({parent:g,children:S})=>{o.push(g.unitId),S.forEach(f=>{o.push(f.unitId)})});const a=r.getGroupDrawingOp(t),{unitId:s,subUnitId:l,undo:u,redo:d,objects:c}=a;return n.syncExecuteCommand(h.SetDrawingApplyMutation.id,{op:d,unitId:s,subUnitId:l,objects:c,type:h.DrawingApplyType.GROUP})?(e.pushUndoRedo({unitID:s,undoMutations:[{id:h.SetDrawingApplyMutation.id,params:{op:u,unitId:s,subUnitId:l,objects:Je(c),type:h.DrawingApplyType.UNGROUP}},{id:G.id,params:o}],redoMutations:[{id:h.SetDrawingApplyMutation.id,params:{op:d,unitId:s,subUnitId:l,objects:c,type:h.DrawingApplyType.GROUP}},{id:G.id,params:o}]}),!0):!1}},Ee={id:"sheet.command.ungroup-sheet-image",type:p.CommandType.COMMAND,handler:(i,t)=>{const n=i.get(p.ICommandService),e=i.get(p.IUndoRedoService),r=i.get(h.ISheetDrawingService);if(!t)return!1;const o=[];t.forEach(({parent:g,children:S})=>{o.push(g.unitId),S.forEach(f=>{o.push(f.unitId)})});const a=r.getUngroupDrawingOp(t),{unitId:s,subUnitId:l,undo:u,redo:d,objects:c}=a;return n.syncExecuteCommand(h.SetDrawingApplyMutation.id,{op:d,unitId:s,subUnitId:l,objects:c,type:h.DrawingApplyType.UNGROUP})?(e.pushUndoRedo({unitID:s,undoMutations:[{id:h.SetDrawingApplyMutation.id,params:{op:u,unitId:s,subUnitId:l,objects:qe(c),type:h.DrawingApplyType.GROUP}},{id:G.id,params:o}],redoMutations:[{id:h.SetDrawingApplyMutation.id,params:{op:d,unitId:s,subUnitId:l,objects:c,type:h.DrawingApplyType.UNGROUP}},{id:G.id,params:o}]}),!0):!1}};function H(i,t,n){const{from:e,to:r,flipY:o=!1,flipX:a=!1,angle:s=0,skewX:l=0,skewY:u=0}=i,{column:d,columnOffset:c,row:m,rowOffset:g}=e,{column:S,columnOffset:f,row:v,rowOffset:y}=r,M=n.attachRangeWithCoord({startColumn:d,endColumn:d,startRow:m,endRow:m});if(M==null)return;const C=n.attachRangeWithCoord({startColumn:S,endColumn:S,startRow:v,endRow:v});if(C==null)return;const{startX:R,startY:I}=M,{startX:O,startY:w}=C;let U=L.precisionTo(R+c,1),E=L.precisionTo(I+g,1),j=L.precisionTo(O+f-U,1),P=L.precisionTo(w+y-E,1);M.startX===C.endX&&(j=0),M.startY===C.endY&&(P=0);const b=n.getCurrentSkeleton(),D=b.rowHeaderWidth+b.columnTotalWidth,W=b.columnHeaderHeight+b.rowTotalHeight;return U+j>D&&(U=D-j),E+P>W&&(E=W-P),{flipY:o,flipX:a,angle:s,skewX:l,skewY:u,left:U,top:E,width:j,height:P}}function V(i,t){const{left:n=0,top:e=0,width:r=0,height:o=0,flipY:a=!1,flipX:s=!1,angle:l=0,skewX:u=0,skewY:d=0}=i,c=t.getSelectionCellByPosition(n,e);if(c==null)return;const m={column:c.actualColumn,columnOffset:L.precisionTo(n-c.startX,1),row:c.actualRow,rowOffset:L.precisionTo(e-c.startY,1)},g=t.getSelectionCellByPosition(n+r,e+o);if(g==null)return;const S={column:g.actualColumn,columnOffset:L.precisionTo(n+r-g.startX,1),row:g.actualRow,rowOffset:L.precisionTo(e+o-g.startY,1)};return{flipY:a,flipX:s,angle:l,skewX:u,skewY:d,from:m,to:S}}var Ze=Object.defineProperty,Qe=Object.getOwnPropertyDescriptor,et=(i,t,n,e)=>{for(var r=e>1?void 0:e?Qe(t,n):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(t,n,r):a(r))||r);return e&&r&&Ze(t,n,r),r},K=(i,t)=>(n,e)=>t(n,e,i);let Se=class extends p.Disposable{constructor(i,t,n,e,r,o,a,s,l,u){super(),this._commandService=i,this._univerInstanceService=t,this._selectionManagerService=n,this._imageIoService=e,this._sheetDrawingService=r,this._drawingManagerService=o,this._contextService=a,this._messageService=s,this._localeService=l,this._renderManagerService=u,this._init()}get _selectionRenderService(){return this._renderManagerService.getRenderById(this._univerInstanceService.getCurrentUnitForType(p.UniverInstanceType.UNIVER_SHEET).getUnitId()).with($.ISheetSelectionRenderService)}get _skeletonManagerService(){return this._renderManagerService.getRenderById(this._univerInstanceService.getCurrentUnitForType(p.UniverInstanceType.UNIVER_SHEET).getUnitId()).with($.SheetSkeletonManagerService)}_init(){this._initCommandListeners(),this._updateImageListener(),this._updateOrderListener(),this._groupDrawingListener(),this._focusDrawingListener(),this._drawingAddListener()}_initCommandListeners(){this.disposeWithMe(this._commandService.onCommandExecuted(async i=>{if(i.id===ae.id||i.id===oe.id){const t=i.params;if(t.files==null)return;const n=t.files.length;if(n>A.DRAWING_IMAGE_COUNT_LIMIT){this._messageService.show({type:J.MessageType.Error,content:this._localeService.t("update-status.exceedMaxCount",String(A.DRAWING_IMAGE_COUNT_LIMIT))});return}this._imageIoService.setWaitCount(n),i.id===ae.id?t.files.forEach(async e=>{await this._insertCellImage(e)}):t.files.forEach(async e=>{await this._insertFloatImage(e)})}}))}async _insertCellImage(i){}async _insertFloatImage(i){let t;try{t=await this._imageIoService.saveImage(i)}catch(M){const C=M.message;C===A.ImageUploadStatusType.ERROR_EXCEED_SIZE?this._messageService.show({type:J.MessageType.Error,content:this._localeService.t("update-status.exceedMaxSize",String(A.DRAWING_IMAGE_ALLOW_SIZE/(1024*1024)))}):C===A.ImageUploadStatusType.ERROR_IMAGE_TYPE?this._messageService.show({type:J.MessageType.Error,content:this._localeService.t("update-status.invalidImageType")}):C===A.ImageUploadStatusType.ERROR_IMAGE&&this._messageService.show({type:J.MessageType.Error,content:this._localeService.t("update-status.invalidImage")})}if(t==null)return;const n=this._getUnitInfo();if(n==null)return;const{unitId:e,subUnitId:r}=n,{imageId:o,imageSourceType:a,source:s,base64Cache:l}=t,{width:u,height:d,image:c}=await A.getImageSize(l||""),m=this._renderManagerService.getRenderById(e);if(m==null)return;const{width:g,height:S}=m.scene;this._imageIoService.addImageSourceCache(s,a,c);let f=1;if(u>A.DRAWING_IMAGE_WIDTH_LIMIT||d>A.DRAWING_IMAGE_HEIGHT_LIMIT){const M=A.DRAWING_IMAGE_WIDTH_LIMIT/u,C=A.DRAWING_IMAGE_HEIGHT_LIMIT/d;f=Math.max(M,C)}const v=this._getImagePosition(u*f,d*f,g,S);if(v==null)return;const y={unitId:e,subUnitId:r,drawingId:o,drawingType:A.DrawingTypeEnum.DRAWING_IMAGE,imageSourceType:a,source:s,transform:H(v,this._selectionRenderService,this._skeletonManagerService),sheetTransform:v};this._commandService.executeCommand(fe.id,{unitId:e,drawings:[y]})}_getUnitInfo(){const i=this._univerInstanceService.getCurrentUnitForType(p.UniverInstanceType.UNIVER_SHEET);if(i==null)return;const t=i.getActiveSheet();if(t==null)return;const n=i.getUnitId(),e=t.getSheetId();return{unitId:n,subUnitId:e}}_getImagePosition(i,t,n,e){const r=this._selectionManagerService.getCurrentSelections();let o={startRow:0,endRow:0,startColumn:0,endColumn:0};r&&r.length>0&&(o=r[r.length-1].range);const a=$.attachRangeWithCoord(this._skeletonManagerService.getCurrent().skeleton,o);if(a==null)return;let{startColumn:s,startRow:l,startX:u,startY:d}=a,c=!1;if(u+i>n&&(u=n-i,u<0&&(u=0,i=n),c=!0),d+t>e&&(d=e-t,d<0&&(d=0,t=e),c=!0),c){const f=this._selectionRenderService.getSelectionCellByPosition(u,d);if(f==null)return;u=f.startX,d=f.startY,s=f.actualColumn,l=f.actualRow}const m={column:s,columnOffset:0,row:l,rowOffset:0},g=this._selectionRenderService.getSelectionCellByPosition(u+i,d+t);if(g==null)return;const S={column:g.actualColumn,columnOffset:u+i-g.startX,row:g.actualRow,rowOffset:d+t-g.startY};return{from:m,to:S}}_updateOrderListener(){this._drawingManagerService.featurePluginOrderUpdate$.subscribe(i=>{const{unitId:t,subUnitId:n,drawingIds:e,arrangeType:r}=i;this._commandService.executeCommand(Te.id,{unitId:t,subUnitId:n,drawingIds:e,arrangeType:r})})}_updateImageListener(){this._drawingManagerService.featurePluginUpdate$.subscribe(i=>{const t=[];i.length!==0&&(i.forEach(n=>{const{unitId:e,subUnitId:r,drawingId:o,drawingType:a,transform:s}=n;if(s==null)return;const l=this._sheetDrawingService.getDrawingByParam({unitId:e,subUnitId:r,drawingId:o});if(l==null)return;const u=V({...l.transform,...s},this._selectionRenderService);if(u==null)return;const d={...n,transform:{...l.transform,...s,...H(u,this._selectionRenderService,this._skeletonManagerService)},sheetTransform:{...u}};t.push(d)}),t.length>0&&this._commandService.executeCommand(se.id,{unitId:i[0].unitId,drawings:t}))})}_groupDrawingListener(){this._drawingManagerService.featurePluginGroupUpdate$.subscribe(i=>{this._commandService.executeCommand(Re.id,i);const{unitId:t,subUnitId:n,drawingId:e}=i[0].parent;this._drawingManagerService.focusDrawing([{unitId:t,subUnitId:n,drawingId:e}])}),this._drawingManagerService.featurePluginUngroupUpdate$.subscribe(i=>{this._commandService.executeCommand(Ee.id,i)})}_focusDrawingListener(){this.disposeWithMe(this._drawingManagerService.focus$.subscribe(i=>{i==null||i.length===0?(this._contextService.setContextValue(p.FOCUSING_COMMON_DRAWINGS,!1),this._sheetDrawingService.focusDrawing([])):(this._contextService.setContextValue(p.FOCUSING_COMMON_DRAWINGS,!0),this._sheetDrawingService.focusDrawing(i))}))}_drawingAddListener(){this.disposeWithMe(this._sheetDrawingService.add$.subscribe(i=>{this._registerDrawing(i)}))}_registerDrawing(i){i.forEach(n=>{const e=this._sheetDrawingService.getDrawingByParam(n);if(e==null)return;const{sheetTransform:r}=e;e.transform=H(r,this._selectionRenderService,this._skeletonManagerService)});const t=i[0].unitId;this._drawingManagerService.registerDrawingData(t,this._sheetDrawingService.getDrawingDataForUnit(t)),this._drawingManagerService.initializeNotification(t)}};Se=et([p.OnLifecycle(p.LifecycleStages.Rendered,Se),K(0,p.ICommandService),K(1,p.IUniverInstanceService),K(2,B.Inject(_.SheetsSelectionsService)),K(3,A.IImageIoService),K(4,h.ISheetDrawingService),K(5,A.IDrawingManagerService),K(6,p.IContextService),K(7,F.IMessageService),K(8,B.Inject(p.LocaleService)),K(9,L.IRenderManagerService)],Se);var x=function(){return x=Object.assign||function(i){for(var t,n=1,e=arguments.length;n<e;n++){t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(i[r]=t[r])}return i},x.apply(this,arguments)},tt=function(i,t){var n={};for(var e in i)Object.prototype.hasOwnProperty.call(i,e)&&t.indexOf(e)<0&&(n[e]=i[e]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,e=Object.getOwnPropertySymbols(i);r<e.length;r++)t.indexOf(e[r])<0&&Object.prototype.propertyIsEnumerable.call(i,e[r])&&(n[e[r]]=i[e[r]]);return n},Ne=N.forwardRef(function(i,t){var n=i.icon,e=i.id,r=i.className,o=i.extend,a=tt(i,["icon","id","className","extend"]),s="univerjs-icon univerjs-icon-".concat(e," ").concat(r||"").trim(),l=N.useRef("_".concat(it()));return Le(n,"".concat(e),{defIds:n.defIds,idSuffix:l.current},x({ref:t,className:s},a),o)});function Le(i,t,n,e,r){return N.createElement(i.tag,x(x({key:t},nt(i,n,r)),e),(rt(i,n).children||[]).map(function(o,a){return Le(o,"".concat(t,"-").concat(i.tag,"-").concat(a),n,void 0,r)}))}function nt(i,t,n){var e=x({},i.attrs);n!=null&&n.colorChannel1&&e.fill==="colorChannel1"&&(e.fill=n.colorChannel1);var r=t.defIds;return!r||r.length===0||(i.tag==="use"&&e["xlink:href"]&&(e["xlink:href"]=e["xlink:href"]+t.idSuffix),Object.entries(e).forEach(function(o){var a=o[0],s=o[1];typeof s=="string"&&(e[a]=s.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),e}function rt(i,t){var n,e=t.defIds;return!e||e.length===0?i:i.tag==="defs"&&(!((n=i.children)===null||n===void 0)&&n.length)?x(x({},i),{children:i.children.map(function(r){return typeof r.attrs.id=="string"&&e&&e.indexOf(r.attrs.id)>-1?x(x({},r),{attrs:x(x({},r.attrs),{id:r.attrs.id+t.idSuffix})}):r})}):i}function it(){return Math.random().toString(36).substring(2,8)}Ne.displayName="UniverIcon";var ot={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M2.2498 3.65005C2.2498 2.87685 2.87661 2.25005 3.64981 2.25005H7.9998C8.33118 2.25005 8.5998 1.98142 8.5998 1.65005C8.5998 1.31868 8.33118 1.05005 7.9998 1.05005H3.64981C2.21387 1.05005 1.0498 2.21411 1.0498 3.65005V12.35C1.0498 13.786 2.21386 14.95 3.6498 14.95H12.3498C13.7857 14.95 14.9498 13.786 14.9498 12.3501V8.00005C14.9498 7.66868 14.6812 7.40005 14.3498 7.40005C14.0184 7.40005 13.7498 7.66868 13.7498 8.00005V9.23974L12.2385 8.1063C11.7252 7.72129 11.0068 7.7723 10.5531 8.22605L9.00869 9.77041L6.73916 7.8251C6.24387 7.40055 5.5095 7.41278 5.02864 7.85359L2.2498 10.4009V3.65005ZM2.2498 12.0287V12.35C2.2498 13.1232 2.87661 13.75 3.6498 13.75H12.3498C13.123 13.75 13.7498 13.1232 13.7498 12.3501V10.7397L11.5186 9.06631C11.4829 9.03956 11.433 9.04314 11.4016 9.07458L9.92249 10.5537L11.1015 11.5642C11.3531 11.7799 11.3822 12.1587 11.1666 12.4103C10.9509 12.6619 10.5721 12.691 10.3205 12.4753L5.9582 8.7362C5.92384 8.70674 5.87288 8.70758 5.83952 8.73816L2.2498 12.0287Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M11.8097 1.14783C12.1411 1.14783 12.4097 1.41646 12.4097 1.74783V3.297H14.1541C14.4855 3.297 14.7541 3.56563 14.7541 3.897C14.7541 4.22837 14.4855 4.497 14.1541 4.497H12.4097V6.24167C12.4097 6.57304 12.1411 6.84167 11.8097 6.84167C11.4783 6.84167 11.2097 6.57304 11.2097 6.24167V4.497H9.6603C9.32893 4.497 9.0603 4.22837 9.0603 3.897C9.0603 3.56563 9.32893 3.297 9.6603 3.297H11.2097V1.74783C11.2097 1.41646 11.4783 1.14783 11.8097 1.14783Z"}}]},je=N.forwardRef(function(i,t){return N.createElement(Ne,Object.assign({},i,{id:"add-image-single",ref:t,icon:ot}))});je.displayName="AddImageSingle";const We={uploadFileMenu:"univer-upload-file-menu",uploadFileMenuInput:"univer-upload-file-menu-input"},$e="COMPONENT_UPLOAD_FILE_MENU";var ve=(i=>(i[i.cellImage=0]="cellImage",i[i.floatImage=1]="floatImage",i))(ve||{});const at=i=>{const{type:t}=i,n=q.useDependency(p.ICommandService),e=N.useRef(null),r=()=>{var s;(s=e.current)==null||s.click()},o=A.DRAWING_IMAGE_ALLOW_IMAGE_LIST.map(s=>`.${s.replace("image/","")}`).join(","),a=s=>{const l=s.target.files;if(l==null)return;const u=Array.from(l);t===ve.floatImage?n.executeCommand(oe.id,{files:u}):t===ve.cellImage&&n.executeCommand(ae.id,{files:u}),e.current&&(e.current.value="")};return N.createElement("div",{onClick:r,className:We.uploadFileMenu},N.createElement("input",{type:"file",className:We.uploadFileMenuInput,ref:e,onChange:a,accept:o,multiple:!0}))},Be="addition-and-subtraction-single",Ge="sheet.menu.image";function st(i){return{id:Ge,type:F.MenuItemType.SUBITEMS,positions:[F.MenuPosition.TOOLBAR_START],group:F.MenuGroup.TOOLBAR_FORMULAS_INSERT,icon:Be,tooltip:"sheetImage.title",hidden$:F.getMenuHiddenObservable(i,p.UniverInstanceType.UNIVER_SHEET),disabled$:$.getCurrentRangeDisable$(i,{workbookTypes:[_.WorkbookEditablePermission],worksheetTypes:[_.WorksheetEditPermission],rangeTypes:[_.RangeProtectionPermissionEditPoint]})}}function ct(i){return{id:oe.id,title:"sheetImage.upload.float",type:F.MenuItemType.SELECTOR,label:{name:$e,props:{type:ve.floatImage}},positions:[Ge],hidden$:F.getMenuHiddenObservable(i,p.UniverInstanceType.UNIVER_SHEET)}}const Z={imageCommonPanel:"univer-image-common-panel",imageCommonPanelGrid:"univer-image-common-panel-grid",imageCommonPanelBorder:"univer-image-common-panel-border",imageCommonPanelTitle:"univer-image-common-panel-title",imageCommonPanelSubtitle:"univer-image-common-panel-subtitle",imageCommonPanelRow:"univer-image-common-panel-row",imageCommonPanelRowVertical:"univer-image-common-panel-row-vertical",imageCommonPanelColumn:"univer-image-common-panel-column",imageCommonPanelColumnCenter:"univer-image-common-panel-column-center",imageCommonPanelInline:"univer-image-common-panel-inline",imageCommonPanelSpan2:"univer-image-common-panel-span2",imageCommonPanelSpan3:"univer-image-common-panel-span3",imageCommonPanelInput:"univer-image-common-panel-input",sheetImageMenu:"univer-sheet-image-menu",sheetImageMenuInput:"univer-sheet-image-menu-input"},lt=i=>{var C;const t=q.useDependency(p.ICommandService),n=q.useDependency(p.LocaleService),e=q.useDependency(A.IDrawingManagerService),r=q.useDependency(L.IRenderManagerService),{drawings:o}=i,a=o[0];if(a==null)return;const{unitId:s}=a,l=r.getRenderById(s),u=l==null?void 0:l.scene;if(u==null)return;const d=u.getTransformerByCreate(),[c,m]=N.useState(!0),g=(C=a.anchorType)!=null?C:h.SheetDrawingAnchorType.Position,[S,f]=N.useState(g);function v(R,I){const O=[];return R.forEach(w=>{const{oKey:U}=w,E=I.getDrawingOKey(U);if(E==null)return O.push(null),!0;const{unitId:j,subUnitId:P,drawingId:b,drawingType:D,anchorType:W,sheetTransform:Y}=E;O.push({unitId:j,subUnitId:P,drawingId:b,anchorType:W,sheetTransform:Y,drawingType:D})}),O}N.useEffect(()=>{const R=d.clearControl$.subscribe(O=>{O===!0&&m(!1)}),I=d.changeStart$.subscribe(O=>{var E;const{objects:w}=O,U=v(w,e);if(U.length===0)m(!1);else if(U.length>=1){m(!0);const j=((E=U[0])==null?void 0:E.anchorType)||h.SheetDrawingAnchorType.Position;f(j)}});return()=>{I.unsubscribe(),R.unsubscribe()}},[]);function y(R){f(R);const I=e.getFocusDrawings();if(I.length===0)return;const O=I.map(w=>({unitId:w.unitId,subUnitId:w.subUnitId,drawingId:w.drawingId,anchorType:R}));t.executeCommand(se.id,{unitId:I[0].unitId,drawings:O})}const M=R=>R?"block":"none";return N.createElement("div",{className:me(Z.imageCommonPanelGrid,Z.imageCommonPanelBorder),style:{display:M(c)}},N.createElement("div",{className:Z.imageCommonPanelRow},N.createElement("div",{className:me(Z.imageCommonPanelColumn,Z.imageCommonPanelTitle)},N.createElement("div",null,n.t("drawing-anchor.title")))),N.createElement("div",{className:me(Z.imageCommonPanelRow)},N.createElement("div",{className:me(Z.imageCommonPanelColumn)},N.createElement(J.RadioGroup,{value:S,onChange:y,direction:"vertical"},N.createElement(J.Radio,{value:h.SheetDrawingAnchorType.Both},n.t("drawing-anchor.both")),N.createElement(J.Radio,{value:h.SheetDrawingAnchorType.Position},n.t("drawing-anchor.position")),N.createElement(J.Radio,{value:h.SheetDrawingAnchorType.None},n.t("drawing-anchor.none"))))))},dt=()=>{const i=q.useDependency(A.IDrawingManagerService),t=i.getFocusDrawings(),[n,e]=N.useState(t);return N.useEffect(()=>{const r=i.focus$.subscribe(o=>{e(o)});return()=>{r.unsubscribe()}},[]),!!(n!=null&&n.length)&&N.createElement("div",{className:Z.imageCommonPanel},N.createElement(Q.DrawingCommonPanel,{drawings:n}),N.createElement(lt,{drawings:n}))},re={id:"sheet.command.move-drawing",type:p.CommandType.COMMAND,handler:(i,t)=>{const n=i.get(p.ICommandService),e=i.get(h.ISheetDrawingService),r=i.get($.ISheetSelectionRenderService),{direction:o}=t,a=e.getFocusDrawings();if(a.length===0)return!1;const s=a[0].unitId,l=a.map(d=>{const{transform:c}=d;if(c==null)return null;const m={...c},{left:g=0,top:S=0}=c;return o===p.Direction.UP?m.top=S-1:o===p.Direction.DOWN?m.top=S+1:o===p.Direction.LEFT?m.left=g-1:o===p.Direction.RIGHT&&(m.left=g+1),{...d,transform:m,sheetTransform:V(m,r)}}).filter(d=>d!=null);return n.syncExecuteCommand(se.id,{unitId:s,drawings:l})?(n.syncExecuteCommand(G.id,[s]),!0):!1}},be={id:"sheet.command.delete-drawing",type:p.CommandType.COMMAND,handler:i=>{const t=i.get(p.ICommandService),e=i.get(h.ISheetDrawingService).getFocusDrawings();if(e.length===0)return!1;const r=e[0].unitId,o=e.map(a=>{const{unitId:s,subUnitId:l,drawingId:u,drawingType:d}=a;return{unitId:s,subUnitId:l,drawingId:u,drawingType:d}});return t.executeCommand(ge.id,{unitId:r,drawings:o})}};function ce(i){return!i.getContextValue(p.FOCUSING_FORMULA_EDITOR)&&!i.getContextValue(p.EDITOR_ACTIVATED)&&i.getContextValue(p.FOCUSING_COMMON_DRAWINGS)}const ut={id:re.id,description:"shortcut.sheet.drawing-move-down",group:"4_sheet-drawing-view",binding:F.KeyCode.ARROW_DOWN,priority:100,preconditions:ce,staticParameters:{direction:p.Direction.DOWN}},mt={id:re.id,description:"shortcut.sheet.drawing-move-up",group:"4_sheet-drawing-view",binding:F.KeyCode.ARROW_UP,priority:100,preconditions:ce,staticParameters:{direction:p.Direction.UP}},gt={id:re.id,description:"shortcut.sheet.drawing-move-left",group:"4_sheet-drawing-view",binding:F.KeyCode.ARROW_LEFT,priority:100,preconditions:ce,staticParameters:{direction:p.Direction.LEFT}},pt={id:re.id,description:"shortcut.sheet.drawing-move-right",group:"4_sheet-drawing-view",binding:F.KeyCode.ARROW_RIGHT,priority:100,preconditions:ce,staticParameters:{direction:p.Direction.RIGHT}},ht={id:be.id,description:"shortcut.sheet.drawing-delete",group:"4_sheet-drawing-view",preconditions:ce,binding:F.KeyCode.DELETE,mac:F.KeyCode.BACKSPACE};var ft=Object.defineProperty,St=Object.getOwnPropertyDescriptor,vt=(i,t,n,e)=>{for(var r=e>1?void 0:e?St(t,n):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(t,n,r):a(r))||r);return e&&r&&ft(t,n,r),r},le=(i,t)=>(n,e)=>t(n,e,i);const wt={};let de=class extends p.Disposable{constructor(i,t,n,e,r,o){super(),this._config=i,this._injector=t,this._componentManager=n,this._menuService=e,this._commandService=r,this._shortcutService=o,this._init()}_initCustomComponents(){const i=this._componentManager;this.disposeWithMe(i.register(Be,je)),this.disposeWithMe(i.register($e,at)),this.disposeWithMe(i.register(Ue,dt))}_initMenus(){const{menu:i={}}=this._config;[st,ct].forEach(t=>{this._menuService.addMenuItem(t(this._injector),i)})}_initCommands(){[oe,ae,fe,ge,se,Me,G,De,Re,Ee,re,be,Te].forEach(i=>this.disposeWithMe(this._commandService.registerCommand(i)))}_initShortcuts(){[ut,mt,gt,pt,ht].forEach(i=>{this.disposeWithMe(this._shortcutService.registerShortcut(i))})}_init(){this._initCommands(),this._initCustomComponents(),this._initMenus(),this._initShortcuts()}};de=vt([p.OnLifecycle(p.LifecycleStages.Rendered,de),le(1,B.Inject(B.Injector)),le(2,B.Inject(F.ComponentManager)),le(3,F.IMenuService),le(4,p.ICommandService),le(5,F.IShortcutService)],de);var _t=Object.defineProperty,It=Object.getOwnPropertyDescriptor,Ct=(i,t,n,e)=>{for(var r=e>1?void 0:e?It(t,n):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(t,n,r):a(r))||r);return e&&r&&_t(t,n,r),r},ie=(i,t)=>(n,e)=>t(n,e,i);const yt=[_.InsertRowCommand.id,_.InsertColCommand.id,_.RemoveRowCommand.id,_.RemoveColCommand.id,_.DeleteRangeMoveLeftCommand.id,_.DeleteRangeMoveUpCommand.id,_.InsertRangeMoveDownCommand.id,_.InsertRangeMoveRightCommand.id,_.DeltaRowHeightCommand.id,_.SetRowHeightCommand.id,_.DeltaColumnWidthCommand.id,_.SetColWidthCommand.id,_.SetRowHiddenCommand.id,_.SetSpecificRowsVisibleCommand.id,_.SetSpecificColsVisibleCommand.id,_.SetColHiddenCommand.id],Mt=[_.SetRowVisibleMutation.id,_.SetRowHiddenMutation.id,_.SetColVisibleMutation.id,_.SetColHiddenMutation.id,_.SetWorksheetRowHeightMutation.id,_.SetWorksheetColWidthMutation.id];let we=class extends p.Disposable{constructor(i,t,n,e,r,o){super(),this._commandService=i,this._sheetInterceptorService=t,this._renderManagerService=n,this._sheetDrawingService=e,this._drawingManagerService=r,this._univerInstanceService=o,this._init()}get _selectionRenderService(){return this._renderManagerService.getRenderById(this._univerInstanceService.getCurrentUnitForType(p.UniverInstanceType.UNIVER_SHEET).getUnitId()).with($.ISheetSelectionRenderService)}get _skeletonManagerService(){return this._renderManagerService.getRenderById(this._univerInstanceService.getCurrentUnitForType(p.UniverInstanceType.UNIVER_SHEET).getUnitId()).with($.SheetSkeletonManagerService)}_init(){this._sheetInterceptorListener(),this._commandListener(),this._sheetRefreshListener()}_sheetInterceptorListener(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:i=>{if(!yt.includes(i.id))return{redos:[],undos:[]};if(i.params==null)return{redos:[],undos:[]};const t=i.id;if(t===_.InsertRowCommand.id)return this._moveRowInterceptor(i.params,"insert");if(t===_.InsertColCommand.id)return this._moveColInterceptor(i.params,"insert");if(t===_.RemoveRowCommand.id)return this._moveRowInterceptor(i.params,"remove");if(t===_.RemoveColCommand.id)return this._moveColInterceptor(i.params,"remove");if(t===_.DeleteRangeMoveLeftCommand.id){const{range:n}=i.params;return this._getRangeMoveUndo(n,0)}else if(t===_.DeleteRangeMoveUpCommand.id){const{range:n}=i.params;return this._getRangeMoveUndo(n,1)}else if(t===_.InsertRangeMoveDownCommand.id){const{range:n}=i.params;return this._getRangeMoveUndo(n,2)}else if(t===_.InsertRangeMoveRightCommand.id){const{range:n}=i.params;return this._getRangeMoveUndo(n,3)}else if(t===_.SetRowHiddenCommand.id||t===_.SetSpecificRowsVisibleCommand.id){const n=i.params,{unitId:e,subUnitId:r,ranges:o}=n;return this._getDrawingUndoForRowVisible(e,r,o)}else if(t===_.SetSpecificColsVisibleCommand.id||t===_.SetColHiddenCommand.id){const n=i.params,{unitId:e,subUnitId:r,ranges:o}=n;return this._getDrawingUndoForColVisible(e,r,o)}else if(t===_.DeltaRowHeightCommand.id||t===_.SetRowHeightCommand.id||t===_.DeltaColumnWidthCommand.id||t===_.SetColWidthCommand.id){const n=i.params,{unitId:e,subUnitId:r,ranges:o}=n,a=t===_.DeltaRowHeightCommand.id||t===_.SetRowHeightCommand.id;return this._getDrawingUndoForRowAndColSize(e,r,o,a)}return{redos:[],undos:[]}}}))}_getRangeMoveUndo(i,t){const n=_.getSheetCommandTarget(this._univerInstanceService);if(n==null)return{redos:[],undos:[]};const e=n.unitId,r=n.subUnitId,o=[],a=[],s=this._sheetDrawingService.getDrawingData(e,r),l=[],u=[];if(Object.keys(s).forEach(d=>{const c=s[d],{updateDrawings:m,deleteDrawings:g}=this._getUpdateOrDeleteDrawings(i,t,c);l.push(...m),u.push(...g)}),l.length===0&&u.length===0)return{redos:[],undos:[]};if(l.length>0){const d=this._sheetDrawingService.getBatchUpdateOp(l),{undo:c,redo:m,objects:g}=d;o.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:r,op:m,objects:g,type:h.DrawingApplyType.UPDATE}}),a.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:r,op:c,objects:g,type:h.DrawingApplyType.UPDATE}})}if(u.length>0){const d=this._sheetDrawingService.getBatchRemoveOp(u),c=d.undo,m=d.redo,g=d.objects;o.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:r,op:m,objects:g,type:h.DrawingApplyType.REMOVE}}),a.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:r,op:c,objects:g,type:h.DrawingApplyType.INSERT}})}return o.push({id:G.id,params:[e]}),a.push({id:G.id,params:[e]}),{redos:o,undos:a}}_getUpdateOrDeleteDrawings(i,t,n){const e=[],r=[],{sheetTransform:o,anchorType:a=h.SheetDrawingAnchorType.Position,transform:s,unitId:l,subUnitId:u,drawingId:d}=n,{from:c,to:m}=o,{row:g,column:S}=c,{row:f,column:v}=m;if(o==null||s==null)return{updateDrawings:e,deleteDrawings:r};const{startRow:y,endRow:M,startColumn:C,endColumn:R}=i;let I=null,O=null;if(t===0&&g>=y&&f<=M)if(S>=C&&v<=R)r.push({unitId:l,subUnitId:u,drawingId:d});else{const w=this._shrinkCol(o,s,C,R,a);I=w==null?void 0:w.newSheetTransform,O=w==null?void 0:w.newTransform}else if(t===1&&S>=C&&v<=R)if(g>=y&&f<=M)r.push({unitId:l,subUnitId:u,drawingId:d});else{const w=this._shrinkRow(o,s,y,M,a);I=w==null?void 0:w.newSheetTransform,O=w==null?void 0:w.newTransform}else if(t===2){const w=this._expandRow(o,s,y,M,a);I=w==null?void 0:w.newSheetTransform,O=w==null?void 0:w.newTransform}else if(t===3){const w=this._expandCol(o,s,C,R,a);I=w==null?void 0:w.newSheetTransform,O=w==null?void 0:w.newTransform}if(I!=null&&O!=null){const w=H(I,this._selectionRenderService,this._skeletonManagerService);e.push({...n,sheetTransform:I,transform:w})}return{updateDrawings:e,deleteDrawings:r}}_remainDrawingSize(i,t,n){const e=V({...i},this._selectionRenderService);e!=null&&t.push({...n,sheetTransform:e})}_getDrawingUndoForColVisible(i,t,n){const e=this._drawingManagerService.getDrawingData(i,t),r=[],o=[];if(Object.keys(e).forEach(d=>{const c=e[d],{sheetTransform:m,transform:g,anchorType:S=h.SheetDrawingAnchorType.Position}=c;if(S===h.SheetDrawingAnchorType.None)this._remainDrawingSize(g,r,c);else{const{from:f,to:v}=m,{row:y,column:M}=f,{row:C,column:R}=v;for(let I=0;I<n.length;I++){const O=n[I],{startRow:w,endRow:U,startColumn:E,endColumn:j}=O;if(R<E)continue;if(S===h.SheetDrawingAnchorType.Position){let D=null,W=null;if(M>=E&&M<=j){const Y=this._skeletonManagerService.attachRangeWithCoord({startColumn:M,endColumn:j,startRow:f.row,endRow:v.row});if(Y==null)return;W={...g,left:Y.startX}}if(W!=null&&(D=V(W,this._selectionRenderService),D!=null&&W!=null)){r.push({...c,sheetTransform:D,transform:W});break}this._remainDrawingSize(g,r,c);continue}if(M>=E&&R<=j)continue;let P=null,b=null;if(M>=E&&M<=j){const D=this._skeletonManagerService.attachRangeWithCoord({startColumn:M,endColumn:j,startRow:f.row,endRow:v.row});if(D==null)return;b={...g,left:(D==null?void 0:D.startX)||0,width:((g==null?void 0:g.width)||0)-D.endX+D.startX}}else if(R>=E&&R<=j){const D=this._skeletonManagerService.attachRangeWithCoord({startColumn:E,endColumn:R,startRow:f.row,endRow:v.row});if(D==null)return;b={...g,left:D.startX-((g==null?void 0:g.width)||0)}}else{const D=this._skeletonManagerService.attachRangeWithCoord({startColumn:E,endColumn:j,startRow:f.row,endRow:v.row});if(D==null)return;if(b={...g,width:((g==null?void 0:g.width)||0)-D.endX+D.startX},P=V(b,this._selectionRenderService),P!=null&&b!=null){o.push({...c,sheetTransform:P,transform:b});break}}if(b!=null&&(P=V(b,this._selectionRenderService)),b!=null&&P!=null){r.push({...c,sheetTransform:P,transform:b});break}else this._remainDrawingSize(g,r,c)}}}),r.length===0&&o.length===0)return{redos:[],undos:[]};const{redos:a,undos:s}=this._createUndoAndRedoMutation(i,t,r),l=[],u=[];if(o.length>0){const{redos:d,undos:c}=this._createUndoAndRedoMutation(i,t,o);l.push(...d),u.push(...c)}return{redos:a,undos:s,preRedos:l,preUndos:u}}_createUndoAndRedoMutation(i,t,n){const e=this._sheetDrawingService.getBatchUpdateOp(n),{undo:r,redo:o,objects:a}=e,s=[{id:h.SetDrawingApplyMutation.id,params:{unitId:i,subUnitId:t,op:o,objects:a,type:h.DrawingApplyType.UPDATE}},{id:G.id,params:[i]}],l=[{id:h.SetDrawingApplyMutation.id,params:{unitId:i,subUnitId:t,op:r,objects:a,type:h.DrawingApplyType.UPDATE}},{id:G.id,params:[i]}];return{redos:s,undos:l}}_getDrawingUndoForRowVisible(i,t,n){const e=this._drawingManagerService.getDrawingData(i,t),r=[],o=[];if(Object.keys(e).forEach(d=>{const c=e[d],{sheetTransform:m,transform:g,anchorType:S=h.SheetDrawingAnchorType.Position}=c;if(S===h.SheetDrawingAnchorType.None)this._remainDrawingSize(g,r,c);else{const{from:f,to:v}=m,{row:y,column:M}=f,{row:C,column:R}=v;for(let I=0;I<n.length;I++){const O=n[I],{startRow:w,endRow:U,startColumn:E,endColumn:j}=O;if(C<w)continue;if(S===h.SheetDrawingAnchorType.Position){let D=null,W=null;if(y>=w&&y<=U){const Y=this._skeletonManagerService.attachRangeWithCoord({startColumn:f.column,endColumn:v.column,startRow:y,endRow:U});if(Y==null)return;W={...g,top:Y.startY}}if(W!=null&&(D=V(W,this._selectionRenderService),D!=null&&W!=null)){r.push({...c,sheetTransform:D,transform:W});break}this._remainDrawingSize(g,r,c);continue}if(y>=w&&C<=U)continue;let P=null,b=null;if(y>=w&&y<=U){const D=this._skeletonManagerService.attachRangeWithCoord({startColumn:f.column,endColumn:v.column,startRow:y,endRow:U});if(D==null)return;b={...g,top:(D==null?void 0:D.startY)||0,height:((g==null?void 0:g.height)||0)-D.endY+D.startY}}else if(C>=w&&C<=U){const D=this._skeletonManagerService.attachRangeWithCoord({startColumn:f.column,endColumn:v.column,startRow:w,endRow:C});if(D==null)return;b={...g,top:D.startY-((g==null?void 0:g.height)||0)}}else{const D=this._skeletonManagerService.attachRangeWithCoord({startColumn:f.column,endColumn:v.column,startRow:w,endRow:U});if(D==null)return;if(b={...g,height:((g==null?void 0:g.height)||0)-D.endY+D.startY},P=V(b,this._selectionRenderService),P!=null&&b!=null){o.push({...c,sheetTransform:P,transform:b});break}}if(b!=null&&(P=V(b,this._selectionRenderService)),b!=null&&P!=null){r.push({...c,sheetTransform:P,transform:b});break}else this._remainDrawingSize(g,r,c)}}}),r.length===0&&o.length===0)return{redos:[],undos:[]};const{redos:a,undos:s}=this._createUndoAndRedoMutation(i,t,r),l=[],u=[];if(o.length>0){const{redos:d,undos:c}=this._createUndoAndRedoMutation(i,t,o);l.push(...d),u.push(...c)}return{redos:a,undos:s,preRedos:l,preUndos:u}}_getDrawingUndoForRowAndColSize(i,t,n,e){const r=this._drawingManagerService.getDrawingData(i,t),o=[];return Object.keys(r).forEach(a=>{const s=r[a],{sheetTransform:l,transform:u,anchorType:d=h.SheetDrawingAnchorType.Position}=s;if(d===h.SheetDrawingAnchorType.None)this._remainDrawingSize(u,o,s);else{const{from:c,to:m}=l,{row:g,column:S}=c,{row:f,column:v}=m;for(let y=0;y<n.length;y++){const M=n[y],{startRow:C,endRow:R,startColumn:I,endColumn:O}=M;if(f<C||v<I)continue;if(d===h.SheetDrawingAnchorType.Position&&(g<=C&&f>=R||S<=I&&v>=O)){this._remainDrawingSize(u,o,s);continue}const w=H({...l},this._selectionRenderService,this._skeletonManagerService);if(w!=null){o.push({...s,transform:w});break}}}}),o.length===0?{redos:[],undos:[]}:this._createUndoAndRedoMutation(i,t,o)}_getUnitIdAndSubUnitId(i,t){let n,e;if(t==="insert")n=i.unitId,e=i.subUnitId;else{const r=_.getSheetCommandTarget(this._univerInstanceService);if(r==null)return;n=r.unitId,e=r.subUnitId}return{unitId:n,subUnitId:e}}_moveRowInterceptor(i,t){const n=this._getUnitIdAndSubUnitId(i,t);if(n==null)return{redos:[],undos:[]};const{unitId:e,subUnitId:r}=n,{range:o}=i,a=o.startRow,s=o.endRow,l=[],u=[],d=this._sheetDrawingService.getDrawingData(e,r),c=[],m=[];if(Object.keys(d).forEach(g=>{const S=d[g],{sheetTransform:f,transform:v,anchorType:y=h.SheetDrawingAnchorType.Position}=S;if(f==null||v==null)return;let M,C;if(t==="insert"){const I=this._expandRow(f,v,a,s,y);M=I==null?void 0:I.newSheetTransform,C=I==null?void 0:I.newTransform}else{const{from:I,to:O}=f,{row:w}=I,{row:U}=O;if(w>=a&&U<=s)m.push({unitId:e,subUnitId:r,drawingId:g});else{const E=this._shrinkRow(f,v,a,s,y);M=E==null?void 0:E.newSheetTransform,C=E==null?void 0:E.newTransform}}if(!M||!C)return;const R={unitId:e,subUnitId:r,drawingId:g,transform:C,sheetTransform:M};c.push(R)}),c.length===0&&m.length===0)return{redos:[],undos:[]};if(c.length>0){const g=this._sheetDrawingService.getBatchUpdateOp(c),{undo:S,redo:f,objects:v}=g;l.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:r,op:f,objects:v,type:h.DrawingApplyType.UPDATE}}),u.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:r,op:S,objects:v,type:h.DrawingApplyType.UPDATE}})}if(m.length>0){const g=this._sheetDrawingService.getBatchRemoveOp(m),S=g.undo,f=g.redo,v=g.objects;l.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:r,op:f,objects:v,type:h.DrawingApplyType.REMOVE}}),u.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:r,op:S,objects:v,type:h.DrawingApplyType.INSERT}})}return l.push({id:G.id,params:[e]}),u.push({id:G.id,params:[e]}),{redos:l,undos:u}}_moveColInterceptor(i,t){const n=this._getUnitIdAndSubUnitId(i,t);if(n==null)return{redos:[],undos:[]};const{unitId:e,subUnitId:r}=n,{range:o}=i,a=o.startColumn,s=o.endColumn,l=[],u=[],d=this._sheetDrawingService.getDrawingData(e,r),c=[],m=[];if(Object.keys(d).forEach(g=>{const S=d[g],{sheetTransform:f,transform:v,anchorType:y=h.SheetDrawingAnchorType.Position}=S;if(f==null||v==null)return;let M,C;if(t==="insert"){const I=this._expandCol(f,v,a,s,y);M=I==null?void 0:I.newSheetTransform,C=I==null?void 0:I.newTransform}else{const{from:I,to:O}=f,{column:w}=I,{column:U}=O;if(w>=a&&U<=s)m.push({unitId:e,subUnitId:r,drawingId:g});else{const E=this._shrinkCol(f,v,a,s,y);M=E==null?void 0:E.newSheetTransform,C=E==null?void 0:E.newTransform}}if(!M||!C)return;const R={unitId:e,subUnitId:r,drawingId:g,transform:C,sheetTransform:M};c.push(R)}),c.length===0&&m.length===0)return{redos:[],undos:[]};if(c.length>0){const g=this._sheetDrawingService.getBatchUpdateOp(c),{undo:S,redo:f,objects:v}=g;l.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:r,op:f,objects:v,type:h.DrawingApplyType.UPDATE}}),u.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:r,op:S,objects:v,type:h.DrawingApplyType.UPDATE}})}if(m.length>0){const g=this._sheetDrawingService.getBatchRemoveOp(m),S=g.undo,f=g.redo,v=g.objects;l.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:r,op:f,objects:v,type:h.DrawingApplyType.REMOVE}}),u.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:r,op:S,objects:v,type:h.DrawingApplyType.INSERT}})}return l.push({id:G.id,params:[e]}),u.push({id:G.id,params:[e]}),{redos:l,undos:u}}_expandCol(i,t,n,e,r=h.SheetDrawingAnchorType.Position){const o=e-n+1,{from:a,to:s}=i,{column:l}=a,{column:u}=s;if(r===h.SheetDrawingAnchorType.None)return{newSheetTransform:V({...t},this._selectionRenderService),newTransform:t};let d=null,c=null;if(l>=n){const m=this._skeletonManagerService.attachRangeWithCoord({startColumn:n,endColumn:e,startRow:a.row,endRow:s.row});if(m==null)return;c={...t,left:(t.left||0)+m.endX-m.startX},d=V(c,this._selectionRenderService)}else if(u>=e)if(r===h.SheetDrawingAnchorType.Both)d={from:{...a},to:{...s,column:u+o}},c=H(d,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:V({...t},this._selectionRenderService),newTransform:t};return d!=null&&c!=null?{newSheetTransform:d,newTransform:c}:null}_shrinkCol(i,t,n,e,r=h.SheetDrawingAnchorType.Position){const o=e-n+1,{from:a,to:s}=i,{column:l}=a,{column:u}=s;if(r===h.SheetDrawingAnchorType.None)return{newSheetTransform:V({...t},this._selectionRenderService),newTransform:t};let d=null,c=null;if(l>e)d={from:{...a,column:l-o},to:{...s,column:u-o}},c=H(d,this._selectionRenderService,this._skeletonManagerService);else{if(l>=n&&u<=e)return null;if(l<n&&u>e)if(r===h.SheetDrawingAnchorType.Both)d={from:{...a},to:{...s,column:u-o}},c=H(d,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:V({...t},this._selectionRenderService),newTransform:t};else if(l>=n&&l<=e){if(l===n)c={...t,left:(t.left||0)-i.from.columnOffset};else{const m=this._skeletonManagerService.attachRangeWithCoord({startColumn:n,endColumn:l-1,startRow:a.row,endRow:s.row});if(m==null)return;c={...t,left:(t.left||0)-m.endX+m.startX-i.from.columnOffset}}d=V(c,this._selectionRenderService)}else if(u>=n&&u<=e&&r===h.SheetDrawingAnchorType.Both){const m=this._skeletonManagerService.attachRangeWithCoord({startColumn:n-1,endColumn:n-1,startRow:a.row,endRow:s.row});if(m==null)return;d={from:{...a},to:{...s,column:n-1,columnOffset:m.endX-m.startX}},c=H(d,this._selectionRenderService,this._skeletonManagerService)}}return d!=null&&c!=null?{newSheetTransform:d,newTransform:c}:null}_expandRow(i,t,n,e,r=h.SheetDrawingAnchorType.Position){const o=e-n+1,{from:a,to:s}=i,{row:l}=a,{row:u}=s;if(r===h.SheetDrawingAnchorType.None)return{newSheetTransform:V({...t},this._selectionRenderService),newTransform:t};let d=null,c=null;if(l>=n){const m=this._skeletonManagerService.attachRangeWithCoord({startRow:n,endRow:e,startColumn:a.column,endColumn:s.column});if(m==null)return;c={...t,top:(t.top||0)+m.endY-m.startY},d=V(c,this._selectionRenderService)}else if(u>=e)if(r===h.SheetDrawingAnchorType.Both)d={from:{...a},to:{...s,row:u+o}},c=H(d,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:V({...t},this._selectionRenderService),newTransform:t};return d!=null&&c!=null?{newSheetTransform:d,newTransform:c}:null}_shrinkRow(i,t,n,e,r=h.SheetDrawingAnchorType.Position){const o=e-n+1,{from:a,to:s}=i,{row:l}=a,{row:u}=s;if(r===h.SheetDrawingAnchorType.None)return{newSheetTransform:V({...t},this._selectionRenderService),newTransform:t};let d=null,c=null;if(l>e)d={from:{...a,row:l-o},to:{...s,row:u-o}},c=H(d,this._selectionRenderService,this._skeletonManagerService);else{if(l>=n&&u<=e)return null;if(l<n&&u>e)if(r===h.SheetDrawingAnchorType.Both)d={from:{...a},to:{...s,row:u-o}},c=H(d,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:V({...t},this._selectionRenderService),newTransform:t};else if(l>=n&&l<=e){if(l===n)c={...t,top:(t.top||0)-i.from.rowOffset};else{const m=this._skeletonManagerService.attachRangeWithCoord({startRow:n,endRow:l-1,startColumn:a.column,endColumn:s.column});if(m==null)return;c={...t,top:(t.top||0)-m.endY+m.startY-i.from.rowOffset}}d=V(c,this._selectionRenderService)}else if(u>=n&&u<=e&&r===h.SheetDrawingAnchorType.Both){const m=this._skeletonManagerService.attachRangeWithCoord({startColumn:a.column,endColumn:a.column,startRow:n-1,endRow:n-1});if(m==null)return;d={from:{...a},to:{...s,row:n-1,rowOffset:m.endY-m.startY}},c=H(d,this._selectionRenderService,this._skeletonManagerService)}}return d!=null&&c!=null?{newSheetTransform:d,newTransform:c}:null}_commandListener(){this.disposeWithMe(this._commandService.onCommandExecuted(i=>{i.id===_.SetWorksheetActiveOperation.id&&setTimeout(()=>{const t=i.params,{unitId:n,subUnitId:e}=t,r=this._drawingManagerService.drawingManagerData,o=[],a=[];Object.keys(r).forEach(s=>{const l=r[s];Object.keys(l).forEach(u=>{const d=l[u].data;d!=null&&Object.keys(d).forEach(c=>{if(s===n&&u===e){const m=d[c];m.transform=H(m.sheetTransform,this._selectionRenderService,this._skeletonManagerService),o.push(d[c])}else a.push(d[c])})})}),this._drawingManagerService.removeNotification(a),this._drawingManagerService.addNotification(o)},0)}))}_sheetRefreshListener(){this.disposeWithMe(this._commandService.onCommandExecuted(i=>{Mt.includes(i.id)&&requestIdleCallback(()=>{const t=i.params,{unitId:n,subUnitId:e,ranges:r}=t;this._refreshDrawingTransform(n,e,r)})}))}_refreshDrawingTransform(i,t,n){const e=this._drawingManagerService.getDrawingData(i,t),r=[];Object.keys(e).forEach(o=>{const a=e[o],{sheetTransform:s,anchorType:l=h.SheetDrawingAnchorType.Position}=a;if(l===h.SheetDrawingAnchorType.None)return!0;const{from:u,to:d}=s,{row:c,column:m}=u,{row:g,column:S}=d;for(let f=0;f<n.length;f++){const v=n[f],{startRow:y,endRow:M,startColumn:C,endColumn:R}=v;if(p.Rectangle.intersects({startRow:y,endRow:M,startColumn:C,endColumn:R},{startRow:c,endRow:g,startColumn:m,endColumn:S})||c>M||m>R){r.push({...a,transform:H(s,this._selectionRenderService,this._skeletonManagerService)});break}}}),r.length!==0&&(this._drawingManagerService.refreshTransform(r),this._commandService.syncExecuteCommand(G.id,[i]))}};we=Ct([p.OnLifecycle(p.LifecycleStages.Rendered,we),ie(0,p.ICommandService),ie(1,B.Inject(_.SheetInterceptorService)),ie(2,L.IRenderManagerService),ie(3,h.ISheetDrawingService),ie(4,A.IDrawingManagerService),ie(5,p.IUniverInstanceService)],we);var Dt=Object.defineProperty,Tt=Object.getOwnPropertyDescriptor,Rt=(i,t,n,e)=>{for(var r=e>1?void 0:e?Tt(t,n):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(t,n,r):a(r))||r);return e&&r&&Dt(t,n,r),r},te=(i,t)=>(n,e)=>t(n,e,i);function Et(i,t,n,e){const{scaleX:r,scaleY:o}=t.getAncestorScale(),a=t.getViewport(L.SHEET_VIEWPORT_KEY.VIEW_MAIN),s={left:!0,top:!0};if(!a)return{...i,absolute:s};const{left:l,right:u,top:d,bottom:c}=i,m=e.getFreeze(),{startColumn:g,startRow:S,xSplit:f,ySplit:v}=m,y=n.getNoMergeCellPositionByIndexWithNoHeader(S-v,g-f),M=n.getNoMergeCellPositionByIndexWithNoHeader(S,g),{rowHeaderWidth:C,columnHeaderHeight:R}=n,I=M.startX-y.startX,O=M.startY-y.startY,{top:w,left:U,viewportScrollX:E,viewportScrollY:j}=a;let P,b;l<U?(s.left=!0,P=(I+C+(l-U))*r,b=Math.max(Math.min((I+C+(u-U))*r,(I+C)*r),(u-E)*r)):(s.left=!1,P=Math.max((l-E)*r,(I+C)*r),b=Math.max((u-E)*r,(I+C)*r));let D,W;return d<w?(s.top=!0,D=(O+R+(d-w))*o,W=Math.max(Math.min((O+R+(u-w))*o,(O+R)*o),(c-j)*o)):(s.top=!1,D=Math.max((d-j)*o,(O+R)*o),W=Math.max((c-j)*o,(O+R)*o)),{left:P,right:b,top:D,bottom:W,absolute:s}}const Oe=(i,t,n,e)=>{const{scene:r}=t,{left:o,top:a,width:s,height:l,angle:u}=i,d={left:o,right:o+s,top:a,bottom:a+l},c=Et(d,r,n,e);return{startX:c.left,endX:c.right,startY:c.top,endY:c.bottom,rotate:u,width:s,height:l,absolute:c.absolute}};T.SheetCanvasFloatDomManagerService=class extends p.Disposable{constructor(n,e,r,o,a,s,l){super();z(this,"_domLayerMap",new Map);z(this,"_domLayerInfoMap",new Map);z(this,"_transformChange$",new k.Subject);z(this,"transformChange$",this._transformChange$.asObservable());z(this,"_remove$",new k.Subject);z(this,"remove$",this._remove$.asObservable());this._renderManagerService=n,this._univerInstanceService=e,this._commandService=r,this._drawingManagerService=o,this._selectionRenderService=a,this._canvasFloatDomService=s,this._sheetDrawingService=l,this._drawingAddListener(),this._scrollUpdateListener(),this._featureUpdateListener(),this._deleteListener()}_ensureMap(n,e){let r=this._domLayerMap.get(n);r||(r=new Map,this._domLayerMap.set(n,r));let o=r.get(e);return o||(o=new Map,r.set(e,o)),o}_getSceneAndTransformerByDrawingSearch(n){if(n==null)return;const e=this._renderManagerService.getRenderById(n),r=e==null?void 0:e.scene;if(e==null||r==null)return null;const o=r.getTransformerByCreate(),a=e.engine.getCanvasElement();return{scene:r,transformer:o,renderObject:e,canvas:a}}_drawingAddListener(){this.disposeWithMe(this._drawingManagerService.add$.subscribe(n=>{n.forEach(e=>{var He,Ye;const{unitId:r,subUnitId:o,drawingId:a}=e,s=_.getSheetCommandTarget(this._univerInstanceService,{unitId:r,subUnitId:o}),l=this._drawingManagerService.getDrawingByParam(e),u=(He=this._renderManagerService.getRenderById(r))==null?void 0:He.with($.SheetSkeletonManagerService).getWorksheetSkeleton(o);if(l==null||s==null||u==null)return;const{transform:d,drawingType:c}=l;if(c!==p.DrawingTypeEnum.DRAWING_DOM)return;const m=this._getSceneAndTransformerByDrawingSearch(r);if(m==null)return;const{scene:g,canvas:S}=m;if(d==null)return!0;const{left:f,top:v,width:y,height:M,angle:C,flipX:R,flipY:I,skewX:O,skewY:w}=d,U=A.getDrawingShapeKeyByDrawingSearch({unitId:r,subUnitId:o,drawingId:a}),E=g.getObject(U);if(E!=null){E.transformByState({left:f,top:v,width:y,height:M,angle:C,flipX:R,flipY:I,skewX:O,skewY:w});return}const j={left:f,top:v,width:y,height:M,zIndex:this._drawingManagerService.getDrawingOrder(r,o).length-1},P=new L.Rect(U,j);g.addObject(P,L.DRAWING_OBJECT_LAYER_INDEX).attachTransformerTo(P);const b=this._ensureMap(r,o),D=new p.DisposableCollection,W=Oe(P,m.renderObject,u.skeleton,s.worksheet),Y=new k.BehaviorSubject(W),ne={dispose:D,rect:P,position$:Y,unitId:r,subUnitId:o};this._canvasFloatDomService.addFloatDom({position$:Y,id:a,componentKey:l.componentKey,onPointerDown:X=>{S.dispatchEvent(new PointerEvent(X.type,X))},onPointerMove:X=>{S.dispatchEvent(new PointerEvent(X.type,X))},onPointerUp:X=>{S.dispatchEvent(new PointerEvent(X.type,X))},onWheel:X=>{S.dispatchEvent(new WheelEvent(X.type,X))},props:(Ye=b.get(a))==null?void 0:Ye.props});const ke=P.onTransformChange$.subscribeEvent(()=>{const X=Oe(P,m.renderObject,u.skeleton,s.worksheet);Y.next(X)});D.add(()=>{this._canvasFloatDomService.removeFloatDom(a)}),ke&&D.add(ke),this._domLayerInfoMap.set(a,ne)})}))}_scrollUpdateListener(){this.disposeWithMe(this._commandService.onCommandExecuted(n=>{var r,o;const e=(a,s)=>{var g;const l=this._getSceneAndTransformerByDrawingSearch(a),u=this._ensureMap(a,s),d=Array.from(u.keys()),c=_.getSheetCommandTarget(this._univerInstanceService,{unitId:a,subUnitId:s}),m=(g=this._renderManagerService.getRenderById(a))==null?void 0:g.with($.SheetSkeletonManagerService).getWorksheetSkeleton(s);!l||!c||!m||d.forEach(S=>{const f=this._domLayerInfoMap.get(S);if(f){const v=Oe(f.rect,l.renderObject,m.skeleton,c.worksheet);f.position$.next(v)}})};if(n.id===$.SetScrollOperation.id){const a=n.params,{unitId:s,sheetId:l}=a;e(s,l)}else if(n.id===$.SetZoomRatioOperation.id){const a=n.params,{unitId:s}=a;Array.from((o=(r=this._domLayerMap.get(s))==null?void 0:r.keys())!=null?o:[]).forEach(u=>{e(s,u)})}else if(n.id===_.SetFrozenMutation.id){const{unitId:a,subUnitId:s}=n.params;e(a,s)}}))}_getPosition(n){const{startX:e,endX:r,startY:o,endY:a}=n,s=this._selectionRenderService.getSelectionCellByPosition(e,o);if(s==null)return;const l={column:s.actualColumn,columnOffset:e-s.startX,row:s.actualRow,rowOffset:o-s.startY},u=this._selectionRenderService.getSelectionCellByPosition(r,a);if(u==null)return;const d={column:u.actualColumn,columnOffset:r-u.startX,row:u.actualRow,rowOffset:a-u.startY};return{from:l,to:d}}_featureUpdateListener(){this.disposeWithMe(this._drawingManagerService.update$.subscribe(n=>{n.forEach(e=>{const r=this._drawingManagerService.getDrawingByParam(e);if(!r||r.drawingType!==p.DrawingTypeEnum.DRAWING_DOM)return;const o={...r.transform};this._transformChange$.next({id:e.drawingId,value:o})})}))}_deleteListener(){this.disposeWithMe(this._drawingManagerService.remove$.subscribe(n=>{n.forEach(e=>{this._removeDom(e.drawingId)})}))}addFloatDomToPosition(n){const e=_.getSheetCommandTarget(this._univerInstanceService,{unitId:n.unitId,subUnitId:n.subUnitId});if(!e)throw new Error("cannot find current target!");const{unitId:r,subUnitId:o}=e,{initPosition:a,componentKey:s}=n,l=p.Tools.generateRandomId(),u=this._getPosition(a);if(u==null)return;this._ensureMap(r,o).set(l,n);const c={unitId:r,subUnitId:o,drawingId:l,drawingType:p.DrawingTypeEnum.DRAWING_DOM,componentKey:s,sheetTransform:u,transform:{left:a.startX,top:a.startY,width:a.endX-a.startX,height:a.endY-a.startY}};return this._commandService.executeCommand(fe.id,{unitId:r,drawings:[c]}),{id:l,dispose:()=>{this._removeDom(l,!0)}}}_removeDom(n,e=!1){const r=this._domLayerInfoMap.get(n);if(!r)return;const{unitId:o,subUnitId:a}=r;this._domLayerInfoMap.delete(n),r.dispose.dispose();const s=this._getSceneAndTransformerByDrawingSearch(o);if(s&&s.scene.removeObject(r.rect),e){this._ensureMap(o,a).delete(n);const u=this._drawingManagerService.getDrawingByParam({unitId:o,subUnitId:a,drawingId:n});if(!u)return;const d=this._sheetDrawingService.getBatchRemoveOp([u]),{redo:c,objects:m}=d;this._commandService.syncExecuteCommand(h.SetDrawingApplyMutation.id,{unitId:o,subUnitId:a,op:c,objects:m,type:h.DrawingApplyType.REMOVE})}}},T.SheetCanvasFloatDomManagerService=Rt([te(0,B.Inject(L.IRenderManagerService)),te(1,p.IUniverInstanceService),te(2,B.Inject(p.ICommandService)),te(3,A.IDrawingManagerService),te(4,$.ISheetSelectionRenderService),te(5,B.Inject(F.CanvasFloatDomService)),te(6,h.ISheetDrawingService)],T.SheetCanvasFloatDomManagerService);var bt=Object.defineProperty,Ot=Object.getOwnPropertyDescriptor,Pt=(i,t,n,e)=>{for(var r=e>1?void 0:e?Ot(t,n):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(t,n,r):a(r))||r);return e&&r&&bt(t,n,r),r},_e=(i,t)=>(n,e)=>t(n,e,i);let Ie=class extends p.Disposable{constructor(i,t,n,e){super(),this._sheetPrintInterceptorService=i,this._drawingRenderService=t,this._drawingManagerService=n,this._renderManagerService=e,this._initPrinting()}_initPrinting(){this.disposeWithMe(this._sheetPrintInterceptorService.interceptor.intercept(this._sheetPrintInterceptorService.interceptor.getInterceptPoints().PRINTING_COMPONENT_COLLECT,{handler:(i,t,n)=>{const{unitId:e,scene:r,subUnitId:o}=t,a=this._drawingManagerService.getDrawingDataForUnit(e),s=a==null?void 0:a[o];return s&&s.order.forEach(l=>{this._drawingRenderService.renderDrawing(s.data[l],r)}),n()}})),this.disposeWithMe(this._sheetPrintInterceptorService.interceptor.intercept(this._sheetPrintInterceptorService.interceptor.getInterceptPoints().PRINTING_RANGE,{handler:(i,t,n)=>{const{unitId:e,subUnitId:r}=t,o=this._renderManagerService.getRenderById(e);if(!o)return n(i);const a=o.with($.SheetSkeletonManagerService).getWorksheetSkeleton(r);if(!a)return n(i);const s=this._drawingManagerService.getDrawingDataForUnit(e),l=s==null?void 0:s[t.subUnitId];if(!l)return n(i);const{scaleX:u,scaleY:d}=o.scene,c=i?{...i}:{startColumn:0,endColumn:0,endRow:0,startRow:0},m=l.order.map(g=>l.data[g]).filter(g=>g.drawingType!==A.DrawingTypeEnum.DRAWING_DOM);return m.length?(m.forEach(g=>{if(!g.groupId&&g.transform&&p.Tools.isDefine(g.transform.left)&&p.Tools.isDefine(g.transform.top)&&p.Tools.isDefine(g.transform.width)&&p.Tools.isDefine(g.transform.height)){const S=a.skeleton.getCellPositionByOffset(g.transform.left,g.transform.top,u,d,{x:0,y:0}),f=a.skeleton.getCellPositionByOffset(g.transform.left+g.transform.width,g.transform.top+g.transform.height,u,d,{x:0,y:0});S.column<c.startColumn&&(c.startColumn=S.column),S.row<c.startRow&&(c.startRow=S.row),c.endRow<f.row&&(c.endRow=f.row),c.endColumn<f.column&&(c.endColumn=f.column)}}),n(c)):n(i)}}))}};Ie=Pt([p.OnLifecycle(p.LifecycleStages.Rendered,Ie),_e(0,B.Inject($.SheetPrintInterceptorService)),_e(1,B.Inject(Q.DrawingRenderService)),_e(2,A.IDrawingManagerService),_e(3,L.IRenderManagerService)],Ie);var At=Object.defineProperty,Ut=Object.getOwnPropertyDescriptor,Nt=(i,t,n,e)=>{for(var r=e>1?void 0:e?Ut(t,n):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(t,n,r):a(r))||r);return e&&r&&At(t,n,r),r},ue=(i,t)=>(n,e)=>t(n,e,i);let Ce=class extends p.Disposable{constructor(i,t,n,e,r){super(),this._drawingManagerService=i,this._renderManagerService=t,this._permissionService=n,this._univerInstanceService=e,this._userManagerService=r,this._initDrawingVisible(),this._initDrawingEditable(),this._initViewPermissionChange(),this._initEditPermissionChange()}_initDrawingVisible(){const i=this._univerInstanceService.getCurrentTypeOfUnit$(p.UniverInstanceType.UNIVER_SHEET);this.disposeWithMe(k.combineLatest([i,this._userManagerService.currentUser$]).subscribe(([t,n])=>{if(!t){this._drawingManagerService.setDrawingVisible(!1);return}t.activeSheet$.subscribe(e=>{if(!e){this._drawingManagerService.setDrawingVisible(!1);return}const r=t.getUnitId(),o=e.getSheetId();if(this._permissionService.composePermission([new _.WorkbookViewPermission(r).id,new _.WorksheetViewPermission(r,o).id]).every(s=>s.value))this._drawingManagerService.setDrawingVisible(!0);else{this._drawingManagerService.setDrawingVisible(!1);const s=t.getUnitId(),l=e.getSheetId(),u=this._drawingManagerService.getDrawingData(s,l),d=Object.values(u),c=this._renderManagerService.getRenderById(s),m=c==null?void 0:c.scene;if(m==null)return;m.getAllObjects().forEach(S=>{S.classType===L.RENDER_CLASS_TYPE.IMAGE&&d.some(f=>S.oKey.includes(f.drawingId))&&m.removeObject(S)})}})}))}_initDrawingEditable(){const i=this._univerInstanceService.getCurrentTypeOfUnit$(p.UniverInstanceType.UNIVER_SHEET);this.disposeWithMe(k.combineLatest([i,this._userManagerService.currentUser$]).subscribe(([t,n])=>{if(!t){this._drawingManagerService.setDrawingEditable(!1);return}t.activeSheet$.subscribe(e=>{if(!e){this._drawingManagerService.setDrawingEditable(!1);return}const r=t.getUnitId(),o=e.getSheetId();if(this._permissionService.composePermission([new _.WorkbookEditablePermission(r).id,new _.WorksheetEditPermission(r,o).id]).every(s=>s.value))this._drawingManagerService.setDrawingEditable(!0);else{this._drawingManagerService.setDrawingEditable(!1);const s=t.getUnitId(),l=e.getSheetId(),u=this._drawingManagerService.getDrawingData(s,l),d=Object.values(u),c=this._renderManagerService.getRenderById(s),m=c==null?void 0:c.scene;if(m==null)return;m.getAllObjects().forEach(S=>{S.classType===L.RENDER_CLASS_TYPE.IMAGE&&d.some(f=>S.oKey.includes(f.drawingId))&&m.detachTransformerFrom(S)})}})}))}_initViewPermissionChange(){const i=this._univerInstanceService.getCurrentTypeOfUnit$(p.UniverInstanceType.UNIVER_SHEET);this.disposeWithMe(k.combineLatest([i,this._userManagerService.currentUser$]).subscribe(([t,n])=>{t&&t.activeSheet$.subscribe(e=>{var c;if(!e)return;const r=t.getUnitId(),o=e.getSheetId();let a=!0;const s=this._renderManagerService.getRenderById(r),l=s==null?void 0:s.scene;if(l==null)return;const u=l.getTransformerByCreate(),d=this._permissionService.composePermission$([new _.WorkbookViewPermission(r).id,new _.WorksheetViewPermission(r,o).id]).pipe(k.map(m=>m.every(g=>g.value)));d==null||d.pipe(k.filter(m=>m!==a),k.distinctUntilChanged()).subscribe({next:m=>{a=m,this._drawingManagerService.setDrawingVisible(m);const g=l.getAllObjects(),S=this._drawingManagerService.getDrawingData(r,o),f=Object.values(S);m?this._drawingManagerService.addNotification(f):(g.forEach(v=>{v.classType===L.RENDER_CLASS_TYPE.IMAGE&&f.some(y=>v.oKey.includes(y.drawingId))&&l.removeObject(v)}),u.clearSelectedObjects())}}),(c=this._permissionService.getPermissionPoint$(new _.WorksheetViewPermission(r,o).id))==null||c.pipe(k.filter(m=>m.value!==a),k.distinctUntilChanged()).subscribe({complete:()=>{a=!0,this._drawingManagerService.setDrawingVisible(!0);const m=this._drawingManagerService.getDrawingData(r,o),g=Object.values(m);this._drawingManagerService.addNotification(g)}})})}))}_initEditPermissionChange(){const i=this._univerInstanceService.getCurrentTypeOfUnit$(p.UniverInstanceType.UNIVER_SHEET);this.disposeWithMe(k.combineLatest([i,this._userManagerService.currentUser$]).subscribe(([t,n])=>{t&&t.activeSheet$.subscribe(e=>{var c;if(!e)return;const r=t.getUnitId(),o=e.getSheetId();let a=!0;const s=this._renderManagerService.getRenderById(r),l=s==null?void 0:s.scene;if(l==null)return;const u=l.getTransformerByCreate(),d=this._permissionService.composePermission$([new _.WorkbookEditablePermission(r).id,new _.WorksheetEditPermission(r,o).id]).pipe(k.map(m=>m.every(g=>g.value)));d==null||d.pipe(k.filter(m=>m!==a),k.distinctUntilChanged()).subscribe({next:m=>{a=m,this._drawingManagerService.setDrawingEditable(m);const g=l.getAllObjects(),S=this._drawingManagerService.getDrawingData(r,o),f=Object.values(S);m?(g.forEach(v=>{v.classType===L.RENDER_CLASS_TYPE.IMAGE&&f.some(y=>v.oKey.includes(y.drawingId))&&l.attachTransformerTo(v)}),this._drawingManagerService.addNotification(f)):(g.forEach(v=>{v.classType===L.RENDER_CLASS_TYPE.IMAGE&&f.some(y=>v.oKey.includes(y.drawingId))&&l.detachTransformerFrom(v)}),u.clearSelectedObjects())}}),(c=this._permissionService.getPermissionPoint$(new _.WorksheetEditPermission(r,o).id))==null||c.pipe(k.filter(m=>m.value!==a),k.distinctUntilChanged()).subscribe({complete:()=>{a=!0;const m=t.getUnitId(),g=e.getSheetId(),S=this._drawingManagerService.getDrawingData(m,g),f=Object.values(S),v=this._renderManagerService.getRenderById(m),y=v==null?void 0:v.scene;if(y==null)return;this._drawingManagerService.setDrawingEditable(!0),y.getAllObjects().forEach(C=>{C.classType===L.RENDER_CLASS_TYPE.IMAGE&&f.some(R=>C.oKey.includes(R.drawingId))&&y.detachTransformerFrom(C)})}})})}))}};Ce=Nt([p.OnLifecycle(p.LifecycleStages.Rendered,Ce),ue(0,A.IDrawingManagerService),ue(1,L.IRenderManagerService),ue(2,p.IPermissionService),ue(3,p.IUniverInstanceService),ue(4,B.Inject(p.UserManagerService))],Ce);var Lt=Object.defineProperty,jt=Object.getOwnPropertyDescriptor,Wt=(i,t,n,e)=>{for(var r=e>1?void 0:e?jt(t,n):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(t,n,r):a(r))||r);return e&&r&&Lt(t,n,r),r},Pe=(i,t)=>(n,e)=>t(n,e,i);let ye=class extends p.Disposable{constructor(t,n,e){super();z(this,"_copyInfo");this._sheetClipboardService=t,this._renderManagerService=n,this._sheetDrawingService=e,this._initCopyPaste()}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:"SHEET_IMAGE_UI_PLUGIN",onBeforeCopy:(t,n,e)=>this._collect(t,n,e),onPasteCells:(t,n,e,r)=>{const{copyType:o=$.COPY_TYPE.COPY,pasteType:a}=r,{range:s}=t||{},{range:l,unitId:u,subUnitId:d}=n;return this._generateMutations(l,{copyType:o,pasteType:a,copyRange:s,unitId:u,subUnitId:d})},onPastePlainText:(t,n)=>({undos:[],redos:[]})})}_collect(t,n,e){var m;const r=(m=this._renderManagerService.getRenderById(t))==null?void 0:m.with($.SheetSkeletonManagerService);if(!r)return;const o=r.attachRangeWithCoord(e);if(!o)return;const{startX:a,endX:s,startY:l,endY:u}=o,d=this._sheetDrawingService.getDrawingData(t,n),c=[];Object.keys(d).forEach(g=>{const S=d[g],{transform:f}=S;if(S.anchorType!==h.SheetDrawingAnchorType.Both||!f)return;const{left:v=0,top:y=0,width:M=0,height:C=0}=f,{drawingStartX:R,drawingEndX:I,drawingStartY:O,drawingEndY:w}={drawingStartX:v,drawingEndX:v+M,drawingStartY:y,drawingEndY:y+C};a<=R&&I<=s&&l<=O&&w<=u&&c.push(S)}),c.length&&(this._copyInfo={drawings:c,unitId:t,subUnitId:n})}_generateMutations(t,n){var E;if(!this._copyInfo)return{redos:[],undos:[]};if([$.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,$.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,$.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,$.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMULA].includes(n.pasteType))return{redos:[],undos:[]};const{copyRange:e}=n;if(!e)return{redos:[],undos:[]};const{drawings:r,unitId:o,subUnitId:a}=this._copyInfo,{ranges:[s,l],mapFunc:u}=$.virtualizeDiscreteRanges([e,t]),{row:d,col:c}=u(s.startRow,s.startColumn),{row:m,col:g}=u(l.startRow,l.startColumn),S=(E=this._renderManagerService.getRenderById(o))==null?void 0:E.with($.SheetSkeletonManagerService);if(!S)return{redos:[],undos:[]};const f=S.attachRangeWithCoord({startRow:d,endRow:d,startColumn:c,endColumn:c}),v=S.attachRangeWithCoord({startRow:m,endRow:m,startColumn:g,endColumn:g});if(!f||!v)return{redos:[],undos:[]};const y=[],M=[],C=v.startX-f.startX,R=v.startY-f.startY,I=m-d,O=g-c,w=n.copyType===$.COPY_TYPE.CUT,{_sheetDrawingService:U}=this;return r.forEach(j=>{const{transform:P,sheetTransform:b}=j;if(!P)return;const D={...j,unitId:o,subUnitId:a,drawingId:w?j.drawingId:p.Tools.generateRandomId(),transform:{...P,left:P.left+C,top:P.top+R},sheetTransform:{to:{...b.to,row:b.to.row+I,column:b.to.column+O},from:{...b.from,row:b.from.row+I,column:b.from.column+O}}};if(w){const{undo:W,redo:Y,objects:ne}=U.getBatchUpdateOp([D]);y.push({id:h.SetDrawingApplyMutation.id,params:{unitId:o,subUnitId:a,type:h.DrawingApplyType.UPDATE,op:Y,objects:ne}}),M.push({id:h.SetDrawingApplyMutation.id,params:{unitId:o,subUnitId:a,type:h.DrawingApplyType.UPDATE,op:W,objects:ne}})}else{const{undo:W,redo:Y,objects:ne}=U.getBatchAddOp([D]);y.push({id:h.SetDrawingApplyMutation.id,params:{op:Y,unitId:o,subUnitId:a,objects:ne,type:h.DrawingApplyType.INSERT}}),M.push({id:h.SetDrawingApplyMutation.id,params:{op:W,unitId:o,subUnitId:a,objects:ne,type:h.DrawingApplyType.REMOVE}})}}),{redos:y,undos:M}}};ye=Wt([p.OnLifecycle(p.LifecycleStages.Ready,ye),Pe(0,$.ISheetClipboardService),Pe(1,L.IRenderManagerService),Pe(2,h.ISheetDrawingService)],ye);var Ve=Object.defineProperty,$t=Object.getOwnPropertyDescriptor,Bt=(i,t,n)=>t in i?Ve(i,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[t]=n,Gt=(i,t,n,e)=>{for(var r=e>1?void 0:e?$t(t,n):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(t,n,r):a(r))||r);return e&&r&&Ve(t,n,r),r},Ae=(i,t)=>(n,e)=>t(n,e,i),Fe=(i,t,n)=>Bt(i,typeof t!="symbol"?t+"":t,n);const Vt="SHEET_IMAGE_UI_PLUGIN";T.UniverSheetsDrawingUIPlugin=class extends p.Plugin{constructor(n={},e,r,o){super();z(this,"_pluginConfig");this._injector=e,this._localeService=r,this._renderManagerService=o,this._pluginConfig=p.Tools.deepMerge({},wt,n)}onStarting(n){super.onStarting(n),this._initDependencies(n)}onRendered(){this._registerRenderModules()}_initDependencies(n){const e=[[T.SheetCanvasFloatDomManagerService],[de,{useFactory:()=>this._injector.createInstance(de,this._pluginConfig)}],[he],[Ie],[Ce]],r=[Se,we];e.forEach(o=>n.add(o)),r.forEach(o=>this._renderManagerService.registerRenderModule(p.UniverInstanceType.UNIVER_SHEET,o))}_registerRenderModules(){[[ye]].forEach(n=>{this.disposeWithMe(this._renderManagerService.registerRenderModule(p.UniverInstanceType.UNIVER_SHEET,n))})}},Fe(T.UniverSheetsDrawingUIPlugin,"type",p.UniverInstanceType.UNIVER_SHEET),Fe(T.UniverSheetsDrawingUIPlugin,"pluginName",Vt),T.UniverSheetsDrawingUIPlugin=Gt([p.DependentOn(A.UniverDrawingPlugin,Q.UniverDrawingUIPlugin,h.UniverSheetsDrawingPlugin),Ae(1,B.Inject(B.Injector)),Ae(2,B.Inject(p.LocaleService)),Ae(3,L.IRenderManagerService)],T.UniverSheetsDrawingUIPlugin),T.ClearSheetDrawingTransformerOperation=G,T.DeleteDrawingsCommand=be,T.EditSheetDrawingOperation=De,T.GroupSheetDrawingCommand=Re,T.InsertCellImageOperation=ae,T.InsertFloatImageOperation=oe,T.InsertSheetDrawingCommand=fe,T.MoveDrawingsCommand=re,T.RemoveSheetDrawingCommand=ge,T.SetDrawingArrangeCommand=Te,T.SetSheetDrawingCommand=se,T.SidebarSheetDrawingOperation=Me,T.UngroupSheetDrawingCommand=Ee,Object.defineProperty(T,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/sheets-drawing-ui",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -52,15 +52,15 @@
52
52
  "clsx": ">=2.0.0",
53
53
  "react": "^16.9.0 || ^17.0.0 || ^18.0.0",
54
54
  "rxjs": ">=7.0.0",
55
- "@univerjs/core": "0.2.1",
56
- "@univerjs/design": "0.2.1",
57
- "@univerjs/drawing": "0.2.1",
58
- "@univerjs/drawing-ui": "0.2.1",
59
- "@univerjs/engine-render": "0.2.1",
60
- "@univerjs/sheets": "0.2.1",
61
- "@univerjs/sheets-drawing": "0.2.1",
62
- "@univerjs/sheets-ui": "0.2.1",
63
- "@univerjs/ui": "0.2.1"
55
+ "@univerjs/core": "0.2.3",
56
+ "@univerjs/design": "0.2.3",
57
+ "@univerjs/drawing": "0.2.3",
58
+ "@univerjs/drawing-ui": "0.2.3",
59
+ "@univerjs/engine-render": "0.2.3",
60
+ "@univerjs/sheets": "0.2.3",
61
+ "@univerjs/sheets-drawing": "0.2.3",
62
+ "@univerjs/sheets-ui": "0.2.3",
63
+ "@univerjs/ui": "0.2.3"
64
64
  },
65
65
  "dependencies": {
66
66
  "@univerjs/icons": "^0.1.58"
@@ -74,16 +74,16 @@
74
74
  "typescript": "^5.5.3",
75
75
  "vite": "^5.3.3",
76
76
  "vitest": "^1.6.0",
77
- "@univerjs/core": "0.2.1",
78
- "@univerjs/design": "0.2.1",
79
- "@univerjs/drawing": "0.2.1",
80
- "@univerjs/shared": "0.2.1",
81
- "@univerjs/drawing-ui": "0.2.1",
82
- "@univerjs/sheets": "0.2.1",
83
- "@univerjs/engine-render": "0.2.1",
84
- "@univerjs/sheets-drawing": "0.2.1",
85
- "@univerjs/sheets-ui": "0.2.1",
86
- "@univerjs/ui": "0.2.1"
77
+ "@univerjs/design": "0.2.3",
78
+ "@univerjs/core": "0.2.3",
79
+ "@univerjs/drawing": "0.2.3",
80
+ "@univerjs/drawing-ui": "0.2.3",
81
+ "@univerjs/shared": "0.2.3",
82
+ "@univerjs/engine-render": "0.2.3",
83
+ "@univerjs/sheets": "0.2.3",
84
+ "@univerjs/sheets-ui": "0.2.3",
85
+ "@univerjs/sheets-drawing": "0.2.3",
86
+ "@univerjs/ui": "0.2.3"
87
87
  },
88
88
  "univerSpace": {
89
89
  ".": {